@esri/hub-common 9.10.2 → 9.13.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 (62) hide show
  1. package/dist/es2017/ArcGISContext.js +169 -0
  2. package/dist/es2017/ArcGISContext.js.map +1 -0
  3. package/dist/es2017/ArcGISContextState.js +203 -0
  4. package/dist/es2017/ArcGISContextState.js.map +1 -0
  5. package/dist/es2017/content/index.js +124 -1
  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/urls/convert-urls-to-anchor-tags.js +14 -0
  10. package/dist/es2017/urls/convert-urls-to-anchor-tags.js.map +1 -0
  11. package/dist/es2017/urls/index.js +1 -0
  12. package/dist/es2017/urls/index.js.map +1 -1
  13. package/dist/es2017/utils/index.js +1 -0
  14. package/dist/es2017/utils/index.js.map +1 -1
  15. package/dist/es2017/utils/sessionLocalStorage.js +47 -0
  16. package/dist/es2017/utils/sessionLocalStorage.js.map +1 -0
  17. package/dist/esm/ArcGISContext.js +209 -0
  18. package/dist/esm/ArcGISContext.js.map +1 -0
  19. package/dist/esm/ArcGISContextState.js +285 -0
  20. package/dist/esm/ArcGISContextState.js.map +1 -0
  21. package/dist/esm/content/index.js +124 -1
  22. package/dist/esm/content/index.js.map +1 -1
  23. package/dist/esm/index.js +1 -0
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/urls/convert-urls-to-anchor-tags.js +14 -0
  26. package/dist/esm/urls/convert-urls-to-anchor-tags.js.map +1 -0
  27. package/dist/esm/urls/index.js +1 -0
  28. package/dist/esm/urls/index.js.map +1 -1
  29. package/dist/esm/utils/index.js +1 -0
  30. package/dist/esm/utils/index.js.map +1 -1
  31. package/dist/esm/utils/sessionLocalStorage.js +50 -0
  32. package/dist/esm/utils/sessionLocalStorage.js.map +1 -0
  33. package/dist/node/ArcGISContext.js +173 -0
  34. package/dist/node/ArcGISContext.js.map +1 -0
  35. package/dist/node/ArcGISContextState.js +207 -0
  36. package/dist/node/ArcGISContextState.js.map +1 -0
  37. package/dist/node/content/index.js +125 -2
  38. package/dist/node/content/index.js.map +1 -1
  39. package/dist/node/index.js +1 -0
  40. package/dist/node/index.js.map +1 -1
  41. package/dist/node/urls/convert-urls-to-anchor-tags.js +18 -0
  42. package/dist/node/urls/convert-urls-to-anchor-tags.js.map +1 -0
  43. package/dist/node/urls/index.js +1 -0
  44. package/dist/node/urls/index.js.map +1 -1
  45. package/dist/node/utils/index.js +1 -0
  46. package/dist/node/utils/index.js.map +1 -1
  47. package/dist/node/utils/sessionLocalStorage.js +53 -0
  48. package/dist/node/utils/sessionLocalStorage.js.map +1 -0
  49. package/dist/types/ArcGISContext.d.ts +98 -0
  50. package/dist/types/ArcGISContextState.d.ts +129 -0
  51. package/dist/types/content/index.d.ts +13 -0
  52. package/dist/types/index.d.ts +1 -0
  53. package/dist/types/types.d.ts +5 -2
  54. package/dist/types/urls/convert-urls-to-anchor-tags.d.ts +5 -0
  55. package/dist/types/urls/index.d.ts +1 -0
  56. package/dist/types/utils/index.d.ts +1 -0
  57. package/dist/types/utils/sessionLocalStorage.d.ts +23 -0
  58. package/dist/umd/common.umd.js +3397 -2684
  59. package/dist/umd/common.umd.js.map +1 -1
  60. package/dist/umd/common.umd.min.js +1 -1
  61. package/dist/umd/common.umd.min.js.map +1 -1
  62. package/package.json +1 -1
