@esri/hub-common 14.31.0 → 14.32.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.
Files changed (50) hide show
  1. package/dist/esm/ArcGISContext.js +19 -0
  2. package/dist/esm/ArcGISContext.js.map +1 -1
  3. package/dist/esm/ArcGISContextManager.js +127 -30
  4. package/dist/esm/ArcGISContextManager.js.map +1 -1
  5. package/dist/esm/templates/_internal/computeLinks.js +9 -2
  6. package/dist/esm/templates/_internal/computeLinks.js.map +1 -1
  7. package/dist/esm/utils/getObjectSize.js +13 -0
  8. package/dist/esm/utils/getObjectSize.js.map +1 -0
  9. package/dist/esm/utils/hubUserAppResources.js +84 -0
  10. package/dist/esm/utils/hubUserAppResources.js.map +1 -0
  11. package/dist/esm/utils/index.js +2 -0
  12. package/dist/esm/utils/index.js.map +1 -1
  13. package/dist/esm/utils/internal/clearUserHubSettings.js +15 -0
  14. package/dist/esm/utils/internal/clearUserHubSettings.js.map +1 -0
  15. package/dist/esm/utils/internal/clearUserSiteSettings.js +15 -0
  16. package/dist/esm/utils/internal/clearUserSiteSettings.js.map +1 -0
  17. package/dist/esm/utils/internal/siteSettingsMigrations.js +20 -0
  18. package/dist/esm/utils/internal/siteSettingsMigrations.js.map +1 -0
  19. package/dist/esm/utils/internal/userAppResources.js +101 -0
  20. package/dist/esm/utils/internal/userAppResources.js.map +1 -0
  21. package/dist/node/ArcGISContext.js +19 -0
  22. package/dist/node/ArcGISContext.js.map +1 -1
  23. package/dist/node/ArcGISContextManager.js +127 -30
  24. package/dist/node/ArcGISContextManager.js.map +1 -1
  25. package/dist/node/templates/_internal/computeLinks.js +9 -2
  26. package/dist/node/templates/_internal/computeLinks.js.map +1 -1
  27. package/dist/node/utils/getObjectSize.js +17 -0
  28. package/dist/node/utils/getObjectSize.js.map +1 -0
  29. package/dist/node/utils/hubUserAppResources.js +91 -0
  30. package/dist/node/utils/hubUserAppResources.js.map +1 -0
  31. package/dist/node/utils/index.js +2 -0
  32. package/dist/node/utils/index.js.map +1 -1
  33. package/dist/node/utils/internal/clearUserHubSettings.js +19 -0
  34. package/dist/node/utils/internal/clearUserHubSettings.js.map +1 -0
  35. package/dist/node/utils/internal/clearUserSiteSettings.js +19 -0
  36. package/dist/node/utils/internal/clearUserSiteSettings.js.map +1 -0
  37. package/dist/node/utils/internal/siteSettingsMigrations.js +25 -0
  38. package/dist/node/utils/internal/siteSettingsMigrations.js.map +1 -0
  39. package/dist/node/utils/internal/userAppResources.js +108 -0
  40. package/dist/node/utils/internal/userAppResources.js.map +1 -0
  41. package/dist/types/ArcGISContext.d.ts +27 -0
  42. package/dist/types/ArcGISContextManager.d.ts +21 -0
  43. package/dist/types/utils/getObjectSize.d.ts +6 -0
  44. package/dist/types/utils/hubUserAppResources.d.ts +45 -0
  45. package/dist/types/utils/index.d.ts +2 -0
  46. package/dist/types/utils/internal/clearUserHubSettings.d.ts +11 -0
  47. package/dist/types/utils/internal/clearUserSiteSettings.d.ts +11 -0
  48. package/dist/types/utils/internal/siteSettingsMigrations.d.ts +13 -0
  49. package/dist/types/utils/internal/userAppResources.d.ts +130 -0
  50. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clearUserHubSettings.js","sourceRoot":"","sources":["../../../../src/utils/internal/clearUserHubSettings.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AAE3C,QAAA,qBAAqB,GAAoB,cAAc,CAAC;AACxD,QAAA,qBAAqB,GAAG,mBAAmB,CAAC;AACzD;;;;;GAKG;AAEH,SAAgB,oBAAoB,CAClC,OAAuB;IAEvB,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,6BAAqB,CAAC,CAAC;IACtD,MAAM,GAAG,GAAG,6BAAqB,CAAC;IAClC,OAAO,qCAAkB,CACvB,OAAO,CAAC,WAAW,CAAC,QAAQ,EAC5B,GAAG,EACH,OAAO,CAAC,SAAS,EACjB,KAAK,CACN,CAAC;AACJ,CAAC;AAXD,oDAWC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clearUserSiteSettings = exports.USER_SITE_SETTINGS_KEY = exports.USER_SITE_SETTINGS_APP = void 0;
