@osdk/client 2.8.0-beta.1 → 2.8.0-beta.10

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 (291) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/build/browser/Client.js +1 -1
  3. package/build/browser/Client.js.map +1 -1
  4. package/build/browser/actions/applyAction.js +2 -1
  5. package/build/browser/actions/applyAction.js.map +1 -1
  6. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +101 -0
  7. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  8. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js +1 -1
  9. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -1
  10. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +1 -1
  11. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  12. package/build/browser/objectSet/ObjectSetListenerWebsocket.js +2 -2
  13. package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  14. package/build/browser/objectSet/createObjectSet.js +0 -4
  15. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  16. package/build/browser/observable/ObservableClient/ObserveLink.js.map +1 -1
  17. package/build/browser/observable/ObservableClient.js +11 -0
  18. package/build/browser/observable/ObservableClient.js.map +1 -1
  19. package/build/browser/observable/internal/AbstractHelper.js +56 -3
  20. package/build/browser/observable/internal/AbstractHelper.js.map +1 -1
  21. package/build/browser/observable/internal/AbstractHelper.test.js +114 -0
  22. package/build/browser/observable/internal/AbstractHelper.test.js.map +1 -0
  23. package/build/browser/observable/internal/BulkObjectLoader.js +71 -9
  24. package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -1
  25. package/build/browser/observable/internal/BulkObjectLoader.test.js +79 -0
  26. package/build/browser/observable/internal/BulkObjectLoader.test.js.map +1 -1
  27. package/build/browser/observable/internal/CacheKeys.js +19 -8
  28. package/build/browser/observable/internal/CacheKeys.js.map +1 -1
  29. package/build/browser/observable/internal/ListQueryView.js +120 -0
  30. package/build/browser/observable/internal/ListQueryView.js.map +1 -0
  31. package/build/browser/observable/internal/ObservableClientImpl.js +136 -24
  32. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  33. package/build/browser/observable/internal/PivotCanonicalizer.js +4 -4
  34. package/build/browser/observable/internal/PivotCanonicalizer.js.map +1 -1
  35. package/build/browser/observable/internal/Query.js +7 -5
  36. package/build/browser/observable/internal/Query.js.map +1 -1
  37. package/build/browser/observable/internal/RdpCanonicalizer.test.js +23 -7
  38. package/build/browser/observable/internal/RdpCanonicalizer.test.js.map +1 -1
  39. package/build/browser/observable/internal/Store.js +19 -2
  40. package/build/browser/observable/internal/Store.js.map +1 -1
  41. package/build/browser/observable/internal/Store.test.js +327 -1
  42. package/build/browser/observable/internal/Store.test.js.map +1 -1
  43. package/build/browser/observable/internal/actions/ActionApplication.js +8 -6
  44. package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -1
  45. package/build/browser/observable/internal/aggregation/AggregationCacheKey.js +5 -3
  46. package/build/browser/observable/internal/aggregation/AggregationCacheKey.js.map +1 -1
  47. package/build/browser/observable/internal/aggregation/AggregationQuery.js +28 -2
  48. package/build/browser/observable/internal/aggregation/AggregationQuery.js.map +1 -1
  49. package/build/browser/observable/internal/aggregation/AggregationsHelper.js +18 -2
  50. package/build/browser/observable/internal/aggregation/AggregationsHelper.js.map +1 -1
  51. package/build/browser/observable/internal/aggregation/AggregationsHelper.test.js +103 -0
  52. package/build/browser/observable/internal/aggregation/AggregationsHelper.test.js.map +1 -0
  53. package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js +22 -3
  54. package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -1
  55. package/build/browser/observable/internal/base-list/BaseListQuery.js +73 -6
  56. package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
  57. package/build/browser/observable/internal/function/FunctionQuery.js +27 -1
  58. package/build/browser/observable/internal/function/FunctionQuery.js.map +1 -1
  59. package/build/browser/observable/internal/function/FunctionsHelper.js +2 -1
  60. package/build/browser/observable/internal/function/FunctionsHelper.js.map +1 -1
  61. package/build/browser/observable/internal/getObjectTypesThatInvalidate.js +2 -2
  62. package/build/browser/observable/internal/getObjectTypesThatInvalidate.js.map +1 -1
  63. package/build/browser/observable/internal/links/LinksHelper.js +3 -2
  64. package/build/browser/observable/internal/links/LinksHelper.js.map +1 -1
  65. package/build/browser/observable/internal/links/SpecificLinkCacheKey.js +7 -5
  66. package/build/browser/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
  67. package/build/browser/observable/internal/links/SpecificLinkQuery.js +97 -62
  68. package/build/browser/observable/internal/links/SpecificLinkQuery.js.map +1 -1
  69. package/build/browser/observable/internal/list/InterfaceListQuery.js +19 -1
  70. package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -1
  71. package/build/browser/observable/internal/list/ListQuery.js +30 -10
  72. package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
  73. package/build/browser/observable/internal/list/ListQuery.test.js +262 -1
  74. package/build/browser/observable/internal/list/ListQuery.test.js.map +1 -1
  75. package/build/browser/observable/internal/list/ListsHelper.js +1 -1
  76. package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
  77. package/build/browser/observable/internal/list/ObjectListQuery.js +22 -21
  78. package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -1
  79. package/build/browser/observable/internal/object/ObjectQuery.js +23 -6
  80. package/build/browser/observable/internal/object/ObjectQuery.js.map +1 -1
  81. package/build/browser/observable/internal/object/ObjectsHelper.js +12 -3
  82. package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
  83. package/build/browser/observable/internal/object/ObjectsHelper.test.js +200 -0
  84. package/build/browser/observable/internal/object/ObjectsHelper.test.js.map +1 -0
  85. package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -1
  86. package/build/browser/observable/internal/objectset/ObjectSetHelper.js +3 -2
  87. package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  88. package/build/browser/observable/internal/objectset/ObjectSetHelper.test.js +94 -0
  89. package/build/browser/observable/internal/objectset/ObjectSetHelper.test.js.map +1 -0
  90. package/build/browser/observable/internal/objectset/ObjectSetQuery.js +4 -1
  91. package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  92. package/build/browser/observable/internal/testUtils/observeLink/expectStandardObserveLink.js +1 -0
  93. package/build/browser/observable/internal/testUtils/observeLink/expectStandardObserveLink.js.map +1 -1
  94. package/build/browser/observable/internal/testUtils.js.map +1 -1
  95. package/build/browser/observable/internal/utils/rdpFieldOperations.js +7 -2
  96. package/build/browser/observable/internal/utils/rdpFieldOperations.js.map +1 -1
  97. package/build/browser/observable/internal/utils/rdpFieldOperations.test.js +55 -0
  98. package/build/browser/observable/internal/utils/rdpFieldOperations.test.js.map +1 -1
  99. package/build/browser/public/unstable-do-not-use.js +1 -0
  100. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  101. package/build/browser/util/UserAgent.js +2 -2
  102. package/build/browser/util/UserAgent.js.map +1 -1
  103. package/build/browser/util/interfaceUtils.js +7 -0
  104. package/build/browser/util/interfaceUtils.js.map +1 -1
  105. package/build/cjs/{chunk-7543GRIE.cjs → chunk-6VOFZIIJ.cjs} +79 -69
  106. package/build/cjs/chunk-6VOFZIIJ.cjs.map +1 -0
  107. package/build/cjs/{chunk-VVKEXIIO.cjs → chunk-YVZM2JPW.cjs} +164 -155
  108. package/build/cjs/chunk-YVZM2JPW.cjs.map +1 -0
  109. package/build/cjs/index.cjs +8 -8
  110. package/build/cjs/public/internal.cjs +8 -8
  111. package/build/cjs/public/unstable-do-not-use.cjs +928 -361
  112. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  113. package/build/cjs/public/unstable-do-not-use.d.cts +64 -26
  114. package/build/esm/Client.js +1 -1
  115. package/build/esm/Client.js.map +1 -1
  116. package/build/esm/actions/applyAction.js +2 -1
  117. package/build/esm/actions/applyAction.js.map +1 -1
  118. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +101 -0
  119. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  120. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js +1 -1
  121. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -1
  122. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +1 -1
  123. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  124. package/build/esm/objectSet/ObjectSetListenerWebsocket.js +2 -2
  125. package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  126. package/build/esm/objectSet/createObjectSet.js +0 -4
  127. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  128. package/build/esm/observable/ObservableClient/ObserveLink.js.map +1 -1
  129. package/build/esm/observable/ObservableClient.js +11 -0
  130. package/build/esm/observable/ObservableClient.js.map +1 -1
  131. package/build/esm/observable/internal/AbstractHelper.js +56 -3
  132. package/build/esm/observable/internal/AbstractHelper.js.map +1 -1
  133. package/build/esm/observable/internal/AbstractHelper.test.js +114 -0
  134. package/build/esm/observable/internal/AbstractHelper.test.js.map +1 -0
  135. package/build/esm/observable/internal/BulkObjectLoader.js +71 -9
  136. package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -1
  137. package/build/esm/observable/internal/BulkObjectLoader.test.js +79 -0
  138. package/build/esm/observable/internal/BulkObjectLoader.test.js.map +1 -1
  139. package/build/esm/observable/internal/CacheKeys.js +19 -8
  140. package/build/esm/observable/internal/CacheKeys.js.map +1 -1
  141. package/build/esm/observable/internal/ListQueryView.js +120 -0
  142. package/build/esm/observable/internal/ListQueryView.js.map +1 -0
  143. package/build/esm/observable/internal/ObservableClientImpl.js +136 -24
  144. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  145. package/build/esm/observable/internal/PivotCanonicalizer.js +4 -4
  146. package/build/esm/observable/internal/PivotCanonicalizer.js.map +1 -1
  147. package/build/esm/observable/internal/Query.js +7 -5
  148. package/build/esm/observable/internal/Query.js.map +1 -1
  149. package/build/esm/observable/internal/RdpCanonicalizer.test.js +23 -7
  150. package/build/esm/observable/internal/RdpCanonicalizer.test.js.map +1 -1
  151. package/build/esm/observable/internal/Store.js +19 -2
  152. package/build/esm/observable/internal/Store.js.map +1 -1
  153. package/build/esm/observable/internal/Store.test.js +327 -1
  154. package/build/esm/observable/internal/Store.test.js.map +1 -1
  155. package/build/esm/observable/internal/actions/ActionApplication.js +8 -6
  156. package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -1
  157. package/build/esm/observable/internal/aggregation/AggregationCacheKey.js +5 -3
  158. package/build/esm/observable/internal/aggregation/AggregationCacheKey.js.map +1 -1
  159. package/build/esm/observable/internal/aggregation/AggregationQuery.js +28 -2
  160. package/build/esm/observable/internal/aggregation/AggregationQuery.js.map +1 -1
  161. package/build/esm/observable/internal/aggregation/AggregationsHelper.js +18 -2
  162. package/build/esm/observable/internal/aggregation/AggregationsHelper.js.map +1 -1
  163. package/build/esm/observable/internal/aggregation/AggregationsHelper.test.js +103 -0
  164. package/build/esm/observable/internal/aggregation/AggregationsHelper.test.js.map +1 -0
  165. package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js +22 -3
  166. package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -1
  167. package/build/esm/observable/internal/base-list/BaseListQuery.js +73 -6
  168. package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
  169. package/build/esm/observable/internal/function/FunctionQuery.js +27 -1
  170. package/build/esm/observable/internal/function/FunctionQuery.js.map +1 -1
  171. package/build/esm/observable/internal/function/FunctionsHelper.js +2 -1
  172. package/build/esm/observable/internal/function/FunctionsHelper.js.map +1 -1
  173. package/build/esm/observable/internal/getObjectTypesThatInvalidate.js +2 -2
  174. package/build/esm/observable/internal/getObjectTypesThatInvalidate.js.map +1 -1
  175. package/build/esm/observable/internal/links/LinksHelper.js +3 -2
  176. package/build/esm/observable/internal/links/LinksHelper.js.map +1 -1
  177. package/build/esm/observable/internal/links/SpecificLinkCacheKey.js +7 -5
  178. package/build/esm/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
  179. package/build/esm/observable/internal/links/SpecificLinkQuery.js +97 -62
  180. package/build/esm/observable/internal/links/SpecificLinkQuery.js.map +1 -1
  181. package/build/esm/observable/internal/list/InterfaceListQuery.js +19 -1
  182. package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -1
  183. package/build/esm/observable/internal/list/ListQuery.js +30 -10
  184. package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
  185. package/build/esm/observable/internal/list/ListQuery.test.js +262 -1
  186. package/build/esm/observable/internal/list/ListQuery.test.js.map +1 -1
  187. package/build/esm/observable/internal/list/ListsHelper.js +1 -1
  188. package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
  189. package/build/esm/observable/internal/list/ObjectListQuery.js +22 -21
  190. package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -1
  191. package/build/esm/observable/internal/object/ObjectQuery.js +23 -6
  192. package/build/esm/observable/internal/object/ObjectQuery.js.map +1 -1
  193. package/build/esm/observable/internal/object/ObjectsHelper.js +12 -3
  194. package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
  195. package/build/esm/observable/internal/object/ObjectsHelper.test.js +200 -0
  196. package/build/esm/observable/internal/object/ObjectsHelper.test.js.map +1 -0
  197. package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -1
  198. package/build/esm/observable/internal/objectset/ObjectSetHelper.js +3 -2
  199. package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  200. package/build/esm/observable/internal/objectset/ObjectSetHelper.test.js +94 -0
  201. package/build/esm/observable/internal/objectset/ObjectSetHelper.test.js.map +1 -0
  202. package/build/esm/observable/internal/objectset/ObjectSetQuery.js +4 -1
  203. package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  204. package/build/esm/observable/internal/testUtils/observeLink/expectStandardObserveLink.js +1 -0
  205. package/build/esm/observable/internal/testUtils/observeLink/expectStandardObserveLink.js.map +1 -1
  206. package/build/esm/observable/internal/testUtils.js.map +1 -1
  207. package/build/esm/observable/internal/utils/rdpFieldOperations.js +7 -2
  208. package/build/esm/observable/internal/utils/rdpFieldOperations.js.map +1 -1
  209. package/build/esm/observable/internal/utils/rdpFieldOperations.test.js +55 -0
  210. package/build/esm/observable/internal/utils/rdpFieldOperations.test.js.map +1 -1
  211. package/build/esm/public/unstable-do-not-use.js +1 -0
  212. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  213. package/build/esm/util/UserAgent.js +2 -2
  214. package/build/esm/util/UserAgent.js.map +1 -1
  215. package/build/esm/util/interfaceUtils.js +7 -0
  216. package/build/esm/util/interfaceUtils.js.map +1 -1
  217. package/build/types/Client.d.ts +1 -1
  218. package/build/types/objectSet/createObjectSet.d.ts +5 -1
  219. package/build/types/objectSet/createObjectSet.d.ts.map +1 -1
  220. package/build/types/observable/ObservableClient/ObserveLink.d.ts +2 -1
  221. package/build/types/observable/ObservableClient/ObserveLink.d.ts.map +1 -1
  222. package/build/types/observable/ObservableClient.d.ts +71 -25
  223. package/build/types/observable/ObservableClient.d.ts.map +1 -1
  224. package/build/types/observable/internal/AbstractHelper.d.ts +1 -1
  225. package/build/types/observable/internal/AbstractHelper.d.ts.map +1 -1
  226. package/build/types/observable/internal/AbstractHelper.test.d.ts +1 -0
  227. package/build/types/observable/internal/AbstractHelper.test.d.ts.map +1 -0
  228. package/build/types/observable/internal/BulkObjectLoader.d.ts +2 -1
  229. package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -1
  230. package/build/types/observable/internal/CacheKeys.d.ts +5 -0
  231. package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
  232. package/build/types/observable/internal/ListQueryView.d.ts +21 -0
  233. package/build/types/observable/internal/ListQueryView.d.ts.map +1 -0
  234. package/build/types/observable/internal/PivotCanonicalizer.d.ts +2 -2
  235. package/build/types/observable/internal/PivotCanonicalizer.d.ts.map +1 -1
  236. package/build/types/observable/internal/Query.d.ts.map +1 -1
  237. package/build/types/observable/internal/Store.d.ts.map +1 -1
  238. package/build/types/observable/internal/Store.test.d.ts.map +1 -1
  239. package/build/types/observable/internal/actions/ActionApplication.d.ts.map +1 -1
  240. package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts +6 -4
  241. package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts.map +1 -1
  242. package/build/types/observable/internal/aggregation/AggregationQuery.d.ts +8 -3
  243. package/build/types/observable/internal/aggregation/AggregationQuery.d.ts.map +1 -1
  244. package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts +19 -14
  245. package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts.map +1 -1
  246. package/build/types/observable/internal/aggregation/AggregationsHelper.test.d.ts +1 -0
  247. package/build/types/observable/internal/aggregation/AggregationsHelper.test.d.ts.map +1 -0
  248. package/build/types/observable/internal/aggregation/ObjectAggregationQuery.d.ts.map +1 -1
  249. package/build/types/observable/internal/base-list/BaseListQuery.d.ts +47 -2
  250. package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -1
  251. package/build/types/observable/internal/function/FunctionQuery.d.ts +1 -1
  252. package/build/types/observable/internal/function/FunctionQuery.d.ts.map +1 -1
  253. package/build/types/observable/internal/function/FunctionsHelper.d.ts +1 -0
  254. package/build/types/observable/internal/function/FunctionsHelper.d.ts.map +1 -1
  255. package/build/types/observable/internal/links/LinksHelper.d.ts +5 -5
  256. package/build/types/observable/internal/links/LinksHelper.d.ts.map +1 -1
  257. package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts +8 -6
  258. package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts.map +1 -1
  259. package/build/types/observable/internal/links/SpecificLinkQuery.d.ts +3 -4
  260. package/build/types/observable/internal/links/SpecificLinkQuery.d.ts.map +1 -1
  261. package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -1
  262. package/build/types/observable/internal/list/ListQuery.d.ts +0 -3
  263. package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
  264. package/build/types/observable/internal/list/ListsHelper.d.ts +4 -4
  265. package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
  266. package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -1
  267. package/build/types/observable/internal/object/ObjectQuery.d.ts +2 -1
  268. package/build/types/observable/internal/object/ObjectQuery.d.ts.map +1 -1
  269. package/build/types/observable/internal/object/ObjectsHelper.d.ts +8 -4
  270. package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -1
  271. package/build/types/observable/internal/object/ObjectsHelper.test.d.ts +1 -0
  272. package/build/types/observable/internal/object/ObjectsHelper.test.d.ts.map +1 -0
  273. package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts +2 -1
  274. package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts.map +1 -1
  275. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts +3 -1
  276. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -1
  277. package/build/types/observable/internal/objectset/ObjectSetHelper.test.d.ts +1 -0
  278. package/build/types/observable/internal/objectset/ObjectSetHelper.test.d.ts.map +1 -0
  279. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +2 -0
  280. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
  281. package/build/types/observable/internal/testUtils.d.ts +2 -2
  282. package/build/types/observable/internal/testUtils.d.ts.map +1 -1
  283. package/build/types/public/unstable-do-not-use.d.ts +1 -0
  284. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  285. package/build/types/util/interfaceUtils.d.ts +2 -1
  286. package/build/types/util/interfaceUtils.d.ts.map +1 -1
  287. package/package.json +12 -12
  288. package/build/cjs/chunk-7543GRIE.cjs.map +0 -1
  289. package/build/cjs/chunk-VVKEXIIO.cjs.map +0 -1
  290. package/build/cjs/delay-W2TSML2P.cjs +0 -75
  291. package/build/cjs/delay-W2TSML2P.cjs.map +0 -1
