@esri/hub-common 14.30.1 → 14.32.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 (61) 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/sites/feed-configuration.js +85 -0
  6. package/dist/esm/sites/feed-configuration.js.map +1 -0
  7. package/dist/esm/sites/index.js +1 -0
  8. package/dist/esm/sites/index.js.map +1 -1
  9. package/dist/esm/utils/getObjectSize.js +13 -0
  10. package/dist/esm/utils/getObjectSize.js.map +1 -0
  11. package/dist/esm/utils/hubUserAppResources.js +84 -0
  12. package/dist/esm/utils/hubUserAppResources.js.map +1 -0
  13. package/dist/esm/utils/index.js +2 -0
  14. package/dist/esm/utils/index.js.map +1 -1
  15. package/dist/esm/utils/internal/clearUserHubSettings.js +15 -0
  16. package/dist/esm/utils/internal/clearUserHubSettings.js.map +1 -0
  17. package/dist/esm/utils/internal/clearUserSiteSettings.js +15 -0
  18. package/dist/esm/utils/internal/clearUserSiteSettings.js.map +1 -0
  19. package/dist/esm/utils/internal/siteSettingsMigrations.js +20 -0
  20. package/dist/esm/utils/internal/siteSettingsMigrations.js.map +1 -0
  21. package/dist/esm/utils/internal/userAppResources.js +101 -0
  22. package/dist/esm/utils/internal/userAppResources.js.map +1 -0
  23. package/dist/esm/utils/poll.js +19 -6
  24. package/dist/esm/utils/poll.js.map +1 -1
  25. package/dist/node/ArcGISContext.js +19 -0
  26. package/dist/node/ArcGISContext.js.map +1 -1
  27. package/dist/node/ArcGISContextManager.js +127 -30
  28. package/dist/node/ArcGISContextManager.js.map +1 -1
  29. package/dist/node/sites/feed-configuration.js +90 -0
  30. package/dist/node/sites/feed-configuration.js.map +1 -0
  31. package/dist/node/sites/index.js +1 -0
  32. package/dist/node/sites/index.js.map +1 -1
  33. package/dist/node/utils/getObjectSize.js +17 -0
  34. package/dist/node/utils/getObjectSize.js.map +1 -0
  35. package/dist/node/utils/hubUserAppResources.js +91 -0
  36. package/dist/node/utils/hubUserAppResources.js.map +1 -0
  37. package/dist/node/utils/index.js +2 -0
  38. package/dist/node/utils/index.js.map +1 -1
  39. package/dist/node/utils/internal/clearUserHubSettings.js +19 -0
  40. package/dist/node/utils/internal/clearUserHubSettings.js.map +1 -0
  41. package/dist/node/utils/internal/clearUserSiteSettings.js +19 -0
  42. package/dist/node/utils/internal/clearUserSiteSettings.js.map +1 -0
  43. package/dist/node/utils/internal/siteSettingsMigrations.js +25 -0
  44. package/dist/node/utils/internal/siteSettingsMigrations.js.map +1 -0
  45. package/dist/node/utils/internal/userAppResources.js +108 -0
  46. package/dist/node/utils/internal/userAppResources.js.map +1 -0
  47. package/dist/node/utils/poll.js +19 -6
  48. package/dist/node/utils/poll.js.map +1 -1
  49. package/dist/types/ArcGISContext.d.ts +27 -0
  50. package/dist/types/ArcGISContextManager.d.ts +21 -0
  51. package/dist/types/sites/feed-configuration.d.ts +20 -0
  52. package/dist/types/sites/index.d.ts +1 -0
  53. package/dist/types/utils/getObjectSize.d.ts +6 -0
  54. package/dist/types/utils/hubUserAppResources.d.ts +45 -0
  55. package/dist/types/utils/index.d.ts +2 -0
  56. package/dist/types/utils/internal/clearUserHubSettings.d.ts +11 -0
  57. package/dist/types/utils/internal/clearUserSiteSettings.d.ts +11 -0
  58. package/dist/types/utils/internal/siteSettingsMigrations.d.ts +13 -0
  59. package/dist/types/utils/internal/userAppResources.d.ts +130 -0
  60. package/dist/types/utils/poll.d.ts +6 -0
  61. package/package.json +1 -1
@@ -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>;
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Function to poll a provided request until a validation
3
3
  * state or timeout is reached
4
+ *
5
+ * NOTE: we expose this as a public util, but should use this
6
+ * functionality sparingly when dealing with the Portal API.
7
+ * Best practice is to leverage this polling functionality
8
+ * internally on functions that we know incur a Portal delay.
9
+ *
4
10
  * @param requestFn
5
11
  * @param validationFn
6
12
  * @param opts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/hub-common",
3
- "version": "14.30.1",
3
+ "version": "14.32.0",
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",