@esri/hub-common 9.46.1 → 9.49.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 (130) hide show
  1. package/dist/es2017/core/traits/WithCatalog.js +1 -0
  2. package/dist/es2017/core/traits/WithCatalog.js.map +1 -0
  3. package/dist/es2017/index.js +1 -0
  4. package/dist/es2017/index.js.map +1 -1
  5. package/dist/es2017/org/fetchOrgLimits.js +32 -0
  6. package/dist/es2017/org/fetchOrgLimits.js.map +1 -0
  7. package/dist/es2017/org/index.js +1 -0
  8. package/dist/es2017/org/index.js.map +1 -1
  9. package/dist/es2017/search/Catalog.js +346 -0
  10. package/dist/es2017/search/Catalog.js.map +1 -0
  11. package/dist/es2017/search/Collection.js +38 -19
  12. package/dist/es2017/search/Collection.js.map +1 -1
  13. package/dist/es2017/search/_internal/{ipredicate-utils.js → expandPredicate.js} +1 -1
  14. package/dist/es2017/search/_internal/expandPredicate.js.map +1 -0
  15. package/dist/es2017/search/_internal/portalSearchGroups.js +1 -1
  16. package/dist/es2017/search/_internal/portalSearchGroups.js.map +1 -1
  17. package/dist/es2017/search/_internal/portalSearchItems.js +1 -1
  18. package/dist/es2017/search/_internal/portalSearchItems.js.map +1 -1
  19. package/dist/es2017/search/_internal/portalSearchUsers.js +1 -1
  20. package/dist/es2017/search/_internal/portalSearchUsers.js.map +1 -1
  21. package/dist/es2017/search/fetchCatalog.js +46 -0
  22. package/dist/es2017/search/fetchCatalog.js.map +1 -0
  23. package/dist/es2017/search/hubSearch.js +1 -1
  24. package/dist/es2017/search/hubSearch.js.map +1 -1
  25. package/dist/es2017/search/index.js +3 -1
  26. package/dist/es2017/search/index.js.map +1 -1
  27. package/dist/es2017/search/serializeQueryForPortal.js +1 -1
  28. package/dist/es2017/search/serializeQueryForPortal.js.map +1 -1
  29. package/dist/es2017/search/upgradeCatalogSchema.js +66 -0
  30. package/dist/es2017/search/upgradeCatalogSchema.js.map +1 -0
  31. package/dist/es2017/types/IMessage.js +1 -0
  32. package/dist/es2017/types/IMessage.js.map +1 -0
  33. package/dist/es2017/types/index.js +2 -0
  34. package/dist/es2017/types/index.js.map +1 -0
  35. package/dist/esm/core/traits/WithCatalog.js +1 -0
  36. package/dist/esm/core/traits/WithCatalog.js.map +1 -0
  37. package/dist/esm/index.js +1 -0
  38. package/dist/esm/index.js.map +1 -1
  39. package/dist/esm/org/fetchOrgLimits.js +32 -0
  40. package/dist/esm/org/fetchOrgLimits.js.map +1 -0
  41. package/dist/esm/org/index.js +1 -0
  42. package/dist/esm/org/index.js.map +1 -1
  43. package/dist/esm/search/Catalog.js +404 -0
  44. package/dist/esm/search/Catalog.js.map +1 -0
  45. package/dist/esm/search/Collection.js +40 -24
  46. package/dist/esm/search/Collection.js.map +1 -1
  47. package/dist/esm/search/_internal/{ipredicate-utils.js → expandPredicate.js} +1 -1
  48. package/dist/esm/search/_internal/expandPredicate.js.map +1 -0
  49. package/dist/esm/search/_internal/portalSearchGroups.js +1 -1
  50. package/dist/esm/search/_internal/portalSearchGroups.js.map +1 -1
  51. package/dist/esm/search/_internal/portalSearchItems.js +1 -1
  52. package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
  53. package/dist/esm/search/_internal/portalSearchUsers.js +1 -1
  54. package/dist/esm/search/_internal/portalSearchUsers.js.map +1 -1
  55. package/dist/esm/search/fetchCatalog.js +59 -0
  56. package/dist/esm/search/fetchCatalog.js.map +1 -0
  57. package/dist/esm/search/hubSearch.js +1 -1
  58. package/dist/esm/search/hubSearch.js.map +1 -1
  59. package/dist/esm/search/index.js +3 -1
  60. package/dist/esm/search/index.js.map +1 -1
  61. package/dist/esm/search/serializeQueryForPortal.js +1 -1
  62. package/dist/esm/search/serializeQueryForPortal.js.map +1 -1
  63. package/dist/esm/search/upgradeCatalogSchema.js +66 -0
  64. package/dist/esm/search/upgradeCatalogSchema.js.map +1 -0
  65. package/dist/esm/types/IMessage.js +1 -0
  66. package/dist/esm/types/IMessage.js.map +1 -0
  67. package/dist/esm/types/index.js +2 -0
  68. package/dist/esm/types/index.js.map +1 -0
  69. package/dist/node/core/traits/WithCatalog.js +3 -0
  70. package/dist/node/core/traits/WithCatalog.js.map +1 -0
  71. package/dist/node/index.js +1 -0
  72. package/dist/node/index.js.map +1 -1
  73. package/dist/node/org/fetchOrgLimits.js +37 -0
  74. package/dist/node/org/fetchOrgLimits.js.map +1 -0
  75. package/dist/node/org/index.js +1 -0
  76. package/dist/node/org/index.js.map +1 -1
  77. package/dist/node/search/Catalog.js +350 -0
  78. package/dist/node/search/Catalog.js.map +1 -0
  79. package/dist/node/search/Collection.js +37 -18
  80. package/dist/node/search/Collection.js.map +1 -1
  81. package/dist/node/search/_internal/{ipredicate-utils.js → expandPredicate.js} +1 -1
  82. package/dist/node/search/_internal/expandPredicate.js.map +1 -0
  83. package/dist/node/search/_internal/portalSearchGroups.js +2 -2
  84. package/dist/node/search/_internal/portalSearchGroups.js.map +1 -1
  85. package/dist/node/search/_internal/portalSearchItems.js +2 -2
  86. package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
  87. package/dist/node/search/_internal/portalSearchUsers.js +2 -2
  88. package/dist/node/search/_internal/portalSearchUsers.js.map +1 -1
  89. package/dist/node/search/fetchCatalog.js +50 -0
  90. package/dist/node/search/fetchCatalog.js.map +1 -0
  91. package/dist/node/search/hubSearch.js +1 -1
  92. package/dist/node/search/hubSearch.js.map +1 -1
  93. package/dist/node/search/index.js +3 -1
  94. package/dist/node/search/index.js.map +1 -1
  95. package/dist/node/search/serializeQueryForPortal.js +2 -2
  96. package/dist/node/search/serializeQueryForPortal.js.map +1 -1
  97. package/dist/node/search/upgradeCatalogSchema.js +71 -0
  98. package/dist/node/search/upgradeCatalogSchema.js.map +1 -0
  99. package/dist/node/types/IMessage.js +3 -0
  100. package/dist/node/types/IMessage.js.map +1 -0
  101. package/dist/node/types/index.js +5 -0
  102. package/dist/node/types/index.js.map +1 -0
  103. package/dist/types/core/traits/WithCatalog.d.ts +7 -0
  104. package/dist/types/core/types/IHubTimeline.d.ts +15 -0
  105. package/dist/types/index.d.ts +1 -0
  106. package/dist/types/org/fetchOrgLimits.d.ts +35 -0
  107. package/dist/types/org/index.d.ts +1 -0
  108. package/dist/types/search/Catalog.d.ts +143 -0
  109. package/dist/types/search/Collection.d.ts +23 -2
  110. package/dist/types/search/_internal/{ipredicate-utils.d.ts → expandPredicate.d.ts} +0 -0
  111. package/dist/types/search/fetchCatalog.d.ts +10 -0
  112. package/dist/types/search/index.d.ts +3 -1
  113. package/dist/types/search/types/IHubSearchOptions.d.ts +5 -1
  114. package/dist/types/search/types/IHubSearchResponse.d.ts +5 -0
  115. package/dist/types/search/upgradeCatalogSchema.d.ts +12 -0
  116. package/dist/types/types/IMessage.d.ts +32 -0
  117. package/dist/types/types/index.d.ts +1 -0
  118. package/dist/umd/common.umd.js +666 -27
  119. package/dist/umd/common.umd.js.map +1 -1
  120. package/package.json +1 -1
  121. package/dist/es2017/search/_internal/ipredicate-utils.js.map +0 -1
  122. package/dist/es2017/search/convertCatalog.js +0 -33
  123. package/dist/es2017/search/convertCatalog.js.map +0 -1
  124. package/dist/esm/search/_internal/ipredicate-utils.js.map +0 -1
  125. package/dist/esm/search/convertCatalog.js +0 -33
  126. package/dist/esm/search/convertCatalog.js.map +0 -1
  127. package/dist/node/search/_internal/ipredicate-utils.js.map +0 -1
  128. package/dist/node/search/convertCatalog.js +0 -37
  129. package/dist/node/search/convertCatalog.js.map +0 -1
  130. package/dist/types/search/convertCatalog.d.ts +0 -6
