@esri/solution-workflow 5.2.0 → 5.2.2
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/README.md +4 -7
- package/dist/cjs/index.js.map +1 -0
- package/dist/{esm/workflow/src → cjs}/workflow.d.ts +12 -3
- package/dist/cjs/workflow.js +118 -0
- package/dist/cjs/workflow.js.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/{cjs/workflow/src → esm}/workflow.d.ts +12 -3
- package/dist/esm/workflow.js +112 -0
- package/dist/esm/workflow.js.map +1 -0
- package/package.json +3 -3
- package/dist/cjs/common/src/generalHelpers.d.ts +0 -400
- package/dist/cjs/common/src/generalHelpers.js +0 -877
- package/dist/cjs/common/src/generalHelpers.js.map +0 -1
- package/dist/cjs/common/src/getItemTypeAbbrev.d.ts +0 -19
- package/dist/cjs/common/src/getItemTypeAbbrev.js +0 -186
- package/dist/cjs/common/src/getItemTypeAbbrev.js.map +0 -1
- package/dist/cjs/common/src/interfaces.d.ts +0 -1344
- package/dist/cjs/common/src/interfaces.js +0 -77
- package/dist/cjs/common/src/interfaces.js.map +0 -1
- package/dist/cjs/common/src/libConnectors.d.ts +0 -73
- package/dist/cjs/common/src/libConnectors.js +0 -115
- package/dist/cjs/common/src/libConnectors.js.map +0 -1
- package/dist/cjs/common/test/mocks/templates.d.ts +0 -71
- package/dist/cjs/common/test/mocks/templates.js +0 -1220
- package/dist/cjs/common/test/mocks/templates.js.map +0 -1
- package/dist/cjs/common/test/mocks/utils.d.ts +0 -605
- package/dist/cjs/common/test/mocks/utils.js +0 -1222
- package/dist/cjs/common/test/mocks/utils.js.map +0 -1
- package/dist/cjs/workflow/src/index.js.map +0 -1
- package/dist/cjs/workflow/src/workflow.js +0 -51
- package/dist/cjs/workflow/src/workflow.js.map +0 -1
- package/dist/esm/common/src/generalHelpers.d.ts +0 -400
- package/dist/esm/common/src/generalHelpers.js +0 -829
- package/dist/esm/common/src/generalHelpers.js.map +0 -1
- package/dist/esm/common/src/getItemTypeAbbrev.d.ts +0 -19
- package/dist/esm/common/src/getItemTypeAbbrev.js +0 -182
- package/dist/esm/common/src/getItemTypeAbbrev.js.map +0 -1
- package/dist/esm/common/src/interfaces.d.ts +0 -1344
- package/dist/esm/common/src/interfaces.js +0 -72
- package/dist/esm/common/src/interfaces.js.map +0 -1
- package/dist/esm/common/src/libConnectors.d.ts +0 -73
- package/dist/esm/common/src/libConnectors.js +0 -105
- package/dist/esm/common/src/libConnectors.js.map +0 -1
- package/dist/esm/common/test/mocks/templates.d.ts +0 -71
- package/dist/esm/common/test/mocks/templates.js +0 -1195
- package/dist/esm/common/test/mocks/templates.js.map +0 -1
- package/dist/esm/common/test/mocks/utils.d.ts +0 -605
- package/dist/esm/common/test/mocks/utils.js +0 -1177
- package/dist/esm/common/test/mocks/utils.js.map +0 -1
- package/dist/esm/workflow/src/index.js.map +0 -1
- package/dist/esm/workflow/src/workflow.js +0 -45
- package/dist/esm/workflow/src/workflow.js.map +0 -1
- /package/dist/cjs/{workflow/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/cjs/{workflow/src/index.js → index.js} +0 -0
- /package/dist/esm/{workflow/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/esm/{workflow/src/index.js → index.js} +0 -0
package/README.md
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
[![npm status][npm-img]][npm-url]
|
|
2
2
|
[![Build status][travis-img]][travis-url]
|
|
3
3
|
[![gzip bundle size][gzip-img]][npm-url]
|
|
4
|
-
[![Coverage status][coverage-img]][coverage-url]
|
|
5
4
|
[![Apache 2.0 licensed][license-img]][license-url]
|
|
6
5
|
|
|
7
6
|
[npm-img]: https://img.shields.io/npm/v/@esri/solution-workflow.svg?style=round-square&color=blue
|
|
8
7
|
[npm-url]: https://www.npmjs.com/package/@esri/solution-workflow
|
|
9
|
-
[travis-img]: https://img.shields.io/travis/Esri/solution.js/develop.svg
|
|
8
|
+
[travis-img]: https://img.shields.io/travis/com/Esri/solution.js/develop.svg
|
|
10
9
|
[travis-url]: https://travis-ci.org/Esri/solution.js
|
|
11
|
-
[gzip-img]: https://img.badgesize.io/https://unpkg.com/@esri/solution-storymap/dist/
|
|
12
|
-
[coverage-img]: https://coveralls.io/repos/github/Esri/solution.js/badge.svg
|
|
13
|
-
[coverage-url]: https://coveralls.io/github/Esri/solution.js
|
|
10
|
+
[gzip-img]: https://img.badgesize.io/https://unpkg.com/@esri/solution-storymap/dist/esm/index.js?compression=gzip
|
|
14
11
|
[license-img]: https://img.shields.io/badge/license-Apache%202.0-blue.svg
|
|
15
12
|
[license-url]: #license
|
|
16
13
|
|
|
17
14
|
# @esri/solution-workflow
|
|
18
15
|
|
|
19
|
-
> Manages the creation and deployment of Workflow
|
|
16
|
+
> Manages the creation and deployment of Workflow item types for [`@esri/solution-*`](https://github.com/Esri/solution.js).
|
|
20
17
|
|
|
21
|
-
### [API Reference](https://esri.github.io/solution.js/
|
|
18
|
+
### [API Reference](https://esri.github.io/solution.js/modules/workflow_src.html)
|
|
22
19
|
|
|
23
20
|
### Issues
|
|
24
21
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,qDAA2B"}
|
|
@@ -22,11 +22,20 @@ import * as common from "@esri/solution-common";
|
|
|
22
22
|
/**
|
|
23
23
|
* Converts a workflow item into a template.
|
|
24
24
|
*
|
|
25
|
-
* @param solutionItemId The solution to contain the template
|
|
26
25
|
* @param itemInfo Info about the item
|
|
27
26
|
* @param destAuthentication Credentials for requests to the destination organization
|
|
28
27
|
* @param srcAuthentication Credentials for requests to source items
|
|
29
28
|
* @returns A promise that will resolve when the template has been created
|
|
30
29
|
*/
|
|
31
|
-
export declare function convertItemToTemplate(): Promise<common.IItemTemplate>;
|
|
32
|
-
|
|
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,CAA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":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,cAAc,YAAY,CAAC"}
|
|
@@ -22,11 +22,20 @@ import * as common from "@esri/solution-common";
|
|
|
22
22
|
/**
|
|
23
23
|
* Converts a workflow item into a template.
|
|
24
24
|
*
|
|
25
|
-
* @param solutionItemId The solution to contain the template
|
|
26
25
|
* @param itemInfo Info about the item
|
|
27
26
|
* @param destAuthentication Credentials for requests to the destination organization
|
|
28
27
|
* @param srcAuthentication Credentials for requests to source items
|
|
29
28
|
* @returns A promise that will resolve when the template has been created
|
|
30
29
|
*/
|
|
31
|
-
export declare function convertItemToTemplate(): Promise<common.IItemTemplate>;
|
|
32
|
-
|
|
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,112 @@
|
|
|
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
|
+
/**
|
|
24
|
+
* Converts a workflow item into a template.
|
|
25
|
+
*
|
|
26
|
+
* @param itemInfo Info about the item
|
|
27
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
28
|
+
* @param srcAuthentication Credentials for requests to source items
|
|
29
|
+
* @returns A promise that will resolve when the template has been created
|
|
30
|
+
*/
|
|
31
|
+
export async function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication) {
|
|
32
|
+
// Init template
|
|
33
|
+
const itemTemplate = common.createInitializedItemTemplate(itemInfo);
|
|
34
|
+
// Templatize item info property values
|
|
35
|
+
itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
|
|
36
|
+
// Request related items
|
|
37
|
+
const relatedPromise = common.getItemRelatedItemsInSameDirection(itemTemplate.itemId, "forward", srcAuthentication);
|
|
38
|
+
// Request its configuration
|
|
39
|
+
const configPromise = common.getWorkflowConfigurationZip(itemInfo.id, srcAuthentication);
|
|
40
|
+
const [relatedItems, configZip] = await Promise.all([relatedPromise, configPromise]);
|
|
41
|
+
// Save the mappings to related items & add those items to the dependencies, but not WMA Code Attachments
|
|
42
|
+
itemTemplate.dependencies = [];
|
|
43
|
+
itemTemplate.relatedItems = [];
|
|
44
|
+
relatedItems.forEach(relatedItem => {
|
|
45
|
+
/* istanbul ignore else */
|
|
46
|
+
if (relatedItem.relationshipType !== "WMA2Code") {
|
|
47
|
+
itemTemplate.relatedItems.push(relatedItem);
|
|
48
|
+
relatedItem.relatedItemIds.forEach(relatedItemId => {
|
|
49
|
+
if (itemTemplate.dependencies.indexOf(relatedItemId) < 0) {
|
|
50
|
+
itemTemplate.dependencies.push(relatedItemId);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// Add the templatized configuration to the template
|
|
56
|
+
itemTemplate.properties.configuration = await common.extractAndTemplatizeWorkflowFromZipFile(configZip);
|
|
57
|
+
return Promise.resolve(itemTemplate);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Converts a workflow template into a new item.
|
|
61
|
+
*
|
|
62
|
+
* @param template Workflow template
|
|
63
|
+
* @param templateDictionary Dictionary of terms to replace in the template
|
|
64
|
+
* @param destAuthentication Credentials for requests to the destination organization
|
|
65
|
+
* @param itemProgressCallback Callback function to report the progress of the item creation
|
|
66
|
+
* @returns Promise resolving with the detemplatized item template, the new item's id, and a boolean
|
|
67
|
+
* indicating if post-processing is needed
|
|
68
|
+
*/
|
|
69
|
+
export async function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
70
|
+
// Interrupt process if progress callback returns `false`
|
|
71
|
+
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
|
|
72
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
|
|
73
|
+
return Promise.resolve(common.generateEmptyCreationResponse(template.type));
|
|
74
|
+
}
|
|
75
|
+
// Replace the templatized symbols in a copy of the template
|
|
76
|
+
let newItemTemplate = common.cloneObject(template);
|
|
77
|
+
newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
|
|
78
|
+
/* istanbul ignore else */
|
|
79
|
+
if (template.item.thumbnail) {
|
|
80
|
+
newItemTemplate.item.thumbnail = template.item.thumbnail;
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
// Create the item, then update its URL with its new id
|
|
84
|
+
const createResponse = await common.createItemWithData(newItemTemplate.item, newItemTemplate.data, destinationAuthentication, templateDictionary.folderId);
|
|
85
|
+
// Interrupt process if progress callback returns `false`
|
|
86
|
+
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.id)) {
|
|
87
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
|
|
88
|
+
void common.removeItem(createResponse.id, destinationAuthentication);
|
|
89
|
+
return Promise.resolve(common.generateEmptyCreationResponse(template.type));
|
|
90
|
+
}
|
|
91
|
+
// Add the new item to the settings
|
|
92
|
+
newItemTemplate.itemId = newItemTemplate.item.id = createResponse.id;
|
|
93
|
+
templateDictionary[template.itemId] = {
|
|
94
|
+
itemId: createResponse.id
|
|
95
|
+
};
|
|
96
|
+
// Add the item's configuration properties
|
|
97
|
+
const configZipFile = await common.compressWorkflowIntoZipFile(newItemTemplate.properties.configuration);
|
|
98
|
+
await common.setWorkflowConfigurationZip(configZipFile, createResponse.id, destinationAuthentication);
|
|
99
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.id);
|
|
100
|
+
return Promise.resolve({
|
|
101
|
+
item: newItemTemplate,
|
|
102
|
+
id: createResponse.id,
|
|
103
|
+
type: newItemTemplate.type,
|
|
104
|
+
postProcess: false
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
|
|
109
|
+
return Promise.resolve(common.generateEmptyCreationResponse(template.type));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# 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,OAAO,KA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AAmB,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/solution-workflow",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
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.
|
|
22
|
+
"@esri/solution-common": "^5.2.2",
|
|
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": "
|
|
69
|
+
"gitHead": "d92c1d8e3e6df12fda59df3ecc395d7570fa60dd"
|
|
70
70
|
}
|