@esri/solution-deployer 4.1.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/deploySolutionFromTemplate.d.ts +48 -48
  2. package/dist/cjs/deploySolutionFromTemplate.js +331 -331
  3. package/dist/cjs/deploySolutionFromTemplate.js.map +1 -1
  4. package/dist/cjs/deploySolutionItems.d.ts +224 -224
  5. package/dist/cjs/deploySolutionItems.js +853 -849
  6. package/dist/cjs/deploySolutionItems.js.map +1 -1
  7. package/dist/cjs/deployer.d.ts +34 -34
  8. package/dist/cjs/deployer.js +101 -101
  9. package/dist/cjs/deployerUtils.d.ts +47 -47
  10. package/dist/cjs/deployerUtils.js +123 -123
  11. package/dist/cjs/helpers/post-process.d.ts +29 -29
  12. package/dist/cjs/helpers/post-process.js +61 -61
  13. package/dist/cjs/helpers/share-templates-to-groups.d.ts +24 -24
  14. package/dist/cjs/helpers/share-templates-to-groups.js +64 -64
  15. package/dist/cjs/helpers/sortTemplates.d.ts +23 -23
  16. package/dist/cjs/helpers/sortTemplates.js +14 -14
  17. package/dist/cjs/index.d.ts +24 -24
  18. package/dist/cjs/index.js +27 -27
  19. package/dist/cjs/module-map.d.ts +23 -23
  20. package/dist/cjs/module-map.js +195 -195
  21. package/dist/esm/deploySolutionFromTemplate.d.ts +48 -48
  22. package/dist/esm/deploySolutionFromTemplate.js +317 -317
  23. package/dist/esm/deploySolutionFromTemplate.js.map +1 -1
  24. package/dist/esm/deploySolutionItems.d.ts +224 -224
  25. package/dist/esm/deploySolutionItems.js +830 -826
  26. package/dist/esm/deploySolutionItems.js.map +1 -1
  27. package/dist/esm/deployer.d.ts +34 -34
  28. package/dist/esm/deployer.js +96 -96
  29. package/dist/esm/deployerUtils.d.ts +47 -47
  30. package/dist/esm/deployerUtils.js +115 -115
  31. package/dist/esm/helpers/post-process.d.ts +29 -29
  32. package/dist/esm/helpers/post-process.js +57 -57
  33. package/dist/esm/helpers/share-templates-to-groups.d.ts +24 -24
  34. package/dist/esm/helpers/share-templates-to-groups.js +60 -60
  35. package/dist/esm/helpers/sortTemplates.d.ts +23 -23
  36. package/dist/esm/helpers/sortTemplates.js +10 -10
  37. package/dist/esm/index.d.ts +24 -24
  38. package/dist/esm/index.js +24 -24
  39. package/dist/esm/module-map.d.ts +23 -23
  40. package/dist/esm/module-map.js +191 -191
  41. package/package.json +12 -12