4
+ const userAppResources_1 = require("./userAppResources");
5
+ exports.USER_SITE_SETTINGS_APP = "self";
6
+ exports.USER_SITE_SETTINGS_KEY = "hub-site-settings.json";
7
+ /**
8
+ * @private
9
+ * Internal use only; Clear User Site Settings
10
+ * @param context
11
+ * @returns
12
+ */
13
+ function clearUserSiteSettings(context) {
14
+ const token = context.tokenFor(exports.USER_SITE_SETTINGS_APP);
15
+ const key = exports.USER_SITE_SETTINGS_KEY;
16
+ return userAppResources_1.removeUserResource(context.currentUser.username, key, context.portalUrl, token);
17
+ }
18
+ exports.clearUserSiteSettings = clearUserSiteSettings;
19
+ //# sourceMappingURL=clearUserSiteSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clearUserSiteSettings.js","sourceRoot":"","sources":["../../../../src/utils/internal/clearUserSiteSettings.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AAE3C,QAAA,sBAAsB,GAAoB,MAAM,CAAC;AACjD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,OAAuB;IAEvB,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,8BAAsB,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,8BAAsB,CAAC;IACnC,OAAO,qCAAkB,CACvB,OAAO,CAAC,WAAW,CAAC,QAAQ,EAC5B,GAAG,EACH,OAAO,CAAC,SAAS,EACjB,KAAK,CACN,CAAC;AACJ,CAAC;AAXD,sDAWC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyHubSettingsMigrations = exports.applySiteSettingsMigrations = void 0;
4
+ const util_1 = require("../../util");
5
+ /**
6
+ * Apply migrations for Site Settings
7
+ * @param settings
8
+ * @returns
9
+ */
10
+ function applySiteSettingsMigrations(settings) {
11
+ // const currentSchema = 1;
12
+ return util_1.cloneObject(settings);
13
+ }
14
+ exports.applySiteSettingsMigrations = applySiteSettingsMigrations;
15
+ /**
16
+ * Apply migrations for Hub Settings
17
+ * @param settings
18
+ * @returns
19
+ */
20
+ function applyHubSettingsMigrations(settings) {
21
+ // const currentSchema = 1;
22
+ return util_1.cloneObject(settings);
23
+ }
24
+ exports.applyHubSettingsMigrations = applyHubSettingsMigrations;
25
+ //# sourceMappingURL=siteSettingsMigrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siteSettingsMigrations.js","sourceRoot":"","sources":["../../../../src/utils/internal/siteSettingsMigrations.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AAGzC;;;;GAIG;AACH,SAAgB,2BAA2B,CACzC,QAA6B;IAE7B,2BAA2B;IAE3B,OAAO,kBAAW,CAAC,QAAQ,CAAsB,CAAC;AACpD,CAAC;AAND,kEAMC;AAED;;;;GAIG;AACH,SAAgB,0BAA0B,CACxC,QAA6B;IAE7B,2BAA2B;IAE3B,OAAO,kBAAW,CAAC,QAAQ,CAAqB,CAAC;AACnD,CAAC;AAND,gEAMC"}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ // These Types and Functions can land in rest-js
3
+ // a friendly name for the scope of the resource
4
+ // the API deals with clientIds, which are
5
+ // listed here https://confluencewikidev.esri.com/pages/viewpage.action?pageId=50561461
6
+ // Generally speaking, the UserResourceScope is a downcased version of the
7
+ // clientId. Hub is unique b/c Sites have their own clientId,
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.listUserResources = exports.removeUserResource = exports.getUserResource = exports.setUserResource = void 0;
10
+ const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
11
+ const fail_safe_1 = require("../fail-safe");
12
+ const getObjectSize_1 = require("../getObjectSize");
13
+ /**
14
+ * @private
15
+ * Set a User-App-Resource
16
+ * By default this will fetch and merge with an existing resource.
17
+ * Passing `true` as the last parameter,
18
+ * @param resource
19
+ * @param username
20
+ * @param portalUrl
21
+ * @param token
22
+ * @param replace
23
+ * @returns
24
+ */
25
+ async function setUserResource(resource, username, portalUrl, token, replace = false) {
26
+ // Ensure we are below 5MB max size
27
+ if (getObjectSize_1.getObjectSize(resource.data).megabytes > 4.95) {
28
+ throw new Error(`User Resource is too large to store. Please ensure it is less than 5MB in size`);
29
+ }
30
+ let payload = resource.data;
31
+ if (!replace) {
32
+ const fsGetResource = fail_safe_1.failSafe(getUserResource, {});
33
+ const currentResource = await fsGetResource(username, resource.key, portalUrl, token);
34
+ // extend current object witn updated object
35
+ payload = Object.assign(Object.assign({}, currentResource), resource.data);
36
+ }
37
+ const ro = {
38
+ portal: portalUrl,
39
+ httpMethod: "POST",
40
+ params: {
41
+ text: JSON.stringify(payload),
42
+ access: resource.access,
43
+ key: resource.key,
44
+ token,
45
+ },
46
+ };
47
+ // TODO Experiment w/ how we can make this call w/o creating a UserSession with the token
48
+ return arcgis_rest_request_1.request(`${portalUrl}/sharing/rest/community/users/${username}/addResource`, ro);
49
+ }
50
+ exports.setUserResource = setUserResource;
51
+ /**
52
+ * @private
53
+ * Gets a user app resource
54
+ * If the resource does not exist, this will throw. This can be wrapped in `failSafe`
55
+ * configured to return an empty object.
56
+ * @param username
57
+ * @param key
58
+ * @param portalUrl
59
+ * @param token
60
+ * @returns
61
+ */
62
+ function getUserResource(username, key, portalUrl, token) {
63
+ const ro = {
64
+ portal: portalUrl,
65
+ };
66
+ return arcgis_rest_request_1.request(`${portalUrl}/sharing/rest/community/users/${username}/resources/${key}?token=${token}`, ro);
67
+ }
68
+ exports.getUserResource = getUserResource;
69
+ /**
70
+ * @private
71
+ * Remove a resource
72
+ * Used primarily in tests, but can be useful if you need to clean up
73
+ * settings that are no longer used
74
+ * @param username
75
+ * @param key
76
+ * @param portalUrl
77
+ * @param token
78
+ * @returns
79
+ */
80
+ function removeUserResource(username, key, portalUrl, token) {
81
+ const ro = {
82
+ portal: portalUrl,
83
+ httpMethod: "POST",
84
+ params: {
85
+ key,
86
+ token,
87
+ },
88
+ };
89
+ return arcgis_rest_request_1.request(`${portalUrl}/sharing/rest/community/users/${username}/removeResource`, ro);
90
+ }
91
+ exports.removeUserResource = removeUserResource;
92
+ /**
93
+ * @private
94
+ * List user resources associated with the user/token.
95
+ * Defaults to listing only resources associated with the app the token is associated with
96
+ * @param username
97
+ * @param portalUrl
98
+ * @param token
99
+ * @returns
100
+ */
101
+ function listUserResources(username, portalUrl, token, returnAllApps = false) {
102
+ const ro = {
103
+ portal: portalUrl,
104
+ };
105
+ return arcgis_rest_request_1.request(`${portalUrl}/sharing/rest/community/users/${username}/resources?f=json&token=${token}&returnAllApps=${returnAllApps}`, ro);
106
+ }
107
+ exports.listUserResources = listUserResources;
108
+ //# sourceMappingURL=userAppResources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userAppResources.js","sourceRoot":"","sources":["../../../../src/utils/internal/userAppResources.ts"],"names":[],"mappings":";AAAA,gDAAgD;AAChD,gDAAgD;AAChD,0CAA0C;AAC1C,uFAAuF;AACvF,0EAA0E;AAC1E,6DAA6D;;;AAE7D,mEAAqE;AACrE,4CAAwC;AACxC,oDAAiD;AAiGjD;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,eAAe,CACnC,QAA0B,EAC1B,QAAgB,EAChB,SAAiB,EACjB,KAAa,EACb,UAAmB,KAAK;IAExB,mCAAmC;IACnC,IAAI,6BAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,IAAI,EAAE;QACjD,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;KACH;IAED,IAAI,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC5B,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,aAAa,GAAG,oBAAQ,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,eAAe,GAAG,MAAM,aAAa,CACzC,QAAQ,EACR,QAAQ,CAAC,GAAG,EACZ,SAAS,EACT,KAAK,CACN,CAAC;QACF,4CAA4C;QAC5C,OAAO,mCAAQ,eAAe,GAAK,QAAQ,CAAC,IAAI,CAAE,CAAC;KACpD;IACD,MAAM,EAAE,GAAoB;QAC1B,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,MAAM;QAClB,MAAM,EAAE;YACN,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;YAC7B,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,GAAG,EAAE,QAAQ,CAAC,GAAG;YACjB,KAAK;SACN;KACF,CAAC;IACF,yFAAyF;IACzF,OAAO,6BAAO,CACZ,GAAG,SAAS,iCAAiC,QAAQ,cAAc,EACnE,EAAE,CACH,CAAC;AACJ,CAAC;AAzCD,0CAyCC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAC7B,QAAgB,EAChB,GAAW,EACX,SAAiB,EACjB,KAAa;IAEb,MAAM,EAAE,GAAoB;QAC1B,MAAM,EAAE,SAAS;KAClB,CAAC;IACF,OAAO,6BAAO,CACZ,GAAG,SAAS,iCAAiC,QAAQ,cAAc,GAAG,UAAU,KAAK,EAAE,EACvF,EAAE,CACH,CAAC;AACJ,CAAC;AAbD,0CAaC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,kBAAkB,CAChC,QAAgB,EAChB,GAAW,EACX,SAAiB,EACjB,KAAa;IAEb,MAAM,EAAE,GAAoB;QAC1B,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,MAAM;QAClB,MAAM,EAAE;YACN,GAAG;YACH,KAAK;SACN;KACF,CAAC;IACF,OAAO,6BAAO,CACZ,GAAG,SAAS,iCAAiC,QAAQ,iBAAiB,EACtE,EAAE,CACH,CAAC;AACJ,CAAC;AAlBD,gDAkBC;AAED;;;;;;;;GAQG;AACH,SAAgB,iBAAiB,CAC/B,QAAgB,EAChB,SAAiB,EACjB,KAAa,EACb,gBAAyB,KAAK;IAE9B,MAAM,EAAE,GAAoB;QAC1B,MAAM,EAAE,SAAS;KAClB,CAAC;IACF,OAAO,6BAAO,CACZ,GAAG,SAAS,iCAAiC,QAAQ,2BAA2B,KAAK,kBAAkB,aAAa,EAAE,EACtH,EAAE,CACmC,CAAC;AAC1C,CAAC;AAbD,8CAaC"}
@@ -4,6 +4,7 @@ import { IRequestOptions } from "@esri/arcgis-rest-request";
4
4
  import { HubServiceStatus } from "./core";
