@esri/solution-simple-types 5.2.3 → 5.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/cjs/dashboard.d.ts +93 -0
  2. package/dist/cjs/dashboard.js +353 -0
  3. package/dist/cjs/dashboard.js.map +1 -0
  4. package/dist/cjs/helpers/convert-item-to-template.d.ts +45 -0
  5. package/dist/cjs/helpers/convert-item-to-template.js +246 -0
  6. package/dist/cjs/helpers/convert-item-to-template.js.map +1 -0
  7. package/dist/cjs/helpers/create-item-from-template.d.ts +17 -0
  8. package/dist/cjs/helpers/create-item-from-template.js +154 -0
  9. package/dist/cjs/helpers/create-item-from-template.js.map +1 -0
  10. package/dist/cjs/helpers/formHelpers.d.ts +25 -0
  11. package/dist/cjs/helpers/formHelpers.js +58 -0
  12. package/dist/cjs/helpers/formHelpers.js.map +1 -0
  13. package/dist/cjs/helpers/notebook-helpers.d.ts +19 -0
  14. package/dist/cjs/helpers/notebook-helpers.js +25 -0
  15. package/dist/cjs/helpers/notebook-helpers.js.map +1 -0
  16. package/dist/cjs/helpers/quickcapture-helpers.d.ts +18 -0
  17. package/dist/cjs/helpers/quickcapture-helpers.js +23 -0
  18. package/dist/cjs/helpers/quickcapture-helpers.js.map +1 -0
  19. package/dist/cjs/helpers/simple-type-helpers.d.ts +18 -0
  20. package/dist/cjs/helpers/simple-type-helpers.js +23 -0
  21. package/dist/cjs/helpers/simple-type-helpers.js.map +1 -0
  22. package/dist/cjs/helpers/update-notebook-data.d.ts +17 -0
  23. package/dist/cjs/helpers/update-notebook-data.js +28 -0
  24. package/dist/cjs/helpers/update-notebook-data.js.map +1 -0
  25. package/dist/cjs/index.d.ts +27 -0
  26. package/dist/cjs/index.js +37 -0
  27. package/dist/cjs/index.js.map +1 -0
  28. package/dist/cjs/notebook.d.ts +65 -0
  29. package/dist/cjs/notebook.js +133 -0
  30. package/dist/cjs/notebook.js.map +1 -0
  31. package/dist/cjs/oic.d.ts +53 -0
  32. package/dist/cjs/oic.js +171 -0
  33. package/dist/cjs/oic.js.map +1 -0
  34. package/dist/cjs/package.json +3 -0
  35. package/dist/cjs/quickcapture.d.ts +75 -0
  36. package/dist/cjs/quickcapture.js +143 -0
  37. package/dist/cjs/quickcapture.js.map +1 -0
  38. package/dist/cjs/simple-types.d.ts +56 -0
  39. package/dist/cjs/simple-types.js +94 -0
  40. package/dist/cjs/simple-types.js.map +1 -0
  41. package/dist/cjs/webmap.d.ts +102 -0
  42. package/dist/cjs/webmap.js +318 -0
  43. package/dist/cjs/webmap.js.map +1 -0
  44. package/dist/cjs/webmappingapplication.d.ts +176 -0
  45. package/dist/cjs/webmappingapplication.js +675 -0
  46. package/dist/cjs/webmappingapplication.js.map +1 -0
  47. package/dist/cjs/workforce.d.ts +34 -0
  48. package/dist/cjs/workforce.js +45 -0
  49. package/dist/cjs/workforce.js.map +1 -0
  50. package/dist/esm/package.json +3 -0
  51. package/package.json +6 -6
