@esri/hub-common 14.21.0 → 14.22.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.
- package/dist/esm/content/_internal/computeProps.js +3 -4
- package/dist/esm/content/_internal/computeProps.js.map +1 -1
- package/dist/esm/groups/addGroupMembers.js +79 -0
- package/dist/esm/groups/addGroupMembers.js.map +1 -0
- package/dist/esm/groups/index.js +1 -2
- package/dist/esm/groups/index.js.map +1 -1
- package/dist/esm/permissions/_internal/checkOwner.js +6 -2
- package/dist/esm/permissions/_internal/checkOwner.js.map +1 -1
- package/dist/esm/permissions/_internal/checkPrivileges.js +5 -1
- package/dist/esm/permissions/_internal/checkPrivileges.js.map +1 -1
- package/dist/node/content/_internal/computeProps.js +2 -3
- package/dist/node/content/_internal/computeProps.js.map +1 -1
- package/dist/node/groups/addGroupMembers.js +83 -0
- package/dist/node/groups/addGroupMembers.js.map +1 -0
- package/dist/node/groups/index.js +1 -2
- package/dist/node/groups/index.js.map +1 -1
- package/dist/node/permissions/_internal/checkOwner.js +6 -2
- package/dist/node/permissions/_internal/checkOwner.js.map +1 -1
- package/dist/node/permissions/_internal/checkPrivileges.js +5 -1
- package/dist/node/permissions/_internal/checkPrivileges.js.map +1 -1
- package/dist/types/core/types/IHubLocation.d.ts +1 -1
- package/dist/types/groups/addGroupMembers.d.ts +16 -0
- package/dist/types/groups/index.d.ts +1 -2
- package/dist/types/groups/types/types.d.ts +10 -61
- package/package.json +1 -1
- package/dist/esm/groups/_internal/AddOrInviteUsersToGroupUtils.js +0 -195
- package/dist/esm/groups/_internal/AddOrInviteUsersToGroupUtils.js.map +0 -1
- package/dist/esm/groups/_internal/processAutoAddUsers.js +0 -62
- package/dist/esm/groups/_internal/processAutoAddUsers.js.map +0 -1
- package/dist/esm/groups/_internal/processEmailUsers.js +0 -50
- package/dist/esm/groups/_internal/processEmailUsers.js.map +0 -1
- package/dist/esm/groups/_internal/processInviteUsers.js +0 -51
- package/dist/esm/groups/_internal/processInviteUsers.js.map +0 -1
- package/dist/esm/groups/addOrInviteUsersToGroup.js +0 -67
- package/dist/esm/groups/addOrInviteUsersToGroup.js.map +0 -1
- package/dist/esm/groups/addOrInviteUsersToGroups.js +0 -51
- package/dist/esm/groups/addOrInviteUsersToGroups.js.map +0 -1
- package/dist/node/groups/_internal/AddOrInviteUsersToGroupUtils.js +0 -205
- package/dist/node/groups/_internal/AddOrInviteUsersToGroupUtils.js.map +0 -1
- package/dist/node/groups/_internal/processAutoAddUsers.js +0 -66
- package/dist/node/groups/_internal/processAutoAddUsers.js.map +0 -1
- package/dist/node/groups/_internal/processEmailUsers.js +0 -54
- package/dist/node/groups/_internal/processEmailUsers.js.map +0 -1
- package/dist/node/groups/_internal/processInviteUsers.js +0 -55
- package/dist/node/groups/_internal/processInviteUsers.js.map +0 -1
- package/dist/node/groups/addOrInviteUsersToGroup.js +0 -71
- package/dist/node/groups/addOrInviteUsersToGroup.js.map +0 -1
- package/dist/node/groups/addOrInviteUsersToGroups.js +0 -55
- package/dist/node/groups/addOrInviteUsersToGroups.js.map +0 -1
- package/dist/types/groups/_internal/AddOrInviteUsersToGroupUtils.d.ts +0 -82
- package/dist/types/groups/_internal/processAutoAddUsers.d.ts +0 -15
- package/dist/types/groups/_internal/processEmailUsers.d.ts +0 -14
- package/dist/types/groups/_internal/processInviteUsers.d.ts +0 -13
- package/dist/types/groups/addOrInviteUsersToGroup.d.ts +0 -18
- package/dist/types/groups/addOrInviteUsersToGroups.d.ts +0 -30
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getItemThumbnailUrl } from "../../resources";
|
|
2
|
-
import { bBoxToExtent,
|
|
2
|
+
import { bBoxToExtent, isBBox } from "../../extent";
|
|
3
3
|
import { getItemHomeUrl } from "../../urls/get-item-home-url";
|
|
4
4
|
import { getContentEditUrl, getHubRelativeUrl } from "./internalContentUtils";
|
|
5
5
|
import { getRelativeWorkspaceUrl } from "../../core/getRelativeWorkspaceUrl";
|
|
@@ -12,10 +12,9 @@ export const getExtentObject = (itemExtent) => {
|
|
|
12
12
|
};
|
|
13
13
|
export function deriveLocationFromItemExtent(itemExtent) {
|
|
14
14
|
const location = { type: "custom" };
|
|
15
|
-
const geometry = getExtentObject(itemExtent);
|
|
15
|
+
const geometry = getExtentObject(itemExtent);
|
|
16
16
|
if (geometry) {
|
|
17
|
-
|
|
18
|
-
location.geometries = [convertedExtent];
|
|
17
|
+
location.geometries = [geometry];
|
|
19
18
|
location.spatialReference = geometry.spatialReference;
|
|
20
19
|
location.extent = itemExtent;
|
|
21
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeProps.js","sourceRoot":"","sources":["../../../../src/content/_internal/computeProps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"computeProps.js","sourceRoot":"","sources":["../../../../src/content/_internal/computeProps.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { failSafe } from "../utils";
|
|
2
|
+
import { autoAddUsers } from "./autoAddUsers";
|
|
3
|
+
import { inviteUsers } from "./inviteUsers";
|
|
4
|
+
/**
|
|
5
|
+
* Add or invite N users to a single group.
|
|
6
|
+
* If autoAdd is true (if the user doing the adding has the 'portal:admin:assignToGroups' priv)
|
|
7
|
+
* then we attempt to auto add EVERY user to the group.
|
|
8
|
+
* If that call fails, then we attempt to invite them.
|
|
9
|
+
*
|
|
10
|
+
* @export
|
|
11
|
+
* @param {string} groupId ID of the group the users will be added to
|
|
12
|
+
* @param {string[]} usernames usernames of the users to add
|
|
13
|
+
* @param {IUserRequestOptions} auth Auth
|
|
14
|
+
* @param {boolean} autoAdd should we auto add users?
|
|
15
|
+
* @return {*} {Promise<IAddGroupMembersResult>}
|
|
16
|
+
*/
|
|
17
|
+
export async function addGroupMembers(groupId, usernames, auth, autoAdd) {
|
|
18
|
+
const added = [];
|
|
19
|
+
const invited = [];
|
|
20
|
+
const notAdded = [];
|
|
21
|
+
const notInvited = [];
|
|
22
|
+
const responses = [];
|
|
23
|
+
// iterate through users as we want a distinct add/invite call per user.
|
|
24
|
+
// This is primarily because batch inviting of users will only return a single consolidated
|
|
25
|
+
// 'success' response, which provides no granularity on which users were actually successfully invited.
|
|
26
|
+
// Similarly errors are consolidated into a single array, which again provides no granularity on which users
|
|
27
|
+
// experienced the error.
|
|
28
|
+
for (const username of usernames) {
|
|
29
|
+
let inviteUser = true;
|
|
30
|
+
const response = {
|
|
31
|
+
username,
|
|
32
|
+
add: null,
|
|
33
|
+
invite: null,
|
|
34
|
+
};
|
|
35
|
+
// expand user into an 'IUser' object for add/invite functions to then extract...
|
|
36
|
+
const user = { username };
|
|
37
|
+
// Create failSafe functions for add/invite
|
|
38
|
+
const failSafeAdd = failSafe(autoAddUsers);
|
|
39
|
+
const failSafeInvite = failSafe(inviteUsers);
|
|
40
|
+
// If we can add the user automatically, then attempt to do so
|
|
41
|
+
if (autoAdd) {
|
|
42
|
+
// fail safe add
|
|
43
|
+
const addResponse = await failSafeAdd(groupId, [user], auth.authentication);
|
|
44
|
+
// add response to response obj
|
|
45
|
+
response.add = addResponse;
|
|
46
|
+
// if they were added, then don't invite and add to added array
|
|
47
|
+
if (!addResponse.notAdded || addResponse.notAdded.length === 0) {
|
|
48
|
+
inviteUser = false;
|
|
49
|
+
added.push(username);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
notAdded.push(username);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (inviteUser) {
|
|
56
|
+
// fail safe invite
|
|
57
|
+
const inviteResponse = await failSafeInvite(groupId, [user], auth.authentication);
|
|
58
|
+
// add response to response obj
|
|
59
|
+
response.invite = inviteResponse;
|
|
60
|
+
// if they were invited, then add to invited array
|
|
61
|
+
if (inviteResponse.success) {
|
|
62
|
+
invited.push(username);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
notInvited.push(username);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// push response to responses array
|
|
69
|
+
responses.push(response);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
added,
|
|
73
|
+
invited,
|
|
74
|
+
notAdded,
|
|
75
|
+
notInvited,
|
|
76
|
+
responses,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=addGroupMembers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addGroupMembers.js","sourceRoot":"","sources":["../../../src/groups/addGroupMembers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,SAAmB,EACnB,IAAyB,EACzB,OAAgB;IAEhB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,SAAS,GAAiC,EAAE,CAAC;IACnD,wEAAwE;IACxE,2FAA2F;IAC3F,uGAAuG;IACvG,4GAA4G;IAC5G,yBAAyB;IACzB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,IAAI,UAAU,GAAG,IAAI,CAAC;QACtB,MAAM,QAAQ,GAA+B;YAC3C,QAAQ;YACR,GAAG,EAAE,IAAI;YACT,MAAM,EAAE,IAAI;SACb,CAAC;QACF,iFAAiF;QACjF,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAW,CAAC;QACnC,2CAA2C;QAC3C,MAAM,WAAW,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;QAC3C,MAAM,cAAc,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC7C,8DAA8D;QAC9D,IAAI,OAAO,EAAE;YACX,gBAAgB;YAChB,MAAM,WAAW,GAAG,MAAM,WAAW,CACnC,OAAO,EACP,CAAC,IAAI,CAAC,EACN,IAAI,CAAC,cAAc,CACpB,CAAC;YACF,+BAA+B;YAC/B,QAAQ,CAAC,GAAG,GAAG,WAAW,CAAC;YAC3B,+DAA+D;YAC/D,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC9D,UAAU,GAAG,KAAK,CAAC;gBACnB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACtB;iBAAM;gBACL,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACzB;SACF;QACD,IAAI,UAAU,EAAE;YACd,mBAAmB;YACnB,MAAM,cAAc,GAAG,MAAM,cAAc,CACzC,OAAO,EACP,CAAC,IAAI,CAAC,EACN,IAAI,CAAC,cAAc,CACpB,CAAC;YACF,+BAA+B;YAC/B,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAC;YACjC,kDAAkD;YAClD,IAAI,cAAc,CAAC,OAAO,EAAE;gBAC1B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACxB;iBAAM;gBACL,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC3B;SACF;QACD,mCAAmC;QACnC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC1B;IACD,OAAO;QACL,KAAK;QACL,OAAO;QACP,QAAQ;QACR,UAAU;QACV,SAAS;KACV,CAAC;AACJ,CAAC"}
|
package/dist/esm/groups/index.js
CHANGED
|
@@ -3,8 +3,7 @@ export * from "./add-users-workflow";
|
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export * from "./HubGroups";
|
|
5
5
|
export * from "./HubGroup";
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./addOrInviteUsersToGroups";
|
|
6
|
+
export * from "./addGroupMembers";
|
|
8
7
|
// TODO: The below are being used in hub-teams. When we deprecate that package we can move
|
|
9
8
|
// The below into _internal and remove the exports from here. They were previously in
|
|
10
9
|
// the add-users-workflow directory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/groups/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/groups/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,0FAA0F;AAC1F,qFAAqF;AACrF,mCAAmC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
|
@@ -7,12 +7,16 @@ import { getPolicyResponseCode } from "./getPolicyResponseCode";
|
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
9
|
export function checkOwner(policy, context, entity) {
|
|
10
|
+
var _a;
|
|
10
11
|
const checks = [];
|
|
11
12
|
// Only return a check if the policy is defined
|
|
12
13
|
if (policy.entityOwner) {
|
|
13
14
|
let response = "granted";
|
|
14
15
|
let name = "entity owner required";
|
|
15
|
-
if (!
|
|
16
|
+
if (!context.isAuthenticated) {
|
|
17
|
+
response = "not-authenticated";
|
|
18
|
+
}
|
|
19
|
+
else if (!entity) {
|
|
16
20
|
// fail b/c no entity
|
|
17
21
|
response = "entity-required";
|
|
18
22
|
}
|
|
@@ -25,7 +29,7 @@ export function checkOwner(policy, context, entity) {
|
|
|
25
29
|
// create the check
|
|
26
30
|
const check = {
|
|
27
31
|
name,
|
|
28
|
-
value: `current user: ${context.currentUser.username}`,
|
|
32
|
+
value: `current user: ${(_a = context.currentUser) === null || _a === void 0 ? void 0 : _a.username}`,
|
|
29
33
|
code: getPolicyResponseCode(response),
|
|
30
34
|
response,
|
|
31
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkOwner.js","sourceRoot":"","sources":["../../../../src/permissions/_internal/checkOwner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,MAAyB,EACzB,OAAuB,EACvB,MAA4B
|
|
1
|
+
{"version":3,"file":"checkOwner.js","sourceRoot":"","sources":["../../../../src/permissions/_internal/checkOwner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,MAAyB,EACzB,OAAuB,EACvB,MAA4B;;IAE5B,MAAM,MAAM,GAAG,EAAoB,CAAC;IACpC,+CAA+C;IAC/C,IAAI,MAAM,CAAC,WAAW,EAAE;QACtB,IAAI,QAAQ,GAAmB,SAAS,CAAC;QACzC,IAAI,IAAI,GAAG,uBAAuB,CAAC;QACnC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;YAC5B,QAAQ,GAAG,mBAAmB,CAAC;SAChC;aAAM,IAAI,CAAC,MAAM,EAAE;YAClB,qBAAqB;YACrB,QAAQ,GAAG,iBAAiB,CAAC;SAC9B;aAAM;YACL,IAAI,GAAG,0BAA0B,MAAM,CAAC,KAAK,EAAE,CAAC;YAChD,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE;gBACjD,QAAQ,GAAG,WAAW,CAAC;aACxB;SACF;QAED,mBAAmB;QACnB,MAAM,KAAK,GAAiB;YAC1B,IAAI;YACJ,KAAK,EAAE,iBAAiB,MAAA,OAAO,CAAC,WAAW,0CAAE,QAAQ,EAAE;YACvD,IAAI,EAAE,qBAAqB,CAAC,QAAQ,CAAC;YACrC,QAAQ;SACT,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACpB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -14,7 +14,11 @@ export function checkPrivileges(policy, context, _entity) {
|
|
|
14
14
|
checks = policy.privileges.map((privilege) => {
|
|
15
15
|
let response = "granted";
|
|
16
16
|
let value = "privilege present";
|
|
17
|
-
if (!context.
|
|
17
|
+
if (!context.isAuthenticated) {
|
|
18
|
+
response = "not-authenticated";
|
|
19
|
+
value = "not authenticated";
|
|
20
|
+
}
|
|
21
|
+
else if (!context.currentUser.privileges.includes(privilege)) {
|
|
18
22
|
response = "privilege-required";
|
|
19
23
|
value = "privilege missing";
|
|
20
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkPrivileges.js","sourceRoot":"","sources":["../../../../src/permissions/_internal/checkPrivileges.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAyB,EACzB,OAAuB,EACvB,OAA6B;;IAE7B,IAAI,MAAM,GAAG,EAAoB,CAAC;IAClC,+CAA+C;IAC/C,UAAI,MAAM,CAAC,UAAU,0CAAE,MAAM,EAAE;QAC7B,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAC3C,IAAI,QAAQ,GAAmB,SAAS,CAAC;YACzC,IAAI,KAAK,GAAG,mBAAmB,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"checkPrivileges.js","sourceRoot":"","sources":["../../../../src/permissions/_internal/checkPrivileges.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,MAAyB,EACzB,OAAuB,EACvB,OAA6B;;IAE7B,IAAI,MAAM,GAAG,EAAoB,CAAC;IAClC,+CAA+C;IAC/C,UAAI,MAAM,CAAC,UAAU,0CAAE,MAAM,EAAE;QAC7B,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAC3C,IAAI,QAAQ,GAAmB,SAAS,CAAC;YACzC,IAAI,KAAK,GAAG,mBAAmB,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;gBAC5B,QAAQ,GAAG,mBAAmB,CAAC;gBAC/B,KAAK,GAAG,mBAAmB,CAAC;aAC7B;iBAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAC9D,QAAQ,GAAG,oBAAoB,CAAC;gBAChC,KAAK,GAAG,mBAAmB,CAAC;aAC7B;YACD,OAAO;gBACL,IAAI,EAAE,uBAAuB,SAAS,EAAE;gBACxC,KAAK;gBACL,QAAQ;gBACR,IAAI,EAAE,qBAAqB,CAAC,QAAQ,CAAC;aACtB,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -15,10 +15,9 @@ exports.getExtentObject = (itemExtent) => {
|
|
|
15
15
|
};
|
|
16
16
|
function deriveLocationFromItemExtent(itemExtent) {
|
|
17
17
|
const location = { type: "custom" };
|
|
18
|
-
const geometry = exports.getExtentObject(itemExtent);
|
|
18
|
+
const geometry = exports.getExtentObject(itemExtent);
|
|
19
19
|
if (geometry) {
|
|
20
|
-
|
|
21
|
-
location.geometries = [convertedExtent];
|
|
20
|
+
location.geometries = [geometry];
|
|
22
21
|
location.spatialReference = geometry.spatialReference;
|
|
23
22
|
location.extent = itemExtent;
|
|
24
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeProps.js","sourceRoot":"","sources":["../../../../src/content/_internal/computeProps.ts"],"names":[],"mappings":";;;AAEA,+CAAsD;AAEtD,yCAAqE;AAGrE,oEAA8D;AAC9D,iEAA8E;AAG9E,gFAA6E;AAC7E,8DAG+B;AAG/B,oEAAoE;AACvD,QAAA,eAAe,GAAG,CAAC,UAAsB,EAAW,EAAE;IACjE,OAAO,eAAM,CAAC,UAAU,CAAC;QACvB,CAAC,CAAE,gCAAK,qBAAY,CAAC,UAAU,CAAC,KAAE,IAAI,EAAE,QAAQ,GAAyB;QACzE,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AAEF,SAAgB,4BAA4B,CAAC,UAAuB;IAClE,MAAM,QAAQ,GAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAClD,MAAM,QAAQ,GAAQ,uBAAe,CAAC,UAAU,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"computeProps.js","sourceRoot":"","sources":["../../../../src/content/_internal/computeProps.ts"],"names":[],"mappings":";;;AAEA,+CAAsD;AAEtD,yCAAqE;AAGrE,oEAA8D;AAC9D,iEAA8E;AAG9E,gFAA6E;AAC7E,8DAG+B;AAG/B,oEAAoE;AACvD,QAAA,eAAe,GAAG,CAAC,UAAsB,EAAW,EAAE;IACjE,OAAO,eAAM,CAAC,UAAU,CAAC;QACvB,CAAC,CAAE,gCAAK,qBAAY,CAAC,UAAU,CAAC,KAAE,IAAI,EAAE,QAAQ,GAAyB;QACzE,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AAEF,SAAgB,4BAA4B,CAAC,UAAuB;IAClE,MAAM,QAAQ,GAAiB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAClD,MAAM,QAAQ,GAAQ,uBAAe,CAAC,UAAU,CAAC,CAAC;IAClD,IAAI,QAAQ,EAAE;QACZ,QAAQ,CAAC,UAAU,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjC,QAAQ,CAAC,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAAC;QACtD,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC;KAC9B;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AATD,oEASC;AAED,SAAgB,YAAY,CAC1B,KAAa,EACb,OAAqC,EACrC,cAA+B,EAC/B,cAA0C,EAAE;;IAE5C,IAAI,KAAa,CAAC;IAClB,IAAI,cAAc,CAAC,cAAc,EAAE;QACjC,MAAM,OAAO,GAAgB,cAAc,CAAC,cAA6B,CAAC;QAC1E,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;KACvB;IACD,gBAAgB;IAChB,MAAM,YAAY,GAAG,+BAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;IAC5E,4EAA4E;IAC5E,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IACpC,OAAO,CAAC,KAAK,GAAG;QACd,IAAI,EAAE,kCAAc,CAAC,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC;QAChD,YAAY,EAAE,wCAAiB,CAC7B,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE,EAC1B,OAAO,CAAC,YAAY,CACrB;QACD,iBAAiB,EAAE,iDAAuB,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC;QACjE,SAAS,EAAE,YAAY;QACvB,cAAc,EAAE,wCAAiB,CAAC,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC;KAC9D,CAAC;IACF,iDAAiD;IACjD,0CAA0C;IAC1C,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC;IAEnD,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;QACrB,uFAAuF;QACvF,OAAO,CAAC,QAAQ;YACd,OAAA,KAAK,CAAC,IAAI,CAAC,UAAU,0CAAE,QAAQ,MAAK,MAAM;gBACxC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;gBAClB,CAAC,CAAC,4BAA4B,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KACvD;IAED,IAAI,WAAW,CAAC,MAAM,EAAE;QACtB,OAAO,CAAC,uBAAuB,GAAG,yCAAoB,CACpD,wCAAmB,CAAC,OAAO,EAC3B,WAAW,CAAC,MAAM,CACnB,CAAC;KACH;IAED,OAAO,OAA8B,CAAC;AACxC,CAAC;AA9CD,oCA8CC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addGroupMembers = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const autoAddUsers_1 = require("./autoAddUsers");
|
|
6
|
+
const inviteUsers_1 = require("./inviteUsers");
|
|
7
|
+
/**
|
|
8
|
+
* Add or invite N users to a single group.
|
|
9
|
+
* If autoAdd is true (if the user doing the adding has the 'portal:admin:assignToGroups' priv)
|
|
10
|
+
* then we attempt to auto add EVERY user to the group.
|
|
11
|
+
* If that call fails, then we attempt to invite them.
|
|
12
|
+
*
|
|
13
|
+
* @export
|
|
14
|
+
* @param {string} groupId ID of the group the users will be added to
|
|
15
|
+
* @param {string[]} usernames usernames of the users to add
|
|
16
|
+
* @param {IUserRequestOptions} auth Auth
|
|
17
|
+
* @param {boolean} autoAdd should we auto add users?
|
|
18
|
+
* @return {*} {Promise<IAddGroupMembersResult>}
|
|
19
|
+
*/
|
|
20
|
+
async function addGroupMembers(groupId, usernames, auth, autoAdd) {
|
|
21
|
+
const added = [];
|
|
22
|
+
const invited = [];
|
|
23
|
+
const notAdded = [];
|
|
24
|
+
const notInvited = [];
|
|
25
|
+
const responses = [];
|
|
26
|
+
// iterate through users as we want a distinct add/invite call per user.
|
|
27
|
+
// This is primarily because batch inviting of users will only return a single consolidated
|
|
28
|
+
// 'success' response, which provides no granularity on which users were actually successfully invited.
|
|
29
|
+
// Similarly errors are consolidated into a single array, which again provides no granularity on which users
|
|
30
|
+
// experienced the error.
|
|
31
|
+
for (const username of usernames) {
|
|
32
|
+
let inviteUser = true;
|
|
33
|
+
const response = {
|
|
34
|
+
username,
|
|
35
|
+
add: null,
|
|
36
|
+
invite: null,
|
|
37
|
+
};
|
|
38
|
+
// expand user into an 'IUser' object for add/invite functions to then extract...
|
|
39
|
+
const user = { username };
|
|
40
|
+
// Create failSafe functions for add/invite
|
|
41
|
+
const failSafeAdd = utils_1.failSafe(autoAddUsers_1.autoAddUsers);
|
|
42
|
+
const failSafeInvite = utils_1.failSafe(inviteUsers_1.inviteUsers);
|
|
43
|
+
// If we can add the user automatically, then attempt to do so
|
|
44
|
+
if (autoAdd) {
|
|
45
|
+
// fail safe add
|
|
46
|
+
const addResponse = await failSafeAdd(groupId, [user], auth.authentication);
|
|
47
|
+
// add response to response obj
|
|
48
|
+
response.add = addResponse;
|
|
49
|
+
// if they were added, then don't invite and add to added array
|
|
50
|
+
if (!addResponse.notAdded || addResponse.notAdded.length === 0) {
|
|
51
|
+
inviteUser = false;
|
|
52
|
+
added.push(username);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
notAdded.push(username);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (inviteUser) {
|
|
59
|
+
// fail safe invite
|
|
60
|
+
const inviteResponse = await failSafeInvite(groupId, [user], auth.authentication);
|
|
61
|
+
// add response to response obj
|
|
62
|
+
response.invite = inviteResponse;
|
|
63
|
+
// if they were invited, then add to invited array
|
|
64
|
+
if (inviteResponse.success) {
|
|
65
|
+
invited.push(username);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
notInvited.push(username);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// push response to responses array
|
|
72
|
+
responses.push(response);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
added,
|
|
76
|
+
invited,
|
|
77
|
+
notAdded,
|
|
78
|
+
notInvited,
|
|
79
|
+
responses,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
exports.addGroupMembers = addGroupMembers;
|
|
83
|
+
//# sourceMappingURL=addGroupMembers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addGroupMembers.js","sourceRoot":"","sources":["../../../src/groups/addGroupMembers.ts"],"names":[],"mappings":";;;AAEA,oCAAoC;AACpC,iDAA8C;AAC9C,+CAA4C;AAI5C;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,SAAmB,EACnB,IAAyB,EACzB,OAAgB;IAEhB,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,MAAM,SAAS,GAAiC,EAAE,CAAC;IACnD,wEAAwE;IACxE,2FAA2F;IAC3F,uGAAuG;IACvG,4GAA4G;IAC5G,yBAAyB;IACzB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,IAAI,UAAU,GAAG,IAAI,CAAC;QACtB,MAAM,QAAQ,GAA+B;YAC3C,QAAQ;YACR,GAAG,EAAE,IAAI;YACT,MAAM,EAAE,IAAI;SACb,CAAC;QACF,iFAAiF;QACjF,MAAM,IAAI,GAAG,EAAE,QAAQ,EAAW,CAAC;QACnC,2CAA2C;QAC3C,MAAM,WAAW,GAAG,gBAAQ,CAAC,2BAAY,CAAC,CAAC;QAC3C,MAAM,cAAc,GAAG,gBAAQ,CAAC,yBAAW,CAAC,CAAC;QAC7C,8DAA8D;QAC9D,IAAI,OAAO,EAAE;YACX,gBAAgB;YAChB,MAAM,WAAW,GAAG,MAAM,WAAW,CACnC,OAAO,EACP,CAAC,IAAI,CAAC,EACN,IAAI,CAAC,cAAc,CACpB,CAAC;YACF,+BAA+B;YAC/B,QAAQ,CAAC,GAAG,GAAG,WAAW,CAAC;YAC3B,+DAA+D;YAC/D,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC9D,UAAU,GAAG,KAAK,CAAC;gBACnB,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACtB;iBAAM;gBACL,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACzB;SACF;QACD,IAAI,UAAU,EAAE;YACd,mBAAmB;YACnB,MAAM,cAAc,GAAG,MAAM,cAAc,CACzC,OAAO,EACP,CAAC,IAAI,CAAC,EACN,IAAI,CAAC,cAAc,CACpB,CAAC;YACF,+BAA+B;YAC/B,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAC;YACjC,kDAAkD;YAClD,IAAI,cAAc,CAAC,OAAO,EAAE;gBAC1B,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACxB;iBAAM;gBACL,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC3B;SACF;QACD,mCAAmC;QACnC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC1B;IACD,OAAO;QACL,KAAK;QACL,OAAO;QACP,QAAQ;QACR,UAAU;QACV,SAAS;KACV,CAAC;AACJ,CAAC;AAxED,0CAwEC"}
|
|
@@ -6,8 +6,7 @@ tslib_1.__exportStar(require("./add-users-workflow"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./types"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./HubGroups"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./HubGroup"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./
|
|
10
|
-
tslib_1.__exportStar(require("./addOrInviteUsersToGroups"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./addGroupMembers"), exports);
|
|
11
10
|
// TODO: The below are being used in hub-teams. When we deprecate that package we can move
|
|
12
11
|
// The below into _internal and remove the exports from here. They were previously in
|
|
13
12
|
// the add-users-workflow directory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/groups/index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,+DAAqC;AACrC,kDAAwB;AACxB,sDAA4B;AAC5B,qDAA2B;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/groups/index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,+DAAqC;AACrC,kDAAwB;AACxB,sDAA4B;AAC5B,qDAA2B;AAC3B,4DAAkC;AAClC,0FAA0F;AAC1F,qFAAqF;AACrF,mCAAmC;AACnC,yDAA+B;AAC/B,wDAA8B;AAC9B,0DAAgC"}
|
|
@@ -10,12 +10,16 @@ const getPolicyResponseCode_1 = require("./getPolicyResponseCode");
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
function checkOwner(policy, context, entity) {
|
|
13
|
+
var _a;
|
|
13
14
|
const checks = [];
|
|
14
15
|
// Only return a check if the policy is defined
|
|
15
16
|
if (policy.entityOwner) {
|
|
16
17
|
let response = "granted";
|
|
17
18
|
let name = "entity owner required";
|
|
18
|
-
if (!
|
|
19
|
+
if (!context.isAuthenticated) {
|
|
20
|
+
response = "not-authenticated";
|
|
21
|
+
}
|
|
22
|
+
else if (!entity) {
|
|
19
23
|
// fail b/c no entity
|
|
20
24
|
response = "entity-required";
|
|
21
25
|
}
|
|
@@ -28,7 +32,7 @@ function checkOwner(policy, context, entity) {
|
|
|
28
32
|
// create the check
|
|
29
33
|
const check = {
|
|
30
34
|
name,
|
|
31
|
-
value: `current user: ${context.currentUser.username}`,
|
|
35
|
+
value: `current user: ${(_a = context.currentUser) === null || _a === void 0 ? void 0 : _a.username}`,
|
|
32
36
|
code: getPolicyResponseCode_1.getPolicyResponseCode(response),
|
|
33
37
|
response,
|
|
34
38
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkOwner.js","sourceRoot":"","sources":["../../../../src/permissions/_internal/checkOwner.ts"],"names":[],"mappings":";;;AAEA,mEAAgE;AAEhE;;;;;;GAMG;AACH,SAAgB,UAAU,CACxB,MAAyB,EACzB,OAAuB,EACvB,MAA4B
|
|
1
|
+
{"version":3,"file":"checkOwner.js","sourceRoot":"","sources":["../../../../src/permissions/_internal/checkOwner.ts"],"names":[],"mappings":";;;AAEA,mEAAgE;AAEhE;;;;;;GAMG;AACH,SAAgB,UAAU,CACxB,MAAyB,EACzB,OAAuB,EACvB,MAA4B;;IAE5B,MAAM,MAAM,GAAG,EAAoB,CAAC;IACpC,+CAA+C;IAC/C,IAAI,MAAM,CAAC,WAAW,EAAE;QACtB,IAAI,QAAQ,GAAmB,SAAS,CAAC;QACzC,IAAI,IAAI,GAAG,uBAAuB,CAAC;QACnC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;YAC5B,QAAQ,GAAG,mBAAmB,CAAC;SAChC;aAAM,IAAI,CAAC,MAAM,EAAE;YAClB,qBAAqB;YACrB,QAAQ,GAAG,iBAAiB,CAAC;SAC9B;aAAM;YACL,IAAI,GAAG,0BAA0B,MAAM,CAAC,KAAK,EAAE,CAAC;YAChD,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO,CAAC,WAAW,CAAC,QAAQ,EAAE;gBACjD,QAAQ,GAAG,WAAW,CAAC;aACxB;SACF;QAED,mBAAmB;QACnB,MAAM,KAAK,GAAiB;YAC1B,IAAI;YACJ,KAAK,EAAE,iBAAiB,MAAA,OAAO,CAAC,WAAW,0CAAE,QAAQ,EAAE;YACvD,IAAI,EAAE,6CAAqB,CAAC,QAAQ,CAAC;YACrC,QAAQ;SACT,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;KACpB;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAjCD,gCAiCC"}
|
|
@@ -17,7 +17,11 @@ function checkPrivileges(policy, context, _entity) {
|
|
|
17
17
|
checks = policy.privileges.map((privilege) => {
|
|
18
18
|
let response = "granted";
|
|
19
19
|
let value = "privilege present";
|
|
20
|
-
if (!context.
|
|
20
|
+
if (!context.isAuthenticated) {
|
|
21
|
+
response = "not-authenticated";
|
|
22
|
+
value = "not authenticated";
|
|
23
|
+
}
|
|
24
|
+
else if (!context.currentUser.privileges.includes(privilege)) {
|
|
21
25
|
response = "privilege-required";
|
|
22
26
|
value = "privilege missing";
|
|
23
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkPrivileges.js","sourceRoot":"","sources":["../../../../src/permissions/_internal/checkPrivileges.ts"],"names":[],"mappings":";;;AAEA,mEAAgE;AAEhE;;;;;;GAMG;AACH,SAAgB,eAAe,CAC7B,MAAyB,EACzB,OAAuB,EACvB,OAA6B;;IAE7B,IAAI,MAAM,GAAG,EAAoB,CAAC;IAClC,+CAA+C;IAC/C,UAAI,MAAM,CAAC,UAAU,0CAAE,MAAM,EAAE;QAC7B,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAC3C,IAAI,QAAQ,GAAmB,SAAS,CAAC;YACzC,IAAI,KAAK,GAAG,mBAAmB,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;
|
|
1
|
+
{"version":3,"file":"checkPrivileges.js","sourceRoot":"","sources":["../../../../src/permissions/_internal/checkPrivileges.ts"],"names":[],"mappings":";;;AAEA,mEAAgE;AAEhE;;;;;;GAMG;AACH,SAAgB,eAAe,CAC7B,MAAyB,EACzB,OAAuB,EACvB,OAA6B;;IAE7B,IAAI,MAAM,GAAG,EAAoB,CAAC;IAClC,+CAA+C;IAC/C,UAAI,MAAM,CAAC,UAAU,0CAAE,MAAM,EAAE;QAC7B,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;YAC3C,IAAI,QAAQ,GAAmB,SAAS,CAAC;YACzC,IAAI,KAAK,GAAG,mBAAmB,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;gBAC5B,QAAQ,GAAG,mBAAmB,CAAC;gBAC/B,KAAK,GAAG,mBAAmB,CAAC;aAC7B;iBAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;gBAC9D,QAAQ,GAAG,oBAAoB,CAAC;gBAChC,KAAK,GAAG,mBAAmB,CAAC;aAC7B;YACD,OAAO;gBACL,IAAI,EAAE,uBAAuB,SAAS,EAAE;gBACxC,KAAK;gBACL,QAAQ;gBACR,IAAI,EAAE,6CAAqB,CAAC,QAAQ,CAAC;aACtB,CAAC;QACpB,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA5BD,0CA4BC"}
|
|
@@ -9,7 +9,7 @@ export interface IHubLocation {
|
|
|
9
9
|
type: IHubLocationType;
|
|
10
10
|
spatialReference?: ISpatialReference;
|
|
11
11
|
extent?: number[][];
|
|
12
|
-
geometries?: __esri.Geometry
|
|
12
|
+
geometries?: Array<Partial<__esri.Geometry>>;
|
|
13
13
|
provenance?: "none" | "custom" | "existing";
|
|
14
14
|
center?: number[];
|
|
15
15
|
orgSpatialReference?: ISpatialReference;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IAddGroupMembersResult } from "./types";
|
|
2
|
+
import { IUserRequestOptions } from "@esri/arcgis-rest-auth";
|
|
3
|
+
/**
|
|
4
|
+
* Add or invite N users to a single group.
|
|
5
|
+
* If autoAdd is true (if the user doing the adding has the 'portal:admin:assignToGroups' priv)
|
|
6
|
+
* then we attempt to auto add EVERY user to the group.
|
|
7
|
+
* If that call fails, then we attempt to invite them.
|
|
8
|
+
*
|
|
9
|
+
* @export
|
|
10
|
+
* @param {string} groupId ID of the group the users will be added to
|
|
11
|
+
* @param {string[]} usernames usernames of the users to add
|
|
12
|
+
* @param {IUserRequestOptions} auth Auth
|
|
13
|
+
* @param {boolean} autoAdd should we auto add users?
|
|
14
|
+
* @return {*} {Promise<IAddGroupMembersResult>}
|
|
15
|
+
*/
|
|
16
|
+
export declare function addGroupMembers(groupId: string, usernames: string[], auth: IUserRequestOptions, autoAdd: boolean): Promise<IAddGroupMembersResult>;
|
|
@@ -3,8 +3,7 @@ export * from "./add-users-workflow";
|
|
|
3
3
|
export * from "./types";
|
|
4
4
|
export * from "./HubGroups";
|
|
5
5
|
export * from "./HubGroup";
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./addOrInviteUsersToGroups";
|
|
6
|
+
export * from "./addGroupMembers";
|
|
8
7
|
export * from "./autoAddUsers";
|
|
9
8
|
export * from "./inviteUsers";
|
|
10
9
|
export * from "./emailOrgUsers";
|
|
@@ -1,72 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IUser } from "@esri/arcgis-rest-types";
|
|
1
|
+
import { IAddGroupUsersResult, IInviteGroupUsersResult } from "@esri/arcgis-rest-portal";
|
|
3
2
|
export interface IEmail {
|
|
4
3
|
subject?: string;
|
|
5
4
|
body?: string;
|
|
6
5
|
copyMe?: boolean;
|
|
7
6
|
}
|
|
8
7
|
/**
|
|
9
|
-
*
|
|
10
|
-
* It extends the IUser interface with an additional property
|
|
11
|
-
* that denotes what org relationship the user might have (world|org|community|partnered|collaborationCoordinator)
|
|
8
|
+
* Interface for result object out of addGroupMembers.
|
|
12
9
|
*/
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* User org relationship interface
|
|
18
|
-
* Object contains users parsed by their org relationship (world|org|community|partnered|collaborationCoordinator)
|
|
19
|
-
*/
|
|
20
|
-
export interface IUserOrgRelationship {
|
|
21
|
-
world: IUserWithOrgType[];
|
|
22
|
-
org: IUserWithOrgType[];
|
|
23
|
-
community: IUserWithOrgType[];
|
|
24
|
-
partnered: IUserWithOrgType[];
|
|
25
|
-
collaborationCoordinator: IUserWithOrgType[];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Interface governing the add or invite response out of process auto add / invite / emailing users
|
|
29
|
-
*/
|
|
30
|
-
export interface IAddOrInviteResponse {
|
|
31
|
-
users: string[];
|
|
32
|
-
errors: ArcGISRequestError[];
|
|
10
|
+
export interface IAddGroupMembersResult {
|
|
11
|
+
added: string[];
|
|
12
|
+
invited: string[];
|
|
33
13
|
notAdded: string[];
|
|
34
14
|
notInvited: string[];
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Email input object for add/invite flow
|
|
39
|
-
* contains both the IEmail object and auth for the email.
|
|
40
|
-
*/
|
|
41
|
-
export interface IAddOrInviteEmail {
|
|
42
|
-
message: IEmail;
|
|
43
|
-
auth: IAuthenticationManager;
|
|
44
|
-
groupId?: string;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Add or invite flow context - object that contains all the needed
|
|
48
|
-
* inputs for org/world/community users
|
|
49
|
-
*/
|
|
50
|
-
export interface IAddOrInviteContext extends IUserOrgRelationship {
|
|
51
|
-
groupId: string;
|
|
52
|
-
primaryRO: IAuthenticationManager;
|
|
53
|
-
allUsers: IUserWithOrgType[];
|
|
54
|
-
canAutoAddUser: boolean;
|
|
55
|
-
addUserAsGroupAdmin: boolean;
|
|
56
|
-
email: IAddOrInviteEmail;
|
|
15
|
+
responses: IAddOrInviteMemberResponse[];
|
|
57
16
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
errors: ArcGISRequestError[];
|
|
63
|
-
notAdded: string[];
|
|
64
|
-
notInvited: string[];
|
|
65
|
-
notEmailed: string[];
|
|
66
|
-
community: IAddOrInviteResponse;
|
|
67
|
-
org: IAddOrInviteResponse;
|
|
68
|
-
world: IAddOrInviteResponse;
|
|
69
|
-
partnered: IAddOrInviteResponse;
|
|
70
|
-
collaborationCoordinator: IAddOrInviteResponse;
|
|
71
|
-
groupId: string;
|
|
17
|
+
export interface IAddOrInviteMemberResponse {
|
|
18
|
+
username: string;
|
|
19
|
+
add: IAddGroupUsersResult;
|
|
20
|
+
invite: IInviteGroupUsersResult;
|
|
72
21
|
}
|