5
5
  import { HubEnvironment, HubLicense, IFeatureFlags } from "./permissions/types";
6
6
  import { IHubRequestOptions, IHubTrustedOrgsResponse } from "./types";
7
+ import { IUserResourceToken, UserResourceApp } from "./ArcGISContextManager";
7
8
  /**
8
9
  * Defines the properties of the ArcGISContext.
9
10
  * Typically components or functions will get an instance
@@ -170,6 +171,16 @@ export interface IArcGISContext {
170
171
  * Trusted orgs xhr response
171
172
  */
172
173
  trustedOrgs: IHubTrustedOrgsResponse[];
174
+ /**
175
+ * Array of exchanged tokens for use
176
+ * with user-app-resources
177
+ */
178
+ userResourceTokens?: IUserResourceToken[];
179
+ /**
180
+ * Return the token for a given app, if defined
181
+ * @param app
182
+ */
183
+ tokenFor(app: UserResourceApp): string;
173
184
  }
174
185
  /**
175
186
  * Options for the ArcGISContext constructor
@@ -230,6 +241,11 @@ export interface IArcGISContextOptions {
230
241
  * Trusted orgs xhr response
231
242
  */
232
243
  trustedOrgs?: IHubTrustedOrgsResponse[];
244
+ /**
245
+ * Array of exchanged tokens for use
246
+ * with user-app-resources
247
+ */
248
+ userResourceTokens?: IUserResourceToken[];
233
249
  }
