@esri/hub-common 14.74.2 → 14.75.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 (209) hide show
  1. package/dist/esm/associations/addAssociation.js +3 -0
  2. package/dist/esm/associations/addAssociation.js.map +1 -1
  3. package/dist/esm/associations/breakAssociation.js +54 -0
  4. package/dist/esm/associations/breakAssociation.js.map +1 -0
  5. package/dist/esm/associations/getAssociatedEntitiesQuery.js +33 -0
  6. package/dist/esm/associations/getAssociatedEntitiesQuery.js.map +1 -0
  7. package/dist/esm/associations/getAssociationStats.js +49 -0
  8. package/dist/esm/associations/getAssociationStats.js.map +1 -0
  9. package/dist/esm/associations/getAvailableToRequestEntitiesQuery.js +65 -0
  10. package/dist/esm/associations/getAvailableToRequestEntitiesQuery.js.map +1 -0
  11. package/dist/esm/associations/getPendingEntitiesQuery.js +41 -0
  12. package/dist/esm/associations/getPendingEntitiesQuery.js.map +1 -0
  13. package/dist/esm/associations/getRequestingEntitiesQuery.js +41 -0
  14. package/dist/esm/associations/getRequestingEntitiesQuery.js.map +1 -0
  15. package/dist/esm/associations/getWellKnownAssociationsCatalog.js +72 -0
  16. package/dist/esm/associations/getWellKnownAssociationsCatalog.js.map +1 -0
  17. package/dist/esm/associations/index.js +12 -0
  18. package/dist/esm/associations/index.js.map +1 -1
  19. package/dist/esm/associations/internal/getAssociationHierarchy.js +33 -0
  20. package/dist/esm/associations/internal/getAssociationHierarchy.js.map +1 -0
  21. package/dist/esm/associations/internal/getIdsFromAssociationGroups.js +25 -0
  22. package/dist/esm/associations/internal/getIdsFromAssociationGroups.js.map +1 -0
  23. package/dist/esm/associations/internal/getIdsFromKeywords.js +22 -0
  24. package/dist/esm/associations/internal/getIdsFromKeywords.js.map +1 -0
  25. package/dist/esm/associations/internal/getIncludesAndReferencesQuery.js +58 -0
  26. package/dist/esm/associations/internal/getIncludesAndReferencesQuery.js.map +1 -0
  27. package/dist/esm/associations/internal/getIncludesDoesNotReferenceQuery.js +58 -0
  28. package/dist/esm/associations/internal/getIncludesDoesNotReferenceQuery.js.map +1 -0
  29. package/dist/esm/associations/internal/getReferencesDoesNotIncludeQuery.js +62 -0
  30. package/dist/esm/associations/internal/getReferencesDoesNotIncludeQuery.js.map +1 -0
  31. package/dist/esm/associations/internal/getTypeByIdsQuery.js +13 -15
  32. package/dist/esm/associations/internal/getTypeByIdsQuery.js.map +1 -1
  33. package/dist/esm/associations/internal/getTypeByNotIdsQuery.js +26 -0
  34. package/dist/esm/associations/internal/getTypeByNotIdsQuery.js.map +1 -0
  35. package/dist/esm/associations/internal/getTypeWithKeywordQuery.js +11 -6
  36. package/dist/esm/associations/internal/getTypeWithKeywordQuery.js.map +1 -1
  37. package/dist/esm/associations/internal/getTypeWithoutKeywordQuery.js +10 -5
  38. package/dist/esm/associations/internal/getTypeWithoutKeywordQuery.js.map +1 -1
  39. package/dist/esm/associations/internal/isAssociationSupported.js +29 -0
  40. package/dist/esm/associations/internal/isAssociationSupported.js.map +1 -0
  41. package/dist/esm/associations/internal/removeAssociationKeyword.js +16 -0
  42. package/dist/esm/associations/internal/removeAssociationKeyword.js.map +1 -0
  43. package/dist/esm/associations/internal/setAssociationKeyword.js +18 -0
  44. package/dist/esm/associations/internal/setAssociationKeyword.js.map +1 -0
  45. package/dist/esm/associations/listAssociations.js +4 -0
  46. package/dist/esm/associations/listAssociations.js.map +1 -1
  47. package/dist/esm/associations/removeAssociation.js +3 -0
  48. package/dist/esm/associations/removeAssociation.js.map +1 -1
  49. package/dist/esm/associations/requestAssociation.js +57 -0
  50. package/dist/esm/associations/requestAssociation.js.map +1 -0
  51. package/dist/esm/associations/types.js +0 -1
  52. package/dist/esm/associations/types.js.map +1 -1
  53. package/dist/esm/core/HubItemEntity.js +9 -0
  54. package/dist/esm/core/HubItemEntity.js.map +1 -1
  55. package/dist/esm/core/_internal/getBasePropertyMap.js +1 -1
  56. package/dist/esm/core/_internal/getBasePropertyMap.js.map +1 -1
  57. package/dist/esm/core/getTypesFromEntityType.js +39 -0
  58. package/dist/esm/core/getTypesFromEntityType.js.map +1 -0
  59. package/dist/esm/core/index.js +1 -0
  60. package/dist/esm/core/index.js.map +1 -1
  61. package/dist/esm/core/processActionLinks.js +1 -1
  62. package/dist/esm/core/processActionLinks.js.map +1 -1
  63. package/dist/esm/core/updateHubEntity.js +4 -0
  64. package/dist/esm/core/updateHubEntity.js.map +1 -1
  65. package/dist/esm/initiatives/HubInitiatives.js +15 -42
  66. package/dist/esm/initiatives/HubInitiatives.js.map +1 -1
  67. package/dist/esm/initiatives/_internal/InitiativeAssociationHierarchies.js +5 -0
  68. package/dist/esm/initiatives/_internal/InitiativeAssociationHierarchies.js.map +1 -0
  69. package/dist/esm/initiatives/_internal/InitiativeBusinessRules.js +29 -0
  70. package/dist/esm/initiatives/_internal/InitiativeBusinessRules.js.map +1 -1
  71. package/dist/esm/projects/_internal/ProjectAssociationHierarchies.js +5 -0
  72. package/dist/esm/projects/_internal/ProjectAssociationHierarchies.js.map +1 -0
  73. package/dist/esm/projects/_internal/ProjectBusinessRules.js +6 -0
  74. package/dist/esm/projects/_internal/ProjectBusinessRules.js.map +1 -1
  75. package/dist/esm/projects/fetch.js +3 -0
  76. package/dist/esm/projects/fetch.js.map +1 -1
  77. package/dist/esm/search/_internal/buildCatalog.js +25 -0
  78. package/dist/esm/search/_internal/buildCatalog.js.map +1 -0
  79. package/dist/esm/search/wellKnownCatalog.js +29 -43
  80. package/dist/esm/search/wellKnownCatalog.js.map +1 -1
  81. package/dist/node/associations/addAssociation.js +3 -0
  82. package/dist/node/associations/addAssociation.js.map +1 -1
  83. package/dist/node/associations/breakAssociation.js +57 -0
  84. package/dist/node/associations/breakAssociation.js.map +1 -0
  85. package/dist/node/associations/getAssociatedEntitiesQuery.js +36 -0
  86. package/dist/node/associations/getAssociatedEntitiesQuery.js.map +1 -0
  87. package/dist/node/associations/getAssociationStats.js +52 -0
  88. package/dist/node/associations/getAssociationStats.js.map +1 -0
  89. package/dist/node/associations/getAvailableToRequestEntitiesQuery.js +68 -0
  90. package/dist/node/associations/getAvailableToRequestEntitiesQuery.js.map +1 -0
  91. package/dist/node/associations/getPendingEntitiesQuery.js +44 -0
  92. package/dist/node/associations/getPendingEntitiesQuery.js.map +1 -0
  93. package/dist/node/associations/getRequestingEntitiesQuery.js +44 -0
  94. package/dist/node/associations/getRequestingEntitiesQuery.js.map +1 -0
  95. package/dist/node/associations/getWellKnownAssociationsCatalog.js +76 -0
  96. package/dist/node/associations/getWellKnownAssociationsCatalog.js.map +1 -0
  97. package/dist/node/associations/index.js +14 -0
  98. package/dist/node/associations/index.js.map +1 -1
  99. package/dist/node/associations/internal/getAssociationHierarchy.js +36 -0
  100. package/dist/node/associations/internal/getAssociationHierarchy.js.map +1 -0
  101. package/dist/node/associations/internal/getIdsFromAssociationGroups.js +28 -0
  102. package/dist/node/associations/internal/getIdsFromAssociationGroups.js.map +1 -0
  103. package/dist/node/associations/internal/getIdsFromKeywords.js +25 -0
  104. package/dist/node/associations/internal/getIdsFromKeywords.js.map +1 -0
  105. package/dist/node/associations/internal/getIncludesAndReferencesQuery.js +61 -0
  106. package/dist/node/associations/internal/getIncludesAndReferencesQuery.js.map +1 -0
  107. package/dist/node/associations/internal/getIncludesDoesNotReferenceQuery.js +61 -0
  108. package/dist/node/associations/internal/getIncludesDoesNotReferenceQuery.js.map +1 -0
  109. package/dist/node/associations/internal/getReferencesDoesNotIncludeQuery.js +65 -0
  110. package/dist/node/associations/internal/getReferencesDoesNotIncludeQuery.js.map +1 -0
  111. package/dist/node/associations/internal/getTypeByIdsQuery.js +13 -15
  112. package/dist/node/associations/internal/getTypeByIdsQuery.js.map +1 -1
  113. package/dist/node/associations/internal/getTypeByNotIdsQuery.js +30 -0
  114. package/dist/node/associations/internal/getTypeByNotIdsQuery.js.map +1 -0
  115. package/dist/node/associations/internal/getTypeWithKeywordQuery.js +11 -6
  116. package/dist/node/associations/internal/getTypeWithKeywordQuery.js.map +1 -1
  117. package/dist/node/associations/internal/getTypeWithoutKeywordQuery.js +10 -5
  118. package/dist/node/associations/internal/getTypeWithoutKeywordQuery.js.map +1 -1
  119. package/dist/node/associations/internal/isAssociationSupported.js +32 -0
  120. package/dist/node/associations/internal/isAssociationSupported.js.map +1 -0
  121. package/dist/node/associations/internal/removeAssociationKeyword.js +20 -0
  122. package/dist/node/associations/internal/removeAssociationKeyword.js.map +1 -0
  123. package/dist/node/associations/internal/setAssociationKeyword.js +22 -0
  124. package/dist/node/associations/internal/setAssociationKeyword.js.map +1 -0
  125. package/dist/node/associations/listAssociations.js +4 -0
  126. package/dist/node/associations/listAssociations.js.map +1 -1
  127. package/dist/node/associations/removeAssociation.js +3 -0
  128. package/dist/node/associations/removeAssociation.js.map +1 -1
  129. package/dist/node/associations/requestAssociation.js +60 -0
  130. package/dist/node/associations/requestAssociation.js.map +1 -0
  131. package/dist/node/associations/types.js +0 -1
  132. package/dist/node/associations/types.js.map +1 -1
  133. package/dist/node/core/HubItemEntity.js +9 -0
  134. package/dist/node/core/HubItemEntity.js.map +1 -1
  135. package/dist/node/core/_internal/getBasePropertyMap.js +1 -1
  136. package/dist/node/core/_internal/getBasePropertyMap.js.map +1 -1
  137. package/dist/node/core/getTypesFromEntityType.js +42 -0
  138. package/dist/node/core/getTypesFromEntityType.js.map +1 -0
  139. package/dist/node/core/index.js +1 -0
  140. package/dist/node/core/index.js.map +1 -1
  141. package/dist/node/core/processActionLinks.js +2 -2
  142. package/dist/node/core/processActionLinks.js.map +1 -1
  143. package/dist/node/core/updateHubEntity.js +4 -0
  144. package/dist/node/core/updateHubEntity.js.map +1 -1
  145. package/dist/node/initiatives/HubInitiatives.js +15 -42
  146. package/dist/node/initiatives/HubInitiatives.js.map +1 -1
  147. package/dist/node/initiatives/_internal/InitiativeAssociationHierarchies.js +8 -0
  148. package/dist/node/initiatives/_internal/InitiativeAssociationHierarchies.js.map +1 -0
  149. package/dist/node/initiatives/_internal/InitiativeBusinessRules.js +29 -0
  150. package/dist/node/initiatives/_internal/InitiativeBusinessRules.js.map +1 -1
  151. package/dist/node/projects/_internal/ProjectAssociationHierarchies.js +8 -0
  152. package/dist/node/projects/_internal/ProjectAssociationHierarchies.js.map +1 -0
  153. package/dist/node/projects/_internal/ProjectBusinessRules.js +6 -0
  154. package/dist/node/projects/_internal/ProjectBusinessRules.js.map +1 -1
  155. package/dist/node/projects/fetch.js +3 -0
  156. package/dist/node/projects/fetch.js.map +1 -1
  157. package/dist/node/search/_internal/buildCatalog.js +29 -0
  158. package/dist/node/search/_internal/buildCatalog.js.map +1 -0
  159. package/dist/node/search/wellKnownCatalog.js +29 -43
  160. package/dist/node/search/wellKnownCatalog.js.map +1 -1
  161. package/dist/types/associations/addAssociation.d.ts +3 -0
  162. package/dist/types/associations/breakAssociation.d.ts +20 -0
  163. package/dist/types/associations/getAssociatedEntitiesQuery.d.ts +21 -0
  164. package/dist/types/associations/getAssociationStats.d.ts +13 -0
  165. package/dist/types/associations/getAvailableToRequestEntitiesQuery.d.ts +21 -0
  166. package/dist/types/associations/getPendingEntitiesQuery.d.ts +26 -0
  167. package/dist/types/associations/getRequestingEntitiesQuery.d.ts +26 -0
  168. package/dist/types/associations/getWellKnownAssociationsCatalog.d.ts +34 -0
  169. package/dist/types/associations/index.d.ts +9 -0
  170. package/dist/types/associations/internal/getAssociationHierarchy.d.ts +15 -0
  171. package/dist/types/associations/internal/getIdsFromAssociationGroups.d.ts +15 -0
  172. package/dist/types/associations/internal/getIdsFromKeywords.d.ts +13 -0
  173. package/dist/types/associations/internal/getIncludesAndReferencesQuery.d.ts +14 -0
  174. package/dist/types/associations/internal/getIncludesDoesNotReferenceQuery.d.ts +14 -0
  175. package/dist/types/associations/internal/getReferencesDoesNotIncludeQuery.d.ts +14 -0
  176. package/dist/types/associations/internal/getTypeByIdsQuery.d.ts +8 -6
  177. package/dist/types/associations/internal/getTypeByNotIdsQuery.d.ts +12 -0
  178. package/dist/types/associations/internal/getTypeWithKeywordQuery.d.ts +8 -5
  179. package/dist/types/associations/internal/getTypeWithoutKeywordQuery.d.ts +8 -5
  180. package/dist/types/associations/internal/isAssociationSupported.d.ts +11 -0
  181. package/dist/types/associations/internal/removeAssociationKeyword.d.ts +12 -0
  182. package/dist/types/associations/internal/setAssociationKeyword.d.ts +12 -0
  183. package/dist/types/associations/listAssociations.d.ts +4 -0
  184. package/dist/types/associations/removeAssociation.d.ts +3 -0
  185. package/dist/types/associations/requestAssociation.d.ts +23 -0
  186. package/dist/types/associations/types.d.ts +53 -0
  187. package/dist/types/core/HubItemEntity.d.ts +9 -0
  188. package/dist/types/core/behaviors/IWIthAssociationBehavior.d.ts +9 -0
  189. package/dist/types/core/getTypesFromEntityType.d.ts +10 -0
  190. package/dist/types/core/index.d.ts +1 -0
  191. package/dist/types/core/traits/IWithAssociations.d.ts +13 -0
  192. package/dist/types/initiatives/HubInitiatives.d.ts +12 -0
  193. package/dist/types/initiatives/_internal/InitiativeAssociationHierarchies.d.ts +2 -0
  194. package/dist/types/initiatives/_internal/InitiativeBusinessRules.d.ts +1 -1
  195. package/dist/types/projects/_internal/ProjectAssociationHierarchies.d.ts +2 -0
  196. package/dist/types/projects/_internal/ProjectBusinessRules.d.ts +1 -1
  197. package/dist/types/projects/fetch.d.ts +3 -0
  198. package/dist/types/search/_internal/buildCatalog.d.ts +12 -0
  199. package/package.json +1 -1
  200. package/dist/esm/associations/internal/getTargetEntityFromAssociationType.js +0 -18
  201. package/dist/esm/associations/internal/getTargetEntityFromAssociationType.js.map +0 -1
  202. package/dist/esm/associations/internal/getTypeFromAssociationType.js +0 -18
  203. package/dist/esm/associations/internal/getTypeFromAssociationType.js.map +0 -1
  204. package/dist/node/associations/internal/getTargetEntityFromAssociationType.js +0 -22
  205. package/dist/node/associations/internal/getTargetEntityFromAssociationType.js.map +0 -1
  206. package/dist/node/associations/internal/getTypeFromAssociationType.js +0 -22
  207. package/dist/node/associations/internal/getTypeFromAssociationType.js.map +0 -1
  208. package/dist/types/associations/internal/getTargetEntityFromAssociationType.d.ts +0 -8
  209. package/dist/types/associations/internal/getTypeFromAssociationType.d.ts +0 -7
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAssociationStats = void 0;
4
+ const getTypeFromEntity_1 = require("../core/getTypeFromEntity");
5
+ const hubSearch_1 = require("../search/hubSearch");
6
+ const getAssociatedEntitiesQuery_1 = require("./getAssociatedEntitiesQuery");
7
+ const getPendingEntitiesQuery_1 = require("./getPendingEntitiesQuery");
8
+ const getRequestingEntitiesQuery_1 = require("./getRequestingEntitiesQuery");
9
+ const getAssociationHierarchy_1 = require("./internal/getAssociationHierarchy");
10
+ const isAssociationSupported_1 = require("./internal/isAssociationSupported");
11
+ /**
12
+ * get an entity's association stats - # of associated, pending,
13
+ * requesting, included/referenced entities
14
+ *
15
+ * @param entity - Hub entity
16
+ * @param associationType - entity type to query for
17
+ * @param context - contextual auth and portal information
18
+ * @returns
19
+ */
20
+ exports.getAssociationStats = async (entity, associationType, context) => {
21
+ let stats;
22
+ const entityType = getTypeFromEntity_1.getTypeFromEntity(entity);
23
+ const isSupported = isAssociationSupported_1.isAssociationSupported(entityType, associationType);
24
+ if (!isSupported) {
25
+ throw new Error(`getAssociationStats: Association between ${entityType} and ${associationType} is not supported.`);
26
+ }
27
+ const associationHierarchy = getAssociationHierarchy_1.getAssociationHierarchy(entityType);
28
+ const isParent = associationHierarchy.children.includes(associationType);
29
+ stats = Object.assign({ associated: 0, pending: 0, requesting: 0 }, (isParent ? { included: 0 } : { referenced: 0 }));
30
+ try {
31
+ const queries = await Promise.all([
32
+ getAssociatedEntitiesQuery_1.getAssociatedEntitiesQuery(entity, associationType, context),
33
+ getPendingEntitiesQuery_1.getPendingEntitiesQuery(entity, associationType, context),
34
+ getRequestingEntitiesQuery_1.getRequestingEntitiesQuery(entity, associationType, context),
35
+ ]);
36
+ const [{ total: associated }, { total: pending }, { total: requesting }] = await Promise.all(queries.map((query) => {
37
+ return hubSearch_1.hubSearch(query, {
38
+ requestOptions: context.hubRequestOptions,
39
+ });
40
+ }));
41
+ stats = Object.assign({ associated,
42
+ pending,
43
+ requesting }, (isParent
44
+ ? { included: associated + pending }
45
+ : { referenced: associated + pending }));
46
+ }
47
+ catch (error) {
48
+ return stats;
49
+ }
50
+ return stats;
51
+ };
52
+ //# sourceMappingURL=getAssociationStats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAssociationStats.js","sourceRoot":"","sources":["../../../src/associations/getAssociationStats.ts"],"names":[],"mappings":";;;AACA,iEAA8D;AAG9D,mDAAgD;AAChD,6EAA0E;AAC1E,uEAAoE;AACpE,6EAA0E;AAC1E,gFAA6E;AAC7E,8EAA2E;AAG3E;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAAG,KAAK,EACtC,MAAiB,EACjB,eAA8B,EAC9B,OAAuB,EACK,EAAE;IAC9B,IAAI,KAAwB,CAAC;IAC7B,MAAM,UAAU,GAAG,qCAAiB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,+CAAsB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAExE,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CACb,4CAA4C,UAAU,QAAQ,eAAe,oBAAoB,CAClG,CAAC;KACH;IAED,MAAM,oBAAoB,GAAG,iDAAuB,CAAC,UAAU,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAEzE,KAAK,mBACH,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,CAAC,EACV,UAAU,EAAE,CAAC,IACV,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CACpD,CAAC;IAEF,IAAI;QACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAChC,uDAA0B,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC;YAC5D,iDAAuB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC;YACzD,uDAA0B,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC;SAC7D,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,GACtE,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,GAAG,CAAC,CAAC,KAAa,EAAE,EAAE;YAC5B,OAAO,qBAAS,CAAC,KAAK,EAAE;gBACtB,cAAc,EAAE,OAAO,CAAC,iBAAiB;aAC1C,CAAC,CAAC;QACL,CAAC,CAAC,CACH,CAAC;QAEJ,KAAK,mBACH,UAAU;YACV,OAAO;YACP,UAAU,IACP,CAAC,QAAQ;YACV,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,GAAG,OAAO,EAAE;YACpC,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,EAAE,CAAC,CAC1C,CAAC;KACH;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,KAAK,CAAC;KACd;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAvailableToRequestEntitiesQuery = void 0;
4
+ const getTypeFromEntity_1 = require("../core/getTypeFromEntity");
5
+ const getAssociationHierarchy_1 = require("./internal/getAssociationHierarchy");
6
+ const isAssociationSupported_1 = require("./internal/isAssociationSupported");
7
+ const get_prop_1 = require("../objects/get-prop");
8
+ const getTypesFromEntityType_1 = require("../core/getTypesFromEntityType");
9
+ const getIdsFromKeywords_1 = require("./internal/getIdsFromKeywords");
10
+ const getTypeByNotIdsQuery_1 = require("./internal/getTypeByNotIdsQuery");
11
+ const negateGroupPredicates_1 = require("../search/_internal/negateGroupPredicates");
12
+ const getTypeByIdsQuery_1 = require("./internal/getTypeByIdsQuery");
13
+ const combineQueries_1 = require("../search/_internal/combineQueries");
14
+ /**
15
+ * An entity can send an "outgoing" request to associate
16
+ * itself with another entity. The following query returns
17
+ * a set of entities that the requesting entity can still
18
+ * request:
19
+ *
20
+ * from a parent perspective: returns a set of children
21
+ * that are NOT "included" in the parent's association group
22
+ *
23
+ * from a child perspective: returns a set of parents that
24
+ * the child does not "reference" with via a typeKeyword of
25
+ * the form ref|<parentType>|<parentID>
26
+ *
27
+ * @param entity - entity requesting association
28
+ * @param associationType - type of entity the requesting entity wants to associate with
29
+ * @param context - contextual auth and portal information
30
+ * @returns {IQuery}
31
+ */
32
+ exports.getAvailableToRequestEntitiesQuery = (entity, associationType) => {
33
+ let query;
34
+ const entityType = getTypeFromEntity_1.getTypeFromEntity(entity);
35
+ const isSupported = isAssociationSupported_1.isAssociationSupported(entityType, associationType);
36
+ if (!isSupported) {
37
+ throw new Error(`getAvailableToRequestEntitiesQuery: Association between ${entityType} and ${associationType} is not supported.`);
38
+ }
39
+ const associationHierarchy = getAssociationHierarchy_1.getAssociationHierarchy(entityType);
40
+ const isParent = associationHierarchy.children.includes(associationType);
41
+ if (isParent) {
42
+ /** 1. build query that returns child entities */
43
+ const childType = getTypesFromEntityType_1.getTypesFromEntityType(associationType);
44
+ const childTypeQuery = getTypeByIdsQuery_1.getTypeByIdsQuery(childType, []);
45
+ /**
46
+ * 2. grab the parent's association query and negate
47
+ * the group predicate
48
+ */
49
+ const notIncludedQuery = negateGroupPredicates_1.negateGroupPredicates(get_prop_1.getProp(entity, "associations.rules.query"));
50
+ /** 3. combine queries - will remove null/undefined entries */
51
+ query = combineQueries_1.combineQueries([notIncludedQuery, childTypeQuery]);
52
+ }
53
+ else {
54
+ /**
55
+ * 1. iterate over the child's typeKeywords and grab the parent
56
+ * ids it references (typeKeyword = <associationType>|<id>)
57
+ */
58
+ const ids = getIdsFromKeywords_1.getIdsFromKeywords(entity, associationType);
59
+ /**
60
+ * 2. build query that returns parent entities NOT
61
+ * "referenced" by the child
62
+ */
63
+ const type = getTypesFromEntityType_1.getTypesFromEntityType(associationType);
64
+ query = getTypeByNotIdsQuery_1.getTypeByNotIdsQuery(type, ids);
65
+ }
66
+ return query;
67
+ };
68
+ //# sourceMappingURL=getAvailableToRequestEntitiesQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAvailableToRequestEntitiesQuery.js","sourceRoot":"","sources":["../../../src/associations/getAvailableToRequestEntitiesQuery.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAG9D,gFAA6E;AAC7E,8EAA2E;AAC3E,kDAA8C;AAC9C,2EAAwE;AACxE,sEAAmE;AACnE,0EAAuE;AACvE,qFAAkF;AAClF,oEAAiE;AACjE,uEAAoE;AAEpE;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,kCAAkC,GAAG,CAChD,MAAiB,EACjB,eAA8B,EACtB,EAAE;IACV,IAAI,KAAa,CAAC;IAClB,MAAM,UAAU,GAAG,qCAAiB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,+CAAsB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAExE,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CACb,2DAA2D,UAAU,QAAQ,eAAe,oBAAoB,CACjH,CAAC;KACH;IAED,MAAM,oBAAoB,GAAG,iDAAuB,CAAC,UAAU,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAEzE,IAAI,QAAQ,EAAE;QACZ,iDAAiD;QACjD,MAAM,SAAS,GAAG,+CAAsB,CAAC,eAAe,CAAC,CAAC;QAC1D,MAAM,cAAc,GAAG,qCAAiB,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAExD;;;WAGG;QACH,MAAM,gBAAgB,GAAG,6CAAqB,CAC5C,kBAAO,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAC5C,CAAC;QAEF,8DAA8D;QAC9D,KAAK,GAAG,+BAAc,CAAC,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC,CAAC;KAC5D;SAAM;QACL;;;WAGG;QACH,MAAM,GAAG,GAAG,uCAAkB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAExD;;;WAGG;QACH,MAAM,IAAI,GAAG,+CAAsB,CAAC,eAAe,CAAC,CAAC;QACrD,KAAK,GAAG,2CAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;KACzC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPendingEntitiesQuery = void 0;
4
+ const getTypeFromEntity_1 = require("../core/getTypeFromEntity");
5
+ const getAssociationHierarchy_1 = require("./internal/getAssociationHierarchy");
6
+ const getReferencesDoesNotIncludeQuery_1 = require("./internal/getReferencesDoesNotIncludeQuery");
7
+ const getIncludesDoesNotReferenceQuery_1 = require("./internal/getIncludesDoesNotReferenceQuery");
8
+ const isAssociationSupported_1 = require("./internal/isAssociationSupported");
9
+ /**
10
+ * Pending entities represent "outgoing" requests that are
11
+ * awaiting "approval". They imply a one-way "connection"
12
+ * between parent/child.
13
+ *
14
+ * From the parent's perspective:
15
+ * parent: "includes" the child in its association query
16
+ * child: does NOT "reference" the parent via a typeKeyword
17
+ *
18
+ * From the child's perspective:
19
+ * parent: does NOT "include" the child in its association query
20
+ * child: "references" the parent via a typeKeyword of the
21
+ * form ref|<parentType>|<parentID>
22
+ *
23
+ * The following returns a query to view an entity's outgoing
24
+ * requests for association with another entity type
25
+ *
26
+ * @param entity - Hub entity
27
+ * @param associationType - entity type to query for
28
+ * @param context - contextual auth and portal information
29
+ * @returns {IQuery}
30
+ */
31
+ exports.getPendingEntitiesQuery = async (entity, associationType, context) => {
32
+ const entityType = getTypeFromEntity_1.getTypeFromEntity(entity);
33
+ const isSupported = isAssociationSupported_1.isAssociationSupported(entityType, associationType);
34
+ if (!isSupported) {
35
+ throw new Error(`getPendingEntitiesQuery: Association between ${entityType} and ${associationType} is not supported.`);
36
+ }
37
+ const associationHierarchy = getAssociationHierarchy_1.getAssociationHierarchy(entityType);
38
+ const isParent = associationHierarchy.children.includes(associationType);
39
+ const query = isParent
40
+ ? await getIncludesDoesNotReferenceQuery_1.getIncludesDoesNotReferenceQuery(entity, associationType, isParent, context)
41
+ : await getReferencesDoesNotIncludeQuery_1.getReferencesDoesNotIncludeQuery(entity, associationType, isParent, context);
42
+ return query;
43
+ };
44
+ //# sourceMappingURL=getPendingEntitiesQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPendingEntitiesQuery.js","sourceRoot":"","sources":["../../../src/associations/getPendingEntitiesQuery.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAG9D,gFAA6E;AAC7E,kGAA+F;AAC/F,kGAA+F;AAC/F,8EAA2E;AAG3E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACU,QAAA,uBAAuB,GAAG,KAAK,EAC1C,MAAiB,EACjB,eAA8B,EAC9B,OAAuB,EACN,EAAE;IACnB,MAAM,UAAU,GAAG,qCAAiB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,+CAAsB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAExE,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CACb,gDAAgD,UAAU,QAAQ,eAAe,oBAAoB,CACtG,CAAC;KACH;IAED,MAAM,oBAAoB,GAAG,iDAAuB,CAAC,UAAU,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAEzE,MAAM,KAAK,GAAG,QAAQ;QACpB,CAAC,CAAC,MAAM,mEAAgC,CACpC,MAAM,EACN,eAAe,EACf,QAAQ,EACR,OAAO,CACR;QACH,CAAC,CAAC,MAAM,mEAAgC,CACpC,MAAM,EACN,eAAe,EACf,QAAQ,EACR,OAAO,CACR,CAAC;IAEN,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRequestingEntitiesQuery = void 0;
4
+ const getTypeFromEntity_1 = require("../core/getTypeFromEntity");
5
+ const getAssociationHierarchy_1 = require("./internal/getAssociationHierarchy");
6
+ const getReferencesDoesNotIncludeQuery_1 = require("./internal/getReferencesDoesNotIncludeQuery");
7
+ const getIncludesDoesNotReferenceQuery_1 = require("./internal/getIncludesDoesNotReferenceQuery");
8
+ const isAssociationSupported_1 = require("./internal/isAssociationSupported");
9
+ /**
10
+ * Requesting entities represent "incoming" requests that are
11
+ * awaiting "approval". They imply a one-way "connection"
12
+ * between parent/child.
13
+ *
14
+ * From the parent's perspective:
15
+ * parent: does NOT "include" the child in its association query
16
+ * child: "references" the parent via a typeKeyword of the
17
+ * form ref|<parentType>|<parentID>
18
+ *
19
+ * From the child's perspective:
20
+ * parent: "includes" the child in its association query
21
+ * child: does NOT "reference" the parent via a typeKeyword
22
+ *
23
+ * The following returns a query to view an entity's incoming
24
+ * requests for association with another entity type
25
+ *
26
+ * @param entity - Hub entity
27
+ * @param associationType - entity type to query for
28
+ * @param context - contextual auth and portal information
29
+ * @returns {IQuery}
30
+ */
31
+ exports.getRequestingEntitiesQuery = async (entity, associationType, context) => {
32
+ const entityType = getTypeFromEntity_1.getTypeFromEntity(entity);
33
+ const isSupported = isAssociationSupported_1.isAssociationSupported(entityType, associationType);
34
+ if (!isSupported) {
35
+ throw new Error(`getRequestingEntitiesQuery: Association between ${entityType} and ${associationType} is not supported.`);
36
+ }
37
+ const associationHierarchy = getAssociationHierarchy_1.getAssociationHierarchy(entityType);
38
+ const isParent = associationHierarchy.children.includes(associationType);
39
+ const query = isParent
40
+ ? await getReferencesDoesNotIncludeQuery_1.getReferencesDoesNotIncludeQuery(entity, associationType, isParent, context)
41
+ : await getIncludesDoesNotReferenceQuery_1.getIncludesDoesNotReferenceQuery(entity, associationType, isParent, context);
42
+ return query;
43
+ };
44
+ //# sourceMappingURL=getRequestingEntitiesQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getRequestingEntitiesQuery.js","sourceRoot":"","sources":["../../../src/associations/getRequestingEntitiesQuery.ts"],"names":[],"mappings":";;;AAAA,iEAA8D;AAG9D,gFAA6E;AAC7E,kGAA+F;AAC/F,kGAA+F;AAC/F,8EAA2E;AAG3E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACU,QAAA,0BAA0B,GAAG,KAAK,EAC7C,MAAiB,EACjB,eAA8B,EAC9B,OAAuB,EACN,EAAE;IACnB,MAAM,UAAU,GAAG,qCAAiB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,+CAAsB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;IAExE,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CACb,mDAAmD,UAAU,QAAQ,eAAe,oBAAoB,CACzG,CAAC;KACH;IAED,MAAM,oBAAoB,GAAG,iDAAuB,CAAC,UAAU,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAEzE,MAAM,KAAK,GAAG,QAAQ;QACpB,CAAC,CAAC,MAAM,mEAAgC,CACpC,MAAM,EACN,eAAe,EACf,QAAQ,EACR,OAAO,CACR;QACH,CAAC,CAAC,MAAM,mEAAgC,CACpC,MAAM,EACN,eAAe,EACf,QAAQ,EACR,OAAO,CACR,CAAC;IAEN,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWellKnownAssociationsCatalog = void 0;
4
+ const core_1 = require("../core");
5
+ const buildCatalog_1 = require("../search/_internal/buildCatalog");
6
+ const getEntityTypeFromType_1 = require("../search/_internal/getEntityTypeFromType");
7
+ const getAssociatedEntitiesQuery_1 = require("./getAssociatedEntitiesQuery");
8
+ const getPendingEntitiesQuery_1 = require("./getPendingEntitiesQuery");
9
+ const getAvailableToRequestEntitiesQuery_1 = require("./getAvailableToRequestEntitiesQuery");
10
+ const getRequestingEntitiesQuery_1 = require("./getRequestingEntitiesQuery");
11
+ const isAssociationSupported_1 = require("./internal/isAssociationSupported");
12
+ const wellKnownCatalog_1 = require("../search/wellKnownCatalog");
13
+ /**
14
+ * There are two primary UI workflows when we consider associations:
15
+ * 1. Viewing associations
16
+ * 2. Forming associations
17
+ *
18
+ * Because associations involve a 2-way agreement between parent
19
+ * and child, when viewing associations, there are 3 gallery states
20
+ * that can be viewed: "associated", "pending", and "requesting"
21
+ * entities. Additionally, when forming associations, we need a
22
+ * picker experience filtered to entities that can still be
23
+ * requested for association.
24
+ *
25
+ * These define the "well-known" association catalogs that this
26
+ * util can return. In turn, these can be passed into the catalog
27
+ * and/or gallery-picker components to render the appropriate
28
+ * UI experience.
29
+ *
30
+ * @param i18nScope - translation scope to be interpolated into the catalog
31
+ * @param catalogName - name of the well-known catalog requested
32
+ * @param entity - primary entity the catalog is being built for
33
+ * @param associationType - type of entity the primary entity wants to view associations for
34
+ * @param context - contextual auth and portal information
35
+ * @returns {IHubCatalog}
36
+ */
37
+ async function getWellKnownAssociationsCatalog(i18nScope, catalogName, entity, associationType, context) {
38
+ let catalog;
39
+ const entityType = core_1.getTypeFromEntity(entity);
40
+ const isSupported = isAssociationSupported_1.isAssociationSupported(entityType, associationType);
41
+ if (!isSupported) {
42
+ throw new Error(`getWellKnownAssociationsCatalog: Association between ${entityType} and ${associationType} is not supported.`);
43
+ }
44
+ i18nScope = wellKnownCatalog_1.dotifyString(i18nScope);
45
+ const targetEntity = getEntityTypeFromType_1.getEntityTypeFromType(entity.type);
46
+ /** 1. build a collection based on the provided associationType */
47
+ const collections = [
48
+ wellKnownCatalog_1.getWellknownCollection(i18nScope, targetEntity, associationType),
49
+ ];
50
+ /** 2. build a query based on the provided catalogName */
51
+ let query;
52
+ switch (catalogName) {
53
+ case "associated":
54
+ query = await getAssociatedEntitiesQuery_1.getAssociatedEntitiesQuery(entity, associationType, context);
55
+ break;
56
+ case "pending":
57
+ query = await getPendingEntitiesQuery_1.getPendingEntitiesQuery(entity, associationType, context);
58
+ break;
59
+ case "requesting":
60
+ query = await getRequestingEntitiesQuery_1.getRequestingEntitiesQuery(entity, associationType, context);
61
+ break;
62
+ case "availableToRequest":
63
+ query = getAvailableToRequestEntitiesQuery_1.getAvailableToRequestEntitiesQuery(entity, associationType);
64
+ break;
65
+ }
66
+ /** 3. build the well-known catalog */
67
+ // if query filters are undefined (e.g. query = null), we assume
68
+ // an empty state, and we need to construct a default query
69
+ // filter that will return no results
70
+ const filters = (query === null || query === void 0 ? void 0 : query.filters) ? query.filters
71
+ : [{ predicates: [{ type: ["Code Attachment"] }] }];
72
+ catalog = buildCatalog_1.buildCatalog(i18nScope, catalogName, filters, collections, targetEntity);
73
+ return catalog;
74
+ }
75
+ exports.getWellKnownAssociationsCatalog = getWellKnownAssociationsCatalog;
76
+ //# sourceMappingURL=getWellKnownAssociationsCatalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWellKnownAssociationsCatalog.js","sourceRoot":"","sources":["../../../src/associations/getWellKnownAssociationsCatalog.ts"],"names":[],"mappings":";;;AACA,kCAA4C;AAE5C,mEAAgE;AAChE,qFAAkF;AAClF,6EAA0E;AAC1E,uEAAoE;AACpE,6FAA0F;AAC1F,6EAA0E;AAC1E,8EAA2E;AAE3E,iEAIoC;AAapC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,KAAK,UAAU,+BAA+B,CACnD,SAAiB,EACjB,WAAwC,EACxC,MAAiB,EACjB,eAA8B,EAC9B,OAAuB;IAEvB,IAAI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C,CAAC;IACtD,OAAO,GAAG,2BAAY,CACpB,SAAS,EACT,WAAW,EACX,OAAO,EACP,WAAW,EACX,YAAY,CACb,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAtED,0EAsEC"}
@@ -2,7 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./addAssociation"), exports);
5
+ tslib_1.__exportStar(require("./breakAssociation"), exports);
5
6
  tslib_1.__exportStar(require("./listAssociations"), exports);
