@esri/solution-common 1.1.2 → 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.
- package/dist/esm/completeItem.js +6 -7
- package/dist/esm/completeItem.js.map +1 -1
- package/dist/esm/create-hub-request-options.d.ts +4 -4
- package/dist/esm/create-hub-request-options.js +9 -12
- package/dist/esm/create-hub-request-options.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteEmptyGroups.js +2 -2
- package/dist/esm/deleteHelpers/deleteEmptyGroups.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js +15 -15
- package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteSolutionContents.js +20 -22
- package/dist/esm/deleteHelpers/deleteSolutionContents.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteSolutionFolder.js +10 -10
- package/dist/esm/deleteHelpers/deleteSolutionFolder.js.map +1 -1
- package/dist/esm/deleteHelpers/deleteSolutionItem.js +4 -4
- package/dist/esm/deleteHelpers/deleteSolutionItem.js.map +1 -1
- package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js +1 -1
- package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js.map +1 -1
- package/dist/esm/deleteHelpers/removeItems.js +20 -29
- package/dist/esm/deleteHelpers/removeItems.js.map +1 -1
- package/dist/esm/deleteHelpers/reportProgress.js +3 -6
- package/dist/esm/deleteHelpers/reportProgress.js.map +1 -1
- package/dist/esm/deleteSolution.js +10 -12
- package/dist/esm/deleteSolution.js.map +1 -1
- package/dist/esm/dependencies.js +27 -19
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/featureServiceHelpers.d.ts +6 -0
- package/dist/esm/featureServiceHelpers.js +530 -500
- package/dist/esm/featureServiceHelpers.js.map +1 -1
- package/dist/esm/generalHelpers.js +72 -76
- package/dist/esm/generalHelpers.js.map +1 -1
- package/dist/esm/get-subscription-info.js +5 -3
- package/dist/esm/get-subscription-info.js.map +1 -1
- package/dist/esm/getDeletableSolutionInfo.js +6 -10
- package/dist/esm/getDeletableSolutionInfo.js.map +1 -1
- package/dist/esm/getSolutionSummary.js +15 -19
- package/dist/esm/getSolutionSummary.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces.d.ts +39 -1
- package/dist/esm/interfaces.js +3 -3
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/libConnectors.js +5 -7
- package/dist/esm/libConnectors.js.map +1 -1
- package/dist/esm/migrations/apply-schema.js +3 -3
- package/dist/esm/migrations/apply-schema.js.map +1 -1
- package/dist/esm/migrations/is-legacy-solution.js +2 -2
- package/dist/esm/migrations/is-legacy-solution.js.map +1 -1
- package/dist/esm/migrations/upgrade-three-dot-one.js +3 -3
- package/dist/esm/migrations/upgrade-three-dot-one.js.map +1 -1
- package/dist/esm/migrations/upgrade-three-dot-zero.js +1 -1
- package/dist/esm/migrations/upgrade-three-dot-zero.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-five.js +17 -8
- package/dist/esm/migrations/upgrade-two-dot-five.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-four.js +12 -12
- package/dist/esm/migrations/upgrade-two-dot-four.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-one.js +1 -1
- package/dist/esm/migrations/upgrade-two-dot-one.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-seven.js +1 -1
- package/dist/esm/migrations/upgrade-two-dot-seven.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-six.js +9 -12
- package/dist/esm/migrations/upgrade-two-dot-six.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-three.js +3 -3
- package/dist/esm/migrations/upgrade-two-dot-three.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-two.js +3 -3
- package/dist/esm/migrations/upgrade-two-dot-two.js.map +1 -1
- package/dist/esm/migrations/upgrade-two-dot-zero.js +8 -9
- package/dist/esm/migrations/upgrade-two-dot-zero.js.map +1 -1
- package/dist/esm/migrator.js +5 -7
- package/dist/esm/migrator.js.map +1 -1
- package/dist/esm/polyfills.js +5 -5
- package/dist/esm/polyfills.js.map +1 -1
- package/dist/esm/resourceHelpers.js +54 -57
- package/dist/esm/resourceHelpers.js.map +1 -1
- package/dist/esm/resources/add-resource-from-blob.js +2 -2
- package/dist/esm/resources/add-resource-from-blob.js.map +1 -1
- package/dist/esm/resources/addMetadataFromBlob.js +1 -1
- package/dist/esm/resources/addMetadataFromBlob.js.map +1 -1
- package/dist/esm/resources/convert-item-resource-to-storage-resource.js +6 -7
- package/dist/esm/resources/convert-item-resource-to-storage-resource.js.map +1 -1
- package/dist/esm/resources/convert-storage-resource-to-item-resource.js +8 -9
- package/dist/esm/resources/convert-storage-resource-to-item-resource.js.map +1 -1
- package/dist/esm/resources/copyAssociatedFiles.js +44 -53
- package/dist/esm/resources/copyAssociatedFiles.js.map +1 -1
- package/dist/esm/resources/copyDataIntoItem.js +5 -11
- package/dist/esm/resources/copyDataIntoItem.js.map +1 -1
- package/dist/esm/resources/copyMetadataIntoItem.js +4 -10
- package/dist/esm/resources/copyMetadataIntoItem.js.map +1 -1
- package/dist/esm/resources/copyResourceIntoZip.js +5 -7
- package/dist/esm/resources/copyResourceIntoZip.js.map +1 -1
- package/dist/esm/resources/copyZipIntoItem.js +5 -9
- package/dist/esm/resources/copyZipIntoItem.js.map +1 -1
- package/dist/esm/resources/createCopyResults.js +5 -2
- package/dist/esm/resources/createCopyResults.js.map +1 -1
- package/dist/esm/resources/get-blob.js +7 -5
- package/dist/esm/resources/get-blob.js.map +1 -1
- package/dist/esm/resources/getItemResourcesFilesFromPaths.js +7 -7
- package/dist/esm/resources/getItemResourcesFilesFromPaths.js.map +1 -1
- package/dist/esm/resources/getItemResourcesPaths.js +7 -8
- package/dist/esm/resources/getItemResourcesPaths.js.map +1 -1
- package/dist/esm/resources/transform-resource-paths-to-solution-resources.js +8 -9
- package/dist/esm/resources/transform-resource-paths-to-solution-resources.js.map +1 -1
- package/dist/esm/restHelpers.d.ts +65 -5
- package/dist/esm/restHelpers.js +422 -276
- package/dist/esm/restHelpers.js.map +1 -1
- package/dist/esm/restHelpersGet.js +102 -111
- package/dist/esm/restHelpersGet.js.map +1 -1
- package/dist/esm/sharing/share-item-to-groups.d.ts +2 -1
- package/dist/esm/sharing/share-item-to-groups.js +12 -6
- package/dist/esm/sharing/share-item-to-groups.js.map +1 -1
- package/dist/esm/templatization.js +64 -40
- package/dist/esm/templatization.js.map +1 -1
- package/dist/esm/trackingHelpers.d.ts +116 -0
- package/dist/esm/trackingHelpers.js +205 -0
- package/dist/esm/trackingHelpers.js.map +1 -0
- package/dist/esm/velocityHelpers.d.ts +2 -0
- package/dist/esm/velocityHelpers.js +30 -12
- package/dist/esm/velocityHelpers.js.map +1 -1
- package/dist/esm/workforceHelpers.d.ts +11 -0
- package/dist/esm/workforceHelpers.js +208 -180
- package/dist/esm/workforceHelpers.js.map +1 -1
- package/dist/node/completeItem.js +8 -9
- package/dist/node/completeItem.js.map +1 -1
- package/dist/node/create-hub-request-options.d.ts +4 -4
- package/dist/node/create-hub-request-options.js +11 -14
- package/dist/node/create-hub-request-options.js.map +1 -1
- package/dist/node/deleteHelpers/deleteEmptyGroups.js +3 -3
- package/dist/node/deleteHelpers/deleteEmptyGroups.js.map +1 -1
- package/dist/node/deleteHelpers/deleteGroupIfEmpty.js +16 -16
- package/dist/node/deleteHelpers/deleteGroupIfEmpty.js.map +1 -1
- package/dist/node/deleteHelpers/deleteSolutionContents.js +26 -28
- package/dist/node/deleteHelpers/deleteSolutionContents.js.map +1 -1
- package/dist/node/deleteHelpers/deleteSolutionFolder.js +11 -11
- package/dist/node/deleteHelpers/deleteSolutionFolder.js.map +1 -1
- package/dist/node/deleteHelpers/deleteSolutionItem.js +6 -6
- package/dist/node/deleteHelpers/deleteSolutionItem.js.map +1 -1
- package/dist/node/deleteHelpers/index.js +1 -1
- package/dist/node/deleteHelpers/reconstructBuildOrderIds.js +2 -2
- package/dist/node/deleteHelpers/reconstructBuildOrderIds.js.map +1 -1
- package/dist/node/deleteHelpers/removeItems.js +26 -35
- package/dist/node/deleteHelpers/removeItems.js.map +1 -1
- package/dist/node/deleteHelpers/reportProgress.js +4 -7
- package/dist/node/deleteHelpers/reportProgress.js.map +1 -1
- package/dist/node/deleteSolution.js +12 -14
- package/dist/node/deleteSolution.js.map +1 -1
- package/dist/node/dependencies.js +29 -21
- package/dist/node/dependencies.js.map +1 -1
- package/dist/node/featureServiceHelpers.d.ts +6 -0
- package/dist/node/featureServiceHelpers.js +535 -504
- package/dist/node/featureServiceHelpers.js.map +1 -1
- package/dist/node/generalHelpers.js +75 -79
- package/dist/node/generalHelpers.js.map +1 -1
- package/dist/node/get-subscription-info.js +7 -5
- package/dist/node/get-subscription-info.js.map +1 -1
- package/dist/node/getDeletableSolutionInfo.js +8 -12
- package/dist/node/getDeletableSolutionInfo.js.map +1 -1
- package/dist/node/getSolutionSummary.js +19 -23
- package/dist/node/getSolutionSummary.js.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +2 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/interfaces.d.ts +39 -1
- package/dist/node/interfaces.js.map +1 -1
- package/dist/node/libConnectors.js +8 -10
- package/dist/node/libConnectors.js.map +1 -1
- package/dist/node/migrations/apply-schema.js +4 -4
- package/dist/node/migrations/apply-schema.js.map +1 -1
- package/dist/node/migrations/is-legacy-solution.js +3 -3
- package/dist/node/migrations/is-legacy-solution.js.map +1 -1
- package/dist/node/migrations/upgrade-three-dot-one.js +5 -5
- package/dist/node/migrations/upgrade-three-dot-one.js.map +1 -1
- package/dist/node/migrations/upgrade-three-dot-zero.js +2 -2
- package/dist/node/migrations/upgrade-three-dot-zero.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-five.js +18 -9
- package/dist/node/migrations/upgrade-two-dot-five.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-four.js +13 -13
- package/dist/node/migrations/upgrade-two-dot-four.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-one.js +2 -2
- package/dist/node/migrations/upgrade-two-dot-one.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-seven.js +2 -2
- package/dist/node/migrations/upgrade-two-dot-seven.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-six.js +10 -13
- package/dist/node/migrations/upgrade-two-dot-six.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-three.js +5 -5
- package/dist/node/migrations/upgrade-two-dot-three.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-two.js +5 -5
- package/dist/node/migrations/upgrade-two-dot-two.js.map +1 -1
- package/dist/node/migrations/upgrade-two-dot-zero.js +9 -10
- package/dist/node/migrations/upgrade-two-dot-zero.js.map +1 -1
- package/dist/node/migrator.js +16 -18
- package/dist/node/migrator.js.map +1 -1
- package/dist/node/polyfills.js +5 -5
- package/dist/node/polyfills.js.map +1 -1
- package/dist/node/resourceHelpers.js +62 -65
- package/dist/node/resourceHelpers.js.map +1 -1
- package/dist/node/resources/add-resource-from-blob.js +4 -4
- package/dist/node/resources/add-resource-from-blob.js.map +1 -1
- package/dist/node/resources/addMetadataFromBlob.js +2 -2
- package/dist/node/resources/addMetadataFromBlob.js.map +1 -1
- package/dist/node/resources/convert-item-resource-to-storage-resource.js +6 -7
- package/dist/node/resources/convert-item-resource-to-storage-resource.js.map +1 -1
- package/dist/node/resources/convert-storage-resource-to-item-resource.js +9 -10
- package/dist/node/resources/convert-storage-resource-to-item-resource.js.map +1 -1
- package/dist/node/resources/copyAssociatedFiles.js +52 -61
- package/dist/node/resources/copyAssociatedFiles.js.map +1 -1
- package/dist/node/resources/copyDataIntoItem.js +9 -15
- package/dist/node/resources/copyDataIntoItem.js.map +1 -1
- package/dist/node/resources/copyMetadataIntoItem.js +7 -13
- package/dist/node/resources/copyMetadataIntoItem.js.map +1 -1
- package/dist/node/resources/copyResourceIntoZip.js +7 -9
- package/dist/node/resources/copyResourceIntoZip.js.map +1 -1
- package/dist/node/resources/copyZipIntoItem.js +8 -12
- package/dist/node/resources/copyZipIntoItem.js.map +1 -1
- package/dist/node/resources/createCopyResults.js +5 -2
- package/dist/node/resources/createCopyResults.js.map +1 -1
- package/dist/node/resources/get-blob.js +8 -6
- package/dist/node/resources/get-blob.js.map +1 -1
- package/dist/node/resources/getItemResourcesFilesFromPaths.js +8 -8
- package/dist/node/resources/getItemResourcesFilesFromPaths.js.map +1 -1
- package/dist/node/resources/getItemResourcesPaths.js +9 -10
- package/dist/node/resources/getItemResourcesPaths.js.map +1 -1
- package/dist/node/resources/index.js +1 -1
- package/dist/node/resources/transform-resource-paths-to-solution-resources.js +10 -11
- package/dist/node/resources/transform-resource-paths-to-solution-resources.js.map +1 -1
- package/dist/node/restHelpers.d.ts +65 -5
- package/dist/node/restHelpers.js +437 -285
- package/dist/node/restHelpers.js.map +1 -1
- package/dist/node/restHelpersGet.js +107 -116
- package/dist/node/restHelpersGet.js.map +1 -1
- package/dist/node/sharing/index.js +1 -1
- package/dist/node/sharing/share-item-to-groups.d.ts +2 -1
- package/dist/node/sharing/share-item-to-groups.js +13 -7
- package/dist/node/sharing/share-item-to-groups.js.map +1 -1
- package/dist/node/templatization.js +61 -37
- package/dist/node/templatization.js.map +1 -1
- package/dist/node/trackingHelpers.d.ts +116 -0
- package/dist/node/trackingHelpers.js +217 -0
- package/dist/node/trackingHelpers.js.map +1 -0
- package/dist/node/velocityHelpers.d.ts +2 -0
- package/dist/node/velocityHelpers.js +33 -15
- package/dist/node/velocityHelpers.js.map +1 -1
- package/dist/node/workforceHelpers.d.ts +11 -0
- package/dist/node/workforceHelpers.js +214 -185
- package/dist/node/workforceHelpers.js.map +1 -1
- package/dist/umd/common.umd.js +14830 -14466
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +3 -3
- package/dist/umd/common.umd.min.js.map +1 -1
- package/dist/umd/create-hub-request-options.d.ts +4 -4
- package/dist/umd/featureServiceHelpers.d.ts +6 -0
- package/dist/umd/index.d.ts +1 -0
- package/dist/umd/interfaces.d.ts +39 -1
- package/dist/umd/restHelpers.d.ts +65 -5
- package/dist/umd/sharing/share-item-to-groups.d.ts +2 -1
- package/dist/umd/trackingHelpers.d.ts +116 -0
- package/dist/umd/velocityHelpers.d.ts +2 -0
- package/dist/umd/workforceHelpers.d.ts +11 -0
- package/package.json +24 -24
|
@@ -35,32 +35,31 @@ import JSZip from "jszip";
|
|
|
35
35
|
* @param filesPerZip Number of files to include per zip file; AGO limits zips to 50 files
|
|
36
36
|
* @return A promise which resolves to a list of the result of the copies
|
|
37
37
|
*/
|
|
38
|
-
export function copyFilesAsResources(files, destinationItemId, destinationAuthentication, filesPerZip) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var zipInfos = [];
|
|
38
|
+
export function copyFilesAsResources(files, destinationItemId, destinationAuthentication, filesPerZip = 40) {
|
|
39
|
+
return new Promise(resolve => {
|
|
40
|
+
let awaitAllItems = [];
|
|
41
|
+
const zipInfos = [];
|
|
43
42
|
if (files.length > 0) {
|
|
44
43
|
// Bundle the resources into chunked zip updates because AGO tends to have problems with
|
|
45
44
|
// many updates in a row to the same item: it claims success despite randomly failing.
|
|
46
45
|
// Note that AGO imposes a limit of 50 files per zip, so we break the list of resource
|
|
47
46
|
// file info into chunks below this threshold and start a zip for each
|
|
48
47
|
// https://developers.arcgis.com/rest/users-groups-and-items/add-resources.htm
|
|
49
|
-
|
|
50
|
-
chunkedResourceFiles.forEach(
|
|
48
|
+
const chunkedResourceFiles = chunkArray(files, filesPerZip);
|
|
49
|
+
chunkedResourceFiles.forEach((chunk, index) => {
|
|
51
50
|
// Create a zip for this chunk
|
|
52
|
-
|
|
53
|
-
filename:
|
|
51
|
+
const zipInfo = {
|
|
52
|
+
filename: `resources${index}.zip`,
|
|
54
53
|
zip: new JSZip(),
|
|
55
54
|
filelist: []
|
|
56
55
|
};
|
|
57
|
-
awaitAllItems = awaitAllItems.concat(chunk.map(
|
|
56
|
+
awaitAllItems = awaitAllItems.concat(chunk.map(file => copyResourceIntoZip(file, zipInfo)));
|
|
58
57
|
zipInfos.push(zipInfo);
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
60
|
if (awaitAllItems.length > 0) {
|
|
62
61
|
// Wait until the Resource zip file(s) are prepared
|
|
63
|
-
void Promise.all(awaitAllItems).then(
|
|
62
|
+
void Promise.all(awaitAllItems).then((results) => {
|
|
64
63
|
// We have three types of results:
|
|
65
64
|
// | fetchedFromSource | copiedToDestination | interpretation | |
|
|
66
65
|
// +-------------------+---------------------+------------------------------------------------+
|
|
@@ -68,13 +67,11 @@ export function copyFilesAsResources(files, destinationItemId, destinationAuthen
|
|
|
68
67
|
// | true | true | file has been fetched and sent to AGO |
|
|
69
68
|
// | true | undefined | file has been fetched and will be sent via zip |
|
|
70
69
|
// Filter out copiedToDestination===undefined; we'll get their status when we send their zip
|
|
71
|
-
results = results.filter(
|
|
72
|
-
|
|
73
|
-
typeof result.copiedToDestination === "undefined");
|
|
74
|
-
});
|
|
70
|
+
results = results.filter((result) => !(result.fetchedFromSource &&
|
|
71
|
+
typeof result.copiedToDestination === "undefined"));
|
|
75
72
|
// Now send the resources to AGO
|
|
76
73
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
77
|
-
_copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication).then(
|
|
74
|
+
_copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication).then((zipResults) => {
|
|
78
75
|
resolve(results.concat(zipResults));
|
|
79
76
|
});
|
|
80
77
|
});
|
|
@@ -97,15 +94,13 @@ export function copyFilesAsResources(files, destinationItemId, destinationAuthen
|
|
|
97
94
|
* @return A promise which resolves to a list of the result of the copies
|
|
98
95
|
*/
|
|
99
96
|
export function copyAssociatedFilesByType(fileInfos, sourceAuthentication, destinationItemId, destinationAuthentication) {
|
|
100
|
-
return new Promise(
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
return new Promise(resolve => {
|
|
98
|
+
let awaitAllItems = [];
|
|
99
|
+
let resourceFileInfos = fileInfos;
|
|
103
100
|
awaitAllItems = fileInfos
|
|
104
|
-
.filter(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
})
|
|
108
|
-
.map(function (fileInfo) {
|
|
101
|
+
.filter(fileInfo => fileInfo.type === EFileType.Data ||
|
|
102
|
+
fileInfo.type === EFileType.Metadata)
|
|
103
|
+
.map(fileInfo => {
|
|
109
104
|
// Handle Data and Metadata first
|
|
110
105
|
switch (fileInfo.type) {
|
|
111
106
|
case EFileType.Data:
|
|
@@ -119,25 +114,23 @@ export function copyAssociatedFilesByType(fileInfos, sourceAuthentication, desti
|
|
|
119
114
|
}
|
|
120
115
|
});
|
|
121
116
|
// Now add in the Resources
|
|
122
|
-
resourceFileInfos = fileInfos.filter(
|
|
123
|
-
|
|
124
|
-
});
|
|
125
|
-
var zipInfos = [];
|
|
117
|
+
resourceFileInfos = fileInfos.filter(fileInfo => fileInfo.type === EFileType.Info || fileInfo.type === EFileType.Resource);
|
|
118
|
+
const zipInfos = [];
|
|
126
119
|
if (resourceFileInfos.length > 0) {
|
|
127
120
|
// Bundle the resources into chunked zip updates because AGO tends to have problems with
|
|
128
121
|
// many updates in a row to the same item: it claims success despite randomly failing.
|
|
129
122
|
// Note that AGO imposes a limit of 50 files per zip, so we break the list of resource
|
|
130
123
|
// file info into chunks below this threshold and start a zip for each
|
|
131
124
|
// https://developers.arcgis.com/rest/users-groups-and-items/add-resources.htm
|
|
132
|
-
|
|
133
|
-
chunkedResourceFileInfo.forEach(
|
|
125
|
+
const chunkedResourceFileInfo = chunkArray(resourceFileInfos, 40); // leave a bit of room below threshold
|
|
126
|
+
chunkedResourceFileInfo.forEach((chunk, index) => {
|
|
134
127
|
// Create a zip for this chunk
|
|
135
|
-
|
|
136
|
-
filename:
|
|
128
|
+
const zipInfo = {
|
|
129
|
+
filename: `resources${index}.zip`,
|
|
137
130
|
zip: new JSZip(),
|
|
138
131
|
filelist: []
|
|
139
132
|
};
|
|
140
|
-
awaitAllItems = awaitAllItems.concat(chunk.map(
|
|
133
|
+
awaitAllItems = awaitAllItems.concat(chunk.map(fileInfo => {
|
|
141
134
|
return copyResourceIntoZipFromInfo(fileInfo, sourceAuthentication, zipInfo);
|
|
142
135
|
}));
|
|
143
136
|
zipInfos.push(zipInfo);
|
|
@@ -145,7 +138,7 @@ export function copyAssociatedFilesByType(fileInfos, sourceAuthentication, desti
|
|
|
145
138
|
}
|
|
146
139
|
if (awaitAllItems.length > 0) {
|
|
147
140
|
// Wait until all Data and Metadata files have been copied and the Resource zip file(s) prepared
|
|
148
|
-
void Promise.all(awaitAllItems).then(
|
|
141
|
+
void Promise.all(awaitAllItems).then((results) => {
|
|
149
142
|
// We have three types of results:
|
|
150
143
|
// | fetchedFromSource | copiedToDestination | interpretation | |
|
|
151
144
|
// +-------------------+---------------------+------------------------------------------------+
|
|
@@ -153,13 +146,11 @@ export function copyAssociatedFilesByType(fileInfos, sourceAuthentication, desti
|
|
|
153
146
|
// | true | true | file has been fetched and sent to AGO |
|
|
154
147
|
// | true | undefined | file has been fetched and will be sent via zip |
|
|
155
148
|
// Filter out copiedToDestination===undefined; we'll get their status when we send their zip
|
|
156
|
-
results = results.filter(
|
|
157
|
-
|
|
158
|
-
typeof result.copiedToDestination === "undefined");
|
|
159
|
-
});
|
|
149
|
+
results = results.filter((result) => !(result.fetchedFromSource &&
|
|
150
|
+
typeof result.copiedToDestination === "undefined"));
|
|
160
151
|
// Now send the resources to AGO
|
|
161
152
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
162
|
-
_copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication).then(
|
|
153
|
+
_copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication).then((zipResults) => {
|
|
163
154
|
resolve(results.concat(zipResults));
|
|
164
155
|
});
|
|
165
156
|
});
|
|
@@ -179,14 +170,14 @@ export function copyAssociatedFilesByType(fileInfos, sourceAuthentication, desti
|
|
|
179
170
|
* @return A promise which resolves to a list of the result of the copies
|
|
180
171
|
*/
|
|
181
172
|
export function _copyAssociatedFileZips(zipInfos, destinationItemId, destinationAuthentication) {
|
|
182
|
-
return new Promise(
|
|
183
|
-
|
|
173
|
+
return new Promise(resolve => {
|
|
174
|
+
const results = [];
|
|
184
175
|
// Filter out empty zips, which can happen when none of the files in the chunk going into a zip
|
|
185
176
|
// can be fetched; e.g., the only file is metadata.xml, and the source item doesn't have metadata
|
|
186
|
-
|
|
177
|
+
const nonEmptyZipInfos = zipInfos.filter((zipInfo) => Object.keys(zipInfo.zip.files).length > 0);
|
|
187
178
|
if (nonEmptyZipInfos.length > 0) {
|
|
188
179
|
// Send the zip(s) to AGO
|
|
189
|
-
void _sendZipsSeriallyToItem(nonEmptyZipInfos, destinationItemId, destinationAuthentication).then(
|
|
180
|
+
void _sendZipsSeriallyToItem(nonEmptyZipInfos, destinationItemId, destinationAuthentication).then((zipResults) => {
|
|
190
181
|
resolve(zipResults);
|
|
191
182
|
});
|
|
192
183
|
}
|
|
@@ -205,30 +196,30 @@ export function _copyAssociatedFileZips(zipInfos, destinationItemId, destination
|
|
|
205
196
|
* @return A promise which resolves to a list of the result of the copies
|
|
206
197
|
*/
|
|
207
198
|
function _sendZipsSeriallyToItem(zipInfos, destinationItemId, destinationAuthentication) {
|
|
208
|
-
return new Promise(
|
|
209
|
-
|
|
199
|
+
return new Promise(resolve => {
|
|
200
|
+
let allResults = [];
|
|
210
201
|
// Remove zip from bottom of list
|
|
211
|
-
|
|
202
|
+
const zipInfoToSend = zipInfos.pop();
|
|
212
203
|
// Send predecessors in list
|
|
213
|
-
|
|
204
|
+
let sendOthersPromise = Promise.resolve([]);
|
|
214
205
|
if (zipInfos.length > 0) {
|
|
215
206
|
sendOthersPromise = _sendZipsSeriallyToItem(zipInfos, destinationItemId, destinationAuthentication);
|
|
216
207
|
}
|
|
217
208
|
void sendOthersPromise
|
|
218
|
-
.then(
|
|
209
|
+
.then((response) => {
|
|
219
210
|
allResults = response;
|
|
220
211
|
// Stall a little to give AGO time to catch up
|
|
221
|
-
return new Promise(
|
|
222
|
-
setTimeout(
|
|
212
|
+
return new Promise(resolveSleep => {
|
|
213
|
+
setTimeout(() => resolveSleep(), 1000);
|
|
223
214
|
});
|
|
224
215
|
})
|
|
225
|
-
.then(
|
|
216
|
+
.then(() => {
|
|
226
217
|
// Now send the zip removed from bottom of the input list
|
|
227
218
|
return copyZipIntoItem(zipInfoToSend, destinationItemId, destinationAuthentication);
|
|
228
219
|
})
|
|
229
|
-
.then(
|
|
220
|
+
.then((zipResult) => {
|
|
230
221
|
// Save the result of copying this zip as a status for each of the files that it contains
|
|
231
|
-
zipResult.filelist.forEach(
|
|
222
|
+
zipResult.filelist.forEach((fileInfo) => {
|
|
232
223
|
allResults.push(createCopyResults(fileInfo, true, zipResult.copiedToDestination));
|
|
233
224
|
});
|
|
234
225
|
resolve(allResults);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyAssociatedFiles.js","sourceRoot":"","sources":["../../../src/resources/copyAssociatedFiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;GAEG;AAEH,OAAO,EACL,SAAS,EAOV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wHAAwH;AAExH;;;;;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8CAA8C;YAC9C,OAAO,IAAI,OAAO,CAAO,YAAY,CAAC,EAAE;gBACtC,UAAU,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,EAAE,IAAI,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,EAAE;YACT,yDAAyD;YACzD,OAAO,eAAe,CACpB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,CAC1B,CAAC;QACJ,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,SAA0B,EAAE,EAAE;YACnC,yFAAyF;YACzF,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,QAA6B,EAAE,EAAE;gBAC3D,UAAU,CAAC,IAAI,CACb,iBAAiB,CACf,QAAQ,EACR,IAAI,EACJ,SAAS,CAAC,mBAAmB,CACA,CAChC,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,UAAU,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -28,9 +28,9 @@ import { updateItem as helpersUpdateItem } from "../restHelpers";
|
|
|
28
28
|
* @return A promise which resolves to the result of the copy
|
|
29
29
|
*/
|
|
30
30
|
export function copyDataIntoItem(fileInfo, sourceAuthentication, destinationItemId, destinationAuthentication) {
|
|
31
|
-
return new Promise(
|
|
32
|
-
getBlob(fileInfo.url, sourceAuthentication).then(
|
|
33
|
-
|
|
31
|
+
return new Promise(resolve => {
|
|
32
|
+
getBlob(fileInfo.url, sourceAuthentication).then(blob => {
|
|
33
|
+
const update = {
|
|
34
34
|
id: destinationItemId,
|
|
35
35
|
data: createMimeTypedFile({
|
|
36
36
|
blob: blob,
|
|
@@ -38,15 +38,9 @@ export function copyDataIntoItem(fileInfo, sourceAuthentication, destinationItem
|
|
|
38
38
|
mimeType: fileInfo.mimeType || blob.type
|
|
39
39
|
})
|
|
40
40
|
};
|
|
41
|
-
helpersUpdateItem(update, destinationAuthentication, fileInfo.folder).then(
|
|
42
|
-
return resolve(createCopyResults(fileInfo, true, true));
|
|
43
|
-
}, function () {
|
|
44
|
-
return resolve(createCopyResults(fileInfo, true, false));
|
|
45
|
-
} // unable to add resource
|
|
41
|
+
helpersUpdateItem(update, destinationAuthentication, fileInfo.folder).then(() => resolve(createCopyResults(fileInfo, true, true)), () => resolve(createCopyResults(fileInfo, true, false)) // unable to add resource
|
|
46
42
|
);
|
|
47
|
-
},
|
|
48
|
-
return resolve(createCopyResults(fileInfo, false));
|
|
49
|
-
} // unable to get resource
|
|
43
|
+
}, () => resolve(createCopyResults(fileInfo, false)) // unable to get resource
|
|
50
44
|
);
|
|
51
45
|
});
|
|
52
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyDataIntoItem.js","sourceRoot":"","sources":["../../../src/resources/copyDataIntoItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA6B,EAC7B,oBAAiC,EACjC,iBAAyB,EACzB,yBAAsC;IAEtC,OAAO,IAAI,OAAO,CAA6B,
|
|
1
|
+
{"version":3,"file":"copyDataIntoItem.js","sourceRoot":"","sources":["../../../src/resources/copyDataIntoItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OA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,15 @@ import { getBlob } from "./get-blob";
|
|
|
27
27
|
* @return A promise which resolves to the result of the copy
|
|
28
28
|
*/
|
|
29
29
|
export function copyMetadataIntoItem(fileInfo, sourceAuthentication, destinationItemId, destinationAuthentication) {
|
|
30
|
-
return new Promise(
|
|
31
|
-
getBlob(fileInfo.url, sourceAuthentication).then(
|
|
30
|
+
return new Promise(resolve => {
|
|
31
|
+
getBlob(fileInfo.url, sourceAuthentication).then(blob => {
|
|
32
32
|
if (blob.type !== "text/xml" && blob.type !== "application/xml") {
|
|
33
33
|
resolve(createCopyResults(fileInfo, false)); // unable to get resource
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
addMetadataFromBlob(blob, destinationItemId, destinationAuthentication).then(
|
|
37
|
-
return resolve(createCopyResults(fileInfo, true, true));
|
|
38
|
-
}, function () {
|
|
39
|
-
return resolve(createCopyResults(fileInfo, true, false));
|
|
40
|
-
} // unable to add resource
|
|
36
|
+
addMetadataFromBlob(blob, destinationItemId, destinationAuthentication).then(() => resolve(createCopyResults(fileInfo, true, true)), () => resolve(createCopyResults(fileInfo, true, false)) // unable to add resource
|
|
41
37
|
);
|
|
42
|
-
},
|
|
43
|
-
return resolve(createCopyResults(fileInfo, false));
|
|
44
|
-
} // unable to get resource
|
|
38
|
+
}, () => resolve(createCopyResults(fileInfo, false)) // unable to get resource
|
|
45
39
|
);
|
|
46
40
|
});
|
|
47
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyMetadataIntoItem.js","sourceRoot":"","sources":["../../../src/resources/copyMetadataIntoItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAA6B,EAC7B,oBAAiC,EACjC,iBAAyB,EACzB,yBAAsC;IAEtC,OAAO,IAAI,OAAO,CAA6B,
|
|
1
|
+
{"version":3,"file":"copyMetadataIntoItem.js","sourceRoot":"","sources":["../../../src/resources/copyMetadataIntoItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAA6B,EAC7B,oBAAiC,EACjC,iBAAyB,EACzB,yBAAsC;IAEtC,OAAO,IAAI,OAAO,CAA6B,OAAO,CAAC,EAAE;QACvD,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAC9C,IAAI,CAAC,EAAE;YACL,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE;gBAC/D,OAAO,CACL,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAA+B,CACjE,CAAC,CAAC,yBAAyB;gBAC5B,OAAO;aACR;YACD,mBAAmB,CACjB,IAAI,EACJ,iBAAiB,EACjB,yBAAyB,CAC1B,CAAC,IAAI,CACJ,GAAG,EAAE,CACH,OAAO,CACL,iBAAiB,CACf,QAAQ,EACR,IAAI,EACJ,IAAI,CACyB,CAChC,EACH,GAAG,EAAE,CACH,OAAO,CACL,iBAAiB,CACf,QAAQ,EACR,IAAI,EACJ,KAAK,CACwB,CAChC,CAAC,yBAAyB;aAC9B,CAAC;QACJ,CAAC,EACD,GAAG,EAAE,CACH,OAAO,CACL,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAA+B,CACjE,CAAC,yBAAyB;SAC9B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -45,8 +45,8 @@ export function copyResourceIntoZip(file, zipInfo) {
|
|
|
45
45
|
* @return A promise which resolves to the result of the copy
|
|
46
46
|
*/
|
|
47
47
|
export function copyResourceIntoZipFromInfo(fileInfo, sourceAuthentication, zipInfo) {
|
|
48
|
-
return new Promise(
|
|
49
|
-
getBlobAsFile(fileInfo.url, fileInfo.filename, sourceAuthentication).then(
|
|
48
|
+
return new Promise(resolve => {
|
|
49
|
+
getBlobAsFile(fileInfo.url, fileInfo.filename, sourceAuthentication).then((file) => {
|
|
50
50
|
// And add it to the zip
|
|
51
51
|
if (fileInfo.folder) {
|
|
52
52
|
zipInfo.zip
|
|
@@ -58,11 +58,9 @@ export function copyResourceIntoZipFromInfo(fileInfo, sourceAuthentication, zipI
|
|
|
58
58
|
}
|
|
59
59
|
zipInfo.filelist.push(fileInfo);
|
|
60
60
|
resolve(createCopyResults(fileInfo, true));
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
createCopyResults(fileInfo, false));
|
|
65
|
-
});
|
|
61
|
+
}, () => resolve(
|
|
62
|
+
// unable to get resource
|
|
63
|
+
createCopyResults(fileInfo, false)));
|
|
66
64
|
});
|
|
67
65
|
}
|
|
68
66
|
//# sourceMappingURL=copyResourceIntoZip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyResourceIntoZip.js","sourceRoot":"","sources":["../../../src/resources/copyResourceIntoZip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AASH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,wHAAwH;AAExH;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAiB,EACjB,OAAiB;IAEjB,oBAAoB;IACpB,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,OAAO,C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AAC,CAAC;KAC9D;IACD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAA+B,CAAC;AACrE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAA6B,EAC7B,oBAAiC,EACjC,OAAiB;IAEjB,OAAO,IAAI,OAAO,CAA6B,OAAO,CAAC,EAAE;QACvD,aAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC,IAAI,CACvE,CAAC,IAAS,EAAE,EAAE;YACZ,wBAAwB;YACxB,IAAI,QAAQ,CAAC,MAAM,EAAE;gBACnB,OAAO,CAAC,GAAG;qBACR,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;qBACvB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACpD;iBAAM;gBACL,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aAC7D;YACD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAChC,OAAO,CACL,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAA+B,CAChE,CAAC;QACJ,CAAC,EACD,GAAG,EAAE,CACH,OAAO;QACL,yBAAyB;QACzB,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAA+B,CACjE,CACJ,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -26,14 +26,14 @@ import { createCopyResults } from "./createCopyResults";
|
|
|
26
26
|
* @return A promise which resolves to the result of the copy
|
|
27
27
|
*/
|
|
28
28
|
export function copyZipIntoItem(zipInfo, destinationItemId, destinationAuthentication) {
|
|
29
|
-
return new Promise(
|
|
29
|
+
return new Promise(resolve => {
|
|
30
30
|
zipInfo.zip
|
|
31
31
|
.generateAsync({ type: "blob" })
|
|
32
|
-
.then(
|
|
32
|
+
.then((content) => {
|
|
33
33
|
return blobToFile(content, zipInfo.filename, "application/zip");
|
|
34
34
|
})
|
|
35
|
-
.then(
|
|
36
|
-
|
|
35
|
+
.then((zipfile) => {
|
|
36
|
+
const addResourceOptions = {
|
|
37
37
|
id: destinationItemId,
|
|
38
38
|
resource: zipfile,
|
|
39
39
|
authentication: destinationAuthentication,
|
|
@@ -43,11 +43,7 @@ export function copyZipIntoItem(zipInfo, destinationItemId, destinationAuthentic
|
|
|
43
43
|
};
|
|
44
44
|
return addItemResource(addResourceOptions);
|
|
45
45
|
})
|
|
46
|
-
.then(
|
|
47
|
-
return resolve(createCopyResults(zipInfo, true, true));
|
|
48
|
-
}, function () {
|
|
49
|
-
return resolve(createCopyResults(zipInfo, true, false));
|
|
50
|
-
} // unable to add resource
|
|
46
|
+
.then(() => resolve(createCopyResults(zipInfo, true, true)), () => resolve(createCopyResults(zipInfo, true, false)) // unable to add resource
|
|
51
47
|
);
|
|
52
48
|
});
|
|
53
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyZipIntoItem.js","sourceRoot":"","sources":["../../../src/resources/copyZipIntoItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAEL,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,wHAAwH;AAExH;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAiB,EACjB,iBAAyB,EACzB,yBAAsC;IAEtC,OAAO,IAAI,OAAO,CAAkB,
|
|
1
|
+
{"version":3,"file":"copyZipIntoItem.js","sourceRoot":"","sources":["../../../src/resources/copyZipIntoItem.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAEL,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,wHAAwH;AAExH;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAiB,EACjB,iBAAyB,EACzB,yBAAsC;IAEtC,OAAO,IAAI,OAAO,CAAkB,OAAO,CAAC,EAAE;QAC5C,OAAO,CAAC,GAAG;aACR,aAAa,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;aAC/B,IAAI,CAAC,CAAC,OAAa,EAAE,EAAE;YACtB,OAAO,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QAClE,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,OAAa,EAAE,EAAE;YACtB,MAAM,kBAAkB,GAAyB;gBAC/C,EAAE,EAAE,iBAAiB;gBACrB,QAAQ,EAAE,OAAO;gBACjB,cAAc,EAAE,yBAAyB;gBACzC,MAAM,EAAE;oBACN,OAAO,EAAE,IAAI;iBACd;aACF,CAAC;YACF,OAAO,eAAe,CAAC,kBAAkB,CAAC,CAAC;QAC7C,CAAC,CAAC;aACD,IAAI,CACH,GAAG,EAAE,CACH,OAAO,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAoB,CAAC,EACpE,GAAG,EAAE,CACH,OAAO,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAoB,CAAC,CAAC,yBAAyB;SAChG,CAAC;IACN,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { __assign } from "tslib";
|
|
17
16
|
// ------------------------------------------------------------------------------------------------------------------ //
|
|
18
17
|
/**
|
|
19
18
|
* Generates IAssociatedFileCopyResults object.
|
|
@@ -24,6 +23,10 @@ import { __assign } from "tslib";
|
|
|
24
23
|
* @return IAssociatedFileCopyResults object
|
|
25
24
|
*/
|
|
26
25
|
export function createCopyResults(fileInfo, fetchedFromSource, copiedToDestination) {
|
|
27
|
-
return
|
|
26
|
+
return {
|
|
27
|
+
...fileInfo,
|
|
28
|
+
fetchedFromSource,
|
|
29
|
+
copiedToDestination
|
|
30
|
+
};
|
|
28
31
|
}
|
|
29
32
|
//# sourceMappingURL=createCopyResults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCopyResults.js","sourceRoot":"","sources":["../../../src/resources/createCopyResults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"createCopyResults.js","sourceRoot":"","sources":["../../../src/resources/createCopyResults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,wHAAwH;AAExH;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAa,EACb,iBAA0B,EAC1B,mBAA6B;IAE7B,OAAO;QACL,GAAG,QAAQ;QACX,iBAAiB;QACjB,mBAAmB;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { request } from "@esri/arcgis-rest-request";
|
|
3
2
|
/**
|
|
4
3
|
* Gets a Blob from a web site.
|
|
@@ -8,13 +7,16 @@ import { request } from "@esri/arcgis-rest-request";
|
|
|
8
7
|
* @param requestOptions - Options for the request, including parameters relevant to the endpoint.
|
|
9
8
|
* @return Promise that will resolve with Blob or an AGO-style JSON failure response
|
|
10
9
|
*/
|
|
11
|
-
export function getBlob(url, authentication, requestOptions) {
|
|
12
|
-
if (requestOptions === void 0) { requestOptions = {}; }
|
|
10
|
+
export function getBlob(url, authentication, requestOptions = {}) {
|
|
13
11
|
if (!url) {
|
|
14
12
|
return Promise.reject("Url must be provided");
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const blobRequestOptions = {
|
|
15
|
+
authentication: authentication,
|
|
16
|
+
rawResponse: true,
|
|
17
|
+
...requestOptions
|
|
18
|
+
};
|
|
19
|
+
return request(url, blobRequestOptions).then(response => {
|
|
18
20
|
return response.blob();
|
|
19
21
|
});
|
|
20
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-blob.js","sourceRoot":"","sources":["../../../src/resources/get-blob.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-blob.js","sourceRoot":"","sources":["../../../src/resources/get-blob.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,OAAO,EAAmB,MAAM,2BAA2B,CAAC;AACrE;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO,CACrB,GAAW,EACX,cAA2B,EAC3B,iBAAkC,EAAE;IAEpC,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;KAC/C;IAED,MAAM,kBAAkB,GAAG;QACzB,cAAc,EAAE,cAAc;QAC9B,WAAW,EAAE,IAAI;QACjB,GAAG,cAAc;KACC,CAAC;IAErB,OAAO,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACtD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -24,22 +24,22 @@ import { getBlobAsFile } from "../restHelpersGet";
|
|
|
24
24
|
*/
|
|
25
25
|
export function getItemResourcesFilesFromPaths(resourceItemFilePaths, authentication) {
|
|
26
26
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
27
|
-
return Promise.all(resourceItemFilePaths.map(
|
|
28
|
-
return new Promise(
|
|
29
|
-
getBlobAsFile(fileInfo.url, fileInfo.filename, authentication).then(
|
|
27
|
+
return Promise.all(resourceItemFilePaths.map(fileInfo => {
|
|
28
|
+
return new Promise(resolve => {
|
|
29
|
+
getBlobAsFile(fileInfo.url, fileInfo.filename, authentication).then(file => {
|
|
30
30
|
resolve({
|
|
31
31
|
itemId: fileInfo.itemId,
|
|
32
|
-
file
|
|
32
|
+
file,
|
|
33
33
|
folder: fileInfo.folder,
|
|
34
34
|
filename: fileInfo.filename
|
|
35
35
|
});
|
|
36
|
-
},
|
|
36
|
+
}, () => {
|
|
37
37
|
resolve(null);
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
|
-
})).then(
|
|
40
|
+
})).then((files) => {
|
|
41
41
|
// Discard failures
|
|
42
|
-
return files.filter(
|
|
42
|
+
return files.filter(file => !!file);
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
//# sourceMappingURL=getItemResourcesFilesFromPaths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getItemResourcesFilesFromPaths.js","sourceRoot":"","sources":["../../../src/resources/getItemResourcesFilesFromPaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,wHAAwH;AAExH;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC5C,qBAA4C,EAC5C,cAA2B;IAE3B,mEAAmE;IACnE,OAAO,OAAO,CAAC,GAAG,CAChB,qBAAqB,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"getItemResourcesFilesFromPaths.js","sourceRoot":"","sources":["../../../src/resources/getItemResourcesFilesFromPaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,wHAAwH;AAExH;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC5C,qBAA4C,EAC5C,cAA2B;IAE3B,mEAAmE;IACnE,OAAO,OAAO,CAAC,GAAG,CAChB,qBAAqB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;QACnC,OAAO,IAAI,OAAO,CAAc,OAAO,CAAC,EAAE;YACxC,aAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,IAAI,CACjE,IAAI,CAAC,EAAE;gBACL,OAAO,CAAC;oBACN,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,IAAI;oBACJ,MAAM,EAAE,QAAQ,CAAC,MAAM;oBACvB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;iBACb,CAAC,CAAC;YACpB,CAAC,EACD,GAAG,EAAE;gBACH,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CACH,CAAC,IAAI,CAAC,CAAC,KAAoB,EAAE,EAAE;QAC9B,mBAAmB;QACnB,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -25,16 +25,15 @@ import { generateSourceFilePaths } from "../resourceHelpers";
|
|
|
25
25
|
* @param storageVersion Version of the Solution template
|
|
26
26
|
* @return A promise which resolves with an array of paths to resources for the item
|
|
27
27
|
*/
|
|
28
|
-
export function getItemResourcesPaths(itemTemplate, solutionItemId, authentication, storageVersion) {
|
|
29
|
-
if (storageVersion === void 0) { storageVersion = 0; }
|
|
28
|
+
export function getItemResourcesPaths(itemTemplate, solutionItemId, authentication, storageVersion = 0) {
|
|
30
29
|
// get the resources for the item
|
|
31
|
-
return getItemResources(itemTemplate.itemId, authentication).then(
|
|
30
|
+
return getItemResources(itemTemplate.itemId, authentication).then(resourceResponse => {
|
|
32
31
|
// map out the resource names and filter for things we
|
|
33
32
|
// don't want transferred at this time
|
|
34
|
-
|
|
35
|
-
.map(
|
|
36
|
-
.filter(
|
|
37
|
-
|
|
33
|
+
const itemResources = resourceResponse.resources
|
|
34
|
+
.map((r) => r.resource)
|
|
35
|
+
.filter((res) => {
|
|
36
|
+
let result = true;
|
|
38
37
|
// StoryMaps has a set of resources that must be interpolated and can not be
|
|
39
38
|
// directly copied, so they must be filtered out. Sub-optimal as it spreads
|
|
40
39
|
// type specific logic around the app, but until we refactor how resources
|
|
@@ -56,7 +55,7 @@ export function getItemResourcesPaths(itemTemplate, solutionItemId, authenticati
|
|
|
56
55
|
return result;
|
|
57
56
|
});
|
|
58
57
|
// create the filePaths
|
|
59
|
-
|
|
58
|
+
const resourceItemFilePaths = generateSourceFilePaths(authentication.portal, itemTemplate.itemId, itemTemplate.item.thumbnail, itemResources, itemTemplate.type === "Group", storageVersion);
|
|
60
59
|
return Promise.resolve(resourceItemFilePaths);
|
|
61
60
|
});
|
|
62
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getItemResourcesPaths.js","sourceRoot":"","sources":["../../../src/resources/getItemResourcesPaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,UAAU,qBAAqB,CACnC,YAA2B,EAC3B,cAAsB,EACtB,cAA2B,EAC3B,
|
|
1
|
+
{"version":3,"file":"getItemResourcesPaths.js","sourceRoot":"","sources":["../../../src/resources/getItemResourcesPaths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAG7D,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,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ChD,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -22,8 +22,7 @@ import { isGuid } from "@esri/hub-common";
|
|
|
22
22
|
*
|
|
23
23
|
* @param resourceStrings Array of resource paths
|
|
24
24
|
*/
|
|
25
|
-
export function transformResourcePathsToSolutionResources(resourceStrings) {
|
|
26
|
-
if (resourceStrings === void 0) { resourceStrings = []; }
|
|
25
|
+
export function transformResourcePathsToSolutionResources(resourceStrings = []) {
|
|
27
26
|
return resourceStrings.map(transformResourcePathToSolutionResource);
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
@@ -45,12 +44,12 @@ export function transformResourcePathToSolutionResource(resourcePath) {
|
|
|
45
44
|
* @param resourcePath String
|
|
46
45
|
*/
|
|
47
46
|
export function _getSolutionResourceTypeFromResourcePath(resourcePath) {
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
let type = SolutionResourceType.resource;
|
|
48
|
+
const folder = resourcePath
|
|
50
49
|
.split("/")
|
|
51
50
|
.slice(0, -1)
|
|
52
51
|
.join("/") || "";
|
|
53
|
-
PATH_TO_TYPE_MAP.forEach(
|
|
52
|
+
PATH_TO_TYPE_MAP.forEach(entry => {
|
|
54
53
|
if (folder.endsWith(entry.ending)) {
|
|
55
54
|
type = entry.type;
|
|
56
55
|
}
|
|
@@ -61,7 +60,7 @@ export function _getSolutionResourceTypeFromResourcePath(resourcePath) {
|
|
|
61
60
|
* Mapping of strings that have been appended to the resource path to
|
|
62
61
|
* encode the resource type
|
|
63
62
|
*/
|
|
64
|
-
|
|
63
|
+
const PATH_TO_TYPE_MAP = [
|
|
65
64
|
{ ending: "_info_thumbnail", type: SolutionResourceType.thumbnail },
|
|
66
65
|
{ ending: "_info_metadata", type: SolutionResourceType.metadata },
|
|
67
66
|
{ ending: "_info_data", type: SolutionResourceType.data },
|
|
@@ -104,16 +103,16 @@ export function _extractFilenameFromResourcePath(path) {
|
|
|
104
103
|
*/
|
|
105
104
|
export function _extractPathFromResourcePath(resourcePath) {
|
|
106
105
|
// default case
|
|
107
|
-
|
|
106
|
+
let path = "";
|
|
108
107
|
// parse up the path by splittins on `/` and dropping the last segment
|
|
109
|
-
|
|
108
|
+
const parsedPath = resourcePath
|
|
110
109
|
.split("/")
|
|
111
110
|
.slice(0, -1)
|
|
112
111
|
.join("/") || "";
|
|
113
112
|
// if we got something...
|
|
114
113
|
if (parsedPath) {
|
|
115
114
|
// now we need to see if this has any of the well-known endings
|
|
116
|
-
|
|
115
|
+
const isWellKnownPath = PATH_TO_TYPE_MAP.reduce((acc, entry) => {
|
|
117
116
|
if (parsedPath.endsWith(entry.ending)) {
|
|
118
117
|
acc = true;
|
|
119
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-resource-paths-to-solution-resources.js","sourceRoot":"","sources":["../../../src/resources/transform-resource-paths-to-solution-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAqB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C;;;;;;GAMG;AACH,MAAM,UAAU,yCAAyC,CACvD,
|
|
1
|
+
{"version":3,"file":"transform-resource-paths-to-solution-resources.js","sourceRoot":"","sources":["../../../src/resources/transform-resource-paths-to-solution-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAqB,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C;;;;;;GAMG;AACH,MAAM,UAAU,yCAAyC,CACvD,kBAA4B,EAAE;IAE9B,OAAO,eAAe,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;AACtE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uCAAuC,CACrD,YAAoB;IAEpB,OAAO;QACL,QAAQ,EAAE,gCAAgC,CAAC,YAAY,CAAC;QACxD,IAAI,EAAE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