@osdk/client 2.6.0-beta.2 → 2.6.0-beta.4

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 (267) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +2 -1
  3. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  4. package/build/browser/index.js.map +1 -1
  5. package/build/browser/internal/conversions/extractNamespace.js +22 -0
  6. package/build/browser/internal/conversions/extractNamespace.js.map +1 -0
  7. package/build/browser/internal/conversions/fullyQualifyPropName.js +26 -0
  8. package/build/browser/internal/conversions/fullyQualifyPropName.js.map +1 -0
  9. package/build/browser/internal/conversions/makeGeoFilterBbox.js +41 -0
  10. package/build/browser/internal/conversions/makeGeoFilterBbox.js.map +1 -0
  11. package/build/browser/internal/conversions/makeGeoFilterIntersects.js +29 -0
  12. package/build/browser/internal/conversions/makeGeoFilterIntersects.js.map +1 -0
  13. package/build/browser/internal/conversions/makeGeoFilterPolygon.js +30 -0
  14. package/build/browser/internal/conversions/makeGeoFilterPolygon.js.map +1 -0
  15. package/build/browser/internal/conversions/makeGeoFilterWithin.js +48 -0
  16. package/build/browser/internal/conversions/makeGeoFilterWithin.js.map +1 -0
  17. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +30 -99
  18. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  19. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +139 -0
  20. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  21. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +1 -1
  22. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  23. package/build/browser/object/fetchPage.js +1 -1
  24. package/build/browser/object/fetchPage.js.map +1 -1
  25. package/build/browser/object/formatting/applyPropertyFormatter.js +7 -1
  26. package/build/browser/object/formatting/applyPropertyFormatter.js.map +1 -1
  27. package/build/browser/object/formatting/applyPropertyFormatter.test.js +305 -2
  28. package/build/browser/object/formatting/applyPropertyFormatter.test.js.map +1 -1
  29. package/build/browser/object/formatting/formatDateTime.js +158 -0
  30. package/build/browser/object/formatting/formatDateTime.js.map +1 -0
  31. package/build/browser/objectSet/ObjectSetListenerWebsocket.js +17 -0
  32. package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  33. package/build/browser/observable/ObservableClient.js.map +1 -1
  34. package/build/browser/observable/internal/BulkObjectLoader.js +12 -4
  35. package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -1
  36. package/build/browser/observable/internal/BulkObjectLoader.test.js +48 -0
  37. package/build/browser/observable/internal/BulkObjectLoader.test.js.map +1 -1
  38. package/build/browser/observable/internal/CacheKeys.js +9 -3
  39. package/build/browser/observable/internal/CacheKeys.js.map +1 -1
  40. package/build/browser/observable/internal/Canonicalizer.js +51 -0
  41. package/build/browser/observable/internal/Canonicalizer.js.map +1 -0
  42. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  43. package/build/browser/observable/internal/OrderByCanonicalizer.js +1 -4
  44. package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -1
  45. package/build/browser/observable/internal/RdpCanonicalizer.js +66 -0
  46. package/build/browser/observable/internal/RdpCanonicalizer.js.map +1 -0
  47. package/build/browser/observable/internal/RdpCanonicalizer.test.js +68 -0
  48. package/build/browser/observable/internal/RdpCanonicalizer.test.js.map +1 -0
  49. package/build/browser/observable/internal/SimpleWhereClause.js.map +1 -1
  50. package/build/browser/observable/internal/Store.js +160 -6
  51. package/build/browser/observable/internal/Store.js.map +1 -1
  52. package/build/browser/observable/internal/WhereClauseCanonicalizer.js +1 -1
  53. package/build/browser/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
  54. package/build/browser/observable/internal/actions/ActionApplication.js +1 -1
  55. package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -1
  56. package/build/browser/observable/internal/actions/OptimisticJob.js +3 -3
  57. package/build/browser/observable/internal/actions/OptimisticJob.js.map +1 -1
  58. package/build/browser/observable/internal/base-list/BaseListQuery.js +12 -3
  59. package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
  60. package/build/browser/observable/internal/base-list/createCollectionConnectable.js +0 -5
  61. package/build/browser/observable/internal/base-list/createCollectionConnectable.js.map +1 -1
  62. package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js +26 -13
  63. package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -1
  64. package/build/browser/observable/internal/evaluateFilter.js +61 -0
  65. package/build/browser/observable/internal/evaluateFilter.js.map +1 -0
  66. package/build/browser/observable/internal/links/SpecificLinkCacheKey.js +33 -1
  67. package/build/browser/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
  68. package/build/browser/observable/internal/list/InterfaceListQuery.js +8 -3
  69. package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -1
  70. package/build/browser/observable/internal/list/ListCacheKey.js +22 -1
  71. package/build/browser/observable/internal/list/ListCacheKey.js.map +1 -1
  72. package/build/browser/observable/internal/list/ListQuery.js +19 -13
  73. package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
  74. package/build/browser/observable/internal/list/ListsHelper.js +12 -8
  75. package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
  76. package/build/browser/observable/internal/list/ObjectListQuery.js +10 -1
  77. package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -1
  78. package/build/browser/observable/internal/object/ObjectCacheKey.js +20 -1
  79. package/build/browser/observable/internal/object/ObjectCacheKey.js.map +1 -1
  80. package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.js +126 -0
  81. package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.js.map +1 -0
  82. package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.test.js +173 -0
  83. package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.test.js.map +1 -0
  84. package/build/browser/observable/internal/object/ObjectQuery.js +10 -58
  85. package/build/browser/observable/internal/object/ObjectQuery.js.map +1 -1
  86. package/build/browser/observable/internal/object/ObjectsHelper.js +65 -5
  87. package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
  88. package/build/browser/observable/internal/objectMatchesWhereClause.js +3 -37
  89. package/build/browser/observable/internal/objectMatchesWhereClause.js.map +1 -1
  90. package/build/browser/observable/internal/testUtils.js +3 -2
  91. package/build/browser/observable/internal/testUtils.js.map +1 -1
  92. package/build/browser/observable/internal/utils/rdpFieldOperations.js +83 -0
  93. package/build/browser/observable/internal/utils/rdpFieldOperations.js.map +1 -0
  94. package/build/browser/util/UserAgent.js +2 -2
  95. package/build/cjs/{chunk-X7WMWKLM.cjs → chunk-7567LSZD.cjs} +192 -55
  96. package/build/cjs/chunk-7567LSZD.cjs.map +1 -0
  97. package/build/cjs/{chunk-6L3MX4LH.cjs → chunk-VNLY3YOJ.cjs} +241 -196
  98. package/build/cjs/chunk-VNLY3YOJ.cjs.map +1 -0
  99. package/build/cjs/index.cjs +8 -8
  100. package/build/cjs/index.d.cts +1 -1
  101. package/build/cjs/public/internal.cjs +8 -8
  102. package/build/cjs/public/unstable-do-not-use.cjs +633 -208
  103. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  104. package/build/cjs/public/unstable-do-not-use.d.cts +6 -5
  105. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +2 -1
  106. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  107. package/build/esm/index.js.map +1 -1
  108. package/build/esm/internal/conversions/extractNamespace.js +22 -0
  109. package/build/esm/internal/conversions/extractNamespace.js.map +1 -0
  110. package/build/esm/internal/conversions/fullyQualifyPropName.js +26 -0
  111. package/build/esm/internal/conversions/fullyQualifyPropName.js.map +1 -0
  112. package/build/esm/internal/conversions/makeGeoFilterBbox.js +41 -0
  113. package/build/esm/internal/conversions/makeGeoFilterBbox.js.map +1 -0
  114. package/build/esm/internal/conversions/makeGeoFilterIntersects.js +29 -0
  115. package/build/esm/internal/conversions/makeGeoFilterIntersects.js.map +1 -0
  116. package/build/esm/internal/conversions/makeGeoFilterPolygon.js +30 -0
  117. package/build/esm/internal/conversions/makeGeoFilterPolygon.js.map +1 -0
  118. package/build/esm/internal/conversions/makeGeoFilterWithin.js +48 -0
  119. package/build/esm/internal/conversions/makeGeoFilterWithin.js.map +1 -0
  120. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +30 -99
  121. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  122. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +139 -0
  123. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  124. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +1 -1
  125. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  126. package/build/esm/object/fetchPage.js +1 -1
  127. package/build/esm/object/fetchPage.js.map +1 -1
  128. package/build/esm/object/formatting/applyPropertyFormatter.js +7 -1
  129. package/build/esm/object/formatting/applyPropertyFormatter.js.map +1 -1
  130. package/build/esm/object/formatting/applyPropertyFormatter.test.js +305 -2
  131. package/build/esm/object/formatting/applyPropertyFormatter.test.js.map +1 -1
  132. package/build/esm/object/formatting/formatDateTime.js +158 -0
  133. package/build/esm/object/formatting/formatDateTime.js.map +1 -0
  134. package/build/esm/objectSet/ObjectSetListenerWebsocket.js +17 -0
  135. package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  136. package/build/esm/observable/ObservableClient.js.map +1 -1
  137. package/build/esm/observable/internal/BulkObjectLoader.js +12 -4
  138. package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -1
  139. package/build/esm/observable/internal/BulkObjectLoader.test.js +48 -0
  140. package/build/esm/observable/internal/BulkObjectLoader.test.js.map +1 -1
  141. package/build/esm/observable/internal/CacheKeys.js +9 -3
  142. package/build/esm/observable/internal/CacheKeys.js.map +1 -1
  143. package/build/esm/observable/internal/Canonicalizer.js +51 -0
  144. package/build/esm/observable/internal/Canonicalizer.js.map +1 -0
  145. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  146. package/build/esm/observable/internal/OrderByCanonicalizer.js +1 -4
  147. package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -1
  148. package/build/esm/observable/internal/RdpCanonicalizer.js +66 -0
  149. package/build/esm/observable/internal/RdpCanonicalizer.js.map +1 -0
  150. package/build/esm/observable/internal/RdpCanonicalizer.test.js +68 -0
  151. package/build/esm/observable/internal/RdpCanonicalizer.test.js.map +1 -0
  152. package/build/esm/observable/internal/SimpleWhereClause.js.map +1 -1
  153. package/build/esm/observable/internal/Store.js +160 -6
  154. package/build/esm/observable/internal/Store.js.map +1 -1
  155. package/build/esm/observable/internal/WhereClauseCanonicalizer.js +1 -1
  156. package/build/esm/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
  157. package/build/esm/observable/internal/actions/ActionApplication.js +1 -1
  158. package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -1
  159. package/build/esm/observable/internal/actions/OptimisticJob.js +3 -3
  160. package/build/esm/observable/internal/actions/OptimisticJob.js.map +1 -1
  161. package/build/esm/observable/internal/base-list/BaseListQuery.js +12 -3
  162. package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
  163. package/build/esm/observable/internal/base-list/createCollectionConnectable.js +0 -5
  164. package/build/esm/observable/internal/base-list/createCollectionConnectable.js.map +1 -1
  165. package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js +26 -13
  166. package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -1
  167. package/build/esm/observable/internal/evaluateFilter.js +61 -0
  168. package/build/esm/observable/internal/evaluateFilter.js.map +1 -0
  169. package/build/esm/observable/internal/links/SpecificLinkCacheKey.js +33 -1
  170. package/build/esm/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
  171. package/build/esm/observable/internal/list/InterfaceListQuery.js +8 -3
  172. package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -1
  173. package/build/esm/observable/internal/list/ListCacheKey.js +22 -1
  174. package/build/esm/observable/internal/list/ListCacheKey.js.map +1 -1
  175. package/build/esm/observable/internal/list/ListQuery.js +19 -13
  176. package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
  177. package/build/esm/observable/internal/list/ListsHelper.js +12 -8
  178. package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
  179. package/build/esm/observable/internal/list/ObjectListQuery.js +10 -1
  180. package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -1
  181. package/build/esm/observable/internal/object/ObjectCacheKey.js +20 -1
  182. package/build/esm/observable/internal/object/ObjectCacheKey.js.map +1 -1
  183. package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.js +126 -0
  184. package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.js.map +1 -0
  185. package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.test.js +173 -0
  186. package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.test.js.map +1 -0
  187. package/build/esm/observable/internal/object/ObjectQuery.js +10 -58
  188. package/build/esm/observable/internal/object/ObjectQuery.js.map +1 -1
  189. package/build/esm/observable/internal/object/ObjectsHelper.js +65 -5
  190. package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
  191. package/build/esm/observable/internal/objectMatchesWhereClause.js +3 -37
  192. package/build/esm/observable/internal/objectMatchesWhereClause.js.map +1 -1
  193. package/build/esm/observable/internal/testUtils.js +3 -2
  194. package/build/esm/observable/internal/testUtils.js.map +1 -1
  195. package/build/esm/observable/internal/utils/rdpFieldOperations.js +83 -0
  196. package/build/esm/observable/internal/utils/rdpFieldOperations.js.map +1 -0
  197. package/build/esm/util/UserAgent.js +2 -2
  198. package/build/types/index.d.ts +1 -1
  199. package/build/types/index.d.ts.map +1 -1
  200. package/build/types/internal/conversions/extractNamespace.d.ts +1 -0
  201. package/build/types/internal/conversions/extractNamespace.d.ts.map +1 -0
  202. package/build/types/internal/conversions/fullyQualifyPropName.d.ts +2 -0
  203. package/build/types/internal/conversions/fullyQualifyPropName.d.ts.map +1 -0
  204. package/build/types/internal/conversions/makeGeoFilterBbox.d.ts +3 -0
  205. package/build/types/internal/conversions/makeGeoFilterBbox.d.ts.map +1 -0
  206. package/build/types/internal/conversions/makeGeoFilterIntersects.d.ts +3 -0
  207. package/build/types/internal/conversions/makeGeoFilterIntersects.d.ts.map +1 -0
  208. package/build/types/internal/conversions/makeGeoFilterPolygon.d.ts +3 -0
  209. package/build/types/internal/conversions/makeGeoFilterPolygon.d.ts.map +1 -0
  210. package/build/types/internal/conversions/makeGeoFilterWithin.d.ts +3 -0
  211. package/build/types/internal/conversions/makeGeoFilterWithin.d.ts.map +1 -0
  212. package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
  213. package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
  214. package/build/types/object/formatting/applyPropertyFormatter.d.ts.map +1 -1
  215. package/build/types/object/formatting/formatDateTime.d.ts +6 -0
  216. package/build/types/object/formatting/formatDateTime.d.ts.map +1 -0
  217. package/build/types/observable/ObservableClient.d.ts +15 -5
  218. package/build/types/observable/ObservableClient.d.ts.map +1 -1
  219. package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -1
  220. package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
  221. package/build/types/observable/internal/Canonicalizer.d.ts +37 -0
  222. package/build/types/observable/internal/Canonicalizer.d.ts.map +1 -0
  223. package/build/types/observable/internal/OrderByCanonicalizer.d.ts.map +1 -1
  224. package/build/types/observable/internal/RdpCanonicalizer.d.ts +8 -0
  225. package/build/types/observable/internal/RdpCanonicalizer.d.ts.map +1 -0
  226. package/build/types/observable/internal/RdpCanonicalizer.test.d.ts +1 -0
  227. package/build/types/observable/internal/RdpCanonicalizer.test.d.ts.map +1 -0
  228. package/build/types/observable/internal/SimpleWhereClause.d.ts +6 -2
  229. package/build/types/observable/internal/SimpleWhereClause.d.ts.map +1 -1
  230. package/build/types/observable/internal/Store.d.ts +4 -0
  231. package/build/types/observable/internal/Store.d.ts.map +1 -1
  232. package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts +5 -2
  233. package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts.map +1 -1
  234. package/build/types/observable/internal/actions/ActionApplication.d.ts.map +1 -1
  235. package/build/types/observable/internal/base-list/BaseListQuery.d.ts +6 -0
  236. package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -1
  237. package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts +1 -23
  238. package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts.map +1 -1
  239. package/build/types/observable/internal/evaluateFilter.d.ts +6 -0
  240. package/build/types/observable/internal/evaluateFilter.d.ts.map +1 -0
  241. package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts +5 -0
  242. package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts.map +1 -1
  243. package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -1
  244. package/build/types/observable/internal/list/ListCacheKey.d.ts +7 -1
  245. package/build/types/observable/internal/list/ListCacheKey.d.ts.map +1 -1
  246. package/build/types/observable/internal/list/ListQuery.d.ts +7 -7
  247. package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
  248. package/build/types/observable/internal/list/ListsHelper.d.ts +3 -1
  249. package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
  250. package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -1
  251. package/build/types/observable/internal/object/ObjectCacheKey.d.ts +6 -1
  252. package/build/types/observable/internal/object/ObjectCacheKey.d.ts.map +1 -1
  253. package/build/types/observable/internal/object/ObjectCacheKeyRegistry.d.ts +60 -0
  254. package/build/types/observable/internal/object/ObjectCacheKeyRegistry.d.ts.map +1 -0
  255. package/build/types/observable/internal/object/ObjectCacheKeyRegistry.test.d.ts +1 -0
  256. package/build/types/observable/internal/object/ObjectCacheKeyRegistry.test.d.ts.map +1 -0
  257. package/build/types/observable/internal/object/ObjectQuery.d.ts +1 -1
  258. package/build/types/observable/internal/object/ObjectQuery.d.ts.map +1 -1
  259. package/build/types/observable/internal/object/ObjectsHelper.d.ts +15 -1
  260. package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -1
  261. package/build/types/observable/internal/objectMatchesWhereClause.d.ts.map +1 -1
  262. package/build/types/observable/internal/testUtils.d.ts.map +1 -1
  263. package/build/types/observable/internal/utils/rdpFieldOperations.d.ts +5 -0
  264. package/build/types/observable/internal/utils/rdpFieldOperations.d.ts.map +1 -0
  265. package/package.json +9 -9
  266. package/build/cjs/chunk-6L3MX4LH.cjs.map +0 -1
  267. package/build/cjs/chunk-X7WMWKLM.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ListQuery.js","names":["invariant","additionalContext","BaseListQuery","DEBUG_ONLY__changesToString","objectSortaMatchesWhereClause","objectMatchesWhereClause","OrderBySortingStrategy","API_NAME_IDX","TYPE_IDX","WHERE_IDX","ORDER_BY_IDX","ListQuery","whereClause","orderBy","objectSet","registerCacheChanges","batch","changes","registerList","cacheKey","constructor","store","subject","apiName","opts","process","env","NODE_ENV","client","logger","child","msgPrefix","otherKeys","map","x","JSON","stringify","join","undefined","createObjectSet","sortingStrategy","minResultsToLoad","canonicalWhere","fetchPageData","signal","resp","fetchPage","$nextPageToken","nextPageToken","$pageSize","options","pageSize","Object","keys","length","$orderBy","aborted","Error","fetchedData","postProcessFetchedData","data","handleFetchError","error","_status","subjects","get","writeToStore","invalidateObjectType","objectType","modified","add","revalidate","maybeUpdateAndRevalidate","optimisticId","methodName","debug","has","relevantObjects","_extractAndCategorizeRelevantObjects","status","added","sortaMatches","size","newList","needsRevalidation","existingList","Set","read","value","toAdd","strictMatches","toRemove","deleted","obj","all","objectCacheKey","cacheKeys","$objectType","$primaryKey","optimisticWrite","existingObjectCacheKey","key","push","_updateList","matchType","#matchType","extractRelevantObjects","group","values","registerStreamUpdates","sub","info","websocketSubscription","subscribe","onChange","onOswChange","bind","onError","onOswError","onOutOfDate","onOswOutOfDate","onSuccessfulSubscription","onOswSuccessfulSubscription","unsubscribe","errors","object","objOrIface","state","$apiName","$as","objects","storeOsdkInstances","onOswRemoved","existing","newObjects","filter","o","write","catch","e","console","isListCacheKey","type"],"sources":["ListQuery.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 Logger,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PageResult,\n PropertyKeys,\n} from \"@osdk/api\";\nimport type { Observable, Subscription } from \"rxjs\";\nimport invariant from \"tiny-invariant\";\nimport { additionalContext } from \"../../../Client.js\";\nimport type { InterfaceHolder } from \"../../../object/convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type {\n ObjectHolder,\n} from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { ListPayload } from \"../../ListPayload.js\";\nimport type { Status } from \"../../ObservableClient/common.js\";\nimport { BaseListQuery } from \"../base-list/BaseListQuery.js\";\nimport type { BatchContext } from \"../BatchContext.js\";\nimport { type CacheKey } from \"../CacheKey.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport { type Changes, DEBUG_ONLY__changesToString } from \"../Changes.js\";\nimport type { Entry } from \"../Layer.js\";\nimport { type ObjectCacheKey } from \"../object/ObjectCacheKey.js\";\nimport { objectSortaMatchesWhereClause as objectMatchesWhereClause } from \"../objectMatchesWhereClause.js\";\nimport type { OptimisticId } from \"../OptimisticId.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport { OrderBySortingStrategy } from \"../sorting/SortingStrategy.js\";\nimport type { Store } from \"../Store.js\";\nimport type { SubjectPayload } from \"../SubjectPayload.js\";\nimport type { ListCacheKey } from \"./ListCacheKey.js\";\nimport type { ListQueryOptions } from \"./ListQueryOptions.js\";\n\nexport const API_NAME_IDX = 1;\nexport const TYPE_IDX = 0;\nexport const WHERE_IDX = 2;\nexport const ORDER_BY_IDX = 3;\n\ntype ExtractRelevantObjectsResult = Record<\"added\" | \"modified\", {\n all: (ObjectHolder | InterfaceHolder)[];\n strictMatches: Set<(ObjectHolder | InterfaceHolder)>;\n sortaMatches: Set<(ObjectHolder | InterfaceHolder)>;\n}>;\n\n/**\n * Base class for filtered and sorted object collection queries.\n * - Handles where clause filtering and orderBy sorting\n * - Manages pagination through fetchMore\n * - Auto-updates when matching objects change\n * - Uses canonicalized cache keys for consistency\n */\nexport abstract class ListQuery extends BaseListQuery<\n ListCacheKey,\n ListPayload,\n ListQueryOptions\n> {\n // pageSize?: number; // this is the internal page size. we need to track this properly\n\n protected apiName: string;\n #whereClause: Canonical<SimpleWhereClause>;\n\n // Using base class minResultsToLoad instead of a private property\n #orderBy: Canonical<Record<string, \"asc\" | \"desc\" | undefined>>;\n #objectSet: ObjectSet<ObjectTypeDefinition>;\n\n /**\n * Register changes to the cache specific to ListQuery\n */\n protected registerCacheChanges(batch: BatchContext): void {\n batch.changes.registerList(this.cacheKey);\n }\n\n constructor(\n store: Store,\n subject: Observable<SubjectPayload<ListCacheKey>>,\n apiName: string,\n whereClause: Canonical<SimpleWhereClause>,\n orderBy: Canonical<Record<string, \"asc\" | \"desc\" | undefined>>,\n cacheKey: ListCacheKey,\n opts: ListQueryOptions,\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: `ListQuery<${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`,\n })\n )\n : undefined,\n );\n\n this.apiName = apiName;\n this.#whereClause = whereClause;\n this.#orderBy = orderBy;\n this.#objectSet = this.createObjectSet(store);\n // Initialize the sorting strategy\n this.sortingStrategy = new OrderBySortingStrategy(\n this.apiName,\n this.#orderBy,\n );\n // Initialize the minResultsToLoad inherited from BaseCollectionQuery\n this.minResultsToLoad = 0;\n }\n\n get canonicalWhere(): Canonical<SimpleWhereClause> {\n return this.#whereClause;\n }\n\n /**\n * Create the ObjectSet for this query.\n */\n protected abstract createObjectSet(\n store: Store,\n ): ObjectSet<ObjectTypeDefinition>;\n\n /**\n * Implements fetchPageData from BaseCollectionQuery template method\n * Fetches a page of data\n */\n protected async fetchPageData(\n signal: AbortSignal | undefined,\n ): Promise<PageResult<Osdk.Instance<any>>> {\n // Fetch the data with pagination\n const resp = await this.#objectSet.fetchPage({\n $nextPageToken: this.nextPageToken,\n $pageSize: this.options.pageSize,\n // For now this keeps the shared test code from falling apart\n // but shouldn't be needed ideally\n ...(Object.keys(this.#orderBy).length > 0\n ? { $orderBy: this.#orderBy }\n : {}),\n });\n\n if (signal?.aborted) {\n throw new Error(\"Aborted\");\n }\n\n this.nextPageToken = resp.nextPageToken;\n const fetchedData = await this.postProcessFetchedData(resp.data);\n\n return {\n ...resp,\n data: fetchedData,\n };\n }\n\n /**\n * Handle fetch errors by setting appropriate error state and notifying subscribers\n */\n protected handleFetchError(\n error: unknown,\n _status: Status,\n batch: BatchContext,\n ): Entry<ListCacheKey> {\n this.logger?.error(\"error\", error);\n this.store.subjects.get(this.cacheKey).error(error);\n\n // We don't call super.handleFetchError because ListQuery has special error handling\n // but we still use writeToStore to create a properly structured Entry\n return this.writeToStore({ data: [] }, \"error\", batch);\n }\n\n /**\n * Will revalidate the list if its query is affected by invalidating the\n * apiName of the object type passed in.\n *\n * @param apiName to invalidate\n * @returns\n */\n abstract revalidateObjectType(apiName: string): Promise<void>;\n\n /**\n * Postprocess fetched data.\n */\n protected abstract postProcessFetchedData(\n data: Osdk.Instance<any>[],\n ): Promise<Osdk.Instance<any>[]>;\n\n invalidateObjectType = async (\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void> => {\n if (this.cacheKey.otherKeys[1] === objectType) {\n // Only invalidate lists for the matching apiName\n changes?.modified.add(this.cacheKey);\n return this.revalidate(true);\n }\n };\n\n /**\n * Note: This method is not async because I want it to return right after it\n * finishes the synchronous updates. The promise that is returned\n * will resolve after the revalidation is complete.\n * @param changes\n * @param optimisticId\n * @returns If revalidation is needed, a promise that resolves after the\n * revalidation is complete. Otherwise, undefined.\n */\n\n maybeUpdateAndRevalidate = (\n changes: Changes,\n optimisticId: OptimisticId | undefined,\n ): Promise<void> | undefined => {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"maybeUpdateAndRevalidate\" }).debug(\n DEBUG_ONLY__changesToString(changes),\n );\n this.logger?.child({ methodName: \"maybeUpdateAndRevalidate\" }).debug(\n `Already in changes? ${changes.modified.has(this.cacheKey)}`,\n );\n }\n\n if (changes.modified.has(this.cacheKey)) return;\n // mark ourselves as updated so we don't infinite recurse.\n changes.modified.add(this.cacheKey);\n\n try {\n const relevantObjects = this._extractAndCategorizeRelevantObjects(\n changes,\n );\n\n // If we got purely strict matches we can just update the list and move\n // on with our lives. But if we got sorta matches, then we need to revalidate\n // the list so we preemptively set it to loading to avoid thrashing the store.\n const status = optimisticId\n || relevantObjects.added.sortaMatches.size > 0\n || relevantObjects.modified.sortaMatches.size > 0\n ? \"loading\"\n : \"loaded\";\n\n // while we only push updates for the strict matches, we still need to\n // trigger the list updating if some of our objects changed\n\n const newList: Array<ObjectCacheKey> = [];\n\n let needsRevalidation = false;\n this.store.batch({ optimisticId, changes }, (batch) => {\n const existingList = new Set(\n batch.read(this.cacheKey)?.value?.data,\n );\n\n const toAdd = new Set<ObjectHolder | InterfaceHolder>(\n // easy case. objects are new to the cache and they match this filter\n relevantObjects.added.strictMatches,\n );\n\n // anything thats been deleted can be removed, so start there\n const toRemove = new Set<CacheKey>(changes.deleted);\n\n // deal with the modified objects\n for (const obj of relevantObjects.modified.all) {\n if (relevantObjects.modified.strictMatches.has(obj)) {\n const objectCacheKey = this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n obj.$objectType,\n obj.$primaryKey,\n );\n\n if (!existingList.has(objectCacheKey)) {\n // object is new to the list\n toAdd.add(obj);\n }\n continue;\n } else if (batch.optimisticWrite) {\n // we aren't removing objects in optimistic mode\n // we also don't want to trigger revalidation in optimistic mode\n // as it should be triggered when the optimistic job is done\n continue;\n } else {\n // object is no longer a strict match\n const existingObjectCacheKey = this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n obj.$objectType,\n obj.$primaryKey,\n );\n\n toRemove.add(existingObjectCacheKey);\n\n if (relevantObjects.modified.sortaMatches.has(obj)) {\n // since it might still be in the list we need to revalidate\n needsRevalidation = true;\n }\n }\n }\n\n for (const key of existingList) {\n if (toRemove.has(key)) continue;\n newList.push(key);\n }\n for (const obj of toAdd) {\n newList.push(\n this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n obj.$objectType,\n obj.$primaryKey,\n ),\n );\n }\n\n this._updateList(\n newList,\n status,\n batch,\n /* append */ false,\n );\n });\n\n if (needsRevalidation) {\n return this.revalidate(true);\n }\n return undefined;\n } finally {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"maybeUpdateAndRevalidate\" })\n .debug(\"in finally\");\n }\n }\n };\n\n #matchType(obj: ObjectHolder | InterfaceHolder): false | \"strict\" | \"sorta\" {\n // if its a strict match we can just insert it into place\n if (objectMatchesWhereClause(obj, this.#whereClause, true)) {\n return \"strict\";\n }\n // sorta match means it used a filter we cannot use on the frontend\n if (objectMatchesWhereClause(obj, this.#whereClause, false)) {\n return \"sorta\";\n }\n return false;\n }\n\n protected _extractAndCategorizeRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult {\n const relevantObjects = this.extractRelevantObjects(changes);\n\n // categorize\n for (const group of Object.values(relevantObjects)) {\n for (const obj of group.all ?? []) {\n const matchType = this.#matchType(obj);\n if (matchType) {\n group[`${matchType}Matches`].add(obj);\n }\n }\n }\n\n return relevantObjects;\n }\n\n /**\n * Extract relevant objects for this query type.\n */\n protected abstract extractRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult;\n\n registerStreamUpdates(sub: Subscription): void {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.logger?.child({ methodName: \"registerStreamUpdates\" })\n : this.logger;\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.child({ methodName: \"observeList\" }).info(\n \"Subscribing from websocket\",\n );\n }\n\n // FIXME: We should only do this once. If we already have one we should probably\n // just reuse it.\n\n const websocketSubscription = this.#objectSet.subscribe({\n onChange: this.onOswChange.bind(this),\n onError: this.onOswError.bind(this),\n onOutOfDate: this.onOswOutOfDate.bind(this),\n onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this),\n });\n\n sub.add(() => {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.child({ methodName: \"observeList\" }).info(\n \"Unsubscribing from websocket\",\n );\n }\n\n websocketSubscription.unsubscribe();\n });\n }\n\n protected onOswSuccessfulSubscription(): void {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child(\n { methodName: \"onSuccessfulSubscription\" },\n ).debug(\"\");\n }\n }\n\n protected onOswOutOfDate(): void {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child(\n { methodName: \"onOutOfDate\" },\n ).debug(\"\");\n }\n }\n\n protected onOswError(errors: {\n subscriptionClosed: boolean;\n error: any;\n }): void {\n if (this.logger) {\n this.logger?.child({ methodName: \"onError\" }).error(\n \"subscription errors\",\n errors,\n );\n }\n }\n\n protected onOswChange(\n { object: objOrIface, state }: ObjectUpdate<ObjectTypeDefinition, string>,\n ): void {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.logger?.child({ methodName: \"registerStreamUpdates\" })\n : this.logger;\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.child({ methodName: \"onChange\" }).debug(\n `Got an update of type: ${state}`,\n objOrIface,\n );\n }\n\n if (state === \"ADDED_OR_UPDATED\") {\n const object: ObjectHolder =\n (objOrIface.$apiName !== objOrIface.$objectType\n ? objOrIface.$as(objOrIface.$objectType)\n : objOrIface) as unknown as ObjectHolder;\n\n this.store.batch({}, (batch) => {\n this.store.objects.storeOsdkInstances(\n [object as Osdk.Instance<any>],\n batch,\n );\n });\n } else if (state === \"REMOVED\") {\n this.onOswRemoved(objOrIface, logger);\n }\n }\n\n protected onOswRemoved(\n objOrIface: Osdk.Instance<ObjectTypeDefinition, never, string, {}>,\n logger: Logger | undefined,\n ): void {\n this.store.batch({}, (batch) => {\n // Read the truth layer (since not optimistic)\n const existing = batch.read(this.cacheKey);\n invariant(\n existing,\n \"the truth value for our list should exist as we already subscribed\",\n );\n if (existing.status === \"loaded\") {\n const objectCacheKey = this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n objOrIface.$objectType,\n objOrIface.$primaryKey,\n );\n // remove the object from the list\n const newObjects = existing.value?.data.filter(\n (o) => o !== objectCacheKey,\n );\n\n // If the filter didn't change anything, then the list was already\n // updated (or didn't exist, which is nonsensical)\n if (newObjects?.length !== existing.value?.data.length) {\n batch.changes.registerList(this.cacheKey);\n batch.write(\n this.cacheKey,\n { data: newObjects ?? [] },\n \"loaded\",\n );\n // Should there be an else for this case? Do we need to invalidate\n // the paging tokens we may have? FIXME\n }\n\n return;\n }\n // There may be a tiny race here where OSW tells us the object has\n // been removed but an outstanding invalidation of this query is\n // about to return. In this case, its possible that we remove this item\n // from the list and then the returned list load re-adds it.\n // To avoid this, we will just force reload the query to be sure\n // we don't leave things in a bad state.\n if (process.env.NODE_ENV !== \"production\") {\n logger?.info(\n \"Removing an object from an object list that is in the middle of being loaded.\",\n existing,\n );\n }\n\n this.revalidate(/* force */ true).catch((e: unknown) => {\n if (logger) {\n logger?.error(\"Uncaught error while revalidating list\", e);\n } else {\n // Make sure we write to the console if there is no logger!\n // eslint-disable-next-line no-console\n console.error(\"Uncaught error while revalidating list\", e);\n }\n });\n });\n }\n}\n\nexport function isListCacheKey(\n cacheKey: CacheKey,\n): cacheKey is ListCacheKey {\n return cacheKey.type === \"list\";\n}\n\n/**\n * Copied from @osdk/api\n */\ntype ObjectUpdate<\n O extends ObjectOrInterfaceDefinition,\n P extends PropertyKeys<O>,\n> = {\n object: Osdk.Instance<O, never, P>;\n state: \"ADDED_OR_UPDATED\" | \"REMOVED\";\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,iBAAiB,QAAQ,oBAAoB;AAOtD,SAASC,aAAa,QAAQ,+BAA+B;AAI7D,SAAuBC,2BAA2B,QAAQ,eAAe;AAGzE,SAASC,6BAA6B,IAAIC,wBAAwB,QAAQ,gCAAgC;AAG1G,SAASC,sBAAsB,QAAQ,+BAA+B;AAMtE,OAAO,MAAMC,YAAY,GAAG,CAAC;AAC7B,OAAO,MAAMC,QAAQ,GAAG,CAAC;AACzB,OAAO,MAAMC,SAAS,GAAG,CAAC;AAC1B,OAAO,MAAMC,YAAY,GAAG,CAAC;AAQ7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAeC,SAAS,SAAST,aAAa,CAInD;EACA;;EAGA,CAACU,WAAW;;EAEZ;EACA,CAACC,OAAO;EACR,CAACC,SAAS;;EAEV;AACF;AACA;EACYC,oBAAoBA,CAACC,KAAmB,EAAQ;IACxDA,KAAK,CAACC,OAAO,CAACC,YAAY,CAAC,IAAI,CAACC,QAAQ,CAAC;EAC3C;EAEAC,WAAWA,CACTC,KAAY,EACZC,OAAiD,EACjDC,OAAe,EACfX,WAAyC,EACzCC,OAA8D,EAC9DM,QAAsB,EACtBK,IAAsB,EACtB;IACA,KAAK,CACHH,KAAK,EACLC,OAAO,EACPE,IAAI,EACJL,QAAQ,EACRM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,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K;QACtD,IAAI9G,MAAM,EAAE;UACVA,MAAM,EAAEiC,KAAK,CAAC,wCAAwC,EAAE6E,CAAC,CAAC;QAC5D,CAAC,MAAM;UACL;UACA;UACAC,OAAO,CAAC9E,KAAK,CAAC,wCAAwC,EAAE6E,CAAC,CAAC;QAC5D;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF;AAEA,OAAO,SAASE,cAAcA,CAC5B1H,QAAkB,EACQ;EAC1B,OAAOA,QAAQ,CAAC2H,IAAI,KAAK,MAAM;AACjC;;AAEA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"ListQuery.js","names":["invariant","additionalContext","BaseListQuery","DEBUG_ONLY__changesToString","objectSortaMatchesWhereClause","objectMatchesWhereClause","OrderBySortingStrategy","ORDER_BY_IDX","WHERE_IDX","API_NAME_IDX","RDP_IDX","ListQuery","whereClause","orderBy","objectSet","registerCacheChanges","batch","changes","registerList","cacheKey","constructor","store","subject","apiName","opts","process","env","NODE_ENV","client","logger","child","msgPrefix","otherKeys","map","x","JSON","stringify","join","undefined","createObjectSet","sortingStrategy","minResultsToLoad","canonicalWhere","fetchPageData","signal","resp","fetchPage","$nextPageToken","nextPageToken","$pageSize","options","pageSize","Object","keys","length","$orderBy","aborted","Error","fetchedData","postProcessFetchedData","data","handleFetchError","error","_status","subjects","get","writeToStore","invalidateObjectType","objectType","modified","add","revalidate","maybeUpdateAndRevalidate","optimisticId","methodName","debug","has","relevantObjects","_extractAndCategorizeRelevantObjects","status","added","sortaMatches","size","newList","needsRevalidation","existingList","Set","read","value","toAdd","strictMatches","toRemove","deleted","obj","all","objectCacheKey","getObjectCacheKey","optimisticWrite","existingObjectCacheKey","key","push","_updateList","matchType","#matchType","extractRelevantObjects","group","values","registerStreamUpdates","sub","info","websocketSubscription","subscribe","onChange","onOswChange","bind","onError","onOswError","onOutOfDate","onOswOutOfDate","onSuccessfulSubscription","onOswSuccessfulSubscription","unsubscribe","errors","object","objOrIface","state","$apiName","$objectType","$as","objects","storeOsdkInstances","rdpConfig","onOswRemoved","existing","newObjects","filter","o","write","catch","e","console","pk","$primaryKey","cacheKeys","isListCacheKey","type"],"sources":["ListQuery.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 Logger,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PageResult,\n PropertyKeys,\n} from \"@osdk/api\";\nimport type { Observable, Subscription } from \"rxjs\";\nimport invariant from \"tiny-invariant\";\nimport { additionalContext } from \"../../../Client.js\";\nimport type { InterfaceHolder } from \"../../../object/convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type {\n ObjectHolder,\n} from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { ListPayload } from \"../../ListPayload.js\";\nimport type { Status } from \"../../ObservableClient/common.js\";\nimport { BaseListQuery } from \"../base-list/BaseListQuery.js\";\nimport type { BatchContext } from \"../BatchContext.js\";\nimport { type CacheKey } from \"../CacheKey.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport { type Changes, DEBUG_ONLY__changesToString } from \"../Changes.js\";\nimport type { Entry } from \"../Layer.js\";\nimport { type ObjectCacheKey } from \"../object/ObjectCacheKey.js\";\nimport { objectSortaMatchesWhereClause as objectMatchesWhereClause } from \"../objectMatchesWhereClause.js\";\nimport type { OptimisticId } from \"../OptimisticId.js\";\nimport type { SimpleWhereClause } from \"../SimpleWhereClause.js\";\nimport { OrderBySortingStrategy } from \"../sorting/SortingStrategy.js\";\nimport type { Store } from \"../Store.js\";\nimport type { SubjectPayload } from \"../SubjectPayload.js\";\nimport { type ListCacheKey, ORDER_BY_IDX, WHERE_IDX } from \"./ListCacheKey.js\";\nexport { API_NAME_IDX, RDP_IDX } from \"./ListCacheKey.js\";\nimport type { ListQueryOptions } from \"./ListQueryOptions.js\";\n\ntype ExtractRelevantObjectsResult = Record<\"added\" | \"modified\", {\n all: (ObjectHolder | InterfaceHolder)[];\n strictMatches: Set<(ObjectHolder | InterfaceHolder)>;\n sortaMatches: Set<(ObjectHolder | InterfaceHolder)>;\n}>;\n\n/**\n * Base class for filtered and sorted object collection queries.\n * - Handles where clause filtering and orderBy sorting\n * - Manages pagination through fetchMore\n * - Auto-updates when matching objects change\n * - Uses canonicalized cache keys for consistency\n */\nexport abstract class ListQuery extends BaseListQuery<\n ListCacheKey,\n ListPayload,\n ListQueryOptions\n> {\n // pageSize?: number; // this is the internal page size. we need to track this properly\n\n protected apiName: string;\n #whereClause: Canonical<SimpleWhereClause>;\n\n // Using base class minResultsToLoad instead of a private property\n #orderBy: Canonical<Record<string, \"asc\" | \"desc\" | undefined>>;\n #objectSet: ObjectSet<ObjectTypeDefinition>;\n\n /**\n * Register changes to the cache specific to ListQuery\n */\n protected registerCacheChanges(batch: BatchContext): void {\n batch.changes.registerList(this.cacheKey);\n }\n\n constructor(\n store: Store,\n subject: Observable<SubjectPayload<ListCacheKey>>,\n apiName: string,\n cacheKey: ListCacheKey,\n opts: ListQueryOptions,\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: `ListQuery<${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`,\n })\n )\n : undefined,\n );\n\n this.apiName = apiName;\n this.#whereClause = cacheKey.otherKeys[WHERE_IDX];\n this.#orderBy = cacheKey.otherKeys[ORDER_BY_IDX];\n this.#objectSet = this.createObjectSet(store);\n // Initialize the sorting strategy\n this.sortingStrategy = new OrderBySortingStrategy(\n this.apiName,\n this.#orderBy,\n );\n // Initialize the minResultsToLoad inherited from BaseCollectionQuery\n this.minResultsToLoad = 0;\n }\n\n get canonicalWhere(): Canonical<SimpleWhereClause> {\n return this.#whereClause;\n }\n\n /**\n * Create the ObjectSet for this query.\n */\n protected abstract createObjectSet(\n store: Store,\n ): ObjectSet<ObjectTypeDefinition>;\n\n /**\n * Implements fetchPageData from BaseCollectionQuery template method\n * Fetches a page of data\n */\n protected async fetchPageData(\n signal: AbortSignal | undefined,\n ): Promise<PageResult<Osdk.Instance<any>>> {\n // Fetch the data with pagination\n const resp = await this.#objectSet.fetchPage({\n $nextPageToken: this.nextPageToken,\n $pageSize: this.options.pageSize,\n // For now this keeps the shared test code from falling apart\n // but shouldn't be needed ideally\n ...(Object.keys(this.#orderBy).length > 0\n ? { $orderBy: this.#orderBy }\n : {}),\n });\n\n if (signal?.aborted) {\n throw new Error(\"Aborted\");\n }\n\n this.nextPageToken = resp.nextPageToken;\n const fetchedData = await this.postProcessFetchedData(resp.data);\n\n return {\n ...resp,\n data: fetchedData,\n };\n }\n\n /**\n * Handle fetch errors by setting appropriate error state and notifying subscribers\n */\n protected handleFetchError(\n error: unknown,\n _status: Status,\n batch: BatchContext,\n ): Entry<ListCacheKey> {\n this.logger?.error(\"error\", error);\n this.store.subjects.get(this.cacheKey).error(error);\n\n // We don't call super.handleFetchError because ListQuery has special error handling\n // but we still use writeToStore to create a properly structured Entry\n return this.writeToStore({ data: [] }, \"error\", batch);\n }\n\n /**\n * Will revalidate the list if its query is affected by invalidating the\n * apiName of the object type passed in.\n *\n * @param apiName to invalidate\n * @returns\n */\n abstract revalidateObjectType(apiName: string): Promise<void>;\n\n /**\n * Postprocess fetched data.\n */\n protected abstract postProcessFetchedData(\n data: Osdk.Instance<any>[],\n ): Promise<Osdk.Instance<any>[]>;\n\n invalidateObjectType = async (\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void> => {\n if (this.apiName === objectType) {\n // Only invalidate lists for the matching apiName\n changes?.modified.add(this.cacheKey);\n return this.revalidate(true);\n }\n };\n\n /**\n * Note: This method is not async because I want it to return right after it\n * finishes the synchronous updates. The promise that is returned\n * will resolve after the revalidation is complete.\n * @param changes\n * @param optimisticId\n * @returns If revalidation is needed, a promise that resolves after the\n * revalidation is complete. Otherwise, undefined.\n */\n\n maybeUpdateAndRevalidate = (\n changes: Changes,\n optimisticId: OptimisticId | undefined,\n ): Promise<void> | undefined => {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"maybeUpdateAndRevalidate\" }).debug(\n DEBUG_ONLY__changesToString(changes),\n );\n this.logger?.child({ methodName: \"maybeUpdateAndRevalidate\" }).debug(\n `Already in changes? ${changes.modified.has(this.cacheKey)}`,\n );\n }\n\n if (changes.modified.has(this.cacheKey)) return;\n // mark ourselves as updated so we don't infinite recurse.\n changes.modified.add(this.cacheKey);\n\n try {\n const relevantObjects = this._extractAndCategorizeRelevantObjects(\n changes,\n );\n\n // If we got purely strict matches we can just update the list and move\n // on with our lives. But if we got sorta matches, then we need to revalidate\n // the list so we preemptively set it to loading to avoid thrashing the store.\n const status = optimisticId\n || relevantObjects.added.sortaMatches.size > 0\n || relevantObjects.modified.sortaMatches.size > 0\n ? \"loading\"\n : \"loaded\";\n\n // while we only push updates for the strict matches, we still need to\n // trigger the list updating if some of our objects changed\n\n const newList: Array<ObjectCacheKey> = [];\n\n let needsRevalidation = false;\n this.store.batch({ optimisticId, changes }, (batch) => {\n const existingList = new Set(\n batch.read(this.cacheKey)?.value?.data,\n );\n\n const toAdd = new Set<ObjectHolder | InterfaceHolder>(\n // easy case. objects are new to the cache and they match this filter\n relevantObjects.added.strictMatches,\n );\n\n // anything thats been deleted can be removed, so start there\n const toRemove = new Set<CacheKey>(changes.deleted);\n\n // deal with the modified objects\n for (const obj of relevantObjects.modified.all) {\n if (relevantObjects.modified.strictMatches.has(obj)) {\n const objectCacheKey = this.getObjectCacheKey(obj);\n\n if (!existingList.has(objectCacheKey)) {\n // object is new to the list\n toAdd.add(obj);\n }\n continue;\n } else if (batch.optimisticWrite) {\n // we aren't removing objects in optimistic mode\n // we also don't want to trigger revalidation in optimistic mode\n // as it should be triggered when the optimistic job is done\n continue;\n } else {\n // object is no longer a strict match\n const existingObjectCacheKey = this.getObjectCacheKey(obj);\n\n toRemove.add(existingObjectCacheKey);\n\n if (relevantObjects.modified.sortaMatches.has(obj)) {\n // since it might still be in the list we need to revalidate\n needsRevalidation = true;\n }\n }\n }\n\n for (const key of existingList) {\n if (toRemove.has(key)) continue;\n newList.push(key);\n }\n for (const obj of toAdd) {\n newList.push(this.getObjectCacheKey(obj));\n }\n\n this._updateList(\n newList,\n status,\n batch,\n /* append */ false,\n );\n });\n\n if (needsRevalidation) {\n return this.revalidate(true);\n }\n return undefined;\n } finally {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"maybeUpdateAndRevalidate\" })\n .debug(\"in finally\");\n }\n }\n };\n\n #matchType(obj: ObjectHolder | InterfaceHolder): false | \"strict\" | \"sorta\" {\n // if its a strict match we can just insert it into place\n if (objectMatchesWhereClause(obj, this.#whereClause, true)) {\n return \"strict\";\n }\n // sorta match means it used a filter we cannot use on the frontend\n if (objectMatchesWhereClause(obj, this.#whereClause, false)) {\n return \"sorta\";\n }\n return false;\n }\n\n protected _extractAndCategorizeRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult {\n const relevantObjects = this.extractRelevantObjects(changes);\n\n // categorize\n for (const group of Object.values(relevantObjects)) {\n for (const obj of group.all ?? []) {\n const matchType = this.#matchType(obj);\n if (matchType) {\n group[`${matchType}Matches`].add(obj);\n }\n }\n }\n\n return relevantObjects;\n }\n\n /**\n * Extract relevant objects for this query type.\n */\n protected abstract extractRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult;\n\n registerStreamUpdates(sub: Subscription): void {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.logger?.child({ methodName: \"registerStreamUpdates\" })\n : this.logger;\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.child({ methodName: \"observeList\" }).info(\n \"Subscribing from websocket\",\n );\n }\n\n // FIXME: We should only do this once. If we already have one we should probably\n // just reuse it.\n\n const websocketSubscription = this.#objectSet.subscribe({\n onChange: this.onOswChange.bind(this),\n onError: this.onOswError.bind(this),\n onOutOfDate: this.onOswOutOfDate.bind(this),\n onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this),\n });\n\n sub.add(() => {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.child({ methodName: \"observeList\" }).info(\n \"Unsubscribing from websocket\",\n );\n }\n\n websocketSubscription.unsubscribe();\n });\n }\n\n protected onOswSuccessfulSubscription(): void {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child(\n { methodName: \"onSuccessfulSubscription\" },\n ).debug(\"\");\n }\n }\n\n protected onOswOutOfDate(): void {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child(\n { methodName: \"onOutOfDate\" },\n ).debug(\"\");\n }\n }\n\n protected onOswError(errors: {\n subscriptionClosed: boolean;\n error: any;\n }): void {\n if (this.logger) {\n this.logger?.child({ methodName: \"onError\" }).error(\n \"subscription errors\",\n errors,\n );\n }\n }\n\n protected onOswChange(\n { object: objOrIface, state }: ObjectUpdate<ObjectTypeDefinition, string>,\n ): void {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.logger?.child({ methodName: \"registerStreamUpdates\" })\n : this.logger;\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.child({ methodName: \"onChange\" }).debug(\n `Got an update of type: ${state}`,\n objOrIface,\n );\n }\n\n if (state === \"ADDED_OR_UPDATED\") {\n const object: ObjectHolder =\n (objOrIface.$apiName !== objOrIface.$objectType\n ? objOrIface.$as(objOrIface.$objectType)\n : objOrIface) as unknown as ObjectHolder;\n\n this.store.batch({}, (batch) => {\n this.store.objects.storeOsdkInstances(\n [object as Osdk.Instance<any>],\n batch,\n this.rdpConfig,\n );\n });\n } else if (state === \"REMOVED\") {\n this.onOswRemoved(objOrIface, logger);\n }\n }\n\n protected onOswRemoved(\n objOrIface: Osdk.Instance<ObjectTypeDefinition, never, string, {}>,\n logger: Logger | undefined,\n ): void {\n this.store.batch({}, (batch) => {\n // Read the truth layer (since not optimistic)\n const existing = batch.read(this.cacheKey);\n invariant(\n existing,\n \"the truth value for our list should exist as we already subscribed\",\n );\n if (existing.status === \"loaded\") {\n const objectCacheKey = this.getObjectCacheKey(objOrIface);\n // remove the object from the list\n const newObjects = existing.value?.data.filter(\n (o) => o !== objectCacheKey,\n );\n\n // If the filter didn't change anything, then the list was already\n // updated (or didn't exist, which is nonsensical)\n if (newObjects?.length !== existing.value?.data.length) {\n batch.changes.registerList(this.cacheKey);\n batch.write(\n this.cacheKey,\n { data: newObjects ?? [] },\n \"loaded\",\n );\n // Should there be an else for this case? Do we need to invalidate\n // the paging tokens we may have? FIXME\n }\n\n return;\n }\n // There may be a tiny race here where OSW tells us the object has\n // been removed but an outstanding invalidation of this query is\n // about to return. In this case, its possible that we remove this item\n // from the list and then the returned list load re-adds it.\n // To avoid this, we will just force reload the query to be sure\n // we don't leave things in a bad state.\n if (process.env.NODE_ENV !== \"production\") {\n logger?.info(\n \"Removing an object from an object list that is in the middle of being loaded.\",\n existing,\n );\n }\n\n this.revalidate(/* force */ true).catch((e: unknown) => {\n if (logger) {\n logger?.error(\"Uncaught error while revalidating list\", e);\n } else {\n // Make sure we write to the console if there is no logger!\n // eslint-disable-next-line no-console\n console.error(\"Uncaught error while revalidating list\", e);\n }\n });\n });\n }\n\n /**\n * Get cache key for object.\n */\n private getObjectCacheKey(\n obj: { $objectType: string; $primaryKey: string | number | boolean },\n ): ObjectCacheKey {\n const pk = obj.$primaryKey as string | number;\n return this.cacheKeys.get<ObjectCacheKey>(\n \"object\",\n obj.$objectType,\n pk,\n this.rdpConfig ?? undefined,\n );\n }\n}\n\nexport function isListCacheKey(\n cacheKey: CacheKey,\n): cacheKey is ListCacheKey {\n return cacheKey.type === \"list\";\n}\n\n/**\n * Copied from @osdk/api\n */\ntype ObjectUpdate<\n O extends ObjectOrInterfaceDefinition,\n P extends PropertyKeys<O>,\n> = {\n object: Osdk.Instance<O, never, P>;\n state: \"ADDED_OR_UPDATED\" | \"REMOVED\";\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAOA,SAAS,MAAM,gBAAgB;AACtC,SAASC,iBAAiB,QAAQ,oBAAoB;AAOtD,SAASC,aAAa,QAAQ,+BAA+B;AAI7D,SAAuBC,2BAA2B,QAAQ,eAAe;AAGzE,SAASC,6BAA6B,IAAIC,wBAAwB,QAAQ,gCAAgC;AAG1G,SAASC,sBAAsB,QAAQ,+BAA+B;AAGtE,SAA4BC,YAAY,EAAEC,SAAS,QAAQ,mBAAmB;AAC9E,SAASC,YAAY,EAAEC,OAAO,QAAQ,mBAAmB;AASzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAeC,SAAS,SAAST,aAAa,CAInD;EACA;;EAGA,CAACU,WAAW;;EAEZ;EACA,CAACC,OAAO;EACR,CAACC,SAAS;;EAEV;AACF;AACA;EACYC,oBAAoBA,CAACC,KAAmB,EAAQ;IACxDA,KAAK,CAACC,OAAO,CAACC,YAAY,CAAC,IAAI,CAACC,QAAQ,CAAC;EAC3C;EAEAC,WAAWA,CACTC,KAAY,EACZC,OAAiD,EACjDC,OAAe,EACfJ,QAAsB,EACtBK,IAAsB,EACtB;IACA,KAAK,CACHH,KAAK,EACLC,OAAO,EACPE,IAAI,EACJL,QAAQ,EACRM,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GAEjCN,KAAK,CAACO,MAAM,CAAC3B,iBAAiB,CAAC,CAAC4B,MAAM,EAAEC,KAAK,CAAC,CAAC,CAAC,EAAE;MAChDC,SAAS,EAAE,aACTZ,QAAQ,CAACa,SAAS,CAACC,GAAG,CAACC,CAAC,IAAIC,IAA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,EACR4B,GAAG,CAACkC,WAAW,EACfc,EAAE,EACF,IAAI,CAACV,SAAS,IAAI7F,SACpB,CAAC;EACH;AACF;AAEA,OAAO,SAAS0G,cAAcA,CAC5B7H,QAAkB,EACQ;EAC1B,OAAOA,QAAQ,CAAC8H,IAAI,KAAK,MAAM;AACjC;;AAEA;AACA;AACA","ignoreList":[]}
