@esri/solutions-components 0.6.37 → 0.6.39
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/calcite-alert_3.cjs.entry.js +1 -1
- package/dist/cjs/calcite-combobox_6.cjs.entry.js +1 -1
- package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
- package/dist/cjs/card-manager_3.cjs.entry.js +7 -4
- package/dist/cjs/crowdsource-manager.cjs.entry.js +1 -1
- package/dist/cjs/{downloadUtils-37d9aaf3.js → downloadUtils-d8e48fbd.js} +55 -12
- package/dist/cjs/{index.es-d1d9b140.js → index.es-6159eedc.js} +4 -3
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/map-select-tools_3.cjs.entry.js +4 -3
- package/dist/cjs/{mapViewUtils-96172223.js → mapViewUtils-f7bbc35b.js} +5 -2
- package/dist/cjs/public-notification.cjs.entry.js +5 -4
- package/dist/cjs/{clean-url-d5326abb.js → restHelpersGet-c94617cf.js} +398 -0
- package/dist/cjs/solution-configuration.cjs.entry.js +565 -565
- package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
- package/dist/cjs/{solution-store-714601a2.js → solution-store-b40c2f46.js} +19 -383
- package/dist/cjs/solutions-components.cjs.js +1 -1
- package/dist/collection/components/crowdsource-manager/crowdsource-manager.js +10 -4
- package/dist/collection/components/map-card/map-card.js +26 -1
- package/dist/collection/components/public-notification/public-notification.js +6 -5
- package/dist/collection/utils/downloadUtils.js +50 -8
- package/dist/collection/utils/downloadUtils.ts +62 -9
- package/dist/collection/utils/interfaces.ts +2 -0
- package/dist/collection/utils/queryUtils.js +5 -2
- package/dist/collection/utils/queryUtils.ts +4 -2
- package/dist/components/crowdsource-manager.js +1 -1
- package/dist/components/downloadUtils.js +51 -8
- package/dist/components/map-card2.js +4 -1
- package/dist/components/public-notification.js +2 -2
- package/dist/components/queryUtils.js +5 -2
- package/dist/components/{clean-url.js → restHelpersGet.js} +392 -1
- package/dist/components/solution-configuration.js +552 -552
- package/dist/components/solution-store.js +2 -365
- package/dist/esm/calcite-alert_3.entry.js +1 -1
- package/dist/esm/calcite-combobox_6.entry.js +1 -1
- package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
- package/dist/esm/card-manager_3.entry.js +7 -4
- package/dist/esm/crowdsource-manager.entry.js +1 -1
- package/dist/esm/{downloadUtils-76379e4a.js → downloadUtils-d41ecba9.js} +53 -10
- package/dist/esm/{index.es-0d134a52.js → index.es-b226bf47.js} +4 -3
- package/dist/esm/loader.js +1 -1
- package/dist/esm/map-select-tools_3.entry.js +4 -3
- package/dist/esm/{mapViewUtils-08f6cfce.js → mapViewUtils-1e2befd7.js} +5 -2
- package/dist/esm/public-notification.entry.js +5 -4
- package/dist/esm/{clean-url-bce022e6.js → restHelpersGet-a5ec2192.js} +392 -1
- package/dist/esm/solution-configuration.entry.js +552 -552
- package/dist/esm/solution-contents_3.entry.js +2 -2
- package/dist/esm/{solution-store-3ee6c7a3.js → solution-store-17bb0a75.js} +2 -365
- package/dist/esm/solutions-components.js +1 -1
- package/dist/solutions-components/{p-9800e602.entry.js → p-091120c5.entry.js} +1 -1
- package/dist/solutions-components/p-1b14b687.entry.js +6 -0
- package/dist/solutions-components/{p-646e983f.entry.js → p-2d143359.entry.js} +1 -1
- package/dist/solutions-components/{p-ac7332b3.entry.js → p-40e95e2b.entry.js} +1 -1
- package/dist/solutions-components/p-420e1585.entry.js +36 -0
- package/dist/solutions-components/p-4807b2a1.js +36 -0
- package/dist/solutions-components/p-56a3b81e.entry.js +6 -0
- package/dist/solutions-components/p-5856dc4f.js +66 -0
- package/dist/solutions-components/p-89b4b401.js +145 -0
- package/dist/solutions-components/{p-4ecad91c.entry.js → p-973625f8.entry.js} +1 -1
- package/dist/solutions-components/p-99391a15.entry.js +6 -0
- package/dist/solutions-components/{p-03130804.js → p-9ecb5d66.js} +1 -1
- package/dist/solutions-components/{p-b02eb8f4.js → p-a8661f1f.js} +30 -30
- package/dist/solutions-components/p-ba064f24.entry.js +6 -0
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/downloadUtils.ts +62 -9
- package/dist/solutions-components/utils/interfaces.ts +2 -0
- package/dist/solutions-components/utils/queryUtils.ts +4 -2
- package/dist/types/components/crowdsource-manager/crowdsource-manager.d.ts +3 -3
- package/dist/types/components/map-card/map-card.d.ts +5 -1
- package/dist/types/components/public-notification/public-notification.d.ts +1 -1
- package/dist/types/components.d.ts +16 -8
- package/dist/types/utils/interfaces.d.ts +1 -0
- package/package.json +1 -1
- package/dist/solutions-components/p-13b21d19.entry.js +0 -36
- package/dist/solutions-components/p-15070568.js +0 -36
- package/dist/solutions-components/p-63867402.entry.js +0 -6
- package/dist/solutions-components/p-81a0c88f.entry.js +0 -6
- package/dist/solutions-components/p-b7804687.entry.js +0 -6
- package/dist/solutions-components/p-d0544f24.js +0 -192
- package/dist/solutions-components/p-eba875d9.entry.js +0 -6
- package/dist/solutions-components/p-ecc95259.js +0 -20
@@ -4,10 +4,10 @@
|
|
4
4
|
* http://www.apache.org/licenses/LICENSE-2.0
|
5
5
|
*/
|
6
6
|
import { r as registerInstance, h, H as Host, g as getElement } from './index-0740c914.js';
|
7
|
-
import {
|
7
|
+
import { s as state } from './solution-store-17bb0a75.js';
|
8
8
|
import './solution-resource-be35d35b.js';
|
9
|
+
import { r as request, N as NODEJS_DEFAULT_REFERER_HEADER, c as cleanUrl, e as encodeQueryString, A as ArcGISAuthError, a as getProp } from './restHelpersGet-a5ec2192.js';
|
9
10
|
import { g as getLocaleComponentStrings } from './locale-6be4e8f0.js';
|
10
|
-
import { r as request, N as NODEJS_DEFAULT_REFERER_HEADER, c as cleanUrl, e as encodeQueryString, A as ArcGISAuthError } from './clean-url-bce022e6.js';
|
11
11
|
import './index-71d123d4.js';
|
12
12
|
import './interfaces-7470d906.js';
|
13
13
|
import './_commonjsHelpers-d5f9d613.js';
|
@@ -35,576 +35,234 @@ function decodeQueryString(query) {
|
|
35
35
|
}, {});
|
36
36
|
}
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
38
|
+
/*! *****************************************************************************
|
39
|
+
Copyright (c) Microsoft Corporation.
|
40
|
+
|
41
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
42
|
+
purpose with or without fee is hereby granted.
|
43
|
+
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
45
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
46
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
47
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
48
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
49
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
50
|
+
PERFORMANCE OF THIS SOFTWARE.
|
51
|
+
***************************************************************************** */
|
52
|
+
|
53
|
+
var __assign = function() {
|
54
|
+
__assign = Object.assign || function __assign(t) {
|
55
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
56
|
+
s = arguments[i];
|
57
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
58
|
+
}
|
59
|
+
return t;
|
60
|
+
};
|
61
|
+
return __assign.apply(this, arguments);
|
62
|
+
};
|
63
|
+
|
64
|
+
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
|
65
|
+
* Apache-2.0 */
|
66
|
+
function fetchToken(url, requestOptions) {
|
67
|
+
var options = requestOptions;
|
68
|
+
// we generate a response, so we can't return the raw response
|
69
|
+
options.rawResponse = false;
|
70
|
+
return request(url, options).then(function (response) {
|
71
|
+
var r = {
|
72
|
+
token: response.access_token,
|
73
|
+
username: response.username,
|
74
|
+
expires: new Date(
|
75
|
+
// convert seconds in response to milliseconds and add the value to the current time to calculate a static expiration timestamp
|
76
|
+
Date.now() + (response.expires_in * 1000 - 1000)),
|
77
|
+
ssl: response.ssl === true
|
78
|
+
};
|
79
|
+
if (response.refresh_token) {
|
80
|
+
r.refreshToken = response.refresh_token;
|
81
|
+
}
|
82
|
+
return r;
|
83
|
+
});
|
78
84
|
}
|
79
|
-
|
80
|
-
|
81
|
-
*
|
82
|
-
|
83
|
-
|
84
|
-
* @returns a hierarchy for item and item dependency display
|
85
|
-
*/
|
86
|
-
function getItemHierarchy(templates) {
|
87
|
-
const hierarchy = [];
|
88
|
-
// Get the template specified by id out of a list of templates
|
89
|
-
function getTemplateInSolution(templates, id) {
|
90
|
-
const iTemplate = templates.findIndex((template) => id === template.itemId);
|
91
|
-
return iTemplate >= 0 ? templates[iTemplate] : null;
|
92
|
-
}
|
93
|
-
// Hierarchically list the dependencies of specified node
|
94
|
-
function traceItemId(id, accumulatedHierarchy, alreadyVisitedIds = []) {
|
95
|
-
// Get the dependencies of the node
|
96
|
-
const template = getTemplateInSolution(templates, id);
|
85
|
+
|
86
|
+
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
87
|
+
* Apache-2.0 */
|
88
|
+
function generateToken(url, requestOptions) {
|
89
|
+
var options = requestOptions;
|
97
90
|
/* istanbul ignore else */
|
98
|
-
if (
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
};
|
103
|
-
// Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops
|
104
|
-
/* istanbul ignore else */
|
105
|
-
if (alreadyVisitedIds.indexOf(id) < 0) {
|
106
|
-
// Add dependency to alreadyVisitedIds list
|
107
|
-
alreadyVisitedIds.push(id);
|
108
|
-
template.dependencies.forEach((dependencyId) => {
|
109
|
-
// Remove dependency from list of templates to visit in the top-level loop
|
110
|
-
const iDependencyTemplate = templateItemIds.indexOf(dependencyId);
|
111
|
-
/* istanbul ignore else */
|
112
|
-
if (iDependencyTemplate >= 0) {
|
113
|
-
templateItemIds.splice(iDependencyTemplate, 1);
|
114
|
-
}
|
115
|
-
traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
|
116
|
-
});
|
117
|
-
}
|
118
|
-
accumulatedHierarchy.push(templateEntry);
|
91
|
+
if (typeof window !== "undefined" &&
|
92
|
+
window.location &&
|
93
|
+
window.location.host) {
|
94
|
+
options.params.referer = window.location.host;
|
119
95
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
.filter((template) => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes
|
125
|
-
.sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs
|
126
|
-
templateItemIds = templateItemIds.concat(otherItems.map((template) => template.itemId));
|
127
|
-
// Step through the list of nodes; we'll also remove nodes as we visit them
|
128
|
-
let itemId = templateItemIds.shift();
|
129
|
-
while (typeof itemId !== "undefined") {
|
130
|
-
traceItemId(itemId, hierarchy);
|
131
|
-
itemId = templateItemIds.shift();
|
132
|
-
}
|
133
|
-
return hierarchy;
|
96
|
+
else {
|
97
|
+
options.params.referer = NODEJS_DEFAULT_REFERER_HEADER;
|
98
|
+
}
|
99
|
+
return request(url, options);
|
134
100
|
}
|
101
|
+
|
135
102
|
/**
|
136
|
-
*
|
137
|
-
*
|
138
|
-
* @param templates a list of item templates from the solution
|
139
|
-
* @param translations nls translation object
|
140
|
-
*
|
141
|
-
* @returns a list of variables from the solution item templates
|
103
|
+
* Used to test if a URL is an ArcGIS Online URL
|
142
104
|
*/
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
value: undefined,
|
151
|
-
dependencies: [{
|
152
|
-
id: t.itemId,
|
153
|
-
title: translations.itemId,
|
154
|
-
value: `{{${t.itemId}.itemId}}`,
|
155
|
-
}]
|
156
|
-
};
|
157
|
-
if (t.item.url) {
|
158
|
-
item.dependencies.push({
|
159
|
-
id: t.itemId,
|
160
|
-
title: translations.url,
|
161
|
-
value: `{{${t.itemId}.url}}`,
|
162
|
-
});
|
105
|
+
var arcgisOnlineUrlRegex = /^https?:\/\/(\S+)\.arcgis\.com.+/;
|
106
|
+
function isOnline(url) {
|
107
|
+
return arcgisOnlineUrlRegex.test(url);
|
108
|
+
}
|
109
|
+
function normalizeOnlinePortalUrl(portalUrl) {
|
110
|
+
if (!arcgisOnlineUrlRegex.test(portalUrl)) {
|
111
|
+
return portalUrl;
|
163
112
|
}
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
});
|
172
|
-
_addLayersOrTables(t.properties.layers || [], item, t, translations);
|
173
|
-
_addLayersOrTables(t.properties.tables || [], item, t, translations);
|
113
|
+
switch (getOnlineEnvironment(portalUrl)) {
|
114
|
+
case "dev":
|
115
|
+
return "https://devext.arcgis.com/sharing/rest";
|
116
|
+
case "qa":
|
117
|
+
return "https://qaext.arcgis.com/sharing/rest";
|
118
|
+
default:
|
119
|
+
return "https://www.arcgis.com/sharing/rest";
|
174
120
|
}
|
175
|
-
vars.push(item);
|
176
|
-
});
|
177
|
-
return vars;
|
178
121
|
}
|
122
|
+
function getOnlineEnvironment(url) {
|
123
|
+
if (!arcgisOnlineUrlRegex.test(url)) {
|
124
|
+
return null;
|
125
|
+
}
|
126
|
+
var match = url.match(arcgisOnlineUrlRegex);
|
127
|
+
var subdomain = match[1].split(".").pop();
|
128
|
+
if (subdomain.includes("dev")) {
|
129
|
+
return "dev";
|
130
|
+
}
|
131
|
+
if (subdomain.includes("qa")) {
|
132
|
+
return "qa";
|
133
|
+
}
|
134
|
+
return "production";
|
135
|
+
}
|
136
|
+
function isFederated(owningSystemUrl, portalUrl) {
|
137
|
+
var normalizedPortalUrl = cleanUrl(normalizeOnlinePortalUrl(portalUrl)).replace(/https?:\/\//, "");
|
138
|
+
var normalizedOwningSystemUrl = cleanUrl(owningSystemUrl).replace(/https?:\/\//, "");
|
139
|
+
return new RegExp(normalizedOwningSystemUrl, "i").test(normalizedPortalUrl);
|
140
|
+
}
|
141
|
+
function canUseOnlineToken(portalUrl, requestUrl) {
|
142
|
+
var portalIsOnline = isOnline(portalUrl);
|
143
|
+
var requestIsOnline = isOnline(requestUrl);
|
144
|
+
var portalEnv = getOnlineEnvironment(portalUrl);
|
145
|
+
var requestEnv = getOnlineEnvironment(requestUrl);
|
146
|
+
if (portalIsOnline && requestIsOnline && portalEnv === requestEnv) {
|
147
|
+
return true;
|
148
|
+
}
|
149
|
+
return false;
|
150
|
+
}
|
151
|
+
|
152
|
+
/* Copyright (c) 2018-2020 Environmental Systems Research Institute, Inc.
|
153
|
+
* Apache-2.0 */
|
179
154
|
/**
|
180
|
-
*
|
155
|
+
* Validates that the user has access to the application
|
156
|
+
* and if they user should be presented a "View Only" mode
|
181
157
|
*
|
182
|
-
*
|
158
|
+
* This is only needed/valid for Esri applications that are "licensed"
|
159
|
+
* and shipped in ArcGIS Online or ArcGIS Enterprise. Most custom applications
|
160
|
+
* should not need or use this.
|
183
161
|
*
|
184
|
-
*
|
185
|
-
|
186
|
-
function getOrganizationVariables(translations) {
|
187
|
-
const orgVars = [{
|
188
|
-
id: "",
|
189
|
-
title: translations.geocodeUrl,
|
190
|
-
value: "{{organization.helperServices.geocode:getDefaultLocatorURL}}"
|
191
|
-
}, {
|
192
|
-
id: "",
|
193
|
-
title: translations.geometryUrl,
|
194
|
-
value: "{{organization.helperServices.geometry.url}}"
|
195
|
-
}, {
|
196
|
-
id: "",
|
197
|
-
title: translations.portalBaseUrl,
|
198
|
-
value: "{{portalBaseUrl}}"
|
199
|
-
}, {
|
200
|
-
id: "",
|
201
|
-
title: translations.routeUrl,
|
202
|
-
value: "{{organization.helperServices.route.url}}"
|
203
|
-
}, {
|
204
|
-
id: "",
|
205
|
-
title: translations.solutionItemExtent,
|
206
|
-
value: "{{solutionItemExtent}}"
|
207
|
-
}];
|
208
|
-
return orgVars;
|
209
|
-
}
|
210
|
-
//--------------------------------------------------------------------------
|
211
|
-
//
|
212
|
-
// Private Functions
|
213
|
-
//
|
214
|
-
//--------------------------------------------------------------------------
|
215
|
-
/**
|
216
|
-
* Explore a solution item template for variables we will allow users to insert at runtime.
|
217
|
-
* This function will update the item argument that is passed in with the var details.
|
218
|
-
*
|
219
|
-
* @param children a list of layers or tables from a template
|
220
|
-
* @param item an object that store key details for a given variable
|
221
|
-
* @param template one of the templates from the current solution
|
222
|
-
* @param translations nls translations object
|
223
|
-
*
|
224
|
-
*/
|
225
|
-
function _addLayersOrTables(children, item, template, translations) {
|
226
|
-
children.forEach(l => {
|
227
|
-
const name = l.name && l.name.indexOf("||") > -1 ? l.name.split("||")[1].replace("}}", "").trim() : l.name;
|
228
|
-
item.dependencies.push({
|
229
|
-
id: template.itemId,
|
230
|
-
title: `${name} (${translations.id})`,
|
231
|
-
value: `{{${template.itemId}.layer${l.id}.id}}`,
|
232
|
-
});
|
233
|
-
item.dependencies.push({
|
234
|
-
id: template.itemId,
|
235
|
-
title: `${name} (${translations.name})`,
|
236
|
-
value: `{{${template.itemId}.layer${l.id}.name||${name}}}`,
|
237
|
-
});
|
238
|
-
});
|
239
|
-
}
|
240
|
-
/**
|
241
|
-
* Capture key details from the solution item template
|
242
|
-
*
|
243
|
-
* @param template one of the templates from the current solution
|
244
|
-
* @param templates full list of templates
|
245
|
-
* @param dependencies list of hierarchical dependencies
|
162
|
+
* ```js
|
163
|
+
* import { validateAppAccess } from '@esri/arcgis-rest-auth';
|
246
164
|
*
|
247
|
-
*
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
groupDetails: _getGroupDetails(template, templates)
|
264
|
-
}*/
|
265
|
-
};
|
266
|
-
}
|
267
|
-
/**
|
268
|
-
* Capture key details from the solution item template
|
165
|
+
* return validateAppAccess('your-token', 'theClientId')
|
166
|
+
* .then((result) => {
|
167
|
+
* if (!result.value) {
|
168
|
+
* // redirect or show some other ui
|
169
|
+
* } else {
|
170
|
+
* if (result.viewOnlyUserTypeApp) {
|
171
|
+
* // use this to inform your app to show a "View Only" mode
|
172
|
+
* }
|
173
|
+
* }
|
174
|
+
* })
|
175
|
+
* .catch((err) => {
|
176
|
+
* // two possible errors
|
177
|
+
* // invalid clientId: {"error":{"code":400,"messageCode":"GWM_0007","message":"Invalid request","details":[]}}
|
178
|
+
* // invalid token: {"error":{"code":498,"message":"Invalid token.","details":[]}}
|
179
|
+
* })
|
180
|
+
* ```
|
269
181
|
*
|
270
|
-
*
|
271
|
-
*
|
182
|
+
* Note: This is only usable by Esri applications hosted on *arcgis.com, *esri.com or within
|
183
|
+
* an ArcGIS Enterprise installation. Custom applications can not use this.
|
272
184
|
*
|
273
|
-
* @
|
185
|
+
* @param token platform token
|
186
|
+
* @param clientId application client id
|
187
|
+
* @param portal Optional
|
274
188
|
*/
|
275
|
-
function
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
return prev;
|
288
|
-
}, []);
|
189
|
+
function validateAppAccess(token, clientId, portal) {
|
190
|
+
if (portal === void 0) { portal = "https://www.arcgis.com/sharing/rest"; }
|
191
|
+
var url = portal + "/oauth2/validateAppAccess";
|
192
|
+
var ro = {
|
193
|
+
method: "POST",
|
194
|
+
params: {
|
195
|
+
f: "json",
|
196
|
+
client_id: clientId,
|
197
|
+
token: token,
|
198
|
+
},
|
199
|
+
};
|
200
|
+
return request(url, ro);
|
289
201
|
}
|
290
|
-
|
291
|
-
|
292
|
-
*
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
return {
|
305
|
-
title: item.title || "",
|
306
|
-
snippet: item.snippet || "",
|
307
|
-
description: item.description || "",
|
308
|
-
tags: item.tags || [],
|
309
|
-
accessInformation: !isGroup ? item.accessInformation || "" : "",
|
310
|
-
licenseInfo: !isGroup ? item.licenseInfo || "" : ""
|
311
|
-
};
|
202
|
+
|
203
|
+
/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.
|
204
|
+
* Apache-2.0 */
|
205
|
+
function defer() {
|
206
|
+
var deferred = {
|
207
|
+
promise: null,
|
208
|
+
resolve: null,
|
209
|
+
reject: null,
|
210
|
+
};
|
211
|
+
deferred.promise = new Promise(function (resolve, reject) {
|
212
|
+
deferred.resolve = resolve;
|
213
|
+
deferred.reject = reject;
|
214
|
+
});
|
215
|
+
return deferred;
|
312
216
|
}
|
313
|
-
*/
|
314
217
|
/**
|
315
|
-
*
|
316
|
-
*
|
317
|
-
*
|
318
|
-
*
|
319
|
-
*
|
320
|
-
*
|
218
|
+
* ```js
|
219
|
+
* import { UserSession } from '@esri/arcgis-rest-auth';
|
220
|
+
* UserSession.beginOAuth2({
|
221
|
+
* // register an app of your own to create a unique clientId
|
222
|
+
* clientId: "abc123",
|
223
|
+
* redirectUri: 'https://yourapp.com/authenticate.html'
|
224
|
+
* })
|
225
|
+
* .then(session)
|
226
|
+
* // or
|
227
|
+
* new UserSession({
|
228
|
+
* username: "jsmith",
|
229
|
+
* password: "123456"
|
230
|
+
* })
|
231
|
+
* // or
|
232
|
+
* UserSession.deserialize(cache)
|
233
|
+
* ```
|
234
|
+
* Used to authenticate both ArcGIS Online and ArcGIS Enterprise users. `UserSession` includes helper methods for [OAuth 2.0](/arcgis-rest-js/guides/browser-authentication/) in both browser and server applications.
|
321
235
|
*/
|
322
|
-
|
323
|
-
function
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
}
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
): boolean {
|
353
|
-
return template.type !== "Group" && template.resources.some(r => r.indexOf("_info_thumbnail") < 0) &&
|
354
|
-
(template.data === null || JSON.stringify(template.data) === "{}");
|
355
|
-
}
|
356
|
-
*/
|
357
|
-
/**
|
358
|
-
* Sort the template ids based on their dependencies
|
359
|
-
*
|
360
|
-
* @param templates full list of templates
|
361
|
-
*
|
362
|
-
* @returns a list of Itop level item ids
|
363
|
-
*/
|
364
|
-
function _getTopLevelItemIds(templates) {
|
365
|
-
// Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
|
366
|
-
const topLevelItemCandidateIds = templates.map((template) => template.itemId);
|
367
|
-
templates.forEach((template) => {
|
368
|
-
(template.dependencies || []).forEach((dependencyId) => {
|
369
|
-
const iNode = topLevelItemCandidateIds.indexOf(dependencyId);
|
370
|
-
if (iNode >= 0) {
|
371
|
-
// Node is somebody's dependency, so remove the node from the list of top-level nodes
|
372
|
-
// If iNode == -1, then it's a shared dependency and it has already been removed
|
373
|
-
topLevelItemCandidateIds.splice(iNode, 1);
|
374
|
-
}
|
375
|
-
});
|
376
|
-
});
|
377
|
-
return topLevelItemCandidateIds;
|
378
|
-
}
|
379
|
-
|
380
|
-
/*! *****************************************************************************
|
381
|
-
Copyright (c) Microsoft Corporation.
|
382
|
-
|
383
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
384
|
-
purpose with or without fee is hereby granted.
|
385
|
-
|
386
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
387
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
388
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
389
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
390
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
391
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
392
|
-
PERFORMANCE OF THIS SOFTWARE.
|
393
|
-
***************************************************************************** */
|
394
|
-
|
395
|
-
var __assign = function() {
|
396
|
-
__assign = Object.assign || function __assign(t) {
|
397
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
398
|
-
s = arguments[i];
|
399
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
400
|
-
}
|
401
|
-
return t;
|
402
|
-
};
|
403
|
-
return __assign.apply(this, arguments);
|
404
|
-
};
|
405
|
-
|
406
|
-
/* Copyright (c) 2017 Environmental Systems Research Institute, Inc.
|
407
|
-
* Apache-2.0 */
|
408
|
-
function fetchToken(url, requestOptions) {
|
409
|
-
var options = requestOptions;
|
410
|
-
// we generate a response, so we can't return the raw response
|
411
|
-
options.rawResponse = false;
|
412
|
-
return request(url, options).then(function (response) {
|
413
|
-
var r = {
|
414
|
-
token: response.access_token,
|
415
|
-
username: response.username,
|
416
|
-
expires: new Date(
|
417
|
-
// convert seconds in response to milliseconds and add the value to the current time to calculate a static expiration timestamp
|
418
|
-
Date.now() + (response.expires_in * 1000 - 1000)),
|
419
|
-
ssl: response.ssl === true
|
420
|
-
};
|
421
|
-
if (response.refresh_token) {
|
422
|
-
r.refreshToken = response.refresh_token;
|
423
|
-
}
|
424
|
-
return r;
|
425
|
-
});
|
426
|
-
}
|
427
|
-
|
428
|
-
/* Copyright (c) 2017-2018 Environmental Systems Research Institute, Inc.
|
429
|
-
* Apache-2.0 */
|
430
|
-
function generateToken(url, requestOptions) {
|
431
|
-
var options = requestOptions;
|
432
|
-
/* istanbul ignore else */
|
433
|
-
if (typeof window !== "undefined" &&
|
434
|
-
window.location &&
|
435
|
-
window.location.host) {
|
436
|
-
options.params.referer = window.location.host;
|
437
|
-
}
|
438
|
-
else {
|
439
|
-
options.params.referer = NODEJS_DEFAULT_REFERER_HEADER;
|
440
|
-
}
|
441
|
-
return request(url, options);
|
442
|
-
}
|
443
|
-
|
444
|
-
/**
|
445
|
-
* Used to test if a URL is an ArcGIS Online URL
|
446
|
-
*/
|
447
|
-
var arcgisOnlineUrlRegex = /^https?:\/\/(\S+)\.arcgis\.com.+/;
|
448
|
-
function isOnline(url) {
|
449
|
-
return arcgisOnlineUrlRegex.test(url);
|
450
|
-
}
|
451
|
-
function normalizeOnlinePortalUrl(portalUrl) {
|
452
|
-
if (!arcgisOnlineUrlRegex.test(portalUrl)) {
|
453
|
-
return portalUrl;
|
454
|
-
}
|
455
|
-
switch (getOnlineEnvironment(portalUrl)) {
|
456
|
-
case "dev":
|
457
|
-
return "https://devext.arcgis.com/sharing/rest";
|
458
|
-
case "qa":
|
459
|
-
return "https://qaext.arcgis.com/sharing/rest";
|
460
|
-
default:
|
461
|
-
return "https://www.arcgis.com/sharing/rest";
|
462
|
-
}
|
463
|
-
}
|
464
|
-
function getOnlineEnvironment(url) {
|
465
|
-
if (!arcgisOnlineUrlRegex.test(url)) {
|
466
|
-
return null;
|
467
|
-
}
|
468
|
-
var match = url.match(arcgisOnlineUrlRegex);
|
469
|
-
var subdomain = match[1].split(".").pop();
|
470
|
-
if (subdomain.includes("dev")) {
|
471
|
-
return "dev";
|
472
|
-
}
|
473
|
-
if (subdomain.includes("qa")) {
|
474
|
-
return "qa";
|
475
|
-
}
|
476
|
-
return "production";
|
477
|
-
}
|
478
|
-
function isFederated(owningSystemUrl, portalUrl) {
|
479
|
-
var normalizedPortalUrl = cleanUrl(normalizeOnlinePortalUrl(portalUrl)).replace(/https?:\/\//, "");
|
480
|
-
var normalizedOwningSystemUrl = cleanUrl(owningSystemUrl).replace(/https?:\/\//, "");
|
481
|
-
return new RegExp(normalizedOwningSystemUrl, "i").test(normalizedPortalUrl);
|
482
|
-
}
|
483
|
-
function canUseOnlineToken(portalUrl, requestUrl) {
|
484
|
-
var portalIsOnline = isOnline(portalUrl);
|
485
|
-
var requestIsOnline = isOnline(requestUrl);
|
486
|
-
var portalEnv = getOnlineEnvironment(portalUrl);
|
487
|
-
var requestEnv = getOnlineEnvironment(requestUrl);
|
488
|
-
if (portalIsOnline && requestIsOnline && portalEnv === requestEnv) {
|
489
|
-
return true;
|
490
|
-
}
|
491
|
-
return false;
|
492
|
-
}
|
493
|
-
|
494
|
-
/* Copyright (c) 2018-2020 Environmental Systems Research Institute, Inc.
|
495
|
-
* Apache-2.0 */
|
496
|
-
/**
|
497
|
-
* Validates that the user has access to the application
|
498
|
-
* and if they user should be presented a "View Only" mode
|
499
|
-
*
|
500
|
-
* This is only needed/valid for Esri applications that are "licensed"
|
501
|
-
* and shipped in ArcGIS Online or ArcGIS Enterprise. Most custom applications
|
502
|
-
* should not need or use this.
|
503
|
-
*
|
504
|
-
* ```js
|
505
|
-
* import { validateAppAccess } from '@esri/arcgis-rest-auth';
|
506
|
-
*
|
507
|
-
* return validateAppAccess('your-token', 'theClientId')
|
508
|
-
* .then((result) => {
|
509
|
-
* if (!result.value) {
|
510
|
-
* // redirect or show some other ui
|
511
|
-
* } else {
|
512
|
-
* if (result.viewOnlyUserTypeApp) {
|
513
|
-
* // use this to inform your app to show a "View Only" mode
|
514
|
-
* }
|
515
|
-
* }
|
516
|
-
* })
|
517
|
-
* .catch((err) => {
|
518
|
-
* // two possible errors
|
519
|
-
* // invalid clientId: {"error":{"code":400,"messageCode":"GWM_0007","message":"Invalid request","details":[]}}
|
520
|
-
* // invalid token: {"error":{"code":498,"message":"Invalid token.","details":[]}}
|
521
|
-
* })
|
522
|
-
* ```
|
523
|
-
*
|
524
|
-
* Note: This is only usable by Esri applications hosted on *arcgis.com, *esri.com or within
|
525
|
-
* an ArcGIS Enterprise installation. Custom applications can not use this.
|
526
|
-
*
|
527
|
-
* @param token platform token
|
528
|
-
* @param clientId application client id
|
529
|
-
* @param portal Optional
|
530
|
-
*/
|
531
|
-
function validateAppAccess(token, clientId, portal) {
|
532
|
-
if (portal === void 0) { portal = "https://www.arcgis.com/sharing/rest"; }
|
533
|
-
var url = portal + "/oauth2/validateAppAccess";
|
534
|
-
var ro = {
|
535
|
-
method: "POST",
|
536
|
-
params: {
|
537
|
-
f: "json",
|
538
|
-
client_id: clientId,
|
539
|
-
token: token,
|
540
|
-
},
|
541
|
-
};
|
542
|
-
return request(url, ro);
|
543
|
-
}
|
544
|
-
|
545
|
-
/* Copyright (c) 2017-2019 Environmental Systems Research Institute, Inc.
|
546
|
-
* Apache-2.0 */
|
547
|
-
function defer() {
|
548
|
-
var deferred = {
|
549
|
-
promise: null,
|
550
|
-
resolve: null,
|
551
|
-
reject: null,
|
552
|
-
};
|
553
|
-
deferred.promise = new Promise(function (resolve, reject) {
|
554
|
-
deferred.resolve = resolve;
|
555
|
-
deferred.reject = reject;
|
556
|
-
});
|
557
|
-
return deferred;
|
558
|
-
}
|
559
|
-
/**
|
560
|
-
* ```js
|
561
|
-
* import { UserSession } from '@esri/arcgis-rest-auth';
|
562
|
-
* UserSession.beginOAuth2({
|
563
|
-
* // register an app of your own to create a unique clientId
|
564
|
-
* clientId: "abc123",
|
565
|
-
* redirectUri: 'https://yourapp.com/authenticate.html'
|
566
|
-
* })
|
567
|
-
* .then(session)
|
568
|
-
* // or
|
569
|
-
* new UserSession({
|
570
|
-
* username: "jsmith",
|
571
|
-
* password: "123456"
|
572
|
-
* })
|
573
|
-
* // or
|
574
|
-
* UserSession.deserialize(cache)
|
575
|
-
* ```
|
576
|
-
* Used to authenticate both ArcGIS Online and ArcGIS Enterprise users. `UserSession` includes helper methods for [OAuth 2.0](/arcgis-rest-js/guides/browser-authentication/) in both browser and server applications.
|
577
|
-
*/
|
578
|
-
var UserSession = /** @class */ (function () {
|
579
|
-
function UserSession(options) {
|
580
|
-
this.clientId = options.clientId;
|
581
|
-
this._refreshToken = options.refreshToken;
|
582
|
-
this._refreshTokenExpires = options.refreshTokenExpires;
|
583
|
-
this.username = options.username;
|
584
|
-
this.password = options.password;
|
585
|
-
this._token = options.token;
|
586
|
-
this._tokenExpires = options.tokenExpires;
|
587
|
-
this.portal = options.portal
|
588
|
-
? cleanUrl(options.portal)
|
589
|
-
: "https://www.arcgis.com/sharing/rest";
|
590
|
-
this.ssl = options.ssl;
|
591
|
-
this.provider = options.provider || "arcgis";
|
592
|
-
this.tokenDuration = options.tokenDuration || 20160;
|
593
|
-
this.redirectUri = options.redirectUri;
|
594
|
-
this.refreshTokenTTL = options.refreshTokenTTL || 20160;
|
595
|
-
this.server = options.server;
|
596
|
-
this.federatedServers = {};
|
597
|
-
this.trustedDomains = [];
|
598
|
-
// if a non-federated server was passed explicitly, it should be trusted.
|
599
|
-
if (options.server) {
|
600
|
-
// if the url includes more than '/arcgis/', trim the rest
|
601
|
-
var root = this.getServerRootUrl(options.server);
|
602
|
-
this.federatedServers[root] = {
|
603
|
-
token: options.token,
|
604
|
-
expires: options.tokenExpires,
|
605
|
-
};
|
606
|
-
}
|
607
|
-
this._pendingTokenRequests = {};
|
236
|
+
var UserSession = /** @class */ (function () {
|
237
|
+
function UserSession(options) {
|
238
|
+
this.clientId = options.clientId;
|
239
|
+
this._refreshToken = options.refreshToken;
|
240
|
+
this._refreshTokenExpires = options.refreshTokenExpires;
|
241
|
+
this.username = options.username;
|
242
|
+
this.password = options.password;
|
243
|
+
this._token = options.token;
|
244
|
+
this._tokenExpires = options.tokenExpires;
|
245
|
+
this.portal = options.portal
|
246
|
+
? cleanUrl(options.portal)
|
247
|
+
: "https://www.arcgis.com/sharing/rest";
|
248
|
+
this.ssl = options.ssl;
|
249
|
+
this.provider = options.provider || "arcgis";
|
250
|
+
this.tokenDuration = options.tokenDuration || 20160;
|
251
|
+
this.redirectUri = options.redirectUri;
|
252
|
+
this.refreshTokenTTL = options.refreshTokenTTL || 20160;
|
253
|
+
this.server = options.server;
|
254
|
+
this.federatedServers = {};
|
255
|
+
this.trustedDomains = [];
|
256
|
+
// if a non-federated server was passed explicitly, it should be trusted.
|
257
|
+
if (options.server) {
|
258
|
+
// if the url includes more than '/arcgis/', trim the rest
|
259
|
+
var root = this.getServerRootUrl(options.server);
|
260
|
+
this.federatedServers[root] = {
|
261
|
+
token: options.token,
|
262
|
+
expires: options.tokenExpires,
|
263
|
+
};
|
264
|
+
}
|
265
|
+
this._pendingTokenRequests = {};
|
608
266
|
}
|
609
267
|
Object.defineProperty(UserSession.prototype, "token", {
|
610
268
|
/**
|
@@ -1438,6 +1096,348 @@ var UserSession = /** @class */ (function () {
|
|
1438
1096
|
return UserSession;
|
1439
1097
|
}());
|
1440
1098
|
|
1099
|
+
/** @license
|
1100
|
+
* Copyright 2022 Esri
|
1101
|
+
*
|
1102
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
1103
|
+
* you may not use this file except in compliance with the License.
|
1104
|
+
* You may obtain a copy of the License at
|
1105
|
+
*
|
1106
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
1107
|
+
*
|
1108
|
+
* Unless required by applicable law or agreed to in writing, software
|
1109
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
1110
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
1111
|
+
* See the License for the specific language governing permissions and
|
1112
|
+
* limitations under the License.
|
1113
|
+
*/
|
1114
|
+
//--------------------------------------------------------------------------
|
1115
|
+
//
|
1116
|
+
// Public Functions
|
1117
|
+
//
|
1118
|
+
//--------------------------------------------------------------------------
|
1119
|
+
/**
|
1120
|
+
* Sort the solution items
|
1121
|
+
*
|
1122
|
+
* @param templates a list of item templates from the solution
|
1123
|
+
*
|
1124
|
+
* @returns a sorted list of solution items
|
1125
|
+
*/
|
1126
|
+
function getInventoryItems(templates) {
|
1127
|
+
const hierarchy = getItemHierarchy(templates);
|
1128
|
+
const ids = hierarchy.reduce((prev, cur) => {
|
1129
|
+
prev.push(cur.id);
|
1130
|
+
return prev;
|
1131
|
+
}, []);
|
1132
|
+
return templates.reduce((prev, cur) => {
|
1133
|
+
if (ids.indexOf(cur.itemId) > -1) {
|
1134
|
+
const hierarchyItems = hierarchy.filter(hi => hi.id === cur.itemId);
|
1135
|
+
prev.push(_getItemFromTemplate(cur, templates, hierarchyItems[0].dependencies));
|
1136
|
+
}
|
1137
|
+
return prev;
|
1138
|
+
}, []);
|
1139
|
+
}
|
1140
|
+
/**
|
1141
|
+
* Create item hierarchy that will avoid issues from cylical dependencies
|
1142
|
+
*
|
1143
|
+
* @param templates a list of item templates from the solution
|
1144
|
+
*
|
1145
|
+
* @returns a hierarchy for item and item dependency display
|
1146
|
+
*/
|
1147
|
+
function getItemHierarchy(templates) {
|
1148
|
+
const hierarchy = [];
|
1149
|
+
// Get the template specified by id out of a list of templates
|
1150
|
+
function getTemplateInSolution(templates, id) {
|
1151
|
+
const iTemplate = templates.findIndex((template) => id === template.itemId);
|
1152
|
+
return iTemplate >= 0 ? templates[iTemplate] : null;
|
1153
|
+
}
|
1154
|
+
// Hierarchically list the dependencies of specified node
|
1155
|
+
function traceItemId(id, accumulatedHierarchy, alreadyVisitedIds = []) {
|
1156
|
+
// Get the dependencies of the node
|
1157
|
+
const template = getTemplateInSolution(templates, id);
|
1158
|
+
/* istanbul ignore else */
|
1159
|
+
if (template) {
|
1160
|
+
const templateEntry = {
|
1161
|
+
id,
|
1162
|
+
dependencies: []
|
1163
|
+
};
|
1164
|
+
// Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops
|
1165
|
+
/* istanbul ignore else */
|
1166
|
+
if (alreadyVisitedIds.indexOf(id) < 0) {
|
1167
|
+
// Add dependency to alreadyVisitedIds list
|
1168
|
+
alreadyVisitedIds.push(id);
|
1169
|
+
template.dependencies.forEach((dependencyId) => {
|
1170
|
+
// Remove dependency from list of templates to visit in the top-level loop
|
1171
|
+
const iDependencyTemplate = templateItemIds.indexOf(dependencyId);
|
1172
|
+
/* istanbul ignore else */
|
1173
|
+
if (iDependencyTemplate >= 0) {
|
1174
|
+
templateItemIds.splice(iDependencyTemplate, 1);
|
1175
|
+
}
|
1176
|
+
traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
|
1177
|
+
});
|
1178
|
+
}
|
1179
|
+
accumulatedHierarchy.push(templateEntry);
|
1180
|
+
}
|
1181
|
+
}
|
1182
|
+
// Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes
|
1183
|
+
let templateItemIds = _getTopLevelItemIds(templates);
|
1184
|
+
const otherItems = templates
|
1185
|
+
.filter((template) => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes
|
1186
|
+
.sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs
|
1187
|
+
templateItemIds = templateItemIds.concat(otherItems.map((template) => template.itemId));
|
1188
|
+
// Step through the list of nodes; we'll also remove nodes as we visit them
|
1189
|
+
let itemId = templateItemIds.shift();
|
1190
|
+
while (typeof itemId !== "undefined") {
|
1191
|
+
traceItemId(itemId, hierarchy);
|
1192
|
+
itemId = templateItemIds.shift();
|
1193
|
+
}
|
1194
|
+
return hierarchy;
|
1195
|
+
}
|
1196
|
+
/**
|
1197
|
+
* Explore the solution item templates for variables we will allow users to insert at runtime
|
1198
|
+
*
|
1199
|
+
* @param templates a list of item templates from the solution
|
1200
|
+
* @param translations nls translation object
|
1201
|
+
*
|
1202
|
+
* @returns a list of variables from the solution item templates
|
1203
|
+
*/
|
1204
|
+
function getSolutionVariables(templates, translations) {
|
1205
|
+
const vars = [];
|
1206
|
+
templates.forEach(t => {
|
1207
|
+
const item = {
|
1208
|
+
id: t.itemId,
|
1209
|
+
title: t.item.title || t.item.name,
|
1210
|
+
type: t.type,
|
1211
|
+
value: undefined,
|
1212
|
+
dependencies: [{
|
1213
|
+
id: t.itemId,
|
1214
|
+
title: translations.itemId,
|
1215
|
+
value: `{{${t.itemId}.itemId}}`,
|
1216
|
+
}]
|
1217
|
+
};
|
1218
|
+
if (t.item.url) {
|
1219
|
+
item.dependencies.push({
|
1220
|
+
id: t.itemId,
|
1221
|
+
title: translations.url,
|
1222
|
+
value: `{{${t.itemId}.url}}`,
|
1223
|
+
});
|
1224
|
+
}
|
1225
|
+
if (t.type === "Feature Service") {
|
1226
|
+
// TODO need to set source service name var...
|
1227
|
+
// TODO need to set soure service shape field name "{{d05b3cf1ffcb4a4fa677627dfb18609e.name}}.Shape"
|
1228
|
+
item.dependencies.push({
|
1229
|
+
id: t.itemId,
|
1230
|
+
title: translations.solutionExtent,
|
1231
|
+
value: `{{${t.itemId}.solutionExtent}}`,
|
1232
|
+
});
|
1233
|
+
_addLayersOrTables(t.properties.layers || [], item, t, translations);
|
1234
|
+
_addLayersOrTables(t.properties.tables || [], item, t, translations);
|
1235
|
+
}
|
1236
|
+
vars.push(item);
|
1237
|
+
});
|
1238
|
+
return vars;
|
1239
|
+
}
|
1240
|
+
/**
|
1241
|
+
* Set key organization variables we will allow users to insert at runtime
|
1242
|
+
*
|
1243
|
+
* @param translations nls translation object
|
1244
|
+
*
|
1245
|
+
* @returns a list of variables for the organization
|
1246
|
+
*/
|
1247
|
+
function getOrganizationVariables(translations) {
|
1248
|
+
const orgVars = [{
|
1249
|
+
id: "",
|
1250
|
+
title: translations.geocodeUrl,
|
1251
|
+
value: "{{organization.helperServices.geocode:getDefaultLocatorURL}}"
|
1252
|
+
}, {
|
1253
|
+
id: "",
|
1254
|
+
title: translations.geometryUrl,
|
1255
|
+
value: "{{organization.helperServices.geometry.url}}"
|
1256
|
+
}, {
|
1257
|
+
id: "",
|
1258
|
+
title: translations.portalBaseUrl,
|
1259
|
+
value: "{{portalBaseUrl}}"
|
1260
|
+
}, {
|
1261
|
+
id: "",
|
1262
|
+
title: translations.routeUrl,
|
1263
|
+
value: "{{organization.helperServices.route.url}}"
|
1264
|
+
}, {
|
1265
|
+
id: "",
|
1266
|
+
title: translations.solutionItemExtent,
|
1267
|
+
value: "{{solutionItemExtent}}"
|
1268
|
+
}];
|
1269
|
+
return orgVars;
|
1270
|
+
}
|
1271
|
+
//--------------------------------------------------------------------------
|
1272
|
+
//
|
1273
|
+
// Private Functions
|
1274
|
+
//
|
1275
|
+
//--------------------------------------------------------------------------
|
1276
|
+
/**
|
1277
|
+
* Explore a solution item template for variables we will allow users to insert at runtime.
|
1278
|
+
* This function will update the item argument that is passed in with the var details.
|
1279
|
+
*
|
1280
|
+
* @param children a list of layers or tables from a template
|
1281
|
+
* @param item an object that store key details for a given variable
|
1282
|
+
* @param template one of the templates from the current solution
|
1283
|
+
* @param translations nls translations object
|
1284
|
+
*
|
1285
|
+
*/
|
1286
|
+
function _addLayersOrTables(children, item, template, translations) {
|
1287
|
+
children.forEach(l => {
|
1288
|
+
const name = l.name && l.name.indexOf("||") > -1 ? l.name.split("||")[1].replace("}}", "").trim() : l.name;
|
1289
|
+
item.dependencies.push({
|
1290
|
+
id: template.itemId,
|
1291
|
+
title: `${name} (${translations.id})`,
|
1292
|
+
value: `{{${template.itemId}.layer${l.id}.id}}`,
|
1293
|
+
});
|
1294
|
+
item.dependencies.push({
|
1295
|
+
id: template.itemId,
|
1296
|
+
title: `${name} (${translations.name})`,
|
1297
|
+
value: `{{${template.itemId}.layer${l.id}.name||${name}}}`,
|
1298
|
+
});
|
1299
|
+
});
|
1300
|
+
}
|
1301
|
+
/**
|
1302
|
+
* Capture key details from the solution item template
|
1303
|
+
*
|
1304
|
+
* @param template one of the templates from the current solution
|
1305
|
+
* @param templates full list of templates
|
1306
|
+
* @param dependencies list of hierarchical dependencies
|
1307
|
+
*
|
1308
|
+
* @returns an IInventoryItem that is used by other components to work with this template
|
1309
|
+
*/
|
1310
|
+
function _getItemFromTemplate(template, templates, dependencies) {
|
1311
|
+
return {
|
1312
|
+
id: template.itemId || "",
|
1313
|
+
title: template.item.title || "",
|
1314
|
+
dependencies: _getDependencies(dependencies, templates),
|
1315
|
+
type: template.item.type || "",
|
1316
|
+
typeKeywords: template.item.typeKeywords || [] /*,
|
1317
|
+
solutionItem: {
|
1318
|
+
itemId: template.itemId,
|
1319
|
+
itemDetails: _getItemDetails(template.item, template.type === "Group"),
|
1320
|
+
isResource: _getIsResource(template),
|
1321
|
+
data: template.data,
|
1322
|
+
properties: template.properties,
|
1323
|
+
type: template.type,
|
1324
|
+
groupDetails: _getGroupDetails(template, templates)
|
1325
|
+
}*/
|
1326
|
+
};
|
1327
|
+
}
|
1328
|
+
/**
|
1329
|
+
* Capture key details from the solution item template
|
1330
|
+
*
|
1331
|
+
* @param dependencies list of dependencies from a template
|
1332
|
+
* @param templates full list of templates
|
1333
|
+
*
|
1334
|
+
* @returns a list of IInventoryItem that are used by other components to work with the templates
|
1335
|
+
*/
|
1336
|
+
function _getDependencies(dependencies, templates) {
|
1337
|
+
const dependencyItems = [];
|
1338
|
+
const depIds = dependencies.reduce((prev, cur) => {
|
1339
|
+
prev.push(cur.id);
|
1340
|
+
dependencyItems.push(cur);
|
1341
|
+
return prev;
|
1342
|
+
}, []);
|
1343
|
+
return templates.reduce((prev, curr) => {
|
1344
|
+
const i = depIds.indexOf(curr.itemId);
|
1345
|
+
if (i > -1) {
|
1346
|
+
prev.push(_getItemFromTemplate(curr, templates, dependencyItems[i].dependencies));
|
1347
|
+
}
|
1348
|
+
return prev;
|
1349
|
+
}, []);
|
1350
|
+
}
|
1351
|
+
/**
|
1352
|
+
* Capture the key item details for a given template
|
1353
|
+
*
|
1354
|
+
* @param item the templates item
|
1355
|
+
* @param isGroup boolean to indicate if the item is a group
|
1356
|
+
* @param itemId the item id of the template
|
1357
|
+
*
|
1358
|
+
* @returns a IItemDetails object for the current item
|
1359
|
+
*/
|
1360
|
+
/*
|
1361
|
+
function _getItemDetails(
|
1362
|
+
item: any,
|
1363
|
+
isGroup: boolean
|
1364
|
+
): IItemDetails {
|
1365
|
+
return {
|
1366
|
+
title: item.title || "",
|
1367
|
+
snippet: item.snippet || "",
|
1368
|
+
description: item.description || "",
|
1369
|
+
tags: item.tags || [],
|
1370
|
+
accessInformation: !isGroup ? item.accessInformation || "" : "",
|
1371
|
+
licenseInfo: !isGroup ? item.licenseInfo || "" : ""
|
1372
|
+
};
|
1373
|
+
}
|
1374
|
+
*/
|
1375
|
+
/**
|
1376
|
+
* Capture the key item details for a given group template
|
1377
|
+
*
|
1378
|
+
* @param template one of the templates from the current solution
|
1379
|
+
* @param templates full list of templates
|
1380
|
+
*
|
1381
|
+
* @returns a list of IItemShare objects
|
1382
|
+
*/
|
1383
|
+
/*
|
1384
|
+
function _getGroupDetails(
|
1385
|
+
template: any,
|
1386
|
+
templates: any[]
|
1387
|
+
): IItemShare[] {
|
1388
|
+
return template.type === "Group" ? templates.reduce((prev, cur) => {
|
1389
|
+
if (cur.itemId !== template.itemId && cur.type !== "Group") {
|
1390
|
+
prev.push({
|
1391
|
+
id: cur.itemId,
|
1392
|
+
title: cur.item.name || cur.item.title,
|
1393
|
+
isShared: (cur.groups || []).indexOf(template.itemId) > -1,
|
1394
|
+
shareItem: (cur.groups || []).indexOf(template.itemId) > -1,
|
1395
|
+
type: cur.type,
|
1396
|
+
typeKeywords: cur.item.typeKeywords
|
1397
|
+
});
|
1398
|
+
}
|
1399
|
+
return prev;
|
1400
|
+
}, []) : [];
|
1401
|
+
}
|
1402
|
+
*/
|
1403
|
+
/**
|
1404
|
+
* Used to understand if we are dealing with a binary object that will support upload/download
|
1405
|
+
*
|
1406
|
+
* @param template one of the templates from the current solution
|
1407
|
+
*
|
1408
|
+
* @returns true if this item supports upload/download
|
1409
|
+
*/
|
1410
|
+
/*
|
1411
|
+
function _getIsResource(
|
1412
|
+
template: any
|
1413
|
+
): boolean {
|
1414
|
+
return template.type !== "Group" && template.resources.some(r => r.indexOf("_info_thumbnail") < 0) &&
|
1415
|
+
(template.data === null || JSON.stringify(template.data) === "{}");
|
1416
|
+
}
|
1417
|
+
*/
|
1418
|
+
/**
|
1419
|
+
* Sort the template ids based on their dependencies
|
1420
|
+
*
|
1421
|
+
* @param templates full list of templates
|
1422
|
+
*
|
1423
|
+
* @returns a list of Itop level item ids
|
1424
|
+
*/
|
1425
|
+
function _getTopLevelItemIds(templates) {
|
1426
|
+
// Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
|
1427
|
+
const topLevelItemCandidateIds = templates.map((template) => template.itemId);
|
1428
|
+
templates.forEach((template) => {
|
1429
|
+
(template.dependencies || []).forEach((dependencyId) => {
|
1430
|
+
const iNode = topLevelItemCandidateIds.indexOf(dependencyId);
|
1431
|
+
if (iNode >= 0) {
|
1432
|
+
// Node is somebody's dependency, so remove the node from the list of top-level nodes
|
1433
|
+
// If iNode == -1, then it's a shared dependency and it has already been removed
|
1434
|
+
topLevelItemCandidateIds.splice(iNode, 1);
|
1435
|
+
}
|
1436
|
+
});
|
1437
|
+
});
|
1438
|
+
return topLevelItemCandidateIds;
|
1439
|
+
}
|
1440
|
+
|
1441
1441
|
const solutionConfigurationCss = ".configuration-container{position:relative;height:100%;width:100%}.configuration{position:absolute;top:0px;right:0px;bottom:0px;left:0px;display:flex;padding:0.5rem;border:1px #808080 solid}.config-tabs{width:100%}.config-tab{width:100%}.config-solution{position:absolute;top:3.5rem;right:-1px;bottom:-1px;left:-1px;display:flex;padding:0.5rem}.config-inventory{display:inline;max-width:-moz-min-content;max-width:min-content;flex-grow:0;overflow-y:auto}.config-inventory-hide{display:none;max-width:-moz-min-content;max-width:min-content;flex-grow:0;overflow-y:auto}.config-item{position:relative;display:inline;flex-grow:1;overflow-y:auto;margin-inline-start:0.5rem}solution-contents{position:relative;height:100%}solution-item{position:relative;height:100%}solution-spatial-ref{position:relative;height:100%;width:100%;overflow-y:auto}";
|
1442
1442
|
|
1443
1443
|
const SolutionConfiguration = class {
|