@esri/solution-simple-types 4.1.2 → 5.0.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 (69) hide show
  1. package/dist/cjs/dashboard.d.ts +93 -93
  2. package/dist/cjs/dashboard.js +352 -352
  3. package/dist/cjs/helpers/convert-item-to-template.d.ts +46 -46
  4. package/dist/cjs/helpers/convert-item-to-template.js +235 -209
  5. package/dist/cjs/helpers/convert-item-to-template.js.map +1 -1
  6. package/dist/cjs/helpers/create-item-from-template.d.ts +17 -17
  7. package/dist/cjs/helpers/create-item-from-template.js +153 -138
  8. package/dist/cjs/helpers/create-item-from-template.js.map +1 -1
  9. package/dist/cjs/helpers/notebook-helpers.d.ts +19 -19
  10. package/dist/cjs/helpers/notebook-helpers.js +24 -24
  11. package/dist/cjs/helpers/quickcapture-helpers.d.ts +18 -18
  12. package/dist/cjs/helpers/quickcapture-helpers.js +22 -22
  13. package/dist/cjs/helpers/simple-type-helpers.d.ts +18 -18
  14. package/dist/cjs/helpers/simple-type-helpers.js +22 -22
  15. package/dist/cjs/helpers/update-notebook-data.d.ts +17 -17
  16. package/dist/cjs/helpers/update-notebook-data.js +27 -27
  17. package/dist/cjs/index.d.ts +27 -27
  18. package/dist/cjs/index.js +36 -36
  19. package/dist/cjs/notebook.d.ts +66 -66
  20. package/dist/cjs/notebook.js +133 -133
  21. package/dist/cjs/oic.d.ts +53 -53
  22. package/dist/cjs/oic.js +170 -170
  23. package/dist/cjs/quickcapture.d.ts +76 -87
  24. package/dist/cjs/quickcapture.js +143 -192
  25. package/dist/cjs/quickcapture.js.map +1 -1
  26. package/dist/cjs/simple-types.d.ts +57 -57
  27. package/dist/cjs/simple-types.js +94 -94
  28. package/dist/cjs/webmap.d.ts +102 -102
  29. package/dist/cjs/webmap.js +325 -325
  30. package/dist/cjs/webmappingapplication.d.ts +176 -176
  31. package/dist/cjs/webmappingapplication.js +674 -674
  32. package/dist/cjs/webmappingapplication.js.map +1 -1
  33. package/dist/cjs/workforce.d.ts +34 -34
  34. package/dist/cjs/workforce.js +44 -44
  35. package/dist/esm/dashboard.d.ts +93 -93
  36. package/dist/esm/dashboard.js +339 -339
  37. package/dist/esm/helpers/convert-item-to-template.d.ts +46 -46
  38. package/dist/esm/helpers/convert-item-to-template.js +228 -202
  39. package/dist/esm/helpers/convert-item-to-template.js.map +1 -1
  40. package/dist/esm/helpers/create-item-from-template.d.ts +17 -17
  41. package/dist/esm/helpers/create-item-from-template.js +148 -133
  42. package/dist/esm/helpers/create-item-from-template.js.map +1 -1
  43. package/dist/esm/helpers/notebook-helpers.d.ts +19 -19
  44. package/dist/esm/helpers/notebook-helpers.js +20 -20
  45. package/dist/esm/helpers/quickcapture-helpers.d.ts +18 -18
  46. package/dist/esm/helpers/quickcapture-helpers.js +19 -19
  47. package/dist/esm/helpers/simple-type-helpers.d.ts +18 -18
  48. package/dist/esm/helpers/simple-type-helpers.js +19 -19
  49. package/dist/esm/helpers/update-notebook-data.d.ts +17 -17
  50. package/dist/esm/helpers/update-notebook-data.js +23 -23
  51. package/dist/esm/index.d.ts +27 -27
  52. package/dist/esm/index.js +27 -27
  53. package/dist/esm/notebook.d.ts +66 -66
  54. package/dist/esm/notebook.js +123 -123
  55. package/dist/esm/oic.d.ts +53 -53
  56. package/dist/esm/oic.js +162 -162
  57. package/dist/esm/quickcapture.d.ts +76 -87
  58. package/dist/esm/quickcapture.js +131 -179
  59. package/dist/esm/quickcapture.js.map +1 -1
  60. package/dist/esm/simple-types.d.ts +57 -57
  61. package/dist/esm/simple-types.js +86 -86
  62. package/dist/esm/webmap.d.ts +102 -102
  63. package/dist/esm/webmap.js +312 -312
  64. package/dist/esm/webmappingapplication.d.ts +176 -176
  65. package/dist/esm/webmappingapplication.js +648 -648
  66. package/dist/esm/webmappingapplication.js.map +1 -1
  67. package/dist/esm/workforce.d.ts +34 -34
  68. package/dist/esm/workforce.js +38 -38
  69. package/package.json +7 -7
