@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.
Files changed (55) hide show
  1. package/dist/esm/content/_internal/computeProps.js +3 -4
  2. package/dist/esm/content/_internal/computeProps.js.map +1 -1
  3. package/dist/esm/groups/addGroupMembers.js +79 -0
  4. package/dist/esm/groups/addGroupMembers.js.map +1 -0
  5. package/dist/esm/groups/index.js +1 -2
  6. package/dist/esm/groups/index.js.map +1 -1
  7. package/dist/esm/permissions/_internal/checkOwner.js +6 -2
  8. package/dist/esm/permissions/_internal/checkOwner.js.map +1 -1
  9. package/dist/esm/permissions/_internal/checkPrivileges.js +5 -1
  10. package/dist/esm/permissions/_internal/checkPrivileges.js.map +1 -1
  11. package/dist/node/content/_internal/computeProps.js +2 -3
  12. package/dist/node/content/_internal/computeProps.js.map +1 -1
  13. package/dist/node/groups/addGroupMembers.js +83 -0
  14. package/dist/node/groups/addGroupMembers.js.map +1 -0
  15. package/dist/node/groups/index.js +1 -2
  16. package/dist/node/groups/index.js.map +1 -1
  17. package/dist/node/permissions/_internal/checkOwner.js +6 -2
  18. package/dist/node/permissions/_internal/checkOwner.js.map +1 -1
  19. package/dist/node/permissions/_internal/checkPrivileges.js +5 -1
  20. package/dist/node/permissions/_internal/checkPrivileges.js.map +1 -1
  21. package/dist/types/core/types/IHubLocation.d.ts +1 -1
  22. package/dist/types/groups/addGroupMembers.d.ts +16 -0
  23. package/dist/types/groups/index.d.ts +1 -2
  24. package/dist/types/groups/types/types.d.ts +10 -61
  25. package/package.json +1 -1
  26. package/dist/esm/groups/_internal/AddOrInviteUsersToGroupUtils.js +0 -195
  27. package/dist/esm/groups/_internal/AddOrInviteUsersToGroupUtils.js.map +0 -1
  28. package/dist/esm/groups/_internal/processAutoAddUsers.js +0 -62
  29. package/dist/esm/groups/_internal/processAutoAddUsers.js.map +0 -1
  30. package/dist/esm/groups/_internal/processEmailUsers.js +0 -50
  31. package/dist/esm/groups/_internal/processEmailUsers.js.map +0 -1
  32. package/dist/esm/groups/_internal/processInviteUsers.js +0 -51
  33. package/dist/esm/groups/_internal/processInviteUsers.js.map +0 -1
  34. package/dist/esm/groups/addOrInviteUsersToGroup.js +0 -67
  35. package/dist/esm/groups/addOrInviteUsersToGroup.js.map +0 -1
  36. package/dist/esm/groups/addOrInviteUsersToGroups.js +0 -51
  37. package/dist/esm/groups/addOrInviteUsersToGroups.js.map +0 -1
  38. package/dist/node/groups/_internal/AddOrInviteUsersToGroupUtils.js +0 -205
  39. package/dist/node/groups/_internal/AddOrInviteUsersToGroupUtils.js.map +0 -1
  40. package/dist/node/groups/_internal/processAutoAddUsers.js +0 -66
  41. package/dist/node/groups/_internal/processAutoAddUsers.js.map +0 -1
  42. package/dist/node/groups/_internal/processEmailUsers.js +0 -54
  43. package/dist/node/groups/_internal/processEmailUsers.js.map +0 -1
  44. package/dist/node/groups/_internal/processInviteUsers.js +0 -55
  45. package/dist/node/groups/_internal/processInviteUsers.js.map +0 -1
  46. package/dist/node/groups/addOrInviteUsersToGroup.js +0 -71
  47. package/dist/node/groups/addOrInviteUsersToGroup.js.map +0 -1
  48. package/dist/node/groups/addOrInviteUsersToGroups.js +0 -55
  49. package/dist/node/groups/addOrInviteUsersToGroups.js.map +0 -1
  50. package/dist/types/groups/_internal/AddOrInviteUsersToGroupUtils.d.ts +0 -82
  51. package/dist/types/groups/_internal/processAutoAddUsers.d.ts +0 -15
  52. package/dist/types/groups/_internal/processEmailUsers.d.ts +0 -14
  53. package/dist/types/groups/_internal/processInviteUsers.d.ts +0 -13
  54. package/dist/types/groups/addOrInviteUsersToGroup.d.ts +0 -18
  55. package/dist/types/groups/addOrInviteUsersToGroups.d.ts +0 -30
