@osdk/client 2.7.1 → 2.8.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/CHANGELOG.md +92 -157
  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 +5 -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/createMinimalClient.js +1 -0
  10. package/build/browser/createMinimalClient.js.map +1 -1
  11. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +17 -1
  12. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  13. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +101 -0
  14. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  15. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js +1 -1
  16. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -1
  17. package/build/browser/fetchMetadata.test.js +9 -0
  18. package/build/browser/fetchMetadata.test.js.map +1 -1
  19. package/build/browser/intellisense.test.js +1 -1
  20. package/build/browser/intellisense.test.js.map +1 -1
  21. package/build/browser/internal/conversions/modernToLegacyWhereClause.js +1 -1
  22. package/build/browser/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  23. package/build/browser/object/aggregate.js +1 -0
  24. package/build/browser/object/aggregate.js.map +1 -1
  25. package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
  26. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js +3 -0
  27. package/build/browser/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
  28. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
  29. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  30. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +85 -3
  31. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  32. package/build/browser/object/convertWireToOsdkObjects.js +4 -4
  33. package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
  34. package/build/browser/object/convertWireToOsdkObjects.test.js +48 -27
  35. package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
  36. package/build/browser/object/fetchPage.js +18 -5
  37. package/build/browser/object/fetchPage.js.map +1 -1
  38. package/build/browser/object/object.test.js +123 -0
  39. package/build/browser/object/object.test.js.map +1 -1
  40. package/build/browser/objectSet/ObjectSet.test.js +6 -6
  41. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  42. package/build/browser/objectSet/ObjectSetListenerWebsocket.js +4 -4
  43. package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  44. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +3 -1
  45. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  46. package/build/browser/objectSet/createObjectSet.js +0 -4
  47. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  48. package/build/browser/objectSet/fetchLinksPage.js +1 -0
  49. package/build/browser/objectSet/fetchLinksPage.js.map +1 -1
  50. package/build/browser/observable/ObservableClient/ObserveLink.js.map +1 -1
  51. package/build/browser/observable/ObservableClient.js +11 -0
  52. package/build/browser/observable/ObservableClient.js.map +1 -1
  53. package/build/browser/observable/internal/AbstractHelper.js +56 -3
  54. package/build/browser/observable/internal/AbstractHelper.js.map +1 -1
  55. package/build/browser/observable/internal/AbstractHelper.test.js +114 -0
  56. package/build/browser/observable/internal/AbstractHelper.test.js.map +1 -0
  57. package/build/browser/observable/internal/BulkObjectLoader.js +71 -9
  58. package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -1
  59. package/build/browser/observable/internal/BulkObjectLoader.test.js +79 -0
  60. package/build/browser/observable/internal/BulkObjectLoader.test.js.map +1 -1
  61. package/build/browser/observable/internal/CacheKeys.js +19 -8
  62. package/build/browser/observable/internal/CacheKeys.js.map +1 -1
  63. package/build/browser/observable/internal/ListQueryView.js +120 -0
  64. package/build/browser/observable/internal/ListQueryView.js.map +1 -0
  65. package/build/browser/observable/internal/ObservableClientImpl.js +136 -24
  66. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  67. package/build/browser/observable/internal/PivotCanonicalizer.js +4 -4
  68. package/build/browser/observable/internal/PivotCanonicalizer.js.map +1 -1
  69. package/build/browser/observable/internal/Query.js +7 -5
  70. package/build/browser/observable/internal/Query.js.map +1 -1
  71. package/build/browser/observable/internal/RdpCanonicalizer.test.js +23 -7
  72. package/build/browser/observable/internal/RdpCanonicalizer.test.js.map +1 -1
  73. package/build/browser/observable/internal/Store.js +19 -2
  74. package/build/browser/observable/internal/Store.js.map +1 -1
  75. package/build/browser/observable/internal/Store.test.js +328 -1
  76. package/build/browser/observable/internal/Store.test.js.map +1 -1
  77. package/build/browser/observable/internal/actions/ActionApplication.js +7 -4
  78. package/build/browser/observable/internal/actions/ActionApplication.js.map +1 -1
  79. package/build/browser/observable/internal/actions/OptimisticJob.js +1 -1
  80. package/build/browser/observable/internal/actions/OptimisticJob.js.map +1 -1
  81. package/build/browser/observable/internal/aggregation/AggregationCacheKey.js +5 -3
  82. package/build/browser/observable/internal/aggregation/AggregationCacheKey.js.map +1 -1
  83. package/build/browser/observable/internal/aggregation/AggregationQuery.js +28 -2
  84. package/build/browser/observable/internal/aggregation/AggregationQuery.js.map +1 -1
  85. package/build/browser/observable/internal/aggregation/AggregationsHelper.js +18 -2
  86. package/build/browser/observable/internal/aggregation/AggregationsHelper.js.map +1 -1
  87. package/build/browser/observable/internal/aggregation/AggregationsHelper.test.js +103 -0
  88. package/build/browser/observable/internal/aggregation/AggregationsHelper.test.js.map +1 -0
  89. package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js +22 -3
  90. package/build/browser/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -1
  91. package/build/browser/observable/internal/base-list/BaseListQuery.js +73 -6
  92. package/build/browser/observable/internal/base-list/BaseListQuery.js.map +1 -1
  93. package/build/browser/observable/internal/function/FunctionQuery.js +27 -1
  94. package/build/browser/observable/internal/function/FunctionQuery.js.map +1 -1
  95. package/build/browser/observable/internal/function/FunctionsHelper.js +2 -1
  96. package/build/browser/observable/internal/function/FunctionsHelper.js.map +1 -1
  97. package/build/browser/observable/internal/getObjectTypesThatInvalidate.js +2 -2
  98. package/build/browser/observable/internal/getObjectTypesThatInvalidate.js.map +1 -1
  99. package/build/browser/observable/internal/links/LinksHelper.js +3 -2
  100. package/build/browser/observable/internal/links/LinksHelper.js.map +1 -1
  101. package/build/browser/observable/internal/links/SpecificLinkCacheKey.js +7 -5
  102. package/build/browser/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
  103. package/build/browser/observable/internal/links/SpecificLinkQuery.js +97 -62
  104. package/build/browser/observable/internal/links/SpecificLinkQuery.js.map +1 -1
  105. package/build/browser/observable/internal/list/InterfaceListQuery.js +19 -1
  106. package/build/browser/observable/internal/list/InterfaceListQuery.js.map +1 -1
  107. package/build/browser/observable/internal/list/ListQuery.js +30 -10
  108. package/build/browser/observable/internal/list/ListQuery.js.map +1 -1
  109. package/build/browser/observable/internal/list/ListQuery.test.js +262 -1
  110. package/build/browser/observable/internal/list/ListQuery.test.js.map +1 -1
  111. package/build/browser/observable/internal/list/ListsHelper.js +1 -1
  112. package/build/browser/observable/internal/list/ListsHelper.js.map +1 -1
  113. package/build/browser/observable/internal/list/ObjectListQuery.js +22 -21
  114. package/build/browser/observable/internal/list/ObjectListQuery.js.map +1 -1
  115. package/build/browser/observable/internal/object/ObjectQuery.js +23 -6
  116. package/build/browser/observable/internal/object/ObjectQuery.js.map +1 -1
  117. package/build/browser/observable/internal/object/ObjectsHelper.js +12 -3
  118. package/build/browser/observable/internal/object/ObjectsHelper.js.map +1 -1
  119. package/build/browser/observable/internal/object/ObjectsHelper.test.js +200 -0
  120. package/build/browser/observable/internal/object/ObjectsHelper.test.js.map +1 -0
  121. package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -1
  122. package/build/browser/observable/internal/objectset/ObjectSetHelper.js +3 -2
  123. package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  124. package/build/browser/observable/internal/objectset/ObjectSetHelper.test.js +94 -0
  125. package/build/browser/observable/internal/objectset/ObjectSetHelper.test.js.map +1 -0
  126. package/build/browser/observable/internal/objectset/ObjectSetQuery.js +4 -1
  127. package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  128. package/build/browser/observable/internal/testUtils/observeLink/expectStandardObserveLink.js +1 -0
  129. package/build/browser/observable/internal/testUtils/observeLink/expectStandardObserveLink.js.map +1 -1
  130. package/build/browser/observable/internal/testUtils.js.map +1 -1
  131. package/build/browser/observable/internal/utils/rdpFieldOperations.js +7 -2
  132. package/build/browser/observable/internal/utils/rdpFieldOperations.js.map +1 -1
  133. package/build/browser/observable/internal/utils/rdpFieldOperations.test.js +55 -0
  134. package/build/browser/observable/internal/utils/rdpFieldOperations.test.js.map +1 -1
  135. package/build/browser/ontology/loadActionMetadata.js +3 -1
  136. package/build/browser/ontology/loadActionMetadata.js.map +1 -1
  137. package/build/browser/ontology/loadFullObjectMetadata.js +2 -1
  138. package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
  139. package/build/browser/ontology/loadInterfaceMetadata.js +2 -1
  140. package/build/browser/ontology/loadInterfaceMetadata.js.map +1 -1
  141. package/build/browser/public/unstable-do-not-use.js +1 -0
  142. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  143. package/build/browser/util/UserAgent.js +2 -2
  144. package/build/browser/util/UserAgent.js.map +1 -1
  145. package/build/browser/util/interfaceUtils.js +7 -0
  146. package/build/browser/util/interfaceUtils.js.map +1 -1
  147. package/build/cjs/{chunk-OVZCGOMG.cjs → chunk-6VOFZIIJ.cjs} +196 -92
  148. package/build/cjs/chunk-6VOFZIIJ.cjs.map +1 -0
  149. package/build/cjs/{chunk-OZNDU7AU.cjs → chunk-YVZM2JPW.cjs} +237 -196
  150. package/build/cjs/chunk-YVZM2JPW.cjs.map +1 -0
  151. package/build/cjs/{createClient-BDmrDOzZ.d.cts → createClient-BPK4om7e.d.cts} +1 -0
  152. package/build/cjs/index.cjs +8 -8
  153. package/build/cjs/index.d.cts +1 -1
  154. package/build/cjs/public/internal.cjs +8 -8
  155. package/build/cjs/public/unstable-do-not-use.cjs +928 -360
  156. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  157. package/build/cjs/public/unstable-do-not-use.d.cts +65 -27
  158. package/build/esm/Client.js +1 -1
  159. package/build/esm/Client.js.map +1 -1
  160. package/build/esm/MinimalClientContext.js.map +1 -1
  161. package/build/esm/actions/applyAction.js +5 -0
  162. package/build/esm/actions/applyAction.js.map +1 -1
  163. package/build/esm/createClient.js +2 -1
  164. package/build/esm/createClient.js.map +1 -1
  165. package/build/esm/createMinimalClient.js +1 -0
  166. package/build/esm/createMinimalClient.js.map +1 -1
  167. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +17 -1
  168. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  169. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +101 -0
  170. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  171. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js +1 -1
  172. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -1
  173. package/build/esm/fetchMetadata.test.js +9 -0
  174. package/build/esm/fetchMetadata.test.js.map +1 -1
  175. package/build/esm/intellisense.test.js +1 -1
  176. package/build/esm/intellisense.test.js.map +1 -1
  177. package/build/esm/internal/conversions/modernToLegacyWhereClause.js +1 -1
  178. package/build/esm/internal/conversions/modernToLegacyWhereClause.js.map +1 -1
  179. package/build/esm/object/aggregate.js +1 -0
  180. package/build/esm/object/aggregate.js.map +1 -1
  181. package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -1
  182. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js +3 -0
  183. package/build/esm/object/convertWireToOsdkObjects/InternalSymbols.js.map +1 -1
  184. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
  185. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  186. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +85 -3
  187. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  188. package/build/esm/object/convertWireToOsdkObjects.js +4 -4
  189. package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
  190. package/build/esm/object/convertWireToOsdkObjects.test.js +48 -27
  191. package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
  192. package/build/esm/object/fetchPage.js +18 -5
  193. package/build/esm/object/fetchPage.js.map +1 -1
  194. package/build/esm/object/object.test.js +123 -0
  195. package/build/esm/object/object.test.js.map +1 -1
  196. package/build/esm/objectSet/ObjectSet.test.js +6 -6
  197. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  198. package/build/esm/objectSet/ObjectSetListenerWebsocket.js +4 -4
  199. package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  200. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +3 -1
  201. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  202. package/build/esm/objectSet/createObjectSet.js +0 -4
  203. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  204. package/build/esm/objectSet/fetchLinksPage.js +1 -0
  205. package/build/esm/objectSet/fetchLinksPage.js.map +1 -1
  206. package/build/esm/observable/ObservableClient/ObserveLink.js.map +1 -1
  207. package/build/esm/observable/ObservableClient.js +11 -0
  208. package/build/esm/observable/ObservableClient.js.map +1 -1
  209. package/build/esm/observable/internal/AbstractHelper.js +56 -3
  210. package/build/esm/observable/internal/AbstractHelper.js.map +1 -1
  211. package/build/esm/observable/internal/AbstractHelper.test.js +114 -0
  212. package/build/esm/observable/internal/AbstractHelper.test.js.map +1 -0
  213. package/build/esm/observable/internal/BulkObjectLoader.js +71 -9
  214. package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -1
  215. package/build/esm/observable/internal/BulkObjectLoader.test.js +79 -0
  216. package/build/esm/observable/internal/BulkObjectLoader.test.js.map +1 -1
  217. package/build/esm/observable/internal/CacheKeys.js +19 -8
  218. package/build/esm/observable/internal/CacheKeys.js.map +1 -1
  219. package/build/esm/observable/internal/ListQueryView.js +120 -0
  220. package/build/esm/observable/internal/ListQueryView.js.map +1 -0
  221. package/build/esm/observable/internal/ObservableClientImpl.js +136 -24
  222. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  223. package/build/esm/observable/internal/PivotCanonicalizer.js +4 -4
  224. package/build/esm/observable/internal/PivotCanonicalizer.js.map +1 -1
  225. package/build/esm/observable/internal/Query.js +7 -5
  226. package/build/esm/observable/internal/Query.js.map +1 -1
  227. package/build/esm/observable/internal/RdpCanonicalizer.test.js +23 -7
  228. package/build/esm/observable/internal/RdpCanonicalizer.test.js.map +1 -1
  229. package/build/esm/observable/internal/Store.js +19 -2
  230. package/build/esm/observable/internal/Store.js.map +1 -1
  231. package/build/esm/observable/internal/Store.test.js +328 -1
  232. package/build/esm/observable/internal/Store.test.js.map +1 -1
  233. package/build/esm/observable/internal/actions/ActionApplication.js +7 -4
  234. package/build/esm/observable/internal/actions/ActionApplication.js.map +1 -1
  235. package/build/esm/observable/internal/actions/OptimisticJob.js +1 -1
  236. package/build/esm/observable/internal/actions/OptimisticJob.js.map +1 -1
  237. package/build/esm/observable/internal/aggregation/AggregationCacheKey.js +5 -3
  238. package/build/esm/observable/internal/aggregation/AggregationCacheKey.js.map +1 -1
  239. package/build/esm/observable/internal/aggregation/AggregationQuery.js +28 -2
  240. package/build/esm/observable/internal/aggregation/AggregationQuery.js.map +1 -1
  241. package/build/esm/observable/internal/aggregation/AggregationsHelper.js +18 -2
  242. package/build/esm/observable/internal/aggregation/AggregationsHelper.js.map +1 -1
  243. package/build/esm/observable/internal/aggregation/AggregationsHelper.test.js +103 -0
  244. package/build/esm/observable/internal/aggregation/AggregationsHelper.test.js.map +1 -0
  245. package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js +22 -3
  246. package/build/esm/observable/internal/aggregation/ObjectAggregationQuery.js.map +1 -1
  247. package/build/esm/observable/internal/base-list/BaseListQuery.js +73 -6
  248. package/build/esm/observable/internal/base-list/BaseListQuery.js.map +1 -1
  249. package/build/esm/observable/internal/function/FunctionQuery.js +27 -1
  250. package/build/esm/observable/internal/function/FunctionQuery.js.map +1 -1
  251. package/build/esm/observable/internal/function/FunctionsHelper.js +2 -1
  252. package/build/esm/observable/internal/function/FunctionsHelper.js.map +1 -1
  253. package/build/esm/observable/internal/getObjectTypesThatInvalidate.js +2 -2
  254. package/build/esm/observable/internal/getObjectTypesThatInvalidate.js.map +1 -1
  255. package/build/esm/observable/internal/links/LinksHelper.js +3 -2
  256. package/build/esm/observable/internal/links/LinksHelper.js.map +1 -1
  257. package/build/esm/observable/internal/links/SpecificLinkCacheKey.js +7 -5
  258. package/build/esm/observable/internal/links/SpecificLinkCacheKey.js.map +1 -1
  259. package/build/esm/observable/internal/links/SpecificLinkQuery.js +97 -62
  260. package/build/esm/observable/internal/links/SpecificLinkQuery.js.map +1 -1
  261. package/build/esm/observable/internal/list/InterfaceListQuery.js +19 -1
  262. package/build/esm/observable/internal/list/InterfaceListQuery.js.map +1 -1
  263. package/build/esm/observable/internal/list/ListQuery.js +30 -10
  264. package/build/esm/observable/internal/list/ListQuery.js.map +1 -1
  265. package/build/esm/observable/internal/list/ListQuery.test.js +262 -1
  266. package/build/esm/observable/internal/list/ListQuery.test.js.map +1 -1
  267. package/build/esm/observable/internal/list/ListsHelper.js +1 -1
  268. package/build/esm/observable/internal/list/ListsHelper.js.map +1 -1
  269. package/build/esm/observable/internal/list/ObjectListQuery.js +22 -21
  270. package/build/esm/observable/internal/list/ObjectListQuery.js.map +1 -1
  271. package/build/esm/observable/internal/object/ObjectQuery.js +23 -6
  272. package/build/esm/observable/internal/object/ObjectQuery.js.map +1 -1
  273. package/build/esm/observable/internal/object/ObjectsHelper.js +12 -3
  274. package/build/esm/observable/internal/object/ObjectsHelper.js.map +1 -1
  275. package/build/esm/observable/internal/object/ObjectsHelper.test.js +200 -0
  276. package/build/esm/observable/internal/object/ObjectsHelper.test.js.map +1 -0
  277. package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -1
  278. package/build/esm/observable/internal/objectset/ObjectSetHelper.js +3 -2
  279. package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -1
  280. package/build/esm/observable/internal/objectset/ObjectSetHelper.test.js +94 -0
  281. package/build/esm/observable/internal/objectset/ObjectSetHelper.test.js.map +1 -0
  282. package/build/esm/observable/internal/objectset/ObjectSetQuery.js +4 -1
  283. package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -1
  284. package/build/esm/observable/internal/testUtils/observeLink/expectStandardObserveLink.js +1 -0
  285. package/build/esm/observable/internal/testUtils/observeLink/expectStandardObserveLink.js.map +1 -1
  286. package/build/esm/observable/internal/testUtils.js.map +1 -1
  287. package/build/esm/observable/internal/utils/rdpFieldOperations.js +7 -2
  288. package/build/esm/observable/internal/utils/rdpFieldOperations.js.map +1 -1
  289. package/build/esm/observable/internal/utils/rdpFieldOperations.test.js +55 -0
  290. package/build/esm/observable/internal/utils/rdpFieldOperations.test.js.map +1 -1
  291. package/build/esm/ontology/loadActionMetadata.js +3 -1
  292. package/build/esm/ontology/loadActionMetadata.js.map +1 -1
  293. package/build/esm/ontology/loadFullObjectMetadata.js +2 -1
  294. package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
  295. package/build/esm/ontology/loadInterfaceMetadata.js +2 -1
  296. package/build/esm/ontology/loadInterfaceMetadata.js.map +1 -1
  297. package/build/esm/public/unstable-do-not-use.js +1 -0
  298. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  299. package/build/esm/util/UserAgent.js +2 -2
  300. package/build/esm/util/UserAgent.js.map +1 -1
  301. package/build/esm/util/interfaceUtils.js +7 -0
  302. package/build/esm/util/interfaceUtils.js.map +1 -1
  303. package/build/types/Client.d.ts +1 -1
  304. package/build/types/MinimalClientContext.d.ts +1 -1
  305. package/build/types/actions/applyAction.d.ts.map +1 -1
  306. package/build/types/createClient.d.ts +1 -0
  307. package/build/types/createClient.d.ts.map +1 -1
  308. package/build/types/object/convertWireToOsdkObjects/InternalSymbols.d.ts +2 -0
  309. package/build/types/object/convertWireToOsdkObjects/InternalSymbols.d.ts.map +1 -1
  310. package/build/types/object/convertWireToOsdkObjects.d.ts +4 -4
  311. package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
  312. package/build/types/object/fetchPage.d.ts.map +1 -1
  313. package/build/types/object/object.test.d.ts.map +1 -1
  314. package/build/types/objectSet/createObjectSet.d.ts +5 -14
  315. package/build/types/objectSet/createObjectSet.d.ts.map +1 -1
  316. package/build/types/objectSet/fetchLinksPage.d.ts +1 -9
  317. package/build/types/objectSet/fetchLinksPage.d.ts.map +1 -1
  318. package/build/types/observable/ObservableClient/ObserveLink.d.ts +2 -1
  319. package/build/types/observable/ObservableClient/ObserveLink.d.ts.map +1 -1
  320. package/build/types/observable/ObservableClient.d.ts +71 -25
  321. package/build/types/observable/ObservableClient.d.ts.map +1 -1
  322. package/build/types/observable/internal/AbstractHelper.d.ts +1 -1
  323. package/build/types/observable/internal/AbstractHelper.d.ts.map +1 -1
  324. package/build/types/observable/internal/AbstractHelper.test.d.ts +1 -0
  325. package/build/types/observable/internal/AbstractHelper.test.d.ts.map +1 -0
  326. package/build/types/observable/internal/BulkObjectLoader.d.ts +2 -1
  327. package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -1
  328. package/build/types/observable/internal/CacheKeys.d.ts +5 -0
  329. package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
  330. package/build/types/observable/internal/ListQueryView.d.ts +21 -0
  331. package/build/types/observable/internal/ListQueryView.d.ts.map +1 -0
  332. package/build/types/observable/internal/PivotCanonicalizer.d.ts +2 -2
  333. package/build/types/observable/internal/PivotCanonicalizer.d.ts.map +1 -1
  334. package/build/types/observable/internal/Query.d.ts.map +1 -1
  335. package/build/types/observable/internal/Store.d.ts.map +1 -1
  336. package/build/types/observable/internal/Store.test.d.ts.map +1 -1
  337. package/build/types/observable/internal/actions/ActionApplication.d.ts.map +1 -1
  338. package/build/types/observable/internal/actions/OptimisticJob.d.ts.map +1 -1
  339. package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts +6 -4
  340. package/build/types/observable/internal/aggregation/AggregationCacheKey.d.ts.map +1 -1
  341. package/build/types/observable/internal/aggregation/AggregationQuery.d.ts +8 -3
  342. package/build/types/observable/internal/aggregation/AggregationQuery.d.ts.map +1 -1
  343. package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts +19 -14
  344. package/build/types/observable/internal/aggregation/AggregationsHelper.d.ts.map +1 -1
  345. package/build/types/observable/internal/aggregation/AggregationsHelper.test.d.ts +1 -0
  346. package/build/types/observable/internal/aggregation/AggregationsHelper.test.d.ts.map +1 -0
  347. package/build/types/observable/internal/aggregation/ObjectAggregationQuery.d.ts.map +1 -1
  348. package/build/types/observable/internal/base-list/BaseListQuery.d.ts +47 -2
  349. package/build/types/observable/internal/base-list/BaseListQuery.d.ts.map +1 -1
  350. package/build/types/observable/internal/function/FunctionQuery.d.ts +1 -1
  351. package/build/types/observable/internal/function/FunctionQuery.d.ts.map +1 -1
  352. package/build/types/observable/internal/function/FunctionsHelper.d.ts +1 -0
  353. package/build/types/observable/internal/function/FunctionsHelper.d.ts.map +1 -1
  354. package/build/types/observable/internal/links/LinksHelper.d.ts +5 -5
  355. package/build/types/observable/internal/links/LinksHelper.d.ts.map +1 -1
  356. package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts +8 -6
  357. package/build/types/observable/internal/links/SpecificLinkCacheKey.d.ts.map +1 -1
  358. package/build/types/observable/internal/links/SpecificLinkQuery.d.ts +3 -4
  359. package/build/types/observable/internal/links/SpecificLinkQuery.d.ts.map +1 -1
  360. package/build/types/observable/internal/list/InterfaceListQuery.d.ts.map +1 -1
  361. package/build/types/observable/internal/list/ListQuery.d.ts +0 -3
  362. package/build/types/observable/internal/list/ListQuery.d.ts.map +1 -1
  363. package/build/types/observable/internal/list/ListsHelper.d.ts +4 -4
  364. package/build/types/observable/internal/list/ListsHelper.d.ts.map +1 -1
  365. package/build/types/observable/internal/list/ObjectListQuery.d.ts.map +1 -1
  366. package/build/types/observable/internal/object/ObjectQuery.d.ts +2 -1
  367. package/build/types/observable/internal/object/ObjectQuery.d.ts.map +1 -1
  368. package/build/types/observable/internal/object/ObjectsHelper.d.ts +8 -4
  369. package/build/types/observable/internal/object/ObjectsHelper.d.ts.map +1 -1
  370. package/build/types/observable/internal/object/ObjectsHelper.test.d.ts +1 -0
  371. package/build/types/observable/internal/object/ObjectsHelper.test.d.ts.map +1 -0
  372. package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts +2 -1
  373. package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts.map +1 -1
  374. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts +3 -1
  375. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -1
  376. package/build/types/observable/internal/objectset/ObjectSetHelper.test.d.ts +1 -0
  377. package/build/types/observable/internal/objectset/ObjectSetHelper.test.d.ts.map +1 -0
  378. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +2 -0
  379. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -1
  380. package/build/types/observable/internal/testUtils.d.ts +2 -2
  381. package/build/types/observable/internal/testUtils.d.ts.map +1 -1
  382. package/build/types/public/unstable-do-not-use.d.ts +1 -0
  383. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  384. package/build/types/util/interfaceUtils.d.ts +2 -1
  385. package/build/types/util/interfaceUtils.d.ts.map +1 -1
  386. package/package.json +15 -14
  387. package/build/cjs/chunk-OVZCGOMG.cjs.map +0 -1
  388. package/build/cjs/chunk-OZNDU7AU.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkOVZCGOMG_cjs = require('../chunk-OVZCGOMG.cjs');
