@esri/solution-creator 1.1.2 → 1.2.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/createItemTemplate.js +56 -63
- package/dist/esm/createItemTemplate.js.map +1 -1
- package/dist/esm/creator.js +54 -47
- package/dist/esm/creator.js.map +1 -1
- package/dist/esm/helpers/add-content-to-solution.js +72 -78
- package/dist/esm/helpers/add-content-to-solution.js.map +1 -1
- package/dist/esm/module-map.js +2 -2
- package/dist/esm/module-map.js.map +1 -1
- package/dist/node/createItemTemplate.js +59 -66
- package/dist/node/createItemTemplate.js.map +1 -1
- package/dist/node/creator.js +56 -49
- package/dist/node/creator.js.map +1 -1
- package/dist/node/helpers/add-content-to-solution.js +75 -81
- package/dist/node/helpers/add-content-to-solution.js.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/module-map.js +9 -9
- package/dist/node/module-map.js.map +1 -1
- package/dist/umd/creator.umd.js +1263 -1271
- package/dist/umd/creator.umd.js.map +1 -1
- package/dist/umd/creator.umd.min.js +3 -3
- package/dist/umd/creator.umd.min.js.map +1 -1
- package/package.json +33 -33
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { __assign } from "tslib";
|
|
17
16
|
/**
|
|
18
17
|
* Manages creation of the template of a Solution item via the REST API.
|
|
19
18
|
*
|
|
@@ -36,7 +35,7 @@ import { moduleMap, UNSUPPORTED } from "./module-map";
|
|
|
36
35
|
* @protected
|
|
37
36
|
*/
|
|
38
37
|
export function createItemTemplate(solutionItemId, itemId, templateDictionary, srcAuthentication, destAuthentication, existingTemplates, itemProgressCallback) {
|
|
39
|
-
return new Promise(
|
|
38
|
+
return new Promise(resolve => {
|
|
40
39
|
// Check if item and its dependents are already in list or are queued
|
|
41
40
|
if (findTemplateInList(existingTemplates, itemId)) {
|
|
42
41
|
resolve([]);
|
|
@@ -47,36 +46,32 @@ export function createItemTemplate(solutionItemId, itemId, templateDictionary, s
|
|
|
47
46
|
itemProgressCallback(itemId, EItemProgressStatus.Started, 0);
|
|
48
47
|
// Fetch the item
|
|
49
48
|
getItemBase(itemId, srcAuthentication)
|
|
50
|
-
.catch(
|
|
49
|
+
.catch(() => {
|
|
51
50
|
// If item query fails, try fetching item as a group
|
|
52
51
|
// Change its placeholder from an empty type to the Group type so that we can later distinguish
|
|
53
52
|
// between items and groups (the base info for a group doesn't include a type property)
|
|
54
53
|
replaceTemplate(existingTemplates, itemId, createPlaceholderTemplate(itemId, "Group"));
|
|
55
54
|
return getGroupBase(itemId, srcAuthentication);
|
|
56
55
|
})
|
|
57
|
-
.then(
|
|
56
|
+
.then(itemInfo => {
|
|
58
57
|
itemInfo = sanitizeJSONAndReportChanges(itemInfo);
|
|
59
58
|
// Save the URL as a symbol
|
|
60
59
|
if (itemInfo.url) {
|
|
61
60
|
templateDictionary[itemInfo.url] = "{{" + itemInfo.id + ".url}}";
|
|
62
61
|
itemInfo.origUrl = itemInfo.url;
|
|
63
62
|
}
|
|
64
|
-
|
|
63
|
+
const idTest = /^source-[0-9A-F]{32}/i;
|
|
65
64
|
// Remove any source-itemId type keywords
|
|
66
65
|
if (Array.isArray(itemInfo.typeKeywords)) {
|
|
67
|
-
itemInfo.typeKeywords = itemInfo.typeKeywords.filter(
|
|
68
|
-
return idTest.test(v) ? false : true;
|
|
69
|
-
});
|
|
66
|
+
itemInfo.typeKeywords = itemInfo.typeKeywords.filter(v => idTest.test(v) ? false : true);
|
|
70
67
|
}
|
|
71
68
|
// Remove any source-itemId tags
|
|
72
69
|
/* istanbul ignore else */
|
|
73
70
|
if (Array.isArray(itemInfo.tags)) {
|
|
74
|
-
itemInfo.tags = itemInfo.tags.filter(
|
|
75
|
-
return idTest.test(v) ? false : true;
|
|
76
|
-
});
|
|
71
|
+
itemInfo.tags = itemInfo.tags.filter(v => idTest.test(v) ? false : true);
|
|
77
72
|
}
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
const placeholder = findTemplateInList(existingTemplates, itemId);
|
|
74
|
+
let itemType = placeholder.type;
|
|
80
75
|
if (!itemType) {
|
|
81
76
|
// Groups have this defined when their placeholder is created
|
|
82
77
|
itemType = itemInfo.type;
|
|
@@ -85,14 +80,16 @@ export function createItemTemplate(solutionItemId, itemId, templateDictionary, s
|
|
|
85
80
|
if (!itemInfo.type) {
|
|
86
81
|
itemInfo.type = itemType; // Groups don't have this property, so we'll patch it in
|
|
87
82
|
}
|
|
88
|
-
placeholder.item =
|
|
83
|
+
placeholder.item = {
|
|
84
|
+
...itemInfo
|
|
85
|
+
};
|
|
89
86
|
// Interrupt process if progress callback returns `false`
|
|
90
87
|
if (!itemProgressCallback(itemId, EItemProgressStatus.Created, 1)) {
|
|
91
88
|
itemProgressCallback(itemId, EItemProgressStatus.Cancelled, 1);
|
|
92
89
|
resolve(fail("Cancelled"));
|
|
93
90
|
return;
|
|
94
91
|
}
|
|
95
|
-
|
|
92
|
+
const itemHandler = moduleMap[itemType];
|
|
96
93
|
if (!itemHandler || itemHandler === UNSUPPORTED) {
|
|
97
94
|
if (itemHandler === UNSUPPORTED) {
|
|
98
95
|
itemProgressCallback(itemId, EItemProgressStatus.Ignored, 1);
|
|
@@ -118,17 +115,15 @@ export function createItemTemplate(solutionItemId, itemId, templateDictionary, s
|
|
|
118
115
|
} */
|
|
119
116
|
// Delegate the creation of the item to the handler
|
|
120
117
|
itemHandler
|
|
121
|
-
.convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, templateDictionary)
|
|
122
|
-
.then(
|
|
118
|
+
.convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary)
|
|
119
|
+
.then(itemTemplate => {
|
|
123
120
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
124
|
-
getItemResourcesPaths(itemTemplate, solutionItemId, srcAuthentication, SolutionTemplateFormatVersion).then(
|
|
121
|
+
getItemResourcesPaths(itemTemplate, solutionItemId, srcAuthentication, SolutionTemplateFormatVersion).then((resourceItemFilePaths) => {
|
|
125
122
|
itemTemplate.item.thumbnail = null; // not needed in this property; handled as a resource
|
|
126
123
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
127
|
-
getItemResourcesFilesFromPaths(resourceItemFilePaths, srcAuthentication).then(
|
|
124
|
+
getItemResourcesFilesFromPaths(resourceItemFilePaths, srcAuthentication).then((resourceItemFiles) => {
|
|
128
125
|
// update the template's resources
|
|
129
|
-
itemTemplate.resources = itemTemplate.resources.concat(resourceItemFiles.map(
|
|
130
|
-
return file.folder + "/" + file.filename;
|
|
131
|
-
}));
|
|
126
|
+
itemTemplate.resources = itemTemplate.resources.concat(resourceItemFiles.map((file) => file.folder + "/" + file.filename));
|
|
132
127
|
// Set the value keyed by the id to the created template, replacing the placeholder template
|
|
133
128
|
replaceTemplate(existingTemplates, itemTemplate.itemId, itemTemplate);
|
|
134
129
|
// Trace item dependencies
|
|
@@ -139,25 +134,23 @@ export function createItemTemplate(solutionItemId, itemId, templateDictionary, s
|
|
|
139
134
|
else {
|
|
140
135
|
// Get its dependencies, asking each to get its dependents via
|
|
141
136
|
// recursive calls to this function
|
|
142
|
-
|
|
143
|
-
itemTemplate.dependencies.forEach(
|
|
137
|
+
const dependentDfds = [];
|
|
138
|
+
itemTemplate.dependencies.forEach(dependentId => {
|
|
144
139
|
if (!findTemplateInList(existingTemplates, dependentId)) {
|
|
145
|
-
|
|
140
|
+
dependentDfds.push(createItemTemplate(solutionItemId, dependentId, templateDictionary, srcAuthentication, destAuthentication, existingTemplates, itemProgressCallback));
|
|
146
141
|
}
|
|
147
142
|
});
|
|
148
143
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
149
|
-
Promise.all(
|
|
144
|
+
Promise.all(dependentDfds).then((dependentResourceItemFiles) => {
|
|
150
145
|
// Templatization of item and its dependencies done
|
|
151
146
|
itemProgressCallback(itemId, EItemProgressStatus.Finished, 1);
|
|
152
|
-
resourceItemFiles = dependentResourceItemFiles.reduce(
|
|
153
|
-
return accumulator.concat(currentValue);
|
|
154
|
-
}, resourceItemFiles);
|
|
147
|
+
resourceItemFiles = dependentResourceItemFiles.reduce((accumulator, currentValue) => accumulator.concat(currentValue), resourceItemFiles);
|
|
155
148
|
resolve(resourceItemFiles);
|
|
156
149
|
});
|
|
157
150
|
}
|
|
158
151
|
});
|
|
159
152
|
});
|
|
160
|
-
},
|
|
153
|
+
}, error => {
|
|
161
154
|
placeholder.properties["error"] = JSON.stringify(error);
|
|
162
155
|
replaceTemplate(existingTemplates, itemId, placeholder);
|
|
163
156
|
itemProgressCallback(itemId, EItemProgressStatus.Failed, 1);
|
|
@@ -166,7 +159,7 @@ export function createItemTemplate(solutionItemId, itemId, templateDictionary, s
|
|
|
166
159
|
}
|
|
167
160
|
},
|
|
168
161
|
// Id not found or item is not accessible
|
|
169
|
-
|
|
162
|
+
() => {
|
|
170
163
|
itemProgressCallback(itemId, EItemProgressStatus.Failed, 1);
|
|
171
164
|
itemProgressCallback(itemId, EItemProgressStatus.Failed, 1);
|
|
172
165
|
resolve([]);
|
|
@@ -182,20 +175,20 @@ export function createItemTemplate(solutionItemId, itemId, templateDictionary, s
|
|
|
182
175
|
* @return A list of templates that have templatized field references
|
|
183
176
|
*/
|
|
184
177
|
export function postProcessFieldReferences(templates) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return templates.map(
|
|
178
|
+
const datasourceInfos = _getDatasourceInfos(templates);
|
|
179
|
+
const templateTypeHash = _getTemplateTypeHash(templates);
|
|
180
|
+
return templates.map(template => {
|
|
188
181
|
/* istanbul ignore else */
|
|
189
182
|
if (template.type === "Web Mapping Application" ||
|
|
190
183
|
template.type === "Dashboard" ||
|
|
191
184
|
template.type === "Web Map") {
|
|
192
|
-
|
|
193
|
-
|
|
185
|
+
const webMapFSDependencies = _getWebMapFSDependencies(template, templateTypeHash);
|
|
186
|
+
const itemHandler = moduleMap[template.item.type];
|
|
194
187
|
/* istanbul ignore else */
|
|
195
188
|
if (itemHandler) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (
|
|
189
|
+
const dependencies = webMapFSDependencies.concat(template.dependencies);
|
|
190
|
+
let dependantDatasources = datasourceInfos.filter(ds => {
|
|
191
|
+
if (dependencies.indexOf(ds.itemId) > -1) {
|
|
199
192
|
return ds;
|
|
200
193
|
}
|
|
201
194
|
});
|
|
@@ -216,13 +209,13 @@ export function postProcessFieldReferences(templates) {
|
|
|
216
209
|
* @return A list of IDataSourceInfo objects with key properties
|
|
217
210
|
*/
|
|
218
211
|
export function _getDatasourceInfos(templates) {
|
|
219
|
-
|
|
220
|
-
templates.forEach(
|
|
212
|
+
const datasourceInfos = [];
|
|
213
|
+
templates.forEach(t => {
|
|
221
214
|
if (t.type === "Feature Service") {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
layersAndTables.forEach(
|
|
215
|
+
const layers = getProp(t, "properties.layers") || [];
|
|
216
|
+
const tables = getProp(t, "properties.tables") || [];
|
|
217
|
+
const layersAndTables = layers.concat(tables);
|
|
218
|
+
layersAndTables.forEach(obj => {
|
|
226
219
|
/* istanbul ignore else */
|
|
227
220
|
if (!hasDatasource(datasourceInfos, t.itemId, obj.id)) {
|
|
228
221
|
datasourceInfos.push({
|
|
@@ -249,8 +242,8 @@ export function _getDatasourceInfos(templates) {
|
|
|
249
242
|
* @return The lookup object with type, dependencies, and webmap layer info
|
|
250
243
|
*/
|
|
251
244
|
export function _getTemplateTypeHash(templates) {
|
|
252
|
-
|
|
253
|
-
templates.forEach(
|
|
245
|
+
const templateTypeHash = {};
|
|
246
|
+
templates.forEach(template => {
|
|
254
247
|
templateTypeHash[template.itemId] = {
|
|
255
248
|
type: template.type,
|
|
256
249
|
dependencies: template.dependencies
|
|
@@ -269,14 +262,14 @@ export function _getTemplateTypeHash(templates) {
|
|
|
269
262
|
* @return The lookup object with webmap layer info added
|
|
270
263
|
*/
|
|
271
264
|
export function _updateWebMapHashInfo(template, hashItem) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
265
|
+
const operationalLayers = getProp(template, "data.operationalLayers") || [];
|
|
266
|
+
const tables = getProp(template, "data.tables") || [];
|
|
267
|
+
const layersAndTables = operationalLayers.concat(tables);
|
|
275
268
|
if (layersAndTables && layersAndTables.length > 0) {
|
|
276
269
|
hashItem.layersAndTables = [];
|
|
277
|
-
layersAndTables.forEach(
|
|
278
|
-
|
|
279
|
-
|
|
270
|
+
layersAndTables.forEach(layer => {
|
|
271
|
+
const obj = {};
|
|
272
|
+
let itemId;
|
|
280
273
|
/* istanbul ignore else */
|
|
281
274
|
if (layer.itemId) {
|
|
282
275
|
itemId = layer.itemId;
|
|
@@ -313,16 +306,16 @@ export function _addLayerIdToDatasourceUrl(datasourceUrl, layerId) {
|
|
|
313
306
|
* @return The updated datasource infos
|
|
314
307
|
*/
|
|
315
308
|
export function _addMapLayerIds(datasourceInfos, templateTypeHash) {
|
|
316
|
-
|
|
309
|
+
const webMapIds = Object.keys(templateTypeHash).filter(k => {
|
|
317
310
|
if (templateTypeHash[k].type === "Web Map") {
|
|
318
311
|
return templateTypeHash[k];
|
|
319
312
|
}
|
|
320
313
|
});
|
|
321
|
-
return datasourceInfos.map(
|
|
322
|
-
webMapIds.forEach(
|
|
323
|
-
templateTypeHash[webMapId].layersAndTables.forEach(
|
|
324
|
-
|
|
325
|
-
|
|
314
|
+
return datasourceInfos.map(ds => {
|
|
315
|
+
webMapIds.forEach(webMapId => {
|
|
316
|
+
templateTypeHash[webMapId].layersAndTables.forEach((opLayer) => {
|
|
317
|
+
const opLayerInfo = opLayer[ds.itemId];
|
|
318
|
+
const url = _addLayerIdToDatasourceUrl(ds.url, ds.layerId);
|
|
326
319
|
if (opLayerInfo &&
|
|
327
320
|
url === opLayerInfo.url &&
|
|
328
321
|
ds.ids.indexOf(opLayerInfo.id) < 0) {
|
|
@@ -342,11 +335,11 @@ export function _addMapLayerIds(datasourceInfos, templateTypeHash) {
|
|
|
342
335
|
* @return A lsit of feature service item IDs
|
|
343
336
|
*/
|
|
344
337
|
export function _getWebMapFSDependencies(template, templateTypeHash) {
|
|
345
|
-
|
|
346
|
-
template.dependencies.forEach(
|
|
347
|
-
|
|
338
|
+
const webMapFSDependencies = [];
|
|
339
|
+
template.dependencies.forEach(dep => {
|
|
340
|
+
const depObj = templateTypeHash[dep];
|
|
348
341
|
if (depObj.type === "Web Map") {
|
|
349
|
-
depObj.dependencies.forEach(
|
|
342
|
+
depObj.dependencies.forEach((depObjDependency) => {
|
|
350
343
|
/* istanbul ignore else */
|
|
351
344
|
if (templateTypeHash[depObjDependency].type === "Feature Service") {
|
|
352
345
|
webMapFSDependencies.push(depObjDependency);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createItemTemplate.js","sourceRoot":"","sources":["../../src/createItemTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"createItemTemplate.js","sourceRoot":"","sources":["../../src/createItemTemplate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,aAAa,EAOb,8BAA8B,EAC9B,qBAAqB,EACrB,eAAe,EACf,4BAA4B,EAC5B,IAAI,EAEL,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtD,wHAAwH;AAExH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,cAAsB,EACtB,MAAc,EACd,kBAAuB,EACvB,iBAA8B,EAC9B,kBAA+B,EAC/B,iBAAkC,EAClC,oBAA2C;IAE3C,OAAO,IAAI,OAAO,CAAC,O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,CAAC,MAAM,CAAC,CAAC;gBAC5C,MAAM,GAAG,GAAW,0BAA0B,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;gBACnE,IACE,WAAW;oBACX,GAAG,KAAK,WAAW,CAAC,GAAG;oBACvB,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAClC;oBACA,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;iBAC7B;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAuB,EACvB,gBAAqB;IAErB,MAAM,oBAAoB,GAAa,EAAE,CAAC;IAC1C,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;QAClC,MAAM,MAAM,GAAQ,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE;YAC7B,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,gBAAwB,EAAE,EAAE;gBACvD,0BAA0B;gBAC1B,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,IAAI,KAAK,iBAAiB,EAAE;oBACjE,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;iBAC7C;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;IACH,OAAO,oBAAoB,CAAC;AAC9B,CAAC"}
|
package/dist/esm/creator.js
CHANGED
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
*
|
|
19
19
|
* @module creator
|
|
20
20
|
*/
|
|
21
|
-
import { appendQueryParam, createItemWithData, createLongId, createShortId, CURRENT_SCHEMA_VERSION, generateSourceThumbnailUrl, getBlobAsFile, getFilenameFromUrl, getGroupBase, getGroupContents, getItemBase, getVelocityUrlBase, removeItem, sanitizeJSONAndReportChanges } from "@esri/solution-common";
|
|
21
|
+
import { appendQueryParam, createItemWithData, createLongId, createShortId, CURRENT_SCHEMA_VERSION, generateSourceThumbnailUrl, getBlobAsFile, getFilenameFromUrl, getGroupBase, getGroupContents, getItemBase, getPortal, getUser, getVelocityUrlBase, removeItem, sanitizeJSONAndReportChanges, setLocationTrackingEnabled } from "@esri/solution-common";
|
|
22
22
|
import { failSafe } from "@esri/hub-common";
|
|
23
23
|
import { addContentToSolution } from "./helpers/add-content-to-solution";
|
|
24
24
|
// Simple no-op to clean up progressCallback management
|
|
25
|
-
|
|
25
|
+
const noOp = () => { };
|
|
26
26
|
/**
|
|
27
27
|
* Creates a solution item.
|
|
28
28
|
*
|
|
@@ -33,8 +33,8 @@ var noOp = function () { };
|
|
|
33
33
|
* @return A promise that resolves with the AGO id of the new solution
|
|
34
34
|
*/
|
|
35
35
|
export function createSolution(sourceId, srcAuthentication, destAuthentication, options) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const createOptions = options || {};
|
|
37
|
+
const progressCb = createOptions.progressCallback || noOp;
|
|
38
38
|
createOptions.templateDictionary = Object.assign({}, createOptions.templateDictionary);
|
|
39
39
|
progressCb(1); // let the caller know that we've started
|
|
40
40
|
// Assume that source is a group and try to get group's information
|
|
@@ -45,43 +45,54 @@ export function createSolution(sourceId, srcAuthentication, destAuthentication,
|
|
|
45
45
|
])
|
|
46
46
|
.then(
|
|
47
47
|
// Group fetches worked; assumption was correct
|
|
48
|
-
|
|
48
|
+
responses => {
|
|
49
49
|
createOptions.itemIds = responses[1];
|
|
50
50
|
progressCb(15);
|
|
51
|
-
return new Promise(
|
|
51
|
+
return new Promise(resolve => {
|
|
52
52
|
// Update the createOptions with values from the group
|
|
53
53
|
resolve(_applySourceToCreateOptions(createOptions, responses[0], srcAuthentication, true));
|
|
54
54
|
});
|
|
55
55
|
},
|
|
56
56
|
// Assumption incorrect; try source as an item
|
|
57
|
-
|
|
58
|
-
return new Promise(
|
|
57
|
+
() => {
|
|
58
|
+
return new Promise((resolve, reject) => {
|
|
59
59
|
createOptions.itemIds = [sourceId];
|
|
60
60
|
getItemBase(sourceId, srcAuthentication).then(
|
|
61
61
|
// Update the createOptions with values from the item
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
itemBase => resolve(_applySourceToCreateOptions(createOptions, itemBase, srcAuthentication, false)), reject);
|
|
63
|
+
});
|
|
64
|
+
})
|
|
65
|
+
.then(createOptions => {
|
|
66
|
+
return new Promise((resolve, reject) => {
|
|
67
|
+
Promise.all([
|
|
68
|
+
getPortal("", srcAuthentication),
|
|
69
|
+
getUser(srcAuthentication)
|
|
70
|
+
]).then(responses => {
|
|
71
|
+
// check tracking
|
|
72
|
+
const [portalResponse, userResponse] = responses;
|
|
73
|
+
setLocationTrackingEnabled(portalResponse, userResponse, createOptions.templateDictionary);
|
|
74
|
+
resolve(createOptions);
|
|
64
75
|
}, reject);
|
|
65
76
|
});
|
|
66
77
|
})
|
|
67
78
|
.then(
|
|
68
79
|
// Use a copy of the thumbnail rather than a URL to it
|
|
69
|
-
|
|
80
|
+
createOptions => {
|
|
70
81
|
return _addThumbnailFileToCreateOptions(createOptions, srcAuthentication);
|
|
71
82
|
})
|
|
72
83
|
.then(
|
|
73
84
|
// Create a solution
|
|
74
|
-
|
|
85
|
+
createOptions => {
|
|
75
86
|
return _createSolutionFromItemIds(createOptions, srcAuthentication, destAuthentication);
|
|
76
87
|
})
|
|
77
88
|
.then(
|
|
78
89
|
// Successfully created solution
|
|
79
|
-
|
|
90
|
+
createdSolutionId => {
|
|
80
91
|
progressCb(100); // finished
|
|
81
92
|
return createdSolutionId;
|
|
82
93
|
},
|
|
83
94
|
// Error fetching group, group contents, or item, or error creating solution from ids
|
|
84
|
-
|
|
95
|
+
error => {
|
|
85
96
|
progressCb(1);
|
|
86
97
|
console.error(error);
|
|
87
98
|
throw error;
|
|
@@ -96,13 +107,11 @@ export function createSolution(sourceId, srcAuthentication, destAuthentication,
|
|
|
96
107
|
* @param isGroup Boolean to indicate if the files are associated with a group or item
|
|
97
108
|
* @internal
|
|
98
109
|
*/
|
|
99
|
-
export function _applySourceToCreateOptions(createOptions, sourceInfo, srcAuthentication, isGroup) {
|
|
100
|
-
if (isGroup === void 0) { isGroup = false; }
|
|
110
|
+
export function _applySourceToCreateOptions(createOptions, sourceInfo, srcAuthentication, isGroup = false) {
|
|
101
111
|
// Create a solution from the group's or item's contents,
|
|
102
112
|
// using the group's or item's information as defaults for the solution item
|
|
103
|
-
["title", "snippet", "description", "tags"].forEach(
|
|
104
|
-
|
|
105
|
-
createOptions[prop] = (_a = createOptions[prop]) !== null && _a !== void 0 ? _a : sourceInfo[prop];
|
|
113
|
+
["title", "snippet", "description", "tags"].forEach(prop => {
|
|
114
|
+
createOptions[prop] = createOptions[prop] ?? sourceInfo[prop];
|
|
106
115
|
});
|
|
107
116
|
if (!createOptions.thumbnailurl && sourceInfo.thumbnail) {
|
|
108
117
|
// Get the full path to the thumbnail
|
|
@@ -119,17 +128,17 @@ export function _applySourceToCreateOptions(createOptions, sourceInfo, srcAuthen
|
|
|
119
128
|
* @internal
|
|
120
129
|
*/
|
|
121
130
|
export function _addThumbnailFileToCreateOptions(createOptions, srcAuthentication) {
|
|
122
|
-
return new Promise(
|
|
131
|
+
return new Promise(resolve => {
|
|
123
132
|
if (!createOptions.thumbnail && createOptions.thumbnailurl) {
|
|
124
133
|
// Figure out the thumbnail's filename
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
const filename = getFilenameFromUrl(createOptions.thumbnailurl) || "thumbnail";
|
|
135
|
+
const thumbnailurl = appendQueryParam(createOptions.thumbnailurl, "w=400");
|
|
127
136
|
delete createOptions.thumbnailurl;
|
|
128
137
|
// Fetch the thumbnail
|
|
129
|
-
getBlobAsFile(thumbnailurl, filename, srcAuthentication).then(
|
|
138
|
+
getBlobAsFile(thumbnailurl, filename, srcAuthentication).then(thumbnail => {
|
|
130
139
|
createOptions.thumbnail = thumbnail;
|
|
131
140
|
resolve(createOptions);
|
|
132
|
-
},
|
|
141
|
+
}, () => {
|
|
133
142
|
resolve(createOptions);
|
|
134
143
|
});
|
|
135
144
|
}
|
|
@@ -149,19 +158,19 @@ export function _addThumbnailFileToCreateOptions(createOptions, srcAuthenticatio
|
|
|
149
158
|
* @internal
|
|
150
159
|
*/
|
|
151
160
|
export function _createSolutionFromItemIds(options, srcAuthentication, destAuthentication) {
|
|
152
|
-
|
|
161
|
+
let solutionId = "";
|
|
153
162
|
// Create a solution from the list of items
|
|
154
163
|
return _createSolutionItem(destAuthentication, options)
|
|
155
|
-
.then(
|
|
164
|
+
.then(id => {
|
|
156
165
|
solutionId = id;
|
|
157
166
|
// Add list of items to the new solution
|
|
158
167
|
return addContentToSolution(solutionId, options, srcAuthentication, destAuthentication);
|
|
159
168
|
})
|
|
160
|
-
.catch(
|
|
169
|
+
.catch(addError => {
|
|
161
170
|
// If the solution item got created, delete it
|
|
162
171
|
if (solutionId) {
|
|
163
|
-
|
|
164
|
-
return failSafeRemove(solutionId, destAuthentication).then(
|
|
172
|
+
const failSafeRemove = failSafe(removeItem, { success: true });
|
|
173
|
+
return failSafeRemove(solutionId, destAuthentication).then(() => {
|
|
165
174
|
throw addError;
|
|
166
175
|
});
|
|
167
176
|
}
|
|
@@ -180,11 +189,11 @@ export function _createSolutionFromItemIds(options, srcAuthentication, destAuthe
|
|
|
180
189
|
* @internal
|
|
181
190
|
*/
|
|
182
191
|
export function _createSolutionItem(authentication, options) {
|
|
183
|
-
|
|
192
|
+
const model = _createSolutionItemModel(options);
|
|
184
193
|
// Create new solution item
|
|
185
194
|
delete model.item.thumbnailurl;
|
|
186
|
-
model.item.thumbnail = options
|
|
187
|
-
return createItemWithData(model.item, model.data, authentication, options
|
|
195
|
+
model.item.thumbnail = options?.thumbnail;
|
|
196
|
+
return createItemWithData(model.item, model.data, authentication, options?.folderId).then(createResponse => {
|
|
188
197
|
return Promise.resolve(createResponse.id);
|
|
189
198
|
});
|
|
190
199
|
}
|
|
@@ -196,26 +205,25 @@ export function _createSolutionItem(authentication, options) {
|
|
|
196
205
|
* @internal
|
|
197
206
|
*/
|
|
198
207
|
export function _createSolutionItemModel(options) {
|
|
199
|
-
var _a, _b, _c, _d, _e;
|
|
200
208
|
// Solution uses all supplied tags but for deploy.* tags; that information goes into properties
|
|
201
|
-
|
|
202
|
-
|
|
209
|
+
const creationTags = options?.tags ?? [];
|
|
210
|
+
const solutionItem = {
|
|
203
211
|
type: "Solution",
|
|
204
|
-
title:
|
|
205
|
-
snippet:
|
|
206
|
-
description:
|
|
212
|
+
title: options?.title ?? createShortId(),
|
|
213
|
+
snippet: options?.snippet ?? "",
|
|
214
|
+
description: options?.description ?? "",
|
|
207
215
|
properties: {
|
|
208
216
|
schemaVersion: CURRENT_SCHEMA_VERSION
|
|
209
217
|
},
|
|
210
|
-
thumbnailurl:
|
|
211
|
-
tags: creationTags.filter(
|
|
218
|
+
thumbnailurl: options?.thumbnailurl ?? "",
|
|
219
|
+
tags: creationTags.filter((tag) => !tag.startsWith("deploy.")),
|
|
212
220
|
typeKeywords: ["Solution", "Template"].concat(_getDeploymentProperties(creationTags))
|
|
213
221
|
};
|
|
214
222
|
// ensure that snippet and description are not nefarious
|
|
215
|
-
|
|
216
|
-
|
|
223
|
+
const sanitizedItem = sanitizeJSONAndReportChanges(solutionItem);
|
|
224
|
+
const addlKeywords = options?.additionalTypeKeywords || [];
|
|
217
225
|
sanitizedItem.typeKeywords = [].concat(solutionItem.typeKeywords, addlKeywords);
|
|
218
|
-
|
|
226
|
+
const solutionData = {
|
|
219
227
|
metadata: {},
|
|
220
228
|
templates: []
|
|
221
229
|
};
|
|
@@ -233,12 +241,11 @@ export function _createSolutionItemModel(options) {
|
|
|
233
241
|
* @internal
|
|
234
242
|
*/
|
|
235
243
|
export function _getDeploymentProperties(tags) {
|
|
236
|
-
var _a, _b;
|
|
237
244
|
return [
|
|
238
245
|
"solutionid-" +
|
|
239
|
-
(
|
|
246
|
+
(_getDeploymentProperty("deploy.id.", tags) ?? createLongId()),
|
|
240
247
|
"solutionversion-" +
|
|
241
|
-
(
|
|
248
|
+
(_getDeploymentProperty("deploy.version.", tags) ?? "1.0")
|
|
242
249
|
];
|
|
243
250
|
}
|
|
244
251
|
/**
|
|
@@ -250,7 +257,7 @@ export function _getDeploymentProperties(tags) {
|
|
|
250
257
|
* @internal
|
|
251
258
|
*/
|
|
252
259
|
export function _getDeploymentProperty(desiredTagPrefix, tags) {
|
|
253
|
-
|
|
260
|
+
const foundTagAsList = tags.filter(tag => tag.startsWith(desiredTagPrefix));
|
|
254
261
|
if (foundTagAsList.length > 0) {
|
|
255
262
|
return foundTagAsList[0].substr(desiredTagPrefix.length);
|
|
256
263
|
}
|
package/dist/esm/creator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"creator.js","sourceRoot":"","sources":["../../src/creator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,0BAA0B,EAC1B,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAKlB,UAAU,EACV,4BAA4B,
|
|
1
|
+
{"version":3,"file":"creator.js","sourceRoot":"","sources":["../../src/creator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,0BAA0B,EAC1B,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,OAAO,EACP,kBAAkB,EAKlB,UAAU,EACV,4BAA4B,EAC5B,0BAA0B,EAE3B,MAAM,uBAAuB,CAA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