@@ -1,124 +1,124 @@
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.isSolutionTemplateItem = exports._isModel = exports.updateDeployOptions = exports.getSolutionTemplateItem = void 0;
19
- const tslib_1 = require("tslib");
20
- const common = tslib_1.__importStar(require("@esri/solution-common"));
21
- /**
22
- * Given an itemId or an object, either fetch the item or
23
- * resolve using the object, if it is structured as expected
24
- *
25
- * @param idOrObject string || object like `{item:{...}, data: {...}}`
26
- * @param authentication UserSession
27
- */
28
- function getSolutionTemplateItem(idOrObject, authentication) {
29
- if (typeof idOrObject === "string") {
30
- // get the item + data
31
- return Promise.all([
32
- common.getItemBase(idOrObject, authentication),
33
- common.getItemDataAsJson(idOrObject, authentication)
34
- ]).then(([item, data]) => {
35
- // format into a model and migrate the schema
36
- return common.migrateSchema({
37
- item,
38
- data
39
- });
40
- });
41
- }
42
- else {
43
- // check if it is a "Model"
44
- if (_isModel(idOrObject)) {
45
- // run migrations
46
- return common.migrateSchema(idOrObject);
47
- }
48
- else {
49
- return Promise.reject(common.fail(`getSolutionTemplateItem must be passed an item id or a model object`));
50
- }
51
- }
52
- }
53
- exports.getSolutionTemplateItem = getSolutionTemplateItem;
54
- /**
55
- * Update the Deploy Options with information from the
56
- * Solution Template item
57
- *
58
- * @param deployOptions
59
- * @param item
60
- * @param authentication
61
- */
62
- function updateDeployOptions(deployOptions, item, authentication) {
63
- deployOptions.jobId = deployOptions.jobId ?? item.id;
64
- deployOptions.title = deployOptions.title ?? item.title;
65
- deployOptions.snippet = deployOptions.snippet ?? item.snippet;
66
- deployOptions.description = deployOptions.description ?? item.description;
67
- deployOptions.tags = deployOptions.tags ?? item.tags;
68
- // add the thumbnail url
69
- deployOptions.thumbnailurl = item.thumbnail
70
- ? common.getItemThumbnailUrl(item.id, item.thumbnail, false, authentication)
71
- : null;
72
- return deployOptions;
73
- }
74
- exports.updateDeployOptions = updateDeployOptions;
75
- /**
76
- * Check if an object is an Model
77
- *
78
- * @param obj any object
79
- * @private
80
- */
81
- function _isModel(obj) {
82
- let result = false;
83
- // TODO Hoist into common?
84
- const isNotStringOrArray = (v) => v != null &&
85
- typeof v !== "string" &&
86
- !Array.isArray(v) &&
87
- typeof v === "object";
88
- if (isNotStringOrArray(obj)) {
89
- result = ["item", "data"].reduce((acc, prop) => {
90
- if (acc) {
91
- acc = isNotStringOrArray(obj[prop]);
92
- }
93
- return acc;
94
- }, true);
95
- }
96
- return result;
97
- }
98
- exports._isModel = _isModel;
99
- /**
100
- * Does the item have the correct type and keywords
101
- * to be a Solution Template item?
102
- *
103
- * @param item IItem
104
- */
105
- function isSolutionTemplateItem(item) {
106
- const kwds = item.typeKeywords;
107
- // Solution items
108
- let result = false;
109
- if (item.type === "Solution") {
110
- if (kwds.indexOf("Solution") > -1 &&
111
- (kwds.indexOf("Template") > -1 || kwds.indexOf("solutionTemplate") > -1)) {
112
- result = true;
113
- }
114
- }
115
- // Older Hub Solutions used Web Mapping Application items
116
- if (item.type === "Web Mapping Application") {
117
- if (kwds.indexOf("hubSolutionTemplate") > -1) {
118
- result = true;
119
- }
120
- }
121
- return result;
122
- }
123
- exports.isSolutionTemplateItem = isSolutionTemplateItem;
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.isSolutionTemplateItem = exports._isModel = exports.updateDeployOptions = exports.getSolutionTemplateItem = void 0;
19
+ const tslib_1 = require("tslib");
20
+ const common = tslib_1.__importStar(require("@esri/solution-common"));
21
+ /**
22
+ * Given an itemId or an object, either fetch the item or
23
+ * resolve using the object, if it is structured as expected
24
+ *
25
+ * @param idOrObject string || object like `{item:{...}, data: {...}}`
26
+ * @param authentication UserSession
27
+ */
28
+ function getSolutionTemplateItem(idOrObject, authentication) {
29
+ if (typeof idOrObject === "string") {
30
+ // get the item + data
31
+ return Promise.all([
32
+ common.getItemBase(idOrObject, authentication),
33
+ common.getItemDataAsJson(idOrObject, authentication)
34
+ ]).then(([item, data]) => {
35
+ // format into a model and migrate the schema
36
+ return common.migrateSchema({
37
+ item,
38
+ data
39
+ });
40
+ });
41
+ }
42
+ else {
43
+ // check if it is a "Model"
44
+ if (_isModel(idOrObject)) {
45
+ // run migrations
46
+ return common.migrateSchema(idOrObject);
47
+ }
48
+ else {
49
+ return Promise.reject(common.fail(`getSolutionTemplateItem must be passed an item id or a model object`));
50
+ }
51
+ }
52
+ }
53
+ exports.getSolutionTemplateItem = getSolutionTemplateItem;
54
+ /**
55
+ * Update the Deploy Options with information from the
56
+ * Solution Template item
57
+ *
58
+ * @param deployOptions
59
+ * @param item
60
+ * @param authentication
61
+ */
62
+ function updateDeployOptions(deployOptions, item, authentication) {
63
+ deployOptions.jobId = deployOptions.jobId ?? item.id;
64
+ deployOptions.title = deployOptions.title ?? item.title;
65
+ deployOptions.snippet = deployOptions.snippet ?? item.snippet;
66
+ deployOptions.description = deployOptions.description ?? item.description;
67
+ deployOptions.tags = deployOptions.tags ?? item.tags;
68
+ // add the thumbnail url
69
+ deployOptions.thumbnailurl = item.thumbnail
70
+ ? common.getItemThumbnailUrl(item.id, item.thumbnail, false, authentication)
71
+ : null;
72
+ return deployOptions;
73
+ }
74
+ exports.updateDeployOptions = updateDeployOptions;
75
+ /**
76
+ * Check if an object is an Model
77
+ *
78
+ * @param obj any object
79
+ * @private
80
+ */
81
+ function _isModel(obj) {
82
+ let result = false;
83
+ // TODO Hoist into common?
84
+ const isNotStringOrArray = (v) => v != null &&
85
+ typeof v !== "string" &&
86
+ !Array.isArray(v) &&
87
+ typeof v === "object";
88
+ if (isNotStringOrArray(obj)) {
89
+ result = ["item", "data"].reduce((acc, prop) => {
90
+ if (acc) {
91
+ acc = isNotStringOrArray(obj[prop]);
92
+ }
93
+ return acc;
94
+ }, true);
95
+ }
96
+ return result;
97
+ }
98
+ exports._isModel = _isModel;
99
+ /**
100
+ * Does the item have the correct type and keywords
101
+ * to be a Solution Template item?
102
+ *
103
+ * @param item IItem
104
+ */
105
+ function isSolutionTemplateItem(item) {
106
+ const kwds = item.typeKeywords;
107
+ // Solution items
108
+ let result = false;
109
+ if (item.type === "Solution") {
110
+ if (kwds.indexOf("Solution") > -1 &&
111
+ (kwds.indexOf("Template") > -1 || kwds.indexOf("solutionTemplate") > -1)) {
112
+ result = true;
113
+ }
114
+ }
115
+ // Older Hub Solutions used Web Mapping Application items
116
+ if (item.type === "Web Mapping Application") {
117
+ if (kwds.indexOf("hubSolutionTemplate") > -1) {
118
+ result = true;
119
+ }
120
+ }
121
+ return result;
122
+ }
123
+ exports.isSolutionTemplateItem = isSolutionTemplateItem;
124
124
  //# sourceMappingURL=deployerUtils.js.map
