@esri/solution-common 5.3.7 → 5.4.1

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.
Files changed (49) hide show
  1. package/dist/cjs/completeItem.js +2 -7
  2. package/dist/cjs/completeItem.js.map +1 -1
  3. package/dist/cjs/deleteHelpers/removeItems.js +5 -0
  4. package/dist/cjs/deleteHelpers/removeItems.js.map +1 -1
  5. package/dist/cjs/formHelpers.d.ts +0 -15
  6. package/dist/cjs/formHelpers.js +1 -39
  7. package/dist/cjs/formHelpers.js.map +1 -1
  8. package/dist/cjs/index.d.ts +1 -0
  9. package/dist/cjs/index.js +1 -0
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/interfaces.d.ts +40 -0
  12. package/dist/cjs/interfaces.js.map +1 -1
  13. package/dist/cjs/item-reuse.d.ts +141 -0
  14. package/dist/cjs/item-reuse.js +173 -0
  15. package/dist/cjs/item-reuse.js.map +1 -0
  16. package/dist/cjs/restHelpers.d.ts +5 -7
  17. package/dist/cjs/restHelpers.js +7 -12
  18. package/dist/cjs/restHelpers.js.map +1 -1
  19. package/dist/cjs/restHelpersGet.d.ts +16 -0
  20. package/dist/cjs/restHelpersGet.js +27 -1
  21. package/dist/cjs/restHelpersGet.js.map +1 -1
  22. package/dist/cjs/workflowHelpers.d.ts +22 -21
  23. package/dist/cjs/workflowHelpers.js +76 -48
  24. package/dist/cjs/workflowHelpers.js.map +1 -1
  25. package/dist/esm/completeItem.js +2 -7
  26. package/dist/esm/completeItem.js.map +1 -1
  27. package/dist/esm/deleteHelpers/removeItems.js +5 -0
  28. package/dist/esm/deleteHelpers/removeItems.js.map +1 -1
  29. package/dist/esm/formHelpers.d.ts +0 -15
  30. package/dist/esm/formHelpers.js +0 -36
  31. package/dist/esm/formHelpers.js.map +1 -1
  32. package/dist/esm/index.d.ts +1 -0
  33. package/dist/esm/index.js +1 -0
  34. package/dist/esm/index.js.map +1 -1
  35. package/dist/esm/interfaces.d.ts +40 -0
  36. package/dist/esm/interfaces.js.map +1 -1
  37. package/dist/esm/item-reuse.d.ts +141 -0
  38. package/dist/esm/item-reuse.js +164 -0
  39. package/dist/esm/item-reuse.js.map +1 -0
  40. package/dist/esm/restHelpers.d.ts +5 -7
  41. package/dist/esm/restHelpers.js +7 -12
  42. package/dist/esm/restHelpers.js.map +1 -1
  43. package/dist/esm/restHelpersGet.d.ts +16 -0
  44. package/dist/esm/restHelpersGet.js +24 -0
  45. package/dist/esm/restHelpersGet.js.map +1 -1
  46. package/dist/esm/workflowHelpers.d.ts +22 -21
  47. package/dist/esm/workflowHelpers.js +72 -44
  48. package/dist/esm/workflowHelpers.js.map +1 -1
  49. package/package.json +5 -5
@@ -62,13 +62,8 @@ async function getCompleteItem(itemId, authentication) {
62
62
  completeItem.featureServiceProperties = await restHelpers.getFeatureServiceProperties(itemBase.url, authentication);
63
63
  }
64
64
  else if (itemBase.type === "Workflow") {
65
- const user = await restHelpersGet.getUser(authentication);
66
- let server;
67
- const portal = new URL(authentication.portal);
68
- if (!portal.origin.endsWith(".arcgis.com") && !portal.origin.endsWith(".esri.com")) {
69
- server = authentication.portal.replace("/sharing/rest", "");
70
- }
71
- const workflowConfigZip = await restHelpers.getWorkflowConfigurationZip(itemBase.id, authentication, user.orgId, server);
65
+ const workflowBaseUrl = await workflowHelpers.getWorkflowBaseURL(authentication);
66
+ const workflowConfigZip = await restHelpers.getWorkflowConfigurationZip(itemBase.id, workflowBaseUrl, authentication);
72
67
  completeItem.workflowConfiguration = await workflowHelpers.extractWorkflowFromZipFile(workflowConfigZip);
73
68
  }
74
69
  return Promise.resolve(completeItem);
