@esri/hub-common 9.47.0 → 9.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es2017/core/traits/WithCatalog.js +1 -0
- package/dist/es2017/core/traits/WithCatalog.js.map +1 -0
- package/dist/es2017/index.js +1 -0
- package/dist/es2017/index.js.map +1 -1
- package/dist/es2017/org/fetchOrgLimits.js +32 -0
- package/dist/es2017/org/fetchOrgLimits.js.map +1 -0
- package/dist/es2017/org/index.js +1 -0
- package/dist/es2017/org/index.js.map +1 -1
- package/dist/es2017/search/Catalog.js +346 -0
- package/dist/es2017/search/Catalog.js.map +1 -0
- package/dist/es2017/search/Collection.js +38 -19
- package/dist/es2017/search/Collection.js.map +1 -1
- package/dist/es2017/search/_internal/{ipredicate-utils.js → expandPredicate.js} +1 -1
- package/dist/es2017/search/_internal/expandPredicate.js.map +1 -0
- package/dist/es2017/search/_internal/portalSearchGroups.js +1 -1
- package/dist/es2017/search/_internal/portalSearchGroups.js.map +1 -1
- package/dist/es2017/search/_internal/portalSearchItems.js +1 -1
- package/dist/es2017/search/_internal/portalSearchItems.js.map +1 -1
- package/dist/es2017/search/_internal/portalSearchUsers.js +1 -1
- package/dist/es2017/search/_internal/portalSearchUsers.js.map +1 -1
- package/dist/es2017/search/fetchCatalog.js +46 -0
- package/dist/es2017/search/fetchCatalog.js.map +1 -0
- package/dist/es2017/search/hubSearch.js +1 -1
- package/dist/es2017/search/hubSearch.js.map +1 -1
- package/dist/es2017/search/index.js +3 -1
- package/dist/es2017/search/index.js.map +1 -1
- package/dist/es2017/search/serializeQueryForPortal.js +2 -1
- package/dist/es2017/search/serializeQueryForPortal.js.map +1 -1
- package/dist/es2017/search/upgradeCatalogSchema.js +66 -0
- package/dist/es2017/search/upgradeCatalogSchema.js.map +1 -0
- package/dist/es2017/types/IMessage.js +1 -0
- package/dist/es2017/types/IMessage.js.map +1 -0
- package/dist/es2017/types/index.js +2 -0
- package/dist/es2017/types/index.js.map +1 -0
- package/dist/esm/core/traits/WithCatalog.js +1 -0
- package/dist/esm/core/traits/WithCatalog.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/org/fetchOrgLimits.js +32 -0
- package/dist/esm/org/fetchOrgLimits.js.map +1 -0
- package/dist/esm/org/index.js +1 -0
- package/dist/esm/org/index.js.map +1 -1
- package/dist/esm/search/Catalog.js +404 -0
- package/dist/esm/search/Catalog.js.map +1 -0
- package/dist/esm/search/Collection.js +40 -24
- package/dist/esm/search/Collection.js.map +1 -1
- package/dist/esm/search/_internal/{ipredicate-utils.js → expandPredicate.js} +1 -1
- package/dist/esm/search/_internal/expandPredicate.js.map +1 -0
- package/dist/esm/search/_internal/portalSearchGroups.js +1 -1
- package/dist/esm/search/_internal/portalSearchGroups.js.map +1 -1
- package/dist/esm/search/_internal/portalSearchItems.js +1 -1
- package/dist/esm/search/_internal/portalSearchItems.js.map +1 -1
- package/dist/esm/search/_internal/portalSearchUsers.js +1 -1
- package/dist/esm/search/_internal/portalSearchUsers.js.map +1 -1
- package/dist/esm/search/fetchCatalog.js +59 -0
- package/dist/esm/search/fetchCatalog.js.map +1 -0
- package/dist/esm/search/hubSearch.js +1 -1
- package/dist/esm/search/hubSearch.js.map +1 -1
- package/dist/esm/search/index.js +3 -1
- package/dist/esm/search/index.js.map +1 -1
- package/dist/esm/search/serializeQueryForPortal.js +2 -1
- package/dist/esm/search/serializeQueryForPortal.js.map +1 -1
- package/dist/esm/search/upgradeCatalogSchema.js +66 -0
- package/dist/esm/search/upgradeCatalogSchema.js.map +1 -0
- package/dist/esm/types/IMessage.js +1 -0
- package/dist/esm/types/IMessage.js.map +1 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/node/core/traits/WithCatalog.js +3 -0
- package/dist/node/core/traits/WithCatalog.js.map +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/org/fetchOrgLimits.js +37 -0
- package/dist/node/org/fetchOrgLimits.js.map +1 -0
- package/dist/node/org/index.js +1 -0
- package/dist/node/org/index.js.map +1 -1
- package/dist/node/search/Catalog.js +350 -0
- package/dist/node/search/Catalog.js.map +1 -0
- package/dist/node/search/Collection.js +37 -18
- package/dist/node/search/Collection.js.map +1 -1
- package/dist/node/search/_internal/{ipredicate-utils.js → expandPredicate.js} +1 -1
- package/dist/node/search/_internal/expandPredicate.js.map +1 -0
- package/dist/node/search/_internal/portalSearchGroups.js +2 -2
- package/dist/node/search/_internal/portalSearchGroups.js.map +1 -1
- package/dist/node/search/_internal/portalSearchItems.js +2 -2
- package/dist/node/search/_internal/portalSearchItems.js.map +1 -1
- package/dist/node/search/_internal/portalSearchUsers.js +2 -2
- package/dist/node/search/_internal/portalSearchUsers.js.map +1 -1
- package/dist/node/search/fetchCatalog.js +50 -0
- package/dist/node/search/fetchCatalog.js.map +1 -0
- package/dist/node/search/hubSearch.js +1 -1
- package/dist/node/search/hubSearch.js.map +1 -1
- package/dist/node/search/index.js +3 -1
- package/dist/node/search/index.js.map +1 -1
- package/dist/node/search/serializeQueryForPortal.js +3 -2
- package/dist/node/search/serializeQueryForPortal.js.map +1 -1
- package/dist/node/search/upgradeCatalogSchema.js +71 -0
- package/dist/node/search/upgradeCatalogSchema.js.map +1 -0
- package/dist/node/types/IMessage.js +3 -0
- package/dist/node/types/IMessage.js.map +1 -0
- package/dist/node/types/index.js +5 -0
- package/dist/node/types/index.js.map +1 -0
- package/dist/types/core/traits/WithCatalog.d.ts +7 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/org/fetchOrgLimits.d.ts +35 -0
- package/dist/types/org/index.d.ts +1 -0
- package/dist/types/search/Catalog.d.ts +143 -0
- package/dist/types/search/Collection.d.ts +23 -2
- package/dist/types/search/_internal/{ipredicate-utils.d.ts → expandPredicate.d.ts} +0 -0
- package/dist/types/search/fetchCatalog.d.ts +10 -0
- package/dist/types/search/index.d.ts +3 -1
- package/dist/types/search/types/IHubSearchOptions.d.ts +5 -1
- package/dist/types/search/types/IHubSearchResponse.d.ts +5 -0
- package/dist/types/search/upgradeCatalogSchema.d.ts +12 -0
- package/dist/types/types/IMessage.d.ts +32 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/umd/common.umd.js +667 -27
- package/dist/umd/common.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/es2017/search/_internal/ipredicate-utils.js.map +0 -1
- package/dist/es2017/search/convertCatalog.js +0 -33
- package/dist/es2017/search/convertCatalog.js.map +0 -1
- package/dist/esm/search/_internal/ipredicate-utils.js.map +0 -1
- package/dist/esm/search/convertCatalog.js +0 -33
- package/dist/esm/search/convertCatalog.js.map +0 -1
- package/dist/node/search/_internal/ipredicate-utils.js.map +0 -1
- package/dist/node/search/convertCatalog.js +0 -37
- package/dist/node/search/convertCatalog.js.map +0 -1
- package/dist/types/search/convertCatalog.d.ts +0 -6
package/dist/umd/common.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/hub-common - v9.
|
|
2
|
+
* @esri/hub-common - v9.49.0 - Tue Jul 26 2022 19:34:30 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
|
-
*
|
|
14959
|
-
* @param
|
|
14990
|
+
* Apply schema upgrades to Catalog objects
|
|
14991
|
+
* @param catalog
|
|
14992
|
+
* @returns
|
|
14960
14993
|
*/
|
|
14961
|
-
function
|
|
14962
|
-
var
|
|
14963
|
-
|
|
14964
|
-
|
|
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
|
|
14979
|
-
|
|
14999
|
+
else {
|
|
15000
|
+
// apply migrations in order
|
|
15001
|
+
clone = applyCatalogSchema(clone);
|
|
15002
|
+
return clone;
|
|
14980
15003
|
}
|
|
14981
|
-
|
|
14982
|
-
|
|
14983
|
-
|
|
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
|
-
|
|
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
|
/**
|
|
@@ -15135,6 +15198,7 @@
|
|
|
15135
15198
|
var portalAllowList = [
|
|
15136
15199
|
"access",
|
|
15137
15200
|
"categories",
|
|
15201
|
+
"capabilities",
|
|
15138
15202
|
"created",
|
|
15139
15203
|
"description",
|
|
15140
15204
|
"disabled",
|
|
@@ -18782,13 +18846,584 @@
|
|
|
18782
18846
|
};
|
|
18783
18847
|
fn = getProp(fnHash, apiType + "." + filterType);
|
|
18784
18848
|
if (!fn) {
|
|
18785
|
-
throw new HubError$1("hubSearch", "Search via \"" + filterType + "\" filter against \"" + apiType + "\" api is not implemented");
|
|
18849
|
+
throw new HubError$1("hubSearch", "Search via \"" + filterType + "\" filter against \"" + apiType + "\" api is not implemented. Please ensure \"targetEntity\" is defined on the query.");
|
|
18786
18850
|
}
|
|
18787
18851
|
return [2 /*return*/, fn(cloneObject$1(query), options)];
|
|
18788
18852
|
});
|
|
18789
18853
|
});
|
|
18790
18854
|
}
|
|
18791
18855
|
|
|
18856
|
+
/**
|
|
18857
|
+
* Collection Class
|
|
18858
|
+
*
|
|
18859
|
+
* Abstracts searching a Collection
|
|
18860
|
+
*
|
|
18861
|
+
* For more information, check out the [Catalog & Collection Guide](/hub.js/guides/concepts/catalog-collection/)
|
|
18862
|
+
*/
|
|
18863
|
+
var Collection = /** @class */ (function () {
|
|
18864
|
+
function Collection(collection, context) {
|
|
18865
|
+
this._collection = collection;
|
|
18866
|
+
this._context = context;
|
|
18867
|
+
}
|
|
18868
|
+
/**
|
|
18869
|
+
* Create an instance of a Collection from a JSON object
|
|
18870
|
+
* @param collection
|
|
18871
|
+
* @param context
|
|
18872
|
+
* @returns
|
|
18873
|
+
*/
|
|
18874
|
+
Collection.fromJson = function (collection, context) {
|
|
18875
|
+
return new Collection(collection, context);
|
|
18876
|
+
};
|
|
18877
|
+
/**
|
|
18878
|
+
* Return the JSON object backing the instance
|
|
18879
|
+
* @returns
|
|
18880
|
+
*/
|
|
18881
|
+
Collection.prototype.toJson = function () {
|
|
18882
|
+
return cloneObject$1(this._collection);
|
|
18883
|
+
};
|
|
18884
|
+
Object.defineProperty(Collection.prototype, "label", {
|
|
18885
|
+
// Getters
|
|
18886
|
+
get: function () {
|
|
18887
|
+
return this._collection.label;
|
|
18888
|
+
},
|
|
18889
|
+
enumerable: false,
|
|
18890
|
+
configurable: true
|
|
18891
|
+
});
|
|
18892
|
+
Object.defineProperty(Collection.prototype, "key", {
|
|
18893
|
+
get: function () {
|
|
18894
|
+
return this._collection.key;
|
|
18895
|
+
},
|
|
18896
|
+
enumerable: false,
|
|
18897
|
+
configurable: true
|
|
18898
|
+
});
|
|
18899
|
+
Object.defineProperty(Collection.prototype, "include", {
|
|
18900
|
+
get: function () {
|
|
18901
|
+
return this._collection.include || [];
|
|
18902
|
+
},
|
|
18903
|
+
enumerable: false,
|
|
18904
|
+
configurable: true
|
|
18905
|
+
});
|
|
18906
|
+
Object.defineProperty(Collection.prototype, "scope", {
|
|
18907
|
+
get: function () {
|
|
18908
|
+
return this._collection.scope;
|
|
18909
|
+
},
|
|
18910
|
+
enumerable: false,
|
|
18911
|
+
configurable: true
|
|
18912
|
+
});
|
|
18913
|
+
Object.defineProperty(Collection.prototype, "sortField", {
|
|
18914
|
+
get: function () {
|
|
18915
|
+
return this._collection.sortField || "title";
|
|
18916
|
+
},
|
|
18917
|
+
enumerable: false,
|
|
18918
|
+
configurable: true
|
|
18919
|
+
});
|
|
18920
|
+
Object.defineProperty(Collection.prototype, "sortDirection", {
|
|
18921
|
+
get: function () {
|
|
18922
|
+
return this._collection.sortDirection || "asc";
|
|
18923
|
+
},
|
|
18924
|
+
enumerable: false,
|
|
18925
|
+
configurable: true
|
|
18926
|
+
});
|
|
18927
|
+
Object.defineProperty(Collection.prototype, "targetEntity", {
|
|
18928
|
+
get: function () {
|
|
18929
|
+
return this._collection.targetEntity;
|
|
18930
|
+
},
|
|
18931
|
+
enumerable: false,
|
|
18932
|
+
configurable: true
|
|
18933
|
+
});
|
|
18934
|
+
/**
|
|
18935
|
+
* Search the collection using a string or IQuery
|
|
18936
|
+
* @param query
|
|
18937
|
+
* @param options
|
|
18938
|
+
* @returns
|
|
18939
|
+
*/
|
|
18940
|
+
Collection.prototype.search = function (query, options) {
|
|
18941
|
+
if (options === void 0) { options = {}; }
|
|
18942
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18943
|
+
var qry, opts;
|
|
18944
|
+
return __generator(this, function (_a) {
|
|
18945
|
+
if (typeof query === "string") {
|
|
18946
|
+
// construct a query from that...
|
|
18947
|
+
qry = {
|
|
18948
|
+
targetEntity: this._collection.targetEntity,
|
|
18949
|
+
filters: [
|
|
18950
|
+
{
|
|
18951
|
+
predicates: [
|
|
18952
|
+
{
|
|
18953
|
+
term: query,
|
|
18954
|
+
},
|
|
18955
|
+
],
|
|
18956
|
+
},
|
|
18957
|
+
],
|
|
18958
|
+
};
|
|
18959
|
+
}
|
|
18960
|
+
else {
|
|
18961
|
+
qry = query;
|
|
18962
|
+
}
|
|
18963
|
+
// TODO: What should happen when a Query is passed in that has a targetEntity that doesn't match the collection's targetEntity?
|
|
18964
|
+
// merge the passed in query w/ the scope
|
|
18965
|
+
qry.filters = __spreadArrays(qry.filters, this.scope.filters);
|
|
18966
|
+
opts = cloneObject$1(options);
|
|
18967
|
+
opts.requestOptions = this._context.hubRequestOptions;
|
|
18968
|
+
// inject default sort info if not specified
|
|
18969
|
+
opts.sortField = options.sortField || this.sortField;
|
|
18970
|
+
opts.sortOrder = options.sortOrder || this.sortDirection;
|
|
18971
|
+
// inject default includes if not specified
|
|
18972
|
+
opts.include = options.include || this.include;
|
|
18973
|
+
// execute the search and return results
|
|
18974
|
+
return [2 /*return*/, hubSearch(qry, opts)];
|
|
18975
|
+
});
|
|
18976
|
+
});
|
|
18977
|
+
};
|
|
18978
|
+
return Collection;
|
|
18979
|
+
}());
|
|
18980
|
+
|
|
18981
|
+
/**
|
|
18982
|
+
* Fetch a IHubCatalog from a backing item.
|
|
18983
|
+
* This will apply schema upgrades to the structure
|
|
18984
|
+
* @param identifier
|
|
18985
|
+
* @param requestOptions
|
|
18986
|
+
* @returns
|
|
18987
|
+
*/
|
|
18988
|
+
function fetchCatalog(identifier, requestOptions) {
|
|
18989
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
18990
|
+
var getPrms, url, fetched;
|
|
18991
|
+
return __generator(this, function (_a) {
|
|
18992
|
+
switch (_a.label) {
|
|
18993
|
+
case 0:
|
|
18994
|
+
// identifier can be a guid or a url
|
|
18995
|
+
if (identifier.indexOf("http") === 0) {
|
|
18996
|
+
url = identifier;
|
|
18997
|
+
// get down the the hostname
|
|
18998
|
+
url = stripProtocol(url);
|
|
18999
|
+
// if url does not include a hash (i.e. it's not portal)
|
|
19000
|
+
// then we want to split on the first slash to get the hostname
|
|
19001
|
+
// lookupDomain will handle the enterprise base urls
|
|
19002
|
+
if (!url.includes("#")) {
|
|
19003
|
+
url = url.split("/")[0];
|
|
19004
|
+
}
|
|
19005
|
+
getPrms = lookupDomain(url, requestOptions)
|
|
19006
|
+
// get the item's data, and read the catalog out of it
|
|
19007
|
+
.then(function (_a) {
|
|
19008
|
+
var siteId = _a.siteId;
|
|
19009
|
+
return getItemData(siteId, requestOptions);
|
|
19010
|
+
})
|
|
19011
|
+
.then(function (data) {
|
|
19012
|
+
return upgradeCatalogSchema(data.catalog || {});
|
|
19013
|
+
});
|
|
19014
|
+
}
|
|
19015
|
+
else if (isGuid(identifier)) {
|
|
19016
|
+
// get the item's data, and read the catalog out of it
|
|
19017
|
+
getPrms = getItemData(identifier, requestOptions).then(function (data) {
|
|
19018
|
+
return upgradeCatalogSchema(data.catalog || {});
|
|
19019
|
+
});
|
|
19020
|
+
}
|
|
19021
|
+
else {
|
|
19022
|
+
throw new HubError$1("Catalog.create", "Identifier must be a url, guid");
|
|
19023
|
+
}
|
|
19024
|
+
return [4 /*yield*/, getPrms];
|
|
19025
|
+
case 1:
|
|
19026
|
+
fetched = _a.sent();
|
|
19027
|
+
return [2 /*return*/, fetched];
|
|
19028
|
+
}
|
|
19029
|
+
});
|
|
19030
|
+
});
|
|
19031
|
+
}
|
|
19032
|
+
|
|
19033
|
+
/**
|
|
19034
|
+
* Catalog Class
|
|
19035
|
+
*
|
|
19036
|
+
* Abstracts working with Catalogs and fetching collections with
|
|
19037
|
+
* the correct scope applied.
|
|
19038
|
+
*
|
|
19039
|
+
* For more information, check out the [Catalog & Collection Guide](/hub.js/guides/concepts/catalog-collection/)
|
|
19040
|
+
*/
|
|
19041
|
+
var Catalog = /** @class */ (function () {
|
|
19042
|
+
// internal - use static factory methods
|
|
19043
|
+
function Catalog(catalog, context) {
|
|
19044
|
+
this._catalog = catalog;
|
|
19045
|
+
this._context = context;
|
|
19046
|
+
}
|
|
19047
|
+
/**
|
|
19048
|
+
* Create a Collection instance from a Catalog json object, a site url or itemId
|
|
19049
|
+
* '''js
|
|
19050
|
+
* const catalog = await Catalog.create('https://site-org.hub.arcgis.com', context);
|
|
19051
|
+
* '''
|
|
19052
|
+
*
|
|
19053
|
+
* @param identifier
|
|
19054
|
+
* @param context
|
|
19055
|
+
* @returns
|
|
19056
|
+
*/
|
|
19057
|
+
Catalog.init = function (identifier, context) {
|
|
19058
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
19059
|
+
var mgr, fetched;
|
|
19060
|
+
return __generator(this, function (_a) {
|
|
19061
|
+
switch (_a.label) {
|
|
19062
|
+
case 0:
|
|
19063
|
+
if (!!context) return [3 /*break*/, 2];
|
|
19064
|
+
return [4 /*yield*/, ArcGISContextManager.create()];
|
|
19065
|
+
case 1:
|
|
19066
|
+
mgr = _a.sent();
|
|
19067
|
+
context = mgr.context;
|
|
19068
|
+
_a.label = 2;
|
|
19069
|
+
case 2: return [4 /*yield*/, fetchCatalog(identifier, context.hubRequestOptions)];
|
|
19070
|
+
case 3:
|
|
19071
|
+
fetched = _a.sent();
|
|
19072
|
+
// return an instance
|
|
19073
|
+
return [2 /*return*/, new Catalog(fetched, context)];
|
|
19074
|
+
}
|
|
19075
|
+
});
|
|
19076
|
+
});
|
|
19077
|
+
};
|
|
19078
|
+
/**
|
|
19079
|
+
* Create a Catalog instance from a Catalog Json object
|
|
19080
|
+
* @param json
|
|
19081
|
+
* @param context
|
|
19082
|
+
* @returns
|
|
19083
|
+
*/
|
|
19084
|
+
Catalog.fromJson = function (json, context) {
|
|
19085
|
+
// ensure it's in the latest structure
|
|
19086
|
+
var catalog = upgradeCatalogSchema(json);
|
|
19087
|
+
return new Catalog(catalog, context);
|
|
19088
|
+
};
|
|
19089
|
+
/**
|
|
19090
|
+
* Return the JSON object backing the instance
|
|
19091
|
+
* @returns
|
|
19092
|
+
*/
|
|
19093
|
+
Catalog.prototype.toJson = function () {
|
|
19094
|
+
return cloneObject$1(this._catalog);
|
|
19095
|
+
};
|
|
19096
|
+
Object.defineProperty(Catalog.prototype, "schemaVersion", {
|
|
19097
|
+
/**
|
|
19098
|
+
* Return the schema version
|
|
19099
|
+
*/
|
|
19100
|
+
get: function () {
|
|
19101
|
+
return this._catalog.schemaVersion;
|
|
19102
|
+
},
|
|
19103
|
+
enumerable: false,
|
|
19104
|
+
configurable: true
|
|
19105
|
+
});
|
|
19106
|
+
Object.defineProperty(Catalog.prototype, "title", {
|
|
19107
|
+
/**
|
|
19108
|
+
* Title getter
|
|
19109
|
+
*/
|
|
19110
|
+
get: function () {
|
|
19111
|
+
return this._catalog.title;
|
|
19112
|
+
},
|
|
19113
|
+
/**
|
|
19114
|
+
* Title setter
|
|
19115
|
+
*/
|
|
19116
|
+
set: function (v) {
|
|
19117
|
+
this._catalog.title = v;
|
|
19118
|
+
},
|
|
19119
|
+
enumerable: false,
|
|
19120
|
+
configurable: true
|
|
19121
|
+
});
|
|
19122
|
+
Object.defineProperty(Catalog.prototype, "scopes", {
|
|
19123
|
+
/**
|
|
19124
|
+
* Return the existing scopes hash
|
|
19125
|
+
*/
|
|
19126
|
+
get: function () {
|
|
19127
|
+
return this._catalog.scopes;
|
|
19128
|
+
},
|
|
19129
|
+
enumerable: false,
|
|
19130
|
+
configurable: true
|
|
19131
|
+
});
|
|
19132
|
+
Object.defineProperty(Catalog.prototype, "availableScopes", {
|
|
19133
|
+
/**
|
|
19134
|
+
* Return an array of the entity types available in this Catalog
|
|
19135
|
+
*/
|
|
19136
|
+
get: function () {
|
|
19137
|
+
return Object.keys(this.scopes);
|
|
19138
|
+
},
|
|
19139
|
+
enumerable: false,
|
|
19140
|
+
configurable: true
|
|
19141
|
+
});
|
|
19142
|
+
/**
|
|
19143
|
+
* Get the scope's query for a particular entity type
|
|
19144
|
+
* @param type
|
|
19145
|
+
* @returns
|
|
19146
|
+
*/
|
|
19147
|
+
Catalog.prototype.getScope = function (type) {
|
|
19148
|
+
return this._catalog.scopes[type];
|
|
19149
|
+
};
|
|
19150
|
+
/**
|
|
19151
|
+
* Set the scope for a specific entity type
|
|
19152
|
+
* @param type
|
|
19153
|
+
* @param query
|
|
19154
|
+
*/
|
|
19155
|
+
Catalog.prototype.setScope = function (type, query) {
|
|
19156
|
+
this._catalog.scopes[type] = query;
|
|
19157
|
+
};
|
|
19158
|
+
Object.defineProperty(Catalog.prototype, "collections", {
|
|
19159
|
+
/**
|
|
19160
|
+
* Get the collections array. Returns simple objects not Collection instances
|
|
19161
|
+
*/
|
|
19162
|
+
get: function () {
|
|
19163
|
+
return this._catalog.collections || [];
|
|
19164
|
+
},
|
|
19165
|
+
enumerable: false,
|
|
19166
|
+
configurable: true
|
|
19167
|
+
});
|
|
19168
|
+
Object.defineProperty(Catalog.prototype, "collectionNames", {
|
|
19169
|
+
/**
|
|
19170
|
+
* Get the names of the collections
|
|
19171
|
+
*/
|
|
19172
|
+
get: function () {
|
|
19173
|
+
return mapBy("key", this.collections);
|
|
19174
|
+
},
|
|
19175
|
+
enumerable: false,
|
|
19176
|
+
configurable: true
|
|
19177
|
+
});
|
|
19178
|
+
/**
|
|
19179
|
+
* Get a Collection instance by name
|
|
19180
|
+
* @param name
|
|
19181
|
+
* @returns
|
|
19182
|
+
*/
|
|
19183
|
+
Catalog.prototype.getCollection = function (name) {
|
|
19184
|
+
var json = this.collections.find(function (entry) { return entry.key === name; });
|
|
19185
|
+
if (json) {
|
|
19186
|
+
// clone it then merge in the associated scope filter
|
|
19187
|
+
var clone = cloneObject$1(json);
|
|
19188
|
+
var catalogScope = this.getScope(clone.scope.targetEntity);
|
|
19189
|
+
if (catalogScope === null || catalogScope === void 0 ? void 0 : catalogScope.filters) {
|
|
19190
|
+
clone.scope.filters = __spreadArrays(clone.scope.filters, catalogScope.filters);
|
|
19191
|
+
}
|
|
19192
|
+
return Collection.fromJson(clone, this._context);
|
|
19193
|
+
}
|
|
19194
|
+
else {
|
|
19195
|
+
throw new HubError$1("getCollection", "Collection \"" + name + "\" is not present in the Catalog");
|
|
19196
|
+
}
|
|
19197
|
+
};
|
|
19198
|
+
/**
|
|
19199
|
+
* Search for Items
|
|
19200
|
+
* Will throw if the Catalog does not have a scope defined for items
|
|
19201
|
+
* @param query
|
|
19202
|
+
* @param options
|
|
19203
|
+
* @returns
|
|
19204
|
+
*/
|
|
19205
|
+
Catalog.prototype.searchItems = function (query, options) {
|
|
19206
|
+
if (options === void 0) { options = {}; }
|
|
19207
|
+
if (!this.getScope("item")) {
|
|
19208
|
+
var result = this.getEmptyResult();
|
|
19209
|
+
result.messages = [
|
|
19210
|
+
{
|
|
19211
|
+
code: "missingScope",
|
|
19212
|
+
message: "Catalog does not have a scope for items",
|
|
19213
|
+
data: {
|
|
19214
|
+
scope: "item",
|
|
19215
|
+
},
|
|
19216
|
+
},
|
|
19217
|
+
];
|
|
19218
|
+
return Promise.resolve(result);
|
|
19219
|
+
}
|
|
19220
|
+
else {
|
|
19221
|
+
// ensure it's an item search
|
|
19222
|
+
options.targetEntity = "item";
|
|
19223
|
+
return this.search(query, options);
|
|
19224
|
+
}
|
|
19225
|
+
};
|
|
19226
|
+
/**
|
|
19227
|
+
* Search for Groups
|
|
19228
|
+
* Will throw if the Catalog does not have a scope defined for groups
|
|
19229
|
+
* @param query
|
|
19230
|
+
* @param options
|
|
19231
|
+
* @returns
|
|
19232
|
+
*/
|
|
19233
|
+
Catalog.prototype.searchGroups = function (query, options) {
|
|
19234
|
+
if (options === void 0) { options = {}; }
|
|
19235
|
+
if (!this.getScope("group")) {
|
|
19236
|
+
var result = this.getEmptyResult();
|
|
19237
|
+
result.messages = [
|
|
19238
|
+
{
|
|
19239
|
+
code: "missingScope",
|
|
19240
|
+
message: "Catalog does not have a scope for groups",
|
|
19241
|
+
data: {
|
|
19242
|
+
scope: "group",
|
|
19243
|
+
},
|
|
19244
|
+
},
|
|
19245
|
+
];
|
|
19246
|
+
return Promise.resolve(result);
|
|
19247
|
+
}
|
|
19248
|
+
else {
|
|
19249
|
+
// ensure it's an group search
|
|
19250
|
+
options.targetEntity = "group";
|
|
19251
|
+
return this.search(query, options);
|
|
19252
|
+
}
|
|
19253
|
+
};
|
|
19254
|
+
/**
|
|
19255
|
+
* Search for Users
|
|
19256
|
+
* Will throw if the Catalog does not have a scope defined for users
|
|
19257
|
+
* @param query
|
|
19258
|
+
* @param options
|
|
19259
|
+
* @returns
|
|
19260
|
+
*/
|
|
19261
|
+
Catalog.prototype.searchUsers = function (query, options) {
|
|
19262
|
+
if (options === void 0) { options = {}; }
|
|
19263
|
+
if (!this.getScope("user")) {
|
|
19264
|
+
var result = this.getEmptyResult();
|
|
19265
|
+
result.messages = [
|
|
19266
|
+
{
|
|
19267
|
+
code: "missingScope",
|
|
19268
|
+
message: "Catalog does not have a scope for user",
|
|
19269
|
+
data: {
|
|
19270
|
+
scope: "user",
|
|
19271
|
+
},
|
|
19272
|
+
},
|
|
19273
|
+
];
|
|
19274
|
+
return Promise.resolve(result);
|
|
19275
|
+
}
|
|
19276
|
+
else {
|
|
19277
|
+
// ensure it's an group search
|
|
19278
|
+
options.targetEntity = "user";
|
|
19279
|
+
return this.search(query, options);
|
|
19280
|
+
}
|
|
19281
|
+
};
|
|
19282
|
+
/**
|
|
19283
|
+
* Execute a search against all the collections in the Catalog
|
|
19284
|
+
* @param query
|
|
19285
|
+
* @param options
|
|
19286
|
+
* @returns
|
|
19287
|
+
*/
|
|
19288
|
+
Catalog.prototype.searchCollections = function (query, options) {
|
|
19289
|
+
if (options === void 0) { options = {}; }
|
|
19290
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
19291
|
+
var qry, promiseKeys, promises, responses, hash, i;
|
|
19292
|
+
var _this = this;
|
|
19293
|
+
return __generator(this, function (_a) {
|
|
19294
|
+
switch (_a.label) {
|
|
19295
|
+
case 0:
|
|
19296
|
+
qry = {
|
|
19297
|
+
targetEntity: "item",
|
|
19298
|
+
filters: [
|
|
19299
|
+
{
|
|
19300
|
+
predicates: [
|
|
19301
|
+
{
|
|
19302
|
+
term: query,
|
|
19303
|
+
},
|
|
19304
|
+
],
|
|
19305
|
+
},
|
|
19306
|
+
],
|
|
19307
|
+
};
|
|
19308
|
+
promiseKeys = [];
|
|
19309
|
+
promises = this.collectionNames.map(function (name) {
|
|
19310
|
+
var col = _this.getCollection(name);
|
|
19311
|
+
promiseKeys.push(name);
|
|
19312
|
+
qry.targetEntity = col.targetEntity;
|
|
19313
|
+
return col.search(qry, options);
|
|
19314
|
+
});
|
|
19315
|
+
return [4 /*yield*/, Promise.all(promises)];
|
|
19316
|
+
case 1:
|
|
19317
|
+
responses = _a.sent();
|
|
19318
|
+
hash = {};
|
|
19319
|
+
for (i = 0; i < promiseKeys.length; i++) {
|
|
19320
|
+
hash[promiseKeys[i]] = responses[i];
|
|
19321
|
+
}
|
|
19322
|
+
return [2 /*return*/, hash];
|
|
19323
|
+
}
|
|
19324
|
+
});
|
|
19325
|
+
});
|
|
19326
|
+
};
|
|
19327
|
+
/**
|
|
19328
|
+
* Execute a search against all the scopes in the Catalog
|
|
19329
|
+
* @param query
|
|
19330
|
+
* @param options
|
|
19331
|
+
* @returns
|
|
19332
|
+
*/
|
|
19333
|
+
Catalog.prototype.searchScopes = function (query, options) {
|
|
19334
|
+
if (options === void 0) { options = {}; }
|
|
19335
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
19336
|
+
var qry, promiseKeys, promises, responses, hash, i;
|
|
19337
|
+
var _this = this;
|
|
19338
|
+
return __generator(this, function (_a) {
|
|
19339
|
+
switch (_a.label) {
|
|
19340
|
+
case 0:
|
|
19341
|
+
qry = {
|
|
19342
|
+
targetEntity: "item",
|
|
19343
|
+
filters: [
|
|
19344
|
+
{
|
|
19345
|
+
predicates: [
|
|
19346
|
+
{
|
|
19347
|
+
term: query,
|
|
19348
|
+
},
|
|
19349
|
+
],
|
|
19350
|
+
},
|
|
19351
|
+
],
|
|
19352
|
+
};
|
|
19353
|
+
promiseKeys = [];
|
|
19354
|
+
promises = this.availableScopes.map(function (name) {
|
|
19355
|
+
promiseKeys.push(name);
|
|
19356
|
+
// make clones
|
|
19357
|
+
var qryClone = cloneObject$1(qry);
|
|
19358
|
+
var optsClone = cloneObject$1(options);
|
|
19359
|
+
// set the target entity
|
|
19360
|
+
qryClone.targetEntity = name;
|
|
19361
|
+
optsClone.targetEntity = name;
|
|
19362
|
+
// return the search promise
|
|
19363
|
+
return _this.search(qryClone, optsClone);
|
|
19364
|
+
});
|
|
19365
|
+
return [4 /*yield*/, Promise.all(promises)];
|
|
19366
|
+
case 1:
|
|
19367
|
+
responses = _a.sent();
|
|
19368
|
+
hash = {};
|
|
19369
|
+
for (i = 0; i < promiseKeys.length; i++) {
|
|
19370
|
+
hash[promiseKeys[i]] = responses[i];
|
|
19371
|
+
}
|
|
19372
|
+
return [2 /*return*/, hash];
|
|
19373
|
+
}
|
|
19374
|
+
});
|
|
19375
|
+
});
|
|
19376
|
+
};
|
|
19377
|
+
/**
|
|
19378
|
+
* Execute a search against the Catalog as a whole
|
|
19379
|
+
* @param query
|
|
19380
|
+
* @param targetEntity
|
|
19381
|
+
* @returns
|
|
19382
|
+
*/
|
|
19383
|
+
Catalog.prototype.search = function (query, options) {
|
|
19384
|
+
var targetEntity = options.targetEntity;
|
|
19385
|
+
var qry;
|
|
19386
|
+
if (typeof query === "string") {
|
|
19387
|
+
qry = {
|
|
19388
|
+
targetEntity: targetEntity,
|
|
19389
|
+
filters: [
|
|
19390
|
+
{
|
|
19391
|
+
predicates: [
|
|
19392
|
+
{
|
|
19393
|
+
term: query,
|
|
19394
|
+
},
|
|
19395
|
+
],
|
|
19396
|
+
},
|
|
19397
|
+
],
|
|
19398
|
+
};
|
|
19399
|
+
}
|
|
19400
|
+
else {
|
|
19401
|
+
qry = cloneObject$1(query);
|
|
19402
|
+
}
|
|
19403
|
+
// Now merge in catalog scope level filters
|
|
19404
|
+
qry.filters = __spreadArrays(qry.filters, this.getScope(targetEntity).filters);
|
|
19405
|
+
var opts = cloneObject$1(options);
|
|
19406
|
+
// An Catalog instance always uses the context so we remove/replace any passed in auth
|
|
19407
|
+
delete opts.authentication;
|
|
19408
|
+
opts.requestOptions = this._context.hubRequestOptions;
|
|
19409
|
+
return hubSearch(qry, opts);
|
|
19410
|
+
};
|
|
19411
|
+
/**
|
|
19412
|
+
* Construct an empty result. Returned when a search is performed against an entity type that
|
|
19413
|
+
* does not have a scope defined.
|
|
19414
|
+
* @returns
|
|
19415
|
+
*/
|
|
19416
|
+
Catalog.prototype.getEmptyResult = function () {
|
|
19417
|
+
return {
|
|
19418
|
+
results: [],
|
|
19419
|
+
total: 0,
|
|
19420
|
+
hasNext: false,
|
|
19421
|
+
next: null,
|
|
19422
|
+
};
|
|
19423
|
+
};
|
|
19424
|
+
return Catalog;
|
|
19425
|
+
}());
|
|
19426
|
+
|
|
18792
19427
|
/**
|
|
18793
19428
|
* Enrich a generic search result
|
|
18794
19429
|
* @param group
|
|
@@ -20399,6 +21034,8 @@
|
|
|
20399
21034
|
|
|
20400
21035
|
exports.ArcGISContext = ArcGISContext;
|
|
20401
21036
|
exports.ArcGISContextManager = ArcGISContextManager;
|
|
21037
|
+
exports.Catalog = Catalog;
|
|
21038
|
+
exports.Collection = Collection;
|
|
20402
21039
|
exports.DEFAULT_THEME = DEFAULT_THEME;
|
|
20403
21040
|
exports.ENTERPRISE_SITE_ITEM_TYPE = ENTERPRISE_SITE_ITEM_TYPE;
|
|
20404
21041
|
exports.GLOBAL_EXTENT = GLOBAL_EXTENT;
|
|
@@ -20545,8 +21182,10 @@
|
|
|
20545
21182
|
exports.fetchContent = fetchContent;
|
|
20546
21183
|
exports.fetchHubTranslation = fetchHubTranslation;
|
|
20547
21184
|
exports.fetchImageAsBlob = fetchImageAsBlob;
|
|
21185
|
+
exports.fetchMaxNumUserGroupsLimit = fetchMaxNumUserGroupsLimit;
|
|
20548
21186
|
exports.fetchModelFromItem = fetchModelFromItem;
|
|
20549
21187
|
exports.fetchOrg = fetchOrg;
|
|
21188
|
+
exports.fetchOrgLimits = fetchOrgLimits;
|
|
20550
21189
|
exports.fetchProject = fetchProject;
|
|
20551
21190
|
exports.fetchSite = fetchSite;
|
|
20552
21191
|
exports.fetchSiteModel = fetchSiteModel;
|
|
@@ -20708,6 +21347,7 @@
|
|
|
20708
21347
|
exports.updateModel = updateModel;
|
|
20709
21348
|
exports.updateProject = updateProject;
|
|
20710
21349
|
exports.updateSite = updateSite;
|
|
21350
|
+
exports.upgradeCatalogSchema = upgradeCatalogSchema;
|
|
20711
21351
|
exports.upgradeProtocol = upgradeProtocol;
|
|
20712
21352
|
exports.upgradeSiteSchema = upgradeSiteSchema;
|
|
20713
21353
|
exports.uploadResourcesFromUrl = uploadResourcesFromUrl;
|