@esri/solution-workflow 5.2.8 → 5.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/workflow.d.ts +1 -0
- package/dist/cjs/workflow.js +28 -11
- package/dist/cjs/workflow.js.map +1 -1
- package/dist/cjs/workflowHelpers.d.ts +38 -0
- package/dist/cjs/workflowHelpers.js +75 -0
- package/dist/cjs/workflowHelpers.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/workflow.d.ts +1 -0
- package/dist/esm/workflow.js +28 -11
- package/dist/esm/workflow.js.map +1 -1
- package/dist/esm/workflowHelpers.d.ts +38 -0
- package/dist/esm/workflowHelpers.js +69 -0
- package/dist/esm/workflowHelpers.js.map +1 -0
- package/package.json +4 -4
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,qDAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,qDAA2B;AAC3B,4DAAkC"}
|
package/dist/cjs/workflow.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import * as common from "@esri/solution-common";
|
|
|
25
25
|
* @param itemInfo Info about the item
|
|
26
26
|
* @param destAuthentication Credentials for requests to the destination organization
|
|
27
27
|
* @param srcAuthentication Credentials for requests to source items
|
|
28
|
+
* @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
28
29
|
* @returns A promise that will resolve when the template has been created
|
|
29
30
|
*/
|
|
30
31
|
export declare function convertItemToTemplate(itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
|
package/dist/cjs/workflow.js
CHANGED
|
@@ -23,6 +23,7 @@ const tslib_1 = require("tslib");
|
|
|
23
23
|
* @module workflow
|
|
24
24
|
*/
|
|
25
25
|
const common = tslib_1.__importStar(require("@esri/solution-common"));
|
|
26
|
+
const workflowHelpers = tslib_1.__importStar(require("./workflowHelpers"));
|
|
26
27
|
// ------------------------------------------------------------------------------------------------------------------ //
|
|
27
28
|
/**
|
|
28
29
|
* Converts a workflow item into a template.
|
|
@@ -30,6 +31,7 @@ const common = tslib_1.__importStar(require("@esri/solution-common"));
|
|
|
30
31
|
* @param itemInfo Info about the item
|
|
31
32
|
* @param destAuthentication Credentials for requests to the destination organization
|
|
32
33
|
* @param srcAuthentication Credentials for requests to source items
|
|
34
|
+
* @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
33
35
|
* @returns A promise that will resolve when the template has been created
|
|
34
36
|
*/
|
|
35
37
|
async function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication) {
|
|
@@ -57,7 +59,7 @@ async function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentica
|
|
|
57
59
|
}
|
|
58
60
|
});
|
|
59
61
|
// Add the templatized configuration to the template
|
|
60
|
-
itemTemplate.properties.configuration = await common.
|
|
62
|
+
itemTemplate.properties.configuration = await common.extractWorkflowFromZipFile(configZip);
|
|
61
63
|
return Promise.resolve(itemTemplate);
|
|
62
64
|
}
|
|
63
65
|
exports.convertItemToTemplate = convertItemToTemplate;
|
|
@@ -85,26 +87,41 @@ async function createItemFromTemplate(template, templateDictionary, destinationA
|
|
|
85
87
|
newItemTemplate.item.thumbnail = template.item.thumbnail;
|
|
86
88
|
}
|
|
87
89
|
try {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
const createdWorkflowItemId = await workflowHelpers.addWorkflowItem(newItemTemplate, destinationAuthentication);
|
|
91
|
+
if (!createdWorkflowItemId) {
|
|
92
|
+
throw new Error("Failed to create workflow item");
|
|
93
|
+
}
|
|
90
94
|
// Interrupt process if progress callback returns `false`
|
|
91
|
-
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2,
|
|
95
|
+
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createdWorkflowItemId)) {
|
|
92
96
|
itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
|
|
93
|
-
void common.removeItem(
|
|
97
|
+
void common.removeItem(createdWorkflowItemId, destinationAuthentication);
|
|
94
98
|
return Promise.resolve(common.generateEmptyCreationResponse(template.type));
|
|
95
99
|
}
|
|
96
100
|
// Add the new item to the settings
|
|
97
|
-
newItemTemplate.itemId = newItemTemplate.item.id =
|
|
101
|
+
newItemTemplate.itemId = newItemTemplate.item.id = createdWorkflowItemId;
|
|
98
102
|
templateDictionary[template.itemId] = {
|
|
99
|
-
itemId:
|
|
103
|
+
itemId: createdWorkflowItemId
|
|
100
104
|
};
|
|
101
|
-
//
|
|
105
|
+
// Detempletize the workflow configuration
|
|
106
|
+
newItemTemplate.properties.configuration = common.replaceInTemplate(newItemTemplate.properties.configuration, templateDictionary);
|
|
107
|
+
// Add the item's configuration properties; throw if the configuration update fails
|
|
102
108
|
const configZipFile = await common.compressWorkflowIntoZipFile(newItemTemplate.properties.configuration);
|
|
103
|
-
await common.setWorkflowConfigurationZip(configZipFile,
|
|
104
|
-
|
|
109
|
+
await common.setWorkflowConfigurationZip(configZipFile, createdWorkflowItemId, destinationAuthentication);
|
|
110
|
+
// Fetch the auxiliary items
|
|
111
|
+
const itemIds = await workflowHelpers.fetchAuxiliaryItems(createdWorkflowItemId, destinationAuthentication);
|
|
112
|
+
// Move the workflow and auxiliary items to the destination
|
|
113
|
+
itemIds.push(createdWorkflowItemId);
|
|
114
|
+
const moveResults = await common.moveItemsToFolder(itemIds, templateDictionary.folderId, destinationAuthentication);
|
|
115
|
+
const hasFailure = moveResults.some(result => {
|
|
116
|
+
return !result.success;
|
|
117
|
+
});
|
|
118
|
+
if (hasFailure) {
|
|
119
|
+
throw new Error("Failed to move all workflow items");
|
|
120
|
+
}
|
|
121
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createdWorkflowItemId);
|
|
105
122
|
return Promise.resolve({
|
|
106
123
|
item: newItemTemplate,
|
|
107
|
-
id:
|
|
124
|
+
id: createdWorkflowItemId,
|
|
108
125
|
type: newItemTemplate.type,
|
|
109
126
|
postProcess: false
|
|
110
127
|
});
|
package/dist/cjs/workflow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/workflow.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH,sEAAgD;
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/workflow.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH,sEAAgD;AAChD,2EAAqD;AAErD,wHAAwH;AAExH;;;;;;;;GAQG;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,EAC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ACnB,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;AA3GD,wDA2GC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
* Creates a new workflow item.
|
|
24
|
+
*
|
|
25
|
+
* @param item Item to add
|
|
26
|
+
* @param authentication Credentials for requests to the workflow manager
|
|
27
|
+
* @returns Promise resolving with new item's AGO id
|
|
28
|
+
* @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
|
|
29
|
+
*/
|
|
30
|
+
export declare function addWorkflowItem(item: common.IItemTemplate, authentication: common.UserSession): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Fetches the auxiliary items.
|
|
33
|
+
*
|
|
34
|
+
* @param workflowItemId Workflow whose auxiliary items are to be fetched
|
|
35
|
+
* @param authentication Credentials for requests to the destination organization
|
|
36
|
+
* @returns List of auxiliary item ids
|
|
37
|
+
*/
|
|
38
|
+
export declare function fetchAuxiliaryItems(workflowItemId: string, authentication: common.UserSession): Promise<string[]>;
|
|
@@ -0,0 +1,75 @@
|
|
|
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.fetchAuxiliaryItems = exports.addWorkflowItem = 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
|
+
const restRequest = tslib_1.__importStar(require("@esri/arcgis-rest-request"));
|
|
27
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new workflow item.
|
|
30
|
+
*
|
|
31
|
+
* @param item Item to add
|
|
32
|
+
* @param authentication Credentials for requests to the workflow manager
|
|
33
|
+
* @returns Promise resolving with new item's AGO id
|
|
34
|
+
* @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
|
|
35
|
+
*/
|
|
36
|
+
async function addWorkflowItem(item, authentication) {
|
|
37
|
+
const user = await authentication.getUser({ authentication });
|
|
38
|
+
// Add the workflow item
|
|
39
|
+
const workflowUrl = `https://workflow.arcgis.com/${user.orgId}/admin/createWorkflowItem?name=${item.item.title}`;
|
|
40
|
+
const requestOptions = {
|
|
41
|
+
authentication: authentication,
|
|
42
|
+
headers: {
|
|
43
|
+
Accept: "application/json",
|
|
44
|
+
Authorization: `Bearer ${authentication.token}`,
|
|
45
|
+
"Content-Type": "application/json",
|
|
46
|
+
Host: "workflow.arcgis.com",
|
|
47
|
+
"X-Esri-Authorization": `Bearer ${authentication.token}`
|
|
48
|
+
},
|
|
49
|
+
params: {
|
|
50
|
+
name: `${item.item.title}`
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const createdWorkflowResponse = await restRequest.request(workflowUrl, requestOptions);
|
|
54
|
+
return Promise.resolve(createdWorkflowResponse.itemId);
|
|
55
|
+
}
|
|
56
|
+
exports.addWorkflowItem = addWorkflowItem;
|
|
57
|
+
/**
|
|
58
|
+
* Fetches the auxiliary items.
|
|
59
|
+
*
|
|
60
|
+
* @param workflowItemId Workflow whose auxiliary items are to be fetched
|
|
61
|
+
* @param authentication Credentials for requests to the destination organization
|
|
62
|
+
* @returns List of auxiliary item ids
|
|
63
|
+
*/
|
|
64
|
+
async function fetchAuxiliaryItems(workflowItemId, authentication) {
|
|
65
|
+
const workflowItemName = `workflow_${workflowItemId}`;
|
|
66
|
+
const workflowLocationsItemName = `WorkflowLocations_${workflowItemId}`;
|
|
67
|
+
const workflowViewsItemName = `workflow_views_${workflowItemId}`;
|
|
68
|
+
const auxiliaryItemsResults = await common.searchItems({
|
|
69
|
+
q: `title:${workflowItemName} OR title:${workflowLocationsItemName} OR title:${workflowViewsItemName}`,
|
|
70
|
+
authentication: authentication
|
|
71
|
+
});
|
|
72
|
+
return Promise.resolve(auxiliaryItemsResults.results.map(item => item.id));
|
|
73
|
+
}
|
|
74
|
+
exports.fetchAuxiliaryItems = fetchAuxiliaryItems;
|
|
75
|
+
//# sourceMappingURL=workflowHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowHelpers.js","sourceRoot":"","sources":["../../src/workflowHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH,sEAAgD;AAChD,+EAAyD;AAEzD,wHAAwH;AAExH;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CACnC,IAA0B,EAC1B,cAAkC;IAElC,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC;IAE9D,wBAAwB;IACxB,MAAM,WAAW,GAAG,+BAA+B,IAAI,CAAC,KAAK,kCAAkC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjH,MAAM,cAAc,GAAgC;QAClD,cAAc,EAAE,cAAc;QAC9B,OAAO,EAAE;YACP,MAAM,EAAE,kBAAkB;YAC1B,aAAa,EAAE,UAAU,cAAc,CAAC,KAAK,EAAE;YAC/C,cAAc,EAAE,kBAAkB;YAClC,IAAI,EAAE,qBAAqB;YAC3B,sBAAsB,EAAE,UAAU,cAAc,CAAC,KAAK,EAAE;SACzD;QACD,MAAM,EAAE;YACN,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;SAC3B;KACF,CAAC;IACF,MAAM,uBAAuB,GAAG,MAAM,WAAW,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAEvF,OAAO,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC;AAxBD,0CAwBC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,mBAAmB,CACvC,cAAsB,EACtB,cAAkC;IAElC,MAAM,gBAAgB,GAAG,YAAY,cAAc,EAAE,CAAC;IACtD,MAAM,yBAAyB,GAAG,qBAAqB,cAAc,EAAE,CAAC;IACxE,MAAM,qBAAqB,GAAG,kBAAkB,cAAc,EAAE,CAAC;IAEjE,MAAM,qBAAqB,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;QACrD,CAAC,EAAE,SAAS,gBAAgB,aAAa,yBAAyB,aAAa,qBAAqB,EAAE;QACtG,cAAc,EAAE,cAAc;KAC/B,CAAC,CAAC;IACH,OAAO,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7E,CAAC;AAbD,kDAaC"}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC"}
|
package/dist/esm/workflow.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import * as common from "@esri/solution-common";
|
|
|
25
25
|
* @param itemInfo Info about the item
|
|
26
26
|
* @param destAuthentication Credentials for requests to the destination organization
|
|
27
27
|
* @param srcAuthentication Credentials for requests to source items
|
|
28
|
+
* @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
28
29
|
* @returns A promise that will resolve when the template has been created
|
|
29
30
|
*/
|
|
30
31
|
export declare function convertItemToTemplate(itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
|
package/dist/esm/workflow.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* @module workflow
|
|
20
20
|
*/
|
|
21
21
|
import * as common from "@esri/solution-common";
|
|
22
|
+
import * as workflowHelpers from "./workflowHelpers";
|
|
22
23
|
// ------------------------------------------------------------------------------------------------------------------ //
|
|
23
24
|
/**
|
|
24
25
|
* Converts a workflow item into a template.
|
|
@@ -26,6 +27,7 @@ import * as common from "@esri/solution-common";
|
|
|
26
27
|
* @param itemInfo Info about the item
|
|
27
28
|
* @param destAuthentication Credentials for requests to the destination organization
|
|
28
29
|
* @param srcAuthentication Credentials for requests to source items
|
|
30
|
+
* @param {any} templateDictionary Hash of facts: folder id, org URL, adlib replacements
|
|
29
31
|
* @returns A promise that will resolve when the template has been created
|
|
30
32
|
*/
|
|
31
33
|
export async function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication) {
|
|
@@ -53,7 +55,7 @@ export async function convertItemToTemplate(itemInfo, destAuthentication, srcAut
|
|
|
53
55
|
}
|
|
54
56
|
});
|
|
55
57
|
// Add the templatized configuration to the template
|
|
56
|
-
itemTemplate.properties.configuration = await common.
|
|
58
|
+
itemTemplate.properties.configuration = await common.extractWorkflowFromZipFile(configZip);
|
|
57
59
|
return Promise.resolve(itemTemplate);
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
@@ -80,26 +82,41 @@ export async function createItemFromTemplate(template, templateDictionary, desti
|
|
|
80
82
|
newItemTemplate.item.thumbnail = template.item.thumbnail;
|
|
81
83
|
}
|
|
82
84
|
try {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
const createdWorkflowItemId = await workflowHelpers.addWorkflowItem(newItemTemplate, destinationAuthentication);
|
|
86
|
+
if (!createdWorkflowItemId) {
|
|
87
|
+
throw new Error("Failed to create workflow item");
|
|
88
|
+
}
|
|
85
89
|
// Interrupt process if progress callback returns `false`
|
|
86
|
-
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2,
|
|
90
|
+
if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createdWorkflowItemId)) {
|
|
87
91
|
itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
|
|
88
|
-
void common.removeItem(
|
|
92
|
+
void common.removeItem(createdWorkflowItemId, destinationAuthentication);
|
|
89
93
|
return Promise.resolve(common.generateEmptyCreationResponse(template.type));
|
|
90
94
|
}
|
|
91
95
|
// Add the new item to the settings
|
|
92
|
-
newItemTemplate.itemId = newItemTemplate.item.id =
|
|
96
|
+
newItemTemplate.itemId = newItemTemplate.item.id = createdWorkflowItemId;
|
|
93
97
|
templateDictionary[template.itemId] = {
|
|
94
|
-
itemId:
|
|
98
|
+
itemId: createdWorkflowItemId
|
|
95
99
|
};
|
|
96
|
-
//
|
|
100
|
+
// Detempletize the workflow configuration
|
|
101
|
+
newItemTemplate.properties.configuration = common.replaceInTemplate(newItemTemplate.properties.configuration, templateDictionary);
|
|
102
|
+
// Add the item's configuration properties; throw if the configuration update fails
|
|
97
103
|
const configZipFile = await common.compressWorkflowIntoZipFile(newItemTemplate.properties.configuration);
|
|
98
|
-
await common.setWorkflowConfigurationZip(configZipFile,
|
|
99
|
-
|
|
104
|
+
await common.setWorkflowConfigurationZip(configZipFile, createdWorkflowItemId, destinationAuthentication);
|
|
105
|
+
// Fetch the auxiliary items
|
|
106
|
+
const itemIds = await workflowHelpers.fetchAuxiliaryItems(createdWorkflowItemId, destinationAuthentication);
|
|
107
|
+
// Move the workflow and auxiliary items to the destination
|
|
108
|
+
itemIds.push(createdWorkflowItemId);
|
|
109
|
+
const moveResults = await common.moveItemsToFolder(itemIds, templateDictionary.folderId, destinationAuthentication);
|
|
110
|
+
const hasFailure = moveResults.some(result => {
|
|
111
|
+
return !result.success;
|
|
112
|
+
});
|
|
113
|
+
if (hasFailure) {
|
|
114
|
+
throw new Error("Failed to move all workflow items");
|
|
115
|
+
}
|
|
116
|
+
itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createdWorkflowItemId);
|
|
100
117
|
return Promise.resolve({
|
|
101
118
|
item: newItemTemplate,
|
|
102
|
-
id:
|
|
119
|
+
id: createdWorkflowItemId,
|
|
103
120
|
type: newItemTemplate.type,
|
|
104
121
|
postProcess: false
|
|
105
122
|
});
|
package/dist/esm/workflow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAErD,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,CAAC,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,GAAG,MAAM,CAAC,2BAA2B,CACtD,QAAQ,CAAC,EAAE,EACX,iBAAiB,CAClB,CAAC;IAEF,MAAM,CAAC,YAAY,EAA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CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;KAC7E;AACH,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
* Creates a new workflow item.
|
|
24
|
+
*
|
|
25
|
+
* @param item Item to add
|
|
26
|
+
* @param authentication Credentials for requests to the workflow manager
|
|
27
|
+
* @returns Promise resolving with new item's AGO id
|
|
28
|
+
* @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
|
|
29
|
+
*/
|
|
30
|
+
export declare function addWorkflowItem(item: common.IItemTemplate, authentication: common.UserSession): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Fetches the auxiliary items.
|
|
33
|
+
*
|
|
34
|
+
* @param workflowItemId Workflow whose auxiliary items are to be fetched
|
|
35
|
+
* @param authentication Credentials for requests to the destination organization
|
|
36
|
+
* @returns List of auxiliary item ids
|
|
37
|
+
*/
|
|
38
|
+
export declare function fetchAuxiliaryItems(workflowItemId: string, authentication: common.UserSession): Promise<string[]>;
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
import * as restRequest from "@esri/arcgis-rest-request";
|
|
23
|
+
// ------------------------------------------------------------------------------------------------------------------ //
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new workflow item.
|
|
26
|
+
*
|
|
27
|
+
* @param item Item to add
|
|
28
|
+
* @param authentication Credentials for requests to the workflow manager
|
|
29
|
+
* @returns Promise resolving with new item's AGO id
|
|
30
|
+
* @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
|
|
31
|
+
*/
|
|
32
|
+
export async function addWorkflowItem(item, authentication) {
|
|
33
|
+
const user = await authentication.getUser({ authentication });
|
|
34
|
+
// Add the workflow item
|
|
35
|
+
const workflowUrl = `https://workflow.arcgis.com/${user.orgId}/admin/createWorkflowItem?name=${item.item.title}`;
|
|
36
|
+
const requestOptions = {
|
|
37
|
+
authentication: authentication,
|
|
38
|
+
headers: {
|
|
39
|
+
Accept: "application/json",
|
|
40
|
+
Authorization: `Bearer ${authentication.token}`,
|
|
41
|
+
"Content-Type": "application/json",
|
|
42
|
+
Host: "workflow.arcgis.com",
|
|
43
|
+
"X-Esri-Authorization": `Bearer ${authentication.token}`
|
|
44
|
+
},
|
|
45
|
+
params: {
|
|
46
|
+
name: `${item.item.title}`
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const createdWorkflowResponse = await restRequest.request(workflowUrl, requestOptions);
|
|
50
|
+
return Promise.resolve(createdWorkflowResponse.itemId);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Fetches the auxiliary items.
|
|
54
|
+
*
|
|
55
|
+
* @param workflowItemId Workflow whose auxiliary items are to be fetched
|
|
56
|
+
* @param authentication Credentials for requests to the destination organization
|
|
57
|
+
* @returns List of auxiliary item ids
|
|
58
|
+
*/
|
|
59
|
+
export async function fetchAuxiliaryItems(workflowItemId, authentication) {
|
|
60
|
+
const workflowItemName = `workflow_${workflowItemId}`;
|
|
61
|
+
const workflowLocationsItemName = `WorkflowLocations_${workflowItemId}`;
|
|
62
|
+
const workflowViewsItemName = `workflow_views_${workflowItemId}`;
|
|
63
|
+
const auxiliaryItemsResults = await common.searchItems({
|
|
64
|
+
q: `title:${workflowItemName} OR title:${workflowLocationsItemName} OR title:${workflowViewsItemName}`,
|
|
65
|
+
authentication: authentication
|
|
66
|
+
});
|
|
67
|
+
return Promise.resolve(auxiliaryItemsResults.results.map(item => item.id));
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=workflowHelpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflowHelpers.js","sourceRoot":"","sources":["../../src/workflowHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAC;AAEzD,wHAAwH;AAExH;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAA0B,EAC1B,cAAkC;IAElC,MAAM,IA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AC,CAAC;AAC7E,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.10",
|
|
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,12 +19,12 @@
|
|
|
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.10",
|
|
23
23
|
"@types/jasmine": "^5.1.4",
|
|
24
24
|
"fetch-mock": "^7.7.3",
|
|
25
25
|
"jasmine": "^5.1.0",
|
|
26
26
|
"jasmine-core": "^5.1.0",
|
|
27
|
-
"rollup": "^4.
|
|
27
|
+
"rollup": "^4.13.2"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"jszip": "3.10.1",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"esri",
|
|
67
67
|
"ES6"
|
|
68
68
|
],
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "5ad94c5c39559c3399cc7c42ba1b0075ec618bf4"
|
|
70
70
|
}
|