@loaders.gl/arcgis 5.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/LICENSE +52 -0
  2. package/README.md +28 -0
  3. package/dist/arcgis/arcgis-capability-graph.d.ts +50 -0
  4. package/dist/arcgis/arcgis-capability-graph.d.ts.map +1 -0
  5. package/dist/arcgis/arcgis-capability-graph.js +221 -0
  6. package/dist/arcgis/arcgis-capability-graph.js.map +1 -0
  7. package/dist/arcgis/arcgis-feature-query.d.ts +53 -0
  8. package/dist/arcgis/arcgis-feature-query.d.ts.map +1 -0
  9. package/dist/arcgis/arcgis-feature-query.js +381 -0
  10. package/dist/arcgis/arcgis-feature-query.js.map +1 -0
  11. package/dist/arcgis/arcgis-feature-server-source-loader-types.d.ts +33 -0
  12. package/dist/arcgis/arcgis-feature-server-source-loader-types.d.ts.map +1 -0
  13. package/dist/arcgis/arcgis-feature-server-source-loader-types.js +21 -0
  14. package/dist/arcgis/arcgis-feature-server-source-loader-types.js.map +1 -0
  15. package/dist/arcgis/arcgis-feature-server-source-loader.d.ts +84 -0
  16. package/dist/arcgis/arcgis-feature-server-source-loader.d.ts.map +1 -0
  17. package/dist/arcgis/arcgis-feature-server-source-loader.js +280 -0
  18. package/dist/arcgis/arcgis-feature-server-source-loader.js.map +1 -0
  19. package/dist/arcgis/arcgis-image-server-source-loader-types.d.ts +31 -0
  20. package/dist/arcgis/arcgis-image-server-source-loader-types.d.ts.map +1 -0
  21. package/dist/arcgis/arcgis-image-server-source-loader-types.js +21 -0
  22. package/dist/arcgis/arcgis-image-server-source-loader-types.js.map +1 -0
  23. package/dist/arcgis/arcgis-image-server-source-loader.d.ts +60 -0
  24. package/dist/arcgis/arcgis-image-server-source-loader.d.ts.map +1 -0
  25. package/dist/arcgis/arcgis-image-server-source-loader.js +130 -0
  26. package/dist/arcgis/arcgis-image-server-source-loader.js.map +1 -0
  27. package/dist/arcgis/arcgis-image-tile-source-loader-types.d.ts +31 -0
  28. package/dist/arcgis/arcgis-image-tile-source-loader-types.d.ts.map +1 -0
  29. package/dist/arcgis/arcgis-image-tile-source-loader-types.js +21 -0
  30. package/dist/arcgis/arcgis-image-tile-source-loader-types.js.map +1 -0
  31. package/dist/arcgis/arcgis-image-tile-source-loader.d.ts +63 -0
  32. package/dist/arcgis/arcgis-image-tile-source-loader.d.ts.map +1 -0
  33. package/dist/arcgis/arcgis-image-tile-source-loader.js +147 -0
  34. package/dist/arcgis/arcgis-image-tile-source-loader.js.map +1 -0
  35. package/dist/arcgis/arcgis-map-tile-source-loader-types.d.ts +31 -0
  36. package/dist/arcgis/arcgis-map-tile-source-loader-types.d.ts.map +1 -0
  37. package/dist/arcgis/arcgis-map-tile-source-loader-types.js +21 -0
  38. package/dist/arcgis/arcgis-map-tile-source-loader-types.js.map +1 -0
  39. package/dist/arcgis/arcgis-map-tile-source-loader.d.ts +62 -0
  40. package/dist/arcgis/arcgis-map-tile-source-loader.d.ts.map +1 -0
  41. package/dist/arcgis/arcgis-map-tile-source-loader.js +196 -0
  42. package/dist/arcgis/arcgis-map-tile-source-loader.js.map +1 -0
  43. package/dist/arcgis/arcgis-scene-aggregation.d.ts +34 -0
  44. package/dist/arcgis/arcgis-scene-aggregation.d.ts.map +1 -0
  45. package/dist/arcgis/arcgis-scene-aggregation.js +57 -0
  46. package/dist/arcgis/arcgis-scene-aggregation.js.map +1 -0
  47. package/dist/arcgis/arcgis-scene-server-source-loader-types.d.ts +31 -0
  48. package/dist/arcgis/arcgis-scene-server-source-loader-types.d.ts.map +1 -0
  49. package/dist/arcgis/arcgis-scene-server-source-loader-types.js +21 -0
  50. package/dist/arcgis/arcgis-scene-server-source-loader-types.js.map +1 -0
  51. package/dist/arcgis/arcgis-scene-server-source-loader.d.ts +64 -0
  52. package/dist/arcgis/arcgis-scene-server-source-loader.d.ts.map +1 -0
  53. package/dist/arcgis/arcgis-scene-server-source-loader.js +159 -0
  54. package/dist/arcgis/arcgis-scene-server-source-loader.js.map +1 -0
  55. package/dist/arcgis/arcgis-server.d.ts +15 -0
  56. package/dist/arcgis/arcgis-server.d.ts.map +1 -0
  57. package/dist/arcgis/arcgis-server.js +41 -0
  58. package/dist/arcgis/arcgis-server.js.map +1 -0
  59. package/dist/arcgis/arcgis-url-utils.d.ts +3 -0
  60. package/dist/arcgis/arcgis-url-utils.d.ts.map +1 -0
  61. package/dist/arcgis/arcgis-url-utils.js +23 -0
  62. package/dist/arcgis/arcgis-url-utils.js.map +1 -0
  63. package/dist/arcgis/arcgis-vector-tile-server-source-loader-types.d.ts +31 -0
  64. package/dist/arcgis/arcgis-vector-tile-server-source-loader-types.d.ts.map +1 -0
  65. package/dist/arcgis/arcgis-vector-tile-server-source-loader-types.js +21 -0
  66. package/dist/arcgis/arcgis-vector-tile-server-source-loader-types.js.map +1 -0
  67. package/dist/arcgis/arcgis-vector-tile-server-source-loader.d.ts +66 -0
  68. package/dist/arcgis/arcgis-vector-tile-server-source-loader.d.ts.map +1 -0
  69. package/dist/arcgis/arcgis-vector-tile-server-source-loader.js +150 -0
  70. package/dist/arcgis/arcgis-vector-tile-server-source-loader.js.map +1 -0
  71. package/dist/arcgis-feature-query-types.d.ts +77 -0
  72. package/dist/arcgis-feature-query-types.d.ts.map +1 -0
  73. package/dist/arcgis-feature-query-types.js +5 -0
  74. package/dist/arcgis-feature-query-types.js.map +1 -0
  75. package/dist/arcgis-items.d.ts +64 -0
  76. package/dist/arcgis-items.d.ts.map +1 -0
  77. package/dist/arcgis-items.js +137 -0
  78. package/dist/arcgis-items.js.map +1 -0
  79. package/dist/arcgis-source-types.d.ts +372 -0
  80. package/dist/arcgis-source-types.d.ts.map +1 -0
  81. package/dist/arcgis-source-types.js +108 -0
  82. package/dist/arcgis-source-types.js.map +1 -0
  83. package/dist/authentication.d.ts +25 -0
  84. package/dist/authentication.d.ts.map +1 -0
  85. package/dist/authentication.js +94 -0
  86. package/dist/authentication.js.map +1 -0
  87. package/dist/bundled.d.ts +152 -0
  88. package/dist/bundled.d.ts.map +1 -0
  89. package/dist/bundled.js +34 -0
  90. package/dist/bundled.js.map +1 -0
  91. package/dist/index.cjs +25620 -0
  92. package/dist/index.cjs.map +6 -0
  93. package/dist/index.d.ts +24 -0
  94. package/dist/index.d.ts.map +1 -0
  95. package/dist/index.js +11 -0
  96. package/dist/index.js.map +1 -0
  97. package/dist/service-registry.d.ts +18 -0
  98. package/dist/service-registry.d.ts.map +1 -0
  99. package/dist/service-registry.js +29 -0
  100. package/dist/service-registry.js.map +1 -0
  101. package/package.json +96 -0
  102. package/src/arcgis/arcgis-capability-graph.ts +297 -0
  103. package/src/arcgis/arcgis-feature-query.ts +442 -0
  104. package/src/arcgis/arcgis-feature-server-source-loader-types.ts +34 -0
  105. package/src/arcgis/arcgis-feature-server-source-loader.ts +373 -0
  106. package/src/arcgis/arcgis-image-server-source-loader-types.ts +34 -0
  107. package/src/arcgis/arcgis-image-server-source-loader.ts +186 -0
  108. package/src/arcgis/arcgis-image-tile-source-loader-types.ts +34 -0
  109. package/src/arcgis/arcgis-image-tile-source-loader.ts +192 -0
  110. package/src/arcgis/arcgis-map-tile-source-loader-types.ts +34 -0
  111. package/src/arcgis/arcgis-map-tile-source-loader.ts +248 -0
  112. package/src/arcgis/arcgis-scene-aggregation.ts +90 -0
  113. package/src/arcgis/arcgis-scene-server-source-loader-types.ts +36 -0
  114. package/src/arcgis/arcgis-scene-server-source-loader.ts +216 -0
  115. package/src/arcgis/arcgis-server.ts +61 -0
  116. package/src/arcgis/arcgis-url-utils.ts +26 -0
  117. package/src/arcgis/arcgis-vector-tile-server-source-loader-types.ts +36 -0
  118. package/src/arcgis/arcgis-vector-tile-server-source-loader.ts +196 -0
  119. package/src/arcgis-feature-query-types.ts +89 -0
  120. package/src/arcgis-items.ts +233 -0
  121. package/src/arcgis-source-types.ts +372 -0
  122. package/src/authentication.ts +118 -0
  123. package/src/bundled.ts +68 -0
  124. package/src/index.ts +70 -0
  125. package/src/service-registry.ts +43 -0