234
250
  /**
235
251
  * Abstraction that holds a `UserSession`, along with
@@ -261,6 +277,7 @@ export declare class ArcGISContext implements IArcGISContext {
261
277
  private _featureFlags;
262
278
  private _trustedOrgIds;
263
279
  private _trustedOrgs;
280
+ private _userResourceTokens;
264
281
  /**
265
282
  * Create a new instance of `ArcGISContext`.
266
283
  *
@@ -419,4 +436,14 @@ export declare class ArcGISContext implements IArcGISContext {
419
436
  * Returns the array of Trusted Orgs
420
437
  */
421
438
  get trustedOrgs(): IHubTrustedOrgsResponse[];
439
+ /**
440
+ * Return the whole array of user resource tokens
441
+ */
442
+ get userResourceTokens(): IUserResourceToken[];
443
+ /**
444
+ * Return a token for a specific app
445
+ * @param app
446
+ * @returns
447
+ */
448
+ tokenFor(app: UserResourceApp): string;
422
449
  }
@@ -5,6 +5,14 @@ import { Level } from "./utils/logger";
5
5
  import { HubServiceStatus } from "./core";
6
6
  import { IFeatureFlags } from "./permissions";
7
7
  import { IHubTrustedOrgsResponse } from "./types";
8
+ export declare type UserResourceApp = "self" | "hubforarcgis" | "arcgisonline";
9
+ export interface IUserResourceConfig {
10
+ app: UserResourceApp;
11
+ clientId: string;
12
+ }
13
+ export interface IUserResourceToken extends IUserResourceConfig {
14
+ token: string;
15
+ }
8
16
  /**
9
17
  * Options that can be passed into `ArcGISContextManager.create`
10
18
  */
