@osdk/client 2.5.2 → 2.6.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (488) hide show
  1. package/CHANGELOG.md +118 -73
  2. package/build/browser/Client.js +1 -1
  3. package/build/browser/Client.js.map +1 -1
  4. package/build/browser/MinimalClientContext.js.map +1 -1
  5. package/build/browser/actions/applyAction.js +4 -0
  6. package/build/browser/actions/applyAction.js.map +1 -1
  7. package/build/browser/createClient.js +2 -1
  8. package/build/browser/createClient.js.map +1 -1
  9. package/build/browser/createClient.test.js +19 -1
  10. package/build/browser/createClient.test.js.map +1 -1
  11. package/build/browser/createMinimalClient.js +4 -2
  12. package/build/browser/createMinimalClient.js.map +1 -1
  13. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +19 -1
  14. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  15. package/build/browser/fetchMetadata.test.js +11 -0
  16. package/build/browser/fetchMetadata.test.js.map +1 -1
  17. package/build/browser/index.js +2 -2
  18. package/build/browser/index.js.map +1 -1
  19. package/build/browser/internal/conversions/extractNamespace.js +22 -0
  20. package/build/browser/internal/conversions/extractNamespace.js.map +1 -0
  21. package/build/browser/internal/conversions/fullyQualifyPropName.js +26 -0
  22. package/build/browser/internal/conversions/fullyQualifyPropName.js.map +1 -0
  23. package/build/browser/internal/conversions/makeGeoFilterBbox.js +41 -0
  24. package/build/browser/internal/conversions/makeGeoFilterBbox.js.map +1 -0
  25. package/build/browser/internal/conversions/makeGeoFilterIntersects.js +29 -0
  26. package/build/browser/internal/conversions/makeGeoFilterIntersects.js.map +1 -0
  27. package/build/browser/internal/conversions/makeGeoFilterPolygon.js +30 -0
  28. package/build/browser/internal/conversions/makeGeoFilterPolygon.js.map +1 -0
  29. package/build/browser/internal/conversions/makeGeoFilterWithin.js +48 -0
  30. package/build/browser/internal/conversions/makeGeoFilterWithin.js.map +1 -0
  31. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +59 -105
  32. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  33. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js +309 -0
  34. package/build/browser/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  35. package/build/browser/object/aggregate.js +3 -0
  36. package/build/browser/object/aggregate.js.map +1 -1
  37. package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
  38. package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
  39. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +5 -1
  40. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  41. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +10 -0
  42. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  43. package/build/browser/object/convertWireToOsdkObjects.test.js +12 -0
  44. package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
  45. package/build/browser/object/fetchPage.js +13 -6
  46. package/build/browser/object/fetchPage.js.map +1 -1
  47. package/build/browser/object/formatting/applyPropertyFormatter.js +58 -0
  48. package/build/browser/object/formatting/applyPropertyFormatter.js.map +1 -0
  49. package/build/browser/object/formatting/applyPropertyFormatter.test.js +726 -0
  50. package/build/browser/object/formatting/applyPropertyFormatter.test.js.map +1 -0
  51. package/build/browser/object/formatting/formatBoolean.js +23 -0
  52. package/build/browser/object/formatting/formatBoolean.js.map +1 -0
  53. package/build/browser/object/formatting/formatDateTime.js +158 -0
  54. package/build/browser/object/formatting/formatDateTime.js.map +1 -0
  55. package/build/browser/object/formatting/formatNumber.js +242 -0
  56. package/build/browser/object/formatting/formatNumber.js.map +1 -0
  57. package/build/browser/object/formatting/propertyFormattingUtils.js +39 -0
  58. package/build/browser/object/formatting/propertyFormattingUtils.js.map +1 -0
  59. package/build/browser/object/mediaUpload.js +3 -0
  60. package/build/browser/object/mediaUpload.js.map +1 -1
  61. package/build/browser/objectSet/ObjectSetListenerWebsocket.js +17 -0
  62. package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  63. package/build/browser/objectSet/createObjectSet.js +11 -0
  64. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  65. package/build/browser/observable/ObservableClient.js.map +1 -1
  66. package/build/browser/observable/internal/BulkObjectLoader.js +12 -4
  67. package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -1
  68. package/build/browser/observable/internal/BulkObjectLoader.test.js +48 -0
  69. package/build/browser/observable/internal/BulkObjectLoader.test.js.map +1 -1
  70. package/build/browser/observable/internal/CacheKeys.js +9 -3
  71. package/build/browser/observable/internal/CacheKeys.js.map +1 -1
  72. package/build/browser/observable/internal/Canonicalizer.js +51 -0
  73. package/build/browser/observable/internal/Canonicalizer.js.map +1 -0
  74. package/build/browser/observable/internal/Changes.js.map +1 -1
  75. package/build/browser/observable/internal/IntersectCanonicalizer.js +35 -0
  76. package/build/browser/observable/internal/IntersectCanonicalizer.js.map +1 -0
  77. package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
  78. package/build/browser/observable/internal/ObservableClientImpl.js +3 -0
  79. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  80. package/build/browser/observable/internal/OrderByCanonicalizer.js +1 -4
  81. package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -1
  82. package/build/browser/observable/internal/PivotCanonicalizer.js +33 -0
  83. package/build/browser/observable/internal/PivotCanonicalizer.js.map +1 -0
  84. package/build/browser/observable/internal/RdpCanonicalizer.js +66 -0
  85. package/build/browser/observable/internal/RdpCanonicalizer.js.map +1 -0
  86. package/build/browser/observable/internal/RdpCanonicalizer.test.js +68 -0
  87. package/build/browser/observable/internal/RdpCanonicalizer.test.js.map +1 -0
  88. package/build/browser/observable/internal/SimpleWhereClause.js.map +1 -1
  89. package/build/browser/observable/internal/Store.js +172 -6
  90. package/build/browser/observable/internal/Store.js.map +1 -1
  91. package/build/browser/observable/internal/WhereClauseCanonicalizer.js +1 -1
  92. package/build/browser/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
  93. package/build/browser/observable/internal/actions/ActionApplication.js +1 -1
  94. package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -1
  95. package/build/browser/observable/internal/actions/OptimisticJob.js +3 -3
  96. package/build/browser/observable/internal/actions/OptimisticJob.js.map +1 -1
  97. package/build/browser/observable/internal/aggregation/AggregationCacheKey.js +22 -0
  98. package/build/browser/observable/internal/aggregation/AggregationCacheKey.js.map +1 -0
  99. package/build/browser/observable/internal/aggregation/AggregationQuery.js +77 -0
  100. package/build/browser/observable/internal/aggregation/AggregationQuery.js.map +1 -0
  101. package/build/browser/observable/internal/aggregation/AggregationsHelper.js +54 -0
  102. package/build/browser/observable/internal/aggregation/AggregationsHelper.js.map +1 -0
  103. package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js +33 -0
  104. package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -0
  105. package/build/browser/observable/internal/base-list/BaseListQuery.js +145 -5
  106. package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
  107. package/build/browser/observable/internal/base-list/createCollectionConnectable.js +0 -5
  108. package/build/browser/observable/internal/base-list/createCollectionConnectable.js.map +1 -1
  109. package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js +26 -13
  110. package/build/browser/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -1
  111. package/build/browser/observable/internal/evaluateFilter.js +61 -0
  112. package/build/browser/observable/internal/evaluateFilter.js.map +1 -0
  113. package/build/browser/observable/internal/links/SpecificLinkCacheKey.js +33 -1
  114. package/build/browser/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
  115. package/build/browser/observable/internal/list/InterfaceListQuery.js +8 -3
  116. package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -1
  117. package/build/browser/observable/internal/list/ListCacheKey.js +24 -1
  118. package/build/browser/observable/internal/list/ListCacheKey.js.map +1 -1
  119. package/build/browser/observable/internal/list/ListQuery.js +35 -62
  120. package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
  121. package/build/browser/observable/internal/list/ListQueryOptions.js.map +1 -1
  122. package/build/browser/observable/internal/list/ListsHelper.js +18 -8
  123. package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
  124. package/build/browser/observable/internal/list/ObjectListQuery.js +51 -3
  125. package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -1
  126. package/build/browser/observable/internal/object/ObjectCacheKey.js +20 -1
  127. package/build/browser/observable/internal/object/ObjectCacheKey.js.map +1 -1
  128. package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.js +126 -0
  129. package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.js.map +1 -0
  130. package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.test.js +173 -0
  131. package/build/browser/observable/internal/object/ObjectCacheKeyRegistry.test.js.map +1 -0
  132. package/build/browser/observable/internal/object/ObjectQuery.js +10 -58
  133. package/build/browser/observable/internal/object/ObjectQuery.js.map +1 -1
  134. package/build/browser/observable/internal/object/ObjectsHelper.js +65 -5
  135. package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
  136. package/build/browser/observable/internal/objectMatchesWhereClause.js +3 -37
  137. package/build/browser/observable/internal/objectMatchesWhereClause.js.map +1 -1
  138. package/build/browser/observable/internal/objectMatchesWhereClause.test.js +2 -1
  139. package/build/browser/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
  140. package/build/browser/observable/internal/objectset/ObjectSetHelper.js +5 -1
  141. package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  142. package/build/browser/observable/internal/objectset/ObjectSetQuery.js +3 -0
  143. package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  144. package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -1
  145. package/build/browser/observable/internal/testUtils/invalidateList.js +6 -1
  146. package/build/browser/observable/internal/testUtils/invalidateList.js.map +1 -1
  147. package/build/browser/observable/internal/testUtils.js +5 -3
  148. package/build/browser/observable/internal/testUtils.js.map +1 -1
  149. package/build/browser/observable/internal/types/ObjectUpdate.js +2 -0
  150. package/build/browser/observable/internal/types/ObjectUpdate.js.map +1 -0
  151. package/build/browser/observable/internal/utils/rdpFieldOperations.js +83 -0
  152. package/build/browser/observable/internal/utils/rdpFieldOperations.js.map +1 -0
  153. package/build/browser/ontology/loadActionMetadata.js +3 -1
  154. package/build/browser/ontology/loadActionMetadata.js.map +1 -1
  155. package/build/browser/ontology/loadFullObjectMetadata.js +2 -1
  156. package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
  157. package/build/browser/ontology/loadInterfaceMetadata.js +2 -1
  158. package/build/browser/ontology/loadInterfaceMetadata.js.map +1 -1
  159. package/build/browser/public/internal-node.js +18 -0
  160. package/build/browser/public/internal-node.js.map +1 -0
  161. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  162. package/build/browser/queries/applyQuery.js +5 -4
  163. package/build/browser/queries/applyQuery.js.map +1 -1
  164. package/build/browser/util/UserAgent.js +2 -2
  165. package/build/browser/util/UserAgent.js.map +1 -1
  166. package/build/browser/util/extractObjectOrInterfaceType.js +5 -1
  167. package/build/browser/util/extractObjectOrInterfaceType.js.map +1 -1
  168. package/build/browser/util/extractObjectOrInterfaceType.test.js +21 -2
  169. package/build/browser/util/extractObjectOrInterfaceType.test.js.map +1 -1
  170. package/build/browser/util/toDataValue.js +16 -1
  171. package/build/browser/util/toDataValue.js.map +1 -1
  172. package/build/browser/util/toDataValue.test.js +42 -2
  173. package/build/browser/util/toDataValue.test.js.map +1 -1
  174. package/build/cjs/chunk-6SCDLAU2.cjs +57 -0
  175. package/build/cjs/chunk-6SCDLAU2.cjs.map +1 -0
  176. package/build/cjs/{chunk-SDFKR62Z.cjs → chunk-HJX4D4KL.cjs} +627 -63
  177. package/build/cjs/chunk-HJX4D4KL.cjs.map +1 -0
  178. package/build/cjs/{chunk-MEL46GIF.cjs → chunk-RO7XAQOS.cjs} +454 -242
  179. package/build/cjs/chunk-RO7XAQOS.cjs.map +1 -0
  180. package/build/cjs/{createClient-BJo8T7Js.d.cts → createClient-mOlFts15.d.cts} +1 -0
  181. package/build/cjs/{delay-QK4T7RVX.cjs → delay-KIUUJ5NJ.cjs} +4 -3
  182. package/build/cjs/delay-KIUUJ5NJ.cjs.map +1 -0
  183. package/build/cjs/index.cjs +24 -8
  184. package/build/cjs/index.cjs.map +1 -1
  185. package/build/cjs/index.d.cts +10 -3
  186. package/build/cjs/public/internal-node.cjs +193767 -0
  187. package/build/cjs/public/internal-node.cjs.map +1 -0
  188. package/build/cjs/public/internal-node.d.cts +29 -0
  189. package/build/cjs/public/internal.cjs +16 -9
  190. package/build/cjs/public/internal.cjs.map +1 -1
  191. package/build/cjs/public/unstable-do-not-use.cjs +1736 -868
  192. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  193. package/build/cjs/public/unstable-do-not-use.d.cts +43 -7
  194. package/build/esm/Client.js +1 -1
  195. package/build/esm/Client.js.map +1 -1
  196. package/build/esm/MinimalClientContext.js.map +1 -1
  197. package/build/esm/actions/applyAction.js +4 -0
  198. package/build/esm/actions/applyAction.js.map +1 -1
  199. package/build/esm/createClient.js +2 -1
  200. package/build/esm/createClient.js.map +1 -1
  201. package/build/esm/createClient.test.js +19 -1
  202. package/build/esm/createClient.test.js.map +1 -1
  203. package/build/esm/createMinimalClient.js +4 -2
  204. package/build/esm/createMinimalClient.js.map +1 -1
  205. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +19 -1
  206. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  207. package/build/esm/fetchMetadata.test.js +11 -0
  208. package/build/esm/fetchMetadata.test.js.map +1 -1
  209. package/build/esm/index.js +2 -2
  210. package/build/esm/index.js.map +1 -1
  211. package/build/esm/internal/conversions/extractNamespace.js +22 -0
  212. package/build/esm/internal/conversions/extractNamespace.js.map +1 -0
  213. package/build/esm/internal/conversions/fullyQualifyPropName.js +26 -0
  214. package/build/esm/internal/conversions/fullyQualifyPropName.js.map +1 -0
  215. package/build/esm/internal/conversions/makeGeoFilterBbox.js +41 -0
  216. package/build/esm/internal/conversions/makeGeoFilterBbox.js.map +1 -0
  217. package/build/esm/internal/conversions/makeGeoFilterIntersects.js +29 -0
  218. package/build/esm/internal/conversions/makeGeoFilterIntersects.js.map +1 -0
  219. package/build/esm/internal/conversions/makeGeoFilterPolygon.js +30 -0
  220. package/build/esm/internal/conversions/makeGeoFilterPolygon.js.map +1 -0
  221. package/build/esm/internal/conversions/makeGeoFilterWithin.js +48 -0
  222. package/build/esm/internal/conversions/makeGeoFilterWithin.js.map +1 -0
  223. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +59 -105
  224. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  225. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js +309 -0
  226. package/build/esm/internal/conversions/modernToLegacyWhereClause.test.js.map +1 -1
  227. package/build/esm/object/aggregate.js +3 -0
  228. package/build/esm/object/aggregate.js.map +1 -1
  229. package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
  230. package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
  231. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +5 -1
  232. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  233. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +10 -0
  234. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  235. package/build/esm/object/convertWireToOsdkObjects.test.js +12 -0
  236. package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
  237. package/build/esm/object/fetchPage.js +13 -6
  238. package/build/esm/object/fetchPage.js.map +1 -1
  239. package/build/esm/object/formatting/applyPropertyFormatter.js +58 -0
  240. package/build/esm/object/formatting/applyPropertyFormatter.js.map +1 -0
  241. package/build/esm/object/formatting/applyPropertyFormatter.test.js +726 -0
  242. package/build/esm/object/formatting/applyPropertyFormatter.test.js.map +1 -0
  243. package/build/esm/object/formatting/formatBoolean.js +23 -0
  244. package/build/esm/object/formatting/formatBoolean.js.map +1 -0
  245. package/build/esm/object/formatting/formatDateTime.js +158 -0
  246. package/build/esm/object/formatting/formatDateTime.js.map +1 -0
  247. package/build/esm/object/formatting/formatNumber.js +242 -0
  248. package/build/esm/object/formatting/formatNumber.js.map +1 -0
  249. package/build/esm/object/formatting/propertyFormattingUtils.js +39 -0
  250. package/build/esm/object/formatting/propertyFormattingUtils.js.map +1 -0
  251. package/build/esm/object/mediaUpload.js +3 -0
  252. package/build/esm/object/mediaUpload.js.map +1 -1
  253. package/build/esm/objectSet/ObjectSetListenerWebsocket.js +17 -0
  254. package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  255. package/build/esm/objectSet/createObjectSet.js +11 -0
  256. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  257. package/build/esm/observable/ObservableClient.js.map +1 -1
  258. package/build/esm/observable/internal/BulkObjectLoader.js +12 -4
  259. package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -1
  260. package/build/esm/observable/internal/BulkObjectLoader.test.js +48 -0
  261. package/build/esm/observable/internal/BulkObjectLoader.test.js.map +1 -1
  262. package/build/esm/observable/internal/CacheKeys.js +9 -3
  263. package/build/esm/observable/internal/CacheKeys.js.map +1 -1
  264. package/build/esm/observable/internal/Canonicalizer.js +51 -0
  265. package/build/esm/observable/internal/Canonicalizer.js.map +1 -0
  266. package/build/esm/observable/internal/Changes.js.map +1 -1
  267. package/build/esm/observable/internal/IntersectCanonicalizer.js +35 -0
  268. package/build/esm/observable/internal/IntersectCanonicalizer.js.map +1 -0
  269. package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
  270. package/build/esm/observable/internal/ObservableClientImpl.js +3 -0
  271. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  272. package/build/esm/observable/internal/OrderByCanonicalizer.js +1 -4
  273. package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -1
  274. package/build/esm/observable/internal/PivotCanonicalizer.js +33 -0
  275. package/build/esm/observable/internal/PivotCanonicalizer.js.map +1 -0
  276. package/build/esm/observable/internal/RdpCanonicalizer.js +66 -0
  277. package/build/esm/observable/internal/RdpCanonicalizer.js.map +1 -0
  278. package/build/esm/observable/internal/RdpCanonicalizer.test.js +68 -0
  279. package/build/esm/observable/internal/RdpCanonicalizer.test.js.map +1 -0
  280. package/build/esm/observable/internal/SimpleWhereClause.js.map +1 -1
  281. package/build/esm/observable/internal/Store.js +172 -6
  282. package/build/esm/observable/internal/Store.js.map +1 -1
  283. package/build/esm/observable/internal/WhereClauseCanonicalizer.js +1 -1
  284. package/build/esm/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
  285. package/build/esm/observable/internal/actions/ActionApplication.js +1 -1
  286. package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -1
  287. package/build/esm/observable/internal/actions/OptimisticJob.js +3 -3
  288. package/build/esm/observable/internal/actions/OptimisticJob.js.map +1 -1
  289. package/build/esm/observable/internal/aggregation/AggregationCacheKey.js +22 -0
  290. package/build/esm/observable/internal/aggregation/AggregationCacheKey.js.map +1 -0
  291. package/build/esm/observable/internal/aggregation/AggregationQuery.js +77 -0
  292. package/build/esm/observable/internal/aggregation/AggregationQuery.js.map +1 -0
  293. package/build/esm/observable/internal/aggregation/AggregationsHelper.js +54 -0
  294. package/build/esm/observable/internal/aggregation/AggregationsHelper.js.map +1 -0
  295. package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js +33 -0
  296. package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -0
  297. package/build/esm/observable/internal/base-list/BaseListQuery.js +145 -5
  298. package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
  299. package/build/esm/observable/internal/base-list/createCollectionConnectable.js +0 -5
  300. package/build/esm/observable/internal/base-list/createCollectionConnectable.js.map +1 -1
  301. package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js +26 -13
  302. package/build/esm/observable/internal/base-list/createCollectionConnectable.test.js.map +1 -1
  303. package/build/esm/observable/internal/evaluateFilter.js +61 -0
  304. package/build/esm/observable/internal/evaluateFilter.js.map +1 -0
  305. package/build/esm/observable/internal/links/SpecificLinkCacheKey.js +33 -1
  306. package/build/esm/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
  307. package/build/esm/observable/internal/list/InterfaceListQuery.js +8 -3
  308. package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -1
  309. package/build/esm/observable/internal/list/ListCacheKey.js +24 -1
  310. package/build/esm/observable/internal/list/ListCacheKey.js.map +1 -1
  311. package/build/esm/observable/internal/list/ListQuery.js +35 -62
  312. package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
  313. package/build/esm/observable/internal/list/ListQueryOptions.js.map +1 -1
  314. package/build/esm/observable/internal/list/ListsHelper.js +18 -8
  315. package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
  316. package/build/esm/observable/internal/list/ObjectListQuery.js +51 -3
  317. package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -1
  318. package/build/esm/observable/internal/object/ObjectCacheKey.js +20 -1
  319. package/build/esm/observable/internal/object/ObjectCacheKey.js.map +1 -1
  320. package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.js +126 -0
  321. package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.js.map +1 -0
  322. package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.test.js +173 -0
  323. package/build/esm/observable/internal/object/ObjectCacheKeyRegistry.test.js.map +1 -0
  324. package/build/esm/observable/internal/object/ObjectQuery.js +10 -58
  325. package/build/esm/observable/internal/object/ObjectQuery.js.map +1 -1
  326. package/build/esm/observable/internal/object/ObjectsHelper.js +65 -5
  327. package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
  328. package/build/esm/observable/internal/objectMatchesWhereClause.js +3 -37
  329. package/build/esm/observable/internal/objectMatchesWhereClause.js.map +1 -1
  330. package/build/esm/observable/internal/objectMatchesWhereClause.test.js +2 -1
  331. package/build/esm/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
  332. package/build/esm/observable/internal/objectset/ObjectSetHelper.js +5 -1
  333. package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  334. package/build/esm/observable/internal/objectset/ObjectSetQuery.js +3 -0
  335. package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  336. package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -1
  337. package/build/esm/observable/internal/testUtils/invalidateList.js +6 -1
  338. package/build/esm/observable/internal/testUtils/invalidateList.js.map +1 -1
  339. package/build/esm/observable/internal/testUtils.js +5 -3
  340. package/build/esm/observable/internal/testUtils.js.map +1 -1
  341. package/build/esm/observable/internal/types/ObjectUpdate.js +2 -0
  342. package/build/esm/observable/internal/types/ObjectUpdate.js.map +1 -0
  343. package/build/esm/observable/internal/utils/rdpFieldOperations.js +83 -0
  344. package/build/esm/observable/internal/utils/rdpFieldOperations.js.map +1 -0
  345. package/build/esm/ontology/loadActionMetadata.js +3 -1
  346. package/build/esm/ontology/loadActionMetadata.js.map +1 -1
  347. package/build/esm/ontology/loadFullObjectMetadata.js +2 -1
  348. package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
  349. package/build/esm/ontology/loadInterfaceMetadata.js +2 -1
  350. package/build/esm/ontology/loadInterfaceMetadata.js.map +1 -1
  351. package/build/esm/public/internal-node.js +18 -0
  352. package/build/esm/public/internal-node.js.map +1 -0
  353. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  354. package/build/esm/queries/applyQuery.js +5 -4
  355. package/build/esm/queries/applyQuery.js.map +1 -1
  356. package/build/esm/util/UserAgent.js +2 -2
  357. package/build/esm/util/UserAgent.js.map +1 -1
  358. package/build/esm/util/extractObjectOrInterfaceType.js +5 -1
  359. package/build/esm/util/extractObjectOrInterfaceType.js.map +1 -1
  360. package/build/esm/util/extractObjectOrInterfaceType.test.js +21 -2
  361. package/build/esm/util/extractObjectOrInterfaceType.test.js.map +1 -1
  362. package/build/esm/util/toDataValue.js +16 -1
  363. package/build/esm/util/toDataValue.js.map +1 -1
  364. package/build/esm/util/toDataValue.test.js +42 -2
  365. package/build/esm/util/toDataValue.test.js.map +1 -1
  366. package/build/types/Client.d.ts +1 -1
  367. package/build/types/MinimalClientContext.d.ts +3 -1
  368. package/build/types/MinimalClientContext.d.ts.map +1 -1
  369. package/build/types/actions/applyAction.d.ts.map +1 -1
  370. package/build/types/createClient.d.ts +1 -0
  371. package/build/types/createClient.d.ts.map +1 -1
  372. package/build/types/index.d.ts +3 -3
  373. package/build/types/index.d.ts.map +1 -1
  374. package/build/types/internal/conversions/extractNamespace.d.ts +1 -0
  375. package/build/types/internal/conversions/extractNamespace.d.ts.map +1 -0
  376. package/build/types/internal/conversions/fullyQualifyPropName.d.ts +2 -0
  377. package/build/types/internal/conversions/fullyQualifyPropName.d.ts.map +1 -0
  378. package/build/types/internal/conversions/makeGeoFilterBbox.d.ts +3 -0
  379. package/build/types/internal/conversions/makeGeoFilterBbox.d.ts.map +1 -0
  380. package/build/types/internal/conversions/makeGeoFilterIntersects.d.ts +3 -0
  381. package/build/types/internal/conversions/makeGeoFilterIntersects.d.ts.map +1 -0
  382. package/build/types/internal/conversions/makeGeoFilterPolygon.d.ts +3 -0
  383. package/build/types/internal/conversions/makeGeoFilterPolygon.d.ts.map +1 -0
  384. package/build/types/internal/conversions/makeGeoFilterWithin.d.ts +3 -0
  385. package/build/types/internal/conversions/makeGeoFilterWithin.d.ts.map +1 -0
  386. package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts +1 -1
  387. package/build/types/internal/conversions/modernToLegacyWhereClause.d.ts.map +1 -1
  388. package/build/types/object/fetchPage.d.ts.map +1 -1
  389. package/build/types/object/formatting/applyPropertyFormatter.d.ts +18 -0
  390. package/build/types/object/formatting/applyPropertyFormatter.d.ts.map +1 -0
  391. package/build/types/object/formatting/applyPropertyFormatter.test.d.ts +1 -0
  392. package/build/types/object/formatting/applyPropertyFormatter.test.d.ts.map +1 -0
  393. package/build/types/object/formatting/formatBoolean.d.ts +5 -0
  394. package/build/types/object/formatting/formatBoolean.d.ts.map +1 -0
  395. package/build/types/object/formatting/formatDateTime.d.ts +6 -0
  396. package/build/types/object/formatting/formatDateTime.d.ts.map +1 -0
  397. package/build/types/object/formatting/formatNumber.d.ts +15 -0
  398. package/build/types/object/formatting/formatNumber.d.ts.map +1 -0
  399. package/build/types/object/formatting/propertyFormattingUtils.d.ts +10 -0
  400. package/build/types/object/formatting/propertyFormattingUtils.d.ts.map +1 -0
  401. package/build/types/object/mediaUpload.d.ts +2 -1
  402. package/build/types/object/mediaUpload.d.ts.map +1 -1
  403. package/build/types/observable/ObservableClient.d.ts +60 -5
  404. package/build/types/observable/ObservableClient.d.ts.map +1 -1
  405. package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -1
  406. package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
  407. package/build/types/observable/internal/Canonicalizer.d.ts +37 -0
  408. package/build/types/observable/internal/Canonicalizer.d.ts.map +1 -0
  409. package/build/types/observable/internal/Changes.d.ts +4 -3
  410. package/build/types/observable/internal/Changes.d.ts.map +1 -1
  411. package/build/types/observable/internal/IntersectCanonicalizer.d.ts +18 -0
  412. package/build/types/observable/internal/IntersectCanonicalizer.d.ts.map +1 -0
  413. package/build/types/observable/internal/KnownCacheKey.d.ts +2 -1
  414. package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -1
  415. package/build/types/observable/internal/OrderByCanonicalizer.d.ts.map +1 -1
  416. package/build/types/observable/internal/PivotCanonicalizer.d.ts +10 -0
  417. package/build/types/observable/internal/PivotCanonicalizer.d.ts.map +1 -0
  418. package/build/types/observable/internal/RdpCanonicalizer.d.ts +8 -0
  419. package/build/types/observable/internal/RdpCanonicalizer.d.ts.map +1 -0
  420. package/build/types/observable/internal/RdpCanonicalizer.test.d.ts +1 -0
  421. package/build/types/observable/internal/RdpCanonicalizer.test.d.ts.map +1 -0
  422. package/build/types/observable/internal/SimpleWhereClause.d.ts +6 -2
  423. package/build/types/observable/internal/SimpleWhereClause.d.ts.map +1 -1
  424. package/build/types/observable/internal/Store.d.ts +10 -0
  425. package/build/types/observable/internal/Store.d.ts.map +1 -1
  426. package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts +5 -2
  427. package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts.map +1 -1
  428. package/build/types/observable/internal/actions/ActionApplication.d.ts.map +1 -1
  429. package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts +12 -0
  430. package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts.map +1 -0
  431. package/build/types/observable/internal/aggregation/AggregationQuery.d.ts +49 -0
  432. package/build/types/observable/internal/aggregation/AggregationQuery.d.ts.map +1 -0
  433. package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts +37 -0
  434. package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts.map +1 -0
  435. package/build/types/observable/internal/aggregation/ObjectAggregationQuery.d.ts +5 -0
  436. package/build/types/observable/internal/aggregation/ObjectAggregationQuery.d.ts.map +1 -0
  437. package/build/types/observable/internal/base-list/BaseListQuery.d.ts +48 -2
  438. package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -1
  439. package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts +1 -23
  440. package/build/types/observable/internal/base-list/createCollectionConnectable.d.ts.map +1 -1
  441. package/build/types/observable/internal/evaluateFilter.d.ts +6 -0
  442. package/build/types/observable/internal/evaluateFilter.d.ts.map +1 -0
  443. package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts +5 -0
  444. package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts.map +1 -1
  445. package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -1
  446. package/build/types/observable/internal/list/ListCacheKey.d.ts +10 -1
  447. package/build/types/observable/internal/list/ListCacheKey.d.ts.map +1 -1
  448. package/build/types/observable/internal/list/ListQuery.d.ts +12 -15
  449. package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
  450. package/build/types/observable/internal/list/ListQueryOptions.d.ts +9 -1
  451. package/build/types/observable/internal/list/ListQueryOptions.d.ts.map +1 -1
  452. package/build/types/observable/internal/list/ListsHelper.d.ts +7 -1
  453. package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
  454. package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -1
  455. package/build/types/observable/internal/object/ObjectCacheKey.d.ts +6 -1
  456. package/build/types/observable/internal/object/ObjectCacheKey.d.ts.map +1 -1
  457. package/build/types/observable/internal/object/ObjectCacheKeyRegistry.d.ts +60 -0
  458. package/build/types/observable/internal/object/ObjectCacheKeyRegistry.d.ts.map +1 -0
  459. package/build/types/observable/internal/object/ObjectCacheKeyRegistry.test.d.ts +1 -0
  460. package/build/types/observable/internal/object/ObjectCacheKeyRegistry.test.d.ts.map +1 -0
  461. package/build/types/observable/internal/object/ObjectQuery.d.ts +1 -1
  462. package/build/types/observable/internal/object/ObjectQuery.d.ts.map +1 -1
  463. package/build/types/observable/internal/object/ObjectsHelper.d.ts +15 -1
  464. package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -1
  465. package/build/types/observable/internal/objectMatchesWhereClause.d.ts.map +1 -1
  466. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -1
  467. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +2 -1
  468. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
  469. package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts +1 -0
  470. package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts.map +1 -1
  471. package/build/types/observable/internal/testUtils.d.ts +1 -1
  472. package/build/types/observable/internal/testUtils.d.ts.map +1 -1
  473. package/build/types/observable/internal/types/ObjectUpdate.d.ts +11 -0
  474. package/build/types/observable/internal/types/ObjectUpdate.d.ts.map +1 -0
  475. package/build/types/observable/internal/utils/rdpFieldOperations.d.ts +5 -0
  476. package/build/types/observable/internal/utils/rdpFieldOperations.d.ts.map +1 -0
  477. package/build/types/public/internal-node.d.ts +2 -0
  478. package/build/types/public/internal-node.d.ts.map +1 -0
  479. package/build/types/public/unstable-do-not-use.d.ts +1 -1
  480. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  481. package/build/types/queries/applyQuery.d.ts.map +1 -1
  482. package/internal-node.d.ts +17 -0
  483. package/package.json +23 -13
  484. package/build/cjs/chunk-MEL46GIF.cjs.map +0 -1
  485. package/build/cjs/chunk-Q7SFCCGT.cjs +0 -11
  486. package/build/cjs/chunk-Q7SFCCGT.cjs.map +0 -1
  487. package/build/cjs/chunk-SDFKR62Z.cjs.map +0 -1
  488. package/build/cjs/delay-QK4T7RVX.cjs.map +0 -1
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkSDFKR62Z_cjs = require('../chunk-SDFKR62Z.cjs');
4
- var chunkMEL46GIF_cjs = require('../chunk-MEL46GIF.cjs');
5
- require('../chunk-Q7SFCCGT.cjs');
3
+ var chunkHJX4D4KL_cjs = require('../chunk-HJX4D4KL.cjs');
4
+ var chunkRO7XAQOS_cjs = require('../chunk-RO7XAQOS.cjs');
5
+ var chunk6SCDLAU2_cjs = require('../chunk-6SCDLAU2.cjs');
6
6
  var trie = require('@wry/trie');