@@ -0,0 +1,98 @@
1
+ import { UserSession } from "@esri/arcgis-rest-auth";
2
+ import { IArcGISContextState } from "./ArcGISContextState";
3
+ /**
4
+ * Options that can be passed into `ArcGISContext.create`
5
+ */
6
+ export interface IArcGISContextOptions {
7
+ /**
8
+ * Existing user session, which may be created from Identity Manager
9
+ * `const session = UserSession.fromCredential(idMgr.getCredential());`
10
+ */
11
+ authentication?: UserSession;
12
+ /**
13
+ * ArcGIS Online or ArcGIS Enterprise portal url.
14
+ * Do not include `/sharing/rest`
15
+ * Defaults to `https://www.arcgis.com`
16
+ * For ArcGIS Enterprise, you must include the webadaptor name.
17
+ * i.e. https://gis.mytown.gov/portal
18
+ *
19
+ * When Authentication is present, the UserSession.portal value is
20
+ * used instead of this property.
21
+ */
22
+ portalUrl?: string;
23
+ /**
24
+ * If set to `true` additional logging will be sent to the console
25
+ * Defaults to false.
26
+ */
27
+ debug?: boolean;
28
+ }
29
+ /**
30
+ * Application Context Object
31
+ *
32
+ * Abstraction that combines a `UserSession` with
33
+ * the `portal/self` and `user/self` responses to
34
+ * provide a central lookup of platform information.
35
+ *
36
+ * This is a work-in-progress, and will likely expand over time.
37
+ *
38
+ * `ArcGISContext` is used in conjuction with the `arcgis-app-identity`
39
+ * component to orchestrate oAuth.
40
+ */
41
+ export declare class ArcGISContext {
42
+ /**
43
+ * Random identifier useful for debugging issues
44
+ * where race-conditions can result in multiple
45
+ * contexts getting created
46
+ */
47
+ id: number;
48
+ private _state;
49
+ private _authentication;
50
+ private _portalUrl;
51
+ private _hubUrl;
52
+ private _portalSelf;
53
+ private _currentUser;
54
+ private _debug;
55
+ /**
56
+ * Private constructor. Use `ArcGISContext.create(...)` to
57
+ * instantiate an instance
58
+ * @param opts
59
+ */
60
+ private constructor();
61
+ /**
62
+ * Static async Factory
63
+ * @param opts
64
+ * @returns
65
+ */
66
+ static create(opts?: IArcGISContextOptions): Promise<ArcGISContext>;
67
+ /**
68
+ * If we have a UserSession, fetch portal/self and
69
+ * store that along with current user
70
+ */
71
+ initialize(): Promise<void>;
72
+ /**
73
+ * Set the Authentication (UserSession) for the context.
74
+ * This should be called when a user signs into a running
75
+ * application.
76
+ * @param auth
77
+ */
78
+ setAuthentication(auth: UserSession): Promise<void>;
79
+ /**
80
+ * Clear the Authentication (UserSession). This should be
81
+ * called when a user signs out of an application, but
82
+ * the application continues running
83
+ */
84
+ clearAuthentication(): void;
85
+ /**
86
+ * Return a reference to the current state.
87
+ * When `.setAuthentication()` or `.clearAuthenentication()` are
88
+ * called, the state will be re-created. This is done so frameworks
89
+ * like React or Ember can detect changes.
90
+ */
91
+ get state(): IArcGISContextState;
92
+ /**
93
+ * @internal
94
+ * Log debugging messages to the console
95
+ * @param message
96
+ */
97
+ private log;
98
+ }
@@ -0,0 +1,129 @@
1
+ import { IUser, IUserRequestOptions, UserSession } from "@esri/arcgis-rest-auth";
2
+ import { IPortal } from "@esri/arcgis-rest-portal";
3
+ import { IRequestOptions } from "@esri/arcgis-rest-request";
4
+ import { IHubRequestOptions } from ".";
5
+ /**
6
+ * Defined the properties of the ArcGISContext.state
7
+ * object. This wll be a class instance, and when authentication
8
+ * changes, the instance will be replaced. This is done to allow
9
+ * frameworks like React or Ember to bind into the .state property
10
+ * and react when it changes.
11
+ */
12
+ export interface IArcGISContextState {
13
+ id: number;
14
+ session: UserSession;
15
+ isAuthenticated: boolean;
16
+ userRequestOptions: IUserRequestOptions;
17
+ requestOptions: IRequestOptions;
18
+ hubRequestOptions: IHubRequestOptions;
19
+ portalUrl: string;
20
+ sharingApiUrl: string;
21
+ hubUrl: string;
22
+ isPortal: boolean;
23
+ discussionsServiceUrl: string;
24
+ hubSearchServiceUrl: string;
25
+ domainServiceUrl: string;
26
+ eventsConfig: any;
27
+ hubEnabled: boolean;
28
+ communityOrgId: string;
29
+ communityOrgHostname: string;
30
+ communityOrgUrl: string;
31
+ helperServices: any;
32
+ currentUser: IUser;
33
+ portal: IPortal;
34
+ }
35
+ /**
36
+ * @internal
37
+ */
38
+ export interface IArcGISContextStateOptions {
39
+ id: number;
40
+ portalUrl: string;
41
+ hubUrl: string;
42
+ authentication?: UserSession;
43
+ portalSelf?: IPortal;
44
+ currentUser?: IUser;
45
+ }
46
+ /**
47
+ * @internal
48
+ * Thin class just used to enable getters
49
+ *
50
+ * This class should not be used by anything other than
51
+ * the ArcGISContext class
52
+ */
53
+ export declare class ArcGISContextState implements IArcGISContextState {
54
+ id: number;
55
+ private _authentication;
56
+ private _portalUrl;
57
+ private _hubUrl;
58
+ private _portalSelf;
59
+ private _currentUser;
60
+ constructor(opts: IArcGISContextStateOptions);
61
+ /**
62
+ * Return the UserSession if authenticated
63
+ */
64
+ get session(): UserSession;
65
+ /**
66
+ * Return boolean indicating if authenticatio is present
67
+ */
68
+ get isAuthenticated(): boolean;
69
+ /**
70
+ * Return `IUserRequestOptions`, which is used for REST-JS
71
+ * functions which require authentication information.
72
+ *
73
+ * If context is not authenticated, this function will throw
74
+ */
75
+ get userRequestOptions(): IUserRequestOptions;
76
+ /**
77
+ * Return `IRequestOptions`, which is used by REST-JS functions
78
+ * which *may* use authentication information if provided.
79
+ *
80
+ * If context is not authenticated, this function just returns
81
+ * the `portal` property, which informs REST-JS what Sharing API
82
+ * instance to use (i.e. AGO, Enterprise etc)
83
+ */
84
+ get requestOptions(): IRequestOptions;
85
+ /**
86
+ * Return a `IHubRequestOptions` object
87
+ */
88
+ get hubRequestOptions(): IHubRequestOptions;
89
+ /**
90
+ * Return the portal url.
91
+ *
92
+ * If authenticated @ ArcGIS Online, it will return
93
+ * the https://org.env.arcgis.com
94
+ *
95
+ * If authenticated @ ArcGIS Enterprise, it will return
96
+ * https://portalHostname, which includes the web adaptor
97
+ */
98
+ get portalUrl(): string;
99
+ /**
100
+ * Returns the url to the sharing api
101
+ * i.e. https://myorg.maps.arcgis.com/sharing/rest
102
+ */
103
+ get sharingApiUrl(): string;
104
+ get hubUrl(): string;
105
+ /**
106
+ * Returns boolean indicating if the backing system
107
+ * is ArcGIS Enterprise (formerly ArcGIS Portal) or not
108
+ */
109
+ get isPortal(): boolean;
110
+ get discussionsServiceUrl(): string;
111
+ get hubSearchServiceUrl(): string;
112
+ get domainServiceUrl(): string;
113
+ get eventsConfig(): any;
114
+ /**
115
+ * Returns boolean indicating if the current user
116
+ * belongs to an organization that has licensed
117
+ * ArcGIS Hub
118
+ */
119
+ get hubEnabled(): boolean;
120
+ /**
121
+ * Return Hub Community Org Id, if defined
122
+ */
123
+ get communityOrgId(): string;
124
+ get communityOrgHostname(): string;
125
+ get communityOrgUrl(): string;
126
+ get helperServices(): any;
127
+ get currentUser(): IUser;
128
+ get portal(): IPortal;
129
+ }
@@ -210,6 +210,19 @@ export declare function datasetToItem(dataset: DatasetResource): IItem;
210
210
  * @returns new content