@@ -65,6 +73,16 @@ export interface IArcGISContextManagerOptions {
65
73
  * Trusted orgs xhr response
66
74
  */
67
75
  trustedOrgs?: IHubTrustedOrgsResponse[];
76
+ /**
77
+ * Array of app, clientId's that Context Manager should
78
+ * exchange tokens for
79
+ */
80
+ resourceConfigs?: IUserResourceConfig[];
81
+ /**
82
+ * Array of app, clientId, token objects which Context
83
+ * Manager has exchanged tokens for
84
+ */
85
+ resourceTokens?: IUserResourceToken[];
68
86
  }
69
87
  /**
70
88
  * The manager exposes context (`IArcGISContext`), which combines a `UserSession` with
@@ -99,6 +117,8 @@ export declare class ArcGISContextManager {
99
117
  private _featureFlags;
100
118
  private _trustedOrgIds;
101
119
  private _trustedOrgs;
120
+ private _resourceConfigs;
121
+ private _resourceTokens;
102
122
  /**
103
123
  * Private constructor. Use `ArcGISContextManager.create(...)` to
104
124
  * instantiate an instance
@@ -166,3 +186,4 @@ export declare class ArcGISContextManager {
166
186
  */
167
187
  private get contextOpts();
168
188
  }
189
+ export declare const ALPHA_ORGS: string[];
@@ -0,0 +1,6 @@
1
+ export interface IObjectSize {
2
+ bytes: number;
3
+ kilobytes: number;
4
+ megabytes: number;
5
+ }
6
+ export declare function getObjectSize(object: Record<string, any>): IObjectSize;
@@ -0,0 +1,45 @@
1
+ import { IArcGISContext } from "../ArcGISContext";
2
+ /**
3
+ * Site Level Settings
4
+ */
5
+ export interface IUserSiteSettings {
6
+ schemaVersion: number;
7
+ username?: string;
8
+ updated?: number;
9
+ }
10
+ /**
11
+ * Hub Level Settings
12
+ */
13
+ export interface IUserHubSettings {
14
+ schemaVersion: number;
15
+ username?: string;
16
+ updated?: number;
17
+ }
18
+ /**
19
+ * Store User settings in the Site App's cache
20
+ * @param settings
21
+ * @param context
22
+ * @param replace
23
+ * @returns
24
+ */
25
+ export declare function setUserSiteSettings(settings: IUserSiteSettings, context: IArcGISContext, replace?: boolean): Promise<void>;
26
+ /**
27
+ * Get the current user's settings for the current Site
28
+ * @param context
29
+ * @returns
30
+ */
31
+ export declare function getUserSiteSettings(context: IArcGISContext): Promise<IUserSiteSettings>;
32
+ /**
33
+ * Store the current user's Hub settings
34
+ * @param settings
35
+ * @param context
36
+ * @param replace
37
+ * @returns
38
+ */
39
+ export declare function setUserHubSettings(settings: IUserHubSettings, context: IArcGISContext, replace?: boolean): Promise<void>;
40
+ /**
41
+ * Get the current user's settings for ArcGIS Hub
42
+ * @param context
43
+ * @returns
44
+ */
45
+ export declare function getUserHubSettings(context: IArcGISContext): Promise<IUserHubSettings>;
@@ -23,3 +23,5 @@ export * from "./titleize";
23
23
  export * from "./memoize";
