@esri/hub-common 14.115.0 → 14.116.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 (84) hide show
  1. package/dist/esm/core/HubItemEntity.js +20 -25
  2. package/dist/esm/core/HubItemEntity.js.map +1 -1
  3. package/dist/esm/core/getEntityGroups.js +23 -0
  4. package/dist/esm/core/getEntityGroups.js.map +1 -0
  5. package/dist/esm/core/index.js +4 -0
  6. package/dist/esm/core/index.js.map +1 -1
  7. package/dist/esm/core/setEntityAccess.js +38 -0
  8. package/dist/esm/core/setEntityAccess.js.map +1 -0
  9. package/dist/esm/core/shareEntityWithGroups.js +25 -0
  10. package/dist/esm/core/shareEntityWithGroups.js.map +1 -0
  11. package/dist/esm/core/unshareEntityWithGroups.js +25 -0
  12. package/dist/esm/core/unshareEntityWithGroups.js.map +1 -0
  13. package/dist/esm/events/HubEvent.js +29 -4
  14. package/dist/esm/events/HubEvent.js.map +1 -1
  15. package/dist/esm/events/_internal/PropertyMapper.js +1 -1
  16. package/dist/esm/events/_internal/PropertyMapper.js.map +1 -1
  17. package/dist/esm/events/_internal/getEventGroups.js +17 -0
  18. package/dist/esm/events/_internal/getEventGroups.js.map +1 -0
  19. package/dist/esm/events/_internal/getPropertyMap.js +9 -1
  20. package/dist/esm/events/_internal/getPropertyMap.js.map +1 -1
  21. package/dist/esm/events/_internal/shareEventWithGroups.js +42 -0
  22. package/dist/esm/events/_internal/shareEventWithGroups.js.map +1 -0
  23. package/dist/esm/events/_internal/unshareEventWithGroups.js +26 -0
  24. package/dist/esm/events/_internal/unshareEventWithGroups.js.map +1 -0
  25. package/dist/esm/events/defaults.js +1 -1
  26. package/dist/esm/events/defaults.js.map +1 -1
  27. package/dist/esm/events/edit.js +1 -0
  28. package/dist/esm/events/edit.js.map +1 -1
  29. package/dist/esm/items/share-item-to-groups.js +29 -10
  30. package/dist/esm/items/share-item-to-groups.js.map +1 -1
  31. package/dist/esm/items/unshare-item-from-groups.js +4 -3
  32. package/dist/esm/items/unshare-item-from-groups.js.map +1 -1
  33. package/dist/esm/utils/poll.js +23 -31
  34. package/dist/esm/utils/poll.js.map +1 -1
  35. package/dist/node/core/HubItemEntity.js +20 -25
  36. package/dist/node/core/HubItemEntity.js.map +1 -1
  37. package/dist/node/core/getEntityGroups.js +27 -0
  38. package/dist/node/core/getEntityGroups.js.map +1 -0
  39. package/dist/node/core/index.js +4 -0
  40. package/dist/node/core/index.js.map +1 -1
  41. package/dist/node/core/setEntityAccess.js +42 -0
  42. package/dist/node/core/setEntityAccess.js.map +1 -0
  43. package/dist/node/core/shareEntityWithGroups.js +29 -0
  44. package/dist/node/core/shareEntityWithGroups.js.map +1 -0
  45. package/dist/node/core/unshareEntityWithGroups.js +29 -0
  46. package/dist/node/core/unshareEntityWithGroups.js.map +1 -0
  47. package/dist/node/events/HubEvent.js +29 -4
  48. package/dist/node/events/HubEvent.js.map +1 -1
  49. package/dist/node/events/_internal/PropertyMapper.js +1 -1
  50. package/dist/node/events/_internal/PropertyMapper.js.map +1 -1
  51. package/dist/node/events/_internal/getEventGroups.js +21 -0
  52. package/dist/node/events/_internal/getEventGroups.js.map +1 -0
  53. package/dist/node/events/_internal/getPropertyMap.js +9 -1
  54. package/dist/node/events/_internal/getPropertyMap.js.map +1 -1
  55. package/dist/node/events/_internal/shareEventWithGroups.js +46 -0
  56. package/dist/node/events/_internal/shareEventWithGroups.js.map +1 -0
  57. package/dist/node/events/_internal/unshareEventWithGroups.js +30 -0
  58. package/dist/node/events/_internal/unshareEventWithGroups.js.map +1 -0
  59. package/dist/node/events/defaults.js +1 -1
  60. package/dist/node/events/defaults.js.map +1 -1
  61. package/dist/node/events/edit.js +1 -0
  62. package/dist/node/events/edit.js.map +1 -1
  63. package/dist/node/items/share-item-to-groups.js +28 -9
  64. package/dist/node/items/share-item-to-groups.js.map +1 -1
  65. package/dist/node/items/unshare-item-from-groups.js +4 -3
  66. package/dist/node/items/unshare-item-from-groups.js.map +1 -1
  67. package/dist/node/utils/poll.js +24 -31
  68. package/dist/node/utils/poll.js.map +1 -1
  69. package/dist/types/core/HubItemEntity.d.ts +12 -1
  70. package/dist/types/core/behaviors/IWithSharingBehavior.d.ts +10 -0
  71. package/dist/types/core/getEntityGroups.d.ts +10 -0
  72. package/dist/types/core/index.d.ts +4 -0
  73. package/dist/types/core/setEntityAccess.d.ts +11 -0
  74. package/dist/types/core/shareEntityWithGroups.d.ts +10 -0
  75. package/dist/types/core/types/IHubEvent.d.ts +8 -0
  76. package/dist/types/core/unshareEntityWithGroups.d.ts +10 -0
  77. package/dist/types/events/HubEvent.d.ts +12 -2
  78. package/dist/types/events/_internal/getEventGroups.d.ts +9 -0
  79. package/dist/types/events/_internal/shareEventWithGroups.d.ts +10 -0
  80. package/dist/types/events/_internal/unshareEventWithGroups.d.ts +10 -0
  81. package/dist/types/items/share-item-to-groups.d.ts +5 -4
  82. package/dist/types/items/unshare-item-from-groups.d.ts +1 -1
  83. package/dist/types/utils/poll.d.ts +4 -4
  84. package/package.json +1 -1
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shareEventWithGroups = void 0;
4
+ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
5
+ const util_1 = require("../../util");
6
+ const events_1 = require("../api/events");
7
+ const poll_1 = require("../../utils/poll");
8
+ /**
9
+ * Shares an event with one or more groups
10
+ * @param groupIds An array of group IDs to share the event with
11
+ * @param entity An IHubEvent object
12
+ * @param context An IArcGISContext object
13
+ * @returns a promise that resolves IHubItemEntity
14
+ */
15
+ async function shareEventWithGroups(groupIds, entity, context) {
16
+ const fn = arcgis_rest_portal_1.searchGroups.bind(undefined, Object.assign({ q: `id:(${groupIds.join(" OR ")})`, num: groupIds.length }, context.requestOptions));
17
+ const validate = (resp) => resp.results.length === groupIds.length;
18
+ if (groupIds.length) {
19
+ try {
20
+ // We poll for the expected group results as newly created groups aren't immediately available in the
21
+ // AGO group search index. Polling here eliminates the need for us to potentially implement this polling
22
+ // in multiple places in our app where we create new groups from. In the majority of cases, this will only fire
23
+ // a single request.
24
+ const { results: groups } = await poll_1.poll(fn, validate);
25
+ const { readGroupIds, editGroupIds } = groups.reduce((acc, group) => {
26
+ const key = group.capabilities.includes("updateitemcontrol")
27
+ ? "editGroupIds"
28
+ : "readGroupIds";
29
+ return Object.assign(Object.assign({}, acc), { [key]: [...acc[key], group.id] });
30
+ }, { readGroupIds: [], editGroupIds: [] });
31
+ const { readGroups: updatedReadGroupIds, editGroups: updatedEditGroupIds, } = await events_1.updateEvent(Object.assign({ eventId: entity.id, data: {
32
+ readGroups: [...entity.readGroupIds, ...readGroupIds].filter(util_1.unique),
33
+ editGroups: [...entity.editGroupIds, ...editGroupIds].filter(util_1.unique),
34
+ } }, context.hubRequestOptions));
35
+ return Object.assign(Object.assign({}, entity), { readGroupIds: updatedReadGroupIds, editGroupIds: updatedEditGroupIds });
36
+ }
37
+ catch (e) {
38
+ throw new Error(`Entity: ${entity.id} could not be shared with groups: ${groupIds.join(", ")}`);
39
+ }
40
+ }
41
+ else {
42
+ return entity;
43
+ }
44
+ }
45
+ exports.shareEventWithGroups = shareEventWithGroups;
46
+ //# sourceMappingURL=shareEventWithGroups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shareEventWithGroups.js","sourceRoot":"","sources":["../../../../src/events/_internal/shareEventWithGroups.ts"],"names":[],"mappings":";;;AAAA,iEAA+E;AAG/E,qCAAoC;AACpC,0CAA4C;AAC5C,2CAAwC;AAExC;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CACxC,QAAkB,EAClB,MAAiB,EACjB,OAAuB;IAEvB,MAAM,EAAE,GAAyC,iCAAY,CAAC,IAAI,CAChE,SAAS,kBAEP,CAAC,EAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAClC,GAAG,EAAE,QAAQ,CAAC,MAAM,IACjB,OAAO,CAAC,cAAc,EAE5B,CAAC;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mB,IACjC;SACH;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,IAAI,KAAK,CACb,WAAW,MAAM,CAAC,EAAE,qCAAqC,QAAQ,CAAC,IAAI,CACpE,IAAI,CACL,EAAE,CACJ,CAAC;SACH;KACF;SAAM;QACL,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AA/DD,oDA+DC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unshareEventWithGroups = void 0;
4
+ const events_1 = require("../api/events");
5
+ /**
6
+ * Unshares an event with one or more groups
7
+ * @param groupIds An array of group IDs to unshare the group from
8
+ * @param entity An IHubEvent object
9
+ * @param context An IArcGISContext object
10
+ * @returns An updated IHubEvent object
11
+ */
12
+ async function unshareEventWithGroups(groupIds, entity, context) {
13
+ if (groupIds.length) {
14
+ try {
15
+ const { readGroups: updatedReadGroupIds, editGroups: updatedEditGroupIds, } = await events_1.updateEvent(Object.assign({ eventId: entity.id, data: {
16
+ readGroups: entity.readGroupIds.filter((groupId) => !groupIds.includes(groupId)),
17
+ editGroups: entity.editGroupIds.filter((groupId) => !groupIds.includes(groupId)),
18
+ } }, context.hubRequestOptions));
19
+ return Object.assign(Object.assign({}, entity), { readGroupIds: updatedReadGroupIds, editGroupIds: updatedEditGroupIds });
20
+ }
21
+ catch (e) {
22
+ throw new Error(`Entity: ${entity.id} could not be unshared with groups: ${groupIds.join(", ")}`);
23
+ }
24
+ }
25
+ else {
26
+ return entity;
27
+ }
28
+ }
29
+ exports.unshareEventWithGroups = unshareEventWithGroups;
30
+ //# sourceMappingURL=unshareEventWithGroups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unshareEventWithGroups.js","sourceRoot":"","sources":["../../../../src/events/_internal/unshareEventWithGroups.ts"],"names":[],"mappings":";;;AAEA,0CAA4C;AAE5C;;;;;;GAMG;AACI,KAAK,UAAU,sBAAsB,CAC1C,QAAkB,EAClB,MAAiB,EACjB,OAAuB;IAEvB,IAAI,QAAQ,CAAC,MAAM,EAAE;QACnB,IAAI;YACF,MAAM,EACJ,UAAU,EAAE,mBAAmB,EAC/B,UAAU,EAAE,mBAAmB,GAChC,GAAG,MAAM,oBAAW,iBACnB,OAAO,EAAE,MAAM,CAAC,EAAE,EAClB,IAAI,EAAE;oBACJ,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CACpC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CACzC;oBACD,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CACpC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CACzC;iBACF,IACE,OAAO,CAAC,iBAAiB,EAC5B,CAAC;YACH,uCACK,MAAM,KACT,YAAY,EAAE,mBAAmB,EACjC,YAAY,EAAE,mBAAmB,IACjC;SACH;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,IAAI,KAAK,CACb,WACE,MAAM,CAAC,EACT,uCAAuC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC7D,CAAC;SACH;KACF;SAAM;QACL,OAAO,MAAM,CAAC;KACf;AACH,CAAC;AArCD,wDAqCC"}
@@ -9,7 +9,7 @@ const types_1 = require("./types");
9
9
  */
