@esri/hub-common 9.21.2 → 9.23.1

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 (62) hide show
  1. package/dist/es2017/content/_fetch.js +87 -0
  2. package/dist/es2017/content/_fetch.js.map +1 -0
  3. package/dist/es2017/content/_internal.js +75 -3
  4. package/dist/es2017/content/_internal.js.map +1 -1
  5. package/dist/es2017/content/compose.js +59 -22
  6. package/dist/es2017/content/compose.js.map +1 -1
  7. package/dist/es2017/content/fetch.js +109 -0
  8. package/dist/es2017/content/fetch.js.map +1 -0
  9. package/dist/es2017/content/index.js +9 -80
  10. package/dist/es2017/content/index.js.map +1 -1
  11. package/dist/es2017/content/slugs.js +63 -0
  12. package/dist/es2017/content/slugs.js.map +1 -0
  13. package/dist/es2017/content/types.js +1 -0
  14. package/dist/es2017/content/types.js.map +1 -0
  15. package/dist/es2017/items/_enrichments.js +176 -0
  16. package/dist/es2017/items/_enrichments.js.map +1 -0
  17. package/dist/esm/content/_fetch.js +102 -0
  18. package/dist/esm/content/_fetch.js.map +1 -0
  19. package/dist/esm/content/_internal.js +75 -3
  20. package/dist/esm/content/_internal.js.map +1 -1
  21. package/dist/esm/content/compose.js +60 -21
  22. package/dist/esm/content/compose.js.map +1 -1
  23. package/dist/esm/content/fetch.js +177 -0
  24. package/dist/esm/content/fetch.js.map +1 -0
  25. package/dist/esm/content/index.js +9 -80
  26. package/dist/esm/content/index.js.map +1 -1
  27. package/dist/esm/content/slugs.js +63 -0
  28. package/dist/esm/content/slugs.js.map +1 -0
  29. package/dist/esm/content/types.js +1 -0
  30. package/dist/esm/content/types.js.map +1 -0
  31. package/dist/esm/items/_enrichments.js +177 -0
  32. package/dist/esm/items/_enrichments.js.map +1 -0
  33. package/dist/node/content/_fetch.js +90 -0
  34. package/dist/node/content/_fetch.js.map +1 -0
  35. package/dist/node/content/_internal.js +76 -4
  36. package/dist/node/content/_internal.js.map +1 -1
  37. package/dist/node/content/compose.js +59 -22
  38. package/dist/node/content/compose.js.map +1 -1
  39. package/dist/node/content/fetch.js +112 -0
  40. package/dist/node/content/fetch.js.map +1 -0
  41. package/dist/node/content/index.js +11 -86
  42. package/dist/node/content/index.js.map +1 -1
  43. package/dist/node/content/slugs.js +70 -0
  44. package/dist/node/content/slugs.js.map +1 -0
  45. package/dist/node/content/types.js +3 -0
  46. package/dist/node/content/types.js.map +1 -0
  47. package/dist/node/items/_enrichments.js +179 -0
  48. package/dist/node/items/_enrichments.js.map +1 -0
  49. package/dist/types/content/_fetch.d.ts +60 -0
  50. package/dist/types/content/_internal.d.ts +79 -0
  51. package/dist/types/content/compose.d.ts +31 -0
  52. package/dist/types/content/fetch.d.ts +24 -0
  53. package/dist/types/content/index.d.ts +4 -41
  54. package/dist/types/content/slugs.d.ts +34 -0
  55. package/dist/types/content/types.d.ts +7 -0
  56. package/dist/types/core/types/IHubContent.d.ts +4 -0
  57. package/dist/types/items/_enrichments.d.ts +24 -0
  58. package/dist/umd/common.umd.js +2238 -836
  59. package/dist/umd/common.umd.js.map +1 -1
  60. package/dist/umd/common.umd.min.js +1 -1
  61. package/dist/umd/common.umd.min.js.map +1 -1
  62. package/package.json +2 -1