@@ -1 +1 @@
1
- {"version":3,"file":"completeItem.js","sourceRoot":"","sources":["../../src/completeItem.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAYH,mEAA6C;AAC7C,yEAAmD;AACnD,2EAAqD;AAErD,wHAAwH;AAExH;;;;;;GAMG;AACI,KAAK,UAAU,eAAe,CACnC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AAe,CAAC,0BAA0B,CAAC,iBAAiB,CAAC,CAAC;KAC1G;IAED,OAAO,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AACvC,CAAC;AArED,0CAqEC"}
@@ -25,6 +25,7 @@ const reportProgress = tslib_1.__importStar(require("./reportProgress"));
25
25
  const hubSites = tslib_1.__importStar(require("@esri/hub-sites"));
26
26
  const portal = tslib_1.__importStar(require("@esri/arcgis-rest-portal"));
27
27
  const restHelpers = tslib_1.__importStar(require("../restHelpers"));
28
+ const workflowHelpers = tslib_1.__importStar(require("../workflowHelpers"));
28
29
  const create_hub_request_options_1 = require("../create-hub-request-options");
29
30
  // ------------------------------------------------------------------------------------------------------------------ //
30
31
  /**
@@ -64,6 +65,10 @@ function removeItems(solutionSummary, hubSiteItemIds, authentication, percentDon
64
65
  const options = await (0, create_hub_request_options_1.createHubRequestOptions)(authentication);
65
66
  return hubSites.removeSite(itemToDelete.id, options);
66
67
  }
68
+ else if (itemToDelete.type === "Workflow") {
69
+ const workflowBaseUrl = await workflowHelpers.getWorkflowBaseURL(authentication);
70
+ return workflowHelpers.deleteWorkflowItem(itemToDelete.id, workflowBaseUrl, authentication);
71
+ }
67
72
  else {
68
73
  return restHelpers.removeItem(itemToDelete.id, authentication);
69
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"removeItems.js","sourceRoot":"","sources":["../../../src/deleteHelpers/removeItems.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;GAEG;AAEH,8CAKuB;AACvB,yEAAmD;AACnD,kEAA4C;AAC5C,yEAAmD;AACnD,oEAA8C;AAC9C,8EAAwE;AAExE,wHAAwH;AAExH;;;;;;;;;;;;;GAaG;AACH,SAAgB,WAAW,CACzB,eAAgC,EAChC,cAAwB,EACxB,cAA2B,EAC3B,WAAmB,EACnB,mBAA2B,EAC3B,gBAAwC,EAAE;IAE1C,IAAI,sBAAuC,CAAC;IAC5C,IAAI,sBAAuC,CAAC;IAC5C,MA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B,GAAG;YACvB,EAAE,EAAE,eAAe,CAAC,EAAE;YACtB,KAAK,EAAE,eAAe,CAAC,KAAK;YAC5B,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;SACX,CAAC;QACF,sBAAsB,GAAG;YACvB,EAAE,EAAE,eAAe,CAAC,EAAE;YACtB,KAAK,EAAE,eAAe,CAAC,KAAK;YAC5B,MAAM,EAAE,eAAe,CAAC,MAAM;YAC9B,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,EAAE;SACX,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,sBAAsB,EAAE,sBAAsB,CAAC,CAAC,CAAC;KAC1E;AACH,CAAC;AApGD,kCAoGC"}
@@ -15,21 +15,6 @@
15
15
  */
16
16
  import { UserSession } from "./interfaces";
17
17
  import JSZip from "jszip";
18
- /**
19
- * Gets the webhooks from a Form zip object's *.info file.
20
- *
21
- * @param zipObject Zip file object from which to get the webhooks
22
- * @returns Promise that resolves to an array of webhooks
23
- */
24
- export declare function getWebHooksFromZipObject(zipObject: JSZip): Promise<string[]>;
25
- /**
26
- * Sets the webhooks in a Form zip object's *.info file.
27
- *
28
- * @param zipObject Zip file object in which to set the webhooks
29
- * @param webHooks Array of webhooks to set
30
- * @returns Promise that resolves to the updated zip object
31
- */
32
- export declare function setWebHooksInZipObject(zipObject: JSZip, webHooks: any[]): Promise<JSZip>;
33
18
  /**
34
19
  * Updates an item with a zip object, including any webhooks.
35
20
  *
@@ -15,49 +15,11 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.updateItemWithZipObject = exports.setWebHooksInZipObject = exports.getWebHooksFromZipObject = void 0;
18
+ exports.updateItemWithZipObject = void 0;
19
19
  const tslib_1 = require("tslib");
20
- const generalHelpers = tslib_1.__importStar(require("./generalHelpers"));
21
20
  const zipUtils = tslib_1.__importStar(require("./zip-utils"));
22
21
  const restHelpers_1 = require("./restHelpers");
23
22
  // ------------------------------------------------------------------------------------------------------------------ //
24
- /**
25
- * Gets the webhooks from a Form zip object's *.info file.
26
- *
27
- * @param zipObject Zip file object from which to get the webhooks
28
- * @returns Promise that resolves to an array of webhooks
29
- */
30
- async function getWebHooksFromZipObject(zipObject) {
31
- const zipObjectContents = await zipUtils.getZipObjectContents(zipObject);
32
- let webhooks = [];
33
- zipObjectContents.forEach((zipFile) => {
34
- if (zipFile.file.endsWith(".info")) {
35
- const infoFileJson = JSON.parse(zipFile.content);
36
- webhooks = generalHelpers.getProp(infoFileJson, "notificationsInfo.webhooks") || [];
37
- }
38
- });
39
- return Promise.resolve(webhooks);
40
- }
41
- exports.getWebHooksFromZipObject = getWebHooksFromZipObject;
42
- /**
43
- * Sets the webhooks in a Form zip object's *.info file.
44
- *
45
- * @param zipObject Zip file object in which to set the webhooks
46
- * @param webHooks Array of webhooks to set
47
- * @returns Promise that resolves to the updated zip object
48
- */
49
- async function setWebHooksInZipObject(zipObject, webHooks) {
50
- const zipObjectContents = await zipUtils.getZipObjectContents(zipObject);
51
- zipObjectContents.forEach((zipFile) => {
52
- if (zipFile.file.endsWith(".info")) {
53
- const infoFileJson = JSON.parse(zipFile.content);
54
- generalHelpers.setProp(infoFileJson, "notificationsInfo.webhooks", webHooks);
55
- zipObject.file(zipFile.file, JSON.stringify(infoFileJson));
56
- }
57
- });
58
- return Promise.resolve(zipObject);
59
- }
60
- exports.setWebHooksInZipObject = setWebHooksInZipObject;
61
23
  /**
62
24
  * Updates an item with a zip object, including any webhooks.
63
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"formHelpers.js","sourceRoot":"","sources":["../../src/formHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,yEAAmD;AAEnD,8DAAwC;AACxC,+CAA2C;AAI3C,wHAAwH;AAExH;;;;;GAKG;AACI,KAAK,UAAU,wBAAwB,CAC5C,SAAgB;IAEhB,MAAM,iBAAi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IAEtC,sCAAsC;IACtC,MAAM,MAAM,GAAgB;QAC1B,EAAE,EAAE,iBAAiB;QACrB,IAAI,EAAG,MAAM,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,iBAAiB,MAAM,CAAC;KAChF,CAAA;IAED,OAAO,IAAA,wBAAU,EAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;AACvD,CAAC;AAZD,0DAYC"}
1
+ {"version":3,"file":"formHelpers.js","sourceRoot":"","sources":["../../src/formHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,8DAAwC;AACxC,+CAA2C;AAI3C,wHAAwH;AAExH;;;;;;;GAOG;AACI,KAAK,UAAU,uBAAuB,CAC3C,SAAgB,EAChB,iBAAyB,EACzB,yBAAsC;IAEtC,sCAAsC;IACtC,MAAM,MAAM,GAAgB;QAC1B,EAAE,EAAE,iBAAiB;QACrB,IAAI,EAAG,MAAM,QAAQ,CAAC,kBAAkB,CAAC,SAAS,EAAE,GAAG,iBAAiB,MAAM,CAAC;KAChF,CAAA;IAED,OAAO,IAAA,wBAAU,EAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;AACvD,CAAC;AAZD,0DAYC"}
@@ -31,6 +31,7 @@ export * from "./getItemTypeAbbrev";
31
31
  export * from "./getSolutionSummary";
32
32
  export * from "./get-subscription-info";
33
33
  export * from "./interfaces";
34
+ export * from "./item-reuse";
34
35
  export * from "./libConnectors";
35
36
  export * from "./migrator";
36
37
  export * from "./resourceHelpers";
package/dist/cjs/index.js CHANGED
@@ -34,6 +34,7 @@ tslib_1.__exportStar(require("./getItemTypeAbbrev"), exports);
34
34
  tslib_1.__exportStar(require("./getSolutionSummary"), exports);
35
35
  tslib_1.__exportStar(require("./get-subscription-info"), exports);
36
36
  tslib_1.__exportStar(require("./interfaces"), exports);
37
+ tslib_1.__exportStar(require("./item-reuse"), exports);
37
38
  tslib_1.__exportStar(require("./libConnectors"), exports);
38
39
  tslib_1.__exportStar(require("./migrator"), exports);
39
40
  tslib_1.__exportStar(require("./resourceHelpers"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,yDAA+B;AAC/B,uEAA6C;AAC7C,0DAAgC;AAChC,2DAAiC;AACjC,yDAA+B;AAC/B,kEAAwC;AACxC,wDAA8B;AAC9B,2DAAiC;AACjC,qEAA2C;AAC3C,8DAAoC;AACpC,+DAAqC;AACrC,kEAAwC;AACxC,uDAA6B;AAC7B,0DAAgC;AAChC,qDAA2B;AAC3B,4DAAkC;AAClC,sDAA4B;AAC5B,wDAA8B;AAC9B,2DAAiC;AACjC,oDAA0B;AAC1B,2DAAiC;AACjC,4DAAkC;AAClC,4DAAkC;AAClC,4DAAkC;AAClC,6DAAmC;AACnC,sDAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH;;;;GAIG;AAEH,yDAA+B;AAC/B,uEAA6C;AAC7C,0DAAgC;AAChC,2DAAiC;AACjC,yDAA+B;AAC/B,kEAAwC;AACxC,wDAA8B;AAC9B,2DAAiC;AACjC,qEAA2C;AAC3C,8DAAoC;AACpC,+DAAqC;AACrC,kEAAwC;AACxC,uDAA6B;AAC7B,uDAA6B;AAC7B,0DAAgC;AAChC,qDAA2B;AAC3B,4DAAkC;AAClC,sDAA4B;AAC5B,wDAA8B;AAC9B,2DAAiC;AACjC,oDAA0B;AAC1B,2DAAiC;AACjC,4DAAkC;AAClC,4DAAkC;AAClC,4DAAkC;AAClC,6DAAmC;AACnC,sDAA4B"}
@@ -1014,11 +1014,51 @@ export interface ISolutionItemData {
1014
1014
  * General information about the solution template
1015
1015
  */
1016
1016
  metadata: any;
1017
+ /**
1018
+ * Supplemental information about the solution, e.g., its default spatial reference
1019
+ */
1020
+ params?: ISolutionItemDataParams;
1017
1021
  /**
1018
1022
  * The collection of templates
1019
1023
  */
1020
1024
  templates: IItemTemplate[];
1021
1025
  }
