@esri/solution-common 5.2.1 → 5.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/README.md +4 -7
  2. package/dist/esm/completeItem.js +3 -3
  3. package/dist/esm/completeItem.js.map +1 -1
  4. package/dist/esm/formHelpers.d.ts +41 -0
  5. package/dist/esm/formHelpers.js +71 -0
  6. package/dist/esm/formHelpers.js.map +1 -0
  7. package/dist/esm/generalHelpers.d.ts +33 -0
  8. package/dist/esm/generalHelpers.js +44 -1
  9. package/dist/esm/generalHelpers.js.map +1 -1
  10. package/dist/esm/index.d.ts +2 -0
  11. package/dist/esm/index.js +2 -0
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/interfaces.d.ts +19 -1
  14. package/dist/esm/interfaces.js.map +1 -1
  15. package/dist/esm/restHelpers.d.ts +10 -1
  16. package/dist/esm/restHelpers.js +25 -1
  17. package/dist/esm/restHelpers.js.map +1 -1
  18. package/dist/esm/templatization.js +5 -3
  19. package/dist/esm/templatization.js.map +1 -1
  20. package/dist/esm/workflowHelpers.d.ts +21 -1
  21. package/dist/esm/workflowHelpers.js +48 -48
  22. package/dist/esm/workflowHelpers.js.map +1 -1
  23. package/dist/esm/zip-utils.d.ts +44 -17
  24. package/dist/esm/zip-utils.js +73 -24
  25. package/dist/esm/zip-utils.js.map +1 -1
  26. package/package.json +3 -3
  27. package/dist/cjs/completeItem.d.ts +0 -29
  28. package/dist/cjs/completeItem.js +0 -92
  29. package/dist/cjs/completeItem.js.map +0 -1
  30. package/dist/cjs/create-hub-request-options.d.ts +0 -29
  31. package/dist/cjs/create-hub-request-options.js +0 -64
  32. package/dist/cjs/create-hub-request-options.js.map +0 -1
  33. package/dist/cjs/deleteHelpers/deleteEmptyGroups.d.ts +0 -24
  34. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js +0 -42
  35. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js.map +0 -1
  36. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.d.ts +0 -27
  37. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js +0 -97
  38. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js.map +0 -1
  39. package/dist/cjs/deleteHelpers/deleteSolutionContents.d.ts +0 -38
  40. package/dist/cjs/deleteHelpers/deleteSolutionContents.js +0 -130
  41. package/dist/cjs/deleteHelpers/deleteSolutionContents.js.map +0 -1
  42. package/dist/cjs/deleteHelpers/deleteSolutionFolder.d.ts +0 -29
  43. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js +0 -79
  44. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js.map +0 -1
  45. package/dist/cjs/deleteHelpers/deleteSolutionItem.d.ts +0 -30
  46. package/dist/cjs/deleteHelpers/deleteSolutionItem.js +0 -54
  47. package/dist/cjs/deleteHelpers/deleteSolutionItem.js.map +0 -1
  48. package/dist/cjs/deleteHelpers/index.d.ts +0 -22
  49. package/dist/cjs/deleteHelpers/index.js +0 -26
  50. package/dist/cjs/deleteHelpers/index.js.map +0 -1
  51. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.d.ts +0 -27
  52. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js +0 -34
  53. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js.map +0 -1
  54. package/dist/cjs/deleteHelpers/removeItems.d.ts +0 -34
  55. package/dist/cjs/deleteHelpers/removeItems.js +0 -112
  56. package/dist/cjs/deleteHelpers/removeItems.js.map +0 -1
  57. package/dist/cjs/deleteHelpers/reportProgress.d.ts +0 -27
  58. package/dist/cjs/deleteHelpers/reportProgress.js +0 -46
  59. package/dist/cjs/deleteHelpers/reportProgress.js.map +0 -1
  60. package/dist/cjs/deleteSolution.d.ts +0 -55
  61. package/dist/cjs/deleteSolution.js +0 -107
  62. package/dist/cjs/deleteSolution.js.map +0 -1
  63. package/dist/cjs/dependencies.d.ts +0 -26
  64. package/dist/cjs/dependencies.js +0 -171
  65. package/dist/cjs/dependencies.js.map +0 -1
  66. package/dist/cjs/featureServiceHelpers.d.ts +0 -799
  67. package/dist/cjs/featureServiceHelpers.js +0 -2438
  68. package/dist/cjs/featureServiceHelpers.js.map +0 -1
  69. package/dist/cjs/generalHelpers.d.ts +0 -400
  70. package/dist/cjs/generalHelpers.js +0 -877
  71. package/dist/cjs/generalHelpers.js.map +0 -1
  72. package/dist/cjs/get-subscription-info.d.ts +0 -27
  73. package/dist/cjs/get-subscription-info.js +0 -39
  74. package/dist/cjs/get-subscription-info.js.map +0 -1
  75. package/dist/cjs/getDeletableSolutionInfo.d.ts +0 -29
  76. package/dist/cjs/getDeletableSolutionInfo.js +0 -53
  77. package/dist/cjs/getDeletableSolutionInfo.js.map +0 -1
  78. package/dist/cjs/getItemTypeAbbrev.d.ts +0 -19
  79. package/dist/cjs/getItemTypeAbbrev.js +0 -186
  80. package/dist/cjs/getItemTypeAbbrev.js.map +0 -1
  81. package/dist/cjs/getSolutionSummary.d.ts +0 -27
  82. package/dist/cjs/getSolutionSummary.js +0 -101
  83. package/dist/cjs/getSolutionSummary.js.map +0 -1
  84. package/dist/cjs/index.d.ts +0 -44
  85. package/dist/cjs/index.js +0 -48
  86. package/dist/cjs/index.js.map +0 -1
  87. package/dist/cjs/interfaces.d.ts +0 -1344
  88. package/dist/cjs/interfaces.js +0 -77
  89. package/dist/cjs/interfaces.js.map +0 -1
  90. package/dist/cjs/libConnectors.d.ts +0 -73
  91. package/dist/cjs/libConnectors.js +0 -115
  92. package/dist/cjs/libConnectors.js.map +0 -1
  93. package/dist/cjs/migrations/apply-schema.d.ts +0 -24
  94. package/dist/cjs/migrations/apply-schema.js +0 -36
  95. package/dist/cjs/migrations/apply-schema.js.map +0 -1
  96. package/dist/cjs/migrations/is-legacy-solution.d.ts +0 -24
  97. package/dist/cjs/migrations/is-legacy-solution.js +0 -40
  98. package/dist/cjs/migrations/is-legacy-solution.js.map +0 -1
  99. package/dist/cjs/migrations/upgrade-three-dot-one.d.ts +0 -27
  100. package/dist/cjs/migrations/upgrade-three-dot-one.js +0 -49
  101. package/dist/cjs/migrations/upgrade-three-dot-one.js.map +0 -1
  102. package/dist/cjs/migrations/upgrade-three-dot-zero.d.ts +0 -27
  103. package/dist/cjs/migrations/upgrade-three-dot-zero.js +0 -43
  104. package/dist/cjs/migrations/upgrade-three-dot-zero.js.map +0 -1
  105. package/dist/cjs/migrations/upgrade-two-dot-five.d.ts +0 -24
  106. package/dist/cjs/migrations/upgrade-two-dot-five.js +0 -73
  107. package/dist/cjs/migrations/upgrade-two-dot-five.js.map +0 -1
  108. package/dist/cjs/migrations/upgrade-two-dot-four.d.ts +0 -24
  109. package/dist/cjs/migrations/upgrade-two-dot-four.js +0 -72
  110. package/dist/cjs/migrations/upgrade-two-dot-four.js.map +0 -1
  111. package/dist/cjs/migrations/upgrade-two-dot-one.d.ts +0 -7
  112. package/dist/cjs/migrations/upgrade-two-dot-one.js +0 -39
  113. package/dist/cjs/migrations/upgrade-two-dot-one.js.map +0 -1
  114. package/dist/cjs/migrations/upgrade-two-dot-seven.d.ts +0 -23
  115. package/dist/cjs/migrations/upgrade-two-dot-seven.js +0 -58
  116. package/dist/cjs/migrations/upgrade-two-dot-seven.js.map +0 -1
  117. package/dist/cjs/migrations/upgrade-two-dot-six.d.ts +0 -27
  118. package/dist/cjs/migrations/upgrade-two-dot-six.js +0 -61
  119. package/dist/cjs/migrations/upgrade-two-dot-six.js.map +0 -1
  120. package/dist/cjs/migrations/upgrade-two-dot-three.d.ts +0 -23
  121. package/dist/cjs/migrations/upgrade-two-dot-three.js +0 -55
  122. package/dist/cjs/migrations/upgrade-two-dot-three.js.map +0 -1
  123. package/dist/cjs/migrations/upgrade-two-dot-two.d.ts +0 -23
  124. package/dist/cjs/migrations/upgrade-two-dot-two.js +0 -58
  125. package/dist/cjs/migrations/upgrade-two-dot-two.js.map +0 -1
  126. package/dist/cjs/migrations/upgrade-two-dot-zero.d.ts +0 -44
  127. package/dist/cjs/migrations/upgrade-two-dot-zero.js +0 -95
  128. package/dist/cjs/migrations/upgrade-two-dot-zero.js.map +0 -1
  129. package/dist/cjs/migrator.d.ts +0 -25
  130. package/dist/cjs/migrator.js +0 -77
  131. package/dist/cjs/migrator.js.map +0 -1
  132. package/dist/cjs/resourceHelpers.d.ts +0 -191
  133. package/dist/cjs/resourceHelpers.js +0 -384
  134. package/dist/cjs/resourceHelpers.js.map +0 -1
  135. package/dist/cjs/resources/add-resource-from-blob.d.ts +0 -26
  136. package/dist/cjs/resources/add-resource-from-blob.js +0 -52
  137. package/dist/cjs/resources/add-resource-from-blob.js.map +0 -1
  138. package/dist/cjs/resources/addMetadataFromBlob.d.ts +0 -25
  139. package/dist/cjs/resources/addMetadataFromBlob.js +0 -43
  140. package/dist/cjs/resources/addMetadataFromBlob.js.map +0 -1
  141. package/dist/cjs/resources/convert-item-resource-to-storage-resource.d.ts +0 -32
  142. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js +0 -70
  143. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js.map +0 -1
  144. package/dist/cjs/resources/convert-storage-resource-to-item-resource.d.ts +0 -29
  145. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js +0 -70
  146. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js.map +0 -1
  147. package/dist/cjs/resources/copyAssociatedFiles.d.ts +0 -67
  148. package/dist/cjs/resources/copyAssociatedFiles.js +0 -304
  149. package/dist/cjs/resources/copyAssociatedFiles.js.map +0 -1
  150. package/dist/cjs/resources/copyDataIntoItem.d.ts +0 -33
  151. package/dist/cjs/resources/copyDataIntoItem.js +0 -62
  152. package/dist/cjs/resources/copyDataIntoItem.js.map +0 -1
  153. package/dist/cjs/resources/copyMetadataIntoItem.d.ts +0 -26
  154. package/dist/cjs/resources/copyMetadataIntoItem.js +0 -46
  155. package/dist/cjs/resources/copyMetadataIntoItem.js.map +0 -1
  156. package/dist/cjs/resources/copyResourceIntoZip.d.ts +0 -33
  157. package/dist/cjs/resources/copyResourceIntoZip.js +0 -78
  158. package/dist/cjs/resources/copyResourceIntoZip.js.map +0 -1
  159. package/dist/cjs/resources/copyZipIntoItem.d.ts +0 -25
  160. package/dist/cjs/resources/copyZipIntoItem.js +0 -54
  161. package/dist/cjs/resources/copyZipIntoItem.js.map +0 -1
  162. package/dist/cjs/resources/createCopyResults.d.ts +0 -25
  163. package/dist/cjs/resources/createCopyResults.js +0 -36
  164. package/dist/cjs/resources/createCopyResults.js.map +0 -1
  165. package/dist/cjs/resources/get-blob.d.ts +0 -26
  166. package/dist/cjs/resources/get-blob.js +0 -27
  167. package/dist/cjs/resources/get-blob.js.map +0 -1
  168. package/dist/cjs/resources/getItemResourcesFilesFromPaths.d.ts +0 -24
  169. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js +0 -49
  170. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js.map +0 -1
  171. package/dist/cjs/resources/getItemResourcesPaths.d.ts +0 -26
  172. package/dist/cjs/resources/getItemResourcesPaths.js +0 -76
  173. package/dist/cjs/resources/getItemResourcesPaths.js.map +0 -1
  174. package/dist/cjs/resources/index.d.ts +0 -29
  175. package/dist/cjs/resources/index.js +0 -33
  176. package/dist/cjs/resources/index.js.map +0 -1
  177. package/dist/cjs/resources/solution-resource.d.ts +0 -35
  178. package/dist/cjs/resources/solution-resource.js +0 -31
  179. package/dist/cjs/resources/solution-resource.js.map +0 -1
  180. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.d.ts +0 -56
  181. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js +0 -146
  182. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js.map +0 -1
  183. package/dist/cjs/restHelpers.d.ts +0 -598
  184. package/dist/cjs/restHelpers.js +0 -1929
  185. package/dist/cjs/restHelpers.js.map +0 -1
  186. package/dist/cjs/restHelpersGet.d.ts +0 -288
  187. package/dist/cjs/restHelpersGet.js +0 -804
  188. package/dist/cjs/restHelpersGet.js.map +0 -1
  189. package/dist/cjs/sharing/index.d.ts +0 -16
  190. package/dist/cjs/sharing/index.js +0 -20
  191. package/dist/cjs/sharing/index.js.map +0 -1
  192. package/dist/cjs/sharing/share-item-to-groups.d.ts +0 -26
  193. package/dist/cjs/sharing/share-item-to-groups.js +0 -44
  194. package/dist/cjs/sharing/share-item-to-groups.js.map +0 -1
  195. package/dist/cjs/templatization.d.ts +0 -139
  196. package/dist/cjs/templatization.js +0 -314
  197. package/dist/cjs/templatization.js.map +0 -1
  198. package/dist/cjs/trackingHelpers.d.ts +0 -116
  199. package/dist/cjs/trackingHelpers.js +0 -217
  200. package/dist/cjs/trackingHelpers.js.map +0 -1
  201. package/dist/cjs/velocityHelpers.d.ts +0 -57
  202. package/dist/cjs/velocityHelpers.js +0 -135
  203. package/dist/cjs/velocityHelpers.js.map +0 -1
  204. package/dist/cjs/workflowHelpers.d.ts +0 -17
  205. package/dist/cjs/workflowHelpers.js +0 -76
  206. package/dist/cjs/workflowHelpers.js.map +0 -1
  207. package/dist/cjs/workforceHelpers.d.ts +0 -115
  208. package/dist/cjs/workforceHelpers.js +0 -749
  209. package/dist/cjs/workforceHelpers.js.map +0 -1
  210. package/dist/cjs/zip-utils.d.ts +0 -49
  211. package/dist/cjs/zip-utils.js +0 -89
  212. package/dist/cjs/zip-utils.js.map +0 -1