10
10
  function buildDefaultEventEntity() {
11
11
  const dates = getDefaultEventDatesAndTimes_1.getDefaultEventDatesAndTimes();
12
- return Object.assign({ access: "private", allowRegistration: true, attendanceType: types_1.HubEventAttendanceType.InPerson, categories: [], inPersonCapacity: null, isAllDay: false, isCanceled: false, isDiscussable: true, isPlanned: true, isRemoved: false, name: "", notifyAttendees: true, onlineCapacity: null, onlineDetails: null, onlineUrl: null, references: [], schemaVersion: 1, tags: [] }, dates);
12
+ return Object.assign({ access: "private", allowRegistration: true, attendanceType: types_1.HubEventAttendanceType.InPerson, categories: [], inPersonCapacity: null, isAllDay: false, isCanceled: false, isDiscussable: true, isPlanned: true, isRemoved: false, name: "", notifyAttendees: true, onlineCapacity: null, onlineDetails: null, onlineUrl: null, references: [], schemaVersion: 1, tags: [], readGroupIds: [], editGroupIds: [] }, dates);
13
13
  }
14
14
  exports.buildDefaultEventEntity = buildDefaultEventEntity;
15
15
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/events/defaults.ts"],"names":[],"mappings":";;;AACA,2FAAwF;AACxF,+DAKsC;AACtC,mCAAiD;AAEjD;;GAEG;AACH,SAAgB,uBAAuB;IACrC,MAAM,KAAK,GAAG,2DAA4B,EAAE,CAAC;IAC7C,uBACE,MAAM,EAAE,SAAS,EACjB,iBAAiB,EAAE,IAAI,EACvB,cAAc,EAAE,8BAAsB,CAAC,QAAQ,EAC/C,UAAU,EAAE,EAAE,EACd,gBAAgB,EAAE,IAAI,EACtB,QAAQ,EAAE,KAAK,EACf,UAAU,EAAE,KAAK,EACjB,aAAa,EAAE,IAAI,EACnB,SAAS,EAAE,IAAI,EACf,SAAS,EAAE,KAAK,EAChB,IAAI,EAAE,EAAE,EACR,eAAe,EAAE,IAAI,EACrB,cAAc,EAAE,IAAI,EACpB,aAAa,EAAE,IAAI,EACnB,SAAS,EAAE,IAAI,EACf,UAAU,EAAE,EAAE,EACd,aAAa,EAAE,CAAC,EAChB,IAAI,EAAE,EAAE,IACL,KAAK,EAER;AACJ,CAAC;AAxBD,0DAwBC;AAED;;GAEG;AACH,SAAgB,uBAAuB;IACrC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,2DAA4B,EAAE,CAAC;IACtE,OAAO;QACL,MAAM,EAAE,0BAAW,CAAC,OAAO;QAC3B,MAAM,EAAE,KAAK;QACb,iBAAiB,EAAE,IAAI;QACvB,cAAc,EAAE,CAAC,kCAAmB,CAAC,SAAS,CAAC;QAC/C,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,EAAE;QACd,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE;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;QACd,UAAU,EAAE,EAAE;QACd,WAAW,EAAE,WAAW,CAAC,WAAW,EAAE;QACtC,eAAe,EAAE,IAAI;QACrB,UAAU,EAAE,EAAE;QACd,aAAa,EAAE,aAAa,CAAC,WAAW,EAAE;QAC1C,MAAM,EAAE,0BAAW,CAAC,OAAO;QAC3B,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;KACS,CAAC;AACvB,CAAC;AAjBD,0DAiBC"}
@@ -74,6 +74,7 @@ async function updateHubEvent(event, requestOptions) {
74
74
  onlineMeetings: model.onlineMeetings,
75
75
  readGroups: model.readGroups,
76
76
  startDateTime: model.startDateTime,
77
+ status: model.status,
77
78
  summary: model.summary,
78
79
  tags: model.tags,
79
80
  timeZone: model.timeZone,
@@ -1 +1 @@
1
- {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/events/edit.ts"],"names":[],"mappings":";;;AAEA,+DAA4D;AAC5D,+DAAiE;AACjE,yCAA8E;AAC9E,yCAGsB;AAEtB;;;;;;;;;GASG;AACI,KAAK,UAAU,cAAc,CAClC,YAAgC,EAChC,cAAkC;IAElC,MAAM,KAAK,mCAAQ,kCAAuB,EAAE,GAAK,YAAY,CAAE,CAAC;IAEhE,8EAA8E;IAC9E,8BAA8B;IAC9B,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC;IAEhC,4BAA4B;IAC5B,kEAAkE;IAElE,MAAM,MAAM,GAAG,IAAI,oCAAmB,CAAC,+BAAc,EAAE,CAAC,CAAC;IAEzD,IAAI,KAAK,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,kCAAuB,EAAE,CAAC,CAAC;IAEnE,MAAM,IAAI,GAAG;QACX,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,cAAc,EAAE,KAAK,CAAC,cA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AK,CAAC,cAAc;QACpC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,KAAK,EAAE,KAAK,CAAC,KAAK;KAEnB,CAAC;IAEF,KAAK,GAAG,MAAM,oBAAc,iBAC1B,OAAO,EAAE,KAAK,CAAC,EAAE,EACjB,IAAI,IACD,cAAc,EACjB,CAAC;IAEH,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,CAAc,CAAC;AACtD,CAAC;AA1CD,wCA0CC"}
@@ -2,20 +2,39 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shareItemToGroups = void 0;
4
4
  const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
5
+ const poll_1 = require("../utils/poll");
5
6
  /**
6
7
  * Share an item to a set of groups
7
- * @param {String} itemId Iten Id to share to the groups
8
- * @param {Array} groups Array of group id's to which the item will be shared
8
+ * @param {String} itemId Item Id to share to the groups
9
+ * @param {Array} groupIds Array of group id's to which the item will be shared
10
+ * @param {IRequestOptions} requestOptions
9
11
  * @param {String} owner optional Owner username to determine which endpoint to hit
10
- * @param {*} requestOptions
11
12
  */
12
- function shareItemToGroups(itemId, groups, requestOptions, owner) {
13
- return Promise.all(groups.map((groupId) => {
14
- const opt = Object.assign({}, { id: itemId, groupId }, requestOptions);
15
- if (owner) {
16
- opt.owner = owner;
13
+ async function shareItemToGroups(itemId, groupIds, requestOptions, owner) {
14
+ const fn = arcgis_rest_portal_1.searchGroups.bind(undefined, Object.assign({ q: `id:(${groupIds.join(" OR ")})`, num: groupIds.length }, requestOptions));
15
+ const validate = (resp) => resp.results.length === groupIds.length;
16
+ let groups;
17
+ try {
18
+ // We poll for the expected group results as newly created groups aren't immediately available in the
19
+ // AGO group search index. Polling here eliminates the need for us to potentially implement this polling
20
+ // in multiple places in our app where we create new groups from. In the majority of cases, this will only fire
21
+ // a single request.
22
+ ({ results: groups } = groupIds.length
23
+ ? await poll_1.poll(fn, validate)
24
+ : { results: [] });
25
+ }
26
+ catch (e) {
27
+ throw new Error(`Error sharing item: ${itemId} with groups: ${groupIds.join(", ")}`);
28
+ }
29
+ return Promise.all(groups.map(async (group) => {
30
+ const opt = Object.assign(Object.assign({}, requestOptions), { id: itemId, groupId: group.id, owner, confirmItemControl: group.capabilities.includes("updateitemcontrol") });
31
+ try {
32
+ const res = await arcgis_rest_portal_1.shareItemWithGroup(opt);
33
+ return res;
34
+ }
35
+ catch (e) {
36
+ throw new Error(`Error sharing item: ${itemId} with group: ${group.id}`);
17
37
  }
18
- return arcgis_rest_portal_1.shareItemWithGroup(opt);
19
38
  }));
20
39
  }
21
40
  exports.shareItemToGroups = shareItemToGroups;
@@ -1 +1 @@
1
- {"version":3,"file":"share-item-to-groups.js","sourceRoot":"","sources":["../../../src/items/share-item-to-groups.ts"],"names":[],"mappings":";;;AACA,iEAGkC;AAElC;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAC/B,MAAc,EACd,MAAgB,EAChB,cAA+B,EAC/B,KAAc;IAEd,OAAO,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,GAAG,CAAC,CAAC,OAAe,EAAE,EAAE;QAC7B,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CACvB,EAAE,EACF,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EACvB,cAAc,CACS,CAAC;QAC1B,IAAI,KAAK,EAAE;YACT,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;SACnB;QACD,OAAO,uCAAkB,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAnBD,8CAmBC"}
1
+ {"version":3,"file":"share-item-to-groups.js","sourceRoot":"","sources":["../../../src/items/share-item-to-groups.ts"],"names":[],"mappings":";;;AACA,iEAOkC;AAClC,wCAAqC;AAErC;;;;;;GAMG;AACI,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,QAAkB,EAClB,cAA+B,EAC/B,KAAc;IAEd,MAAM,EAAE,GAAyC,iCAAY,CAAC,IAAI,CAChE,SAAS,kBAEP,CAAC,EAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAClC,GAAG,EAAE,QAAQ,CAAC,MAAM,IACjB,cAAc,EAEpB,CAAC;IACF,MAAM,QAAQ,GAAG,CAAC,IAA2B,EAAE,EAAE,CAC/C,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;IAC1C,IAAI,MAAgB,CAAC;IACrB,IAAI;QACF,qGAAqG;QACrG,wGAAwG;QACxG,+GAA+G;QAC/G,oBAAoB;QACpB,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,MAAM;YACpC,CAAC,CAAC,MAAM,WAAI,CAAwB,EAAE,EAAE,QAAQ,CAAC;YACjD,CAAC,CAAE,EAAE,OAAO,EAAE,EAAE,EAA4B,CAAC,CAAC;KACjD;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,uBAAuB,MAAM,iBAAiB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpE,CAAC;KACH;IACD,OAAO,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACzB,MAAM,GAAG,GAAG,gCACP,cAAc,KACjB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,KAAK,CAAC,EAAE,EACjB,KAAK,EACL,kBAAkB,EAAE,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,mBAAmB,CAAC,GAC7C,CAAC;QAC1B,IAAI;YACF,MAAM,GAAG,GAAG,MAAM,uCAAkB,CAAC,GAAG,CAAC,CAAC;YAC1C,OAAO,GAAG,CAAC;SACZ;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,IAAI,KAAK,CACb,uBAAuB,MAAM,gBAAgB,KAAK,CAAC,EAAE,EAAE,CACxD,CAAC;SACH;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAjDD,8CAiDC"}
@@ -6,8 +6,8 @@ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
6
6
  * Unshare an item from a set of groups
7
7
  * @param {String} itemId Item Id to unshare from groups
8
8
  * @param {Array} groups Array of group id's from which the item will be unshared
9
- * @param {String} owner optional Owner username to determine which endpoint to hit
10
9
  * @param {IRequestOptions} requestOptions
10
+ * @param {String} owner optional Owner username to determine which endpoint to hit
11
11
  */
12
12
  function unshareItemFromGroups(itemId, groups, requestOptions, owner) {
13
13
  return Promise.all(groups.map(async (groupId) => {
@@ -20,10 +20,11 @@ function unshareItemFromGroups(itemId, groups, requestOptions, owner) {
20
20
  // individual call in another try/catch block to
21
21
  // make sure it catches before all promises finish
22
22
  try {
23
- return await arcgis_rest_portal_1.unshareItemWithGroup(opt);
23
+ const results = await arcgis_rest_portal_1.unshareItemWithGroup(opt);
24
+ return results;
24
25
  }
25
26
  catch (err) {
26
- throw Error(`Error unsharing item: ${itemId} with group: ${groupId}`);
27
+ throw new Error(`Error unsharing item: ${itemId} with group: ${groupId}`);
27
28
  }
28
29
  }));
29
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"unshare-item-from-groups.js","sourceRoot":"","sources":["../../../src/items/unshare-item-from-groups.ts"],"names":[],"mappings":";;;AAAA,iEAIkC;AAGlC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,MAAc,EACd,MAAgB,EAChB,cAA+B,EAC/B,KAAc;IAEd,OAAO,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CACvB,EAAE,EACF,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EACvB,cAAc,CACS,CAAC;QAC1B,IAAI,KAAK,EAAE;YACT,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;SACnB;QACD,+CAA+C;QAC/C,8CAA8C;QAC9C,gDAAgD;QAChD,kDAAkD;QAClD,IAAI;YACF,OAAO,MAAM,yCAAoB,CAAC,GAAG,CAAC,CAAC;SACxC;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,KAAK,CAAC,yBAAyB,MAAM,gBAAgB,OAAO,EAAE,CAAC,CAAC;SACvE;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AA3BD,sDA2BC"}
1
+ {"version":3,"file":"unshare-item-from-groups.js","sourceRoot":"","sources":["../../../src/items/unshare-item-from-groups.ts"],"names":[],"mappings":";;;AAAA,iEAIkC;AAGlC;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,MAAc,EACd,MAAgB,EAChB,cAA+B,EAC/B,KAAc;IAEd,OAAO,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CACvB,EAAE,EACF,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,EACvB,cAAc,CACS,CAAC;QAC1B,IAAI,KAAK,EAAE;YACT,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC;SACnB;QACD,+CAA+C;QAC/C,8CAA8C;QAC9C,gDAAgD;QAChD,kDAAkD;QAClD,IAAI;YACF,MAAM,OAAO,GAAG,MAAM,yCAAoB,CAAC,GAAG,CAAC,CAAC;YAChD,OAAO,OAAO,CAAC;SAChB;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,KAAK,CACb,yBAAyB,MAAM,gBAAgB,OAAO,EAAE,CACzD,CAAC;SACH;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AA9BD,sDA8BC"}
@@ -14,36 +14,29 @@ exports.poll = void 0;
14
14
  * @param validationFn
15
15
  * @param opts
16
16
  */
17
- exports.poll = async (requestFn, validationFn, opts) => {
18
- const options = opts || /* istanbul ignore next - we must pass in overrides for tests */ {};
19
- const timeout = isNaN(options.timeout) ? 30000 : options.timeout;
20
- /* istanbul ignore next - should not cover the 3000 case in tests */
21
- const timeBetweenRequests = isNaN(options.timeBetweenRequests)
22
- ? 3000
23
- : options.timeBetweenRequests;
24
- let resp;
25
- let requestCount = 0;
26
- let timeElapsed = 0;
27
- do {
28
- // On subsequent requests, check if the timeout has been reached
29
- // If YES: throw an error
30
- // If NO: delay before the next request
31
- if (requestCount > 0) {
32
- timeElapsed += requestCount * timeBetweenRequests;
33
- if (timeElapsed >= timeout) {
34
- throw new Error("Polling timeout");
35
- }
36
- // NOTE: we incrementally increase the time between requests
37
- // so as not to hammer an API with subsequent calls.
38
- // This was specifically requested by the Portal API team
39
- await delay(requestCount * timeBetweenRequests);
17
+ async function poll(requestFn, validationFn, options) {
18
+ const isGreaterThanZero = (num) => !isNaN(num) && num > 0;
19
+ const _maxAttempts = isGreaterThanZero(options === null || options === void 0 ? void 0 : options.maxAttempts)
20
+ ? options.maxAttempts
21
+ : 7;
22
+ const _delay = isGreaterThanZero(options === null || options === void 0 ? void 0 : options.initialRetryDelay)
23
+ ? options.initialRetryDelay
24
+ : 500;
25
+ async function pollRecursive(attempt, delay) {
26
+ if (attempt > _maxAttempts) {
27
+ throw new Error(`Polling failed after ${_maxAttempts} attempts`);
40
28
  }
41
- resp = await requestFn();
42
- requestCount++;
43
- } while (!validationFn(resp));
44
- return resp;
45
- };
46
- const delay = (milliseconds) => {
47
- return new Promise((resolve) => setTimeout(resolve, milliseconds));
48
- };
29
+ const results = await new Promise((resolve) => {
30
+ setTimeout(async () => {
31
+ const res = await requestFn();
32
+ resolve(res);
33
+ }, delay);
34
+ });
35
+ return validationFn(results)
36
+ ? results
37
+ : await pollRecursive(attempt + 1, attempt === 1 ? _delay : delay * 2);
38
+ }
39
+ return pollRecursive(1, 0);
40
+ }
41
+ exports.poll = poll;
49
42
  //# sourceMappingURL=poll.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"poll.js","sourceRoot":"","sources":["../../../src/utils/poll.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACU,QAAA,IAAI,GAAG,KAAK,EACvB,SAAoB,EACpB,YAAoC,EACpC,IAGC,EACa,EAAE;IAChB,MAAM,OAAO,GACX,IAAI,IAAI,gEAAgE,CAAC,EAAE,CAAC;IAC9E,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACjE,oEAAoE;IACpE,MAAM,mBAAmB,GAAG,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC5D,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;IAEhC,IAAI,IAAS,CAAC;IACd,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,GAAG;QACD,gEAAgE;QAChE,yBAAyB;QACzB,uCAAuC;QACvC,IAAI,YAAY,GAAG,CAAC,EAAE;YACpB,WAAW,IAAI,YAAY,GAAG,mBAAmB,CAAC;YAClD,IAAI,WAAW,IAAI,OAAO,EAAE;gBAC1B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;aACpC;YAED,4DAA4D;YAC5D,oDAAoD;YACpD,yDAAyD;YACzD,MAAM,KAAK,CA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pB,MAAM,GAAG,GAAG,MAAM,SAAS,EAAE,CAAC;gBAC9B,OAAO,CAAC,GAAG,CAAC,CAAC;YACf,CAAC,EAAE,KAAK,CAAC,CAAC;QACZ,CAAC,CAAC,CAAC;QACH,OAAO,YAAY,CAAC,OAAO,CAAC;YAC1B,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,MAAM,aAAa,CAAC,OAAO,GAAG,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7B,CAAC;AA9BD,oBA8BC"}
@@ -3,7 +3,8 @@ import { IArcGISContext } from "../ArcGISContext";
3
3
  import { IPermissionAccessResponse, IEntityPermissionPolicy, Permission } from "../permissions";
4
4
  import { IWithSharingBehavior, IWithStoreBehavior, IWithFeaturedImageBehavior, IWithPermissionBehavior, IWithAssociationBehavior } from "./behaviors";
5
5
  import { IWithThumbnailBehavior } from "./behaviors/IWithThumbnailBehavior";
6
- import { IHubItemEntity, SettableAccessLevel } from "./types";
6
+ import { IHubItemEntity } from "./types/IHubItemEntity";
7
+ import { SettableAccessLevel } from "./types/types";
7
8
  import { IWithDiscussionsBehavior } from "./behaviors/IWithDiscussionsBehavior";
8
9
  import { IWithFollowersBehavior } from "./behaviors/IWithFollowersBehavior";
9
10
  import { AssociationType, IAssociationInfo } from "../associations/types";
@@ -84,11 +85,21 @@ export declare abstract class HubItemEntity<T extends IHubItemEntity> implements
84
85
  * @param groupId
85
86
  */
86
87
  shareWithGroup(groupId: string): Promise<void>;
88
+ /**
89
+ * Share the Entity with the specified group ids
90
+ * @param groupIds
91
+ */
92
+ shareWithGroups(groupIds: string[]): Promise<void>;
87
93
  /**
88
94
  * Unshare the Entity with the specified group id
89
95
  * @param groupId
90
96
  */
91
97
  unshareWithGroup(groupId: string): Promise<void>;
98
+ /**
99
+ * Unshare the Entity with the specified group ids
100
+ * @param groupIds
101
+ */
102
+ unshareWithGroups(groupIds: string[]): Promise<void>;
92
103
  /**
93
104
  * Set the access level of the backing item
94
105
  * @param access
@@ -9,11 +9,21 @@ export interface IWithSharingBehavior {
9
9
  * @param groupId
10
10
  */
11
11
  shareWithGroup(groupId: string): Promise<void>;
12
+ /**
13
+ * Share the item with multiple groups
14
+ * @param groupIds
15
+ */
16
+ shareWithGroups(groupIds: string[]): Promise<void>;
12
17
  /**
13
18
  * Unshare the item with the specified group
14
19
  * @param groupId
15
20
  */
16
21
  unshareWithGroup(groupId: string): Promise<void>;
22
+ /**
23
+ * Unshare the item with the specified group
24
+ * @param groupId
25
+ */
26
+ unshareWithGroups(groupIds: string[]): Promise<void>;
17
27
  /**
18
28
  * Set the access level for the item
19
29
  * @param access
@@ -0,0 +1,10 @@
1
+ import { IGroup } from "@esri/arcgis-rest-portal";
2
+ import { IArcGISContext } from "../ArcGISContext";
3
+ import { IHubItemEntity } from "./types/IHubItemEntity";
4
+ /**
5
+ * Fetches an array of groups the entity is shared with
6
+ * @param entity An IHubItemEntity
7
+ * @param context An IArcGISContext
8
+ * @returns a promise that resolves an array of groups the entity is shared with
9
+ */
10
+ export declare function getEntityGroups(entity: IHubItemEntity, context: IArcGISContext): Promise<IGroup[]>;
@@ -9,3 +9,7 @@ export * from "./getTypesFromEntityType";
9
9
  export * from "./getRelativeWorkspaceUrl";
10
10
  export * from "./isValidEntityType";
11
11
  export * from "./processActionLinks";
12
+ export * from "./setEntityAccess";
13
+ export * from "./shareEntityWithGroups";
14
+ export * from "./unshareEntityWithGroups";
15
+ export * from "./getEntityGroups";
@@ -0,0 +1,11 @@
1
+ import { IArcGISContext } from "../ArcGISContext";
2
+ import { SettableAccessLevel } from "./types/types";
3
+ import { HubEntity } from "./types/HubEntity";
4
+ /**
5
+ * Sets an entity's access to the given access
6
+ * @param entity A HubEntity object
7
+ * @param access The access to set the entity to
8
+ * @param context An IArcGISContext object
9
+ * @returns a promise
10
+ */
11
+ export declare function setEntityAccess(entity: HubEntity, access: SettableAccessLevel, context: IArcGISContext): Promise<void>;
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../ArcGISContext";
2
+ import { IHubItemEntity } from "./types/IHubItemEntity";
3
+ /**
4
+ * Shares an entity to one or more groups
5
+ * @param entity An IHubItemEntity object
6
+ * @param groupIds An array of group IDs to share the entity to
7
+ * @param context An IArcGISContext object
8
+ * @returns a promise that resolves the updated entity
9
+ */
10
+ export declare function shareEntityWithGroups(entity: IHubItemEntity, groupIds: string[], context: IArcGISContext): Promise<IHubItemEntity>;
@@ -42,6 +42,10 @@ export interface IHubEvent extends IHubItemEntity, IWithPermissions, IWithSlug {
42
42
  * True when the user can change the status of the event to `removed`
43
43
  */
44
44
  canChangeStatusRemoved: boolean;
45
+ /**
46
+ * An Array of edit group IDs the event is shared with
47
+ */
48
+ editGroupIds: string[];
45
49
  /**
46
50
  * The end date of the event
47
51
  */
@@ -94,6 +98,10 @@ export interface IHubEvent extends IHubItemEntity, IWithPermissions, IWithSlug {
94
98
  * The URL for an online event
95
99
  */
96
100
  onlineUrl?: string | null;
101
+ /**
102
+ * An Array of view group IDs the event is shared with
103
+ */
104
+ readGroupIds: string[];
97
105
  /**
98
106
  * A collection of objects containing the ids & types for entities that the event references
99
107
  */
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../ArcGISContext";
2
+ import { IHubItemEntity } from "./types/IHubItemEntity";
3
+ /**
4
+ * Unshares an entity from one or more groups
5
+ * @param entity An IHubItemEntity object
6
+ * @param groupIds An array of group IDs to unshare the entity from
7
+ * @param context An IArcGISContext object
8
+ * @returns a promise that resolves the updated entity
9
+ */
10
+ export declare function unshareEntityWithGroups(entity: IHubItemEntity, groupIds: string[], context: IArcGISContext): Promise<IHubItemEntity>;
@@ -1,7 +1,7 @@
1
1
  import { IGroup } from "@esri/arcgis-rest-types";
2
2
  import { HubItemEntity } from "../core/HubItemEntity";
3
3
  import { IHubEventEditor, IHubEvent } from "../core/types/IHubEvent";
4
- import { IWithEditorBehavior, IWithSharingBehavior } from "../core/behaviors";
4
+ import { IWithEditorBehavior } from "../core/behaviors";
5
5
  import { SettableAccessLevel } from "../core/types/types";
6
6
  import { IArcGISContext } from "../ArcGISContext";
7
7
  import { IEntityEditorContext } from "../core/types";
@@ -11,7 +11,7 @@ import { EventEditorType } from "./_internal/EventSchemaCreate";
11
11
  * Defines the properties of a Hub Event object
12
12
  * @internal
13
13
  */
14
- export declare class HubEvent extends HubItemEntity<IHubEvent> implements IWithSharingBehavior, IWithEditorBehavior {
14
+ export declare class HubEvent extends HubItemEntity<IHubEvent> implements IWithEditorBehavior {
15
15
  /**
16
16
  * Create an instance from a HubEvent object
17
17
  * @param json - JSON object to create a HubEvent from
@@ -45,11 +45,21 @@ export declare class HubEvent extends HubItemEntity<IHubEvent> implements IWithS
45
45
  * @param groupId The ID of the group to share the Event to
46
46
  */
47
47
  shareWithGroup(groupId: string): Promise<void>;
48
+ /**
49
+ * Share the Entity with the specified group ids
50
+ * @param groupIds The IDs of the groups to share the Event to
51
+ */
52
+ shareWithGroups(groupIds: string[]): Promise<void>;
48
53
  /**
49
54
  * Unshare the Event with the specified group id
50
55
  * @param groupId The ID of the group to unshar ethe Event with
51
56
  */
52
57
  unshareWithGroup(groupId: string): Promise<void>;
58
+ /**
59
+ * Unshare the Event with the specified group ids
60
+ * @param groupIds The IDs of the groups to unshare the Event with
61
+ */
62
+ unshareWithGroups(groupIds: string[]): Promise<void>;
53
63
  /**
54
64
  * Sets the access level of the event
55
65
  * @param access The access level to set the Event to
@@ -0,0 +1,9 @@
1
+ import { IGroup } from "@esri/arcgis-rest-portal";
2
+ import { IArcGISContext } from "../../ArcGISContext";
3
+ /**
4
+ * Fetches the groups an event is shared with
5
+ * @param eventId The ID of the event to fetch the groups for
6
+ * @param context An IArcGISContext object
7
+ * @returns
8
+ */
9
+ export declare function getEventGroups(eventId: string, context: IArcGISContext): Promise<IGroup[]>;
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IHubEvent } from "../../core/types/IHubEvent";
3
+ /**
4
+ * Shares an event with one or more groups
5
+ * @param groupIds An array of group IDs to share the event with
6
+ * @param entity An IHubEvent object
7
+ * @param context An IArcGISContext object
8
+ * @returns a promise that resolves IHubItemEntity
9
+ */
10
+ export declare function shareEventWithGroups(groupIds: string[], entity: IHubEvent, context: IArcGISContext): Promise<IHubEvent>;
@@ -0,0 +1,10 @@
1
+ import { IArcGISContext } from "../../ArcGISContext";
2
+ import { IHubEvent } from "../../core/types/IHubEvent";
3
+ /**
4
+ * Unshares an event with one or more groups
5
+ * @param groupIds An array of group IDs to unshare the group from
6
+ * @param entity An IHubEvent object
7
+ * @param context An IArcGISContext object
8
+ * @returns An updated IHubEvent object
9
+ */
10
+ export declare function unshareEventWithGroups(groupIds: string[], entity: IHubEvent, context: IArcGISContext): Promise<IHubEvent>;
@@ -1,9 +1,10 @@
1
1
  import { IRequestOptions } from "@esri/arcgis-rest-request";
2
+ import { ISharingResponse } from "@esri/arcgis-rest-portal";
2
3
  /**
3
4
  * Share an item to a set of groups
4
- * @param {String} itemId Iten Id to share to the groups
5
- * @param {Array} groups Array of group id's to which the item will be shared
5
+ * @param {String} itemId Item Id to share to the groups
6
+ * @param {Array} groupIds Array of group id's to which the item will be shared
7
+ * @param {IRequestOptions} requestOptions
6
8
  * @param {String} owner optional Owner username to determine which endpoint to hit
7
- * @param {*} requestOptions
8
9
  */
9
- export declare function shareItemToGroups(itemId: string, groups: string[], requestOptions: IRequestOptions, owner?: string): Promise<import("@esri/arcgis-rest-portal").ISharingResponse[]>;
10
+ export declare function shareItemToGroups(itemId: string, groupIds: string[], requestOptions: IRequestOptions, owner?: string): Promise<ISharingResponse[]>;
@@ -4,7 +4,7 @@ import { IRequestOptions } from "@esri/arcgis-rest-request";
4
4
  * Unshare an item from a set of groups
5
5
  * @param {String} itemId Item Id to unshare from groups
6
6
  * @param {Array} groups Array of group id's from which the item will be unshared
7
- * @param {String} owner optional Owner username to determine which endpoint to hit
8
7
  * @param {IRequestOptions} requestOptions
8
+ * @param {String} owner optional Owner username to determine which endpoint to hit
9
9
  */
10
10
  export declare function unshareItemFromGroups(itemId: string, groups: string[], requestOptions: IRequestOptions, owner?: string): Promise<ISharingResponse[]>;
@@ -11,7 +11,7 @@
11
11
  * @param validationFn
12
12
  * @param opts
13
13
  */
14
- export declare const poll: (requestFn: () => any, validationFn: (resp: any) => boolean, opts?: {
15
- timeout?: number;
16
- timeBetweenRequests?: number;
17
- }) => Promise<any>;
14
+ export declare function poll<T>(requestFn: () => Promise<T>, validationFn: (resp: T) => boolean, options?: {
15
+ maxAttempts?: number;
16
+ initialRetryDelay?: number;
17
+ }): Promise<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esri/hub-common",
3
- "version": "14.115.0",
3
+ "version": "14.116.0",
4
4
  "description": "Common TypeScript types and utility functions for @esri/hub.js.",
5
5
  "main": "dist/node/index.js",
6
6
  "module": "dist/esm/index.js",