@@ -1,5 +1,5 @@
1
1
  /* @preserve
2
- * @esri/hub-common - v9.46.0 - Fri Jul 15 2022 18:16:25 GMT+0000 (Coordinated Universal Time)
2
+ * @esri/hub-common - v9.48.0 - Thu Jul 21 2022 15:41:36 GMT+0000 (Coordinated Universal Time)
3
3
  * Copyright (c) 2022 Environmental Systems Research Institute, Inc.
4
4
  * Apache-2.0
5
5
  */
@@ -10011,6 +10011,37 @@
10011
10011
  return getPortal(orgId, __assign(__assign({}, options), { portal: basePortalUrl }));
10012
10012
  };
10013
10013
 
10014
+ /**
10015
+ * Generic function to fetch org limits
10016
+ * @param orgId
10017
+ * @param limitsType
10018
+ * @param limitName
10019
+ * @param options
10020
+ * @returns
10021
+ */
10022
+ function fetchOrgLimits(orgId, limitsType, limitName, options) {
10023
+ var portal = options.authentication.portal;
10024
+ var url = portal + "/portals/" + orgId + "/limits?limitsType=" + limitsType + "&limitName=" + limitName + "&f=json";
10025
+ return request(url, options);
10026
+ }
10027
+ /**
10028
+ * Fetch the maximum number of groups a user can create in an org
10029
+ * @param orgId
10030
+ * @param options
10031
+ * @returns
10032
+ */
10033
+ function fetchMaxNumUserGroupsLimit(orgId, options) {
10034
+ return fetchOrgLimits(orgId, "Groups", "MaxNumUserGroups", options)
10035
+ .then(function (response) {
10036
+ return response.limitValue;
10037
+ })
10038
+ .catch(function (_) {
10039
+ // it's possible that the org doesn't have this property set, and
10040
+ // the api will return a 500 error. So we just return the default value
10041
+ return 512;
10042
+ });
10043
+ }
10044
+
10014
10045
  /**
10015
10046
  * Parse metadataxml into json object
10016
10047
  * @param metadataXml
@@ -14954,36 +14985,68 @@
14954
14985
  return __assign(__assign({}, state), facetState);
14955
14986
  }
14956
14987
 
14988
+ var CATALOG_SCHEMA_VERSION = 1.0;
14957
14989
  /**
14958
- * Convert the original site catalog structure into a formal ICatalog
14959
- * @param original
14990
+ * Apply schema upgrades to Catalog objects
14991
+ * @param catalog
14992
+ * @returns
14960
14993
  */