@@ -50,8 +50,7 @@ export class ActionApplication {
50
50
  if (process.env.NODE_ENV !== "production") {
51
51
  if (ACTION_DELAY > 0) {
52
52
  logger?.debug("action done, pausing", actionResults);
53
- const delay = (await import("delay")).default;
54
- await delay(ACTION_DELAY);
53
+ await new Promise(resolve => setTimeout(resolve, ACTION_DELAY));
55
54
  logger?.debug("action done, pausing done");
56
55
  }
57
56
  }
@@ -85,15 +84,18 @@ export class ActionApplication {
85
84
  promisesToWait.push(this.store.invalidateObject(obj.objectType, obj.primaryKey));
86
85
  }
87
86
  }
87
+
88
+ // Use the registry to find all RDP variant cache keys for each deleted object.
88
89
  this.store.batch({}, batch => {
89
90
  for (const {
90
91
  objectType,
91
92
  primaryKey
92
93
  } of deletedObjects ?? []) {
93
- const cacheKey = this.store.cacheKeys.get("object", objectType, primaryKey, /* rdpConfig */undefined);
94
- this.store.queries.peek(cacheKey)?.deleteFromStore("loaded",
95
- // this is probably not the best value to use
96
- batch);
94
+ for (const cacheKey of this.store.objectCacheKeyRegistry.getVariants(objectType, primaryKey)) {
95
+ this.store.queries.peek(cacheKey)?.deleteFromStore("loaded",
96
+ // this is probably not the best value to use
97
+ batch);
98
+ }
97
99
  }
98
100
  });
99
101
  await Promise.all(promisesToWait);