@@ -1,804 +0,0 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2018 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.getPortalDefaultBasemap = exports._getItemResourcesTranche = exports._getGroupContentsTranche = exports._fixTextBlobType = exports.getThumbnailFile = exports.getSolutionsRelatedToAnItem = exports.getPortalUrlFromAuth = exports.getPortalSharingUrlFromAuth = exports.getJson = exports.getItemThumbnailUrl = exports.getItemThumbnailAsFile = exports.getItemThumbnail = exports.getItemsRelatedToASolution = exports.getItemResourcesFiles = exports.getItemResources = exports.getItemRelatedItemsInSameDirection = exports.getItemRelatedItems = exports.getItemMetadataBlobUrl = exports.getItemMetadataBlob = exports.getItemMetadataAsFile = exports.getItemInfoFileUrlPrefix = exports.getItemDataBlobUrl = exports.getItemDataBlob = exports.getItemDataAsJson = exports.getItemDataAsFile = exports.getItemBase = exports.getGroupContents = exports.getGroupCategorySchema = exports.getGroupBase = exports.getFilenameFromUrl = exports.getBlobCheckForError = exports.getBlobAsFile = exports.getFoldersAndGroups = exports.getUsername = exports.getUser = exports.getPortal = exports.checkJsonForError = void 0;
19
- /**
20
- * Provides common item fetch functions involving the arcgis-rest-js library.
21
- *
22
- * @module restHelpersGet
23
- */
24
- const generalHelpers_1 = require("./generalHelpers");
25
- const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
26
- const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
27
- const get_blob_1 = require("./resources/get-blob");
28
- const restHelpers_1 = require("./restHelpers");
29
- // ------------------------------------------------------------------------------------------------------------------ //
30
- const ZIP_FILE_HEADER_SIGNATURE = "PK";
31
- function checkJsonForError(json) {
32
- return typeof json?.error !== "undefined";
33
- }
34
- exports.checkJsonForError = checkJsonForError;
35
- function getPortal(id, authentication) {
36
- const requestOptions = {
37
- authentication: authentication
38
- };
39
- return (0, arcgis_rest_portal_1.getPortal)(id, requestOptions);
40
- }
41
- exports.getPortal = getPortal;
42
- function getUser(authentication) {
43
- return authentication.getUser();
44
- }
45
- exports.getUser = getUser;
46
- function getUsername(authentication) {
47
- return new Promise((resolve, reject) => {
48
- getUser(authentication).then((user) => resolve(user.username), reject);
49
- });
50
- }
51
- exports.getUsername = getUsername;
52
- function getFoldersAndGroups(authentication) {
53
- return new Promise((resolve, reject) => {
54
- const requestOptions = {
55
- httpMethod: "GET",
56
- authentication: authentication,
57
- rawResponse: false
58
- };
59
- // Folders
60
- const foldersUrl = `${authentication.portal}/content/users/${encodeURIComponent(authentication.username)}`;
61
- // Groups
62
- const groupsUrl = `${authentication.portal}/community/users/${encodeURIComponent(authentication.username)}`;
63
- Promise.all([
64
- (0, arcgis_rest_request_1.request)(foldersUrl, requestOptions),
65
- (0, arcgis_rest_request_1.request)(groupsUrl, requestOptions)
66
- ]).then(responses => {
67
- resolve({
68
- folders: responses[0].folders || [],
69
- groups: responses[1].groups || []
70
- });
71
- }, e => reject(e));
72
- });
73
- }
74
- exports.getFoldersAndGroups = getFoldersAndGroups;
75
- /**
76
- * Gets a Blob from a web site and casts it as a file using the supplied name.
77
- *
78
- * @param url Address of Blob
79
- * @param filename Name to use for file
80
- * @param authentication Credentials for the request
81
- * @returns Promise that will resolve with a File, undefined if the Blob is null, or an AGO-style JSON failure response
82
- */
83
- function getBlobAsFile(url, filename, authentication, ignoreErrors = [], mimeType) {
84
- return new Promise((resolve, reject) => {
85
- // Get the blob from the URL
86
- getBlobCheckForError(url, authentication, ignoreErrors).then(blob => !blob ? resolve(null) : resolve((0, generalHelpers_1.blobToFile)(blob, filename, mimeType)), reject);
87
- });
88
- }
89
- exports.getBlobAsFile = getBlobAsFile;
90
- /**
91
- * Gets a Blob from a web site and checks for a JSON error packet in the Blob.
92
- *
93
- * @param url Address of Blob
94
- * @param authentication Credentials for the request
95
- * @param ignoreErrors List of HTTP error codes that should be ignored
96
- * @returns Promise that will resolve with Blob or an AGO-REST JSON failure response
97
- */
98
- function getBlobCheckForError(url, authentication, ignoreErrors = []) {
99
- return new Promise((resolve, reject) => {
100
- // Get the blob from the URL
101
- (0, get_blob_1.getBlob)(url, authentication).then(blob => {
102
- // Reclassify text/plain blobs as needed
103
- _fixTextBlobType(blob).then(adjustedBlob => {
104
- if (adjustedBlob.type === "application/json") {
105
- // Blob may be an error
106
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
107
- (0, generalHelpers_1.blobToJson)(adjustedBlob).then((json) => {
108
- // Check for valid JSON with an error
109
- if (json?.error) {
110
- const code = json.error.code;
111
- if (code !== undefined && ignoreErrors.indexOf(code) >= 0) {
112
- resolve(null); // Error, but ignored
113
- }
114
- else {
115
- reject(json); // Other error; fail with error
116
- }
117
- }
118
- else {
119
- resolve(adjustedBlob);
120
- }
121
- });
122
- }
123
- else {
124
- resolve(adjustedBlob);
125
- }
126
- }, reject);
127
- }, reject);
128
- });
129
- }
130
- exports.getBlobCheckForError = getBlobCheckForError;
131
- /**
132
- * Extracts the text in a url between the last forward slash and the beginning of the url's parameters.
133
- *
134
- * @param url URL to work with
135
- * @returns Text extracted; empty if url ends with a forward slash or has a "?" immediately after the last
136
- * forward slash
137
- */
138
- function getFilenameFromUrl(url) {
139
- if (!url) {
140
- return "";
141
- }
142
- let iParamsStart = url.indexOf("?");
143
- /* istanbul ignore else */
144
- if (iParamsStart < 0) {
145
- iParamsStart = url.length;
146
- }
147
- const iFilenameStart = url.lastIndexOf("/", iParamsStart) + 1;
148
- return iFilenameStart < iParamsStart
149
- ? url.substring(iFilenameStart, iParamsStart)
150
- : "";
151
- }
152
- exports.getFilenameFromUrl = getFilenameFromUrl;
153
- /**
154
- * Gets the primary information of an AGO group.
155
- *
156
- * @param groupId Id of an group whose primary information is sought
157
- * @param authentication Credentials for the request to AGO
158
- * @returns A promise that will resolve with group's JSON or error JSON or throws ArcGISRequestError in case of HTTP error
159
- * or response error code
160
- */
161
- function getGroupBase(groupId, authentication) {
162
- const requestOptions = {
163
- authentication: authentication
164
- };
165
- return (0, arcgis_rest_portal_1.getGroup)(groupId, requestOptions);
166
- }
167
- exports.getGroupBase = getGroupBase;
168
- /**
169
- * Gets the category schema set on a group.
170
- *
171
- * @param groupId Id of an group whose category schema information is sought
172
- * @param authentication Credentials for the request to AGO
173
- * @returns A promise that will resolve with JSON of group's category schema
174
- * @see https://developers.arcgis.com/rest/users-groups-and-items/group-category-schema.htm
175
- */
176
- function getGroupCategorySchema(groupId, authentication) {
177
- const requestOptions = {
178
- authentication: authentication
179
- };
180
- return (0, arcgis_rest_portal_1.getGroupCategorySchema)(groupId, requestOptions);
181
- }
182
- exports.getGroupCategorySchema = getGroupCategorySchema;
183
- /**
184
- * Gets the ids of the dependencies (contents) of an AGO group.
185
- *
186
- * @param groupId Id of a group whose contents are sought
187
- * @param authentication Credentials for the request to AGO
188
- * @returns A promise that will resolve with list of dependent ids or an empty list
189
- */
190
- function getGroupContents(groupId, authentication) {
191
- return new Promise((resolve, reject) => {
192
- const pagingParams = {
193
- start: 1,
194
- num: 100 // max allowed by REST API
195
- };
196
- // Fetch group items
197
- _getGroupContentsTranche(groupId, pagingParams, authentication).then(contents => {
198
- resolve(contents);
199
- }, reject);
200
- });
201
- }
202
- exports.getGroupContents = getGroupContents;
203
- /**
204
- * Gets the primary information of an AGO item.
205
- *
206
- * @param itemId Id of an item whose primary information is sought
207
- * @param authentication Credentials for the request to AGO
208
- * @returns A promise that will resolve with item's JSON or error JSON or throws ArcGISRequestError in case of HTTP error
209
- * or response error code
210
- */
211
- function getItemBase(itemId, authentication) {
212
- const itemParam = {
213
- authentication: authentication
214
- };
215
- return (0, arcgis_rest_portal_1.getItem)(itemId, itemParam);
216
- }
217
- exports.getItemBase = getItemBase;
218
- /**
219
- * Gets the data information of an AGO item in its raw (Blob) form and casts it as a file using the supplied name.
220
- *
221
- * @param itemId Id of an item whose data information is sought
222
- * @param filename Name to use for file
223
- * @param authentication Credentials for the request to AGO
224
- * @returns Promise that will resolve with a File, undefined if the Blob is null, or an AGO-style JSON failure response
225
- */
226
- function getItemDataAsFile(itemId, filename, authentication) {
227
- return new Promise(resolve => {
228
- getItemDataBlob(itemId, authentication).then(blob => resolve((0, generalHelpers_1.blobToFile)(blob, filename)), () => resolve(null));
229
- });
230
- }
231
- exports.getItemDataAsFile = getItemDataAsFile;
232
- /**
233
- * Gets the data information of an AGO item in its JSON form.
234
- *
235
- * @param itemId Id of an item whose data information is sought
236
- * @param filename Name to use for file
237
- * @param authentication Credentials for the request to AGO
238
- * @returns Promise that will resolve with JSON, or an AGO-style JSON failure response
239
- */
240
- function getItemDataAsJson(itemId, authentication) {
241
- return new Promise(resolve => {
242
- getItemDataBlob(itemId, authentication).then(blob => resolve((0, generalHelpers_1.blobToJson)(blob)), () => resolve(null));
243
- });
244
- }
245
- exports.getItemDataAsJson = getItemDataAsJson;
246
- /**
247
- * Gets the data information of an AGO item in its raw (Blob) form.
248
- *
249
- * @param itemId Id of an item whose data information is sought
250
- * @param authentication Credentials for the request to AGO
251
- * @returns A promise that will resolve with the data Blob or null if the item doesn't have a data section
252
- */
253
- function getItemDataBlob(itemId, authentication) {
254
- return new Promise(resolve => {
255
- const url = getItemDataBlobUrl(itemId, authentication);
256
- getBlobCheckForError(url, authentication, [400, 500]).then(blob => resolve(_fixTextBlobType(blob)), () => resolve(null));
257
- });
258
- }
259
- exports.getItemDataBlob = getItemDataBlob;
260
- /**
261
- * Gets the URL to the data information of an AGO item in its raw (Blob) form.
262
- *
263
- * @param itemId Id of an item whose data information is sought
264
- * @param authentication Credentials for the request to AGO
265
- * @returns URL string
266
- */
267
- function getItemDataBlobUrl(itemId, authentication) {
268
- return `${getPortalSharingUrlFromAuth(authentication)}/content/items/${itemId}/data`;
269
- }
270
- exports.getItemDataBlobUrl = getItemDataBlobUrl;
271
- /**
272
- * Gets the URL to an information item in an AGO item.
273
- *
274
- * @param itemId Id of an item whose data information is sought
275
- * @param authentication Credentials for the request to AGO
276
- * @returns URL string
277
- */
278
- function getItemInfoFileUrlPrefix(itemId, authentication) {
279
- return `${getPortalSharingUrlFromAuth(authentication)}/content/items/${itemId}/info/`;
280
- }
281
- exports.getItemInfoFileUrlPrefix = getItemInfoFileUrlPrefix;
282
- /**
283
- * Gets the metadata information of an AGO item.
284
- *
285
- * @param itemId Id of an item whose data information is sought
286
- * @param authentication Credentials for the request to AGO
287
- * @returns Promise that will resolve with `undefined` or a File containing the metadata
288
- */
289
- function getItemMetadataAsFile(itemId, authentication) {
290
- return new Promise(resolve => {
291
- getItemMetadataBlob(itemId, authentication).then(blob => {
292
- if (!blob || (blob && blob.type.startsWith("application/json"))) {
293
- resolve(null); // JSON error
294
- }
295
- else {
296
- resolve((0, generalHelpers_1.blobToFile)(blob, "metadata.xml"));
297
- }
298
- }, () => resolve(null));
299
- });
300
- }
301
- exports.getItemMetadataAsFile = getItemMetadataAsFile;
302
- /**
303
- * Gets the metadata information of an AGO item.
304
- *
305
- * @param itemId Id of an item whose data information is sought
306
- * @param authentication Credentials for the request to AGO
307
- * @returns A promise that will resolve with the metadata Blob or null if the item doesn't have a metadata file
308
- */
309
- function getItemMetadataBlob(itemId, authentication) {
310
- return new Promise((resolve, reject) => {
311
- const url = getItemMetadataBlobUrl(itemId, authentication);
312
- getBlobCheckForError(url, authentication, [400]).then(resolve, reject);
313
- });
314
- }
315
- exports.getItemMetadataBlob = getItemMetadataBlob;
316
- /**
317
- * Gets the URL to the metadata information of an AGO item.
318
- *
319
- * @param itemId Id of an item whose data information is sought
320
- * @param authentication Credentials for the request to AGO
321
- * @returns URL string
322
- */
323
- function getItemMetadataBlobUrl(itemId, authentication) {
324
- return (getItemInfoFileUrlPrefix(itemId, authentication) + "metadata/metadata.xml");
325
- }
326
- exports.getItemMetadataBlobUrl = getItemMetadataBlobUrl;
327
- /**
328
- * Gets the related items of an AGO item.
329
- *
330
- * @param itemId Id of an item whose related items are sought
331
- * @param relationshipType Tag for relationship type, e.g., "Solution2Item"
332
- * @param direction Relationship direction
333
- * @param authentication Credentials for the request to AGO
334
- * @param num Number of related items to request per batch; maximum is 100
335
- * @returns A promise that will resolve with the list of related items
336
- */
337
- function getItemRelatedItems(itemId, relationshipType, direction, authentication, num = 100) {
338
- return new Promise(resolve => {
339
- const itemRelatedItemsParam = {
340
- id: itemId,
341
- relationshipType,
342
- authentication: authentication,
343
- params: {
344
- direction,
345
- start: 1,
346
- num
347
- }
348
- };
349
- // Fetch related items
350
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
351
- _getItemRelatedItemsTranche(itemRelatedItemsParam).then(response => {
352
- resolve(response);
353
- });
354
- });
355
- }
356
- exports.getItemRelatedItems = getItemRelatedItems;
357
- /**
358
- * Gets all of the related items of an AGO item in the specified direction.
359
- *
360
- * @param itemId Id of an item whose related items are sought
361
- * @param direction
362
- * @param authentication Credentials for the request to AGO
363
- * @returns A promise that will resolve with a list of IRelatedItems
364
- */
365
- function getItemRelatedItemsInSameDirection(itemId, direction, authentication) {
366
- return new Promise(resolve => {
367
- const relationshipTypes = [
368
- // from ItemRelationshipType
369
- "APIKey2Item",
370
- "Area2CustomPackage",
371
- "Area2Package",
372
- "Item2Attachment",
373
- "Item2Report",
374
- "Listed2Provisioned",
375
- "Map2AppConfig",
376
- "Map2Area",
377
- "Map2FeatureCollection",
378
- "Map2Service",
379
- "MobileApp2Code",
380
- "Service2Data",
381
- "Service2Layer",
382
- "Service2Route",
383
- "Service2Service",
384
- "Service2Style",
385
- "Solution2Item",
386
- "Style2Style",
387
- "Survey2Data",
388
- "Survey2Service",
389
- "SurveyAddIn2Data",
390
- "Theme2Story",
391
- "TrackView2Map",
392
- "WebStyle2DesktopStyle",
393
- "WMA2Code",
394
- "WorkforceMap2FeatureService"
395
- ];
396
- const relatedItemDefs = relationshipTypes.map(relationshipType => getItemRelatedItems(itemId, relationshipType, direction, authentication));
397
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
398
- Promise.all(relatedItemDefs).then((relationshipResponses) => {
399
- const relatedItems = [];
400
- for (let i = 0; i < relationshipTypes.length; ++i) {
401
- if (relationshipResponses[i].total > 0) {
402
- relatedItems.push({
403
- relationshipType: relationshipTypes[i],
404
- relatedItemIds: relationshipResponses[i].relatedItems.map(item => item.id)
405
- });
406
- }
407
- }
408
- resolve(relatedItems);
409
- });
410
- });
411
- }
412
- exports.getItemRelatedItemsInSameDirection = getItemRelatedItemsInSameDirection;
413
- function getItemResources(id, authentication) {
414
- return new Promise(resolve => {
415
- const requestOptions = {
416
- authentication: authentication
417
- };
418
- (0, arcgis_rest_portal_1.getItemResources)(id, requestOptions).then(resolve, () => {
419
- resolve({
420
- total: 0,
421
- start: 1,
422
- num: 0,
423
- nextStart: -1,
424
- resources: []
425
- });
426
- });
427
- });
428
- }
429
- exports.getItemResources = getItemResources;
430
- /**
431
- * Gets the resources of an AGO item.
432
- *
433
- * @param itemId Id of an item whose resources are sought
434
- * @param authentication Credentials for the request to AGO
435
- * @returns Promise that will resolve with a list of Files or an AGO-style JSON failure response
436
- */
437
- function getItemResourcesFiles(itemId, authentication) {
438
- return new Promise((resolve, reject) => {
439
- const pagingParams = {
440
- start: 1,
441
- num: 100 // max allowed by REST API
442
- };
443
- // Fetch resources
444
- _getItemResourcesTranche(itemId, pagingParams, authentication).then(itemResourcesDef => {
445
- Promise.all(itemResourcesDef).then(resolve, reject);
446
- }, reject);
447
- });
448
- }
449
- exports.getItemResourcesFiles = getItemResourcesFiles;
450
- /**
451
- * Gets all of the items associated with a Solution via a Solution2Item relationship.
452
- *
453
- * @param solutionItemId Id of a deployed Solution
454
- * @param authentication Credentials for the request
455
- * @returns Promise resolving to a list of detailed item information
456
- */
457
- function getItemsRelatedToASolution(solutionItemId, authentication) {
458
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
459
- return getItemRelatedItems(solutionItemId, "Solution2Item", "forward", authentication).then((relationshipResponse) => {
460
- return relationshipResponse.relatedItems;
461
- });
462
- }
463
- exports.getItemsRelatedToASolution = getItemsRelatedToASolution;
464
- /**
465
- * Gets the thumbnail of an AGO item.
466
- *
467
- * @param itemId Id of an item whose resources are sought
468
- * @param thumbnailUrlPart The partial name of the item's thumbnail as reported by the `thumbnail` property
469
- * in the item's base section
470
- * @param isGroup Switch indicating if the item is a group
471
- * @param authentication Credentials for the request to AGO
472
- * @returns Promise that will resolve with an image Blob or an AGO-style JSON failure response
473
- */
474
- function getItemThumbnail(itemId, thumbnailUrlPart, isGroup, authentication) {
475
- return new Promise((resolve, reject) => {
476
- if (!thumbnailUrlPart) {
477
- resolve(null);
478
- return;
479
- }
480
- const url = getItemThumbnailUrl(itemId, thumbnailUrlPart, isGroup, authentication);
481
- getBlobCheckForError(url, authentication, [500]).then(blob => resolve(_fixTextBlobType(blob)), reject);
482
- });
483
- }
484
- exports.getItemThumbnail = getItemThumbnail;
485
- /**
486
- * Gets the thumbnail of an AGO item.
487
- *
488
- * @param itemId Id of an item whose resources are sought
489
- * @param thumbnailUrlPart The partial name of the item's thumbnail as reported by the `thumbnail` property
490
- * in the item's base section
491
- * @param isGroup Switch indicating if the item is a group
492
- * @param authentication Credentials for the request to AGO
493
- * @returns Promise that will resolve with an image Blob or an AGO-style JSON failure response
494
- */
495
- function getItemThumbnailAsFile(itemId, thumbnailUrlPart, isGroup, authentication) {
496
- return new Promise((resolve, reject) => {
497
- /* istanbul ignore else */
498
- if (!thumbnailUrlPart) {
499
- resolve(null);
500
- return;
501
- }
502
- const url = getItemThumbnailUrl(itemId, thumbnailUrlPart, isGroup, authentication);
503
- const iFilenameStart = thumbnailUrlPart.lastIndexOf("/") + 1;
504
- const filename = thumbnailUrlPart.substring(iFilenameStart);
505
- getBlobAsFile(url, filename, authentication, [400, 500]).then(resolve, reject);
506
- });
507
- }
508
- exports.getItemThumbnailAsFile = getItemThumbnailAsFile;
509
- /**
510
- * Gets the URL to the thumbnail of an AGO item.
511
- *
512
- * @param itemId Id of an item whose resources are sought
513
- * @param thumbnailUrlPart The partial name of the item's thumbnail as reported by the `thumbnail` property
514
- * in the item's base section
515
- * @param isGroup Switch indicating if the item is a group
516
- * @param authentication Credentials for the request to AGO
517
- * @returns URL string
518
- */
519
- function getItemThumbnailUrl(itemId, thumbnailUrlPart, isGroup, authentication) {
520
- return ((0, generalHelpers_1.checkUrlPathTermination)(getPortalSharingUrlFromAuth(authentication)) +
521
- (isGroup ? "community/groups/" : "content/items/") +
522
- itemId +
523
- "/info/" +
524
- thumbnailUrlPart);
525
- }
526
- exports.getItemThumbnailUrl = getItemThumbnailUrl;
527
- /**
528
- * Gets a JSON from a web site.
529
- *
530
- * @param url Address of JSON
531
- * @param authentication Credentials for the request
532
- * @returns Promise that will resolve with JSON
533
- */
534
- function getJson(url, authentication) {
535
- // Get the blob from the URL
536
- const requestOptions = { httpMethod: "GET" };
537
- return (0, get_blob_1.getBlob)(url, authentication, requestOptions)
538
- .then(blob => {
539
- // Reclassify text/plain blobs as needed
540
- return _fixTextBlobType(blob);
541
- })
542
- .then(adjustedBlob => {
543
- if (adjustedBlob.type === "application/json") {
544
- // Blob may be an error
545
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
546
- return (0, generalHelpers_1.blobToJson)(adjustedBlob);
547
- }
548
- else {
549
- return Promise.resolve(null);
550
- }
551
- });
552
- }
553
- exports.getJson = getJson;
554
- /**
555
- * Extracts the portal sharing url from a supplied authentication.
556
- *
557
- * @param authentication Credentials for the request to AGO
558
- * @returns Portal sharing url to be used in API requests, defaulting to `https://www.arcgis.com/sharing/rest`
559
- */
560
- function getPortalSharingUrlFromAuth(authentication) {
561
- // If auth was passed, use that portal
562
- return (0, generalHelpers_1.getProp)(authentication, "portal") || "https://www.arcgis.com/sharing/rest";
563
- }
564
- exports.getPortalSharingUrlFromAuth = getPortalSharingUrlFromAuth;
565
- /**
566
- * Extracts the portal url from a supplied authentication.
567
- *
568
- * @param authentication Credentials for the request to AGO
569
- * @returns Portal url to be used in API requests, defaulting to `https://www.arcgis.com`
570
- */
571
- function getPortalUrlFromAuth(authentication) {
572
- return getPortalSharingUrlFromAuth(authentication).replace("/sharing/rest", "");
573
- }
574
- exports.getPortalUrlFromAuth = getPortalUrlFromAuth;
575
- /**
576
- * Gets the ids of all Solution items associated with an AGO item via a Solution2Item relationship.
577
- *
578
- * @param itemId Id of an AGO item to query
579
- * @param authentication Credentials for the request
580
- * @returns Promise resolving to a list of Solution item ids
581
- */
582
- function getSolutionsRelatedToAnItem(itemId, authentication) {
583
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
584
- return getItemRelatedItems(itemId, "Solution2Item", "reverse", authentication).then((relationshipResponse) => {
585
- return relationshipResponse.relatedItems.map(item => item.id);
586
- });
587
- }
588
- exports.getSolutionsRelatedToAnItem = getSolutionsRelatedToAnItem;
589
- function getThumbnailFile(url, filename, authentication) {
590
- return new Promise(resolve => {
591
- getBlobAsFile(url, filename, authentication, [500]).then(resolve, () => resolve(null));
592
- });
593
- }
594
- exports.getThumbnailFile = getThumbnailFile;
595
- // ------------------------------------------------------------------------------------------------------------------ //
596
- /**
597
- * Fixes the types of Blobs incorrectly typed as text/plain.
598
- *
599
- * @param blob Blob to check
600
- * @returns Promise resolving to original Blob, unless it's originally typed as text/plain but is
601
- * really JSON, ZIP, or XML
602
- * @private
603
- */
604
- function _fixTextBlobType(blob) {
605
- return new Promise((resolve, reject) => {
606
- if (blob &&
607
- blob.size > 0 &&
608
- (blob.type.startsWith("text/plain") ||
609
- blob.type.startsWith("application/json"))) {
610
- (0, generalHelpers_1.blobToText)(blob).then(blobText => {
611
- // Convertible to JSON?
612
- try {
613
- JSON.parse(blobText);
614
- // Yes; reclassify as JSON
615
- resolve(new Blob([blob], { type: "application/json" }));
616
- }
617
- catch (ignored) {
618
- // Nope; test for ZIP file
619
- if (blobText.length > 4 &&
620
- blobText.substr(0, 4) === ZIP_FILE_HEADER_SIGNATURE) {
621
- // Yes; reclassify as ZIP
622
- resolve(new Blob([blob], { type: "application/zip" }));
623
- }
624
- else if (blobText.startsWith("<")) {
625
- // Reclassify as XML; since the blob started out as text/plain, it's more likely that is
626
- // meant to be human-readable, so we'll use text/xml instead of application/xml
627
- resolve(new Blob([blob], { type: "text/xml" }));
628
- }
629
- else {
630
- // Leave as text
631
- resolve(blob);
632
- }
633
- }
634
- },
635
- // Faulty blob
636
- reject);
637
- }
638
- else {
639
- // Empty or not typed as plain text, so simply return
640
- if (blob) {
641
- resolve(blob);
642
- }
643
- else {
644
- reject();
645
- }
646
- }
647
- });
648
- }
649
- exports._fixTextBlobType = _fixTextBlobType;
650
- /**
651
- * Gets some of the ids of the dependencies (contents) of an AGO group.
652
- *
653
- * @param groupId Id of a group whose contents are sought
654
- * @param pagingParams Structure with start and num properties for the tranche to fetch
655
- * @param authentication Credentials for the request to AGO
656
- * @returns A promise that will resolve with list of dependent ids or an empty list
657
- * @private
658
- */
659
- function _getGroupContentsTranche(groupId, pagingParams, authentication) {
660
- return new Promise((resolve, reject) => {
661
- // Fetch group items
662
- const pagingRequest = {
663
- paging: pagingParams,
664
- authentication: authentication
665
- };
666
- (0, arcgis_rest_portal_1.getGroupContent)(groupId, pagingRequest).then(contents => {
667
- if (contents.num > 0) {
668
- // Extract the list of content ids from the JSON returned
669
- const trancheIds = contents.items.map((item) => item.id);
670
- // Are there more contents to fetch?
671
- if (contents.nextStart > 0) {
672
- pagingRequest.paging.start = contents.nextStart;
673
- _getGroupContentsTranche(groupId, pagingParams, authentication).then((allSubsequentTrancheIds) => {
674
- // Append all of the following tranches to the current tranche and return it
675
- resolve(trancheIds.concat(allSubsequentTrancheIds));
676
- }, reject);
677
- }
678
- else {
679
- resolve(trancheIds);
680
- }
681
- }
682
- else {
683
- resolve([]);
684
- }
685
- }, reject);
686
- });
687
- }
688
- exports._getGroupContentsTranche = _getGroupContentsTranche;
689
- /**
690
- * Gets some of the related items of an AGO item.
691
- *
692
- * @param requestOptions Item id, relationship type, relationship direction, authentication, and paging
693
- * @returns A promise that will resolve with the list of related items
694
- * @private
695
- */
696
- function _getItemRelatedItemsTranche(requestOptions) {
697
- return new Promise(resolve => {
698
- const response = {
699
- total: 0,
700
- relatedItems: []
701
- };
702
- (0, arcgis_rest_portal_1.getRelatedItems)(requestOptions).then(
703
- // Have to use `any` because `IGetRelatedItemsResponse` doesn't include all of the response properties
704
- (results) => {
705
- // Are there any results?
706
- if (results.aggregations.total.count > 0) {
707
- response.total = results.aggregations.total.count;
708
- response.relatedItems = results.relatedItems;
709
- // Are there more items to fetch?
710
- if (results.nextkey) {
711
- requestOptions.params.start += requestOptions.params.num;
712
- requestOptions.params.nextkey = results.nextkey;
713
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
714
- _getItemRelatedItemsTranche(requestOptions).then((allSubsequentResults) => {
715
- // Append all of the following tranches to the current tranche and return it
716
- response.total += allSubsequentResults.total;
717
- response.relatedItems = response.relatedItems.concat(allSubsequentResults.relatedItems);
718
- resolve(response);
719
- });
720
- }
721
- else {
722
- resolve(response);
723
- }
724
- }
725
- else {
726
- resolve(response);
727
- }
728
- }, () => {
729
- resolve(response);
730
- });
731
- });
732
- }
733
- /**
734
- * Gets some of the resources of an AGO item.
735
- *
736
- * @param itemId Id of an item whose resources are sought
737
- * @param pagingParams Structure with start and num properties for the tranche to fetch
738
- * @param authentication Credentials for the request to AGO
739
- * @returns Promise that will resolve with a list of File promises or an AGO-style JSON failure response
740
- * @private
741
- */
742
- function _getItemResourcesTranche(itemId, pagingParams, authentication) {
743
- return new Promise((resolve, reject) => {
744
- // Fetch resources
745
- const portalSharingUrl = getPortalSharingUrlFromAuth(authentication);
746
- const trancheUrl = `${portalSharingUrl}/content/items/${itemId}/resources`;
747
- const itemResourcesDef = [];
748
- const options = {
749
- params: {
750
- ...pagingParams
751
- },
752
- authentication: authentication
753
- };
754
- (0, arcgis_rest_request_1.request)(trancheUrl, options).then(contents => {
755
- if (contents.num > 0) {
756
- // Extract the list of resource filenames from the JSON returned
757
- contents.resources.forEach((resource) => {
758
- const itemResourceUrl = `${portalSharingUrl}/content/items/${itemId}/resources/${resource.resource}`;
759
- itemResourcesDef.push(getBlobAsFile(itemResourceUrl, resource.resource, authentication));
760
- });
761
- // Are there more resources to fetch?
762
- if (contents.nextStart > 0) {
763
- pagingParams.start = contents.nextStart;
764
- _getItemResourcesTranche(itemId, pagingParams, authentication).then((allSubsequentTrancheDefs) => {
765
- // Append all of the following tranches to the current tranche and return it
766
- resolve(itemResourcesDef.concat(allSubsequentTrancheDefs));
767
- }, reject);
768
- }
769
- else {
770
- resolve(itemResourcesDef);
771
- }
772
- }
773
- else {
774
- resolve([]);
775
- }
776
- }, reject);
777
- });
778
- }
779
- exports._getItemResourcesTranche = _getItemResourcesTranche;
780
- /**
781
- * Retrieves the default basemap for the given & basemapGalleryGroupQuery, basemapTitle
782
- *
783
- * @param {string} basemapGalleryGroupQuery The default basemap group query
784
- * @param {string} basemapTitle The default basemap title
785
- * @param {UserSession} authentication The session info
786
- * @returns {IItem}
787
- */
788
- function getPortalDefaultBasemap(basemapGalleryGroupQuery, basemapTitle, authentication) {
789
- return (0, restHelpers_1.searchGroups)(basemapGalleryGroupQuery, authentication, { num: 1 })
790
- .then(({ results: [basemapGroup] }) => {
791
- if (!basemapGroup) {
792
- throw new Error("No basemap group found");
793
- }
794
- return (0, restHelpers_1.searchGroupContents)(basemapGroup.id, `title:${basemapTitle}`, authentication, { num: 1 });
795
- })
796
- .then(({ results: [defaultBasemap] }) => {
797
- if (!defaultBasemap) {
798
- throw new Error("No basemap found");
799
- }
800
- return defaultBasemap;
801
- });
802
- }
803
- exports.getPortalDefaultBasemap = getPortalDefaultBasemap;
804
- //# sourceMappingURL=restHelpersGet.js.map