@esri/hub-common 14.21.1 → 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/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/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/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
|
@@ -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"}
|
|
@@ -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,2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__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"}
|
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { processAutoAddUsers } from "./processAutoAddUsers";
|
|
2
|
-
import { processInviteUsers } from "./processInviteUsers";
|
|
3
|
-
// Add or invite flow based on the type of user begins here
|
|
4
|
-
/**
|
|
5
|
-
* @private
|
|
6
|
-
* Handles add/invite logic for collaboration coordinators inside partnered orgs.
|
|
7
|
-
* This is intentionally split out from the invitation of partnered org normal members,
|
|
8
|
-
* because the two types of partnered org usres (regular and collaboration coordinator)
|
|
9
|
-
* always come from the same 'bucket', however have distinctly different add paths Invite vs auto add.
|
|
10
|
-
* It returns either an empty instance of the addOrInviteResponse
|
|
11
|
-
* object, or their response from auto adding users.
|
|
12
|
-
*
|
|
13
|
-
* @export
|
|
14
|
-
* @param {IAddOrInviteContext} context context object
|
|
15
|
-
* @return {IAddOrInviteResponse} response object
|
|
16
|
-
*/
|
|
17
|
-
export async function addOrInviteCollaborationCoordinators(context) {
|
|
18
|
-
// If there are no org users return handling no users
|
|
19
|
-
if (!context.collaborationCoordinator ||
|
|
20
|
-
context.collaborationCoordinator.length === 0) {
|
|
21
|
-
// we return an empty object because
|
|
22
|
-
// if you leave out any of the props
|
|
23
|
-
// from the final object and you are concatting together arrays you can concat
|
|
24
|
-
// an undeifined inside an array which will throw off array lengths.
|
|
25
|
-
return handleNoUsers();
|
|
26
|
-
}
|
|
27
|
-
return processAutoAddUsers(context, "collaborationCoordinator");
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @private
|
|
31
|
-
* Handles add/invite logic for community users
|
|
32
|
-
* It returns either an empty instance of the addOrInviteResponse
|
|
33
|
-
* object, or either ther esponse from processing auto adding
|
|
34
|
-
* users or inviting users. If an email has been passed in it also notifies
|
|
35
|
-
* processAutoAddUsers that emails should be sent.
|
|
36
|
-
*
|
|
37
|
-
* @export
|
|
38
|
-
* @param {IAddOrInviteContext} context context object
|
|
39
|
-
* @return {IAddOrInviteResponse} response object
|
|
40
|
-
*/
|
|
41
|
-
export async function addOrInviteCommunityUsers(context) {
|
|
42
|
-
// We default to handleNoUsers
|
|
43
|
-
// we return an empty object because
|
|
44
|
-
// if you leave out any of the props
|
|
45
|
-
// from the final object and you are concatting together arrays you can concat
|
|
46
|
-
// an undeifined inside an array which will throw off array lengths.
|
|
47
|
-
let fnToCall = handleNoUsers;
|
|
48
|
-
let shouldEmail = false;
|
|
49
|
-
// If community users were passed in...
|
|
50
|
-
if (context.community && context.community.length > 0) {
|
|
51
|
-
// Default to either autoAdd or invite based on canAutoAddUser.
|
|
52
|
-
fnToCall = context.canAutoAddUser
|
|
53
|
-
? processAutoAddUsers
|
|
54
|
-
: processInviteUsers;
|
|
55
|
-
// If we have an email object
|
|
56
|
-
// Then we will auto add...
|
|
57
|
-
// But whether or not we email is still in question
|
|
58
|
-
if (context.email) {
|
|
59
|
-
// If the email object has the groupId property...
|
|
60
|
-
if (context.email.hasOwnProperty("groupId")) {
|
|
61
|
-
// If the email objects groupId property is the same as the current groupId in context...
|
|
62
|
-
// (This function is part of a flow that could work for N groupIds)
|
|
63
|
-
if (context.email.groupId === context.groupId) {
|
|
64
|
-
// Then we auto add and send email
|
|
65
|
-
fnToCall = processAutoAddUsers;
|
|
66
|
-
shouldEmail = true;
|
|
67
|
-
} // ELSE if the groupId's do NOT match, we will fall back
|
|
68
|
-
// To autoAdd or invite as per line 32.
|
|
69
|
-
// We are doing the above logic (lines 43 - 47) because
|
|
70
|
-
// We wish to add users to core groups, followers, and content groups
|
|
71
|
-
// but only to email the core group.
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
// If it does not have a groupId at all then we will autoAdd and email.
|
|
75
|
-
fnToCall = processAutoAddUsers;
|
|
76
|
-
shouldEmail = true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Return/call the function
|
|
81
|
-
return fnToCall(context, "community", shouldEmail);
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* @private
|
|
85
|
-
* Handles add/invite logic for Org users
|
|
86
|
-
* It returns either an empty instance of the addOrInviteResponse
|
|
87
|
-
* object, or either ther esponse from processing auto adding a users or inviting a user
|
|
88
|
-
*
|
|
89
|
-
* @export
|
|
90
|
-
* @param {IAddOrInviteContext} context context object
|
|
91
|
-
* @return {IAddOrInviteResponse} response object
|
|
92
|
-
*/
|
|
93
|
-
export async function addOrInviteOrgUsers(context) {
|
|
94
|
-
// If there are no org users return handling no users
|
|
95
|
-
if (!context.org || context.org.length === 0) {
|
|
96
|
-
// we return an empty object because
|
|
97
|
-
// if you leave out any of the props
|
|
98
|
-
// from the final object and you are concatting together arrays you can concat
|
|
99
|
-
// an undeifined inside an array which will throw off array lengths.
|
|
100
|
-
return handleNoUsers();
|
|
101
|
-
}
|
|
102
|
-
// for org user if you have assignUsers then auto add the user
|
|
103
|
-
// if not then invite the user
|
|
104
|
-
return context.canAutoAddUser
|
|
105
|
-
? processAutoAddUsers(context, "org")
|
|
106
|
-
: processInviteUsers(context, "org");
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* @private
|
|
110
|
-
* Handles add/invite logic for partnered org users.
|
|
111
|
-
* It returns either an empty instance of the addOrInviteResponse
|
|
112
|
-
* object, or their response from inviting users.
|
|
113
|
-
*
|
|
114
|
-
* @export
|
|
115
|
-
* @param {IAddOrInviteContext} context context object
|
|
116
|
-
* @return {IAddOrInviteResponse} response object
|
|
117
|
-
*/
|
|
118
|
-
export async function addOrInvitePartneredUsers(context) {
|
|
119
|
-
// If there are no org users return handling no users
|
|
120
|
-
if (!context.partnered || context.partnered.length === 0) {
|
|
121
|
-
// we return an empty object because
|
|
122
|
-
// if you leave out any of the props
|
|
123
|
-
// from the final object and you are concatting together arrays you can concat
|
|
124
|
-
// an undeifined inside an array which will throw off array lengths.
|
|
125
|
-
return handleNoUsers();
|
|
126
|
-
}
|
|
127
|
-
// process invite
|
|
128
|
-
return processInviteUsers(context, "partnered");
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* @private
|
|
132
|
-
* Handles add/invite logic for world users
|
|
133
|
-
* It either returns an empty instance of the add/invite response
|
|
134
|
-
* object, or a populated version from processInviteUsers
|
|
135
|
-
*
|
|
136
|
-
* @export
|
|
137
|
-
* @param {IAddOrInviteContext} context Context object
|
|
138
|
-
* @return {IAddOrInviteResponse} Response object
|
|
139
|
-
*/
|
|
140
|
-
export async function addOrInviteWorldUsers(context) {
|
|
141
|
-
// If there are no world users return handling no users
|
|
142
|
-
if (!context.world || context.world.length === 0) {
|
|
143
|
-
// we return an empty object because
|
|
144
|
-
// if you leave out any of the props
|
|
145
|
-
// from the final object and you are concatting together arrays you can concat
|
|
146
|
-
// an undeifined inside an array which will throw off array lengths.
|
|
147
|
-
return handleNoUsers();
|
|
148
|
-
}
|
|
149
|
-
// process invite
|
|
150
|
-
return processInviteUsers(context, "world");
|
|
151
|
-
}
|
|
152
|
-
// Add or invite flow based on the type of user ends here
|
|
153
|
-
/**
|
|
154
|
-
* @private
|
|
155
|
-
* Returns an empty instance of the addorinviteresponse object.
|
|
156
|
-
* We are using this because if you leave out any of the props
|
|
157
|
-
* from the final object and you are concatting together arrays you can concat
|
|
158
|
-
* an undeifined inside an array which will throw off array lengths.
|
|
159
|
-
*
|
|
160
|
-
* @export
|
|
161
|
-
* @return {IAddOrInviteResponse}
|
|
162
|
-
*/
|
|
163
|
-
export async function handleNoUsers(context, userType, shouldEmail) {
|
|
164
|
-
return {
|
|
165
|
-
notAdded: [],
|
|
166
|
-
notEmailed: [],
|
|
167
|
-
notInvited: [],
|
|
168
|
-
users: [],
|
|
169
|
-
errors: [],
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* @private
|
|
174
|
-
* Takes users array and sorts them into an object by the type of user they are
|
|
175
|
-
* based on the orgType prop (world|org|community)
|
|
176
|
-
*
|
|
177
|
-
* @export
|
|
178
|
-
* @param {IUserWithOrgType[]} users array of users
|
|
179
|
-
* @return {IUserOrgRelationship} Object of users sorted by type (world, org, community)
|
|
180
|
-
*/
|
|
181
|
-
export function groupUsersByOrgRelationship(users) {
|
|
182
|
-
return users.reduce((acc, user) => {
|
|
183
|
-
// keyof needed to make bracket notation work without TS throwing a wobbly.
|
|
184
|
-
const orgType = user.orgType;
|
|
185
|
-
acc[orgType].push(user);
|
|
186
|
-
return acc;
|
|
187
|
-
}, {
|
|
188
|
-
world: [],
|
|
189
|
-
org: [],
|
|
190
|
-
community: [],
|
|
191
|
-
partnered: [],
|
|
192
|
-
collaborationCoordinator: [],
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
//# sourceMappingURL=AddOrInviteUsersToGroupUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AddOrInviteUsersToGroupUtils.js","sourceRoot":"","sources":["../../../../src/groups/_internal/AddOrInviteUsersToGroupUtils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,2DAA2D;AAE3D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,oCAAoC,CACxD,OAA4B;IAE5B,qDAAqD;IACrD,IACE,CAAC,OAAO,CAAC,wBAAwB;QACjC,OAAO,CAAC,wBAAwB,CAAC,MAAM,KAAK,CAAC,EAC7C;QACA,oCAAoC;QACpC,oCAAoC;QACpC,8EAA8E;QAC9E,oEAAoE;QACpE,OAAO,aAAa,EAAE,CAAC;KACxB;IACD,OAAO,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAA4B;IAE5B,8BAA8B;IAC9B,oCAAoC;IACpC,oCAAoC;IACpC,8EAA8E;IAC9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ACjB,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACZ,2EAA2E;QAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAqC,CAAC;QAC3D,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,GAAG,CAAC;IACb,CAAC,EACD;QACE,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,EAAE;QACP,SAAS,EAAE,EAAE;QACb,SAAS,EAAE,EAAE;QACb,wBAAwB,EAAE,EAAE;KAC7B,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { getProp } from "../../objects/get-prop";
|
|
2
|
-
import { autoAddUsers } from "../autoAddUsers";
|
|
3
|
-
import { processEmailUsers } from "./processEmailUsers";
|
|
4
|
-
import { autoAddUsersAsAdmins } from "./autoAddUsersAsAdmins";
|
|
5
|
-
/**
|
|
6
|
-
* @private
|
|
7
|
-
* Governs logic for automatically adding N users to a group.
|
|
8
|
-
* Users are added as either a regular user OR as an administrator of the group
|
|
9
|
-
* depending on the addUserAsGroupAdmin prop on the IAddOrInviteContext.
|
|
10
|
-
* If there is an email object on the IAddOrInviteContext, then email notifications are sent.
|
|
11
|
-
*
|
|
12
|
-
* @export
|
|
13
|
-
* @param {IAddOrInviteContext} context context object
|
|
14
|
-
* @param {string} userType what type of user is it: org | world | community
|
|
15
|
-
* @param {boolean} [shouldEmail=false] should the user be emailed?
|
|
16
|
-
* @return {IAddOrInviteResponse} response object
|
|
17
|
-
*/
|
|
18
|
-
export async function processAutoAddUsers(context, userType, shouldEmail = false) {
|
|
19
|
-
// fetch users out of context object
|
|
20
|
-
const users = getProp(context, userType);
|
|
21
|
-
let autoAddResponse;
|
|
22
|
-
let emailResponse;
|
|
23
|
-
let notAdded = [];
|
|
24
|
-
let errors = [];
|
|
25
|
-
// fetch addUserAsGroupAdmin out of context
|
|
26
|
-
const { addUserAsGroupAdmin } = context;
|
|
27
|
-
if (addUserAsGroupAdmin) {
|
|
28
|
-
// if is core group we elevate user to admin
|
|
29
|
-
autoAddResponse = await autoAddUsersAsAdmins(getProp(context, "groupId"), users, getProp(context, "primaryRO"));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
// if not then we are just auto adding them
|
|
33
|
-
autoAddResponse = await autoAddUsers(getProp(context, "groupId"), users, getProp(context, "primaryRO"));
|
|
34
|
-
}
|
|
35
|
-
// handle notAdded users
|
|
36
|
-
if (autoAddResponse.notAdded) {
|
|
37
|
-
notAdded = notAdded.concat(autoAddResponse.notAdded);
|
|
38
|
-
}
|
|
39
|
-
// Merge errors into empty array
|
|
40
|
-
if (autoAddResponse.errors) {
|
|
41
|
-
errors = errors.concat(autoAddResponse.errors);
|
|
42
|
-
}
|
|
43
|
-
// run email process
|
|
44
|
-
if (shouldEmail) {
|
|
45
|
-
emailResponse = await processEmailUsers(context);
|
|
46
|
-
// merge errors in to overall errors array to keep things flat
|
|
47
|
-
if (emailResponse.errors && emailResponse.errors.length > 0) {
|
|
48
|
-
errors = errors.concat(emailResponse.errors);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// if you leave out any of the props
|
|
52
|
-
// from the final object and you are concatting together arrays you can concat
|
|
53
|
-
// an undeifined inside an array which will throw off array lengths.
|
|
54
|
-
return {
|
|
55
|
-
users: users.map((u) => u.username),
|
|
56
|
-
notAdded,
|
|
57
|
-
errors,
|
|
58
|
-
notEmailed: (emailResponse === null || emailResponse === void 0 ? void 0 : emailResponse.notEmailed) || [],
|
|
59
|
-
notInvited: [],
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=processAutoAddUsers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processAutoAddUsers.js","sourceRoot":"","sources":["../../../../src/groups/_internal/processAutoAddUsers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,E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,CAAC;QACjD,8DAA8D;QAC9D,IAAI,aAAa,CAAC,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3D,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SAC9C;KACF;IACD,oCAAoC;IACpC,8EAA8E;IAC9E,oEAAoE;IACpE,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;QACnC,QAAQ;QACR,MAAM;QACN,UAAU,EAAE,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,UAAU,KAAI,EAAE;QAC3C,UAAU,EAAE,EAAE;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { getProp } from "../../objects/get-prop";
|
|
2
|
-
import { emailOrgUsers } from "../emailOrgUsers";
|
|
3
|
-
/**
|
|
4
|
-
* @private
|
|
5
|
-
* Governs the logic for emailing N users. It acts under the assumption
|
|
6
|
-
* that all the 'community' users are the ones being emailed (this is due to platform rules we conform to)
|
|
7
|
-
* Function is called upstream depending on if an email object is attached to the context.
|
|
8
|
-
* Email object contains its own auth as it'll require the community admin to send the email itself.
|
|
9
|
-
* An individual email call goes out for each user due to how the response of multiple users in a single call works.
|
|
10
|
-
*
|
|
11
|
-
* @export
|
|
12
|
-
* @param {IAddOrInviteContext} context context object
|
|
13
|
-
* @return {IAddOrInviteResponse} response object
|
|
14
|
-
*/
|
|
15
|
-
export async function processEmailUsers(context) {
|
|
16
|
-
// Fetch users out of context. We only email community users so we are
|
|
17
|
-
// explicit about that
|
|
18
|
-
const users = getProp(context, "community");
|
|
19
|
-
const notEmailed = [];
|
|
20
|
-
let errors = [];
|
|
21
|
-
// iterate through users as we want a distinct email call per user due to how
|
|
22
|
-
// batch email will only respond with success: true/false
|
|
23
|
-
// and if there is an error then it gets priority even though successes do still go through
|
|
24
|
-
for (const user of users) {
|
|
25
|
-
// Make email call...
|
|
26
|
-
const emailResponse = await emailOrgUsers([user], getProp(context, "email.message"), getProp(context, "email.auth"), true);
|
|
27
|
-
// If it's just a failed email
|
|
28
|
-
// then add username to notEmailed array
|
|
29
|
-
if (!emailResponse.success) {
|
|
30
|
-
notEmailed.push(user.username);
|
|
31
|
-
// If there was a legit error
|
|
32
|
-
// Then only the error returns from
|
|
33
|
-
// online. Add error AND include username in notEmailed array.
|
|
34
|
-
if (emailResponse.errors) {
|
|
35
|
-
errors = errors.concat(emailResponse.errors);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// if you leave out any of the props
|
|
40
|
-
// from the final object and you are concatting together arrays you can concat
|
|
41
|
-
// an undeifined inside an array which will throw off array lengths.
|
|
42
|
-
return {
|
|
43
|
-
users: users.map((u) => u.username),
|
|
44
|
-
notEmailed,
|
|
45
|
-
errors,
|
|
46
|
-
notInvited: [],
|
|
47
|
-
notAdded: [],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=processEmailUsers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"processEmailUsers.js","sourceRoot":"","sources":["../../../../src/groups/_internal/processEmailUsers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAA4B;IAE5B,sEAAsE;IACtE,sBAAsB;IACtB,MAAM,KAAK,GAAY,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACrD,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,IAAI,MAAM,GAAyB,EAAE,CAAC;IACtC,6EAA6E;IAC7E,yDAAyD;IACzD,2FAA2F;IAC3F,KAAK,MAAM,IA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