@@ -19,6 +19,7 @@ import { IHubAdditionalResource } from "../core/types/IHubAdditionalResource";
19
19
  * @param content original content
20
20
  * @param boundary boundary provenance
21
21
  * @returns
22
+ * @private
22
23
  */
23
24
  export declare const setContentBoundary: (content: IHubContent, boundary: GeographyProvenance) => {
24
25
  boundary: IHubGeography;
@@ -67,6 +68,9 @@ export declare const setContentBoundary: (content: IHubContent, boundary: Geogra
67
68
  layer?: Partial<ILayerDefinition>;
68
69
  isProxied?: boolean;
69
70
  additionalResources?: IHubAdditionalResource[];
71
+ viewDefinition?: {
72
+ definitionExpression?: string;
73
+ };
70
74
  itemCategories?: string[];
71
75
  normalizedType?: string;
72
76
  orgId?: string;
@@ -109,18 +113,60 @@ export declare const setContentBoundary: (content: IHubContent, boundary: Geogra
109
113
  spatialReference?: ISpatialReference;
110
114
  properties?: any;
111
115
  };
116
+ /**
117
+ * get a content's boundary based on the item's boundary property
118
+ * @param item
119
+ * @returns
120
+ * @private
121
+ */
112
122
  export declare const getContentBoundary: (item: IItem) => IHubGeography;
123
+ /**
124
+ * Determine if we are in an enterprise environment
125
+ * NOTE: when no request options are provided, the underlying
126
+ * request functions assume that we are online in production
127
+ * so we only want use enterprise logic if isPortal is explicitly defined
128
+ * @param requestOptions
129
+ * @returns
130
+ * @private
131
+ */
113
132
  export declare const isPortal: (requestOptions?: IHubRequestOptions) => boolean;
133
+ /**
134
+ * Determine if we can use the Hub API for an item, i.e.
135
+ * the item is public and we are not in an enterprise environment
136
+ * @param item
137
+ * @param requestOptions
138
+ * @returns
139
+ * @private
140
+ */
141
+ export declare const canUseHubApiForItem: (item: IItem, requestOptions?: IHubRequestOptions) => boolean;
114
142
  /**
115
143
  * Returns whether or not an item is a proxied csv
116
144
  *
117
145
  * @param item
118
146
  * @param requestOptions Hub Request Options (including whether we're in portal)
119
147
  * @returns
148
+ * @private
120
149
  */
121
150
  export declare const isProxiedCSV: (item: IItem, requestOptions?: IHubRequestOptions) => boolean;
151
+ /**
152
+ * Get the relative URL to use for the item in a hub site
153
+ * @param type
154
+ * @param identifier
155
+ * @param typeKeywords
156
+ * @returns
157
+ * @private
158
+ */
122
159
  export declare const getHubRelativeUrl: (type: string, identifier: string, typeKeywords?: string[]) => string;
160
+ /**
161
+ * Is this content type a page?
162
+ * @param type
163
+ * @returns
164
+ * @private
165
+ */
123
166
  export declare const isPageType: (type: string) => boolean;
167
+ /**
168
+ * well known paths to formal metadata values
169
+ */
124
170
  export interface IMetadataPaths {
125
171
  updateFrequency: string;
126
172
  metadataUpdateFrequency: string;
@@ -129,8 +175,24 @@ export interface IMetadataPaths {
129
175
  pubDate: string;
130
176
  createDate: string;
131
177
  }
178
+ /**
179
+ * Get the path to a well known metadata value
180
+ * @param identifier identifier for well known metadata value
181
+ * @returns path to be used like get(metadata, path)
182
+ * @private
183
+ */
132
184
  export declare function getMetadataPath(identifier: keyof IMetadataPaths): string;
185
+ /**
186
+ * Get a well known value from metadata
187
+ * @param metadata
188
+ * @param identifier identifier for well known metadata value
189
+ * @returns
190
+ * @private
191
+ */
133
192
  export declare function getValueFromMetadata(metadata: any, identifier: keyof IMetadataPaths): any;
193
+ /**
194
+ * Date precisions
195
+ */
134
196
  export declare enum DatePrecision {
135
197
  Year = "year",
136
198
  Month = "month",
@@ -147,12 +209,26 @@ export declare enum DatePrecision {
147
209
  *
148
210
  * @param {string} isoString
149
211
  * @return { date: Date, precision: DatePrecision }
212
+ * @private
150
213
  */
151
214
  export declare function parseISODateString(isoString: string): {
152
215
  date: Date;
153
216
  precision: DatePrecision;
154
217
  };
218
+ /**
219
+ * Get the spatial reference from layer or server info
220
+ * @param server
221
+ * @param layer
222
+ * @returns
223
+ * @private
224
+ */
155
225
  export declare const getServerSpatialReference: (server: Partial<IFeatureServiceDefinition>, layer?: ILayerDefinition) => ISpatialReference;
226
+ /**
227
+ * Get the spatial reference as an object for an item
228
+ * @param item
229
+ * @returns spatial reference object
230
+ * @private
231
+ */
156
232
  export declare const getItemSpatialReference: (item: IItem) => ISpatialReference;
157
233
  /**
158
234
  * Data model for additional resources that are extracted
@@ -171,6 +247,7 @@ interface IAGOAdditionalResource {
171
247
  * @param item
172
248
  * @param metadata formal metadata
173
249
  * @returns
250
+ * @private
174
251
  */
175
252
  export declare const getAdditionalResources: (item: IItem, metadata?: any, requestOptions?: IHubRequestOptions) => IHubAdditionalResource[];
176
253
  /**
@@ -181,6 +258,7 @@ export declare const getAdditionalResources: (item: IItem, metadata?: any, reque
181
258
  * @param resource raw additional resource of an item
182
259
  * @param item
183
260
  * @returns
261
+ * @private
184
262
  */
185
263
  export declare const isDataSourceOfItem: (resource: IAGOAdditionalResource, item: IItem) => boolean;
186
264
  /**
@@ -193,6 +271,7 @@ export declare const isDataSourceOfItem: (resource: IAGOAdditionalResource, item
193
271
  * @param item
194
272
  * @param requestOptions IHubRequestOptions, including authentication
195
273
  * @returns
274
+ * @private
196
275
  */
197
276
  export declare const getAdditionalResourceUrl: (resource: IAGOAdditionalResource, item: IItem, requestOptions?: IHubRequestOptions) => string;
198
277
  export {};
@@ -1,6 +1,8 @@
1
1
  import { IItem } from "@esri/arcgis-rest-portal";
2
+ import { ILayerDefinition } from "@esri/arcgis-rest-feature-layer";
2
3
  import { IHubRequestOptions } from "../types";
3
4
  import { IHubContentEnrichments, IHubContent } from "../core";
5
+ import { IHubExtent } from "./_fetch";
4
6
  /**
5
7
  * The possible values for updateFrequency
6
8
  *
@@ -105,7 +107,36 @@ export interface IComposeContentOptions extends IHubContentEnrichments {
105
107
  layerId?: number;
106
108
  slug?: string;
107
109
  requestOptions?: IHubRequestOptions;
110
+ /**
111
+ * Either the item's extent, or the item's
112
+ * layer or server's extent converted to a lat/lng coordinate pair
113
+ */
114
+ extent?: IHubExtent;
115
+ /**
116
+ * The appropriate summary to show for the item, coming from either
117
+ * the item's data (for pages or initiatives) or the item's description
118
+ */
119
+ searchDescription?: string;
108
120
  }
121
+ /**
122
+ * get the layer object for
123
+ * - an item that refers to a specific layer of a service
124
+ * - a multi-layer services (if a layer id was passed in)
125
+ * - a single layer feature service
126
+ * @param item
127
+ * @param layers the layers and tables returned from the service
128
+ * @param layerId a specific id
129
+ * @returns layer definition
130
+ * @private
131
+ */
132
+ export declare const getItemLayer: (item: IItem, layers: ILayerDefinition[], layerId?: number) => ILayerDefinition;
133
+ /**
134
+ * determine if a layer is a layer view
135
+ * @param layer
136
+ * @returns
137
+ * @private
138
+ */
139
+ export declare const isLayerView: (layer: ILayerDefinition) => boolean;
109
140
  /**
110
141
  * Compose a new content object out of an item, enrichments, and context
111
142
  * @param item
@@ -0,0 +1,24 @@
1
+ import { IHubContent } from "../core";
2
+ import { ItemOrServerEnrichment } from "../items/_enrichments";
3
+ import { IHubRequestOptions } from "../types";
4
+ interface IFetchItemAndEnrichmentsOptions extends IHubRequestOptions {
5
+ enrichments?: ItemOrServerEnrichment[];
6
+ }
7
+ export interface IFetchContentOptions extends IFetchItemAndEnrichmentsOptions {
8
+ layerId?: number;
9
+ siteOrgKey?: string;
10
+ }
11
+ /**
12
+ * Fetch enriched content from the Portal and Hub APIs.
13
+ * @param identifier content slug or id
14
+ * @param options Request options with additional options to control how the content or enrichments are fetched
15
+ * @returns A content object composed of the backing item and enrichments
16
+ *
17
+ * ```js
18
+ * import { fetchContent } from '@esri/hub-common'
19
+ * // fetch content by slug
20
+ * const content = await fetchContent('my-org::item-name')
21
+ * ```
22
+ */
23
+ export declare const fetchContent: (identifier: string, options?: IFetchContentOptions) => Promise<IHubContent>;
24
+ export {};
@@ -1,15 +1,12 @@
1
- import { ResourceObject } from "jsonapi-typescript";
2
1
  import { IItem } from "@esri/arcgis-rest-portal";
3
2
  import { HubType, IModel } from "../types";
4
3
  import { IHubContent } from "../core";
4
+ import { DatasetResource } from "./types";
5
5
  export * from "./compose";
6
6
  export * from "./get-family";
7
- /**
8
- * JSONAPI dataset resource returned by the Hub API
9
- */
10
- export declare type DatasetResource = ResourceObject<"dataset", {
11
- [k: string]: any;
12
- }>;
7
+ export * from "./slugs";
8
+ export * from "./fetch";
9
+ export * from "./types";
13
10
  /**
14
11
  * ```js
15
12
  * import { getCategory } from "@esri/hub-common";
@@ -69,40 +66,6 @@ export declare function getTypeCategories(item?: any): string[];
69
66
  * @returns the preferred id for the given content.
70
67
  */
71
68
  export declare function getContentIdentifier(content: IHubContent, site?: IModel): string;
72
- /**
73
- * Parse item ID and layer ID (if any) from dataset record ID
74
- *
75
- * @param datasetId Hub API dataset record id ({itemId}_{layerId} or {itemId})
76
- * @returns A hash with the `itemId` and `layerId` (if any)
77
- */
78
- export declare function parseDatasetId(datasetId: string): {
79
- itemId: string;
80
- layerId?: string;
81
- };
82
- /**
83
- * Determine if an identifier is a Hub API slug
84
- *
85
- * @param identifier Hub API slug ({orgKey}::{title-as-slug} or {title-as-slug})
86
- * or record id ((itemId}_{layerId} or {itemId})
87
- * @returns true if the identifier is valid _and_ is **not** a record id
88
- */
89
- export declare function isSlug(identifier: string): boolean;
90
- /**
91
- * Add a context (prefix) to slug if it doesn't already have one
92
- *
93
- * @param slug Hub API slug (with or without context)
94
- * @param context usually a portal's orgKey
95
- * @returns slug with context ({context}::{slug})
96
- */
97
- export declare function addContextToSlug(slug: string, context: string): string;
98
- /**
99
- * Remove context (prefix) from a slug
100
- *
101
- * @param slug Hub API slug with context
102
- * @param context usually a portal's orgKey
103
- * @returns slug without context
104
- */
105
- export declare function removeContextFromSlug(slug: string, context: string): string;
106
69
  /**
107
70
  * DEPRECATED: Use getFamily() instead.
108
71
  *
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Parse item ID and layer ID (if any) from dataset record ID
3
+ *
4
+ * @param datasetId Hub API dataset record id ({itemId}_{layerId} or {itemId})
5
+ * @returns A hash with the `itemId` and `layerId` (if any)
6
+ */
7
+ export declare function parseDatasetId(datasetId: string): {
8
+ itemId: string;
9
+ layerId?: string;
10
+ };
11
+ /**
12
+ * Determine if an identifier is a Hub API slug
13
+ *
14
+ * @param identifier Hub API slug ({orgKey}::{title-as-slug} or {title-as-slug})
15
+ * or record id ((itemId}_{layerId} or {itemId})
16
+ * @returns true if the identifier is valid _and_ is **not** a record id
17
+ */
18
+ export declare function isSlug(identifier: string): boolean;
19
+ /**
20
+ * Add a context (prefix) to slug if it doesn't already have one
21
+ *
22
+ * @param slug Hub API slug (with or without context)
23
+ * @param context usually a portal's orgKey
24
+ * @returns slug with context ({context}::{slug})
25
+ */
26
+ export declare function addContextToSlug(slug: string, context: string): string;
27
+ /**
28
+ * Remove context (prefix) from a slug
29
+ *
30
+ * @param slug Hub API slug with context
31
+ * @param context usually a portal's orgKey
32
+ * @returns slug without context
33
+ */
34
+ export declare function removeContextFromSlug(slug: string, context: string): string;
@@ -0,0 +1,7 @@
1
+ import { ResourceObject } from "jsonapi-typescript";
2
+ /**
3
+ * JSONAPI dataset resource returned by the Hub API
4
+ */
5
+ export declare type DatasetResource = ResourceObject<"dataset", {
6
+ [k: string]: any;
7
+ }>;
@@ -77,6 +77,10 @@ export interface IHubContent extends IHubItemEntity, IHubContentEnrichments, IIt
77
77
  isProxied?: boolean;
78
78
  /** links to additional resources specified in the formal item metadata */
79
79
  additionalResources?: IHubAdditionalResource[];
80
+ /** definition for content that refers to a client-side layer view */
81
+ viewDefinition?: {
82
+ definitionExpression?: string;
83
+ };
80
84
  itemCategories?: string[];
81
85
  normalizedType?: string;
82
86
  orgId?: string;
@@ -0,0 +1,24 @@
1
+ import { IItem } from "@esri/arcgis-rest-portal";
2
+ import { IItemEnrichments, IServerEnrichments } from "../core";
3
+ import { IHubRequestOptions } from "../types";
4
+ /**
5
+ * An object containing the item and fetched enrichments
6
+ */
7
+ export interface IItemAndEnrichments extends IItemEnrichments, IServerEnrichments {
8
+ item: IItem;
9
+ }
10
+ /**
11
+ * The name of an enrichment that comes either
12
+ * from the portal API for the item
13
+ * or from the server that the item points to
14
+ */
15
+ export declare type ItemOrServerEnrichment = keyof IItemEnrichments | keyof IServerEnrichments;
16
+ /**
17
+ * Fetch enrichments for an item
18
+ * @param item
19
+ * @param enrichments the list of enrichments to fetch
20
+ * @param requestOptions
21
+ * @returns an object with the item and enrichments
22
+ * @private
23
+ */
24
+ export declare const fetchItemEnrichments: (item: IItem, enrichments: ItemOrServerEnrichment[], requestOptions?: IHubRequestOptions) => Promise<IItemAndEnrichments>;