@esri/hub-common 9.21.1 → 9.23.0

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 +60 -21
  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 -70
  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 +61 -20
  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 -70
  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 +60 -21
  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 -76
  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 +2075 -662
  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
@@ -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>;