@esri/solution-common 1.2.0 → 1.3.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.
Files changed (47) hide show
  1. package/dist/esm/generalHelpers.d.ts +12 -1
  2. package/dist/esm/generalHelpers.js +22 -0
  3. package/dist/esm/generalHelpers.js.map +1 -1
  4. package/dist/esm/restHelpers.d.ts +53 -8
  5. package/dist/esm/restHelpers.js +139 -13
  6. package/dist/esm/restHelpers.js.map +1 -1
  7. package/dist/esm/templatization.js +1 -0
  8. package/dist/esm/templatization.js.map +1 -1
  9. package/dist/node/completeItem.js +3 -2
  10. package/dist/node/completeItem.js.map +1 -1
  11. package/dist/node/deleteHelpers/deleteGroupIfEmpty.js +2 -1
  12. package/dist/node/deleteHelpers/deleteGroupIfEmpty.js.map +1 -1
  13. package/dist/node/deleteHelpers/deleteSolutionContents.js +6 -5
  14. package/dist/node/deleteHelpers/deleteSolutionContents.js.map +1 -1
  15. package/dist/node/deleteHelpers/deleteSolutionFolder.js +2 -1
  16. package/dist/node/deleteHelpers/deleteSolutionFolder.js.map +1 -1
  17. package/dist/node/deleteHelpers/deleteSolutionItem.js +3 -2
  18. package/dist/node/deleteHelpers/deleteSolutionItem.js.map +1 -1
  19. package/dist/node/deleteHelpers/reconstructBuildOrderIds.js +2 -1
  20. package/dist/node/deleteHelpers/reconstructBuildOrderIds.js.map +1 -1
  21. package/dist/node/deleteHelpers/removeItems.js +5 -4
  22. package/dist/node/deleteHelpers/removeItems.js.map +1 -1
  23. package/dist/node/deleteSolution.js +3 -2
  24. package/dist/node/deleteSolution.js.map +1 -1
  25. package/dist/node/generalHelpers.d.ts +12 -1
  26. package/dist/node/generalHelpers.js +24 -1
  27. package/dist/node/generalHelpers.js.map +1 -1
  28. package/dist/node/getDeletableSolutionInfo.js +3 -2
  29. package/dist/node/getDeletableSolutionInfo.js.map +1 -1
  30. package/dist/node/getSolutionSummary.js +4 -3
  31. package/dist/node/getSolutionSummary.js.map +1 -1
  32. package/dist/node/libConnectors.js +2 -1
  33. package/dist/node/libConnectors.js.map +1 -1
  34. package/dist/node/resources/copyAssociatedFiles.js +2 -1
  35. package/dist/node/resources/copyAssociatedFiles.js.map +1 -1
  36. package/dist/node/restHelpers.d.ts +53 -8
  37. package/dist/node/restHelpers.js +145 -15
  38. package/dist/node/restHelpers.js.map +1 -1
  39. package/dist/node/templatization.js +1 -0
  40. package/dist/node/templatization.js.map +1 -1
  41. package/dist/umd/common.umd.js +169 -15
  42. package/dist/umd/common.umd.js.map +1 -1
  43. package/dist/umd/common.umd.min.js +4 -4
  44. package/dist/umd/common.umd.min.js.map +1 -1
  45. package/dist/umd/generalHelpers.d.ts +12 -1
  46. package/dist/umd/restHelpers.d.ts +53 -8
  47. package/package.json +10 -10