211
211
  */
212
212
  export declare const setContentType: (content: IHubContent, type: string) => IHubContent;
213
+ /**
214
+ * Compute the content type icon based on the normalizedType
215
+ * @param normalizedType
216
+ * @returns content type icon
217
+ */
218
+ export declare const getContentTypeIcon: (normalizedType: string) => any;
219
+ /**
220
+ * Compute the content type label
221
+ * @param normalizedType
222
+ * @param isProxied
223
+ * @returns content type label
224
+ */
225
+ export declare const getContentTypeLabel: (normalizedType: string, isProxied: boolean) => string;
213
226
  /**
214
227
  * returns a new content that has the specified hubId and updated identifier
215
228
  * @param content orignal content
@@ -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 "./ArcGISContext";
21
22
  import OperationStack from "./OperationStack";
22
23
  import OperationError from "./OperationError";
23
24
  export { OperationStack, OperationError };
@@ -82,7 +82,11 @@ export interface ISolutionTemplate extends IModel {
82
82
  };
83
83
  }
84
84
  export declare type GenericAsyncFunc = (...args: any) => Promise<any>;
85
- interface IHubRequestOptionsPortalSelf extends IPortal {
85
+ /**
86
+ * @internal
87
+ * This just adds user to the IPortal interface
88
+ */
89
+ export interface IHubRequestOptionsPortalSelf extends IPortal {
86
90
  user?: IUser;
87
91
  }