7
- var deepEqual5 = require('fast-deep-equal');
8
- var invariant3 = require('tiny-invariant');
7
+ var deepEqual = require('fast-deep-equal');
8
+ var invariant4 = require('tiny-invariant');
9
9
  var shared_net_fetch = require('@osdk/shared.net.fetch');
10
10
  var rxjs = require('rxjs');
11
11
  var mnemonist = require('mnemonist');
@@ -14,10 +14,21 @@ var shared_net_errors = require('@osdk/shared.net.errors');
14
14
 
15
15
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
16
16
 
17
- var deepEqual5__default = /*#__PURE__*/_interopDefault(deepEqual5);
18
- var invariant3__default = /*#__PURE__*/_interopDefault(invariant3);
17
+ var deepEqual__default = /*#__PURE__*/_interopDefault(deepEqual);
18
+ var invariant4__default = /*#__PURE__*/_interopDefault(invariant4);
19
19
  var groupBy__default = /*#__PURE__*/_interopDefault(groupBy);
20
20
 
21
+ // src/public/unstable-do-not-use.ts
22
+ chunk6SCDLAU2_cjs.init_cjs_shims();
23
+
24
+ // src/observable/computeObjectSetCacheKey.ts
25
+ chunk6SCDLAU2_cjs.init_cjs_shims();
26
+
27
+ // src/observable/internal/OrderByCanonicalizer.ts
28
+ chunk6SCDLAU2_cjs.init_cjs_shims();
29
+
30
+ // src/observable/internal/WeakRefTrie.ts
31
+ chunk6SCDLAU2_cjs.init_cjs_shims();
21
32
  var defaultMakeData = () => /* @__PURE__ */ Object.create(null);
22
33
  var WeakRefTrie = class {
23
34
  #finalizer = new FinalizationRegistry((orderBy) => {
@@ -62,10 +73,7 @@ var OrderByCanonicalizer = class {
62
73
  }
63
74
  return result;
64
75
  }, []);
65
- let data = Object.fromEntries(pairs);
66
- if (process.env.NODE_ENV !== "production") {
67
- data = Object.freeze(data);
68
- }
76
+ const data = Object.fromEntries(pairs);
69
77
  return data;
70
78
  });
71
79
  canonicalize = (orderBy) => {
@@ -73,6 +81,9 @@ var OrderByCanonicalizer = class {
73
81
  return this.#trie.lookupArray(strings);
74
82
  };
75
83
  };
