Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hub-common): add minimal definitions of ArcGIS types and drop arcgis-js-api #1797

Merged
merged 8 commits into from
Feb 7, 2025
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module.exports = function (config) {
tsconfig: "./tsconfig.json",
bundlerOptions: {
transforms: [require("karma-typescript-es6-transform")()],
exclude: ["@esri/arcgis-rest-types"],
exclude: [ "@esri/arcgis-rest-types" ],
resolve: {
// karmas resolver cant figure out the symlinked deps from lerna
// so we need to manually alias each package here.
Expand Down
77 changes: 30 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
],
"dependencies": {
"@terraformer/arcgis": "^2.1.2",
"@types/arcgis-js-api": "~4.28.0",
"abab": "^2.0.5",
"adlib": "^3.0.8",
"ajv": "^6.12.6",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export const deriveLocationFromItem = (item: IItem): IHubLocation => {
// determine the spatial reference of the extent.
const bbox = GeoJSONPolygonToBBox(extent as any as Polygon);
const defaultSpatialReference = { wkid: 4326 };
const _geometry: Partial<__esri.Geometry> = {
const _geometry = {
type: "polygon",
...geojsonToArcGIS(extent as any as Polygon),
spatialReference: allCoordinatesPossiblyWGS84(bbox)
Expand Down
12 changes: 5 additions & 7 deletions packages/common/src/core/types/IHubLocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ export interface IHubLocation {
extent?: number[][];

// array of geometries representing the location
// NOTE: we use partial here b/c __esri.Geometry
// is the type for instances and includes methods, etc
// but we want to be able to pass around POJOs as well as instances
// instead, we might want to use __esri.GeometryProperties or
// a discriminated union of the point, line, polygon, and extent _property_ types
// but for now it is a non-breaking change to relax __esri.Geometry w/ a partial
geometries?: Array<Partial<__esri.Geometry>>;
// NOTE: we use any here b/c it's silly to add @arcgis/core
// just to get the Geometry type, which is basically an any anyway
// and as of 4.32 next we see (non-fatal) TS errors when running karma tests
// but for now it is a non-breaking change to relax Geometry to any
geometries?: any[];

/** The name of the location */
name?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/core/types/Metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export interface IMetricAttributes extends IEntityInfo {
*/
export interface IMetricFeature {
attributes: IMetricAttributes;
geometry?: __esri.Geometry;
geometry?: any;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { IExtent } from "@esri/arcgis-rest-types";
import { request } from "@esri/arcgis-rest-request";
import {
DownloadOperationStatus,
Expand Down Expand Up @@ -71,16 +72,17 @@ function validateOptions(options: IFetchDownloadFileOptions) {
}
}

function getExportImageExtent(
options: IFetchDownloadFileOptions
): __esri.Extent {
function getExportImageExtent(options: IFetchDownloadFileOptions): IExtent {
const { entity, geometry } = options;
const serverExtent = getProp(entity, "extendedProps.server.extent");
const serverExtent = getProp(
entity,
"extendedProps.server.extent"
) as IExtent;

// TODO: Factor in entity.extent if it exists AND is a valid 4326 bbox
let result: __esri.Extent = null;
let result: IExtent = null;
if (geometry) {
result = geometry as __esri.Extent;
result = geometry as IExtent;
} else if (serverExtent) {
result = serverExtent;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/downloads/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export interface IFetchDownloadFileOptions {
format: ServiceDownloadFormat;
context: IArcGISContext;
layers?: number[]; // layers to download; when not specified, all layers will be downloaded
geometry?: __esri.Geometry; // geometry to filter results by
geometry?: any; // geometry to filter results by
where?: string; // where clause to filter results by
progressCallback?: downloadProgressCallback;
pollInterval?: number; // interval in milliseconds to poll for job completion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe("fetchHubApiDownloadFile", () => {
geometry: {
type: "point",
toJSON: () => ({ type: "point", coordinates: [1, 2] }),
} as unknown as __esri.Point,
} as any,
where: "1=1",
});

Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/initiatives/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const INITIATIVE_LOCATION: IHubLocation = {
[-76.8191059305754, 39.08220981728297],
],
],
} as unknown as __esri.Geometry,
} as any,
],
};

Expand Down
2 changes: 1 addition & 1 deletion packages/common/test/projects/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const PROJECT_LOCATION: IHubLocation = {
[-76.8191059305754, 39.08220981728297],
],
],
} as unknown as __esri.Geometry,
} as any,
],
};

Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
], /* List of folders to include type definitions from. */
"types": [
"node",
"jasmine",
"arcgis-js-api"
"jasmine"
], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */

Expand Down