@esri/hub-common 14.26.2 → 14.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/esm/content/_internal/ContentBusinessRules.js +5 -0
  2. package/dist/esm/content/_internal/ContentBusinessRules.js.map +1 -1
  3. package/dist/esm/core/EntityEditor.js +4 -0
  4. package/dist/esm/core/EntityEditor.js.map +1 -1
  5. package/dist/esm/core/fetchHubEntity.js +4 -0
  6. package/dist/esm/core/fetchHubEntity.js.map +1 -1
  7. package/dist/esm/core/getTypeFromEntity.js +3 -0
  8. package/dist/esm/core/getTypeFromEntity.js.map +1 -1
  9. package/dist/esm/core/schemas/internal/getEntityEditorSchemas.js +10 -0
  10. package/dist/esm/core/schemas/internal/getEntityEditorSchemas.js.map +1 -1
  11. package/dist/esm/core/schemas/types.js +2 -0
  12. package/dist/esm/core/schemas/types.js.map +1 -1
  13. package/dist/esm/core/types/HubEntityType.js +1 -0
  14. package/dist/esm/core/types/HubEntityType.js.map +1 -1
  15. package/dist/esm/core/types/IHubTemplate.js +1 -0
  16. package/dist/esm/core/types/IHubTemplate.js.map +1 -0
  17. package/dist/esm/core/types/index.js +1 -0
  18. package/dist/esm/core/types/index.js.map +1 -1
  19. package/dist/esm/core/updateHubEntity.js +4 -0
  20. package/dist/esm/core/updateHubEntity.js.map +1 -1
  21. package/dist/esm/index.js +1 -0
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/permissions/HubPermissionPolicies.js +2 -0
  24. package/dist/esm/permissions/HubPermissionPolicies.js.map +1 -1
  25. package/dist/esm/permissions/types/Permission.js +2 -0
  26. package/dist/esm/permissions/types/Permission.js.map +1 -1
  27. package/dist/esm/search/_internal/portalSearchItems.js +4 -0
  28. package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
  29. package/dist/esm/templates/HubTemplate.js +178 -0
  30. package/dist/esm/templates/HubTemplate.js.map +1 -0
  31. package/dist/esm/templates/_internal/TemplateBusinessRules.js +82 -0
  32. package/dist/esm/templates/_internal/TemplateBusinessRules.js.map +1 -0
  33. package/dist/esm/templates/_internal/TemplateSchema.js +8 -0
  34. package/dist/esm/templates/_internal/TemplateSchema.js.map +1 -0
  35. package/dist/esm/templates/_internal/TemplateUiSchemaEdit.js +97 -0
  36. package/dist/esm/templates/_internal/TemplateUiSchemaEdit.js.map +1 -0
  37. package/dist/esm/templates/_internal/computeLinks.js +26 -0
  38. package/dist/esm/templates/_internal/computeLinks.js.map +1 -0
  39. package/dist/esm/templates/_internal/computeProps.js +36 -0
  40. package/dist/esm/templates/_internal/computeProps.js.map +1 -0
  41. package/dist/esm/templates/_internal/getPropertyMap.js +14 -0
  42. package/dist/esm/templates/_internal/getPropertyMap.js.map +1 -0
  43. package/dist/esm/templates/defaults.js +40 -0
  44. package/dist/esm/templates/defaults.js.map +1 -0
  45. package/dist/esm/templates/edit.js +76 -0
  46. package/dist/esm/templates/edit.js.map +1 -0
  47. package/dist/esm/templates/fetch.js +108 -0
  48. package/dist/esm/templates/fetch.js.map +1 -0
  49. package/dist/esm/templates/index.js +5 -0
  50. package/dist/esm/templates/index.js.map +1 -0
  51. package/dist/esm/templates/utils.js +37 -0
  52. package/dist/esm/templates/utils.js.map +1 -0
  53. package/dist/esm/templates/view.js +81 -0
  54. package/dist/esm/templates/view.js.map +1 -0
  55. package/dist/esm/urls/getCardModelUrl.js +11 -11
  56. package/dist/esm/urls/getCardModelUrl.js.map +1 -1
  57. package/dist/node/content/_internal/ContentBusinessRules.js +5 -0
  58. package/dist/node/content/_internal/ContentBusinessRules.js.map +1 -1
  59. package/dist/node/core/EntityEditor.js +4 -0
  60. package/dist/node/core/EntityEditor.js.map +1 -1
  61. package/dist/node/core/fetchHubEntity.js +6 -2
  62. package/dist/node/core/fetchHubEntity.js.map +1 -1
  63. package/dist/node/core/getTypeFromEntity.js +3 -0
  64. package/dist/node/core/getTypeFromEntity.js.map +1 -1
  65. package/dist/node/core/schemas/internal/getEntityEditorSchemas.js +10 -0
  66. package/dist/node/core/schemas/internal/getEntityEditorSchemas.js.map +1 -1
  67. package/dist/node/core/schemas/types.js +2 -0
  68. package/dist/node/core/schemas/types.js.map +1 -1
  69. package/dist/node/core/types/HubEntityType.js +1 -0
  70. package/dist/node/core/types/HubEntityType.js.map +1 -1
  71. package/dist/node/core/types/IHubTemplate.js +3 -0
  72. package/dist/node/core/types/IHubTemplate.js.map +1 -0
  73. package/dist/node/core/types/index.js +1 -0
  74. package/dist/node/core/types/index.js.map +1 -1
  75. package/dist/node/core/updateHubEntity.js +4 -0
  76. package/dist/node/core/updateHubEntity.js.map +1 -1
  77. package/dist/node/index.js +1 -0
  78. package/dist/node/index.js.map +1 -1
  79. package/dist/node/permissions/HubPermissionPolicies.js +2 -0
  80. package/dist/node/permissions/HubPermissionPolicies.js.map +1 -1
  81. package/dist/node/permissions/types/Permission.js +2 -0
  82. package/dist/node/permissions/types/Permission.js.map +1 -1
  83. package/dist/node/search/_internal/portalSearchItems.js +4 -0
  84. package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
  85. package/dist/node/templates/HubTemplate.js +182 -0
  86. package/dist/node/templates/HubTemplate.js.map +1 -0
  87. package/dist/node/templates/_internal/TemplateBusinessRules.js +85 -0
  88. package/dist/node/templates/_internal/TemplateBusinessRules.js.map +1 -0
  89. package/dist/node/templates/_internal/TemplateSchema.js +11 -0
  90. package/dist/node/templates/_internal/TemplateSchema.js.map +1 -0
  91. package/dist/node/templates/_internal/TemplateUiSchemaEdit.js +100 -0
  92. package/dist/node/templates/_internal/TemplateUiSchemaEdit.js.map +1 -0
  93. package/dist/node/templates/_internal/computeLinks.js +30 -0
  94. package/dist/node/templates/_internal/computeLinks.js.map +1 -0
  95. package/dist/node/templates/_internal/computeProps.js +40 -0
  96. package/dist/node/templates/_internal/computeProps.js.map +1 -0
  97. package/dist/node/templates/_internal/getPropertyMap.js +18 -0
  98. package/dist/node/templates/_internal/getPropertyMap.js.map +1 -0
  99. package/dist/node/templates/defaults.js +43 -0
  100. package/dist/node/templates/defaults.js.map +1 -0
  101. package/dist/node/templates/edit.js +83 -0
  102. package/dist/node/templates/edit.js.map +1 -0
  103. package/dist/node/templates/fetch.js +114 -0
  104. package/dist/node/templates/fetch.js.map +1 -0
  105. package/dist/node/templates/index.js +8 -0
  106. package/dist/node/templates/index.js.map +1 -0
  107. package/dist/node/templates/utils.js +40 -0
  108. package/dist/node/templates/utils.js.map +1 -0
  109. package/dist/node/templates/view.js +84 -0
  110. package/dist/node/templates/view.js.map +1 -0
  111. package/dist/node/urls/getCardModelUrl.js +11 -11
  112. package/dist/node/urls/getCardModelUrl.js.map +1 -1
  113. package/dist/types/content/_internal/ContentBusinessRules.d.ts +1 -1
  114. package/dist/types/core/schemas/types.d.ts +1 -1
  115. package/dist/types/core/types/HubEntity.d.ts +2 -1
  116. package/dist/types/core/types/HubEntityType.d.ts +1 -1
  117. package/dist/types/core/types/IHubTemplate.d.ts +13 -0
  118. package/dist/types/core/types/index.d.ts +1 -0
  119. package/dist/types/index.d.ts +1 -0
  120. package/dist/types/permissions/types/Permission.d.ts +2 -1
  121. package/dist/types/templates/HubTemplate.d.ts +79 -0
  122. package/dist/types/templates/_internal/TemplateBusinessRules.d.ts +17 -0
  123. package/dist/types/templates/_internal/TemplateSchema.d.ts +4 -0
  124. package/dist/types/templates/_internal/TemplateUiSchemaEdit.d.ts +15 -0
  125. package/dist/types/templates/_internal/computeLinks.d.ts +11 -0
  126. package/dist/types/templates/_internal/computeProps.d.ts +13 -0
  127. package/dist/types/templates/_internal/getPropertyMap.d.ts +8 -0
  128. package/dist/types/templates/defaults.d.ts +14 -0
  129. package/dist/types/templates/edit.d.ts +37 -0
  130. package/dist/types/templates/fetch.d.ts +28 -0
  131. package/dist/types/templates/index.d.ts +4 -0
  132. package/dist/types/templates/utils.d.ts +13 -0
  133. package/dist/types/templates/view.d.ts +19 -0
  134. package/dist/types/urls/getCardModelUrl.d.ts +4 -2
  135. package/package.json +1 -1
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HubTemplate = void 0;
4
+ const getEditorConfig_1 = require("../core/schemas/getEditorConfig");
5
+ const HubItemEntity_1 = require("../core/HubItemEntity");
6
+ const defaults_1 = require("./defaults");
7
+ const edit_1 = require("./edit");
8
+ const fetch_1 = require("./fetch");
9
+ const enrichEntity_1 = require("../core/enrichEntity");
10
+ const util_1 = require("../util");
11
+ /**
12
+ * Hub Template Class - this class encapsulates the standard
13
+ * operations for a "Solution" item despite the Hub team not
14
+ * "owning" this item type. Our primary goal is to allow
15
+ * editing of the item's meta information, manage sharing, etc.
16
+ */
17
+ class HubTemplate extends HubItemEntity_1.HubItemEntity {
18
+ /**
19
+ * Private constructor to allow for future
20
+ * template-specific logic
21
+ * @param template
22
+ * @param context
23
+ */
24
+ constructor(template, context) {
25
+ super(template, context);
26
+ }
27
+ /**
28
+ * Create an HubTemplate instance from an IHubTemplate object
29
+ * @param json - JSON object to create a HubTemplate from
30
+ * @param context - ArcGIS context
31
+ * @returns
32
+ */
33
+ static fromJson(json, context) {
34
+ // merge what we have with the default values
35
+ const pojo = this.applyDefaults(json, context);
36
+ return new HubTemplate(pojo, context);
37
+ }
38
+ /**
39
+ * Create a new HubTemplate, returning a HubTemplate instance.
40
+ * This does not automatically persist the Template into
41
+ * the backing store unless save is set to true
42
+ *
43
+ * NOTE: we have no immediate plans to allow template creation
44
+ * from the context of the Hub application, but scaffolding this
45
+ * method for potential future implementation. The underlying
46
+ * createTemplate function will throw an error if attempted.
47
+ * @param partialTemplate
48
+ * @param context
49
+ * @param save
50
+ */
51
+ static async create(partialTemplate, context, save = false) {
52
+ const pojo = this.applyDefaults(partialTemplate, context);
53
+ const instance = HubTemplate.fromJson(pojo, context);
54
+ if (save) {
55
+ await instance.save();
56
+ }
57
+ return instance;
58
+ }
59
+ /**
60
+ * Fetch a HubTemplate from the backing store and return
61
+ * a HubTemplate instance
62
+ * @param identifier
63
+ * @param context
64
+ */
65
+ static async fetch(identifier, context) {
66
+ try {
67
+ const initiativeTemplate = await fetch_1.fetchTemplate(identifier, context.requestOptions);
68
+ return HubTemplate.fromJson(initiativeTemplate, context);
69
+ }
70
+ catch (ex) {
71
+ if (ex.message ===
72
+ "CONT_0001: Item does not exist or is inaccessible.") {
73
+ throw new Error(`Template ${identifier} not found.`);
74
+ }
75
+ else {
76
+ throw ex;
77
+ }
78
+ }
79
+ }
80
+ /**
81
+ * Given a partial Template, apply defaults to
82
+ * it to ensure that a baseline of properties are set
83
+ * @param partialTemplate
84
+ * @param context
85
+ */
86
+ static applyDefaults(partialTemplate, context) {
87
+ // ensure we have the orgUrlKey
88
+ if (!partialTemplate.orgUrlKey) {
89
+ partialTemplate.orgUrlKey = context.portal.urlKey;
90
+ }
91
+ // extend the partial over the defaults
92
+ const pojo = Object.assign(Object.assign({}, defaults_1.DEFAULT_TEMPLATE), partialTemplate);
93
+ return pojo;
94
+ }
95
+ /*
96
+ * Get a specific editor config for the HubTemplate entity.
97
+ * @param i18nScope
98
+ * @param type
99
+ */
100
+ async getEditorConfig(i18nScope, type) {
101
+ // delegate to the schema subsystem
102
+ return getEditorConfig_1.getEditorConfig(i18nScope, type, this.entity, this.context);
103
+ }
104
+ /**
105
+ * Transform template entity into an editor object
106
+ * @param editorContext
107
+ */
108
+ async toEditor(editorContext = {}, include = []) {
109
+ // 1. optionally enrich entity and cast to editor
110
+ const editor = include.length
111
+ ? (await enrichEntity_1.enrichEntity(util_1.cloneObject(this.entity), include, this.context.hubRequestOptions))
112
+ : util_1.cloneObject(this.entity);
113
+ // 2. Apply transforms to relevant entity values so they
114
+ // can be consumed by the editor
115
+ return editor;
116
+ }
117
+ /**
118
+ * Transform editor values into a template entity
119
+ * @param editor
120
+ */
121
+ async fromEditor(editor) {
122
+ // Setting the thumbnailCache will ensure that the
123
+ // thumbnail is updated on the next save
124
+ if (editor._thumbnail) {
125
+ if (editor._thumbnail.blob) {
126
+ this.thumbnailCache = {
127
+ file: editor._thumbnail.blob,
128
+ filename: editor._thumbnail.filename,
129
+ clear: false,
130
+ };
131
+ }
132
+ else {
133
+ this.thumbnailCache = {
134
+ clear: true,
135
+ };
136
+ }
137
+ }
138
+ delete editor._thumbnail;
139
+ const entity = edit_1.editorToTemplate(editor, this.context.portal);
140
+ // save, which will also create
141
+ this.entity = entity;
142
+ await this.save();
143
+ return this.entity;
144
+ }
145
+ /**
146
+ * Update the instance's internal entity state
147
+ * @param changes
148
+ */
149
+ update(changes) {
150
+ if (this.isDestroyed) {
151
+ throw new Error("HubTemplate is already destroyed.");
152
+ }
153
+ this.entity = Object.assign(Object.assign({}, this.entity), changes);
154
+ }
155
+ /** Save the HubTemplate to the backing store */
156
+ async save() {
157
+ if (this.isDestroyed) {
158
+ throw new Error("HubTemplate is already destroyed.");
159
+ }
160
+ // 1. create or update. Note: the underlying createTemplate
161
+ // function will throw an error because we don't currently
162
+ // allow for template creation from the context of Hub
163
+ this.entity = this.entity.id
164
+ ? await edit_1.updateTemplate(this.entity, this.context.userRequestOptions)
165
+ : await edit_1.createTemplate(this.entity, this.context.userRequestOptions);
166
+ // 2. call the after save hook on HubItemEntity superclass
167
+ await super.afterSave();
168
+ }
169
+ /**
170
+ * Delete the Hub Template's backing item and set a flag
171
+ * indicating it's been destroyed
172
+ */
173
+ async delete() {
174
+ if (this.isDestroyed) {
175
+ throw new Error("HubTemplate is already destroyed.");
176
+ }
177
+ this.isDestroyed = true;
178
+ await edit_1.deleteTemplate(this.entity.id, this.context.userRequestOptions);
179
+ }
180
+ }
181
+ exports.HubTemplate = HubTemplate;
182
+ //# sourceMappingURL=HubTemplate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HubTemplate.js","sourceRoot":"","sources":["../../../src/templates/HubTemplate.ts"],"names":[],"mappings":";;;AACA,qEAAkE;AAElE,yDAAsD;AAGtD,yCAA8C;AAC9C,iCAKgB;AAChB,mCAAwC;AAExC,uDAAoD;AACpD,kCAAsC;AAEtC;;;;;G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AW,GAAG,IAAI,CAAC;QACxB,MAAM,qBAAc,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxE,CAAC;CACF;AAhND,kCAgNC"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TemplatePermissionPolicies = exports.TemplatePermissions = exports.TemplateDefaultFeatures = void 0;
4
+ /**
5
+ * Default features for a Template. These are the features
6
+ * that can be enabled / disabled by the entity owner
7
+ */
8
+ exports.TemplateDefaultFeatures = {};
9
+ /**
10
+ * @private
11
+ * Template permissions: these define the requirements
12
+ * any user must meet to perform related actions
13
+ */
14
+ exports.TemplatePermissions = [
15
+ "hub:template",
16
+ "hub:template:create",
17
+ "hub:template:delete",
18
+ "hub:template:edit",
19
+ "hub:template:manage",
20
+ "hub:template:view",
21
+ "hub:template:workspace:overview",
22
+ "hub:template:workspace:details",
23
+ "hub:template:workspace:dashboard",
24
+ "hub:template:workspace:collaborators",
25
+ "hub:template:workspace:settings",
26
+ ];
27
+ /**
28
+ * @private
29
+ * Template permission policies
30
+ */
31
+ exports.TemplatePermissionPolicies = [
32
+ {
33
+ permission: "hub:template",
34
+ availability: ["alpha"],
35
+ services: ["portal"],
36
+ },
37
+ {
38
+ permission: "hub:template:create",
39
+ dependencies: ["hub:template"],
40
+ authenticated: true,
41
+ privileges: ["portal:user:createItem"],
42
+ },
43
+ {
44
+ permission: "hub:template:delete",
45
+ dependencies: ["hub:template"],
46
+ authenticated: true,
47
+ entityOwner: true,
48
+ },
49
+ {
50
+ permission: "hub:template:view",
51
+ dependencies: ["hub:template"],
52
+ },
53
+ {
54
+ permission: "hub:template:edit",
55
+ dependencies: ["hub:template"],
56
+ authenticated: true,
57
+ entityEdit: true,
58
+ },
59
+ {
60
+ permission: "hub:template:manage",
61
+ dependencies: ["hub:template:edit"],
62
+ },
63
+ {
64
+ permission: "hub:template:workspace:overview",
65
+ dependencies: ["hub:template:view"],
66
+ },
67
+ {
68
+ permission: "hub:template:workspace:details",
69
+ dependencies: ["hub:template:manage"],
70
+ },
71
+ {
72
+ permission: "hub:template:workspace:dashboard",
73
+ dependencies: ["hub:template:manage"],
74
+ },
75
+ {
76
+ permission: "hub:template:workspace:collaborators",
77
+ dependencies: ["hub:template:manage"],
78
+ },
79
+ {
80
+ permission: "hub:template:workspace:settings",
81
+ dependencies: ["hub:template:manage"],
82
+ entityOwner: true,
83
+ },
84
+ ];
85
+ //# sourceMappingURL=TemplateBusinessRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateBusinessRules.js","sourceRoot":"","sources":["../../../../src/templates/_internal/TemplateBusinessRules.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACU,QAAA,uBAAuB,GAAkB,EAAE,CAAC;AAEzD;;;;GAIG;AACU,QAAA,mBAAmB,GAAG;IACjC,cAAc;IACd,qBAAqB;IACrB,qBAAqB;IACrB,mBAAmB;IACnB,qBAAqB;IACrB,mBAAmB;IACnB,iCAAiC;IACjC,gCAAgC;IAChC,kCAAkC;IAClC,sCAAsC;IACtC,iCAAiC;CACzB,CAAC;AAEX;;;GAGG;AACU,QAAA,0BAA0B,GAAwB;IAC7D;QACE,UAAU,EAAE,cAAc;QAC1B,YAAY,EAAE,CAAC,OAAO,CAAC;QACvB,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;IACD;QACE,UAAU,EAAE,qBAAqB;QACjC,YAAY,EAAE,CAAC,cAAc,CAAC;QAC9B,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,CAAC,wBAAwB,CAAC;KACvC;IACD;QACE,UAAU,EAAE,qBAAqB;QACjC,YAAY,EAAE,CAAC,cAAc,CAAC;QAC9B,aAAa,EAAE,IAAI;QACnB,WAAW,EAAE,IAAI;KAClB;IACD;QACE,UAAU,EAAE,mBAAmB;QAC/B,YAAY,EAAE,CAAC,cAAc,CAAC;KAC/B;IACD;QACE,UAAU,EAAE,mBAAmB;QAC/B,YAAY,EAAE,CAAC,cAAc,CAAC;QAC9B,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,IAAI;KACjB;IACD;QACE,UAAU,EAAE,qBAAqB;QACjC,YAAY,EAAE,CAAC,mBAAmB,CAAC;KACpC;IACD;QACE,UAAU,EAAE,iCAAiC;QAC7C,YAAY,EAAE,CAAC,mBAAmB,CAAC;KACpC;IACD;QACE,UAAU,EAAE,gCAAgC;QAC5C,YAAY,EAAE,CAAC,qBAAqB,CAAC;KACtC;IACD;QACE,UAAU,EAAE,kCAAkC;QAC9C,YAAY,EAAE,CAAC,qBAAqB,CAAC;KACtC;IACD;QACE,UAAU,EAAE,sCAAsC;QAClD,YAAY,EAAE,CAAC,qBAAqB,CAAC;KACtC;IACD;QACE,UAAU,EAAE,iCAAiC;QAC7C,YAAY,EAAE,CAAC,qBAAqB,CAAC;QACrC,WAAW,EAAE,IAAI;KAClB;CACF,CAAC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TemplateSchema = exports.TemplateEditorTypes = void 0;
4
+ const HubItemEntitySchema_1 = require("../../core/schemas/shared/HubItemEntitySchema");
5
+ exports.TemplateEditorTypes = ["hub:template:edit"];
6
+ exports.TemplateSchema = Object.assign(Object.assign({}, HubItemEntitySchema_1.HubItemEntitySchema), { properties: Object.assign(Object.assign({}, HubItemEntitySchema_1.HubItemEntitySchema.properties), { previewUrl: {
7
+ type: "string",
8
+ if: { minLength: 1 },
9
+ then: { format: "uri" },
10
+ } }) });
11
+ //# sourceMappingURL=TemplateSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateSchema.js","sourceRoot":"","sources":["../../../../src/templates/_internal/TemplateSchema.ts"],"names":[],"mappings":";;;AACA,uFAAoF;AAIvE,QAAA,mBAAmB,GAAG,CAAC,mBAAmB,CAAU,CAAC;AAErD,QAAA,cAAc,GAAyB,gCAC/C,yCAAmB,KACtB,UAAU,kCACL,yCAAmB,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,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildUiSchema = void 0;
4
+ const types_1 = require("../../core/schemas/types");
5
+ /**
6
+ * @private
7
+ * constructs the complete edit uiSchema for Hub Templates.
8
+ * This defines how the schema properties should be rendered
9
+ * in the template editing experience.
10
+ *
11
+ * @param i18nScope
12
+ * @param entity
13
+ * @param context
14
+ * @returns
15
+ */
16
+ exports.buildUiSchema = async (i18nScope, entity, context) => {
17
+ return {
18
+ type: "Layout",
19
+ elements: [
20
+ {
21
+ type: "Section",
22
+ labelKey: `${i18nScope}.sections.basicInfo.label`,
23
+ elements: [
24
+ {
25
+ type: "Control",
26
+ scope: "/properties/name",
27
+ labelKey: `${i18nScope}.fields.name.label`,
28
+ options: {
29
+ messages: [
30
+ {
31
+ type: types_1.UiSchemaMessageTypes.error,
32
+ keyword: "required",
33
+ icon: true,
34
+ labelKey: `${i18nScope}.fields.name.requiredError`,
35
+ },
36
+ ],
37
+ },
38
+ },
39
+ {
40
+ type: "Control",
41
+ scope: "/properties/previewUrl",
42
+ labelKey: `${i18nScope}.fields.previewUrl.label`,
43
+ options: {
44
+ helperText: {
45
+ labelKey: `${i18nScope}.fields.previewUrl.helperText`,
46
+ },
47
+ messages: [
48
+ {
49
+ type: "ERROR",
50
+ keyword: "if",
51
+ hidden: true,
52
+ },
53
+ ],
54
+ },
55
+ },
56
+ {
57
+ labelKey: `${i18nScope}.fields.summary.label`,
58
+ scope: "/properties/summary",
59
+ type: "Control",
60
+ options: {
61
+ control: "hub-field-input-input",
62
+ type: "textarea",
63
+ helperText: {
64
+ labelKey: `${i18nScope}.fields.summary.helperText`,
65
+ },
66
+ },
67
+ },
68
+ {
69
+ labelKey: `${i18nScope}.fields.description.label`,
70
+ scope: "/properties/description",
71
+ type: "Control",
72
+ options: {
73
+ control: "hub-field-input-input",
74
+ type: "textarea",
75
+ helperText: {
76
+ labelKey: `${i18nScope}.fields.description.helperText`,
77
+ },
78
+ },
79
+ },
80
+ {
81
+ labelKey: `${i18nScope}.fields.thumbnail.label`,
82
+ scope: "/properties/_thumbnail",
83
+ type: "Control",
84
+ options: {
85
+ control: "hub-field-input-image-picker",
86
+ imgSrc: entity.thumbnailUrl,
87
+ maxWidth: 727,
88
+ maxHeight: 484,
89
+ aspectRatio: 1.5,
90
+ helperText: {
91
+ labelKey: `${i18nScope}.fields.thumbnail.helperText`,
92
+ },
93
+ },
94
+ },
95
+ ],
96
+ },
97
+ ],
98
+ };
99
+ };
100
+ //# sourceMappingURL=TemplateUiSchemaEdit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateUiSchemaEdit.js","sourceRoot":"","sources":["../../../../src/templates/_internal/TemplateUiSchemaEdit.ts"],"names":[],"mappings":";;;AACA,oDAA2E;AAG3E;;;;;;;;;;GAUG;AACU,QAAA,aAAa,GAAG,KAAK,EAChC,SAAiB,EACjB,MAAoB,EACpB,OAAuB,EACH,EAAE;IACtB,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE;YACR;gBACE,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE,GAAG,SAAS,2BAA2B;gBACjD,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,SAAS;wBACf,KAAK,EAAE,kBAAkB;wBACzB,QAAQ,EAAE,GAAG,SAAS,oBAAoB;wBAC1C,OAAO,EAAE;4BACP,QAAQ,EAAE;gCACR;oCACE,IAAI,EAAE,4BAAoB,CAAC,KAAK;oCAChC,OAAO,EAAE,UAAU;oCACnB,IAAI,EAAE,IAAI;oCACV,QAAQ,EAAE,GAAG,SAAS,4BAA4B;iCACnD;6BACF;yBACF;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Property(exports, "__esModule", { value: true });
3
+ exports.computeLinks = void 0;
4
+ const urls_1 = require("../../urls");
5
+ const items_1 = require("../../items");
6
+ const internalContentUtils_1 = require("../../content/_internal/internalContentUtils");
7
+ const getRelativeWorkspaceUrl_1 = require("../../core/getRelativeWorkspaceUrl");
8
+ const get_item_thumbnail_url_1 = require("../../resources/get-item-thumbnail-url");
9
+ /**
10
+ * Compute the links that get appended to a Hub Template
11
+ * search result and entity
12
+ *
13
+ * @param item
14
+ * @param requestOptions
15
+ */
16
+ function computeLinks(item, requestOptions) {
17
+ let token;
18
+ if (requestOptions.authentication) {
19
+ const session = requestOptions.authentication;
20
+ token = session.token;
21
+ }
22
+ return {
23
+ self: urls_1.getItemHomeUrl(item.id, requestOptions),
24
+ siteRelative: internalContentUtils_1.getHubRelativeUrl(item.type, items_1.getItemIdentifier(item), item.typeKeywords),
25
+ workspaceRelative: getRelativeWorkspaceUrl_1.getRelativeWorkspaceUrl(item.type, items_1.getItemIdentifier(item)),
26
+ thumbnail: get_item_thumbnail_url_1.getItemThumbnailUrl(item, requestOptions, token),
27
+ };
28
+ }
29
+ exports.computeLinks = computeLinks;
30
+ //# sourceMappingURL=computeLinks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeLinks.js","sourceRoot":"","sources":["../../../../src/templates/_internal/computeLinks.ts"],"names":[],"mappings":";;;AAGA,qCAA4C;AAE5C,uCAAgD;AAChD,uFAAiF;AACjF,gFAA6E;AAC7E,mFAA6E;AAE7E;;;;;;GAMG;AACH,SAAgB,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,qBAAc,CAAC,IAAI,CAAC,EAAE,EAAE,cAAc,CAAC;QAC7C,YAAY,EAAE,wCAAiB,CAC7B,IAAI,CAAC,IAAI,EACT,yBAAiB,CAAC,IAAI,CAAC,EACvB,IAAI,CAAC,YAAY,CAClB;QACD,iBAAiB,EAAE,iDAAuB,CACxC,IAAI,CAAC,IAAI,EACT,yBAAiB,CAAC,IAAI,CAAC,CACxB;QACD,SAAS,EAAE,4CAAmB,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC;KAC5D,CAAC;AACJ,CAAC;AAvBD,oCAuBC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeProps = void 0;
4
+ const utils_1 = require("../../discussions/utils");
5
+ const processEntityFeatures_1 = require("../../permissions/_internal/processEntityFeatures");
6
+ const TemplateBusinessRules_1 = require("./TemplateBusinessRules");
7
+ const computeLinks_1 = require("./computeLinks");
8
+ const objects_1 = require("../../objects");
9
+ const utils_2 = require("../utils");
10
+ /**
11
+ * @private
12
+ * Given a model and a template, set various computed
13
+ * properties on the template that can't be directly
14
+ * mapped from the model
15
+ * @param model
16
+ * @param template
17
+ * @param requestOptions
18
+ */
19
+ function computeProps(model, template, requestOptions) {
20
+ // 1. compute relevant template links
21
+ template.links = computeLinks_1.computeLinks(model.item, requestOptions);
22
+ // 2. append the template's thumbnail url at the top-level
23
+ template.thumbnailUrl = template.links.thumbnail;
24
+ // 3. compute relevant template dates
25
+ template.createdDate = new Date(model.item.created);
26
+ template.createdDateSource = "item.created";
27
+ template.updatedDate = new Date(model.item.modified);
28
+ template.updatedDateSource = "item.modified";
29
+ // 4. determine whether the template is discussable
30
+ template.isDiscussable = utils_1.isDiscussable(template);
31
+ // 5. process features that can be disabled by the entity owner
32
+ template.features = processEntityFeatures_1.processEntityFeatures(objects_1.getProp(model, "data.settings.features") || {}, TemplateBusinessRules_1.TemplateDefaultFeatures);
33
+ // 6. compute additional template-specific properties
34
+ template.isDeployed = (objects_1.getProp(model, "item.typeKeywords") || []).includes("Deployed");
35
+ template.deployedType = utils_2.getDeployedTemplateType(model.item);
36
+ // 7. cast b/c this takes a partial but returns a full template
37
+ return template;
38
+ }
39
+ exports.computeProps = computeProps;
40
+ //# sourceMappingURL=computeProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeProps.js","sourceRoot":"","sources":["../../../../src/templates/_internal/computeProps.ts"],"names":[],"mappings":";;;AACA,mDAAwD;AACxD,6FAA0F;AAE1F,mEAAkE;AAElE,iDAA8C;AAC9C,2CAAwC;AACxC,oCAAmD;AAEnD;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAC1B,KAAa,EACb,QAA+B,EAC/B,cAA+B;IAE/B,qCAAqC;IACrC,QAAQ,CAAC,KAAK,GAAG,2BAAY,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAE1D,0DAA0D;IAC1D,QAAQ,CAAC,YAAY,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC;IAEjD,qCAAqC;IACrC,QAAQ,CAAC,WAAW,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpD,QAAQ,CAAC,iBAAiB,GAAG,cAAc,CAAC;IAC5C,QAAQ,CAAC,WAAW,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrD,QAAQ,CAAC,iBAAiB,GAAG,eAAe,CAAC;IAE7C,mDAAmD;IACnD,QAAQ,CAAC,aAAa,GAAG,qBAAa,CAAC,QAAQ,CAAC,CAAC;IAEjD,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,GAAG,6CAAqB,CACvC,iBAAO,CAAC,KAAK,EAAE,wBAAwB,CAAC,IAAI,EAAE,EAC9C,+CAAuB,CACxB,CAAC;IAEF,qDAAqD;IACrD,QAAQ,CAAC,UAAU,GAAG,CAAC,iBAAO,CAAC,KAAK,EAAE,mBAAmB,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CACxE,UAAU,CACX,CAAC;IACF,QAAQ,CAAC,YAAY,GAAG,+BAAuB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE5D,+DAA+D;IAC/D,OAAO,QAAwB,CAAC;AAClC,CAAC;AAlCD,oCAkCC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPropertyMap = void 0;
4
+ const getBasePropertyMap_1 = require("../../core/_internal/getBasePropertyMap");
5
+ /**
6
+ * @private
7
+ * Returns an Array of IPropertyMap objects that
8
+ * define the projection of properties from an
9
+ * IModel to an IHubTemplate
10
+ */
11
+ function getPropertyMap() {
12
+ const map = getBasePropertyMap_1.getBasePropertyMap();
13
+ // IHubTemplate specific mappings
14
+ map.push({ entityKey: "previewUrl", storeKey: "item.properties.previewUrl" });
15
+ return map;
16
+ }
17
+ exports.getPropertyMap = getPropertyMap;
18
+ //# sourceMappingURL=getPropertyMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPropertyMap.js","sourceRoot":"","sources":["../../../../src/templates/_internal/getPropertyMap.ts"],"names":[],"mappings":";;;AAAA,gFAA6E;AAG7E;;;;;GAKG;AACH,SAAgB,cAAc;IAC5B,MAAM,GAAG,GAAG,uCAAkB,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;AAPD,wCAOC"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_TEMPLATE_MODEL = exports.DEFAULT_TEMPLATE = exports.HUB_TEMPLATE_ITEM_TYPE = void 0;
4
+ const TemplateBusinessRules_1 = require("./_internal/TemplateBusinessRules");
5
+ /**
6
+ * NOTE: this file provides default values for new
7
+ * Hub Template creation; however, we have no immediate
8
+ * plans to allow template creation from the context of
9
+ * our application. Scaffolding these defaults for
10
+ * potential future implementation
11
+ */
12
+ exports.HUB_TEMPLATE_ITEM_TYPE = "Solution";
13
+ /** Default values for a new IHubTemplate */
14
+ exports.DEFAULT_TEMPLATE = {
15
+ schemaVersion: 1,
16
+ catalog: { schemaVersion: 0 },
17
+ name: "",
18
+ tags: [],
19
+ typeKeywords: [exports.HUB_TEMPLATE_ITEM_TYPE],
20
+ view: {},
21
+ permissions: [],
22
+ features: TemplateBusinessRules_1.TemplateDefaultFeatures,
23
+ };
24
+ /** Default values for a new HubTemplate Model (backing item) */
25
+ exports.DEFAULT_TEMPLATE_MODEL = {
26
+ item: {
27
+ type: exports.HUB_TEMPLATE_ITEM_TYPE,
28
+ title: "",
29
+ description: "",
30
+ snippet: "",
31
+ tags: [],
32
+ typeKeywords: [exports.HUB_TEMPLATE_ITEM_TYPE],
33
+ properties: {
34
+ slug: "",
35
+ schemaVersion: 1,
36
+ },
37
+ },
38
+ data: {
39
+ permissions: [],
40
+ view: {},
41
+ },
42
+ };
43
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/templates/defaults.ts"],"names":[],"mappings":";;;AACA,6EAA4E;AAG5E;;;;;;GAMG;AAEU,QAAA,sBAAsB,GAAG,UAAU,CAAC;AAEjD,4CAA4C;AAC/B,QAAA,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,8BAAsB,CAAC;IACtC,IAAI,EAAE,EAAE;IACR,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,+CAAuB;CAClC,CAAC;AAEF,gEAAgE;AACnD,QAAA,sBAAsB,GAAW;IAC5C,IAAI,EAAE;QACJ,IAAI,EAAE,8BAAsB;QAC5B,KAAK,EAAE,EAAE;QACT,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,EAAE;QACR,YAAY,EAAE,CAAC,8BAAsB,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,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteTemplate = exports.editorToTemplate = exports.updateTemplate = exports.createTemplate = void 0;
4
+ const slugs_1 = require("../items/slugs");
5
+ const discussions_1 = require("../discussions");
6
+ const PropertyMapper_1 = require("../core/_internal/PropertyMapper");
7
+ const util_1 = require("../util");
8
+ const models_1 = require("../models");
9
+ const getPropertyMap_1 = require("./_internal/getPropertyMap");
10
+ const computeProps_1 = require("./_internal/computeProps");
11
+ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
12
+ /**
13
+ * @private
14
+ * Creates a Hub Template's backing Solution item and returns
15
+ * the created entity
16
+ *
17
+ * NOTE: We have no immediate plans to allow template creation
18
+ * from the context of the Hub application, but scaffolding
19
+ * this util for potential future implementation. For now,
20
+ * we will throw an error
21
+ * @param partialTemplate
22
+ * @param requestOptions
23
+ */
24
+ function createTemplate(partialTemplate, requestOptions) {
25
+ throw new Error("Template creation is not currently supported from the context of Hub");
26
+ }
27
+ exports.createTemplate = createTemplate;
28
+ /**
29
+ * @private
30
+ * Updates a Hub Template's backing item and returns
31
+ * the updated entity
32
+ * @param template
33
+ * @param requestOptions
34
+ */
35
+ async function updateTemplate(template, requestOptions) {
36
+ // 1. Verify the slug is unique, excluding the current template
37
+ template.slug = await slugs_1.getUniqueSlug({ slug: template.slug, existingId: template.id }, requestOptions);
38
+ // 2. Update relevant typeKeywords
39
+ template.typeKeywords = discussions_1.setDiscussableKeyword(template.typeKeywords, template.isDiscussable);
40
+ // 3. Fetch the backing model (item + data)
41
+ const model = await models_1.getModel(template.id, requestOptions);
42
+ // 4. Create a property mapper between the template
43
+ // object and item model
44
+ const mapper = new PropertyMapper_1.PropertyMapper(getPropertyMap_1.getPropertyMap());
45
+ // 5. Create item model from updated template object, using
46
+ // the existing model as a starting point
47
+ const modelToUpdate = mapper.entityToStore(template, model);
48
+ // 6. Update the backing item
49
+ const updatedModel = await models_1.updateModel(modelToUpdate, requestOptions);
50
+ // 7. Map the item back into an IHubTemplate
51
+ const updatedTemplate = mapper.storeToEntity(updatedModel, template);
52
+ // 8. Compute + set various properties on the IHubTemplate
53
+ // that cannot be directly mapped from the item
54
+ template = computeProps_1.computeProps(model, updatedTemplate, requestOptions);
55
+ return updatedTemplate;
56
+ }
57
+ exports.updateTemplate = updateTemplate;
58
+ /**
59
+ * Convert an IHubTemplateEditor back into a IHubTemplate
60
+ * @param editor
61
+ * @param portal
62
+ */
63
+ function editorToTemplate(editor, portal) {
64
+ // 1. cast editor to IHubTemplate
65
+ const template = util_1.cloneObject(editor);
66
+ // 2. ensure there's an org url key
67
+ template.orgUrlKey = editor.orgUrlKey ? editor.orgUrlKey : portal.urlKey;
68
+ return template;
69
+ }
70
+ exports.editorToTemplate = editorToTemplate;
71
+ /**
72
+ * @private
73
+ * Remove a Hub Template's backing item
74
+ * @param id
75
+ * @param requestOptions
76
+ */
77
+ async function deleteTemplate(id, requestOptions) {
78
+ const ro = Object.assign(Object.assign({}, requestOptions), { id });
79
+ await arcgis_rest_portal_1.removeItem(ro);
80
+ return;
81
+ }
82
+ exports.deleteTemplate = deleteTemplate;
83
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/templates/edit.ts"],"names":[],"mappings":";;;AAEA,0CAA+C;AAC/C,gDAAuD;AACvD,qEAAkE;AAElE,kCAAsC;AACtC,sCAAkD;AAClD,+DAA4D;AAC5D,2DAAwD;AACxD,iEAIkC;AAElC;;;;;;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