@@ -1,7 +1,7 @@
1
1
  /* @preserve
2
- * @esri/solution-common - v1.2.0 - Apache-2.0
3
- * Copyright (c) 2018-2021 Esri, Inc.
4
- * Thu Dec 09 2021 16:01:08 GMT-0800 (Pacific Standard Time)
2
+ * @esri/solution-common - v1.3.0 - Apache-2.0
3
+ * Copyright (c) 2018-2022 Esri, Inc.
4
+ * Thu Feb 17 2022 09:40:12 GMT-0800 (Pacific Standard Time)
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -4834,6 +4834,28 @@
4834
4834
  return a;
4835
4835
  }, []);
4836
4836
  }
4837
+ /**
4838
+ * Get a property out of a deeply nested object
4839
+ * Does not handle anything but nested object graph
4840
+ *
4841
+ * @param obj Object to retrieve value from
4842
+ * @param path Path into an object, e.g., "data.values.webmap", where "data" is a top-level property
4843
+ * in obj
4844
+ * @param defaultV Optional value to use if any part of path--including final value--is undefined
4845
+ * @return Value at end of path
4846
+ */
4847
+ function getPropWithDefault(obj, path, defaultV) {
4848
+ const value = path.split(".").reduce(function (prev, curr) {
4849
+ /* istanbul ignore next no need to test undefined scenario */
4850
+ return prev ? prev[curr] : undefined;
4851
+ }, obj);
4852
+ if (typeof value === "undefined") {
4853
+ return defaultV;
4854
+ }
4855
+ else {
4856
+ return value;
4857
+ }
4858
+ }
4837
4859
  /**
4838
4860
  * Updates a list of the items dependencies if more are found in the
4839
4861
  * provided value.
@@ -5691,6 +5713,7 @@
5691
5713
  description: itemInfo.description,
5692
5714
  snippet: itemInfo.snippet,
5693
5715
  tags: itemInfo.tags,
5716
+ typeKeywords: itemInfo.typeKeywords,
5694
5717
  title: itemInfo.title,
5695
5718
  thumbnail: itemInfo.thumbnail
5696
5719
  };
@@ -9949,16 +9972,6 @@
9949
9972
  function getUserSession(options = {}) {
9950
9973
  return new arcgisRestAuth.UserSession(options);
9951
9974
  }
9952
- /**
9953
- * Searches for items matching a query and that the caller has access to.
9954
- *
9955
- * @param search Search string (e.g., "q=redlands+map")
9956
- * @return Promise resolving with search results
9957
- * @see https://developers.arcgis.com/rest/users-groups-and-items/search.htm
9958
- */
9959
- function searchItems(search) {
9960
- return portal.searchItems(search);
9961
- }
9962
9975
  /**
9963
9976
  * Adds a forward relationship between two items.
9964
9977
  *
@@ -10098,6 +10111,35 @@
10098
10111
  }
10099
10112
  });
10100
10113
  }
10114
+ /**
10115
+ * Converts a general search into an ISearchOptions structure.
10116
+ *
10117
+ * @param search Search specified in one of three ways
10118
+ * @return Recast search
10119
+ */
10120
+ function convertToISearchOptions(search) {
10121
+ // Convert the search into an ISearchOptions
10122
+ let searchOptions = {
10123
+ q: "",
10124
+ start: 1,
10125
+ num: 100
10126
+ };
10127
+ if (typeof search === "string") {
10128
+ // Insert query into defaults
10129
+ searchOptions.q = search;
10130
+ }
10131
+ else if (search instanceof portal.SearchQueryBuilder) {
10132
+ // Insert query into defaults
10133
+ searchOptions.q = search.toParam();
10134
+ }
10135
+ else { // search is ISearchOptions
10136
+ searchOptions = {
10137
+ ...searchOptions,
10138
+ ...search // request
10139
+ };
10140
+ }
10141
+ return searchOptions;
10142
+ }
10101
10143
  /**
10102
10144
  * Simple validate function to ensure all coordinates are numbers
10103
10145
  * In some cases orgs can have null or undefined coordinate values associated with the org extent
@@ -10174,7 +10216,7 @@
10174
10216
  * @return Original extent if it's already using outSR or the extents projected into the outSR
10175
10217
  */
10176
10218
  function convertExtent(extent, outSR, geometryServiceUrl, authentication) {
10177
- const _requestOptions = Object.assign({}, authentication);
10219
+ const _requestOptions = { authentication };
10178
10220
  return new Promise((resolve, reject) => {
10179
10221
  // tslint:disable-next-line:no-unnecessary-type-assertion
10180
10222
  if (extent.spatialReference.wkid === outSR?.wkid || !outSR) {
@@ -10899,6 +10941,51 @@
10899
10941
  });
10900
10942
  });
10901
10943
  }
