@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.
- package/dist/es2017/content/_fetch.js +87 -0
- package/dist/es2017/content/_fetch.js.map +1 -0
- package/dist/es2017/content/_internal.js +75 -3
- package/dist/es2017/content/_internal.js.map +1 -1
- package/dist/es2017/content/compose.js +60 -21
- package/dist/es2017/content/compose.js.map +1 -1
- package/dist/es2017/content/fetch.js +109 -0
- package/dist/es2017/content/fetch.js.map +1 -0
- package/dist/es2017/content/index.js +9 -70
- package/dist/es2017/content/index.js.map +1 -1
- package/dist/es2017/content/slugs.js +63 -0
- package/dist/es2017/content/slugs.js.map +1 -0
- package/dist/es2017/content/types.js +1 -0
- package/dist/es2017/content/types.js.map +1 -0
- package/dist/es2017/items/_enrichments.js +176 -0
- package/dist/es2017/items/_enrichments.js.map +1 -0
- package/dist/esm/content/_fetch.js +102 -0
- package/dist/esm/content/_fetch.js.map +1 -0
- package/dist/esm/content/_internal.js +75 -3
- package/dist/esm/content/_internal.js.map +1 -1
- package/dist/esm/content/compose.js +61 -20
- package/dist/esm/content/compose.js.map +1 -1
- package/dist/esm/content/fetch.js +177 -0
- package/dist/esm/content/fetch.js.map +1 -0
- package/dist/esm/content/index.js +9 -70
- package/dist/esm/content/index.js.map +1 -1
- package/dist/esm/content/slugs.js +63 -0
- package/dist/esm/content/slugs.js.map +1 -0
- package/dist/esm/content/types.js +1 -0
- package/dist/esm/content/types.js.map +1 -0
- package/dist/esm/items/_enrichments.js +177 -0
- package/dist/esm/items/_enrichments.js.map +1 -0
- package/dist/node/content/_fetch.js +90 -0
- package/dist/node/content/_fetch.js.map +1 -0
- package/dist/node/content/_internal.js +76 -4
- package/dist/node/content/_internal.js.map +1 -1
- package/dist/node/content/compose.js +60 -21
- package/dist/node/content/compose.js.map +1 -1
- package/dist/node/content/fetch.js +112 -0
- package/dist/node/content/fetch.js.map +1 -0
- package/dist/node/content/index.js +11 -76
- package/dist/node/content/index.js.map +1 -1
- package/dist/node/content/slugs.js +70 -0
- package/dist/node/content/slugs.js.map +1 -0
- package/dist/node/content/types.js +3 -0
- package/dist/node/content/types.js.map +1 -0
- package/dist/node/items/_enrichments.js +179 -0
- package/dist/node/items/_enrichments.js.map +1 -0
- package/dist/types/content/_fetch.d.ts +60 -0
- package/dist/types/content/_internal.d.ts +79 -0
- package/dist/types/content/compose.d.ts +31 -0
- package/dist/types/content/fetch.d.ts +24 -0
- package/dist/types/content/index.d.ts +4 -41
- package/dist/types/content/slugs.d.ts +34 -0
- package/dist/types/content/types.d.ts +7 -0
- package/dist/types/core/types/IHubContent.d.ts +4 -0
- package/dist/types/items/_enrichments.d.ts +24 -0
- package/dist/umd/common.umd.js +2075 -662
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- 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
|
-
*
|
|
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;
|
|
@@ -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>;
|