@esri/hub-common 14.26.2 → 14.27.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/esm/core/EntityEditor.js +4 -0
- package/dist/esm/core/EntityEditor.js.map +1 -1
- package/dist/esm/core/fetchHubEntity.js +4 -0
- package/dist/esm/core/fetchHubEntity.js.map +1 -1
- package/dist/esm/core/getTypeFromEntity.js +3 -0
- package/dist/esm/core/getTypeFromEntity.js.map +1 -1
- package/dist/esm/core/schemas/internal/getEntityEditorSchemas.js +10 -0
- package/dist/esm/core/schemas/internal/getEntityEditorSchemas.js.map +1 -1
- package/dist/esm/core/schemas/types.js +2 -0
- package/dist/esm/core/schemas/types.js.map +1 -1
- package/dist/esm/core/types/HubEntityType.js +1 -0
- package/dist/esm/core/types/HubEntityType.js.map +1 -1
- package/dist/esm/core/types/IHubTemplate.js +1 -0
- package/dist/esm/core/types/IHubTemplate.js.map +1 -0
- package/dist/esm/core/types/index.js +1 -0
- package/dist/esm/core/types/index.js.map +1 -1
- package/dist/esm/core/updateHubEntity.js +4 -0
- package/dist/esm/core/updateHubEntity.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/permissions/HubPermissionPolicies.js +2 -0
- package/dist/esm/permissions/HubPermissionPolicies.js.map +1 -1
- package/dist/esm/permissions/types/Permission.js +2 -0
- package/dist/esm/permissions/types/Permission.js.map +1 -1
- package/dist/esm/search/_internal/portalSearchItems.js +4 -0
- package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
- package/dist/esm/templates/HubTemplate.js +178 -0
- package/dist/esm/templates/HubTemplate.js.map +1 -0
- package/dist/esm/templates/_internal/TemplateBusinessRules.js +82 -0
- package/dist/esm/templates/_internal/TemplateBusinessRules.js.map +1 -0
- package/dist/esm/templates/_internal/TemplateSchema.js +8 -0
- package/dist/esm/templates/_internal/TemplateSchema.js.map +1 -0
- package/dist/esm/templates/_internal/TemplateUiSchemaEdit.js +97 -0
- package/dist/esm/templates/_internal/TemplateUiSchemaEdit.js.map +1 -0
- package/dist/esm/templates/_internal/computeLinks.js +26 -0
- package/dist/esm/templates/_internal/computeLinks.js.map +1 -0
- package/dist/esm/templates/_internal/computeProps.js +36 -0
- package/dist/esm/templates/_internal/computeProps.js.map +1 -0
- package/dist/esm/templates/_internal/getPropertyMap.js +14 -0
- package/dist/esm/templates/_internal/getPropertyMap.js.map +1 -0
- package/dist/esm/templates/defaults.js +40 -0
- package/dist/esm/templates/defaults.js.map +1 -0
- package/dist/esm/templates/edit.js +76 -0
- package/dist/esm/templates/edit.js.map +1 -0
- package/dist/esm/templates/fetch.js +108 -0
- package/dist/esm/templates/fetch.js.map +1 -0
- package/dist/esm/templates/index.js +5 -0
- package/dist/esm/templates/index.js.map +1 -0
- package/dist/esm/templates/utils.js +37 -0
- package/dist/esm/templates/utils.js.map +1 -0
- package/dist/esm/templates/view.js +81 -0
- package/dist/esm/templates/view.js.map +1 -0
- package/dist/esm/urls/getCardModelUrl.js +11 -11
- package/dist/esm/urls/getCardModelUrl.js.map +1 -1
- package/dist/node/core/EntityEditor.js +4 -0
- package/dist/node/core/EntityEditor.js.map +1 -1
- package/dist/node/core/fetchHubEntity.js +6 -2
- package/dist/node/core/fetchHubEntity.js.map +1 -1
- package/dist/node/core/getTypeFromEntity.js +3 -0
- package/dist/node/core/getTypeFromEntity.js.map +1 -1
- package/dist/node/core/schemas/internal/getEntityEditorSchemas.js +10 -0
- package/dist/node/core/schemas/internal/getEntityEditorSchemas.js.map +1 -1
- package/dist/node/core/schemas/types.js +2 -0
- package/dist/node/core/schemas/types.js.map +1 -1
- package/dist/node/core/types/HubEntityType.js +1 -0
- package/dist/node/core/types/HubEntityType.js.map +1 -1
- package/dist/node/core/types/IHubTemplate.js +3 -0
- package/dist/node/core/types/IHubTemplate.js.map +1 -0
- package/dist/node/core/types/index.js +1 -0
- package/dist/node/core/types/index.js.map +1 -1
- package/dist/node/core/updateHubEntity.js +4 -0
- package/dist/node/core/updateHubEntity.js.map +1 -1
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/permissions/HubPermissionPolicies.js +2 -0
- package/dist/node/permissions/HubPermissionPolicies.js.map +1 -1
- package/dist/node/permissions/types/Permission.js +2 -0
- package/dist/node/permissions/types/Permission.js.map +1 -1
- package/dist/node/search/_internal/portalSearchItems.js +4 -0
- package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
- package/dist/node/templates/HubTemplate.js +182 -0
- package/dist/node/templates/HubTemplate.js.map +1 -0
- package/dist/node/templates/_internal/TemplateBusinessRules.js +85 -0
- package/dist/node/templates/_internal/TemplateBusinessRules.js.map +1 -0
- package/dist/node/templates/_internal/TemplateSchema.js +11 -0
- package/dist/node/templates/_internal/TemplateSchema.js.map +1 -0
- package/dist/node/templates/_internal/TemplateUiSchemaEdit.js +100 -0
- package/dist/node/templates/_internal/TemplateUiSchemaEdit.js.map +1 -0
- package/dist/node/templates/_internal/computeLinks.js +30 -0
- package/dist/node/templates/_internal/computeLinks.js.map +1 -0
- package/dist/node/templates/_internal/computeProps.js +40 -0
- package/dist/node/templates/_internal/computeProps.js.map +1 -0
- package/dist/node/templates/_internal/getPropertyMap.js +18 -0
- package/dist/node/templates/_internal/getPropertyMap.js.map +1 -0
- package/dist/node/templates/defaults.js +43 -0
- package/dist/node/templates/defaults.js.map +1 -0
- package/dist/node/templates/edit.js +83 -0
- package/dist/node/templates/edit.js.map +1 -0
- package/dist/node/templates/fetch.js +114 -0
- package/dist/node/templates/fetch.js.map +1 -0
- package/dist/node/templates/index.js +8 -0
- package/dist/node/templates/index.js.map +1 -0
- package/dist/node/templates/utils.js +40 -0
- package/dist/node/templates/utils.js.map +1 -0
- package/dist/node/templates/view.js +84 -0
- package/dist/node/templates/view.js.map +1 -0
- package/dist/node/urls/getCardModelUrl.js +11 -11
- package/dist/node/urls/getCardModelUrl.js.map +1 -1
- package/dist/types/core/schemas/types.d.ts +1 -1
- package/dist/types/core/types/HubEntity.d.ts +2 -1
- package/dist/types/core/types/HubEntityType.d.ts +1 -1
- package/dist/types/core/types/IHubTemplate.d.ts +13 -0
- package/dist/types/core/types/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/permissions/types/Permission.d.ts +2 -1
- package/dist/types/templates/HubTemplate.d.ts +79 -0
- package/dist/types/templates/_internal/TemplateBusinessRules.d.ts +17 -0
- package/dist/types/templates/_internal/TemplateSchema.d.ts +4 -0
- package/dist/types/templates/_internal/TemplateUiSchemaEdit.d.ts +15 -0
- package/dist/types/templates/_internal/computeLinks.d.ts +11 -0
- package/dist/types/templates/_internal/computeProps.d.ts +13 -0
- package/dist/types/templates/_internal/getPropertyMap.d.ts +8 -0
- package/dist/types/templates/defaults.d.ts +14 -0
- package/dist/types/templates/edit.d.ts +37 -0
- package/dist/types/templates/fetch.d.ts +28 -0
- package/dist/types/templates/index.d.ts +4 -0
- package/dist/types/templates/utils.d.ts +13 -0
- package/dist/types/templates/view.d.ts +19 -0
- package/dist/types/urls/getCardModelUrl.d.ts +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateSchema.js","sourceRoot":"","sources":["../../../../src/templates/_internal/TemplateSchema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,+CAA+C,CAAC;AAIpF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,mBAAmB,CAAU,CAAC;AAElE,MAAM,CAAC,MAAM,cAAc,GAAyB,gCAC/C,mBAAmB,KACtB,UAAU,kCACL,mBAAmB,CAAC,UAAU,KACjC,UAAU,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,EAAE;YACpB,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;SACxB,MAEoB,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { UiSchemaMessageTypes } from "../../core/schemas/types";
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
* constructs the complete edit uiSchema for Hub Templates.
|
|
5
|
+
* This defines how the schema properties should be rendered
|
|
6
|
+
* in the template editing experience.
|
|
7
|
+
*
|
|
8
|
+
* @param i18nScope
|
|
9
|
+
* @param entity
|
|
10
|
+
* @param context
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export const buildUiSchema = async (i18nScope, entity, context) => {
|
|
14
|
+
return {
|
|
15
|
+
type: "Layout",
|
|
16
|
+
elements: [
|
|
17
|
+
{
|
|
18
|
+
type: "Section",
|
|
19
|
+
labelKey: `${i18nScope}.sections.basicInfo.label`,
|
|
20
|
+
elements: [
|
|
21
|
+
{
|
|
22
|
+
type: "Control",
|
|
23
|
+
scope: "/properties/name",
|
|
24
|
+
labelKey: `${i18nScope}.fields.name.label`,
|
|
25
|
+
options: {
|
|
26
|
+
messages: [
|
|
27
|
+
{
|
|
28
|
+
type: UiSchemaMessageTypes.error,
|
|
29
|
+
keyword: "required",
|
|
30
|
+
icon: true,
|
|
31
|
+
labelKey: `${i18nScope}.fields.name.requiredError`,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: "Control",
|
|
38
|
+
scope: "/properties/previewUrl",
|
|
39
|
+
labelKey: `${i18nScope}.fields.previewUrl.label`,
|
|
40
|
+
options: {
|
|
41
|
+
helperText: {
|
|
42
|
+
labelKey: `${i18nScope}.fields.previewUrl.helperText`,
|
|
43
|
+
},
|
|
44
|
+
messages: [
|
|
45
|
+
{
|
|
46
|
+
type: "ERROR",
|
|
47
|
+
keyword: "if",
|
|
48
|
+
hidden: true,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
labelKey: `${i18nScope}.fields.summary.label`,
|
|
55
|
+
scope: "/properties/summary",
|
|
56
|
+
type: "Control",
|
|
57
|
+
options: {
|
|
58
|
+
control: "hub-field-input-input",
|
|
59
|
+
type: "textarea",
|
|
60
|
+
helperText: {
|
|
61
|
+
labelKey: `${i18nScope}.fields.summary.helperText`,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
labelKey: `${i18nScope}.fields.description.label`,
|
|
67
|
+
scope: "/properties/description",
|
|
68
|
+
type: "Control",
|
|
69
|
+
options: {
|
|
70
|
+
control: "hub-field-input-input",
|
|
71
|
+
type: "textarea",
|
|
72
|
+
helperText: {
|
|
73
|
+
labelKey: `${i18nScope}.fields.description.helperText`,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
labelKey: `${i18nScope}.fields.thumbnail.label`,
|
|
79
|
+
scope: "/properties/_thumbnail",
|
|
80
|
+
type: "Control",
|
|
81
|
+
options: {
|
|
82
|
+
control: "hub-field-input-image-picker",
|
|
83
|
+
imgSrc: entity.thumbnailUrl,
|
|
84
|
+
maxWidth: 727,
|
|
85
|
+
maxHeight: 484,
|
|
86
|
+
aspectRatio: 1.5,
|
|
87
|
+
helperText: {
|
|
88
|
+
labelKey: `${i18nScope}.fields.thumbnail.helperText`,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=TemplateUiSchemaEdit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateUiSchemaEdit.js","sourceRoot":"","sources":["../../../../src/templates/_internal/TemplateUiSchemaEdit.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAG3E;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAChC,SAAiB,EACjB,MAAoB,EACpB,O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AAgC;6BACvD;yBACF;qBACF;oBACD;wBACE,QAAQ,EAAE,GAAG,SAAS,yBAAyB;wBAC/C,KAAK,EAAE,wBAAwB;wBAC/B,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE;4BACP,OAAO,EAAE,8BAA8B;4BACvC,MAAM,EAAE,MAAM,CAAC,YAAY;4BAC3B,QAAQ,EAAE,GAAG;4BACb,SAAS,EAAE,GAAG;4BACd,WAAW,EAAE,GAAG;4BAChB,UAAU,EAAE;gCACV,QAAQ,EAAE,GAAG,SAAS,8BAA8B;6BACrD;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getItemHomeUrl } from "../../urls";
|
|
2
|
+
import { getItemIdentifier } from "../../items";
|
|
3
|
+
import { getHubRelativeUrl } from "../../content/_internal/internalContentUtils";
|
|
4
|
+
import { getRelativeWorkspaceUrl } from "../../core/getRelativeWorkspaceUrl";
|
|
5
|
+
import { getItemThumbnailUrl } from "../../resources/get-item-thumbnail-url";
|
|
6
|
+
/**
|
|
7
|
+
* Compute the links that get appended to a Hub Template
|
|
8
|
+
* search result and entity
|
|
9
|
+
*
|
|
10
|
+
* @param item
|
|
11
|
+
* @param requestOptions
|
|
12
|
+
*/
|
|
13
|
+
export function computeLinks(item, requestOptions) {
|
|
14
|
+
let token;
|
|
15
|
+
if (requestOptions.authentication) {
|
|
16
|
+
const session = requestOptions.authentication;
|
|
17
|
+
token = session.token;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
self: getItemHomeUrl(item.id, requestOptions),
|
|
21
|
+
siteRelative: getHubRelativeUrl(item.type, getItemIdentifier(item), item.typeKeywords),
|
|
22
|
+
workspaceRelative: getRelativeWorkspaceUrl(item.type, getItemIdentifier(item)),
|
|
23
|
+
thumbnail: getItemThumbnailUrl(item, requestOptions, token),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=computeLinks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeLinks.js","sourceRoot":"","sources":["../../../../src/templates/_internal/computeLinks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAW,EACX,cAA+B;IAE/B,IAAI,KAAa,CAAC;IAClB,IAAI,cAAc,CAAC,cAAc,EAAE;QACjC,MAAM,OAAO,GAAgB,cAAc,CAAC,cAA6B,CAAC;QAC1E,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;KACvB;IAED,OAAO;QACL,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,cAAc,CAAC;QAC7C,YAAY,EAAE,iBAAiB,CAC7B,IAAI,CAAC,IAAI,EACT,iBAAiB,CAAC,IAAI,CAAC,EACvB,IAAI,CAAC,YAAY,CAClB;QACD,iBAAiB,EAAE,uBAAuB,CACxC,IAAI,CAAC,IAAI,EACT,iBAAiB,CAAC,IAAI,CAAC,CACxB;QACD,SAAS,EAAE,mBAAmB,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC;KAC5D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isDiscussable } from "../../discussions/utils";
|
|
2
|
+
import { processEntityFeatures } from "../../permissions/_internal/processEntityFeatures";
|
|
3
|
+
import { TemplateDefaultFeatures } from "./TemplateBusinessRules";
|
|
4
|
+
import { computeLinks } from "./computeLinks";
|
|
5
|
+
import { getProp } from "../../objects";
|
|
6
|
+
import { getDeployedTemplateType } from "../utils";
|
|
7
|
+
/**
|
|
8
|
+
* @private
|
|
9
|
+
* Given a model and a template, set various computed
|
|
10
|
+
* properties on the template that can't be directly
|
|
11
|
+
* mapped from the model
|
|
12
|
+
* @param model
|
|
13
|
+
* @param template
|
|
14
|
+
* @param requestOptions
|
|
15
|
+
*/
|
|
16
|
+
export function computeProps(model, template, requestOptions) {
|
|
17
|
+
// 1. compute relevant template links
|
|
18
|
+
template.links = computeLinks(model.item, requestOptions);
|
|
19
|
+
// 2. append the template's thumbnail url at the top-level
|
|
20
|
+
template.thumbnailUrl = template.links.thumbnail;
|
|
21
|
+
// 3. compute relevant template dates
|
|
22
|
+
template.createdDate = new Date(model.item.created);
|
|
23
|
+
template.createdDateSource = "item.created";
|
|
24
|
+
template.updatedDate = new Date(model.item.modified);
|
|
25
|
+
template.updatedDateSource = "item.modified";
|
|
26
|
+
// 4. determine whether the template is discussable
|
|
27
|
+
template.isDiscussable = isDiscussable(template);
|
|
28
|
+
// 5. process features that can be disabled by the entity owner
|
|
29
|
+
template.features = processEntityFeatures(getProp(model, "data.settings.features") || {}, TemplateDefaultFeatures);
|
|
30
|
+
// 6. compute additional template-specific properties
|
|
31
|
+
template.isDeployed = (getProp(model, "item.typeKeywords") || []).includes("Deployed");
|
|
32
|
+
template.deployedType = getDeployedTemplateType(model.item);
|
|
33
|
+
// 7. cast b/c this takes a partial but returns a full template
|
|
34
|
+
return template;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=computeProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"computeProps.js","sourceRoot":"","sources":["../../../../src/templates/_internal/computeProps.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAE1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE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} from "../../core/_internal/getBasePropertyMap";
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
* Returns an Array of IPropertyMap objects that
|
|
5
|
+
* define the projection of properties from an
|
|
6
|
+
* IModel to an IHubTemplate
|
|
7
|
+
*/
|
|
8
|
+
export function getPropertyMap() {
|
|
9
|
+
const map = getBasePropertyMap();
|
|
10
|
+
// IHubTemplate specific mappings
|
|
11
|
+
map.push({ entityKey: "previewUrl", storeKey: "item.properties.previewUrl" });
|
|
12
|
+
return map;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=getPropertyMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPropertyMap.js","sourceRoot":"","sources":["../../../../src/templates/_internal/getPropertyMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAG7E;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,kBAAkB,EAAE,CAAC;IAEjC,iCAAiC;IACjC,GAAG,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,4BAA4B,EAAE,CAAC,CAAC;IAE9E,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TemplateDefaultFeatures } from "./_internal/TemplateBusinessRules";
|
|
2
|
+
/**
|
|
3
|
+
* NOTE: this file provides default values for new
|
|
4
|
+
* Hub Template creation; however, we have no immediate
|
|
5
|
+
* plans to allow template creation from the context of
|
|
6
|
+
* our application. Scaffolding these defaults for
|
|
7
|
+
* potential future implementation
|
|
8
|
+
*/
|
|
9
|
+
export const HUB_TEMPLATE_ITEM_TYPE = "Solution";
|
|
10
|
+
/** Default values for a new IHubTemplate */
|
|
11
|
+
export const DEFAULT_TEMPLATE = {
|
|
12
|
+
schemaVersion: 1,
|
|
13
|
+
catalog: { schemaVersion: 0 },
|
|
14
|
+
name: "",
|
|
15
|
+
tags: [],
|
|
16
|
+
typeKeywords: [HUB_TEMPLATE_ITEM_TYPE],
|
|
17
|
+
view: {},
|
|
18
|
+
permissions: [],
|
|
19
|
+
features: TemplateDefaultFeatures,
|
|
20
|
+
};
|
|
21
|
+
/** Default values for a new HubTemplate Model (backing item) */
|
|
22
|
+
export const DEFAULT_TEMPLATE_MODEL = {
|
|
23
|
+
item: {
|
|
24
|
+
type: HUB_TEMPLATE_ITEM_TYPE,
|
|
25
|
+
title: "",
|
|
26
|
+
description: "",
|
|
27
|
+
snippet: "",
|
|
28
|
+
tags: [],
|
|
29
|
+
typeKeywords: [HUB_TEMPLATE_ITEM_TYPE],
|
|
30
|
+
properties: {
|
|
31
|
+
slug: "",
|
|
32
|
+
schemaVersion: 1,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
data: {
|
|
36
|
+
permissions: [],
|
|
37
|
+
view: {},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/templates/defaults.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAG5E;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,UAAU,CAAC;AAEjD,4CAA4C;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAA0B;IACrD,aAAa,EAAE,CAAC;IAChB,OAAO,EAAE,EAAE,aAAa,EAAE,CAAC,EAAE;IAC7B,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,YAAY,EAAE,CAAC,sBAAsB,CAAC;IACtC,IAAI,EAAE,EAAE;IACR,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,uBAAuB;CAClC,CAAC;AAEF,gEAAgE;AAChE,MAAM,CAAC,MAAM,sBAAsB,GAAW;IAC5C,IAAI,EAAE;QACJ,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,EAAE;QACT,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,EAAE;QACR,YAAY,EAAE,CAAC,sBAAsB,CAAC;QACtC,UAAU,EAAE;YACV,IAAI,EAAE,EAAE;YACR,aAAa,EAAE,CAAC;SACjB;KACF;IACD,IAAI,EAAE;QACJ,WAAW,EAAE,EAAE;QACf,IAAI,EAAE,EAAE;KACT;CACmB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getUniqueSlug } from "../items/slugs";
|
|
2
|
+
import { setDiscussableKeyword } from "../discussions";
|
|
3
|
+
import { PropertyMapper } from "../core/_internal/PropertyMapper";
|
|
4
|
+
import { cloneObject } from "../util";
|
|
5
|
+
import { getModel, updateModel } from "../models";
|
|
6
|
+
import { getPropertyMap } from "./_internal/getPropertyMap";
|
|
7
|
+
import { computeProps } from "./_internal/computeProps";
|
|
8
|
+
import { removeItem, } from "@esri/arcgis-rest-portal";
|
|
9
|
+
/**
|
|
10
|
+
* @private
|
|
11
|
+
* Creates a Hub Template's backing Solution item and returns
|
|
12
|
+
* the created entity
|
|
13
|
+
*
|
|
14
|
+
* NOTE: We have no immediate plans to allow template creation
|
|
15
|
+
* from the context of the Hub application, but scaffolding
|
|
16
|
+
* this util for potential future implementation. For now,
|
|
17
|
+
* we will throw an error
|
|
18
|
+
* @param partialTemplate
|
|
19
|
+
* @param requestOptions
|
|
20
|
+
*/
|
|
21
|
+
export function createTemplate(partialTemplate, requestOptions) {
|
|
22
|
+
throw new Error("Template creation is not currently supported from the context of Hub");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* Updates a Hub Template's backing item and returns
|
|
27
|
+
* the updated entity
|
|
28
|
+
* @param template
|
|
29
|
+
* @param requestOptions
|
|
30
|
+
*/
|
|
31
|
+
export async function updateTemplate(template, requestOptions) {
|
|
32
|
+
// 1. Verify the slug is unique, excluding the current template
|
|
33
|
+
template.slug = await getUniqueSlug({ slug: template.slug, existingId: template.id }, requestOptions);
|
|
34
|
+
// 2. Update relevant typeKeywords
|
|
35
|
+
template.typeKeywords = setDiscussableKeyword(template.typeKeywords, template.isDiscussable);
|
|
36
|
+
// 3. Fetch the backing model (item + data)
|
|
37
|
+
const model = await getModel(template.id, requestOptions);
|
|
38
|
+
// 4. Create a property mapper between the template
|
|
39
|
+
// object and item model
|
|
40
|
+
const mapper = new PropertyMapper(getPropertyMap());
|
|
41
|
+
// 5. Create item model from updated template object, using
|
|
42
|
+
// the existing model as a starting point
|
|
43
|
+
const modelToUpdate = mapper.entityToStore(template, model);
|
|
44
|
+
// 6. Update the backing item
|
|
45
|
+
const updatedModel = await updateModel(modelToUpdate, requestOptions);
|
|
46
|
+
// 7. Map the item back into an IHubTemplate
|
|
47
|
+
const updatedTemplate = mapper.storeToEntity(updatedModel, template);
|
|
48
|
+
// 8. Compute + set various properties on the IHubTemplate
|
|
49
|
+
// that cannot be directly mapped from the item
|
|
50
|
+
template = computeProps(model, updatedTemplate, requestOptions);
|
|
51
|
+
return updatedTemplate;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Convert an IHubTemplateEditor back into a IHubTemplate
|
|
55
|
+
* @param editor
|
|
56
|
+
* @param portal
|
|
57
|
+
*/
|
|
58
|
+
export function editorToTemplate(editor, portal) {
|
|
59
|
+
// 1. cast editor to IHubTemplate
|
|
60
|
+
const template = cloneObject(editor);
|
|
61
|
+
// 2. ensure there's an org url key
|
|
62
|
+
template.orgUrlKey = editor.orgUrlKey ? editor.orgUrlKey : portal.urlKey;
|
|
63
|
+
return template;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @private
|
|
67
|
+
* Remove a Hub Template's backing item
|
|
68
|
+
* @param id
|
|
69
|
+
* @param requestOptions
|
|
70
|
+
*/
|
|
71
|
+
export async function deleteTemplate(id, requestOptions) {
|
|
72
|
+
const ro = Object.assign(Object.assign({}, requestOptions), { id });
|
|
73
|
+
await removeItem(ro);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/templates/edit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAGL,UAAU,GACX,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAC5B,eAAsC,EACtC,cAAmC;IAEnC,MAAM,IAAI,KAAK,CACb,sEAAsE,CACvE,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAsB,EACtB,cAAmC;IAEnC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,GAAG,MAAM,aAAa,CACjC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,EAAE,EAChD,cAAc,CACf,CAAC;IAEF,kCAAkC;IAClC,QAAQ,CAAC,YAAY,GAAG,qBAAqB,CAC3C,QAAQ,CAAC,YAAY,EACrB,QAAQ,CAAC,aAAa,CACvB,CAAC;IAEF,2CAA2C;IAC3C,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAE1D,mDAAmD;IACnD,wBAAwB;IACxB,MAAM,MAAM,GAAG,IAAI,cAAc,CAC/B,cAAc,EAAE,CACjB,CAAC;IAEF,2DAA2D;IAC3D,yCAAyC;IACzC,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE5D,6BAA6B;IAC7B,MAAM,YAAY,GAAG,MAAM,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IAEtE,4CAA4C;IAC5C,MAAM,eAAe,GAAG,MAAM,CAAC,aAAa,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;IAErE,0DAA0D;IAC1D,+CAA+C;IAC/C,QAAQ,GAAG,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;IAEhE,OAAO,eAA+B,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAA0B,EAC1B,MAAe;IAEf,iCAAiC;IACjC,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAiB,CAAC;IAErD,mCAAmC;IACnC,QAAQ,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEzE,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,EAAU,EACV,cAAmC;IAEnC,MAAM,EAAE,GAAG,gCAAK,cAAc,GAAK,EAAE,EAAE,EAAE,CAAsB,CAAC;IAChE,MAAM,UAAU,CAAC,EAAE,CAAC,CAAC;IAErB,OAAO;AACT,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { isGuid, mapBy } from "../utils";
|
|
2
|
+
import { getItem } from "@esri/arcgis-rest-portal";
|
|
3
|
+
import { getItemBySlug } from "../items/slugs";
|
|
4
|
+
import { fetchModelFromItem } from "../models";
|
|
5
|
+
import { PropertyMapper } from "../core/_internal/PropertyMapper";
|
|
6
|
+
import { getPropertyMap } from "./_internal/getPropertyMap";
|
|
7
|
+
import { computeProps } from "./_internal/computeProps";
|
|
8
|
+
import { getFamily } from "../content/get-family";
|
|
9
|
+
import { unique } from "../util";
|
|
10
|
+
import { parseInclude } from "../search/_internal/parseInclude";
|
|
11
|
+
import { fetchItemEnrichments } from "../items/_enrichments";
|
|
12
|
+
import { getProp } from "../objects";
|
|
13
|
+
import { computeLinks } from "./_internal/computeLinks";
|
|
14
|
+
import { getDeployedTemplateType } from "./utils";
|
|
15
|
+
/**
|
|
16
|
+
* @private
|
|
17
|
+
* Fetch a Hub Template backing item by id or slug
|
|
18
|
+
* @param identifier item id or slug
|
|
19
|
+
* @param requestOptions
|
|
20
|
+
*/
|
|
21
|
+
export async function fetchTemplate(identifier, requestOptions) {
|
|
22
|
+
let getPrms;
|
|
23
|
+
if (isGuid(identifier)) {
|
|
24
|
+
getPrms = getItem(identifier, requestOptions);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
getPrms = getItemBySlug(identifier, requestOptions);
|
|
28
|
+
}
|
|
29
|
+
return getPrms.then((item) => {
|
|
30
|
+
if (!item)
|
|
31
|
+
return null;
|
|
32
|
+
return convertItemToTemplate(item, requestOptions);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* @private
|
|
37
|
+
* Convert a Solution Item into a Hub Template, fetching
|
|
38
|
+
* any additional information that may be required
|
|
39
|
+
* @param item
|
|
40
|
+
* @param auth
|
|
41
|
+
*/
|
|
42
|
+
export async function convertItemToTemplate(item, requestOptions) {
|
|
43
|
+
const model = await fetchModelFromItem(item, requestOptions);
|
|
44
|
+
// 1. Create a property mapper between the the template
|
|
45
|
+
// object and item model
|
|
46
|
+
const mapper = new PropertyMapper(getPropertyMap());
|
|
47
|
+
// 2. Map the item into an IHubTemplate
|
|
48
|
+
const template = mapper.storeToEntity(model, {});
|
|
49
|
+
// 3. Compute + set various properties on the IHubTemplate
|
|
50
|
+
// that cannot be directly mapped from the item
|
|
51
|
+
return computeProps(model, template, requestOptions);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @private
|
|
55
|
+
* Fetch template specific enrichments
|
|
56
|
+
* @param item
|
|
57
|
+
* @param include
|
|
58
|
+
* @param requestOptions
|
|
59
|
+
*/
|
|
60
|
+
export async function enrichTemplateSearchResult(item, include, requestOptions) {
|
|
61
|
+
const result = {
|
|
62
|
+
access: item.access,
|
|
63
|
+
id: item.id,
|
|
64
|
+
type: item.type,
|
|
65
|
+
name: item.title,
|
|
66
|
+
owner: item.owner,
|
|
67
|
+
typeKeywords: item.typeKeywords,
|
|
68
|
+
tags: item.tags,
|
|
69
|
+
categories: item.categories,
|
|
70
|
+
summary: item.snippet || item.description,
|
|
71
|
+
createdDate: new Date(item.created),
|
|
72
|
+
createdDateSource: "item.created",
|
|
73
|
+
updatedDate: new Date(item.modified),
|
|
74
|
+
updatedDateSource: "item.modified",
|
|
75
|
+
family: getFamily(item.type),
|
|
76
|
+
links: {
|
|
77
|
+
self: "not-implemented",
|
|
78
|
+
siteRelative: "not-implemented",
|
|
79
|
+
thumbnail: "not-implemented",
|
|
80
|
+
workspaceRelative: "not-implemented",
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
// 1. optionally enrich the template item with
|
|
84
|
+
// well-known item enrichments
|
|
85
|
+
const DEFAULTS = [];
|
|
86
|
+
// merge default and provided "include" enrichments
|
|
87
|
+
include = [...DEFAULTS, ...include].filter(unique);
|
|
88
|
+
// Parse the includes into a valid set of enrichments
|
|
89
|
+
const specs = include.map(parseInclude);
|
|
90
|
+
// Extract out the low-level enrichments needed
|
|
91
|
+
const enrichments = mapBy("enrichment", specs).filter(unique);
|
|
92
|
+
// fetch the enrichments
|
|
93
|
+
let enriched = {};
|
|
94
|
+
if (enrichments.length) {
|
|
95
|
+
enriched = await fetchItemEnrichments(item, enrichments, requestOptions);
|
|
96
|
+
}
|
|
97
|
+
// map the enriched props onto the result
|
|
98
|
+
specs.forEach((spec) => {
|
|
99
|
+
result[spec.prop] = getProp(enriched, spec.path);
|
|
100
|
+
});
|
|
101
|
+
// 2. append relevant links onto the search result - these
|
|
102
|
+
// are the same links that get appended to the template entity
|
|
103
|
+
result.links = computeLinks(item, requestOptions);
|
|
104
|
+
// 3. append additional template-specific properties
|
|
105
|
+
result.deployedType = getDeployedTemplateType(item);
|
|
106
|
+
return result;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../../../src/templates/fetch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAS,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAElD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aA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CAAC,CAAC,CAAC;IAEH,0DAA0D;IAC1D,8DAA8D;IAC9D,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAElD,oDAAoD;IACpD,MAAM,CAAC,YAAY,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAEpD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/templates/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { dasherize } from "../utils";
|
|
2
|
+
import { capitalize } from "../util";
|
|
3
|
+
/**
|
|
4
|
+
* We do our best to glean what the solution template
|
|
5
|
+
* is supposed to become when deployed. This util
|
|
6
|
+
* extracts the expected item type from the
|
|
7
|
+
* hubSolutionType typeKeyword on the solution item
|
|
8
|
+
*
|
|
9
|
+
* We use this in various UIs to show the expected
|
|
10
|
+
* type rather than "Solution"
|
|
11
|
+
*
|
|
12
|
+
* @param template
|
|
13
|
+
*/
|
|
14
|
+
export const getDeployedTemplateType = (template) => {
|
|
15
|
+
let deployedType = "Solution";
|
|
16
|
+
// 1. Extract the camelCase item type from the
|
|
17
|
+
// hubSolutionType|<camel-case-item-type> typeKeyword
|
|
18
|
+
const hubSolutionTypeKeyword = template.typeKeywords.find((keyword) => keyword.startsWith("hubSolutionType|"));
|
|
19
|
+
// 2. Attempt to de-camelize the item type
|
|
20
|
+
if (hubSolutionTypeKeyword) {
|
|
21
|
+
const camelizedType = hubSolutionTypeKeyword.split("|")[1];
|
|
22
|
+
deployedType = dasherize(camelizedType)
|
|
23
|
+
.split("-")
|
|
24
|
+
.map((str) => capitalize(str))
|
|
25
|
+
.join(" ");
|
|
26
|
+
// some item types need to be handled separately
|
|
27
|
+
// because they don't follow the standard pattern
|
|
28
|
+
const exceptionMap = {
|
|
29
|
+
storyMap: "StoryMap",
|
|
30
|
+
};
|
|
31
|
+
if (exceptionMap[camelizedType]) {
|
|
32
|
+
deployedType = exceptionMap[camelizedType];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return deployedType;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/templates/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,QAAe,EAAU,EAAE;IACjE,IAAI,YAAY,GAAG,UAAU,CAAC;IAC9B,8CAA8C;IAC9C,qDAAqD;IACrD,MAAM,sBAAsB,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,OAAe,EAAE,EAAE,CAC5E,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,CACvC,CAAC;IAEF,0CAA0C;IAC1C,IAAI,sBAAsB,EAAE;QAC1B,MAAM,aAAa,GAAG,sBAAsB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3D,YAAY,GAAG,SAAS,CAAC,aAAa,CAAC;aACpC,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aAC7B,IAAI,CAAC,GAAG,CAAC,CAAC;QAEb,gDAAgD;QAChD,iDAAiD;QACjD,MAAM,YAAY,GAA2B;YAC3C,QAAQ,EAAE,UAAU;SAErB,CAAC;QAEF,IAAI,YAAY,CAAC,aAAa,CAAC,EAAE;YAC/B,YAAY,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;SAC5C;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { getFamily } from "../content/get-family";
|
|
2
|
+
import { getShortenedCategories } from "../content/_internal/internalContentUtils";
|
|
3
|
+
import { getCardModelUrlFromEntity, getCardModelUrlFromResult, } from "../urls/getCardModelUrl";
|
|
4
|
+
/**
|
|
5
|
+
* Convert a template entity into a card view model that can
|
|
6
|
+
* be consumed by the suite of hub gallery components
|
|
7
|
+
*
|
|
8
|
+
* @param template template entity
|
|
9
|
+
* @param context auth & portal information
|
|
10
|
+
* @param opts view model options
|
|
11
|
+
*/
|
|
12
|
+
export const templateToCardModel = (template, context, opts) => {
|
|
13
|
+
const { actionLinks = [], baseUrl = "", locale = "en-US", target = "self", } = opts || {};
|
|
14
|
+
const titleUrl = getCardModelUrlFromEntity(template, context, target, baseUrl);
|
|
15
|
+
return Object.assign(Object.assign(Object.assign({}, getSharedTemplateCardModel(template, locale)), { actionLinks,
|
|
16
|
+
titleUrl }), (template.thumbnailUrl && { thumbnailUrl: template.thumbnailUrl }));
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Convert a template hub search result into a card view model
|
|
20
|
+
* that can be consumed by the suite of hub gallery components
|
|
21
|
+
*
|
|
22
|
+
* @param searchResult hub template search result
|
|
23
|
+
* @param opts view model options
|
|
24
|
+
*/
|
|
25
|
+
export const templateResultToCardModel = (searchResult, opts) => {
|
|
26
|
+
const { actionLinks = [], baseUrl = "", locale = "en-US", target = "self", } = opts || {};
|
|
27
|
+
const titleUrl = getCardModelUrlFromResult(searchResult, target, baseUrl);
|
|
28
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, getSharedTemplateCardModel(searchResult, locale)), { actionLinks }), (!isNaN(searchResult.index) && { index: searchResult.index })), { titleUrl }), (searchResult.links.thumbnail && {
|
|
29
|
+
thumbnailUrl: searchResult.links.thumbnail,
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Given a template entity OR hub serach result, construct the
|
|
34
|
+
* template's shared card view model properties
|
|
35
|
+
*
|
|
36
|
+
* @param entityOrSearchResult template entity or hub search result
|
|
37
|
+
* @param locale internationalization locale
|
|
38
|
+
*/
|
|
39
|
+
const getSharedTemplateCardModel = (entityOrSearchResult, locale) => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const additionalInfo = [
|
|
42
|
+
{
|
|
43
|
+
i18nKey: "type",
|
|
44
|
+
value: entityOrSearchResult.type,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
i18nKey: "dateUpdated",
|
|
48
|
+
value: entityOrSearchResult.updatedDate.toLocaleDateString(locale),
|
|
49
|
+
},
|
|
50
|
+
...(((_a = entityOrSearchResult.tags) === null || _a === void 0 ? void 0 : _a.length) ? [
|
|
51
|
+
{
|
|
52
|
+
i18nKey: "tags",
|
|
53
|
+
value: entityOrSearchResult.tags.join(", "),
|
|
54
|
+
},
|
|
55
|
+
]
|
|
56
|
+
: []),
|
|
57
|
+
...(((_b = entityOrSearchResult.categories) === null || _b === void 0 ? void 0 : _b.length) ? [
|
|
58
|
+
{
|
|
59
|
+
i18nKey: "categories",
|
|
60
|
+
value: getShortenedCategories(entityOrSearchResult.categories).join(", "),
|
|
61
|
+
},
|
|
62
|
+
]
|
|
63
|
+
: []),
|
|
64
|
+
{
|
|
65
|
+
i18nKey: "dateCreated",
|
|
66
|
+
value: entityOrSearchResult.createdDate.toLocaleDateString(locale),
|
|
67
|
+
},
|
|
68
|
+
];
|
|
69
|
+
return {
|
|
70
|
+
access: entityOrSearchResult.access,
|
|
71
|
+
badges: [],
|
|
72
|
+
id: entityOrSearchResult.id,
|
|
73
|
+
family: getFamily(entityOrSearchResult.type),
|
|
74
|
+
source: entityOrSearchResult.owner,
|
|
75
|
+
summary: entityOrSearchResult.summary,
|
|
76
|
+
title: entityOrSearchResult.name,
|
|
77
|
+
type: entityOrSearchResult.type,
|
|
78
|
+
additionalInfo,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/templates/view.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,yBAAyB,CAAC;AAQjC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsC,CACpE,QAAsB,EACtB,OAAuB,EACvB,IAA8B,EACX,EAAE;IACrB,MAAM,EACJ,WAAW,GAAG,EAAE,EAChB,OAAO,GAAG,EAAE,EACZ,MAAM,GAAG,OAAO,EAChB,MAAM,GAAG,MAAM,GAChB,GAAG,IAAI,IAAI,EAAE,CAAC;IAEf,MAAM,QAAQ,GAAG,yBAAyB,CACxC,QAAQ,EACR,OAAO,EACP,MAAM,EACN,OAAO,CACR,CAAC;IAEF,qDACK,0BAA0B,CAAC,QAAQ,EAAE,MAAM,CAAC,KAC/C,WAAW;QACX,QAAQ,KACL,CAAC,QAAQ,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC,EACrE;AACJ,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAwB,CAC5D,YAA8B,EAC9B,IAA8B,EACX,EAAE;IACrB,MAAM,EACJ,WAAW,GAAG,EAAE,EAChB,OAAO,GAAG,EAAE,EACZ,MAAM,GAAG,OAAO,EAChB,MAAM,GAAG,MAAM,GAChB,GAAG,IAAI,IAAI,EAAE,CAAC;IAEf,MAAM,QAAQ,GAAG,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE1E,iFACK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AE,oBAAoB,CAAC,EAAE;QAC3B,MAAM,EAAE,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC;QAC5C,MAAM,EAAE,oBAAoB,CAAC,KAAK;QAClC,OAAO,EAAE,oBAAoB,CAAC,OAAO;QACrC,KAAK,EAAE,oBAAoB,CAAC,IAAI;QAChC,IAAI,EAAE,oBAAoB,CAAC,IAAI;QAC/B,cAAc;KACf,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { getRelativeWorkspaceUrl } from "../core/getRelativeWorkspaceUrl";
|
|
2
|
-
import { getHubRelativeUrl } from "../content/_internal/internalContentUtils";
|
|
3
|
-
import { getItemHomeUrl } from "./get-item-home-url";
|
|
4
1
|
/**
|
|
5
|
-
*
|
|
2
|
+
* given a target and hub search result, this util
|
|
3
|
+
* returns a gallery card's title url
|
|
6
4
|
*
|
|
7
5
|
* @param result hub search result
|
|
8
6
|
* @param target context the card should redirect to
|
|
@@ -38,7 +36,8 @@ export function getCardModelUrlFromResult(result, target, baseUrl) {
|
|
|
38
36
|
return titleUrl;
|
|
39
37
|
}
|
|
40
38
|
/**
|
|
41
|
-
*
|
|
39
|
+
* given a target and hub entity, this util
|
|
40
|
+
* returns a gallery card's title url
|
|
42
41
|
*
|
|
43
42
|
* @param entity hub entity
|
|
44
43
|
* @param context auth & portal information
|
|
@@ -46,6 +45,7 @@ export function getCardModelUrlFromResult(result, target, baseUrl) {
|
|
|
46
45
|
* @param baseUrl base url to work in conjunction with the target
|
|
47
46
|
*/
|
|
48
47
|
export function getCardModelUrlFromEntity(entity, context, target, baseUrl) {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f;
|
|
49
49
|
let titleUrl;
|
|
50
50
|
if (target === "event") {
|
|
51
51
|
titleUrl = "#";
|
|
@@ -57,17 +57,17 @@ export function getCardModelUrlFromEntity(entity, context, target, baseUrl) {
|
|
|
57
57
|
switch (entity.type) {
|
|
58
58
|
default:
|
|
59
59
|
titleUrl = {
|
|
60
|
-
self:
|
|
60
|
+
self: (_a = entity.links) === null || _a === void 0 ? void 0 : _a.self,
|
|
61
61
|
siteRelative: baseUrl
|
|
62
|
-
? `${baseUrl}${
|
|
63
|
-
:
|
|
62
|
+
? `${baseUrl}${((_b = entity.links) === null || _b === void 0 ? void 0 : _b.siteRelative) || ""}`
|
|
63
|
+
: (_c = entity.links) === null || _c === void 0 ? void 0 : _c.siteRelative,
|
|
64
64
|
workspaceRelative: baseUrl
|
|
65
|
-
? `${baseUrl}${
|
|
66
|
-
:
|
|
65
|
+
? `${baseUrl}${((_d = entity.links) === null || _d === void 0 ? void 0 : _d.workspaceRelative) || ""}`
|
|
66
|
+
: (_e = entity.links) === null || _e === void 0 ? void 0 : _e.workspaceRelative,
|
|
67
67
|
}[target];
|
|
68
68
|
break;
|
|
69
69
|
case "Hub Site Application":
|
|
70
|
-
titleUrl =
|
|
70
|
+
titleUrl = (_f = entity.links) === null || _f === void 0 ? void 0 : _f.self;
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
}
|