14961
- function convertCatalog(original) {
14962
- var catalog = {
14963
- schemaVersion: 1,
14964
- title: "Default Catalog",
14965
- scopes: {
14966
- item: {
14967
- targetEntity: "item",
14968
- filters: [],
14969
- },
14970
- },
14971
- collections: [],
14972
- };
14973
- var rawGroups = getProp(original, "groups");
14974
- var groups = [];
14975
- if (Array.isArray(rawGroups) && rawGroups.length) {
14976
- groups = rawGroups;
14994
+ function upgradeCatalogSchema(catalog) {
14995
+ var clone = cloneObject$1(catalog);
14996
+ if (getProp(clone, "schemaVersion") === CATALOG_SCHEMA_VERSION) {
14997
+ return clone;
14977
14998
  }
14978
- else if (typeof rawGroups === "string") {
14979
- groups = [rawGroups];
14999
+ else {
15000
+ // apply migrations in order
15001
+ clone = applyCatalogSchema(clone);
15002
+ return clone;
14980
15003
  }
14981
- if (groups.length) {
14982
- catalog.scopes.item.filters.push({
14983
- predicates: [{ group: groups }],
14984
- });
15004
+ }
15005
+ /**
15006
+ * Apply the Catalog schema to the original, unversioned
15007
+ * site catalog objects
15008
+ * @param original
15009
+ * @returns
15010
+ */
15011
+ function applyCatalogSchema(original) {
15012
+ if (getProp(original, "schemaVersion") > 1.0) {
15013
+ return original;
15014
+ }
15015
+ else {
15016
+ var catalog = {
15017
+ schemaVersion: 1,
15018
+ title: "Default Catalog",
15019
+ scopes: {
15020
+ item: {
15021
+ targetEntity: "item",
15022
+ filters: [],
15023
+ },
15024
+ },
15025
+ collections: [],
15026
+ };
15027
+ var rawGroups = getProp(original, "groups");
15028
+ var groups = [];
15029
+ if (Array.isArray(rawGroups) && rawGroups.length) {
15030
+ groups = rawGroups;
15031
+ }
15032
+ else if (typeof rawGroups === "string") {
15033
+ groups = [rawGroups];
15034
+ }
15035
+ if (groups.length) {
15036
+ catalog.scopes.item.filters.push({
15037
+ predicates: [{ group: groups }],
15038
+ });
15039
+ }
15040
+ return catalog;
14985
15041
  }
14986
- return catalog;
15042
+ }
15043
+ /**
15044
+ * DEPRECATED: Use upgradeCatalogSchema(...)
15045
+ * @param original
15046
+ */
15047
+ /* istanbul ignore next */
15048
+ function convertCatalog(original) {
15049
+ return upgradeCatalogSchema(original);
14987
15050
  }
14988
15051
 
14989
15052
  /**
@@ -18782,13 +18845,584 @@
18782
18845
  };
18783
18846
  fn = getProp(fnHash, apiType + "." + filterType);
18784
18847
  if (!fn) {
18785
- throw new HubError$1("hubSearch", "Search via \"" + filterType + "\" filter against \"" + apiType + "\" api is not implemented");
18848
+ throw new HubError$1("hubSearch", "Search via \"" + filterType + "\" filter against \"" + apiType + "\" api is not implemented. Please ensure \"targetEntity\" is defined on the query.");
18786
18849
  }
18787
18850
  return [2 /*return*/, fn(cloneObject$1(query), options)];
18788
18851
  });
18789
18852
  });
