@esri/solution-feature-layer 1.1.5 → 1.2.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/solution-feature-layer - v1.
|
|
2
|
+
* @esri/solution-feature-layer - v1.2.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2018-2021 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Thu Dec 09 2021 16:03:00 GMT-0800 (Pacific Standard Time)
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -18,8 +18,28 @@
|
|
|
18
18
|
(function (global, factory) {
|
|
19
19
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@esri/solution-common')) :
|
|
20
20
|
typeof define === 'function' && define.amd ? define(['exports', '@esri/solution-common'], factory) :
|
|
21
|
-
(global = global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution));
|
|
22
|
-
}(this, (function (exports, common) { 'use strict';
|
|
21
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arcgisSolution = global.arcgisSolution || {}, global.arcgisSolution));
|
|
22
|
+
})(this, (function (exports, common) { 'use strict';
|
|
23
|
+
|
|
24
|
+
function _interopNamespace(e) {
|
|
25
|
+
if (e && e.__esModule) return e;
|
|
26
|
+
var n = Object.create(null);
|
|
27
|
+
if (e) {
|
|
28
|
+
Object.keys(e).forEach(function (k) {
|
|
29
|
+
if (k !== 'default') {
|
|
30
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
31
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return e[k]; }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
n["default"] = e;
|
|
39
|
+
return Object.freeze(n);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var common__namespace = /*#__PURE__*/_interopNamespace(common);
|
|
23
43
|
|
|
24
44
|
/** @license
|
|
25
45
|
* Copyright 2018 Esri
|
|
@@ -51,27 +71,28 @@
|
|
|
51
71
|
function convertItemToTemplate(solutionItemId, itemInfo, destAuthentication, srcAuthentication, templateDictionary) {
|
|
52
72
|
return new Promise((resolve, reject) => {
|
|
53
73
|
// Init template
|
|
54
|
-
const template =
|
|
55
|
-
const hasInvalidDesignations =
|
|
74
|
+
const template = common__namespace.createInitializedItemTemplate(itemInfo);
|
|
75
|
+
const hasInvalidDesignations = common__namespace.hasInvalidGroupDesignations(itemInfo.groupDesignations);
|
|
56
76
|
if (hasInvalidDesignations) {
|
|
57
|
-
|
|
58
|
-
.
|
|
77
|
+
common__namespace
|
|
78
|
+
.updateTemplateForInvalidDesignations(template, srcAuthentication)
|
|
79
|
+
.then(_template => resolve(_template), e => reject(common__namespace.fail(e)));
|
|
59
80
|
}
|
|
60
81
|
else {
|
|
61
82
|
// Update the estimated cost factor to deploy this item
|
|
62
83
|
template.estimatedDeploymentCostFactor = 10;
|
|
63
84
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
64
|
-
|
|
85
|
+
common__namespace.getItemDataAsJson(template.item.id, srcAuthentication).then(data => {
|
|
65
86
|
template.data = data;
|
|
66
|
-
|
|
87
|
+
common__namespace.getServiceLayersAndTables(template, srcAuthentication).then(itemTemplate => {
|
|
67
88
|
// Extract dependencies
|
|
68
|
-
|
|
89
|
+
common__namespace.extractDependencies(itemTemplate, srcAuthentication).then((dependencies) => {
|
|
69
90
|
// set the dependencies as an array of IDs from the array of IDependency
|
|
70
91
|
itemTemplate.dependencies = dependencies.map((dep) => dep.id);
|
|
71
92
|
// resolve the template with templatized values
|
|
72
|
-
resolve(
|
|
73
|
-
}, (e) => reject(
|
|
74
|
-
}, e => reject(
|
|
93
|
+
resolve(common__namespace.templatize(itemTemplate, dependencies, false, templateDictionary));
|
|
94
|
+
}, (e) => reject(common__namespace.fail(e)));
|
|
95
|
+
}, e => reject(common__namespace.fail(e)));
|
|
75
96
|
});
|
|
76
97
|
}
|
|
77
98
|
});
|
|
@@ -92,54 +113,60 @@
|
|
|
92
113
|
function createItemFromTemplate(template, templateDictionary, destinationAuthentication, itemProgressCallback) {
|
|
93
114
|
return new Promise(resolve => {
|
|
94
115
|
// Interrupt process if progress callback returns `false`
|
|
95
|
-
if (!itemProgressCallback(template.itemId,
|
|
96
|
-
itemProgressCallback(template.itemId,
|
|
97
|
-
resolve(
|
|
116
|
+
if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Started, 0)) {
|
|
117
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Ignored, 0);
|
|
118
|
+
resolve(common__namespace.generateEmptyCreationResponse(template.type));
|
|
98
119
|
return;
|
|
99
120
|
}
|
|
100
121
|
// Replace the templatized symbols in a copy of the template
|
|
101
|
-
let newItemTemplate =
|
|
102
|
-
newItemTemplate =
|
|
122
|
+
let newItemTemplate = common__namespace.cloneObject(template);
|
|
123
|
+
newItemTemplate = common__namespace.replaceInTemplate(newItemTemplate, templateDictionary);
|
|
103
124
|
// Thumbnail has to be updated separately; doesn't work in create service call
|
|
104
125
|
delete newItemTemplate.item.thumbnail;
|
|
105
126
|
// cache the popup info to be added later
|
|
106
|
-
const popupInfos =
|
|
127
|
+
const popupInfos = common__namespace.cachePopupInfos(newItemTemplate.data);
|
|
107
128
|
// Create the item, then update its URL with its new id
|
|
108
|
-
|
|
129
|
+
common__namespace
|
|
130
|
+
.createFeatureService(newItemTemplate, destinationAuthentication, templateDictionary)
|
|
109
131
|
.then(createResponse => {
|
|
110
132
|
if (createResponse.success) {
|
|
111
133
|
// Interrupt process if progress callback returns `false`
|
|
112
|
-
if (!itemProgressCallback(template.itemId,
|
|
113
|
-
itemProgressCallback(template.itemId,
|
|
114
|
-
|
|
115
|
-
.
|
|
134
|
+
if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Created, template.estimatedDeploymentCostFactor / 2, createResponse.serviceItemId)) {
|
|
135
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Cancelled, 0);
|
|
136
|
+
common__namespace
|
|
137
|
+
.removeItem(createResponse.serviceItemId, destinationAuthentication)
|
|
138
|
+
.then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
|
|
116
139
|
}
|
|
117
140
|
else {
|
|
118
141
|
// Detemplatize what we can now that the service has been created
|
|
119
|
-
newItemTemplate =
|
|
142
|
+
newItemTemplate = common__namespace.updateTemplate(newItemTemplate, templateDictionary, createResponse);
|
|
120
143
|
// Add the layers and tables to the feature service
|
|
121
|
-
|
|
144
|
+
common__namespace
|
|
145
|
+
.addFeatureServiceLayersAndTables(newItemTemplate, templateDictionary, popupInfos, destinationAuthentication)
|
|
122
146
|
.then(() => {
|
|
123
|
-
newItemTemplate =
|
|
147
|
+
newItemTemplate = common__namespace.updateTemplate(newItemTemplate, templateDictionary, createResponse);
|
|
124
148
|
// Update the item with snippet, description, popupInfo, etc.
|
|
125
|
-
|
|
149
|
+
common__namespace
|
|
150
|
+
.updateItemExtended({
|
|
126
151
|
...newItemTemplate.item,
|
|
127
152
|
url: undefined // can't update the URL of a feature service
|
|
128
153
|
}, newItemTemplate.data, destinationAuthentication, template.item.thumbnail, undefined, templateDictionary)
|
|
129
154
|
.then(() => {
|
|
130
155
|
// Interrupt process if progress callback returns `false`
|
|
131
|
-
if (!itemProgressCallback(template.itemId,
|
|
132
|
-
itemProgressCallback(template.itemId,
|
|
133
|
-
|
|
134
|
-
.
|
|
156
|
+
if (!itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Finished, template.estimatedDeploymentCostFactor / 2, createResponse.serviceItemId)) {
|
|
157
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Cancelled, 0);
|
|
158
|
+
common__namespace
|
|
159
|
+
.removeItem(createResponse.serviceItemId, destinationAuthentication)
|
|
160
|
+
.then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
|
|
135
161
|
}
|
|
136
162
|
else {
|
|
137
163
|
// Update the template to match what we've stored in AGO
|
|
138
|
-
|
|
164
|
+
common__namespace
|
|
165
|
+
.getItemBase(newItemTemplate.itemId, destinationAuthentication)
|
|
139
166
|
.then(updatedItem => {
|
|
140
167
|
newItemTemplate.item = updatedItem;
|
|
141
168
|
/* istanbul ignore else */
|
|
142
|
-
if (
|
|
169
|
+
if (common__namespace.getProp(newItemTemplate, "item.url") &&
|
|
143
170
|
!newItemTemplate.item.url.endsWith("/")) {
|
|
144
171
|
newItemTemplate.item.url += "/";
|
|
145
172
|
}
|
|
@@ -147,40 +174,43 @@
|
|
|
147
174
|
item: newItemTemplate,
|
|
148
175
|
id: createResponse.serviceItemId,
|
|
149
176
|
type: newItemTemplate.type,
|
|
150
|
-
postProcess:
|
|
177
|
+
postProcess: common__namespace.hasUnresolvedVariables({
|
|
151
178
|
item: newItemTemplate.item,
|
|
152
179
|
data: newItemTemplate.data
|
|
153
180
|
}) ||
|
|
154
|
-
|
|
181
|
+
common__namespace.isWorkforceProject(newItemTemplate)
|
|
155
182
|
});
|
|
156
183
|
}, () => {
|
|
157
|
-
itemProgressCallback(template.itemId,
|
|
158
|
-
|
|
159
|
-
.
|
|
184
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
185
|
+
common__namespace
|
|
186
|
+
.removeItem(createResponse.serviceItemId, destinationAuthentication)
|
|
187
|
+
.then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
|
|
160
188
|
} // fails to update item
|
|
161
189
|
);
|
|
162
190
|
}
|
|
163
191
|
}, () => {
|
|
164
|
-
itemProgressCallback(template.itemId,
|
|
165
|
-
|
|
166
|
-
.
|
|
192
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
193
|
+
common__namespace
|
|
194
|
+
.removeItem(createResponse.serviceItemId, destinationAuthentication)
|
|
195
|
+
.then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
|
|
167
196
|
} // fails to update item
|
|
168
197
|
);
|
|
169
198
|
}, () => {
|
|
170
|
-
itemProgressCallback(template.itemId,
|
|
171
|
-
|
|
172
|
-
.
|
|
199
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
200
|
+
common__namespace
|
|
201
|
+
.removeItem(createResponse.serviceItemId, destinationAuthentication)
|
|
202
|
+
.then(() => resolve(common__namespace.generateEmptyCreationResponse(template.type)), () => resolve(common__namespace.generateEmptyCreationResponse(template.type)));
|
|
173
203
|
} // fails to add service layers and/or tables
|
|
174
204
|
);
|
|
175
205
|
}
|
|
176
206
|
}
|
|
177
207
|
else {
|
|
178
|
-
itemProgressCallback(template.itemId,
|
|
179
|
-
resolve(
|
|
208
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
209
|
+
resolve(common__namespace.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
180
210
|
}
|
|
181
211
|
}, () => {
|
|
182
|
-
itemProgressCallback(template.itemId,
|
|
183
|
-
resolve(
|
|
212
|
+
itemProgressCallback(template.itemId, common__namespace.EItemProgressStatus.Failed, 0);
|
|
213
|
+
resolve(common__namespace.generateEmptyCreationResponse(template.type)); // fails to create item
|
|
184
214
|
});
|
|
185
215
|
});
|
|
186
216
|
}
|
|
@@ -196,11 +226,13 @@
|
|
|
196
226
|
*/
|
|
197
227
|
function postProcess(itemId, type, itemInfos, template, templates, templateDictionary, authentication) {
|
|
198
228
|
return new Promise((resolve, reject) => {
|
|
199
|
-
|
|
229
|
+
common__namespace
|
|
230
|
+
.updateItemTemplateFromDictionary(itemId, templateDictionary, authentication)
|
|
200
231
|
.then(results => {
|
|
201
|
-
if (
|
|
202
|
-
template =
|
|
203
|
-
|
|
232
|
+
if (common__namespace.isWorkforceProject(template)) {
|
|
233
|
+
template = common__namespace.replaceInTemplate(template, templateDictionary);
|
|
234
|
+
common__namespace
|
|
235
|
+
.fineTuneCreatedWorkforceItem(template, authentication, template.item.url, templateDictionary)
|
|
204
236
|
.then(resolve, reject);
|
|
205
237
|
}
|
|
206
238
|
else {
|
|
@@ -217,5 +249,5 @@
|
|
|
217
249
|
|
|
218
250
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
219
251
|
|
|
220
|
-
}))
|
|
252
|
+
}));
|
|
221
253
|
//# sourceMappingURL=feature-layer.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-layer.umd.js","sources":["../../src/feature-layer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of feature layers and services.\r\n *\r\n * @module feature-layer\r\n */\r\n\r\n//#region Imports ----------------------------------------------------------------------------------------------//\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n//#endregion\r\n\r\n//#region Publish Process --------------------------------------------------------------------------------------//\r\n\r\n/**\r\n * Fills in missing data, including full layer and table definitions, in a feature services' definition.\r\n *\r\n * @param solutionItemId\r\n * @param itemInfo Feature service item\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @param templateDictionary Hash mapping property names to replacement values\r\n * @return A promise that will resolve when fullItem has been updated\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: common.UserSession,\r\n srcAuthentication: common.UserSession,\r\n templateDictionary?: any\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>((resolve, reject) => {\r\n // Init template\r\n const template: common.IItemTemplate = common.createInitializedItemTemplate(\r\n itemInfo\r\n );\r\n\r\n const hasInvalidDesignations: boolean = common.hasInvalidGroupDesignations(\r\n itemInfo.groupDesignations\r\n );\r\n if (hasInvalidDesignations) {\r\n common\r\n .updateTemplateForInvalidDesignations(template, srcAuthentication)\r\n .then(\r\n _template => resolve(_template),\r\n e => reject(common.fail(e))\r\n );\r\n } else {\r\n // Update the estimated cost factor to deploy this item\r\n template.estimatedDeploymentCostFactor = 10;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common.getItemDataAsJson(template.item.id, srcAuthentication).then(data => {\r\n template.data = data;\r\n common.getServiceLayersAndTables(template, srcAuthentication).then(\r\n itemTemplate => {\r\n // Extract dependencies\r\n common.extractDependencies(itemTemplate, srcAuthentication).then(\r\n (dependencies: common.IDependency[]) => {\r\n // set the dependencies as an array of IDs from the array of IDependency\r\n itemTemplate.dependencies = dependencies.map(\r\n (dep: any) => dep.id\r\n );\r\n\r\n // resolve the template with templatized values\r\n resolve(\r\n common.templatize(\r\n itemTemplate,\r\n dependencies,\r\n false,\r\n templateDictionary\r\n )\r\n );\r\n },\r\n (e: any) => reject(common.fail(e))\r\n );\r\n },\r\n e => reject(common.fail(e))\r\n );\r\n });\r\n }\r\n });\r\n}\r\n\r\n//#endregion\r\n\r\n//#region Deploy Process ---------------------------------------------------------------------------------------//\r\n\r\n/**\r\n * Creates an item in a specified folder (except for Group item type).\r\n *\r\n * @param itemTemplate Item to be created; n.b.: this item is modified\r\n * @param folderId Id of folder to receive item; null indicates that the item goes into the root\r\n * folder; ignored for Group item type\r\n * @param settings Hash mapping property names to replacement values\r\n * @param authentication Credentials for the request\r\n * @return A promise that will resolve with the id of the created item\r\n * @protected\r\n */\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n\r\n // Thumbnail has to be updated separately; doesn't work in create service call\r\n delete newItemTemplate.item.thumbnail;\r\n\r\n // cache the popup info to be added later\r\n const popupInfos: common.IPopupInfos = common.cachePopupInfos(\r\n newItemTemplate.data\r\n );\r\n\r\n // Create the item, then update its URL with its new id\r\n common\r\n .createFeatureService(\r\n newItemTemplate,\r\n destinationAuthentication,\r\n templateDictionary\r\n )\r\n .then(\r\n createResponse => {\r\n if (createResponse.success) {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.serviceItemId\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // Detemplatize what we can now that the service has been created\r\n newItemTemplate = common.updateTemplate(\r\n newItemTemplate,\r\n templateDictionary,\r\n createResponse\r\n );\r\n // Add the layers and tables to the feature service\r\n common\r\n .addFeatureServiceLayersAndTables(\r\n newItemTemplate,\r\n templateDictionary,\r\n popupInfos,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () => {\r\n newItemTemplate = common.updateTemplate(\r\n newItemTemplate,\r\n templateDictionary,\r\n createResponse\r\n );\r\n // Update the item with snippet, description, popupInfo, etc.\r\n common\r\n .updateItemExtended(\r\n {\r\n ...newItemTemplate.item,\r\n url: undefined // can't update the URL of a feature service\r\n },\r\n newItemTemplate.data,\r\n destinationAuthentication,\r\n template.item.thumbnail,\r\n undefined,\r\n templateDictionary\r\n )\r\n .then(\r\n () => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.serviceItemId\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } else {\r\n // Update the template to match what we've stored in AGO\r\n common\r\n .getItemBase(\r\n newItemTemplate.itemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n updatedItem => {\r\n newItemTemplate.item = updatedItem;\r\n /* istanbul ignore else */\r\n if (\r\n common.getProp(\r\n newItemTemplate,\r\n \"item.url\"\r\n ) &&\r\n !newItemTemplate.item.url.endsWith(\"/\")\r\n ) {\r\n newItemTemplate.item.url += \"/\";\r\n }\r\n\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.serviceItemId,\r\n type: newItemTemplate.type,\r\n postProcess:\r\n common.hasUnresolvedVariables({\r\n item: newItemTemplate.item,\r\n data: newItemTemplate.data\r\n }) ||\r\n common.isWorkforceProject(newItemTemplate)\r\n });\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } // fails to update item\r\n );\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } // fails to update item\r\n );\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n )\r\n );\r\n } // fails to add service layers and/or tables\r\n );\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Feature Layer post-processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\nexport function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: common.IItemTemplate,\r\n templates: common.IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<common.IUpdateItemResponse> {\r\n return new Promise<common.IUpdateItemResponse>((resolve, reject) => {\r\n common\r\n .updateItemTemplateFromDictionary(\r\n itemId,\r\n templateDictionary,\r\n authentication\r\n )\r\n .then(results => {\r\n if (common.isWorkforceProject(template)) {\r\n template = common.replaceInTemplate(template, templateDictionary);\r\n common\r\n .fineTuneCreatedWorkforceItem(\r\n template,\r\n authentication,\r\n template.item.url,\r\n templateDictionary\r\n )\r\n .then(resolve, reject);\r\n } else {\r\n resolve(results);\r\n }\r\n }, reject);\r\n });\r\n}\r\n\r\n//#endregion\r\n"],"names":["common.createInitializedItemTemplate","common.hasInvalidGroupDesignations","common\r\n .updateTemplateForInvalidDesignations","common.fail","common.getItemDataAsJson","common.getServiceLayersAndTables","common.extractDependencies","common.templatize","common.EItemProgressStatus","common.generateEmptyCreationResponse","common.cloneObject","common.replaceInTemplate","common.cachePopupInfos","common\r\n .createFeatureService","common\r\n .removeItem","common.updateTemplate","common\r\n .addFeatureServiceLayersAndTables","common\r\n .updateItemExtended","common\r\n .removeItem","common\r\n .getItemBase","common.getProp","common.hasUnresolvedVariables","common.isWorkforceProject","common\r\n .removeItem","common\r\n .removeItem","common\r\n .removeItem","common\r\n .updateItemTemplateFromDictionary","common\r\n .fineTuneCreated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C,CAAC;OACd,CAAC,CAAC;EACL,CAAC;EAED;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"feature-layer.umd.js","sources":["../../src/feature-layer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of feature layers and services.\r\n *\r\n * @module feature-layer\r\n */\r\n\r\n//#region Imports ----------------------------------------------------------------------------------------------//\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n//#endregion\r\n\r\n//#region Publish Process --------------------------------------------------------------------------------------//\r\n\r\n/**\r\n * Fills in missing data, including full layer and table definitions, in a feature services' definition.\r\n *\r\n * @param solutionItemId\r\n * @param itemInfo Feature service item\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @param templateDictionary Hash mapping property names to replacement values\r\n * @return A promise that will resolve when fullItem has been updated\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: common.UserSession,\r\n srcAuthentication: common.UserSession,\r\n templateDictionary?: any\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>((resolve, reject) => {\r\n // Init template\r\n const template: common.IItemTemplate = common.createInitializedItemTemplate(\r\n itemInfo\r\n );\r\n\r\n const hasInvalidDesignations: boolean = common.hasInvalidGroupDesignations(\r\n itemInfo.groupDesignations\r\n );\r\n if (hasInvalidDesignations) {\r\n common\r\n .updateTemplateForInvalidDesignations(template, srcAuthentication)\r\n .then(\r\n _template => resolve(_template),\r\n e => reject(common.fail(e))\r\n );\r\n } else {\r\n // Update the estimated cost factor to deploy this item\r\n template.estimatedDeploymentCostFactor = 10;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common.getItemDataAsJson(template.item.id, srcAuthentication).then(data => {\r\n template.data = data;\r\n common.getServiceLayersAndTables(template, srcAuthentication).then(\r\n itemTemplate => {\r\n // Extract dependencies\r\n common.extractDependencies(itemTemplate, srcAuthentication).then(\r\n (dependencies: common.IDependency[]) => {\r\n // set the dependencies as an array of IDs from the array of IDependency\r\n itemTemplate.dependencies = dependencies.map(\r\n (dep: any) => dep.id\r\n );\r\n\r\n // resolve the template with templatized values\r\n resolve(\r\n common.templatize(\r\n itemTemplate,\r\n dependencies,\r\n false,\r\n templateDictionary\r\n )\r\n );\r\n },\r\n (e: any) => reject(common.fail(e))\r\n );\r\n },\r\n e => reject(common.fail(e))\r\n );\r\n });\r\n }\r\n });\r\n}\r\n\r\n//#endregion\r\n\r\n//#region Deploy Process ---------------------------------------------------------------------------------------//\r\n\r\n/**\r\n * Creates an item in a specified folder (except for Group item type).\r\n *\r\n * @param itemTemplate Item to be created; n.b.: this item is modified\r\n * @param folderId Id of folder to receive item; null indicates that the item goes into the root\r\n * folder; ignored for Group item type\r\n * @param settings Hash mapping property names to replacement values\r\n * @param authentication Credentials for the request\r\n * @return A promise that will resolve with the id of the created item\r\n * @protected\r\n */\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n\r\n // Thumbnail has to be updated separately; doesn't work in create service call\r\n delete newItemTemplate.item.thumbnail;\r\n\r\n // cache the popup info to be added later\r\n const popupInfos: common.IPopupInfos = common.cachePopupInfos(\r\n newItemTemplate.data\r\n );\r\n\r\n // Create the item, then update its URL with its new id\r\n common\r\n .createFeatureService(\r\n newItemTemplate,\r\n destinationAuthentication,\r\n templateDictionary\r\n )\r\n .then(\r\n createResponse => {\r\n if (createResponse.success) {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.serviceItemId\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // Detemplatize what we can now that the service has been created\r\n newItemTemplate = common.updateTemplate(\r\n newItemTemplate,\r\n templateDictionary,\r\n createResponse\r\n );\r\n // Add the layers and tables to the feature service\r\n common\r\n .addFeatureServiceLayersAndTables(\r\n newItemTemplate,\r\n templateDictionary,\r\n popupInfos,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () => {\r\n newItemTemplate = common.updateTemplate(\r\n newItemTemplate,\r\n templateDictionary,\r\n createResponse\r\n );\r\n // Update the item with snippet, description, popupInfo, etc.\r\n common\r\n .updateItemExtended(\r\n {\r\n ...newItemTemplate.item,\r\n url: undefined // can't update the URL of a feature service\r\n },\r\n newItemTemplate.data,\r\n destinationAuthentication,\r\n template.item.thumbnail,\r\n undefined,\r\n templateDictionary\r\n )\r\n .then(\r\n () => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.serviceItemId\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } else {\r\n // Update the template to match what we've stored in AGO\r\n common\r\n .getItemBase(\r\n newItemTemplate.itemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n updatedItem => {\r\n newItemTemplate.item = updatedItem;\r\n /* istanbul ignore else */\r\n if (\r\n common.getProp(\r\n newItemTemplate,\r\n \"item.url\"\r\n ) &&\r\n !newItemTemplate.item.url.endsWith(\"/\")\r\n ) {\r\n newItemTemplate.item.url += \"/\";\r\n }\r\n\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.serviceItemId,\r\n type: newItemTemplate.type,\r\n postProcess:\r\n common.hasUnresolvedVariables({\r\n item: newItemTemplate.item,\r\n data: newItemTemplate.data\r\n }) ||\r\n common.isWorkforceProject(newItemTemplate)\r\n });\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } // fails to update item\r\n );\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } // fails to update item\r\n );\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n )\r\n );\r\n } // fails to add service layers and/or tables\r\n );\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Feature Layer post-processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\nexport function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: common.IItemTemplate,\r\n templates: common.IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<common.IUpdateItemResponse> {\r\n return new Promise<common.IUpdateItemResponse>((resolve, reject) => {\r\n common\r\n .updateItemTemplateFromDictionary(\r\n itemId,\r\n templateDictionary,\r\n authentication\r\n )\r\n .then(results => {\r\n if (common.isWorkforceProject(template)) {\r\n template = common.replaceInTemplate(template, templateDictionary);\r\n common\r\n .fineTuneCreatedWorkforceItem(\r\n template,\r\n authentication,\r\n template.item.url,\r\n templateDictionary\r\n )\r\n .then(resolve, reject);\r\n } else {\r\n resolve(results);\r\n }\r\n }, reject);\r\n });\r\n}\r\n\r\n//#endregion\r\n"],"names":["common"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;;;;;;;;;;;;;;;EA0BA;EAEA;EAEA;;;;;;;;;;WAUgB,qBAAqB,CACnC,cAAsB,EACtB,QAAa,EACb,kBAAsC,EACtC,iBAAqC,EACrC,kBAAwB;MAExB,OAAO,IAAI,OAAO,CAAuB,CAAC,OAAO,EAAE,MAAM;;UAEvD,MAAM,QAAQ,GAAyBA,iBAAM,CAAC,6BAA6B,CACzE,QAAQ,CACT,CAAC;UAEF,MAAM,sBAAsB,GAAYA,iBAAM,CAAC,2BAA2B,CACxE,QAAQ,CAAC,iBAAiB,CAC3B,CAAC;UACF,IAAI,sBAAsB,EAAE;cAC1BA,iBAAM;mBACH,oCAAoC,CAAC,QAAQ,EAAE,iBAAiB,CAAC;mBACjE,IAAI,CACH,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,EAC/B,CAAC,IAAI,MAAM,CAACA,iBAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAC5B,CAAC;WACL;eAAM;;cAEL,QAAQ,CAAC,6BAA6B,GAAG,EAAE,CAAC;;cAG5CA,iBAAM,CAAC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI;kBACrE,QAAQ,C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
2
|
-
* @esri/solution-feature-layer - v1.
|
|
2
|
+
* @esri/solution-feature-layer - v1.2.0 - Apache-2.0
|
|
3
3
|
* Copyright (c) 2018-2021 Esri, Inc.
|
|
4
|
-
*
|
|
4
|
+
* Thu Dec 09 2021 16:03:07 GMT-0800 (Pacific Standard Time)
|
|
5
5
|
*
|
|
6
6
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
7
|
* you may not use this file except in compliance with the License.
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-common")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-common"],t):t((e=e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution)}(this,(function(e,t){"use strict";e.convertItemToTemplate=function(e,r,s,
|
|
18
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@esri/solution-common")):"function"==typeof define&&define.amd?define(["exports","@esri/solution-common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arcgisSolution=e.arcgisSolution||{},e.arcgisSolution)}(this,(function(e,t){"use strict";function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(t);e.convertItemToTemplate=function(e,t,r,s,o){return new Promise(((e,r)=>{const i=n.createInitializedItemTemplate(t);n.hasInvalidGroupDesignations(t.groupDesignations)?n.updateTemplateForInvalidDesignations(i,s).then((t=>e(t)),(e=>r(n.fail(e)))):(i.estimatedDeploymentCostFactor=10,n.getItemDataAsJson(i.item.id,s).then((t=>{i.data=t,n.getServiceLayersAndTables(i,s).then((t=>{n.extractDependencies(t,s).then((r=>{t.dependencies=r.map((e=>e.id)),e(n.templatize(t,r,!1,o))}),(e=>r(n.fail(e))))}),(e=>r(n.fail(e))))})))}))},e.createItemFromTemplate=function(e,t,r,s){return new Promise((o=>{if(!s(e.itemId,n.EItemProgressStatus.Started,0))return s(e.itemId,n.EItemProgressStatus.Ignored,0),void o(n.generateEmptyCreationResponse(e.type));let i=n.cloneObject(e);i=n.replaceInTemplate(i,t),delete i.item.thumbnail;const a=n.cachePopupInfos(i.data);n.createFeatureService(i,r,t).then((m=>{m.success?s(e.itemId,n.EItemProgressStatus.Created,e.estimatedDeploymentCostFactor/2,m.serviceItemId)?(i=n.updateTemplate(i,t,m),n.addFeatureServiceLayersAndTables(i,t,a,r).then((()=>{i=n.updateTemplate(i,t,m),n.updateItemExtended({...i.item,url:void 0},i.data,r,e.item.thumbnail,void 0,t).then((()=>{s(e.itemId,n.EItemProgressStatus.Finished,e.estimatedDeploymentCostFactor/2,m.serviceItemId)?n.getItemBase(i.itemId,r).then((e=>{i.item=e,n.getProp(i,"item.url")&&!i.item.url.endsWith("/")&&(i.item.url+="/"),o({item:i,id:m.serviceItemId,type:i.type,postProcess:n.hasUnresolvedVariables({item:i.item,data:i.data})||n.isWorkforceProject(i)})}),(()=>{s(e.itemId,n.EItemProgressStatus.Failed,0),n.removeItem(m.serviceItemId,r).then((()=>o(n.generateEmptyCreationResponse(e.type))),(()=>o(n.generateEmptyCreationResponse(e.type))))})):(s(e.itemId,n.EItemProgressStatus.Cancelled,0),n.removeItem(m.serviceItemId,r).then((()=>o(n.generateEmptyCreationResponse(e.type))),(()=>o(n.generateEmptyCreationResponse(e.type)))))}),(()=>{s(e.itemId,n.EItemProgressStatus.Failed,0),n.removeItem(m.serviceItemId,r).then((()=>o(n.generateEmptyCreationResponse(e.type))),(()=>o(n.generateEmptyCreationResponse(e.type))))}))}),(()=>{s(e.itemId,n.EItemProgressStatus.Failed,0),n.removeItem(m.serviceItemId,r).then((()=>o(n.generateEmptyCreationResponse(e.type))),(()=>o(n.generateEmptyCreationResponse(e.type))))}))):(s(e.itemId,n.EItemProgressStatus.Cancelled,0),n.removeItem(m.serviceItemId,r).then((()=>o(n.generateEmptyCreationResponse(e.type))),(()=>o(n.generateEmptyCreationResponse(e.type))))):(s(e.itemId,n.EItemProgressStatus.Failed,0),o(n.generateEmptyCreationResponse(e.type)))}),(()=>{s(e.itemId,n.EItemProgressStatus.Failed,0),o(n.generateEmptyCreationResponse(e.type))}))}))},e.postProcess=function(e,t,r,s,o,i,a){return new Promise(((t,r)=>{n.updateItemTemplateFromDictionary(e,i,a).then((e=>{n.isWorkforceProject(s)?(s=n.replaceInTemplate(s,i),n.fineTuneCreatedWorkforceItem(s,a,s.item.url,i).then(t,r)):t(e)}),r)}))},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
19
19
|
//# sourceMappingURL=feature-layer.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-layer.umd.min.js","sources":["../../src/feature-layer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of feature layers and services.\r\n *\r\n * @module feature-layer\r\n */\r\n\r\n//#region Imports ----------------------------------------------------------------------------------------------//\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n//#endregion\r\n\r\n//#region Publish Process --------------------------------------------------------------------------------------//\r\n\r\n/**\r\n * Fills in missing data, including full layer and table definitions, in a feature services' definition.\r\n *\r\n * @param solutionItemId\r\n * @param itemInfo Feature service item\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @param templateDictionary Hash mapping property names to replacement values\r\n * @return A promise that will resolve when fullItem has been updated\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: common.UserSession,\r\n srcAuthentication: common.UserSession,\r\n templateDictionary?: any\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>((resolve, reject) => {\r\n // Init template\r\n const template: common.IItemTemplate = common.createInitializedItemTemplate(\r\n itemInfo\r\n );\r\n\r\n const hasInvalidDesignations: boolean = common.hasInvalidGroupDesignations(\r\n itemInfo.groupDesignations\r\n );\r\n if (hasInvalidDesignations) {\r\n common\r\n .updateTemplateForInvalidDesignations(template, srcAuthentication)\r\n .then(\r\n _template => resolve(_template),\r\n e => reject(common.fail(e))\r\n );\r\n } else {\r\n // Update the estimated cost factor to deploy this item\r\n template.estimatedDeploymentCostFactor = 10;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common.getItemDataAsJson(template.item.id, srcAuthentication).then(data => {\r\n template.data = data;\r\n common.getServiceLayersAndTables(template, srcAuthentication).then(\r\n itemTemplate => {\r\n // Extract dependencies\r\n common.extractDependencies(itemTemplate, srcAuthentication).then(\r\n (dependencies: common.IDependency[]) => {\r\n // set the dependencies as an array of IDs from the array of IDependency\r\n itemTemplate.dependencies = dependencies.map(\r\n (dep: any) => dep.id\r\n );\r\n\r\n // resolve the template with templatized values\r\n resolve(\r\n common.templatize(\r\n itemTemplate,\r\n dependencies,\r\n false,\r\n templateDictionary\r\n )\r\n );\r\n },\r\n (e: any) => reject(common.fail(e))\r\n );\r\n },\r\n e => reject(common.fail(e))\r\n );\r\n });\r\n }\r\n });\r\n}\r\n\r\n//#endregion\r\n\r\n//#region Deploy Process ---------------------------------------------------------------------------------------//\r\n\r\n/**\r\n * Creates an item in a specified folder (except for Group item type).\r\n *\r\n * @param itemTemplate Item to be created; n.b.: this item is modified\r\n * @param folderId Id of folder to receive item; null indicates that the item goes into the root\r\n * folder; ignored for Group item type\r\n * @param settings Hash mapping property names to replacement values\r\n * @param authentication Credentials for the request\r\n * @return A promise that will resolve with the id of the created item\r\n * @protected\r\n */\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n\r\n // Thumbnail has to be updated separately; doesn't work in create service call\r\n delete newItemTemplate.item.thumbnail;\r\n\r\n // cache the popup info to be added later\r\n const popupInfos: common.IPopupInfos = common.cachePopupInfos(\r\n newItemTemplate.data\r\n );\r\n\r\n // Create the item, then update its URL with its new id\r\n common\r\n .createFeatureService(\r\n newItemTemplate,\r\n destinationAuthentication,\r\n templateDictionary\r\n )\r\n .then(\r\n createResponse => {\r\n if (createResponse.success) {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.serviceItemId\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // Detemplatize what we can now that the service has been created\r\n newItemTemplate = common.updateTemplate(\r\n newItemTemplate,\r\n templateDictionary,\r\n createResponse\r\n );\r\n // Add the layers and tables to the feature service\r\n common\r\n .addFeatureServiceLayersAndTables(\r\n newItemTemplate,\r\n templateDictionary,\r\n popupInfos,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () => {\r\n newItemTemplate = common.updateTemplate(\r\n newItemTemplate,\r\n templateDictionary,\r\n createResponse\r\n );\r\n // Update the item with snippet, description, popupInfo, etc.\r\n common\r\n .updateItemExtended(\r\n {\r\n ...newItemTemplate.item,\r\n url: undefined // can't update the URL of a feature service\r\n },\r\n newItemTemplate.data,\r\n destinationAuthentication,\r\n template.item.thumbnail,\r\n undefined,\r\n templateDictionary\r\n )\r\n .then(\r\n () => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.serviceItemId\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } else {\r\n // Update the template to match what we've stored in AGO\r\n common\r\n .getItemBase(\r\n newItemTemplate.itemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n updatedItem => {\r\n newItemTemplate.item = updatedItem;\r\n /* istanbul ignore else */\r\n if (\r\n common.getProp(\r\n newItemTemplate,\r\n \"item.url\"\r\n ) &&\r\n !newItemTemplate.item.url.endsWith(\"/\")\r\n ) {\r\n newItemTemplate.item.url += \"/\";\r\n }\r\n\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.serviceItemId,\r\n type: newItemTemplate.type,\r\n postProcess:\r\n common.hasUnresolvedVariables({\r\n item: newItemTemplate.item,\r\n data: newItemTemplate.data\r\n }) ||\r\n common.isWorkforceProject(newItemTemplate)\r\n });\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } // fails to update item\r\n );\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } // fails to update item\r\n );\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n )\r\n );\r\n } // fails to add service layers and/or tables\r\n );\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Feature Layer post-processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\nexport function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: common.IItemTemplate,\r\n templates: common.IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<common.IUpdateItemResponse> {\r\n return new Promise<common.IUpdateItemResponse>((resolve, reject) => {\r\n common\r\n .updateItemTemplateFromDictionary(\r\n itemId,\r\n templateDictionary,\r\n authentication\r\n )\r\n .then(results => {\r\n if (common.isWorkforceProject(template)) {\r\n template = common.replaceInTemplate(template, templateDictionary);\r\n common\r\n .fineTuneCreatedWorkforceItem(\r\n template,\r\n authentication,\r\n template.item.url,\r\n templateDictionary\r\n )\r\n .then(resolve, reject);\r\n } else {\r\n resolve(results);\r\n }\r\n }, reject);\r\n });\r\n}\r\n\r\n//#endregion\r\n"],"names":["solutionItemId","itemInfo","destAuthentication","srcAuthentication","templateDictionary","Promise","resolve","reject","template","common.createInitializedItemTemplate","common.hasInvalidGroupDesignations","groupDesignations","common\r\n .updateTemplateForInvalidDesignations","then","_template","e","common.fail","estimatedDeploymentCostFactor","common.getItemDataAsJson","item","id","data","common.getServiceLayersAndTables","itemTemplate","common.extractDependencies","dependencies","map","dep","common.templatize","destinationAuthentication","itemProgressCallback","itemId","common.EItemProgressStatus","Started","Ignored","common.generateEmptyCreationResponse","type","newItemTemplate","common.cloneObject","common.replaceInTemplate","thumbnail","popupInfos","common.cachePopupInfos","common\r\n .createFeatureService","createResponse","success","Created","serviceItemId","common.updateTemplate","common\r\n .addFeatureServiceLayersAndTables","common\r\n .updateItemExtended","url","undefined","Finished","common\r\n .getItemBase","updatedItem","common.getProp","endsWith","postProcess","common.hasUnresolvedVariables","common.isWorkforceProject","Failed","common\r\n .removeItem","Cancelled","common\r\n .removeItem","common\r\n .removeItem","common\r\n .removeItem","common\r\n .removeItem","itemInfos","templates","authentication","common\r\n .updateItemTemplateFromDictionary","results","common\r\n .fineTuneCreatedWorkforceItem"],"mappings":";;;;;;;;;;;;;;;;;2UAyCEA,EACAC,EACAC,EACAC,EACAC,GAEA,OAAO,IAAIC,SAA8B,CAACC,EAASC,KAEjD,MAAMC,EAAiCC,gCACrCR,GAGsCS,8BACtCT,EAASU,mBAGTC,uCACwCJ,EAAUL,GAC/CU,MACCC,GAAaR,EAAQQ,KACrBC,GAAKR,EAAOS,OAAYD,OAI5BP,EAASS,8BAAgC,GAGzCC,oBAAyBV,EAASW,KAAKC,GAAIjB,GAAmBU,MAAKQ,IACjEb,EAASa,KAAOA,EAChBC,4BAAiCd,EAAUL,GAAmBU,MAC5DU,IAEEC,sBAA2BD,EAAcpB,GAAmBU,MACzDY,IAECF,EAAaE,aAAeA,EAAaC,KACtCC,GAAaA,EAAIP,KAIpBd,EACEsB,aACEL,EACAE,GACA,EACArB,OAILW,GAAWR,EAAOS,OAAYD,SAGnCA,GAAKR,EAAOS,OAAYD,gDAuBhCP,EACAJ,EACAyB,EACAC,GAEA,OAAO,IAAIzB,SAAgDC,IAEzD,IACGwB,EACCtB,EAASuB,OACTC,sBAA2BC,QAC3B,GASF,OANAH,EACEtB,EAASuB,OACTC,sBAA2BE,QAC3B,QAEF5B,EAAQ6B,gCAAqC3B,EAAS4B,OAKxD,IAAIC,EAAwCC,cAAmB9B,GAC/D6B,EAAkBE,oBAChBF,EACAjC,UAIKiC,EAAgBlB,KAAKqB,UAG5B,MAAMC,EAAiCC,kBACrCL,EAAgB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B,gCACE3B,EAAS4B,SAGf,IACE9B,EACE6B,gCACE3B,EAAS4B,eAO3B,KACEN,EACEtB,EAASuB,OACTC,sBAA2B6B,OAC3B,GAEFK,aAEItB,EAAeG,cACflB,GAEDhB,MACC,IACEP,EACE6B,gCAAqC3B,EAAS4B,SAElD,IACE9B,EACE6B,gCAAqC3B,EAAS4B,cApM5DN,EACEtB,EAASuB,OACTC,sBAA2B+B,UAC3B,GAEFI,aAEIvB,EAAeG,cACflB,GAEDhB,MACC,IACEP,EACE6B,gCAAqC3B,EAAS4B,SAElD,IACE9B,EAAQ6B,gCAAqC3B,EAAS4B,WA2L9DN,EACEtB,EAASuB,OACTC,sBAA2B6B,OAC3B,GAEFvD,EAAQ6B,gCAAqC3B,EAAS4B,WAG1D,KACEN,EACEtB,EAASuB,OACTC,sBAA2B6B,OAC3B,GAEFvD,EAAQ6B,gCAAqC3B,EAAS4B,qCAiB9DL,EACAK,EACAgC,EACA5D,EACA6D,EACAjE,EACAkE,GAEA,OAAO,IAAIjE,SAAoC,CAACC,EAASC,KACvDgE,mCAEIxC,EACA3B,EACAkE,GAEDzD,MAAK2D,IACAZ,qBAA0BpD,IAC5BA,EAAW+B,oBAAyB/B,EAAUJ,GAC9CqE,+BAEIjE,EACA8D,EACA9D,EAASW,KAAKgC,IACd/C,GAEDS,KAAKP,EAASC,IAEjBD,EAAQkE,KAETjE"}
|
|
1
|
+
{"version":3,"file":"feature-layer.umd.min.js","sources":["../../src/feature-layer.ts"],"sourcesContent":["/** @license\r\n * Copyright 2018 Esri\r\n *\r\n * Licensed under the Apache License, Version 2.0 (the \"License\");\r\n * you may not use this file except in compliance with the License.\r\n * You may obtain a copy of the License at\r\n *\r\n * http://www.apache.org/licenses/LICENSE-2.0\r\n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an \"AS IS\" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n\r\n/**\r\n * Manages the creation and deployment of feature layers and services.\r\n *\r\n * @module feature-layer\r\n */\r\n\r\n//#region Imports ----------------------------------------------------------------------------------------------//\r\n\r\nimport * as common from \"@esri/solution-common\";\r\n\r\n//#endregion\r\n\r\n//#region Publish Process --------------------------------------------------------------------------------------//\r\n\r\n/**\r\n * Fills in missing data, including full layer and table definitions, in a feature services' definition.\r\n *\r\n * @param solutionItemId\r\n * @param itemInfo Feature service item\r\n * @param destAuthentication Credentials for requests to the destination organization\r\n * @param srcAuthentication Credentials for requests to source items\r\n * @param templateDictionary Hash mapping property names to replacement values\r\n * @return A promise that will resolve when fullItem has been updated\r\n */\r\nexport function convertItemToTemplate(\r\n solutionItemId: string,\r\n itemInfo: any,\r\n destAuthentication: common.UserSession,\r\n srcAuthentication: common.UserSession,\r\n templateDictionary?: any\r\n): Promise<common.IItemTemplate> {\r\n return new Promise<common.IItemTemplate>((resolve, reject) => {\r\n // Init template\r\n const template: common.IItemTemplate = common.createInitializedItemTemplate(\r\n itemInfo\r\n );\r\n\r\n const hasInvalidDesignations: boolean = common.hasInvalidGroupDesignations(\r\n itemInfo.groupDesignations\r\n );\r\n if (hasInvalidDesignations) {\r\n common\r\n .updateTemplateForInvalidDesignations(template, srcAuthentication)\r\n .then(\r\n _template => resolve(_template),\r\n e => reject(common.fail(e))\r\n );\r\n } else {\r\n // Update the estimated cost factor to deploy this item\r\n template.estimatedDeploymentCostFactor = 10;\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n common.getItemDataAsJson(template.item.id, srcAuthentication).then(data => {\r\n template.data = data;\r\n common.getServiceLayersAndTables(template, srcAuthentication).then(\r\n itemTemplate => {\r\n // Extract dependencies\r\n common.extractDependencies(itemTemplate, srcAuthentication).then(\r\n (dependencies: common.IDependency[]) => {\r\n // set the dependencies as an array of IDs from the array of IDependency\r\n itemTemplate.dependencies = dependencies.map(\r\n (dep: any) => dep.id\r\n );\r\n\r\n // resolve the template with templatized values\r\n resolve(\r\n common.templatize(\r\n itemTemplate,\r\n dependencies,\r\n false,\r\n templateDictionary\r\n )\r\n );\r\n },\r\n (e: any) => reject(common.fail(e))\r\n );\r\n },\r\n e => reject(common.fail(e))\r\n );\r\n });\r\n }\r\n });\r\n}\r\n\r\n//#endregion\r\n\r\n//#region Deploy Process ---------------------------------------------------------------------------------------//\r\n\r\n/**\r\n * Creates an item in a specified folder (except for Group item type).\r\n *\r\n * @param itemTemplate Item to be created; n.b.: this item is modified\r\n * @param folderId Id of folder to receive item; null indicates that the item goes into the root\r\n * folder; ignored for Group item type\r\n * @param settings Hash mapping property names to replacement values\r\n * @param authentication Credentials for the request\r\n * @return A promise that will resolve with the id of the created item\r\n * @protected\r\n */\r\nexport function createItemFromTemplate(\r\n template: common.IItemTemplate,\r\n templateDictionary: any,\r\n destinationAuthentication: common.UserSession,\r\n itemProgressCallback: common.IItemProgressCallback\r\n): Promise<common.ICreateItemFromTemplateResponse> {\r\n return new Promise<common.ICreateItemFromTemplateResponse>(resolve => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Started,\r\n 0\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Ignored,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type));\r\n return;\r\n }\r\n\r\n // Replace the templatized symbols in a copy of the template\r\n let newItemTemplate: common.IItemTemplate = common.cloneObject(template);\r\n newItemTemplate = common.replaceInTemplate(\r\n newItemTemplate,\r\n templateDictionary\r\n );\r\n\r\n // Thumbnail has to be updated separately; doesn't work in create service call\r\n delete newItemTemplate.item.thumbnail;\r\n\r\n // cache the popup info to be added later\r\n const popupInfos: common.IPopupInfos = common.cachePopupInfos(\r\n newItemTemplate.data\r\n );\r\n\r\n // Create the item, then update its URL with its new id\r\n common\r\n .createFeatureService(\r\n newItemTemplate,\r\n destinationAuthentication,\r\n templateDictionary\r\n )\r\n .then(\r\n createResponse => {\r\n if (createResponse.success) {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Created,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.serviceItemId\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(common.generateEmptyCreationResponse(template.type))\r\n );\r\n } else {\r\n // Detemplatize what we can now that the service has been created\r\n newItemTemplate = common.updateTemplate(\r\n newItemTemplate,\r\n templateDictionary,\r\n createResponse\r\n );\r\n // Add the layers and tables to the feature service\r\n common\r\n .addFeatureServiceLayersAndTables(\r\n newItemTemplate,\r\n templateDictionary,\r\n popupInfos,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () => {\r\n newItemTemplate = common.updateTemplate(\r\n newItemTemplate,\r\n templateDictionary,\r\n createResponse\r\n );\r\n // Update the item with snippet, description, popupInfo, etc.\r\n common\r\n .updateItemExtended(\r\n {\r\n ...newItemTemplate.item,\r\n url: undefined // can't update the URL of a feature service\r\n },\r\n newItemTemplate.data,\r\n destinationAuthentication,\r\n template.item.thumbnail,\r\n undefined,\r\n templateDictionary\r\n )\r\n .then(\r\n () => {\r\n // Interrupt process if progress callback returns `false`\r\n if (\r\n !itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Finished,\r\n template.estimatedDeploymentCostFactor / 2,\r\n createResponse.serviceItemId\r\n )\r\n ) {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Cancelled,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } else {\r\n // Update the template to match what we've stored in AGO\r\n common\r\n .getItemBase(\r\n newItemTemplate.itemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n updatedItem => {\r\n newItemTemplate.item = updatedItem;\r\n /* istanbul ignore else */\r\n if (\r\n common.getProp(\r\n newItemTemplate,\r\n \"item.url\"\r\n ) &&\r\n !newItemTemplate.item.url.endsWith(\"/\")\r\n ) {\r\n newItemTemplate.item.url += \"/\";\r\n }\r\n\r\n resolve({\r\n item: newItemTemplate,\r\n id: createResponse.serviceItemId,\r\n type: newItemTemplate.type,\r\n postProcess:\r\n common.hasUnresolvedVariables({\r\n item: newItemTemplate.item,\r\n data: newItemTemplate.data\r\n }) ||\r\n common.isWorkforceProject(newItemTemplate)\r\n });\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } // fails to update item\r\n );\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(\r\n template.type\r\n )\r\n )\r\n );\r\n } // fails to update item\r\n );\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n common\r\n .removeItem(\r\n createResponse.serviceItemId,\r\n destinationAuthentication\r\n )\r\n .then(\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n ),\r\n () =>\r\n resolve(\r\n common.generateEmptyCreationResponse(template.type)\r\n )\r\n );\r\n } // fails to add service layers and/or tables\r\n );\r\n }\r\n } else {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n },\r\n () => {\r\n itemProgressCallback(\r\n template.itemId,\r\n common.EItemProgressStatus.Failed,\r\n 0\r\n );\r\n resolve(common.generateEmptyCreationResponse(template.type)); // fails to create item\r\n }\r\n );\r\n });\r\n}\r\n\r\n/**\r\n * Feature Layer post-processing actions\r\n *\r\n * @param {string} itemId The item ID\r\n * @param {string} type The template type\r\n * @param {any[]} itemInfos Array of {id: 'ef3', type: 'Web Map'} objects\r\n * @param {any} templateDictionary The template dictionary\r\n * @param {UserSession} authentication The destination session info\r\n * @returns Promise resolving to successfulness of update\r\n */\r\nexport function postProcess(\r\n itemId: string,\r\n type: string,\r\n itemInfos: any[],\r\n template: common.IItemTemplate,\r\n templates: common.IItemTemplate[],\r\n templateDictionary: any,\r\n authentication: common.UserSession\r\n): Promise<common.IUpdateItemResponse> {\r\n return new Promise<common.IUpdateItemResponse>((resolve, reject) => {\r\n common\r\n .updateItemTemplateFromDictionary(\r\n itemId,\r\n templateDictionary,\r\n authentication\r\n )\r\n .then(results => {\r\n if (common.isWorkforceProject(template)) {\r\n template = common.replaceInTemplate(template, templateDictionary);\r\n common\r\n .fineTuneCreatedWorkforceItem(\r\n template,\r\n authentication,\r\n template.item.url,\r\n templateDictionary\r\n )\r\n .then(resolve, reject);\r\n } else {\r\n resolve(results);\r\n }\r\n }, reject);\r\n });\r\n}\r\n\r\n//#endregion\r\n"],"names":["solutionItemId","itemInfo","destAuthentication","srcAuthentication","templateDictionary","Promise","resolve","reject","template","common","createInitializedItemTemplate","hasInvalidGroupDesignations","groupDesignations","updateTemplateForInvalidDesignations","then","_template","e","fail","estimatedDeploymentCostFactor","getItemDataAsJson","item","id","data","getServiceLayersAndTables","itemTemplate","extractDependencies","dependencies","map","dep","templatize","destinationAuthentication","itemProgressCallback","itemId","EItemProgressStatus","Started","Ignored","generateEmptyCreationResponse","type","newItemTemplate","cloneObject","replaceInTemplate","thumbnail","popupInfos","cachePopupInfos","createFeatureService","createResponse","success","Created","serviceItemId","updateTemplate","addFeatureServiceLayersAndTables","updateItemExtended","url","undefined","Finished","getItemBase","updatedItem","getProp","endsWith","postProcess","hasUnresolvedVariables","isWorkforceProject","Failed","removeItem","Cancelled","itemInfos","templates","authentication","updateItemTemplateFromDictionary","results","fineTuneCreatedWorkforceItem"],"mappings":";;;;;;;;;;;;;;;;;+pBAyCEA,EACAC,EACAC,EACAC,EACAC,GAEA,OAAO,IAAIC,SAA8B,CAACC,EAASC,KAEjD,MAAMC,EAAiCC,EAAOC,8BAC5CT,GAGsCQ,EAAOE,4BAC7CV,EAASW,mBAGTH,EACGI,qCAAqCL,EAAUL,GAC/CW,MACCC,GAAaT,EAAQS,KACrBC,GAAKT,EAAOE,EAAOQ,KAAKD,OAI5BR,EAASU,8BAAgC,GAGzCT,EAAOU,kBAAkBX,EAASY,KAAKC,GAAIlB,GAAmBW,MAAKQ,IACjEd,EAASc,KAAOA,EAChBb,EAAOc,0BAA0Bf,EAAUL,GAAmBW,MAC5DU,IAEEf,EAAOgB,oBAAoBD,EAAcrB,GAAmBW,MACzDY,IAECF,EAAaE,aAAeA,EAAaC,KACtCC,GAAaA,EAAIP,KAIpBf,EACEG,EAAOoB,WACLL,EACAE,GACA,EACAtB,OAILY,GAAWT,EAAOE,EAAOQ,KAAKD,SAGnCA,GAAKT,EAAOE,EAAOQ,KAAKD,gDAuBhCR,EACAJ,EACA0B,EACAC,GAEA,OAAO,IAAI1B,SAAgDC,IAEzD,IACGyB,E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2D,iCACCpC,EACA5B,EACA+D,GAEDrD,MAAKuD,IACA5D,EAAOoD,mBAAmBrD,IAC5BA,EAAWC,EAAO+B,kBAAkBhC,EAAUJ,GAC9CK,EACG6D,6BACC9D,EACA2D,EACA3D,EAASY,KAAKgC,IACdhD,GAEDU,KAAKR,EAASC,IAEjBD,EAAQ+D,KAET9D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/solution-feature-layer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Manages the creation and deployment of feature layers and services for @esri/solution.js.",
|
|
5
5
|
"main": "dist/node/index.js",
|
|
6
6
|
"unpkg": "dist/umd/feature-layer.umd.min.js",
|
|
@@ -13,32 +13,32 @@
|
|
|
13
13
|
"dist/**"
|
|
14
14
|
],
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@esri/arcgis-rest-auth": "3.4.
|
|
17
|
-
"@esri/arcgis-rest-feature-layer": "3.4.
|
|
18
|
-
"@esri/arcgis-rest-portal": "3.4.
|
|
19
|
-
"@esri/arcgis-rest-request": "3.4.
|
|
20
|
-
"@esri/arcgis-rest-service-admin": "3.4.
|
|
21
|
-
"@esri/hub-common": "9.2
|
|
22
|
-
"@esri/hub-initiatives": "9.2
|
|
23
|
-
"@esri/hub-sites": "9.2
|
|
24
|
-
"@esri/hub-teams": "9.2
|
|
25
|
-
"rollup": "^
|
|
26
|
-
"typescript": "^4.
|
|
16
|
+
"@esri/arcgis-rest-auth": "3.4.3",
|
|
17
|
+
"@esri/arcgis-rest-feature-layer": "3.4.3",
|
|
18
|
+
"@esri/arcgis-rest-portal": "3.4.3",
|
|
19
|
+
"@esri/arcgis-rest-request": "3.4.3",
|
|
20
|
+
"@esri/arcgis-rest-service-admin": "3.4.3",
|
|
21
|
+
"@esri/hub-common": "9.7.2",
|
|
22
|
+
"@esri/hub-initiatives": "9.7.2",
|
|
23
|
+
"@esri/hub-sites": "9.7.2",
|
|
24
|
+
"@esri/hub-teams": "9.7.2",
|
|
25
|
+
"rollup": "^2.60.0",
|
|
26
|
+
"typescript": "^4.4.4"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@esri/arcgis-rest-auth": "3.4.
|
|
30
|
-
"@esri/arcgis-rest-feature-layer": "3.4.
|
|
31
|
-
"@esri/arcgis-rest-portal": "3.4.
|
|
32
|
-
"@esri/arcgis-rest-request": "3.4.
|
|
33
|
-
"@esri/arcgis-rest-service-admin": "3.4.
|
|
34
|
-
"@esri/hub-common": "9.2
|
|
35
|
-
"@esri/hub-initiatives": "9.2
|
|
36
|
-
"@esri/hub-sites": "9.2
|
|
37
|
-
"@esri/hub-teams": "9.2
|
|
29
|
+
"@esri/arcgis-rest-auth": "3.4.3",
|
|
30
|
+
"@esri/arcgis-rest-feature-layer": "3.4.3",
|
|
31
|
+
"@esri/arcgis-rest-portal": "3.4.3",
|
|
32
|
+
"@esri/arcgis-rest-request": "3.4.3",
|
|
33
|
+
"@esri/arcgis-rest-service-admin": "3.4.3",
|
|
34
|
+
"@esri/hub-common": "9.7.2",
|
|
35
|
+
"@esri/hub-initiatives": "9.7.2",
|
|
36
|
+
"@esri/hub-sites": "9.7.2",
|
|
37
|
+
"@esri/hub-teams": "9.7.2"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@esri/solution-common": "^1.
|
|
41
|
-
"tslib": "
|
|
40
|
+
"@esri/solution-common": "^1.2.0",
|
|
41
|
+
"tslib": "1.13.0"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"prepare": "npm run build",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"esri",
|
|
91
91
|
"ES6"
|
|
92
92
|
],
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "70f706fb28a50db0b9b13030f263f8e9e270b98d"
|
|
94
94
|
}
|