24
24
  export * from "./getEnvironmentFromPortalUrl";
25
25
  export * from "./poll";
26
+ export * from "./hubUserAppResources";
27
+ export * from "./getObjectSize";
@@ -0,0 +1,11 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { UserResourceApp } from "../../ArcGISContextManager";
3
+ export declare const USER_HUB_SETTINGS_APP: UserResourceApp;
4
+ export declare const USER_HUB_SETTINGS_KEY = "hub-settings.json";
5
+ /**
6
+ * @private
7
+ * Internal use only; Clear User Hub Settings
8
+ * @param context
9
+ * @returns
10
+ */
11
+ export declare function clearUserHubSettings(context: IArcGISContext): Promise<Record<string, any>>;
@@ -0,0 +1,11 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { UserResourceApp } from "../../ArcGISContextManager";
3
+ export declare const USER_SITE_SETTINGS_APP: UserResourceApp;
4
+ export declare const USER_SITE_SETTINGS_KEY = "hub-site-settings.json";
5
+ /**
6
+ * @private
7
+ * Internal use only; Clear User Site Settings
8
+ * @param context
9
+ * @returns
10
+ */
11
+ export declare function clearUserSiteSettings(context: IArcGISContext): Promise<Record<string, any>>;
@@ -0,0 +1,13 @@
1
+ import { IUserHubSettings, IUserSiteSettings } from "../hubUserAppResources";
2
+ /**
3
+ * Apply migrations for Site Settings
4
+ * @param settings
5
+ * @returns
6
+ */
7
+ export declare function applySiteSettingsMigrations(settings: Record<string, any>): IUserSiteSettings;
8
+ /**
9
+ * Apply migrations for Hub Settings
10
+ * @param settings
11
+ * @returns
12
+ */
13
+ export declare function applyHubSettingsMigrations(settings: Record<string, any>): IUserHubSettings;
@@ -0,0 +1,130 @@
1
+ /**
2
+ * @private
3
+ * Defines the access for the resource. The access level can be one of the following:
4
+ * - `userappprivate` Resource is available only to the user through the app from which resource was uploaded.
5
+ * - `userprivateallapps` Resource is available only to the user that uploaded the resource through any app.
6
+ * - `allorgusersprivateapp` Resource is available to all members of the org as that of the resource owner and through the app that uploaded. We allow adding resource with level only if the user's access is either public or org.
7
+ * - `public` Resource is available to anyone (including anonymous access) through any app. We allow adding a resource at public level only if the user's access is public and the canSharePublic flag of the org is set to true.
8
+ */
9
+ export declare type UserResourceAccess =
10
+ /**
11
+ * Resource is available only to the user through the app from which resource was uploaded.
12
+ */
13
+ "userappprivate" | "userprivateallapps" | "allorgusersprivateapp" | "public";
14
+ /**
15
+ * @private
16
+ * Add an User-App Resource
17
+ */
18
+ export interface IAddUserResource {
19
+ /**
20
+ * The filename of the resource
21
+ */
22
+ key: string;
23
+ /**
24
+ * The json object to store; will be stringified
25
+ */
26
+ data: Record<string, any>;
27
+ /**
28
+ * The access level for the resource
29
+ */
30
+ access: UserResourceAccess;
31
+ }
32
+ /**
33
+ * @private
34
+ * Information about a user app resource
35
+ */
36
+ export interface IUserResourceInfo {
37
+ /**
38
+ * The filename of the resource
39
+ */
40
+ key: string;
41
+ /**
42
+ * The clientId of the app that created the resource
43
+ */
44
+ clientId: string;
45
+ /**
46
+ * The date the resource was created
47
+ */
48
+ created: string;
49
+ /**
50
+ * The size of the resource in bytes
51
+ */
52
+ size: number;
53
+ /**
54
+ * The access level for the resource
55
+ */
56
+ access: UserResourceAccess;
57
+ }
58
+ /**
59
+ * @private
60
+ * Returned when we get a list of resources for a user
61
+ */
62
+ export interface IUserResourceListResponse {
63
+ /**
64
+ * The total number of resources
65
+ */
66
+ total: number;
67
+ /**
68
+ * The index of the first resource in the list
69
+ */
70
+ start: number;
71
+ /**
72
+ * The number of resources returned
73
+ */
74
+ num: number;
75
+ /**
76
+ * The next index to use to get the next set of resources
77
+ */
78
+ nextStart: number;
79
+ /**
80
+ * The list of resources
81
+ */
82
+ userResources: IUserResourceInfo[];
83
+ }
84
+ /**
85
+ * @private
86
+ * Set a User-App-Resource
87
+ * By default this will fetch and merge with an existing resource.
88
+ * Passing `true` as the last parameter,
89
+ * @param resource
90
+ * @param username
91
+ * @param portalUrl
92
+ * @param token
93
+ * @param replace
94
+ * @returns
95
+ */
96
+ export declare function setUserResource(resource: IAddUserResource, username: string, portalUrl: string, token: string, replace?: boolean): Promise<void>;
97
+ /**
98
+ * @private
99
+ * Gets a user app resource
100
+ * If the resource does not exist, this will throw. This can be wrapped in `failSafe`
101
+ * configured to return an empty object.
102
+ * @param username
103
+ * @param key
104
+ * @param portalUrl
105
+ * @param token
106
+ * @returns
107
+ */
108
+ export declare function getUserResource(username: string, key: string, portalUrl: string, token: string): Promise<Record<string, any>>;
109
+ /**
110
+ * @private
111
+ * Remove a resource
112
+ * Used primarily in tests, but can be useful if you need to clean up
113
+ * settings that are no longer used
114
+ * @param username
115
+ * @param key
116
+ * @param portalUrl
117
+ * @param token
118
+ * @returns
119
+ */
120
+ export declare function removeUserResource(username: string, key: string, portalUrl: string, token: string): Promise<Record<string, any>>;
121
+ /**
122
+ * @private
123
+ * List user resources associated with the user/token.
124
+ * Defaults to listing only resources associated with the app the token is associated with
125
+ * @param username
126
+ * @param portalUrl
127
+ * @param token
128
+ * @returns
129
+ */
130
+ export declare function listUserResources(username: string, portalUrl: string, token: string, returnAllApps?: boolean): Promise<IUserResourceListResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/hub-common",
3
- "version": "14.31.0",
3
+ "version": "14.32.1",
4
4
  "description": "Common TypeScript types and utility functions for @esri/hub.js.",
5
5
  "main": "dist/node/index.js",
6
6
  "module": "dist/esm/index.js",