@esri/solution-workflow 5.2.3 → 5.2.4

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.
@@ -0,0 +1,21 @@
1
+ /** @license
2
+ * Copyright 2024 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Manages the creation and deployment of workflow item types.
18
+ *
19
+ * @module workflow
20
+ */
21
+ export * from "./workflow";
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2024 Esri
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const tslib_1 = require("tslib");
19
+ /**
20
+ * Manages the creation and deployment of workflow item types.
21
+ *
22
+ * @module workflow
23
+ */
24
+ tslib_1.__exportStar(require("./workflow"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,qDAA2B"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,41 @@
1
+ /** @license
2
+ * Copyright 2024 Esri
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ /**
17
+ * Manages the creation and deployment of workflow item types.
18
+ *
19
+ * @module workflow
20
+ */
21
+ import * as common from "@esri/solution-common";
22
+ /**
23
+ * Converts a workflow item into a template.
24
+ *
25
+ * @param itemInfo Info about the item
26
+ * @param destAuthentication Credentials for requests to the destination organization
27
+ * @param srcAuthentication Credentials for requests to source items
28
+ * @returns A promise that will resolve when the template has been created
29
+ */
30
+ export declare function convertItemToTemplate(itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
31
+ /**
32
+ * Converts a workflow template into a new item.
33
+ *
34
+ * @param template Workflow template
35
+ * @param templateDictionary Dictionary of terms to replace in the template
36
+ * @param destAuthentication Credentials for requests to the destination organization
37
+ * @param itemProgressCallback Callback function to report the progress of the item creation
38
+ * @returns Promise resolving with the detemplatized item template, the new item's id, and a boolean
39
+ * indicating if post-processing is needed
40
+ */
41
+ export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2024 Esri
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
19
+ const tslib_1 = require("tslib");
20
+ /**
21
+ * Manages the creation and deployment of workflow item types.
22
+ *
23
+ * @module workflow
24
+ */
25
+ const common = tslib_1.__importStar(require("@esri/solution-common"));
26
+ // ------------------------------------------------------------------------------------------------------------------ //
27
+ /**
28
+ * Converts a workflow item into a template.
29
+ *
30
+ * @param itemInfo Info about the item
31
+ * @param destAuthentication Credentials for requests to the destination organization
32
+ * @param srcAuthentication Credentials for requests to source items
33
+ * @returns A promise that will resolve when the template has been created
34
+ */
35
+ async function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication) {
36
+ // Init template
37
+ const itemTemplate = common.createInitializedItemTemplate(itemInfo);
38
+ // Templatize item info property values
39
+ itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
40
+ // Request related items
41
+ const relatedPromise = common.getItemRelatedItemsInSameDirection(itemTemplate.itemId, "forward", srcAuthentication);
42
+ // Request its configuration
43
+ const configPromise = common.getWorkflowConfigurationZip(itemInfo.id, srcAuthentication);
44
+ const [relatedItems, configZip] = await Promise.all([relatedPromise, configPromise]);
45
+ // Save the mappings to related items & add those items to the dependencies, but not WMA Code Attachments
46
+ itemTemplate.dependencies = [];
47
+ itemTemplate.relatedItems = [];
48
+ relatedItems.forEach(relatedItem => {
49
+ /* istanbul ignore else */
50
+ if (relatedItem.relationshipType !== "WMA2Code") {
51
+ itemTemplate.relatedItems.push(relatedItem);
52
+ relatedItem.relatedItemIds.forEach(relatedItemId => {
53
+ if (itemTemplate.dependencies.indexOf(relatedItemId) < 0) {
54
+ itemTemplate.dependencies.push(relatedItemId);
55
+ }
56
+ });
57
+ }
58
+ });
59
+ // Add the templatized configuration to the template
60
+ itemTemplate.properties.configuration = await common.extractAndTemplatizeWorkflowFromZipFile(configZip);
61
+ return Promise.resolve(itemTemplate);
62
+ }
63
+ exports.convertItemToTemplate = convertItemToTemplate;
64
+ /**
65
+ * Converts a workflow template into a new item.
66
+ *
67
+ * @param template Workflow template
68
+ * @param templateDictionary Dictionary of terms to replace in the template
69
+ * @param destAuthentication Credentials for requests to the destination organization
70
+ * @param itemProgressCallback Callback function to report the progress of the item creation
71
+ * @returns Promise resolving with the detemplatized item template, the new item's id, and a boolean
72
+ * indicating if post-processing is needed
73
+ */
74
+ async function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
75
+ // Interrupt process if progress callback returns `false`
76
+ if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
77
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
78
+ return Promise.resolve(common.generateEmptyCreationResponse(template.type));
79
+ }
80
+ // Replace the templatized symbols in a copy of the template
81
+ let newItemTemplate = common.cloneObject(template);
82
+ newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
83
+ /* istanbul ignore else */
84
+ if (template.item.thumbnail) {
85
+ newItemTemplate.item.thumbnail = template.item.thumbnail;
86
+ }
87
+ try {
88
+ // Create the item, then update its URL with its new id
89
+ const createResponse = await common.createItemWithData(newItemTemplate.item, newItemTemplate.data, destinationAuthentication, templateDictionary.folderId);
90
+ // Interrupt process if progress callback returns `false`
91
+ if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
92
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
93
+ void common.removeItem(createResponse.id, destinationAuthentication);
94
+ return Promise.resolve(common.generateEmptyCreationResponse(template.type));
95
+ }
96
+ // Add the new item to the settings
97
+ newItemTemplate.itemId = newItemTemplate.item.id = createResponse.id;
98
+ templateDictionary[template.itemId] = {
99
+ itemId: createResponse.id
100
+ };
101
+ // Add the item's configuration properties
102
+ const configZipFile = await common.compressWorkflowIntoZipFile(newItemTemplate.properties.configuration);
103
+ await common.setWorkflowConfigurationZip(configZipFile, createResponse.id, destinationAuthentication);
104
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.id);
105
+ return Promise.resolve({
106
+ item: newItemTemplate,
107
+ id: createResponse.id,
108
+ type: newItemTemplate.type,
109
+ postProcess: false
110
+ });
111
+ }
112
+ catch (err) {
113
+ itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
114
+ return Promise.resolve(common.generateEmptyCreationResponse(template.type));
115
+ }
116
+ }
117
+ exports.createItemFromTemplate = createItemFromTemplate;
118
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/workflow.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH,sEAAgD;AAEhD,wHAAwH;AAExH;;;;;;;GAOG;AACI,KAAK,UAAU,qBAAqB,CACzC,QAAa,EACb,kBAAsC,EACtC,iBAAqC;IAErC,gBAAgB;IAChB,MAAM,YAAY,GAAyB,MAAM,CAAC,6BAA6B,CAC7E,QAAQ,CACT,CAAC;IAEF,uCAAuC;IACvC,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;IAEF,wBAAwB;IACxB,MAAM,cAAc,GAAG,MAAM,CAAC,kCAAkC,CAC9D,YAAY,CAAC,MAAM,EACnB,SAAS,EACT,iBAAiB,CAClB,CAAC;IAEF,4BAA4B;IAC5B,MAAM,aAAa,GAA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ACpC,MAAM,EAAE,cAAc,CAAC,EAAE;SAC1B,CAAC;QAEF,0CAA0C;QAC1C,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,2BAA2B,CAAC,eAAe,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QACzG,MAAM,MAAM,CAAC,2BAA2B,CACtC,aAAa,EACb,cAAc,CAAC,EAAE,EACjB,yBAAyB,CAC1B,CAAC;QAEF,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EACnC,QAAQ,CAAC,6BAA6B,GAAG,CAAC,EAC1C,cAAc,CAAC,EAAE,CAClB,CAAC;QAEF,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,eAAe;YACrB,EAAE,EAAE,cAAc,CAAC,EAAE;YACrB,IAAI,EAAE,eAAe,CAAC,IAAI;YAC1B,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;KACJ;IAAC,OAAO,GAAG,EAAE;QACZ,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,MAAM,EACjC,CAAC,CACF,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;KAC7E;AACH,CAAC;AAhGD,wDAgGC"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-workflow",
3
- "version": "5.2.3",
3
+ "version": "5.2.4",
4
4
  "description": "Manages the creation and deployment of Workflow item types for @esri/solution.js.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -19,7 +19,7 @@
19
19
  ],
20
20
  "devDependencies": {
21
21
  "@esri/arcgis-rest-auth": "^3.7.0",
22
- "@esri/solution-common": "^5.2.3",
22
+ "@esri/solution-common": "^5.2.4",
23
23
  "@types/jasmine": "^5.1.4",
24
24
  "fetch-mock": "^7.7.3",
25
25
  "jasmine": "^5.1.0",
@@ -66,5 +66,5 @@
66
66
  "esri",
67
67
  "ES6"
68
68
  ],
69
- "gitHead": "bcf0907f47cf8a2970f8da38f8e1e2a4ac7beccb"
69
+ "gitHead": "c3329c6814c1d7b898eb130bf3a7feeda12f074f"
70
70
  }