4
- var chunkOZNDU7AU_cjs = require('../chunk-OZNDU7AU.cjs');
3
+ var chunk6VOFZIIJ_cjs = require('../chunk-6VOFZIIJ.cjs');
4
+ var chunkYVZM2JPW_cjs = require('../chunk-YVZM2JPW.cjs');
5
5
  var chunkLDTMSHUZ_cjs = require('../chunk-LDTMSHUZ.cjs');
6
6
  var trie = require('@wry/trie');
7
7
  var deepEqual = require('fast-deep-equal');
@@ -153,7 +153,7 @@ var WhereClauseCanonicalizer = class {
153
153
  var whereCanonicalizer = new WhereClauseCanonicalizer();
154
154
  var orderByCanonicalizer = new OrderByCanonicalizer();
155
155
  function computeObjectSetCacheKey(objectSet, options) {
156
- const keyParts = ["objectSet", chunkOZNDU7AU_cjs.getWireObjectSet(objectSet)];
156
+ const keyParts = ["objectSet", chunkYVZM2JPW_cjs.getWireObjectSet(objectSet)];
157
157
  if (!options) {
158
158
  return JSON.stringify(keyParts);
159
159
  }
@@ -165,13 +165,13 @@ function computeObjectSetCacheKey(objectSet, options) {
165
165
  keyParts.push("props", propKeys);
166
166
  }
167
167
  if (options.union && options.union.length > 0) {
168
- keyParts.push("union", options.union.map((os) => chunkOZNDU7AU_cjs.getWireObjectSet(os)));
168
+ keyParts.push("union", options.union.map((os) => chunkYVZM2JPW_cjs.getWireObjectSet(os)));
169
169
  }
170
170
  if (options.intersect && options.intersect.length > 0) {
171
- keyParts.push("intersect", options.intersect.map((os) => chunkOZNDU7AU_cjs.getWireObjectSet(os)));
171
+ keyParts.push("intersect", options.intersect.map((os) => chunkYVZM2JPW_cjs.getWireObjectSet(os)));
172
172
  }
173
173
  if (options.subtract && options.subtract.length > 0) {
174
- keyParts.push("subtract", options.subtract.map((os) => chunkOZNDU7AU_cjs.getWireObjectSet(os)));
174
+ keyParts.push("subtract", options.subtract.map((os) => chunkYVZM2JPW_cjs.getWireObjectSet(os)));
175
175
  }
176
176
  if (options.pivotTo) {
177
177
  keyParts.push("pivotTo", options.pivotTo);
@@ -228,43 +228,40 @@ var ObservableClientImpl = class {
228
228
  subFn
229
229
  );
230
230
  };
231
- observeAggregation = (options, subFn) => {
231
+ observeAggregation(options, subFn) {
232
+ if (options.objectSet) {
233
+ return this.__experimentalStore.aggregations.observeAsync(options, subFn);
234
+ }
232
235
  return this.__experimentalStore.aggregations.observe(options, subFn);
233
- };
236
+ }
234
237
  observeFunction = (queryDef, params, options, subFn) => {
235
238
  const dependsOn = options.dependsOn?.map((dep) => typeof dep === "string" ? dep : dep.apiName);
236
- const dependsOnObjects = options.dependsOnObjects?.map((obj) => ({
237
- $apiName: obj.$objectType ?? obj.$apiName,
238
- $primaryKey: obj.$primaryKey
239
- }));
239
+ const instances = [];
240
+ const objectSetWires = [];
241
+ for (const item of options.dependsOnObjects ?? []) {
242
+ if (chunkYVZM2JPW_cjs.isObjectSet(item)) {
243
+ objectSetWires.push(chunkYVZM2JPW_cjs.getWireObjectSet(item));
244
+ } else {
245
+ instances.push({
246
+ $apiName: item.$objectType ?? item.$apiName,
247
+ $primaryKey: item.$primaryKey
248
+ });
249
+ }
250
+ }
251
+ const objectSetTypesPromise = objectSetWires.length > 0 ? Promise.all(objectSetWires.map((wire) => chunkYVZM2JPW_cjs.extractObjectOrInterfaceType(this.__experimentalStore.client[chunkYVZM2JPW_cjs.additionalContext], wire))).then((types) => types.filter((t) => t != null).map((t) => t.apiName)) : void 0;
240
252
  return this.__experimentalStore.functions.observe({
241
253
  ...options,
242
254
  queryDef,
243
255
  params,
244
256
  dependsOn,
245
- dependsOnObjects
257
+ dependsOnObjects: instances,
258
+ objectSetTypesPromise
246
259
  }, subFn);
247
260
  };
248
261
  observeLinks = (objects, linkName, options, subFn) => {
249
262
  const objectsArray = Array.isArray(objects) ? objects : [objects];
250
- const parentSub = new rxjs.Subscription();
251
- for (const obj of objectsArray) {
252
- const querySubscription = this.__experimentalStore.links.observe(
253
- {
254
- ...options,
255
- srcType: {
256
- type: "object",
257
- apiName: obj.$objectType ?? obj.$apiName
258
- },
259
- linkName,
260
- pk: obj.$primaryKey
261
- },
262
- // cast to cross typed to untyped barrier
263
- subFn
264
- );
265
- parentSub.add(querySubscription);
266
- }
267
- return new UnsubscribableWrapper(parentSub);
263
+ const observer = subFn;
264
+ return objectsArray.length <= 1 ? observeSingleLink(this.__experimentalStore, objectsArray, linkName, options, observer) : observeMultiLinks(this.__experimentalStore, objectsArray, linkName, options, observer);
268
265
  };
269
266
  observeObjectSet(baseObjectSet, options, subFn) {
270
267
  return this.__experimentalStore.objectSets.observe(
@@ -295,6 +292,114 @@ var ObservableClientImpl = class {
295
292
  return this.__experimentalStore.whereCanonicalizer.canonicalize(where);
296
293
  }
297
294
  };
295
+ function observeSingleLink(store, objectsArray, linkName, options, observer) {
296
+ if (objectsArray.length === 0) {
297
+ observer.next({
298
+ resolvedList: [],
299
+ isOptimistic: false,
300
+ lastUpdated: 0,
301
+ fetchMore: () => Promise.resolve(),
302
+ hasMore: false,
303
+ status: "loaded",
304
+ totalCount: "0"
305
+ });
306
+ return new UnsubscribableWrapper(new rxjs.Subscription());
307
+ }
308
+ const parentSub = new rxjs.Subscription();
309
+ for (const obj of objectsArray) {
310
+ const sourceType = obj.$apiName === obj.$objectType ? "object" : "interface";
311
+ parentSub.add(store.links.observe({
312
+ ...options,
313
+ srcType: {
314
+ type: sourceType,
315
+ apiName: obj.$apiName
316
+ },
317
+ sourceUnderlyingObjectType: obj.$objectType,
318
+ linkName,
319
+ pk: obj.$primaryKey
320
+ }, observer));
321
+ }
322
+ return new UnsubscribableWrapper(parentSub);
323
+ }
324
+ function observeMultiLinks(store, objectsArray, linkName, options, observer) {
325
+ const parentSub = new rxjs.Subscription();
326
+ const totalExpected = objectsArray.length;
327
+ const perObjectResults = /* @__PURE__ */ new Map();
328
+ let errored = false;
329
+ function mergeAndEmit() {
330
+ if (errored) {
331
+ return;
332
+ }
333
+ const seen = /* @__PURE__ */ new Map();
334
+ const fetchMores = [];
335
+ let latestUpdated = 0;
336
+ let hasMore = false;
337
+ let isOptimistic = false;
338
+ for (const payload of perObjectResults.values()) {
339
+ for (const obj of payload.resolvedList) {
340
+ seen.set(`${obj.$objectType}:${obj.$primaryKey}`, obj);
341
+ }
342
+ if (payload.lastUpdated > latestUpdated) {
343
+ latestUpdated = payload.lastUpdated;
344
+ }
345
+ if (payload.isOptimistic) {
346
+ isOptimistic = true;
347
+ }
348
+ if (payload.hasMore) {
349
+ hasMore = true;
350
+ fetchMores.push(payload.fetchMore);
351
+ }
352
+ }
353
+ const payloads = [...perObjectResults.values()];
354
+ const loading = perObjectResults.size < totalExpected || payloads.some((p) => p.status === "init" || p.status === "loading");
355
+ observer.next({
356
+ resolvedList: Array.from(seen.values()),
357
+ isOptimistic,
358
+ lastUpdated: latestUpdated,
359
+ fetchMore: hasMore ? () => Promise.all(fetchMores.map((fn) => fn())).then(() => {
360
+ }) : () => Promise.resolve(),
361
+ hasMore,
362
+ status: loading ? "loading" : payloads.some((p) => p.status === "error") ? "error" : "loaded",
363
+ ...!hasMore ? {
364
+ totalCount: String(seen.size)
365
+ } : {}
366
+ });
367
+ }
368
+ for (const obj of objectsArray) {
369
+ const objKey = `${obj.$objectType ?? obj.$apiName}:${obj.$primaryKey}`;
370
+ const sourceType = obj.$apiName === obj.$objectType ? "object" : "interface";
371
+ parentSub.add(store.links.observe({
372
+ ...options,
373
+ srcType: {
374
+ type: sourceType,
375
+ apiName: obj.$apiName
376
+ },
377
+ sourceUnderlyingObjectType: obj.$objectType,
378
+ linkName,
379
+ pk: obj.$primaryKey
380
+ }, {
381
+ next: (payload) => {
382
+ if (errored) {
383
+ return;
384
+ }
385
+ perObjectResults.set(objKey, payload);
386
+ mergeAndEmit();
387
+ },
388
+ error: (err) => {
389
+ if (errored) {
390
+ return;
391
+ }
392
+ errored = true;
393
+ parentSub.unsubscribe();
394
+ observer.error(err);
395
+ },
396
+ // store link queries are long-lived and do not complete
397
+ complete: () => {
398
+ }
399
+ }));
400
+ }
401
+ return new UnsubscribableWrapper(parentSub);
402
+ }
298
403
 
299
404
  // src/observable/internal/Store.ts
300
405
  chunkLDTMSHUZ_cjs.init_cjs_shims();
@@ -371,12 +476,12 @@ var OptimisticJob = class {
371
476
  return this;
372
477
  },
373
478
  createObject(type, pk, properties) {
374
- const create = store.client[chunkOZNDU7AU_cjs.additionalContext].objectFactory2(store.client[chunkOZNDU7AU_cjs.additionalContext], [{
479
+ const create = store.client[chunkYVZM2JPW_cjs.additionalContext].objectFactory2(store.client[chunkYVZM2JPW_cjs.additionalContext], [{
375
480
  $primaryKey: pk,
376
481
  $apiName: type.apiName,
377
482
  $objectType: type.apiName,
378
483
  ...properties
379
- }], void 0, {}).then((objs) => {
484
+ }], void 0, {}, void 0).then((objs) => {
380
485
  return objs[0];
381
486
  });
382
487
  addedObjectPromises.push(create);
@@ -476,18 +581,13 @@ var ActionApplication = class {
476
581
  objectType,
477
582
  primaryKey
478
583
  } of deletedObjects ?? []) {
479
- const cacheKey = this.store.cacheKeys.get(
480
- "object",
481
- objectType,
482
- primaryKey,
483
- /* rdpConfig */
484
- void 0
485
- );
486
- this.store.queries.peek(cacheKey)?.deleteFromStore(
487
- "loaded",
488
- // this is probably not the best value to use
489
- batch
490
- );
584
+ for (const cacheKey of this.store.objectCacheKeyRegistry.getVariants(objectType, primaryKey)) {
585
+ this.store.queries.peek(cacheKey)?.deleteFromStore(
586
+ "loaded",
587
+ // this is probably not the best value to use
588
+ batch
589
+ );
590
+ }
491
591
  }
492
592
  });
493
593
  await Promise.all(promisesToWait);
@@ -502,9 +602,11 @@ var ActionApplication = class {
502
602
  // src/observable/internal/aggregation/AggregationCacheKey.ts
503
603
  chunkLDTMSHUZ_cjs.init_cjs_shims();
504
604
  var API_NAME_IDX = 1;
505
- var WHERE_IDX = 2;
506
- var RDP_IDX = 3;
507
- var AGGREGATE_IDX = 4;
605
+ var WIRE_OBJECT_SET_IDX = 2;
606
+ var WHERE_IDX = 3;
607
+ var RDP_IDX = 4;
608
+ var INTERSECT_IDX = 5;
609
+ var AGGREGATE_IDX = 6;
508
610
 
509
611
  // src/observable/internal/aggregation/AggregationsHelper.ts
510
612
  chunkLDTMSHUZ_cjs.init_cjs_shims();
@@ -512,6 +614,83 @@ chunkLDTMSHUZ_cjs.init_cjs_shims();
512
614
  // src/observable/internal/AbstractHelper.ts
513
615
  chunkLDTMSHUZ_cjs.init_cjs_shims();
514
616
 
617
+ // src/observable/internal/ListQueryView.ts
618
+ chunkLDTMSHUZ_cjs.init_cjs_shims();
619
+ var viewIdCounter = 0;
620
+ var ListQueryView = class {
621
+ #query;
622
+ #viewLimit;
623
+ #pageSize;
624
+ #viewId;
625
+ #hasAutoFetch;
626
+ #fetchMore;
627
+ #pendingFetchMore;
628
+ #lastPayload;
629
+ #observer;
630
+ constructor(query, pageSize, autoFetchMore) {
631
+ this.#query = query;
632
+ this.#pageSize = pageSize;
633
+ this.#viewId = `view_${++viewIdCounter}`;
634
+ this.#hasAutoFetch = autoFetchMore === true || typeof autoFetchMore === "number" && autoFetchMore > 0;
635
+ this.#viewLimit = this.#hasAutoFetch ? Number.MAX_SAFE_INTEGER : pageSize;
636
+ this.#fetchMore = this.#createFetchMore();
637
+ query.registerFetchPageSize(this.#viewId, pageSize);
638
+ }
639
+ subscribe(observer) {
640
+ this.#observer = observer;
641
+ const sub = this.#query.subscribe({
642
+ next: (payload) => {
643
+ this.#lastPayload = payload;
644
+ observer.next?.(this.#transformPayload(payload));
645
+ if (!this.#hasAutoFetch && payload.status === "loaded" && payload.resolvedList.length < this.#viewLimit && this.#query.hasMorePages()) {
646
+ void this.#query.fetchMore();
647
+ }
648
+ },
649
+ error: (err) => observer.error?.(err),
650
+ complete: () => observer.complete?.()
651
+ });
652
+ sub.add(() => {
653
+ this.#query.unregisterFetchPageSize(this.#viewId);
654
+ this.#observer = void 0;
655
+ this.#lastPayload = void 0;
656
+ });
657
+ return sub;
658
+ }
659
+ #reEmitWithNewViewLimit() {
660
+ if (this.#lastPayload && this.#observer) {
661
+ this.#observer.next?.(this.#transformPayload(this.#lastPayload));
662
+ }
663
+ }
664
+ #transformPayload(payload) {
665
+ const loadedCount = payload.resolvedList.length;
666
+ return {
667
+ ...payload,
668
+ resolvedList: payload.resolvedList.slice(0, this.#viewLimit),
669
+ hasMore: this.#viewLimit < loadedCount || payload.hasMore,
670
+ fetchMore: this.#fetchMore,
671
+ status: loadedCount >= this.#viewLimit && payload.status === "loading" ? "loaded" : payload.status
672
+ };
673
+ }
674
+ #createFetchMore() {
675
+ return () => {
676
+ if (this.#pendingFetchMore) {
677
+ return this.#pendingFetchMore;
678
+ }
679
+ this.#viewLimit += this.#pageSize;
680
+ const loadedCount = this.#query.getLoadedCount();
681
+ const hasMoreOnServer = this.#query.hasMorePages();
682
+ if (this.#viewLimit > loadedCount && hasMoreOnServer) {
683
+ this.#pendingFetchMore = this.#query.fetchMore().finally(() => {
684
+ this.#pendingFetchMore = void 0;
685
+ });
686
+ return this.#pendingFetchMore;
687
+ }
688
+ this.#reEmitWithNewViewLimit();
689
+ return Promise.resolve();
690
+ };
691
+ }
692
+ };
693
+
515
694
  // src/observable/internal/QuerySubscription.ts