@@ -0,0 +1,18 @@
1
+ /** @license
2
+ * Copyright 2020 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
+ import { convertItemToTemplate } from "./convert-item-to-template";
17
+ import { createItemFromTemplate } from "./create-item-from-template";
18
+ export { createItemFromTemplate, convertItemToTemplate };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertItemToTemplate = exports.createItemFromTemplate = void 0;
4
+ /** @license
5
+ * Copyright 2020 Esri
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const convert_item_to_template_1 = require("./convert-item-to-template");
20
+ Object.defineProperty(exports, "convertItemToTemplate", { enumerable: true, get: function () { return convert_item_to_template_1.convertItemToTemplate; } });
21
+ const create_item_from_template_1 = require("./create-item-from-template");
22
+ Object.defineProperty(exports, "createItemFromTemplate", { enumerable: true, get: function () { return create_item_from_template_1.createItemFromTemplate; } });
23
+ //# sourceMappingURL=simple-type-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simple-type-helpers.js","sourceRoot":"","sources":["../../../src/helpers/simple-type-helpers.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,yEAAmE;AAIlC,sGAJxB,gDAAqB,OAIwB;AAHtD,2EAAqE;AAG5D,uGAHA,kDAAsB,OAGA"}
@@ -0,0 +1,17 @@
1
+ /** @license
2
+ * Copyright 2020 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
+ import { UserSession } from "@esri/solution-common";
17
+ export declare function updateNotebookData(itemId: string, data: any, authentication: UserSession): Promise<any>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateNotebookData = void 0;
4
+ /** @license
5
+ * Copyright 2020 Esri
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const solution_common_1 = require("@esri/solution-common");
20
+ function updateNotebookData(itemId, data, authentication) {
21
+ const updateOptions = {
22
+ id: itemId,
23
+ data: (0, solution_common_1.jsonToBlob)(data)
24
+ };
25
+ return (0, solution_common_1.updateItem)(updateOptions, authentication);
26
+ }
27
+ exports.updateNotebookData = updateNotebookData;
28
+ //# sourceMappingURL=update-notebook-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-notebook-data.js","sourceRoot":"","sources":["../../../src/helpers/update-notebook-data.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,2DAK+B;AAE/B,SAAgB,kBAAkB,CAChC,MAAc,EACd,IAAS,EACT,cAA2B;IAE3B,MAAM,aAAa,GAAgB;QACjC,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,IAAA,4BAAU,EAAC,IAAI,CAAC;KACvB,CAAC;IACF,OAAO,IAAA,4BAAU,EAAC,aAAa,EAAE,cAAc,CAAC,CAAC;AACnD,CAAC;AAVD,gDAUC"}
@@ -0,0 +1,27 @@
1
+ /** @license
2
+ * Copyright 2018 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 simple item types.
18
+ *
19
+ * @module simple-types
20
+ */
21
+ import * as simpleTypeHelpers from "./helpers/simple-type-helpers";
22
+ import * as notebookHelpers from "./helpers/notebook-helpers";
23
+ import * as quickcaptureHelpers from "./helpers/quickcapture-helpers";
24
+ import * as simpleTypes from "./simple-types";
25
+ import * as notebookProcessor from "./notebook";
26
+ import * as quickcaptureProcessor from "./quickcapture";
27
+ export { simpleTypes, notebookProcessor, notebookHelpers, simpleTypeHelpers, quickcaptureHelpers, quickcaptureProcessor };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2018 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.quickcaptureProcessor = exports.quickcaptureHelpers = exports.simpleTypeHelpers = exports.notebookHelpers = exports.notebookProcessor = exports.simpleTypes = void 0;
19
+ const tslib_1 = require("tslib");
20
+ /**
21
+ * Manages the creation and deployment of simple item types.
22
+ *
23
+ * @module simple-types
24
+ */
25
+ const simpleTypeHelpers = tslib_1.__importStar(require("./helpers/simple-type-helpers"));
26
+ exports.simpleTypeHelpers = simpleTypeHelpers;
27
+ const notebookHelpers = tslib_1.__importStar(require("./helpers/notebook-helpers"));
28
+ exports.notebookHelpers = notebookHelpers;
29
+ const quickcaptureHelpers = tslib_1.__importStar(require("./helpers/quickcapture-helpers"));
30
+ exports.quickcaptureHelpers = quickcaptureHelpers;
31
+ const simpleTypes = tslib_1.__importStar(require("./simple-types"));
32
+ exports.simpleTypes = simpleTypes;
33
+ const notebookProcessor = tslib_1.__importStar(require("./notebook"));
34
+ exports.notebookProcessor = notebookProcessor;
35
+ const quickcaptureProcessor = tslib_1.__importStar(require("./quickcapture"));
36
+ exports.quickcaptureProcessor = quickcaptureProcessor;
37
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH;;;;GAIG;AACH,yFAAmE;AAWjE,8CAAiB;AAVnB,oFAA8D;AAS5D,0CAAe;AARjB,4FAAsE;AAUpE,kDAAmB;AATrB,oEAA8C;AAK5C,kCAAW;AAJb,sEAAgD;AAK9C,8CAAiB;AAJnB,8EAAwD;AAQtD,sDAAqB"}
@@ -0,0 +1,65 @@
1
+ /** @license
2
+ * Copyright 2020 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
+ import * as common from "@esri/solution-common";
17
+ /**
18
+ * Converts a notebook item into a template.
19
+ *
20
+ * @param itemInfo Info about the item
21
+ * @param destAuthentication Credentials for requests to the destination organization
22
+ * @param srcAuthentication Credentials for requests to source items
23
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
24
+ * @returns A promise that will resolve when the template has been created
25
+ */
26
+ export declare function convertItemToTemplate(itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession, templateDictionary: any): Promise<common.IItemTemplate>;
27
+ export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
28
+ /**
29
+ * Converts a Python Notebook item to a template.
30
+ *
31
+ * @param itemTemplate template for the Python Notebook
32
+ * @returns templatized itemTemplate
33
+ */
34
+ export declare function convertNotebookToTemplate(itemTemplate: common.IItemTemplate): common.IItemTemplate;
35
+ /**
36
+ * Remove interpreter and papermill props
37
+ *
38
+ * This function will update the data passed in by removing key props
39
+ *
40
+ * @param data The notebooks data object
41
+ *
42
+ */
43
+ export declare function deleteProps(data: any): void;
44
+ /**
45
+ * Update the notebooks data
46
+ *
47
+ * @param originalTemplate The original template item
48
+ * @param newlyCreatedItem The current item that may have unswapped variables
49
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
50
+ * @param authentication Credentials for the requests to the destination
51
+ *
52
+ * @returns A promise that will resolve once any updates have been made
53
+ */
54
+ export declare function fineTuneCreatedItem(originalTemplate: common.IItemTemplate, newlyCreatedItem: common.IItemTemplate, templateDictionary: any, authentication: common.UserSession): Promise<void>;
55
+ /**
56
+ * Notebook specific post-processing actions
57
+ *
58
+ * @param {string} itemId The item ID
59
+ * @param {string} type The template type
60
+ * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
61
+ * @param {any} templateDictionary The template dictionary
62
+ * @param {UserSession} authentication The destination session info
63
+ * @returns {Promise<any>}
64
+ */
65
+ export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: common.IItemTemplate, templates: common.IItemTemplate[], templateDictionary: any, authentication: common.UserSession): Promise<any>;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2020 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.postProcess = exports.fineTuneCreatedItem = exports.deleteProps = exports.convertNotebookToTemplate = exports.createItemFromTemplate = exports.convertItemToTemplate = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const common = tslib_1.__importStar(require("@esri/solution-common"));
21
+ // Need to import collectively to enable spying
22
+ const notebookHelpers = tslib_1.__importStar(require("./helpers/notebook-helpers"));
23
+ /**
24
+ * Converts a notebook item into a template.
25
+ *
26
+ * @param itemInfo Info about the item
27
+ * @param destAuthentication Credentials for requests to the destination organization
28
+ * @param srcAuthentication Credentials for requests to source items
29
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
30
+ * @returns A promise that will resolve when the template has been created
31
+ */
32
+ function convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
33
+ // Delegate back to simple-types, which will in-turn delegate
34
+ // to convertNotebookToTemplate at the correct point in the process
35
+ // This is a temporary refactor step
36
+ return notebookHelpers.convertItemToTemplate(itemInfo, destAuthentication, srcAuthentication, templateDictionary);
37
+ }
38
+ exports.convertItemToTemplate = convertItemToTemplate;
39
+ // Delegate back to simple-types
40
+ // This is a temporary refactor step
41
+ function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
42
+ return notebookHelpers.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
43
+ }
44
+ exports.createItemFromTemplate = createItemFromTemplate;
45
+ /**
46
+ * Converts a Python Notebook item to a template.
47
+ *
48
+ * @param itemTemplate template for the Python Notebook
49
+ * @returns templatized itemTemplate
50
+ */
51
+ function convertNotebookToTemplate(itemTemplate) {
52
+ // The templates data to process
53
+ const data = itemTemplate.data;
54
+ deleteProps(data);
55
+ let dataString = JSON.stringify(data);
56
+ const idTest = /[0-9A-F]{32}/gim;
57
+ if (data && idTest.test(dataString)) {
58
+ const ids = dataString.match(idTest);
59
+ const verifiedIds = [];
60
+ ids.forEach(id => {
61
+ if (verifiedIds.indexOf(id) === -1) {
62
+ verifiedIds.push(id);
63
+ // templatize the itemId--but only once per unique id
64
+ const regEx = new RegExp(id, "gm");
65
+ dataString = dataString.replace(regEx, "{{" + id + ".itemId}}");
66
+ // update the dependencies
67
+ if (itemTemplate.dependencies.indexOf(id) === -1) {
68
+ itemTemplate.dependencies.push(id);
69
+ }
70
+ }
71
+ });
72
+ itemTemplate.data = JSON.parse(dataString);
73
+ }
74
+ return itemTemplate;
75
+ }
76
+ exports.convertNotebookToTemplate = convertNotebookToTemplate;
77
+ /**
78
+ * Remove interpreter and papermill props
79
+ *
80
+ * This function will update the data passed in by removing key props
81
+ *
82
+ * @param data The notebooks data object
83
+ *
84
+ */
85
+ function deleteProps(data) {
86
+ /* istanbul ignore else */
87
+ if (data) {
88
+ const props = ["metadata.interpreter", "metadata.papermill"];
89
+ common.deleteProps(data, props);
90
+ (data.cells || []).forEach((cell) => {
91
+ common.deleteProps(cell, props);
92
+ });
93
+ }
94
+ }
95
+ exports.deleteProps = deleteProps;
96
+ /**
97
+ * Update the notebooks data
98
+ *
99
+ * @param originalTemplate The original template item
100
+ * @param newlyCreatedItem The current item that may have unswapped variables
101
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
102
+ * @param authentication Credentials for the requests to the destination
103
+ *
104
+ * @returns A promise that will resolve once any updates have been made
105
+ */
106
+ function fineTuneCreatedItem(originalTemplate, newlyCreatedItem, templateDictionary, authentication) {
107
+ return new Promise((resolve, reject) => {
108
+ const updateOptions = {
109
+ id: newlyCreatedItem.itemId,
110
+ url: newlyCreatedItem.item.url,
111
+ data: common.jsonToFile(newlyCreatedItem.data, newlyCreatedItem.itemId + ".ipynb")
112
+ };
113
+ common
114
+ .updateItem(updateOptions, authentication)
115
+ .then(() => resolve(null), reject);
116
+ });
117
+ }
118
+ exports.fineTuneCreatedItem = fineTuneCreatedItem;
119
+ /**
120
+ * Notebook specific post-processing actions
121
+ *
122
+ * @param {string} itemId The item ID
123
+ * @param {string} type The template type
124
+ * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
125
+ * @param {any} templateDictionary The template dictionary
126
+ * @param {UserSession} authentication The destination session info
127
+ * @returns {Promise<any>}
128
+ */
129
+ function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
130
+ return common.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
131
+ }
132
+ exports.postProcess = postProcess;
133
+ //# sourceMappingURL=notebook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notebook.js","sourceRoot":"","sources":["../../src/notebook.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;AAEH,sEAAgD;AAChD,+CAA+C;AAC/C,oFAA8D;AAE9D;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CACnC,QAAa,EACb,kBAAsC,EACtC,iBAAqC,EACrC,kBAAuB;IAEvB,6DAA6D;IAC7D,mEAAmE;IACnE,oCAAoC;IACpC,OAAO,eAAe,CAAC,qBAAqB,CAC1C,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,CACnB,CAAC;AACJ,CAAC;AAfD,sDAeC;AAED,gCAAgC;AAChC,oCAAoC;AACpC,SAAgB,sBAAsB,CACpC,QAA8B,EAC9B,kBAAuB,EACvB,yBAA6C,EAC7C,oBAAkD;IAElD,OAAO,eAAe,CAAC,sBAAsB,CAC3C,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,oBAAoB,CACrB,CAAC;AACJ,CAAC;AAZD,wDAYC;AAED;;;;;GAKG;AACH,SAAgB,yBAAyB,CACvC,YAAkC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AAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAS,EAAE,EAAE;YACvC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAXD,kCAWC;AAED;;;;;;;;;GASG;AACH,SAAgB,mBAAmB,CACjC,gBAAsC,EACtC,gBAAsC,EACtC,kBAAuB,EACvB,cAAkC;IAElC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,aAAa,GAAuB;YACxC,EAAE,EAAE,gBAAgB,CAAC,MAAM;YAC3B,GAAG,EAAE,gBAAgB,CAAC,IAAI,CAAC,GAAG;YAC9B,IAAI,EAAE,MAAM,CAAC,UAAU,CACrB,gBAAgB,CAAC,IAAI,EACrB,gBAAgB,CAAC,MAAM,GAAG,QAAQ,CACnC;SACF,CAAC;QACF,MAAM;aACH,UAAU,CAAC,aAAa,EAAE,cAAc,CAAC;aACzC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAnBD,kDAmBC;AAED;;;;;;;;;GASG;AACH,SAAgB,WAAW,CACzB,MAAc,EACd,IAAY,EACZ,SAAgB,EAChB,QAA8B,EAC9B,SAAiC,EACjC,kBAAuB,EACvB,cAAkC;IAElC,OAAO,MAAM,CAAC,gCAAgC,CAC5C,MAAM,EACN,kBAAkB,EAClB,cAAc,CACf,CAAC;AACJ,CAAC;AAdD,kCAcC"}
@@ -0,0 +1,53 @@
1
+ /** @license
2
+ * Copyright 2018 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
+ import * as common from "@esri/solution-common";
17
+ /**
18
+ * Converts an AGOL OIC (Oriented Imagery Catalog) item to a template.
19
+ *
20
+ * @param itemTemplate Template for the OIC (Oriented Imagery Catalog) item
21
+ * @param destAuthentication Credentials for requests to the destination organization
22
+ * @param srcAuthentication Credentials for requests to source items
23
+ * @returns Template for the solution item that contains key details for item reconstruction
24
+ */
25
+ export declare function convertItemToTemplate(itemTemplate: common.IItemTemplate, destAuthentication: common.UserSession, srcAuthentication: common.UserSession): Promise<common.IItemTemplate>;
26
+ /**
27
+ * Gets the ids of the dependencies of an AGOL OIC (Oriented Imagery Catalog) item.
28
+ *
29
+ * @param itemTemplate A OIC (Oriented Imagery Catalog) item whose dependencies are sought
30
+ * @param authentication Credentials for any requests
31
+ * @returns List of dependencies ids and url/itemId hash
32
+ * @private
33
+ */
34
+ export declare function _extractDependencies(itemTemplate: common.IItemTemplate, authentication: common.UserSession): Promise<any>;
35
+ /**
36
+ * Extracts the AGOL itemId for each layer in a list using the url.
37
+ *
38
+ * @param layerURLs List of OIC layer URLs
39
+ * @param dependencies Current list of dependencies
40
+ * @param authentication Credentials for any requests
41
+ * @returns List of dependencies ids and url/itemId hash
42
+ * @private
43
+ */
44
+ export declare function _getLayerIds(layerURLs: string[], dependencies: string[], authentication: common.UserSession): Promise<any>;
45
+ /**
46
+ * Templatizes the url and item id for a layer.
47
+ *
48
+ * @param layerURL OIC layer URL
49
+ * @param urlHash Lookup object for analysis layers
50
+ * @returns Templatized URL if layerURL is in the urlHash
51
+ * @private
52
+ */
53
+ export declare function _templatizeOicLayerUrl(layerURL: string, urlHash: any): string;
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ /** @license
3
+ * Copyright 2018 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._templatizeOicLayerUrl = exports._getLayerIds = exports._extractDependencies = exports.convertItemToTemplate = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const common = tslib_1.__importStar(require("@esri/solution-common"));
21
+ // ------------------------------------------------------------------------------------------------------------------ //
22
+ /**
23
+ * Converts an AGOL OIC (Oriented Imagery Catalog) item to a template.
24
+ *
25
+ * @param itemTemplate Template for the OIC (Oriented Imagery Catalog) item
26
+ * @param destAuthentication Credentials for requests to the destination organization
27
+ * @param srcAuthentication Credentials for requests to source items
28
+ * @returns Template for the solution item that contains key details for item reconstruction
29
+ */
30
+ function convertItemToTemplate(itemTemplate, destAuthentication, srcAuthentication) {
31
+ return new Promise((resolve, reject) => {
32
+ // Extract dependencies
33
+ _extractDependencies(itemTemplate, srcAuthentication).then((results) => {
34
+ itemTemplate.dependencies = results.dependencies;
35
+ // Templatize the map layer ids after we've extracted them as dependencies
36
+ /* istanbul ignore else */
37
+ if (itemTemplate.data?.properties) {
38
+ itemTemplate.data.properties.ServiceURL = _templatizeOicLayerUrl(itemTemplate.data.properties.ServiceURL, results.urlHash);
39
+ itemTemplate.data.properties.OverviewURL = _templatizeOicLayerUrl(itemTemplate.data.properties.OverviewURL, results.urlHash);
40
+ }
41
+ resolve(itemTemplate);
42
+ }, e => reject(common.fail(e)));
43
+ });
44
+ }
45
+ exports.convertItemToTemplate = convertItemToTemplate;
46
+ /**
47
+ * Gets the ids of the dependencies of an AGOL OIC (Oriented Imagery Catalog) item.
48
+ *
49
+ * @param itemTemplate A OIC (Oriented Imagery Catalog) item whose dependencies are sought
50
+ * @param authentication Credentials for any requests
51
+ * @returns List of dependencies ids and url/itemId hash
52
+ * @private
53
+ */
54
+ function _extractDependencies(itemTemplate, authentication) {
55
+ return new Promise((resolve, reject) => {
56
+ const dependencies = [];
57
+ if (itemTemplate.data?.properties) {
58
+ const layerURLs = [];
59
+ /* istanbul ignore else */
60
+ if (itemTemplate.data.properties.ServiceURL) {
61
+ layerURLs.push(itemTemplate.data.properties.ServiceURL);
62
+ }
63
+ /* istanbul ignore else */
64
+ if (itemTemplate.data.properties.OverviewURL &&
65
+ itemTemplate.data.properties.OverviewURL !==
66
+ itemTemplate.data.properties.ServiceURL) {
67
+ layerURLs.push(itemTemplate.data.properties.OverviewURL);
68
+ }
69
+ _getLayerIds(layerURLs, dependencies, authentication).then(results => {
70
+ resolve(results);
71
+ }, e => reject(common.fail(e)));
72
+ }
73
+ else {
74
+ resolve({
75
+ dependencies: dependencies,
76
+ urlHash: {}
77
+ });
78
+ }
79
+ });
80
+ }
81
+ exports._extractDependencies = _extractDependencies;
82
+ /**
83
+ * Extracts the AGOL itemId for each layer in a list using the url.
84
+ *
85
+ * @param layerURLs List of OIC layer URLs
86
+ * @param dependencies Current list of dependencies
87
+ * @param authentication Credentials for any requests
88
+ * @returns List of dependencies ids and url/itemId hash
89
+ * @private
90
+ */
91
+ function _getLayerIds(layerURLs, dependencies, authentication) {
92
+ return new Promise((resolve, reject) => {
93
+ const urlHash = {};
94
+ const options = {
95
+ f: "json",
96
+ authentication: authentication
97
+ };
98
+ const layerPromises = [];
99
+ const layerChecks = {};
100
+ const filteredLayerURLs = layerURLs.filter(layerURL => {
101
+ if (layerURL) {
102
+ const results = /.+FeatureServer/g.exec(layerURL);
103
+ const baseUrl = Array.isArray(results) && results.length > 0 ? results[0] : undefined;
104
+ if (baseUrl) {
105
+ // avoid redundant checks when we have a layer with subLayers
106
+ /* istanbul ignore else */
107
+ if (Object.keys(layerChecks).indexOf(baseUrl) < 0) {
108
+ layerChecks[baseUrl] = common.rest_request(layerURL, options);
109
+ }
110
+ layerPromises.push(layerChecks[baseUrl]);
111
+ return true;
112
+ }
113
+ else {
114
+ return false;
115
+ }
116
+ }
117
+ else {
118
+ return false;
119
+ }
120
+ });
121
+ if (layerPromises.length > 0) {
122
+ Promise.all(layerPromises).then(serviceResponses => {
123
+ serviceResponses.forEach((serviceResponse, i) => {
124
+ /* istanbul ignore else */
125
+ if (common.getProp(serviceResponse, "serviceItemId")) {
126
+ const id = serviceResponse.serviceItemId;
127
+ /* istanbul ignore else */
128
+ if (dependencies.indexOf(id) < 0) {
129
+ dependencies.push(id);
130
+ }
131
+ urlHash[filteredLayerURLs[i]] = id;
132
+ }
133
+ });
134
+ resolve({
135
+ dependencies: dependencies,
136
+ urlHash: urlHash
137
+ });
138
+ }, e => reject(common.fail(e)));
139
+ }
140
+ else {
141
+ resolve({
142
+ dependencies: dependencies,
143
+ urlHash: urlHash
144
+ });
145
+ }
146
+ });
147
+ }
148
+ exports._getLayerIds = _getLayerIds;
149
+ /**
150
+ * Templatizes the url and item id for a layer.
151
+ *
152
+ * @param layerURL OIC layer URL
153
+ * @param urlHash Lookup object for analysis layers
154
+ * @returns Templatized URL if layerURL is in the urlHash
155
+ * @private
156
+ */
157
+ function _templatizeOicLayerUrl(layerURL, urlHash) {
158
+ let templatizedURL = layerURL;
159
+ if (layerURL) {
160
+ const id = urlHash[layerURL];
161
+ if (id) {
162
+ const layerId = layerURL.substr(layerURL.lastIndexOf("/") + 1);
163
+ templatizedURL = common.templatizeTerm(id, id, ".layer" + layerId + ".url");
164
+ }
165
+ // replace everything up until /home with portalBaseUrl var and templatize the itemId
166
+ templatizedURL = common.templatizeIds(templatizedURL.replace(/.+?(?=\/home)/, "{{portalBaseUrl}}"));
167
+ }
168
+ return templatizedURL;
169
+ }
170
+ exports._templatizeOicLayerUrl = _templatizeOicLayerUrl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