@esri/hub-common 9.13.0 → 9.14.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 (69) hide show
  1. package/dist/es2017/ArcGISContext.js +66 -106
  2. package/dist/es2017/ArcGISContext.js.map +1 -1
  3. package/dist/es2017/ArcGISContextManager.js +163 -0
  4. package/dist/es2017/ArcGISContextManager.js.map +1 -0
  5. package/dist/es2017/content/index.js +12 -3
  6. package/dist/es2017/content/index.js.map +1 -1
  7. package/dist/es2017/index.js +1 -0
  8. package/dist/es2017/index.js.map +1 -1
  9. package/dist/es2017/search/_searchContent.js +18 -7
  10. package/dist/es2017/search/_searchContent.js.map +1 -1
  11. package/dist/es2017/search/_searchGroups.js +1 -11
  12. package/dist/es2017/search/_searchGroups.js.map +1 -1
  13. package/dist/es2017/search/utils.js +1 -1
  14. package/dist/es2017/urls/getHubApiFromPortalUrl.js +21 -0
  15. package/dist/es2017/urls/getHubApiFromPortalUrl.js.map +1 -0
  16. package/dist/es2017/urls/getPortalBaseFromOrgUrl.js +25 -0
  17. package/dist/es2017/urls/getPortalBaseFromOrgUrl.js.map +1 -0
  18. package/dist/es2017/urls/index.js +2 -0
  19. package/dist/es2017/urls/index.js.map +1 -1
  20. package/dist/esm/ArcGISContext.js +66 -139
  21. package/dist/esm/ArcGISContext.js.map +1 -1
  22. package/dist/esm/ArcGISContextManager.js +207 -0
  23. package/dist/esm/ArcGISContextManager.js.map +1 -0
  24. package/dist/esm/content/index.js +12 -3
  25. package/dist/esm/content/index.js.map +1 -1
  26. package/dist/esm/index.js +1 -0
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/search/_searchContent.js +18 -7
  29. package/dist/esm/search/_searchContent.js.map +1 -1
  30. package/dist/esm/search/_searchGroups.js +3 -13
  31. package/dist/esm/search/_searchGroups.js.map +1 -1
  32. package/dist/esm/search/utils.js +1 -1
  33. package/dist/esm/urls/getHubApiFromPortalUrl.js +21 -0
  34. package/dist/esm/urls/getHubApiFromPortalUrl.js.map +1 -0
  35. package/dist/esm/urls/getPortalBaseFromOrgUrl.js +25 -0
  36. package/dist/esm/urls/getPortalBaseFromOrgUrl.js.map +1 -0
  37. package/dist/esm/urls/index.js +2 -0
  38. package/dist/esm/urls/index.js.map +1 -1
  39. package/dist/node/ArcGISContext.js +66 -106
  40. package/dist/node/ArcGISContext.js.map +1 -1
  41. package/dist/node/ArcGISContextManager.js +167 -0
  42. package/dist/node/ArcGISContextManager.js.map +1 -0
  43. package/dist/node/content/index.js +12 -3
  44. package/dist/node/content/index.js.map +1 -1
  45. package/dist/node/index.js +1 -0
  46. package/dist/node/index.js.map +1 -1
  47. package/dist/node/search/_searchContent.js +17 -6
  48. package/dist/node/search/_searchContent.js.map +1 -1
  49. package/dist/node/search/_searchGroups.js +1 -11
  50. package/dist/node/search/_searchGroups.js.map +1 -1
  51. package/dist/node/search/utils.js +1 -1
  52. package/dist/node/urls/getHubApiFromPortalUrl.js +25 -0
  53. package/dist/node/urls/getHubApiFromPortalUrl.js.map +1 -0
  54. package/dist/node/urls/getPortalBaseFromOrgUrl.js +29 -0
  55. package/dist/node/urls/getPortalBaseFromOrgUrl.js.map +1 -0
  56. package/dist/node/urls/index.js +2 -0
  57. package/dist/node/urls/index.js.map +1 -1
  58. package/dist/types/ArcGISContext.d.ts +211 -54
  59. package/dist/types/ArcGISContextManager.d.ts +116 -0
  60. package/dist/types/index.d.ts +1 -0
  61. package/dist/types/search/utils.d.ts +1 -1
  62. package/dist/types/urls/getHubApiFromPortalUrl.d.ts +8 -0
  63. package/dist/types/urls/getPortalBaseFromOrgUrl.d.ts +9 -0
  64. package/dist/types/urls/index.d.ts +2 -0
  65. package/dist/umd/common.umd.js +344 -153
  66. package/dist/umd/common.umd.js.map +1 -1
  67. package/dist/umd/common.umd.min.js +1 -1
  68. package/dist/umd/common.umd.min.js.map +1 -1
  69. package/package.json +1 -1