516
695
  chunkLDTMSHUZ_cjs.init_cjs_shims();
517
696
  var subscriptionIdCounter = 0;
@@ -539,6 +718,9 @@ var QuerySubscription = class extends UnsubscribableWrapper {
539
718
  };
540
719
 
541
720
  // src/observable/internal/AbstractHelper.ts
721
+ function supportsViews(query) {
722
+ return query != null && typeof query.registerFetchPageSize === "function" && typeof query.getLoadedCount === "function" && typeof query.hasMorePages === "function" && typeof query.notifySubscribers === "function" && typeof query.fetchMore === "function";
723
+ }
542
724
  var AbstractHelper = class {
543
725
  constructor(store, cacheKeys) {
544
726
  this.store = store;
@@ -549,7 +731,16 @@ var AbstractHelper = class {
549
731
  return this._subscribe(query, options, subFn);
550
732
  }
551
733
  _subscribe(query, options, subFn) {
552
- this.store.cacheKeys.retain(query.cacheKey);
734
+ const pendingCleanupCount = this.store.pendingCleanup.get(query.cacheKey) ?? 0;
735
+ if (pendingCleanupCount > 0) {
736
+ if (pendingCleanupCount === 1) {
737
+ this.store.pendingCleanup.delete(query.cacheKey);
738
+ } else {
739
+ this.store.pendingCleanup.set(query.cacheKey, pendingCleanupCount - 1);
740
+ }
741
+ } else {
742
+ this.store.cacheKeys.retain(query.cacheKey);
743
+ }
553
744
  if (options.mode !== "offline") {
554
745
  query.revalidate(options.mode === "force").catch((e) => {
555
746
  subFn.error(e);
@@ -560,12 +751,25 @@ var AbstractHelper = class {
560
751
  }
561
752
  });
562
753
  }
563
- const sub = query.subscribe(subFn);
754
+ const listOptions = options;
755
+ const useView = supportsViews(query) && (listOptions.pageSize !== void 0 || listOptions.autoFetchMore !== void 0);
756
+ const sub = useView ? new ListQueryView(query, listOptions.pageSize ?? 100, listOptions.autoFetchMore).subscribe(subFn) : query.subscribe(subFn);
564
757
  const querySub = new QuerySubscription(query, sub);
565
758
  query.registerSubscriptionDedupeInterval(querySub.subscriptionId, options.dedupeInterval);
566
759
  sub.add(() => {
567
760
  query.unregisterSubscriptionDedupeInterval(querySub.subscriptionId);
568
- this.store.cacheKeys.release(query.cacheKey);
761
+ this.store.pendingCleanup.set(query.cacheKey, (this.store.pendingCleanup.get(query.cacheKey) ?? 0) + 1);
762
+ queueMicrotask(() => {
763
+ const currentPending = this.store.pendingCleanup.get(query.cacheKey) ?? 0;
764
+ if (currentPending > 0) {
765
+ if (currentPending === 1) {
766
+ this.store.pendingCleanup.delete(query.cacheKey);
767
+ } else {
768
+ this.store.pendingCleanup.set(query.cacheKey, currentPending - 1);
769
+ }
770
+ this.store.cacheKeys.release(query.cacheKey);
771
+ }
772
+ });
569
773
  });
570
774
  return querySub;
571
775
  }
@@ -577,6 +781,162 @@ chunkLDTMSHUZ_cjs.init_cjs_shims();
577
781
  // src/observable/internal/aggregation/AggregationQuery.ts
578
782
  chunkLDTMSHUZ_cjs.init_cjs_shims();
579
783
 
784
+ // src/observable/internal/getObjectTypesThatInvalidate.ts
785
+ chunkLDTMSHUZ_cjs.init_cjs_shims();
786
+ async function getObjectTypesThatInvalidate(mc, objectSet) {
787
+ const counts = {};
788
+ const resultType = await calcObjectSet(objectSet, {
789
+ counts,
790
+ methodInput: void 0,
791
+ ontologyProvider: mc.ontologyProvider
792
+ });
793
+ const tweaked = {
794
+ ...counts,
795
+ [resultType.apiName]: counts[resultType.apiName] - 1
796
+ };
797
+ return {
798
+ resultType,
799
+ counts,
800
+ invalidationSet: new Set(Object.entries(tweaked).filter(([, v]) => v > 0).map(([k]) => k))
801
+ };
802
+ }
803
+ async function calcObjectSet(os, ctx) {
804
+ const op = ctx.ontologyProvider;
805
+ async function bumpObject(apiName) {
806
+ const objectType = await op.getObjectDefinition(apiName);
807
+ ctx.counts[apiName] = (ctx.counts[apiName] ?? 0) + 1;
808
+ return objectType;
809
+ }
810
+ async function bumpInterface(apiName) {
811
+ const interfaceDef = await op.getInterfaceDefinition(apiName);
812
+ for (const s of interfaceDef.implementedBy ?? []) {
813
+ ctx.counts[s] = (ctx.counts[s] ?? 0) + 1;
814
+ }
815
+ return interfaceDef;
816
+ }
817
+ switch (os.type) {
818
+ case "base":
819
+ return await bumpObject(os.objectType);
820
+ case "interfaceBase":
821
+ return await bumpInterface(os.interfaceType);
822
+ case "interfaceLinkSearchAround": {
823
+ const srcDef = await calcObjectSet(os.objectSet, ctx);
824
+ !(srcDef.type === "interface") ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false) : invariant5__default.default(false) : void 0;
825
+ for (const [k, v] of Object.entries(srcDef.links)) {
826
+ if (k === os.interfaceLink) {
827
+ if (v.targetType === "object") {
828
+ return await bumpObject(v.targetTypeApiName);
829
+ }
830
+ return await bumpInterface(v.targetTypeApiName);
831
+ }
832
+ }
833
+ throw new Error(`Could not find link ${os.interfaceLink} in object set ${JSON.stringify(os.objectSet)}`);
834
+ }
835
+ case "searchAround": {
836
+ const contextDef = await calcObjectSet(os.objectSet, ctx);
837
+ !(contextDef.type === "object") ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false) : invariant5__default.default(false) : void 0;
838
+ for (const [k, v] of Object.entries(contextDef.links)) {
839
+ if (k === os.link) {
840
+ return await bumpObject(v.targetType);
841
+ }
842
+ }
843
+ throw new Error(`Could not find link ${os.link} in object set ${JSON.stringify(os.objectSet)}`);
844
+ }
845
+ case "filter":
846
+ return calcObjectSet(os.objectSet, ctx);
847
+ case "union":
848
+ case "subtract":
849
+ case "intersect":
850
+ const returnTypes = await Promise.all(os.objectSets.map(async (os2) => {
851
+ const counts = {};
852
+ const r = await calcObjectSet(os2, {
853
+ ...ctx,
854
+ counts
855
+ });
856
+ return {
857
+ r,
858
+ counts
859
+ };
860
+ }));
861
+ for (const {
862
+ counts
863
+ } of returnTypes) {
864
+ for (const [k, v] of Object.entries(counts)) {
865
+ ctx.counts[k] = Math.max(ctx.counts[k] ?? 0, v);
866
+ }
867
+ }
868
+ if (returnTypes.length === 0) {
869
+ throw new Error(`Could not find any context types for set operation`);
870
+ }
871
+ const allMatch = returnTypes.every(({
872
+ r
873
+ }) => r.apiName === returnTypes[0].r.apiName);
874
+ if (!allMatch) {
875
+ throw new Error(`Incompatible context types found for set operation`);
876
+ }
877
+ return returnTypes[0].r;
878
+ case "withProperties":
879
+ for (const [, v] of Object.entries(os.derivedProperties)) {
880
+ await calcRdp(v, {
881
+ ...ctx,
882
+ methodInput: os.objectSet
883
+ });
884
+ }
885
+ return calcObjectSet(os.objectSet, {
886
+ ...ctx,
887
+ methodInput: os.objectSet
888
+ });
889
+ // used by rdps
890
+ case "methodInput":
891
+ !ctx.methodInput ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "methodInput must be provided") : invariant5__default.default(false) : void 0;
892
+ return await calcObjectSet(ctx.methodInput, {
893
+ ...ctx,
894
+ counts: {}
895
+ });
896
+ case "asType":
897
+ // we don't currently support this anywhere.
898
+ case "asBaseObjectTypes":
899
+ // We don't currently support this because it could return multiple object types conceptually
900
+ // internally, we actually use it this way but we shouldn't be finding that object sets.
901
+ case "reference":
902
+ // reference is particularly problematic because we cannot answer the question about
903
+ // which types without loading the object set definition (and it can change).
904
+ case "static":
905
+ throw new Error(`Unsupported ObjectSet type ${os.type}`);
906
+ case "nearestNeighbors":
907
+ return calcObjectSet(os.objectSet, ctx);
908
+ default:
909
+ throw new Error(`Unhandled ObjectSet type ${os.type}`);
910
+ }
911
+ }
912
+ async function calcRdp(dpd, ctx) {
913
+ switch (dpd.type) {
914
+ // Operates on object sets
915
+ case "selection":
916
+ return await calcObjectSet(dpd.objectSet, ctx);
917
+ // Operates on single property
918
+ case "negate":
919
+ case "extract":
920
+ case "absoluteValue":
921
+ return await calcRdp(dpd.property, ctx);
922
+ // Operates on many (unordered) properties
923
+ case "least":
924
+ case "greatest":
925
+ case "add":
926
+ case "multiply":
927
+ return await Promise.all(dpd.properties.map((innerDpd) => calcRdp(innerDpd, ctx)));
928
+ // Operates on 2 ordered properties
929
+ case "subtract":
930
+ case "divide":
931
+ return await Promise.all([calcRdp(dpd.left, ctx), calcRdp(dpd.right, ctx)]);
932
+ // Operates on a single property name
933
+ case "property":
934
+ return;
935
+ default:
936
+ throw new Error(`Unhandled DerivedPropertyDefinition type ${dpd.type}`);
937
+ }
938
+ }
939
+
580
940
  // src/observable/internal/Query.ts