6
7
  tslib_1.__exportStar(require("./removeAssociation"), exports);
7
8
  tslib_1.__exportStar(require("./types"), exports);
9
+ tslib_1.__exportStar(require("./getAssociatedEntitiesQuery"), exports);
10
+ tslib_1.__exportStar(require("./getAssociationStats"), exports);
11
+ tslib_1.__exportStar(require("./getAvailableToRequestEntitiesQuery"), exports);
12
+ tslib_1.__exportStar(require("./getPendingEntitiesQuery"), exports);
13
+ tslib_1.__exportStar(require("./getRequestingEntitiesQuery"), exports);
14
+ tslib_1.__exportStar(require("./getWellKnownAssociationsCatalog"), exports);
15
+ // Note: we expose "requestAssociation" under 2 names.
16
+ // These actions are functionally equivalent, but we want
17
+ // to make the intent more clear to the consumer.
18
+ var requestAssociation_1 = require("./requestAssociation");
19
+ Object.defineProperty(exports, "requestAssociation", { enumerable: true, get: function () { return requestAssociation_1.requestAssociation; } });
20
+ var requestAssociation_2 = require("./requestAssociation");
21
+ Object.defineProperty(exports, "acceptAssociation", { enumerable: true, get: function () { return requestAssociation_2.requestAssociation; } });
8
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/associations/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,6DAAmC;AACnC,8DAAoC;AACpC,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/associations/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,6DAAmC;AACnC,6DAAmC;AACnC,8DAAoC;AACpC,kDAAwB;AACxB,uEAA6C;AAC7C,gEAAsC;AACtC,+EAAqD;AACrD,oEAA0C;AAC1C,uEAA6C;AAC7C,4EAAkD;AAClD,sDAAsD;AACtD,yDAAyD;AACzD,iDAAiD;AACjD,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,2DAA+E;AAAtE,uHAAA,kBAAkB,OAAqB"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAssociationHierarchy = void 0;
4
+ const ProjectAssociationHierarchies_1 = require("../../projects/_internal/ProjectAssociationHierarchies");
5
+ const InitiativeAssociationHierarchies_1 = require("../../initiatives/_internal/InitiativeAssociationHierarchies");
6
+ /**
7
+ * associations are hierarchical in nature, e.g.
8
+ * there is always a parent and a child involved
9
+ * in the relationship.
10
+ *
11
+ * given an entity type, this util returns the
12
+ * parent and children entity types that it can
13
+ * associate with
14
+ *
15
+ * @param type - entity type
16
+ * @returns {IHubAssociationHierarchy}
17
+ */
18
+ exports.getAssociationHierarchy = (type) => {
19
+ let hierarchy = {
20
+ children: [],
21
+ parents: [],
22
+ };
23
+ switch (type) {
24
+ case "initiative":
25
+ hierarchy = InitiativeAssociationHierarchies_1.InitiativeAssociationHierarchies;
26
+ break;
27
+ case "project":
28
+ hierarchy = ProjectAssociationHierarchies_1.ProjectAssociationHierarchies;
29
+ break;
30
+ // as we support more entity associations, we'll need to extend this
31
+ default:
32
+ throw new Error(`getAssociationHierarchy: Invalid type for associations: ${type}.`);
33
+ }
34
+ return hierarchy;
35
+ };
36
+ //# sourceMappingURL=getAssociationHierarchy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getAssociationHierarchy.js","sourceRoot":"","sources":["../../../../src/associations/internal/getAssociationHierarchy.ts"],"names":[],"mappings":";;;AAEA,0GAAuG;AACvG,mHAAgH;AAEhH;;;;;;;;;;;GAWG;AACU,QAAA,uBAAuB,GAAG,CACrC,IAAmB,EACO,EAAE;IAC5B,IAAI,SAAS,GAA6B;QACxC,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;KACZ,CAAC;IACF,QAAQ,IAAI,EAAE;QACZ,KAAK,YAAY;YACf,SAAS,GAAG,mEAAgC,CAAC;YAC7C,MAAM;QACR,KAAK,SAAS;YACZ,SAAS,GAAG,6DAA6B,CAAC;YAC1C,MAAM;QACR,oEAAoE;QACpE;YACE,MAAM,IAAI,KAAK,CACb,2DAA2D,IAAI,GAAG,CACnE,CAAC;KACL;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIdsFromAssociationGroups = void 0;
4
+ /**
5
+ * given an array of groups, this util maps over them,
6
+ * and for each, determines if it's an association group
7
+ * by checking if it has a typeKeyword of the form
8
+ * <associationType>|<id>. If so, it extracts and returns
9
+ * the id which corresponds to the parent entity that this
10
+ * association group belongs to
11
+ *
12
+ * @param groups - array of groups
13
+ * @param associationType - entity type to extract ids for
14
+ * @returns {string[]}
15
+ */
16
+ exports.getIdsFromAssociationGroups = (groups, associationType) => {
17
+ return groups.reduce((ids, group) => {
18
+ // 1. determine if the group is an association group
19
+ const associationTypeKeyword = group.typeKeywords.find((keyword) => keyword.startsWith(`${associationType}|`));
20
+ // 2. if so, store the parent id from the typeKeyword to return
21
+ if (associationTypeKeyword) {
22
+ const id = associationTypeKeyword.split("|")[1];
23
+ ids.push(id);
24
+ }
25
+ return ids;
26
+ }, []);
27
+ };
28
+ //# sourceMappingURL=getIdsFromAssociationGroups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIdsFromAssociationGroups.js","sourceRoot":"","sources":["../../../../src/associations/internal/getIdsFromAssociationGroups.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;GAWG;AACU,QAAA,2BAA2B,GAAG,CACzC,MAAgB,EAChB,eAA8B,EACpB,EAAE;IACZ,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAa,EAAE,KAAa,EAAE,EAAE;QACpD,oDAAoD;QACpD,MAAM,sBAAsB,GAAG,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,OAAe,EAAE,EAAE,CACzE,OAAO,CAAC,UAAU,CAAC,GAAG,eAAe,GAAG,CAAC,CAC1C,CAAC;QAEF,+DAA+D;QAC/D,IAAI,sBAAsB,EAAE;YAC1B,MAAM,EAAE,GAAG,sBAAsB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACd;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIdsFromKeywords = void 0;
4
+ const objects_1 = require("../../objects");
5
+ /**
6
+ * given a hub entity, this util maps over its typeKeywords,
7
+ * and for each, determines if it is an association typeKeyword
8
+ * by checking whether it has the form ref|<associationType>|<id>.
9
+ * If so, it extracts and returns the id which correspond to the
10
+ * parent entity that this entity is associated with.
11
+ *
12
+ * @param entity - hub entity to extract ids from
13
+ * @param associationType - entity type to extract ids for
14
+ * @returns {string[]}
15
+ */
16
+ exports.getIdsFromKeywords = (entity, associationType) => {
17
+ return objects_1.getProp(entity, "typeKeywords").reduce((ids, keyword) => {
18
+ if (keyword.startsWith(`ref|${associationType}|`)) {
19
+ const id = keyword.split("|")[2];
20
+ ids.push(id);
21
+ }
22
+ return ids;
23
+ }, []);
24
+ };
25
+ //# sourceMappingURL=getIdsFromKeywords.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIdsFromKeywords.js","sourceRoot":"","sources":["../../../../src/associations/internal/getIdsFromKeywords.ts"],"names":[],"mappings":";;;AACA,2CAAwC;AAExC;;;;;;;;;;GAUG;AACU,QAAA,kBAAkB,GAAG,CAChC,MAAiB,EACjB,eAA8B,EACpB,EAAE;IACZ,OAAO,iBAAO,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,MAAM,CAC3C,CAAC,GAAa,EAAE,OAAe,EAAE,EAAE;QACjC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,eAAe,GAAG,CAAC,EAAE;YACjD,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YACjC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACd;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIncludesAndReferencesQuery = void 0;
4
+ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
5
+ const getTypesFromEntityType_1 = require("../../core/getTypesFromEntityType");
6
+ const get_prop_1 = require("../../objects/get-prop");
7
+ const combineQueries_1 = require("../../search/_internal/combineQueries");
8
+ const getTypeWithKeywordQuery_1 = require("./getTypeWithKeywordQuery");
9
+ const getTypeByIdsQuery_1 = require("./getTypeByIdsQuery");
10
+ const getTypeFromEntity_1 = require("../../core/getTypeFromEntity");
11
+ const getIdsFromKeywords_1 = require("./getIdsFromKeywords");
12
+ const getIdsFromAssociationGroups_1 = require("./getIdsFromAssociationGroups");
13
+ /**
14
+ * builds a query that will return entities that are
15
+ * "included" AND "referenced"
16
+ *
17
+ * @param entity - Hub entity
18
+ * @param associationType - entity type to query for
19
+ * @param isParent - whether the provided Hub entity is the parent in the association relationship
20
+ * @param context - contextual auth and portal information
21
+ * @returns {IQuery}
22
+ */
23
+ exports.getIncludesAndReferencesQuery = async (entity, associationType, isParent, context) => {
24
+ if (isParent) {
25
+ /**
26
+ * 1. build query that returns child entities WITH a
27
+ * typeKeyword reference to the parent
28
+ */
29
+ const parentType = getTypeFromEntity_1.getTypeFromEntity(entity);
30
+ const referencedQuery = getTypeWithKeywordQuery_1.getTypeWithKeywordQuery(getTypesFromEntityType_1.getTypesFromEntityType(associationType), `ref|${parentType}|${entity.id}`);
31
+ /** 2. grab the parent's association query */
32
+ const includedQuery = get_prop_1.getProp(entity, "associations.rules.query");
33
+ /** 3. combine queries - will remove null/undefined entries */
34
+ return combineQueries_1.combineQueries([referencedQuery, includedQuery]);
35
+ }
36
+ else {
37
+ /** 1. fetch the groups a child has been shared with */
38
+ const { admin, member, other } = await arcgis_rest_portal_1.getItemGroups(entity.id, context.requestOptions);
39
+ const groupsChildIsSharedWith = [...admin, ...member, ...other];
40
+ /**
41
+ * 2. filter the child's groups down to association groups
42
+ * (by checking if they have a typeKeyword of the form
43
+ * <associationType>|<id>) and extract parent ids
44
+ */
45
+ const parentIdsThatIncludeChild = getIdsFromAssociationGroups_1.getIdsFromAssociationGroups(groupsChildIsSharedWith, associationType);
46
+ /**
47
+ * 3. iterate over the child's typeKeywords and grab the parent
48
+ * ids it references (typeKeyword = <associationType>|<id>)
49
+ */
50
+ const parentIdsChildReferences = getIdsFromKeywords_1.getIdsFromKeywords(entity, associationType);
51
+ /**
52
+ * 4. filter the parent ids down to those that include
53
+ * the child AND that the child references
54
+ */
55
+ const parentIds = parentIdsThatIncludeChild.filter((id) => parentIdsChildReferences.includes(id));
56
+ /** 5. return a query for the filtered parent ids */
57
+ const type = getTypesFromEntityType_1.getTypesFromEntityType(associationType);
58
+ return parentIds.length ? getTypeByIdsQuery_1.getTypeByIdsQuery(type, parentIds) : null;
59
+ }
60
+ };
61
+ //# sourceMappingURL=getIncludesAndReferencesQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIncludesAndReferencesQuery.js","sourceRoot":"","sources":["../../../../src/associations/internal/getIncludesAndReferencesQuery.ts"],"names":[],"mappings":";;;AAAA,iEAAiE;AAEjE,8EAA2E;AAC3E,qDAAiD;AAE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C;QACrD,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,qCAAiB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KACrE;AACH,CAAC,CAAC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIncludesDoesNotReferenceQuery = void 0;
4
+ const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
5
+ const getTypesFromEntityType_1 = require("../../core/getTypesFromEntityType");
6
+ const get_prop_1 = require("../../objects/get-prop");
7
+ const combineQueries_1 = require("../../search/_internal/combineQueries");
8
+ const getTypeWithoutKeywordQuery_1 = require("./getTypeWithoutKeywordQuery");
9
+ const getTypeByIdsQuery_1 = require("./getTypeByIdsQuery");
10
+ const getTypeFromEntity_1 = require("../../core/getTypeFromEntity");
11
+ const getIdsFromKeywords_1 = require("./getIdsFromKeywords");
12
+ const getIdsFromAssociationGroups_1 = require("./getIdsFromAssociationGroups");
13
+ /**
14
+ * builds a query that will return entities that are
15
+ * "included" but NOT "referenced"
16
+ *
17
+ * @param entity - Hub entity
18
+ * @param associationType - entity type to query for
19
+ * @param isParent - whether the provided Hub entity is the parent in the association relationship
20
+ * @param context - contextual auth and portal information
21
+ * @returns {IQuery}
22
+ */
23
+ exports.getIncludesDoesNotReferenceQuery = async (entity, associationType, isParent, context) => {
24
+ if (isParent) {
25
+ /**
26
+ * 1. build query that returns child entities WITHOUT a
27
+ * typeKeyword reference to the parent
28
+ */
29
+ const parentType = getTypeFromEntity_1.getTypeFromEntity(entity);
30
+ const referencedQuery = getTypeWithoutKeywordQuery_1.getTypeWithoutKeywordQuery(getTypesFromEntityType_1.getTypesFromEntityType(associationType), `ref|${parentType}|${entity.id}`);
31
+ /** 2. grab the parent entity's association query */
32
+ const includedQuery = get_prop_1.getProp(entity, "associations.rules.query");
33
+ /** 3. combine queries - will remove null/undefined entries */
34
+ return combineQueries_1.combineQueries([referencedQuery, includedQuery]);
35
+ }
36
+ else {
37
+ /** 1. fetch the groups a child has been shared with */
38
+ const { admin, member, other } = await arcgis_rest_portal_1.getItemGroups(entity.id, context.requestOptions);
39
+ const groupsChildIsSharedWith = [...admin, ...member, ...other];
40
+ /**
41
+ * 2. filter the child's groups down to association groups
42
+ * (by checking if they have a typeKeyword of the form
43
+ * <associationType>|<id>) and extract parent ids
44
+ */
45
+ const parentIdsThatIncludeChild = getIdsFromAssociationGroups_1.getIdsFromAssociationGroups(groupsChildIsSharedWith, associationType);
46
+ /**
47
+ * 3. iterate over the child's typeKeywords and grab the parent
48
+ * ids it references (typeKeyword = <associationType>|<id>)
49
+ */
50
+ const parentIdsChildReferences = getIdsFromKeywords_1.getIdsFromKeywords(entity, associationType);
51
+ /**
52
+ * 4. filter the parent ids down to those that include the
53
+ * child, but that the child does NOT reference
54
+ */
55
+ const parentIds = parentIdsThatIncludeChild.filter((id) => !parentIdsChildReferences.includes(id));
56
+ /** 5. return a query for the filtered parent ids */
57
+ const type = getTypesFromEntityType_1.getTypesFromEntityType(associationType);
58
+ return parentIds.length ? getTypeByIdsQuery_1.getTypeByIdsQuery(type, parentIds) : null;
59
+ }
60
+ };
61
+ //# sourceMappingURL=getIncludesDoesNotReferenceQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getIncludesDoesNotReferenceQuery.js","sourceRoot":"","sources":["../../../../src/associations/internal/getIncludesDoesNotReferenceQuery.ts"],"names":[],"mappings":";;;AAAA,iEAAyD;AAEzD,8EAA2E;AAC3E,qDAAiD;AAEjD,0EAAuE;AACvE,6EAA0E;AAE1E,2DAAwD;AACxD,oEAAiE;AACjE,6DAA0D;AAC1D,+EAA4E;AAE5E;;;;;;;;;GASG;AACU,QAAA,gCAAgC,GAAG,KAAK,EACnD,MAAiB,EACjB,eAA8B,EAC9B,QAAiB,EACjB,OAAuB,EACN,EAAE;IACnB,IAAI,QAAQ,EAAE;QACZ;;;WAGG;QACH,MAAM,UAAU,GAAG,qCAA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