@@ -1,24 +1,24 @@
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 { jsonToBlob, updateItem } from "@esri/solution-common";
17
- export function updateNotebookData(itemId, data, authentication) {
18
- const updateOptions = {
19
- id: itemId,
20
- data: jsonToBlob(data)
21
- };
22
- return updateItem(updateOptions, authentication);
23
- }
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 { jsonToBlob, updateItem } from "@esri/solution-common";
17
+ export function updateNotebookData(itemId, data, authentication) {
18
+ const updateOptions = {
19
+ id: itemId,
20
+ data: jsonToBlob(data)
21
+ };
22
+ return updateItem(updateOptions, authentication);
23
+ }
24
24
  //# sourceMappingURL=update-notebook-data.js.map
@@ -1,27 +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 };
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 };
package/dist/esm/index.js CHANGED
@@ -1,28 +1,28 @@
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 };
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 };
28
28
  //# sourceMappingURL=index.js.map
@@ -1,66 +1,66 @@
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 solutionItemId The solution to contain the template
21
- * @param itemInfo Info about the item
22
- * @param destAuthentication Credentials for requests to the destination organization
23
- * @param srcAuthentication Credentials for requests to source items
24
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
25
- * @returns A promise that will resolve when the template has been created
26
- */
27
- export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession, templateDictionary: any): Promise<common.IItemTemplate>;
28
- export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
29
- /**
30
- * Converts a Python Notebook item to a template.
31
- *
32
- * @param itemTemplate template for the Python Notebook
33
- * @returns templatized itemTemplate
34
- */
35
- export declare function convertNotebookToTemplate(itemTemplate: common.IItemTemplate): common.IItemTemplate;
36
- /**
37
- * Remove interpreter and papermill props
38
- *
39
- * This function will update the data passed in by removing key props
40
- *
41
- * @param data The notebooks data object
42
- *
43
- */
44
- export declare function deleteProps(data: any): void;
45
- /**
46
- * Update the notebooks data
47
- *
48
- * @param originalTemplate The original template item
49
- * @param newlyCreatedItem The current item that may have unswapped variables
50
- * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
51
- * @param authentication Credentials for the requests to the destination
52
- *
53
- * @returns A promise that will resolve once any updates have been made
54
- */
55
- export declare function fineTuneCreatedItem(originalTemplate: common.IItemTemplate, newlyCreatedItem: common.IItemTemplate, templateDictionary: any, authentication: common.UserSession): Promise<void>;
56
- /**
57
- * Notebook specific post-processing actions
58
- *
59
- * @param {string} itemId The item ID
60
- * @param {string} type The template type
61
- * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
62
- * @param {any} templateDictionary The template dictionary
63
- * @param {UserSession} authentication The destination session info
64
- * @returns {Promise<any>}
65
- */
66
- export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: common.IItemTemplate, templates: common.IItemTemplate[], templateDictionary: any, authentication: common.UserSession): Promise<any>;
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 solutionItemId The solution to contain the template
21
+ * @param itemInfo Info about the item
22
+ * @param destAuthentication Credentials for requests to the destination organization
23
+ * @param srcAuthentication Credentials for requests to source items
24
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
25
+ * @returns A promise that will resolve when the template has been created
26
+ */
27
+ export declare function convertItemToTemplate(solutionItemId: string, itemInfo: any, destAuthentication: common.UserSession, srcAuthentication: common.UserSession, templateDictionary: any): Promise<common.IItemTemplate>;
28
+ export declare function createItemFromTemplate(template: common.IItemTemplate, templateDictionary: any, destinationAuthentication: common.UserSession, itemProgressCallback: common.IItemProgressCallback): Promise<common.ICreateItemFromTemplateResponse>;
29
+ /**
30
+ * Converts a Python Notebook item to a template.
31
+ *
32
+ * @param itemTemplate template for the Python Notebook
33
+ * @returns templatized itemTemplate
34
+ */
35
+ export declare function convertNotebookToTemplate(itemTemplate: common.IItemTemplate): common.IItemTemplate;
36
+ /**
37
+ * Remove interpreter and papermill props
38
+ *
39
+ * This function will update the data passed in by removing key props
40
+ *
41
+ * @param data The notebooks data object
42
+ *
43
+ */
44
+ export declare function deleteProps(data: any): void;
45
+ /**
46
+ * Update the notebooks data
47
+ *
48
+ * @param originalTemplate The original template item
49
+ * @param newlyCreatedItem The current item that may have unswapped variables
50
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
51
+ * @param authentication Credentials for the requests to the destination
52
+ *
53
+ * @returns A promise that will resolve once any updates have been made
54
+ */
55
+ export declare function fineTuneCreatedItem(originalTemplate: common.IItemTemplate, newlyCreatedItem: common.IItemTemplate, templateDictionary: any, authentication: common.UserSession): Promise<void>;
56
+ /**
57
+ * Notebook specific post-processing actions
58
+ *
59
+ * @param {string} itemId The item ID
60
+ * @param {string} type The template type
61
+ * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
62
+ * @param {any} templateDictionary The template dictionary
63
+ * @param {UserSession} authentication The destination session info
64
+ * @returns {Promise<any>}
65
+ */
66
+ export declare function postProcess(itemId: string, type: string, itemInfos: any[], template: common.IItemTemplate, templates: common.IItemTemplate[], templateDictionary: any, authentication: common.UserSession): Promise<any>;
@@ -1,124 +1,124 @@
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
- // Need to import collectively to enable spying
18
- import * as notebookHelpers from "./helpers/notebook-helpers";
19
- /**
20
- * Converts a notebook item into a template.
21
- *
22
- * @param solutionItemId The solution to contain the template
23
- * @param itemInfo Info about the item
24
- * @param destAuthentication Credentials for requests to the destination organization
25
- * @param srcAuthentication Credentials for requests to source items
26
- * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
27
- * @returns A promise that will resolve when the template has been created
28
- */
29
- export function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
30
- // Delegate back to simple-types, which will in-turn delegate
31
- // to convertNotebookToTemplate at the correct point in the process
32
- // This is a temporary refactor step
33
- return notebookHelpers.convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
34
- }
35
- // Delegate back to simple-types
36
- // This is a temporary refactor step
37
- export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
38
- return notebookHelpers.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
39
- }
40
- /**
41
- * Converts a Python Notebook item to a template.
42
- *
43
- * @param itemTemplate template for the Python Notebook
44
- * @returns templatized itemTemplate
45
- */
46
- export function convertNotebookToTemplate(itemTemplate) {
47
- // The templates data to process
48
- const data = itemTemplate.data;
49
- deleteProps(data);
50
- let dataString = JSON.stringify(data);
51
- const idTest = /[0-9A-F]{32}/gim;
52
- if (data && idTest.test(dataString)) {
53
- const ids = dataString.match(idTest);
54
- const verifiedIds = [];
55
- ids.forEach(id => {
56
- if (verifiedIds.indexOf(id) === -1) {
57
- verifiedIds.push(id);
58
- // templatize the itemId--but only once per unique id
59
- const regEx = new RegExp(id, "gm");
60
- dataString = dataString.replace(regEx, "{{" + id + ".itemId}}");
61
- // update the dependencies
62
- if (itemTemplate.dependencies.indexOf(id) === -1) {
63
- itemTemplate.dependencies.push(id);
64
- }
65
- }
66
- });
67
- itemTemplate.data = JSON.parse(dataString);
68
- }
69
- return itemTemplate;
70
- }
71
- /**
72
- * Remove interpreter and papermill props
73
- *
74
- * This function will update the data passed in by removing key props
75
- *
76
- * @param data The notebooks data object
77
- *
78
- */
79
- export function deleteProps(data) {
80
- /* istanbul ignore else */
81
- if (data) {
82
- const props = ["metadata.interpreter", "metadata.papermill"];
83
- common.deleteProps(data, props);
84
- (data.cells || []).forEach((cell) => {
85
- common.deleteProps(cell, props);
86
- });
87
- }
88
- }
89
- /**
90
- * Update the notebooks data
91
- *
92
- * @param originalTemplate The original template item
93
- * @param newlyCreatedItem The current item that may have unswapped variables
94
- * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
95
- * @param authentication Credentials for the requests to the destination
96
- *
97
- * @returns A promise that will resolve once any updates have been made
98
- */
99
- export function fineTuneCreatedItem(originalTemplate, newlyCreatedItem, templateDictionary, authentication) {
100
- return new Promise((resolve, reject) => {
101
- const updateOptions = {
102
- id: newlyCreatedItem.itemId,
103
- url: newlyCreatedItem.item.url,
104
- data: common.jsonToFile(newlyCreatedItem.data, newlyCreatedItem.itemId + ".ipynb")
105
- };
106
- common
107
- .updateItem(updateOptions, authentication)
108
- .then(() => resolve(null), reject);
109
- });
110
- }
111
- /**
112
- * Notebook specific post-processing actions
113
- *
114
- * @param {string} itemId The item ID
115
- * @param {string} type The template type
116
- * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
117
- * @param {any} templateDictionary The template dictionary
118
- * @param {UserSession} authentication The destination session info
119
- * @returns {Promise<any>}
120
- */
121
- export function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
122
- return common.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
123
- }
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
+ // Need to import collectively to enable spying
18
+ import * as notebookHelpers from "./helpers/notebook-helpers";
19
+ /**
20
+ * Converts a notebook item into a template.
21
+ *
22
+ * @param solutionItemId The solution to contain the template
23
+ * @param itemInfo Info about the item
24
+ * @param destAuthentication Credentials for requests to the destination organization
25
+ * @param srcAuthentication Credentials for requests to source items
26
+ * @param templateDictionary Hash of facts: folder id, org URL, adlib replacements
27
+ * @returns A promise that will resolve when the template has been created
28
+ */
29
+ export function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
30
+ // Delegate back to simple-types, which will in-turn delegate
31
+ // to convertNotebookToTemplate at the correct point in the process
32
+ // This is a temporary refactor step
33
+ return notebookHelpers.convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary);
34
+ }
35
+ // Delegate back to simple-types
36
+ // This is a temporary refactor step
37
+ export function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
38
+ return notebookHelpers.createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback);
39
+ }
40
+ /**
41
+ * Converts a Python Notebook item to a template.
42
+ *
43
+ * @param itemTemplate template for the Python Notebook
44
+ * @returns templatized itemTemplate
45
+ */
46
+ export function convertNotebookToTemplate(itemTemplate) {
47
+ // The templates data to process
48
+ const data = itemTemplate.data;
49
+ deleteProps(data);
50
+ let dataString = JSON.stringify(data);
51
+ const idTest = /[0-9A-F]{32}/gim;
52
+ if (data && idTest.test(dataString)) {
53
+ const ids = dataString.match(idTest);
54
+ const verifiedIds = [];
55
+ ids.forEach(id => {
56
+ if (verifiedIds.indexOf(id) === -1) {
57
+ verifiedIds.push(id);
58
+ // templatize the itemId--but only once per unique id
59
+ const regEx = new RegExp(id, "gm");
60
+ dataString = dataString.replace(regEx, "{{" + id + ".itemId}}");
61
+ // update the dependencies
62
+ if (itemTemplate.dependencies.indexOf(id) === -1) {
63
+ itemTemplate.dependencies.push(id);
64
+ }
65
+ }
66
+ });
67
+ itemTemplate.data = JSON.parse(dataString);
68
+ }
69
+ return itemTemplate;
70
+ }
71
+ /**
72
+ * Remove interpreter and papermill props
73
+ *
74
+ * This function will update the data passed in by removing key props
75
+ *
76
+ * @param data The notebooks data object
77
+ *
78
+ */
79
+ export function deleteProps(data) {
80
+ /* istanbul ignore else */
81
+ if (data) {
82
+ const props = ["metadata.interpreter", "metadata.papermill"];
83
+ common.deleteProps(data, props);
84
+ (data.cells || []).forEach((cell) => {
85
+ common.deleteProps(cell, props);
86
+ });
87
+ }
88
+ }
89
+ /**
90
+ * Update the notebooks data
91
+ *
92
+ * @param originalTemplate The original template item
93
+ * @param newlyCreatedItem The current item that may have unswapped variables
94
+ * @param templateDictionary Hash of facts: org URL, adlib replacements, deferreds for dependencies
95
+ * @param authentication Credentials for the requests to the destination
96
+ *
97
+ * @returns A promise that will resolve once any updates have been made
98
+ */
99
+ export function fineTuneCreatedItem(originalTemplate, newlyCreatedItem, templateDictionary, authentication) {
100
+ return new Promise((resolve, reject) => {
101
+ const updateOptions = {
102
+ id: newlyCreatedItem.itemId,
103
+ url: newlyCreatedItem.item.url,
104
+ data: common.jsonToFile(newlyCreatedItem.data, newlyCreatedItem.itemId + ".ipynb")
105
+ };
106
+ common
107
+ .updateItem(updateOptions, authentication)
108
+ .then(() => resolve(null), reject);
109
+ });
110
+ }
111
+ /**
112
+ * Notebook specific post-processing actions
113
+ *
114
+ * @param {string} itemId The item ID
115
+ * @param {string} type The template type
116
+ * @param {any[]} itemInfos Array of \{id: 'ef3', type: 'Web Map'\} objects
117
+ * @param {any} templateDictionary The template dictionary
118
+ * @param {UserSession} authentication The destination session info
119
+ * @returns {Promise<any>}
120
+ */
121
+ export function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
122
+ return common.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication);
123
+ }
124
124
  //# sourceMappingURL=notebook.js.map
package/dist/esm/oic.d.ts CHANGED
@@ -1,53 +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;
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;