84
+
85
+ // src/observable/internal/WhereClauseCanonicalizer.ts
86
+ chunk6SCDLAU2_cjs.init_cjs_shims();
76
87
  var WhereClauseCanonicalizer = class {
77
88
  /**
78
89
  * This is a shortcut cache for any WhereClause's that we have
@@ -105,7 +116,7 @@ var WhereClauseCanonicalizer = class {
105
116
  options: []
106
117
  };
107
118
  this.#existingOptions.set(cacheKey, lookupEntry);
108
- const canon = lookupEntry.options.find((ref) => deepEqual5__default.default(ref.deref(), calculatedCanon))?.deref() ?? calculatedCanon;
119
+ const canon = lookupEntry.options.find((ref) => deepEqual__default.default(ref.deref(), calculatedCanon))?.deref() ?? calculatedCanon;
109
120
  if (canon === calculatedCanon) {
110
121
  lookupEntry.options.push(new WeakRef(canon));
111
122
  }
@@ -115,8 +126,8 @@ var WhereClauseCanonicalizer = class {
115
126
  #toCanon = (where, set = /* @__PURE__ */ new Set()) => {
116
127
  if ("$and" in where) {
117
128
  if (process.env.NODE_ENV !== "production") {
118
- !Array.isArray(where.$and) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected $and to be an array") : invariant3__default.default(false) : void 0;
119
- !(Object.keys(where).length === 1) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected only $and to be present") : invariant3__default.default(false) : void 0;
129
+ !Array.isArray(where.$and) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected $and to be an array") : invariant4__default.default(false) : void 0;
130
+ !(Object.keys(where).length === 1) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected only $and to be present") : invariant4__default.default(false) : void 0;
120
131
  }
121
132
  if (where.$and.length === 0) {
122
133
  return {};
@@ -130,7 +141,7 @@ var WhereClauseCanonicalizer = class {
130
141
  if (k === "$and" || k === "$or") {
131
142
  return [k, v.map((x) => this.#toCanon(x, set))];
132
143
  }
133
- if (k !== "$not" && typeof v === "object" && "$eq" in v) {
144
+ if (k !== "$not" && typeof v === "object" && v != null && "$eq" in v) {
134
145
  return [k, v["$eq"]];
135
146
  }
136
147
  return [k, v];
@@ -142,7 +153,7 @@ var WhereClauseCanonicalizer = class {
142
153
  var whereCanonicalizer = new WhereClauseCanonicalizer();
143
154
  var orderByCanonicalizer = new OrderByCanonicalizer();
144
155
  function computeObjectSetCacheKey(objectSet, options) {
145
- const keyParts = ["objectSet", chunkMEL46GIF_cjs.getWireObjectSet(objectSet)];
156
+ const keyParts = ["objectSet", chunkRO7XAQOS_cjs.getWireObjectSet(objectSet)];
146
157
  if (!options) {
147
158
  return JSON.stringify(keyParts);
148
159
  }
@@ -154,13 +165,13 @@ function computeObjectSetCacheKey(objectSet, options) {
154
165
  keyParts.push("props", propKeys);
155
166
  }
156
167
  if (options.union && options.union.length > 0) {
157
- keyParts.push("union", options.union.map((os) => chunkMEL46GIF_cjs.getWireObjectSet(os)));
168
+ keyParts.push("union", options.union.map((os) => chunkRO7XAQOS_cjs.getWireObjectSet(os)));
158
169
  }
159
170
  if (options.intersect && options.intersect.length > 0) {
160
- keyParts.push("intersect", options.intersect.map((os) => chunkMEL46GIF_cjs.getWireObjectSet(os)));
171
+ keyParts.push("intersect", options.intersect.map((os) => chunkRO7XAQOS_cjs.getWireObjectSet(os)));
161
172
  }
162
173
  if (options.subtract && options.subtract.length > 0) {
163
- keyParts.push("subtract", options.subtract.map((os) => chunkMEL46GIF_cjs.getWireObjectSet(os)));
174
+ keyParts.push("subtract", options.subtract.map((os) => chunkRO7XAQOS_cjs.getWireObjectSet(os)));
164
175
  }
165
176
  if (options.pivotTo) {
166
177
  keyParts.push("pivotTo", options.pivotTo);
@@ -174,7 +185,14 @@ function computeObjectSetCacheKey(objectSet, options) {
174
185
  return JSON.stringify(keyParts);
175
186
  }
176
187
 
188
+ // src/observable/ObservableClient.ts
189
+ chunk6SCDLAU2_cjs.init_cjs_shims();
190
+
191
+ // src/observable/internal/ObservableClientImpl.ts
192
+ chunk6SCDLAU2_cjs.init_cjs_shims();
193
+
177
194
  // src/observable/internal/UnsubscribableWrapper.ts
195
+ chunk6SCDLAU2_cjs.init_cjs_shims();
178
196
  var UnsubscribableWrapper = class {
179
197
  #subscription;
180
198
  constructor(subscription) {
@@ -210,6 +228,9 @@ var ObservableClientImpl = class {
210
228
  subFn
211
229
  );
212
230
  };
231
+ observeAggregation = (options, subFn) => {
232
+ return this.__experimentalStore.aggregations.observe(options, subFn);
233
+ };
213
234
  observeLinks = (objects, linkName, options, subFn) => {
214
235
  const objectsArray = Array.isArray(objects) ? objects : [objects];
215
236
  const parentSub = new rxjs.Subscription();
@@ -255,11 +276,22 @@ var ObservableClientImpl = class {
255
276
  }
256
277
  };
257
278
 
279
+ // src/observable/internal/Store.ts
280
+ chunk6SCDLAU2_cjs.init_cjs_shims();
281
+
258
282
  // src/observable/DebugFlags.ts
283
+ chunk6SCDLAU2_cjs.init_cjs_shims();
259
284
  process.env.NODE_ENV !== "production" && false;
260
285
  var DEBUG_CACHE_KEYS = process.env.NODE_ENV !== "production" && false;
261
286
 
287
+ // src/observable/internal/actions/ActionApplication.ts
288
+ chunk6SCDLAU2_cjs.init_cjs_shims();
289
+
290
+ // src/observable/internal/actions/OptimisticJob.ts
291
+ chunk6SCDLAU2_cjs.init_cjs_shims();
292
+
262
293
  // src/observable/internal/OptimisticId.ts
294
+ chunk6SCDLAU2_cjs.init_cjs_shims();
263
295
  function createOptimisticId() {
264
296
  if (process.env.NODE_ENV !== "production") {
265
297
  if (createOptimisticId.counter === void 0) {
@@ -292,7 +324,7 @@ var OptimisticJob = class {
292
324
  store.objects.getQuery({
293
325
  apiName: obj.value.$objectType,
294
326
  pk: obj.value.$primaryKey
295
- }).writeToStore(obj.value, "loading", batch);
327
+ }, void 0).writeToStore(obj.value, "loading", batch);
296
328
  } else {
297
329
  throw obj;
298
330
  }
@@ -301,13 +333,13 @@ var OptimisticJob = class {
301
333
  store.objects.getQuery({
302
334
  apiName: obj.$objectType,
303
335
  pk: obj.$primaryKey
304
- }).writeToStore(obj, "loading", batch);
336
+ }, void 0).writeToStore(obj, "loading", batch);
305
337
  }
306
338
  for (const obj of deletedObjects) {
307
339
  store.objects.getQuery({
308
340
  apiName: obj.$objectType,
309
341
  pk: obj.$primaryKey
310
- }).deleteFromStore("loading", batch);
342
+ }, void 0).deleteFromStore("loading", batch);
311
343
  }
312
344
  });
313
345
  return batchResult.changes;
@@ -319,7 +351,7 @@ var OptimisticJob = class {
319
351
  return this;
320
352
  },
321
353
  createObject(type, pk, properties) {
322
- const create = store.client[chunkMEL46GIF_cjs.additionalContext].objectFactory2(store.client[chunkMEL46GIF_cjs.additionalContext], [{
354
+ const create = store.client[chunkRO7XAQOS_cjs.additionalContext].objectFactory2(store.client[chunkRO7XAQOS_cjs.additionalContext], [{
323
355
  $primaryKey: pk,
324
356
  $apiName: type.apiName,
325
357
  $objectType: type.apiName,
@@ -386,7 +418,7 @@ var ActionApplication = class {
386
418
  if (process.env.NODE_ENV !== "production") {
387
419
  if (ACTION_DELAY > 0) {
388
420
  logger?.debug("action done, pausing", actionResults);
389
- const delay = (await import('../delay-QK4T7RVX.cjs')).default;
421
+ const delay = (await import('../delay-KIUUJ5NJ.cjs')).default;
390
422
  await delay(ACTION_DELAY);
391
423
  logger?.debug("action done, pausing done");
392
424
  }
@@ -421,7 +453,13 @@ var ActionApplication = class {
421
453
  objectType,
422
454
  primaryKey
423
455
  } of deletedObjects ?? []) {
424
- const cacheKey = this.store.cacheKeys.get("object", objectType, primaryKey);
456
+ const cacheKey = this.store.cacheKeys.get(
457
+ "object",
458
+ objectType,
459
+ primaryKey,
460
+ /* rdpConfig */
461
+ void 0
462
+ );
425
463
  this.store.queries.peek(cacheKey)?.deleteFromStore(
426
464
  "loaded",
427
465
  // this is probably not the best value to use
@@ -438,727 +476,950 @@ var ActionApplication = class {
438
476
  };
439
477
  };
440
478
 
441
- // src/observable/internal/RefCounts.ts
442
- var RefCounts = class {
443
- refCounts = /* @__PURE__ */ new Map();
444
- // keeps our objects around for some extended duration after they are no longer
445
- // needed which is good for quick clicks across tabs.
446
- gcMap = /* @__PURE__ */ new Map();
447
- constructor(keepAlive, cleanup) {
448
- this.keepAlive = keepAlive;
449
- this.cleanup = cleanup;
450
- }
451
- register(key) {
452
- if (!this.refCounts.has(key)) {
453
- this.gcMap.set(key, Date.now() + this.keepAlive);
454
- }
455
- return key;
456
- }
457
- retain(key) {
458
- const count = this.refCounts.get(key) ?? 0;
459
- this.refCounts.set(key, count + 1);
460
- if (this.gcMap.has(key)) {
461
- this.gcMap.delete(key);
462
- }
479
+ // src/observable/internal/aggregation/AggregationCacheKey.ts
480
+ chunk6SCDLAU2_cjs.init_cjs_shims();
481
+ var API_NAME_IDX = 1;
482
+ var WHERE_IDX = 2;
483
+ var RDP_IDX = 3;
484
+ var AGGREGATE_IDX = 4;
485
+
486
+ // src/observable/internal/aggregation/AggregationsHelper.ts
487
+ chunk6SCDLAU2_cjs.init_cjs_shims();
488
+
489
+ // src/observable/internal/AbstractHelper.ts
490
+ chunk6SCDLAU2_cjs.init_cjs_shims();
491
+
492
+ // src/observable/internal/QuerySubscription.ts
493
+ chunk6SCDLAU2_cjs.init_cjs_shims();
494
+ var subscriptionIdCounter = 0;
495
+ var QuerySubscription = class extends UnsubscribableWrapper {
496
+ /** @internal */
497
+ /** @internal */
498
+ /** @internal */
499
+ constructor(query, subscription) {
500
+ super(subscription);
501
+ this.query = query;
502
+ this.subscription = subscription;
503
+ this.subscriptionId = `sub_${++subscriptionIdCounter}`;
504
+ Object.defineProperties(this, {
505
+ query: {
506
+ enumerable: false
507
+ },
508
+ subscription: {
509
+ enumerable: false
510
+ },
511
+ subscriptionId: {
512
+ enumerable: false
513
+ }
514
+ });
463
515
  }
464
- release(key) {
465
- const count = this.refCounts.get(key);
466
- if (count === void 0) ; else if (count === 1) {
467
- this.refCounts.delete(key);
468
- this.gcMap.set(key, Date.now() + this.keepAlive);
469
- } else {
470
- this.refCounts.set(key, count - 1);
471
- }
516
+ };
517
+
518
+ // src/observable/internal/AbstractHelper.ts
519
+ var AbstractHelper = class {
520
+ constructor(store, cacheKeys) {
521
+ this.store = store;
522
+ this.cacheKeys = cacheKeys;
472
523
  }
473
- has(key) {
474
- return this.refCounts.has(key);
524
+ observe(options, subFn) {
525
+ const query = this.getQuery(options);
526
+ return this._subscribe(query, options, subFn);
475
527
  }
476
- gc() {
477
- const now = Date.now();
478
- for (const [key, deathTime] of this.gcMap) {
479
- if (deathTime < now) {
480
- this.gcMap.delete(key);
481
- this.cleanup(key);
482
- }
528
+ _subscribe(query, options, subFn) {
529
+ this.store.cacheKeys.retain(query.cacheKey);
530
+ if (options.mode !== "offline") {
531
+ query.revalidate(options.mode === "force").catch((e) => {
532
+ subFn.error(e);
533
+ if (this.store.logger) {
534
+ this.store.logger.error("Unhandled error in observeObject", e);
535
+ } else {
536
+ throw e;
537
+ }
538
+ });
483
539
  }
540
+ const sub = query.subscribe(subFn);
541
+ const querySub = new QuerySubscription(query, sub);
542
+ query.registerSubscriptionDedupeInterval(querySub.subscriptionId, options.dedupeInterval);
543
+ sub.add(() => {
544
+ query.unregisterSubscriptionDedupeInterval(querySub.subscriptionId);
545
+ this.store.cacheKeys.release(query.cacheKey);
546
+ });
547
+ return querySub;
484
548
  }
485
549
  };
486
550
 
487
- // src/observable/internal/CacheKeys.ts
488
- var CacheKeys = class {
489
- #cacheKeys = new trie.Trie(false, (keys) => {
490
- const cacheKey = {
491
- type: keys[0],
492
- otherKeys: keys.slice(1)
493
- };
494
- this.#onCreate?.(cacheKey);
495
- return cacheKey;
496
- });
497
- #refCounts = new RefCounts(6e4, (k) => this.#cleanupCacheKey(k));
498
- // we are currently only using this for debug logging and should just remove it in the future if that
499
- // continues to be true
500
- #finalizationRegistry;
501
- #onCreate;
502
- #onDestroy;
503
- constructor({
504
- onCreate,
505
- onDestroy
506
- }) {
507
- this.#onCreate = onCreate;
508
- this.#onDestroy = onDestroy;
509
- setInterval(() => {
510
- this.#refCounts.gc();
511
- }, 1e3);
512
- this.#finalizationRegistry = new FinalizationRegistry((cleanupCallback) => {
513
- try {
514
- cleanupCallback();
515
- } catch (e) {
516
- console.error("Caught an error while running a finalization callback", e);
551
+ // src/observable/internal/aggregation/ObjectAggregationQuery.ts
552
+ chunk6SCDLAU2_cjs.init_cjs_shims();
553
+
554
+ // src/observable/internal/aggregation/AggregationQuery.ts
555
+ chunk6SCDLAU2_cjs.init_cjs_shims();
556
+
557
+ // src/observable/internal/Query.ts
558
+ chunk6SCDLAU2_cjs.init_cjs_shims();
559
+ var Query = class {
560
+ retainCount = 0;
561
+ #connectable;
562
+ #subscription;
563
+ #subject;
564
+ #subscriptionDedupeIntervals = /* @__PURE__ */ new Map();
565
+ /** @internal */
566
+ constructor(store, observable, opts, cacheKey, logger) {
567
+ this.options = opts;
568
+ this.cacheKey = cacheKey;
569
+ this.store = store;
570
+ this.cacheKeys = store.cacheKeys;
571
+ this.#subject = observable;
572
+ this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkRO7XAQOS_cjs.additionalContext].logger : store.client[chunkRO7XAQOS_cjs.additionalContext].logger?.child({}, {
573
+ msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
574
+ }));
575
+ }
576
+ subscribe(observer) {
577
+ this.#connectable ??= this._createConnectable(this.#subject);
578
+ this.#subscription = this.#connectable.connect();
579
+ const sub = this.#connectable.subscribe({
580
+ next: (value) => {
581
+ if (observer.next) {
582
+ observer.next(value);
583
+ }
584
+ },
585
+ error: (err) => {
586
+ if (observer.error) {
587
+ observer.error(err);
588
+ }
589
+ },
590
+ complete: () => {
591
+ if (observer.complete) {
592
+ observer.complete();
593
+ }
517
594
  }
518
595
  });
596
+ return sub;
519
597
  }
520
- get(type, ...args) {
521
- const cacheKeyArgs = [type, ...args];
522
- if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) ;
523
- const cacheKey = this.#cacheKeys.lookupArray(cacheKeyArgs);
524
- this.#refCounts.register(cacheKey);
525
- return cacheKey;
526
- }
527
- retain(cacheKey) {
528
- this.#refCounts.retain(cacheKey);
529
- }
530
- release(cacheKey) {
531
- this.#refCounts.release(cacheKey);
532
- }
533
- #remove(cacheKey) {
534
- this.#cacheKeys.remove(cacheKey.type, ...cacheKey.otherKeys);
598
+ /**
599
+ * Register a subscription's dedupeInterval value
600
+ */
601
+ registerSubscriptionDedupeInterval(subscriptionId, dedupeInterval) {
602
+ if (dedupeInterval != null && dedupeInterval > 0) {
603
+ this.#subscriptionDedupeIntervals.set(subscriptionId, dedupeInterval);
604
+ }
535
605
  }
536
606
  /**
537
- * Called after a key is no longer retained and the timeout has elapsed
538
- * @param key
607
+ * Unregister a subscription's dedupeInterval value
539
608
  */
540
- #cleanupCacheKey = (key) => {
541
- this.#onDestroy?.(key);
542
- this.#remove(key);
543
- };
544
- };
545
-
546
- // src/observable/internal/CacheKey.ts
547
- function DEBUG_ONLY__cacheKeyToString(x) {
548
- if (process.env.NODE_ENV !== "production") {
549
- return `${x.type}CacheKey<${x.otherKeys.map((xx) => JSON.stringify(xx)).join(", ")}>`.replaceAll('"', "'");
550
- } else {
551
- throw new Error("not implemented");
609
+ unregisterSubscriptionDedupeInterval(subscriptionId) {
610
+ this.#subscriptionDedupeIntervals.delete(subscriptionId);
552
611
  }
553
- }
554
- function DEBUG_ONLY__cacheKeysToString(x) {
555
- if (process.env.NODE_ENV !== "production") {
556
- return "\n - " + x.map(DEBUG_ONLY__cacheKeyToString).join("\n - ");
557
- } else {
558
- throw new Error("not implemented");
559
- }
560
- }
561
-
562
- // src/observable/internal/Changes.ts
563
- var Changes = class {
564
- modifiedObjects = new mnemonist.MultiMap();
565
- addedObjects = new mnemonist.MultiMap();
566
- added = /* @__PURE__ */ new Set();
567
- modified = /* @__PURE__ */ new Set();
568
- deleted = /* @__PURE__ */ new Set();
569
- registerObject = (cacheKey, data, isNew) => {
570
- this[isNew ? "addedObjects" : "modifiedObjects"].set(data.$apiName, data);
571
- this[isNew ? "added" : "modified"].add(cacheKey);
572
- };
573
- deleteObject = (cacheKey) => {
574
- this.deleted.add(cacheKey);
575
- };
576
- registerList = (key) => {
577
- this.modified.add(key);
578
- };
579
- registerLink = (cacheKey) => {
580
- this.modified.add(cacheKey);
581
- };
582
- deleteLink = (cacheKey) => {
583
- this.deleted.add(cacheKey);
584
- };
585
- registerObjectSet = (key) => {
586
- this.modified.add(key);
587
- };
588
- isEmpty() {
589
- return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0 && this.deleted.size === 0;
590
- }
591
- };
592
- function createChangedObjects() {
593
- return new Changes();
594
- }
595
- function DEBUG_ONLY__changesToString(changes) {
596
- if (process.env.NODE_ENV !== "production") {
597
- return JSON.stringify({
598
- modifiedObjects: multimapHelper(changes.modifiedObjects),
599
- addedObjects: multimapHelper(changes.addedObjects),
600
- added: listHelper(changes.added),
601
- modified: listHelper(changes.modified)
602
- }, null, 2);
603
- } else {
604
- throw new Error("not implemented");
605
- }
606
- }
607
- function listHelper(set) {
608
- return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);
609
- }
610
- function multimapHelper(multimap) {
611
- return Object.fromEntries(Array.from(multimap.associations()).map(([type, objects]) => {
612
- return [type, objects.map((o) => o.$primaryKey)];
613
- }));
614
- }
615
-
616
- // src/observable/internal/createInitEntry.ts
617
- function createInitEntry(cacheKey) {
618
- return {
619
- cacheKey,
620
- status: "init",
621
- value: void 0,
622
- lastUpdated: 0
623
- };
624
- }
625
-
626
- // src/observable/internal/WeakMapWithEntries.ts
627
- var WeakMapWithEntries = class {
628
- #map = /* @__PURE__ */ new WeakMap();
629
- #list = [];
630
- #toClean = [];
631
- #needsCleaning = false;
632
- #registry = new FinalizationRegistry(() => {
633
- this.#toClean.push(new WeakRef({}));
634
- this.#needsCleaning = true;
635
- });
636
- constructor() {
637
- const weakThis = new WeakRef(this);
638
- const intervalId = setInterval(() => {
639
- const self = weakThis.deref();
640
- if (self) {
641
- if (this.#needsCleaning) {
642
- this.#clean();
643
- }
644
- } else {
645
- clearInterval(intervalId);
646
- }
647
- }, 1e3);
648
- }
649
- #clean() {
650
- this.#list = this.#list.filter((ref) => ref.deref() !== void 0);
651
- }
652
- // functions for WeakMap
653
- delete(key) {
654
- const ret = this.#map.delete(key);
655
- this.#toClean.push(new WeakRef(key));
656
- this.#needsCleaning = true;
657
- return ret;
658
- }
659
- get(key) {
660
- return this.#map.get(key);
661
- }
662
- has(key) {
663
- return this.#map.has(key);
612
+ /**
613
+ * Get the minimum dedupeInterval from all active subscriptions
614
+ */
615
+ getMinimumDedupeInterval() {
616
+ if (this.#subscriptionDedupeIntervals.size === 0) {
617
+ return this.options.dedupeInterval ?? 0;
618
+ }
619
+ return Math.min(...this.#subscriptionDedupeIntervals.values());
664
620
  }
665
621
  /**
666
- * Adds a new element with a specified key and value.
667
- * @param key Must be an object or symbol.
622
+ * Causes the query to revalidate. This will cause the query to fetch
623
+ * the latest data from the server and update the store if it is deemed
624
+ * "stale" or if `force` is true.
625
+ *
626
+ * @param force
627
+ * @returns
668
628
  */
669
- set(key, value) {
670
- if (!this.#map.has(key)) {
671
- this.#list.push(new WeakRef(key));
629
+ async revalidate(force) {
630
+ const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
631
+ methodName: "revalidate"
632
+ }) : this.logger;
633
+ if (force) {
634
+ this.abortController?.abort();
672
635
  }
673
- this.#map.set(key, value);
674
- return this;
636
+ if (this.pendingFetch) {
637
+ if (process.env.NODE_ENV !== "production") {
638
+ logger?.debug("Fetch is already pending, using it");
639
+ }
640
+ await this.pendingFetch;
641
+ return;
642
+ }
643
+ const minDedupeInterval = this.getMinimumDedupeInterval();
644
+ if (minDedupeInterval > 0 && this.lastFetchStarted != null && Date.now() - this.lastFetchStarted < minDedupeInterval) {
645
+ if (process.env.NODE_ENV !== "production") {
646
+ logger?.debug("Within dupeInterval, aborting revalidate");
647
+ }
648
+ return Promise.resolve();
649
+ }
650
+ if (process.env.NODE_ENV !== "production") {
651
+ logger?.debug("Starting actual revalidate");
652
+ }
653
+ this.store.batch({}, (batch) => {
654
+ this.setStatus("loading", batch);
655
+ });
656
+ this._preFetch();
657
+ this.lastFetchStarted = Date.now();
658
+ if (process.env.NODE_ENV !== "production") {
659
+ logger?.debug("calling _fetchAndStore()");
660
+ }
661
+ this.pendingFetch = this._fetchAndStore().finally(() => {
662
+ logger?.debug("promise's finally for _fetchAndStore()");
663
+ this.pendingFetch = void 0;
664
+ });
665
+ await this.pendingFetch;
666
+ return;
675
667
  }
676
- [Symbol.toStringTag] = "WeakMap";
677
- // functions for iterables
678
- /** Returns an iterable of entries in the map. */
679
- [Symbol.iterator]() {
680
- return this.entries();
668
+ _preFetch() {
681
669
  }
682
670
  /**
683
- * Returns an iterable of key, value pairs for every entry in the map.
671
+ * Sets the status of the query in the store (but does not store that in `changes`).
672
+ *
673
+ * @param status
674
+ * @param batch
675
+ * @returns
684
676
  */
685
- entries() {
686
- const self = this;
687
- function* iter() {
688
- for (const ref of self.#list) {
689
- const key = ref.deref();
690
- if (key !== void 0) {
691
- yield [key, self.#map.get(key)];
692
- }
677
+ setStatus(status, batch) {
678
+ if (process.env.NODE_ENV !== "production") {
679
+ this.logger?.child({
680
+ methodName: "setStatus"
681
+ }).debug(`Attempting to set status to '${status}'`);
682
+ }
683
+ const existing = batch.read(this.cacheKey);
684
+ if (existing?.status === status) {
685
+ if (process.env.NODE_ENV !== "production") {
686
+ this.logger?.child({
687
+ methodName: "setStatus"
688
+ }).debug(`Status is already set to '${status}'; aborting`);
693
689
  }
690
+ return;
694
691
  }
695
- return iter();
692
+ if (process.env.NODE_ENV !== "production") {
693
+ this.logger?.child({
694
+ methodName: "setStatus"
695
+ }).debug(`Writing status '${status}' to cache`);
696
+ }
697
+ batch.write(this.cacheKey, existing?.value, status);
696
698
  }
697
- /**
698
- * Returns an iterable of keys in the map
699
- */
700
- keys() {
701
- const self = this;
702
- function* iter() {
703
- for (const ref of self.#list) {
704
- const key = ref.deref();
705
- if (key !== void 0) {
706
- yield key;
707
- }
708
- }
699
+ dispose() {
700
+ if (this.abortController) {
701
+ this.abortController.abort();
709
702
  }
710
- return iter();
703
+ this.#subscription?.unsubscribe();
704
+ this._dispose();
711
705
  }
712
706
  /**
713
- * Returns an iterable of values in the map
707
+ * Per query type dispose functionality
714
708
  */
715
- values() {
716
- const self = this;
717
- function* iter() {
718
- for (const ref of self.#list) {
719
- const key = ref.deref();
720
- if (key !== void 0) {
721
- const value = self.#map.get(key);
722
- if (value !== void 0) {
723
- yield value;
724
- }
725
- }
726
- }
727
- }
728
- return iter();
709
+ _dispose() {
729
710
  }
711
+ /**
712
+ * The purpose of this method is to provide a way for others to write
713
+ * directly into the store for this query.
714
+ *
715
+ * @param data
716
+ * @param status
717
+ * @param batch
718
+ */
719
+ /**
720
+ * @param changes
721
+ * @param optimisticId
722
+ * @returns If revalidation is needed, a promise that resolves after the
723
+ * revalidation is complete. Otherwise, undefined.
724
+ */
730
725
  };
731
726
 
732
- // src/observable/internal/Layer.ts
733
- var Layer = class _Layer {
734
- #parent;
735
- #cache = new WeakMapWithEntries();
736
- #layerId;
737
- constructor(parent, layerId) {
738
- this.#parent = parent;
739
- this.#layerId = layerId;
740
- }
741
- get parentLayer() {
742
- return this.#parent;
743
- }
744
- get layerId() {
745
- return this.#layerId;
727
+ // src/observable/internal/aggregation/AggregationQuery.ts
728
+ var AggregationQuery = class extends Query {
729
+ constructor(store, subject, cacheKey, opts) {
730
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkRO7XAQOS_cjs.additionalContext].logger?.child({}, {
731
+ msgPrefix: `AggregationQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
732
+ }) : void 0);
733
+ this.apiName = cacheKey.otherKeys[API_NAME_IDX];
734
+ this.canonicalWhere = cacheKey.otherKeys[WHERE_IDX];
735
+ this.rdpConfig = cacheKey.otherKeys[RDP_IDX];
736
+ this.canonicalAggregate = cacheKey.otherKeys[AGGREGATE_IDX];
746
737
  }
747
- addLayer(layerId) {
748
- return new _Layer(this, layerId);
738
+ _createConnectable(subject) {
739
+ return rxjs.connectable(subject.pipe(rxjs.map((x) => {
740
+ return {
741
+ status: x.status,
742
+ result: x.value,
743
+ lastUpdated: x.lastUpdated,
744
+ error: x.status === "error" ? new Error("Aggregation failed") : void 0
745
+ };
746
+ })), {
747
+ connector: () => new rxjs.BehaviorSubject({
748
+ status: "init",
749
+ result: void 0,
750
+ lastUpdated: 0
751
+ })
752
+ });
749
753
  }
750
- removeLayer(layerId) {
751
- if (layerId == null || this.#parent == null) {
752
- return this;
753
- }
754
- if (this.#layerId !== layerId) {
755
- this.#parent = this.#parent.removeLayer(layerId);
756
- return this;
754
+ async _fetchAndStore() {
755
+ if (process.env.NODE_ENV !== "production") {
756
+ this.logger?.child({
757
+ methodName: "_fetchAndStore"
758
+ }).debug("calling _fetchAndStore");
759
+ }
760
+ try {
761
+ const result = await this._fetchAggregation();
762
+ this.store.batch({}, (batch) => {
763
+ this.writeToStore(result, "loaded", batch);
764
+ });
765
+ } catch (err) {
766
+ this.store.batch({}, (batch) => {
767
+ this.writeToStore(void 0, "error", batch);
768
+ });
757
769
  }
758
- return this.#parent.removeLayer(layerId);
759
770
  }
760
- entries() {
761
- return this.#cache.entries();
771
+ writeToStore(data, status, batch) {
772
+ batch.write(this.cacheKey, data, status);
773
+ batch.changes.modified.add(this.cacheKey);
774
+ return batch.read(this.cacheKey);
762
775
  }
763
- keys() {
764
- return this.#cache.keys();
776
+ invalidateObjectType = (objectType, changes) => {
777
+ if (this.apiName === objectType) {
778
+ changes?.modified.add(this.cacheKey);
779
+ return this.revalidate(true);
780
+ }
781
+ return Promise.resolve();
782
+ };
783
+ };
784
+
785
+ // src/observable/internal/aggregation/ObjectAggregationQuery.ts
786
+ var ObjectAggregationQuery = class extends AggregationQuery {
787
+ async _fetchAggregation() {
788
+ const type = this.cacheKey.otherKeys[API_NAME_IDX];
789
+ let objectSet = this.store.client({
790
+ type: "object",
791
+ apiName: type
792
+ });
793
+ if (this.rdpConfig) {
794
+ objectSet = objectSet.withProperties(this.rdpConfig);
795
+ }
796
+ objectSet = objectSet.where(this.canonicalWhere);
797
+ return await objectSet.aggregate(this.canonicalAggregate);
765
798
  }
766
- get(cacheKey) {
767
- return this.#cache.get(cacheKey) ?? this.#parent?.get(cacheKey);
799
+ };
800
+
801
+ // src/observable/internal/aggregation/AggregationsHelper.ts
802
+ var AggregationsHelper = class extends AbstractHelper {
803
+ constructor(store, cacheKeys, whereCanonicalizer2, rdpCanonicalizer) {
804
+ super(store, cacheKeys);
805
+ this.whereCanonicalizer = whereCanonicalizer2;
806
+ this.rdpCanonicalizer = rdpCanonicalizer;
768
807
  }
769
- set(cacheKey, value) {
770
- this.#cache.set(cacheKey, value);
808
+ observe(options, subFn) {
809
+ return super.observe(options, subFn);
771
810
  }
772
- };
773
- var Subjects = class {
774
- #layers;
775
- // we can use a regular Map here because the refCounting will
776
- // handle cleanup.
777
- #cacheKeyToSubject = /* @__PURE__ */ new WeakMap();
778
- constructor({
779
- logger,
780
- layers
781
- }) {
782
- this.logger = logger;
783
- this.#layers = layers;
811
+ getQuery(options) {
812
+ const {
813
+ type,
814
+ where,
815
+ withProperties,
816
+ aggregate
817
+ } = options;
818
+ const {
819
+ apiName
820
+ } = type;
821
+ const typeKind = "type" in type ? type.type : "interface";
822
+ const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
823
+ const canonRdp = withProperties ? this.rdpCanonicalizer.canonicalize(withProperties) : void 0;
824
+ const canonAggregate = this.canonicalizeAggregate(aggregate);
825
+ const aggregationCacheKey = this.cacheKeys.get("aggregation", typeKind, apiName, canonWhere, canonRdp, canonAggregate);
826
+ return this.store.queries.get(aggregationCacheKey, () => {
827
+ if (typeKind !== "object") {
828
+ throw new Error("Only ObjectTypeDefinition is currently supported for aggregations");
829
+ }
830
+ return new ObjectAggregationQuery(this.store, this.store.subjects.get(aggregationCacheKey), aggregationCacheKey, options);
831
+ });
832
+ }
833
+ canonicalizeAggregate(aggregate) {
834
+ return JSON.parse(JSON.stringify(aggregate));
784
835
  }
785
- peek = (cacheKey) => {
786
- return this.#cacheKeyToSubject.get(cacheKey);
787
- };
788
- get = (cacheKey) => {
789
- let subject = this.#cacheKeyToSubject.get(cacheKey);
790
- if (!subject) {
791
- const initialValue = this.#layers.top.get(cacheKey) ?? createInitEntry(cacheKey);
792
- subject = new rxjs.BehaviorSubject({
793
- ...initialValue,
794
- isOptimistic: initialValue.value !== this.#layers.truth.get(cacheKey)?.value
795
- });
796
- this.#cacheKeyToSubject.set(cacheKey, subject);
797
- }
798
- return subject;
799
- };
800
- delete = (cacheKey) => {
801
- const subject = this.peek(cacheKey);
802
- if (subject) {
803
- subject.complete();
804
- this.#cacheKeyToSubject.delete(cacheKey);
805
- }
806
- };
807
836
  };
808
837
 
809
- // src/observable/internal/tombstone.ts
810
- var tombstone = void 0;
838
+ // src/observable/internal/CacheKey.ts
839
+ chunk6SCDLAU2_cjs.init_cjs_shims();
840
+ function DEBUG_ONLY__cacheKeyToString(x) {
841
+ if (process.env.NODE_ENV !== "production") {
842
+ return `${x.type}CacheKey<${x.otherKeys.map((xx) => JSON.stringify(xx)).join(", ")}>`.replaceAll('"', "'");
843
+ } else {
844
+ throw new Error("not implemented");
845
+ }
846
+ }
847
+ function DEBUG_ONLY__cacheKeysToString(x) {
848
+ if (process.env.NODE_ENV !== "production") {
849
+ return "\n - " + x.map(DEBUG_ONLY__cacheKeyToString).join("\n - ");
850
+ } else {
851
+ throw new Error("not implemented");
852
+ }
853
+ }
811
854
 
812
- // src/observable/internal/Layers.ts
813
- var Layers = class {
814
- #truthLayer = new Layer(void 0, void 0);
815
- #topLayer;
816
- #onRevalidate;
817
- constructor({
818
- logger,
819
- onRevalidate
820
- }) {
821
- this.logger = logger;
822
- this.#topLayer = this.#truthLayer;
823
- this.subjects = new Subjects({
824
- logger,
825
- layers: this
826
- });
827
- this.#onRevalidate = onRevalidate;
855
+ // src/observable/internal/CacheKeys.ts
856
+ chunk6SCDLAU2_cjs.init_cjs_shims();
857
+
858
+ // src/observable/internal/RefCounts.ts
859
+ chunk6SCDLAU2_cjs.init_cjs_shims();
860
+ var RefCounts = class {
861
+ refCounts = /* @__PURE__ */ new Map();
862
+ // keeps our objects around for some extended duration after they are no longer
863
+ // needed which is good for quick clicks across tabs.
864
+ gcMap = /* @__PURE__ */ new Map();
865
+ constructor(keepAlive, cleanup) {
866
+ this.keepAlive = keepAlive;
867
+ this.cleanup = cleanup;
828
868
  }
829
- get top() {
830
- return this.#topLayer;
869
+ register(key) {
870
+ if (!this.refCounts.has(key)) {
871
+ this.gcMap.set(key, Date.now() + this.keepAlive);
872
+ }
873
+ return key;
831
874
  }
832
- get truth() {
833
- return this.#truthLayer;
875
+ retain(key) {
876
+ const count = this.refCounts.get(key) ?? 0;
877
+ this.refCounts.set(key, count + 1);
878
+ if (this.gcMap.has(key)) {
879
+ this.gcMap.delete(key);
880
+ }
834
881
  }
835
- remove(layerId) {
836
- !(layerId != null) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "undefined is the reserved layerId for the truth layer") : invariant3__default.default(false) : void 0;
837
- let currentLayer = this.#topLayer;
838
- const cacheKeys = /* @__PURE__ */ new Map();
839
- while (currentLayer != null && currentLayer.parentLayer != null) {
840
- if (currentLayer.layerId === layerId) {
841
- for (const [k, v] of currentLayer.entries()) {
842
- if (cacheKeys.has(k)) continue;
843
- cacheKeys.set(k, v);
844
- }
845
- }
846
- currentLayer = currentLayer.parentLayer;
882
+ release(key) {
883
+ const count = this.refCounts.get(key);
884
+ if (count === void 0) ; else if (count === 1) {
885
+ this.refCounts.delete(key);
886
+ this.gcMap.set(key, Date.now() + this.keepAlive);
887
+ } else {
888
+ this.refCounts.set(key, count - 1);
847
889
  }
848
- this.#topLayer = this.#topLayer.removeLayer(layerId);
849
- for (const [k, oldEntry] of cacheKeys) {
850
- const currentEntry = this.#topLayer.get(k);
851
- if (oldEntry !== currentEntry) {
852
- const newEntry = currentEntry ?? createInitEntry(k);
853
- this.subjects.peek(k)?.next({
854
- ...newEntry,
855
- isOptimistic: currentEntry?.value !== this.#truthLayer.get(k)?.value
856
- });
890
+ }
891
+ has(key) {
892
+ return this.refCounts.has(key);
893
+ }
894
+ gc() {
895
+ const now = Date.now();
896
+ for (const [key, deathTime] of this.gcMap) {
897
+ if (deathTime < now) {
898
+ this.gcMap.delete(key);
899
+ this.cleanup(key);
857
900
  }
858
901
  }
859
902
  }
860
- batch({
861
- optimisticId,
862
- changes
863
- }, batchFn) {
864
- !(optimisticId === void 0 || !!optimisticId) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "optimistic must be undefined or not falsy") : invariant3__default.default(false) : void 0;
865
- const batchContext = this.#createBatchContext({
866
- optimisticId,
867
- changes
868
- });
869
- const retVal = batchFn(batchContext);
870
- this.#onRevalidate(changes, optimisticId).catch((e) => {
871
- if (this.logger) {
872
- this.logger.error("Unhandled error in batch", e);
873
- } else {
874
- console.error("Unhandled error in batch", e);
875
- throw e;
876
- }
877
- });
878
- return {
879
- batchResult: batchContext,
880
- retVal,
881
- changes: batchContext.changes
903
+ };
904
+
905
+ // src/observable/internal/CacheKeys.ts
906
+ var CacheKeys = class {
907
+ #cacheKeys = new trie.Trie(false, (keys) => {
908
+ const cacheKey = {
909
+ type: keys[0],
910
+ otherKeys: keys.slice(1)
882
911
  };
883
- }
884
- #createBatchContext({
885
- optimisticId,
886
- changes
912
+ this.#onCreate?.(cacheKey);
913
+ return cacheKey;
914
+ });
915
+ #refCounts = new RefCounts(6e4, (k) => this.#cleanupCacheKey(k));
916
+ // we are currently only using this for debug logging and should just remove it in the future if that
917
+ // continues to be true
918
+ #finalizationRegistry;
919
+ #onCreate;
920
+ #onDestroy;
921
+ constructor({
922
+ onCreate,
923
+ onDestroy
887
924
  }) {
888
- let needsLayer = optimisticId !== void 0;
889
- const batchContext = {
890
- changes,
891
- createLayerIfNeeded: () => {
892
- if (needsLayer) {
893
- this.#topLayer = this.#topLayer.addLayer(optimisticId);
894
- needsLayer = false;
895
- }
896
- },
897
- optimisticWrite: !!optimisticId,
898
- write: (cacheKey, value, status) => {
899
- const oldTopValue = this.#topLayer.get(cacheKey);
900
- if (optimisticId) batchContext.createLayerIfNeeded();
901
- const writeLayer = optimisticId ? this.#topLayer : this.#truthLayer;
902
- const newValue = {
903
- cacheKey,
904
- value,
905
- lastUpdated: Date.now(),
906
- status
907
- };
908
- writeLayer.set(cacheKey, newValue);
909
- const newTopValue = this.#topLayer.get(cacheKey);
910
- if (oldTopValue !== newTopValue) {
911
- this.subjects.get(cacheKey)?.next({
912
- ...newValue,
913
- isOptimistic: newTopValue?.value !== this.#truthLayer.get(cacheKey)?.value
914
- });
915
- }
916
- return newValue;
917
- },
918
- delete: (cacheKey, status) => {
919
- return batchContext.write(cacheKey, tombstone, status);
920
- },
921
- read: (cacheKey) => {
922
- return optimisticId ? this.#topLayer.get(cacheKey) : this.#truthLayer.get(cacheKey);
925
+ this.#onCreate = onCreate;
926
+ this.#onDestroy = onDestroy;
927
+ setInterval(() => {
928
+ this.#refCounts.gc();
929
+ }, 1e3);
930
+ this.#finalizationRegistry = new FinalizationRegistry((cleanupCallback) => {
931
+ try {
932
+ cleanupCallback();
933
+ } catch (e) {
934
+ console.error("Caught an error while running a finalization callback", e);
923
935
  }
924
- };
925
- return batchContext;
936
+ });
937
+ }
938
+ get(type, ...args) {
939
+ const normalizedArgs = [...args];
940
+ while (normalizedArgs.length > 0 && normalizedArgs[normalizedArgs.length - 1] === void 0) {
941
+ normalizedArgs.pop();
942
+ }
943
+ const cacheKeyArgs = [type, ...normalizedArgs];
944
+ if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) ;
945
+ const cacheKey = this.#cacheKeys.lookupArray(cacheKeyArgs);
946
+ this.#refCounts.register(cacheKey);
947
+ return cacheKey;
948
+ }
949
+ retain(cacheKey) {
950
+ this.#refCounts.retain(cacheKey);
951
+ }
952
+ release(cacheKey) {
953
+ this.#refCounts.release(cacheKey);
954
+ }
955
+ #remove(cacheKey) {
956
+ this.#cacheKeys.remove(cacheKey.type, ...cacheKey.otherKeys);
926
957
  }
958
+ /**
959
+ * Called after a key is no longer retained and the timeout has elapsed
960
+ * @param key
961
+ */
962
+ #cleanupCacheKey = (key) => {
963
+ this.#onDestroy?.(key);
964
+ this.#remove(key);
965
+ };
927
966
  };
928
967
 
929
- // src/observable/internal/QuerySubscription.ts
930
- var subscriptionIdCounter = 0;
931
- var QuerySubscription = class extends UnsubscribableWrapper {
932
- /** @internal */
933
- /** @internal */
934
- /** @internal */
935
- constructor(query, subscription) {
936
- super(subscription);
937
- this.query = query;
938
- this.subscription = subscription;
939
- this.subscriptionId = `sub_${++subscriptionIdCounter}`;
940
- Object.defineProperties(this, {
941
- query: {
942
- enumerable: false
943
- },
944
- subscription: {
945
- enumerable: false
946
- },
947
- subscriptionId: {
948
- enumerable: false
949
- }
950
- });
968
+ // src/observable/internal/Changes.ts
969
+ chunk6SCDLAU2_cjs.init_cjs_shims();
970
+ var Changes = class {
971
+ modifiedObjects = new mnemonist.MultiMap();
972
+ addedObjects = new mnemonist.MultiMap();
973
+ added = /* @__PURE__ */ new Set();
974
+ modified = /* @__PURE__ */ new Set();
975
+ deleted = /* @__PURE__ */ new Set();
976
+ registerObject = (cacheKey, data, isNew) => {
977
+ this[isNew ? "addedObjects" : "modifiedObjects"].set(data.$apiName, data);
978
+ this[isNew ? "added" : "modified"].add(cacheKey);
979
+ };
980
+ deleteObject = (cacheKey) => {
981
+ this.deleted.add(cacheKey);
982
+ };
983
+ registerList = (key) => {
984
+ this.modified.add(key);
985
+ };
986
+ registerLink = (cacheKey) => {
987
+ this.modified.add(cacheKey);
988
+ };
989
+ deleteLink = (cacheKey) => {
990
+ this.deleted.add(cacheKey);
991
+ };
992
+ registerObjectSet = (key) => {
993
+ this.modified.add(key);
994
+ };
995
+ isEmpty() {
996
+ return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0 && this.deleted.size === 0;
951
997
  }
952
998
  };
999
+ function createChangedObjects() {
1000
+ return new Changes();
1001
+ }
1002
+ function DEBUG_ONLY__changesToString(changes) {
1003
+ if (process.env.NODE_ENV !== "production") {
1004
+ return JSON.stringify({
1005
+ modifiedObjects: multimapHelper(changes.modifiedObjects),
1006
+ addedObjects: multimapHelper(changes.addedObjects),
1007
+ added: listHelper(changes.added),
1008
+ modified: listHelper(changes.modified)
1009
+ }, null, 2);
1010
+ } else {
1011
+ throw new Error("not implemented");
1012
+ }
1013
+ }
1014
+ function listHelper(set) {
1015
+ return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);
1016
+ }
1017
+ function multimapHelper(multimap) {
1018
+ return Object.fromEntries(Array.from(multimap.associations()).map(([type, objects]) => {
1019
+ return [type, objects.map((o) => o.$primaryKey)];
1020
+ }));
1021
+ }
953
1022
 
954
- // src/observable/internal/AbstractHelper.ts
955
- var AbstractHelper = class {
956
- constructor(store, cacheKeys) {
957
- this.store = store;
958
- this.cacheKeys = cacheKeys;
1023
+ // src/observable/internal/IntersectCanonicalizer.ts
1024
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1025
+
1026
+ // src/observable/internal/Canonicalizer.ts
1027
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1028
+ var CachingCanonicalizer = class {
1029
+ /**
1030
+ * Cache for input object identity.
1031
+ */
1032
+ inputCache = /* @__PURE__ */ new WeakMap();
1033
+ /**
1034
+ * Look up or create a canonical form for the given input.
1035
+ * This method handles the structural deduplication logic.
1036
+ *
1037
+ * @param input The input to canonicalize
1038
+ * @returns The canonical form
1039
+ */
1040
+ canonicalize(input) {
1041
+ if (!input) {
1042
+ return void 0;
1043
+ }
1044
+ if (this.inputCache.has(input)) {
1045
+ return this.inputCache.get(input);
1046
+ }
1047
+ const canonical = this.lookupOrCreate(input);
1048
+ this.inputCache.set(input, canonical);
1049
+ return canonical;
959
1050
  }
960
- observe(options, subFn) {
961
- const query = this.getQuery(options);
962
- return this._subscribe(query, options, subFn);
1051
+ };
1052
+
1053
+ // src/observable/internal/IntersectCanonicalizer.ts
1054
+ var IntersectCanonicalizer = class extends CachingCanonicalizer {
1055
+ structuralCache = /* @__PURE__ */ new Map();
1056
+ constructor(whereCanonicalizer2) {
1057
+ super();
1058
+ this.whereCanonicalizer = whereCanonicalizer2;
963
1059
  }
964
- _subscribe(query, options, subFn) {
965
- this.store.cacheKeys.retain(query.cacheKey);
966
- if (options.mode !== "offline") {
967
- query.revalidate(options.mode === "force").catch((e) => {
968
- subFn.error(e);
969
- if (this.store.logger) {
970
- this.store.logger.error("Unhandled error in observeObject", e);
971
- } else {
972
- throw e;
973
- }
974
- });
1060
+ lookupOrCreate(intersectWith) {
1061
+ const canonicalClauses = intersectWith.map((item) => this.whereCanonicalizer.canonicalize(item.where ?? {}));
1062
+ const structuralKey = canonicalClauses.map((clause) => JSON.stringify(clause)).join("||");
1063
+ let canonical = this.structuralCache.get(structuralKey);
1064
+ if (!canonical) {
1065
+ canonical = canonicalClauses;
1066
+ this.structuralCache.set(structuralKey, canonical);
975
1067
  }
976
- const sub = query.subscribe(subFn);
977
- const querySub = new QuerySubscription(query, sub);
978
- query.registerSubscriptionDedupeInterval(querySub.subscriptionId, options.dedupeInterval);
979
- sub.add(() => {
980
- query.unregisterSubscriptionDedupeInterval(querySub.subscriptionId);
981
- this.store.cacheKeys.release(query.cacheKey);
982
- });
983
- return querySub;
1068
+ return canonical;
984
1069
  }
985
1070
  };
986
1071
 
987
- // src/observable/internal/isObjectInstance.ts
988
- function isObjectInstance(item) {
989
- return item != null && typeof item === "object" && "$primaryKey" in item;
1072
+ // src/observable/internal/Layers.ts
1073
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1074
+
1075
+ // src/observable/internal/createInitEntry.ts
1076
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1077
+ function createInitEntry(cacheKey) {
1078
+ return {
1079
+ cacheKey,
1080
+ status: "init",
1081
+ value: void 0,
1082
+ lastUpdated: 0
1083
+ };
990
1084
  }
991
1085
 
992
- // src/observable/internal/Query.ts
993
- var Query = class {
994
- retainCount = 0;
995
- #connectable;
996
- #subscription;
997
- #subject;
998
- #subscriptionDedupeIntervals = /* @__PURE__ */ new Map();
999
- /** @internal */
1000
- constructor(store, observable, opts, cacheKey, logger) {
1001
- this.options = opts;
1002
- this.cacheKey = cacheKey;
1003
- this.store = store;
1004
- this.cacheKeys = store.cacheKeys;
1005
- this.#subject = observable;
1006
- this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkMEL46GIF_cjs.additionalContext].logger : store.client[chunkMEL46GIF_cjs.additionalContext].logger?.child({}, {
1007
- msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
1008
- }));
1009
- }
1010
- subscribe(observer) {
1011
- this.#connectable ??= this._createConnectable(this.#subject);
1012
- this.#subscription = this.#connectable.connect();
1013
- const sub = this.#connectable.subscribe({
1014
- next: (value) => {
1015
- if (observer.next) {
1016
- observer.next(value);
1017
- }
1018
- },
1019
- error: (err) => {
1020
- if (observer.error) {
1021
- observer.error(err);
1022
- }
1023
- },
1024
- complete: () => {
1025
- if (observer.complete) {
1026
- observer.complete();
1086
+ // src/observable/internal/Layer.ts
1087
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1088
+
1089
+ // src/observable/internal/WeakMapWithEntries.ts
1090
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1091
+ var WeakMapWithEntries = class {
1092
+ #map = /* @__PURE__ */ new WeakMap();
1093
+ #list = [];
1094
+ #toClean = [];
1095
+ #needsCleaning = false;
1096
+ #registry = new FinalizationRegistry(() => {
1097
+ this.#toClean.push(new WeakRef({}));
1098
+ this.#needsCleaning = true;
1099
+ });
1100
+ constructor() {
1101
+ const weakThis = new WeakRef(this);
1102
+ const intervalId = setInterval(() => {
1103
+ const self = weakThis.deref();
1104
+ if (self) {
1105
+ if (this.#needsCleaning) {
1106
+ this.#clean();
1027
1107
  }
1108
+ } else {
1109
+ clearInterval(intervalId);
1028
1110
  }
1029
- });
1030
- return sub;
1111
+ }, 1e3);
1112
+ }
1113
+ #clean() {
1114
+ this.#list = this.#list.filter((ref) => ref.deref() !== void 0);
1115
+ }
1116
+ // functions for WeakMap
1117
+ delete(key) {
1118
+ const ret = this.#map.delete(key);
1119
+ this.#toClean.push(new WeakRef(key));
1120
+ this.#needsCleaning = true;
1121
+ return ret;
1122
+ }
1123
+ get(key) {
1124
+ return this.#map.get(key);
1125
+ }
1126
+ has(key) {
1127
+ return this.#map.has(key);
1031
1128
  }
1032
1129
  /**
1033
- * Register a subscription's dedupeInterval value
1130
+ * Adds a new element with a specified key and value.
1131
+ * @param key Must be an object or symbol.
1034
1132
  */
1035
- registerSubscriptionDedupeInterval(subscriptionId, dedupeInterval) {
1036
- if (dedupeInterval != null && dedupeInterval > 0) {
1037
- this.#subscriptionDedupeIntervals.set(subscriptionId, dedupeInterval);
1133
+ set(key, value) {
1134
+ if (!this.#map.has(key)) {
1135
+ this.#list.push(new WeakRef(key));
1038
1136
  }
1137
+ this.#map.set(key, value);
1138
+ return this;
1139
+ }
1140
+ [Symbol.toStringTag] = "WeakMap";
1141
+ // functions for iterables
1142
+ /** Returns an iterable of entries in the map. */
1143
+ [Symbol.iterator]() {
1144
+ return this.entries();
1039
1145
  }
1040
1146
  /**
1041
- * Unregister a subscription's dedupeInterval value
1147
+ * Returns an iterable of key, value pairs for every entry in the map.
1042
1148
  */
1043
- unregisterSubscriptionDedupeInterval(subscriptionId) {
1044
- this.#subscriptionDedupeIntervals.delete(subscriptionId);
1149
+ entries() {
1150
+ const self = this;
1151
+ function* iter() {
1152
+ for (const ref of self.#list) {
1153
+ const key = ref.deref();
1154
+ if (key !== void 0) {
1155
+ yield [key, self.#map.get(key)];
1156
+ }
1157
+ }
1158
+ }
1159
+ return iter();
1045
1160
  }
1046
1161
  /**
1047
- * Get the minimum dedupeInterval from all active subscriptions
1162
+ * Returns an iterable of keys in the map
1048
1163
  */
1049
- getMinimumDedupeInterval() {
1050
- if (this.#subscriptionDedupeIntervals.size === 0) {
1051
- return this.options.dedupeInterval ?? 0;
1164
+ keys() {
1165
+ const self = this;
1166
+ function* iter() {
1167
+ for (const ref of self.#list) {
1168
+ const key = ref.deref();
1169
+ if (key !== void 0) {
1170
+ yield key;
1171
+ }
1172
+ }
1052
1173
  }
1053
- return Math.min(...this.#subscriptionDedupeIntervals.values());
1174
+ return iter();
1054
1175
  }
1055
1176
  /**
1056
- * Causes the query to revalidate. This will cause the query to fetch
1057
- * the latest data from the server and update the store if it is deemed
1058
- * "stale" or if `force` is true.
1059
- *
1060
- * @param force
1061
- * @returns
1177
+ * Returns an iterable of values in the map
1062
1178
  */
1063
- async revalidate(force) {
1064
- const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
1065
- methodName: "revalidate"
1066
- }) : this.logger;
1067
- if (force) {
1068
- this.abortController?.abort();
1069
- }
1070
- if (this.pendingFetch) {
1071
- if (process.env.NODE_ENV !== "production") {
1072
- logger?.debug("Fetch is already pending, using it");
1179
+ values() {
1180
+ const self = this;
1181
+ function* iter() {
1182
+ for (const ref of self.#list) {
1183
+ const key = ref.deref();
1184
+ if (key !== void 0) {
1185
+ const value = self.#map.get(key);
1186
+ if (value !== void 0) {
1187
+ yield value;
1188
+ }
1189
+ }
1073
1190
  }
1074
- await this.pendingFetch;
1075
- return;
1076
1191
  }
1077
- const minDedupeInterval = this.getMinimumDedupeInterval();
1078
- if (minDedupeInterval > 0 && this.lastFetchStarted != null && Date.now() - this.lastFetchStarted < minDedupeInterval) {
1079
- if (process.env.NODE_ENV !== "production") {
1080
- logger?.debug("Within dupeInterval, aborting revalidate");
1081
- }
1082
- return Promise.resolve();
1192
+ return iter();
1193
+ }
1194
+ };
1195
+
1196
+ // src/observable/internal/Layer.ts
1197
+ var Layer = class _Layer {
1198
+ #parent;
1199
+ #cache = new WeakMapWithEntries();
1200
+ #layerId;
1201
+ constructor(parent, layerId) {
1202
+ this.#parent = parent;
1203
+ this.#layerId = layerId;
1204
+ }
1205
+ get parentLayer() {
1206
+ return this.#parent;
1207
+ }
1208
+ get layerId() {
1209
+ return this.#layerId;
1210
+ }
1211
+ addLayer(layerId) {
1212
+ return new _Layer(this, layerId);
1213
+ }
1214
+ removeLayer(layerId) {
1215
+ if (layerId == null || this.#parent == null) {
1216
+ return this;
1083
1217
  }
1084
- if (process.env.NODE_ENV !== "production") {
1085
- logger?.debug("Starting actual revalidate");
1218
+ if (this.#layerId !== layerId) {
1219
+ this.#parent = this.#parent.removeLayer(layerId);
1220
+ return this;
1086
1221
  }
1087
- this.store.batch({}, (batch) => {
1088
- this.setStatus("loading", batch);
1089
- });
1090
- this._preFetch();
1091
- this.lastFetchStarted = Date.now();
1092
- if (process.env.NODE_ENV !== "production") {
1093
- logger?.debug("calling _fetchAndStore()");
1222
+ return this.#parent.removeLayer(layerId);
1223
+ }
1224
+ entries() {
1225
+ return this.#cache.entries();
1226
+ }
1227
+ keys() {
1228
+ return this.#cache.keys();
1229
+ }
1230
+ get(cacheKey) {
1231
+ return this.#cache.get(cacheKey) ?? this.#parent?.get(cacheKey);
1232
+ }
1233
+ set(cacheKey, value) {
1234
+ this.#cache.set(cacheKey, value);
1235
+ }
1236
+ };
1237
+
1238
+ // src/observable/internal/Subjects.ts
1239
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1240
+ var Subjects = class {
1241
+ #layers;
1242
+ // we can use a regular Map here because the refCounting will
1243
+ // handle cleanup.
1244
+ #cacheKeyToSubject = /* @__PURE__ */ new WeakMap();
1245
+ constructor({
1246
+ logger,
1247
+ layers
1248
+ }) {
1249
+ this.logger = logger;
1250
+ this.#layers = layers;
1251
+ }
1252
+ peek = (cacheKey) => {
1253
+ return this.#cacheKeyToSubject.get(cacheKey);
1254
+ };
1255
+ get = (cacheKey) => {
1256
+ let subject = this.#cacheKeyToSubject.get(cacheKey);
1257
+ if (!subject) {
1258
+ const initialValue = this.#layers.top.get(cacheKey) ?? createInitEntry(cacheKey);
1259
+ subject = new rxjs.BehaviorSubject({
1260
+ ...initialValue,
1261
+ isOptimistic: initialValue.value !== this.#layers.truth.get(cacheKey)?.value
1262
+ });
1263
+ this.#cacheKeyToSubject.set(cacheKey, subject);
1094
1264
  }
1095
- this.pendingFetch = this._fetchAndStore().finally(() => {
1096
- logger?.debug("promise's finally for _fetchAndStore()");
1097
- this.pendingFetch = void 0;
1265
+ return subject;
1266
+ };
1267
+ delete = (cacheKey) => {
1268
+ const subject = this.peek(cacheKey);
1269
+ if (subject) {
1270
+ subject.complete();
1271
+ this.#cacheKeyToSubject.delete(cacheKey);
1272
+ }
1273
+ };
1274
+ };
1275
+
1276
+ // src/observable/internal/tombstone.ts
1277
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1278
+ var tombstone = void 0;
1279
+
1280
+ // src/observable/internal/Layers.ts
1281
+ var Layers = class {
1282
+ #truthLayer = new Layer(void 0, void 0);
1283
+ #topLayer;
1284
+ #onRevalidate;
1285
+ constructor({
1286
+ logger,
1287
+ onRevalidate
1288
+ }) {
1289
+ this.logger = logger;
1290
+ this.#topLayer = this.#truthLayer;
1291
+ this.subjects = new Subjects({
1292
+ logger,
1293
+ layers: this
1098
1294
  });
1099
- await this.pendingFetch;
1100
- return;
1295
+ this.#onRevalidate = onRevalidate;
1101
1296
  }
1102
- _preFetch() {
1297
+ get top() {
1298
+ return this.#topLayer;
1103
1299
  }
1104
- /**
1105
- * Sets the status of the query in the store (but does not store that in `changes`).
1106
- *
1107
- * @param status
1108
- * @param batch
1109
- * @returns
1110
- */
1111
- setStatus(status, batch) {
1112
- if (process.env.NODE_ENV !== "production") {
1113
- this.logger?.child({
1114
- methodName: "setStatus"
1115
- }).debug(`Attempting to set status to '${status}'`);
1300
+ get truth() {
1301
+ return this.#truthLayer;
1302
+ }
1303
+ remove(layerId) {
1304
+ !(layerId != null) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "undefined is the reserved layerId for the truth layer") : invariant4__default.default(false) : void 0;
1305
+ let currentLayer = this.#topLayer;
1306
+ const cacheKeys = /* @__PURE__ */ new Map();
1307
+ while (currentLayer != null && currentLayer.parentLayer != null) {
1308
+ if (currentLayer.layerId === layerId) {
1309
+ for (const [k, v] of currentLayer.entries()) {
1310
+ if (cacheKeys.has(k)) continue;
1311
+ cacheKeys.set(k, v);
1312
+ }
1313
+ }
1314
+ currentLayer = currentLayer.parentLayer;
1116
1315
  }
1117
- const existing = batch.read(this.cacheKey);
1118
- if (existing?.status === status) {
1119
- if (process.env.NODE_ENV !== "production") {
1120
- this.logger?.child({
1121
- methodName: "setStatus"
1122
- }).debug(`Status is already set to '${status}'; aborting`);
1316
+ this.#topLayer = this.#topLayer.removeLayer(layerId);
1317
+ for (const [k, oldEntry] of cacheKeys) {
1318
+ const currentEntry = this.#topLayer.get(k);
1319
+ if (oldEntry !== currentEntry) {
1320
+ const newEntry = currentEntry ?? createInitEntry(k);
1321
+ this.subjects.peek(k)?.next({
1322
+ ...newEntry,
1323
+ isOptimistic: currentEntry?.value !== this.#truthLayer.get(k)?.value
1324
+ });
1123
1325
  }
1124
- return;
1125
- }
1126
- if (process.env.NODE_ENV !== "production") {
1127
- this.logger?.child({
1128
- methodName: "setStatus"
1129
- }).debug(`Writing status '${status}' to cache`);
1130
1326
  }
1131
- batch.write(this.cacheKey, existing?.value, status);
1132
1327
  }
1133
- dispose() {
1134
- if (this.abortController) {
1135
- this.abortController.abort();
1136
- }
1137
- this.#subscription?.unsubscribe();
1138
- this._dispose();
1328
+ batch({
1329
+ optimisticId,
1330
+ changes
1331
+ }, batchFn) {
1332
+ !(optimisticId === void 0 || !!optimisticId) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "optimistic must be undefined or not falsy") : invariant4__default.default(false) : void 0;
1333
+ const batchContext = this.#createBatchContext({
1334
+ optimisticId,
1335
+ changes
1336
+ });
1337
+ const retVal = batchFn(batchContext);
1338
+ this.#onRevalidate(changes, optimisticId).catch((e) => {
1339
+ if (this.logger) {
1340
+ this.logger.error("Unhandled error in batch", e);
1341
+ } else {
1342
+ console.error("Unhandled error in batch", e);
1343
+ throw e;
1344
+ }
1345
+ });
1346
+ return {
1347
+ batchResult: batchContext,
1348
+ retVal,
1349
+ changes: batchContext.changes
1350
+ };
1139
1351
  }
1140
- /**
1141
- * Per query type dispose functionality
1142
- */
1143
- _dispose() {
1352
+ #createBatchContext({
1353
+ optimisticId,
1354
+ changes
1355
+ }) {
1356
+ let needsLayer = optimisticId !== void 0;
1357
+ const batchContext = {
1358
+ changes,
1359
+ createLayerIfNeeded: () => {
1360
+ if (needsLayer) {
1361
+ this.#topLayer = this.#topLayer.addLayer(optimisticId);
1362
+ needsLayer = false;
1363
+ }
1364
+ },
1365
+ optimisticWrite: !!optimisticId,
1366
+ write: (cacheKey, value, status) => {
1367
+ const oldTopValue = this.#topLayer.get(cacheKey);
1368
+ if (optimisticId) batchContext.createLayerIfNeeded();
1369
+ const writeLayer = optimisticId ? this.#topLayer : this.#truthLayer;
1370
+ const newValue = {
1371
+ cacheKey,
1372
+ value,
1373
+ lastUpdated: Date.now(),
1374
+ status
1375
+ };
1376
+ writeLayer.set(cacheKey, newValue);
1377
+ const newTopValue = this.#topLayer.get(cacheKey);
1378
+ if (oldTopValue !== newTopValue) {
1379
+ this.subjects.get(cacheKey)?.next({
1380
+ ...newValue,
1381
+ isOptimistic: newTopValue?.value !== this.#truthLayer.get(cacheKey)?.value
1382
+ });
1383
+ }
1384
+ return newValue;
1385
+ },
1386
+ delete: (cacheKey, status) => {
1387
+ return batchContext.write(cacheKey, tombstone, status);
1388
+ },
1389
+ read: (cacheKey) => {
1390
+ return optimisticId ? this.#topLayer.get(cacheKey) : this.#truthLayer.get(cacheKey);
1391
+ }
1392
+ };
1393
+ return batchContext;
1144
1394
  }
1145
- /**
1146
- * The purpose of this method is to provide a way for others to write
1147
- * directly into the store for this query.
1148
- *
1149
- * @param data
1150
- * @param status
1151
- * @param batch
1152
- */
1153
- /**
1154
- * @param changes
1155
- * @param optimisticId
1156
- * @returns If revalidation is needed, a promise that resolves after the
1157
- * revalidation is complete. Otherwise, undefined.
1158
- */
1159
1395
  };
1160
1396
 
1397
+ // src/observable/internal/links/LinksHelper.ts
1398
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1399
+
1400
+ // src/observable/internal/links/SpecificLinkQuery.ts
1401
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1402
+
1403
+ // src/observable/internal/base-list/BaseListQuery.ts
1404
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1405
+
1406
+ // src/observable/internal/isObjectInstance.ts
1407
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1408
+ function isObjectInstance(item) {
1409
+ return item != null && typeof item === "object" && "$primaryKey" in item;
1410
+ }
1411
+
1412
+ // src/observable/internal/list/ListCacheKey.ts
1413
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1414
+ var API_NAME_IDX2 = 1;
1415
+ var WHERE_IDX2 = 2;
1416
+ var ORDER_BY_IDX = 3;
1417
+ var RDP_IDX2 = 4;
1418
+ var INTERSECT_IDX = 5;
1419
+ var PIVOT_IDX = 6;
1420
+
1161
1421
  // src/observable/internal/sorting/SortingStrategy.ts
1422
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1162
1423
  var NoOpSortingStrategy = class {
1163
1424
  sortCacheKeys(objectCacheKeys, _batch) {
1164
1425
  return objectCacheKeys;
@@ -1204,6 +1465,9 @@ function createOrderBySortFns(orderBy) {
1204
1465
  };
1205
1466
  });
1206
1467
  }
1468
+
1469
+ // src/observable/internal/base-list/createCollectionConnectable.ts
1470
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1207
1471
  function createCollectionConnectable(subject, subjects, createPayload) {
1208
1472
  return rxjs.connectable(subject.pipe(rxjs.switchMap((listEntry) => {
1209
1473
  const resolvedData = listEntry?.value?.data == null || listEntry.value.data.length === 0 ? rxjs.of([]) : rxjs.combineLatest(listEntry.value.data.map((cacheKey) => subjects.get(cacheKey).pipe(rxjs.map((objectEntry) => objectEntry?.value), rxjs.distinctUntilChanged())));
@@ -1225,6 +1489,7 @@ function createCollectionConnectable(subject, subjects, createPayload) {
1225
1489
  }
1226
1490
 
1227
1491
  // src/observable/internal/base-list/removeDuplicates.ts
1492
+ chunk6SCDLAU2_cjs.init_cjs_shims();
1228
1493
  function removeDuplicates(objectCacheKeys, batch) {
1229
1494
  const visited = /* @__PURE__ */ new Set();
1230
1495
  return objectCacheKeys.filter((key) => {
@@ -1244,6 +1509,12 @@ var BaseListQuery = class extends Query {
1244
1509
  * @protected
1245
1510
  */
1246
1511
  sortingStrategy = new NoOpSortingStrategy();
1512
+ /**
1513
+ * Get RDP configuration from the cache key
1514
+ */
1515
+ get rdpConfig() {
1516
+ return this.cacheKey.otherKeys[RDP_IDX2];
1517
+ }
1247
1518
  // Collection-specific behavior is implemented by subclasses
1248
1519
  /**
1249
1520
  * Token for the next page of results
@@ -1276,7 +1547,7 @@ var BaseListQuery = class extends Query {
1276
1547
  if (items.length === 0) {
1277
1548
  objectCacheKeys = [];
1278
1549
  } else if (isObjectInstance(items[0])) {
1279
- objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch);
1550
+ objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch, this.rdpConfig);
1280
1551
  } else {
1281
1552
  objectCacheKeys = items;
1282
1553
  }
@@ -1295,7 +1566,7 @@ var BaseListQuery = class extends Query {
1295
1566
  */
1296
1567
  writeToStore(data, status, batch) {
1297
1568
  const entry = batch.read(this.cacheKey);
1298
- if (entry && deepEqual5__default.default(data, entry.value)) {
1569
+ if (entry && deepEqual__default.default(data, entry.value)) {
1299
1570
  if (entry.status === status) {
1300
1571
  if (process.env.NODE_ENV !== "production") {
1301
1572
  this.logger?.child({
@@ -1404,9 +1675,11 @@ var BaseListQuery = class extends Query {
1404
1675
  return this.pendingPageFetch;
1405
1676
  }
1406
1677
  if (this.pendingFetch) {
1407
- this.pendingPageFetch = new Promise(async (res) => {
1678
+ this.pendingPageFetch = (async () => {
1408
1679
  await this.pendingFetch;
1409
- res(this.fetchMore());
1680
+ await this.fetchMore();
1681
+ })().finally(() => {
1682
+ this.pendingPageFetch = void 0;
1410
1683
  });
1411
1684
  return this.pendingPageFetch;
1412
1685
  }
@@ -1480,7 +1753,8 @@ var BaseListQuery = class extends Query {
1480
1753
  } = this.store.batch({}, (batch) => {
1481
1754
  const append = this.nextPageToken != null;
1482
1755
  const finalStatus = result.nextPageToken ? status : "loaded";
1483
- return this._updateList(this.store.objects.storeOsdkInstances(result.data, batch), finalStatus, batch, append);
1756
+ const objectKeys = this.store.objects.storeOsdkInstances(result.data, batch, this.rdpConfig);
1757
+ return this._updateList(objectKeys, finalStatus, batch, append);
1484
1758
  });
1485
1759
  return retVal;
1486
1760
  } catch (error) {
@@ -1549,7 +1823,7 @@ var BaseListQuery = class extends Query {
1549
1823
  if (items.length === 0) {
1550
1824
  objectCacheKeys = [];
1551
1825
  } else if (isObjectInstance(items[0])) {
1552
- objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch);
1826
+ objectCacheKeys = this.store.objects.storeOsdkInstances(items, batch, this.rdpConfig);
1553
1827
  } else {
1554
1828
  objectCacheKeys = items;
1555
1829
  }
@@ -1560,6 +1834,132 @@ var BaseListQuery = class extends Query {
1560
1834
  data: objectCacheKeys
1561
1835
  }, options.status, batch);
1562
1836
  }
1837
+ //
1838
+ // Shared Websocket Subscription Methods
1839
+ //
1840
+ /**
1841
+ * Create standard websocket subscription handlers for an ObjectSet.
1842
+ * Subclasses can override individual handlers for custom behavior.
1843
+ *
1844
+ * @param objectSet The ObjectSet to subscribe to
1845
+ * @param sub The parent subscription to add cleanup to
1846
+ * @param methodName The method name for logging purposes
1847
+ */
1848
+ createWebsocketSubscription(objectSet, sub, methodName = "registerStreamUpdates") {
1849
+ const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
1850
+ methodName
1851
+ }) : this.logger;
1852
+ if (process.env.NODE_ENV !== "production") {
1853
+ logger?.child({
1854
+ methodName
1855
+ }).info("Subscribing from websocket");
1856
+ }
1857
+ try {
1858
+ const websocketSubscription = objectSet.subscribe({
1859
+ onChange: this.onOswChange.bind(this),
1860
+ onError: this.onOswError.bind(this),
1861
+ onOutOfDate: this.onOswOutOfDate.bind(this),
1862
+ onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this)
1863
+ });
1864
+ sub.add(() => {
1865
+ if (process.env.NODE_ENV !== "production") {
1866
+ logger?.child({
1867
+ methodName
1868
+ }).info("Unsubscribing from websocket");
1869
+ }
1870
+ websocketSubscription.unsubscribe();
1871
+ });
1872
+ } catch (error) {
1873
+ if (this.logger) {
1874
+ this.logger.child({
1875
+ methodName
1876
+ }).error("Failed to register stream updates", error);
1877
+ }
1878
+ this.onOswError({
1879
+ subscriptionClosed: true,
1880
+ error
1881
+ });
1882
+ }
1883
+ }
1884
+ /**
1885
+ * Handler called when websocket subscription is successfully established.
1886
+ */
1887
+ onOswSuccessfulSubscription() {
1888
+ if (process.env.NODE_ENV !== "production") {
1889
+ this.logger?.child({
1890
+ methodName: "onSuccessfulSubscription"
1891
+ }).debug("");
1892
+ }
1893
+ }
1894
+ /**
1895
+ * Handler called when subscribed data becomes out of date.
1896
+ */
1897
+ onOswOutOfDate() {
1898
+ if (process.env.NODE_ENV !== "production") {
1899
+ this.logger?.child({
1900
+ methodName: "onOutOfDate"
1901
+ }).debug("");
1902
+ }
1903
+ }
1904
+ /**
1905
+ * Handler called when websocket subscription encounters an error.
1906
+ */
1907
+ onOswError(errors) {
1908
+ if (this.logger) {
1909
+ this.logger?.child({
1910
+ methodName: "onError"
1911
+ }).error("subscription errors", errors);
1912
+ }
1913
+ }
1914
+ /**
1915
+ * Handler called when an object in the subscribed set is added or updated.
1916
+ * Default implementation stores the object with RDP config if available.
1917
+ *
1918
+ * @param update The object update notification
1919
+ */
1920
+ onOswChange({
1921
+ object,
1922
+ state
1923
+ }) {
1924
+ const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
1925
+ methodName: "registerStreamUpdates"
1926
+ }) : this.logger;
1927
+ if (process.env.NODE_ENV !== "production") {
1928
+ logger?.child({
1929
+ methodName: "onChange"
1930
+ }).debug(`Got an update of type: ${state}`, object);
1931
+ }
1932
+ if (state === "ADDED_OR_UPDATED") {
1933
+ this.store.batch({}, (batch) => {
1934
+ this.store.objects.storeOsdkInstances(
1935
+ [object],
1936
+ batch,
1937
+ this.rdpConfig
1938
+ // Safe - null for queries without RDPs
1939
+ );
1940
+ });
1941
+ } else if (state === "REMOVED") {
1942
+ this.onOswRemoved(object);
1943
+ }
1944
+ }
1945
+ /**
1946
+ * Handler called when an object is removed from the subscribed set.
1947
+ * Default implementation deletes the object from cache.
1948
+ * ListQuery overrides this for list-specific removal logic.
1949
+ *
1950
+ * @param object The removed object
1951
+ */
1952
+ onOswRemoved(object) {
1953
+ if (process.env.NODE_ENV !== "production") {
1954
+ this.logger?.child({
1955
+ methodName: "onRemoved"
1956
+ }).debug("Removing object", object);
1957
+ }
1958
+ this.store.batch({}, (batch) => {
1959
+ const objectCacheKey = this.store.cacheKeys.get("object", object.$apiName, object.$primaryKey);
1960
+ batch.delete(objectCacheKey, "loaded");
1961
+ });
1962
+ }
1563
1963
  };
1564
1964
 
1565
1965
  // src/observable/internal/links/SpecificLinkQuery.ts
@@ -1576,7 +1976,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
1576
1976
  batch.changes.modified.add(this.cacheKey);
1577
1977
  }
1578
1978
  constructor(store, subject, cacheKey, opts) {
1579
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkMEL46GIF_cjs.additionalContext].logger?.child({}, {
1979
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkRO7XAQOS_cjs.additionalContext].logger?.child({}, {
1580
1980
  msgPrefix: `SpecificLinkQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
1581
1981
  }) : void 0);
1582
1982
  [this.#sourceApiName, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
@@ -1593,7 +1993,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
1593
1993
  type: "object",
1594
1994
  apiName: this.#sourceApiName
1595
1995
  };
1596
- const sourceMetadata = await client[chunkMEL46GIF_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
1996
+ const sourceMetadata = await client[chunkRO7XAQOS_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
1597
1997
  const sourceQuery = client(sourceObjectDef).where({
1598
1998
  [sourceMetadata.primaryKeyApiName]: this.#sourcePk
1599
1999
  });
@@ -1620,7 +2020,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
1620
2020
  */
1621
2021
  deleteFromStore(status, batch) {
1622
2022
  const entry = batch.read(this.cacheKey);
1623
- if (entry && deepEqual5__default.default(tombstone, entry.value)) {
2023
+ if (entry && deepEqual__default.default(tombstone, entry.value)) {
1624
2024
  if (process.env.NODE_ENV !== "production") {
1625
2025
  this.logger?.child({
1626
2026
  methodName: "deleteFromStore"
@@ -1657,7 +2057,7 @@ var SpecificLinkQuery = class extends BaseListQuery {
1657
2057
  return this.revalidate(true);
1658
2058
  } else {
1659
2059
  return (async () => {
1660
- const sourceMetadata = await this.store.client[chunkMEL46GIF_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
2060
+ const sourceMetadata = await this.store.client[chunkRO7XAQOS_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
1661
2061
  const linkDef = sourceMetadata.links?.[this.#linkName];
1662
2062
  if (!linkDef || linkDef.targetType !== objectType) return;
1663
2063
  const promise = this.revalidate(true);
@@ -1687,11 +2087,62 @@ var LinksHelper = class extends AbstractHelper {
1687
2087
  });
1688
2088
  }
1689
2089
  };
2090
+
2091
+ // src/observable/internal/list/ListsHelper.ts
2092
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2093
+
2094
+ // src/observable/internal/list/InterfaceListQuery.ts
2095
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2096
+
2097
+ // src/observable/internal/list/ListQuery.ts
2098
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2099
+
2100
+ // src/observable/internal/objectMatchesWhereClause.ts
2101
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2102
+
2103
+ // src/observable/internal/evaluateFilter.ts
2104
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2105
+ function evaluateFilter(f, realValue, expected, strict) {
2106
+ switch (f) {
2107
+ case "$eq":
2108
+ return realValue === expected;
2109
+ case "$gt":
2110
+ return realValue > expected;
2111
+ case "$lt":
2112
+ return realValue < expected;
2113
+ case "$gte":
2114
+ return realValue >= expected;
2115
+ case "$lte":
2116
+ return realValue <= expected;
2117
+ case "$ne":
2118
+ return realValue !== expected;
2119
+ case "$in":
2120
+ return expected.$in.includes(realValue);
2121
+ case "$isNull":
2122
+ return realValue == null;
2123
+ case "$startsWith":
2124
+ return realValue.startsWith(expected);
2125
+ case "$contains":
2126
+ case "$containsAllTerms":
2127
+ case "$containsAllTermsInOrder":
2128
+ case "$containsAnyTerm":
2129
+ case "$intersects":
2130
+ case "$within":
2131
+ return !strict;
2132
+ default:
2133
+ if (process.env.NODE_ENV !== "production") {
2134
+ process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `Unknown where filter ${f}`) : invariant4__default.default(false) ;
2135
+ }
2136
+ return !strict;
2137
+ }
2138
+ }
2139
+
2140
+ // src/observable/internal/objectMatchesWhereClause.ts
1690
2141
  function is$and(whereClause) {
1691
2142
  if (process.env.NODE_ENV !== "production") {
1692
2143
  if ("$and" in whereClause) {
1693
- !Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected $and to be an array") : invariant3__default.default(false) : void 0;
1694
- !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected only $and to be present") : invariant3__default.default(false) : void 0;
2144
+ !Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected $and to be an array") : invariant4__default.default(false) : void 0;
2145
+ !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected only $and to be present") : invariant4__default.default(false) : void 0;
1695
2146
  }
1696
2147
  }
1697
2148
  return "$and" in whereClause;
@@ -1699,8 +2150,8 @@ function is$and(whereClause) {
1699
2150
  function is$or(whereClause) {
1700
2151
  if (process.env.NODE_ENV !== "production") {
1701
2152
  if ("$or" in whereClause) {
1702
- !Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected $or to be an array") : invariant3__default.default(false) : void 0;
1703
- !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected only $or to be present") : invariant3__default.default(false) : void 0;
2153
+ !Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected $or to be an array") : invariant4__default.default(false) : void 0;
2154
+ !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected only $or to be present") : invariant4__default.default(false) : void 0;
1704
2155
  }
1705
2156
  }
1706
2157
  return "$or" in whereClause;
@@ -1708,13 +2159,13 @@ function is$or(whereClause) {
1708
2159
  function is$not(whereClause) {
1709
2160
  if (process.env.NODE_ENV !== "production") {
1710
2161
  if ("$not" in whereClause) {
1711
- !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "expected only $not to be present") : invariant3__default.default(false) : void 0;
2162
+ !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "expected only $not to be present") : invariant4__default.default(false) : void 0;
1712
2163
  }
1713
2164
  }
1714
2165
  return "$not" in whereClause;
1715
2166
  }
1716
2167
  function objectSortaMatchesWhereClause(o, whereClause, strict) {
1717
- if (deepEqual5__default.default({}, whereClause)) {
2168
+ if (deepEqual__default.default({}, whereClause)) {
1718
2169
  return true;
1719
2170
  }
1720
2171
  if (is$and(whereClause)) {
@@ -1727,42 +2178,11 @@ function objectSortaMatchesWhereClause(o, whereClause, strict) {
1727
2178
  return !objectSortaMatchesWhereClause(o, whereClause.$not, strict);
1728
2179
  }
1729
2180
  return Object.entries(whereClause).every(([key, filter]) => {
1730
- if (typeof filter === "object") {
2181
+ if (typeof filter === "object" && filter != null) {
1731
2182
  const realValue = o[key];
1732
2183
  const [f] = Object.keys(filter);
1733
2184
  const expected = filter[f];
1734
- switch (f) {
1735
- case "$eq":
1736
- return realValue === expected;
1737
- case "$gt":
1738
- return realValue > expected;
1739
- case "$lt":
1740
- return realValue < expected;
1741
- case "$gte":
1742
- return realValue >= expected;
1743
- case "$lte":
1744
- return realValue <= expected;
1745
- case "$ne":
1746
- return realValue !== expected;
1747
- case "$in":
1748
- return expected.$in.includes(realValue);
1749
- case "$isNull":
1750
- return realValue == null;
1751
- case "$startsWith":
1752
- return realValue.startsWith(expected);
1753
- case "$contains":
1754
- case "$containsAllTerms":
1755
- case "$containsAllTermsInOrder":
1756
- case "$containsAnyTerm":
1757
- case "$intersects":
1758
- case "$within":
1759
- return !strict;
1760
- default:
1761
- if (process.env.NODE_ENV !== "production") {
1762
- process.env.NODE_ENV !== "production" ? invariant3__default.default(false, `Unknown where filter ${f}`) : invariant3__default.default(false) ;
1763
- }
1764
- return !strict;
1765
- }
2185
+ return evaluateFilter(f, realValue, expected, strict);
1766
2186
  }
1767
2187
  if (key in o) {
1768
2188
  if (o[key] === filter) {
@@ -1774,12 +2194,13 @@ function objectSortaMatchesWhereClause(o, whereClause, strict) {
1774
2194
  }
1775
2195
 
1776
2196
  // src/observable/internal/list/ListQuery.ts
1777
- var API_NAME_IDX = 1;
1778
2197
  var ListQuery = class extends BaseListQuery {
1779
2198
  // pageSize?: number; // this is the internal page size. we need to track this properly
1780
2199
  #whereClause;
1781
2200
  // Using base class minResultsToLoad instead of a private property
1782
2201
  #orderBy;
2202
+ #intersectWith;
2203
+ #pivotInfo;
1783
2204
  #objectSet;
1784
2205
  /**
1785
2206
  * Register changes to the cache specific to ListQuery
@@ -1787,13 +2208,15 @@ var ListQuery = class extends BaseListQuery {
1787
2208
  registerCacheChanges(batch) {
1788
2209
  batch.changes.registerList(this.cacheKey);
1789
2210
  }
1790
- constructor(store, subject, apiName, whereClause, orderBy, cacheKey, opts) {
1791
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkMEL46GIF_cjs.additionalContext].logger?.child({}, {
2211
+ constructor(store, subject, apiName, cacheKey, opts) {
2212
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkRO7XAQOS_cjs.additionalContext].logger?.child({}, {
1792
2213
  msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
1793
2214
  }) : void 0);
1794
2215
  this.apiName = apiName;
1795
- this.#whereClause = whereClause;
1796
- this.#orderBy = orderBy;
2216
+ this.#whereClause = cacheKey.otherKeys[WHERE_IDX2];
2217
+ this.#orderBy = cacheKey.otherKeys[ORDER_BY_IDX];
2218
+ this.#intersectWith = cacheKey.otherKeys[INTERSECT_IDX];
2219
+ this.#pivotInfo = cacheKey.otherKeys[PIVOT_IDX];
1797
2220
  this.#objectSet = this.createObjectSet(store);
1798
2221
  this.sortingStrategy = new OrderBySortingStrategy(this.apiName, this.#orderBy);
1799
2222
  this.minResultsToLoad = 0;
@@ -1801,6 +2224,12 @@ var ListQuery = class extends BaseListQuery {
1801
2224
  get canonicalWhere() {
1802
2225
  return this.#whereClause;
1803
2226
  }
2227
+ get canonicalIntersectWith() {
2228
+ return this.#intersectWith;
2229
+ }
2230
+ get canonicalPivotInfo() {
2231
+ return this.#pivotInfo;
2232
+ }
1804
2233
  /**
1805
2234
  * Create the ObjectSet for this query.
1806
2235
  */
@@ -1849,7 +2278,7 @@ var ListQuery = class extends BaseListQuery {
1849
2278
  * Postprocess fetched data.
1850
2279
  */
1851
2280
  invalidateObjectType = async (objectType, changes) => {
1852
- if (this.cacheKey.otherKeys[1] === objectType) {
2281
+ if (this.apiName === objectType) {
1853
2282
  changes?.modified.add(this.cacheKey);
1854
2283
  return this.revalidate(true);
1855
2284
  }
@@ -1891,7 +2320,7 @@ var ListQuery = class extends BaseListQuery {
1891
2320
  const toRemove = new Set(changes.deleted);
1892
2321
  for (const obj of relevantObjects.modified.all) {
1893
2322
  if (relevantObjects.modified.strictMatches.has(obj)) {
1894
- const objectCacheKey = this.cacheKeys.get("object", obj.$objectType, obj.$primaryKey);
2323
+ const objectCacheKey = this.getObjectCacheKey(obj);
1895
2324
  if (!existingList.has(objectCacheKey)) {
1896
2325
  toAdd.add(obj);
1897
2326
  }
@@ -1899,7 +2328,7 @@ var ListQuery = class extends BaseListQuery {
1899
2328
  } else if (batch.optimisticWrite) {
1900
2329
  continue;
1901
2330
  } else {
1902
- const existingObjectCacheKey = this.cacheKeys.get("object", obj.$objectType, obj.$primaryKey);
2331
+ const existingObjectCacheKey = this.getObjectCacheKey(obj);
1903
2332
  toRemove.add(existingObjectCacheKey);
1904
2333
  if (relevantObjects.modified.sortaMatches.has(obj)) {
1905
2334
  needsRevalidation = true;
@@ -1911,7 +2340,7 @@ var ListQuery = class extends BaseListQuery {
1911
2340
  newList.push(key);
1912
2341
  }
1913
2342
  for (const obj of toAdd) {
1914
- newList.push(this.cacheKeys.get("object", obj.$objectType, obj.$primaryKey));
2343
+ newList.push(this.getObjectCacheKey(obj));
1915
2344
  }
1916
2345
  this._updateList(
1917
2346
  newList,
@@ -1949,58 +2378,16 @@ var ListQuery = class extends BaseListQuery {
1949
2378
  const matchType = this.#matchType(obj);
1950
2379
  if (matchType) {
1951
2380
  group[`${matchType}Matches`].add(obj);
1952
- }
1953
- }
1954
- }
1955
- return relevantObjects;
1956
- }
1957
- /**
1958
- * Extract relevant objects for this query type.
1959
- */
1960
- registerStreamUpdates(sub) {
1961
- const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
1962
- methodName: "registerStreamUpdates"
1963
- }) : this.logger;
1964
- if (process.env.NODE_ENV !== "production") {
1965
- logger?.child({
1966
- methodName: "observeList"
1967
- }).info("Subscribing from websocket");
1968
- }
1969
- const websocketSubscription = this.#objectSet.subscribe({
1970
- onChange: this.onOswChange.bind(this),
1971
- onError: this.onOswError.bind(this),
1972
- onOutOfDate: this.onOswOutOfDate.bind(this),
1973
- onSuccessfulSubscription: this.onOswSuccessfulSubscription.bind(this)
1974
- });
1975
- sub.add(() => {
1976
- if (process.env.NODE_ENV !== "production") {
1977
- logger?.child({
1978
- methodName: "observeList"
1979
- }).info("Unsubscribing from websocket");
1980
- }
1981
- websocketSubscription.unsubscribe();
1982
- });
1983
- }
1984
- onOswSuccessfulSubscription() {
1985
- if (process.env.NODE_ENV !== "production") {
1986
- this.logger?.child({
1987
- methodName: "onSuccessfulSubscription"
1988
- }).debug("");
1989
- }
1990
- }
1991
- onOswOutOfDate() {
1992
- if (process.env.NODE_ENV !== "production") {
1993
- this.logger?.child({
1994
- methodName: "onOutOfDate"
1995
- }).debug("");
1996
- }
1997
- }
1998
- onOswError(errors) {
1999
- if (this.logger) {
2000
- this.logger?.child({
2001
- methodName: "onError"
2002
- }).error("subscription errors", errors);
2381
+ }
2382
+ }
2003
2383
  }
2384
+ return relevantObjects;
2385
+ }
2386
+ /**
2387
+ * Extract relevant objects for this query type.
2388
+ */
2389
+ registerStreamUpdates(sub) {
2390
+ this.createWebsocketSubscription(this.#objectSet, sub, "observeList");
2004
2391
  }
2005
2392
  onOswChange({
2006
2393
  object: objOrIface,
@@ -2017,18 +2404,21 @@ var ListQuery = class extends BaseListQuery {
2017
2404
  if (state === "ADDED_OR_UPDATED") {
2018
2405
  const object = objOrIface.$apiName !== objOrIface.$objectType ? objOrIface.$as(objOrIface.$objectType) : objOrIface;
2019
2406
  this.store.batch({}, (batch) => {
2020
- this.store.objects.storeOsdkInstances([object], batch);
2407
+ this.store.objects.storeOsdkInstances([object], batch, this.rdpConfig);
2021
2408
  });
2022
2409
  } else if (state === "REMOVED") {
2023
- this.onOswRemoved(objOrIface, logger);
2410
+ this.onOswRemoved(objOrIface);
2024
2411
  }
2025
2412
  }
2026
- onOswRemoved(objOrIface, logger) {
2413
+ onOswRemoved(objOrIface) {
2414
+ const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
2415
+ methodName: "onOswRemoved"
2416
+ }) : this.logger;
2027
2417
  this.store.batch({}, (batch) => {
2028
2418
  const existing = batch.read(this.cacheKey);
2029
- !existing ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, "the truth value for our list should exist as we already subscribed") : invariant3__default.default(false) : void 0;
2419
+ !existing ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, "the truth value for our list should exist as we already subscribed") : invariant4__default.default(false) : void 0;
2030
2420
  if (existing.status === "loaded") {
2031
- const objectCacheKey = this.cacheKeys.get("object", objOrIface.$objectType, objOrIface.$primaryKey);
2421
+ const objectCacheKey = this.getObjectCacheKey(objOrIface);
2032
2422
  const newObjects = existing.value?.data.filter((o) => o !== objectCacheKey);
2033
2423
  if (newObjects?.length !== existing.value?.data.length) {
2034
2424
  batch.changes.registerList(this.cacheKey);
@@ -2053,15 +2443,28 @@ var ListQuery = class extends BaseListQuery {
2053
2443
  });
2054
2444
  });
2055
2445
  }
2446
+ /**
2447
+ * Get cache key for object.
2448
+ */
2449
+ getObjectCacheKey(obj) {
2450
+ const pk = obj.$primaryKey;
2451
+ return this.cacheKeys.get("object", obj.$objectType, pk, this.rdpConfig ?? void 0);
2452
+ }
2056
2453
  };
2057
2454
 
2058
2455
  // src/observable/internal/list/InterfaceListQuery.ts
2059
2456
  var InterfaceListQuery = class extends ListQuery {
2060
2457
  createObjectSet(store) {
2061
- return store.client({
2062
- type: "interface",
2458
+ const rdpConfig = this.cacheKey.otherKeys[RDP_IDX2];
2459
+ const type = "interface";
2460
+ const objectTypeDef = {
2461
+ type,
2063
2462
  apiName: this.apiName
2064
- }).where(this.canonicalWhere);
2463
+ };
2464
+ if (rdpConfig != null) {
2465
+ return store.client(objectTypeDef).withProperties(rdpConfig).where(this.canonicalWhere);
2466
+ }
2467
+ return store.client(objectTypeDef).where(this.canonicalWhere);
2065
2468
  }
2066
2469
  async revalidateObjectType(apiName) {
2067
2470
  const objectMetadata = await this.store.client.fetchMetadata({
@@ -2080,7 +2483,7 @@ var InterfaceListQuery = class extends ListQuery {
2080
2483
  }
2081
2484
  extractRelevantObjects(changes) {
2082
2485
  const matchesApiName = ([, object]) => {
2083
- return this.apiName in object[chunkSDFKR62Z_cjs.ObjectDefRef].interfaceMap;
2486
+ return this.apiName in object[chunkHJX4D4KL_cjs.ObjectDefRef].interfaceMap;
2084
2487
  };
2085
2488
  const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
2086
2489
  const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
@@ -2101,7 +2504,7 @@ var InterfaceListQuery = class extends ListQuery {
2101
2504
  async function reloadDataAsFullObjects(client, data) {
2102
2505
  const groups = groupBy__default.default(data, (x) => x.$objectType);
2103
2506
  const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
2104
- const objectDef = objects[0][chunkSDFKR62Z_cjs.UnderlyingOsdkObject][chunkSDFKR62Z_cjs.ObjectDefRef];
2507
+ const objectDef = objects[0][chunkHJX4D4KL_cjs.UnderlyingOsdkObject][chunkHJX4D4KL_cjs.ObjectDefRef];
2105
2508
  const where = {
2106
2509
  [objectDef.primaryKeyApiName]: {
2107
2510
  $in: objects.map((x) => x.$primaryKey)
@@ -2111,19 +2514,66 @@ async function reloadDataAsFullObjects(client, data) {
2111
2514
  return [apiName, Object.fromEntries(result.data.map((x) => [x.$primaryKey, x]))];
2112
2515
  })));
2113
2516
  data = data.map((obj) => {
2114
- !objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey] ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false, `Could not find object ${obj.$objectType} ${obj.$primaryKey}`) : invariant3__default.default(false) : void 0;
2517
+ !objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey] ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false, `Could not find object ${obj.$objectType} ${obj.$primaryKey}`) : invariant4__default.default(false) : void 0;
2115
2518
  return objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey];
2116
2519
  });
2117
2520
  return data;
2118
2521
  }
2119
2522
 
2120
2523
  // src/observable/internal/list/ObjectListQuery.ts
2524
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2121
2525
  var ObjectListQuery = class extends ListQuery {
2122
2526
  createObjectSet(store) {
2123
- return store.client({
2527
+ const rdpConfig = this.cacheKey.otherKeys[RDP_IDX2];
2528
+ const intersectWith = this.cacheKey.otherKeys[INTERSECT_IDX];
2529
+ const pivotInfo = this.cacheKey.otherKeys[PIVOT_IDX];
2530
+ if (pivotInfo != null) {
2531
+ const sourceSet = store.client({
2532
+ type: "object",
2533
+ apiName: pivotInfo.sourceType
2534
+ });
2535
+ let objectSet2 = sourceSet.pivotTo(pivotInfo.linkName);
2536
+ if (rdpConfig != null) {
2537
+ objectSet2 = objectSet2.withProperties(rdpConfig);
2538
+ }
2539
+ objectSet2 = objectSet2.where(this.canonicalWhere);
2540
+ if (intersectWith != null && intersectWith.length > 0) {
2541
+ const intersectSets = intersectWith.map((whereClause) => {
2542
+ let intersectSet = store.client({
2543
+ type: "object",
2544
+ apiName: pivotInfo.targetType
2545
+ });
2546
+ if (rdpConfig != null) {
2547
+ intersectSet = intersectSet.withProperties(rdpConfig);
2548
+ }
2549
+ return intersectSet.where(whereClause);
2550
+ });
2551
+ objectSet2 = objectSet2.intersect(...intersectSets);
2552
+ }
2553
+ return objectSet2;
2554
+ }
2555
+ let objectSet = store.client({
2124
2556
  type: "object",
2125
2557
  apiName: this.apiName
2126
- }).where(this.canonicalWhere);
2558
+ });
2559
+ if (rdpConfig != null) {
2560
+ objectSet = objectSet.withProperties(rdpConfig);
2561
+ }
2562
+ objectSet = objectSet.where(this.canonicalWhere);
2563
+ if (intersectWith != null && intersectWith.length > 0) {
2564
+ const intersectSets = intersectWith.map((whereClause) => {
2565
+ let intersectSet = store.client({
2566
+ type: "object",
2567
+ apiName: this.apiName
2568
+ });
2569
+ if (rdpConfig != null) {
2570
+ intersectSet = intersectSet.withProperties(rdpConfig);
2571
+ }
2572
+ return intersectSet.where(whereClause);
2573
+ });
2574
+ objectSet = objectSet.intersect(...intersectSets);
2575
+ }
2576
+ return objectSet;
2127
2577
  }
2128
2578
  async revalidateObjectType(apiName) {
2129
2579
  if (this.apiName === apiName) {
@@ -2139,12 +2589,12 @@ var ObjectListQuery = class extends ListQuery {
2139
2589
  extractRelevantObjects(changes) {
2140
2590
  return {
2141
2591
  added: {
2142
- all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
2592
+ all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX2]) ?? [],
2143
2593
  strictMatches: /* @__PURE__ */ new Set(),
2144
2594
  sortaMatches: /* @__PURE__ */ new Set()
2145
2595
  },
2146
2596
  modified: {
2147
- all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
2597
+ all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX2]) ?? [],
2148
2598
  strictMatches: /* @__PURE__ */ new Set(),
2149
2599
  sortaMatches: /* @__PURE__ */ new Set()
2150
2600
  }
@@ -2154,10 +2604,13 @@ var ObjectListQuery = class extends ListQuery {
2154
2604
 
2155
2605
  // src/observable/internal/list/ListsHelper.ts
2156
2606
  var ListsHelper = class extends AbstractHelper {
2157
- constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2) {
2607
+ constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2, rdpCanonicalizer, intersectCanonicalizer, pivotCanonicalizer) {
2158
2608
  super(store, cacheKeys);
2159
2609
  this.whereCanonicalizer = whereCanonicalizer2;
2160
2610
  this.orderByCanonicalizer = orderByCanonicalizer2;
2611
+ this.rdpCanonicalizer = rdpCanonicalizer;
2612
+ this.intersectCanonicalizer = intersectCanonicalizer;
2613
+ this.pivotCanonicalizer = pivotCanonicalizer;
2161
2614
  }
2162
2615
  observe(options, subFn) {
2163
2616
  const ret = super.observe(options, subFn);
@@ -2168,24 +2621,217 @@ var ListsHelper = class extends AbstractHelper {
2168
2621
  }
2169
2622
  getQuery(options) {
2170
2623
  const {
2171
- type: {
2172
- apiName,
2173
- type
2174
- },
2624
+ type: typeDefinition,
2175
2625
  where,
2176
- orderBy
2626
+ orderBy,
2627
+ withProperties,
2628
+ intersectWith,
2629
+ pivotTo
2177
2630
  } = options;
2631
+ const {
2632
+ apiName,
2633
+ type
2634
+ } = typeDefinition;
2178
2635
  const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
2179
2636
  const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
2180
- const listCacheKey = this.cacheKeys.get("list", type, apiName, canonWhere, canonOrderBy);
2637
+ const canonRdp = withProperties ? this.rdpCanonicalizer.canonicalize(withProperties) : void 0;
2638
+ const canonIntersect = intersectWith && intersectWith.length > 0 ? this.intersectCanonicalizer.canonicalize(intersectWith) : void 0;
2639
+ const canonPivot = pivotTo ? this.pivotCanonicalizer.canonicalize(apiName, pivotTo) : void 0;
2640
+ const listCacheKey = this.cacheKeys.get("list", type, apiName, canonWhere, canonOrderBy, canonRdp, canonIntersect, canonPivot);
2181
2641
  return this.store.queries.get(listCacheKey, () => {
2182
2642
  const QueryClass = type === "object" ? ObjectListQuery : InterfaceListQuery;
2183
- return new QueryClass(this.store, this.store.subjects.get(listCacheKey), apiName, canonWhere, canonOrderBy, listCacheKey, options);
2643
+ return new QueryClass(this.store, this.store.subjects.get(listCacheKey), apiName, listCacheKey, options);
2644
+ });
2645
+ }
2646
+ };
2647
+
2648
+ // src/observable/internal/object/ObjectCacheKey.ts
2649
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2650
+ var API_NAME_IDX3 = 0;
2651
+ var RDP_CONFIG_IDX = 2;
2652
+
2653
+ // src/observable/internal/object/ObjectCacheKeyRegistry.ts
2654
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2655
+
2656
+ // src/observable/internal/utils/rdpFieldOperations.ts
2657
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2658
+ function extractRdpFieldNames(rdpConfig) {
2659
+ if (!rdpConfig) {
2660
+ return /* @__PURE__ */ new Set();
2661
+ }
2662
+ return new Set(Object.keys(rdpConfig));
2663
+ }
2664
+ function deleteField(obj, field) {
2665
+ const mutableObj = obj;
2666
+ delete mutableObj[field];
2667
+ }
2668
+ function setField(obj, field, value) {
2669
+ const mutableObj = obj;
2670
+ mutableObj[field] = value;
2671
+ }
2672
+ function stripRdpFields(value, rdpFields) {
2673
+ if (rdpFields.size === 0) {
2674
+ return value;
2675
+ }
2676
+ const result = {
2677
+ ...value
2678
+ };
2679
+ for (const field of rdpFields) {
2680
+ deleteField(result, field);
2681
+ }
2682
+ return result;
2683
+ }
2684
+ function isSuperset(superset, subset) {
2685
+ for (const field of subset) {
2686
+ if (!superset.has(field)) {
2687
+ return false;
2688
+ }
2689
+ }
2690
+ return true;
2691
+ }
2692
+ function filterToFields(value, allowedFields) {
2693
+ const result = {
2694
+ ...value
2695
+ };
2696
+ const allFields = Object.keys(result);
2697
+ for (const field of allFields) {
2698
+ if (!allowedFields.has(field)) {
2699
+ deleteField(result, field);
2700
+ }
2701
+ }
2702
+ return result;
2703
+ }
2704
+ function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, targetCurrentValue) {
2705
+ if (targetRdpFields.size === 0) {
2706
+ return stripRdpFields(sourceValue, sourceRdpFields);
2707
+ }
2708
+ if (isSuperset(sourceRdpFields, targetRdpFields)) {
2709
+ if (sourceRdpFields.size === targetRdpFields.size) {
2710
+ return sourceValue;
2711
+ }
2712
+ return filterToFields(sourceValue, targetRdpFields);
2713
+ }
2714
+ const merged = {
2715
+ ...sourceValue
2716
+ };
2717
+ if (targetCurrentValue) {
2718
+ const targetAsRecord = targetCurrentValue;
2719
+ for (const field of targetRdpFields) {
2720
+ if (!sourceRdpFields.has(field) && field in targetCurrentValue) {
2721
+ setField(merged, field, targetAsRecord[field]);
2722
+ }
2723
+ }
2724
+ }
2725
+ return merged;
2726
+ }
2727
+
2728
+ // src/observable/internal/object/ObjectCacheKeyRegistry.ts
2729
+ var ObjectCacheKeyRegistry = class {
2730
+ /**
2731
+ * Map from base key (apiName:primaryKey) to all related cache key variants and metadata
2732
+ */
2733
+ baseToVariants = /* @__PURE__ */ new Map();
2734
+ /**
2735
+ * Metadata for each cache key (apiName, primaryKey, rdpConfig)
2736
+ */
2737
+ keyMetadata = /* @__PURE__ */ new WeakMap();
2738
+ /**
2739
+ * Register a cache key variant for an object
2740
+ */
2741
+ register(cacheKey, apiName, primaryKey, rdpConfig) {
2742
+ const baseKey = this.makeBaseKey(apiName, primaryKey);
2743
+ const primaryKeyStr = String(primaryKey);
2744
+ this.keyMetadata.set(cacheKey, {
2745
+ apiName,
2746
+ primaryKey: primaryKeyStr,
2747
+ rdpConfig,
2748
+ rdpFieldSet: rdpConfig ? extractRdpFieldNames(rdpConfig) : void 0
2184
2749
  });
2750
+ let entry = this.baseToVariants.get(baseKey);
2751
+ if (!entry) {
2752
+ entry = {
2753
+ variants: /* @__PURE__ */ new Set(),
2754
+ apiName,
2755
+ primaryKey: primaryKeyStr
2756
+ };
2757
+ this.baseToVariants.set(baseKey, entry);
2758
+ }
2759
+ entry.variants.add(cacheKey);
2760
+ }
2761
+ /**
2762
+ * Get all variant cache keys for a specific object
2763
+ */
2764
+ getVariants(apiName, primaryKey) {
2765
+ const baseKey = this.makeBaseKey(apiName, primaryKey);
2766
+ const entry = this.baseToVariants.get(baseKey);
2767
+ return new Set(entry?.variants ?? []);
2768
+ }
2769
+ /**
2770
+ * Unregister a cache key when it's being cleaned up
2771
+ */
2772
+ unregister(cacheKey) {
2773
+ const metadata = this.keyMetadata.get(cacheKey);
2774
+ if (!metadata) return;
2775
+ const baseKey = this.makeBaseKey(metadata.apiName, metadata.primaryKey);
2776
+ const entry = this.baseToVariants.get(baseKey);
2777
+ if (entry) {
2778
+ entry.variants.delete(cacheKey);
2779
+ if (entry.variants.size === 0) {
2780
+ this.baseToVariants.delete(baseKey);
2781
+ }
2782
+ }
2783
+ this.keyMetadata.delete(cacheKey);
2784
+ }
2785
+ /**
2786
+ * Get metadata for a cache key
2787
+ */
2788
+ getMetadata(cacheKey) {
2789
+ return this.keyMetadata.get(cacheKey);
2790
+ }
2791
+ /**
2792
+ * Get the count of variants for a specific object
2793
+ */
2794
+ getVariantCount(apiName, primaryKey) {
2795
+ const baseKey = this.makeBaseKey(apiName, primaryKey);
2796
+ return this.baseToVariants.get(baseKey)?.variants.size ?? 0;
2797
+ }
2798
+ /**
2799
+ * Generate a base key from apiName and primaryKey
2800
+ */
2801
+ makeBaseKey(apiName, primaryKey) {
2802
+ return `${apiName}:${primaryKey}`;
2803
+ }
2804
+ /**
2805
+ * Check if a cache key has RDP configuration
2806
+ */
2807
+ hasRdpConfig(cacheKey) {
2808
+ return this.keyMetadata.get(cacheKey)?.rdpConfig != null;
2809
+ }
2810
+ /**
2811
+ * Get the RDP configuration for a cache key
2812
+ */
2813
+ getRdpConfig(cacheKey) {
2814
+ return this.keyMetadata.get(cacheKey)?.rdpConfig;
2815
+ }
2816
+ /**
2817
+ * Get the cached RDP field set for a cache key
2818
+ */
2819
+ getRdpFieldSet(cacheKey) {
2820
+ return this.keyMetadata.get(cacheKey)?.rdpFieldSet ?? /* @__PURE__ */ new Set();
2185
2821
  }
2186
2822
  };
2187
2823
 
2824
+ // src/observable/internal/object/ObjectsHelper.ts
2825
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2826
+
2827
+ // src/observable/internal/object/ObjectQuery.ts
2828
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2829
+
2830
+ // src/observable/internal/BulkObjectLoader.ts
2831
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2832
+
2188
2833
  // ../../node_modules/.pnpm/p-defer@4.0.1/node_modules/p-defer/index.js
2834
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2189
2835
  function pDefer() {
2190
2836
  const deferred = {};
2191
2837
  deferred.promise = new Promise((resolve, reject) => {
@@ -2211,7 +2857,7 @@ var BulkObjectLoader = class {
2211
2857
  #maxEntries;
2212
2858
  constructor(client, maxWait = 25, maxEntries = 100) {
2213
2859
  this.#client = client;
2214
- this.#logger = client[chunkMEL46GIF_cjs.additionalContext].logger;
2860
+ this.#logger = client[chunkRO7XAQOS_cjs.additionalContext].logger;
2215
2861
  this.#maxWait = maxWait;
2216
2862
  this.#maxEntries = maxEntries;
2217
2863
  }
@@ -2246,13 +2892,18 @@ var BulkObjectLoader = class {
2246
2892
  };
2247
2893
  const objMetadata = await this.#client.fetchMetadata(miniDef);
2248
2894
  const pks = arr.map((x) => x.primaryKey);
2249
- const {
2250
- data
2251
- } = await this.#client(miniDef).where({
2895
+ const whereClause = pks.length === 1 ? {
2896
+ [objMetadata.primaryKeyApiName]: {
2897
+ $eq: pks[0]
2898
+ }
2899
+ } : {
2252
2900
  [objMetadata.primaryKeyApiName]: {
2253
2901
  $in: pks
2254
2902
  }
2255
- }).fetchPage({
2903
+ };
2904
+ const {
2905
+ data
2906
+ } = await this.#client(miniDef).where(whereClause).fetchPage({
2256
2907
  $pageSize: pks.length
2257
2908
  });
2258
2909
  for (const {
@@ -2274,7 +2925,7 @@ var ObjectQuery = class extends Query {
2274
2925
  #apiName;
2275
2926
  #pk;
2276
2927
  constructor(store, subject, type, pk, cacheKey, opts) {
2277
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkMEL46GIF_cjs.additionalContext].logger?.child({}, {
2928
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkRO7XAQOS_cjs.additionalContext].logger?.child({}, {
2278
2929
  msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
2279
2930
  }) : void 0);
2280
2931
  this.#apiName = type;
@@ -2309,62 +2960,17 @@ var ObjectQuery = class extends Query {
2309
2960
  });
2310
2961
  }
2311
2962
  writeToStore(data, status, batch) {
2312
- const entry = batch.read(this.cacheKey);
2313
- if (entry && deepEqual5__default.default(data, entry.value)) {
2314
- if (entry.status === status) {
2315
- if (process.env.NODE_ENV !== "production") {
2316
- this.logger?.child({
2317
- methodName: "writeToStore"
2318
- }).debug(`Object was deep equal and status unchanged (${status}), skipping update`);
2319
- }
2320
- return entry;
2321
- }
2322
- if (process.env.NODE_ENV !== "production") {
2323
- this.logger?.child({
2324
- methodName: "writeToStore"
2325
- }).debug(`Object was deep equal, just setting status (old status: ${entry.status}, new status: ${status})`);
2326
- }
2327
- return batch.write(this.cacheKey, entry.value, status);
2328
- }
2329
- if (process.env.NODE_ENV !== "production") {
2330
- this.logger?.child({
2331
- methodName: "writeToStore"
2332
- }).debug(JSON.stringify({
2333
- status
2334
- }), data);
2335
- }
2336
- const ret = batch.write(this.cacheKey, data, status);
2337
- batch.changes.registerObject(
2338
- this.cacheKey,
2339
- data,
2340
- /* isNew */
2341
- !entry
2342
- );
2343
- return ret;
2963
+ batch.read(this.cacheKey);
2964
+ const rdpConfig = this.cacheKey.otherKeys[RDP_CONFIG_IDX];
2965
+ this.store.objectCacheKeyRegistry.register(this.cacheKey, this.#apiName, this.#pk, rdpConfig);
2966
+ this.store.objects.propagateWrite(this.cacheKey, data, status, batch);
2967
+ return batch.read(this.cacheKey);
2344
2968
  }
2345
2969
  deleteFromStore(status, batch) {
2346
- const entry = batch.read(this.cacheKey);
2347
- if (entry && deepEqual5__default.default(tombstone, entry.value)) {
2348
- if (process.env.NODE_ENV !== "production") {
2349
- this.logger?.child({
2350
- methodName: "deleteFromStore"
2351
- }).debug(`Object was deep equal, just setting status`);
2352
- }
2353
- return batch.write(this.cacheKey, entry.value, status);
2354
- }
2355
- if (process.env.NODE_ENV !== "production") {
2356
- this.logger?.child({
2357
- methodName: "deleteFromStore"
2358
- }).debug(JSON.stringify({
2359
- status
2360
- }));
2361
- }
2362
- if (!entry || !entry.value) {
2363
- return;
2364
- }
2365
- const ret = batch.delete(this.cacheKey, status);
2366
- batch.changes.deleteObject(this.cacheKey);
2367
- return ret;
2970
+ const rdpConfig = this.cacheKey.otherKeys[RDP_CONFIG_IDX];
2971
+ this.store.objectCacheKeyRegistry.register(this.cacheKey, this.#apiName, this.#pk, rdpConfig);
2972
+ this.store.objects.propagateWrite(this.cacheKey, tombstone, status, batch);
2973
+ return batch.read(this.cacheKey);
2368
2974
  }
2369
2975
  invalidateObjectType = (objectType, changes) => {
2370
2976
  if (this.#apiName === objectType) {
@@ -2380,37 +2986,94 @@ var ObjectsHelper = class extends AbstractHelper {
2380
2986
  observe(options, subFn) {
2381
2987
  return super.observe(options, subFn);
2382
2988
  }
2383
- getQuery(options) {
2989
+ getQuery(options, rdpConfig) {
2384
2990
  const apiName = typeof options.apiName === "string" ? options.apiName : options.apiName.apiName;
2385
2991
  const {
2386
2992
  pk
2387
2993
  } = options;
2388
- const objectCacheKey = this.cacheKeys.get("object", apiName, pk);
2994
+ const objectCacheKey = this.cacheKeys.get("object", apiName, pk, rdpConfig ?? void 0);
2389
2995
  return this.store.queries.get(objectCacheKey, () => new ObjectQuery(this.store, this.store.subjects.get(objectCacheKey), apiName, pk, objectCacheKey, {
2390
2996
  dedupeInterval: 0
2391
2997
  }));
2392
2998
  }
2393
2999
  /**
2394
3000
  * Internal helper method for writing objects to the store and returning their
2395
- * object keys
3001
+ * object keys. For list queries with RDPs, the rdpConfig is included in the
3002
+ * cache key to ensure proper data isolation.
2396
3003
  * @internal
2397
3004
  */
2398
- storeOsdkInstances(values, batch) {
3005
+ storeOsdkInstances(values, batch, rdpConfig) {
2399
3006
  return values.map((v) => this.getQuery({
2400
3007
  apiName: v.$apiName,
2401
3008
  pk: v.$primaryKey
2402
- }).writeToStore(v, "loaded", batch).cacheKey);
3009
+ }, rdpConfig).writeToStore(v, "loaded", batch).cacheKey);
3010
+ }
3011
+ /**
3012
+ * Write an object to cache and propagate to all related cache keys
3013
+ * @internal
3014
+ */
3015
+ propagateWrite(sourceCacheKey, value, status, batch) {
3016
+ const existing = batch.read(sourceCacheKey);
3017
+ const dataChanged = !existing || existing.value === void 0 || value === tombstone || !deepEqual__default.default(existing.value, value);
3018
+ const statusChanged = !existing || existing.status !== status;
3019
+ if (!dataChanged && !statusChanged) {
3020
+ return;
3021
+ }
3022
+ const valueToWrite = !dataChanged && existing ? existing.value : value;
3023
+ batch.write(sourceCacheKey, valueToWrite, status);
3024
+ if (value !== tombstone) {
3025
+ batch.changes.registerObject(sourceCacheKey, value, !existing);
3026
+ }
3027
+ const metadata = this.store.objectCacheKeyRegistry.getMetadata(sourceCacheKey);
3028
+ const relatedKeys = metadata ? this.store.objectCacheKeyRegistry.getVariants(metadata.apiName, metadata.primaryKey) : /* @__PURE__ */ new Set([sourceCacheKey]);
3029
+ for (const targetKey of relatedKeys) {
3030
+ if (targetKey === sourceCacheKey || !this.isKeyActive(targetKey)) {
3031
+ continue;
3032
+ }
3033
+ if (value === tombstone) {
3034
+ batch.write(targetKey, tombstone, status);
3035
+ continue;
3036
+ }
3037
+ const targetCurrentValue = batch.read(targetKey)?.value;
3038
+ const merged = this.mergeForTarget(value, targetCurrentValue && this.isObjectHolder(targetCurrentValue) ? targetCurrentValue : void 0, sourceCacheKey, targetKey);
3039
+ batch.write(targetKey, merged, status);
3040
+ }
3041
+ }
3042
+ /**
3043
+ * Check if a cache key is actively observed
3044
+ */
3045
+ isKeyActive(key) {
3046
+ const subject = this.store.subjects.peek(key);
3047
+ return subject?.observed === true;
3048
+ }
3049
+ /**
3050
+ * Type guard to check if a value is an ObjectHolder
3051
+ */
3052
+ isObjectHolder(value) {
3053
+ return value != null && typeof value === "object" && "$apiName" in value && "$primaryKey" in value;
3054
+ }
3055
+ /**
3056
+ * Merge object data for a specific target cache key, preserving RDP fields
3057
+ */
3058
+ mergeForTarget(sourceValue, targetCurrentValue, sourceCacheKey, targetCacheKey) {
3059
+ const sourceRdpFields = this.store.objectCacheKeyRegistry.getRdpFieldSet(sourceCacheKey);
3060
+ const targetRdpFields = this.store.objectCacheKeyRegistry.getRdpFieldSet(targetCacheKey);
3061
+ return mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, targetCurrentValue);
2403
3062
  }
2404
3063
  };
2405
3064
 
3065
+ // src/observable/internal/objectset/ObjectSetHelper.ts
3066
+ chunk6SCDLAU2_cjs.init_cjs_shims();
3067
+
2406
3068
  // src/observable/internal/objectset/ObjectSetQuery.ts
3069
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2407
3070
  var ObjectSetQuery = class extends BaseListQuery {
2408
3071
  #baseObjectSetWire;
2409
3072
  #operations;
2410
3073
  #composedObjectSet;
2411
3074
  #objectTypes;
2412
3075
  constructor(store, subject, baseObjectSetWire, operations, cacheKey, opts) {
2413
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkMEL46GIF_cjs.additionalContext].logger?.child({}, {
3076
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkRO7XAQOS_cjs.additionalContext].logger?.child({}, {
2414
3077
  msgPrefix: `ObjectSetQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
2415
3078
  }) : void 0);
2416
3079
  this.#baseObjectSetWire = baseObjectSetWire;
@@ -2453,7 +3116,7 @@ var ObjectSetQuery = class extends BaseListQuery {
2453
3116
  }
2454
3117
  if (opts.union) {
2455
3118
  for (const os of opts.union) {
2456
- const wire = chunkMEL46GIF_cjs.getWireObjectSet(os);
3119
+ const wire = chunkRO7XAQOS_cjs.getWireObjectSet(os);
2457
3120
  if (wire.type) {
2458
3121
  types.add(wire.type);
2459
3122
  }
@@ -2461,7 +3124,7 @@ var ObjectSetQuery = class extends BaseListQuery {
2461
3124
  }
2462
3125
  if (opts.intersect) {
2463
3126
  for (const os of opts.intersect) {
2464
- const wire = chunkMEL46GIF_cjs.getWireObjectSet(os);
3127
+ const wire = chunkRO7XAQOS_cjs.getWireObjectSet(os);
2465
3128
  if (wire.type) {
2466
3129
  types.add(wire.type);
2467
3130
  }
@@ -2469,7 +3132,7 @@ var ObjectSetQuery = class extends BaseListQuery {
2469
3132
  }
2470
3133
  if (opts.subtract) {
2471
3134
  for (const os of opts.subtract) {
2472
- const wire = chunkMEL46GIF_cjs.getWireObjectSet(os);
3135
+ const wire = chunkRO7XAQOS_cjs.getWireObjectSet(os);
2473
3136
  if (wire.type) {
2474
3137
  types.add(wire.type);
2475
3138
  }
@@ -2509,6 +3172,9 @@ var ObjectSetQuery = class extends BaseListQuery {
2509
3172
  data: []
2510
3173
  }, "error", batch);
2511
3174
  }
3175
+ registerStreamUpdates(sub) {
3176
+ this.createWebsocketSubscription(this.#composedObjectSet, sub, "observeObjectSet");
3177
+ }
2512
3178
  invalidateObjectType = async (objectType, changes) => {
2513
3179
  if (this.#objectTypes.has(objectType)) {
2514
3180
  changes?.modified.add(this.cacheKey);
@@ -2537,13 +3203,17 @@ var ObjectSetHelper = class extends AbstractHelper {
2537
3203
  this.orderByCanonicalizer = orderByCanonicalizer2;
2538
3204
  }
2539
3205
  observe(options, subFn) {
2540
- return super.observe(options, subFn);
3206
+ const ret = super.observe(options, subFn);
3207
+ if (options.streamUpdates) {
3208
+ ret.query.registerStreamUpdates(ret.subscription);
3209
+ }
3210
+ return ret;
2541
3211
  }
2542
3212
  getQuery(options) {
2543
3213
  const {
2544
3214
  baseObjectSet
2545
3215
  } = options;
2546
- const baseObjectSetWire = JSON.stringify(chunkMEL46GIF_cjs.getWireObjectSet(baseObjectSet));
3216
+ const baseObjectSetWire = JSON.stringify(chunkRO7XAQOS_cjs.getWireObjectSet(baseObjectSet));
2547
3217
  const operations = this.buildCanonicalizedOperations(options);
2548
3218
  const objectSetCacheKey = this.cacheKeys.get("objectSet", baseObjectSetWire, operations);
2549
3219
  return this.store.queries.get(objectSetCacheKey, () => {
@@ -2559,13 +3229,13 @@ var ObjectSetHelper = class extends AbstractHelper {
2559
3229
  operations.withProperties = Object.keys(options.withProperties).sort();
2560
3230
  }
2561
3231
  if (options.union && options.union.length > 0) {
2562
- operations.union = options.union.map((os) => JSON.stringify(chunkMEL46GIF_cjs.getWireObjectSet(os)));
3232
+ operations.union = options.union.map((os) => JSON.stringify(chunkRO7XAQOS_cjs.getWireObjectSet(os)));
2563
3233
  }
2564
3234
  if (options.intersect && options.intersect.length > 0) {
2565
- operations.intersect = options.intersect.map((os) => JSON.stringify(chunkMEL46GIF_cjs.getWireObjectSet(os)));
3235
+ operations.intersect = options.intersect.map((os) => JSON.stringify(chunkRO7XAQOS_cjs.getWireObjectSet(os)));
2566
3236
  }
2567
3237
  if (options.subtract && options.subtract.length > 0) {
2568
- operations.subtract = options.subtract.map((os) => JSON.stringify(chunkMEL46GIF_cjs.getWireObjectSet(os)));
3238
+ operations.subtract = options.subtract.map((os) => JSON.stringify(chunkRO7XAQOS_cjs.getWireObjectSet(os)));
2569
3239
  }
2570
3240
  if (options.pivotTo) {
2571
3241
  operations.pivotTo = options.pivotTo;
@@ -2580,7 +3250,27 @@ var ObjectSetHelper = class extends AbstractHelper {
2580
3250
  }
2581
3251
  };
2582
3252
 
3253
+ // src/observable/internal/PivotCanonicalizer.ts
3254
+ chunk6SCDLAU2_cjs.init_cjs_shims();
3255
+ var PivotCanonicalizer = class {
3256
+ #cache = /* @__PURE__ */ new Map();
3257
+ canonicalize(sourceType, linkName) {
3258
+ const key = `${sourceType}::${linkName}`;
3259
+ let canonical = this.#cache.get(key);
3260
+ if (!canonical) {
3261
+ canonical = {
3262
+ sourceType,
3263
+ linkName,
3264
+ targetType: "<targetType>"
3265
+ };
3266
+ this.#cache.set(key, canonical);
3267
+ }
3268
+ return canonical;
3269
+ }
3270
+ };
3271
+
2583
3272
  // src/observable/internal/Queries.ts
3273
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2584
3274
  var Queries = class {
2585
3275
  // we can use a regular Map here because the refCounting will
2586
3276
  // handle cleanup.
@@ -2605,12 +3295,62 @@ var Queries = class {
2605
3295
  }
2606
3296
  };
2607
3297
 
3298
+ // src/observable/internal/RdpCanonicalizer.ts
3299
+ chunk6SCDLAU2_cjs.init_cjs_shims();
3300
+ var RdpCanonicalizer = class extends CachingCanonicalizer {
3301
+ structuralCache = /* @__PURE__ */ new Map();
3302
+ lookupOrCreate(rdp) {
3303
+ const definitionMap = /* @__PURE__ */ new Map();
3304
+ const computedProperties = {};
3305
+ const objectTypeHolder = {
3306
+ type: "object",
3307
+ apiName: "__rdp_canonicalizer_holder__"
3308
+ };
3309
+ for (const [key, rdpFunction] of Object.entries(rdp)) {
3310
+ const builder = chunkRO7XAQOS_cjs.createWithPropertiesObjectSet(
3311
+ objectTypeHolder,
3312
+ {
3313
+ type: "methodInput"
3314
+ },
3315
+ definitionMap,
3316
+ /* fromBaseObjectSet */
3317
+ true
3318
+ );
3319
+ const result = rdpFunction(builder);
3320
+ const definition = definitionMap.get(result);
3321
+ if (definition) {
3322
+ computedProperties[key] = definition;
3323
+ }
3324
+ }
3325
+ const sortedKeys = Object.keys(computedProperties).sort();
3326
+ const sortedDefinitions = {};
3327
+ for (const key of sortedKeys) {
3328
+ sortedDefinitions[key] = computedProperties[key];
3329
+ }
3330
+ const definitionsKey = JSON.stringify(sortedDefinitions);
3331
+ let canonical = this.structuralCache.get(definitionsKey);
3332
+ if (!canonical) {
3333
+ const sortedRdp = {};
3334
+ for (const key of Object.keys(rdp).sort()) {
3335
+ sortedRdp[key] = rdp[key];
3336
+ }
3337
+ canonical = sortedRdp;
3338
+ this.structuralCache.set(definitionsKey, canonical);
3339
+ }
3340
+ return canonical;
3341
+ }
3342
+ };
3343
+
2608
3344
  // src/observable/internal/Store.ts
2609
3345
  var Store = class {
2610
3346
  whereCanonicalizer = new WhereClauseCanonicalizer();
2611
3347
  orderByCanonicalizer = new OrderByCanonicalizer();
3348
+ rdpCanonicalizer = new RdpCanonicalizer();
3349
+ intersectCanonicalizer = new IntersectCanonicalizer(this.whereCanonicalizer);
3350
+ pivotCanonicalizer = new PivotCanonicalizer();
2612
3351
  /** @internal */
2613
3352
  queries = new Queries();
3353
+ objectCacheKeyRegistry = new ObjectCacheKeyRegistry();
2614
3354
  layers = new Layers({
2615
3355
  logger: this.logger,
2616
3356
  onRevalidate: this.#maybeRevalidateQueries.bind(this)
@@ -2618,14 +3358,15 @@ var Store = class {
2618
3358
  subjects = this.layers.subjects;
2619
3359
  // these are hopefully temporary
2620
3360
  constructor(client) {
2621
- this.logger = client[chunkMEL46GIF_cjs.additionalContext].logger?.child({}, {
3361
+ this.logger = client[chunkRO7XAQOS_cjs.additionalContext].logger?.child({}, {
2622
3362
  msgPrefix: "Store"
2623
3363
  });
2624
3364
  this.client = client;
2625
3365
  this.cacheKeys = new CacheKeys({
2626
3366
  onDestroy: this.#cleanupCacheKey
2627
3367
  });
2628
- this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
3368
+ this.aggregations = new AggregationsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.rdpCanonicalizer);
3369
+ this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer, this.intersectCanonicalizer, this.pivotCanonicalizer);
2629
3370
  this.objects = new ObjectsHelper(this, this.cacheKeys);
2630
3371
  this.links = new LinksHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
2631
3372
  this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
@@ -2637,7 +3378,7 @@ var Store = class {
2637
3378
  #cleanupCacheKey = (key) => {
2638
3379
  const subject = this.subjects.peek(key);
2639
3380
  if (process.env.NODE_ENV !== "production") {
2640
- !subject ? process.env.NODE_ENV !== "production" ? invariant3__default.default(false) : invariant3__default.default(false) : void 0;
3381
+ !subject ? process.env.NODE_ENV !== "production" ? invariant4__default.default(false) : invariant4__default.default(false) : void 0;
2641
3382
  }
2642
3383
  this.subjects.delete(key);
2643
3384
  this.queries.delete(key);
@@ -2668,13 +3409,28 @@ var Store = class {
2668
3409
  if (typeof apiName !== "string") {
2669
3410
  apiName = apiName.apiName;
2670
3411
  }
2671
- return this.objects.getQuery({
2672
- apiName,
2673
- pk
2674
- }).revalidate(
2675
- /* force */
2676
- true
2677
- );
3412
+ const variants = this.objectCacheKeyRegistry.getVariants(apiName, pk);
3413
+ const promises = [];
3414
+ if (variants.size === 0) {
3415
+ promises.push(this.objects.getQuery({
3416
+ apiName,
3417
+ pk
3418
+ }, void 0).revalidate(
3419
+ /* force */
3420
+ true
3421
+ ));
3422
+ } else {
3423
+ for (const key of variants) {
3424
+ const query = this.queries.peek(key);
3425
+ if (query) {
3426
+ promises.push(query.revalidate(
3427
+ /* force */
3428
+ true
3429
+ ));
3430
+ }
3431
+ }
3432
+ }
3433
+ return Promise.allSettled(promises);
2678
3434
  }
2679
3435
  async #maybeRevalidateQueries(changes, optimisticId) {
2680
3436
  const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
@@ -2694,7 +3450,17 @@ var Store = class {
2694
3450
  try {
2695
3451
  const promises = [];
2696
3452
  for (const cacheKey of this.queries.keys()) {
2697
- const promise = this.queries.peek(cacheKey)?.maybeUpdateAndRevalidate?.(changes, optimisticId);
3453
+ const query = this.queries.peek(cacheKey);
3454
+ if (!query?.maybeUpdateAndRevalidate) {
3455
+ continue;
3456
+ }
3457
+ if (!this.#shouldPropagateToQuery({
3458
+ cacheKey,
3459
+ maybeUpdateAndRevalidate: query.maybeUpdateAndRevalidate
3460
+ }, changes, optimisticId)) {
3461
+ continue;
3462
+ }
3463
+ const promise = query.maybeUpdateAndRevalidate(changes, optimisticId);
2698
3464
  if (promise) promises.push(promise);
2699
3465
  }
2700
3466
  await Promise.all(promises);
@@ -2704,6 +3470,107 @@ var Store = class {
2704
3470
  }
2705
3471
  }
2706
3472
  }
3473
+ /**
3474
+ * Determines whether changes should propagate to a specific query.
3475
+ * Prevents unnecessary observable pipeline execution for cross-propagation.
3476
+ *
3477
+ * @param query - The query to check
3478
+ * @param changes - The changes that occurred
3479
+ * @param optimisticId - Optional optimistic update ID
3480
+ * @returns true if the query should be notified of these changes
3481
+ */
3482
+ #shouldPropagateToQuery(query, changes, optimisticId) {
3483
+ if (optimisticId) {
3484
+ return true;
3485
+ }
3486
+ if (changes.modified.has(query.cacheKey)) {
3487
+ return true;
3488
+ }
3489
+ if (this.#shouldPropagateForObjectTypeChanges(query.cacheKey, changes)) {
3490
+ return true;
3491
+ }
3492
+ const queryRdpConfig = this.#getQueryRdpConfig(query.cacheKey);
3493
+ return queryRdpConfig != null;
3494
+ }
3495
+ /**
3496
+ * Checks if changes to an object type should propagate to a query.
3497
+ * This ensures queries receive updates when objects of their type are added/modified.
3498
+ *
3499
+ * @param cacheKey - The cache key of the query
3500
+ * @param changes - The changes that occurred
3501
+ * @returns true if the query should be notified based on object type changes
3502
+ */
3503
+ #shouldPropagateForObjectTypeChanges(cacheKey, changes) {
3504
+ const queryObjectType = this.#getQueryObjectType(cacheKey);
3505
+ if (!queryObjectType) {
3506
+ return false;
3507
+ }
3508
+ const affected = this.#changesAffectObjectType(changes, queryObjectType);
3509
+ if (process.env.NODE_ENV !== "production") {
3510
+ this.logger?.child({
3511
+ methodName: "shouldPropagateToQuery"
3512
+ }).debug(`Query type: ${queryObjectType}, affected: ${affected}`, {
3513
+ queryKey: DEBUG_ONLY__cacheKeyToString(cacheKey),
3514
+ addedCount: changes.addedObjects.get(queryObjectType)?.length ?? 0,
3515
+ modifiedCount: changes.modifiedObjects.get(queryObjectType)?.length ?? 0
3516
+ });
3517
+ }
3518
+ return affected;
3519
+ }
3520
+ /**
3521
+ * Extracts RDP configuration from a cache key if present.
3522
+ *
3523
+ * @param cacheKey - The cache key to check
3524
+ * @returns The RDP configuration, null, or undefined
3525
+ */
3526
+ #getQueryRdpConfig(cacheKey) {
3527
+ if ("otherKeys" in cacheKey && Array.isArray(cacheKey.otherKeys)) {
3528
+ if (cacheKey.type === "object") {
3529
+ return cacheKey.otherKeys[RDP_CONFIG_IDX];
3530
+ } else if (cacheKey.type === "list") {
3531
+ return cacheKey.otherKeys[RDP_IDX2];
3532
+ } else if (cacheKey.type === "aggregation") {
3533
+ return cacheKey.otherKeys[RDP_IDX];
3534
+ }
3535
+ }
3536
+ return void 0;
3537
+ }
3538
+ /**
3539
+ * Extracts the object type (apiName) from a cache key.
3540
+ *
3541
+ * @param cacheKey - The cache key to check
3542
+ * @returns The object type/apiName, or undefined if not applicable
3543
+ */
3544
+ #getQueryObjectType(cacheKey) {
3545
+ if ("otherKeys" in cacheKey && Array.isArray(cacheKey.otherKeys)) {
3546
+ if (cacheKey.type === "object") {
3547
+ return cacheKey.otherKeys[API_NAME_IDX3];
3548
+ } else if (cacheKey.type === "list") {
3549
+ return cacheKey.otherKeys[API_NAME_IDX2];
3550
+ } else if (cacheKey.type === "aggregation") {
3551
+ return cacheKey.otherKeys[API_NAME_IDX];
3552
+ }
3553
+ }
3554
+ return void 0;
3555
+ }
3556
+ /**
3557
+ * Checks if changes affect a specific object type.
3558
+ *
3559
+ * @param changes - The changes to check
3560
+ * @param objectType - The object type to check for
3561
+ * @returns true if the changes include added or modified objects of this type
3562
+ */
3563
+ #changesAffectObjectType(changes, objectType) {
3564
+ const addedForType = changes.addedObjects.get(objectType);
3565
+ if (addedForType && addedForType.length > 0) {
3566
+ return true;
3567
+ }
3568
+ const modifiedForType = changes.modifiedObjects.get(objectType);
3569
+ if (modifiedForType && modifiedForType.length > 0) {
3570
+ return true;
3571
+ }
3572
+ return false;
3573
+ }
2707
3574
  /**
2708
3575
  * Invalidates all cache entries for a specific object type.
2709
3576
  * This will revalidate:
@@ -2757,10 +3624,10 @@ var Store = class {
2757
3624
 
2758
3625
  // src/observable/ObservableClient.ts
2759
3626
  function createObservableClient(client) {
2760
- const tweakedClient = chunkSDFKR62Z_cjs.createClientFromContext({
2761
- ...client[chunkMEL46GIF_cjs.additionalContext],
2762
- fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkMEL46GIF_cjs.additionalContext].fetch, (headers) => {
2763
- headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkSDFKR62Z_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
3627
+ const tweakedClient = chunkHJX4D4KL_cjs.createClientFromContext({
3628
+ ...client[chunkRO7XAQOS_cjs.additionalContext],
3629
+ fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkRO7XAQOS_cjs.additionalContext].fetch, (headers) => {
3630
+ headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkHJX4D4KL_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
2764
3631
  return headers;
2765
3632
  })
2766
3633
  });
@@ -2768,6 +3635,7 @@ function createObservableClient(client) {
2768
3635
  }
2769
3636
 
2770
3637
  // src/public-utils/osdkConfig.ts
3638
+ chunk6SCDLAU2_cjs.init_cjs_shims();
2771
3639
  function getMetaTagContent(name) {
2772
3640
  const element = document.querySelector(`meta[name="${name}"]`);
2773
3641
  const val = element ? element.getAttribute("content") : null;
@@ -2803,11 +3671,11 @@ function getOsdkConfig(ontologyRid) {
2803
3671
 
2804
3672
  Object.defineProperty(exports, "createClientWithTransaction", {
2805
3673
  enumerable: true,
2806
- get: function () { return chunkSDFKR62Z_cjs.createClientWithTransaction; }
3674
+ get: function () { return chunkHJX4D4KL_cjs.createClientWithTransaction; }
2807
3675
  });
2808
3676
  Object.defineProperty(exports, "augment", {
2809
3677
  enumerable: true,
2810
- get: function () { return chunkMEL46GIF_cjs.augment; }
3678
+ get: function () { return chunkRO7XAQOS_cjs.augment; }
2811
3679
  });
2812
3680
  exports.computeObjectSetCacheKey = computeObjectSetCacheKey;
2813
3681
  exports.createObservableClient = createObservableClient;