@@ -1,29 +1,29 @@
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, IItemTemplate, ICreateItemFromTemplateResponse } from "@esri/solution-common";
17
- /**
18
- * Delegate post-processing to the type specific
19
- * processors. This allows each type to have fine-grained
20
- * control over what they do. Common post-processing is
21
- * exposed as functions that can be imported
22
- *
23
- * @param deployedSolutionId
24
- * @param templates
25
- * @param clonedSolutions
26
- * @param authentication
27
- * @param templateDictionary
28
- */
29
- export declare function postProcess(deployedSolutionId: string, templates: IItemTemplate[], clonedSolutions: ICreateItemFromTemplateResponse[], authentication: UserSession, templateDictionary: any): 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 { UserSession, IItemTemplate, ICreateItemFromTemplateResponse } from "@esri/solution-common";
17
+ /**
18
+ * Delegate post-processing to the type specific
19
+ * processors. This allows each type to have fine-grained
20
+ * control over what they do. Common post-processing is
21
+ * exposed as functions that can be imported
22
+ *
23
+ * @param deployedSolutionId
24
+ * @param templates
25
+ * @param clonedSolutions
26
+ * @param authentication
27
+ * @param templateDictionary
28
+ */
29
+ export declare function postProcess(deployedSolutionId: string, templates: IItemTemplate[], clonedSolutions: ICreateItemFromTemplateResponse[], authentication: UserSession, templateDictionary: any): Promise<any>;
@@ -1,62 +1,62 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.postProcess = 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
- const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
21
- const module_map_1 = require("../module-map");
22
- const share_templates_to_groups_1 = require("./share-templates-to-groups");
23
- /**
24
- * Delegate post-processing to the type specific
25
- * processors. This allows each type to have fine-grained
26
- * control over what they do. Common post-processing is
27
- * exposed as functions that can be imported
28
- *
29
- * @param deployedSolutionId
30
- * @param templates
31
- * @param clonedSolutions
32
- * @param authentication
33
- * @param templateDictionary
34
- */
35
- function postProcess(deployedSolutionId, templates, clonedSolutions, authentication, templateDictionary) {
36
- // connect the solution with its items; groups cannot be connected
37
- const relationshipPromises = clonedSolutions
38
- .filter(entry => entry.type !== "Group")
39
- .map(entry => (0, arcgis_rest_portal_1.addItemRelationship)({
40
- originItemId: deployedSolutionId,
41
- destinationItemId: entry.id,
42
- relationshipType: "Solution2Item",
43
- authentication: authentication
44
- }) // TODO: remove `as any`, which is here until arcgis-rest-js' ItemRelationshipType defn catches up
45
- );
46
- // delegate sharing to groups
47
- const sharePromises = (0, share_templates_to_groups_1.shareTemplatesToGroups)(templates, templateDictionary, authentication);
48
- // what needs post processing?
49
- const itemsToProcess = clonedSolutions.filter(entry => entry.postProcess);
50
- // map over these items
51
- const postProcessPromises = itemsToProcess.reduce((acc, entry) => {
52
- const itemHandler = module_map_1.moduleMap[entry.type];
53
- // only delegate if the handler has a postProcess method
54
- if (itemHandler && itemHandler.postProcess) {
55
- acc.push(itemHandler.postProcess(entry.id, entry.type, clonedSolutions, (0, solution_common_1.getTemplateById)(templates, entry.id), templates, templateDictionary, authentication));
56
- }
57
- return acc;
58
- }, []);
59
- return Promise.all([sharePromises].concat(postProcessPromises, relationshipPromises));
60
- }
61
- exports.postProcess = postProcess;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.postProcess = 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
+ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
21
+ const module_map_1 = require("../module-map");
22
+ const share_templates_to_groups_1 = require("./share-templates-to-groups");
23
+ /**
24
+ * Delegate post-processing to the type specific
25
+ * processors. This allows each type to have fine-grained
26
+ * control over what they do. Common post-processing is
27
+ * exposed as functions that can be imported
28
+ *
29
+ * @param deployedSolutionId
30
+ * @param templates
31
+ * @param clonedSolutions
32
+ * @param authentication
33
+ * @param templateDictionary
34
+ */
35
+ function postProcess(deployedSolutionId, templates, clonedSolutions, authentication, templateDictionary) {
36
+ // connect the solution with its items; groups cannot be connected
37
+ const relationshipPromises = clonedSolutions
38
+ .filter(entry => entry.type !== "Group")
39
+ .map(entry => (0, arcgis_rest_portal_1.addItemRelationship)({
40
+ originItemId: deployedSolutionId,
41
+ destinationItemId: entry.id,
42
+ relationshipType: "Solution2Item",
43
+ authentication: authentication
44
+ }) // TODO: remove `as any`, which is here until arcgis-rest-js' ItemRelationshipType defn catches up
45
+ );
46
+ // delegate sharing to groups
47
+ const sharePromises = (0, share_templates_to_groups_1.shareTemplatesToGroups)(templates, templateDictionary, authentication);
48
+ // what needs post processing?
49
+ const itemsToProcess = clonedSolutions.filter(entry => entry.postProcess);
50
+ // map over these items
51
+ const postProcessPromises = itemsToProcess.reduce((acc, entry) => {
52
+ const itemHandler = module_map_1.moduleMap[entry.type];
53
+ // only delegate if the handler has a postProcess method
54
+ if (itemHandler && itemHandler.postProcess) {
55
+ acc.push(itemHandler.postProcess(entry.id, entry.type, clonedSolutions, (0, solution_common_1.getTemplateById)(templates, entry.id), templates, templateDictionary, authentication));
56
+ }
57
+ return acc;
58
+ }, []);
59
+ return Promise.all([sharePromises].concat(postProcessPromises, relationshipPromises));
60
+ }
61
+ exports.postProcess = postProcess;
62
62
  //# sourceMappingURL=post-process.js.map