@@ -0,0 +1,150 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { ArcGISAuthentication } from "../authentication.js";
5
+ import { ARCGIS_VECTOR_TILE_SERVER_SOURCE_LOADER_METADATA } from "../arcgis-source-types.js";
6
+ import { DataSource } from '@loaders.gl/loader-utils';
7
+ import { MVTLoader } from '@loaders.gl/mvt';
8
+ /** A source for ArcGIS VectorTileServer metadata and PBF tiles. */
9
+ export class ArcGISVectorTileServerSource extends DataSource {
10
+ /** Decoded tile family consumed by generic tile renderers. */
11
+ mimeType = 'application/vnd.mapbox-vector-tile';
12
+ /** ArcGIS tiles are decoded to WGS84 coordinates before rendering. */
13
+ localCoordinates = false;
14
+ /** Cached service metadata request. */
15
+ serviceMetadata = null;
16
+ /** Query parameters supplied with the service URL, such as an access token. */
17
+ serviceQueryParameters;
18
+ /** Creates an ArcGIS VectorTileServer source. */
19
+ constructor(url, options = {}, coreApi) {
20
+ const serviceURL = new URL(url);
21
+ serviceURL.pathname = serviceURL.pathname.replace(/\/$/, '');
22
+ super(`${serviceURL.origin}${serviceURL.pathname}`, options, ARCGIS_VECTOR_TILE_SERVER_SOURCE_LOADER_METADATA.defaultOptions, coreApi);
23
+ this.serviceQueryParameters = new URLSearchParams(serviceURL.search);
24
+ }
25
+ /** Returns normalized service and tile-grid metadata. */
26
+ async getMetadata() {
27
+ const metadata = await this.getServiceMetadata();
28
+ const tileInfo = metadata.tileInfo;
29
+ const lods = tileInfo?.lods || [];
30
+ const extent = metadata.fullExtent || metadata.initialExtent;
31
+ return {
32
+ name: metadata.mapName || this.url.split('/').pop() || '',
33
+ title: metadata.mapName,
34
+ abstract: metadata.serviceDescription,
35
+ format: 'application/vnd.mapbox-vector-tile',
36
+ minZoom: lods[0]?.level,
37
+ maxZoom: lods.at(-1)?.level,
38
+ boundingBox: extent
39
+ ? [
40
+ [extent.xmin, extent.ymin],
41
+ [extent.xmax, extent.ymax]
42
+ ]
43
+ : undefined,
44
+ layer: {
45
+ name: metadata.mapName || '',
46
+ srs: tileInfo?.spatialReference ? [getSpatialReference(tileInfo.spatialReference)] : [],
47
+ layers: []
48
+ },
49
+ formatHeader: {
50
+ tileInfo,
51
+ styleURL: this.getStyleURL(),
52
+ spriteURL: this.getSpriteURL()
53
+ }
54
+ };
55
+ }
56
+ /** Fetches one raw PBF tile from the ArcGIS tile endpoint. */
57
+ async getTile(parameters, signal) {
58
+ const response = await this.fetch(this.getTileURL(parameters), {
59
+ signal,
60
+ headers: { Accept: 'application/vnd.mapbox-vector-tile, application/x-protobuf' }
61
+ });
62
+ if (!response.ok)
63
+ return null;
64
+ return response.arrayBuffer();
65
+ }
66
+ /** Returns the schema advertised by decoded vector tiles. */
67
+ async getSchema() {
68
+ return { fields: [], metadata: {} };
69
+ }
70
+ /** Fetches and decodes one ArcGIS vector tile to geographic coordinates. */
71
+ async getVectorTile(parameters) {
72
+ const arrayBuffer = await this.getTile(parameters, parameters.signal);
73
+ if (!arrayBuffer) {
74
+ return null;
75
+ }
76
+ const inheritedOptions = this.loadOptions.mvt;
77
+ const sourceOptions = this.options['arcgis-vector-tile-server']?.mvt;
78
+ return (await this.coreApi.parse(arrayBuffer, MVTLoader, {
79
+ ...this.loadOptions,
80
+ mvt: {
81
+ ...inheritedOptions,
82
+ ...sourceOptions,
83
+ coordinates: 'wgs84',
84
+ tileIndex: { x: parameters.x, y: parameters.y, z: parameters.z },
85
+ layers: normalizeLayers(parameters.layers) || sourceOptions?.layers || inheritedOptions?.layers
86
+ }
87
+ }));
88
+ }
89
+ /** Provides decoded vector tiles through the deck.gl source interface. */
90
+ async getTileData(parameters) {
91
+ return this.getVectorTile({ ...parameters.index, signal: parameters.signal });
92
+ }
93
+ /** Builds the ArcGIS cached vector tile URL. */
94
+ getTileURL(parameters) {
95
+ return this.getResourceURL(`/tile/${parameters.z}/${parameters.y}/${parameters.x}.pbf`);
96
+ }
97
+ /** Returns the service metadata URL. */
98
+ getMetadataURL() {
99
+ const url = new URL(this.getResourceURL(''));
100
+ url.searchParams.set('f', 'pjson');
101
+ return url.toString();
102
+ }
103
+ /** Returns the ArcGIS Mapbox style resource URL. */
104
+ getStyleURL() {
105
+ return this.getResourceURL('/resources/styles/root.json');
106
+ }
107
+ /** Returns the ArcGIS sprite resource base URL. */
108
+ getSpriteURL() {
109
+ return this.getResourceURL('/resources/sprites/sprite');
110
+ }
111
+ /** Loads and caches the ArcGIS VectorTileServer metadata document. */
112
+ async getServiceMetadata() {
113
+ this.serviceMetadata ||= this.fetch(this.getMetadataURL()).then(async (response) => {
114
+ if (!response.ok)
115
+ throw new Error(`ArcGIS VectorTileServer request failed: ${response.status}`);
116
+ return (await response.json());
117
+ });
118
+ return this.serviceMetadata;
119
+ }
120
+ /** Builds a resource URL while retaining service query parameters. */
121
+ getResourceURL(resourcePath) {
122
+ const url = new URL(this.url);
123
+ url.pathname = `${url.pathname.replace(/\/$/, '')}${resourcePath}`;
124
+ for (const [key, value] of this.serviceQueryParameters) {
125
+ url.searchParams.set(key, value);
126
+ }
127
+ return url.toString();
128
+ }
129
+ }
130
+ /** Runtime service loader for synchronous construction. */
131
+ export const ArcGISVectorTileServerSourceLoaderWithParser = {
132
+ ...ARCGIS_VECTOR_TILE_SERVER_SOURCE_LOADER_METADATA,
133
+ dataType: null,
134
+ batchType: null,
135
+ preload: undefined,
136
+ /** Supplies ArcGIS credentials after loading the selected implementation. */
137
+ getAuthentications: () => [ArcGISAuthentication],
138
+ createDataSource: (url, options = {}, coreApi) => new ArcGISVectorTileServerSource(url, options, coreApi)
139
+ };
140
+ /** Converts an ArcGIS spatial reference to an EPSG identifier. */
141
+ function getSpatialReference(spatialReference) {
142
+ return `EPSG:${spatialReference.latestWkid || spatialReference.wkid}`;
143
+ }
144
+ /** Normalizes generic tile layer selection for the MVT parser. */
145
+ function normalizeLayers(layers) {
146
+ if (!layers)
147
+ return undefined;
148
+ return Array.isArray(layers) ? layers : [layers];
149
+ }
150
+ //# sourceMappingURL=arcgis-vector-tile-server-source-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcgis-vector-tile-server-source-loader.js","sourceRoot":"","sources":["../../src/arcgis/arcgis-vector-tile-server-source-loader.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,oBAAoB,EAAC,6BAA0B;AACvD,OAAO,EAAC,gDAAgD,EAAC,kCAA+B;AAexF,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,SAAS,EAAwB,MAAM,iBAAiB,CAAC;AAGjE,mEAAmE;AACnE,MAAM,OAAO,4BACX,SAAQ,UAA6D;IAGrE,8DAA8D;IACrD,QAAQ,GAAG,oCAAoC,CAAC;IACzD,sEAAsE;IAC7D,gBAAgB,GAAG,KAAK,CAAC;IAClC,uCAAuC;IAC/B,eAAe,GAAoD,IAAI,CAAC;IAChF,+EAA+E;IAC9D,sBAAsB,CAAkB;IAEzD,iDAAiD;IACjD,YACE,GAAW,EACX,UAAqD,EAAE,EACvD,OAAiB;QAEjB,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAChC,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7D,KAAK,CACH,GAAG,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC,QAAQ,EAAE,EAC5C,OAAO,EACP,gDAAgD,CAAC,cAAc,EAC/D,OAAO,CACR,CAAC;QACF,IAAI,CAAC,sBAAsB,GAAG,IAAI,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACvE,CAAC;IAED,yDAAyD;IACzD,KAAK,CAAC,WAAW;QACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACjD,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QACnC,M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 import type { ArcGISFeatureServiceQueryOptions } from "./arcgis-source-types.js";
4
+ /** Parameters shared by feature, table and MapServer layer queries. */
5
+ export type ArcGISFeatureQueryParameters = Partial<GetFeaturesParameters> & {
6
+ /** Per-request filters, overriding source query defaults. */
7
+ query?: ArcGISFeatureServiceQueryOptions;
8
+ };
9
+ /** Controls bounded retrieval of a complete query. */
10
+ export type ArcGISFeatureQueryOptions = ArcGISFeatureQueryParameters & {
11
+ /** Maximum records per page, capped by the advertised service limit. Default 1000. */
12
+ pageSize?: number;
13
+ /** Maximum retained records. Default 100000; reaching it can produce an incomplete result. */
14
+ maxFeatures?: number;
15
+ /** Concurrent object-ID batches, between 1 and 8. Default 4; offset pages are serial. */
16
+ concurrency?: number;
17
+ /** Auto uses ordered pagination when advertised, otherwise object-ID batches. */
18
+ strategy?: 'auto' | 'offset' | 'object-ids';
19
+ /** Reports each yielded page, including the final completion assessment. */
20
+ onProgress?: (progress: ArcGISFeatureQueryProgress) => void;
21
+ };
22
+ /** Completion evidence for the selected query, never a transactional snapshot guarantee. */
23
+ export type ArcGISFeatureQueryProgress = {
24
+ /** Number of unique records retained so far. */
25
+ loaded: number;
26
+ /** Count observed before retrieval; absent for a single-page request. */
27
+ expectedCount?: number;
28
+ /** Number of data pages processed. */
29
+ pages: number;
30
+ /** Duplicate records discarded while retrieving pages. */
31
+ duplicates: number;
32
+ /** True only after traversal finishes and its unique count matches the initial server count. */
33
+ complete: boolean;
34
+ /** Whether the query includes a viewport bounding box. */
35
+ scope: 'viewport' | 'query';
36
+ /** Retrieval strategy used for this result. */
37
+ strategy: 'offset' | 'object-ids' | 'page';
38
+ /** Why retrieval is in progress, finished, or incomplete. */
39
+ reason: 'loading' | 'complete' | 'single-page' | 'feature-limit' | 'id-limit' | 'count-mismatch' | 'no-progress';
40
+ };
41
+ /** One page with cumulative progress, or the collected result of queryFeatures(). */
42
+ export type ArcGISFeatureQueryResult = ArcGISFeatureQueryProgress & {
43
+ /** Spatial features or table records represented as features with null geometry. */
44
+ data: GeoJSONTable;
45
+ };
46
+ /** Result of an IDs-only request; this alone does not prove query completeness. */
47
+ export type ArcGISFeatureObjectIds = {
48
+ /** Stable object ID field advertised by the response. */
49
+ objectIdFieldName: string;
50
+ /** Unique safe-integer or string identifiers returned by the service. */
51
+ objectIds: (number | string)[];
52
+ /** True when the service explicitly reports truncated identifiers. */
53
+ exceededTransferLimit: boolean;
54
+ };
55
+ /** Extent-only response, retaining the service's explicit spatial reference. */
56
+ export type ArcGISFeatureExtent = {
57
+ /** Matching record count when supplied by the server. */
58
+ count?: number;
59
+ /** Null for an empty or nonspatial query. */
60
+ extent: {
61
+ /** Minimum x coordinate. */
62
+ xmin: number;
63
+ /** Minimum y coordinate. */
64
+ ymin: number;
65
+ /** Maximum x coordinate. */
66
+ xmax: number;
67
+ /** Maximum y coordinate. */
68
+ ymax: number;
69
+ /** Coordinate reference of the returned bounds. */
70
+ spatialReference: {
71
+ wkid?: number;
72
+ latestWkid?: number;
73
+ wkt?: string;
74
+ };
75
+ } | null;
76
+ };
77
+ //# sourceMappingURL=arcgis-feature-query-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcgis-feature-query-types.d.ts","sourceRoot":"","sources":["../src/arcgis-feature-query-types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,gCAAgC,EAAC,iCAA8B;AAE5E,uEAAuE;AACvE,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,qBAAqB,CAAC,GAAG;IAC1E,6DAA6D;IAC7D,KAAK,CAAC,EAAE,gCAAgC,CAAC;CAC1C,CAAC;AAEF,sDAAsD;AACtD,MAAM,MAAM,yBAAyB,GAAG,4BAA4B,GAAG;IACrE,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8FAA8F;I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AAM,CAAC;IACf,6CAA6C;IAC7C,MAAM,EAAE;QACN,4BAA4B;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,4BAA4B;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,4BAA4B;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,4BAA4B;QAC5B,IAAI,EAAE,MAAM,CAAC;QACb,mDAAmD;QACnD,gBAAgB,EAAE;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,UAAU,CAAC,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,CAAA;SAAC,CAAC;KACtE,GAAG,IAAI,CAAC;CACV,CAAC"}
@@ -0,0 +1,5 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export {};
5
+ //# sourceMappingURL=arcgis-feature-query-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcgis-feature-query-types.js","sourceRoot":"","sources":["../src/arcgis-feature-query-types.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC"}
@@ -0,0 +1,64 @@
1
+ import type { FetchLike } from '@loaders.gl/loader-utils';
2
+ /** A supported service-backed portal item, retaining the original portal metadata. */
3
+ export type ArcGISItem = {
4
+ /** Portal item identifier. */
5
+ id: string;
6
+ /** Display title supplied by the publisher. */
7
+ title: string;
8
+ /** Portal item type, distinct from the REST service type. */
9
+ type: string;
10
+ /** REST service endpoint. */
11
+ url: string;
12
+ /** Publisher description, potentially containing HTML; do not render it unsanitized. */
13
+ description?: string;
14
+ /** Publisher attribution, potentially containing HTML. */
15
+ accessInformation?: string;
16
+ /** Geographic item extent in longitude/latitude, when published. */
17
+ extent?: number[][];
18
+ /** Unmodified additional portal metadata. */
19
+ [name: string]: unknown;
20
+ };
21
+ /** An explicit service/layer choice; resolving a choice does not prove renderer support. */
22
+ export type ArcGISItemLayer = {
23
+ /** Numeric layer identifier, or null for a single root service. */
24
+ id: number | null;
25
+ /** Publisher-provided layer name. */
26
+ name: string;
27
+ /** Endpoint to pass to an appropriate ArcGIS source loader. */
28
+ url: string;
29
+ /** Whether this is a spatial layer, nonspatial table, or root service. */
30
+ kind: 'layer' | 'table' | 'service';
31
+ };
32
+ /** A resolved service item with choices and optional selected layer metadata. */
33
+ export type ArcGISItemResolution = {
34
+ /** Canonical portal REST root, including an Enterprise web-adaptor path. */
35
+ portalUrl: string;
36
+ /** Original item metadata, including description, extent and attribution. */
37
+ item: ArcGISItem;
38
+ /** Original service metadata. */
39
+ service: Record<string, any>;
40
+ /** Available choices; no implicit first-layer selection is made. */
41
+ layers: ArcGISItemLayer[];
42
+ /** Explicitly selected layer and its raw fields, domains, extent and attribution. */
43
+ selectedLayer?: ArcGISItemLayer & {
44
+ /** Unmodified selected-layer metadata. */ metadata: Record<string, any>;
45
+ };
46
+ };
47
+ /** Controls item resolution without owning authentication or OAuth state. */
48
+ export type ArcGISItemOptions = {
49
+ /** Portal root or sharing/rest endpoint. Defaults to ArcGIS Online for bare IDs. */
50
+ portalUrl?: string;
51
+ /** Shared authenticated transport, also used for service and selected-layer metadata. */
52
+ fetch?: FetchLike;
53
+ /** Cancels all metadata requests. */
54
+ signal?: AbortSignal;
55
+ /** Explicit layer/table identifier to inspect, or null for a root service. */
56
+ layerId?: number | null;
57
+ };
58
+ /**
59
+ * Resolves a portal item ID, item-details URL, or item REST URL into explicit service choices.
60
+ * Fetches only item, service, and (when selected) layer metadata. Web Maps/Web Scenes are rejected.
61
+ * URLs discovered in metadata never expand the credential's trusted origins.
62
+ */
63
+ export declare function resolveArcGISItem(input: string, options?: ArcGISItemOptions): Promise<ArcGISItemResolution>;
64
+ //# sourceMappingURL=arcgis-items.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcgis-items.d.ts","sourceRoot":"","sources":["../src/arcgis-items.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AAExD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AC,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,qCAAqC;IACrC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAWF;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CAmE/B"}
@@ -0,0 +1,137 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ /** Service-backed item types supported by this resolver. */
5
+ const ITEM_SERVICES = {
6
+ 'Feature Service': 'FeatureServer',
7
+ 'Map Service': 'MapServer',
8
+ 'Image Service': 'ImageServer',
9
+ 'Vector Tile Service': 'VectorTileServer',
10
+ 'Scene Service': 'SceneServer'
11
+ };
12
+ /**
13
+ * Resolves a portal item ID, item-details URL, or item REST URL into explicit service choices.
14
+ * Fetches only item, service, and (when selected) layer metadata. Web Maps/Web Scenes are rejected.
15
+ * URLs discovered in metadata never expand the credential's trusted origins.
16
+ */
17
+ export async function resolveArcGISItem(input, options = {}) {
18
+ const { itemId, portalUrl } = parseItemReference(input, options.portalUrl);
19
+ const fetchFile = options.fetch || fetch;
20
+ const item = (await fetchMetadata(`${portalUrl}/content/items/${itemId}`, fetchFile, options.signal));
21
+ const serviceType = Object.hasOwn(ITEM_SERVICES, item.type)
22
+ ? ITEM_SERVICES[item.type]
23
+ : undefined;
24
+ if (!serviceType)
25
+ throw new Error('Unsupported ArcGIS item type. Resolve a service item, not a Web Map or Web Scene.');
26
+ if (typeof item.id !== 'string' ||
27
+ item.id.toLowerCase() !== itemId ||
28
+ typeof item.title !== 'string')
29
+ throw new Error('Invalid ArcGIS item metadata.');
30
+ const serviceUrl = parseEndpoint(item.url);
31
+ const serviceMatch = serviceUrl.pathname.match(/\/(FeatureServer|MapServer|ImageServer|VectorTileServer|SceneServer)(?:\/(?:layers\/)?(\d+))?\/?$/i);
32
+ if (!serviceMatch ||
33
+ serviceMatch[1].toLowerCase() !== serviceType.toLowerCase() ||
34
+ (serviceMatch[2] !== undefined &&
35
+ !new RegExp(serviceType === 'SceneServer'
36
+ ? '/SceneServer/layers/\\d+/?$'
37
+ : '/(FeatureServer|MapServer)/\\d+/?$', 'i').test(serviceUrl.pathname))) {
38
+ throw new Error('ArcGIS item URL does not match its supported service type.');
39
+ }
40
+ const url = serviceUrl.href.replace(/\/$/, '');
41
+ const service = await fetchMetadata(url, fetchFile, options.signal);
42
+ const isLayer = serviceMatch[2] !== undefined;
43
+ const layers = isLayer
44
+ ? [
45
+ {
46
+ id: Number(serviceMatch[2]),
47
+ name: service.name || item.title,
48
+ url,
49
+ kind: service.type === 'Table' ? 'table' : 'layer'
50
+ }
51
+ ]
52
+ : [
53
+ ...createLayerChoices(service.layers, 'layer', url, serviceType),
54
+ ...createLayerChoices(service.tables, 'table', url, serviceType)
55
+ ];
56
+ // Map roots are also useful as image sources; image/vector tile roots are single services.
57
+ if (!isLayer && serviceType !== 'FeatureServer' && serviceType !== 'SceneServer') {
58
+ layers.unshift({ id: null, name: service.name || item.title, url, kind: 'service' });
59
+ }
60
+ const resolution = { portalUrl, item, service, layers };
61
+ if (options.layerId !== undefined) {
62
+ const layer = layers.find(candidate => candidate.id === options.layerId);
63
+ if (!layer)
64
+ throw new Error('The requested ArcGIS layer or table is not present in this item.');
65
+ const metadata = layer.url === url ? service : await fetchMetadata(layer.url, fetchFile, options.signal);
66
+ resolution.selectedLayer = { ...layer, metadata };
67
+ }
68
+ return resolution;
69
+ }
70
+ /** Builds choices from advertised numeric layer IDs without recursively fetching sublayers. */
71
+ function createLayerChoices(entries, kind, url, serviceType) {
72
+ if (!Array.isArray(entries))
73
+ return [];
74
+ return entries
75
+ .filter(entry => Number.isSafeInteger(entry?.id) && entry.id >= 0)
76
+ .map(entry => ({
77
+ id: entry.id,
78
+ name: typeof entry.name === 'string' ? entry.name : String(entry.id),
79
+ url: `${url}/${serviceType === 'SceneServer' ? 'layers/' : ''}${entry.id}`,
80
+ kind
81
+ }));
82
+ }
83
+ /** Parses only documented item URL shapes, retaining Enterprise portal prefixes. */
84
+ function parseItemReference(input, configuredPortal) {
85
+ let itemId = input;
86
+ let inferredPortal;
87
+ if (!/^[a-f\d]{32}$/i.test(input)) {
88
+ const url = new URL(input);
89
+ if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password || url.hash)
90
+ throw new Error('Invalid ArcGIS item URL.');
91
+ const details = url.pathname.match(/^(.*)\/home\/item\.html$/);
92
+ const rest = url.pathname.match(/^(.*)\/sharing\/rest\/content\/items\/([a-f\d]{32})\/?$/i);
93
+ if (details) {
94
+ itemId = url.searchParams.get('id') || '';
95
+ inferredPortal = `${url.origin}${details[1]}/sharing/rest`;
96
+ }
97
+ else if (rest) {
98
+ itemId = rest[2];
99
+ inferredPortal = `${url.origin}${rest[1]}/sharing/rest`;
100
+ }
101
+ else
102
+ throw new Error('Expected an ArcGIS item ID or item-details/REST URL.');
103
+ if ([...url.searchParams.keys()].some(key => !['id', 'f'].includes(key)))
104
+ throw new Error('Item URLs must not contain credentials or extra parameters.');
105
+ }
106
+ if (!/^[a-f\d]{32}$/i.test(itemId))
107
+ throw new Error('ArcGIS item IDs must contain 32 hexadecimal characters.');
108
+ const portal = parseEndpoint(configuredPortal || inferredPortal || 'https://www.arcgis.com');
109
+ const portalUrl = `${portal.href.replace(/\/$/, '').replace(/\/sharing\/rest$/i, '')}/sharing/rest`;
110
+ if (inferredPortal && portalUrl !== inferredPortal)
111
+ throw new Error('Item URL does not belong to the configured portal.');
112
+ return { itemId: itemId.toLowerCase(), portalUrl };
113
+ }
114
+ /** Rejects credential-bearing or non-HTTP metadata endpoints. */
115
+ function parseEndpoint(value) {
116
+ const url = new URL(value);
117
+ if (!['http:', 'https:'].includes(url.protocol) ||
118
+ url.username ||
119
+ url.password ||
120
+ url.search ||
121
+ url.hash) {
122
+ throw new Error('ArcGIS endpoints must be HTTP(S) URLs without credentials, query parameters or fragments.');
123
+ }
124
+ return url;
125
+ }
126
+ /** Reads JSON metadata and rejects ArcGIS error envelopes even with HTTP 200. */
127
+ async function fetchMetadata(url, fetchFile, signal) {
128
+ const response = await fetchFile(`${url}?f=json`, { signal });
129
+ if (!response.ok)
130
+ throw new Error(`ArcGIS metadata request failed (HTTP ${response.status}).`);
131
+ const metadata = await response.json();
132
+ if (!metadata || typeof metadata !== 'object' || Array.isArray(metadata) || metadata.error) {
133
+ throw new Error('ArcGIS metadata is unavailable or access was denied.');
134
+ }
135
+ return metadata;
136
+ }
137
+ //# sourceMappingURL=arcgis-items.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcgis-items.js","sourceRoot":"","sources":["../src/arcgis-items.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAgEpC,4DAA4D;AAC5D,MAAM,aAAa,GAAqC;IACtD,iBAAiB,EAAE,eAAe;IAClC,aAAa,EAAE,WAAW;IAC1B,eAAe,EAAE,aAAa;IAC9B,qBAAqB,EAAE,kBAAkB;IACzC,eAAe,EAAE,aAAa;CAC/B,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAAa,EACb,UAA6B,EAAE;IAE/B,MAAM,EAAC,MAAM,EAAE,SAAS,EAAC,GAAG,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACzE,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACzC,MAAM,IAAI,GAAG,CAAC,MAAM,aAAa,CAC/B,GAAG,SAAS,kBAAkB,MAAM,EAAE,EACtC,SAAS,EACT,OAAO,CAAC,MAAM,CACf,CAAe,CAAC;IACjB,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,CA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