@esri/hub-common 9.13.1 → 9.15.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/ArcGISContext.js +202 -120
- package/dist/es2017/ArcGISContext.js.map +1 -1
- package/dist/es2017/ArcGISContextManager.js +171 -0
- package/dist/es2017/ArcGISContextManager.js.map +1 -0
- package/dist/es2017/Hub.js +70 -0
- package/dist/es2017/Hub.js.map +1 -0
- package/dist/es2017/HubError.js +34 -0
- package/dist/es2017/HubError.js.map +1 -0
- package/dist/es2017/collections.js +23 -0
- package/dist/es2017/collections.js.map +1 -1
- package/dist/es2017/content/_internal.js.map +1 -1
- package/dist/es2017/content/index.js +25 -17
- package/dist/es2017/content/index.js.map +1 -1
- package/dist/es2017/core/helpers/PropertyMapper.js +95 -0
- package/dist/es2017/core/helpers/PropertyMapper.js.map +1 -0
- package/dist/es2017/core/index.js +3 -0
- package/dist/es2017/core/index.js.map +1 -0
- package/dist/es2017/core/traits/WithBannerImage.js +1 -0
- package/dist/es2017/core/traits/WithBannerImage.js.map +1 -0
- package/dist/es2017/core/traits/WithLayout.js +1 -0
- package/dist/es2017/core/traits/WithLayout.js.map +1 -0
- package/dist/es2017/core/traits/WithSlug.js +1 -0
- package/dist/es2017/core/traits/WithSlug.js.map +1 -0
- package/dist/es2017/core/traits/index.js +4 -0
- package/dist/es2017/core/traits/index.js.map +1 -0
- package/dist/es2017/core/types/IContentEnrichments.js +1 -0
- package/dist/es2017/core/types/IContentEnrichments.js.map +1 -0
- package/dist/es2017/core/types/IHubContent.js +1 -0
- package/dist/es2017/core/types/IHubContent.js.map +1 -0
- package/dist/es2017/core/types/IHubEntityBase.js +1 -0
- package/dist/es2017/core/types/IHubEntityBase.js.map +1 -0
- package/dist/es2017/core/types/IHubEntityManager.js +1 -0
- package/dist/es2017/core/types/IHubEntityManager.js.map +1 -0
- package/dist/es2017/core/types/IHubEvent.js +1 -0
- package/dist/es2017/core/types/IHubEvent.js.map +1 -0
- package/dist/es2017/core/types/IHubImage.js +1 -0
- package/dist/es2017/core/types/IHubImage.js.map +1 -0
- package/dist/es2017/core/types/IHubInitiative.js +1 -0
- package/dist/es2017/core/types/IHubInitiative.js.map +1 -0
- package/dist/es2017/core/types/IHubItemEntity.js +1 -0
- package/dist/es2017/core/types/IHubItemEntity.js.map +1 -0
- package/dist/es2017/core/types/IHubLayout.js +1 -0
- package/dist/es2017/core/types/IHubLayout.js.map +1 -0
- package/dist/es2017/core/types/IHubPage.js +1 -0
- package/dist/es2017/core/types/IHubPage.js.map +1 -0
- package/dist/es2017/core/types/IHubProject.js +1 -0
- package/dist/es2017/core/types/IHubProject.js.map +1 -0
- package/dist/es2017/core/types/IHubSite.js +1 -0
- package/dist/es2017/core/types/IHubSite.js.map +1 -0
- package/dist/es2017/core/types/IHubTimeline.js +1 -0
- package/dist/es2017/core/types/IHubTimeline.js.map +1 -0
- package/dist/es2017/core/types/IItemEnrichments.js +1 -0
- package/dist/es2017/core/types/IItemEnrichments.js.map +1 -0
- package/dist/es2017/core/types/index.js +15 -0
- package/dist/es2017/core/types/index.js.map +1 -0
- package/dist/es2017/index.js +11 -5
- package/dist/es2017/index.js.map +1 -1
- package/dist/es2017/items/fail-safe-update.js +2 -2
- package/dist/es2017/items/fail-safe-update.js.map +1 -1
- package/dist/es2017/items/get-model-from-options.js +2 -2
- package/dist/es2017/items/get-model-from-options.js.map +1 -1
- package/dist/es2017/items/index.js +2 -3
- package/dist/es2017/items/index.js.map +1 -1
- package/dist/es2017/items/slugs.js +92 -0
- package/dist/es2017/items/slugs.js.map +1 -0
- package/dist/es2017/models/index.js +98 -0
- package/dist/es2017/models/index.js.map +1 -0
- package/dist/es2017/{items/serialize-model.js → models/serializeModel.js} +1 -1
- package/dist/es2017/models/serializeModel.js.map +1 -0
- package/dist/es2017/projects/HubProjectManager.js +115 -0
- package/dist/es2017/projects/HubProjectManager.js.map +1 -0
- package/dist/es2017/projects/HubProjects.js +194 -0
- package/dist/es2017/projects/HubProjects.js.map +1 -0
- package/dist/es2017/projects/index.js +3 -0
- package/dist/es2017/projects/index.js.map +1 -0
- package/dist/es2017/search/_searchContent.js +18 -7
- package/dist/es2017/search/_searchContent.js.map +1 -1
- package/dist/es2017/search/_searchGroups.js +1 -11
- package/dist/es2017/search/_searchGroups.js.map +1 -1
- package/dist/es2017/search/utils.js +1 -1
- package/dist/es2017/urls/getHubApiFromPortalUrl.js +21 -0
- package/dist/es2017/urls/getHubApiFromPortalUrl.js.map +1 -0
- package/dist/es2017/urls/getPortalBaseFromOrgUrl.js +25 -0
- package/dist/es2017/urls/getPortalBaseFromOrgUrl.js.map +1 -0
- package/dist/es2017/urls/index.js +2 -0
- package/dist/es2017/urls/index.js.map +1 -1
- package/dist/es2017/utils/dasherize.js +25 -0
- package/dist/es2017/utils/dasherize.js.map +1 -0
- package/dist/es2017/utils/index.js +1 -0
- package/dist/es2017/utils/index.js.map +1 -1
- package/dist/esm/ArcGISContext.js +308 -180
- package/dist/esm/ArcGISContext.js.map +1 -1
- package/dist/esm/ArcGISContextManager.js +215 -0
- package/dist/esm/ArcGISContextManager.js.map +1 -0
- package/dist/esm/Hub.js +89 -0
- package/dist/esm/Hub.js.map +1 -0
- package/dist/esm/HubError.js +40 -0
- package/dist/esm/HubError.js.map +1 -0
- package/dist/esm/collections.js +23 -0
- package/dist/esm/collections.js.map +1 -1
- package/dist/esm/content/_internal.js.map +1 -1
- package/dist/esm/content/index.js +25 -17
- package/dist/esm/content/index.js.map +1 -1
- package/dist/esm/core/helpers/PropertyMapper.js +97 -0
- package/dist/esm/core/helpers/PropertyMapper.js.map +1 -0
- package/dist/esm/core/index.js +3 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/traits/WithBannerImage.js +1 -0
- package/dist/esm/core/traits/WithBannerImage.js.map +1 -0
- package/dist/esm/core/traits/WithLayout.js +1 -0
- package/dist/esm/core/traits/WithLayout.js.map +1 -0
- package/dist/esm/core/traits/WithSlug.js +1 -0
- package/dist/esm/core/traits/WithSlug.js.map +1 -0
- package/dist/esm/core/traits/index.js +4 -0
- package/dist/esm/core/traits/index.js.map +1 -0
- package/dist/esm/core/types/IContentEnrichments.js +1 -0
- package/dist/esm/core/types/IContentEnrichments.js.map +1 -0
- package/dist/esm/core/types/IHubContent.js +1 -0
- package/dist/esm/core/types/IHubContent.js.map +1 -0
- package/dist/esm/core/types/IHubEntityBase.js +1 -0
- package/dist/esm/core/types/IHubEntityBase.js.map +1 -0
- package/dist/esm/core/types/IHubEntityManager.js +1 -0
- package/dist/esm/core/types/IHubEntityManager.js.map +1 -0
- package/dist/esm/core/types/IHubEvent.js +1 -0
- package/dist/esm/core/types/IHubEvent.js.map +1 -0
- package/dist/esm/core/types/IHubImage.js +1 -0
- package/dist/esm/core/types/IHubImage.js.map +1 -0
- package/dist/esm/core/types/IHubInitiative.js +1 -0
- package/dist/esm/core/types/IHubInitiative.js.map +1 -0
- package/dist/esm/core/types/IHubItemEntity.js +1 -0
- package/dist/esm/core/types/IHubItemEntity.js.map +1 -0
- package/dist/esm/core/types/IHubLayout.js +1 -0
- package/dist/esm/core/types/IHubLayout.js.map +1 -0
- package/dist/esm/core/types/IHubPage.js +1 -0
- package/dist/esm/core/types/IHubPage.js.map +1 -0
- package/dist/esm/core/types/IHubProject.js +1 -0
- package/dist/esm/core/types/IHubProject.js.map +1 -0
- package/dist/esm/core/types/IHubSite.js +1 -0
- package/dist/esm/core/types/IHubSite.js.map +1 -0
- package/dist/esm/core/types/IHubTimeline.js +1 -0
- package/dist/esm/core/types/IHubTimeline.js.map +1 -0
- package/dist/esm/core/types/IItemEnrichments.js +1 -0
- package/dist/esm/core/types/IItemEnrichments.js.map +1 -0
- package/dist/esm/core/types/index.js +15 -0
- package/dist/esm/core/types/index.js.map +1 -0
- package/dist/esm/index.js +11 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/items/fail-safe-update.js +2 -2
- package/dist/esm/items/fail-safe-update.js.map +1 -1
- package/dist/esm/items/get-model-from-options.js +2 -2
- package/dist/esm/items/get-model-from-options.js.map +1 -1
- package/dist/esm/items/index.js +2 -3
- package/dist/esm/items/index.js.map +1 -1
- package/dist/esm/items/slugs.js +93 -0
- package/dist/esm/items/slugs.js.map +1 -0
- package/dist/esm/models/index.js +99 -0
- package/dist/esm/models/index.js.map +1 -0
- package/dist/esm/{items/serialize-model.js → models/serializeModel.js} +1 -1
- package/dist/esm/models/serializeModel.js.map +1 -0
- package/dist/esm/projects/HubProjectManager.js +142 -0
- package/dist/esm/projects/HubProjectManager.js.map +1 -0
- package/dist/esm/projects/HubProjects.js +225 -0
- package/dist/esm/projects/HubProjects.js.map +1 -0
- package/dist/esm/projects/index.js +3 -0
- package/dist/esm/projects/index.js.map +1 -0
- package/dist/esm/search/_searchContent.js +18 -7
- package/dist/esm/search/_searchContent.js.map +1 -1
- package/dist/esm/search/_searchGroups.js +3 -13
- package/dist/esm/search/_searchGroups.js.map +1 -1
- package/dist/esm/search/utils.js +1 -1
- package/dist/esm/urls/getHubApiFromPortalUrl.js +21 -0
- package/dist/esm/urls/getHubApiFromPortalUrl.js.map +1 -0
- package/dist/esm/urls/getPortalBaseFromOrgUrl.js +25 -0
- package/dist/esm/urls/getPortalBaseFromOrgUrl.js.map +1 -0
- package/dist/esm/urls/index.js +2 -0
- package/dist/esm/urls/index.js.map +1 -1
- package/dist/esm/utils/dasherize.js +25 -0
- package/dist/esm/utils/dasherize.js.map +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/node/ArcGISContext.js +203 -121
- package/dist/node/ArcGISContext.js.map +1 -1
- package/dist/node/ArcGISContextManager.js +175 -0
- package/dist/node/ArcGISContextManager.js.map +1 -0
- package/dist/node/Hub.js +74 -0
- package/dist/node/Hub.js.map +1 -0
- package/dist/node/HubError.js +37 -0
- package/dist/node/HubError.js.map +1 -0
- package/dist/node/collections.js +24 -1
- package/dist/node/collections.js.map +1 -1
- package/dist/node/content/_internal.js.map +1 -1
- package/dist/node/content/index.js +25 -17
- package/dist/node/content/index.js.map +1 -1
- package/dist/node/core/helpers/PropertyMapper.js +101 -0
- package/dist/node/core/helpers/PropertyMapper.js.map +1 -0
- package/dist/node/core/index.js +6 -0
- package/dist/node/core/index.js.map +1 -0
- package/dist/node/core/traits/WithBannerImage.js +3 -0
- package/dist/node/core/traits/WithBannerImage.js.map +1 -0
- package/dist/node/core/traits/WithLayout.js +3 -0
- package/dist/node/core/traits/WithLayout.js.map +1 -0
- package/dist/node/core/traits/WithSlug.js +3 -0
- package/dist/node/core/traits/WithSlug.js.map +1 -0
- package/dist/node/core/traits/index.js +7 -0
- package/dist/node/core/traits/index.js.map +1 -0
- package/dist/node/core/types/IContentEnrichments.js +3 -0
- package/dist/node/core/types/IContentEnrichments.js.map +1 -0
- package/dist/node/core/types/IHubContent.js +3 -0
- package/dist/node/core/types/IHubContent.js.map +1 -0
- package/dist/node/core/types/IHubEntityBase.js +3 -0
- package/dist/node/core/types/IHubEntityBase.js.map +1 -0
- package/dist/node/core/types/IHubEntityManager.js +3 -0
- package/dist/node/core/types/IHubEntityManager.js.map +1 -0
- package/dist/node/core/types/IHubEvent.js +3 -0
- package/dist/node/core/types/IHubEvent.js.map +1 -0
- package/dist/node/core/types/IHubImage.js +3 -0
- package/dist/node/core/types/IHubImage.js.map +1 -0
- package/dist/node/core/types/IHubInitiative.js +3 -0
- package/dist/node/core/types/IHubInitiative.js.map +1 -0
- package/dist/node/core/types/IHubItemEntity.js +3 -0
- package/dist/node/core/types/IHubItemEntity.js.map +1 -0
- package/dist/node/core/types/IHubLayout.js +3 -0
- package/dist/node/core/types/IHubLayout.js.map +1 -0
- package/dist/node/core/types/IHubPage.js +3 -0
- package/dist/node/core/types/IHubPage.js.map +1 -0
- package/dist/node/core/types/IHubProject.js +3 -0
- package/dist/node/core/types/IHubProject.js.map +1 -0
- package/dist/node/core/types/IHubSite.js +3 -0
- package/dist/node/core/types/IHubSite.js.map +1 -0
- package/dist/node/core/types/IHubTimeline.js +3 -0
- package/dist/node/core/types/IHubTimeline.js.map +1 -0
- package/dist/node/core/types/IItemEnrichments.js +3 -0
- package/dist/node/core/types/IItemEnrichments.js.map +1 -0
- package/dist/node/core/types/index.js +18 -0
- package/dist/node/core/types/index.js.map +1 -0
- package/dist/node/index.js +12 -5
- package/dist/node/index.js.map +1 -1
- package/dist/node/items/fail-safe-update.js +3 -3
- package/dist/node/items/fail-safe-update.js.map +1 -1
- package/dist/node/items/get-model-from-options.js +3 -3
- package/dist/node/items/get-model-from-options.js.map +1 -1
- package/dist/node/items/index.js +2 -3
- package/dist/node/items/index.js.map +1 -1
- package/dist/node/items/slugs.js +99 -0
- package/dist/node/items/slugs.js.map +1 -0
- package/dist/node/models/index.js +106 -0
- package/dist/node/models/index.js.map +1 -0
- package/dist/node/{items/serialize-model.js → models/serializeModel.js} +1 -1
- package/dist/node/models/serializeModel.js.map +1 -0
- package/dist/node/projects/HubProjectManager.js +119 -0
- package/dist/node/projects/HubProjectManager.js.map +1 -0
- package/dist/node/projects/HubProjects.js +201 -0
- package/dist/node/projects/HubProjects.js.map +1 -0
- package/dist/node/projects/index.js +6 -0
- package/dist/node/projects/index.js.map +1 -0
- package/dist/node/search/_searchContent.js +17 -6
- package/dist/node/search/_searchContent.js.map +1 -1
- package/dist/node/search/_searchGroups.js +1 -11
- package/dist/node/search/_searchGroups.js.map +1 -1
- package/dist/node/search/utils.js +1 -1
- package/dist/node/urls/getHubApiFromPortalUrl.js +25 -0
- package/dist/node/urls/getHubApiFromPortalUrl.js.map +1 -0
- package/dist/node/urls/getPortalBaseFromOrgUrl.js +29 -0
- package/dist/node/urls/getPortalBaseFromOrgUrl.js.map +1 -0
- package/dist/node/urls/index.js +2 -0
- package/dist/node/urls/index.js.map +1 -1
- package/dist/node/utils/dasherize.js +29 -0
- package/dist/node/utils/dasherize.js.map +1 -0
- package/dist/node/utils/index.js +1 -0
- package/dist/node/utils/index.js.map +1 -1
- package/dist/types/ArcGISContext.d.ts +280 -58
- package/dist/types/ArcGISContextManager.d.ts +130 -0
- package/dist/types/Hub.d.ts +72 -0
- package/dist/types/HubError.d.ts +17 -0
- package/dist/types/collections.d.ts +12 -0
- package/dist/types/content/_internal.d.ts +57 -38
- package/dist/types/content/index.d.ts +8 -8
- package/dist/types/core/helpers/PropertyMapper.d.ts +69 -0
- package/dist/types/core/index.d.ts +2 -0
- package/dist/types/core/traits/WithBannerImage.d.ts +30 -0
- package/dist/types/core/traits/WithLayout.d.ts +54 -0
- package/dist/types/core/traits/WithSlug.d.ts +15 -0
- package/dist/types/core/traits/index.d.ts +3 -0
- package/dist/types/core/types/IContentEnrichments.d.ts +10 -0
- package/dist/types/core/types/IHubContent.d.ts +77 -0
- package/dist/types/core/types/IHubEntityBase.d.ts +41 -0
- package/dist/types/core/types/IHubEntityManager.d.ts +33 -0
- package/dist/types/core/types/IHubEvent.d.ts +10 -0
- package/dist/types/core/types/IHubImage.d.ts +25 -0
- package/dist/types/core/types/IHubInitiative.d.ts +8 -0
- package/dist/types/core/types/IHubItemEntity.d.ts +42 -0
- package/dist/types/core/types/IHubLayout.d.ts +20 -0
- package/dist/types/core/types/IHubPage.d.ts +8 -0
- package/dist/types/core/types/IHubProject.d.ts +15 -0
- package/dist/types/core/types/IHubSite.d.ts +11 -0
- package/dist/types/core/types/IHubTimeline.d.ts +41 -0
- package/dist/types/core/types/IItemEnrichments.d.ts +23 -0
- package/dist/types/core/types/index.d.ts +14 -0
- package/dist/types/index.d.ts +11 -5
- package/dist/types/items/index.d.ts +2 -3
- package/dist/types/items/slugs.d.ts +43 -0
- package/dist/types/models/index.d.ts +42 -0
- package/dist/types/{items/serialize-model.d.ts → models/serializeModel.d.ts} +0 -0
- package/dist/types/projects/HubProjectManager.d.ts +81 -0
- package/dist/types/projects/HubProjects.d.ts +31 -0
- package/dist/types/projects/index.d.ts +2 -0
- package/dist/types/search/utils.d.ts +1 -1
- package/dist/types/types.d.ts +2 -92
- package/dist/types/urls/getHubApiFromPortalUrl.d.ts +8 -0
- package/dist/types/urls/getPortalBaseFromOrgUrl.d.ts +9 -0
- package/dist/types/urls/index.d.ts +2 -0
- package/dist/types/utils/dasherize.d.ts +17 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/umd/common.umd.js +4632 -3668
- 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 +1 -1
- package/dist/es2017/ArcGISContextState.js +0 -203
- package/dist/es2017/ArcGISContextState.js.map +0 -1
- package/dist/es2017/items/get-model.js +0 -19
- package/dist/es2017/items/get-model.js.map +0 -1
- package/dist/es2017/items/serialize-model.js.map +0 -1
- package/dist/esm/ArcGISContextState.js +0 -285
- package/dist/esm/ArcGISContextState.js.map +0 -1
- package/dist/esm/items/get-model.js +0 -19
- package/dist/esm/items/get-model.js.map +0 -1
- package/dist/esm/items/serialize-model.js.map +0 -1
- package/dist/node/ArcGISContextState.js +0 -207
- package/dist/node/ArcGISContextState.js.map +0 -1
- package/dist/node/items/get-model.js +0 -23
- package/dist/node/items/get-model.js.map +0 -1
- package/dist/node/items/serialize-model.js.map +0 -1
- package/dist/types/ArcGISContextState.d.ts +0 -129
- package/dist/types/items/get-model.d.ts +0 -8
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { cloneObject, deepSet, getProp } from "../..";
|
|
2
|
+
/**
|
|
3
|
+
* Manage forward and backward property mappings to
|
|
4
|
+
* streamline conversion between the Hub entities, and
|
|
5
|
+
* the backing IModel
|
|
6
|
+
*/
|
|
7
|
+
var PropertyMapper = /** @class */ (function () {
|
|
8
|
+
/**
|
|
9
|
+
* Pass in the mappings between the Entity and
|
|
10
|
+
* it's backing structure (model or otherwise)
|
|
11
|
+
* @param mappings
|
|
12
|
+
*/
|
|
13
|
+
function PropertyMapper(mappings) {
|
|
14
|
+
this.mappings = mappings;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Map properties from a model on to the entity object.
|
|
18
|
+
*
|
|
19
|
+
* Used when constructing an entity can from a fetched model,
|
|
20
|
+
* in which case the entity should be an empty object (`{}`).
|
|
21
|
+
*
|
|
22
|
+
* Can also be used to apply changes to an entity from a model,
|
|
23
|
+
* in which case an existing entity can be passed in.
|
|
24
|
+
* @param model
|
|
25
|
+
* @param object
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
PropertyMapper.prototype.modelToObject = function (model, object) {
|
|
29
|
+
return mapModelToObject(model, object, this.mappings);
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Map properties from an entity object onto a model.
|
|
33
|
+
*
|
|
34
|
+
* Typically the model will already exist, and this
|
|
35
|
+
* method is used to transfer changes to the model
|
|
36
|
+
* prior to storage.
|
|
37
|
+
* @param object
|
|
38
|
+
* @param model
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
PropertyMapper.prototype.objectToModel = function (object, model) {
|
|
42
|
+
return mapObjectToModel(object, model, this.mappings);
|
|
43
|
+
};
|
|
44
|
+
return PropertyMapper;
|
|
45
|
+
}());
|
|
46
|
+
export { PropertyMapper };
|
|
47
|
+
/**
|
|
48
|
+
* Generic function to apply properties from an Object
|
|
49
|
+
* (i.e. IHubProject) onto a Model that can be persisted to an Item
|
|
50
|
+
* @param object
|
|
51
|
+
* @param model
|
|
52
|
+
* @param mappings
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export function mapObjectToModel(object, model, mappings) {
|
|
56
|
+
return mapProps(object, "objectKey", model, "modelKey", mappings);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Generic function to apply properties from a Model
|
|
60
|
+
* onto an Object (i.e. IHubProject etc)
|
|
61
|
+
* @param model
|
|
62
|
+
* @param object
|
|
63
|
+
* @param mappings
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
export function mapModelToObject(model, object, mappings) {
|
|
67
|
+
return mapProps(model, "modelKey", object, "objectKey", mappings);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Internal function to map between objects
|
|
71
|
+
* @param source
|
|
72
|
+
* @param sourceKey
|
|
73
|
+
* @param target
|
|
74
|
+
* @param targetKey
|
|
75
|
+
* @param mappings
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
function mapProps(source, sourceKey, target, targetKey, mappings) {
|
|
79
|
+
// clone the target
|
|
80
|
+
var clone = cloneObject(target);
|
|
81
|
+
// walk the property map array
|
|
82
|
+
mappings.forEach(function (entry) {
|
|
83
|
+
// Verbose b/c typescript hates the use of property indexing with generics
|
|
84
|
+
// i.e. entry<T>[sourceKey] make typescript angry
|
|
85
|
+
var sourcePath = getProp(entry, sourceKey);
|
|
86
|
+
var targetPath = getProp(entry, targetKey);
|
|
87
|
+
// get the value from the source
|
|
88
|
+
var sourceVal = getProp(source, sourcePath);
|
|
89
|
+
// if it's not null or undefined
|
|
90
|
+
if (sourceVal !== null && sourceVal !== undefined) {
|
|
91
|
+
// set it
|
|
92
|
+
deepSet(clone, targetPath, sourceVal);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return clone;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=PropertyMapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyMapper.js","sourceRoot":"","sources":["../../../../src/core/helpers/PropertyMapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAU,MAAM,OAAO,CAAC;AAE9D;;;;GAIG;AACH;IAEE;;;;OAIG;IACH,wBAAY,QAAwB;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IACD;;;;;;;;;;;OAWG;IACH,sCAAa,GAAb,UAAc,KAAa,EAAE,MAAS;QACpC,OAAO,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;IAED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AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=WithBannerImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithBannerImage.js","sourceRoot":"","sources":["../../../../src/core/traits/WithBannerImage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=WithLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithLayout.js","sourceRoot":"","sources":["../../../../src/core/traits/WithLayout.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=WithSlug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithSlug.js","sourceRoot":"","sources":["../../../../src/core/traits/WithSlug.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/traits/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IContentEnrichments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IContentEnrichments.js","sourceRoot":"","sources":["../../../../src/core/types/IContentEnrichments.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubContent.js","sourceRoot":"","sources":["../../../../src/core/types/IHubContent.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubEntityBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubEntityBase.js","sourceRoot":"","sources":["../../../../src/core/types/IHubEntityBase.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubEntityManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubEntityManager.js","sourceRoot":"","sources":["../../../../src/core/types/IHubEntityManager.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubEvent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubEvent.js","sourceRoot":"","sources":["../../../../src/core/types/IHubEvent.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubImage.js","sourceRoot":"","sources":["../../../../src/core/types/IHubImage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubInitiative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubInitiative.js","sourceRoot":"","sources":["../../../../src/core/types/IHubInitiative.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubItemEntity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubItemEntity.js","sourceRoot":"","sources":["../../../../src/core/types/IHubItemEntity.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubLayout.js","sourceRoot":"","sources":["../../../../src/core/types/IHubLayout.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubPage.js","sourceRoot":"","sources":["../../../../src/core/types/IHubPage.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubProject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubProject.js","sourceRoot":"","sources":["../../../../src/core/types/IHubProject.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubSite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubSite.js","sourceRoot":"","sources":["../../../../src/core/types/IHubSite.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IHubTimeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHubTimeline.js","sourceRoot":"","sources":["../../../../src/core/types/IHubTimeline.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=IItemEnrichments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IItemEnrichments.js","sourceRoot":"","sources":["../../../../src/core/types/IItemEnrichments.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./IContentEnrichments";
|
|
2
|
+
export * from "./IItemEnrichments";
|
|
3
|
+
export * from "./IHubContent";
|
|
4
|
+
export * from "./IHubEntityBase";
|
|
5
|
+
export * from "./IHubItemEntity";
|
|
6
|
+
export * from "./IHubEntityManager";
|
|
7
|
+
export * from "./IHubEvent";
|
|
8
|
+
export * from "./IHubImage";
|
|
9
|
+
export * from "./IHubInitiative";
|
|
10
|
+
export * from "./IHubLayout";
|
|
11
|
+
export * from "./IHubPage";
|
|
12
|
+
export * from "./IHubProject";
|
|
13
|
+
export * from "./IHubSite";
|
|
14
|
+
export * from "./IHubTimeline";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,28 +2,34 @@
|
|
|
2
2
|
* Apache-2.0 */
|
|
3
3
|
export * from "./access";
|
|
4
4
|
export * from "./api";
|
|
5
|
+
export * from "./ArcGISContext";
|
|
6
|
+
export * from "./ArcGISContextManager";
|
|
5
7
|
export * from "./auth";
|
|
6
8
|
export * from "./categories";
|
|
7
9
|
export * from "./content";
|
|
10
|
+
export * from "./core";
|
|
8
11
|
export * from "./downloads";
|
|
9
12
|
export * from "./extent";
|
|
10
13
|
export * from "./groups";
|
|
14
|
+
export * from "./i18n";
|
|
11
15
|
export * from "./items";
|
|
16
|
+
export * from "./models";
|
|
12
17
|
export * from "./objects";
|
|
18
|
+
export * from "./projects";
|
|
19
|
+
export * from "./request";
|
|
13
20
|
export * from "./resources";
|
|
14
21
|
export * from "./search";
|
|
15
22
|
export * from "./sites";
|
|
23
|
+
export * from "./surveys";
|
|
16
24
|
export * from "./types";
|
|
17
25
|
export * from "./urls";
|
|
18
26
|
export * from "./util";
|
|
19
27
|
export * from "./utils";
|
|
20
|
-
export * from "./
|
|
21
|
-
export * from "./request";
|
|
22
|
-
export * from "./surveys";
|
|
23
|
-
export * from "./ArcGISContext";
|
|
28
|
+
export * from "./Hub";
|
|
24
29
|
import OperationStack from "./OperationStack";
|
|
25
30
|
import OperationError from "./OperationError";
|
|
31
|
+
import HubError from "./HubError";
|
|
26
32
|
// Re-exports
|
|
27
|
-
export { OperationStack, OperationError };
|
|
33
|
+
export { OperationStack, OperationError, HubError };
|
|
28
34
|
export { btoa, atob } from "abab";
|
|
29
35
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;gBACgB;AAEhB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AAEtB,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { updateItem } from "@esri/arcgis-rest-portal";
|
|
2
|
-
import { serializeModel } from "
|
|
2
|
+
import { serializeModel } from "../models/serializeModel";
|
|
3
3
|
import { failSafe } from "../utils";
|
|
4
4
|
/**
|
|
5
5
|
* Update a model's item, wrapped in a failSafe so this will not blow up if
|
|
@@ -11,7 +11,7 @@ import { failSafe } from "../utils";
|
|
|
11
11
|
export function failSafeUpdate(model, requestOptions) {
|
|
12
12
|
var failSafedUpdate = failSafe(updateItem, {
|
|
13
13
|
id: model.item.id,
|
|
14
|
-
success: true
|
|
14
|
+
success: true,
|
|
15
15
|
});
|
|
16
16
|
var opts = Object.assign({ item: serializeModel(model) }, requestOptions);
|
|
17
17
|
return failSafedUpdate(opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fail-safe-update.js","sourceRoot":"","sources":["../../../src/items/fail-safe-update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAsB,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"fail-safe-update.js","sourceRoot":"","sources":["../../../src/items/fail-safe-update.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAsB,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAa,EACb,cAAmC;IAEnC,IAAM,eAAe,GAAG,QAAQ,CAAC,UAAU,EAAE;QAC3C,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE;QACjB,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;IACH,IAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CACxB,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,EAAE,EAC/B,cAAc,CACO,CAAC;IACxB,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { failSafe } from "../utils";
|
|
2
|
-
import { getModel } from "
|
|
2
|
+
import { getModel } from "../models";
|
|
3
3
|
/**
|
|
4
4
|
* To streamline passing of either a model id or the model itself, we use this function
|
|
5
5
|
* to extract the model or fetch it, and return it. It uses `failSafe` and if the item
|
|
@@ -19,7 +19,7 @@ export function getModelFromOptions(modelType, options) {
|
|
|
19
19
|
if (options[idProp]) {
|
|
20
20
|
var failSafeModel = failSafe(getModel, {
|
|
21
21
|
item: { id: options[idProp] },
|
|
22
|
-
isMissing: true
|
|
22
|
+
isMissing: true,
|
|
23
23
|
});
|
|
24
24
|
return failSafeModel(options[idProp], options);
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-model-from-options.js","sourceRoot":"","sources":["../../../src/items/get-model-from-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"get-model-from-options.js","sourceRoot":"","sources":["../../../src/items/get-model-from-options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAGrC;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,OAA4B;IAE5B,IAAM,SAAS,GAAM,SAAS,UAAO,CAAC;IACtC,IAAM,MAAM,GAAM,SAAS,OAAI,CAAC;IAChC,+CAA+C;IAC/C,IAAI,OAAO,CAAC,SAAS,CAAC,EAAE;QACtB,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC;KAC5C;SAAM;QACL,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;YACnB,IAAM,aAAa,GAAG,QAAQ,CAAC,QAAQ,EAAE;gBACvC,IAAI,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE;gBAC7B,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YACH,OAAO,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;SAChD;aAAM;YACL,MAAM,IAAI,KAAK,CACb,4CAA0C,SAAS,aAAQ,MAAM,eAAY,CAC9E,CAAC;SACH;KACF;AACH,CAAC"}
|
package/dist/esm/items/index.js
CHANGED
|
@@ -2,13 +2,10 @@ export * from "./_unprotect-and-remove-item";
|
|
|
2
2
|
export * from "./apply-properties-to-items";
|
|
3
3
|
export * from "./delete-prop";
|
|
4
4
|
export * from "./fail-safe-update";
|
|
5
|
-
export * from "./get-model";
|
|
6
5
|
export * from "./get-model-from-options";
|
|
7
6
|
export * from "./interpolate";
|
|
8
7
|
export * from "./interpolate-item-id";
|
|
9
|
-
export * from "./normalize-solution-template-item";
|
|
10
8
|
export * from "./replace-item-id";
|
|
11
|
-
export * from "./serialize-model";
|
|
12
9
|
export * from "./share-item-to-groups";
|
|
13
10
|
export * from "./unprotect-model";
|
|
14
11
|
export * from "./unshare-item-from-groups";
|
|
@@ -16,4 +13,6 @@ export * from "./does-item-exist-with-title";
|
|
|
16
13
|
export * from "./get-unique-item-title";
|
|
17
14
|
export * from "./fetch-all-pages";
|
|
18
15
|
export * from "./get-structured-license";
|
|
16
|
+
export * from "./slugs";
|
|
17
|
+
export * from "./normalize-solution-template-item";
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/items/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/items/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,SAAS,CAAC;AACxB,cAAc,oCAAoC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { searchItems } from "@esri/arcgis-rest-portal";
|
|
2
|
+
import { slugify } from "..";
|
|
3
|
+
// TODO: work out how to unify content slug fns
|
|
4
|
+
// https: github.com/Esri/hub.js/blob/master/packages/common/src/content/index.ts#L301-L348
|
|
5
|
+
/**
|
|
6
|
+
* Create a slug, namespaced to an org
|
|
7
|
+
* Typically used to lookup items by a human readable name in urls
|
|
8
|
+
*
|
|
9
|
+
* @param title
|
|
10
|
+
* @param orgKey
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export function constructSlug(title, orgKey) {
|
|
14
|
+
return orgKey.toLowerCase() + "-" + slugify(title);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Adds/Updates the slug typekeyword
|
|
18
|
+
* Returns a new array of keywords
|
|
19
|
+
* @param typeKeywords
|
|
20
|
+
* @param slug
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export function setSlugKeyword(typeKeywords, slug) {
|
|
24
|
+
// remove slug entry from array
|
|
25
|
+
var removed = typeKeywords.filter(function (entry) {
|
|
26
|
+
return !entry.startsWith("slug|");
|
|
27
|
+
});
|
|
28
|
+
// now add it
|
|
29
|
+
removed.push("slug|" + slug);
|
|
30
|
+
return removed;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Get an item by searching for items with a typeKeyword like `slug|{slug-value}`
|
|
34
|
+
*
|
|
35
|
+
* For example, if you pass a slug `"snow-map"` into this function, it will
|
|
36
|
+
* search for items with `slug|snow-map` in it's typeKeywords array,
|
|
37
|
+
*
|
|
38
|
+
* @param slug
|
|
39
|
+
* @param requestOptions
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
export function getItemBySlug(slug, requestOptions) {
|
|
43
|
+
var opts = {
|
|
44
|
+
q: "",
|
|
45
|
+
filter: "typekeywords:\"slug|" + slug + "\"",
|
|
46
|
+
authentication: requestOptions.authentication,
|
|
47
|
+
};
|
|
48
|
+
return searchItems(opts)
|
|
49
|
+
.then(function (response) {
|
|
50
|
+
if (response.results.length) {
|
|
51
|
+
return response.results[0];
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
})
|
|
57
|
+
.catch(function (e) {
|
|
58
|
+
throw Error("Error in getItemBySlug " + e);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Given a slug, search for items using that slug, incrementing the slug name until
|
|
63
|
+
* a unique value is found
|
|
64
|
+
*
|
|
65
|
+
* For example, if a slug of `"snow-map"` into this function and some item exists
|
|
66
|
+
* with that slug, it would return `"snow-map-1"`.
|
|
67
|
+
*
|
|
68
|
+
* @param slug
|
|
69
|
+
* @param requestOptions
|
|
70
|
+
* @param step
|
|
71
|
+
* @returns
|
|
72
|
+
*/
|
|
73
|
+
export function getUniqueSlug(slug, requestOptions, step) {
|
|
74
|
+
if (step === void 0) { step = 0; }
|
|
75
|
+
var combined = slug;
|
|
76
|
+
if (step) {
|
|
77
|
+
combined = slug + "-" + step;
|
|
78
|
+
}
|
|
79
|
+
return getItemBySlug(combined, requestOptions)
|
|
80
|
+
.then(function (result) {
|
|
81
|
+
if (result) {
|
|
82
|
+
step++;
|
|
83
|
+
return getUniqueSlug(slug, requestOptions, step);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return combined;
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
.catch(function (e) {
|
|
90
|
+
throw Error("Error in getUniqueSlug " + e);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=slugs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slugs.js","sourceRoot":"","sources":["../../../src/items/slugs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAGvD,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,+CAA+C;AAC/C,2FAA2F;AAE3F;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAc;IACzD,OAAU,MAAM,CAAC,WAAW,EAAE,SAAI,OAAO,CAAC,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;YACV,IAAI,EAAE,CAAC;YACP,OAAO,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;SAClD;aAAM;YACL,OAAO,QAAQ,CAAC;SACjB;IACH,CAAC,CAAC;SACD,KAAK,CAAC,UAAC,CAAC;QACP,MAAM,KAAK,CAAC,4BAA0B,CAAG,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
export * from "./serializeModel";
|
|
3
|
+
import { createItem, getItem, getItemData, updateItem, } from "@esri/arcgis-rest-portal";
|
|
4
|
+
import { cloneObject, getItemBySlug } from "..";
|
|
5
|
+
/**
|
|
6
|
+
* Gets the full item/data model for an item id
|
|
7
|
+
* @param {string} id
|
|
8
|
+
* @param {Object} requestOptions
|
|
9
|
+
*/
|
|
10
|
+
export function getModel(id, requestOptions) {
|
|
11
|
+
return Promise.all([
|
|
12
|
+
getItem(id, requestOptions),
|
|
13
|
+
getItemData(id, requestOptions),
|
|
14
|
+
]).then(function (result) {
|
|
15
|
+
// shape this into a model
|
|
16
|
+
return {
|
|
17
|
+
item: result[0],
|
|
18
|
+
data: result[1],
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get a model by it's slug
|
|
24
|
+
*
|
|
25
|
+
* This uses the [Filter](https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm) option of the
|
|
26
|
+
* to search for an item that has a typekeyword of `slug|{slug-value}`
|
|
27
|
+
*
|
|
28
|
+
* This is useful for applications that want to use human-readable urls instead
|
|
29
|
+
* of using item ids.
|
|
30
|
+
*
|
|
31
|
+
* @param slug
|
|
32
|
+
* @param requestOptions
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
export function getModelBySlug(slug, requestOptions) {
|
|
36
|
+
return getItemBySlug(slug, requestOptions)
|
|
37
|
+
.then(function (item) {
|
|
38
|
+
var prms = [Promise.resolve(item)];
|
|
39
|
+
if (item) {
|
|
40
|
+
prms.push(getItemData(item.id, requestOptions));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
prms.push(Promise.resolve(null));
|
|
44
|
+
}
|
|
45
|
+
return Promise.all(prms);
|
|
46
|
+
})
|
|
47
|
+
.then(function (result) {
|
|
48
|
+
if (result[0]) {
|
|
49
|
+
return {
|
|
50
|
+
item: result[0],
|
|
51
|
+
data: result[1],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create an item to back and IModel.
|
|
61
|
+
*
|
|
62
|
+
* @param {IModel}
|
|
63
|
+
* @param {IRequestOptions} requestOptions
|
|
64
|
+
* @returns {Promise<IModel>}
|
|
65
|
+
*/
|
|
66
|
+
export function createModel(model, requestOptions) {
|
|
67
|
+
var clone = cloneObject(model);
|
|
68
|
+
var item = cloneObject(model.item);
|
|
69
|
+
item.data = cloneObject(model.data);
|
|
70
|
+
var opts = __assign({ item: item }, requestOptions);
|
|
71
|
+
return createItem(opts).then(function (response) {
|
|
72
|
+
clone.item.id = response.id;
|
|
73
|
+
clone.item.created = new Date().getTime();
|
|
74
|
+
clone.item.modified = clone.item.created;
|
|
75
|
+
return clone;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Update an IModel. Generic function that will be used across all
|
|
80
|
+
* type-specific update functions
|
|
81
|
+
*
|
|
82
|
+
* @export
|
|
83
|
+
* @param {IModel} "model" object (i.e. `{item:{...}, data:{...}}`)
|
|
84
|
+
* @param {IRequestOptions} requestOptions
|
|
85
|
+
* @returns {Promise<IModel>}
|
|
86
|
+
*/
|
|
87
|
+
export function updateModel(model, requestOptions) {
|
|
88
|
+
var clone = cloneObject(model);
|
|
89
|
+
var item = cloneObject(model.item);
|
|
90
|
+
item.data = cloneObject(model.data);
|
|
91
|
+
var opts = __assign({ item: item }, requestOptions);
|
|
92
|
+
return updateItem(opts).then(function () {
|
|
93
|
+
// update the modified prop
|
|
94
|
+
// this won't be exact, but it will be very close
|
|
95
|
+
clone.item.modified = new Date().getTime();
|
|
96
|
+
return clone;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":";AAAA,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EACL,UAAU,EACV,OAAO,EACP,WAAW,EAKX,UAAU,GACX,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,WAAW,EAAU,aAAa,EAAE,MAAM,IAAI,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,EAAU,EACV,cAA+B;IAE/B,OAAO,OAAO,CAAC,GAAG,CAAC;QACjB,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC;QAC3B,WAAW,CAAC,EAAE,EAAE,cAAc,CAAC;KAChC,CAAC,CAAC,IAAI,CAAC,UAAC,MAAoB;QAC3B,0BAA0B;QAC1B,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;YACf,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;SAChB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAY,EACZ,cAA+B;IAE/B,OAAO,aAAa,CAAC,IAAI,EAAE,cAAc,CAAC;SACvC,IAAI,CAAC,UAAC,IAAI;QACT,IAAM,IAAI,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,cAAc,CA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