@@ -0,0 +1,116 @@
1
+ import { IPortal } from "@esri/arcgis-rest-portal";
2
+ import { IUser, UserSession } from "@esri/arcgis-rest-auth";
3
+ import { IArcGISContext } from "./ArcGISContext";
4
+ import { Level } from ".";
5
+ /**
6
+ * Options that can be passed into `ArcGISContextManager.create`
7
+ */
8
+ export interface IArcGISContextManagerOptions {
9
+ /**
10
+ * Existing user session, which may be created from Identity Manager
11
+ * `const session = UserSession.fromCredential(idMgr.getCredential());`
12
+ */
13
+ authentication?: UserSession;
14
+ /**
15
+ * ArcGIS Online or ArcGIS Enterprise portal url.
16
+ * Do not include `/sharing/rest`
17
+ * Defaults to `https://www.arcgis.com`
18
+ * For ArcGIS Enterprise, you must include the webadaptor name.
19
+ * i.e. https://gis.mytown.gov/portal
20
+ *
21
+ * When Authentication is present, the UserSession.portal value is
22
+ * used instead of this property.
23
+ */
24
+ portalUrl?: string;
25
+ /**
26
+ * Portal self for the authenticated user. If not passed into `.create`
27
+ * with the UserSession, it will be fetched
28
+ */
29
+ portal?: IPortal;
30
+ /**
31
+ * Current user as `IUser`. If not passed into `.create` with the UserSession
32
+ * it will be fetched.
33
+ */
34
+ currentUser?: IUser;
35
+ /**
36
+ * Logging level
37
+ * off > error > warn > info > debug > all
38
+ * defaults to 'error'
39
+ */
40
+ logLevel?: Level;
41
+ }
42
+ /**
43
+ * The manager exposes context (`IArcGISContext`), which combines a `UserSession` with
44
+ * the `portal/self` and `user/self` responses to provide a central lookup for platform
45
+ * information, api urls, and other useful properties for developers such as IRequestOptions
46
+ * IUserRequestOptions, IHubRequestOptions etc.
47
+ *
48
+ * The context is exposed on gthe `.context` property, and as the authentication changes
49
+ * the `.context` is re-created. This is done to allow web frameworks to watch for
50
+ * changes on that single property, instead of having to leverage observers or events
51
+ * for change detection.
52
+ *
53
+ * Please see the [ArcGISContext Guide](/hub.js/guides/context) for additional information.
54
+ *
55
+ */
56
+ export declare class ArcGISContextManager {
57
+ /**
58
+ * Random identifier useful for debugging issues
59
+ * where race-conditions can result in multiple
60
+ * contexts getting created
61
+ */
62
+ id: number;
63
+ private _context;
64
+ private _authentication;
65
+ private _portalUrl;
66
+ private _hubUrl;
67
+ private _portalSelf;
68
+ private _currentUser;
69
+ private _logLevel;
70
+ /**
71
+ * Private constructor. Use `ArcGISContextManager.create(...)` to
72
+ * instantiate an instance
73
+ * @param opts
74
+ */
75
+ private constructor();
76
+ /**
77
+ * Used to create a new instance of the ArcGISContext class.
78
+ *
79
+ * ```js
80
+ * const ctxMgr = await ArcGISContextManager.create();
81
+ * ```
82
+ *
83
+ * @param opts
84
+ * @returns
85
+ */
86
+ static create(opts?: IArcGISContextManagerOptions): Promise<ArcGISContextManager>;
87
+ /**
88
+ * Set the Authentication (UserSession) for the context.
89
+ * This should be called when a user signs into a running
90
+ * application.
91
+ * @param auth
92
+ */
93
+ setAuthentication(auth: UserSession): Promise<void>;
94
+ /**
95
+ * Clear the Authentication (UserSession). This should be
96
+ * called when a user signs out of an application, but
97
+ * the application continues running
98
+ */
99
+ clearAuthentication(): void;
100
+ /**
101
+ * Return a reference to the current state.
102
+ * When `.setAuthentication()` or `.clearAuthenentication()` are
103
+ * called, the state will be re-created. This is done so frameworks
104
+ * like React or Ember can detect changes.
105
+ */
106
+ get context(): IArcGISContext;
107
+ /**
108
+ * If we have a UserSession, fetch portal/self and
109
+ * store that along with current user
110
+ */
111
+ private initialize;
112
+ /**
113
+ * Getter to streamline the creation of updated Context instances
114
+ */
115
+ private get contextOpts();
116
+ }
@@ -18,6 +18,7 @@ export * from "./utils";
18
18
  export * from "./i18n";
19
19
  export * from "./request";
20
20
  export * from "./surveys";
21
+ export * from "./ArcGISContextManager";
21
22
  export * from "./ArcGISContext";
22
23
  import OperationStack from "./OperationStack";
23
24
  import OperationError from "./OperationError";
@@ -104,7 +104,7 @@ export declare function getNextFunction<T>(request: ISearchOptions, nextStart: n
104
104
  * Construct a the full url to a group thumbnail
105
105
  *
106
106
  * - If the group has a thumbnail, construct the full url
107
- * - If the group is not public, append on the token
107
+ * - If the group is not public, append on the token (if passed in)
108
108
  * @param portalUrl
109
109
  * @param group
110
110
  * @param token
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Cross-walk from a portalUrl to the corresponding Hub API Url
3
+ *
4
+ * If the passed url is not recognized, then this will return `undefined`
5
+ * @param portalUrl
6
+ * @returns
7
+ */
8
+ export declare function getHubApiFromPortalUrl(portalUrl: string): string;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Given an org url, get the portal base url
3
+ *
4
+ * i.e. https://myorg.maps.arcgis.com will return https://www.arcgis.com
5
+ *
6
+ * @param orgUrl
7
+ * @returns
8
+ */
9
+ export declare function getPortalBaseFromOrgUrl(orgUrl: string): string;
@@ -13,6 +13,8 @@ export * from "./get-item-home-url";
13
13
  export * from "./get-item-api-url";
14
14
  export * from "./get-item-data-url";
15
15
  export * from "./convert-urls-to-anchor-tags";
16
+ export * from "./getHubApiFromPortalUrl";
17
+ export * from "./getPortalBaseFromOrgUrl";
16
18
  /**
17
19
  *
18
20
  * @param url