@esri/solution-workflow 6.0.4-alpha.0 → 6.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/solution-workflow",
3
- "version": "6.0.4-alpha.0",
3
+ "version": "6.1.0-alpha.0",
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",
@@ -22,7 +22,7 @@
22
22
  "npm-check-updates": "^17.1.0"
23
23
  },
24
24
  "dependencies": {
25
- "@esri/solution-common": "^6.0.4-alpha.0",
25
+ "@esri/solution-common": "^6.1.0-alpha.0",
26
26
  "tslib": "1.14.1"
27
27
  },
28
28
  "scripts": {
@@ -61,5 +61,5 @@
61
61
  "esri",
62
62
  "ES6"
63
63
  ],
64
- "gitHead": "bcb7bdb81c58fc94f1dc497547bb8dbffb85fdbd"
64
+ "gitHead": "19cbc20f4da03baa4676b3fad82abcea533432c3"
65
65
  }
@@ -1,22 +0,0 @@
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";
22
- export * from "./workflowHelpers";
package/dist/cjs/index.js DELETED
@@ -1,26 +0,0 @@
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
- tslib_1.__exportStar(require("./workflowHelpers"), exports);
26
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,qDAA2B;AAC3B,4DAAkC"}
@@ -1,42 +0,0 @@
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
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
29
- * @returns A promise that will resolve when the template has been created
30
- */
31
- export declare function convertItemToTemplate(itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession, templateDictionary: any): Promise<common.IItemTemplate>;
32
- /**
33
- * Converts a workflow template into a new item.
34
- *
35
- * @param template Workflow template
36
- * @param templateDictionary Dictionary of terms to replace in the template
37
- * @param destAuthentication Credentials for requests to the destination organization
38
- * @param itemProgressCallback Callback function to report the progress of the item creation
39
- * @returns Promise resolving with the detemplatized item template, the new item's id, and a boolean
40
- * indicating if post-processing is needed
41
- */
42
- export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
@@ -1,143 +0,0 @@
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
- const workflowHelpers = tslib_1.__importStar(require("./workflowHelpers"));
27
- // ------------------------------------------------------------------------------------------------------------------ //
28
- /**
29
- * Converts a workflow item into a template.
30
- *
31
- * @param itemInfo Info about the item
32
- * @param destAuthentication Credentials for requests to the destination organization
33
- * @param srcAuthentication Credentials for requests to source items
34
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
35
- * @returns A promise that will resolve when the template has been created
36
- */
37
- async function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
38
- // Init template
39
- const itemTemplate = common.createInitializedItemTemplate(itemInfo);
40
- itemTemplate.estimatedDeploymentCostFactor = 20; // creating a workflow item can be really slow
41
- // Templatize item info property values
42
- itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
43
- // Request related items
44
- const relatedPromise = common.getItemRelatedItemsInSameDirection(itemTemplate.itemId, "forward", srcAuthentication);
45
- // Request its configuration
46
- const configPromise = common.getWorkflowConfigurationZip(itemInfo.id, templateDictionary.workflowBaseUrl, srcAuthentication);
47
- // Request its data
48
- const dataPromise = common.getItemDataAsJson(itemInfo.id, srcAuthentication);
49
- const [relatedItems, configZip, data] = await Promise.all([relatedPromise, configPromise, dataPromise]);
50
- itemTemplate.data = data;
51
- // Save the mappings to related items & add those items to the dependencies, but not WMA Code Attachments
52
- itemTemplate.dependencies = [];
53
- itemTemplate.relatedItems = [];
54
- // get the dependencies listed in the workflow items data
55
- common.getWorkflowDependencies(itemTemplate);
56
- relatedItems.forEach((relatedItem) => {
57
- /* istanbul ignore else */
58
- if (relatedItem.relationshipType !== "WMA2Code") {
59
- itemTemplate.relatedItems.push(relatedItem);
60
- relatedItem.relatedItemIds.forEach((relatedItemId) => {
61
- if (itemTemplate.dependencies.indexOf(relatedItemId) < 0) {
62
- itemTemplate.dependencies.push(relatedItemId);
63
- }
64
- });
65
- }
66
- });
67
- // Add the configuration to the template
68
- itemTemplate.properties.configuration = await common.extractWorkflowFromZipFile(configZip);
69
- return Promise.resolve(itemTemplate);
70
- }
71
- exports.convertItemToTemplate = convertItemToTemplate;
72
- /**
73
- * Converts a workflow template into a new item.
74
- *
75
- * @param template Workflow template
76
- * @param templateDictionary Dictionary of terms to replace in the template
77
- * @param destAuthentication Credentials for requests to the destination organization
78
- * @param itemProgressCallback Callback function to report the progress of the item creation
79
- * @returns Promise resolving with the detemplatized item template, the new item's id, and a boolean
80
- * indicating if post-processing is needed
81
- */
82
- async function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
83
- // Interrupt process if progress callback returns `false`
84
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
85
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
86
- return Promise.resolve(common.generateEmptyCreationResponse(template.type));
87
- }
88
- template.data = {};
89
- // Replace the templatized symbols in a copy of the template
90
- let newItemTemplate = common.cloneObject(template);
91
- newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
92
- /* istanbul ignore else */
93
- if (template.item.thumbnail) {
94
- newItemTemplate.item.thumbnail = template.item.thumbnail;
95
- }
96
- try {
97
- const createdWorkflowItemId = await workflowHelpers.addWorkflowItem(newItemTemplate, templateDictionary.workflowBaseUrl, destinationAuthentication);
98
- if (!createdWorkflowItemId) {
99
- throw new Error("Failed to create workflow item");
100
- }
101
- // Interrupt process if progress callback returns `false`
102
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createdWorkflowItemId)) {
103
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
104
- void common.removeItem(createdWorkflowItemId, destinationAuthentication);
105
- return Promise.resolve(common.generateEmptyCreationResponse(template.type));
106
- }
107
- // Add the new item to the settings
108
- newItemTemplate.itemId = newItemTemplate.item.id = createdWorkflowItemId;
109
- templateDictionary[template.itemId] = {
110
- itemId: createdWorkflowItemId,
111
- };
112
- await workflowHelpers.updateTemplateDictionaryForWorkflow(template.itemId, createdWorkflowItemId, templateDictionary, destinationAuthentication);
113
- // Detempletize the workflow configuration
114
- newItemTemplate.properties.configuration = common.replaceInTemplate(newItemTemplate.properties.configuration, templateDictionary);
115
- // Add the item's configuration properties; throw if the configuration update fails
116
- const configZipFile = await common.compressWorkflowIntoZipFile(newItemTemplate.properties.configuration);
117
- await common.setWorkflowConfigurationZip(createdWorkflowItemId, configZipFile, templateDictionary.workflowBaseUrl, destinationAuthentication);
118
- // Fetch the auxiliary items
119
- const itemIds = await workflowHelpers.fetchAuxiliaryItems(createdWorkflowItemId, destinationAuthentication);
120
- // Move the workflow and auxiliary items to the destination
121
- itemIds.push(createdWorkflowItemId);
122
- const moveResults = await common.moveItemsToFolder(itemIds, templateDictionary.folderId, destinationAuthentication);
123
- const hasFailure = moveResults.some((result) => {
124
- return !result.success;
125
- });
126
- if (hasFailure) {
127
- throw new Error("Failed to move all workflow items");
128
- }
129
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createdWorkflowItemId);
130
- return Promise.resolve({
131
- item: newItemTemplate,
132
- id: createdWorkflowItemId,
133
- type: newItemTemplate.type,
134
- postProcess: false,
135
- });
136
- }
137
- catch (err) {
138
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
139
- return Promise.resolve(common.generateEmptyCreationResponse(template.type));
140
- }
141
- }
142
- exports.createItemFromTemplate = createItemFromTemplate;
143
- //# sourceMappingURL=workflow.js.map
@@ -1 +0,0 @@
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,EACrC,kBAAuB;IAEvB,gBAAgB;IAChB,MAAM,YAAY,GAAyB,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IAC1F,YAAY,CAAC,6BAA6B,GAAG,EAAE,CAAC,CAAC,8CAA8C;IAE/F,uCAAuC;IACvC,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;IAEpG,wBAAwB;IACxB,MAAM,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C,OAAO,EAAE,kBAAkB,CAAC,QAAQ,EAAE,yBAAyB,CAAC,CAAC;QACpH,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YAC7C,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,IAAI,UAAU,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;SACtD;QAED,oBAAoB,CAClB,QAAQ,CAAC,MAAM,EACf,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EACnC,QAAQ,CAAC,6BAA6B,GAAG,CAAC,EAC1C,qBAAqB,CACtB,CAAC;QAEF,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,eAAe;YACrB,EAAE,EAAE,qBAAqB;YACzB,IAAI,EAAE,eAAe,CAAC,IAAI;YAC1B,WAAW,EAAE,KAAK;SACnB,CAAC,CAAC;KACJ;IAAC,OAAO,GAAG,EAAE;QACZ,oBAAoB,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC5E,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,6BAA6B,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;KAC7E;AACH,CAAC;AAzGD,wDAyGC"}
@@ -1,79 +0,0 @@
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 workflowHelpers
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 workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
27
- * @param authentication Credentials for requests to the workflow manager
28
- * @returns Promise resolving with new item's AGO id
29
- * @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
30
- */
31
- export declare function addWorkflowItem(item: common.IItemTemplate, workflowBaseUrl: string, authentication: common.UserSession): Promise<string>;
32
- /**
33
- * Fetches the auxiliary items.
34
- *
35
- * @param workflowItemId Workflow whose auxiliary items are to be fetched
36
- * @param authentication Credentials for requests to the destination organization
37
- * @returns List of auxiliary item ids
38
- */
39
- export declare function fetchAuxiliaryItems(workflowItemId: string, authentication: common.UserSession): Promise<string[]>;
40
- /**
41
- * Updates the dependencies of the workflow item from its configuration.
42
- *
43
- * @param templates A collection of AGO item templates
44
- * @returns Updated templates list
45
- */
46
- export declare function postProcessFormItems(templates: common.IItemTemplate[]): common.IItemTemplate[];
47
- /**
48
- * Fetch the data from the new Workflow item and update the templateDictionary for variable replacement
49
- *
50
- * @param sourceId The id of the source Workflow item that was used to create the solution template
51
- * @param newId The id of the Workflow item that has been deployed
52
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
53
- * @param authentication Credentials for requests to the destination organization
54
- *
55
- */
56
- export declare function updateTemplateDictionaryForWorkflow(sourceId: string, newId: string, templateDictionary: any, authentication: common.UserSession): Promise<void>;
57
- /**
58
- * Store ids and key values for variable replacement from the new Workflow item based on
59
- * previously stored source IDs.
60
- *
61
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
62
- * @param key The property from the workflow items data that contains an item id for a supporting service
63
- * @param workflowLookup The stored source item Ids from the templateDictionary
64
- * @param workflowData The data object from the new Workflow item
65
- * @param authentication Credentials for requests to the destination organization
66
- *
67
- */
68
- export declare function updateTempDictWorkflowId(templateDictionary: any, key: string, workflowLookup: any, workflowData: any, authentication: common.UserSession): Promise<void>;
69
- /**
70
- * Store key values for variable replacement from the new Workflow item
71
- *
72
- * @param layers
73
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
74
- * @param baseUrl The base url of the new item
75
- * @param srcId The id of the source item that was used to create the solution
76
- * @param itemId The id of the new item that was created by workflow
77
- *
78
- */
79
- export declare function _cacheLayerDetails(layers: any[], templateDictionary: any, baseUrl: string, srcId: string, itemId: string): void;
@@ -1,166 +0,0 @@
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._cacheLayerDetails = exports.updateTempDictWorkflowId = exports.updateTemplateDictionaryForWorkflow = exports.postProcessFormItems = 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 workflowHelpers
24
- */
25
- const common = tslib_1.__importStar(require("@esri/solution-common"));
26
- // ------------------------------------------------------------------------------------------------------------------ //
27
- /**
28
- * Creates a new workflow item.
29
- *
30
- * @param item Item to add
31
- * @param workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
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, workflowBaseUrl, authentication) {
37
- // Add the workflow item
38
- const url = `${workflowBaseUrl}/admin/createWorkflowItem?name=${item.item.title}`;
39
- const options = {
40
- authentication: authentication,
41
- headers: {
42
- "Accept": "application/json",
43
- "Authorization": `Bearer ${authentication.token}`,
44
- "Content-Type": "application/json",
45
- "X-Esri-Authorization": `Bearer ${authentication.token}`,
46
- },
47
- params: {
48
- name: `${item.item.title}`,
49
- },
50
- };
51
- const createdWorkflowResponse = await common.request(url, options);
52
- return Promise.resolve(createdWorkflowResponse.itemId);
53
- }
54
- exports.addWorkflowItem = addWorkflowItem;
55
- /**
56
- * Fetches the auxiliary items.
57
- *
58
- * @param workflowItemId Workflow whose auxiliary items are to be fetched
59
- * @param authentication Credentials for requests to the destination organization
60
- * @returns List of auxiliary item ids
61
- */
62
- async function fetchAuxiliaryItems(workflowItemId, authentication) {
63
- const workflowItemName = `workflow_${workflowItemId}`;
64
- const workflowLocationsItemName = `WorkflowLocations_${workflowItemId}`;
65
- const workflowViewsItemName = `workflow_views_${workflowItemId}`;
66
- const auxiliaryItemsResults = await common.searchItems({
67
- q: `title:${workflowItemName} OR title:${workflowLocationsItemName} OR title:${workflowViewsItemName}`,
68
- authentication: authentication,
69
- });
70
- return Promise.resolve(auxiliaryItemsResults.results.map((item) => item.id));
71
- }
72
- exports.fetchAuxiliaryItems = fetchAuxiliaryItems;
73
- /**
74
- * Updates the dependencies of the workflow item from its configuration.
75
- *
76
- * @param templates A collection of AGO item templates
77
- * @returns Updated templates list
78
- */
79
- function postProcessFormItems(templates) {
80
- for (const template of templates) {
81
- if (template.type === "Workflow") {
82
- const ids = common.getTemplatedIds(JSON.stringify(template.properties.configuration));
83
- template.dependencies = common.dedupe([...template.dependencies, ...ids]);
84
- }
85
- }
86
- return templates;
87
- }
88
- exports.postProcessFormItems = postProcessFormItems;
89
- /**
90
- * Fetch the data from the new Workflow item and update the templateDictionary for variable replacement
91
- *
92
- * @param sourceId The id of the source Workflow item that was used to create the solution template
93
- * @param newId The id of the Workflow item that has been deployed
94
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
95
- * @param authentication Credentials for requests to the destination organization
96
- *
97
- */
98
- async function updateTemplateDictionaryForWorkflow(sourceId, newId, templateDictionary, authentication) {
99
- const workflowData = await common.getItemDataAsJson(newId, authentication);
100
- const workflowLookup = common.getProp(templateDictionary, `workflows.${sourceId}`);
101
- if (workflowLookup) {
102
- await updateTempDictWorkflowId(templateDictionary, "viewSchema", workflowLookup, workflowData, authentication);
103
- await updateTempDictWorkflowId(templateDictionary, "workflowLocations", workflowLookup, workflowData, authentication);
104
- await updateTempDictWorkflowId(templateDictionary, "workflowSchema", workflowLookup, workflowData, authentication);
105
- }
106
- }
107
- exports.updateTemplateDictionaryForWorkflow = updateTemplateDictionaryForWorkflow;
108
- /**
109
- * Store ids and key values for variable replacement from the new Workflow item based on
110
- * previously stored source IDs.
111
- *
112
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
113
- * @param key The property from the workflow items data that contains an item id for a supporting service
114
- * @param workflowLookup The stored source item Ids from the templateDictionary
115
- * @param workflowData The data object from the new Workflow item
116
- * @param authentication Credentials for requests to the destination organization
117
- *
118
- */
119
- async function updateTempDictWorkflowId(templateDictionary, key, workflowLookup, workflowData, authentication) {
120
- const id = workflowLookup[key];
121
- const itemId = common.getProp(workflowData, `${key}.itemId`);
122
- templateDictionary[id].itemId = itemId;
123
- const item = await common.getCompleteItem(itemId, authentication);
124
- const baseUrl = common.getProp(item, "base.url");
125
- templateDictionary[id].url = baseUrl;
126
- templateDictionary[id].name = common.getProp(item, "base.name");
127
- const layers = common.getProp(item, "featureServiceProperties.layers");
128
- _cacheLayerDetails(layers, templateDictionary, baseUrl, id, itemId);
129
- const tables = common.getProp(item, "featureServiceProperties.tables");
130
- _cacheLayerDetails(tables, templateDictionary, baseUrl, id, itemId);
131
- }
132
- exports.updateTempDictWorkflowId = updateTempDictWorkflowId;
133
- /**
134
- * Store key values for variable replacement from the new Workflow item
135
- *
136
- * @param layers
137
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
138
- * @param baseUrl The base url of the new item
139
- * @param srcId The id of the source item that was used to create the solution
140
- * @param itemId The id of the new item that was created by workflow
141
- *
142
- */
143
- function _cacheLayerDetails(layers, templateDictionary, baseUrl, srcId, itemId) {
144
- if (layers && srcId !== "__proto__" && srcId !== "constructor" && srcId !== "prototype") {
145
- layers.forEach((layer) => {
146
- const fields = layer.fields.reduce((prev, cur) => {
147
- prev[cur.name.toLowerCase()] = {
148
- alias: cur.alias,
149
- name: cur.name,
150
- type: cur.type,
151
- };
152
- return prev;
153
- }, {});
154
- const layerId = layer.id;
155
- const url = `${baseUrl}/${layerId}`;
156
- templateDictionary[srcId][`layer${layerId}`] = {
157
- fields,
158
- itemId,
159
- layerId,
160
- url,
161
- };
162
- });
163
- }
164
- }
165
- exports._cacheLayerDetails = _cacheLayerDetails;
166
- //# sourceMappingURL=workflowHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflowHelpers.js","sourceRoot":"","sources":["../../src/workflowHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AAEH,sEAAgD;AAEhD,wHAAwH;AAExH;;;;;;;;GAQG;AACI,KAAK,UAAU,eAAe,CACnC,IAA0B,EAC1B,eAAuB,EACvB,cAAkC;IAElC,wBAAwB;IACxB,MAAM,GAAG,GAAG,GAAG,eAAe,kCAAkC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAElF,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,cAAc;QAC9B,OAAO,EAAE;YACP,QAAQ,EAAE,kBAAkB;YAC5B,eAAe,EAAE,UAAU,cAAc,CAAC,KAAK,EAAE;YACjD,cAAc,EAAE,kBAAkB;YAClC,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,MAAM,CAAC,OAAO,CAAC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/** @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";
22
- export * from "./workflowHelpers";
package/dist/esm/index.js DELETED
@@ -1,23 +0,0 @@
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";
22
- export * from "./workflowHelpers";
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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"}
@@ -1,42 +0,0 @@
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
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
29
- * @returns A promise that will resolve when the template has been created
30
- */
31
- export declare function convertItemToTemplate(itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession, templateDictionary: any): Promise<common.IItemTemplate>;
32
- /**
33
- * Converts a workflow template into a new item.
34
- *
35
- * @param template Workflow template
36
- * @param templateDictionary Dictionary of terms to replace in the template
37
- * @param destAuthentication Credentials for requests to the destination organization
38
- * @param itemProgressCallback Callback function to report the progress of the item creation
39
- * @returns Promise resolving with the detemplatized item template, the new item's id, and a boolean
40
- * indicating if post-processing is needed
41
- */
42
- export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
@@ -1,137 +0,0 @@
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 workflowHelpers from "./workflowHelpers";
23
- // ------------------------------------------------------------------------------------------------------------------ //
24
- /**
25
- * Converts a workflow item into a template.
26
- *
27
- * @param itemInfo Info about the item
28
- * @param destAuthentication Credentials for requests to the destination organization
29
- * @param srcAuthentication Credentials for requests to source items
30
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
31
- * @returns A promise that will resolve when the template has been created
32
- */
33
- export async function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
34
- // Init template
35
- const itemTemplate = common.createInitializedItemTemplate(itemInfo);
36
- itemTemplate.estimatedDeploymentCostFactor = 20; // creating a workflow item can be really slow
37
- // Templatize item info property values
38
- itemTemplate.item.id = common.templatizeTerm(itemTemplate.item.id, itemTemplate.item.id, ".itemId");
39
- // Request related items
40
- const relatedPromise = common.getItemRelatedItemsInSameDirection(itemTemplate.itemId, "forward", srcAuthentication);
41
- // Request its configuration
42
- const configPromise = common.getWorkflowConfigurationZip(itemInfo.id, templateDictionary.workflowBaseUrl, srcAuthentication);
43
- // Request its data
44
- const dataPromise = common.getItemDataAsJson(itemInfo.id, srcAuthentication);
45
- const [relatedItems, configZip, data] = await Promise.all([relatedPromise, configPromise, dataPromise]);
46
- itemTemplate.data = data;
47
- // Save the mappings to related items & add those items to the dependencies, but not WMA Code Attachments
48
- itemTemplate.dependencies = [];
49
- itemTemplate.relatedItems = [];
50
- // get the dependencies listed in the workflow items data
51
- common.getWorkflowDependencies(itemTemplate);
52
- relatedItems.forEach((relatedItem) => {
53
- /* istanbul ignore else */
54
- if (relatedItem.relationshipType !== "WMA2Code") {
55
- itemTemplate.relatedItems.push(relatedItem);
56
- relatedItem.relatedItemIds.forEach((relatedItemId) => {
57
- if (itemTemplate.dependencies.indexOf(relatedItemId) < 0) {
58
- itemTemplate.dependencies.push(relatedItemId);
59
- }
60
- });
61
- }
62
- });
63
- // Add the configuration to the template
64
- itemTemplate.properties.configuration = await common.extractWorkflowFromZipFile(configZip);
65
- return Promise.resolve(itemTemplate);
66
- }
67
- /**
68
- * Converts a workflow template into a new item.
69
- *
70
- * @param template Workflow template
71
- * @param templateDictionary Dictionary of terms to replace in the template
72
- * @param destAuthentication Credentials for requests to the destination organization
73
- * @param itemProgressCallback Callback function to report the progress of the item creation
74
- * @returns Promise resolving with the detemplatized item template, the new item's id, and a boolean
75
- * indicating if post-processing is needed
76
- */
77
- export async function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
78
- // Interrupt process if progress callback returns `false`
79
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Started, 0)) {
80
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Ignored, 0);
81
- return Promise.resolve(common.generateEmptyCreationResponse(template.type));
82
- }
83
- template.data = {};
84
- // Replace the templatized symbols in a copy of the template
85
- let newItemTemplate = common.cloneObject(template);
86
- newItemTemplate = common.replaceInTemplate(newItemTemplate, templateDictionary);
87
- /* istanbul ignore else */
88
- if (template.item.thumbnail) {
89
- newItemTemplate.item.thumbnail = template.item.thumbnail;
90
- }
91
- try {
92
- const createdWorkflowItemId = await workflowHelpers.addWorkflowItem(newItemTemplate, templateDictionary.workflowBaseUrl, destinationAuthentication);
93
- if (!createdWorkflowItemId) {
94
- throw new Error("Failed to create workflow item");
95
- }
96
- // Interrupt process if progress callback returns `false`
97
- if (!itemProgressCallback(template.itemId, common.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createdWorkflowItemId)) {
98
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Cancelled, 0);
99
- void common.removeItem(createdWorkflowItemId, destinationAuthentication);
100
- return Promise.resolve(common.generateEmptyCreationResponse(template.type));
101
- }
102
- // Add the new item to the settings
103
- newItemTemplate.itemId = newItemTemplate.item.id = createdWorkflowItemId;
104
- templateDictionary[template.itemId] = {
105
- itemId: createdWorkflowItemId,
106
- };
107
- await workflowHelpers.updateTemplateDictionaryForWorkflow(template.itemId, createdWorkflowItemId, templateDictionary, destinationAuthentication);
108
- // Detempletize the workflow configuration
109
- newItemTemplate.properties.configuration = common.replaceInTemplate(newItemTemplate.properties.configuration, templateDictionary);
110
- // Add the item's configuration properties; throw if the configuration update fails
111
- const configZipFile = await common.compressWorkflowIntoZipFile(newItemTemplate.properties.configuration);
112
- await common.setWorkflowConfigurationZip(createdWorkflowItemId, configZipFile, templateDictionary.workflowBaseUrl, destinationAuthentication);
113
- // Fetch the auxiliary items
114
- const itemIds = await workflowHelpers.fetchAuxiliaryItems(createdWorkflowItemId, destinationAuthentication);
115
- // Move the workflow and auxiliary items to the destination
116
- itemIds.push(createdWorkflowItemId);
117
- const moveResults = await common.moveItemsToFolder(itemIds, templateDictionary.folderId, destinationAuthentication);
118
- const hasFailure = moveResults.some((result) => {
119
- return !result.success;
120
- });
121
- if (hasFailure) {
122
- throw new Error("Failed to move all workflow items");
123
- }
124
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createdWorkflowItemId);
125
- return Promise.resolve({
126
- item: newItemTemplate,
127
- id: createdWorkflowItemId,
128
- type: newItemTemplate.type,
129
- postProcess: false,
130
- });
131
- }
132
- catch (err) {
133
- itemProgressCallback(template.itemId, common.EItemProgressStatus.Failed, 0);
134
- return Promise.resolve(common.generateEmptyCreationResponse(template.type));
135
- }
136
- }
137
- //# sourceMappingURL=workflow.js.map
@@ -1 +0,0 @@
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,EACrC,kBAAuB;IAEvB,gBAAgB;IAChB,MAAM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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 workflowHelpers
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 workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
27
- * @param authentication Credentials for requests to the workflow manager
28
- * @returns Promise resolving with new item's AGO id
29
- * @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
30
- */
31
- export declare function addWorkflowItem(item: common.IItemTemplate, workflowBaseUrl: string, authentication: common.UserSession): Promise<string>;
32
- /**
33
- * Fetches the auxiliary items.
34
- *
35
- * @param workflowItemId Workflow whose auxiliary items are to be fetched
36
- * @param authentication Credentials for requests to the destination organization
37
- * @returns List of auxiliary item ids
38
- */
39
- export declare function fetchAuxiliaryItems(workflowItemId: string, authentication: common.UserSession): Promise<string[]>;
40
- /**
41
- * Updates the dependencies of the workflow item from its configuration.
42
- *
43
- * @param templates A collection of AGO item templates
44
- * @returns Updated templates list
45
- */
46
- export declare function postProcessFormItems(templates: common.IItemTemplate[]): common.IItemTemplate[];
47
- /**
48
- * Fetch the data from the new Workflow item and update the templateDictionary for variable replacement
49
- *
50
- * @param sourceId The id of the source Workflow item that was used to create the solution template
51
- * @param newId The id of the Workflow item that has been deployed
52
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
53
- * @param authentication Credentials for requests to the destination organization
54
- *
55
- */
56
- export declare function updateTemplateDictionaryForWorkflow(sourceId: string, newId: string, templateDictionary: any, authentication: common.UserSession): Promise<void>;
57
- /**
58
- * Store ids and key values for variable replacement from the new Workflow item based on
59
- * previously stored source IDs.
60
- *
61
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
62
- * @param key The property from the workflow items data that contains an item id for a supporting service
63
- * @param workflowLookup The stored source item Ids from the templateDictionary
64
- * @param workflowData The data object from the new Workflow item
65
- * @param authentication Credentials for requests to the destination organization
66
- *
67
- */
68
- export declare function updateTempDictWorkflowId(templateDictionary: any, key: string, workflowLookup: any, workflowData: any, authentication: common.UserSession): Promise<void>;
69
- /**
70
- * Store key values for variable replacement from the new Workflow item
71
- *
72
- * @param layers
73
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
74
- * @param baseUrl The base url of the new item
75
- * @param srcId The id of the source item that was used to create the solution
76
- * @param itemId The id of the new item that was created by workflow
77
- *
78
- */
79
- export declare function _cacheLayerDetails(layers: any[], templateDictionary: any, baseUrl: string, srcId: string, itemId: string): void;
@@ -1,156 +0,0 @@
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 workflowHelpers
20
- */
21
- import * as common from "@esri/solution-common";
22
- // ------------------------------------------------------------------------------------------------------------------ //
23
- /**
24
- * Creates a new workflow item.
25
- *
26
- * @param item Item to add
27
- * @param workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
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, workflowBaseUrl, authentication) {
33
- // Add the workflow item
34
- const url = `${workflowBaseUrl}/admin/createWorkflowItem?name=${item.item.title}`;
35
- const options = {
36
- authentication: authentication,
37
- headers: {
38
- "Accept": "application/json",
39
- "Authorization": `Bearer ${authentication.token}`,
40
- "Content-Type": "application/json",
41
- "X-Esri-Authorization": `Bearer ${authentication.token}`,
42
- },
43
- params: {
44
- name: `${item.item.title}`,
45
- },
46
- };
47
- const createdWorkflowResponse = await common.request(url, options);
48
- return Promise.resolve(createdWorkflowResponse.itemId);
49
- }
50
- /**
51
- * Fetches the auxiliary items.
52
- *
53
- * @param workflowItemId Workflow whose auxiliary items are to be fetched
54
- * @param authentication Credentials for requests to the destination organization
55
- * @returns List of auxiliary item ids
56
- */
57
- export async function fetchAuxiliaryItems(workflowItemId, authentication) {
58
- const workflowItemName = `workflow_${workflowItemId}`;
59
- const workflowLocationsItemName = `WorkflowLocations_${workflowItemId}`;
60
- const workflowViewsItemName = `workflow_views_${workflowItemId}`;
61
- const auxiliaryItemsResults = await common.searchItems({
62
- q: `title:${workflowItemName} OR title:${workflowLocationsItemName} OR title:${workflowViewsItemName}`,
63
- authentication: authentication,
64
- });
65
- return Promise.resolve(auxiliaryItemsResults.results.map((item) => item.id));
66
- }
67
- /**
68
- * Updates the dependencies of the workflow item from its configuration.
69
- *
70
- * @param templates A collection of AGO item templates
71
- * @returns Updated templates list
72
- */
73
- export function postProcessFormItems(templates) {
74
- for (const template of templates) {
75
- if (template.type === "Workflow") {
76
- const ids = common.getTemplatedIds(JSON.stringify(template.properties.configuration));
77
- template.dependencies = common.dedupe([...template.dependencies, ...ids]);
78
- }
79
- }
80
- return templates;
81
- }
82
- /**
83
- * Fetch the data from the new Workflow item and update the templateDictionary for variable replacement
84
- *
85
- * @param sourceId The id of the source Workflow item that was used to create the solution template
86
- * @param newId The id of the Workflow item that has been deployed
87
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
88
- * @param authentication Credentials for requests to the destination organization
89
- *
90
- */
91
- export async function updateTemplateDictionaryForWorkflow(sourceId, newId, templateDictionary, authentication) {
92
- const workflowData = await common.getItemDataAsJson(newId, authentication);
93
- const workflowLookup = common.getProp(templateDictionary, `workflows.${sourceId}`);
94
- if (workflowLookup) {
95
- await updateTempDictWorkflowId(templateDictionary, "viewSchema", workflowLookup, workflowData, authentication);
96
- await updateTempDictWorkflowId(templateDictionary, "workflowLocations", workflowLookup, workflowData, authentication);
97
- await updateTempDictWorkflowId(templateDictionary, "workflowSchema", workflowLookup, workflowData, authentication);
98
- }
99
- }
100
- /**
101
- * Store ids and key values for variable replacement from the new Workflow item based on
102
- * previously stored source IDs.
103
- *
104
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
105
- * @param key The property from the workflow items data that contains an item id for a supporting service
106
- * @param workflowLookup The stored source item Ids from the templateDictionary
107
- * @param workflowData The data object from the new Workflow item
108
- * @param authentication Credentials for requests to the destination organization
109
- *
110
- */
111
- export async function updateTempDictWorkflowId(templateDictionary, key, workflowLookup, workflowData, authentication) {
112
- const id = workflowLookup[key];
113
- const itemId = common.getProp(workflowData, `${key}.itemId`);
114
- templateDictionary[id].itemId = itemId;
115
- const item = await common.getCompleteItem(itemId, authentication);
116
- const baseUrl = common.getProp(item, "base.url");
117
- templateDictionary[id].url = baseUrl;
118
- templateDictionary[id].name = common.getProp(item, "base.name");
119
- const layers = common.getProp(item, "featureServiceProperties.layers");
120
- _cacheLayerDetails(layers, templateDictionary, baseUrl, id, itemId);
121
- const tables = common.getProp(item, "featureServiceProperties.tables");
122
- _cacheLayerDetails(tables, templateDictionary, baseUrl, id, itemId);
123
- }
124
- /**
125
- * Store key values for variable replacement from the new Workflow item
126
- *
127
- * @param layers
128
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
129
- * @param baseUrl The base url of the new item
130
- * @param srcId The id of the source item that was used to create the solution
131
- * @param itemId The id of the new item that was created by workflow
132
- *
133
- */
134
- export function _cacheLayerDetails(layers, templateDictionary, baseUrl, srcId, itemId) {
135
- if (layers && srcId !== "__proto__" && srcId !== "constructor" && srcId !== "prototype") {
136
- layers.forEach((layer) => {
137
- const fields = layer.fields.reduce((prev, cur) => {
138
- prev[cur.name.toLowerCase()] = {
139
- alias: cur.alias,
140
- name: cur.name,
141
- type: cur.type,
142
- };
143
- return prev;
144
- }, {});
145
- const layerId = layer.id;
146
- const url = `${baseUrl}/${layerId}`;
147
- templateDictionary[srcId][`layer${layerId}`] = {
148
- fields,
149
- itemId,
150
- layerId,
151
- url,
152
- };
153
- });
154
- }
155
- }
156
- //# sourceMappingURL=workflowHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflowHelpers.js","sourceRoot":"","sources":["../../src/workflowHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAEhD,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAA0B,EAC1B,eAAuB,EACvB,cAAkC;IAElC,wBAAwB;IACxB,MAAM,GAAG,GAAG,GAAG,eAAe,kCAAkC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAElF,MAAM,OAAO,GAA2B;QACtC,cAAc,EAAE,cAAc;QAC9B,OAAO,EAAE;YACP,QAAQ,EAAE,kBAAkB;YAC5B,eAAe,EAAE,UAAU,cAAc,CAAC,KAAK,EAAE;YACjD,cAAc,EAAE,kBAAkB;YAClC,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,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAEnE,OAAO,OAAO,CAAC,OAAO,CAAC,uBAA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