88
92
  export interface IHubRequestOptions extends IRequestOptions {
@@ -415,4 +419,3 @@ export interface ISearchResponse<T> {
415
419
  next: (params?: any) => Promise<ISearchResponse<T>>;
416
420
  facets?: IFacet[];
417
421
  }
418
- export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Convert urls in a string to hyperlinks
3
+ * @param {content} string
4
+ */
5
+ export declare function convertUrlsToAnchorTags(content: string): string;
@@ -12,6 +12,7 @@ export * from "./get-hub-url-from-portal";
12
12
  export * from "./get-item-home-url";
13
13
  export * from "./get-item-api-url";
14
14
  export * from "./get-item-data-url";
15
+ export * from "./convert-urls-to-anchor-tags";
15
16
  /**
16
17
  *
17
18
  * @param url
@@ -15,3 +15,4 @@ export * from "./increment-string";
15
15
  export * from "./logger";
16
16
  export * from "./is-update-group";
17
17
  export * from "./revertable-tasks";
18
+ export * from "./sessionLocalStorage";
@@ -0,0 +1,23 @@
1
+ import { UserSession } from "@esri/arcgis-rest-auth";
2
+ /**
3
+ * Remove any serialized sessions associated with the passed clientId
4
+ * from a browser's local storage
5
+ * @param clientId oAuth Client Id
6
+ * @param win optional window (used for testing)
7
+ */
8
+ export declare function clearSession(clientId: string, win?: any): void;
9
+ /**
10
+ * Re-hydrate a UserSession from a browser's local storage.
11
+ * If not found,
12
+ * @param clientId oAuth Client Id
13
+ * @param win optional window (used for testing)
14
+ * @returns
15
+ */
16
+ export declare function getSession(clientId: string, win?: any): UserSession | null;
17
+ /**
18
+ * Serialize a UserSession into a browser's local storage
19
+ * @param clientId oAuth Client Id
20
+ * @param session UserSession
21
+ * @param win optional window (used for testing)
22
+ */
23
+ export declare function saveSession(clientId: string, session: UserSession, win?: any): void;