@@ -18,10 +18,11 @@ import { AbstractHelper } from "../AbstractHelper.js";
18
18
  import { InterfaceListQuery } from "./InterfaceListQuery.js";
19
19
  import { ObjectListQuery } from "./ObjectListQuery.js";
20
20
  export class ListsHelper extends AbstractHelper {
21
- constructor(store, cacheKeys, whereCanonicalizer, orderByCanonicalizer) {
21
+ constructor(store, cacheKeys, whereCanonicalizer, orderByCanonicalizer, rdpCanonicalizer) {
22
22
  super(store, cacheKeys);
23
23
  this.whereCanonicalizer = whereCanonicalizer;
24
24
  this.orderByCanonicalizer = orderByCanonicalizer;
25
+ this.rdpCanonicalizer = rdpCanonicalizer;
25
26
  }
26
27
  observe(options, subFn) {
27
28
  const ret = super.observe(options, subFn);
@@ -32,19 +33,22 @@ export class ListsHelper extends AbstractHelper {
32
33
  }
33
34
  getQuery(options) {
34
35
  const {
35
- type: {
36
- apiName,
37
- type
38
- },
36
+ type: typeDefinition,
39
37
  where,
40
- orderBy
38
+ orderBy,
39
+ withProperties
41
40
  } = options;
41
+ const {
42
+ apiName,
43
+ type
44
+ } = typeDefinition;
42
45
  const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
43
46
  const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
44
- const listCacheKey = this.cacheKeys.get("list", type, apiName, canonWhere, canonOrderBy);
47
+ const canonRdp = withProperties ? this.rdpCanonicalizer.canonicalize(withProperties) : undefined;
48
+ const listCacheKey = this.cacheKeys.get("list", type, apiName, canonWhere, canonOrderBy, canonRdp);
45
49
  return this.store.queries.get(listCacheKey, () => {
46
50
  const QueryClass = type === "object" ? ObjectListQuery : InterfaceListQuery;
47
- return new QueryClass(this.store, this.store.subjects.get(listCacheKey), apiName, canonWhere, canonOrderBy, listCacheKey, options);
51
+ return new QueryClass(this.store, this.store.subjects.get(listCacheKey), apiName, listCacheKey, options);
48
52
  });
49
53
  }
50
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ListsHelper.js","names":["AbstractHelper","InterfaceListQuery","ObjectListQuery","ListsHelper","constructor","store","cacheKeys","whereCanonicalizer","orderByCanonicalizer","observe","options","subFn","ret","streamUpdates","query","registerStreamUpdates","subscription","getQuery","type","apiName","where","orderBy","canonWhere","canonicalize","canonOrderBy","listCacheKey","get","queries","QueryClass","subjects"],"sources":["ListsHelper.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 { InterfaceDefinition, ObjectTypeDefinition } from \"@osdk/api\";\nimport type { ListPayload } from \"../../ListPayload.js\";\nimport type { ObserveListOptions } from \"../../ObservableClient.js\";\nimport type { Observer } from \"../../ObservableClient/common.js\";\nimport { AbstractHelper } from \"../AbstractHelper.js\";\nimport type { CacheKeys } from \"../CacheKeys.js\";\nimport type { KnownCacheKey } from \"../KnownCacheKey.js\";\nimport type { OrderByCanonicalizer } from \"../OrderByCanonicalizer.js\";\nimport type { QuerySubscription } from \"../QuerySubscription.js\";\nimport type { Store } from \"../Store.js\";\nimport type { WhereClauseCanonicalizer } from \"../WhereClauseCanonicalizer.js\";\nimport { InterfaceListQuery } from \"./InterfaceListQuery.js\";\nimport type { ListCacheKey } from \"./ListCacheKey.js\";\nimport type { ListQuery } from \"./ListQuery.js\";\nimport { ObjectListQuery } from \"./ObjectListQuery.js\";\n\nexport class ListsHelper extends AbstractHelper<\n ListQuery,\n ObserveListOptions<ObjectTypeDefinition | InterfaceDefinition>\n> {\n whereCanonicalizer: WhereClauseCanonicalizer;\n orderByCanonicalizer: OrderByCanonicalizer;\n\n constructor(\n store: Store,\n cacheKeys: CacheKeys<KnownCacheKey>,\n whereCanonicalizer: WhereClauseCanonicalizer,\n orderByCanonicalizer: OrderByCanonicalizer,\n ) {\n super(store, cacheKeys);\n\n this.whereCanonicalizer = whereCanonicalizer;\n this.orderByCanonicalizer = orderByCanonicalizer;\n }\n\n observe<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ListPayload>,\n ): QuerySubscription<ListQuery> {\n const ret = super.observe(options, subFn);\n\n if (options.streamUpdates) {\n ret.query.registerStreamUpdates(ret.subscription);\n }\n return ret;\n }\n\n getQuery<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n ): ListQuery {\n const { type: { apiName, type }, where, orderBy } = options;\n\n const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});\n const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});\n const listCacheKey = this.cacheKeys.get<ListCacheKey>(\n \"list\",\n type,\n apiName,\n canonWhere,\n canonOrderBy,\n );\n\n return this.store.queries.get(listCacheKey, () => {\n const QueryClass = type === \"object\"\n ? ObjectListQuery\n : InterfaceListQuery;\n return new QueryClass(\n this.store,\n this.store.subjects.get(listCacheKey),\n apiName,\n canonWhere,\n canonOrderBy,\n listCacheKey,\n options,\n );\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,SAASA,cAAc,QAAQ,sBAAsB;AAOrD,SAASC,kBAAkB,QAAQ,yBAAyB;AAG5D,SAASC,eAAe,QAAQ,sBAAsB;AAEtD,OAAO,MAAMC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,EACrCN,OAAO,EACPG,UAAU,EACVE,YAAY,EACZC,YAAY,EACZf,OACF,CAAC;IACH,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ListsHelper.js","names":["AbstractHelper","InterfaceListQuery","ObjectListQuery","ListsHelper","constructor","store","cacheKeys","whereCanonicalizer","orderByCanonicalizer","rdpCanonicalizer","observe","options","subFn","ret","streamUpdates","query","registerStreamUpdates","subscription","getQuery","type","typeDefinition","where","orderBy","withProperties","apiName","canonWhere","canonicalize","canonOrderBy","canonRdp","undefined","listCacheKey","get","queries","QueryClass","subjects"],"sources":["ListsHelper.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 { InterfaceDefinition, ObjectTypeDefinition } from \"@osdk/api\";\nimport type { ListPayload } from \"../../ListPayload.js\";\nimport type { ObserveListOptions } from \"../../ObservableClient.js\";\nimport type { Observer } from \"../../ObservableClient/common.js\";\nimport { AbstractHelper } from \"../AbstractHelper.js\";\nimport type { CacheKeys } from \"../CacheKeys.js\";\nimport type { KnownCacheKey } from \"../KnownCacheKey.js\";\nimport type { OrderByCanonicalizer } from \"../OrderByCanonicalizer.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 { InterfaceListQuery } from \"./InterfaceListQuery.js\";\nimport type { ListCacheKey } from \"./ListCacheKey.js\";\nimport type { ListQuery } from \"./ListQuery.js\";\nimport { ObjectListQuery } from \"./ObjectListQuery.js\";\n\nexport class ListsHelper extends AbstractHelper<\n ListQuery,\n ObserveListOptions<ObjectTypeDefinition | InterfaceDefinition>\n> {\n whereCanonicalizer: WhereClauseCanonicalizer;\n orderByCanonicalizer: OrderByCanonicalizer;\n rdpCanonicalizer: RdpCanonicalizer;\n\n constructor(\n store: Store,\n cacheKeys: CacheKeys<KnownCacheKey>,\n whereCanonicalizer: WhereClauseCanonicalizer,\n orderByCanonicalizer: OrderByCanonicalizer,\n rdpCanonicalizer: RdpCanonicalizer,\n ) {\n super(store, cacheKeys);\n\n this.whereCanonicalizer = whereCanonicalizer;\n this.orderByCanonicalizer = orderByCanonicalizer;\n this.rdpCanonicalizer = rdpCanonicalizer;\n }\n\n observe<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ListPayload>,\n ): QuerySubscription<ListQuery> {\n const ret = super.observe(options, subFn);\n\n if (options.streamUpdates) {\n ret.query.registerStreamUpdates(ret.subscription);\n }\n return ret;\n }\n\n getQuery<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n ): ListQuery {\n const { type: typeDefinition, where, orderBy, withProperties } = options;\n const { apiName, type } = typeDefinition;\n\n const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});\n const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});\n const canonRdp = withProperties\n ? this.rdpCanonicalizer.canonicalize(withProperties)\n : undefined;\n\n const listCacheKey = this.cacheKeys.get<ListCacheKey>(\n \"list\",\n type,\n apiName,\n canonWhere,\n canonOrderBy,\n canonRdp,\n );\n\n return this.store.queries.get(listCacheKey, () => {\n const QueryClass = type === \"object\"\n ? ObjectListQuery\n : InterfaceListQuery;\n return new QueryClass(\n this.store,\n this.store.subjects.get(listCacheKey),\n apiName,\n listCacheKey,\n options,\n );\n });\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA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S;IAEb,MAAMC,YAAY,GAAG,IAAI,CAACxB,SAAS,CAACyB,GAAG,CACrC,MAAM,EACNZ,IAAI,EACJK,OAAO,EACPC,UAAU,EACVE,YAAY,EACZC,QACF,CAAC;IAED,OAAO,IAAI,CAACvB,KAAK,CAAC2B,OAAO,CAACD,GAAG,CAACD,YAAY,EAAE,MAAM;MAChD,MAAMG,UAAU,GAAGd,IAAI,KAAK,QAAQ,GAChCjB,eAAe,GACfD,kBAAkB;MACtB,OAAO,IAAIgC,UAAU,CACnB,IAAI,CAAC5B,KAAK,EACV,IAAI,CAACA,KAAK,CAAC6B,QAAQ,CAACH,GAAG,CAACD,YAAY,CAAC,EACrCN,OAAO,EACPM,YAAY,EACZnB,OACF,CAAC;IACH,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
@@ -14,9 +14,18 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { API_NAME_IDX, ListQuery } from "./ListQuery.js";
17
+ import { API_NAME_IDX, ListQuery, RDP_IDX } from "./ListQuery.js";
18
18
  export class ObjectListQuery extends ListQuery {
19
19
  createObjectSet(store) {
20
+ const rdpConfig = this.cacheKey.otherKeys[RDP_IDX];
21
+ if (rdpConfig != null) {
22
+ return store.client({
23
+ type: "object",
24
+ apiName: this.apiName
25
+ })
26
+ // Note: order matters here, we need to apply withProperties before the where clause
27
+ .withProperties(rdpConfig).where(this.canonicalWhere);
28
+ }
20
29
  return store.client({
21
30
  type: "object",
22
31
  apiName: this.apiName
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectListQuery.js","names":["API_NAME_IDX","ListQuery","ObjectListQuery","createObjectSet","store","client","type","apiName","where","canonicalWhere","revalidateObjectType","revalidate","postProcessFetchedData","data","Promise","resolve","extractRelevantObjects","changes","added","all","addedObjects","get","cacheKey","otherKeys","strictMatches","Set","sortaMatches","modified","modifiedObjects"],"sources":["ObjectListQuery.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 { ObjectSet, ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport type { InterfaceHolder } from \"../../../object/convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { Changes } from \"../Changes.js\";\nimport type { Store } from \"../Store.js\";\nimport { API_NAME_IDX, ListQuery } from \"./ListQuery.js\";\n\ntype ExtractRelevantObjectsResult = Record<\"added\" | \"modified\", {\n all: (ObjectHolder | InterfaceHolder)[];\n strictMatches: Set<(ObjectHolder | InterfaceHolder)>;\n sortaMatches: Set<(ObjectHolder | InterfaceHolder)>;\n}>;\n\nexport class ObjectListQuery extends ListQuery {\n protected createObjectSet(store: Store): ObjectSet<ObjectTypeDefinition> {\n return store.client({\n type: \"object\",\n apiName: this.apiName,\n } as ObjectTypeDefinition)\n .where(this.canonicalWhere);\n }\n\n async revalidateObjectType(apiName: string): Promise<void> {\n if (this.apiName === apiName) {\n await this.revalidate(/* force */ true);\n }\n }\n\n protected postProcessFetchedData(\n data: Osdk.Instance<any>[],\n ): Promise<Osdk.Instance<any>[]> {\n return Promise.resolve(data);\n }\n\n protected extractRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult {\n return {\n added: {\n all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX])\n ?? [],\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n modified: {\n all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX])\n ?? [],\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,YAAY,EAAEC,SAAS,QAAQ,gBAAgB;AAQxD,OAAO,MAAMC,eAAe,SAASD,SAAS,CAAC;EACnCE,eAAeA,CAACC,KAAY,EAAmC;IACvE,OAAOA,KAAK,CAACC,MAAM,CAAC;MAClBC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE,IAAI,CAACA;IAChB,CAAyB,CAAC,CACvBC,KAAK,CAAC,IAAI,CAACC,cAAc,CAAC;EAC/B;EAEA,MAAMC,oBAAoBA,CAACH,OAAe,EAAiB;IACzD,IAAI,IAAI,CAACA,OAAO,KAAKA,OAAO,EAAE;MAC5B,MAAM,IAAI,CAACI,UAAU,CAAC,WAAY,IAAI,CAAC;IACzC;EACF;EAEUC,sBAAsBA,CAC9BC,IAA0B,EACK;IAC/B,OAAOC,OAAO,CAACC,OAAO,CAACF,IAAI,CAAC;EAC9B;EAEUG,sBAAsBA,CAC9BC,OAAgB,EACc;IAC9B,OAAO;MACLC,KAAK,EAAE;QACLC,GAAG,EAAEF,OAAO,CAACG,YAAY,CAACC,GAAG,CAAC,IAAI,CAACC,QAAQ,CAACC,SAAS,CAACvB,YAAY,CAAC,CAAC,IAC/D,EAAE;QACPwB,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;QACxBC,YAAY,EAAE,IAAID,GAAG,CAAC;MACxB,CAAC;MACDE,QAAQ,EAAE;QACRR,GAAG,EAAEF,OAAO,CAACW,eAAe,CAACP,GAAG,CAAC,IAAI,CAACC,QAAQ,CAACC,SAAS,CAACvB,YAAY,CAAC,CAAC,IAClE,EAAE;QACPwB,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;QACxBC,YAAY,EAAE,IAAID,GAAG,CAAC;MACxB;IACF,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ObjectListQuery.js","names":["API_NAME_IDX","ListQuery","RDP_IDX","ObjectListQuery","createObjectSet","store","rdpConfig","cacheKey","otherKeys","client","type","apiName","withProperties","where","canonicalWhere","revalidateObjectType","revalidate","postProcessFetchedData","data","Promise","resolve","extractRelevantObjects","changes","added","all","addedObjects","get","strictMatches","Set","sortaMatches","modified","modifiedObjects"],"sources":["ObjectListQuery.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 { ObjectSet, ObjectTypeDefinition, Osdk } from \"@osdk/api\";\nimport type { InterfaceHolder } from \"../../../object/convertWireToOsdkObjects/InterfaceHolder.js\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { Changes } from \"../Changes.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport type { Store } from \"../Store.js\";\nimport { API_NAME_IDX, ListQuery, RDP_IDX } from \"./ListQuery.js\";\n\ntype ExtractRelevantObjectsResult = Record<\"added\" | \"modified\", {\n all: (ObjectHolder | InterfaceHolder)[];\n strictMatches: Set<(ObjectHolder | InterfaceHolder)>;\n sortaMatches: Set<(ObjectHolder | InterfaceHolder)>;\n}>;\n\nexport class ObjectListQuery extends ListQuery {\n protected createObjectSet(store: Store): ObjectSet<ObjectTypeDefinition> {\n const rdpConfig = this.cacheKey.otherKeys[RDP_IDX];\n if (rdpConfig != null) {\n return store.client({\n type: \"object\",\n apiName: this.apiName,\n })\n // Note: order matters here, we need to apply withProperties before the where clause\n .withProperties(rdpConfig as Rdp)\n .where(this.canonicalWhere);\n }\n\n return store.client({\n type: \"object\",\n apiName: this.apiName,\n } as ObjectTypeDefinition)\n .where(this.canonicalWhere);\n }\n\n async revalidateObjectType(apiName: string): Promise<void> {\n if (this.apiName === apiName) {\n await this.revalidate(/* force */ true);\n }\n }\n\n protected postProcessFetchedData(\n data: Osdk.Instance<any>[],\n ): Promise<Osdk.Instance<any>[]> {\n return Promise.resolve(data);\n }\n\n protected extractRelevantObjects(\n changes: Changes,\n ): ExtractRelevantObjectsResult {\n return {\n added: {\n all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX])\n ?? [],\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n modified: {\n all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX])\n ?? [],\n strictMatches: new Set(),\n sortaMatches: new Set(),\n },\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,SAASA,YAAY,EAAEC,SAAS,EAAEC,OAAO,QAAQ,gBAAgB;AAQjE,OAAO,MAAMC,eAAe,SAASF,SAAS,CAAC;EACnCG,eAAeA,CAACC,KAAY,EAAmC;IACvE,MAAMC,SAAS,GAAG,IAAI,CAACC,QAAQ,CAACC,SAAS,CAACN,OAAO,CAAC;IAClD,IAAII,SAAS,IAAI,IAAI,EAAE;MACrB,OAAOD,KAAK,CAACI,MAAM,CAAC;QAClBC,IAAI,EAAE,QAAQ;QACdC,OAAO,EAAE,IAAI,CAACA;MAChB,CAAC;MACC;MAAA,CACCC,cAAc,CAACN,SAAgB,CAAC,CAChCO,KAAK,CAAC,IAAI,CAACC,cAAc,CAAC;IAC/B;IAEA,OAAOT,KAAK,CAACI,MAAM,CAAC;MAClBC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE,IAAI,CAACA;IAChB,CAAyB,CAAC,CACvBE,KAAK,CAAC,IAAI,CAACC,cAAc,CAAC;EAC/B;EAEA,MAAMC,oBAAoBA,CAACJ,OAAe,EAAiB;IACzD,IAAI,IAAI,CAACA,OAAO,KAAKA,OAAO,EAAE;MAC5B,MAAM,IAAI,CAACK,UAAU,CAAC,WAAY,IAAI,CAAC;IACzC;EACF;EAEUC,sBAAsBA,CAC9BC,IAA0B,EACK;IAC/B,OAAOC,OAAO,CAACC,OAAO,CAACF,IAAI,CAAC;EAC9B;EAEUG,sBAAsBA,CAC9BC,OAAgB,EACc;IAC9B,OAAO;MACLC,KAAK,EAAE;QACLC,GAAG,EAAEF,OAAO,CAACG,YAAY,CAACC,GAAG,CAAC,IAAI,CAACnB,QAAQ,CAACC,SAAS,CAACR,YAAY,CAAC,CAAC,IAC/D,EAAE;QACP2B,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;QACxBC,YAAY,EAAE,IAAID,GAAG,CAAC;MACxB,CAAC;MACDE,QAAQ,EAAE;QACRN,GAAG,EAAEF,OAAO,CAACS,eAAe,CAACL,GAAG,CAAC,IAAI,CAACnB,QAAQ,CAACC,SAAS,CAACR,YAAY,CAAC,CAAC,IAClE,EAAE;QACP2B,aAAa,EAAE,IAAIC,GAAG,CAAC,CAAC;QACxBC,YAAY,EAAE,IAAID,GAAG,CAAC;MACxB;IACF,CAAC;EACH;AACF","ignoreList":[]}
@@ -1,2 +1,21 @@
1
- export {};
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
+ // Index constants for accessing otherKeys array elements
18
+ export const API_NAME_IDX = 0;
19
+ export const PK_IDX = 1;
20
+ export const RDP_CONFIG_IDX = 2;
2
21
  //# sourceMappingURL=ObjectCacheKey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ObjectCacheKey.js","names":[],"sources":["ObjectCacheKey.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 { ObjectTypeDefinition, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { CacheKey } from \"../CacheKey.js\";\nimport type { ObjectQuery } from \"./ObjectQuery.js\";\n\nexport interface ObjectCacheKey extends\n CacheKey<\n \"object\",\n ObjectHolder,\n ObjectQuery,\n [string, pk: PrimaryKeyType<ObjectTypeDefinition>]\n >\n{\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"ObjectCacheKey.js","names":["API_NAME_IDX","PK_IDX","RDP_CONFIG_IDX"],"sources":["ObjectCacheKey.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 { ObjectTypeDefinition, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObjectHolder } from \"../../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { CacheKey } from \"../CacheKey.js\";\nimport type { Canonical } from \"../Canonical.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport type { ObjectQuery } from \"./ObjectQuery.js\";\n\n// Index constants for accessing otherKeys array elements\nexport const API_NAME_IDX = 0;\nexport const PK_IDX = 1;\nexport const RDP_CONFIG_IDX = 2;\n\nexport interface ObjectCacheKey extends\n CacheKey<\n \"object\",\n ObjectHolder,\n ObjectQuery,\n [\n apiName: string,\n pk: PrimaryKeyType<ObjectTypeDefinition>,\n rdpConfig?: Canonical<Rdp> | undefined,\n ]\n >\n{\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA,OAAO,MAAMA,YAAY,GAAG,CAAC;AAC7B,OAAO,MAAMC,MAAM,GAAG,CAAC;AACvB,OAAO,MAAMC,cAAc,GAAG,CAAC","ignoreList":[]}
@@ -0,0 +1,126 @@
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 { extractRdpFieldNames } from "../utils/rdpFieldOperations.js";
18
+ /**
19
+ * Registry that tracks relationships between object cache keys with different RDP configurations.
20
+ * This ensures we propagate updates across all "variants" of the same object.
21
+ */
22
+ export class ObjectCacheKeyRegistry {
23
+ /**
24
+ * Map from base key (apiName:primaryKey) to all related cache key variants and metadata
25
+ */
26
+ baseToVariants = new Map();
27
+
28
+ /**
29
+ * Metadata for each cache key (apiName, primaryKey, rdpConfig)
30
+ */
31
+ keyMetadata = new WeakMap();
32
+
33
+ /**
34
+ * Register a cache key variant for an object
35
+ */
36
+ register(cacheKey, apiName, primaryKey, rdpConfig) {
37
+ const baseKey = this.makeBaseKey(apiName, primaryKey);
38
+ const primaryKeyStr = String(primaryKey);
39
+ this.keyMetadata.set(cacheKey, {
40
+ apiName,
41
+ primaryKey: primaryKeyStr,
42
+ rdpConfig,
43
+ rdpFieldSet: rdpConfig ? extractRdpFieldNames(rdpConfig) : undefined
44
+ });
45
+ let entry = this.baseToVariants.get(baseKey);
46
+ if (!entry) {
47
+ entry = {
48
+ variants: new Set(),
49
+ apiName,
50
+ primaryKey: primaryKeyStr
51
+ };
52
+ this.baseToVariants.set(baseKey, entry);
53
+ }
54
+ entry.variants.add(cacheKey);
55
+ }
56
+
57
+ /**
58
+ * Get all variant cache keys for a specific object
59
+ */
60
+ getVariants(apiName, primaryKey) {
61
+ const baseKey = this.makeBaseKey(apiName, primaryKey);
62
+ const entry = this.baseToVariants.get(baseKey);
63
+ return new Set(entry?.variants ?? []);
64
+ }
65
+
66
+ /**
67
+ * Unregister a cache key when it's being cleaned up
68
+ */
69
+ unregister(cacheKey) {
70
+ const metadata = this.keyMetadata.get(cacheKey);
71
+ if (!metadata) return;
72
+ const baseKey = this.makeBaseKey(metadata.apiName, metadata.primaryKey);
73
+ const entry = this.baseToVariants.get(baseKey);
74
+ if (entry) {
75
+ entry.variants.delete(cacheKey);
76
+ if (entry.variants.size === 0) {
77
+ this.baseToVariants.delete(baseKey);
78
+ }
79
+ }
80
+ this.keyMetadata.delete(cacheKey);
81
+ }
82
+
83
+ /**
84
+ * Get metadata for a cache key
85
+ */
86
+ getMetadata(cacheKey) {
87
+ return this.keyMetadata.get(cacheKey);
88
+ }
89
+
90
+ /**
91
+ * Get the count of variants for a specific object
92
+ */
93
+ getVariantCount(apiName, primaryKey) {
94
+ const baseKey = this.makeBaseKey(apiName, primaryKey);
95
+ return this.baseToVariants.get(baseKey)?.variants.size ?? 0;
96
+ }
97
+
98
+ /**
99
+ * Generate a base key from apiName and primaryKey
100
+ */
101
+ makeBaseKey(apiName, primaryKey) {
102
+ return `${apiName}:${primaryKey}`;
103
+ }
104
+
105
+ /**
106
+ * Check if a cache key has RDP configuration
107
+ */
108
+ hasRdpConfig(cacheKey) {
109
+ return this.keyMetadata.get(cacheKey)?.rdpConfig != null;
110
+ }
111
+
112
+ /**
113
+ * Get the RDP configuration for a cache key
114
+ */
115
+ getRdpConfig(cacheKey) {
116
+ return this.keyMetadata.get(cacheKey)?.rdpConfig;
117
+ }
118
+
119
+ /**
120
+ * Get the cached RDP field set for a cache key
121
+ */
122
+ getRdpFieldSet(cacheKey) {
123
+ return this.keyMetadata.get(cacheKey)?.rdpFieldSet ?? new Set();
124
+ }
125
+ }
126
+ //# sourceMappingURL=ObjectCacheKeyRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectCacheKeyRegistry.js","names":["extractRdpFieldNames","ObjectCacheKeyRegistry","baseToVariants","Map","keyMetadata","WeakMap","register","cacheKey","apiName","primaryKey","rdpConfig","baseKey","makeBaseKey","primaryKeyStr","String","set","rdpFieldSet","undefined","entry","get","variants","Set","add","getVariants","unregister","metadata","delete","size","getMetadata","getVariantCount","hasRdpConfig","getRdpConfig","getRdpFieldSet"],"sources":["ObjectCacheKeyRegistry.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 { Canonical } from \"../Canonical.js\";\nimport type { Rdp } from \"../RdpCanonicalizer.js\";\nimport { extractRdpFieldNames } from \"../utils/rdpFieldOperations.js\";\nimport type { ObjectCacheKey } from \"./ObjectCacheKey.js\";\n\ninterface CacheKeyMetadata {\n apiName: string;\n primaryKey: string;\n rdpConfig?: Canonical<Rdp>;\n rdpFieldSet?: ReadonlySet<string>;\n}\n\ninterface BaseKeyEntry {\n variants: Set<ObjectCacheKey>;\n apiName: string;\n primaryKey: string;\n}\n\n/**\n * Registry that tracks relationships between object cache keys with different RDP configurations.\n * This ensures we propagate updates across all \"variants\" of the same object.\n */\nexport class ObjectCacheKeyRegistry {\n /**\n * Map from base key (apiName:primaryKey) to all related cache key variants and metadata\n */\n private baseToVariants = new Map<string, BaseKeyEntry>();\n\n /**\n * Metadata for each cache key (apiName, primaryKey, rdpConfig)\n */\n private keyMetadata = new WeakMap<ObjectCacheKey, CacheKeyMetadata>();\n\n /**\n * Register a cache key variant for an object\n */\n register(\n cacheKey: ObjectCacheKey,\n apiName: string,\n primaryKey: string | number | boolean,\n rdpConfig?: Canonical<Rdp>,\n ): void {\n const baseKey = this.makeBaseKey(apiName, primaryKey);\n const primaryKeyStr = String(primaryKey);\n\n this.keyMetadata.set(cacheKey, {\n apiName,\n primaryKey: primaryKeyStr,\n rdpConfig,\n rdpFieldSet: rdpConfig ? extractRdpFieldNames(rdpConfig) : undefined,\n });\n\n let entry = this.baseToVariants.get(baseKey);\n if (!entry) {\n entry = {\n variants: new Set(),\n apiName,\n primaryKey: primaryKeyStr,\n };\n this.baseToVariants.set(baseKey, entry);\n }\n entry.variants.add(cacheKey);\n }\n\n /**\n * Get all variant cache keys for a specific object\n */\n getVariants(\n apiName: string,\n primaryKey: string | number | boolean,\n ): Set<ObjectCacheKey> {\n const baseKey = this.makeBaseKey(apiName, primaryKey);\n const entry = this.baseToVariants.get(baseKey);\n return new Set(entry?.variants ?? []);\n }\n\n /**\n * Unregister a cache key when it's being cleaned up\n */\n unregister(cacheKey: ObjectCacheKey): void {\n const metadata = this.keyMetadata.get(cacheKey);\n if (!metadata) return;\n\n const baseKey = this.makeBaseKey(metadata.apiName, metadata.primaryKey);\n const entry = this.baseToVariants.get(baseKey);\n\n if (entry) {\n entry.variants.delete(cacheKey);\n if (entry.variants.size === 0) {\n this.baseToVariants.delete(baseKey);\n }\n }\n\n this.keyMetadata.delete(cacheKey);\n }\n\n /**\n * Get metadata for a cache key\n */\n getMetadata(cacheKey: ObjectCacheKey): CacheKeyMetadata | undefined {\n return this.keyMetadata.get(cacheKey);\n }\n\n /**\n * Get the count of variants for a specific object\n */\n getVariantCount(\n apiName: string,\n primaryKey: string | number | boolean,\n ): number {\n const baseKey = this.makeBaseKey(apiName, primaryKey);\n return this.baseToVariants.get(baseKey)?.variants.size ?? 0;\n }\n\n /**\n * Generate a base key from apiName and primaryKey\n */\n private makeBaseKey(\n apiName: string,\n primaryKey: string | number | boolean,\n ): string {\n return `${apiName}:${primaryKey}`;\n }\n\n /**\n * Check if a cache key has RDP configuration\n */\n hasRdpConfig(cacheKey: ObjectCacheKey): boolean {\n return this.keyMetadata.get(cacheKey)?.rdpConfig != null;\n }\n\n /**\n * Get the RDP configuration for a cache key\n */\n getRdpConfig(cacheKey: ObjectCacheKey): Canonical<Rdp> | undefined {\n return this.keyMetadata.get(cacheKey)?.rdpConfig;\n }\n\n /**\n * Get the cached RDP field set for a cache key\n */\n getRdpFieldSet(cacheKey: ObjectCacheKey): ReadonlySet<string> {\n return this.keyMetadata.get(cacheKey)?.rdpFieldSet ?? new Set();\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,oBAAoB,QAAQ,gCAAgC;AAgBrE;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,CAAC;EAClC;AACF;AACA;EACUC,cAAc,GAAG,IAAIC,GAAG,CAAuB,CAAC;;EAExD;AACF;AACA;EACUC,WAAW,GAAG,IAAIC,OAAO,CAAmC,CAAC;;EAErE;AACF;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QAAwB,EAAuB;IAC5D,OAAO,IAAI,CAACH,WAAW,CAACe,GAAG,CAACZ,QAAQ,CAAC,EAAES,WAAW,IAAI,IAAIK,GAAG,CAAC,CAAC;EACjE;AACF","ignoreList":[]}
@@ -0,0 +1,173 @@
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 { describe, expect, it } from "vitest";
18
+ import { ObjectCacheKeyRegistry } from "./ObjectCacheKeyRegistry.js";
19
+ /**
20
+ * Helper function to create mock RDP objects for testing.
21
+ * Creates an RDP config with the specified field names, where each field
22
+ * is a mock Creator function.
23
+ */
24
+ function createMockRdp(...fields) {
25
+ const rdp = {};
26
+ for (const field of fields) {
27
+ rdp[field] = () => ({});
28
+ }
29
+ return rdp;
30
+ }
31
+
32
+ /**
33
+ * Helper function to create a properly typed mock ObjectCacheKey for testing
34
+ */
35
+ function createMockObjectCacheKey(apiName, pk, rdpConfig) {
36
+ return {
37
+ type: "object",
38
+ otherKeys: [apiName, pk, rdpConfig],
39
+ __cacheKey: {
40
+ value: {},
41
+ query: {},
42
+ args: [apiName, pk, rdpConfig]
43
+ }
44
+ };
45
+ }
46
+ describe("ObjectCacheKeyRegistry", () => {
47
+ it("registers and retrieves variant cache keys", () => {
48
+ const registry = new ObjectCacheKeyRegistry();
49
+ const mockRdpAddress = createMockRdp("address", "mockType");
50
+ const mockRdpPhone = createMockRdp("phone", "mockType");
51
+ const key1 = createMockObjectCacheKey("Employee", "emp1", undefined);
52
+ const key2 = createMockObjectCacheKey("Employee", "emp1", mockRdpAddress);
53
+ const key3 = createMockObjectCacheKey("Employee", "emp1", mockRdpPhone);
54
+ const unrelatedKey = createMockObjectCacheKey("Employee", "emp2", undefined);
55
+ registry.register(key1, "Employee", "emp1", undefined);
56
+ registry.register(key2, "Employee", "emp1", mockRdpAddress);
57
+ registry.register(key3, "Employee", "emp1", mockRdpPhone);
58
+ registry.register(unrelatedKey, "Employee", "emp2", undefined);
59
+ const variants = registry.getVariants("Employee", "emp1");
60
+ expect(variants.size).toBe(3);
61
+ expect(variants.has(key1)).toBe(true);
62
+ expect(variants.has(key2)).toBe(true);
63
+ expect(variants.has(key3)).toBe(true);
64
+ expect(variants.has(unrelatedKey)).toBe(false);
65
+
66
+ // Unrelated key should have its own set
67
+ const unrelated = registry.getVariants("Employee", "emp2");
68
+ expect(unrelated.size).toBe(1);
69
+ expect(unrelated.has(unrelatedKey)).toBe(true);
70
+ });
71
+ it("handles un-registration correctly", () => {
72
+ const registry = new ObjectCacheKeyRegistry();
73
+ const mockRdp = createMockRdp("address", "mockType");
74
+ const key1 = createMockObjectCacheKey("Employee", "emp1", undefined);
75
+ const key2 = createMockObjectCacheKey("Employee", "emp1", mockRdp);
76
+ registry.register(key1, "Employee", "emp1", undefined);
77
+ registry.register(key2, "Employee", "emp1", mockRdp);
78
+
79
+ // Both keys should be related
80
+ expect(registry.getVariants("Employee", "emp1").size).toBe(2);
81
+ registry.unregister(key1);
82
+
83
+ // key2 should now be alone
84
+ const related = registry.getVariants("Employee", "emp1");
85
+ expect(related.size).toBe(1);
86
+ expect(related.has(key2)).toBe(true);
87
+ expect(related.has(key1)).toBe(false);
88
+ });
89
+ it("getVariants returns all variants for an object", () => {
90
+ const registry = new ObjectCacheKeyRegistry();
91
+ const key1 = createMockObjectCacheKey("Employee", "emp1", undefined);
92
+ const key2 = createMockObjectCacheKey("Employee", "emp1", createMockRdp("address"));
93
+ registry.register(key1, "Employee", "emp1", undefined);
94
+ registry.register(key2, "Employee", "emp1", createMockRdp("address"));
95
+ const variants = registry.getVariants("Employee", "emp1");
96
+ expect(variants.size).toBe(2);
97
+ expect(variants.has(key1)).toBe(true);
98
+ expect(variants.has(key2)).toBe(true);
99
+
100
+ // Non-existent object should return empty set
101
+ const empty = registry.getVariants("Employee", "emp999");
102
+ expect(empty.size).toBe(0);
103
+ });
104
+ it("correctly identifies RDP configuration", () => {
105
+ const registry = new ObjectCacheKeyRegistry();
106
+ const keyWithoutRdp = createMockObjectCacheKey("Employee", "emp1", undefined);
107
+ const keyWithRdp = createMockObjectCacheKey("Employee", "emp1", createMockRdp("address"));
108
+ registry.register(keyWithoutRdp, "Employee", "emp1", undefined);
109
+ registry.register(keyWithRdp, "Employee", "emp1", createMockRdp("address"));
110
+ expect(registry.hasRdpConfig(keyWithoutRdp)).toBe(false);
111
+ expect(registry.hasRdpConfig(keyWithRdp)).toBe(true);
112
+ expect(registry.getRdpConfig(keyWithoutRdp)).toBeUndefined();
113
+ const rdpConfig = registry.getRdpConfig(keyWithRdp);
114
+ expect(rdpConfig).toBeDefined();
115
+ expect(Object.keys(rdpConfig)).toEqual(["address"]);
116
+ expect(typeof rdpConfig.address).toBe("function");
117
+ });
118
+ it("getVariantCount returns correct count of variants", () => {
119
+ const registry = new ObjectCacheKeyRegistry();
120
+ const key1 = createMockObjectCacheKey("Employee", "emp1", undefined);
121
+ const key2 = createMockObjectCacheKey("Employee", "emp1", createMockRdp("address"));
122
+ const key3 = createMockObjectCacheKey("Employee", "emp1", createMockRdp("phone"));
123
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(0);
124
+ registry.register(key1, "Employee", "emp1", undefined);
125
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(1);
126
+ registry.register(key2, "Employee", "emp1", createMockRdp("address"));
127
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(2);
128
+ registry.register(key3, "Employee", "emp1", createMockRdp("phone"));
129
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(3);
130
+ registry.unregister(key1);
131
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(2);
132
+ expect(registry.getVariantCount("Employee", "emp999")).toBe(0);
133
+ });
134
+ it("handles registering same key multiple times", () => {
135
+ const registry = new ObjectCacheKeyRegistry();
136
+ const key1 = createMockObjectCacheKey("Employee", "emp1", undefined);
137
+ registry.register(key1, "Employee", "emp1", undefined);
138
+ registry.register(key1, "Employee", "emp1", undefined);
139
+ registry.register(key1, "Employee", "emp1", undefined);
140
+
141
+ // Should still have only one variant despite multiple registrations
142
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(1);
143
+ registry.unregister(key1);
144
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(0);
145
+ });
146
+ it("handles unregistering non-existent keys gracefully", () => {
147
+ const registry = new ObjectCacheKeyRegistry();
148
+ const key1 = createMockObjectCacheKey("Employee", "emp1", undefined);
149
+ const key2 = createMockObjectCacheKey("Employee", "emp2", undefined);
150
+ registry.register(key1, "Employee", "emp1", undefined);
151
+
152
+ // Unregistering non-existent key should not throw
153
+ registry.unregister(key2);
154
+
155
+ // key1 should still be registered
156
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(1);
157
+ });
158
+ it("properly cleans up memory when all variants are unregistered", () => {
159
+ const registry = new ObjectCacheKeyRegistry();
160
+ const key1 = createMockObjectCacheKey("Employee", "emp1", undefined);
161
+ const key2 = createMockObjectCacheKey("Employee", "emp1", createMockRdp("address"));
162
+ registry.register(key1, "Employee", "emp1", undefined);
163
+ registry.register(key2, "Employee", "emp1", createMockRdp("address"));
164
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(2);
165
+ registry.unregister(key1);
166
+ registry.unregister(key2);
167
+
168
+ // Should return 0 as the entire entry should be cleaned up
169
+ expect(registry.getVariantCount("Employee", "emp1")).toBe(0);
170
+ expect(registry.getVariants("Employee", "emp1").size).toBe(0);
171
+ });
172
+ });
173
+ //# sourceMappingURL=ObjectCacheKeyRegistry.test.js.map