@esri/solution-file 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.
@@ -24,8 +24,9 @@ import * as common from "@esri/solution-common";
24
24
  *
25
25
  * @param solutionItemId The solution to contain the template
26
26
  * @param itemInfo Info about the item
27
- * @param authentication Credentials for working with AGO
27
+ * @param destAuthentication Credentials for requests to the destination organization
28
+ * @param srcAuthentication Credentials for requests to source items
28
29
  * @return A promise that will resolve when the template has been created
29
30
  */
30
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, authentication: common.UserSession): Promise<common.IItemTemplate>;
31
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
31
32
  export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
package/dist/esm/file.js CHANGED
@@ -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 { __read } from "tslib";
17
16
  /**
18
17
  * Manages the creation and deployment of item types that contain files.
19
18
  *
@@ -26,21 +25,22 @@ import * as common from "@esri/solution-common";
26
25
  *
27
26
  * @param solutionItemId The solution to contain the template
28
27
  * @param itemInfo Info about the item
29
- * @param authentication Credentials for working with AGO
28
+ * @param destAuthentication Credentials for requests to the destination organization
29
+ * @param srcAuthentication Credentials for requests to source items
30
30
  * @return A promise that will resolve when the template has been created
31
31
  */
32
- export function convertItemToTemplate(solutionItemId, itemInfo, authentication) {
33
- return new Promise(function (resolve) {
32
+ export function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
33
+ return new Promise(resolve => {
34
34
  // Init template
35
- var itemTemplate = common.createInitializedItemTemplate(itemInfo);
35
+ const itemTemplate = common.createInitializedItemTemplate(itemInfo);
36
36
  // Templatize item info property values
37
37
  itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
38
38
  // Request file
39
- var dataPromise = new Promise(function (dataResolve) {
39
+ const dataPromise = new Promise(dataResolve => {
40
40
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
41
41
  common
42
- .getItemDataAsFile(itemTemplate.itemId, itemTemplate.item.name, authentication)
43
- .then(function (response) {
42
+ .getItemDataAsFile(itemTemplate.itemId, itemTemplate.item.name, srcAuthentication)
43
+ .then(response => {
44
44
  if (!response || response.size === 0) {
45
45
  dataResolve(null);
46
46
  }
@@ -50,24 +50,24 @@ export function convertItemToTemplate(solutionItemId, itemInfo, authentication)
50
50
  });
51
51
  });
52
52
  // Request related items
53
- var relatedPromise = Promise.resolve({});
53
+ const relatedPromise = Promise.resolve({});
54
54
  // Errors are handled as resolved empty values; this means that there's no `reject` clause to handle, hence:
55
55
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
56
- Promise.all([dataPromise, relatedPromise]).then(function (responses) {
57
- var _a = __read(responses, 1), itemDataResponse = _a[0];
56
+ Promise.all([dataPromise, relatedPromise]).then(responses => {
57
+ const [itemDataResponse] = responses;
58
58
  if (itemDataResponse) {
59
- var resource = common.convertBlobToSupportableResource(itemDataResponse, itemTemplate.item.name);
59
+ const resource = common.convertBlobToSupportableResource(itemDataResponse, itemTemplate.item.name);
60
60
  itemTemplate.properties[resource.filename] = resource.mimeType;
61
- var storageName_1 = common.convertItemResourceToStorageResource(itemTemplate.itemId +
61
+ const storageName = common.convertItemResourceToStorageResource(itemTemplate.itemId +
62
62
  (resource.blob.name === resource.filename
63
63
  ? "_info_data"
64
64
  : "_info_dataz"), resource.blob.name, common.SolutionTemplateFormatVersion);
65
65
  common
66
- .addResourceFromBlob(resource.blob, solutionItemId, storageName_1.folder, storageName_1.filename, authentication)
67
- .then(function () {
68
- itemTemplate.resources.push(storageName_1.folder + "/" + storageName_1.filename);
66
+ .addResourceFromBlob(resource.blob, solutionItemId, storageName.folder, storageName.filename, destAuthentication)
67
+ .then(() => {
68
+ itemTemplate.resources.push(storageName.folder + "/" + storageName.filename);
69
69
  resolve(itemTemplate);
70
- }, function (error) {
70
+ }, error => {
71
71
  itemTemplate.properties["error"] = JSON.stringify(error);
72
72
  resolve(itemTemplate);
73
73
  });
@@ -79,7 +79,7 @@ export function convertItemToTemplate(solutionItemId, itemInfo, authentication)
79
79
  });
80
80
  }
81
81
  export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
82
- return new Promise(function (resolve) {
82
+ return new Promise(resolve => {
83
83
  // Interrupt process if progress callback returns `false`
84
84
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
85
85
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
@@ -87,7 +87,7 @@ export function createItemFromTemplate(template, templateDictionary, destination
87
87
  return;
88
88
  }
89
89
  // Replace the templatized symbols in a copy of the template
90
- var newItemTemplate = common.cloneObject(template);
90
+ let newItemTemplate = common.cloneObject(template);
91
91
  newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
92
92
  /* istanbul ignore else */
93
93
  if (template.item.thumbnail) {
@@ -96,17 +96,13 @@ export function createItemFromTemplate(template, templateDictionary, destination
96
96
  // Create the item, then update its URL with its new id
97
97
  common
98
98
  .createItemWithData(newItemTemplate.item, newItemTemplate.data, destinationAuthentication, templateDictionary.folderId)
99
- .then(function (createResponse) {
99
+ .then(createResponse => {
100
100
  // Interrupt process if progress callback returns `false`
101
101
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
102
102
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
103
103
  common
104
104
  .removeItem(createResponse.id, destinationAuthentication)
105
- .then(function () {
106
- return resolve(common.generateEmptyCreationResponse(template.type));
107
- }, function () {
108
- return resolve(common.generateEmptyCreationResponse(template.type));
109
- });
105
+ .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
110
106
  }
111
107
  else {
112
108
  // Add the new item to the settings
@@ -122,7 +118,7 @@ export function createItemFromTemplate(template, templateDictionary, destination
122
118
  postProcess: false
123
119
  });
124
120
  }
125
- }, function () {
121
+ }, () => {
126
122
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
127
123
  resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
128
124
  });
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAEH;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,wHAAwH;AAExH;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,cAAkC;IAElC,OAAO,IAAI,OAAO,CAAuB,UAAA,OAAO;QAC9C,gBAAgB;QAChB,IAAM,YAAY,GAAyB,MAAM,CAAC,6BAA6B,CAC7E,QAAQ,CACT,CAAC;QAEF,uCAAuC;QACvC,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,cAAc,CAC1C,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,SAAS,CACV,CAAC;QAEF,eAAe;QACf,IAAM,WAAW,GAAG,IAAI,OAAO,CAAO,UAAA,WAAW;YAC/C,mEAAmE;YACnE,MAAM;iBACH,iBAAiB,CAChB,YAAY,CAAC,MAAM,EACnB,YAAY,CAAC,IAAI,CAAC,IAAI,EACtB,cAAc,CACf;iBACA,IAAI,CAAC,UAAA,QAAQ;gBACZ,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE;oBACpC,WAAW,CAAC,IAAI,CAAC,CAAC;iBACnB;qBAAM;oBACL,WAAW,CAAC,QAAQ,CAAC,CA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,CACH,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAC9D,GAAG,EAAE,CACH,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAC/D,CAAC;aACL;iBAAM;gBACL,mCAAmC;gBACnC,eAAe,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,CAAC;gBAC3C,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;oBACpC,MAAM,EAAE,cAAc,CAAC,EAAE;iBAC1B,CAAC;gBAEF,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EACnC,QAAQ,CAAC,6BAA6B,GAAG,CAAC,EAC1C,cAAc,CAAC,EAAE,CAClB,CAAC;gBAEF,OAAO,CAAC;oBACN,IAAI,EAAE,eAAe;oBACrB,EAAE,EAAE,cAAc,CAAC,EAAE;oBACrB,IAAI,EAAE,eAAe,CAAC,IAAI;oBAC1B,WAAW,EAAE,KAAK;iBACnB,CAAC,CAAC;aACJ;QACH,CAAC,EACD,GAAG,EAAE;YACH,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,uBAAuB;QACvF,CAAC,CACF,CAAC;IACN,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -24,8 +24,9 @@ import * as common from "@esri/solution-common";
24
24
  *
25
25
  * @param solutionItemId The solution to contain the template
26
26
  * @param itemInfo Info about the item
27
- * @param authentication Credentials for working with AGO
27
+ * @param destAuthentication Credentials for requests to the destination organization
28
+ * @param srcAuthentication Credentials for requests to source items
28
29
  * @return A promise that will resolve when the template has been created
29
30
  */
30
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, authentication: common.UserSession): Promise<common.IItemTemplate>;
31
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
31
32
  export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
package/dist/node/file.js CHANGED
@@ -16,34 +16,34 @@
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
19
- var tslib_1 = require("tslib");
20
19
  /**
21
20
  * Manages the creation and deployment of item types that contain files.
22
21
  *
23
22
  * @module file
24
23
  */
25
- var common = require("@esri/solution-common");
24
+ const common = require("@esri/solution-common");
26
25
  // ------------------------------------------------------------------------------------------------------------------ //
27
26
  /**
28
27
  * Converts a file item into a template.
29
28
  *
30
29
  * @param solutionItemId The solution to contain the template
31
30
  * @param itemInfo Info about the item
32
- * @param authentication Credentials for working with AGO
31
+ * @param destAuthentication Credentials for requests to the destination organization
32
+ * @param srcAuthentication Credentials for requests to source items
33
33
  * @return A promise that will resolve when the template has been created
34
34
  */
35
- function convertItemToTemplate(solutionItemId, itemInfo, authentication) {
36
- return new Promise(function (resolve) {
35
+ function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
36
+ return new Promise(resolve => {
37
37
  // Init template
38
- var itemTemplate = common.createInitializedItemTemplate(itemInfo);
38
+ const itemTemplate = common.createInitializedItemTemplate(itemInfo);
39
39
  // Templatize item info property values
40
40
  itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
41
41
  // Request file
42
- var dataPromise = new Promise(function (dataResolve) {
42
+ const dataPromise = new Promise(dataResolve => {
43
43
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
44
44
  common
45
- .getItemDataAsFile(itemTemplate.itemId, itemTemplate.item.name, authentication)
46
- .then(function (response) {
45
+ .getItemDataAsFile(itemTemplate.itemId, itemTemplate.item.name, srcAuthentication)
46
+ .then(response => {
47
47
  if (!response || response.size === 0) {
48
48
  dataResolve(null);
49
49
  }
@@ -53,24 +53,24 @@ function convertItemToTemplate(solutionItemId, itemInfo, authentication) {
53
53
  });
54
54
  });
55
55
  // Request related items
56
- var relatedPromise = Promise.resolve({});
56
+ const relatedPromise = Promise.resolve({});
57
57
  // Errors are handled as resolved empty values; this means that there's no `reject` clause to handle, hence:
58
58
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
59
- Promise.all([dataPromise, relatedPromise]).then(function (responses) {
60
- var _a = (0, tslib_1.__read)(responses, 1), itemDataResponse = _a[0];
59
+ Promise.all([dataPromise, relatedPromise]).then(responses => {
60
+ const [itemDataResponse] = responses;
61
61
  if (itemDataResponse) {
62
- var resource = common.convertBlobToSupportableResource(itemDataResponse, itemTemplate.item.name);
62
+ const resource = common.convertBlobToSupportableResource(itemDataResponse, itemTemplate.item.name);
63
63
  itemTemplate.properties[resource.filename] = resource.mimeType;
64
- var storageName_1 = common.convertItemResourceToStorageResource(itemTemplate.itemId +
64
+ const storageName = common.convertItemResourceToStorageResource(itemTemplate.itemId +
65
65
  (resource.blob.name === resource.filename
66
66
  ? "_info_data"
67
67
  : "_info_dataz"), resource.blob.name, common.SolutionTemplateFormatVersion);
68
68
  common
69
- .addResourceFromBlob(resource.blob, solutionItemId, storageName_1.folder, storageName_1.filename, authentication)
70
- .then(function () {
71
- itemTemplate.resources.push(storageName_1.folder + "/" + storageName_1.filename);
69
+ .addResourceFromBlob(resource.blob, solutionItemId, storageName.folder, storageName.filename, destAuthentication)
70
+ .then(() => {
71
+ itemTemplate.resources.push(storageName.folder + "/" + storageName.filename);
72
72
  resolve(itemTemplate);
73
- }, function (error) {
73
+ }, error => {
74
74
  itemTemplate.properties["error"] = JSON.stringify(error);
75
75
  resolve(itemTemplate);
76
76
  });
@@ -83,7 +83,7 @@ function convertItemToTemplate(solutionItemId, itemInfo, authentication) {
83
83
  }
84
84
  exports.convertItemToTemplate = convertItemToTemplate;
85
85
  function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
86
- return new Promise(function (resolve) {
86
+ return new Promise(resolve => {
87
87
  // Interrupt process if progress callback returns `false`
88
88
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
89
89
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
@@ -91,7 +91,7 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
91
91
  return;
92
92
  }
93
93
  // Replace the templatized symbols in a copy of the template
94
- var newItemTemplate = common.cloneObject(template);
94
+ let newItemTemplate = common.cloneObject(template);
95
95
  newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
96
96
  /* istanbul ignore else */
97
97
  if (template.item.thumbnail) {
@@ -100,17 +100,13 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
100
100
  // Create the item, then update its URL with its new id
101
101
  common
102
102
  .createItemWithData(newItemTemplate.item, newItemTemplate.data, destinationAuthentication, templateDictionary.folderId)
103
- .then(function (createResponse) {
103
+ .then(createResponse => {
104
104
  // Interrupt process if progress callback returns `false`
105
105
  if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
106
106
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
107
107
  common
108
108
  .removeItem(createResponse.id, destinationAuthentication)
109
- .then(function () {
110
- return resolve(common.generateEmptyCreationResponse(template.type));
111
- }, function () {
112
- return resolve(common.generateEmptyCreationResponse(template.type));
113
- });
109
+ .then(() => resolve(common.generateEmptyCreationResponse(template.type)), () => resolve(common.generateEmptyCreationResponse(template.type)));
114
110
  }
115
111
  else {
116
112
  // Add the new item to the settings
@@ -126,7 +122,7 @@ function createItemFromTemplate(template, templateDictionary, destinationAuthent
126
122
  postProcess: false
127
123
  });
128
124
  }
129
- }, function () {
125
+ }, () => {
130
126
  itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
131
127
  resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
132
128
  });
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/file.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH,8CAAgD;AAEhD,wHAAwH;AAExH;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,cAAkC;IAElC,OAAO,IAAI,OAAO,CAAuB,UAAA,OAAO;QAC9C,gBAAgB;QAChB,IAAM,YAAY,GAAyB,MAAM,CAAC,6BAA6B,CAC7E,QAAQ,CACT,CAAC;QAEF,uCAAuC;QACvC,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,cAAc,CAC1C,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,SAAS,CACV,CAAC;QAEF,eAAe;QACf,IAAM,WAAW,GAAG,IAAI,OAAO,CAAO,UAAA,WAAW;YAC/C,mEAAmE;YACnE,MAAM;iBACH,iBAAiB,CAChB,YAAY,CAAC,MAAM,EACnB,YAAY,CAAC,IAAI,CAAC,IAAI,EACtB,cAAc,CACf;iBACA,IAAI,CAAC,UAAA,QAAQ;gBACZ,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE;oBACpC,WAAW,CAAC,IAAI,CAAC,CAAC;iBACnB;qBAAM;oBACL,WAAW,CAAC,QAAQ,CAAC,CAAC;iBACvB;YACH,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,wBAAwB;QACxB,IAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CACpC,EAAqC,CACtC,CAAC;QAEF,4GAA4G;QAC5G,mEAAmE;QACnE,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,cA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nC,eAAe,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,CAAC;gBAC3C,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;oBACpC,MAAM,EAAE,cAAc,CAAC,EAAE;iBAC1B,CAAC;gBAEF,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EACnC,QAAQ,CAAC,6BAA6B,GAAG,CAAC,EAC1C,cAAc,CAAC,EAAE,CAClB,CAAC;gBAEF,OAAO,CAAC;oBACN,IAAI,EAAE,eAAe;oBACrB,EAAE,EAAE,cAAc,CAAC,EAAE;oBACrB,IAAI,EAAE,eAAe,CAAC,IAAI;oBAC1B,WAAW,EAAE,KAAK;iBACnB,CAAC,CAAC;aACJ;QACH,CAAC,EACD,GAAG,EAAE;YACH,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,uBAAuB;QACvF,CAAC,CACF,CAAC;IACN,CAAC,CAAC,CAAC;AACL,CAAC;AAnGD,wDAmGC"}
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var tslib_1 = require("tslib");
18
+ const tslib_1 = require("tslib");
19
19
  /**
20
20
  * Manages the creation and deployment of item types that contain files.
21
21
  *
@@ -24,8 +24,9 @@ import * as common from "@esri/solution-common";
24
24
  *
25
25
  * @param solutionItemId The solution to contain the template
26
26
  * @param itemInfo Info about the item
27
- * @param authentication Credentials for working with AGO
27
+ * @param destAuthentication Credentials for requests to the destination organization
28
+ * @param srcAuthentication Credentials for requests to source items
28
29
  * @return A promise that will resolve when the template has been created
29
30
  */
30
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, authentication: common.UserSession): Promise<common.IItemTemplate>;
31
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
31
32
  export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-file - v1.1.2 - Apache-2.0
2
+ * @esri/solution-file - v1.2.0 - Apache-2.0
3
3
  * Copyright (c) 2018-2021 Esri, Inc.
4
- * Mon Aug 30 2021 23:57:51 GMT-0700 (Pacific Daylight Time)
4
+ * Thu Dec 09 2021 16:02:16 GMT-0800 (Pacific Standard Time)
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -16,167 +16,156 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  (function (global, factory) {
19
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/solution-common')) :
20
- typeof define === 'function' && define.amd ? define(['exports', '@esri/solution-common'], factory) :
21
- (global = global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution));
22
- }(this, (function (exports, common) { 'use strict';
19
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/solution-common')) :
20
+ typeof define === 'function' && define.amd ? define(['exports', '@esri/solution-common'], factory) :
21
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution));
22
+ })(this, (function (exports, common) { 'use strict';
23
23
 
24
- /*! *****************************************************************************
25
- Copyright (c) Microsoft Corporation. All rights reserved.
26
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
27
- this file except in compliance with the License. You may obtain a copy of the
28
- License at http://www.apache.org/licenses/LICENSE-2.0
29
-
30
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
31
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
32
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
33
- MERCHANTABLITY OR NON-INFRINGEMENT.
34
-
35
- See the Apache Version 2.0 License for specific language governing permissions
36
- and limitations under the License.
37
- ***************************************************************************** */
38
-
39
- function __read(o, n) {
40
- var m = typeof Symbol === "function" && o[Symbol.iterator];
41
- if (!m) return o;
42
- var i = m.call(o), r, ar = [], e;
43
- try {
44
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
45
- }
46
- catch (error) { e = { error: error }; }
47
- finally {
48
- try {
49
- if (r && !r.done && (m = i["return"])) m.call(i);
50
- }
51
- finally { if (e) throw e.error; }
52
- }
53
- return ar;
24
+ function _interopNamespace(e) {
25
+ if (e && e.__esModule) return e;
26
+ var n = Object.create(null);
27
+ if (e) {
28
+ Object.keys(e).forEach(function (k) {
29
+ if (k !== 'default') {
30
+ var d = Object.getOwnPropertyDescriptor(e, k);
31
+ Object.defineProperty(n, k, d.get ? d : {
32
+ enumerable: true,
33
+ get: function () { return e[k]; }
34
+ });
35
+ }
36
+ });
54
37
  }
38
+ n["default"] = e;
39
+ return Object.freeze(n);
40
+ }
55
41
 
56
- /** @license
57
- * Copyright 2018 Esri
58
- *
59
- * Licensed under the Apache License, Version 2.0 (the "License");
60
- * you may not use this file except in compliance with the License.
61
- * You may obtain a copy of the License at
62
- *
63
- * http://www.apache.org/licenses/LICENSE-2.0
64
- *
65
- * Unless required by applicable law or agreed to in writing, software
66
- * distributed under the License is distributed on an "AS IS" BASIS,
67
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
68
- * See the License for the specific language governing permissions and
69
- * limitations under the License.
70
- */
71
- // ------------------------------------------------------------------------------------------------------------------ //
72
- /**
73
- * Converts a file item into a template.
74
- *
75
- * @param solutionItemId The solution to contain the template
76
- * @param itemInfo Info about the item
77
- * @param authentication Credentials for working with AGO
78
- * @return A promise that will resolve when the template has been created
79
- */
80
- function convertItemToTemplate(solutionItemId, itemInfo, authentication) {
81
- return new Promise(function (resolve) {
82
- // Init template
83
- var itemTemplate = common.createInitializedItemTemplate(itemInfo);
84
- // Templatize item info property values
85
- itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
86
- // Request file
87
- var dataPromise = new Promise(function (dataResolve) {
88
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
89
- common.getItemDataAsFile(itemTemplate.itemId, itemTemplate.item.name, authentication)
90
- .then(function (response) {
91
- if (!response || response.size === 0) {
92
- dataResolve(null);
93
- }
94
- else {
95
- dataResolve(response);
96
- }
97
- });
98
- });
99
- // Request related items
100
- var relatedPromise = Promise.resolve({});
101
- // Errors are handled as resolved empty values; this means that there's no `reject` clause to handle, hence:
102
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
103
- Promise.all([dataPromise, relatedPromise]).then(function (responses) {
104
- var _a = __read(responses, 1), itemDataResponse = _a[0];
105
- if (itemDataResponse) {
106
- var resource = common.convertBlobToSupportableResource(itemDataResponse, itemTemplate.item.name);
107
- itemTemplate.properties[resource.filename] = resource.mimeType;
108
- var storageName_1 = common.convertItemResourceToStorageResource(itemTemplate.itemId +
109
- (resource.blob.name === resource.filename
110
- ? "_info_data"
111
- : "_info_dataz"), resource.blob.name, common.SolutionTemplateFormatVersion);
112
- common.addResourceFromBlob(resource.blob, solutionItemId, storageName_1.folder, storageName_1.filename, authentication)
113
- .then(function () {
114
- itemTemplate.resources.push(storageName_1.folder + "/" + storageName_1.filename);
115
- resolve(itemTemplate);
116
- }, function (error) {
117
- itemTemplate.properties["error"] = JSON.stringify(error);
118
- resolve(itemTemplate);
119
- });
120
- }
121
- else {
122
- resolve(itemTemplate);
123
- }
124
- });
125
- });
126
- }
127
- function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
128
- return new Promise(function (resolve) {
129
- // Interrupt process if progress callback returns `false`
130
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
131
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
132
- resolve(common.generateEmptyCreationResponse(template.type));
133
- return;
134
- }
135
- // Replace the templatized symbols in a copy of the template
136
- var newItemTemplate = common.cloneObject(template);
137
- newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
138
- /* istanbul ignore else */
139
- if (template.item.thumbnail) {
140
- newItemTemplate.item.thumbnail = template.item.thumbnail;
141
- }
142
- // Create the item, then update its URL with its new id
143
- common.createItemWithData(newItemTemplate.item, newItemTemplate.data, destinationAuthentication, templateDictionary.folderId)
144
- .then(function (createResponse) {
145
- // Interrupt process if progress callback returns `false`
146
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
147
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
148
- common.removeItem(createResponse.id, destinationAuthentication)
149
- .then(function () {
150
- return resolve(common.generateEmptyCreationResponse(template.type));
151
- }, function () {
152
- return resolve(common.generateEmptyCreationResponse(template.type));
153
- });
154
- }
155
- else {
156
- // Add the new item to the settings
157
- newItemTemplate.itemId = createResponse.id;
158
- templateDictionary[template.itemId] = {
159
- itemId: createResponse.id
160
- };
161
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.id);
162
- resolve({
163
- item: newItemTemplate,
164
- id: createResponse.id,
165
- type: newItemTemplate.type,
166
- postProcess: false
167
- });
168
- }
169
- }, function () {
170
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
171
- resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item
172
- });
173
- });
174
- }
42
+ var common__namespace = /*#__PURE__*/_interopNamespace(common);
43
+
44
+ /** @license
45
+ * Copyright 2018 Esri
46
+ *
47
+ * Licensed under the Apache License, Version 2.0 (the "License");
48
+ * you may not use this file except in compliance with the License.
49
+ * You may obtain a copy of the License at
50
+ *
51
+ * http://www.apache.org/licenses/LICENSE-2.0
52
+ *
53
+ * Unless required by applicable law or agreed to in writing, software
54
+ * distributed under the License is distributed on an "AS IS" BASIS,
55
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
56
+ * See the License for the specific language governing permissions and
57
+ * limitations under the License.
58
+ */
59
+ // ------------------------------------------------------------------------------------------------------------------ //
60
+ /**
61
+ * Converts a file item into a template.
62
+ *
63
+ * @param solutionItemId The solution to contain the template
64
+ * @param itemInfo Info about the item
65
+ * @param destAuthentication Credentials for requests to the destination organization
66
+ * @param srcAuthentication Credentials for requests to source items
67
+ * @return A promise that will resolve when the template has been created
68
+ */
69
+ function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication) {
70
+ return new Promise(resolve => {
71
+ // Init template
72
+ const itemTemplate = common__namespace.createInitializedItemTemplate(itemInfo);
73
+ // Templatize item info property values
74
+ itemTemplate.item.id = common__namespace.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
75
+ // Request file
76
+ const dataPromise = new Promise(dataResolve => {
77
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
78
+ common__namespace
79
+ .getItemDataAsFile(itemTemplate.itemId, itemTemplate.item.name, srcAuthentication)
80
+ .then(response => {
81
+ if (!response || response.size === 0) {
82
+ dataResolve(null);
83
+ }
84
+ else {
85
+ dataResolve(response);
86
+ }
87
+ });
88
+ });
89
+ // Request related items
90
+ const relatedPromise = Promise.resolve({});
91
+ // Errors are handled as resolved empty values; this means that there's no `reject` clause to handle, hence:
92
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
93
+ Promise.all([dataPromise, relatedPromise]).then(responses => {
94
+ const [itemDataResponse] = responses;
95
+ if (itemDataResponse) {
96
+ const resource = common__namespace.convertBlobToSupportableResource(itemDataResponse, itemTemplate.item.name);
97
+ itemTemplate.properties[resource.filename] = resource.mimeType;
98
+ const storageName = common__namespace.convertItemResourceToStorageResource(itemTemplate.itemId +
99
+ (resource.blob.name === resource.filename
100
+ ? "_info_data"
101
+ : "_info_dataz"), resource.blob.name, common__namespace.SolutionTemplateFormatVersion);
102
+ common__namespace
103
+ .addResourceFromBlob(resource.blob, solutionItemId, storageName.folder, storageName.filename, destAuthentication)
104
+ .then(() => {
105
+ itemTemplate.resources.push(storageName.folder + "/" + storageName.filename);
106
+ resolve(itemTemplate);
107
+ }, error => {
108
+ itemTemplate.properties["error"] = JSON.stringify(error);
109
+ resolve(itemTemplate);
110
+ });
111
+ }
112
+ else {
113
+ resolve(itemTemplate);
114
+ }
115
+ });
116
+ });
117
+ }
118
+ function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
119
+ return new Promise(resolve => {
120
+ // Interrupt process if progress callback returns `false`
121
+ if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Started, 0)) {
122
+ itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Ignored, 0);
123
+ resolve(common__namespace.generateEmptyCreationResponse(template.type));
124
+ return;
125
+ }
126
+ // Replace the templatized symbols in a copy of the template
127
+ let newItemTemplate = common__namespace.cloneObject(template);
128
+ newItemTemplate = common__namespace.replaceInTemplate(newItemTemplate, templateDictionary);
129
+ /* istanbul ignore else */
130
+ if (template.item.thumbnail) {
131
+ newItemTemplate.item.thumbnail = template.item.thumbnail;
132
+ }
133
+ // Create the item, then update its URL with its new id
134
+ common__namespace
135
+ .createItemWithData(newItemTemplate.item, newItemTemplate.data, destinationAuthentication, templateDictionary.folderId)
136
+ .then(createResponse => {
137
+ // Interrupt process if progress callback returns `false`
138
+ if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
139
+ itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Cancelled, 0);
140
+ common__namespace
141
+ .removeItem(createResponse.id, destinationAuthentication)
142
+ .then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
143
+ }
144
+ else {
145
+ // Add the new item to the settings
146
+ newItemTemplate.itemId = createResponse.id;
147
+ templateDictionary[template.itemId] = {
148
+ itemId: createResponse.id
149
+ };
150
+ itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.id);
151
+ resolve({
152
+ item: newItemTemplate,
153
+ id: createResponse.id,
154
+ type: newItemTemplate.type,
155
+ postProcess: false
156
+ });
157
+ }
158
+ }, () => {
159
+ itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
160
+ resolve(common__namespace.generateEmptyCreationResponse(template.type)); // fails to create item
161
+ });
162
+ });
163
+ }
175
164
 
176
- exports.convertItemToTemplate = convertItemToTemplate;
177
- exports.createItemFromTemplate = createItemFromTemplate;
165
+ exports.convertItemToTemplate = convertItemToTemplate;
166
+ exports.createItemFromTemplate = createItemFromTemplate;
178
167
 
179
- Object.defineProperty(exports, '__esModule', { value: true });
168
+ Object.defineProperty(exports, '__esModule', { value: true });
180
169
 
181
- })));
170
+ }));
182
171
  //# sourceMappingURL=file.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file.umd.js","sources":["../../src/file.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of item types that contain files.\r\n *\r\n * @module file\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Converts a file item into a template.\r\n *\r\n * @param solutionItemId The solution to contain the template\r\n * @param itemInfo Info about the item\r\n * @param authentication Credentials for working with AGO\r\n * @return A promise that will resolve when the template has been created\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n authentication: common.UserSession\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>(resolve => {\r\n // Init template\r\n const itemTemplate: common.IItemTemplate = common.createInitializedItemTemplate(\r\n itemInfo\r\n );\r\n\r\n // Templatize item info property values\r\n itemTemplate.item.id = common.templatizeTerm(\r\n itemTemplate.item.id,\r\n itemTemplate.item.id,\r\n \".itemId\"\r\n );\r\n\r\n // Request file\r\n const dataPromise = new Promise<File>(dataResolve => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .getItemDataAsFile(\r\n itemTemplate.itemId,\r\n itemTemplate.item.name,\r\n authentication\r\n )\r\n .then(response => {\r\n if (!response || response.size === 0) {\r\n dataResolve(null);\r\n } else {\r\n dataResolve(response);\r\n }\r\n });\r\n });\r\n\r\n // Request related items\r\n const relatedPromise = Promise.resolve(\r\n {} as common.IGetRelatedItemsResponse\r\n );\r\n\r\n // Errors are handled as resolved empty values; this means that there's no `reject` clause to handle, hence:\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all([dataPromise, relatedPromise]).then(responses => {\r\n const [itemDataResponse] = responses;\r\n\r\n if (itemDataResponse) {\r\n const resource: common.IFileMimeTyped = common.convertBlobToSupportableResource(\r\n itemDataResponse,\r\n itemTemplate.item.name\r\n );\r\n itemTemplate.properties[resource.filename] = resource.mimeType;\r\n\r\n const storageName = common.convertItemResourceToStorageResource(\r\n itemTemplate.itemId +\r\n ((resource.blob as File).name === resource.filename\r\n ? \"_info_data\"\r\n : \"_info_dataz\"),\r\n (resource.blob as File).name,\r\n common.SolutionTemplateFormatVersion\r\n );\r\n common\r\n .addResourceFromBlob(\r\n resource.blob,\r\n solutionItemId,\r\n storageName.folder,\r\n storageName.filename,\r\n authentication\r\n )\r\n .then(\r\n () => {\r\n itemTemplate.resources.push(\r\n storageName.folder + \"/\" + storageName.filename\r\n );\r\n resolve(itemTemplate);\r\n },\r\n error => {\r\n itemTemplate.properties[\"error\"] = JSON.stringify(error);\r\n resolve(itemTemplate);\r\n }\r\n );\r\n } else {\r\n resolve(itemTemplate);\r\n }\r\n });\r\n });\r\n}\r\n\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n /* istanbul ignore else */\r\n if (template.item.thumbnail) {\r\n newItemTemplate.item.thumbnail = template.item.thumbnail;\r\n }\r\n\r\n // Create the item, then update its URL with its new id\r\n common\r\n .createItemWithData(\r\n newItemTemplate.item,\r\n newItemTemplate.data,\r\n destinationAuthentication,\r\n templateDictionary.folderId\r\n )\r\n .then(\r\n createResponse => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(createResponse.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type)),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // Add the new item to the settings\r\n newItemTemplate.itemId = createResponse.id;\r\n templateDictionary[template.itemId] = {\r\n itemId: createResponse.id\r\n };\r\n\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.id\r\n );\r\n\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n"],"names":["common.createInitializedItemTemplate","common.templatizeTerm","common\r\n .getItemDataAsFile","common.convertBlobToSupportableResource","common.convertItemResourceToStorageResource","common.SolutionTemplateFormatVersion","common\r\n .addResourceFromBlob","common.EItemProgressStatus","common.generateEmptyCreationResponse","common.cloneObject","common.replaceInTemplate","common\r\n .createItemWithData","common\r\n .removeItem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;;;;;;;;;;;;;;;IAwBA;IAEA;;;;;;;;aAQgB,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,cAAkC;QAElC,OAAO,IAAI,OAAO,CAAuB,UAAA,OAAO;;YAE9C,IAAM,YAAY,GAAyBA,oCAAoC,CAC7E,QAAQ,CACT,CAAC;;YAGF,YAAY,CAAC,IAAI,CAAC,EAAE,GAAGC,qBAAqB,CAC1C,YAAY,CAAC,IAAI,CAAC,EAAE,EACpB,YAAY,CAAC,IAAI,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src/file.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of item types that contain files.\r\n *\r\n * @module file\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Converts a file item into a template.\r\n *\r\n * @param solutionItemId The solution to contain the template\r\n * @param itemInfo Info about the item\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @return A promise that will resolve when the template has been created\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: common.UserSession,\r\n srcAuthentication: common.UserSession\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>(resolve => {\r\n // Init template\r\n const itemTemplate: common.IItemTemplate = common.createInitializedItemTemplate(\r\n itemInfo\r\n );\r\n\r\n // Templatize item info property values\r\n itemTemplate.item.id = common.templatizeTerm(\r\n itemTemplate.item.id,\r\n itemTemplate.item.id,\r\n \".itemId\"\r\n );\r\n\r\n // Request file\r\n const dataPromise = new Promise<File>(dataResolve => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .getItemDataAsFile(\r\n itemTemplate.itemId,\r\n itemTemplate.item.name,\r\n srcAuthentication\r\n )\r\n .then(response => {\r\n if (!response || response.size === 0) {\r\n dataResolve(null);\r\n } else {\r\n dataResolve(response);\r\n }\r\n });\r\n });\r\n\r\n // Request related items\r\n const relatedPromise = Promise.resolve(\r\n {} as common.IGetRelatedItemsResponse\r\n );\r\n\r\n // Errors are handled as resolved empty values; this means that there's no `reject` clause to handle, hence:\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all([dataPromise, relatedPromise]).then(responses => {\r\n const [itemDataResponse] = responses;\r\n\r\n if (itemDataResponse) {\r\n const resource: common.IFileMimeTyped = common.convertBlobToSupportableResource(\r\n itemDataResponse,\r\n itemTemplate.item.name\r\n );\r\n itemTemplate.properties[resource.filename] = resource.mimeType;\r\n\r\n const storageName = common.convertItemResourceToStorageResource(\r\n itemTemplate.itemId +\r\n ((resource.blob as File).name === resource.filename\r\n ? \"_info_data\"\r\n : \"_info_dataz\"),\r\n (resource.blob as File).name,\r\n common.SolutionTemplateFormatVersion\r\n );\r\n common\r\n .addResourceFromBlob(\r\n resource.blob,\r\n solutionItemId,\r\n storageName.folder,\r\n storageName.filename,\r\n destAuthentication\r\n )\r\n .then(\r\n () => {\r\n itemTemplate.resources.push(\r\n storageName.folder + \"/\" + storageName.filename\r\n );\r\n resolve(itemTemplate);\r\n },\r\n error => {\r\n itemTemplate.properties[\"error\"] = JSON.stringify(error);\r\n resolve(itemTemplate);\r\n }\r\n );\r\n } else {\r\n resolve(itemTemplate);\r\n }\r\n });\r\n });\r\n}\r\n\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n /* istanbul ignore else */\r\n if (template.item.thumbnail) {\r\n newItemTemplate.item.thumbnail = template.item.thumbnail;\r\n }\r\n\r\n // Create the item, then update its URL with its new id\r\n common\r\n .createItemWithData(\r\n newItemTemplate.item,\r\n newItemTemplate.data,\r\n destinationAuthentication,\r\n templateDictionary.folderId\r\n )\r\n .then(\r\n createResponse => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(createResponse.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type)),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // Add the new item to the settings\r\n newItemTemplate.itemId = createResponse.id;\r\n templateDictionary[template.itemId] = {\r\n itemId: createResponse.id\r\n };\r\n\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.id\r\n );\r\n\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n"],"names":["common"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;EAwBA;EAEA;;;;;;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E,CAClB,CAAC;kBAEF,OAAO,CAAC;sBACN,IAAI,EAAE,eAAe;sBACrB,EAAE,EAAE,cAAc,CAAC,EAAE;sBACrB,IAAI,EAAE,eAAe,CAAC,IAAI;sBAC1B,WAAW,EAAE,KAAK;mBACnB,CAAC,CAAC;eACJ;WACF,EACD;cACE,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACfA,iBAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;cACF,OAAO,CAACA,iBAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;WAC9D,CACF,CAAC;OACL,CAAC,CAAC;EACL;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-file - v1.1.2 - Apache-2.0
2
+ * @esri/solution-file - v1.2.0 - Apache-2.0
3
3
  * Copyright (c) 2018-2021 Esri, Inc.
4
- * Mon Aug 30 2021 23:57:56 GMT-0700 (Pacific Daylight Time)
4
+ * Thu Dec 09 2021 16:02:20 GMT-0800 (Pacific Standard Time)
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -15,5 +15,5 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-common")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-common"],t):t((e=e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution)}(this,function(e,t){"use strict";e.convertItemToTemplate=function(e,o,i){return new Promise(function(r){var n=t.createInitializedItemTemplate(o);n.item.id=t.templatizeTerm(n.item.id,n.item.id,".itemId");var m=new Promise(function(e){t.getItemDataAsFile(n.itemId,n.item.name,i).then(function(t){t&&0!==t.size?e(t):e(null)})}),a=Promise.resolve({});Promise.all([m,a]).then(function(o){var m=function(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var i,r,n=o.call(e),m=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)m.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(r)throw r.error}}return m}(o,1)[0];if(m){var a=t.convertBlobToSupportableResource(m,n.item.name);n.properties[a.filename]=a.mimeType;var s=t.convertItemResourceToStorageResource(n.itemId+(a.blob.name===a.filename?"_info_data":"_info_dataz"),a.blob.name,t.SolutionTemplateFormatVersion);t.addResourceFromBlob(a.blob,e,s.folder,s.filename,i).then(function(){n.resources.push(s.folder+"/"+s.filename),r(n)},function(e){n.properties.error=JSON.stringify(e),r(n)})}else r(n)})})},e.createItemFromTemplate=function(e,o,i,r){return new Promise(function(n){if(!r(e.itemId,t.EItemProgressStatus.Started,0))return r(e.itemId,t.EItemProgressStatus.Ignored,0),void n(t.generateEmptyCreationResponse(e.type));var m=t.cloneObject(e);m=t.replaceInTemplate(m,o),e.item.thumbnail&&(m.item.thumbnail=e.item.thumbnail),t.createItemWithData(m.item,m.data,i,o.folderId).then(function(a){r(e.itemId,t.EItemProgressStatus.Created,e.estimatedDeploymentCostFactor/2,a.id)?(m.itemId=a.id,o[e.itemId]={itemId:a.id},r(e.itemId,t.EItemProgressStatus.Finished,e.estimatedDeploymentCostFactor/2,a.id),n({item:m,id:a.id,type:m.type,postProcess:!1})):(r(e.itemId,t.EItemProgressStatus.Cancelled,0),t.removeItem(a.id,i).then(function(){return n(t.generateEmptyCreationResponse(e.type))},function(){return n(t.generateEmptyCreationResponse(e.type))}))},function(){r(e.itemId,t.EItemProgressStatus.Failed,0),n(t.generateEmptyCreationResponse(e.type))})})},Object.defineProperty(e,"__esModule",{value:!0})});
18
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-common")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution)}(this,(function(e,t){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var i=o(t);e.convertItemToTemplate=function(e,t,o,r){return new Promise((n=>{const m=i.createInitializedItemTemplate(t);m.item.id=i.templatizeTerm(m.item.id,m.item.id,".itemId");const s=new Promise((e=>{i.getItemDataAsFile(m.itemId,m.item.name,r).then((t=>{t&&0!==t.size?e(t):e(null)}))})),a=Promise.resolve({});Promise.all([s,a]).then((t=>{const[r]=t;if(r){const t=i.convertBlobToSupportableResource(r,m.item.name);m.properties[t.filename]=t.mimeType;const s=i.convertItemResourceToStorageResource(m.itemId+(t.blob.name===t.filename?"_info_data":"_info_dataz"),t.blob.name,i.SolutionTemplateFormatVersion);i.addResourceFromBlob(t.blob,e,s.folder,s.filename,o).then((()=>{m.resources.push(s.folder+"/"+s.filename),n(m)}),(e=>{m.properties.error=JSON.stringify(e),n(m)}))}else n(m)}))}))},e.createItemFromTemplate=function(e,t,o,r){return new Promise((n=>{if(!r(e.itemId,i.EItemProgressStatus.Started,0))return r(e.itemId,i.EItemProgressStatus.Ignored,0),void n(i.generateEmptyCreationResponse(e.type));let m=i.cloneObject(e);m=i.replaceInTemplate(m,t),e.item.thumbnail&&(m.item.thumbnail=e.item.thumbnail),i.createItemWithData(m.item,m.data,o,t.folderId).then((s=>{r(e.itemId,i.EItemProgressStatus.Created,e.estimatedDeploymentCostFactor/2,s.id)?(m.itemId=s.id,t[e.itemId]={itemId:s.id},r(e.itemId,i.EItemProgressStatus.Finished,e.estimatedDeploymentCostFactor/2,s.id),n({item:m,id:s.id,type:m.type,postProcess:!1})):(r(e.itemId,i.EItemProgressStatus.Cancelled,0),i.removeItem(s.id,o).then((()=>n(i.generateEmptyCreationResponse(e.type))),(()=>n(i.generateEmptyCreationResponse(e.type)))))}),(()=>{r(e.itemId,i.EItemProgressStatus.Failed,0),n(i.generateEmptyCreationResponse(e.type))}))}))},Object.defineProperty(e,"__esModule",{value:!0})}));
19
19
  //# sourceMappingURL=file.umd.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file.umd.min.js","sources":["../../src/file.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of item types that contain files.\r\n *\r\n * @module file\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Converts a file item into a template.\r\n *\r\n * @param solutionItemId The solution to contain the template\r\n * @param itemInfo Info about the item\r\n * @param authentication Credentials for working with AGO\r\n * @return A promise that will resolve when the template has been created\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n authentication: common.UserSession\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>(resolve => {\r\n // Init template\r\n const itemTemplate: common.IItemTemplate = common.createInitializedItemTemplate(\r\n itemInfo\r\n );\r\n\r\n // Templatize item info property values\r\n itemTemplate.item.id = common.templatizeTerm(\r\n itemTemplate.item.id,\r\n itemTemplate.item.id,\r\n \".itemId\"\r\n );\r\n\r\n // Request file\r\n const dataPromise = new Promise<File>(dataResolve => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .getItemDataAsFile(\r\n itemTemplate.itemId,\r\n itemTemplate.item.name,\r\n authentication\r\n )\r\n .then(response => {\r\n if (!response || response.size === 0) {\r\n dataResolve(null);\r\n } else {\r\n dataResolve(response);\r\n }\r\n });\r\n });\r\n\r\n // Request related items\r\n const relatedPromise = Promise.resolve(\r\n {} as common.IGetRelatedItemsResponse\r\n );\r\n\r\n // Errors are handled as resolved empty values; this means that there's no `reject` clause to handle, hence:\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all([dataPromise, relatedPromise]).then(responses => {\r\n const [itemDataResponse] = responses;\r\n\r\n if (itemDataResponse) {\r\n const resource: common.IFileMimeTyped = common.convertBlobToSupportableResource(\r\n itemDataResponse,\r\n itemTemplate.item.name\r\n );\r\n itemTemplate.properties[resource.filename] = resource.mimeType;\r\n\r\n const storageName = common.convertItemResourceToStorageResource(\r\n itemTemplate.itemId +\r\n ((resource.blob as File).name === resource.filename\r\n ? \"_info_data\"\r\n : \"_info_dataz\"),\r\n (resource.blob as File).name,\r\n common.SolutionTemplateFormatVersion\r\n );\r\n common\r\n .addResourceFromBlob(\r\n resource.blob,\r\n solutionItemId,\r\n storageName.folder,\r\n storageName.filename,\r\n authentication\r\n )\r\n .then(\r\n () => {\r\n itemTemplate.resources.push(\r\n storageName.folder + \"/\" + storageName.filename\r\n );\r\n resolve(itemTemplate);\r\n },\r\n error => {\r\n itemTemplate.properties[\"error\"] = JSON.stringify(error);\r\n resolve(itemTemplate);\r\n }\r\n );\r\n } else {\r\n resolve(itemTemplate);\r\n }\r\n });\r\n });\r\n}\r\n\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n /* istanbul ignore else */\r\n if (template.item.thumbnail) {\r\n newItemTemplate.item.thumbnail = template.item.thumbnail;\r\n }\r\n\r\n // Create the item, then update its URL with its new id\r\n common\r\n .createItemWithData(\r\n newItemTemplate.item,\r\n newItemTemplate.data,\r\n destinationAuthentication,\r\n templateDictionary.folderId\r\n )\r\n .then(\r\n createResponse => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(createResponse.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type)),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // Add the new item to the settings\r\n newItemTemplate.itemId = createResponse.id;\r\n templateDictionary[template.itemId] = {\r\n itemId: createResponse.id\r\n };\r\n\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.id\r\n );\r\n\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n"],"names":["solutionItemId","itemInfo","authentication","Promise","resolve","itemTemplate","common.createInitializedItemTemplate","item","id","common.templatizeTerm","dataPromise","dataResolve","common\r\n .getItemDataAsFile","itemId","name","then","response","size","relatedPromise","all","responses","itemDataResponse","__read","resource","common.convertBlobToSupportableResource","properties","filename","mimeType","storageName_1","common.convertItemResourceToStorageResource","blob","common.SolutionTemplateFormatVersion","common\r\n .addResourceFromBlob","folder","resources","push","error","JSON","stringify","template","templateDictionary","destinationAuthentication","itemProgressCallback","common.EItemProgressStatus","Started","Ignored","common.generateEmptyCreationResponse","type","newItemTemplate","common.cloneObject","common.replaceInTemplate","thumbnail","common\r\n .createItemWithData","data","folderId","createResponse","Created","estimatedDeploymentCostFactor","Finished","postProcess","Cancelled","common\r\n .removeItem","Failed"],"mappings":";;;;;;;;;;;;;;;;;0UAmCEA,EACAC,EACAC,GAEA,OAAO,IAAIC,QAA8B,SAAAC,GAEvC,IAAMC,EAAqCC,gCACzCL,GAIFI,EAAaE,KAAKC,GAAKC,iBACrBJ,EAAaE,KAAKC,GAClBH,EAAaE,KAAKC,GAClB,WAIF,IAAME,EAAc,IAAIP,QAAc,SAAAQ,GAEpCC,oBAEIP,EAAaQ,OACbR,EAAaE,KAAKO,KAClBZ,GAEDa,KAAK,SAAAC,GACCA,GAA8B,IAAlBA,EAASC,KAGxBN,EAAYK,GAFZL,EAAY,UAQdO,EAAiBf,QAAQC,QAC7B,IAKFD,QAAQgB,IAAI,CAACT,EAAaQ,IAAiBH,KAAK,SAAAK,GACxC,IAACC,yRAADC,CAAqBF,QAE3B,GAAIC,EAAkB,CACpB,IAAME,EAAkCC,mCACtCH,EACAhB,EAAaE,KAAKO,MAEpBT,EAAaoB,WAAWF,EAASG,UAAYH,EAASI,SAEtD,IAAMC,EAAcC,uCAClBxB,EAAaQ,QACTU,EAASO,KAAchB,OAASS,EAASG,SACvC,aACA,eACLH,EAASO,KAAchB,KACxBiB,iCAEFC,sBAEIT,EAASO,KACT9B,EACA4B,EAA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Q"}
1
+ {"version":3,"file":"file.umd.min.js","sources":["../../src/file.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of item types that contain files.\r\n *\r\n * @module file\r\n */\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n// ------------------------------------------------------------------------------------------------------------------ //\r\n\r\n/**\r\n * Converts a file item into a template.\r\n *\r\n * @param solutionItemId The solution to contain the template\r\n * @param itemInfo Info about the item\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @return A promise that will resolve when the template has been created\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: common.UserSession,\r\n srcAuthentication: common.UserSession\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>(resolve => {\r\n // Init template\r\n const itemTemplate: common.IItemTemplate = common.createInitializedItemTemplate(\r\n itemInfo\r\n );\r\n\r\n // Templatize item info property values\r\n itemTemplate.item.id = common.templatizeTerm(\r\n itemTemplate.item.id,\r\n itemTemplate.item.id,\r\n \".itemId\"\r\n );\r\n\r\n // Request file\r\n const dataPromise = new Promise<File>(dataResolve => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common\r\n .getItemDataAsFile(\r\n itemTemplate.itemId,\r\n itemTemplate.item.name,\r\n srcAuthentication\r\n )\r\n .then(response => {\r\n if (!response || response.size === 0) {\r\n dataResolve(null);\r\n } else {\r\n dataResolve(response);\r\n }\r\n });\r\n });\r\n\r\n // Request related items\r\n const relatedPromise = Promise.resolve(\r\n {} as common.IGetRelatedItemsResponse\r\n );\r\n\r\n // Errors are handled as resolved empty values; this means that there's no `reject` clause to handle, hence:\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n Promise.all([dataPromise, relatedPromise]).then(responses => {\r\n const [itemDataResponse] = responses;\r\n\r\n if (itemDataResponse) {\r\n const resource: common.IFileMimeTyped = common.convertBlobToSupportableResource(\r\n itemDataResponse,\r\n itemTemplate.item.name\r\n );\r\n itemTemplate.properties[resource.filename] = resource.mimeType;\r\n\r\n const storageName = common.convertItemResourceToStorageResource(\r\n itemTemplate.itemId +\r\n ((resource.blob as File).name === resource.filename\r\n ? \"_info_data\"\r\n : \"_info_dataz\"),\r\n (resource.blob as File).name,\r\n common.SolutionTemplateFormatVersion\r\n );\r\n common\r\n .addResourceFromBlob(\r\n resource.blob,\r\n solutionItemId,\r\n storageName.folder,\r\n storageName.filename,\r\n destAuthentication\r\n )\r\n .then(\r\n () => {\r\n itemTemplate.resources.push(\r\n storageName.folder + \"/\" + storageName.filename\r\n );\r\n resolve(itemTemplate);\r\n },\r\n error => {\r\n itemTemplate.properties[\"error\"] = JSON.stringify(error);\r\n resolve(itemTemplate);\r\n }\r\n );\r\n } else {\r\n resolve(itemTemplate);\r\n }\r\n });\r\n });\r\n}\r\n\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n /* istanbul ignore else */\r\n if (template.item.thumbnail) {\r\n newItemTemplate.item.thumbnail = template.item.thumbnail;\r\n }\r\n\r\n // Create the item, then update its URL with its new id\r\n common\r\n .createItemWithData(\r\n newItemTemplate.item,\r\n newItemTemplate.data,\r\n destinationAuthentication,\r\n templateDictionary.folderId\r\n )\r\n .then(\r\n createResponse => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.id\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(createResponse.id, destinationAuthentication)\r\n .then(\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type)),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // Add the new item to the settings\r\n newItemTemplate.itemId = createResponse.id;\r\n templateDictionary[template.itemId] = {\r\n itemId: createResponse.id\r\n };\r\n\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.id\r\n );\r\n\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.id,\r\n type: newItemTemplate.type,\r\n postProcess: false\r\n });\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n"],"names":["solutionItemId","itemInfo","destAuthentication","srcAuthentication","Promise","resolve","itemTemplate","common","createInitializedItemTemplate","item","id","templatizeTerm","dataPromise","dataResolve","getItemDataAsFile","itemId","name","then","response","size","relatedPromise","all","responses","itemDataResponse","resource","convertBlobToSupportableResource","properties","filename","mimeType","storageName","convertItemResourceToStorageResource","blob","SolutionTemplateFormatVersion","addResourceFromBlob","folder","resources","push","error","JSON","stringify","template","templateDictionary","destinationAuthentication","itemProgressCallback","EItemProgressStatus","Started","Ignored","generateEmptyCreationResponse","type","newItemTemplate","cloneObject","replaceInTemplate","thumbnail","createItemWithData","data","folderId","createResponse","Created","estimatedDeploymentCostFactor","Finished","postProcess","Cancelled","removeItem","Failed"],"mappings":";;;;;;;;;;;;;;;;;+pBAoCEA,EACAC,EACAC,EACAC,GAEA,OAAO,IAAIC,SAA8BC,IAEvC,MAAMC,EAAqCC,EAAOC,8BAChDP,GAIFK,EAAaG,KAAKC,GAAKH,EAAOI,eAC5BL,EAAaG,KAAKC,GAClBJ,EAAaG,KAAKC,GAClB,WAIF,MAAME,EAAc,IAAIR,SAAcS,IAEpCN,EACGO,kBACCR,EAAaS,OACbT,EAAaG,KAAKO,KAClBb,GAEDc,MAAKC,IACCA,GAA8B,IAAlBA,EAASC,KAGxBN,EAAYK,GAFZL,EAAY,YAQdO,EAAiBhB,QAAQC,QAC7B,IAKFD,QAAQiB,IAAI,CAACT,EAAaQ,IAAiBH,MAAKK,IAC9C,MAAOC,GAAoBD,EAE3B,GAAIC,EAAkB,CACpB,MAAMC,EAAkCjB,EAAOkB,iCAC7CF,EACAjB,EAAaG,KAAKO,MAEpBV,EAAaoB,WAAWF,EAASG,UAAYH,EAASI,SAEtD,MAAMC,EAActB,EAAOuB,qCACzBxB,EAAaS,QACTS,EAASO,KAAcf,OAASQ,EAASG,SACvC,aACA,eACLH,EAASO,KAAcf,KACxBT,EAAOyB,+BAETzB,EACG0B,oBACCT,EAASO,KACT/B,EACA6B,EAAYK,OACZL,EAAYF,SACZzB,GAEDe,MACC,KACEX,EAAa6B,UAAUC,KACrBP,EAAYK,OAAS,IAAML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@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@esri/solution-file",
3
- "version": "1.1.2",
4
- "description": "Manages the creation and deployment of item types that contain files for @esri/solution.js.",
3
+ "version": "1.2.0",
4
+ "description": "Manages the creation and deployment of item types that contain files for @esri/solution.js.",
5
5
  "main": "dist/node/index.js",
6
6
  "unpkg": "dist/umd/file.umd.min.js",
7
7
  "module": "dist/esm/index.js",
@@ -13,32 +13,32 @@
13
13
  "dist/**"
14
14
  ],
15
15
  "devDependencies": {
16
- "@esri/arcgis-rest-auth": "^3.3.0",
17
- "@esri/arcgis-rest-feature-layer": "^3.3.0",
18
- "@esri/arcgis-rest-portal": "^3.3.0",
19
- "@esri/arcgis-rest-request": "^3.3.0",
20
- "@esri/arcgis-rest-service-admin": "^3.3.0",
21
- "@esri/hub-common": "^8.16.0",
22
- "@esri/hub-initiatives": "^8.16.0",
23
- "@esri/hub-sites": "^8.16.0",
24
- "@esri/hub-teams": "^8.16.0",
25
- "rollup": "^1.22.0",
26
- "typescript": "^4.3.4"
16
+ "@esri/arcgis-rest-auth": "3.4.3",
17
+ "@esri/arcgis-rest-feature-layer": "3.4.3",
18
+ "@esri/arcgis-rest-portal": "3.4.3",
19
+ "@esri/arcgis-rest-request": "3.4.3",
20
+ "@esri/arcgis-rest-service-admin": "3.4.3",
21
+ "@esri/hub-common": "9.7.2",
22
+ "@esri/hub-initiatives": "9.7.2",
23
+ "@esri/hub-sites": "9.7.2",
24
+ "@esri/hub-teams": "9.7.2",
25
+ "rollup": "^2.60.0",
26
+ "typescript": "^4.4.4"
27
27
  },
28
28
  "peerDependencies": {
29
- "@esri/arcgis-rest-auth": "^3.3.0",
30
- "@esri/arcgis-rest-feature-layer": "^3.3.0",
31
- "@esri/arcgis-rest-portal": "^3.3.0",
32
- "@esri/arcgis-rest-request": "^3.3.0",
33
- "@esri/arcgis-rest-service-admin": "^3.3.0",
34
- "@esri/hub-common": "^8.16.0",
35
- "@esri/hub-initiatives": "^8.16.0",
36
- "@esri/hub-sites": "^8.16.0",
37
- "@esri/hub-teams": "^8.16.0"
29
+ "@esri/arcgis-rest-auth": "3.4.3",
30
+ "@esri/arcgis-rest-feature-layer": "3.4.3",
31
+ "@esri/arcgis-rest-portal": "3.4.3",
32
+ "@esri/arcgis-rest-request": "3.4.3",
33
+ "@esri/arcgis-rest-service-admin": "3.4.3",
34
+ "@esri/hub-common": "9.7.2",
35
+ "@esri/hub-initiatives": "9.7.2",
36
+ "@esri/hub-sites": "9.7.2",
37
+ "@esri/hub-teams": "9.7.2"
38
38
  },
39
39
  "dependencies": {
40
- "@esri/solution-common": "^1.1.2",
41
- "tslib": "^1.13.0"
40
+ "@esri/solution-common": "^1.2.0",
41
+ "tslib": "1.13.0"
42
42
  },
43
43
  "scripts": {
44
44
  "prepare": "npm run build",
@@ -90,5 +90,5 @@
90
90
  "esri",
91
91
  "ES6"
92
92
  ],
93
- "gitHead": "c1ea3f67a733c7ee0b79cc19828347cfea9cd163"
93
+ "gitHead": "70f706fb28a50db0b9b13030f263f8e9e270b98d"
94
94
  }