@esri/solutions-components 0.6.36 → 0.6.38
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.
- package/dist/cjs/basemap-gallery_7.cjs.entry.js +16 -0
- package/dist/cjs/calcite-alert_3.cjs.entry.js +2 -13
- 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 +4 -3
- 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 +6 -5
- 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/basemap-gallery/basemap-gallery.js +8 -0
- package/dist/collection/components/edit-card/edit-card.js +1 -12
- package/dist/collection/components/map-legend/map-legend.js +9 -1
- package/dist/collection/components/public-notification/public-notification.js +7 -6
- package/dist/collection/utils/downloadUtils.js +50 -8
- package/dist/collection/utils/downloadUtils.ts +62 -9
- package/dist/collection/utils/queryUtils.js +5 -2
- package/dist/collection/utils/queryUtils.ts +4 -2
- package/dist/components/basemap-gallery2.js +8 -0
- package/dist/components/downloadUtils.js +51 -8
- package/dist/components/edit-card2.js +1 -12
- package/dist/components/map-legend2.js +8 -0
- package/dist/components/public-notification.js +3 -3
- 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/basemap-gallery_7.entry.js +16 -0
- package/dist/esm/calcite-alert_3.entry.js +2 -13
- 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 +4 -3
- 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 +6 -5
- 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-20e627ed.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-0f50087e.entry.js → p-973625f8.entry.js} +2 -2
- 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-fbc7fc26.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/queryUtils.ts +4 -2
- package/dist/types/components/basemap-gallery/basemap-gallery.d.ts +4 -0
- package/dist/types/components/map-legend/map-legend.d.ts +4 -0
- package/dist/types/components/public-notification/public-notification.d.ts +1 -1
- package/dist/types/components.d.ts +2 -2
- package/package.json +1 -1
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/solutions-components/p-13b21d19.entry.js +0 -36
- package/dist/solutions-components/p-15070568.js +0 -36
- package/dist/solutions-components/p-1682bd0f.entry.js +0 -6
- package/dist/solutions-components/p-7b61f856.entry.js +0 -6
- package/dist/solutions-components/p-81a0c88f.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
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
9
9
|
|
|
10
10
|
const index = require('./index-1ffa261f.js');
|
|
11
|
-
const solutionStore = require('./solution-store-
|
|
11
|
+
const solutionStore = require('./solution-store-b40c2f46.js');
|
|
12
12
|
const locale = require('./locale-d50f3250.js');
|
|
13
13
|
const common = require('./common-13719149.js');
|
|
14
14
|
require('./index-2bdbac04.js');
|
|
15
15
|
require('./interfaces-000be6de.js');
|
|
16
16
|
require('./solution-resource-f9e3b289.js');
|
|
17
17
|
require('./_commonjsHelpers-384729db.js');
|
|
18
|
-
require('./
|
|
18
|
+
require('./restHelpersGet-c94617cf.js');
|
|
19
19
|
|
|
20
20
|
const solutionContentsCss = ".icon-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";
|
|
21
21
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const index = require('./index-2bdbac04.js');
|
|
9
9
|
const interfaces = require('./interfaces-000be6de.js');
|
|
10
10
|
const solutionResource = require('./solution-resource-f9e3b289.js');
|
|
11
|
-
const
|
|
11
|
+
const restHelpersGet = require('./restHelpersGet-c94617cf.js');
|
|
12
12
|
|
|
13
13
|
/* Copyright (c) 2018-2019 Environmental Systems Research Institute, Inc.
|
|
14
14
|
* Apache-2.0 */
|
|
@@ -68,7 +68,7 @@ function getPortalUrl(requestOptions) {
|
|
|
68
68
|
if (requestOptions === void 0) { requestOptions = {}; }
|
|
69
69
|
// use portal in options if specified
|
|
70
70
|
if (requestOptions.portal) {
|
|
71
|
-
return
|
|
71
|
+
return restHelpersGet.cleanUrl(requestOptions.portal);
|
|
72
72
|
}
|
|
73
73
|
// if auth was passed, use that portal
|
|
74
74
|
if (requestOptions.authentication) {
|
|
@@ -174,7 +174,7 @@ function updateItem$1(requestOptions) {
|
|
|
174
174
|
if (requestOptions.params.extent && isBBox(requestOptions.params.extent)) {
|
|
175
175
|
requestOptions.params.extent = bboxToString(requestOptions.params.extent);
|
|
176
176
|
}
|
|
177
|
-
return
|
|
177
|
+
return restHelpersGet.request(url, requestOptions);
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
@@ -205,7 +205,7 @@ function updateItemResource(requestOptions) {
|
|
|
205
205
|
? "private"
|
|
206
206
|
: "inherit";
|
|
207
207
|
}
|
|
208
|
-
return
|
|
208
|
+
return restHelpersGet.request(url, requestOptions);
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
|
|
@@ -242,7 +242,7 @@ function addItemResource(requestOptions) {
|
|
|
242
242
|
return determineOwner(requestOptions).then(function (owner) {
|
|
243
243
|
var url = getPortalUrl(requestOptions) + "/content/users/" + owner + "/items/" + requestOptions.id + "/addResources";
|
|
244
244
|
requestOptions.params = __assign({ file: requestOptions.resource, fileName: requestOptions.name, resourcesPrefix: requestOptions.prefix, text: requestOptions.content, access: requestOptions.private ? "private" : "inherit" }, requestOptions.params);
|
|
245
|
-
return
|
|
245
|
+
return restHelpersGet.request(url, requestOptions);
|
|
246
246
|
});
|
|
247
247
|
}
|
|
248
248
|
|
|
@@ -263,373 +263,10 @@ function removeItemResource(requestOptions) {
|
|
|
263
263
|
if (typeof requestOptions.deleteAll !== "undefined") {
|
|
264
264
|
requestOptions.params.deleteAll = requestOptions.deleteAll;
|
|
265
265
|
}
|
|
266
|
-
return
|
|
266
|
+
return restHelpersGet.request(url, requestOptions);
|
|
267
267
|
});
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
/** @license
|
|
271
|
-
* Copyright 2020 Esri
|
|
272
|
-
*
|
|
273
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
274
|
-
* you may not use this file except in compliance with the License.
|
|
275
|
-
* You may obtain a copy of the License at
|
|
276
|
-
*
|
|
277
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
278
|
-
*
|
|
279
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
280
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
281
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
282
|
-
* See the License for the specific language governing permissions and
|
|
283
|
-
* limitations under the License.
|
|
284
|
-
*/
|
|
285
|
-
/**
|
|
286
|
-
* Supplies the File constructor for Microsoft Legacy Edge.
|
|
287
|
-
*
|
|
288
|
-
* @param fileBits Contents for file
|
|
289
|
-
* @param fileName Name for file
|
|
290
|
-
* @param options Bucket of options, euch as `type` for the MIME type; defaults to empty string for `type`
|
|
291
|
-
* @returns File or, for Microsoft Legacy Edge, Blob
|
|
292
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/File/File
|
|
293
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob
|
|
294
|
-
*/
|
|
295
|
-
function new_File(fileBits, fileName, options) {
|
|
296
|
-
let file;
|
|
297
|
-
try {
|
|
298
|
-
// Modern browser
|
|
299
|
-
file = new File(fileBits, fileName, options);
|
|
300
|
-
}
|
|
301
|
-
catch (error) {
|
|
302
|
-
// Microsoft Legacy Edge
|
|
303
|
-
/* istanbul ignore next */
|
|
304
|
-
file = (function () {
|
|
305
|
-
if (typeof options === "undefined") {
|
|
306
|
-
// Microsoft Legacy Edge fails in karma if options is not defined
|
|
307
|
-
options = {
|
|
308
|
-
type: ""
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
const blob = new Blob(fileBits, options);
|
|
312
|
-
blob.lastModified = new Date();
|
|
313
|
-
blob.name = fileName;
|
|
314
|
-
return blob;
|
|
315
|
-
})();
|
|
316
|
-
}
|
|
317
|
-
return file;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/** @license
|
|
321
|
-
* Copyright 2018 Esri
|
|
322
|
-
*
|
|
323
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
324
|
-
* you may not use this file except in compliance with the License.
|
|
325
|
-
* You may obtain a copy of the License at
|
|
326
|
-
*
|
|
327
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
328
|
-
*
|
|
329
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
330
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
331
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
332
|
-
* See the License for the specific language governing permissions and
|
|
333
|
-
* limitations under the License.
|
|
334
|
-
*/
|
|
335
|
-
/**
|
|
336
|
-
* Extracts JSON from a Blob.
|
|
337
|
-
*
|
|
338
|
-
* @param blob Blob to use as source
|
|
339
|
-
* @returns A promise that will resolve with JSON or null
|
|
340
|
-
*/
|
|
341
|
-
function blobToJson(blob) {
|
|
342
|
-
return new Promise(resolve => {
|
|
343
|
-
blobToText(blob).then(blobContents => {
|
|
344
|
-
try {
|
|
345
|
-
resolve(JSON.parse(blobContents));
|
|
346
|
-
}
|
|
347
|
-
catch (err) {
|
|
348
|
-
resolve(null);
|
|
349
|
-
}
|
|
350
|
-
}, () => resolve(null));
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* Converts a Blob to a File.
|
|
355
|
-
*
|
|
356
|
-
* @param blob Blob to use as source
|
|
357
|
-
* @param filename Name to use for file
|
|
358
|
-
* @param mimeType MIME type to override blob's MIME type
|
|
359
|
-
* @returns File created out of Blob and filename
|
|
360
|
-
*/
|
|
361
|
-
function blobToFile(blob, filename, mimeType) {
|
|
362
|
-
return blob
|
|
363
|
-
? new_File([blob], filename ? filename : "", {
|
|
364
|
-
type: mimeType || blob.type
|
|
365
|
-
})
|
|
366
|
-
: null;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Extracts text from a Blob.
|
|
370
|
-
*
|
|
371
|
-
* @param blob Blob to use as source
|
|
372
|
-
* @returns A promise that will resolve with text read from blob
|
|
373
|
-
*/
|
|
374
|
-
function blobToText(blob) {
|
|
375
|
-
return new Promise(resolve => {
|
|
376
|
-
const reader = new FileReader();
|
|
377
|
-
reader.onload = function (evt) {
|
|
378
|
-
// Disable needed because Node requires cast
|
|
379
|
-
// tslint:disable-next-line: no-unnecessary-type-assertion
|
|
380
|
-
const blobContents = evt.target.result;
|
|
381
|
-
resolve(blobContents ? blobContents : ""); // not handling ArrayContents variant
|
|
382
|
-
};
|
|
383
|
-
reader.readAsText(blob);
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Checks that a URL path ends with a slash.
|
|
388
|
-
*
|
|
389
|
-
* @param url URL to check
|
|
390
|
-
* @returns URL, appended with slash if missing
|
|
391
|
-
*/
|
|
392
|
-
function checkUrlPathTermination(url) {
|
|
393
|
-
return url ? (url.endsWith("/") ? url : url + "/") : url;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Gets a property out of a deeply nested object.
|
|
397
|
-
* Does not handle anything but nested object graph
|
|
398
|
-
*
|
|
399
|
-
* @param obj Object to retrieve value from
|
|
400
|
-
* @param path Path into an object, e.g., "data.values.webmap", where "data" is a top-level property
|
|
401
|
-
* in obj
|
|
402
|
-
* @returns Value at end of path
|
|
403
|
-
*/
|
|
404
|
-
function getProp(obj, path) {
|
|
405
|
-
return path.split(".").reduce(function (prev, curr) {
|
|
406
|
-
/* istanbul ignore next no need to test undefined scenario */
|
|
407
|
-
return prev ? prev[curr] : undefined;
|
|
408
|
-
}, obj);
|
|
409
|
-
}
|
|
410
|
-
/**
|
|
411
|
-
* Sets a deeply nested property of an object.
|
|
412
|
-
* Creates the full path if it does not exist.
|
|
413
|
-
*
|
|
414
|
-
* @param obj Object to set value of
|
|
415
|
-
* @param path Path into an object, e.g., "data.values.webmap", where "data" is a top-level property in obj
|
|
416
|
-
* @param value The value to set at the end of the path
|
|
417
|
-
*/
|
|
418
|
-
function setCreateProp(obj, path, value) {
|
|
419
|
-
const pathParts = path.split(".");
|
|
420
|
-
pathParts.reduce((a, b, c) => {
|
|
421
|
-
if (c === pathParts.length - 1) {
|
|
422
|
-
a[b] = value;
|
|
423
|
-
return value;
|
|
424
|
-
}
|
|
425
|
-
else {
|
|
426
|
-
if (!a[b]) {
|
|
427
|
-
a[b] = {};
|
|
428
|
-
}
|
|
429
|
-
return a[b];
|
|
430
|
-
}
|
|
431
|
-
}, obj);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Gets a Blob from a web site.
|
|
436
|
-
*
|
|
437
|
-
* @param url Address of Blob
|
|
438
|
-
* @param authentication Credentials for the request
|
|
439
|
-
* @param requestOptions - Options for the request, including parameters relevant to the endpoint.
|
|
440
|
-
* @returns Promise that will resolve with Blob or an AGO-style JSON failure response
|
|
441
|
-
*/
|
|
442
|
-
function getBlob(url, authentication, requestOptions = {}) {
|
|
443
|
-
if (!url) {
|
|
444
|
-
return Promise.reject("Url must be provided");
|
|
445
|
-
}
|
|
446
|
-
const blobRequestOptions = {
|
|
447
|
-
authentication: authentication,
|
|
448
|
-
rawResponse: true,
|
|
449
|
-
...requestOptions
|
|
450
|
-
};
|
|
451
|
-
return cleanUrl.request(url, blobRequestOptions).then(response => {
|
|
452
|
-
return response.blob();
|
|
453
|
-
});
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/** @license
|
|
457
|
-
* Copyright 2018 Esri
|
|
458
|
-
*
|
|
459
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
460
|
-
* you may not use this file except in compliance with the License.
|
|
461
|
-
* You may obtain a copy of the License at
|
|
462
|
-
*
|
|
463
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
464
|
-
*
|
|
465
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
466
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
467
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
468
|
-
* See the License for the specific language governing permissions and
|
|
469
|
-
* limitations under the License.
|
|
470
|
-
*/
|
|
471
|
-
// ------------------------------------------------------------------------------------------------------------------ //
|
|
472
|
-
const ZIP_FILE_HEADER_SIGNATURE = "PK";
|
|
473
|
-
/**
|
|
474
|
-
* Gets a Blob from a web site and casts it as a file using the supplied name.
|
|
475
|
-
*
|
|
476
|
-
* @param url Address of Blob
|
|
477
|
-
* @param filename Name to use for file
|
|
478
|
-
* @param authentication Credentials for the request
|
|
479
|
-
* @returns Promise that will resolve with a File, undefined if the Blob is null, or an AGO-style JSON failure response
|
|
480
|
-
*/
|
|
481
|
-
function getBlobAsFile(url, filename, authentication, ignoreErrors = [], mimeType) {
|
|
482
|
-
return new Promise((resolve, reject) => {
|
|
483
|
-
// Get the blob from the URL
|
|
484
|
-
getBlobCheckForError(url, authentication, ignoreErrors).then(blob => !blob ? resolve(null) : resolve(blobToFile(blob, filename, mimeType)), reject);
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Gets a Blob from a web site and checks for a JSON error packet in the Blob.
|
|
489
|
-
*
|
|
490
|
-
* @param url Address of Blob
|
|
491
|
-
* @param authentication Credentials for the request
|
|
492
|
-
* @param ignoreErrors List of HTTP error codes that should be ignored
|
|
493
|
-
* @returns Promise that will resolve with Blob or an AGO-REST JSON failure response
|
|
494
|
-
*/
|
|
495
|
-
function getBlobCheckForError(url, authentication, ignoreErrors = []) {
|
|
496
|
-
return new Promise((resolve, reject) => {
|
|
497
|
-
// Get the blob from the URL
|
|
498
|
-
getBlob(url, authentication).then(blob => {
|
|
499
|
-
// Reclassify text/plain blobs as needed
|
|
500
|
-
_fixTextBlobType(blob).then(adjustedBlob => {
|
|
501
|
-
if (adjustedBlob.type === "application/json") {
|
|
502
|
-
// Blob may be an error
|
|
503
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
504
|
-
blobToJson(adjustedBlob).then((json) => {
|
|
505
|
-
// Check for valid JSON with an error
|
|
506
|
-
if (json?.error) {
|
|
507
|
-
const code = json.error.code;
|
|
508
|
-
if (code !== undefined && ignoreErrors.indexOf(code) >= 0) {
|
|
509
|
-
resolve(null); // Error, but ignored
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
reject(json); // Other error; fail with error
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
resolve(adjustedBlob);
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
resolve(adjustedBlob);
|
|
522
|
-
}
|
|
523
|
-
}, reject);
|
|
524
|
-
}, reject);
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* Gets the data information of an AGO item in its JSON form.
|
|
529
|
-
*
|
|
530
|
-
* @param itemId Id of an item whose data information is sought
|
|
531
|
-
* @param filename Name to use for file
|
|
532
|
-
* @param authentication Credentials for the request to AGO
|
|
533
|
-
* @returns Promise that will resolve with JSON, or an AGO-style JSON failure response
|
|
534
|
-
*/
|
|
535
|
-
function getItemDataAsJson(itemId, authentication) {
|
|
536
|
-
return new Promise(resolve => {
|
|
537
|
-
getItemDataBlob(itemId, authentication).then(blob => resolve(blobToJson(blob)), () => resolve(null));
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Gets the data information of an AGO item in its raw (Blob) form.
|
|
542
|
-
*
|
|
543
|
-
* @param itemId Id of an item whose data information is sought
|
|
544
|
-
* @param authentication Credentials for the request to AGO
|
|
545
|
-
* @returns A promise that will resolve with the data Blob or null if the item doesn't have a data section
|
|
546
|
-
*/
|
|
547
|
-
function getItemDataBlob(itemId, authentication) {
|
|
548
|
-
return new Promise(resolve => {
|
|
549
|
-
const url = getItemDataBlobUrl(itemId, authentication);
|
|
550
|
-
getBlobCheckForError(url, authentication, [400, 500]).then(blob => resolve(_fixTextBlobType(blob)), () => resolve(null));
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Gets the URL to the data information of an AGO item in its raw (Blob) form.
|
|
555
|
-
*
|
|
556
|
-
* @param itemId Id of an item whose data information is sought
|
|
557
|
-
* @param authentication Credentials for the request to AGO
|
|
558
|
-
* @returns URL string
|
|
559
|
-
*/
|
|
560
|
-
function getItemDataBlobUrl(itemId, authentication) {
|
|
561
|
-
return `${getPortalSharingUrlFromAuth(authentication)}/content/items/${itemId}/data`;
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* Extracts the portal sharing url from a supplied authentication.
|
|
565
|
-
*
|
|
566
|
-
* @param authentication Credentials for the request to AGO
|
|
567
|
-
* @returns Portal sharing url to be used in API requests, defaulting to `https://www.arcgis.com/sharing/rest`
|
|
568
|
-
*/
|
|
569
|
-
function getPortalSharingUrlFromAuth(authentication) {
|
|
570
|
-
// If auth was passed, use that portal
|
|
571
|
-
return getProp(authentication, "portal") || "https://www.arcgis.com/sharing/rest";
|
|
572
|
-
}
|
|
573
|
-
function getThumbnailFile(url, filename, authentication) {
|
|
574
|
-
return new Promise(resolve => {
|
|
575
|
-
getBlobAsFile(url, filename, authentication, [500]).then(resolve, () => resolve(null));
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
// ------------------------------------------------------------------------------------------------------------------ //
|
|
579
|
-
/**
|
|
580
|
-
* Fixes the types of Blobs incorrectly typed as text/plain.
|
|
581
|
-
*
|
|
582
|
-
* @param blob Blob to check
|
|
583
|
-
* @returns Promise resolving to original Blob, unless it's originally typed as text/plain but is
|
|
584
|
-
* really JSON, ZIP, or XML
|
|
585
|
-
* @private
|
|
586
|
-
*/
|
|
587
|
-
function _fixTextBlobType(blob) {
|
|
588
|
-
return new Promise((resolve, reject) => {
|
|
589
|
-
if (blob &&
|
|
590
|
-
blob.size > 0 &&
|
|
591
|
-
(blob.type.startsWith("text/plain") ||
|
|
592
|
-
blob.type.startsWith("application/json"))) {
|
|
593
|
-
blobToText(blob).then(blobText => {
|
|
594
|
-
// Convertible to JSON?
|
|
595
|
-
try {
|
|
596
|
-
JSON.parse(blobText);
|
|
597
|
-
// Yes; reclassify as JSON
|
|
598
|
-
resolve(new Blob([blob], { type: "application/json" }));
|
|
599
|
-
}
|
|
600
|
-
catch (ignored) {
|
|
601
|
-
// Nope; test for ZIP file
|
|
602
|
-
if (blobText.length > 4 &&
|
|
603
|
-
blobText.substr(0, 4) === ZIP_FILE_HEADER_SIGNATURE) {
|
|
604
|
-
// Yes; reclassify as ZIP
|
|
605
|
-
resolve(new Blob([blob], { type: "application/zip" }));
|
|
606
|
-
}
|
|
607
|
-
else if (blobText.startsWith("<")) {
|
|
608
|
-
// Reclassify as XML; since the blob started out as text/plain, it's more likely that is
|
|
609
|
-
// meant to be human-readable, so we'll use text/xml instead of application/xml
|
|
610
|
-
resolve(new Blob([blob], { type: "text/xml" }));
|
|
611
|
-
}
|
|
612
|
-
else {
|
|
613
|
-
// Leave as text
|
|
614
|
-
resolve(blob);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
},
|
|
618
|
-
// Faulty blob
|
|
619
|
-
reject);
|
|
620
|
-
}
|
|
621
|
-
else {
|
|
622
|
-
// Empty or not typed as plain text, so simply return
|
|
623
|
-
if (blob) {
|
|
624
|
-
resolve(blob);
|
|
625
|
-
}
|
|
626
|
-
else {
|
|
627
|
-
reject();
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
|
|
633
270
|
/** @license
|
|
634
271
|
* Copyright 2018 Esri
|
|
635
272
|
*
|
|
@@ -832,7 +469,7 @@ function copyZipIntoItem(zipInfo, destinationItemId, destinationAuthentication)
|
|
|
832
469
|
zipInfo.zip
|
|
833
470
|
.generateAsync({ type: "blob" })
|
|
834
471
|
.then((content) => {
|
|
835
|
-
return blobToFile(content, zipInfo.filename, "application/zip");
|
|
472
|
+
return restHelpersGet.blobToFile(content, zipInfo.filename, "application/zip");
|
|
836
473
|
})
|
|
837
474
|
.then((zipfile) => {
|
|
838
475
|
const addResourceOptions = {
|
|
@@ -1035,7 +672,7 @@ function copyFilesToStorageItem(files, storageItemId, storageAuthentication) {
|
|
|
1035
672
|
* @returns URL string
|
|
1036
673
|
*/
|
|
1037
674
|
function generateSourceResourceUrl(sourcePortalSharingUrl, itemId, sourceResourceFilename) {
|
|
1038
|
-
return (checkUrlPathTermination(sourcePortalSharingUrl) +
|
|
675
|
+
return (restHelpersGet.checkUrlPathTermination(sourcePortalSharingUrl) +
|
|
1039
676
|
"content/items/" +
|
|
1040
677
|
itemId +
|
|
1041
678
|
"/resources/" +
|
|
@@ -1086,7 +723,7 @@ function getThumbnailFromStorageItem(authentication, filePaths) {
|
|
|
1086
723
|
if (!thumbnailUrl) {
|
|
1087
724
|
return Promise.resolve(null);
|
|
1088
725
|
}
|
|
1089
|
-
return getThumbnailFile(thumbnailUrl, thumbnailFilename, authentication);
|
|
726
|
+
return restHelpersGet.getThumbnailFile(thumbnailUrl, thumbnailFilename, authentication);
|
|
1090
727
|
}
|
|
1091
728
|
/**
|
|
1092
729
|
* Removes the item's resource that matches the filename with new content
|
|
@@ -1210,9 +847,9 @@ class SolutionStore {
|
|
|
1210
847
|
*/
|
|
1211
848
|
async loadSolution(solutionItemId, authentication) {
|
|
1212
849
|
this._authentication = authentication;
|
|
1213
|
-
const solutionData = await getItemDataAsJson(solutionItemId, authentication);
|
|
850
|
+
const solutionData = await restHelpersGet.getItemDataAsJson(solutionItemId, authentication);
|
|
1214
851
|
if (solutionData) {
|
|
1215
|
-
const defaultWkid = getProp(solutionData, "params.wkid.default");
|
|
852
|
+
const defaultWkid = restHelpersGet.getProp(solutionData, "params.wkid.default");
|
|
1216
853
|
await this._prepareSolutionItemsForEditing(solutionItemId, solutionData.templates, authentication);
|
|
1217
854
|
const featureServices = this._getFeatureServices(solutionData.templates);
|
|
1218
855
|
const spatialReferenceInfo = this._getSpatialReferenceInfo(featureServices, defaultWkid);
|
|
@@ -1270,7 +907,7 @@ class SolutionStore {
|
|
|
1270
907
|
await this._prepareSolutionItemsForStorage(solutionItemId, solutionData.templates, this._authentication);
|
|
1271
908
|
const updatedDefaultWkid = this._setSpatialReferenceInfo(spatialReferenceInfo, solutionData.templates);
|
|
1272
909
|
if (updatedDefaultWkid) {
|
|
1273
|
-
setCreateProp(solutionData, "params.wkid", {
|
|
910
|
+
restHelpersGet.setCreateProp(solutionData, "params.wkid", {
|
|
1274
911
|
"label": "Spatial Reference",
|
|
1275
912
|
"default": updatedDefaultWkid,
|
|
1276
913
|
"valueType": "spatialReference",
|
|
@@ -1280,7 +917,7 @@ class SolutionStore {
|
|
|
1280
917
|
});
|
|
1281
918
|
}
|
|
1282
919
|
else {
|
|
1283
|
-
setCreateProp(solutionData, "params.wkid", {});
|
|
920
|
+
restHelpersGet.setCreateProp(solutionData, "params.wkid", {});
|
|
1284
921
|
}
|
|
1285
922
|
const itemInfo = {
|
|
1286
923
|
id: solutionItemId,
|
|
@@ -1418,7 +1055,7 @@ class SolutionStore {
|
|
|
1418
1055
|
const customizeableFeatureServices = this._getCustomizableFeatureServices(templates);
|
|
1419
1056
|
return customizeableFeatureServices.map((fs) => {
|
|
1420
1057
|
const name = fs.item.title || fs.item.name;
|
|
1421
|
-
const wkid = getProp(fs, "properties.service.spatialReference.wkid");
|
|
1058
|
+
const wkid = restHelpersGet.getProp(fs, "properties.service.spatialReference.wkid");
|
|
1422
1059
|
return { name, enabled: wkid.toString().startsWith("{{params.wkid||") };
|
|
1423
1060
|
});
|
|
1424
1061
|
}
|
|
@@ -1658,14 +1295,14 @@ class SolutionStore {
|
|
|
1658
1295
|
let wkid;
|
|
1659
1296
|
if (spatialReferenceInfo.services[name]) { // enabled
|
|
1660
1297
|
wkid = `{{params.wkid||${spatialReferenceInfo.spatialReference}}}`;
|
|
1661
|
-
setCreateProp(fs, "properties.service.spatialReference.wkid", wkid);
|
|
1298
|
+
restHelpersGet.setCreateProp(fs, "properties.service.spatialReference.wkid", wkid);
|
|
1662
1299
|
}
|
|
1663
1300
|
else { // disabled
|
|
1664
|
-
wkid = getProp(fs, "properties.service.spatialReference.wkid");
|
|
1301
|
+
wkid = restHelpersGet.getProp(fs, "properties.service.spatialReference.wkid");
|
|
1665
1302
|
// Remove customizing prefix if present
|
|
1666
1303
|
if (wkid.toString().startsWith(customizingPrefix)) {
|
|
1667
1304
|
wkid = wkid.toString().substring(customizingPrefix.length, wkid.length - 2);
|
|
1668
|
-
setCreateProp(fs, "properties.service.spatialReference.wkid", wkid);
|
|
1305
|
+
restHelpersGet.setCreateProp(fs, "properties.service.spatialReference.wkid", wkid);
|
|
1669
1306
|
}
|
|
1670
1307
|
}
|
|
1671
1308
|
});
|
|
@@ -1674,10 +1311,10 @@ class SolutionStore {
|
|
|
1674
1311
|
else {
|
|
1675
1312
|
// Disable this feature in each service
|
|
1676
1313
|
customizeableFeatureServices.forEach((fs) => {
|
|
1677
|
-
const wkid = getProp(fs, "properties.service.spatialReference.wkid");
|
|
1314
|
+
const wkid = restHelpersGet.getProp(fs, "properties.service.spatialReference.wkid");
|
|
1678
1315
|
// Remove customizing prefix if present
|
|
1679
1316
|
if (wkid.toString().startsWith(customizingPrefix)) {
|
|
1680
|
-
setCreateProp(fs, "properties.service.spatialReference.wkid", wkid.toString().substring(customizingPrefix.length, wkid.length - 2));
|
|
1317
|
+
restHelpersGet.setCreateProp(fs, "properties.service.spatialReference.wkid", wkid.toString().substring(customizingPrefix.length, wkid.length - 2));
|
|
1681
1318
|
}
|
|
1682
1319
|
});
|
|
1683
1320
|
return undefined;
|
|
@@ -1703,5 +1340,4 @@ class SolutionStore {
|
|
|
1703
1340
|
}
|
|
1704
1341
|
const state = SolutionStore.Store;
|
|
1705
1342
|
|
|
1706
|
-
exports.getProp = getProp;
|
|
1707
1343
|
exports.state = state;
|