@esri/hub-common 9.40.0 → 9.42.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 (82) hide show
  1. package/dist/es2017/content/_internal.js +14 -1
  2. package/dist/es2017/content/_internal.js.map +1 -1
  3. package/dist/es2017/core/types/IHubContent.js +1 -0
  4. package/dist/es2017/core/types/IHubContent.js.map +1 -1
  5. package/dist/es2017/index.js +1 -0
  6. package/dist/es2017/index.js.map +1 -1
  7. package/dist/es2017/search/_internal/portalSearchGroups.js.map +1 -1
  8. package/dist/es2017/search/_internal/portalSearchUsers.js +89 -0
  9. package/dist/es2017/search/_internal/portalSearchUsers.js.map +1 -0
  10. package/dist/es2017/search/filter-utils.js +59 -26
  11. package/dist/es2017/search/filter-utils.js.map +1 -1
  12. package/dist/es2017/search/hubSearch.js +4 -1
  13. package/dist/es2017/search/hubSearch.js.map +1 -1
  14. package/dist/es2017/urls/getUserHomeUrl.js +12 -0
  15. package/dist/es2017/urls/getUserHomeUrl.js.map +1 -0
  16. package/dist/es2017/urls/index.js +1 -0
  17. package/dist/es2017/urls/index.js.map +1 -1
  18. package/dist/es2017/users/HubUsers.js +64 -0
  19. package/dist/es2017/users/HubUsers.js.map +1 -0
  20. package/dist/es2017/users/_internal/enrichments.js +85 -0
  21. package/dist/es2017/users/_internal/enrichments.js.map +1 -0
  22. package/dist/es2017/users/index.js +2 -0
  23. package/dist/es2017/users/index.js.map +1 -0
  24. package/dist/esm/content/_internal.js +14 -1
  25. package/dist/esm/content/_internal.js.map +1 -1
  26. package/dist/esm/core/types/IHubContent.js +1 -0
  27. package/dist/esm/core/types/IHubContent.js.map +1 -1
  28. package/dist/esm/index.js +1 -0
  29. package/dist/esm/index.js.map +1 -1
  30. package/dist/esm/search/_internal/portalSearchGroups.js.map +1 -1
  31. package/dist/esm/search/_internal/portalSearchUsers.js +104 -0
  32. package/dist/esm/search/_internal/portalSearchUsers.js.map +1 -0
  33. package/dist/esm/search/filter-utils.js +60 -27
  34. package/dist/esm/search/filter-utils.js.map +1 -1
  35. package/dist/esm/search/hubSearch.js +4 -1
  36. package/dist/esm/search/hubSearch.js.map +1 -1
  37. package/dist/esm/urls/getUserHomeUrl.js +12 -0
  38. package/dist/esm/urls/getUserHomeUrl.js.map +1 -0
  39. package/dist/esm/urls/index.js +1 -0
  40. package/dist/esm/urls/index.js.map +1 -1
  41. package/dist/esm/users/HubUsers.js +66 -0
  42. package/dist/esm/users/HubUsers.js.map +1 -0
  43. package/dist/esm/users/_internal/enrichments.js +86 -0
  44. package/dist/esm/users/_internal/enrichments.js.map +1 -0
  45. package/dist/esm/users/index.js +2 -0
  46. package/dist/esm/users/index.js.map +1 -0
  47. package/dist/node/content/_internal.js +14 -1
  48. package/dist/node/content/_internal.js.map +1 -1
  49. package/dist/node/core/types/IHubContent.js +1 -0
  50. package/dist/node/core/types/IHubContent.js.map +1 -1
  51. package/dist/node/index.js +1 -0
  52. package/dist/node/index.js.map +1 -1
  53. package/dist/node/search/_internal/portalSearchGroups.js.map +1 -1
  54. package/dist/node/search/_internal/portalSearchUsers.js +93 -0
  55. package/dist/node/search/_internal/portalSearchUsers.js.map +1 -0
  56. package/dist/node/search/filter-utils.js +59 -26
  57. package/dist/node/search/filter-utils.js.map +1 -1
  58. package/dist/node/search/hubSearch.js +4 -1
  59. package/dist/node/search/hubSearch.js.map +1 -1
  60. package/dist/node/urls/getUserHomeUrl.js +16 -0
  61. package/dist/node/urls/getUserHomeUrl.js.map +1 -0
  62. package/dist/node/urls/index.js +1 -0
  63. package/dist/node/urls/index.js.map +1 -1
  64. package/dist/node/users/HubUsers.js +68 -0
  65. package/dist/node/users/HubUsers.js.map +1 -0
  66. package/dist/node/users/_internal/enrichments.js +89 -0
  67. package/dist/node/users/_internal/enrichments.js.map +1 -0
  68. package/dist/node/users/index.js +5 -0
  69. package/dist/node/users/index.js.map +1 -0
  70. package/dist/types/content/_internal.d.ts +1 -0
  71. package/dist/types/core/types/IHubContent.d.ts +5 -2
  72. package/dist/types/index.d.ts +1 -0
  73. package/dist/types/search/_internal/portalSearchUsers.d.ts +8 -0
  74. package/dist/types/search/types/types.d.ts +18 -1
  75. package/dist/types/urls/getUserHomeUrl.d.ts +10 -0
  76. package/dist/types/urls/index.d.ts +1 -0
  77. package/dist/types/users/HubUsers.d.ts +11 -0
  78. package/dist/types/users/_internal/enrichments.d.ts +28 -0
  79. package/dist/types/users/index.d.ts +1 -0
  80. package/dist/umd/common.umd.js +359 -61
  81. package/dist/umd/common.umd.js.map +1 -1
  82. package/package.json +1 -1
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchUserEnrichments = void 0;
4
+ const __1 = require("../..");
5
+ const _enrichments_1 = require("../../items/_enrichments");
6
+ const OperationStack_1 = require("../../OperationStack");
7
+ const utils_1 = require("../../utils");
8
+ const enrichUserOrg = (input) => {
9
+ const { data, stack, requestOptions } = input;
10
+ const opId = stack.start("enrichUserOrg");
11
+ const options = Object.assign(Object.assign({}, requestOptions), {
12
+ // In order to get the correct response, we must pass options.portal
13
+ // as a base portal url (e.g., www.arcgis.com, qaext.arcgis.com, etc)
14
+ // **not** an org portal (i.e. org.maps.arcgis.com).
15
+ portal: `${__1.getPortalBaseFromOrgUrl(requestOptions.portal)}/sharing/rest` });
16
+ // TODO: Add Caching
17
+ // Had implemented a simple caching system, but it leads to unstable
18
+ // tests because we can't deterministically clear it
19
+ // if (!orgCache[data.user.orgId]) {
20
+ // orgCache[data.user.orgId] = fetchOrg(data.user.orgId, options);
21
+ // }
22
+ // return (orgCache[data.user.orgId] as Promise<IPortal>)
23
+ return __1.fetchOrg(data.user.orgId, options)
24
+ .then((results) => {
25
+ stack.finish(opId);
26
+ return {
27
+ data: Object.assign(Object.assign({}, data), {
28
+ org: results,
29
+ }),
30
+ stack,
31
+ requestOptions,
32
+ };
33
+ })
34
+ .catch((error) => handleEnrichmentError(error, input, opId));
35
+ };
36
+ /**
37
+ * Simple cache for user org's. This does not expire
38
+ * but that seems reasonable as Org props rarely change
39
+ */
40
+ // This works find at run-time, but it's a problem in tests
41
+ // where we are validating calls. Will work with Randy to
42
+ // create something that's more robust
43
+ // const orgCache: Record<string, any> = {};
44
+ // add the error to the content.errors,
45
+ // log current stack operation as finished with an error
46
+ // and return output that can be piped into the next operation
47
+ const handleEnrichmentError = (error, input, opId) => {
48
+ const { data, stack, requestOptions } = input;
49
+ stack.finish(opId, { error });
50
+ return {
51
+ data: Object.assign(Object.assign({}, data), { errors: _enrichments_1.getEnrichmentErrors(error, data.errors) }),
52
+ stack,
53
+ requestOptions,
54
+ };
55
+ };
56
+ /**
57
+ * Available enrichments for Groups
58
+ */
59
+ const groupEnrichementOperations = {
60
+ org: enrichUserOrg,
61
+ };
62
+ /**
63
+ * Fetch enrichments for Users
64
+ * @param group
65
+ * @param enrichments
66
+ * @param requestOptions
67
+ * @returns
68
+ */
69
+ function fetchUserEnrichments(user, enrichments, requestOptions) {
70
+ // create a pipeline of enrichment operations
71
+ const operations = enrichments.reduce((ops, enrichment) => {
72
+ const operation = groupEnrichementOperations[enrichment];
73
+ // only include the enrichments that we know how to fetch
74
+ operation && ops.push(operation);
75
+ return ops;
76
+ }, []);
77
+ const pipeline = utils_1.createOperationPipeline(operations);
78
+ // execute pipeline and return the item and enrichments
79
+ return pipeline({
80
+ data: { user },
81
+ stack: new OperationStack_1.default(),
82
+ requestOptions,
83
+ }).then((output) => {
84
+ // TODO: send telemetry so we have info on what enrichments are requested and possible errors
85
+ return output.data;
86
+ });
87
+ }
88
+ exports.fetchUserEnrichments = fetchUserEnrichments;
89
+ //# sourceMappingURL=enrichments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enrichments.js","sourceRoot":"","sources":["../../../../src/users/_internal/enrichments.ts"],"names":[],"mappings":";;;AACA,6BAA0D;AAC1D,2DAA+D;AAC/D,yDAAkD;AAElD,uCAAiE;AAgCjE,MAAM,aAAa,GAAG,CACpB,KAA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C,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAChD;QACD,KAAK;QACL,cAAc;KACf,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,0BAA0B,GAA8B;IAC5D,GAAG,EAAE,aAAa;CACnB,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAClC,IAAW,EACX,WAA6B,EAC7B,cAAmC;IAEnC,6CAA6C;IAC7C,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE;QACxD,MAAM,SAAS,GAAG,0BAA0B,CAAC,UAAU,CAAC,CAAC;QACzD,yDAAyD;QACzD,SAAS,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,MAAM,QAAQ,GAAG,+BAAuB,CAAsB,UAAU,CAAC,CAAC;IAC1E,uDAAuD;IACvD,OAAO,QAAQ,CAAC;QACd,IAAI,EAAE,EAAE,IAAI,EAAE;QACd,KAAK,EAAE,IAAI,wBAAc,EAAE;QAC3B,cAAc;KACf,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACjB,6FAA6F;QAC7F,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAtBD,oDAsBC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./HubUsers"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/users/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B"}
@@ -56,6 +56,7 @@ export declare const setContentBoundary: (content: IHubContent, boundary: Geogra
56
56
  organization?: string;
57
57
  orgId?: string;
58
58
  organizationSource: PublisherSource;
59
+ isExternal: boolean;
59
60
  };