@@ -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 { IItemTemplate, UserSession } from "@esri/solution-common";
17
- /**
18
- * Given the created templates
19
- *
20
- * @param templates
21
- * @param templateDictionary
22
- * @param authentication
23
- */
24
- export declare function shareTemplatesToGroups(templates: IItemTemplate[], templateDictionary: any, authentication: 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 { IItemTemplate, UserSession } from "@esri/solution-common";
17
+ /**
18
+ * Given the created templates
19
+ *
20
+ * @param templates
21
+ * @param templateDictionary
22
+ * @param authentication
23
+ */
24
+ export declare function shareTemplatesToGroups(templates: IItemTemplate[], templateDictionary: any, authentication: UserSession): Promise<any>;
@@ -1,65 +1,65 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shareTemplatesToGroups = 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
- const hub_common_1 = require("@esri/hub-common");
21
- /**
22
- * Given the created templates
23
- *
24
- * @param templates
25
- * @param templateDictionary
26
- * @param authentication
27
- */
28
- function shareTemplatesToGroups(templates, templateDictionary, authentication) {
29
- // Filter to entries with groups to share to
30
- const templatesWithGroups = templates.filter(e => {
31
- return e.groups && e.groups.length > 0;
32
- });
33
- // fire off all the promises
34
- return Promise.all(templatesWithGroups.map(tmpl => {
35
- const groupIds = tmpl.groups.reduce((acc, sourceGroupId) => {
36
- return (0, hub_common_1.maybePush)((0, solution_common_1.getProp)(templateDictionary, `${sourceGroupId}.itemId`), acc);
37
- }, []);
38
- // need to pass the tracking owner when sharing to tracking group
39
- if ((0, solution_common_1.isTrackingViewTemplate)(tmpl) && !(0, solution_common_1.getProp)(templateDictionary, "locationTracking.userIsOwner")) {
40
- const trackingGroupId = (0, solution_common_1.getProp)(tmpl, "item.properties.trackViewGroup");
41
- const owner = (0, solution_common_1.getProp)(templateDictionary, "locationTracking.owner");
42
- /* istanbul ignore else */
43
- if (trackingGroupId && owner) {
44
- const trackerGroupIds = groupIds.filter(id => {
45
- return id === (0, solution_common_1.replaceInTemplate)(trackingGroupId, templateDictionary);
46
- });
47
- if (trackerGroupIds.length !== groupIds.length) {
48
- const nonTrackerGroupIds = groupIds.filter(id => id !== trackingGroupId);
49
- return Promise.all([
50
- (0, solution_common_1.shareItemToGroups)(trackerGroupIds, tmpl.itemId, authentication, owner),
51
- (0, solution_common_1.shareItemToGroups)(nonTrackerGroupIds, tmpl.itemId, authentication)
52
- ]);
53
- }
54
- else {
55
- return (0, solution_common_1.shareItemToGroups)(groupIds, tmpl.itemId, authentication, owner);
56
- }
57
- }
58
- }
59
- else {
60
- return (0, solution_common_1.shareItemToGroups)(groupIds, tmpl.itemId, authentication);
61
- }
62
- }));
63
- }
64
- exports.shareTemplatesToGroups = shareTemplatesToGroups;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shareTemplatesToGroups = 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
+ const hub_common_1 = require("@esri/hub-common");
21
+ /**
22
+ * Given the created templates
23
+ *
24
+ * @param templates
25
+ * @param templateDictionary
26
+ * @param authentication
27
+ */
28
+ function shareTemplatesToGroups(templates, templateDictionary, authentication) {
29
+ // Filter to entries with groups to share to
30
+ const templatesWithGroups = templates.filter(e => {
31
+ return e.groups && e.groups.length > 0;
32
+ });
33
+ // fire off all the promises
34
+ return Promise.all(templatesWithGroups.map(tmpl => {
35
+ const groupIds = tmpl.groups.reduce((acc, sourceGroupId) => {
36
+ return (0, hub_common_1.maybePush)((0, solution_common_1.getProp)(templateDictionary, `${sourceGroupId}.itemId`), acc);
37
+ }, []);
38
+ // need to pass the tracking owner when sharing to tracking group
39
+ if ((0, solution_common_1.isTrackingViewTemplate)(tmpl) && !(0, solution_common_1.getProp)(templateDictionary, "locationTracking.userIsOwner")) {
40
+ const trackingGroupId = (0, solution_common_1.getProp)(tmpl, "item.properties.trackViewGroup");
41
+ const owner = (0, solution_common_1.getProp)(templateDictionary, "locationTracking.owner");
42
+ /* istanbul ignore else */
43
+ if (trackingGroupId && owner) {
44
+ const trackerGroupIds = groupIds.filter(id => {
45
+ return id === (0, solution_common_1.replaceInTemplate)(trackingGroupId, templateDictionary);
46
+ });
47
+ if (trackerGroupIds.length !== groupIds.length) {
48
+ const nonTrackerGroupIds = groupIds.filter(id => id !== trackingGroupId);
49
+ return Promise.all([
50
+ (0, solution_common_1.shareItemToGroups)(trackerGroupIds, tmpl.itemId, authentication, owner),
51
+ (0, solution_common_1.shareItemToGroups)(nonTrackerGroupIds, tmpl.itemId, authentication)
52
+ ]);
53
+ }
54
+ else {
55
+ return (0, solution_common_1.shareItemToGroups)(groupIds, tmpl.itemId, authentication, owner);
56
+ }
57
+ }
58
+ }
59
+ else {
60
+ return (0, solution_common_1.shareItemToGroups)(groupIds, tmpl.itemId, authentication);
61
+ }
62
+ }));
63
+ }
64
+ exports.shareTemplatesToGroups = shareTemplatesToGroups;
65
65
  //# sourceMappingURL=share-templates-to-groups.js.map