1026
+ /**
1027
+ * Supplemental information about the solution, e.g., its default spatial reference
1028
+ */
1029
+ export interface ISolutionItemDataParams {
1030
+ /**
1031
+ * Information about the default spatial reference for a solution item.
1032
+ */
1033
+ wkid: ISolutionItemDataWkidParams;
1034
+ }
1035
+ /**
1036
+ * Information about the default spatial reference for a solution item.
1037
+ */
1038
+ export interface ISolutionItemDataWkidParams {
1039
+ /**
1040
+ * A label for the wkid, e.g., "Spatial Reference".
1041
+ */
1042
+ label: string;
1043
+ /**
1044
+ * The default wkid, e.g., "102100"
1045
+ */
1046
+ default: string;
1047
+ /**
1048
+ * A value flag, e.g., "spatialReference"
1049
+ */
1050
+ valueType: string;
1051
+ /**
1052
+ * Attributes of the default spatial reference for a solution item.
1053
+ */
1054
+ attributes: ISolutionItemDataWkidAttrsParams;
1055
+ }
1056
+ /**
1057
+ * Attributes of the default spatial reference for a solution item.
1058
+ */
1059
+ export interface ISolutionItemDataWkidAttrsParams {
1060
+ required: boolean;
1061
+ }
1022
1062
  /**
1023
1063
  * A brief form of an item in a deployed Solution item.
1024
1064
  */
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAeH,wHAAwH;AAExH,2DAIgC;AAD9B,+GAAA,WAAW,OAAA;AAEb,6EAMyC;AADvC,yHAAA,YAAY,OAAA;AAwBd,wHAAwH;AAE3G,QAAA,6BAA6B,GAAG,CAAC,CAAC;AAClC,QAAA,6BAA6B,GAAG,CAAC,CAAC;AAClC,QAAA,WAAW,GAAG,aAAa,CAAC;AAEzC,wHAAwH;AAExH;;GAEG;AACH,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,yCAAI,CAAA;IACJ,yCAAI,CAAA;IACJ,iDAAQ,CAAA;IACR,iDAAQ,CAAA;IACR,mDAAS,CAAA;AACX,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB;AAED;;GAEG;AACH,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,yCAAM,CAAA;IACN,yCAAM,CAAA;IACN,iDAAU,CAAA;IACV,iDAAU,CAAA;IACV,mDAAW,CAAA;AACb,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB;AAED;;GAEG;AACH,IAAY,mBAQX;AARD,WAAY,mBAAmB;IAC7B,mEAAO,CAAA;IACP,mEAAO,CAAA;IACP,uEAAS,CAAA;IACT,qEAAQ,CAAA;IACR,mEAAO,CAAA;IACP,iEAAM,CAAA;IACN,mEAAO,CAAA;AACT,CAAC,EARW,mBAAmB,mCAAnB,mBAAmB,QAQ9B;AAED;;GAEG;AACU,QAAA,mBAAmB,GAAG;IACjC,WAAW;IACX,WAAW;IACX,aAAa;IACb,YAAY;IACZ,WAAW;IACX,UAAU;IACV,SAAS;CACV,CAAC;AA2hDF,wHAAwH"}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAeH,wHAAwH;AAExH,2DAIgC;AAD9B,+GAAA,WAAW,OAAA;AAEb,6EAMyC;AADvC,yHAAA,YAAY,OAAA;AAwBd,wHAAwH;AAE3G,QAAA,6BAA6B,GAAG,CAAC,CAAC;AAClC,QAAA,6BAA6B,GAAG,CAAC,CAAC;AAClC,QAAA,WAAW,GAAG,aAAa,CAAC;AAEzC,wHAAwH;AAExH;;GAEG;AACH,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,yCAAI,CAAA;IACJ,yCAAI,CAAA;IACJ,iDAAQ,CAAA;IACR,iDAAQ,CAAA;IACR,mDAAS,CAAA;AACX,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB;AAED;;GAEG;AACH,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,yCAAM,CAAA;IACN,yCAAM,CAAA;IACN,iDAAU,CAAA;IACV,iDAAU,CAAA;IACV,mDAAW,CAAA;AACb,CAAC,EANW,SAAS,yBAAT,SAAS,QAMpB;AAED;;GAEG;AACH,IAAY,mBAQX;AARD,WAAY,mBAAmB;IAC7B,mEAAO,CAAA;IACP,mEAAO,CAAA;IACP,uEAAS,CAAA;IACT,qEAAQ,CAAA;IACR,mEAAO,CAAA;IACP,iEAAM,CAAA;IACN,mEAAO,CAAA;AACT,CAAC,EARW,mBAAmB,mCAAnB,mBAAmB,QAQ9B;AAED;;GAEG;AACU,QAAA,mBAAmB,GAAG;IACjC,WAAW;IACX,WAAW;IACX,aAAa;IACb,YAAY;IACZ,WAAW;IACX,UAAU;IACV,SAAS;CACV,CAAC;AA0kDF,wHAAwH"}
@@ -0,0 +1,141 @@
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
+ * @module item-reuse
17
+ */
18
+ import { UserSession } from "./interfaces";
19
+ import { IItem, ISearchResult } from "@esri/arcgis-rest-portal";
20
+ export interface ISourceItem {
21
+ /**
22
+ * The key is the id of the item as it is within the solution template that will be deployed
23
+ */
24
+ [key: string]: IReuseItem;
25
+ }
26
+ /**
27
+ * Object that contains key details for items that could be leveraged for reuse
28
+ */
29
+ export interface IReuseItem {
30
+ /**
31
+ * The key is the id of the item as it is within the solution template that will be deployed
32
+ */
33
+ [key: string]: IReuseItemInfo;
34
+ }
35
+ /**
36
+ * Object that contains key details for an item that could be leveraged for reuse
37
+ */
38
+ export interface IReuseItemInfo {
39
+ /**
40
+ * The date/time the item was created
41
+ */
42
+ created: number;
43
+ /**
44
+ * A collection of key details from solutions that leverage this item
45
+ */
46
+ solutions: IReuseSolutions;
47
+ /**
48
+ * The title of the item that is already deployed
49
+ */
50
+ title: string;
51
+ /**
52
+ * The type of item that is already deployed
53
+ */
54
+ type: string;
55
+ }
56
+ /**
57
+ * A collection of key details from a solutions that leverage one or more reuse items
58
+ */
59
+ export interface IReuseSolutions {
60
+ /**
61
+ * A collection of key details from a solution that leverages one or more reuse items
62
+ * The key is the id of the deployed solution.
63
+ */
64
+ [key: string]: IReuseSolution;
65
+ }
66
+ /**
67
+ * A collection of key details from a solution that leverages one or more reuse items
68
+ */
69
+ export interface IReuseSolution {
70
+ /**
71
+ * The date/time the solution was created
72
+ */
73
+ created: number;
74
+ /**
75
+ * The title of the solution is already deployed
76
+ */
77
+ title: string;
78
+ }
79
+ /**
80
+ * Collection of key details about one or more solutions
81
+ */
82
+ export interface ISolutionInfos {
83
+ /**
84
+ * Key details about a solution
85
+ * The key value is the solutions item id
86
+ */
87
+ [key: string]: ISolutionInfo;
88
+ }
89
+ /**
90
+ * Key details about a solution
91
+ */
92
+ export interface ISolutionInfo {
93
+ /**
94
+ * Array of template ids from the solution
95
+ */
96
+ templates: string[];
97
+ /**
98
+ * A collection of key details from a solution that leverages one or more reuse items
99
+ */
100
+ solutionInfo: IReuseSolution;
101
+ }
102
+ /**
103
+ * Find all deployed solutions and their items from the current org for the current user
104
+ *
105
+ * @param authentication Credentials for the request
106
+ */
107
+ export declare function getDeployedSolutionsAndItems(authentication: UserSession): Promise<ISolutionInfos>;
108
+ /**
109
+ * Find all deployed solutions from the current org for the current user
110
+ *
111
+ * @param authentication Credentials for the request
112
+ */
113
+ export declare function getDeployedSolutions(authentication: UserSession): Promise<ISearchResult<IItem>>;
114
+ /**
115
+ * Find key details for the items from each of the deployed solutions
116
+ *
117
+ * @param authentication Credentials for the request
118
+ * @param searchResults key details of the deployed solutions
119
+ */
120
+ export declare function getSolutionItemsFromDeployedSolutions(authentication: UserSession, searchResults: ISearchResult<IItem>): Promise<ISolutionInfos>;
121
+ /**
122
+ * Get the ids for each template in a solution
123
+ *
124
+ * @param authentication Credentials for the request
125
+ */
126
+ export declare function getIdsFromSolutionTemplates(id: string, authentication: UserSession): Promise<string[]>;
127
+ /**
128
+ * Fetch key details for the solution that will be deployed and find any solutions
129
+ * that leverage any of the source items that exist in the solution to be deployed.
130
+ *
131
+ * @param id The id of the solution that will be deployed
132
+ * @param authentication Credentials for the request
133
+ */
134
+ export declare function findReusableSolutionsAndItems(id: string, authentication: UserSession): Promise<ISourceItem>;
135
+ /**
136
+ * Fetch key details for the solution that will be deployed
137
+ *
138
+ * @param id The id of the solution that will be deployed
139
+ * @param authentication Credentials for the request
140
+ */
141
+ export declare function getItemHash(id: string, authentication: UserSession): Promise<ISourceItem>;
@@ -0,0 +1,173 @@
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
+ * @module item-reuse
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.getItemHash = exports.findReusableSolutionsAndItems = exports.getIdsFromSolutionTemplates = exports.getSolutionItemsFromDeployedSolutions = exports.getDeployedSolutions = exports.getDeployedSolutionsAndItems = void 0;
21
+ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
22
+ /**
23
+ * Find all deployed solutions and their items from the current org for the current user
24
+ *
25
+ * @param authentication Credentials for the request
26
+ */
27
+ function getDeployedSolutionsAndItems(authentication) {
28
+ return getDeployedSolutions(authentication).then((searchResults) => {
29
+ return getSolutionItemsFromDeployedSolutions(authentication, searchResults);
30
+ });
31
+ }
32
+ exports.getDeployedSolutionsAndItems = getDeployedSolutionsAndItems;
33
+ /**
34
+ * Find all deployed solutions from the current org for the current user
35
+ *
36
+ * @param authentication Credentials for the request
37
+ */
38
+ function getDeployedSolutions(authentication) {
39
+ const query = new arcgis_rest_portal_1.SearchQueryBuilder()
40
+ .match(authentication.username).in("owner").and()
41
+ .match("Solution").in("type").and()
42
+ .match("Deployed").in("typekeywords");
43
+ return (0, arcgis_rest_portal_1.searchItems)({
44
+ q: query,
45
+ num: 100,
46
+ authentication
47
+ })
48
+ .then((searchResponse) => {
49
+ // Sort the results by title and then id
50
+ searchResponse.results.sort((e1, e2) => {
51
+ if (e1.title !== e2.title) {
52
+ return e1.title < e2.title ? -1 : 1;
53
+ }
54
+ else {
55
+ return e1.id < e2.id ? -1 : 1;
56
+ }
57
+ });
58
+ return searchResponse;
59
+ });
60
+ }
61
+ exports.getDeployedSolutions = getDeployedSolutions;
62
+ /**
63
+ * Find key details for the items from each of the deployed solutions
64
+ *
65
+ * @param authentication Credentials for the request
66
+ * @param searchResults key details of the deployed solutions
67
+ */
68
+ function getSolutionItemsFromDeployedSolutions(authentication, searchResults) {
69
+ const promises = [];
70
+ const itemIds = [];
71
+ const solutions = {};
72
+ if (searchResults.results.length > 0) {
73
+ searchResults.results.forEach((r) => {
74
+ const versionKeywords = r.typeKeywords.filter(v => /solutionversion-.+/.exec(v));
75
+ const version = versionKeywords.length > 0 ? versionKeywords[0] : "";
76
+ itemIds.push(r.id);
77
+ solutions[r.id] = {
78
+ created: r.created,
79
+ title: r.title,
80
+ version
81
+ };
82
+ promises.push((0, arcgis_rest_portal_1.getItemData)(r.id, { authentication }));
83
+ });
84
+ }
85
+ return Promise.all(promises).then(results => {
86
+ return results.reduce((prev, cur, i) => {
87
+ const id = itemIds[i];
88
+ prev[id] = {
89
+ templates: cur.templates.map(template => template.itemId),
90
+ solutionInfo: solutions[id]
91
+ };
92
+ return prev;
93
+ }, {});
94
+ });
95
+ }
96
+ exports.getSolutionItemsFromDeployedSolutions = getSolutionItemsFromDeployedSolutions;
97
+ /**
98
+ * Get the ids for each template in a solution
99
+ *
100
+ * @param authentication Credentials for the request
101
+ */
102
+ function getIdsFromSolutionTemplates(id, authentication) {
103
+ return (0, arcgis_rest_portal_1.getItemData)(id, { authentication }).then(data => {
104
+ ;
105
+ return data.templates.map(t => t.itemId);
106
+ });
107
+ }
108
+ exports.getIdsFromSolutionTemplates = getIdsFromSolutionTemplates;
109
+ /**
110
+ * Fetch key details for the solution that will be deployed and find any solutions
111
+ * that leverage any of the source items that exist in the solution to be deployed.
112
+ *
113
+ * @param id The id of the solution that will be deployed
114
+ * @param authentication Credentials for the request
115
+ */
116
+ function findReusableSolutionsAndItems(id, authentication) {
117
+ return getItemHash(id, authentication).then(itemHash => {
118
+ return getDeployedSolutionsAndItems(authentication).then(results => {
119
+ const sourceIds = Object.keys(itemHash);
120
+ Object.keys(results).forEach(solutionId => {
121
+ const solution = results[solutionId];
122
+ sourceIds.forEach(sourceId => {
123
+ const itemKeys = Object.keys(itemHash[sourceId]);
124
+ itemKeys.forEach(deployedId => {
125
+ const item = itemHash[sourceId][deployedId];
126
+ if (solution.templates.indexOf(deployedId) > -1 && Object.keys(item.solutions).indexOf(solutionId) < 0) {
127
+ item.solutions[solutionId] = solution.solutionInfo;
128
+ }
129
+ });
130
+ });
131
+ });
132
+ return itemHash;
133
+ });
134
+ });
135
+ }
136
+ exports.findReusableSolutionsAndItems = findReusableSolutionsAndItems;
137
+ /**
138
+ * Fetch key details for the solution that will be deployed
139
+ *
140
+ * @param id The id of the solution that will be deployed
141
+ * @param authentication Credentials for the request
142
+ */
143
+ function getItemHash(id, authentication) {
144
+ return getIdsFromSolutionTemplates(id, authentication).then(ids => {
145
+ // search for existing items that reference any of these ids in their typeKeywords
146
+ const promises = ids.map(id => {
147
+ const q = `typekeywords:source-${id} owner:${authentication.username}`;
148
+ const searchOptions = {
149
+ q,
150
+ authentication
151
+ };
152
+ return (0, arcgis_rest_portal_1.searchItems)(searchOptions);
153
+ });
154
+ return Promise.all(promises).then(results => {
155
+ // if we have a result from the typeKeyword search we need to understand what solution it came from and what its id is
156
+ return results.reduce((prev, cur, i) => {
157
+ // key is source id and value is any ids for items that were deployed based on this source
158
+ prev[ids[i]] = cur.results.reduce((prev, cur) => {
159
+ prev[cur.id] = {
160
+ created: cur.created,
161
+ solutions: {},
162
+ title: cur.title,
163
+ type: cur.type
164
+ };
165
+ return prev;
166
+ }, {});
167
+ return prev;
168
+ }, {});
169
+ });
170
+ });
171
+ }
172
+ exports.getItemHash = getItemHash;
173
+ //# sourceMappingURL=item-reuse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item-reuse.js","sourceRoot":"","sources":["../../src/item-reuse.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAGH,iEAA6G;AA+F7G;;;;GAIG;AACH,SAAgB,4BAA4B,CAC1C,cAA2B;IAE3B,OAAO,oBAAoB,CAAC,cAAc,CAAC,CAAC,IAAI,CAC9C,CAAC,aAAmC,EAAE,EAAE;QACtC,OAAO,qCAAqC,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;IAC9E,CAAC,CACF,CAAC;AACJ,CAAC;AARD,oEAQC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAClC,cAA2B;IAE3B,MAAM,KAAK,GAAG,IAAI,uCAAkB,EAAE;SACrC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE;SAChD,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE;SAClC,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC;IACtC,OAAO,IAAA,gCAAW,EAAC;QACjB,CAAC,EAAE,KAAK;QACR,GAAG,EA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C5B,MAAM,CAAC,GAAG,uBAAuB,EAAE,UAAU,cAAc,CAAC,QAAQ,EAAE,CAAC;YACvE,MAAM,aAAa,GAAG;gBACpB,CAAC;gBACD,cAAc;aACf,CAAC;YACF,OAAO,IAAA,gCAAW,EAAC,aAAa,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;YAC1C,sHAAsH;YACtH,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,IAAS,EAAE,GAAQ,EAAE,CAAS,EAAE,EAAE;gBACvD,0FAA0F;gBAC1F,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;oBAC9C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG;wBACb,OAAO,EAAE,GAAG,CAAC,OAAO;wBACpB,SAAS,EAAE,EAAE;wBACb,KAAK,EAAE,GAAG,CAAC,KAAK;wBAChB,IAAI,EAAE,GAAG,CAAC,IAAI;qBACf,CAAA;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC,EAAE,EAAE,CAAC,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC,EAAE,EAAE,CAAC,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAhCD,kCAgCC"}
@@ -271,25 +271,23 @@ export declare function getFeatureServiceProperties(serviceUrl: string, authenti
271
271
  * Fetches the configuration of a workflow.
272
272
  *
273
273
  * @param itemId Id of the workflow item
274
+ * @param workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
274
275
  * @param authentication Credentials for the request to AGOL
275
- * @param orgId Id of organization whose license is to be checked; only used if `enterpriseWebAdaptorUrl` is falsy
276
- * @param workflowURL URL of the workflow manager, e.g., "https://workflow.arcgis.com"
277
276
  * @returns Promise resolving with the workflow configuration in a zip file
278
277
  * @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
279
278
  */
280
- export declare function getWorkflowConfigurationZip(itemId: string, authentication: UserSession, orgId: string | undefined, workflowURL: string): Promise<File>;
279
+ export declare function getWorkflowConfigurationZip(itemId: string, workflowBaseUrl: string, authentication: UserSession): Promise<File>;
281
280
  /**
282
281
  * Sets the configuration of a workflow.
283
282
  *
284
- * @param configurationZipFile Configuration files in a zip file
285
283
  * @param itemId Id of the workflow item
284
+ * @param configurationZipFile Configuration files in a zip file
285
+ * @param workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
286
286
  * @param authentication Credentials for the request to AGOL
287
- * @param orgId Id of organization whose license is to be checked; only used if `enterpriseWebAdaptorUrl` is falsy
288
- * @param workflowURL URL of the workflow manager, e.g., "https://workflow.arcgis.com"
289
287
  * @returns Promise resolving with the workflow configuration in a zip file
290
288
  * @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
291
289
  */
292
- export declare function setWorkflowConfigurationZip(configurationZipFile: File, itemId: string, authentication: UserSession, orgId: string | undefined, workflowURL: string): Promise<IStatusResponse>;
290
+ export declare function setWorkflowConfigurationZip(itemId: string, configurationZipFile: File, workflowBaseUrl: string, authentication: UserSession): Promise<IStatusResponse>;
293
291
  /**
294
292
  * Parses the layers array and will filter subsets of Layers and Tables
295
293
  * Layers and Tables are both returned in the layers array when we access a feature service from the admin api.
@@ -30,7 +30,6 @@ const restHelpersGet_1 = require("./restHelpersGet");
30
30
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
31
31
  const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
32
32
  const arcgis_rest_service_admin_1 = require("@esri/arcgis-rest-service-admin");
33
- const workflowHelpers_1 = require("./workflowHelpers");
34
33
  const workforceHelpers_1 = require("./workforceHelpers");
35
34
  const templatization_1 = require("./templatization");
36
35
  const trackingHelpers_1 = require("./trackingHelpers");
@@ -983,15 +982,13 @@ exports.getFeatureServiceProperties = getFeatureServiceProperties;
983
982
  * Fetches the configuration of a workflow.
984
983
  *
985
984
  * @param itemId Id of the workflow item
985
+ * @param workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
986
986
  * @param authentication Credentials for the request to AGOL
987
- * @param orgId Id of organization whose license is to be checked; only used if `enterpriseWebAdaptorUrl` is falsy
988
- * @param workflowURL URL of the workflow manager, e.g., "https://workflow.arcgis.com"
989
987
  * @returns Promise resolving with the workflow configuration in a zip file
990
988
  * @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
991
989
  */
992
- async function getWorkflowConfigurationZip(itemId, authentication, orgId, workflowURL) {
993
- const workflowUrlRoot = (0, workflowHelpers_1.getWorkflowManagerUrlRoot)(orgId, workflowURL);
994
- const url = `${workflowUrlRoot}/admin/${itemId}/export`;
990
+ async function getWorkflowConfigurationZip(itemId, workflowBaseUrl, authentication) {
991
+ const url = `${workflowBaseUrl}/admin/${itemId}/export`;
995
992
  return (0, arcgis_rest_request_1.request)(url, {
996
993
  authentication,
997
994
  headers: {
@@ -1008,17 +1005,15 @@ exports.getWorkflowConfigurationZip = getWorkflowConfigurationZip;
1008
1005
  /**
1009
1006
  * Sets the configuration of a workflow.
1010
1007
  *
1011
- * @param configurationZipFile Configuration files in a zip file
1012
1008
  * @param itemId Id of the workflow item
1009
+ * @param configurationZipFile Configuration files in a zip file
1010
+ * @param workflowBaseUrl URL of the workflow manager, e.g., "https://workflow.arcgis.com/orgId"
1013
1011
  * @param authentication Credentials for the request to AGOL
1014
- * @param orgId Id of organization whose license is to be checked; only used if `enterpriseWebAdaptorUrl` is falsy
1015
- * @param workflowURL URL of the workflow manager, e.g., "https://workflow.arcgis.com"
1016
1012
  * @returns Promise resolving with the workflow configuration in a zip file
1017
1013
  * @throws {WorkflowJsonExceptionDTO} if request to workflow manager fails
1018
1014
  */
1019
- async function setWorkflowConfigurationZip(configurationZipFile, itemId, authentication, orgId, workflowURL) {
1020
- const workflowUrlRoot = (0, workflowHelpers_1.getWorkflowManagerUrlRoot)(orgId, workflowURL);
1021
- const url = `${workflowUrlRoot}/admin/${itemId}/import`;
1015
+ async function setWorkflowConfigurationZip(itemId, configurationZipFile, workflowBaseUrl, authentication) {
1016
+ const url = `${workflowBaseUrl}/admin/${itemId}/import`;
1022
1017
  return (0, arcgis_rest_request_1.request)(url, {
1023
1018
  authentication,
1024
1019
  headers: {