@@ -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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,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QAChD,oCAAoC;QACpC,oCAAoC;QACpC,8EAA8E;QAC9E,oEAAoE;QACpE,OAAO,aAAa,EAAE,CAAC;KACxB;IACD,iBAAiB;IACjB,OAAO,kBAAkB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED,yDAAyD;AAEzD;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAA6B,EAC7B,QAAsD,EACtD,WAAqB;IAErB,OAAO;QACL,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,EAAE;QACd,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAyB;IAEzB,OAAO,KAAK,CAAC,MAAM,CACjB,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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AiB,CAAC,OAAO,CAAC,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,IAAI,IAAI,KAAK,EAAE;QACxB,qBAAqB;QACrB,MAAM,aAAa,GAAG,MAAM,aAAa,CACvC,CAAC,IAAI,CAAC,EACN,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC,EACjC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,EAC9B,IAAI,CACL,CAAC;QACF,8BAA8B;QAC9B,wCAAwC;QACxC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;YAC1B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/B,6BAA6B;YAC7B,mCAAmC;YACnC,8DAA8D;YAC9D,IAAI,aAAa,CAAC,MAAM,EAAE;gBACxB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;aAC9C;SACF;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,UAAU;QACV,MAAM;QACN,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC"}
@@ -1,51 +0,0 @@
1
- import { getProp } from "../../objects/get-prop";
2
- import { inviteUsers } from "../inviteUsers";
3
- /**
4
- * @private
5
- * Governs the logic for inviting N users to a single group.
6
- * An individual invite call goes out for each user and the results are consolidated.
7
- * See comment in function about the for...of loop which explains reasoning.
8
- *
9
- * @export
10
- * @param {IAddOrInviteContext} context context object
11
- * @param {string} userType what type of user is it: org | world | community
12
- * @return {IAddOrInviteResponse} response object
13
- */
14
- export async function processInviteUsers(context, userType) {
15
- // Fetch users out of context based on userType
16
- const users = getProp(context, userType);
17
- const notInvited = [];
18
- let errors = [];
19
- const { addUserAsGroupAdmin } = context;
20
- // iterate through users as we want a distinct invite call per user due to how
21
- // batch invites will only respond with success: true/false
22
- // and if there is an error then it gets priority even though successes do still go through
23
- for (const user of users) {
24
- // Invite users call
25
- const inviteResponse = await inviteUsers(getProp(context, "groupId"), [user], getProp(context, "primaryRO"), 20160, // timeout
26
- addUserAsGroupAdmin ? "group_admin" : "group_member" // if we are in a core group we want to invite them as a group admin, otherwise a group member
27
- );
28
- // If it's just a failed invite then
29
- // add username to notInvited array
30
- if (!inviteResponse.success) {
31
- notInvited.push(user.username);
32
- // If there was a legit error
33
- // Then only the error returns from
34
- // online. Add error AND include username in notInvited array.
35
- if (inviteResponse.errors) {
36
- errors = errors.concat(inviteResponse.errors);
37
- }
38
- }
39
- }
40
- // if you leave out any of the props
41
- // from the final object and you are concatting together arrays you can concat
42
- // an undeifined inside an array which will throw off array lengths.
43
- return {
44
- users: users.map((u) => u.username),
45
- notInvited,
46
- errors,
47
- notEmailed: [],
48
- notAdded: [],
49
- };
50
- }
51
- //# sourceMappingURL=processInviteUsers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"processInviteUsers.js","sourceRoot":"","sources":["../../../../src/groups/_internal/processInviteUsers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAA4B,EAC5B,QAAqD;IAErD,+CAA+C;IAC/C,MAAM,KAAK,GAAY,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAClD,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,IAAI,MAAM,GAAyB,EAAE,CAAC;IACtC,MAAM,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;IACxC,8EAA8E;IAC9E,2DAA2D;IAC3D,2FAA2F;IAC3F,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,oBAAoB;QACpB,MAAM,cAAc,GAAG,MAAM,WAAW,CACtC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,EAC3B,CAAC,IAAI,CAAC,EACN,OAAO,CAAC,OAAO,EAAE,WAAW,CAAC,EAC7B,KAAK,EAAE,UAAU;QACjB,mBAAmB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,8FAA8F;SACpJ,CAAC;QACF,oCAAoC;QACpC,mCAAmC;QACnC,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;YAC3B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC/B,6BAA6B;YAC7B,mCAAmC;YACnC,8DAA8D;YAC9D,IAAI,cAAc,CAAC,MAAM,EAAE;gBACzB,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;aAC/C;SACF;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,UAAU;QACV,MAAM;QACN,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC"}
@@ -1,67 +0,0 @@
1
- import { addOrInviteCollaborationCoordinators, addOrInviteCommunityUsers, addOrInviteOrgUsers, addOrInvitePartneredUsers, addOrInviteWorldUsers, groupUsersByOrgRelationship, } from "./_internal/AddOrInviteUsersToGroupUtils";
2
- /**
3
- * Add or invite N users to a single group
4
- * Org|community|world logic flows are run even if there are no users applicable for that particular path.
5
- * Results from each path are consolidated and surfaced in the return object as failures and errors are of
6
- * more importance than successes.
7
- *
8
- * @export
9
- * @param {string} groupId Group we are adding users to
10
- * @param {IUserWithOrgType[]} users array of users to add
11
- * @param {IAuthenticationManager} primaryRO primary requestOptions
12
- * @param {boolean} canAutoAddUser Can we automatically add a user to the group?
13
- * @param {boolean} addUserAsGroupAdmin Should the user be added as a group administrator
14
- * @param {IAddOrInviteEmail} email Email object
15
- * @return {IAddOrInviteToGroupResult} Result object
16
- */
17
- export async function addOrInviteUsersToGroup(groupId, users, primaryRO, canAutoAddUser, addUserAsGroupAdmin, email) {
18
- // Group users by their org relationship
19
- const parsedUsers = groupUsersByOrgRelationship(users);
20
- // build up params for the context
21
- const inputParams = {
22
- groupId,
23
- primaryRO,
24
- allUsers: users,
25
- canAutoAddUser,
26
- addUserAsGroupAdmin,
27
- email,
28
- };
29
- // create context from params and parsed users
30
- const context = Object.assign(inputParams, parsedUsers);
31
- // result obj by org relationship
32
- const result = {
33
- community: await addOrInviteCommunityUsers(context),
34
- org: await addOrInviteOrgUsers(context),
35
- world: await addOrInviteWorldUsers(context),
36
- partnered: await addOrInvitePartneredUsers(context),
37
- collaborationCoordinator: await addOrInviteCollaborationCoordinators(context),
38
- notAdded: [],
39
- notInvited: [],
40
- notEmailed: [],
41
- errors: [],
42
- groupId,
43
- };
44
- // Bring not added / invited / emailed / errors up to the top level
45
- result.notAdded = [
46
- ...result.community.notAdded,
47
- ...result.org.notAdded,
48
- ...result.world.notAdded,
49
- ];
50
- result.notInvited = [
51
- ...result.community.notInvited,
52
- ...result.org.notInvited,
53
- ...result.world.notInvited,
54
- ];
55
- result.notEmailed = [
56
- ...result.community.notEmailed,
57
- ...result.org.notEmailed,
58
- ...result.world.notEmailed,
59
- ];
60
- result.errors = [
61
- ...result.community.errors,
62
- ...result.org.errors,
63
- ...result.world.errors,
64
- ];
65
- return result;
66
- }
67
- //# sourceMappingURL=addOrInviteUsersToGroup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addOrInviteUsersToGroup.js","sourceRoot":"","sources":["../../../src/groups/addOrInviteUsersToGroup.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,oCAAoC,EACpC,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,0CAA0C,CAAC;AAElD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,OAAe,EACf,KAAyB,EACzB,SAAiC,EACjC,cAAuB,EACvB,mBAA4B,EAC5B,KAAwB;IAExB,wCAAwC;IACxC,MAAM,WAAW,GAAyB,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAC7E,kCAAkC;IAClC,MAAM,WAAW,GAAG;QAClB,OAAO;QACP,SAAS;QACT,QAAQ,EAAE,KAAK;QACf,cAAc;QACd,mBAAmB;QACnB,KAAK;KACN,CAAC;IACF,8CAA8C;IAC9C,MAAM,OAAO,GAAwB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC7E,iCAAiC;IACjC,M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initial entry point function for add/invite members flow
5
- * when dealing with multiple groups.
6
- * Responses from each group are then consolidated into the final returned object.
7
- *
8
- * @export
9
- * @param {string[]} groupIds array of groups we are adding users to
10
- * @param {IUserWithOrgType[]} users array of users to add to those groups
11
- * @param {IAuthenticationManager} primaryRO primary requestOptions
12
- * @param {boolean} [canAutoAddUser=false] Can we automatically add a user to the group?
13
- * @param {boolean} [addUserAsGroupAdmin=false] Can the user be added to a group as an administrator of that group?
14
- * @param {IAddOrInviteEmail} [email] Email object contains auth for the email && the email object itself
15
- * @return {*} {Promise<{
16
- * notAdded: string[];
17
- * notInvited: string[];
18
- * notEmailed: string[];
19
- * errors: ArcGISRequestError[];
20
- * responses: IAddOrInviteToGroupResult[];
21
- * }>} Results object
22
- */
23
- export async function addOrInviteUsersToGroups(groupIds, users, primaryRO, canAutoAddUser = false, addUserAsGroupAdmin = false, email) {
24
- let notAdded = [];
25
- let notInvited = [];
26
- let notEmailed = [];
27
- let errors = [];
28
- const responses = [];
29
- // need to for..of loop this as a reduce will overwrite promises during execution
30
- // this way we get an object of each group id nicely.
31
- for (const groupId of groupIds) {
32
- // For each group we'll add the users to them.
33
- const result = await addOrInviteUsersToGroup(groupId, users, primaryRO, canAutoAddUser, addUserAsGroupAdmin, email);
34
- // attach each groups results
35
- responses.push(result);
36
- // surface results to the top of the stack...
37
- notAdded = notAdded.concat(result.notAdded);
38
- errors = errors.concat(result.errors);
39
- notInvited = notInvited.concat(result.notInvited);
40
- notEmailed = notEmailed.concat(result.notEmailed);
41
- }
42
- // Return built up result object.
43
- return {
44
- notAdded,
45
- notInvited,
46
- notEmailed,
47
- errors,
48
- responses,
49
- };
50
- }
51
- //# sourceMappingURL=addOrInviteUsersToGroups.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addOrInviteUsersToGroups.js","sourceRoot":"","sources":["../../../src/groups/addOrInviteUsersToGroups.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,QAAkB,EAClB,KAAyB,EACzB,SAAiC,EACjC,iBAA0B,KAAK,EAC/B,sBAA+B,KAAK,EACpC,KAAyB;IAQzB,IAAI,QAAQ,GAAa,EAAE,CAAC;IAC5B,IAAI,UAAU,GAAa,EAAE,CAAC;IAC9B,IAAI,UAAU,GAAa,EAAE,CAAC;IAC9B,IAAI,MAAM,GAAyB,EAAE,CAAC;IACtC,MAAM,SAAS,GAAgC,EAAE,CAAC;IAClD,iFAAiF;IACjF,qDAAqD;IACrD,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,8CAA8C;QAC9C,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAC1C,OAAO,EACP,KAAK,EACL,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,KAAK,CACN,CAAC;QACF,6BAA6B;QAC7B,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,6CAA6C;QAC7C,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAClD,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KACnD;IACD,iCAAiC;IACjC,OAAO;QACL,QAAQ;QACR,UAAU;QACV,UAAU;QACV,MAAM;QACN,SAAS;KACV,CAAC;AACJ,CAAC"}