581
941
  chunkLDTMSHUZ_cjs.init_cjs_shims();
582
942
  var Query = class {
@@ -592,7 +952,7 @@ var Query = class {
592
952
  this.store = store;
593
953
  this.cacheKeys = store.cacheKeys;
594
954
  this.#subject = observable;
595
- this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkOZNDU7AU_cjs.additionalContext].logger : store.client[chunkOZNDU7AU_cjs.additionalContext].logger?.child({}, {
955
+ this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkYVZM2JPW_cjs.additionalContext].logger : store.client[chunkYVZM2JPW_cjs.additionalContext].logger?.child({}, {
596
956
  msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
597
957
  }));
598
958
  }
@@ -663,12 +1023,14 @@ var Query = class {
663
1023
  await this.pendingFetch;
664
1024
  return;
665
1025
  }
666
- const minDedupeInterval = this.getMinimumDedupeInterval();
667
- if (minDedupeInterval > 0 && this.lastFetchStarted != null && Date.now() - this.lastFetchStarted < minDedupeInterval) {
668
- if (process.env.NODE_ENV !== "production") {
669
- logger?.debug("Within dupeInterval, aborting revalidate");
1026
+ if (!force) {
1027
+ const minDedupeInterval = this.getMinimumDedupeInterval();
1028
+ if (minDedupeInterval > 0 && this.lastFetchStarted != null && Date.now() - this.lastFetchStarted < minDedupeInterval) {
1029
+ if (process.env.NODE_ENV !== "production") {
1030
+ logger?.debug("Within dupeInterval, aborting revalidate");
1031
+ }
1032
+ return Promise.resolve();
670
1033
  }
671
- return Promise.resolve();
672
1034
  }
673
1035
  if (process.env.NODE_ENV !== "production") {
674
1036
  logger?.debug("Starting actual revalidate");
@@ -749,14 +1111,39 @@ var Query = class {
749
1111
 
750
1112
  // src/observable/internal/aggregation/AggregationQuery.ts
751
1113
  var AggregationQuery = class extends Query {
1114
+ #invalidationTypes;
1115
+ #invalidationTypesPromise;
752
1116
  constructor(store, subject, cacheKey, opts) {
753
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkOZNDU7AU_cjs.additionalContext].logger?.child({}, {
1117
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkYVZM2JPW_cjs.additionalContext].logger?.child({}, {
754
1118
  msgPrefix: `AggregationQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
755
1119
  }) : void 0);
756
1120
  this.apiName = cacheKey.otherKeys[API_NAME_IDX];
757
1121
  this.canonicalWhere = cacheKey.otherKeys[WHERE_IDX];
758
1122
  this.rdpConfig = cacheKey.otherKeys[RDP_IDX];
759
1123
  this.canonicalAggregate = cacheKey.otherKeys[AGGREGATE_IDX];
1124
+ const serializedObjectSet = cacheKey.otherKeys[WIRE_OBJECT_SET_IDX];
1125
+ this.#invalidationTypes = /* @__PURE__ */ new Set([this.apiName]);
1126
+ if (serializedObjectSet) {
1127
+ this.parsedWireObjectSet = JSON.parse(serializedObjectSet);
1128
+ this.#invalidationTypesPromise = this.#computeInvalidationTypes(this.parsedWireObjectSet);
1129
+ }
1130
+ }
1131
+ async #computeInvalidationTypes(wireObjectSet) {
1132
+ try {
1133
+ const {
1134
+ invalidationSet
1135
+ } = await getObjectTypesThatInvalidate(this.store.client[chunkYVZM2JPW_cjs.additionalContext], wireObjectSet);
1136
+ return /* @__PURE__ */ new Set([this.apiName, ...invalidationSet]);
1137
+ } catch (error) {
1138
+ this.store.logger?.error("Failed to compute invalidation types for aggregation, falling back to base type only", error);
1139
+ return /* @__PURE__ */ new Set([this.apiName]);
1140
+ }
1141
+ }
1142
+ async ensureInvalidationTypesReady() {
1143
+ if (this.#invalidationTypesPromise) {
1144
+ this.#invalidationTypes = await this.#invalidationTypesPromise;
1145
+ this.#invalidationTypesPromise = void 0;
1146
+ }
760
1147
  }
761
1148
  _createConnectable(subject) {
762
1149
  return rxjs.connectable(subject.pipe(rxjs.map((x) => {
@@ -797,7 +1184,7 @@ var AggregationQuery = class extends Query {
797
1184
  return batch.read(this.cacheKey);
798
1185
  }
799
1186
  invalidateObjectType = (objectType, changes) => {
800
- if (this.apiName === objectType) {
1187
+ if (this.#invalidationTypes.has(objectType)) {
801
1188
  changes?.modified.add(this.cacheKey);
802
1189
  return this.revalidate(true);
803
1190
  }
@@ -809,33 +1196,64 @@ var AggregationQuery = class extends Query {
809
1196
  var ObjectAggregationQuery = class extends AggregationQuery {
810
1197
  async _fetchAggregation() {
811
1198
  const type = this.cacheKey.otherKeys[API_NAME_IDX];
812
- let objectSet = this.store.client({
1199
+ const intersectWith = this.cacheKey.otherKeys[INTERSECT_IDX];
1200
+ const objectTypeDef = {
813
1201
  type: "object",
814
1202
  apiName: type
815
- });
1203
+ };
1204
+ let objectSet;
1205
+ if (this.parsedWireObjectSet) {
1206
+ objectSet = chunkYVZM2JPW_cjs.createObjectSet(objectTypeDef, this.store.client[chunkYVZM2JPW_cjs.additionalContext], this.parsedWireObjectSet);
1207
+ } else {
1208
+ objectSet = this.store.client(objectTypeDef);
1209
+ }
816
1210
  if (this.rdpConfig) {
817
1211
  objectSet = objectSet.withProperties(this.rdpConfig);
818
1212
  }
819
1213
  objectSet = objectSet.where(this.canonicalWhere);
1214
+ if (intersectWith != null && intersectWith.length > 0) {
1215
+ const intersectSets = intersectWith.map((whereClause) => {
1216
+ let intersectSet = this.store.client(objectTypeDef);
1217
+ if (this.rdpConfig) {
1218
+ intersectSet = intersectSet.withProperties(this.rdpConfig);
1219
+ }
1220
+ return intersectSet.where(whereClause);
1221
+ });
1222
+ objectSet = objectSet.intersect(...intersectSets);
1223
+ }
820
1224
  return await objectSet.aggregate(this.canonicalAggregate);
821
1225
  }
822
1226
  };
823
1227
 
824
1228
  // src/observable/internal/aggregation/AggregationsHelper.ts
825
1229
  var AggregationsHelper = class extends AbstractHelper {
826
- constructor(store, cacheKeys, whereCanonicalizer2, rdpCanonicalizer) {
1230
+ constructor(store, cacheKeys, whereCanonicalizer2, rdpCanonicalizer, intersectCanonicalizer) {
827
1231
  super(store, cacheKeys);
828
1232
  this.whereCanonicalizer = whereCanonicalizer2;
829
1233
  this.rdpCanonicalizer = rdpCanonicalizer;
1234
+ this.intersectCanonicalizer = intersectCanonicalizer;
830
1235
  }
831
1236
  observe(options, subFn) {
832
1237
  return super.observe(options, subFn);
833
1238
  }
1239
+ async observeAsync(options, subFn) {
1240
+ const query = this.getQueryWithObjectSet(options);
1241
+ await query.ensureInvalidationTypesReady();
1242
+ return this._subscribe(query, options, subFn);
1243
+ }
834
1244
  getQuery(options) {
1245
+ return this.getOrCreateQuery(options, void 0);
1246
+ }
1247
+ getQueryWithObjectSet(options) {
1248
+ const serializedObjectSet = JSON.stringify(chunkYVZM2JPW_cjs.getWireObjectSet(options.objectSet));
1249
+ return this.getOrCreateQuery(options, serializedObjectSet);
1250
+ }
1251
+ getOrCreateQuery(options, serializedObjectSet) {
835
1252
  const {
836
1253
  type,
837
1254
  where,
838
1255
  withProperties,
1256
+ intersectWith,
839
1257
  aggregate
840
1258
  } = options;
841
1259
  const {
@@ -844,8 +1262,9 @@ var AggregationsHelper = class extends AbstractHelper {
844
1262
  const typeKind = "type" in type ? type.type : "interface";
845
1263
  const canonWhere = this.whereCanonicalizer.canonicalize(where ?? {});
846
1264
  const canonRdp = withProperties ? this.rdpCanonicalizer.canonicalize(withProperties) : void 0;
1265
+ const canonIntersect = intersectWith && intersectWith.length > 0 ? this.intersectCanonicalizer.canonicalize(intersectWith) : void 0;
847
1266
  const canonAggregate = this.canonicalizeAggregate(aggregate);
848
- const aggregationCacheKey = this.cacheKeys.get("aggregation", typeKind, apiName, canonWhere, canonRdp, canonAggregate);
1267
+ const aggregationCacheKey = this.cacheKeys.get("aggregation", typeKind, apiName, serializedObjectSet, canonWhere, canonRdp, canonIntersect, canonAggregate);
849
1268
  return this.store.queries.get(aggregationCacheKey, () => {
850
1269
  if (typeKind !== "object") {
851
1270
  throw new Error("Only ObjectTypeDefinition is currently supported for aggregations");
@@ -959,16 +1378,26 @@ var CacheKeys = class {
959
1378
  });
960
1379
  }
961
1380
  get(type, ...args) {
962
- const normalizedArgs = [...args];
963
- while (normalizedArgs.length > 0 && normalizedArgs[normalizedArgs.length - 1] === void 0) {
964
- normalizedArgs.pop();
965
- }
966
- const cacheKeyArgs = [type, ...normalizedArgs];
1381
+ const cacheKeyArgs = this.#normalizeArgs(type, args);
967
1382
  if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) ;
968
1383
  const cacheKey = this.#cacheKeys.lookupArray(cacheKeyArgs);
969
1384
  this.#refCounts.register(cacheKey);
970
1385
  return cacheKey;
971
1386
  }
1387
+ /**
1388
+ * Look up an existing cache key without creating or registering it.
1389
+ * Returns undefined if the key does not exist in the trie.
1390
+ */
1391
+ peek(type, ...args) {
1392
+ return this.#cacheKeys.peekArray(this.#normalizeArgs(type, args));
1393
+ }
1394
+ #normalizeArgs(type, args) {
1395
+ const normalizedArgs = [...args];
1396
+ while (normalizedArgs.length > 0 && normalizedArgs[normalizedArgs.length - 1] === void 0) {
1397
+ normalizedArgs.pop();
1398
+ }
1399
+ return [type, ...normalizedArgs];
1400
+ }
972
1401
  retain(cacheKey) {
973
1402
  this.#refCounts.retain(cacheKey);
974
1403
  }
@@ -1121,7 +1550,7 @@ var FunctionParamsCanonicalizer = class {
1121
1550
  path.push("$:map_end");
1122
1551
  return arr;
1123
1552
  }
1124
- if (chunkOVZCGOMG_cjs.isObjectSpecifiersObject(value)) {
1553
+ if (chunk6VOFZIIJ_cjs.isObjectSpecifiersObject(value)) {
1125
1554
  const objectType = value.$objectType ?? value.$apiName;
1126
1555
  path.push("$:osdk", objectType, value.$primaryKey);
1127
1556
  return {
@@ -1129,8 +1558,8 @@ var FunctionParamsCanonicalizer = class {
1129
1558
  $primaryKey: value.$primaryKey
1130
1559
  };
1131
1560
  }
1132
- if (chunkOZNDU7AU_cjs.isObjectSet(value)) {
1133
- const wire = chunkOZNDU7AU_cjs.getWireObjectSet(value);
1561
+ if (chunkYVZM2JPW_cjs.isObjectSet(value)) {
1562
+ const wire = chunkYVZM2JPW_cjs.getWireObjectSet(value);
1134
1563
  path.push("$:objectset", wire);
1135
1564
  return wire;
1136
1565
  }
@@ -1192,8 +1621,8 @@ var FunctionQuery = class extends Query {
1192
1621
  #dependsOn;
1193
1622
  #dependsOnObjects;
1194
1623
  #queryDef;
1195
- constructor(store, subject, queryDef, params, cacheKey, opts) {
1196
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkOZNDU7AU_cjs.additionalContext].logger?.child({}, {
1624
+ constructor(store, subject, queryDef, params, cacheKey, opts, objectSetTypesPromise) {
1625
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkYVZM2JPW_cjs.additionalContext].logger?.child({}, {
1197
1626
  msgPrefix: `FunctionQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
1198
1627
  }) : void 0);
1199
1628
  this.#apiName = queryDef.apiName;
@@ -1202,6 +1631,29 @@ var FunctionQuery = class extends Query {
1202
1631
  this.#dependsOn = opts.dependsOn;
1203
1632
  this.#dependsOnObjects = opts.dependsOnObjects;
1204
1633
  this.#queryDef = queryDef;
1634
+ if (objectSetTypesPromise) {
1635
+ objectSetTypesPromise.then((types) => {
1636
+ if (this.abortController?.signal.aborted) return;
1637
+ let addedNewTypes = false;
1638
+ for (const type of types) {
1639
+ if (!this.#dependsOn) {
1640
+ this.#dependsOn = [];
1641
+ }
1642
+ if (!this.#dependsOn.includes(type)) {
1643
+ this.#dependsOn.push(type);
1644
+ addedNewTypes = true;
1645
+ }
1646
+ }
1647
+ if (addedNewTypes) {
1648
+ void this.revalidate(true);
1649
+ }
1650
+ }).catch((error) => {
1651
+ if (this.abortController?.signal.aborted) return;
1652
+ if (process.env.NODE_ENV !== "production") {
1653
+ this.logger?.error("Failed to extract ObjectSet types", error);
1654
+ }
1655
+ });
1656
+ }
1205
1657
  }
1206
1658
  _createConnectable(subject) {
1207
1659
  return rxjs.connectable(subject.pipe(rxjs.map((x) => {
@@ -1227,7 +1679,7 @@ var FunctionQuery = class extends Query {
1227
1679
  }).debug("calling _fetchAndStore");
1228
1680
  }
1229
1681
  try {
1230
- const result = await chunkOVZCGOMG_cjs.applyQuery(this.store.client[chunkOZNDU7AU_cjs.additionalContext], this.#queryDef, this.#params);
1682
+ const result = await chunk6VOFZIIJ_cjs.applyQuery(this.store.client[chunkYVZM2JPW_cjs.additionalContext], this.#queryDef, this.#params);
1231
1683
  const executedAt = Date.now();
1232
1684
  this.store.batch({}, (batch) => {
1233
1685
  this.writeToStore({
@@ -1310,13 +1762,14 @@ var FunctionsHelper = class extends AbstractHelper {
1310
1762
  const {
1311
1763
  queryDef,
1312
1764
  params,
1765
+ objectSetTypesPromise,
1313
1766
  ...observeOpts
1314
1767
  } = options;
1315
1768
  const apiName = queryDef.apiName;
1316
1769
  const version = queryDef.isFixedVersion ? queryDef.version : void 0;
1317
1770
  const canonicalParams = this.paramsCanonicalizer.canonicalize(params);
1318
1771
  const functionCacheKey = this.cacheKeys.get("function", apiName, version, canonicalParams);
1319
- return this.store.queries.get(functionCacheKey, () => new FunctionQuery(this.store, this.store.subjects.get(functionCacheKey), queryDef, params, functionCacheKey, observeOpts));
1772
+ return this.store.queries.get(functionCacheKey, () => new FunctionQuery(this.store, this.store.subjects.get(functionCacheKey), queryDef, params, functionCacheKey, observeOpts, objectSetTypesPromise));
1320
1773
  }
1321
1774
  async invalidateFunction(apiName, params) {
1322
1775
  const functionApiName = typeof apiName === "string" ? apiName : apiName.apiName;
@@ -1760,7 +2213,7 @@ var API_NAME_IDX2 = 1;
1760
2213
  var WHERE_IDX2 = 2;
1761
2214
  var ORDER_BY_IDX = 3;
1762
2215
  var RDP_IDX2 = 4;
1763
- var INTERSECT_IDX = 5;
2216
+ var INTERSECT_IDX2 = 5;
1764
2217
  var PIVOT_IDX = 6;
1765
2218
  var RIDS_IDX = 7;
1766
2219
 
@@ -1872,6 +2325,7 @@ var BaseListQuery = class extends Query {
1872
2325
  * Promise tracking an in-progress page fetch
1873
2326
  * @protected
1874
2327
  */
2328
+ #subscriberPageSizes = /* @__PURE__ */ new Map();
1875
2329
  //
1876
2330
  // Shared Implementations
1877
2331
  //
@@ -2026,11 +2480,9 @@ var BaseListQuery = class extends Query {
2026
2480
  return this.pendingPageFetch;
2027
2481
  }
2028
2482
  if (this.pendingFetch) {
2029
- this.pendingPageFetch = (async () => {
2030
- await this.pendingFetch;
2031
- await this.fetchMore();
2032
- })().finally(() => {
2483
+ this.pendingPageFetch = this.pendingFetch.then(() => {
2033
2484
  this.pendingPageFetch = void 0;
2485
+ return this.fetchMore();
2034
2486
  });
2035
2487
  return this.pendingPageFetch;
2036
2488
  }
@@ -2045,6 +2497,56 @@ var BaseListQuery = class extends Query {
2045
2497
  });
2046
2498
  return this.pendingFetch;
2047
2499
  };
2500
+ /**
2501
+ * Register a subscriber's pageSize for fetch optimization.
2502
+ * The query will fetch with the max pageSize across all subscribers.
2503
+ */
2504
+ registerFetchPageSize(viewId, pageSize) {
2505
+ this.#subscriberPageSizes.set(viewId, pageSize);
2506
+ }
2507
+ /**
2508
+ * Unregister a subscriber's pageSize when they unsubscribe.
2509
+ * Allows the effective pageSize to decrease when high-pageSize subscribers leave.
2510
+ */
2511
+ unregisterFetchPageSize(viewId) {
2512
+ this.#subscriberPageSizes.delete(viewId);
2513
+ }
2514
+ /**
2515
+ * Get the effective fetch pageSize (max across all subscribers).
2516
+ * Falls back to options.pageSize or 100 if no subscribers have registered.
2517
+ */
2518
+ getEffectiveFetchPageSize() {
2519
+ if (this.#subscriberPageSizes.size > 0) {
2520
+ return Math.max(...this.#subscriberPageSizes.values());
2521
+ }
2522
+ return this.options.pageSize ?? 100;
2523
+ }
2524
+ /**
2525
+ * Get the current number of loaded items in the cache.
2526
+ */
2527
+ getLoadedCount() {
2528
+ const {
2529
+ retVal
2530
+ } = this.store.batch({}, (batch) => {
2531
+ return batch.read(this.cacheKey)?.value?.data.length ?? 0;
2532
+ });
2533
+ return retVal;
2534
+ }
2535
+ /**
2536
+ * Check if there are more pages available on the server.
2537
+ */
2538
+ hasMorePages() {
2539
+ return this.nextPageToken != null;
2540
+ }
2541
+ /**
2542
+ * Notify all subscribers of a change (used when view limits change
2543
+ * but no new data needs to be fetched).
2544
+ */
2545
+ notifySubscribers() {
2546
+ this.store.batch({}, (batch) => {
2547
+ this.registerCacheChanges(batch);
2548
+ });
2549
+ }
2048
2550
  /**
2049
2551
  * Minimum number of results to load initially
2050
2552
  * May be overridden by subclasses for specific collection types
@@ -2314,8 +2816,9 @@ var BaseListQuery = class extends Query {
2314
2816
  }).debug("Removing object", object);
2315
2817
  }
2316
2818
  this.store.batch({}, (batch) => {
2317
- const objectCacheKey = this.store.cacheKeys.get("object", object.$objectType ?? object.$apiName, object.$primaryKey);
2318
- batch.delete(objectCacheKey, "loaded");
2819
+ for (const objectCacheKey of this.store.objectCacheKeyRegistry.getVariants(object.$objectType ?? object.$apiName, object.$primaryKey)) {
2820
+ batch.delete(objectCacheKey, "loaded");
2821
+ }
2319
2822
  });
2320
2823
  }
2321
2824
  };
@@ -2323,6 +2826,8 @@ var BaseListQuery = class extends Query {
2323
2826
  // src/observable/internal/links/SpecificLinkQuery.ts
2324
2827
  var SpecificLinkQuery = class extends BaseListQuery {
2325
2828
  #sourceApiName;
2829
+ #sourceTypeKind;
2830
+ #sourceUnderlyingObjectType;
2326
2831
  #sourcePk;
2327
2832
  #linkName;
2328
2833
  #whereClause;
@@ -2334,39 +2839,68 @@ var SpecificLinkQuery = class extends BaseListQuery {
2334
2839
  batch.changes.modified.add(this.cacheKey);
2335
2840
  }
2336
2841
  constructor(store, subject, cacheKey, opts) {
2337
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkOZNDU7AU_cjs.additionalContext].logger?.child({}, {
2842
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkYVZM2JPW_cjs.additionalContext].logger?.child({}, {
2338
2843
  msgPrefix: `SpecificLinkQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
2339
2844
  }) : void 0);
2340
- [this.#sourceApiName, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
2845
+ [this.#sourceApiName, this.#sourceTypeKind, this.#sourceUnderlyingObjectType, this.#sourcePk, this.#linkName, this.#whereClause, this.#orderBy] = cacheKey.otherKeys;
2341
2846
  }
2342
- // _fetchAndStore is now implemented in BaseCollectionQuery
2343
2847
  /**
2344
2848
  * Implements fetchPageData from the BaseCollectionQuery template method pattern
2345
- * Fetches a page of linked objects
2346
2849
  */
2347
2850
  async fetchPageData(signal) {
2348
2851
  const client = this.store.client;
2349
- const sourceObjectDef = {
2350
- type: "object",
2351
- apiName: this.#sourceApiName
2352
- };
2353
- const sourceMetadata = await client[chunkOZNDU7AU_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
2852
+ const ontologyProvider = client[chunkYVZM2JPW_cjs.additionalContext].ontologyProvider;
2853
+ const isInterface = this.#sourceTypeKind === "interface";
2354
2854
  if (this.#orderBy && Object.keys(this.#orderBy).length > 0) {
2355
- const linkDef = sourceMetadata.links?.[this.#linkName];
2356
- if (!linkDef?.targetType) {
2357
- throw new Error(`Missing link definition or targetType for link '${this.#linkName}' on object type '${this.#sourceApiName}'`);
2855
+ let targetTypeApiName;
2856
+ if (isInterface) {
2857
+ const interfaceMetadata = await ontologyProvider.getInterfaceDefinition(this.#sourceApiName);
2858
+ const linkDef = interfaceMetadata.links?.[this.#linkName];
2859
+ if (!linkDef) {
2860
+ throw new Error(`Missing link definition for link '${this.#linkName}' on interface '${this.#sourceApiName}'`);
2861
+ }
2862
+ targetTypeApiName = linkDef.targetTypeApiName;
2863
+ } else {
2864
+ const objectMetadata = await ontologyProvider.getObjectDefinition(this.#sourceApiName);
2865
+ const linkDef = objectMetadata.links?.[this.#linkName];
2866
+ if (!linkDef?.targetType) {
2867
+ throw new Error(`Missing link definition or targetType for link '${this.#linkName}' on object type '${this.#sourceApiName}'`);
2868
+ }
2869
+ targetTypeApiName = linkDef.targetType;
2358
2870
  }
2359
- this.sortingStrategy = new OrderBySortingStrategy(linkDef.targetType, this.#orderBy);
2871
+ this.sortingStrategy = new OrderBySortingStrategy(targetTypeApiName, this.#orderBy);
2872
+ }
2873
+ let linkQuery;
2874
+ if (isInterface) {
2875
+ const objectMetadata = await ontologyProvider.getObjectDefinition(this.#sourceUnderlyingObjectType);
2876
+ const interfaceSet = client({
2877
+ type: "interface",
2878
+ apiName: this.#sourceApiName
2879
+ });
2880
+ const objectFilteredByPk = client({
2881
+ type: "object",
2882
+ apiName: this.#sourceUnderlyingObjectType
2883
+ }).where({
2884
+ [objectMetadata.primaryKeyApiName]: this.#sourcePk
2885
+ });
2886
+ const filteredSource = interfaceSet.intersect(objectFilteredByPk);
2887
+ linkQuery = filteredSource.pivotTo(this.#linkName);
2888
+ } else {
2889
+ const objectMetadata = await ontologyProvider.getObjectDefinition(this.#sourceApiName);
2890
+ const sourceSet = client({
2891
+ type: "object",
2892
+ apiName: this.#sourceApiName
2893
+ });
2894
+ const sourceQuery = sourceSet.where({
2895
+ [objectMetadata.primaryKeyApiName]: this.#sourcePk
2896
+ });
2897
+ linkQuery = sourceQuery.pivotTo(this.#linkName);
2360
2898
  }
2361
- const sourceQuery = client(sourceObjectDef).where({
2362
- [sourceMetadata.primaryKeyApiName]: this.#sourcePk
2363
- });
2364
- const linkQuery = sourceQuery.pivotTo(this.#linkName);
2365
2899
  if (signal?.aborted) {
2366
2900
  throw new Error("Aborted");
2367
2901
  }
2368
2902
  const queryParams = {
2369
- $pageSize: this.options.pageSize || 100,
2903
+ $pageSize: this.getEffectiveFetchPageSize(),
2370
2904
  $nextPageToken: this.nextPageToken,
2371
2905
  $includeRid: true
2372
2906
  };
@@ -2417,19 +2951,53 @@ var SpecificLinkQuery = class extends BaseListQuery {
2417
2951
  return Promise.resolve();
2418
2952
  };
2419
2953
  invalidateObjectType = (objectType, changes) => {
2420
- if (this.#sourceApiName === objectType) {
2954
+ if (this.#sourceTypeKind === "object" && this.#sourceApiName === objectType) {
2421
2955
  changes?.modified.add(this.cacheKey);
2422
2956
  return this.revalidate(true);
2423
- } else {
2424
- return (async () => {
2425
- const sourceMetadata = await this.store.client[chunkOZNDU7AU_cjs.additionalContext].ontologyProvider.getObjectDefinition(this.#sourceApiName);
2426
- const linkDef = sourceMetadata.links?.[this.#linkName];
2427
- if (!linkDef || linkDef.targetType !== objectType) return;
2428
- const promise = this.revalidate(true);
2957
+ }
2958
+ return (async () => {
2959
+ try {
2960
+ const ontologyProvider = this.store.client[chunkYVZM2JPW_cjs.additionalContext].ontologyProvider;
2961
+ if (this.#sourceTypeKind === "interface") {
2962
+ const objectMetadata = await ontologyProvider.getObjectDefinition(objectType);
2963
+ if (this.#sourceApiName in objectMetadata.interfaceMap) {
2964
+ changes?.modified.add(this.cacheKey);
2965
+ return void await this.revalidate(true);
2966
+ }
2967
+ }
2968
+ let targetTypeApiName;
2969
+ let targetTypeKind;
2970
+ if (this.#sourceTypeKind === "interface") {
2971
+ const interfaceMetadata = await ontologyProvider.getInterfaceDefinition(this.#sourceApiName);
2972
+ const linkDef = interfaceMetadata.links?.[this.#linkName];
2973
+ targetTypeApiName = linkDef?.targetTypeApiName;
2974
+ targetTypeKind = linkDef?.targetType;
2975
+ } else {
2976
+ const objectMetadata = await ontologyProvider.getObjectDefinition(this.#sourceApiName);
2977
+ const linkDef = objectMetadata.links?.[this.#linkName];
2978
+ targetTypeApiName = linkDef?.targetType;
2979
+ targetTypeKind = "object";
2980
+ }
2981
+ if (!targetTypeApiName) return;
2982
+ if (targetTypeApiName === objectType) {
2983
+ changes?.modified.add(this.cacheKey);
2984
+ return void await this.revalidate(true);
2985
+ }
2986
+ if (targetTypeKind === "interface") {
2987
+ const objectMetadata = await ontologyProvider.getObjectDefinition(objectType);
2988
+ if (targetTypeApiName in objectMetadata.interfaceMap) {
2989
+ changes?.modified.add(this.cacheKey);
2990
+ return void await this.revalidate(true);
2991
+ }
2992
+ }
2993
+ } catch (e) {
2994
+ if (process.env.NODE_ENV !== "production") {
2995
+ this.logger?.error("Failed to resolve metadata during invalidation", e);
2996
+ }
2429
2997
  changes?.modified.add(this.cacheKey);
2430
- return promise;
2431
- })();
2432
- }
2998
+ return void await this.revalidate(true);
2999
+ }
3000
+ })();
2433
3001
  };
2434
3002
  };
2435
3003
 
@@ -2442,11 +3010,12 @@ var LinksHelper = class extends AbstractHelper {
2442
3010
  }
2443
3011
  getQuery(options) {
2444
3012
  const {
2445
- apiName
3013
+ apiName,
3014
+ type: sourceTypeKind
2446
3015
  } = options.srcType;
2447
3016
  const canonWhere = this.whereCanonicalizer.canonicalize(options.where ?? {});
2448
3017
  const canonOrderBy = this.orderByCanonicalizer.canonicalize(options.orderBy ?? {});
2449
- const linkCacheKey = this.cacheKeys.get("specificLink", apiName, options.pk, options.linkName, canonWhere, canonOrderBy);
3018
+ const linkCacheKey = this.cacheKeys.get("specificLink", apiName, sourceTypeKind, options.sourceUnderlyingObjectType, options.pk, options.linkName, canonWhere, canonOrderBy);
2450
3019
  return this.store.queries.get(linkCacheKey, () => {
2451
3020
  return new SpecificLinkQuery(this.store, this.store.subjects.get(linkCacheKey), linkCacheKey, options);
2452
3021
  });
@@ -2462,162 +3031,6 @@ chunkLDTMSHUZ_cjs.init_cjs_shims();
2462
3031
  // src/observable/internal/list/ListQuery.ts
2463
3032
  chunkLDTMSHUZ_cjs.init_cjs_shims();
2464
3033
 
2465
- // src/observable/internal/getObjectTypesThatInvalidate.ts
2466
- chunkLDTMSHUZ_cjs.init_cjs_shims();
2467
- async function getObjectTypesThatInvalidate(mc, objectSet) {
2468
- const counts = {};
2469
- const resultType = await calcObjectSet(objectSet, {
2470
- counts,
2471
- methodInput: void 0,
2472
- ontologyProvider: mc.ontologyProvider
2473
- });
2474
- const tweaked = {
2475
- ...counts,
2476
- [resultType.apiName]: counts[resultType.apiName] - 1
2477
- };
2478
- return {
2479
- resultType,
2480
- counts,
2481
- invalidationSet: new Set(Object.entries(tweaked).filter(([, v]) => v > 0).map(([k]) => k))
2482
- };
2483
- }
2484
- async function calcObjectSet(os, ctx) {
2485
- const op = ctx.ontologyProvider;
2486
- async function bumpObject(apiName) {
2487
- const objectType = await op.getObjectDefinition(apiName);
2488
- ctx.counts[apiName] = (ctx.counts[apiName] ?? 0) + 1;
2489
- return objectType;
2490
- }
2491
- async function bumpInterface(apiName) {
2492
- const interfaceDef = await op.getInterfaceDefinition(apiName);
2493
- for (const s of interfaceDef.implementedBy ?? []) {
2494
- ctx.counts[s] = (ctx.counts[s] ?? 0) + 1;
2495
- }
2496
- return interfaceDef;
2497
- }
2498
- switch (os.type) {
2499
- case "base":
2500
- return await bumpObject(os.objectType);
2501
- case "interfaceBase":
2502
- return await bumpInterface(os.interfaceType);
2503
- case "interfaceLinkSearchAround": {
2504
- const srcDef = await calcObjectSet(os.objectSet, ctx);
2505
- !(srcDef.type === "interface") ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false) : invariant5__default.default(false) : void 0;
2506
- for (const [k, v] of Object.entries(srcDef.links)) {
2507
- if (k === os.interfaceLink) {
2508
- if (v.targetType === "object") {
2509
- return await bumpObject(v.targetType);
2510
- }
2511
- return await bumpInterface(v.targetType);
2512
- }
2513
- }
2514
- throw new Error(`Could not find link ${os.interfaceLink} in object set ${JSON.stringify(os.objectSet)}`);
2515
- }
2516
- case "searchAround": {
2517
- const contextDef = await calcObjectSet(os.objectSet, ctx);
2518
- !(contextDef.type === "object") ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false) : invariant5__default.default(false) : void 0;
2519
- for (const [k, v] of Object.entries(contextDef.links)) {
2520
- if (k === os.link) {
2521
- return await bumpObject(v.targetType);
2522
- }
2523
- }
2524
- throw new Error(`Could not find link ${os.link} in object set ${JSON.stringify(os.objectSet)}`);
2525
- }
2526
- case "filter":
2527
- return calcObjectSet(os.objectSet, ctx);
2528
- case "union":
2529
- case "subtract":
2530
- case "intersect":
2531
- const returnTypes = await Promise.all(os.objectSets.map(async (os2) => {
2532
- const counts = {};
2533
- const r = await calcObjectSet(os2, {
2534
- ...ctx,
2535
- counts
2536
- });
2537
- return {
2538
- r,
2539
- counts
2540
- };
2541
- }));
2542
- for (const {
2543
- counts
2544
- } of returnTypes) {
2545
- for (const [k, v] of Object.entries(counts)) {
2546
- ctx.counts[k] = Math.max(ctx.counts[k] ?? 0, v);
2547
- }
2548
- }
2549
- if (returnTypes.length === 0) {
2550
- throw new Error(`Could not find any context types for set operation`);
2551
- }
2552
- const allMatch = returnTypes.every(({
2553
- r
2554
- }) => r.apiName === returnTypes[0].r.apiName);
2555
- if (!allMatch) {
2556
- throw new Error(`Incompatible context types found for set operation`);
2557
- }
2558
- return returnTypes[0].r;
2559
- case "withProperties":
2560
- for (const [, v] of Object.entries(os.derivedProperties)) {
2561
- await calcRdp(v, {
2562
- ...ctx,
2563
- methodInput: os.objectSet
2564
- });
2565
- }
2566
- return calcObjectSet(os.objectSet, {
2567
- ...ctx,
2568
- methodInput: os.objectSet
2569
- });
2570
- // used by rdps
2571
- case "methodInput":
2572
- !ctx.methodInput ? process.env.NODE_ENV !== "production" ? invariant5__default.default(false, "methodInput must be provided") : invariant5__default.default(false) : void 0;
2573
- return await calcObjectSet(ctx.methodInput, {
2574
- ...ctx,
2575
- counts: {}
2576
- });
2577
- case "asType":
2578
- // we don't currently support this anywhere.
2579
- case "asBaseObjectTypes":
2580
- // We don't currently support this because it could return multiple object types conceptually
2581
- // internally, we actually use it this way but we shouldn't be finding that object sets.
2582
- case "reference":
2583
- // reference is particularly problematic because we cannot answer the question about
2584
- // which types without loading the object set definition (and it can change).
2585
- case "static":
2586
- throw new Error(`Unsupported ObjectSet type ${os.type}`);
2587
- case "nearestNeighbors":
2588
- return calcObjectSet(os.objectSet, ctx);
2589
- default:
2590
- throw new Error(`Unhandled ObjectSet type ${os.type}`);
2591
- }
2592
- }
2593
- async function calcRdp(dpd, ctx) {
2594
- switch (dpd.type) {
2595
- // Operates on object sets
2596
- case "selection":
2597
- return await calcObjectSet(dpd.objectSet, ctx);
2598
- // Operates on single property
2599
- case "negate":
2600
- case "extract":
2601
- case "absoluteValue":
2602
- return await calcRdp(dpd.property, ctx);
2603
- // Operates on many (unordered) properties
2604
- case "least":
2605
- case "greatest":
2606
- case "add":
2607
- case "multiply":
2608
- return await Promise.all(dpd.properties.map((innerDpd) => calcRdp(innerDpd, ctx)));
2609
- // Operates on 2 ordered properties
2610
- case "subtract":
2611
- case "divide":
2612
- return await Promise.all([calcRdp(dpd.left, ctx), calcRdp(dpd.right, ctx)]);
2613
- // Operates on a single property name
2614
- case "property":
2615
- return;
2616
- default:
2617
- throw new Error(`Unhandled DerivedPropertyDefinition type ${dpd.type}`);
2618
- }
2619
- }
2620
-
2621
3034
  // src/observable/internal/objectMatchesWhereClause.ts
2622
3035
  chunkLDTMSHUZ_cjs.init_cjs_shims();
2623
3036
 
@@ -2723,6 +3136,7 @@ var ListQuery = class extends BaseListQuery {
2723
3136
  #intersectWith;
2724
3137
  #pivotInfo;
2725
3138
  #objectSet;
3139
+ #pivotIntersectApplied = false;
2726
3140
  /**
2727
3141
  * Register changes to the cache specific to ListQuery
2728
3142
  */
@@ -2730,13 +3144,13 @@ var ListQuery = class extends BaseListQuery {
2730
3144
  batch.changes.registerList(this.cacheKey);
2731
3145
  }
2732
3146
  constructor(store, subject, apiName, cacheKey, opts) {
2733
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkOZNDU7AU_cjs.additionalContext].logger?.child({}, {
3147
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkYVZM2JPW_cjs.additionalContext].logger?.child({}, {
2734
3148
  msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
2735
3149
  }) : void 0);
2736
3150
  this.apiName = apiName;
2737
3151
  this.#whereClause = cacheKey.otherKeys[WHERE_IDX2];
2738
3152
  this.#orderBy = cacheKey.otherKeys[ORDER_BY_IDX];
2739
- this.#intersectWith = cacheKey.otherKeys[INTERSECT_IDX];
3153
+ this.#intersectWith = cacheKey.otherKeys[INTERSECT_IDX2];
2740
3154
  this.#pivotInfo = cacheKey.otherKeys[PIVOT_IDX];
2741
3155
  this.#objectSet = this.createObjectSet(store);
2742
3156
  if (!this.#pivotInfo) {
@@ -2759,24 +3173,45 @@ var ListQuery = class extends BaseListQuery {
2759
3173
  get canonicalPivotInfo() {
2760
3174
  return this.#pivotInfo;
2761
3175
  }
2762
- /**
2763
- * Create the ObjectSet for this query.
2764
- */
2765
3176
  /**
2766
3177
  * Implements fetchPageData from BaseCollectionQuery template method
2767
3178
  * Fetches a page of data
2768
3179
  */
2769
3180
  async fetchPageData(signal) {
2770
- if (Object.keys(this.#orderBy).length > 0 && !(this.sortingStrategy instanceof OrderBySortingStrategy)) {
2771
- const wireObjectSet = chunkOZNDU7AU_cjs.getWireObjectSet(this.#objectSet);
3181
+ const needsResultType = Object.keys(this.#orderBy).length > 0 && !(this.sortingStrategy instanceof OrderBySortingStrategy) || this.#pivotInfo != null && this.#intersectWith != null && this.#intersectWith.length > 0 && !this.#pivotIntersectApplied;
3182
+ if (needsResultType) {
3183
+ const wireObjectSet = chunkYVZM2JPW_cjs.getWireObjectSet(this.#objectSet);
2772
3184
  const {
2773
3185
  resultType
2774
- } = await getObjectTypesThatInvalidate(this.store.client[chunkOZNDU7AU_cjs.additionalContext], wireObjectSet);
2775
- this.sortingStrategy = new OrderBySortingStrategy(resultType.apiName, this.#orderBy);
3186
+ } = await getObjectTypesThatInvalidate(this.store.client[chunkYVZM2JPW_cjs.additionalContext], wireObjectSet);
3187
+ if (Object.keys(this.#orderBy).length > 0 && !(this.sortingStrategy instanceof OrderBySortingStrategy)) {
3188
+ this.sortingStrategy = new OrderBySortingStrategy(resultType.apiName, this.#orderBy);
3189
+ }
3190
+ if (this.#pivotInfo != null && this.#intersectWith != null && this.#intersectWith.length > 0 && !this.#pivotIntersectApplied) {
3191
+ const rdpConfig = this.cacheKey.otherKeys[RDP_IDX2];
3192
+ const intersectSets = this.#intersectWith.map((whereClause) => {
3193
+ if (resultType.type === "object") {
3194
+ let objectSet = this.store.client({
3195
+ type: "object",
3196
+ apiName: resultType.apiName
3197
+ });
3198
+ if (rdpConfig != null) {
3199
+ objectSet = objectSet.withProperties(rdpConfig);
3200
+ }
3201
+ return objectSet.where(whereClause);
3202
+ }
3203
+ return this.store.client({
3204
+ type: "interface",
3205
+ apiName: resultType.apiName
3206
+ }).where(whereClause);
3207
+ });
3208
+ this.#objectSet = this.#objectSet.intersect(...intersectSets);
3209
+ this.#pivotIntersectApplied = true;
3210
+ }
2776
3211
  }
2777
3212
  const resp = await this.#objectSet.fetchPage({
2778
3213
  $nextPageToken: this.nextPageToken,
2779
- $pageSize: this.options.pageSize,
3214
+ $pageSize: this.getEffectiveFetchPageSize(),
2780
3215
  $includeRid: true,
2781
3216
  // For now this keeps the shared test code from falling apart
2782
3217
  // but shouldn't be needed ideally
@@ -2999,6 +3434,21 @@ var ListQuery = class extends BaseListQuery {
2999
3434
  var InterfaceListQuery = class extends ListQuery {
3000
3435
  createObjectSet(store) {
3001
3436
  const rdpConfig = this.cacheKey.otherKeys[RDP_IDX2];
3437
+ const pivotInfo = this.cacheKey.otherKeys[PIVOT_IDX];
3438
+ if (pivotInfo != null) {
3439
+ const sourceSet = pivotInfo.sourceTypeKind === "interface" ? store.client({
3440
+ type: "interface",
3441
+ apiName: pivotInfo.sourceType
3442
+ }) : store.client({
3443
+ type: "object",
3444
+ apiName: pivotInfo.sourceType
3445
+ });
3446
+ let objectSet = sourceSet.where(this.canonicalWhere).pivotTo(pivotInfo.linkName);
3447
+ if (rdpConfig != null) {
3448
+ objectSet = objectSet.withProperties(rdpConfig);
3449
+ }
3450
+ return objectSet;
3451
+ }
3002
3452
  const type = "interface";
3003
3453
  const objectTypeDef = {
3004
3454
  type,
@@ -3037,7 +3487,7 @@ var InterfaceListQuery = class extends ListQuery {
3037
3487
  }
3038
3488
  extractRelevantObjects(changes) {
3039
3489
  const matchesApiName = ([, object]) => {
3040
- return this.apiName in object[chunkOVZCGOMG_cjs.ObjectDefRef].interfaceMap;
3490
+ return this.apiName in object[chunk6VOFZIIJ_cjs.ObjectDefRef].interfaceMap;
3041
3491
  };
3042
3492
  const added = Array.from(changes.addedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
3043
3493
  const modified = Array.from(changes.modifiedObjects).filter(matchesApiName).map(([, object]) => object.$as(this.apiName));
@@ -3087,37 +3537,37 @@ chunkLDTMSHUZ_cjs.init_cjs_shims();
3087
3537
  var ObjectListQuery = class extends ListQuery {
3088
3538
  createObjectSet(store) {
3089
3539
  const rdpConfig = this.cacheKey.otherKeys[RDP_IDX2];
3090
- const intersectWith = this.cacheKey.otherKeys[INTERSECT_IDX];
3540
+ const intersectWith = this.cacheKey.otherKeys[INTERSECT_IDX2];
3091
3541
  const pivotInfo = this.cacheKey.otherKeys[PIVOT_IDX];
3092
3542
  const rids = this.cacheKey.otherKeys[RIDS_IDX];
3093
- const clientCtx = store.client[chunkOZNDU7AU_cjs.additionalContext];
3543
+ const clientCtx = store.client[chunkYVZM2JPW_cjs.additionalContext];
3094
3544
  const typeDefinition = {
3095
3545
  type: "object",
3096
3546
  apiName: this.apiName
3097
3547
  };
3098
3548
  if (pivotInfo != null) {
3099
- let sourceSet = store.client({
3100
- type: "object",
3101
- apiName: pivotInfo.sourceType
3102
- });
3103
- sourceSet = sourceSet.where(this.canonicalWhere);
3104
- let objectSet2 = sourceSet.pivotTo(pivotInfo.linkName);
3549
+ let sourceSet;
3550
+ if (rids != null) {
3551
+ sourceSet = clientCtx.objectSetFactory({
3552
+ type: "object",
3553
+ apiName: pivotInfo.sourceType
3554
+ }, clientCtx, {
3555
+ type: "static",
3556
+ objects: [...rids]
3557
+ });
3558
+ } else {
3559
+ sourceSet = pivotInfo.sourceTypeKind === "interface" ? store.client({
3560
+ type: "interface",
3561
+ apiName: pivotInfo.sourceType
3562
+ }) : store.client({
3563
+ type: "object",
3564
+ apiName: pivotInfo.sourceType
3565
+ });
3566
+ }
3567
+ let objectSet2 = sourceSet.where(this.canonicalWhere).pivotTo(pivotInfo.linkName);
3105
3568
  if (rdpConfig != null) {
3106
3569
  objectSet2 = objectSet2.withProperties(rdpConfig);
3107
3570
  }
3108
- if (intersectWith != null && intersectWith.length > 0) {
3109
- const intersectSets = intersectWith.map((whereClause) => {
3110
- let intersectSet = store.client({
3111
- type: "object",
3112
- apiName: pivotInfo.targetType
3113
- });
3114
- if (rdpConfig != null) {
3115
- intersectSet = intersectSet.withProperties(rdpConfig);
3116
- }
3117
- return intersectSet.where(whereClause);
3118
- });
3119
- objectSet2 = objectSet2.intersect(...intersectSets);
3120
- }
3121
3571
  return objectSet2;
3122
3572
  }
3123
3573
  let objectSet;
@@ -3211,7 +3661,7 @@ var ListsHelper = class extends AbstractHelper {
3211
3661
  const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
3212
3662
  const canonRdp = withProperties ? this.rdpCanonicalizer.canonicalize(withProperties) : void 0;
3213
3663
  const canonIntersect = intersectWith && intersectWith.length > 0 ? this.intersectCanonicalizer.canonicalize(intersectWith) : void 0;
3214
- const canonPivot = pivotTo ? this.pivotCanonicalizer.canonicalize(apiName, pivotTo) : void 0;
3664
+ const canonPivot = pivotTo ? this.pivotCanonicalizer.canonicalize(apiName, type, pivotTo) : void 0;
3215
3665
  const canonRids = rids != null ? this.ridListCanonicalizer.canonicalize(rids) : void 0;
3216
3666
  const listCacheKey = this.cacheKeys.get("list", type, apiName, canonWhere, canonOrderBy, canonRdp, canonIntersect, canonPivot, canonRids);
3217
3667
  return this.store.queries.get(listCacheKey, () => {
@@ -3241,8 +3691,8 @@ function stripRdpFields(value, rdpFields) {
3241
3691
  if (rdpFields.size === 0) {
3242
3692
  return value;
3243
3693
  }
3244
- const underlying = value[chunkOVZCGOMG_cjs.UnderlyingOsdkObject];
3245
- const objectDef = value[chunkOVZCGOMG_cjs.ObjectDefRef];
3694
+ const underlying = value[chunk6VOFZIIJ_cjs.UnderlyingOsdkObject];
3695
+ const objectDef = value[chunk6VOFZIIJ_cjs.ObjectDefRef];
3246
3696
  const newProps = {
3247
3697
  $apiName: underlying.$apiName,
3248
3698
  $objectType: underlying.$objectType,
@@ -3255,7 +3705,7 @@ function stripRdpFields(value, rdpFields) {
3255
3705
  newProps[key] = underlying[key];
3256
3706
  }
3257
3707
  }
3258
- return chunkOVZCGOMG_cjs.createOsdkObject(value[chunkOVZCGOMG_cjs.ClientRef], objectDef, newProps);
3708
+ return chunk6VOFZIIJ_cjs.createOsdkObject(value[chunk6VOFZIIJ_cjs.ClientRef], objectDef, newProps);
3259
3709
  }
3260
3710
  function isSuperset(superset, subset) {
3261
3711
  for (const field of subset) {
@@ -3266,8 +3716,8 @@ function isSuperset(superset, subset) {
3266
3716
  return true;
3267
3717
  }
3268
3718
  function filterToRdpFields(value, rdpFieldsToKeep, sourceRdpFields) {
3269
- const underlying = value[chunkOVZCGOMG_cjs.UnderlyingOsdkObject];
3270
- const objectDef = value[chunkOVZCGOMG_cjs.ObjectDefRef];
3719
+ const underlying = value[chunk6VOFZIIJ_cjs.UnderlyingOsdkObject];
3720
+ const objectDef = value[chunk6VOFZIIJ_cjs.ObjectDefRef];
3271
3721
  const newProps = {
3272
3722
  $apiName: underlying.$apiName,
3273
3723
  $objectType: underlying.$objectType,
@@ -3283,7 +3733,7 @@ function filterToRdpFields(value, rdpFieldsToKeep, sourceRdpFields) {
3283
3733
  }
3284
3734
  }
3285
3735
  }
3286
- return chunkOVZCGOMG_cjs.createOsdkObject(value[chunkOVZCGOMG_cjs.ClientRef], objectDef, newProps);
3736
+ return chunk6VOFZIIJ_cjs.createOsdkObject(value[chunk6VOFZIIJ_cjs.ClientRef], objectDef, newProps);
3287
3737
  }
3288
3738
  function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, targetCurrentValue) {
3289
3739
  if (targetRdpFields.size === 0) {
@@ -3295,8 +3745,8 @@ function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, target
3295
3745
  }
3296
3746
  return filterToRdpFields(sourceValue, targetRdpFields, sourceRdpFields);
3297
3747
  }
3298
- const sourceUnderlying = sourceValue[chunkOVZCGOMG_cjs.UnderlyingOsdkObject];
3299
- const objectDef = sourceValue[chunkOVZCGOMG_cjs.ObjectDefRef];
3748
+ const sourceUnderlying = sourceValue[chunk6VOFZIIJ_cjs.UnderlyingOsdkObject];
3749
+ const objectDef = sourceValue[chunk6VOFZIIJ_cjs.ObjectDefRef];
3300
3750
  const newProps = {
3301
3751
  $apiName: sourceUnderlying.$apiName,
3302
3752
  $objectType: sourceUnderlying.$objectType,
@@ -3310,14 +3760,16 @@ function mergeObjectFields(sourceValue, sourceRdpFields, targetRdpFields, target
3310
3760
  }
3311
3761
  }
3312
3762
  if (targetCurrentValue) {
3313
- const targetUnderlying = targetCurrentValue[chunkOVZCGOMG_cjs.UnderlyingOsdkObject];
3763
+ const targetUnderlying = targetCurrentValue[chunk6VOFZIIJ_cjs.UnderlyingOsdkObject];
3314
3764
  for (const field of targetRdpFields) {
3315
- if (!sourceRdpFields.has(field) && field in targetUnderlying) {
3316
- newProps[field] = targetUnderlying[field];
3765
+ if (field in targetUnderlying) {
3766
+ if (!sourceRdpFields.has(field) || newProps[field] === void 0) {
3767
+ newProps[field] = targetUnderlying[field];
3768
+ }
3317
3769
  }
3318
3770
  }
3319
3771
  }
3320
- return chunkOVZCGOMG_cjs.createOsdkObject(sourceValue[chunkOVZCGOMG_cjs.ClientRef], objectDef, newProps);
3772
+ return chunk6VOFZIIJ_cjs.createOsdkObject(sourceValue[chunk6VOFZIIJ_cjs.ClientRef], objectDef, newProps);
3321
3773
  }
3322
3774
 
3323
3775
  // src/observable/internal/object/ObjectCacheKeyRegistry.ts
@@ -3452,40 +3904,54 @@ var BulkObjectLoader = class {
3452
3904
  #maxEntries;
3453
3905
  constructor(client, maxWait = 25, maxEntries = 100) {
3454
3906
  this.#client = client;
3455
- this.#logger = client[chunkOZNDU7AU_cjs.additionalContext].logger;
3907
+ this.#logger = client[chunkYVZM2JPW_cjs.additionalContext].logger;
3456
3908
  this.#maxWait = maxWait;
3457
3909
  this.#maxEntries = maxEntries;
3458
3910
  }
3459
- async fetch(apiName, primaryKey) {
3911
+ async fetch(apiName, primaryKey, defType = "object") {
3460
3912
  const deferred = pDefer();
3461
3913
  const entry = this.#m.get(apiName);
3462
3914
  entry.data.push({
3463
3915
  primaryKey,
3464
3916
  deferred
3465
3917
  });
3918
+ if (entry.defType === void 0) {
3919
+ entry.defType = defType;
3920
+ } else if (entry.defType !== defType) {
3921
+ deferred.reject(new shared_net_errors.PalantirApiError(`Conflicting defType for ${apiName}: existing=${entry.defType}, new=${defType}`));
3922
+ return deferred.promise;
3923
+ }
3466
3924
  if (!entry.timer) {
3467
3925
  entry.timer = setTimeout(() => {
3468
- this.#loadObjects(apiName, entry.data);
3926
+ this.#loadObjects(apiName, entry.data, entry.defType ?? "object");
3469
3927
  }, this.#maxWait);
3470
3928
  }
3471
3929
  if (entry.data.length >= this.#maxEntries) {
3472
3930
  clearTimeout(entry.timer);
3473
- this.#loadObjects(apiName, entry.data);
3931
+ this.#loadObjects(apiName, entry.data, entry.defType ?? "object");
3474
3932
  }
3475
3933
  return await deferred.promise;
3476
3934
  }
3477
- #loadObjects(apiName, arr) {
3935
+ #loadObjects(apiName, arr, defType) {
3478
3936
  this.#m.delete(apiName);
3479
- this.#reallyLoadObjects(apiName, arr).catch((e) => {
3937
+ const loadFn = defType === "interface" ? this.#loadInterfaceObjects(apiName, arr) : this.#loadObjectTypeObjects(apiName, arr);
3938
+ loadFn.catch((e) => {
3480
3939
  this.#logger?.error("Unhandled exception", e);
3940
+ for (const {
3941
+ primaryKey,
3942
+ deferred
3943
+ } of arr) {
3944
+ const errorMessage = e instanceof Error ? e.message : String(e);
3945
+ deferred.reject(new shared_net_errors.PalantirApiError(`Failed to load ${apiName} with pk ${primaryKey}: ${errorMessage}`));
3946
+ }
3481
3947
  });
3482
3948
  }
3483
- async #reallyLoadObjects(apiName, arr) {
3484
- const miniDef = {
3949
+ async #loadObjectTypeObjects(apiName, arr) {
3950
+ const objectDef = {
3485
3951
  type: "object",
3486
3952
  apiName
3487
3953
  };
3488
- const objMetadata = await this.#client.fetchMetadata(miniDef);
3954
+ const objMetadata = await this.#client.fetchMetadata(objectDef);
3489
3955
  const pks = arr.map((x) => x.primaryKey);
3490
3956
  const whereClause = pks.length === 1 ? {
3491
3957
  [objMetadata.primaryKeyApiName]: {
@@ -3498,7 +3964,7 @@ var BulkObjectLoader = class {
3498
3964
  };
3499
3965
  const {
3500
3966
  data
3501
- } = await this.#client(miniDef).where(whereClause).fetchPage({
3967
+ } = await this.#client(objectDef).where(whereClause).fetchPage({
3502
3968
  $pageSize: pks.length,
3503
3969
  $includeRid: true
3504
3970
  });
@@ -3514,18 +3980,70 @@ var BulkObjectLoader = class {
3514
3980
  }
3515
3981
  }
3516
3982
  }
3983
+ async #loadInterfaceObjects(apiName, arr) {
3984
+ const pks = arr.map((x) => x.primaryKey);
3985
+ const interfaceDef = {
3986
+ type: "interface",
3987
+ apiName
3988
+ };
3989
+ const interfaceMetadata = await this.#client.fetchMetadata(interfaceDef);
3990
+ const implementingTypes = interfaceMetadata.implementedBy ?? [];
3991
+ const foundObjects = /* @__PURE__ */ new Map();
3992
+ for (const objectTypeName of implementingTypes) {
3993
+ const objectDef = {
3994
+ type: "object",
3995
+ apiName: objectTypeName
3996
+ };
3997
+ const objMetadata = await this.#client.fetchMetadata(objectDef);
3998
+ const remainingPks = pks.filter((pk) => !foundObjects.has(pk));
3999
+ if (remainingPks.length === 0) {
4000
+ break;
4001
+ }
4002
+ const whereClause = remainingPks.length === 1 ? {
4003
+ [objMetadata.primaryKeyApiName]: {
4004
+ $eq: remainingPks[0]
4005
+ }
4006
+ } : {
4007
+ [objMetadata.primaryKeyApiName]: {
4008
+ $in: remainingPks
4009
+ }
4010
+ };
4011
+ const {
4012
+ data
4013
+ } = await this.#client(objectDef).where(whereClause).fetchPage({
4014
+ $pageSize: remainingPks.length
4015
+ });
4016
+ for (const obj of data) {
4017
+ foundObjects.set(obj.$primaryKey, obj);
4018
+ }
4019
+ }
4020
+ for (const {
4021
+ primaryKey,
4022
+ deferred
4023
+ } of arr) {
4024
+ const object = foundObjects.get(primaryKey);
4025
+ if (object) {
4026
+ deferred.resolve(object);
4027
+ } else {
4028
+ deferred.reject(new shared_net_errors.PalantirApiError(`Interface ${apiName} object not found: ${primaryKey}`));
4029
+ }
4030
+ }
4031
+ }
3517
4032
  };
3518
4033
 
3519
4034
  // src/observable/internal/object/ObjectQuery.ts
3520
4035
  var ObjectQuery = class extends Query {
3521
4036
  #apiName;
3522
4037
  #pk;
3523
- constructor(store, subject, type, pk, cacheKey, opts) {
3524
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkOZNDU7AU_cjs.additionalContext].logger?.child({}, {
4038
+ #defType;
4039
+ #implementingTypes;
4040
+ constructor(store, subject, type, pk, cacheKey, opts, defType = "object") {
4041
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkYVZM2JPW_cjs.additionalContext].logger?.child({}, {
3525
4042
  msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
3526
4043
  }) : void 0);
3527
4044
  this.#apiName = type;
3528
4045
  this.#pk = pk;
4046
+ this.#defType = defType;
3529
4047
  }
3530
4048
  _createConnectable(subject) {
3531
4049
  return rxjs.connectable(subject.pipe(rxjs.map((x) => {
@@ -3554,7 +4072,7 @@ var ObjectQuery = class extends Query {
3554
4072
  let obj;
3555
4073
  if (rdpConfig) {
3556
4074
  const miniDef = {
3557
- type: "object",
4075
+ type: this.#defType,
3558
4076
  apiName: this.#apiName
3559
4077
  };
3560
4078
  const fetched = await this.store.client(miniDef).withProperties(rdpConfig).fetchOne(this.#pk, {
@@ -3562,7 +4080,7 @@ var ObjectQuery = class extends Query {
3562
4080
  });
3563
4081
  obj = fetched;
3564
4082
  } else {
3565
- obj = await getBulkObjectLoader(this.store.client).fetch(this.#apiName, this.#pk);
4083
+ obj = await getBulkObjectLoader(this.store.client).fetch(this.#apiName, this.#pk, this.#defType);
3566
4084
  }
3567
4085
  this.store.batch({}, (batch) => {
3568
4086
  this.writeToStore(obj, "loaded", batch);
@@ -3581,12 +4099,26 @@ var ObjectQuery = class extends Query {
3581
4099
  this.store.objects.propagateWrite(this.cacheKey, tombstone, status, batch);
3582
4100
  return batch.read(this.cacheKey);
3583
4101
  }
3584
- invalidateObjectType = (objectType, changes) => {
3585
- if (this.#apiName === objectType) {
4102
+ invalidateObjectType = async (objectType, changes) => {
4103
+ if (this.#defType === "object") {
4104
+ if (this.#apiName === objectType) {
4105
+ changes?.modified.add(this.cacheKey);
4106
+ return this.revalidate(true);
4107
+ }
4108
+ return;
4109
+ }
4110
+ if (!this.#implementingTypes) {
4111
+ const interfaceDef = {
4112
+ type: "interface",
4113
+ apiName: this.#apiName
4114
+ };
4115
+ const metadata = await this.store.client.fetchMetadata(interfaceDef);
4116
+ this.#implementingTypes = new Set(metadata.implementedBy ?? []);
4117
+ }
4118
+ if (this.#implementingTypes.has(objectType)) {
3586
4119
  changes?.modified.add(this.cacheKey);
3587
4120
  return this.revalidate(true);
3588
4121
  }
3589
- return Promise.resolve();
3590
4122
  };
3591
4123
  };
3592
4124
 
@@ -3600,10 +4132,11 @@ var ObjectsHelper = class extends AbstractHelper {
3600
4132
  const {
3601
4133
  pk
3602
4134
  } = options;
4135
+ const defType = chunk6VOFZIIJ_cjs.getDefType(options.apiName);
3603
4136
  const objectCacheKey = this.cacheKeys.get("object", apiName, pk, rdpConfig ?? void 0);
3604
4137
  return this.store.queries.get(objectCacheKey, () => new ObjectQuery(this.store, this.store.subjects.get(objectCacheKey), apiName, pk, objectCacheKey, {
3605
4138
  dedupeInterval: 0
3606
- }));
4139
+ }, defType));
3607
4140
  }
3608
4141
  /**
3609
4142
  * Internal helper method for writing objects to the store and returning their
@@ -3649,11 +4182,18 @@ var ObjectsHelper = class extends AbstractHelper {
3649
4182
  }
3650
4183
  }
3651
4184
  /**
3652
- * Check if a cache key is actively observed
4185
+ * Check if a cache key is actively observed or pending cleanup.
4186
+ * During React unmount-remount cycles, a key may be momentarily
4187
+ * unobserved while its cleanup is deferred to a microtask.
4188
+ * We still propagate to such keys to prevent stale data when
4189
+ * the subscription is re-established.
3653
4190
  */
3654
4191
  isKeyActive(key) {
3655
4192
  const subject = this.store.subjects.peek(key);
3656
- return subject?.observed === true;
4193
+ if (subject?.observed === true) {
4194
+ return true;
4195
+ }
4196
+ return (this.store.pendingCleanup.get(key) ?? 0) > 0;
3657
4197
  }
3658
4198
  /**
3659
4199
  * Type guard to check if a value is an ObjectHolder
@@ -3682,7 +4222,7 @@ var ObjectSetQuery = class extends BaseListQuery {
3682
4222
  #composedObjectSet;
3683
4223
  #objectTypes;
3684
4224
  constructor(store, subject, baseObjectSetWire, operations, cacheKey, opts) {
3685
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkOZNDU7AU_cjs.additionalContext].logger?.child({}, {
4225
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkYVZM2JPW_cjs.additionalContext].logger?.child({}, {
3686
4226
  msgPrefix: `ObjectSetQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
3687
4227
  }) : void 0);
3688
4228
  this.#baseObjectSetWire = baseObjectSetWire;
@@ -3697,6 +4237,9 @@ var ObjectSetQuery = class extends BaseListQuery {
3697
4237
  this.minResultsToLoad = opts.pageSize || 0;
3698
4238
  }
3699
4239
  }
4240
+ get rdpConfig() {
4241
+ return this.#operations.withProperties ?? null;
4242
+ }
3700
4243
  #composeObjectSet(opts) {
3701
4244
  let result = opts.baseObjectSet;
3702
4245
  if (opts.withProperties) {
@@ -3727,7 +4270,7 @@ var ObjectSetQuery = class extends BaseListQuery {
3727
4270
  }
3728
4271
  if (opts.union) {
3729
4272
  for (const os of opts.union) {
3730
- const wire = chunkOZNDU7AU_cjs.getWireObjectSet(os);
4273
+ const wire = chunkYVZM2JPW_cjs.getWireObjectSet(os);
3731
4274
  if (wire.type) {
3732
4275
  types.add(wire.type);
3733
4276
  }
@@ -3735,7 +4278,7 @@ var ObjectSetQuery = class extends BaseListQuery {
3735
4278
  }
3736
4279
  if (opts.intersect) {
3737
4280
  for (const os of opts.intersect) {
3738
- const wire = chunkOZNDU7AU_cjs.getWireObjectSet(os);
4281
+ const wire = chunkYVZM2JPW_cjs.getWireObjectSet(os);
3739
4282
  if (wire.type) {
3740
4283
  types.add(wire.type);
3741
4284
  }
@@ -3743,7 +4286,7 @@ var ObjectSetQuery = class extends BaseListQuery {
3743
4286
  }
3744
4287
  if (opts.subtract) {
3745
4288
  for (const os of opts.subtract) {
3746
- const wire = chunkOZNDU7AU_cjs.getWireObjectSet(os);
4289
+ const wire = chunkYVZM2JPW_cjs.getWireObjectSet(os);
3747
4290
  if (wire.type) {
3748
4291
  types.add(wire.type);
3749
4292
  }
@@ -3763,15 +4306,15 @@ var ObjectSetQuery = class extends BaseListQuery {
3763
4306
  */
3764
4307
  async fetchPageData(signal) {
3765
4308
  if (this.#operations.orderBy && Object.keys(this.#operations.orderBy).length > 0 && !(this.sortingStrategy instanceof OrderBySortingStrategy)) {
3766
- const wireObjectSet = chunkOZNDU7AU_cjs.getWireObjectSet(this.#composedObjectSet);
4309
+ const wireObjectSet = chunkYVZM2JPW_cjs.getWireObjectSet(this.#composedObjectSet);
3767
4310
  const {
3768
4311
  resultType
3769
- } = await getObjectTypesThatInvalidate(this.store.client[chunkOZNDU7AU_cjs.additionalContext], wireObjectSet);
4312
+ } = await getObjectTypesThatInvalidate(this.store.client[chunkYVZM2JPW_cjs.additionalContext], wireObjectSet);
3770
4313
  this.sortingStrategy = new OrderBySortingStrategy(resultType.apiName, this.#operations.orderBy);
3771
4314
  }
3772
4315
  const resp = await this.#composedObjectSet.fetchPage({
3773
4316
  $nextPageToken: this.nextPageToken,
3774
- $pageSize: this.options.pageSize,
4317
+ $pageSize: this.getEffectiveFetchPageSize(),
3775
4318
  $includeRid: true,
3776
4319
  // OrderBy is already applied in the composed ObjectSet
3777
4320
  ...this.#operations.orderBy && Object.keys(this.#operations.orderBy).length > 0 ? {
@@ -3819,10 +4362,11 @@ var ObjectSetQuery = class extends BaseListQuery {
3819
4362
 
3820
4363
  // src/observable/internal/objectset/ObjectSetHelper.ts
3821
4364
  var ObjectSetHelper = class extends AbstractHelper {
3822
- constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2) {
4365
+ constructor(store, cacheKeys, whereCanonicalizer2, orderByCanonicalizer2, rdpCanonicalizer) {
3823
4366
  super(store, cacheKeys);
3824
4367
  this.whereCanonicalizer = whereCanonicalizer2;
3825
4368
  this.orderByCanonicalizer = orderByCanonicalizer2;
4369
+ this.rdpCanonicalizer = rdpCanonicalizer;
3826
4370
  }
3827
4371
  observe(options, subFn) {
3828
4372
  const ret = super.observe(options, subFn);
@@ -3835,7 +4379,7 @@ var ObjectSetHelper = class extends AbstractHelper {
3835
4379
  const {
3836
4380
  baseObjectSet
3837
4381
  } = options;
3838
- const baseObjectSetWire = JSON.stringify(chunkOZNDU7AU_cjs.getWireObjectSet(baseObjectSet));
4382
+ const baseObjectSetWire = JSON.stringify(chunkYVZM2JPW_cjs.getWireObjectSet(baseObjectSet));
3839
4383
  const operations = this.buildCanonicalizedOperations(options);
3840
4384
  const objectSetCacheKey = this.cacheKeys.get("objectSet", baseObjectSetWire, operations);
3841
4385
  return this.store.queries.get(objectSetCacheKey, () => {
@@ -3848,16 +4392,16 @@ var ObjectSetHelper = class extends AbstractHelper {
3848
4392
  operations.where = this.whereCanonicalizer.canonicalize(options.where);
3849
4393
  }
3850
4394
  if (options.withProperties) {
3851
- operations.withProperties = Object.keys(options.withProperties).sort();
4395
+ operations.withProperties = this.rdpCanonicalizer.canonicalize(options.withProperties);
3852
4396
  }
3853
4397
  if (options.union && options.union.length > 0) {
3854
- operations.union = options.union.map((os) => JSON.stringify(chunkOZNDU7AU_cjs.getWireObjectSet(os)));
4398
+ operations.union = options.union.map((os) => JSON.stringify(chunkYVZM2JPW_cjs.getWireObjectSet(os)));
3855
4399
  }
3856
4400
  if (options.intersect && options.intersect.length > 0) {
3857
- operations.intersect = options.intersect.map((os) => JSON.stringify(chunkOZNDU7AU_cjs.getWireObjectSet(os)));
4401
+ operations.intersect = options.intersect.map((os) => JSON.stringify(chunkYVZM2JPW_cjs.getWireObjectSet(os)));
3858
4402
  }
3859
4403
  if (options.subtract && options.subtract.length > 0) {
3860
- operations.subtract = options.subtract.map((os) => JSON.stringify(chunkOZNDU7AU_cjs.getWireObjectSet(os)));
4404
+ operations.subtract = options.subtract.map((os) => JSON.stringify(chunkYVZM2JPW_cjs.getWireObjectSet(os)));
3861
4405
  }
3862
4406
  if (options.pivotTo) {
3863
4407
  operations.pivotTo = options.pivotTo;
@@ -3876,14 +4420,14 @@ var ObjectSetHelper = class extends AbstractHelper {
3876
4420
  chunkLDTMSHUZ_cjs.init_cjs_shims();
3877
4421
  var PivotCanonicalizer = class {
3878
4422
  #cache = /* @__PURE__ */ new Map();
3879
- canonicalize(sourceType, linkName) {
3880
- const key = `${sourceType}::${linkName}`;
4423
+ canonicalize(sourceType, sourceTypeKind, linkName) {
4424
+ const key = `${sourceTypeKind}:${sourceType}::${linkName}`;
3881
4425
  let canonical = this.#cache.get(key);
3882
4426
  if (!canonical) {
3883
4427
  canonical = {
3884
4428
  sourceType,
3885
- linkName,
3886
- targetType: "<targetType>"
4429
+ sourceTypeKind,
4430
+ linkName
3887
4431
  };
3888
4432
  this.#cache.set(key, canonical);
3889
4433
  }
@@ -3929,7 +4473,7 @@ var RdpCanonicalizer = class extends CachingCanonicalizer {
3929
4473
  apiName: "__rdp_canonicalizer_holder__"
3930
4474
  };
3931
4475
  for (const [key, rdpFunction] of Object.entries(rdp)) {
3932
- const builder = chunkOZNDU7AU_cjs.createWithPropertiesObjectSet(
4476
+ const builder = chunkYVZM2JPW_cjs.createWithPropertiesObjectSet(
3933
4477
  objectTypeHolder,
3934
4478
  {
3935
4479
  type: "methodInput"
@@ -3989,6 +4533,17 @@ var Store = class {
3989
4533
  ridListCanonicalizer = new RidListCanonicalizer();
3990
4534
  /** @internal */
3991
4535
  queries = new Queries();
4536
+ /**
4537
+ * Tracks cache keys with deferred cleanup. During React unmount-remount
4538
+ * cycles, a subscription may be cleaned up and immediately re-created.
4539
+ * By deferring cleanup to a microtask, we prevent propagateWrite from
4540
+ * skipping keys that are momentarily between subscriptions.
4541
+ *
4542
+ * The value is a count (not a boolean) so multiple unsubscribes within the
4543
+ * same tick schedule the correct number of releases.
4544
+ * @internal
4545
+ */
4546
+ pendingCleanup = /* @__PURE__ */ new Map();
3992
4547
  objectCacheKeyRegistry = new ObjectCacheKeyRegistry();
3993
4548
  layers = new Layers({
3994
4549
  logger: this.logger,
@@ -3997,19 +4552,19 @@ var Store = class {
3997
4552
  subjects = this.layers.subjects;
3998
4553
  // these are hopefully temporary
3999
4554
  constructor(client) {
4000
- this.logger = client[chunkOZNDU7AU_cjs.additionalContext].logger?.child({}, {
4555
+ this.logger = client[chunkYVZM2JPW_cjs.additionalContext].logger?.child({}, {
4001
4556
  msgPrefix: "Store"
4002
4557
  });
4003
4558
  this.client = client;
4004
4559
  this.cacheKeys = new CacheKeys({
4005
4560
  onDestroy: this.#cleanupCacheKey
4006
4561
  });
4007
- this.aggregations = new AggregationsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.rdpCanonicalizer);
4562
+ this.aggregations = new AggregationsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.rdpCanonicalizer, this.intersectCanonicalizer);
4008
4563
  this.functions = new FunctionsHelper(this, this.cacheKeys);
4009
4564
  this.lists = new ListsHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer, this.intersectCanonicalizer, this.pivotCanonicalizer, this.ridListCanonicalizer);
4010
4565
  this.objects = new ObjectsHelper(this, this.cacheKeys);
4011
4566
  this.links = new LinksHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
4012
- this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer);
4567
+ this.objectSets = new ObjectSetHelper(this, this.cacheKeys, this.whereCanonicalizer, this.orderByCanonicalizer, this.rdpCanonicalizer);
4013
4568
  }
4014
4569
  /**
4015
4570
  * Called after a key is no longer retained and the timeout has elapsed
@@ -4171,6 +4726,11 @@ var Store = class {
4171
4726
  return cacheKey.otherKeys[RDP_IDX2];
4172
4727
  } else if (cacheKey.type === "aggregation") {
4173
4728
  return cacheKey.otherKeys[RDP_IDX];
4729
+ } else if (cacheKey.type === "objectSet") {
4730
+ const query = this.queries.peek(cacheKey);
4731
+ if (query) {
4732
+ return query.rdpConfig;
4733
+ }
4174
4734
  }
4175
4735
  }
4176
4736
  return void 0;
@@ -4270,10 +4830,10 @@ var Store = class {
4270
4830
 
4271
4831
  // src/observable/ObservableClient.ts
4272
4832
  function createObservableClient(client) {
4273
- const tweakedClient = chunkOVZCGOMG_cjs.createClientFromContext({
4274
- ...client[chunkOZNDU7AU_cjs.additionalContext],
4275
- fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkOZNDU7AU_cjs.additionalContext].fetch, (headers) => {
4276
- headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunkOVZCGOMG_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
4833
+ const tweakedClient = chunk6VOFZIIJ_cjs.createClientFromContext({
4834
+ ...client[chunkYVZM2JPW_cjs.additionalContext],
4835
+ fetch: shared_net_fetch.createFetchHeaderMutator(client[chunkYVZM2JPW_cjs.additionalContext].fetch, (headers) => {
4836
+ headers.set("Fetch-User-Agent", [headers.get("Fetch-User-Agent"), chunk6VOFZIIJ_cjs.OBSERVABLE_USER_AGENT].filter((x) => x && x?.length > 0).join(" "));
4277
4837
  return headers;
4278
4838
  })
4279
4839
  });
@@ -4317,11 +4877,19 @@ function getOsdkConfig(ontologyRid) {
4317
4877
 
4318
4878
  Object.defineProperty(exports, "createClientWithTransaction", {
4319
4879
  enumerable: true,
4320
- get: function () { return chunkOVZCGOMG_cjs.createClientWithTransaction; }
4880
+ get: function () { return chunk6VOFZIIJ_cjs.createClientWithTransaction; }
4321
4881
  });
4322
4882
  Object.defineProperty(exports, "augment", {
4323
4883
  enumerable: true,
4324
- get: function () { return chunkOZNDU7AU_cjs.augment; }
4884
+ get: function () { return chunkYVZM2JPW_cjs.augment; }
4885
+ });
4886
+ Object.defineProperty(exports, "getWireObjectSet", {
4887
+ enumerable: true,
4888
+ get: function () { return chunkYVZM2JPW_cjs.getWireObjectSet; }
4889
+ });
4890
+ Object.defineProperty(exports, "isObjectSet", {
4891
+ enumerable: true,
4892
+ get: function () { return chunkYVZM2JPW_cjs.isObjectSet; }
4325
4893
  });
4326
4894
  exports.computeObjectSetCacheKey = computeObjectSetCacheKey;
4327
4895
  exports.createObservableClient = createObservableClient;