10944
+ /**
10945
+ * Searches for items matching a query and that the caller has access to.
10946
+ *
10947
+ * @param search Search string (e.g., "q=redlands+map") or a more detailed structure that can include authentication
10948
+ * @return Promise resolving with search results
10949
+ * @see https://developers.arcgis.com/rest/users-groups-and-items/search.htm
10950
+ */
10951
+ function searchItems(search) {
10952
+ return portal.searchItems(search);
10953
+ }
10954
+ /**
10955
+ * Searches for items matching a query and that the caller has access to, continuing recursively until done.
10956
+ *
10957
+ * @param search Search string (e.g., "q=redlands+map") or a more detailed structure that can include authentication
10958
+ * @param accumulatedResponse Response built from previous requests
10959
+ * @return Promise resolving with search results
10960
+ * @see https://developers.arcgis.com/rest/users-groups-and-items/search.htm
10961
+ */
10962
+ function searchAllItems(search, accumulatedResponse) {
10963
+ // Convert the search into an ISearchOptions
10964
+ const searchOptions = convertToISearchOptions(search);
10965
+ // Provide a base into which results can be concatenated
10966
+ const completeResponse = accumulatedResponse ? accumulatedResponse : {
10967
+ query: searchOptions.q,
10968
+ start: 1,
10969
+ num: 100,
10970
+ nextStart: -1,
10971
+ total: 0,
10972
+ results: []
10973
+ };
10974
+ return new Promise((resolve, reject) => {
10975
+ searchItems(search).then(response => {
10976
+ completeResponse.results = completeResponse.results.concat(response.results);
10977
+ completeResponse.num = completeResponse.total = completeResponse.results.length;
10978
+ if (response.nextStart > 0) {
10979
+ // Insert nextStart into next query
10980
+ searchOptions.start = response.nextStart;
10981
+ resolve(searchAllItems(searchOptions, completeResponse));
10982
+ }
10983
+ else {
10984
+ resolve(completeResponse);
10985
+ }
10986
+ }, e => reject(e));
10987
+ });
10988
+ }
10902
10989
  /**
10903
10990
  * Searches for groups matching criteria.
10904
10991
  *
@@ -10932,7 +11019,7 @@
10932
11019
  */
10933
11020
  function searchAllGroups(searchString, authentication, groups, inPagingParams) {
10934
11021
  const pagingParams = inPagingParams ? inPagingParams : {
10935
- start: 0,
11022
+ start: 1,
10936
11023
  num: 24
10937
11024
  };
10938
11025
  const additionalSearchOptions = {
@@ -10940,6 +11027,7 @@
10940
11027
  sortOrder: "asc",
10941
11028
  ...pagingParams
10942
11029
  };
11030
+ // Provide a base onto which results can be concatenated
10943
11031
  let finalResults = groups ? groups : [];
10944
11032
  return new Promise((resolve, reject) => {
10945
11033
  searchGroups(searchString, authentication, additionalSearchOptions).then(response => {
@@ -10954,6 +11042,46 @@
10954
11042
  }, e => reject(e));
10955
11043
  });
10956
11044
  }