60
61
  portalHomeUrl?: string;
61
62
  portalApiUrl?: string;
@@ -8,6 +8,7 @@ import { IHubAdditionalResource } from "./IHubAdditionalResource";
8
8
  export declare enum PublisherSource {
9
9
  CitationContact = "metadata.resource.citation.contact",
10
10
  ResourceContact = "metadata.resource.contact",
11
+ MetadataContact = "metadata.contact",
11
12
  ItemOwner = "item.owner",
12
13
  None = "none"
13
14
  }
@@ -71,8 +72,9 @@ export interface IHubContent extends IHubItemEntity, IHubContentEnrichments, IIt
71
72
  * Info to display about the content's publisher. Follows this fallback pattern:
72
73
  * 1) Formal Item Metadata > Resource > Citation > Contact
73
74
  * 2) Formal Item Metadata > Resource > Contact
74
- * 3) Item’s Owner and Org Name
75
- * 4) Undefined (Item Owner / Org are private and we can't access additional info)
75
+ * 3) Formal Item Metadata > Contact
76
+ * 4) Item’s Owner and Org Name
77
+ * 5) Undefined (Item Owner / Org are private and we can't access additional info)
76
78
  */
77
79
  publisher?: {
78
80
  name?: string;
@@ -81,6 +83,7 @@ export interface IHubContent extends IHubItemEntity, IHubContentEnrichments, IIt
81
83
  organization?: string;
82
84
  orgId?: string;
83
85
  organizationSource: PublisherSource;
86
+ isExternal: boolean;
84
87
  };
85
88
  /** URL of the resource's page in the Portal Home application */
86
89
  portalHomeUrl?: string;
@@ -26,6 +26,7 @@ export * from "./utils";
26
26
  export * from "./Hub";
27
27
  export * from "./pages";
28
28
  export * from "./org";
29
+ export * from "./users";
29
30
  import OperationStack from "./OperationStack";
30
31
  import OperationError from "./OperationError";
31
32
  import HubError from "./HubError";
@@ -0,0 +1,8 @@
1
+ import { IFilterGroup, IHubSearchOptions, IHubSearchResponse, IHubSearchResult } from "../types";
2
+ /**
3
+ * @private
4
+ * Portal Search implementation for Users
5
+ * @param filterGroups
6
+ * @param options
7
+ */
8
+ export declare function portalSearchUsers(filterGroups: Array<IFilterGroup<"user">>, options: IHubSearchOptions): Promise<IHubSearchResponse<IHubSearchResult>>;
@@ -40,6 +40,7 @@ export interface IFilterTypeMap {
40
40
  item: IItemFilter;
41
41
  user: IUserFilterDefinition;
42
42
  group: IGroupFilterDefinition;
43
+ groupMember: IGroupMemberFilterDefinition;
43
44
  event: IEventFilterDefinition;
44
45
  /**
45
46
  * DEPRECATED use item
@@ -127,7 +128,7 @@ export interface IUserFilterDefinition {
127
128
  email?: string | string[] | IMatchOptions;
128
129
  firstname?: string | string[] | IMatchOptions;
129
130
  fullname?: string | string[] | IMatchOptions;
130
- groups?: string | string[] | IMatchOptions;
131
+ group?: string | string[] | IMatchOptions;
131
132
  lastlogin?: IDateRange<number> | IRelativeDate;
132
133
  lastname?: string | string[] | IMatchOptions;
133
134
  modified?: IDateRange<number> | IRelativeDate;
@@ -135,6 +136,21 @@ export interface IUserFilterDefinition {
135
136
  term?: string;
136
137
  userlicensetype?: string | string[] | IMatchOptions;
137
138
  username?: string | string[] | IMatchOptions;
139
+ emailstatus?: string | string[] | IMatchOptions;
140
+ provider?: string | string[] | IMatchOptions;
141
+ }
142
+ /**
143
+ * These properties must all be passed through
144
+ * so they are sent in separate fields and *not*
145
+ * serialized into a q
146
+ * Also `joined` does not take the same format as
147
+ * dates in `q`
148
+ */
149
+ export interface IGroupMemberFilterDefinition {
150
+ memberType?: "admin" | "member";
151
+ joined?: IDateRange<number> | IRelativeDate;
152
+ name?: string | string[] | IMatchOptions;
153
+ orgIds?: string | string[] | IMatchOptions;
138
154
  }
139
155
  export interface IGroupFilterDefinition {
140
156
  access?: string | string[] | IMatchOptions;
@@ -145,6 +161,7 @@ export interface IGroupFilterDefinition {
145
161
  orgid?: string | string[] | IMatchOptions;
146
162
  owner?: string | string[] | IMatchOptions;
147
163
  searchUserAccess?: "groupMember";
164
+ searchUserName?: string;
148
165
  tags?: string | string[] | IMatchOptions;
149
166
  term?: string;
150
167
  title?: string | string[] | IMatchOptions;
@@ -0,0 +1,10 @@
1
+ import { IRequestOptions } from "@esri/arcgis-rest-request";
2
+ import { IPortal } from "@esri/arcgis-rest-portal";
3
+ import { IHubRequestOptions } from "../types";
4
+ /**
5
+ * Return the URL of the user's page in the Portal Home application
6
+ * @param username The username
7
+ * @param portalUrlOrObject a portal base or API URL, a portal object, or request options containing either of those
8
+ * @returns URL to the user's profile, defaults to `https://www.arcgis.com/home/user.html?user={username}`
9
+ */
10
+ export declare function getUserHomeUrl(username: string, portalUrlOrObject?: string | IPortal | IHubRequestOptions | IRequestOptions): string;
@@ -16,6 +16,7 @@ export * from "./convert-urls-to-anchor-tags";
16
16
  export * from "./getHubApiFromPortalUrl";
17
17
  export * from "./getPortalBaseFromOrgUrl";
18
18
  export * from "./getGroupHomeUrl";
19
+ export * from "./getUserHomeUrl";
19
20
  /**
20
21
  *
21
22
  * @param url
@@ -0,0 +1,11 @@
1
+ import { IUser } from "@esri/arcgis-rest-types";
2
+ import { IHubSearchResult } from "../search";
3
+ import { IHubRequestOptions } from "../types";
4
+ /**
5
+ * Enrich a User object
6
+ * @param user
7
+ * @param includes
8
+ * @param requestOptions
9
+ * @returns
10
+ */
11
+ export declare function enrichUserSearchResult(user: IUser, include: string[], requestOptions: IHubRequestOptions): Promise<IHubSearchResult>;
@@ -0,0 +1,28 @@
1
+ import { IUser, IPortal } from "@esri/arcgis-rest-portal";
2
+ import { IEnrichmentErrorInfo, IHubRequestOptions } from "../../types";
3
+ /**
4
+ * Possible additional properties available through enrichments
5
+ */
6
+ export interface IUserEnrichments {
7
+ org?: IPortal;
8
+ /**
9
+ * Any errors encountered when fetching enrichments
10
+ * see https://github.com/ArcGIS/hub-indexer/blob/master/docs/errors.md#response-formatting-for-errors
11
+ */
12
+ errors?: IEnrichmentErrorInfo[];
13
+ }
14
+ export declare type UserEnrichment = keyof IUserEnrichments;
15
+ /**
16
+ * Merging of the Enrichment and the User
17
+ */
18
+ export interface IUserAndEnrichments extends IUserEnrichments {
19
+ user: IUser;
20
+ }
21
+ /**
22
+ * Fetch enrichments for Users
23
+ * @param group
24
+ * @param enrichments
25
+ * @param requestOptions
26
+ * @returns
27
+ */
28
+ export declare function fetchUserEnrichments(user: IUser, enrichments: UserEnrichment[], requestOptions?: IHubRequestOptions): Promise<IUserAndEnrichments>;
@@ -0,0 +1 @@
1
+ export * from "./HubUsers";