@@ -1 +1 @@
1
- {"version":3,"file":"ActionApplication.js","names":["runOptimisticJob","ACTION_DELAY","process","env","NODE_ENV","ActionApplication","constructor","store","applyAction","action","args","optimisticUpdate","logger","child","methodName","removeOptimisticResult","Array","isArray","debug","results","client","batchApplyAction","$returnEdits","invalidateActionEditResponse","actionResults","delay","default","actionEditResponse","deletedObjects","modifiedObjects","addedObjects","editedObjectTypes","type","changes","promisesToWait","list","obj","push","invalidateObject","objectType","primaryKey","batch","cacheKey","cacheKeys","get","undefined","queries","peek","deleteFromStore","Promise","all","apiName","invalidateObjectType"],"sources":["ActionApplication.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionEditResponse,\n ActionReturnTypeForOptions,\n} from \"@osdk/api\";\nimport type { ActionSignatureFromDef } from \"../../../actions/applyAction.js\";\nimport { type Changes } from \"../Changes.js\";\nimport type { ObjectCacheKey } from \"../object/ObjectCacheKey.js\";\nimport type { Store } from \"../Store.js\";\nimport { runOptimisticJob } from \"./OptimisticJob.js\";\n\nconst ACTION_DELAY = process.env.NODE_ENV === \"production\" ? 0 : 1000;\n\nexport class ActionApplication {\n constructor(private store: Store) {}\n\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args:\n | Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n | Array<Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]>,\n opts?: Store.ApplyActionOptions,\n ) => Promise<ActionEditResponse> = async (\n action,\n args,\n { optimisticUpdate } = {},\n ) => {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.store.logger?.child({ methodName: \"applyAction\" })\n : this.store.logger;\n const removeOptimisticResult = runOptimisticJob(\n this.store,\n optimisticUpdate,\n );\n\n return await (async () => {\n try {\n if (Array.isArray(args)) {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"applying action to multiple args\", args);\n }\n\n const results: ActionReturnTypeForOptions<{ $returnEdits: true }> =\n await this.store\n .client(action).batchApplyAction(\n args,\n { $returnEdits: true },\n );\n\n await this.#invalidateActionEditResponse(results);\n\n return results;\n }\n\n // The types for client get confused when we dynamically applyAction so we\n // have to deal with the `any` here and force cast it to what it should be.\n // TODO: Update the types so this doesn't happen!\n\n const actionResults: ActionEditResponse = await this.store.client(\n action,\n ).applyAction(args as any, { $returnEdits: true });\n\n if (process.env.NODE_ENV !== \"production\") {\n if (ACTION_DELAY > 0) {\n logger?.debug(\"action done, pausing\", actionResults);\n const delay = (await import(\"delay\")).default;\n await delay(ACTION_DELAY);\n logger?.debug(\"action done, pausing done\");\n }\n }\n await this.#invalidateActionEditResponse(actionResults);\n return actionResults;\n } finally {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\n \"optimistic action complete; remove the results\",\n );\n }\n // make sure this happens even if the action fails\n await removeOptimisticResult();\n }\n })();\n };\n\n #invalidateActionEditResponse = async (\n actionEditResponse: ActionEditResponse | undefined,\n ): Promise<void> => {\n if (actionEditResponse == null) {\n return;\n }\n const {\n deletedObjects,\n modifiedObjects,\n addedObjects,\n editedObjectTypes,\n type,\n } = actionEditResponse;\n let changes: Changes | undefined;\n if (type === \"edits\") {\n const promisesToWait: Promise<any>[] = [];\n\n for (const list of [deletedObjects, modifiedObjects, addedObjects]) {\n for (const obj of list ?? []) {\n promisesToWait.push(\n this.store.invalidateObject(obj.objectType, obj.primaryKey),\n );\n }\n }\n\n this.store.batch({}, (batch) => {\n for (const { objectType, primaryKey } of deletedObjects ?? []) {\n const cacheKey = this.store.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n objectType,\n primaryKey,\n /* rdpConfig */ undefined,\n );\n this.store.queries.peek(cacheKey)?.deleteFromStore(\n \"loaded\", // this is probably not the best value to use\n batch,\n );\n }\n });\n await Promise.all(promisesToWait);\n } else {\n for (const apiName of editedObjectTypes) {\n await this.store.invalidateObjectType(apiName as string, changes);\n }\n }\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,YAAY,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAAG,CAAC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,EAAE;UAC7D,MAAMc,QAAQ,GAAG,IAAI,CAACnC,KAAK,CAACoC,SAAS,CAACC,GAAG,CACvC,QAAQ,EACRL,UAAU,EACVC,UAAU,EACV,eAAgBK,SAClB,CAAC;UACD,IAAI,CAACtC,KAAK,CAACuC,OAAO,CAACC,IAAI,CAACL,QAAQ,CAAC,EAAEM,eAAe,CAChD,QAAQ;UAAE;UACVP,KACF,CAAC;QACH;MACF,CAAC,CAAC;MACF,MAAMQ,OAAO,CAACC,GAAG,CAAChB,cAAc,CAAC;IACnC,CAAC,MAAM;MACL,KAAK,MAAMiB,OAAO,IAAIpB,iBAAiB,EAAE;QACvC,MAAM,IAAI,CAACxB,KAAK,CAAC6C,oBAAoB,CAACD,OAAO,EAAYlB,OAAO,CAAC;MACnE;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"ActionApplication.js","names":["runOptimisticJob","ACTION_DELAY","process","env","NODE_ENV","ActionApplication","constructor","store","applyAction","action","args","optimisticUpdate","logger","child","methodName","removeOptimisticResult","Array","isArray","debug","results","client","batchApplyAction","$returnEdits","invalidateActionEditResponse","actionResults","Promise","resolve","setTimeout","actionEditResponse","deletedObjects","modifiedObjects","addedObjects","editedObjectTypes","type","changes","promisesToWait","list","obj","push","invalidateObject","objectType","primaryKey","batch","cacheKey","objectCacheKeyRegistry","getVariants","queries","peek","deleteFromStore","all","apiName","invalidateObjectType"],"sources":["ActionApplication.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionEditResponse,\n ActionReturnTypeForOptions,\n} from \"@osdk/api\";\nimport type { ActionSignatureFromDef } from \"../../../actions/applyAction.js\";\nimport { type Changes } from \"../Changes.js\";\nimport type { Store } from \"../Store.js\";\nimport { runOptimisticJob } from \"./OptimisticJob.js\";\n\nconst ACTION_DELAY = process.env.NODE_ENV === \"production\" ? 0 : 1000;\n\nexport class ActionApplication {\n constructor(private store: Store) {}\n\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args:\n | Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n | Array<Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]>,\n opts?: Store.ApplyActionOptions,\n ) => Promise<ActionEditResponse> = async (\n action,\n args,\n { optimisticUpdate } = {},\n ) => {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.store.logger?.child({ methodName: \"applyAction\" })\n : this.store.logger;\n const removeOptimisticResult = runOptimisticJob(\n this.store,\n optimisticUpdate,\n );\n\n return await (async () => {\n try {\n if (Array.isArray(args)) {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"applying action to multiple args\", args);\n }\n\n const results: ActionReturnTypeForOptions<{ $returnEdits: true }> =\n await this.store\n .client(action).batchApplyAction(\n args,\n { $returnEdits: true },\n );\n\n await this.#invalidateActionEditResponse(results);\n\n return results;\n }\n\n // The types for client get confused when we dynamically applyAction so we\n // have to deal with the `any` here and force cast it to what it should be.\n // TODO: Update the types so this doesn't happen!\n\n const actionResults: ActionEditResponse = await this.store.client(\n action,\n ).applyAction(args as any, { $returnEdits: true });\n\n if (process.env.NODE_ENV !== \"production\") {\n if (ACTION_DELAY > 0) {\n logger?.debug(\"action done, pausing\", actionResults);\n await new Promise<void>(resolve =>\n setTimeout(resolve, ACTION_DELAY)\n );\n logger?.debug(\"action done, pausing done\");\n }\n }\n await this.#invalidateActionEditResponse(actionResults);\n return actionResults;\n } finally {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\n \"optimistic action complete; remove the results\",\n );\n }\n // make sure this happens even if the action fails\n await removeOptimisticResult();\n }\n })();\n };\n\n #invalidateActionEditResponse = async (\n actionEditResponse: ActionEditResponse | undefined,\n ): Promise<void> => {\n if (actionEditResponse == null) {\n return;\n }\n const {\n deletedObjects,\n modifiedObjects,\n addedObjects,\n editedObjectTypes,\n type,\n } = actionEditResponse;\n let changes: Changes | undefined;\n if (type === \"edits\") {\n const promisesToWait: Promise<any>[] = [];\n\n for (const list of [deletedObjects, modifiedObjects, addedObjects]) {\n for (const obj of list ?? []) {\n promisesToWait.push(\n this.store.invalidateObject(obj.objectType, obj.primaryKey),\n );\n }\n }\n\n // Use the registry to find all RDP variant cache keys for each deleted object.\n this.store.batch({}, (batch) => {\n for (const { objectType, primaryKey } of deletedObjects ?? []) {\n for (\n const cacheKey of this.store.objectCacheKeyRegistry.getVariants(\n objectType,\n primaryKey,\n )\n ) {\n this.store.queries.peek(cacheKey)?.deleteFromStore(\n \"loaded\", // this is probably not the best value to use\n batch,\n );\n }\n }\n });\n await Promise.all(promisesToWait);\n } else {\n for (const apiName of editedObjectTypes) {\n await this.store.invalidateObjectType(apiName as string, changes);\n }\n }\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,YAAY,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAAG,CAAC,GAAG,IAAI;AAErE,OAAO,MAAMC,iBAAiB,CAAC;EAC7BC,WAAWA,CAASC,KAAY,EAAE;IAAA,KAAdA,KAAY,GAAZA,KAAY;EAAG;EAEnCC,WAAW,GAMwB,MAAAA,CACjCC,MAAM,EACNC,IAAI,EACJ;IAAEC;EAAiB,CAAC,GAAG,CAAC,CAAC,KACtB;IACH,MAAMC,MAAM,GAAGV,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAChD,IAAI,CA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AAC,MAAM;MACL,KAAK,MAAMe,OAAO,IAAIlB,iBAAiB,EAAE;QACvC,MAAM,IAAI,CAACzB,KAAK,CAAC4C,oBAAoB,CAACD,OAAO,EAAYhB,OAAO,CAAC;MACnE;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -16,7 +16,9 @@
16
16
 
17
17
  export const TYPE_IDX = 0;
18
18
  export const API_NAME_IDX = 1;
19
- export const WHERE_IDX = 2;
20
- export const RDP_IDX = 3;
21
- export const AGGREGATE_IDX = 4;
19
+ export const WIRE_OBJECT_SET_IDX = 2;
20
+ export const WHERE_IDX = 3;
21
+ export const RDP_IDX = 4;
22
+ export const INTERSECT_IDX = 5;
23
+ export const AGGREGATE_IDX = 6;
22
24
  //# sourceMappingURL=AggregationCacheKey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AggregationCacheKey.js","names":["TYPE_IDX","API_NAME_IDX","WHERE_IDX","RDP_IDX","AGGREGATE_IDX"],"sources":["AggregationCacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateOpts,\n AggregationsResults,\n ObjectOrInterfaceDefinition,\n} from \"@osdk/api\";\nimport type { CacheKey } from \"../CacheKey.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport type { AggregationQuery } from \"./AggregationQuery.js\";\n\nexport const TYPE_IDX = 0;\nexport const API_NAME_IDX = 1;\nexport const WHERE_IDX = 2;\nexport const RDP_IDX = 3;\nexport const AGGREGATE_IDX = 4;\n\nexport interface AggregationCacheKey extends\n CacheKey<\n \"aggregation\",\n | AggregationsResults<\n ObjectOrInterfaceDefinition,\n AggregateOpts<ObjectOrInterfaceDefinition>\n >\n | undefined,\n AggregationQuery,\n [\n type: \"object\" | \"interface\",\n apiName: string,\n whereClause: Canonical<SimpleWhereClause>,\n rdpConfig: Canonical<Rdp> | undefined,\n aggregateOpts: Canonical<AggregateOpts<ObjectOrInterfaceDefinition>>,\n ]\n >\n{\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,OAAO,MAAMA,QAAQ,GAAG,CAAC;AACzB,OAAO,MAAMC,YAAY,GAAG,CAAC;AAC7B,OAAO,MAAMC,SAAS,GAAG,CAAC;AAC1B,OAAO,MAAMC,OAAO,GAAG,CAAC;AACxB,OAAO,MAAMC,aAAa,GAAG,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"AggregationCacheKey.js","names":["TYPE_IDX","API_NAME_IDX","WIRE_OBJECT_SET_IDX","WHERE_IDX","RDP_IDX","INTERSECT_IDX","AGGREGATE_IDX"],"sources":["AggregationCacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateOpts,\n AggregationsResults,\n ObjectOrInterfaceDefinition,\n} from \"@osdk/api\";\nimport type { CacheKey } from \"../CacheKey.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport type { AggregationQuery } from \"./AggregationQuery.js\";\n\nexport const TYPE_IDX = 0;\nexport const API_NAME_IDX = 1;\nexport const WIRE_OBJECT_SET_IDX = 2;\nexport const WHERE_IDX = 3;\nexport const RDP_IDX = 4;\nexport const INTERSECT_IDX = 5;\nexport const AGGREGATE_IDX = 6;\n\nexport interface AggregationCacheKey extends\n CacheKey<\n \"aggregation\",\n | AggregationsResults<\n ObjectOrInterfaceDefinition,\n AggregateOpts<ObjectOrInterfaceDefinition>\n >\n | undefined,\n AggregationQuery,\n [\n type: \"object\" | \"interface\",\n apiName: string,\n wireObjectSet: string | undefined,\n whereClause: Canonical<SimpleWhereClause>,\n rdpConfig: Canonical<Rdp> | undefined,\n intersectWith: Canonical<Array<Canonical<SimpleWhereClause>>> | undefined,\n aggregateOpts: Canonical<AggregateOpts<ObjectOrInterfaceDefinition>>,\n ]\n >\n{\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,OAAO,MAAMA,QAAQ,GAAG,CAAC;AACzB,OAAO,MAAMC,YAAY,GAAG,CAAC;AAC7B,OAAO,MAAMC,mBAAmB,GAAG,CAAC;AACpC,OAAO,MAAMC,SAAS,GAAG,CAAC;AAC1B,OAAO,MAAMC,OAAO,GAAG,CAAC;AACxB,OAAO,MAAMC,aAAa,GAAG,CAAC;AAC9B,OAAO,MAAMC,aAAa,GAAG,CAAC","ignoreList":[]}
@@ -16,9 +16,12 @@
16
16
 
17
17
  import { BehaviorSubject, connectable, map } from "rxjs";
18
18
  import { additionalContext } from "../../../Client.js";
19
+ import { getObjectTypesThatInvalidate } from "../getObjectTypesThatInvalidate.js";
19
20
  import { Query } from "../Query.js";
20
- import { AGGREGATE_IDX, API_NAME_IDX, RDP_IDX, WHERE_IDX } from "./AggregationCacheKey.js";
21
+ import { AGGREGATE_IDX, API_NAME_IDX, RDP_IDX, WHERE_IDX, WIRE_OBJECT_SET_IDX } from "./AggregationCacheKey.js";
21
22
  export class AggregationQuery extends Query {
23
+ #invalidationTypes;
24
+ #invalidationTypesPromise;
22
25
  constructor(store, subject, cacheKey, opts) {
23
26
  super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[additionalContext].logger?.child({}, {
24
27
  msgPrefix: `AggregationQuery<${cacheKey.otherKeys.map(x => JSON.stringify(x)).join(", ")}>`
@@ -27,6 +30,29 @@ export class AggregationQuery extends Query {
27
30
  this.canonicalWhere = cacheKey.otherKeys[WHERE_IDX];
28
31
  this.rdpConfig = cacheKey.otherKeys[RDP_IDX];
29
32
  this.canonicalAggregate = cacheKey.otherKeys[AGGREGATE_IDX];
33
+ const serializedObjectSet = cacheKey.otherKeys[WIRE_OBJECT_SET_IDX];
34
+ this.#invalidationTypes = new Set([this.apiName]);
35
+ if (serializedObjectSet) {
36
+ this.parsedWireObjectSet = JSON.parse(serializedObjectSet);
37
+ this.#invalidationTypesPromise = this.#computeInvalidationTypes(this.parsedWireObjectSet);
38
+ }
39
+ }
40
+ async #computeInvalidationTypes(wireObjectSet) {
41
+ try {
42
+ const {
43
+ invalidationSet
44
+ } = await getObjectTypesThatInvalidate(this.store.client[additionalContext], wireObjectSet);
45
+ return new Set([this.apiName, ...invalidationSet]);
46
+ } catch (error) {
47
+ this.store.logger?.error("Failed to compute invalidation types for aggregation, falling back to base type only", error);
48
+ return new Set([this.apiName]);
49
+ }
50
+ }
51
+ async ensureInvalidationTypesReady() {
52
+ if (this.#invalidationTypesPromise) {
53
+ this.#invalidationTypes = await this.#invalidationTypesPromise;
54
+ this.#invalidationTypesPromise = undefined;
55
+ }
30
56
  }
31
57
  _createConnectable(subject) {
32
58
  return connectable(subject.pipe(map(x => {
@@ -67,7 +93,7 @@ export class AggregationQuery extends Query {
67
93
  return batch.read(this.cacheKey);
68
94
  }
69
95
  invalidateObjectType = (objectType, changes) => {
70
- if (this.apiName === objectType) {
96
+ if (this.#invalidationTypes.has(objectType)) {
71
97
  changes?.modified.add(this.cacheKey);
72
98
  return this.revalidate(true);
73
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AggregationQuery.js","names":["BehaviorSubject","connectable","map","additionalContext","Query","AGGREGATE_IDX","API_NAME_IDX","RDP_IDX","WHERE_IDX","AggregationQuery","constructor","store","subject","cacheKey","opts","process","env","NODE_ENV","client","logger","child","msgPrefix","otherKeys","x","JSON","stringify","join","undefined","apiName","canonicalWhere","rdpConfig","canonicalAggregate","_createConnectable","pipe","status","result","value","lastUpdated","error","Error","connector","_fetchAndStore","methodName","debug","_fetchAggregation","batch","writeToStore","err","data","write","changes","modified","add","read","invalidateObjectType","objectType","revalidate","Promise","resolve"],"sources":["AggregationQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateOpts,\n AggregationsResults,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n WhereClause,\n} from \"@osdk/api\";\nimport type { Connectable, Observable, Subject } from \"rxjs\";\nimport { BehaviorSubject, connectable, map } from \"rxjs\";\nimport { additionalContext } from \"../../../Client.js\";\nimport type {\n CommonObserveOptions,\n Status,\n} from \"../../ObservableClient/common.js\";\nimport type { BatchContext } from \"../BatchContext.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { Changes } from \"../Changes.js\";\nimport type { Entry } from \"../Layer.js\";\nimport { Query } from \"../Query.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport type { Store } from \"../Store.js\";\nimport type { SubjectPayload } from \"../SubjectPayload.js\";\nimport {\n AGGREGATE_IDX,\n type AggregationCacheKey,\n API_NAME_IDX,\n RDP_IDX,\n WHERE_IDX,\n} from \"./AggregationCacheKey.js\";\n\nexport interface AggregationPayload<\n Q extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<Q>,\n> {\n result: AggregationsResults<Q, A> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\nexport interface AggregationQueryOptions<\n Q extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<Q>,\n> extends CommonObserveOptions {\n type: Q;\n where?: WhereClause<Q, Record<string, any>>;\n withProperties?: DerivedProperty.Clause<Q>;\n aggregate: A;\n}\n\nexport interface AggregationPayloadBase {\n result:\n | AggregationsResults<\n ObjectOrInterfaceDefinition,\n AggregateOpts<ObjectOrInterfaceDefinition>\n >\n | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\nexport abstract class AggregationQuery extends Query<\n AggregationCacheKey,\n AggregationPayloadBase,\n CommonObserveOptions\n> {\n protected apiName: string;\n protected canonicalWhere: Canonical<SimpleWhereClause>;\n protected canonicalAggregate: Canonical<\n AggregateOpts<ObjectOrInterfaceDefinition>\n >;\n protected rdpConfig: Canonical<Rdp> | undefined;\n\n constructor(\n store: Store,\n subject: Subject<SubjectPayload<AggregationCacheKey>>,\n cacheKey: AggregationCacheKey,\n opts: CommonObserveOptions,\n ) {\n super(\n store,\n subject,\n opts,\n cacheKey,\n process.env.NODE_ENV !== \"production\"\n ? (\n store.client[additionalContext].logger?.child({}, {\n msgPrefix: `AggregationQuery<${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`,\n })\n )\n : undefined,\n );\n this.apiName = cacheKey.otherKeys[API_NAME_IDX];\n this.canonicalWhere = cacheKey.otherKeys[WHERE_IDX];\n this.rdpConfig = cacheKey.otherKeys[RDP_IDX];\n this.canonicalAggregate = cacheKey.otherKeys[AGGREGATE_IDX];\n }\n\n protected _createConnectable(\n subject: Observable<SubjectPayload<AggregationCacheKey>>,\n ): Connectable<AggregationPayloadBase> {\n return connectable<AggregationPayloadBase>(\n subject.pipe(\n map((x) => {\n return {\n status: x.status,\n result: x.value,\n lastUpdated: x.lastUpdated,\n error: x.status === \"error\"\n ? new Error(\"Aggregation failed\")\n : undefined,\n };\n }),\n ),\n {\n connector: () =>\n new BehaviorSubject<AggregationPayloadBase>({\n status: \"init\",\n result: undefined,\n lastUpdated: 0,\n }),\n },\n );\n }\n\n async _fetchAndStore(): Promise<void> {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"_fetchAndStore\" }).debug(\n \"calling _fetchAndStore\",\n );\n }\n\n try {\n const result = await this._fetchAggregation();\n\n this.store.batch({}, (batch) => {\n this.writeToStore(result, \"loaded\", batch);\n });\n } catch (err) {\n this.store.batch({}, (batch) => {\n this.writeToStore(undefined, \"error\", batch);\n });\n }\n }\n\n protected abstract _fetchAggregation(): Promise<\n AggregationCacheKey[\"__cacheKey\"][\"value\"]\n >;\n\n writeToStore(\n data: AggregationCacheKey[\"__cacheKey\"][\"value\"],\n status: Status,\n batch: BatchContext,\n ): Entry<AggregationCacheKey> {\n batch.write(this.cacheKey, data, status);\n batch.changes.modified.add(this.cacheKey);\n return batch.read(this.cacheKey)!;\n }\n\n invalidateObjectType = (\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void> => {\n if (this.apiName === objectType) {\n changes?.modified.add(this.cacheKey);\n return this.revalidate(true);\n }\n return Promise.resolve();\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,eAAe,EAAEC,WAAW,EAAEC,GAAG,QAAQ,MAAM;AACxD,SAASC,iBAAiB,QAAQ,oBAAoB;AAStD,SAASC,KAAK,QAAQ,aAAa;AAKnC,SACEC,aAAa,EAEbC,YAAY,EACZ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EAAE;MAC/BL,OAAO,EAAEC,QAAQ,CAACC,GAAG,CAAC,IAAI,CAACvC,QAAQ,CAAC;MACpC,OAAO,IAAI,CAAC2C,UAAU,CAAC,IAAI,CAAC;IAC9B;IACA,OAAOC,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"AggregationQuery.js","names":["BehaviorSubject","connectable","map","additionalContext","getObjectTypesThatInvalidate","Query","AGGREGATE_IDX","API_NAME_IDX","RDP_IDX","WHERE_IDX","WIRE_OBJECT_SET_IDX","AggregationQuery","invalidationTypes","invalidationTypesPromise","constructor","store","subject","cacheKey","opts","process","env","NODE_ENV","client","logger","child","msgPrefix","otherKeys","x","JSON","stringify","join","undefined","apiName","canonicalWhere","rdpConfig","canonicalAggregate","serializedObjectSet","Set","parsedWireObjectSet","parse","computeInvalidationTypes","#computeInvalidationTypes","wireObjectSet","invalidationSet","error","ensureInvalidationTypesReady","_createConnectable","pipe","status","result","value","lastUpdated","Error","connector","_fetchAndStore","methodName","debug","_fetchAggregation","batch","writeToStore","err","data","write","changes","modified","add","read","invalidateObjectType","objectType","has","revalidate","Promise","resolve"],"sources":["AggregationQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateOpts,\n AggregationsResults,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObjectSet as WireObjectSet } from \"@osdk/foundry.ontologies\";\nimport type { Connectable, Observable, Subject } from \"rxjs\";\nimport { BehaviorSubject, connectable, map } from \"rxjs\";\nimport { additionalContext } from \"../../../Client.js\";\nimport type {\n CommonObserveOptions,\n Status,\n} from \"../../ObservableClient/common.js\";\nimport type { BatchContext } from \"../BatchContext.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { Changes } from \"../Changes.js\";\nimport { getObjectTypesThatInvalidate } from \"../getObjectTypesThatInvalidate.js\";\nimport type { Entry } from \"../Layer.js\";\nimport { Query } from \"../Query.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport type { Store } from \"../Store.js\";\nimport type { SubjectPayload } from \"../SubjectPayload.js\";\nimport {\n AGGREGATE_IDX,\n type AggregationCacheKey,\n API_NAME_IDX,\n RDP_IDX,\n WHERE_IDX,\n WIRE_OBJECT_SET_IDX,\n} from \"./AggregationCacheKey.js\";\n\nexport interface AggregationPayload<\n Q extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<Q>,\n> {\n result: AggregationsResults<Q, A> | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\nexport interface AggregationQueryOptions<\n Q extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<Q>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> extends CommonObserveOptions {\n type: Q;\n where?: WhereClause<Q, RDPs>;\n withProperties?: DerivedProperty.Clause<Q>;\n aggregate: A;\n}\n\nexport interface AggregationPayloadBase {\n result:\n | AggregationsResults<\n ObjectOrInterfaceDefinition,\n AggregateOpts<ObjectOrInterfaceDefinition>\n >\n | undefined;\n status: Status;\n lastUpdated: number;\n error?: Error;\n}\n\nexport abstract class AggregationQuery extends Query<\n AggregationCacheKey,\n AggregationPayloadBase,\n CommonObserveOptions\n> {\n protected apiName: string;\n protected canonicalWhere: Canonical<SimpleWhereClause>;\n protected canonicalAggregate: Canonical<\n AggregateOpts<ObjectOrInterfaceDefinition>\n >;\n protected rdpConfig: Canonical<Rdp> | undefined;\n protected parsedWireObjectSet: WireObjectSet | undefined;\n #invalidationTypes: Set<string>;\n #invalidationTypesPromise: Promise<Set<string>> | undefined;\n\n constructor(\n store: Store,\n subject: Subject<SubjectPayload<AggregationCacheKey>>,\n cacheKey: AggregationCacheKey,\n opts: CommonObserveOptions,\n ) {\n super(\n store,\n subject,\n opts,\n cacheKey,\n process.env.NODE_ENV !== \"production\"\n ? (\n store.client[additionalContext].logger?.child({}, {\n msgPrefix: `AggregationQuery<${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`,\n })\n )\n : undefined,\n );\n this.apiName = cacheKey.otherKeys[API_NAME_IDX];\n this.canonicalWhere = cacheKey.otherKeys[WHERE_IDX];\n this.rdpConfig = cacheKey.otherKeys[RDP_IDX];\n this.canonicalAggregate = cacheKey.otherKeys[AGGREGATE_IDX];\n\n const serializedObjectSet = cacheKey.otherKeys[WIRE_OBJECT_SET_IDX];\n this.#invalidationTypes = new Set([this.apiName]);\n if (serializedObjectSet) {\n this.parsedWireObjectSet = JSON.parse(\n serializedObjectSet,\n ) as WireObjectSet;\n this.#invalidationTypesPromise = this.#computeInvalidationTypes(\n this.parsedWireObjectSet,\n );\n }\n }\n\n async #computeInvalidationTypes(\n wireObjectSet: WireObjectSet,\n ): Promise<Set<string>> {\n try {\n const { invalidationSet } = await getObjectTypesThatInvalidate(\n this.store.client[additionalContext],\n wireObjectSet,\n );\n return new Set([this.apiName, ...invalidationSet]);\n } catch (error) {\n this.store.logger?.error(\n \"Failed to compute invalidation types for aggregation, falling back to base type only\",\n error,\n );\n return new Set([this.apiName]);\n }\n }\n\n async ensureInvalidationTypesReady(): Promise<void> {\n if (this.#invalidationTypesPromise) {\n this.#invalidationTypes = await this.#invalidationTypesPromise;\n this.#invalidationTypesPromise = undefined;\n }\n }\n\n protected _createConnectable(\n subject: Observable<SubjectPayload<AggregationCacheKey>>,\n ): Connectable<AggregationPayloadBase> {\n return connectable<AggregationPayloadBase>(\n subject.pipe(\n map((x) => {\n return {\n status: x.status,\n result: x.value,\n lastUpdated: x.lastUpdated,\n error: x.status === \"error\"\n ? new Error(\"Aggregation failed\")\n : undefined,\n };\n }),\n ),\n {\n connector: () =>\n new BehaviorSubject<AggregationPayloadBase>({\n status: \"init\",\n result: undefined,\n lastUpdated: 0,\n }),\n },\n );\n }\n\n async _fetchAndStore(): Promise<void> {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"_fetchAndStore\" }).debug(\n \"calling _fetchAndStore\",\n );\n }\n\n try {\n const result = await this._fetchAggregation();\n\n this.store.batch({}, (batch) => {\n this.writeToStore(result, \"loaded\", batch);\n });\n } catch (err) {\n this.store.batch({}, (batch) => {\n this.writeToStore(undefined, \"error\", batch);\n });\n }\n }\n\n protected abstract _fetchAggregation(): Promise<\n AggregationCacheKey[\"__cacheKey\"][\"value\"]\n >;\n\n writeToStore(\n data: AggregationCacheKey[\"__cacheKey\"][\"value\"],\n status: Status,\n batch: BatchContext,\n ): Entry<AggregationCacheKey> {\n batch.write(this.cacheKey, data, status);\n batch.changes.modified.add(this.cacheKey);\n return batch.read(this.cacheKey)!;\n }\n\n invalidateObjectType = (\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void> => {\n if (this.#invalidationTypes.has(objectType)) {\n changes?.modified.add(this.cacheKey);\n return this.revalidate(true);\n }\n return Promise.resolve();\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,eAAe,EAAEC,WAAW,EAAEC,GAAG,QAAQ,MAAM;AACxD,SAASC,iBAAiB,QAAQ,oBAAoB;AAQtD,SAASC,4BAA4B,QAAQ,oCAAoC;AAEjF,SAASC,KAAK,QAAQ,aAAa;AAKnC,SACEC,aAAa,EAEbC,YAAY,EACZC,OAAO,EACPC,SAAS,EACTC,mBAAmB,QACd,0BAA0B;AAmCjC,OAAO,MAAeC,gBAAgB,SAASN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,CAACC,OAAO,CAAC,CAAC;EAC1B,CAAC;AACH","ignoreList":[]}
@@ -14,22 +14,37 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ import { getWireObjectSet } from "../../../objectSet/createObjectSet.js";
17
18
  import { AbstractHelper } from "../AbstractHelper.js";
18
19
  import { ObjectAggregationQuery } from "./ObjectAggregationQuery.js";
19
20
  export class AggregationsHelper extends AbstractHelper {
20
- constructor(store, cacheKeys, whereCanonicalizer, rdpCanonicalizer) {
21
+ constructor(store, cacheKeys, whereCanonicalizer, rdpCanonicalizer, intersectCanonicalizer) {
21
22
  super(store, cacheKeys);
22
23
  this.whereCanonicalizer = whereCanonicalizer;
23
24
  this.rdpCanonicalizer = rdpCanonicalizer;
25
+ this.intersectCanonicalizer = intersectCanonicalizer;
24
26
  }
25
27
  observe(options, subFn) {
26
28
  return super.observe(options, subFn);
27
29
  }
30
+ async observeAsync(options, subFn) {
31
+ const query = this.getQueryWithObjectSet(options);
32
+ await query.ensureInvalidationTypesReady();
33
+ return this._subscribe(query, options, subFn);
34
+ }
28
35
  getQuery(options) {
36
+ return this.getOrCreateQuery(options, undefined);
37
+ }
38
+ getQueryWithObjectSet(options) {
39
+ const serializedObjectSet = JSON.stringify(getWireObjectSet(options.objectSet));
40
+ return this.getOrCreateQuery(options, serializedObjectSet);
41
+ }
42
+ getOrCreateQuery(options, serializedObjectSet) {
29
43
  const {
30
44
  type,
31
45
  where,
32
46
  withProperties,
47
+ intersectWith,
33
48
  aggregate
34
49
  } = options;
35
50
  const {
@@ -38,8 +53,9 @@ export class AggregationsHelper extends AbstractHelper {
38
53
  const typeKind = "type" in type ? type.type : "interface";
39
54
  const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
40
55
  const canonRdp = withProperties ? this.rdpCanonicalizer.canonicalize(withProperties) : undefined;
56
+ const canonIntersect = intersectWith && intersectWith.length > 0 ? this.intersectCanonicalizer.canonicalize(intersectWith) : undefined;
41
57
  const canonAggregate = this.canonicalizeAggregate(aggregate);
42
- const aggregationCacheKey = this.cacheKeys.get("aggregation", typeKind, apiName, canonWhere, canonRdp, canonAggregate);
58
+ const aggregationCacheKey = this.cacheKeys.get("aggregation", typeKind, apiName, serializedObjectSet, canonWhere, canonRdp, canonIntersect, canonAggregate);
43
59
  return this.store.queries.get(aggregationCacheKey, () => {
44
60
  if (typeKind !== "object") {
45
61
  throw new Error("Only ObjectTypeDefinition is currently supported for aggregations");
@@ -1 +1 @@
1
- {"version":3,"file":"AggregationsHelper.js","names":["AbstractHelper","ObjectAggregationQuery","AggregationsHelper","constructor","store","cacheKeys","whereCanonicalizer","rdpCanonicalizer","observe","options","subFn","getQuery","type","where","withProperties","aggregate","apiName","typeKind","canonWhere","canonicalize","canonRdp","undefined","canonAggregate","canonicalizeAggregate","aggregationCacheKey","get","queries","Error","subjects","JSON","parse","stringify"],"sources":["AggregationsHelper.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateOpts,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { Observer } from \"../../ObservableClient/common.js\";\nimport { AbstractHelper } from \"../AbstractHelper.js\";\nimport type { CacheKeys } from \"../CacheKeys.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { KnownCacheKey } from \"../KnownCacheKey.js\";\nimport type { QuerySubscription } from \"../QuerySubscription.js\";\nimport type { RdpCanonicalizer } from \"../RdpCanonicalizer.js\";\nimport type { Store } from \"../Store.js\";\nimport type { WhereClauseCanonicalizer } from \"../WhereClauseCanonicalizer.js\";\nimport type { AggregationCacheKey } from \"./AggregationCacheKey.js\";\nimport type {\n AggregationPayloadBase,\n AggregationQuery,\n} from \"./AggregationQuery.js\";\nimport { ObjectAggregationQuery } from \"./ObjectAggregationQuery.js\";\n\nexport interface ObserveAggregationOptions<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n type: T;\n where?: WhereClause<T, RDPs>;\n withProperties?: DerivedProperty.Clause<T>;\n aggregate: A;\n dedupeInterval?: number;\n}\n\nexport class AggregationsHelper extends AbstractHelper<\n AggregationQuery,\n ObserveAggregationOptions<\n ObjectOrInterfaceDefinition,\n AggregateOpts<ObjectOrInterfaceDefinition>\n >\n> {\n whereCanonicalizer: WhereClauseCanonicalizer;\n rdpCanonicalizer: RdpCanonicalizer;\n\n constructor(\n store: Store,\n cacheKeys: CacheKeys<KnownCacheKey>,\n whereCanonicalizer: WhereClauseCanonicalizer,\n rdpCanonicalizer: RdpCanonicalizer,\n ) {\n super(store, cacheKeys);\n\n this.whereCanonicalizer = whereCanonicalizer;\n this.rdpCanonicalizer = rdpCanonicalizer;\n }\n\n observe<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptions<T, A, RDPs>,\n subFn: Observer<AggregationPayloadBase>,\n ): QuerySubscription<AggregationQuery> {\n return super.observe(options, subFn);\n }\n\n getQuery<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptions<T, A, RDPs>,\n ): AggregationQuery {\n const { type, where, withProperties, aggregate } = options;\n const { apiName } = type;\n const typeKind = \"type\" in type ? type.type : \"interface\";\n\n const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});\n const canonRdp = withProperties\n ? this.rdpCanonicalizer.canonicalize(withProperties)\n : undefined;\n\n const canonAggregate = this.canonicalizeAggregate(aggregate);\n\n const aggregationCacheKey = this.cacheKeys.get<AggregationCacheKey>(\n \"aggregation\",\n typeKind,\n apiName,\n canonWhere,\n canonRdp,\n canonAggregate,\n );\n\n return this.store.queries.get(aggregationCacheKey, () => {\n if (typeKind !== \"object\") {\n throw new Error(\n \"Only ObjectTypeDefinition is currently supported for aggregations\",\n );\n }\n return new ObjectAggregationQuery(\n this.store,\n this.store.subjects.get(aggregationCacheKey),\n aggregationCacheKey,\n options,\n );\n });\n }\n\n private canonicalizeAggregate<A extends AggregateOpts<any>>(\n aggregate: A,\n ): Canonical<A> {\n return JSON.parse(JSON.stringify(aggregate)) as Canonical<A>;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,cAAc,QAAQ,sBAAsB;AAarD,SAASC,sBAAsB,QAAQ,6BAA6B;AAcpE,OAAO,MAAMC,kBAAkB,SAASF,cAAc,CAMpD;EAIAG,WAAWA,CACTC,KAAY,EACZC,SAAmC,EACnCC,kBAA4C,EAC5CC,gBAAkC,EAClC;IACA,KAAK,CAACH,KAAK,EAAEC,SAAS,CAAC;IAEvB,IAAI,CAACC,kBAAkB,GAAGA,kBAAkB;IAC5C,IAAI,CAACC,gBAAgB,GAAGA,gBAAgB;EAC1C;EAEAC,OAAOA,CAKLC,OAA8C,EAC9CC,KAAuC,EACF;IACrC,OAAO,KAAK,CAACF,OAAO,CAACC,OAAO,EAAEC,KAAK,CAAC;EACtC;EAEAC,QAAQA,CAKNF,OAA8C,EAC5B;IAClB,MAAM;MAAEG,IAAI;MAAEC,KAAK;MAAEC,cAAc;MAAEC;IAAU,CAAC,GAAGN,OAAO;IAC1D,MAAM;MAAEO;IAAQ,CAAC,GAAGJ,IAAI;IACxB,MAAMK,QAAQ,GAAG,MAAM,IAAIL,IAAI,GAAGA,IAAI,CAACA,IAAI,GAAG,WAAW;IAEzD,MAAMM,UAAU,GAAG,IAAI,CAACZ,kBAAkB,CAACa,YAAY,CAACN,KAAK,IAAI,CAAC,CAAC,CAAC;IACpE,MAAMO,QAAQ,GAAGN,cAAc,GAC3B,IAAI,CAACP,gBAAgB,CAACY,YAAY,CAACL,cAAc,CAAC,GAClDO,SAAS;IAEb,MAAMC,cAAc,GAAG,IAAI,CAACC,qBAAqB,CAACR,SAAS,CAAC;IAE5D,MAAMS,mBAAmB,GAAG,IAAI,CAACnB,SAAS,CAACoB,GAAG,CAC5C,aAAa,EACbR,QAAQ,EACRD,OAAO,EACPE,UAAU,EACVE,QAAQ,EACRE,cACF,CAAC;IAED,OAAO,IAAI,CAAClB,KAAK,CAACsB,OAAO,CAACD,GAAG,CAACD,mBAAmB,EAAE,MAAM;MACvD,IAAIP,QAAQ,KAAK,QAAQ,EAAE;QACzB,MAAM,IAAIU,KAAK,CACb,mEACF,CAAC;MACH;MACA,OAAO,IAAI1B,sBAAsB,CAC/B,IAAI,CAACG,KAAK,EACV,IAAI,CAACA,KAAK,CAACwB,QAAQ,CAACH,GAAG,CAACD,mBAAmB,CAAC,EAC5CA,mBAAmB,EACnBf,OACF,CAAC;IACH,CAAC,CAAC;EACJ;EAEQc,qBAAqBA,CAC3BR,SAAY,EACE;IACd,OAAOc,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAAChB,SAAS,CAAC,CAAC;EAC9C;AACF","ignoreList":[]}
1
+ {"version":3,"file":"AggregationsHelper.js","names":["getWireObjectSet","AbstractHelper","ObjectAggregationQuery","AggregationsHelper","constructor","store","cacheKeys","whereCanonicalizer","rdpCanonicalizer","intersectCanonicalizer","observe","options","subFn","observeAsync","query","getQueryWithObjectSet","ensureInvalidationTypesReady","_subscribe","getQuery","getOrCreateQuery","undefined","serializedObjectSet","JSON","stringify","objectSet","type","where","withProperties","intersectWith","aggregate","apiName","typeKind","canonWhere","canonicalize","canonRdp","canonIntersect","length","canonAggregate","canonicalizeAggregate","aggregationCacheKey","get","queries","Error","subjects","parse"],"sources":["AggregationsHelper.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n AggregateOpts,\n ObjectOrInterfaceDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { getWireObjectSet } from \"../../../objectSet/createObjectSet.js\";\nimport type {\n ObserveAggregationOptions,\n ObserveAggregationOptionsWithObjectSet,\n} from \"../../ObservableClient.js\";\nimport type { Observer } from \"../../ObservableClient/common.js\";\nimport { AbstractHelper } from \"../AbstractHelper.js\";\nimport type { CacheKeys } from \"../CacheKeys.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { IntersectCanonicalizer } from \"../IntersectCanonicalizer.js\";\nimport type { KnownCacheKey } from \"../KnownCacheKey.js\";\nimport type { QuerySubscription } from \"../QuerySubscription.js\";\nimport type { RdpCanonicalizer } from \"../RdpCanonicalizer.js\";\nimport type { Store } from \"../Store.js\";\nimport type { WhereClauseCanonicalizer } from \"../WhereClauseCanonicalizer.js\";\nimport type { AggregationCacheKey } from \"./AggregationCacheKey.js\";\nimport type {\n AggregationPayloadBase,\n AggregationQuery,\n} from \"./AggregationQuery.js\";\nimport { ObjectAggregationQuery } from \"./ObjectAggregationQuery.js\";\n\ntype AggregationOptions =\n | ObserveAggregationOptions<\n ObjectOrInterfaceDefinition,\n AggregateOpts<ObjectOrInterfaceDefinition>\n >\n | ObserveAggregationOptionsWithObjectSet<\n ObjectOrInterfaceDefinition,\n AggregateOpts<ObjectOrInterfaceDefinition>\n >;\n\nexport class AggregationsHelper extends AbstractHelper<\n AggregationQuery,\n AggregationOptions\n> {\n whereCanonicalizer: WhereClauseCanonicalizer;\n rdpCanonicalizer: RdpCanonicalizer;\n intersectCanonicalizer: IntersectCanonicalizer;\n\n constructor(\n store: Store,\n cacheKeys: CacheKeys<KnownCacheKey>,\n whereCanonicalizer: WhereClauseCanonicalizer,\n rdpCanonicalizer: RdpCanonicalizer,\n intersectCanonicalizer: IntersectCanonicalizer,\n ) {\n super(store, cacheKeys);\n\n this.whereCanonicalizer = whereCanonicalizer;\n this.rdpCanonicalizer = rdpCanonicalizer;\n this.intersectCanonicalizer = intersectCanonicalizer;\n }\n\n observe<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptions<T, A, RDPs>,\n subFn: Observer<AggregationPayloadBase>,\n ): QuerySubscription<AggregationQuery> {\n return super.observe(options, subFn);\n }\n\n async observeAsync<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptionsWithObjectSet<T, A, RDPs>,\n subFn: Observer<AggregationPayloadBase>,\n ): Promise<QuerySubscription<AggregationQuery>> {\n const query = this.getQueryWithObjectSet(options);\n await query.ensureInvalidationTypesReady();\n return this._subscribe(\n query,\n options as AggregationOptions,\n subFn,\n );\n }\n\n getQuery<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptions<T, A, RDPs>,\n ): AggregationQuery {\n return this.getOrCreateQuery(options as AggregationOptions, undefined);\n }\n\n getQueryWithObjectSet<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n RDPs extends Record<string, SimplePropertyDef> = {},\n >(\n options: ObserveAggregationOptionsWithObjectSet<T, A, RDPs>,\n ): AggregationQuery {\n const serializedObjectSet = JSON.stringify(\n getWireObjectSet(options.objectSet),\n );\n return this.getOrCreateQuery(\n options as AggregationOptions,\n serializedObjectSet,\n );\n }\n\n private getOrCreateQuery(\n options: AggregationOptions,\n serializedObjectSet: string | undefined,\n ): AggregationQuery {\n const { type, where, withProperties, intersectWith, aggregate } = options;\n const { apiName } = type;\n const typeKind = \"type\" in type ? type.type : \"interface\";\n\n const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});\n const canonRdp = withProperties\n ? this.rdpCanonicalizer.canonicalize(withProperties)\n : undefined;\n const canonIntersect = intersectWith && intersectWith.length > 0\n ? this.intersectCanonicalizer.canonicalize(intersectWith)\n : undefined;\n\n const canonAggregate = this.canonicalizeAggregate(aggregate);\n\n const aggregationCacheKey = this.cacheKeys.get<AggregationCacheKey>(\n \"aggregation\",\n typeKind,\n apiName,\n serializedObjectSet,\n canonWhere,\n canonRdp,\n canonIntersect,\n canonAggregate,\n );\n\n return this.store.queries.get(aggregationCacheKey, () => {\n if (typeKind !== \"object\") {\n throw new Error(\n \"Only ObjectTypeDefinition is currently supported for aggregations\",\n );\n }\n return new ObjectAggregationQuery(\n this.store,\n this.store.subjects.get(aggregationCacheKey),\n aggregationCacheKey,\n options,\n );\n });\n }\n\n private canonicalizeAggregate<\n T extends ObjectOrInterfaceDefinition,\n A extends AggregateOpts<T>,\n >(\n aggregate: A,\n ): Canonical<A> {\n return JSON.parse(JSON.stringify(aggregate)) as Canonical<A>;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,gBAAgB,QAAQ,uCAAuC;AAMxE,SAASC,cAAc,QAAQ,sBAAsB;AAcrD,SAASC,sBAAsB,QAAQ,6BAA6B;AAYpE,OAAO,MAAMC,kBAAkB,SAASF,cAAc,CAGpD;EAKAG,WAAWA,CACTC,KAAY,EACZC,SAAmC,EACnCC,kBAA4C,EAC5CC,gBAAkC,EAClCC,sBAA8C,EAC9C;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CAAC;IACpE,MAAMQ,QAAQ,GAAGP,cAAc,GAC3B,IAAI,CAACnB,gBAAgB,CAACyB,YAAY,CAACN,cAAc,CAAC,GAClDP,SAAS;IACb,MAAMe,cAAc,GAAGP,aAAa,IAAIA,aAAa,CAACQ,MAAM,GAAG,CAAC,GAC5D,IAAI,CAAC3B,sBAAsB,CAACwB,YAAY,CAACL,aAAa,CAAC,GACvDR,SAAS;IAEb,MAAMiB,cAAc,GAAG,IAAI,CAACC,qBAAqB,CAACT,SAAS,CAAC;IAE5D,MAAMU,mBAAmB,GAAG,IAAI,CAACjC,SAAS,CAACkC,GAAG,CAC5C,aAAa,EACbT,QAAQ,EACRD,OAAO,EACPT,mBAAmB,EACnBW,UAAU,EACVE,QAAQ,EACRC,cAAc,EACdE,cACF,CAAC;IAED,OAAO,IAAI,CAAChC,KAAK,CAACoC,OAAO,CAACD,GAAG,CAACD,mBAAmB,EAAE,MAAM;MACvD,IAAIR,QAAQ,KAAK,QAAQ,EAAE;QACzB,MAAM,IAAIW,KAAK,CACb,mEACF,CAAC;MACH;MACA,OAAO,IAAIxC,sBAAsB,CAC/B,IAAI,CAACG,KAAK,EACV,IAAI,CAACA,KAAK,CAACsC,QAAQ,CAACH,GAAG,CAACD,mBAAmB,CAAC,EAC5CA,mBAAmB,EACnB5B,OACF,CAAC;IACH,CAAC,CAAC;EACJ;EAEQ2B,qBAAqBA,CAI3BT,SAAY,EACE;IACd,OAAOP,IAAI,CAACsB,KAAK,CAACtB,IAAI,CAACC,SAAS,CAACM,SAAS,CAAC,CAAC;EAC9C;AACF","ignoreList":[]}
@@ -0,0 +1,103 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Employee, Office } from "@osdk/client.test.ontology";
18
+ import { FauxFoundry, ontologies, startNodeApiServer } from "@osdk/shared.test";
19
+ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
20
+ import { createClient } from "../../../createClient.js";
21
+ import { TestLogger } from "../../../logger/TestLogger.js";
22
+ import { getWireObjectSet } from "../../../objectSet/createObjectSet.js";
23
+ import { Store } from "../Store.js";
24
+ import { WIRE_OBJECT_SET_IDX } from "./AggregationCacheKey.js";
25
+ const logger = new TestLogger({}, {
26
+ level: "debug"
27
+ });
28
+ function setupOntology(fauxFoundry) {
29
+ const fauxOntology = fauxFoundry.getDefaultOntology();
30
+ ontologies.addEmployeeOntology(fauxOntology);
31
+ }
32
+ describe("aggregation ObjectSet support", () => {
33
+ let client;
34
+ let apiServer;
35
+ let fauxFoundry;
36
+ let store;
37
+ beforeAll(() => {
38
+ const testSetup = startNodeApiServer(new FauxFoundry("https://stack.palantir.com/", undefined, {
39
+ logger
40
+ }), createClient, {
41
+ logger
42
+ });
43
+ ({
44
+ client,
45
+ apiServer,
46
+ fauxFoundry
47
+ } = testSetup);
48
+ setupOntology(fauxFoundry);
49
+ return () => {
50
+ testSetup.apiServer.close();
51
+ };
52
+ });
53
+ beforeEach(() => {
54
+ apiServer.resetHandlers();
55
+ store = new Store(client);
56
+ });
57
+ it("includes wireObjectSet in cache key when provided", () => {
58
+ const pivotedSet = client(Employee).pivotTo("officeLink");
59
+ const query = store.aggregations.getQueryWithObjectSet({
60
+ type: Office,
61
+ objectSet: pivotedSet,
62
+ where: {},
63
+ aggregate: {
64
+ $select: {
65
+ $count: "unordered"
66
+ }
67
+ }
68
+ });
69
+ expect(query.cacheKey.otherKeys[WIRE_OBJECT_SET_IDX]).toEqual(JSON.stringify(getWireObjectSet(pivotedSet)));
70
+ });
71
+ it("invalidates pivoted aggregations on source type invalidation", async () => {
72
+ const pivotedSet = client(Employee).pivotTo("officeLink");
73
+ const query = store.aggregations.getQueryWithObjectSet({
74
+ type: Office,
75
+ objectSet: pivotedSet,
76
+ where: {},
77
+ aggregate: {
78
+ $select: {
79
+ $count: "unordered"
80
+ }
81
+ }
82
+ });
83
+ await query.ensureInvalidationTypesReady();
84
+ const revalidateSpy = vi.spyOn(query, "revalidate").mockResolvedValue(undefined);
85
+ await query.invalidateObjectType("Employee", undefined);
86
+ expect(revalidateSpy).toHaveBeenCalledWith(true);
87
+ });
88
+ it("does not invalidate base aggregations on unrelated types", async () => {
89
+ const query = store.aggregations.getQuery({
90
+ type: Office,
91
+ where: {},
92
+ aggregate: {
93
+ $select: {
94
+ $count: "unordered"
95
+ }
96
+ }
97
+ });
98
+ const revalidateSpy = vi.spyOn(query, "revalidate").mockResolvedValue(undefined);
99
+ await query.invalidateObjectType("Employee", undefined);
100
+ expect(revalidateSpy).not.toHaveBeenCalled();
101
+ });
102
+ });
103
+ //# sourceMappingURL=AggregationsHelper.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AggregationsHelper.test.js","names":["Employee","Office","FauxFoundry","ontologies","startNodeApiServer","beforeAll","beforeEach","describe","expect","it","vi","createClient","TestLogger","getWireObjectSet","Store","WIRE_OBJECT_SET_IDX","logger","level","setupOntology","fauxFoundry","fauxOntology","getDefaultOntology","addEmployeeOntology","client","apiServer","store","testSetup","undefined","close","resetHandlers","pivotedSet","pivotTo","query","aggregations","getQueryWithObjectSet","type","objectSet","where","aggregate","$select","$count","cacheKey","otherKeys","toEqual","JSON","stringify","ensureInvalidationTypesReady","revalidateSpy","spyOn","mockResolvedValue","invalidateObjectType","toHaveBeenCalledWith","getQuery","not","toHaveBeenCalled"],"sources":["AggregationsHelper.test.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Employee, Office } from \"@osdk/client.test.ontology\";\nimport type { SetupServer } from \"@osdk/shared.test\";\nimport { FauxFoundry, ontologies, startNodeApiServer } from \"@osdk/shared.test\";\nimport { beforeAll, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport type { Client } from \"../../../Client.js\";\nimport { createClient } from \"../../../createClient.js\";\nimport { TestLogger } from \"../../../logger/TestLogger.js\";\nimport { getWireObjectSet } from \"../../../objectSet/createObjectSet.js\";\nimport { Store } from \"../Store.js\";\nimport { WIRE_OBJECT_SET_IDX } from \"./AggregationCacheKey.js\";\n\nconst logger = new TestLogger({}, { level: \"debug\" });\n\nfunction setupOntology(fauxFoundry: FauxFoundry) {\n const fauxOntology = fauxFoundry.getDefaultOntology();\n ontologies.addEmployeeOntology(fauxOntology);\n}\n\ndescribe(\"aggregation ObjectSet support\", () => {\n let client: Client;\n let apiServer: SetupServer;\n let fauxFoundry: FauxFoundry;\n let store: Store;\n\n beforeAll(() => {\n const testSetup = startNodeApiServer(\n new FauxFoundry(\"https://stack.palantir.com/\", undefined, { logger }),\n createClient,\n { logger },\n );\n ({ client, apiServer, fauxFoundry } = testSetup);\n setupOntology(fauxFoundry);\n\n return () => {\n testSetup.apiServer.close();\n };\n });\n\n beforeEach(() => {\n apiServer.resetHandlers();\n store = new Store(client);\n });\n\n it(\"includes wireObjectSet in cache key when provided\", () => {\n const pivotedSet = client(Employee).pivotTo(\"officeLink\");\n\n const query = store.aggregations.getQueryWithObjectSet({\n type: Office,\n objectSet: pivotedSet,\n where: {},\n aggregate: { $select: { $count: \"unordered\" } },\n });\n\n expect(query.cacheKey.otherKeys[WIRE_OBJECT_SET_IDX]).toEqual(\n JSON.stringify(getWireObjectSet(pivotedSet)),\n );\n });\n\n it(\"invalidates pivoted aggregations on source type invalidation\", async () => {\n const pivotedSet = client(Employee).pivotTo(\"officeLink\");\n\n const query = store.aggregations.getQueryWithObjectSet({\n type: Office,\n objectSet: pivotedSet,\n where: {},\n aggregate: { $select: { $count: \"unordered\" } },\n });\n\n await query.ensureInvalidationTypesReady();\n\n const revalidateSpy = vi.spyOn(query, \"revalidate\")\n .mockResolvedValue(undefined);\n\n await query.invalidateObjectType(\"Employee\", undefined);\n expect(revalidateSpy).toHaveBeenCalledWith(true);\n });\n\n it(\"does not invalidate base aggregations on unrelated types\", async () => {\n const query = store.aggregations.getQuery({\n type: Office,\n where: {},\n aggregate: { $select: { $count: \"unordered\" } },\n });\n\n const revalidateSpy = vi.spyOn(query, \"revalidate\")\n .mockResolvedValue(undefined);\n\n await query.invalidateObjectType(\"Employee\", undefined);\n expect(revalidateSpy).not.toHaveBeenCalled();\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,MAAM,QAAQ,4BAA4B;AAE7D,SAASC,WAAW,EAAEC,UAAU,EAAEC,kBAAkB,QAAQ,mBAAmB;AAC/E,SAASC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,EAAEC,EAAE,QAAQ,QAAQ;AAExE,SAASC,YAAY,QAAQ,0BAA0B;AACvD,SAASC,UAAU,QAAQ,+BAA+B;AAC1D,SAASC,gBAAgB,QAAQ,uCAAuC;AACxE,SAASC,KAAK,QAAQ,aAAa;AACnC,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,MAAMC,MAAM,GAAG,IAAIJ,UAAU,CAAC,CAAC,CAAC,EAAE;EAAEK,KAAK,EAAE;AAAQ,CAAC,CAAC;AAErD,SAASC,aAAaA,CAACC,WAAwB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Aa,CAAC,CAACM,GAAG,CAACC,gBAAgB,CAAC,CAAC;EAC9C,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -14,19 +14,38 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { API_NAME_IDX } from "./AggregationCacheKey.js";
17
+ import { additionalContext } from "../../../Client.js";
18
+ import { createObjectSet } from "../../../objectSet/createObjectSet.js";
19
+ import { API_NAME_IDX, INTERSECT_IDX } from "./AggregationCacheKey.js";
18
20
  import { AggregationQuery } from "./AggregationQuery.js";
19
21
  export class ObjectAggregationQuery extends AggregationQuery {
20
22
  async _fetchAggregation() {
21
23
  const type = this.cacheKey.otherKeys[API_NAME_IDX];
22
- let objectSet = this.store.client({
24
+ const intersectWith = this.cacheKey.otherKeys[INTERSECT_IDX];
25
+ const objectTypeDef = {
23
26
  type: "object",
24
27
  apiName: type
25
- });
28
+ };
29
+ let objectSet;
30
+ if (this.parsedWireObjectSet) {
31
+ objectSet = createObjectSet(objectTypeDef, this.store.client[additionalContext], this.parsedWireObjectSet);
32
+ } else {
33
+ objectSet = this.store.client(objectTypeDef);
34
+ }
26
35
  if (this.rdpConfig) {
27
36
  objectSet = objectSet.withProperties(this.rdpConfig);
28
37
  }
29
38
  objectSet = objectSet.where(this.canonicalWhere);
39
+ if (intersectWith != null && intersectWith.length > 0) {
40
+ const intersectSets = intersectWith.map(whereClause => {
41
+ let intersectSet = this.store.client(objectTypeDef);
42
+ if (this.rdpConfig) {
43
+ intersectSet = intersectSet.withProperties(this.rdpConfig);
44
+ }
45
+ return intersectSet.where(whereClause);
46
+ });
47
+ objectSet = objectSet.intersect(...intersectSets);
48
+ }
30
49
  return await objectSet.aggregate(this.canonicalAggregate);
31
50
  }
32
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectAggregationQuery.js","names":["API_NAME_IDX","AggregationQuery","ObjectAggregationQuery","_fetchAggregation","type","cacheKey","otherKeys","objectSet","store","client","apiName","rdpConfig","withProperties","where","canonicalWhere","aggregate","canonicalAggregate"],"sources":["ObjectAggregationQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DerivedProperty, ObjectTypeDefinition } from \"@osdk/api\";\nimport {\n type AggregationCacheKey,\n API_NAME_IDX,\n} from \"./AggregationCacheKey.js\";\nimport { AggregationQuery } from \"./AggregationQuery.js\";\n\nexport class ObjectAggregationQuery extends AggregationQuery {\n protected async _fetchAggregation(): Promise<\n AggregationCacheKey[\"__cacheKey\"][\"value\"]\n > {\n const type = this.cacheKey.otherKeys[API_NAME_IDX];\n let objectSet = this.store.client({\n type: \"object\",\n apiName: type,\n } as ObjectTypeDefinition);\n\n if (this.rdpConfig) {\n objectSet = objectSet.withProperties(\n this.rdpConfig as DerivedProperty.Clause<ObjectTypeDefinition>,\n );\n }\n\n objectSet = objectSet.where(this.canonicalWhere);\n\n return await objectSet.aggregate(\n this.canonicalAggregate as Parameters<typeof objectSet.aggregate>[0],\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAEEA,YAAY,QACP,0BAA0B;AACjC,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAO,MAAMC,sBAAsB,SAASD,gBAAgB,CAAC;EAC3D,MAAgBE,iBAAiBA,CAAA,EAE/B;IACA,MAAMC,IAAI,GAAG,IAAI,CAACC,QAAQ,CAACC,SAAS,CAACN,YAAY,CAAC;IAClD,IAAIO,SAAS,GAAG,IAAI,CAACC,KAAK,CAACC,MAAM,CAAC;MAChCL,IAAI,EAAE,QAAQ;MACdM,OAAO,EAAEN;IACX,CAAyB,CAAC;IAE1B,IAAI,IAAI,CAACO,SAAS,EAAE;MAClBJ,SAAS,GAAGA,SAAS,CAACK,cAAc,CAClC,IAAI,CAACD,SACP,CAAC;IACH;IAEAJ,SAAS,GAAGA,SAAS,CAACM,KAAK,CAAC,IAAI,CAACC,cAAc,CAAC;IAEhD,OAAO,MAAMP,SAAS,CAACQ,SAAS,CAC9B,IAAI,CAACC,kBACP,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ObjectAggregationQuery.js","names":["additionalContext","createObjectSet","API_NAME_IDX","INTERSECT_IDX","AggregationQuery","ObjectAggregationQuery","_fetchAggregation","type","cacheKey","otherKeys","intersectWith","objectTypeDef","apiName","objectSet","parsedWireObjectSet","store","client","rdpConfig","withProperties","where","canonicalWhere","length","intersectSets","map","whereClause","intersectSet","intersect","aggregate","canonicalAggregate"],"sources":["ObjectAggregationQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { DerivedProperty, ObjectTypeDefinition } from \"@osdk/api\";\nimport { additionalContext } from \"../../../Client.js\";\nimport { createObjectSet } from \"../../../objectSet/createObjectSet.js\";\nimport {\n type AggregationCacheKey,\n API_NAME_IDX,\n INTERSECT_IDX,\n} from \"./AggregationCacheKey.js\";\nimport { AggregationQuery } from \"./AggregationQuery.js\";\n\nexport class ObjectAggregationQuery extends AggregationQuery {\n protected async _fetchAggregation(): Promise<\n AggregationCacheKey[\"__cacheKey\"][\"value\"]\n > {\n const type = this.cacheKey.otherKeys[API_NAME_IDX];\n const intersectWith = this.cacheKey.otherKeys[INTERSECT_IDX];\n const objectTypeDef = {\n type: \"object\",\n apiName: type,\n } as ObjectTypeDefinition;\n\n let objectSet;\n if (this.parsedWireObjectSet) {\n objectSet = createObjectSet(\n objectTypeDef,\n this.store.client[additionalContext],\n this.parsedWireObjectSet,\n );\n } else {\n objectSet = this.store.client(objectTypeDef);\n }\n\n if (this.rdpConfig) {\n objectSet = objectSet.withProperties(\n this.rdpConfig as DerivedProperty.Clause<ObjectTypeDefinition>,\n );\n }\n\n objectSet = objectSet.where(this.canonicalWhere);\n\n if (intersectWith != null && intersectWith.length > 0) {\n const intersectSets = intersectWith.map(whereClause => {\n let intersectSet = this.store.client(objectTypeDef);\n\n if (this.rdpConfig) {\n intersectSet = intersectSet.withProperties(\n this.rdpConfig as DerivedProperty.Clause<ObjectTypeDefinition>,\n );\n }\n\n return intersectSet.where(whereClause);\n });\n\n objectSet = objectSet.intersect(...intersectSets);\n }\n\n return await objectSet.aggregate(\n this.canonicalAggregate as Parameters<typeof objectSet.aggregate>[0],\n );\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAEEC,YAAY,EACZC,aAAa,QACR,0BAA0B;AACjC,SAASC,gBAAgB,QAAQ,uBAAuB;AAExD,OAAO,MAAMC,sBAAsB,SAASD,gBAAgB,CAAC;EAC3D,MAAgBE,iBAAiBA,CAAA,EAE/B;IACA,MAAMC,IAAI,GAAG,IAAI,CAACC,QAAQ,CAACC,SAAS,CAACP,YAAY,CAAC;IAClD,MAAMQ,aAAa,GAAG,IAAI,CAACF,QAAQ,CAACC,SAAS,CAACN,aAAa,CAAC;IAC5D,MAAMQ,aAAa,GAAG;MACpBJ,IAAI,EAAE,QAAQ;MACdK,OAAO,EAAEL;IACX,CAAyB;IAEzB,IAAIM,SAAS;IACb,IAAI,IAAI,CAACC,mBAAmB,EAAE;MAC5BD,SAAS,GAAGZ,eAAe,CACzBU,aAAa,EACb,IAAI,CAACI,KAAK,CAACC,MAAM,CAAChB,iBAAiB,CAAC,EACpC,IAAI,CAACc,mBACP,CAAC;IACH,CAAC,MAAM;MACLD,SAAS,GAAG,IAAI,CAACE,KAAK,CAACC,MAAM,CAACL,aAAa,CAAC;IAC9C;IAEA,IAAI,IAAI,CAACM,SAAS,EAAE;MAClBJ,SAAS,GAAGA,SAAS,CAACK,cAAc,CAClC,IAAI,CAACD,SACP,CAAC;IACH;IAEAJ,SAAS,GAAGA,SAAS,CAACM,KAAK,CAAC,IAAI,CAACC,cAAc,CAAC;IAEhD,IAAIV,aAAa,IAAI,IAAI,IAAIA,aAAa,CAACW,MAAM,GAAG,CAAC,EAAE;MACrD,MAAMC,aAAa,GAAGZ,aAAa,CAACa,GAAG,CAACC,WAAW,IAAI;QACrD,IAAIC,YAAY,GAAG,IAAI,CAACV,KAAK,CAACC,MAAM,CAACL,aAAa,CAAC;QAEnD,IAAI,IAAI,CAACM,SAAS,EAAE;UAClBQ,YAAY,GAAGA,YAAY,CAACP,cAAc,CACxC,IAAI,CAACD,SACP,CAAC;QACH;QAEA,OAAOQ,YAAY,CAACN,KAAK,CAACK,WAAW,CAAC;MACxC,CAAC,CAAC;MAEFX,SAAS,GAAGA,SAAS,CAACa,SAAS,CAAC,GAAGJ,aAAa,CAAC;IACnD;IAEA,OAAO,MAAMT,SAAS,CAACc,SAAS,CAC9B,IAAI,CAACC,kBACP,CAAC;EACH;AACF","ignoreList":[]}
@@ -23,6 +23,16 @@ import { NoOpSortingStrategy } from "../sorting/SortingStrategy.js";
23
23
  import { createCollectionConnectable } from "./createCollectionConnectable.js";
24
24
  import { removeDuplicates } from "./removeDuplicates.js";
25
25
 
26
+ /**
27
+ * Base shape for list-like payloads (ListPayload, SpecificLinkPayload, etc.)
28
+ * Used to constrain PAYLOAD so we can safely access these properties
29
+ */
30
+
31
+ /**
32
+ * Options that include pageSize for list-like queries.
33
+ * This allows BaseListQuery to access pageSize without type casting.
34
+ */
35
+
26
36
  /**
27
37
  * Base class for collection-based queries (lists and links)
28
38
  * Provides common functionality for working with collections of objects
@@ -52,6 +62,8 @@ export class BaseListQuery extends Query {
52
62
  * @protected
53
63
  */
54
64
 
65
+ #subscriberPageSizes = new Map();
66
+
55
67
  //
56
68
  // Shared Implementations
57
69
  //
@@ -224,11 +236,9 @@ export class BaseListQuery extends Query {
224
236
  return this.pendingPageFetch;
225
237
  }
226
238
  if (this.pendingFetch) {
227
- this.pendingPageFetch = (async () => {
228
- await this.pendingFetch;
229
- await this.fetchMore();
230
- })().finally(() => {
239
+ this.pendingPageFetch = this.pendingFetch.then(() => {
231
240
  this.pendingPageFetch = undefined;
241
+ return this.fetchMore();
232
242
  });
233
243
  return this.pendingPageFetch;
234
244
  }
@@ -244,6 +254,62 @@ export class BaseListQuery extends Query {
244
254
  return this.pendingFetch;
245
255
  };
246
256
 
257
+ /**
258
+ * Register a subscriber's pageSize for fetch optimization.
259
+ * The query will fetch with the max pageSize across all subscribers.
260
+ */
261
+ registerFetchPageSize(viewId, pageSize) {
262
+ this.#subscriberPageSizes.set(viewId, pageSize);
263
+ }
264
+
265
+ /**
266
+ * Unregister a subscriber's pageSize when they unsubscribe.
267
+ * Allows the effective pageSize to decrease when high-pageSize subscribers leave.
268
+ */
269
+ unregisterFetchPageSize(viewId) {
270
+ this.#subscriberPageSizes.delete(viewId);
271
+ }
272
+
273
+ /**
274
+ * Get the effective fetch pageSize (max across all subscribers).
275
+ * Falls back to options.pageSize or 100 if no subscribers have registered.
276
+ */
277
+ getEffectiveFetchPageSize() {
278
+ if (this.#subscriberPageSizes.size > 0) {
279
+ return Math.max(...this.#subscriberPageSizes.values());
280
+ }
281
+ return this.options.pageSize ?? 100;
282
+ }
283
+
284
+ /**
285
+ * Get the current number of loaded items in the cache.
286
+ */
287
+ getLoadedCount() {
288
+ const {
289
+ retVal
290
+ } = this.store.batch({}, batch => {
291
+ return batch.read(this.cacheKey)?.value?.data.length ?? 0;
292
+ });
293
+ return retVal;
294
+ }
295
+
296
+ /**
297
+ * Check if there are more pages available on the server.
298
+ */
299
+ hasMorePages() {
300
+ return this.nextPageToken != null;
301
+ }
302
+
303
+ /**
304
+ * Notify all subscribers of a change (used when view limits change
305
+ * but no new data needs to be fetched).
306
+ */
307
+ notifySubscribers() {
308
+ this.store.batch({}, batch => {
309
+ this.registerCacheChanges(batch);
310
+ });
311
+ }
312
+
247
313
  /**
248
314
  * Minimum number of results to load initially
249
315
  * May be overridden by subclasses for specific collection types
@@ -551,8 +617,9 @@ export class BaseListQuery extends Query {
551
617
  }).debug("Removing object", object);
552
618
  }
553
619
  this.store.batch({}, batch => {
554
- const objectCacheKey = this.store.cacheKeys.get("object", object.$objectType ?? object.$apiName, object.$primaryKey);
555
- batch.delete(objectCacheKey, "loaded");
620
+ for (const objectCacheKey of this.store.objectCacheKeyRegistry.getVariants(object.$objectType ?? object.$apiName, object.$primaryKey)) {
621
+ batch.delete(objectCacheKey, "loaded");
622
+ }
556
623
  });
557
624
  }
558
625
  }