@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.
- package/dist/es2017/ArcGISContext.js +66 -106
- package/dist/es2017/ArcGISContext.js.map +1 -1
- package/dist/es2017/ArcGISContextManager.js +163 -0
- package/dist/es2017/ArcGISContextManager.js.map +1 -0
- package/dist/es2017/content/index.js +12 -3
- package/dist/es2017/content/index.js.map +1 -1
- package/dist/es2017/index.js +1 -0
- package/dist/es2017/index.js.map +1 -1
- package/dist/es2017/search/_searchContent.js +18 -7
- package/dist/es2017/search/_searchContent.js.map +1 -1
- package/dist/es2017/search/_searchGroups.js +1 -11
- package/dist/es2017/search/_searchGroups.js.map +1 -1
- package/dist/es2017/search/utils.js +1 -1
- package/dist/es2017/urls/getHubApiFromPortalUrl.js +21 -0
- package/dist/es2017/urls/getHubApiFromPortalUrl.js.map +1 -0
- package/dist/es2017/urls/getPortalBaseFromOrgUrl.js +25 -0
- package/dist/es2017/urls/getPortalBaseFromOrgUrl.js.map +1 -0
- package/dist/es2017/urls/index.js +2 -0
- package/dist/es2017/urls/index.js.map +1 -1
- package/dist/esm/ArcGISContext.js +66 -139
- package/dist/esm/ArcGISContext.js.map +1 -1
- package/dist/esm/ArcGISContextManager.js +207 -0
- package/dist/esm/ArcGISContextManager.js.map +1 -0
- package/dist/esm/content/index.js +12 -3
- package/dist/esm/content/index.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/search/_searchContent.js +18 -7
- package/dist/esm/search/_searchContent.js.map +1 -1
- package/dist/esm/search/_searchGroups.js +3 -13
- package/dist/esm/search/_searchGroups.js.map +1 -1
- package/dist/esm/search/utils.js +1 -1
- package/dist/esm/urls/getHubApiFromPortalUrl.js +21 -0
- package/dist/esm/urls/getHubApiFromPortalUrl.js.map +1 -0
- package/dist/esm/urls/getPortalBaseFromOrgUrl.js +25 -0
- package/dist/esm/urls/getPortalBaseFromOrgUrl.js.map +1 -0
- package/dist/esm/urls/index.js +2 -0
- package/dist/esm/urls/index.js.map +1 -1
- package/dist/node/ArcGISContext.js +66 -106
- package/dist/node/ArcGISContext.js.map +1 -1
- package/dist/node/ArcGISContextManager.js +167 -0
- package/dist/node/ArcGISContextManager.js.map +1 -0
- package/dist/node/content/index.js +12 -3
- package/dist/node/content/index.js.map +1 -1
- package/dist/node/index.js +1 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/search/_searchContent.js +17 -6
- package/dist/node/search/_searchContent.js.map +1 -1
- package/dist/node/search/_searchGroups.js +1 -11
- package/dist/node/search/_searchGroups.js.map +1 -1
- package/dist/node/search/utils.js +1 -1
- package/dist/node/urls/getHubApiFromPortalUrl.js +25 -0
- package/dist/node/urls/getHubApiFromPortalUrl.js.map +1 -0
- package/dist/node/urls/getPortalBaseFromOrgUrl.js +29 -0
- package/dist/node/urls/getPortalBaseFromOrgUrl.js.map +1 -0
- package/dist/node/urls/index.js +2 -0
- package/dist/node/urls/index.js.map +1 -1
- package/dist/types/ArcGISContext.d.ts +211 -54
- package/dist/types/ArcGISContextManager.d.ts +116 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/search/utils.d.ts +1 -1
- package/dist/types/urls/getHubApiFromPortalUrl.d.ts +8 -0
- package/dist/types/urls/getPortalBaseFromOrgUrl.d.ts +9 -0
- package/dist/types/urls/index.d.ts +2 -0
- package/dist/umd/common.umd.js +344 -153
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- 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
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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
|
|
@@ -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
|