11045
+ /**
11046
+ * Searches for group contents matching criteria recursively.
11047
+ *
11048
+ * @param groupId Group whose contents are to be searched
11049
+ * @param searchString Text for which to search, e.g., 'redlands+map', 'type:"Web Map" -type:"Web Mapping Application"'
11050
+ * @param authentication Credentials for the request to AGO
11051
+ * @param additionalSearchOptions Adjustments to search, such as tranche size and categories of interest; categories
11052
+ * are supplied as an array: each array element consists of one or more categories to be ORed; array elements are ANDed
11053
+ * @param portalUrl Rest Url of the portal to perform the search
11054
+ * @param accumulatedResponse Response built from previous requests
11055
+ * @return A promise that will resolve with a structure with a tranche of results and
11056
+ * describing how many items are available
11057
+ * @see https://developers.arcgis.com/rest/users-groups-and-items/group-content-search.htm
11058
+ * @see https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm
11059
+ */
11060
+ function searchGroupAllContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl, accumulatedResponse) {
11061
+ additionalSearchOptions = additionalSearchOptions ? additionalSearchOptions : {};
11062
+ // Provide a base into which results can be concatenated
11063
+ const completeResponse = accumulatedResponse ? accumulatedResponse : {
11064
+ query: searchString,
11065
+ start: 1,
11066
+ num: 100,
11067
+ nextStart: -1,
11068
+ total: 0,
11069
+ results: []
11070
+ };
11071
+ return new Promise((resolve, reject) => {
11072
+ searchGroupContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl).then(response => {
11073
+ completeResponse.results = completeResponse.results.concat(response.results);
11074
+ completeResponse.num = completeResponse.total = completeResponse.results.length;
11075
+ if (response.nextStart > 0) {
11076
+ additionalSearchOptions.start = response.nextStart;
11077
+ resolve(searchGroupAllContents(groupId, searchString, authentication, additionalSearchOptions, portalUrl, completeResponse));
11078
+ }
11079
+ else {
11080
+ resolve(completeResponse);
11081
+ }
11082
+ }, e => reject(e));
11083
+ });
11084
+ }
10957
11085
  /**
10958
11086
  * Searches for group contents matching criteria.
10959
11087
  *
@@ -11069,6 +11197,27 @@
11069
11197
  portal.updateItem(updateOptions).then(response => (response.success ? resolve(response) : reject(response)), err => reject(err));
11070
11198
  });
11071
11199
  }
11200
+ /**
11201
+ * Updates a group.
11202
+ *
11203
+ * @param groupInfo The base info of a group; note that this content will be serialized, which doesn't work
11204
+ * for binary content
11205
+ * @param authentication Credentials for request
11206
+ * @param additionalParams Updates that are put under the `params` property, which is not serialized
11207
+ * @return A Promise that will resolve with the success/failure status of the request
11208
+ */
11209
+ function updateGroup(groupInfo, authentication, additionalParams) {
11210
+ return new Promise((resolve, reject) => {
11211
+ const updateOptions = {
11212
+ group: groupInfo,
11213
+ authentication,
11214
+ params: {
11215
+ ...(additionalParams ?? {})
11216
+ }
11217
+ };
11218
+ portal.updateGroup(updateOptions).then(response => (response.success ? resolve(response) : reject(response)), err => reject(err));
11219
+ });
11220
+ }
11072
11221
  /**
11073
11222
  * Updates an item.
11074
11223
  *
@@ -14849,6 +14998,7 @@
14849
14998
  exports.convertExtentWithFallback = convertExtentWithFallback;
14850
14999
  exports.convertItemResourceToStorageResource = convertItemResourceToStorageResource;
14851
15000
  exports.convertStorageResourceToItemResource = convertStorageResourceToItemResource;
15001
+ exports.convertToISearchOptions = convertToISearchOptions;
14852
15002
  exports.convertWorkforceItemToTemplate = convertWorkforceItemToTemplate;
14853
15003
  exports.copyAssociatedFilesByType = copyAssociatedFilesByType;
14854
15004
  exports.copyDataIntoItem = copyDataIntoItem;
@@ -14950,6 +15100,7 @@
14950
15100
  exports.getPortalSharingUrlFromAuth = getPortalSharingUrlFromAuth;
14951
15101
  exports.getPortalUrlFromAuth = getPortalUrlFromAuth;
14952
15102
  exports.getProp = getProp;
15103
+ exports.getPropWithDefault = getPropWithDefault;
14953
15104
  exports.getProps = getProps;
14954
15105
  exports.getReplaceValue = getReplaceValue;
14955
15106
  exports.getRequest = getRequest;
@@ -15008,6 +15159,8 @@
15008
15159
  exports.sanitizeURLProtocol = sanitizeURLProtocol;
15009
15160
  exports.saveBlobAsFile = saveBlobAsFile;
15010
15161
  exports.searchAllGroups = searchAllGroups;
15162
+ exports.searchAllItems = searchAllItems;
15163
+ exports.searchGroupAllContents = searchGroupAllContents;
15011
15164
  exports.searchGroupContents = searchGroupContents;
15012
15165
  exports.searchGroups = searchGroups;
15013
15166
  exports.searchItems = searchItems;
@@ -15028,6 +15181,7 @@
15028
15181
  exports.templatizeTracker = templatizeTracker;
15029
15182
  exports.templatizeWorkforce = templatizeWorkforce;
15030
15183
  exports.topologicallySortItems = topologicallySortItems;
15184
+ exports.updateGroup = updateGroup;
15031
15185
  exports.updateItem = updateItem;
15032
15186
  exports.updateItemExtended = updateItemExtended;
15033
15187
  exports.updateItemResourceText = updateItemResourceText;