18790
18853
  }
18791
18854
 
18855
+ /**
18856
+ * Collection Class
18857
+ *
18858
+ * Abstracts searching a Collection
18859
+ *
18860
+ * For more information, check out the [Catalog & Collection Guide](/hub.js/guides/concepts/catalog-collection/)
18861
+ */
18862
+ var Collection = /** @class */ (function () {
18863
+ function Collection(collection, context) {
18864
+ this._collection = collection;
18865
+ this._context = context;
18866
+ }
18867
+ /**
18868
+ * Create an instance of a Collection from a JSON object
18869
+ * @param collection
18870
+ * @param context
18871
+ * @returns
18872
+ */
18873
+ Collection.fromJson = function (collection, context) {
18874
+ return new Collection(collection, context);
18875
+ };
18876
+ /**
18877
+ * Return the JSON object backing the instance
18878
+ * @returns
18879
+ */
18880
+ Collection.prototype.toJson = function () {
18881
+ return cloneObject$1(this._collection);
18882
+ };
18883
+ Object.defineProperty(Collection.prototype, "label", {
18884
+ // Getters
18885
+ get: function () {
18886
+ return this._collection.label;
18887
+ },
18888
+ enumerable: false,
18889
+ configurable: true
18890
+ });
18891
+ Object.defineProperty(Collection.prototype, "key", {
18892
+ get: function () {
18893
+ return this._collection.key;
18894
+ },
18895
+ enumerable: false,
18896
+ configurable: true
18897
+ });
18898
+ Object.defineProperty(Collection.prototype, "include", {
18899
+ get: function () {
18900
+ return this._collection.include || [];
18901
+ },
18902
+ enumerable: false,
18903
+ configurable: true
18904
+ });
18905
+ Object.defineProperty(Collection.prototype, "scope", {
18906
+ get: function () {
18907
+ return this._collection.scope;
18908
+ },
18909
+ enumerable: false,
18910
+ configurable: true
18911
+ });
18912
+ Object.defineProperty(Collection.prototype, "sortField", {
18913
+ get: function () {
18914
+ return this._collection.sortField || "title";
18915
+ },
18916
+ enumerable: false,
18917
+ configurable: true
18918
+ });
18919
+ Object.defineProperty(Collection.prototype, "sortDirection", {
18920
+ get: function () {
18921
+ return this._collection.sortDirection || "asc";
18922
+ },
18923
+ enumerable: false,
18924
+ configurable: true
18925
+ });
18926
+ Object.defineProperty(Collection.prototype, "targetEntity", {
18927
+ get: function () {
18928
+ return this._collection.targetEntity;
18929
+ },
18930
+ enumerable: false,
18931
+ configurable: true
18932
+ });
18933
+ /**
18934
+ * Search the collection using a string or IQuery
18935
+ * @param query
18936
+ * @param options
18937
+ * @returns
18938
+ */
18939
+ Collection.prototype.search = function (query, options) {
18940
+ if (options === void 0) { options = {}; }
18941
+ return __awaiter(this, void 0, void 0, function () {
18942
+ var qry, opts;
18943
+ return __generator(this, function (_a) {
18944
+ if (typeof query === "string") {
18945
+ // construct a query from that...
18946
+ qry = {
18947
+ targetEntity: this._collection.targetEntity,
18948
+ filters: [
18949
+ {
18950
+ predicates: [
18951
+ {
18952
+ term: query,
18953
+ },
18954
+ ],
18955
+ },
18956
+ ],
18957
+ };
18958
+ }
18959
+ else {
18960
+ qry = query;
18961
+ }
18962
+ // TODO: What should happen when a Query is passed in that has a targetEntity that doesn't match the collection's targetEntity?
18963
+ // merge the passed in query w/ the scope
18964
+ qry.filters = __spreadArrays(qry.filters, this.scope.filters);
18965
+ opts = cloneObject$1(options);
18966
+ opts.requestOptions = this._context.hubRequestOptions;
18967
+ // inject default sort info if not specified
18968
+ opts.sortField = options.sortField || this.sortField;
18969
+ opts.sortOrder = options.sortOrder || this.sortDirection;
18970
+ // inject default includes if not specified
18971
+ opts.include = options.include || this.include;
18972
+ // execute the search and return results
18973
+ return [2 /*return*/, hubSearch(qry, opts)];
18974
+ });
18975
+ });
18976
+ };
18977
+ return Collection;
18978
+ }());
18979
+
18980
+ /**
18981
+ * Fetch a IHubCatalog from a backing item.
18982
+ * This will apply schema upgrades to the structure
18983
+ * @param identifier
18984
+ * @param requestOptions
18985
+ * @returns
18986
+ */
18987
+ function fetchCatalog(identifier, requestOptions) {
18988
+ return __awaiter(this, void 0, void 0, function () {
18989
+ var getPrms, url, fetched;
18990
+ return __generator(this, function (_a) {
18991
+ switch (_a.label) {
18992
+ case 0:
18993
+ // identifier can be a guid or a url
18994
+ if (identifier.indexOf("http") === 0) {
18995
+ url = identifier;
18996
+ // get down the the hostname
18997
+ url = stripProtocol(url);
18998
+ // if url does not include a hash (i.e. it's not portal)
18999
+ // then we want to split on the first slash to get the hostname
19000
+ // lookupDomain will handle the enterprise base urls
19001
+ if (!url.includes("#")) {
19002
+ url = url.split("/")[0];
19003
+ }
19004
+ getPrms = lookupDomain(url, requestOptions)
19005
+ // get the item's data, and read the catalog out of it
19006
+ .then(function (_a) {
19007
+ var siteId = _a.siteId;
19008
+ return getItemData(siteId, requestOptions);
19009
+ })
19010
+ .then(function (data) {
19011
+ return upgradeCatalogSchema(data.catalog || {});
19012
+ });
19013
+ }
19014
+ else if (isGuid(identifier)) {
19015
+ // get the item's data, and read the catalog out of it
19016
+ getPrms = getItemData(identifier, requestOptions).then(function (data) {
19017
+ return upgradeCatalogSchema(data.catalog || {});
19018
+ });
19019
+ }
19020
+ else {
19021
+ throw new HubError$1("Catalog.create", "Identifier must be a url, guid");
19022
+ }
19023
+ return [4 /*yield*/, getPrms];
19024
+ case 1:
19025
+ fetched = _a.sent();
19026
+ return [2 /*return*/, fetched];
19027
+ }
19028
+ });
19029
+ });
19030
+ }
19031
+
19032
+ /**
19033
+ * Catalog Class
19034
+ *
19035
+ * Abstracts working with Catalogs and fetching collections with
19036
+ * the correct scope applied.
19037
+ *
19038
+ * For more information, check out the [Catalog & Collection Guide](/hub.js/guides/concepts/catalog-collection/)
19039
+ */
19040
+ var Catalog = /** @class */ (function () {
19041
+ // internal - use static factory methods
19042
+ function Catalog(catalog, context) {
19043
+ this._catalog = catalog;
19044
+ this._context = context;
19045
+ }
19046
+ /**
19047
+ * Create a Collection instance from a Catalog json object, a site url or itemId
19048
+ * '''js
19049
+ * const catalog = await Catalog.create('https://site-org.hub.arcgis.com', context);
19050
+ * '''
19051
+ *
19052
+ * @param identifier
19053
+ * @param context
19054
+ * @returns
19055
+ */
19056
+ Catalog.init = function (identifier, context) {
19057
+ return __awaiter(this, void 0, void 0, function () {
19058
+ var mgr, fetched;
19059
+ return __generator(this, function (_a) {
19060
+ switch (_a.label) {
19061
+ case 0:
19062
+ if (!!context) return [3 /*break*/, 2];
19063
+ return [4 /*yield*/, ArcGISContextManager.create()];
19064
+ case 1:
19065
+ mgr = _a.sent();
19066
+ context = mgr.context;
19067
+ _a.label = 2;
19068
+ case 2: return [4 /*yield*/, fetchCatalog(identifier, context.hubRequestOptions)];
19069
+ case 3:
19070
+ fetched = _a.sent();
19071
+ // return an instance
19072
+ return [2 /*return*/, new Catalog(fetched, context)];
19073
+ }
19074
+ });
19075
+ });
19076
+ };
19077
+ /**
19078
+ * Create a Catalog instance from a Catalog Json object
19079
+ * @param json
19080
+ * @param context
19081
+ * @returns
19082
+ */
19083
+ Catalog.fromJson = function (json, context) {
19084
+ // ensure it's in the latest structure
19085
+ var catalog = upgradeCatalogSchema(json);
19086
+ return new Catalog(catalog, context);
19087
+ };
19088
+ /**
19089
+ * Return the JSON object backing the instance
19090
+ * @returns
19091
+ */
19092
+ Catalog.prototype.toJson = function () {
19093
+ return cloneObject$1(this._catalog);
19094
+ };
19095
+ Object.defineProperty(Catalog.prototype, "schemaVersion", {
19096
+ /**
19097
+ * Return the schema version
19098
+ */
19099
+ get: function () {
19100
+ return this._catalog.schemaVersion;
19101
+ },
19102
+ enumerable: false,
19103
+ configurable: true
19104
+ });
19105
+ Object.defineProperty(Catalog.prototype, "title", {
19106
+ /**
19107
+ * Title getter
19108
+ */
19109
+ get: function () {
19110
+ return this._catalog.title;
19111
+ },
19112
+ /**
19113
+ * Title setter
19114
+ */
19115
+ set: function (v) {
19116
+ this._catalog.title = v;
19117
+ },
19118
+ enumerable: false,
19119
+ configurable: true
19120
+ });
19121
+ Object.defineProperty(Catalog.prototype, "scopes", {
19122
+ /**
19123
+ * Return the existing scopes hash
19124
+ */
19125
+ get: function () {
19126
+ return this._catalog.scopes;
19127
+ },
19128
+ enumerable: false,
19129
+ configurable: true
19130
+ });
19131
+ Object.defineProperty(Catalog.prototype, "availableScopes", {
19132
+ /**
19133
+ * Return an array of the entity types available in this Catalog
19134
+ */
19135
+ get: function () {
19136
+ return Object.keys(this.scopes);
19137
+ },
19138
+ enumerable: false,
19139
+ configurable: true
19140
+ });
19141
+ /**
19142
+ * Get the scope's query for a particular entity type
19143
+ * @param type
19144
+ * @returns
19145
+ */
19146
+ Catalog.prototype.getScope = function (type) {
19147
+ return this._catalog.scopes[type];
19148
+ };
19149
+ /**
19150
+ * Set the scope for a specific entity type
19151
+ * @param type
19152
+ * @param query
19153
+ */
19154
+ Catalog.prototype.setScope = function (type, query) {
19155
+ this._catalog.scopes[type] = query;
19156
+ };
19157
+ Object.defineProperty(Catalog.prototype, "collections", {
19158
+ /**
19159
+ * Get the collections array. Returns simple objects not Collection instances
19160
+ */
19161
+ get: function () {
19162
+ return this._catalog.collections || [];
19163
+ },
19164
+ enumerable: false,
19165
+ configurable: true
19166
+ });
19167
+ Object.defineProperty(Catalog.prototype, "collectionNames", {
19168
+ /**
19169
+ * Get the names of the collections
19170
+ */
19171
+ get: function () {
19172
+ return mapBy("key", this.collections);
19173
+ },
19174
+ enumerable: false,
19175
+ configurable: true
19176
+ });
19177
+ /**
19178
+ * Get a Collection instance by name
19179
+ * @param name
19180
+ * @returns
19181
+ */
19182
+ Catalog.prototype.getCollection = function (name) {
19183
+ var json = this.collections.find(function (entry) { return entry.key === name; });
19184
+ if (json) {
19185
+ // clone it then merge in the associated scope filter
19186
+ var clone = cloneObject$1(json);
19187
+ var catalogScope = this.getScope(clone.scope.targetEntity);
19188
+ if (catalogScope === null || catalogScope === void 0 ? void 0 : catalogScope.filters) {
19189
+ clone.scope.filters = __spreadArrays(clone.scope.filters, catalogScope.filters);
19190
+ }
19191
+ return Collection.fromJson(clone, this._context);
19192
+ }
19193
+ else {
19194
+ throw new HubError$1("getCollection", "Collection \"" + name + "\" is not present in the Catalog");
19195
+ }
19196
+ };
19197
+ /**
19198
+ * Search for Items
19199
+ * Will throw if the Catalog does not have a scope defined for items
19200
+ * @param query
19201
+ * @param options
19202
+ * @returns
19203
+ */
19204
+ Catalog.prototype.searchItems = function (query, options) {
19205
+ if (options === void 0) { options = {}; }
19206
+ if (!this.getScope("item")) {
19207
+ var result = this.getEmptyResult();
19208
+ result.messages = [
19209
+ {
19210
+ code: "missingScope",
19211
+ message: "Catalog does not have a scope for items",
19212
+ data: {
19213
+ scope: "item",
19214
+ },
19215
+ },
19216
+ ];
19217
+ return Promise.resolve(result);
19218
+ }
19219
+ else {
19220
+ // ensure it's an item search
19221
+ options.targetEntity = "item";
19222
+ return this.search(query, options);
19223
+ }
19224
+ };
19225
+ /**
19226
+ * Search for Groups
19227
+ * Will throw if the Catalog does not have a scope defined for groups
19228
+ * @param query
19229
+ * @param options
19230
+ * @returns
19231
+ */
19232
+ Catalog.prototype.searchGroups = function (query, options) {
19233
+ if (options === void 0) { options = {}; }
19234
+ if (!this.getScope("group")) {
19235
+ var result = this.getEmptyResult();
19236
+ result.messages = [
19237
+ {
19238
+ code: "missingScope",
19239
+ message: "Catalog does not have a scope for groups",
19240
+ data: {
19241
+ scope: "group",
19242
+ },
19243
+ },
19244
+ ];
19245
+ return Promise.resolve(result);
19246
+ }
19247
+ else {
19248
+ // ensure it's an group search
19249
+ options.targetEntity = "group";
19250
+ return this.search(query, options);
19251
+ }
19252
+ };
19253
+ /**
19254
+ * Search for Users
19255
+ * Will throw if the Catalog does not have a scope defined for users
19256
+ * @param query
19257
+ * @param options
19258
+ * @returns
19259
+ */
19260
+ Catalog.prototype.searchUsers = function (query, options) {
19261
+ if (options === void 0) { options = {}; }
19262
+ if (!this.getScope("user")) {
19263
+ var result = this.getEmptyResult();
19264
+ result.messages = [
19265
+ {
19266
+ code: "missingScope",
19267
+ message: "Catalog does not have a scope for user",
19268
+ data: {
19269
+ scope: "user",
19270
+ },
19271
+ },
19272
+ ];
19273
+ return Promise.resolve(result);
19274
+ }
19275
+ else {
19276
+ // ensure it's an group search
19277
+ options.targetEntity = "user";
19278
+ return this.search(query, options);
19279
+ }
19280
+ };
19281
+ /**
19282
+ * Execute a search against all the collections in the Catalog
19283
+ * @param query
19284
+ * @param options
19285
+ * @returns
19286
+ */
19287
+ Catalog.prototype.searchCollections = function (query, options) {
19288
+ if (options === void 0) { options = {}; }
19289
+ return __awaiter(this, void 0, void 0, function () {
19290
+ var qry, promiseKeys, promises, responses, hash, i;
19291
+ var _this = this;
19292
+ return __generator(this, function (_a) {
19293
+ switch (_a.label) {
19294
+ case 0:
19295
+ qry = {
19296
+ targetEntity: "item",
19297
+ filters: [
19298
+ {
19299
+ predicates: [
19300
+ {
19301
+ term: query,
19302
+ },
19303
+ ],
19304
+ },
19305
+ ],
19306
+ };
19307
+ promiseKeys = [];
19308
+ promises = this.collectionNames.map(function (name) {
19309
+ var col = _this.getCollection(name);
19310
+ promiseKeys.push(name);
19311
+ qry.targetEntity = col.targetEntity;
19312
+ return col.search(qry, options);
19313
+ });
19314
+ return [4 /*yield*/, Promise.all(promises)];
19315
+ case 1:
19316
+ responses = _a.sent();
19317
+ hash = {};
19318
+ for (i = 0; i < promiseKeys.length; i++) {
19319
+ hash[promiseKeys[i]] = responses[i];
19320
+ }
19321
+ return [2 /*return*/, hash];
19322
+ }
19323
+ });
19324
+ });
19325
+ };
19326
+ /**
19327
+ * Execute a search against all the scopes in the Catalog
19328
+ * @param query
19329
+ * @param options
19330
+ * @returns
19331
+ */
19332
+ Catalog.prototype.searchScopes = function (query, options) {
19333
+ if (options === void 0) { options = {}; }
19334
+ return __awaiter(this, void 0, void 0, function () {
19335
+ var qry, promiseKeys, promises, responses, hash, i;
19336
+ var _this = this;
19337
+ return __generator(this, function (_a) {
19338
+ switch (_a.label) {
19339
+ case 0:
19340
+ qry = {
19341
+ targetEntity: "item",
19342
+ filters: [
19343
+ {
19344
+ predicates: [
19345
+ {
19346
+ term: query,
19347
+ },
19348
+ ],
19349
+ },
19350
+ ],
19351
+ };
19352
+ promiseKeys = [];
19353
+ promises = this.availableScopes.map(function (name) {
19354
+ promiseKeys.push(name);
19355
+ // make clones
19356
+ var qryClone = cloneObject$1(qry);
19357
+ var optsClone = cloneObject$1(options);
19358
+ // set the target entity
19359
+ qryClone.targetEntity = name;
19360
+ optsClone.targetEntity = name;
19361
+ // return the search promise
19362
+ return _this.search(qryClone, optsClone);
19363
+ });
19364
+ return [4 /*yield*/, Promise.all(promises)];
19365
+ case 1:
19366
+ responses = _a.sent();
19367
+ hash = {};
19368
+ for (i = 0; i < promiseKeys.length; i++) {
19369
+ hash[promiseKeys[i]] = responses[i];
19370
+ }
19371
+ return [2 /*return*/, hash];
19372
+ }
19373
+ });
19374
+ });
19375
+ };
19376
+ /**
19377
+ * Execute a search against the Catalog as a whole
19378
+ * @param query
19379
+ * @param targetEntity
19380
+ * @returns
19381
+ */
19382
+ Catalog.prototype.search = function (query, options) {
19383
+ var targetEntity = options.targetEntity;
19384
+ var qry;
19385
+ if (typeof query === "string") {
19386
+ qry = {
19387
+ targetEntity: targetEntity,
19388
+ filters: [
19389
+ {
19390
+ predicates: [
19391
+ {
19392
+ term: query,
19393
+ },
19394
+ ],
19395
+ },
19396
+ ],
19397
+ };
19398
+ }
19399
+ else {
19400
+ qry = cloneObject$1(query);
19401
+ }
19402
+ // Now merge in catalog scope level filters
19403
+ qry.filters = __spreadArrays(qry.filters, this.getScope(targetEntity).filters);
19404
+ var opts = cloneObject$1(options);
19405
+ // An Catalog instance always uses the context so we remove/replace any passed in auth
19406
+ delete opts.authentication;
19407
+ opts.requestOptions = this._context.hubRequestOptions;
19408
+ return hubSearch(qry, opts);
19409
+ };
19410
+ /**
19411
+ * Construct an empty result. Returned when a search is performed against an entity type that
19412
+ * does not have a scope defined.
19413
+ * @returns
19414
+ */
19415
+ Catalog.prototype.getEmptyResult = function () {
19416
+ return {
19417
+ results: [],
19418
+ total: 0,
19419
+ hasNext: false,
19420
+ next: null,
19421
+ };
19422
+ };
19423
+ return Catalog;
19424
+ }());
19425
+
18792
19426
  /**
18793
19427
  * Enrich a generic search result
18794
19428
  * @param group
@@ -20399,6 +21033,8 @@
20399
21033
 
20400
21034
  exports.ArcGISContext = ArcGISContext;
20401
21035
  exports.ArcGISContextManager = ArcGISContextManager;
21036
+ exports.Catalog = Catalog;
21037
+ exports.Collection = Collection;
20402
21038
  exports.DEFAULT_THEME = DEFAULT_THEME;
20403
21039
  exports.ENTERPRISE_SITE_ITEM_TYPE = ENTERPRISE_SITE_ITEM_TYPE;
20404
21040
  exports.GLOBAL_EXTENT = GLOBAL_EXTENT;
@@ -20545,8 +21181,10 @@
20545
21181
  exports.fetchContent = fetchContent;
20546
21182
  exports.fetchHubTranslation = fetchHubTranslation;
20547
21183
  exports.fetchImageAsBlob = fetchImageAsBlob;
21184
+ exports.fetchMaxNumUserGroupsLimit = fetchMaxNumUserGroupsLimit;
20548
21185
  exports.fetchModelFromItem = fetchModelFromItem;
20549
21186
  exports.fetchOrg = fetchOrg;
21187
+ exports.fetchOrgLimits = fetchOrgLimits;
20550
21188
  exports.fetchProject = fetchProject;
20551
21189
  exports.fetchSite = fetchSite;
20552
21190
  exports.fetchSiteModel = fetchSiteModel;
@@ -20708,6 +21346,7 @@
20708
21346
  exports.updateModel = updateModel;
20709
21347
  exports.updateProject = updateProject;
20710
21348
  exports.updateSite = updateSite;
21349
+ exports.upgradeCatalogSchema = upgradeCatalogSchema;
20711
21350
  exports.upgradeProtocol = upgradeProtocol;
20712
21351
  exports.upgradeSiteSchema = upgradeSiteSchema;
20713
21352
  exports.uploadResourcesFromUrl = uploadResourcesFromUrl;