@osdk/client 2.2.0-beta.8 → 2.3.0-beta.1

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 (489) hide show
  1. package/CHANGELOG.md +388 -0
  2. package/build/browser/MinimalClientContext.js.map +1 -1
  3. package/build/browser/__unstable/ConjureSupport.js.map +1 -1
  4. package/build/browser/actions/ActionValidationError.js +1 -1
  5. package/build/browser/actions/ActionValidationError.js.map +1 -1
  6. package/build/browser/actions/actions.test.js +134 -89
  7. package/build/browser/actions/actions.test.js.map +1 -1
  8. package/build/browser/actions/applyAction.js.map +1 -1
  9. package/build/browser/createClient.js +5 -1
  10. package/build/browser/createClient.js.map +1 -1
  11. package/build/browser/createClient.test.js +14 -6
  12. package/build/browser/createClient.test.js.map +1 -1
  13. package/build/browser/createMinimalClient.js +2 -2
  14. package/build/browser/createMinimalClient.js.map +1 -1
  15. package/build/browser/createMinimalClientHelper.js +25 -0
  16. package/build/browser/createMinimalClientHelper.js.map +1 -0
  17. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +36 -13
  18. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  19. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js +133 -0
  20. package/build/browser/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  21. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
  22. package/build/browser/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
  23. package/build/browser/fetchMetadata.js +1 -1
  24. package/build/browser/fetchMetadata.js.map +1 -1
  25. package/build/browser/fetchMetadata.test.js +11 -9
  26. package/build/browser/fetchMetadata.test.js.map +1 -1
  27. package/build/browser/index.js +0 -1
  28. package/build/browser/index.js.map +1 -1
  29. package/build/{esm/util/isOsdkBaseObject.js → browser/intellisense.test.helpers/showsObjectPropertyJsdoc.js} +9 -4
  30. package/build/browser/intellisense.test.helpers/showsObjectPropertyJsdoc.js.map +1 -0
  31. package/build/browser/intellisense.test.js +17 -1
  32. package/build/browser/intellisense.test.js.map +1 -1
  33. package/build/browser/logger/BaseLogger.js +59 -0
  34. package/build/browser/logger/BaseLogger.js.map +1 -0
  35. package/build/browser/logger/BrowserLogger.js +67 -0
  36. package/build/browser/logger/BrowserLogger.js.map +1 -0
  37. package/build/browser/logger/MinimalLogger.js +39 -0
  38. package/build/browser/logger/MinimalLogger.js.map +1 -0
  39. package/build/browser/logger/MinimalLogger.test.js +60 -0
  40. package/build/browser/logger/MinimalLogger.test.js.map +1 -0
  41. package/build/browser/logger/TestLogger.js +56 -0
  42. package/build/browser/logger/TestLogger.js.map +1 -0
  43. package/build/browser/object/SimpleOsdkProperties.js +2 -0
  44. package/build/browser/object/SimpleOsdkProperties.js.map +1 -0
  45. package/build/browser/object/attachment.test.js +20 -7
  46. package/build/browser/object/attachment.test.js.map +1 -1
  47. package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js +2 -0
  48. package/build/browser/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -0
  49. package/build/browser/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
  50. package/build/browser/object/convertWireToOsdkObjects/ObjectHolder.js.map +1 -1
  51. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
  52. package/build/browser/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  53. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js +53 -35
  54. package/build/browser/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  55. package/build/browser/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
  56. package/build/browser/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
  57. package/build/browser/object/convertWireToOsdkObjects.js +7 -15
  58. package/build/browser/object/convertWireToOsdkObjects.js.map +1 -1
  59. package/build/browser/object/convertWireToOsdkObjects.test.js +39 -33
  60. package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
  61. package/build/browser/object/fetchPage.js +17 -4
  62. package/build/browser/object/fetchPage.js.map +1 -1
  63. package/build/browser/object/fetchPage.test.js +56 -2
  64. package/build/browser/object/fetchPage.test.js.map +1 -1
  65. package/build/browser/object/geotimeseriesreference.test.js +56 -134
  66. package/build/browser/object/geotimeseriesreference.test.js.map +1 -1
  67. package/build/browser/object/media.test.js +19 -14
  68. package/build/browser/object/media.test.js.map +1 -1
  69. package/build/browser/object/object.test.js +96 -89
  70. package/build/browser/object/object.test.js.map +1 -1
  71. package/build/browser/object/timeseries.test.js +119 -85
  72. package/build/browser/object/timeseries.test.js.map +1 -1
  73. package/build/browser/objectSet/InterfaceObjectSet.test.js +37 -17
  74. package/build/browser/objectSet/InterfaceObjectSet.test.js.map +1 -1
  75. package/build/browser/objectSet/ObjectSet.test.js +200 -116
  76. package/build/browser/objectSet/ObjectSet.test.js.map +1 -1
  77. package/build/browser/objectSet/ObjectSetListenerWebsocket.js +20 -16
  78. package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  79. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +19 -12
  80. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  81. package/build/browser/objectSet/createObjectSet.js +2 -1
  82. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  83. package/build/browser/observable/ListPayload.js.map +1 -1
  84. package/build/browser/observable/ObjectPayload.js.map +1 -1
  85. package/build/browser/observable/ObservableClient.js.map +1 -1
  86. package/build/browser/observable/internal/ActionApplication.js +32 -32
  87. package/build/browser/observable/internal/ActionApplication.js.map +1 -1
  88. package/build/browser/observable/internal/BulkObjectLoader.js +93 -0
  89. package/build/browser/observable/internal/BulkObjectLoader.js.map +1 -0
  90. package/build/browser/observable/internal/BulkObjectLoader.test.js +112 -0
  91. package/build/browser/observable/internal/BulkObjectLoader.test.js.map +1 -0
  92. package/build/browser/observable/internal/CacheKey.js +1 -1
  93. package/build/browser/observable/internal/CacheKey.js.map +1 -1
  94. package/build/browser/observable/internal/CacheKeys.js +2 -2
  95. package/build/browser/observable/internal/CacheKeys.js.map +1 -1
  96. package/build/browser/observable/internal/{ChangedObjects.js → Changes.js} +20 -9
  97. package/build/browser/observable/internal/Changes.js.map +1 -0
  98. package/build/browser/observable/internal/Layer.js +3 -0
  99. package/build/browser/observable/internal/Layer.js.map +1 -1
  100. package/build/browser/observable/internal/ListQuery.js +414 -170
  101. package/build/browser/observable/internal/ListQuery.js.map +1 -1
  102. package/build/browser/observable/internal/ObjectQuery.js +34 -21
  103. package/build/browser/observable/internal/ObjectQuery.js.map +1 -1
  104. package/build/browser/observable/internal/ObservableClientImpl.js +4 -12
  105. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  106. package/build/browser/observable/internal/OptimisticJob.js +1 -1
  107. package/build/browser/observable/internal/OptimisticJob.js.map +1 -1
  108. package/build/browser/observable/internal/OrderByCanonicalizer.js +73 -0
  109. package/build/browser/observable/internal/OrderByCanonicalizer.js.map +1 -0
  110. package/build/browser/observable/internal/OrderByCanonicalizer.test.js +78 -0
  111. package/build/browser/observable/internal/OrderByCanonicalizer.test.js.map +1 -0
  112. package/build/browser/observable/internal/Query.js +64 -31
  113. package/build/browser/observable/internal/Query.js.map +1 -1
  114. package/build/browser/observable/internal/RefCounts.js +7 -2
  115. package/build/browser/observable/internal/RefCounts.js.map +1 -1
  116. package/build/browser/observable/internal/SimpleWhereClause.js +2 -0
  117. package/build/browser/observable/internal/SimpleWhereClause.js.map +1 -0
  118. package/build/browser/observable/internal/Store.js +86 -269
  119. package/build/browser/observable/internal/Store.js.map +1 -1
  120. package/build/browser/observable/internal/Store.test.js +401 -375
  121. package/build/browser/observable/internal/Store.test.js.map +1 -1
  122. package/build/browser/observable/internal/WhereClauseCanonicalizer.js +11 -3
  123. package/build/browser/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
  124. package/build/browser/observable/internal/objectMatchesWhereClause.js +0 -2
  125. package/build/browser/observable/internal/objectMatchesWhereClause.js.map +1 -1
  126. package/build/browser/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
  127. package/build/browser/observable/internal/testUtils.js +85 -20
  128. package/build/browser/observable/internal/testUtils.js.map +1 -1
  129. package/build/browser/ontology/OntologyProvider.js.map +1 -1
  130. package/build/browser/ontology/StandardOntologyProvider.js +12 -5
  131. package/build/browser/ontology/StandardOntologyProvider.js.map +1 -1
  132. package/build/browser/ontology/StandardOntologyProvider.test.js +17 -16
  133. package/build/browser/ontology/StandardOntologyProvider.test.js.map +1 -1
  134. package/build/browser/ontology/loadFullObjectMetadata.js +0 -1
  135. package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
  136. package/build/browser/ontology/loadQueryMetadata.js +5 -2
  137. package/build/browser/ontology/loadQueryMetadata.js.map +1 -1
  138. package/build/browser/public/internal.js +2 -0
  139. package/build/browser/public/internal.js.map +1 -1
  140. package/build/browser/public/unstable-do-not-use.js +1 -0
  141. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  142. package/build/browser/public-utils/osdkConfig.js +49 -0
  143. package/build/browser/public-utils/osdkConfig.js.map +1 -0
  144. package/build/browser/{object/createObjectSpecifierFromPrimaryKey.js → public-utils/vite-env.d.ts} +2 -3
  145. package/build/browser/queries/applyQuery.js +6 -4
  146. package/build/browser/queries/applyQuery.js.map +1 -1
  147. package/build/browser/queries/queries.test.js +93 -27
  148. package/build/browser/queries/queries.test.js.map +1 -1
  149. package/build/browser/queries/types.js.map +1 -1
  150. package/build/browser/tsserver.js.map +1 -1
  151. package/build/browser/util/UserAgent.js +1 -1
  152. package/build/browser/util/extractRdpDefinition.js +140 -0
  153. package/build/browser/util/extractRdpDefinition.js.map +1 -0
  154. package/build/browser/util/extractRdpDefinition.test.js +233 -0
  155. package/build/browser/util/extractRdpDefinition.test.js.map +1 -0
  156. package/build/browser/util/{isOsdkBaseObject.js → isObjectSpecifiersObject.js} +2 -2
  157. package/build/browser/util/isObjectSpecifiersObject.js.map +1 -0
  158. package/build/browser/util/isPoint.js +20 -0
  159. package/build/browser/util/isPoint.js.map +1 -0
  160. package/build/browser/util/objectSpecifierUtils.js +48 -0
  161. package/build/browser/util/objectSpecifierUtils.js.map +1 -0
  162. package/build/browser/util/objectSpecifierUtils.test.js +42 -0
  163. package/build/browser/util/objectSpecifierUtils.test.js.map +1 -0
  164. package/build/browser/util/toDataValue.js +6 -2
  165. package/build/browser/util/toDataValue.js.map +1 -1
  166. package/build/browser/util/toDataValue.test.js +37 -16
  167. package/build/browser/util/toDataValue.test.js.map +1 -1
  168. package/build/browser/util/toDataValueQueries.js +4 -6
  169. package/build/browser/util/toDataValueQueries.js.map +1 -1
  170. package/build/cjs/{Client-DBTcM9gB.d.cts → Client-CgL2LKN9.d.cts} +6 -7
  171. package/build/cjs/{chunk-IU47QMYO.cjs → chunk-FKI2LO2O.cjs} +250 -82
  172. package/build/cjs/chunk-FKI2LO2O.cjs.map +1 -0
  173. package/build/cjs/chunk-T4NIFYZS.cjs +14 -0
  174. package/build/cjs/chunk-T4NIFYZS.cjs.map +1 -0
  175. package/build/cjs/{chunk-JPENHIJB.cjs → chunk-W5PFESFR.cjs} +174 -35
  176. package/build/cjs/chunk-W5PFESFR.cjs.map +1 -0
  177. package/build/cjs/index.cjs +212 -193
  178. package/build/cjs/index.cjs.map +1 -1
  179. package/build/cjs/index.d.cts +4 -24
  180. package/build/cjs/public/internal.cjs +61 -7
  181. package/build/cjs/public/internal.cjs.map +1 -1
  182. package/build/cjs/public/internal.d.cts +50 -3
  183. package/build/cjs/public/unstable-do-not-use.cjs +885 -620
  184. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  185. package/build/cjs/public/unstable-do-not-use.d.cts +35 -25
  186. package/build/esm/MinimalClientContext.js.map +1 -1
  187. package/build/esm/__unstable/ConjureSupport.js.map +1 -1
  188. package/build/esm/actions/ActionValidationError.js +1 -1
  189. package/build/esm/actions/ActionValidationError.js.map +1 -1
  190. package/build/esm/actions/actions.test.js +134 -89
  191. package/build/esm/actions/actions.test.js.map +1 -1
  192. package/build/esm/actions/applyAction.js.map +1 -1
  193. package/build/esm/createClient.js +5 -1
  194. package/build/esm/createClient.js.map +1 -1
  195. package/build/esm/createClient.test.js +14 -6
  196. package/build/esm/createClient.test.js.map +1 -1
  197. package/build/esm/createMinimalClient.js +2 -2
  198. package/build/esm/createMinimalClient.js.map +1 -1
  199. package/build/esm/createMinimalClientHelper.js +25 -0
  200. package/build/esm/createMinimalClientHelper.js.map +1 -0
  201. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +36 -13
  202. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  203. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js +133 -0
  204. package/build/esm/derivedProperties/createWithPropertiesObjectSet.test.js.map +1 -1
  205. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js +93 -0
  206. package/build/esm/derivedProperties/derivedPropertyDefinitionFactory.js.map +1 -0
  207. package/build/esm/fetchMetadata.js +1 -1
  208. package/build/esm/fetchMetadata.js.map +1 -1
  209. package/build/esm/fetchMetadata.test.js +11 -9
  210. package/build/esm/fetchMetadata.test.js.map +1 -1
  211. package/build/esm/index.js +0 -1
  212. package/build/esm/index.js.map +1 -1
  213. package/build/esm/{util/isOsdkObject.js → intellisense.test.helpers/showsObjectPropertyJsdoc.js} +9 -4
  214. package/build/esm/intellisense.test.helpers/showsObjectPropertyJsdoc.js.map +1 -0
  215. package/build/esm/intellisense.test.js +17 -1
  216. package/build/esm/intellisense.test.js.map +1 -1
  217. package/build/esm/logger/BaseLogger.js +59 -0
  218. package/build/esm/logger/BaseLogger.js.map +1 -0
  219. package/build/esm/logger/BrowserLogger.js +67 -0
  220. package/build/esm/logger/BrowserLogger.js.map +1 -0
  221. package/build/esm/logger/MinimalLogger.js +39 -0
  222. package/build/esm/logger/MinimalLogger.js.map +1 -0
  223. package/build/esm/logger/MinimalLogger.test.js +60 -0
  224. package/build/esm/logger/MinimalLogger.test.js.map +1 -0
  225. package/build/esm/logger/TestLogger.js +56 -0
  226. package/build/esm/logger/TestLogger.js.map +1 -0
  227. package/build/esm/object/SimpleOsdkProperties.js +2 -0
  228. package/build/esm/object/SimpleOsdkProperties.js.map +1 -0
  229. package/build/esm/object/attachment.test.js +20 -7
  230. package/build/esm/object/attachment.test.js.map +1 -1
  231. package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js +2 -0
  232. package/build/esm/object/convertWireToOsdkObjects/BaseHolder.js.map +1 -0
  233. package/build/esm/object/convertWireToOsdkObjects/InterfaceHolder.js.map +1 -1
  234. package/build/esm/object/convertWireToOsdkObjects/ObjectHolder.js.map +1 -1
  235. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js +4 -0
  236. package/build/esm/object/convertWireToOsdkObjects/createOsdkInterface.js.map +1 -1
  237. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js +53 -35
  238. package/build/esm/object/convertWireToOsdkObjects/createOsdkObject.js.map +1 -1
  239. package/build/esm/object/convertWireToOsdkObjects/getDollarAs.js.map +1 -1
  240. package/build/esm/object/convertWireToOsdkObjects/getDollarLink.js.map +1 -1
  241. package/build/esm/object/convertWireToOsdkObjects.js +7 -15
  242. package/build/esm/object/convertWireToOsdkObjects.js.map +1 -1
  243. package/build/esm/object/convertWireToOsdkObjects.test.js +39 -33
  244. package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
  245. package/build/esm/object/fetchPage.js +17 -4
  246. package/build/esm/object/fetchPage.js.map +1 -1
  247. package/build/esm/object/fetchPage.test.js +56 -2
  248. package/build/esm/object/fetchPage.test.js.map +1 -1
  249. package/build/esm/object/geotimeseriesreference.test.js +56 -134
  250. package/build/esm/object/geotimeseriesreference.test.js.map +1 -1
  251. package/build/esm/object/media.test.js +19 -14
  252. package/build/esm/object/media.test.js.map +1 -1
  253. package/build/esm/object/object.test.js +96 -89
  254. package/build/esm/object/object.test.js.map +1 -1
  255. package/build/esm/object/timeseries.test.js +119 -85
  256. package/build/esm/object/timeseries.test.js.map +1 -1
  257. package/build/esm/objectSet/InterfaceObjectSet.test.js +37 -17
  258. package/build/esm/objectSet/InterfaceObjectSet.test.js.map +1 -1
  259. package/build/esm/objectSet/ObjectSet.test.js +200 -116
  260. package/build/esm/objectSet/ObjectSet.test.js.map +1 -1
  261. package/build/esm/objectSet/ObjectSetListenerWebsocket.js +20 -16
  262. package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  263. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +19 -12
  264. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  265. package/build/esm/objectSet/createObjectSet.js +2 -1
  266. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  267. package/build/esm/observable/ListPayload.js.map +1 -1
  268. package/build/esm/observable/ObjectPayload.js.map +1 -1
  269. package/build/esm/observable/ObservableClient.js.map +1 -1
  270. package/build/esm/observable/internal/ActionApplication.js +32 -32
  271. package/build/esm/observable/internal/ActionApplication.js.map +1 -1
  272. package/build/esm/observable/internal/BulkObjectLoader.js +93 -0
  273. package/build/esm/observable/internal/BulkObjectLoader.js.map +1 -0
  274. package/build/esm/observable/internal/BulkObjectLoader.test.js +112 -0
  275. package/build/esm/observable/internal/BulkObjectLoader.test.js.map +1 -0
  276. package/build/esm/observable/internal/CacheKey.js +1 -1
  277. package/build/esm/observable/internal/CacheKey.js.map +1 -1
  278. package/build/esm/observable/internal/CacheKeys.js +2 -2
  279. package/build/esm/observable/internal/CacheKeys.js.map +1 -1
  280. package/build/esm/observable/internal/{ChangedObjects.js → Changes.js} +20 -9
  281. package/build/esm/observable/internal/Changes.js.map +1 -0
  282. package/build/esm/observable/internal/Layer.js +3 -0
  283. package/build/esm/observable/internal/Layer.js.map +1 -1
  284. package/build/esm/observable/internal/ListQuery.js +414 -170
  285. package/build/esm/observable/internal/ListQuery.js.map +1 -1
  286. package/build/esm/observable/internal/ObjectQuery.js +34 -21
  287. package/build/esm/observable/internal/ObjectQuery.js.map +1 -1
  288. package/build/esm/observable/internal/ObservableClientImpl.js +4 -12
  289. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  290. package/build/esm/observable/internal/OptimisticJob.js +1 -1
  291. package/build/esm/observable/internal/OptimisticJob.js.map +1 -1
  292. package/build/esm/observable/internal/OrderByCanonicalizer.js +73 -0
  293. package/build/esm/observable/internal/OrderByCanonicalizer.js.map +1 -0
  294. package/build/esm/observable/internal/OrderByCanonicalizer.test.js +78 -0
  295. package/build/esm/observable/internal/OrderByCanonicalizer.test.js.map +1 -0
  296. package/build/esm/observable/internal/Query.js +64 -31
  297. package/build/esm/observable/internal/Query.js.map +1 -1
  298. package/build/esm/observable/internal/RefCounts.js +7 -2
  299. package/build/esm/observable/internal/RefCounts.js.map +1 -1
  300. package/build/esm/observable/internal/SimpleWhereClause.js +2 -0
  301. package/build/esm/observable/internal/SimpleWhereClause.js.map +1 -0
  302. package/build/esm/observable/internal/Store.js +86 -269
  303. package/build/esm/observable/internal/Store.js.map +1 -1
  304. package/build/esm/observable/internal/Store.test.js +401 -375
  305. package/build/esm/observable/internal/Store.test.js.map +1 -1
  306. package/build/esm/observable/internal/WhereClauseCanonicalizer.js +11 -3
  307. package/build/esm/observable/internal/WhereClauseCanonicalizer.js.map +1 -1
  308. package/build/esm/observable/internal/objectMatchesWhereClause.js +0 -2
  309. package/build/esm/observable/internal/objectMatchesWhereClause.js.map +1 -1
  310. package/build/esm/observable/internal/objectMatchesWhereClause.test.js.map +1 -1
  311. package/build/esm/observable/internal/testUtils.js +85 -20
  312. package/build/esm/observable/internal/testUtils.js.map +1 -1
  313. package/build/esm/ontology/OntologyProvider.js.map +1 -1
  314. package/build/esm/ontology/StandardOntologyProvider.js +12 -5
  315. package/build/esm/ontology/StandardOntologyProvider.js.map +1 -1
  316. package/build/esm/ontology/StandardOntologyProvider.test.js +17 -16
  317. package/build/esm/ontology/StandardOntologyProvider.test.js.map +1 -1
  318. package/build/esm/ontology/loadFullObjectMetadata.js +0 -1
  319. package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
  320. package/build/esm/ontology/loadQueryMetadata.js +5 -2
  321. package/build/esm/ontology/loadQueryMetadata.js.map +1 -1
  322. package/build/esm/public/internal.js +2 -0
  323. package/build/esm/public/internal.js.map +1 -1
  324. package/build/esm/public/unstable-do-not-use.js +1 -0
  325. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  326. package/build/esm/public-utils/osdkConfig.js +49 -0
  327. package/build/esm/public-utils/osdkConfig.js.map +1 -0
  328. package/build/esm/{object/createObjectSpecifierFromPrimaryKey.js → public-utils/vite-env.d.ts} +2 -3
  329. package/build/esm/queries/applyQuery.js +6 -4
  330. package/build/esm/queries/applyQuery.js.map +1 -1
  331. package/build/esm/queries/queries.test.js +93 -27
  332. package/build/esm/queries/queries.test.js.map +1 -1
  333. package/build/esm/queries/types.js.map +1 -1
  334. package/build/esm/tsserver.js.map +1 -1
  335. package/build/esm/util/UserAgent.js +1 -1
  336. package/build/esm/util/extractRdpDefinition.js +140 -0
  337. package/build/esm/util/extractRdpDefinition.js.map +1 -0
  338. package/build/esm/util/extractRdpDefinition.test.js +233 -0
  339. package/build/esm/util/extractRdpDefinition.test.js.map +1 -0
  340. package/build/{browser/util/isOsdkObject.js → esm/util/isObjectSpecifiersObject.js} +2 -2
  341. package/build/esm/util/isObjectSpecifiersObject.js.map +1 -0
  342. package/build/esm/util/isPoint.js +20 -0
  343. package/build/esm/util/isPoint.js.map +1 -0
  344. package/build/esm/util/objectSpecifierUtils.js +48 -0
  345. package/build/esm/util/objectSpecifierUtils.js.map +1 -0
  346. package/build/esm/util/objectSpecifierUtils.test.js +42 -0
  347. package/build/esm/util/objectSpecifierUtils.test.js.map +1 -0
  348. package/build/esm/util/toDataValue.js +6 -2
  349. package/build/esm/util/toDataValue.js.map +1 -1
  350. package/build/esm/util/toDataValue.test.js +37 -16
  351. package/build/esm/util/toDataValue.test.js.map +1 -1
  352. package/build/esm/util/toDataValueQueries.js +4 -6
  353. package/build/esm/util/toDataValueQueries.js.map +1 -1
  354. package/build/types/MinimalClientContext.d.ts +1 -1
  355. package/build/types/MinimalClientContext.d.ts.map +1 -1
  356. package/build/types/__unstable/ConjureSupport.d.ts +2 -2
  357. package/build/types/actions/applyAction.d.ts +1 -2
  358. package/build/types/actions/applyAction.d.ts.map +1 -1
  359. package/build/types/createClient.d.ts +1 -1
  360. package/build/types/createClient.d.ts.map +1 -1
  361. package/build/types/createClient.test.d.ts +2 -1
  362. package/build/types/createClient.test.d.ts.map +1 -1
  363. package/build/types/createMinimalClientHelper.d.ts +1 -0
  364. package/build/types/createMinimalClientHelper.d.ts.map +1 -0
  365. package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts +1 -0
  366. package/build/types/derivedProperties/derivedPropertyDefinitionFactory.d.ts.map +1 -0
  367. package/build/types/index.d.ts +4 -6
  368. package/build/types/index.d.ts.map +1 -1
  369. package/build/types/intellisense.test.helpers/showsObjectPropertyJsdoc.d.ts +1 -0
  370. package/build/types/intellisense.test.helpers/showsObjectPropertyJsdoc.d.ts.map +1 -0
  371. package/build/types/logger/BaseLogger.d.ts +33 -0
  372. package/build/types/logger/BaseLogger.d.ts.map +1 -0
  373. package/build/types/logger/BrowserLogger.d.ts +9 -0
  374. package/build/types/logger/BrowserLogger.d.ts.map +1 -0
  375. package/build/types/logger/MinimalLogger.d.ts +9 -0
  376. package/build/types/logger/MinimalLogger.d.ts.map +1 -0
  377. package/build/types/logger/MinimalLogger.test.d.ts +1 -0
  378. package/build/types/logger/MinimalLogger.test.d.ts.map +1 -0
  379. package/build/types/logger/TestLogger.d.ts +14 -0
  380. package/build/types/logger/TestLogger.d.ts.map +1 -0
  381. package/build/types/object/SimpleOsdkProperties.d.ts +1 -0
  382. package/build/types/object/SimpleOsdkProperties.d.ts.map +1 -0
  383. package/build/types/object/convertWireToOsdkObjects/BaseHolder.d.ts +1 -0
  384. package/build/types/object/convertWireToOsdkObjects/BaseHolder.d.ts.map +1 -0
  385. package/build/types/object/convertWireToOsdkObjects.d.ts +8 -1
  386. package/build/types/object/convertWireToOsdkObjects.d.ts.map +1 -1
  387. package/build/types/object/fetchPage.d.ts.map +1 -1
  388. package/build/types/object/object.test.d.ts.map +1 -1
  389. package/build/types/objectSet/ObjectSet.test.d.ts.map +1 -1
  390. package/build/types/observable/ListPayload.d.ts +5 -9
  391. package/build/types/observable/ListPayload.d.ts.map +1 -1
  392. package/build/types/observable/ObjectPayload.d.ts +4 -7
  393. package/build/types/observable/ObjectPayload.d.ts.map +1 -1
  394. package/build/types/observable/ObservableClient.d.ts +27 -11
  395. package/build/types/observable/ObservableClient.d.ts.map +1 -1
  396. package/build/types/observable/internal/ActionApplication.d.ts +2 -2
  397. package/build/types/observable/internal/ActionApplication.d.ts.map +1 -1
  398. package/build/types/observable/internal/BulkObjectLoader.d.ts +8 -0
  399. package/build/types/observable/internal/BulkObjectLoader.d.ts.map +1 -0
  400. package/build/types/observable/internal/BulkObjectLoader.test.d.ts +1 -0
  401. package/build/types/observable/internal/BulkObjectLoader.test.d.ts.map +1 -0
  402. package/build/types/observable/internal/CacheKeys.d.ts +1 -1
  403. package/build/types/observable/internal/CacheKeys.d.ts.map +1 -1
  404. package/build/types/observable/internal/Changes.d.ts +15 -0
  405. package/build/types/observable/internal/Changes.d.ts.map +1 -0
  406. package/build/types/observable/internal/Layer.d.ts +1 -0
  407. package/build/types/observable/internal/Layer.d.ts.map +1 -1
  408. package/build/types/observable/internal/ListQuery.d.ts +59 -14
  409. package/build/types/observable/internal/ListQuery.d.ts.map +1 -1
  410. package/build/types/observable/internal/ObjectQuery.d.ts +5 -6
  411. package/build/types/observable/internal/ObjectQuery.d.ts.map +1 -1
  412. package/build/types/observable/internal/OptimisticJob.d.ts +1 -1
  413. package/build/types/observable/internal/OptimisticJob.d.ts.map +1 -1
  414. package/build/types/observable/internal/OrderByCanonicalizer.d.ts +12 -0
  415. package/build/types/observable/internal/OrderByCanonicalizer.d.ts.map +1 -0
  416. package/build/types/observable/internal/OrderByCanonicalizer.test.d.ts +1 -0
  417. package/build/types/observable/internal/OrderByCanonicalizer.test.d.ts.map +1 -0
  418. package/build/types/observable/internal/Query.d.ts +41 -6
  419. package/build/types/observable/internal/Query.d.ts.map +1 -1
  420. package/build/types/observable/internal/RefCounts.d.ts.map +1 -1
  421. package/build/types/observable/internal/SimpleWhereClause.d.ts +2 -0
  422. package/build/types/observable/internal/SimpleWhereClause.d.ts.map +1 -0
  423. package/build/types/observable/internal/Store.d.ts +20 -44
  424. package/build/types/observable/internal/Store.d.ts.map +1 -1
  425. package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts +2 -1
  426. package/build/types/observable/internal/WhereClauseCanonicalizer.d.ts.map +1 -1
  427. package/build/types/observable/internal/objectMatchesWhereClause.d.ts +4 -2
  428. package/build/types/observable/internal/objectMatchesWhereClause.d.ts.map +1 -1
  429. package/build/types/observable/internal/testUtils.d.ts +39 -10
  430. package/build/types/observable/internal/testUtils.d.ts.map +1 -1
  431. package/build/types/ontology/OntologyProvider.d.ts +1 -1
  432. package/build/types/ontology/OntologyProvider.d.ts.map +1 -1
  433. package/build/types/ontology/loadQueryMetadata.d.ts +1 -1
  434. package/build/types/ontology/loadQueryMetadata.d.ts.map +1 -1
  435. package/build/types/public/internal.d.ts +2 -0
  436. package/build/types/public/internal.d.ts.map +1 -1
  437. package/build/types/public/unstable-do-not-use.d.ts +4 -5
  438. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  439. package/build/types/public-utils/osdkConfig.d.ts +8 -0
  440. package/build/types/public-utils/osdkConfig.d.ts.map +1 -0
  441. package/build/types/public-utils/vite-env.d.d.ts +3 -0
  442. package/build/types/public-utils/vite-env.d.d.ts.map +1 -0
  443. package/build/types/queries/applyQuery.d.ts +2 -2
  444. package/build/types/queries/applyQuery.d.ts.map +1 -1
  445. package/build/types/queries/types.d.ts +1 -1
  446. package/build/types/queries/types.d.ts.map +1 -1
  447. package/build/types/tsserver.d.ts +1 -1
  448. package/build/types/tsserver.d.ts.map +1 -1
  449. package/build/types/util/extractRdpDefinition.d.ts +4 -0
  450. package/build/types/util/extractRdpDefinition.d.ts.map +1 -0
  451. package/build/types/util/extractRdpDefinition.test.d.ts +1 -0
  452. package/build/types/util/extractRdpDefinition.test.d.ts.map +1 -0
  453. package/build/types/util/isObjectSpecifiersObject.d.ts +5 -0
  454. package/build/types/util/isObjectSpecifiersObject.d.ts.map +1 -0
  455. package/build/types/util/isPoint.d.ts +1 -0
  456. package/build/types/util/isPoint.d.ts.map +1 -0
  457. package/build/types/util/objectSpecifierUtils.d.ts +24 -0
  458. package/build/types/util/objectSpecifierUtils.d.ts.map +1 -0
  459. package/build/types/util/objectSpecifierUtils.test.d.ts +1 -0
  460. package/build/types/util/objectSpecifierUtils.test.d.ts.map +1 -0
  461. package/package.json +21 -18
  462. package/build/browser/Logger.js +0 -2
  463. package/build/browser/Logger.js.map +0 -1
  464. package/build/browser/object/createObjectSpecifierFromPrimaryKey.js.map +0 -1
  465. package/build/browser/observable/internal/ChangedObjects.js.map +0 -1
  466. package/build/browser/util/isOsdkBaseObject.js.map +0 -1
  467. package/build/browser/util/isOsdkObject.js.map +0 -1
  468. package/build/cjs/chunk-IU47QMYO.cjs.map +0 -1
  469. package/build/cjs/chunk-JPENHIJB.cjs.map +0 -1
  470. package/build/cjs/chunk-Q7SFCCGT.cjs +0 -11
  471. package/build/cjs/chunk-Q7SFCCGT.cjs.map +0 -1
  472. package/build/cjs/graphql-RGM5SRWV.cjs +0 -10532
  473. package/build/cjs/graphql-RGM5SRWV.cjs.map +0 -1
  474. package/build/esm/Logger.js +0 -2
  475. package/build/esm/Logger.js.map +0 -1
  476. package/build/esm/object/createObjectSpecifierFromPrimaryKey.js.map +0 -1
  477. package/build/esm/observable/internal/ChangedObjects.js.map +0 -1
  478. package/build/esm/util/isOsdkBaseObject.js.map +0 -1
  479. package/build/esm/util/isOsdkObject.js.map +0 -1
  480. package/build/types/Logger.d.ts +0 -17
  481. package/build/types/Logger.d.ts.map +0 -1
  482. package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts +0 -2
  483. package/build/types/object/createObjectSpecifierFromPrimaryKey.d.ts.map +0 -1
  484. package/build/types/observable/internal/ChangedObjects.d.ts +0 -11
  485. package/build/types/observable/internal/ChangedObjects.d.ts.map +0 -1
  486. package/build/types/util/isOsdkBaseObject.d.ts +0 -2
  487. package/build/types/util/isOsdkBaseObject.d.ts.map +0 -1
  488. package/build/types/util/isOsdkObject.d.ts +0 -2
  489. package/build/types/util/isOsdkObject.d.ts.map +0 -1
@@ -1,35 +1,30 @@
1
1
  'use strict';
2
2
 
3
- var chunkJPENHIJB_cjs = require('../chunk-JPENHIJB.cjs');
4
- require('../chunk-Q7SFCCGT.cjs');
3
+ var chunkT4NIFYZS_cjs = require('../chunk-T4NIFYZS.cjs');
4
+ var chunkW5PFESFR_cjs = require('../chunk-W5PFESFR.cjs');
5
5
  var rxjs = require('rxjs');
6
6
  var invariant2 = require('tiny-invariant');
7
7
  var mnemonist = require('mnemonist');
8
8
  var trie = require('@wry/trie');
9
9
  var deepEqual = require('fast-deep-equal');
10
+ var groupBy = require('object.groupby');
11
+ var shared_net_errors = require('@osdk/shared.net.errors');
10
12
 
11
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
14
 
13
15
  var invariant2__default = /*#__PURE__*/_interopDefault(invariant2);
14
16
  var deepEqual__default = /*#__PURE__*/_interopDefault(deepEqual);
17
+ var groupBy__default = /*#__PURE__*/_interopDefault(groupBy);
15
18
 
16
19
  // src/observable/internal/ObservableClientImpl.ts
17
20
  var ObservableClientImpl = class {
18
21
  #store;
19
22
  constructor(store) {
20
23
  this.#store = store;
21
- }
22
- observeObject(apiName, pk, options, subFn) {
23
- return this.#store.observeObject(apiName, pk, options, subFn);
24
- }
25
- observeList(options, subFn) {
26
- return this.#store.observeList(options, subFn);
27
- }
28
- applyAction(action, args, opts) {
29
- return this.#store.applyAction(action, args, opts);
30
- }
31
- canonicalizeWhereClause(where) {
32
- return this.#store.whereCanonicalizer.canonicalize(where);
24
+ this.observeObject = store.observeObject.bind(store);
25
+ this.observeList = store.observeList.bind(store);
26
+ this.applyAction = store.applyAction.bind(store);
27
+ this.canonicalizeWhereClause = store.canonicalizeWhereClause.bind(store);
33
28
  }
34
29
  };
35
30
 
@@ -37,58 +32,60 @@ var ObservableClientImpl = class {
37
32
  process.env.NODE_ENV !== "production" && false;
38
33
  var DEBUG_CACHE_KEYS = process.env.NODE_ENV !== "production" && false;
39
34
 
40
- // ../../node_modules/.pnpm/is-node-process@1.2.0/node_modules/is-node-process/lib/index.mjs
41
- function isNodeProcess() {
42
- if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
43
- return true;
44
- }
45
- if (typeof process !== "undefined") {
46
- const type = process.type;
47
- if (type === "renderer" || type === "worker") {
48
- return false;
49
- }
50
- return !!(process.versions && process.versions.node);
51
- }
52
- return false;
53
- }
54
-
55
- // ../../node_modules/.pnpm/msw@2.7.0_@types+node@22.13.0_typescript@5.5.4/node_modules/msw/lib/core/delay.mjs
56
- var SET_TIMEOUT_MAX_ALLOWED_INT = 2147483647;
57
- var MIN_SERVER_RESPONSE_TIME = 100;
58
- var MAX_SERVER_RESPONSE_TIME = 400;
59
- var NODE_SERVER_RESPONSE_TIME = 5;
60
- function getRealisticResponseTime() {
61
- if (isNodeProcess()) {
62
- return NODE_SERVER_RESPONSE_TIME;
63
- }
64
- return Math.floor(Math.random() * (MAX_SERVER_RESPONSE_TIME - MIN_SERVER_RESPONSE_TIME) + MIN_SERVER_RESPONSE_TIME);
65
- }
66
- async function delay(durationOrMode) {
67
- let delayTime;
68
- if (typeof durationOrMode === "string") {
69
- switch (durationOrMode) {
70
- case "infinite": {
71
- delayTime = SET_TIMEOUT_MAX_ALLOWED_INT;
72
- break;
73
- }
74
- case "real": {
75
- delayTime = getRealisticResponseTime();
76
- break;
77
- }
78
- default: {
79
- throw new Error(`Failed to delay a response: unknown delay mode "${durationOrMode}". Please make sure you provide one of the supported modes ("real", "infinite") or a number.`);
35
+ // ../../node_modules/.pnpm/delay@6.0.0/node_modules/delay/index.js
36
+ var createAbortError = () => {
37
+ const error = new Error("Delay aborted");
38
+ error.name = "AbortError";
39
+ return error;
40
+ };
41
+ var clearMethods = /* @__PURE__ */ new WeakMap();
42
+ function createDelay({
43
+ clearTimeout: defaultClear,
44
+ setTimeout: defaultSet
45
+ } = {}) {
46
+ return (milliseconds, {
47
+ value,
48
+ signal
49
+ } = {}) => {
50
+ if (signal?.aborted) {
51
+ return Promise.reject(createAbortError());
52
+ }
53
+ let timeoutId;
54
+ let settle;
55
+ let rejectFunction;
56
+ const clear = defaultClear ?? clearTimeout;
57
+ const signalListener = () => {
58
+ clear(timeoutId);
59
+ rejectFunction(createAbortError());
60
+ };
61
+ const cleanup = () => {
62
+ if (signal) {
63
+ signal.removeEventListener("abort", signalListener);
80
64
  }
65
+ };
66
+ const delayPromise = new Promise((resolve, reject) => {
67
+ settle = () => {
68
+ cleanup();
69
+ resolve(value);
70
+ };
71
+ rejectFunction = reject;
72
+ timeoutId = (defaultSet ?? setTimeout)(settle, milliseconds);
73
+ });
74
+ if (signal) {
75
+ signal.addEventListener("abort", signalListener, {
76
+ once: true
77
+ });
81
78
  }
82
- } else if (typeof durationOrMode === "undefined") {
83
- delayTime = getRealisticResponseTime();
84
- } else {
85
- if (durationOrMode > SET_TIMEOUT_MAX_ALLOWED_INT) {
86
- throw new Error(`Failed to delay a response: provided delay duration (${durationOrMode}) exceeds the maximum allowed duration for "setTimeout" (${SET_TIMEOUT_MAX_ALLOWED_INT}). This will cause the response to be returned immediately. Please use a number within the allowed range to delay the response by exact duration, or consider the "infinite" delay mode to delay the response indefinitely.`);
87
- }
88
- delayTime = durationOrMode;
89
- }
90
- return new Promise((resolve) => setTimeout(resolve, delayTime));
79
+ clearMethods.set(delayPromise, () => {
80
+ clear(timeoutId);
81
+ timeoutId = null;
82
+ settle();
83
+ });
84
+ return delayPromise;
85
+ };
91
86
  }
87
+ var delay = createDelay();
88
+ var delay_default = delay;
92
89
 
93
90
  // src/observable/internal/CacheKey.ts
94
91
  function DEBUG_ONLY__cacheKeyToString(x) {
@@ -100,28 +97,39 @@ function DEBUG_ONLY__cacheKeyToString(x) {
100
97
  }
101
98
  function DEBUG_ONLY__cacheKeysToString(x) {
102
99
  if (process.env.NODE_ENV !== "production") {
103
- return JSON.stringify(x.map(DEBUG_ONLY__cacheKeyToString), null, 2);
100
+ return "\n - " + x.map(DEBUG_ONLY__cacheKeyToString).join("\n - ");
104
101
  } else {
105
102
  throw new Error("not implemented");
106
103
  }
107
104
  }
108
105
 
109
- // src/observable/internal/ChangedObjects.ts
110
- function createChangedObjects() {
111
- return {
112
- modifiedObjects: new mnemonist.MultiMap(),
113
- addedObjects: new mnemonist.MultiMap(),
114
- addedLists: /* @__PURE__ */ new Set(),
115
- modifiedLists: /* @__PURE__ */ new Set()
106
+ // src/observable/internal/Changes.ts
107
+ var Changes = class {
108
+ modifiedObjects = new mnemonist.MultiMap();
109
+ addedObjects = new mnemonist.MultiMap();
110
+ added = /* @__PURE__ */ new Set();
111
+ modified = /* @__PURE__ */ new Set();
112
+ registerObject = (cacheKey, data, isNew) => {
113
+ this[isNew ? "addedObjects" : "modifiedObjects"].set(data.$apiName, data);
114
+ this[isNew ? "added" : "modified"].add(cacheKey);
116
115
  };
116
+ registerList = (key) => {
117
+ this.modified.add(key);
118
+ };
119
+ isEmpty() {
120
+ return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0;
121
+ }
122
+ };
123
+ function createChangedObjects() {
124
+ return new Changes();
117
125
  }
118
126
  function DEBUG_ONLY__changesToString(changes) {
119
127
  if (process.env.NODE_ENV !== "production") {
120
128
  return JSON.stringify({
121
129
  modifiedObjects: multimapHelper(changes.modifiedObjects),
122
130
  addedObjects: multimapHelper(changes.addedObjects),
123
- addedLists: listHelper(changes.addedLists),
124
- modifiedLists: listHelper(changes.modifiedLists)
131
+ added: listHelper(changes.added),
132
+ modified: listHelper(changes.modified)
125
133
  }, null, 2);
126
134
  } else {
127
135
  throw new Error("not implemented");
@@ -139,7 +147,7 @@ function multimapHelper(multimap) {
139
147
  // src/observable/internal/OptimisticId.ts
140
148
  function createOptimisticId() {
141
149
  if (process.env.NODE_ENV !== "production") {
142
- if (createOptimisticId.counter === undefined) {
150
+ if (createOptimisticId.counter === void 0) {
143
151
  createOptimisticId.counter = 0;
144
152
  }
145
153
  return {
@@ -183,12 +191,12 @@ var OptimisticJob = class {
183
191
  return this;
184
192
  },
185
193
  createObject(type, pk, properties) {
186
- const create = store.client[chunkJPENHIJB_cjs.additionalContext].objectFactory2(store.client[chunkJPENHIJB_cjs.additionalContext], [{
194
+ const create = store.client[chunkW5PFESFR_cjs.additionalContext].objectFactory2(store.client[chunkW5PFESFR_cjs.additionalContext], [{
187
195
  $primaryKey: pk,
188
196
  $apiName: type.apiName,
189
197
  $objectType: type.apiName,
190
198
  ...properties
191
- }], undefined).then((objs) => {
199
+ }], void 0, {}).then((objs) => {
192
200
  return objs[0];
193
201
  });
194
202
  addedObjectPromises.push(create);
@@ -208,7 +216,7 @@ function runOptimisticJob(store, optimisticUpdate) {
208
216
  return () => {
209
217
  return optimisticApplicationDone.then(
210
218
  // we don't want to leak the result
211
- () => undefined
219
+ () => void 0
212
220
  ).finally(() => {
213
221
  store.removeLayer(optimisticId);
214
222
  });
@@ -221,25 +229,30 @@ var ActionApplication = class {
221
229
  constructor(store) {
222
230
  this.store = store;
223
231
  }
224
- applyAction = (action, args, {
232
+ applyAction = async (action, args, {
225
233
  optimisticUpdate
226
234
  } = {}) => {
235
+ const logger = process.env.NODE_ENV !== "production" ? this.store.logger?.child({
236
+ methodName: "applyAction"
237
+ }) : this.store.logger;
227
238
  const removeOptimisticResult = runOptimisticJob(this.store, optimisticUpdate);
228
- return (async () => {
239
+ return await (async () => {
229
240
  try {
230
241
  const actionResults = await this.store.client(action).applyAction(args, {
231
242
  $returnEdits: true
232
243
  });
233
- if (ACTION_DELAY > 0) {
234
- console.log("action done, pausing");
235
- await delay(ACTION_DELAY);
236
- console.log("action done, pausing done");
244
+ if (process.env.NODE_ENV !== "production") {
245
+ if (ACTION_DELAY > 0) {
246
+ logger?.debug("action done, pausing", actionResults);
247
+ await delay_default(ACTION_DELAY);
248
+ logger?.debug("action done, pausing done");
249
+ }
237
250
  }
238
251
  await this.#invalidateActionEditResponse(actionResults);
239
252
  return actionResults;
240
253
  } finally {
241
254
  if (process.env.NODE_ENV !== "production") {
242
- this.store.logger?.debug("optimistic action complete; remove the results");
255
+ logger?.debug("optimistic action complete; remove the results");
243
256
  }
244
257
  await removeOptimisticResult();
245
258
  }
@@ -258,8 +271,20 @@ var ActionApplication = class {
258
271
  typesToInvalidate.add(obj.objectType);
259
272
  }
260
273
  await Promise.all(promisesToWait);
261
- changes = this.#changesFromActionEditResponse(value);
262
- await this.store.maybeRevalidateLists(changes);
274
+ const changes2 = createChangedObjects();
275
+ for (const changeType of ["addedObjects", "modifiedObjects"]) {
276
+ for (const {
277
+ objectType,
278
+ primaryKey
279
+ } of value[changeType] ?? []) {
280
+ const cacheKey = this.store.getCacheKey("object", objectType, primaryKey);
281
+ const obj = this.store.getValue(cacheKey);
282
+ if (obj && obj.value) {
283
+ changes2[changeType].set(objectType, obj.value);
284
+ (changeType === "addedObjects" ? changes2.added : changes2.modified).add(cacheKey);
285
+ }
286
+ }
287
+ }
263
288
  } else {
264
289
  for (const apiName of value.editedObjectTypes) {
265
290
  typesToInvalidate.add(apiName.toString());
@@ -268,21 +293,6 @@ var ActionApplication = class {
268
293
  }
269
294
  return value;
270
295
  };
271
- #changesFromActionEditResponse = (value) => {
272
- const changes = createChangedObjects();
273
- for (const changeType of ["addedObjects", "modifiedObjects"]) {
274
- for (const {
275
- objectType,
276
- primaryKey
277
- } of value[changeType] ?? []) {
278
- const obj = this.store.getObject(objectType, primaryKey);
279
- if (obj) {
280
- changes[changeType].set(objectType, obj);
281
- }
282
- }
283
- }
284
- return changes;
285
- };
286
296
  };
287
297
  var CacheKeys = class {
288
298
  #cacheKeys = new trie.Trie(false, (keys) => {
@@ -301,9 +311,9 @@ var CacheKeys = class {
301
311
  if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) ;
302
312
  return this.#cacheKeys.lookupArray(["object", apiName, pk]);
303
313
  });
304
- this.#registerCacheKeyFactory("list", (apiName, where, orderBy) => {
314
+ this.#registerCacheKeyFactory("list", (type, apiName, where, orderBy) => {
305
315
  if (process.env.NODE_ENV !== "production" && DEBUG_CACHE_KEYS) ;
306
- return this.#cacheKeys.lookupArray(["list", apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]);
316
+ return this.#cacheKeys.lookupArray(["list", type, apiName, whereCanonicalizer.canonicalize(where), orderByCanonicalizer.canonicalize(orderBy)]);
307
317
  });
308
318
  }
309
319
  #registerCacheKeyFactory(type, factory) {
@@ -311,7 +321,7 @@ var CacheKeys = class {
311
321
  }
312
322
  get(type, ...args) {
313
323
  const factory = this.#cacheKeyFactories.get(type);
314
- !factory ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `no cache key factory for type "${type}"`) : invariant2__default.default(false) : undefined;
324
+ !factory ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `no cache key factory for type "${type}"`) : invariant2__default.default(false) : void 0;
315
325
  return factory(...args);
316
326
  }
317
327
  remove(cacheKey) {
@@ -343,7 +353,7 @@ var WeakMapWithEntries = class {
343
353
  }, 1e3);
344
354
  }
345
355
  #clean() {
346
- this.#list = this.#list.filter((ref) => ref.deref() !== undefined);
356
+ this.#list = this.#list.filter((ref) => ref.deref() !== void 0);
347
357
  }
348
358
  // functions for WeakMap
349
359
  delete(key) {
@@ -383,7 +393,7 @@ var WeakMapWithEntries = class {
383
393
  function* iter() {
384
394
  for (const ref of self.#list) {
385
395
  const key = ref.deref();
386
- if (key !== undefined) {
396
+ if (key !== void 0) {
387
397
  yield [key, self.#map.get(key)];
388
398
  }
389
399
  }
@@ -398,7 +408,7 @@ var WeakMapWithEntries = class {
398
408
  function* iter() {
399
409
  for (const ref of self.#list) {
400
410
  const key = ref.deref();
401
- if (key !== undefined) {
411
+ if (key !== void 0) {
402
412
  yield key;
403
413
  }
404
414
  }
@@ -413,9 +423,9 @@ var WeakMapWithEntries = class {
413
423
  function* iter() {
414
424
  for (const ref of self.#list) {
415
425
  const key = ref.deref();
416
- if (key !== undefined) {
426
+ if (key !== void 0) {
417
427
  const value = self.#map.get(key);
418
- if (value !== undefined) {
428
+ if (value !== void 0) {
419
429
  yield value;
420
430
  }
421
431
  }
@@ -456,6 +466,9 @@ var Layer = class _Layer {
456
466
  entries() {
457
467
  return this.#cache.entries();
458
468
  }
469
+ keys() {
470
+ return this.#cache.keys();
471
+ }
459
472
  get(cacheKey) {
460
473
  return this.#cache.get(cacheKey) ?? this.#parent?.get(cacheKey);
461
474
  }
@@ -474,8 +487,8 @@ var Entry = class {
474
487
  function is$and(whereClause) {
475
488
  if (process.env.NODE_ENV !== "production") {
476
489
  if ("$and" in whereClause) {
477
- !Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $and to be an array") : invariant2__default.default(false) : undefined;
478
- !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $and to be present") : invariant2__default.default(false) : undefined;
490
+ !Array.isArray(whereClause.$and) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $and to be an array") : invariant2__default.default(false) : void 0;
491
+ !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $and to be present") : invariant2__default.default(false) : void 0;
479
492
  }
480
493
  }
481
494
  return "$and" in whereClause;
@@ -483,8 +496,8 @@ function is$and(whereClause) {
483
496
  function is$or(whereClause) {
484
497
  if (process.env.NODE_ENV !== "production") {
485
498
  if ("$or" in whereClause) {
486
- !Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $or to be an array") : invariant2__default.default(false) : undefined;
487
- !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $or to be present") : invariant2__default.default(false) : undefined;
499
+ !Array.isArray(whereClause.$or) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $or to be an array") : invariant2__default.default(false) : void 0;
500
+ !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $or to be present") : invariant2__default.default(false) : void 0;
488
501
  }
489
502
  }
490
503
  return "$or" in whereClause;
@@ -492,7 +505,7 @@ function is$or(whereClause) {
492
505
  function is$not(whereClause) {
493
506
  if (process.env.NODE_ENV !== "production") {
494
507
  if ("$not" in whereClause) {
495
- !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $not to be present") : invariant2__default.default(false) : undefined;
508
+ !(Object.keys(whereClause).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $not to be present") : invariant2__default.default(false) : void 0;
496
509
  }
497
510
  }
498
511
  return "$not" in whereClause;
@@ -557,6 +570,90 @@ function objectSortaMatchesWhereClause(o, whereClause, strict) {
557
570
  });
558
571
  }
559
572
 
573
+ // ../../node_modules/.pnpm/p-defer@4.0.1/node_modules/p-defer/index.js
574
+ function pDefer() {
575
+ const deferred = {};
576
+ deferred.promise = new Promise((resolve, reject) => {
577
+ deferred.resolve = resolve;
578
+ deferred.reject = reject;
579
+ });
580
+ return deferred;
581
+ }
582
+
583
+ // src/observable/internal/BulkObjectLoader.ts
584
+ var weakCache = new mnemonist.DefaultWeakMap((c) => new BulkObjectLoader(c));
585
+ function getBulkObjectLoader(client) {
586
+ return weakCache.get(client);
587
+ }
588
+ var BulkObjectLoader = class {
589
+ #client;
590
+ #m = new mnemonist.DefaultMap(() => ({
591
+ data: [],
592
+ timer: void 0
593
+ }));
594
+ #logger;
595
+ #maxWait;
596
+ #maxEntries;
597
+ constructor(client, maxWait = 25, maxEntries = 100) {
598
+ this.#client = client;
599
+ this.#logger = client[chunkW5PFESFR_cjs.additionalContext].logger;
600
+ this.#maxWait = maxWait;
601
+ this.#maxEntries = maxEntries;
602
+ }
603
+ fetch(apiName, primaryKey) {
604
+ const deferred = pDefer();
605
+ const entry = this.#m.get(apiName);
606
+ entry.data.push({
607
+ primaryKey,
608
+ deferred
609
+ });
610
+ if (!entry.timer) {
611
+ entry.timer = setTimeout(() => {
612
+ this.#loadObjects(apiName, entry.data);
613
+ }, this.#maxWait);
614
+ }
615
+ if (entry.data.length >= this.#maxEntries) {
616
+ clearTimeout(entry.timer);
617
+ this.#loadObjects(apiName, entry.data);
618
+ }
619
+ return deferred.promise;
620
+ }
621
+ #loadObjects(apiName, arr) {
622
+ this.#m.delete(apiName);
623
+ this.#reallyLoadObjects(apiName, arr).catch((e) => {
624
+ this.#logger?.error("Unhandled exception", e);
625
+ });
626
+ }
627
+ async #reallyLoadObjects(apiName, arr) {
628
+ const miniDef = {
629
+ type: "object",
630
+ apiName
631
+ };
632
+ const objMetadata = await this.#client.fetchMetadata(miniDef);
633
+ const pks = arr.map((x) => x.primaryKey);
634
+ const {
635
+ data
636
+ } = await this.#client(miniDef).where({
637
+ [objMetadata.primaryKeyApiName]: {
638
+ $in: pks
639
+ }
640
+ }).fetchPage({
641
+ $pageSize: pks.length
642
+ });
643
+ for (const {
644
+ primaryKey,
645
+ deferred
646
+ } of arr) {
647
+ const object = data.find((x) => x.$primaryKey === primaryKey);
648
+ if (object) {
649
+ deferred.resolve(object);
650
+ } else {
651
+ deferred.reject(new shared_net_errors.PalantirApiError("Object not found"));
652
+ }
653
+ }
654
+ }
655
+ };
656
+
560
657
  // src/observable/internal/Query.ts
561
658
  var Query = class {
562
659
  retainCount = 0;
@@ -569,7 +666,7 @@ var Query = class {
569
666
  this.cacheKey = cacheKey;
570
667
  this.store = store;
571
668
  this.#subject = observable;
572
- this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkJPENHIJB_cjs.additionalContext].logger : store.client[chunkJPENHIJB_cjs.additionalContext].logger?.child({}, {
669
+ this.logger = logger ?? (process.env.NODE_ENV === "production" ? store.client[chunkW5PFESFR_cjs.additionalContext].logger : store.client[chunkW5PFESFR_cjs.additionalContext].logger?.child({}, {
573
670
  msgPrefix: process.env.NODE_ENV !== "production" ? `Query<${cacheKey.type}, ${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>` : "Query"
574
671
  }));
575
672
  }
@@ -578,61 +675,66 @@ var Query = class {
578
675
  this.#subscription = this.#connectable.connect();
579
676
  return this.#connectable.subscribe(observer);
580
677
  }
581
- revalidate(force) {
582
- if (process.env.NODE_ENV !== "production") {
583
- this.logger?.info({
584
- methodName: "revalidate"
585
- });
586
- }
678
+ /**
679
+ * Causes the query to revalidate. This will cause the query to fetch
680
+ * the latest data from the server and update the store if it is deemed
681
+ * "stale" or if `force` is true.
682
+ *
683
+ * @param force
684
+ * @returns
685
+ */
686
+ async revalidate(force) {
687
+ const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
688
+ methodName: "revalidate"
689
+ }) : this.logger;
587
690
  if (force) {
588
691
  this.abortController?.abort();
589
692
  }
590
693
  if (this.pendingFetch) {
591
- return this.pendingFetch;
694
+ if (process.env.NODE_ENV !== "production") {
695
+ logger?.info("Fetch is already pending, using it");
696
+ }
697
+ await this.pendingFetch;
698
+ return;
592
699
  }
593
700
  if ((this.options.dedupeInterval ?? 0) > 0 && this.lastFetchStarted != null && Date.now() - this.lastFetchStarted < (this.options.dedupeInterval ?? 0)) {
594
701
  if (process.env.NODE_ENV !== "production") {
595
- this.logger?.trace({
596
- methodName: "revalidate"
597
- }, "DEDUPE");
702
+ logger?.debug("Within dupeInterval, aborting revalidate");
598
703
  }
599
704
  return Promise.resolve();
600
705
  }
706
+ if (process.env.NODE_ENV !== "production") {
707
+ logger?.debug("Starting actual revalidate");
708
+ }
601
709
  this.store.batch({}, (batch) => {
602
710
  this.setStatus("loading", batch);
603
711
  });
604
712
  this._preFetch();
605
713
  this.lastFetchStarted = Date.now();
606
714
  if (process.env.NODE_ENV !== "production") {
607
- this.logger?.trace({
608
- methodName: "revalidate"
609
- }, "calling _fetch()");
610
- }
611
- this.pendingFetch = this._fetch().catch((e) => {
612
- this.logger?.error({
613
- methodName: "revalidate"
614
- }, "_fetch() FAILED", e);
615
- throw e;
616
- }).finally(() => {
617
- this.logger?.info({
618
- methodName: "revalidate"
619
- }, "finally _fetch()");
620
- this.pendingFetch = undefined;
621
- });
622
- if (process.env.NODE_ENV !== "production") {
623
- this.logger?.info({
624
- methodName: "revalidate"
625
- }, "Returning");
715
+ logger?.debug("calling _fetchAndStore()");
626
716
  }
627
- return this.pendingFetch;
717
+ this.pendingFetch = this._fetchAndStore().finally(() => {
718
+ logger?.info("finally _fetchAndStore()");
719
+ this.pendingFetch = void 0;
720
+ });
721
+ await this.pendingFetch;
722
+ return;
628
723
  }
629
724
  _preFetch() {
630
725
  }
726
+ /**
727
+ * Sets the status of the query in the store (but does not store that in `changes`).
728
+ *
729
+ * @param status
730
+ * @param batch
731
+ * @returns
732
+ */
631
733
  setStatus(status, batch) {
632
734
  if (process.env.NODE_ENV !== "production") {
633
- this.logger?.trace({
735
+ this.logger?.child({
634
736
  methodName: "setStatus"
635
- }, status);
737
+ }).debug(status);
636
738
  }
637
739
  const existing = batch.read(this.cacheKey);
638
740
  if (existing?.status === status) return;
@@ -645,31 +747,205 @@ var Query = class {
645
747
  this.#subscription?.unsubscribe();
646
748
  this._dispose();
647
749
  }
750
+ /**
751
+ * Per query type dispose functionality
752
+ */
648
753
  _dispose() {
649
754
  }
755
+ /**
756
+ * The purpose of this method is to provide a way for others to write
757
+ * directly into the store for this query.
758
+ *
759
+ * @param data
760
+ * @param status
761
+ * @param batch
762
+ */
763
+ /**
764
+ * @param changes
765
+ * @param optimisticId
766
+ * @returns If revalidation is needed, a promise that resolves after the
767
+ * revalidation is complete. Otherwise, undefined.
768
+ */
650
769
  };
651
770
 
771
+ // src/observable/internal/ObjectQuery.ts
772
+ var ObjectQuery = class extends Query {
773
+ #apiName;
774
+ #pk;
775
+ constructor(store, subject, type, pk, cacheKey, opts) {
776
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkW5PFESFR_cjs.additionalContext].logger?.child({}, {
777
+ msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
778
+ }) : void 0);
779
+ this.#apiName = type;
780
+ this.#pk = pk;
781
+ }
782
+ _createConnectable(subject) {
783
+ return rxjs.connectable(subject.pipe(rxjs.map((x) => {
784
+ return {
785
+ status: x.status,
786
+ object: x.value,
787
+ lastUpdated: x.lastUpdated,
788
+ isOptimistic: x.isOptimistic
789
+ };
790
+ })), {
791
+ connector: () => new rxjs.BehaviorSubject({
792
+ status: "init",
793
+ object: void 0,
794
+ lastUpdated: 0,
795
+ isOptimistic: false
796
+ })
797
+ });
798
+ }
799
+ async _fetchAndStore() {
800
+ if (process.env.NODE_ENV !== "production") {
801
+ this.logger?.child({
802
+ methodName: "_fetchAndStore"
803
+ }).info("calling _fetchAndStore");
804
+ }
805
+ const obj = await getBulkObjectLoader(this.store.client).fetch(this.#apiName, this.#pk);
806
+ this.store.batch({}, (batch) => {
807
+ this.writeToStore(obj, "loaded", batch);
808
+ });
809
+ }
810
+ writeToStore(data, status, batch) {
811
+ const entry = batch.read(this.cacheKey);
812
+ if (entry && deepEqual__default.default(data, entry.value)) {
813
+ if (process.env.NODE_ENV !== "production") {
814
+ this.logger?.child({
815
+ methodName: "writeToStore"
816
+ }).debug(`Object was deep equal, just setting status`);
817
+ }
818
+ return batch.write(this.cacheKey, entry.value, status);
819
+ }
820
+ if (process.env.NODE_ENV !== "production") {
821
+ this.logger?.child({
822
+ methodName: "writeToStore"
823
+ }).debug(JSON.stringify({
824
+ status
825
+ }), data);
826
+ }
827
+ const ret = batch.write(this.cacheKey, data, status);
828
+ batch.changes.registerObject(
829
+ this.cacheKey,
830
+ data,
831
+ /* isNew */
832
+ !entry
833
+ );
834
+ return ret;
835
+ }
836
+ };
837
+ function storeOsdkInstances(store, values, batch) {
838
+ return values.map((v) => {
839
+ return store.getObjectQuery(v.$apiName, v.$primaryKey).writeToStore(v, "loaded", batch).cacheKey;
840
+ });
841
+ }
842
+
652
843
  // src/observable/internal/ListQuery.ts
653
- var ListQuery = class extends Query {
844
+ var API_NAME_IDX = 1;
845
+ var BaseListQuery = class extends Query {
846
+ //
847
+ // Per list type implementations
848
+ //
849
+ //
850
+ // Shared Implementations
851
+ //
852
+ /**
853
+ * Only intended to be "protected" and used by subclasses but exposed for
854
+ * testing.
855
+ *
856
+ * @param objectCacheKeys
857
+ * @param append
858
+ * @param status
859
+ * @param batch
860
+ * @returns
861
+ */
862
+ _updateList(objectCacheKeys, append, status, batch) {
863
+ if (process.env.NODE_ENV !== "production") {
864
+ const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
865
+ methodName: "updateList"
866
+ }) : this.logger;
867
+ logger?.debug(`{status: ${status}}`, JSON.stringify(objectCacheKeys, null, 2));
868
+ }
869
+ objectCacheKeys = this.#retainReleaseAppend(batch, append, objectCacheKeys);
870
+ objectCacheKeys = this._sortCacheKeys(objectCacheKeys, batch);
871
+ objectCacheKeys = removeDuplicates(objectCacheKeys, batch);
872
+ return this.writeToStore({
873
+ data: objectCacheKeys
874
+ }, status, batch);
875
+ }
876
+ writeToStore(data, status, batch) {
877
+ const entry = batch.read(this.cacheKey);
878
+ if (entry && deepEqual__default.default(data, entry.value)) {
879
+ if (process.env.NODE_ENV !== "production") {
880
+ this.logger?.child({
881
+ methodName: "writeToStore"
882
+ }).debug(`Object was deep equal, just setting status`);
883
+ }
884
+ return batch.write(this.cacheKey, entry.value, status);
885
+ }
886
+ if (process.env.NODE_ENV !== "production") {
887
+ this.logger?.child({
888
+ methodName: "writeToStore"
889
+ }).debug(`{status: ${status}},`, DEBUG_ONLY__cacheKeysToString(data.data));
890
+ }
891
+ const ret = batch.write(this.cacheKey, data, status);
892
+ batch.changes.registerList(this.cacheKey);
893
+ return ret;
894
+ }
895
+ #retainReleaseAppend(batch, append, objectCacheKeys) {
896
+ const existingList = batch.read(this.cacheKey);
897
+ if (!batch.optimisticWrite) {
898
+ if (!append) {
899
+ for (const objectCacheKey of existingList?.value?.data ?? []) {
900
+ this.store.release(objectCacheKey);
901
+ }
902
+ }
903
+ for (const objectCacheKey of objectCacheKeys) {
904
+ this.store.retain(objectCacheKey);
905
+ }
906
+ }
907
+ if (append) {
908
+ objectCacheKeys = [...existingList?.value?.data ?? [], ...objectCacheKeys];
909
+ }
910
+ return objectCacheKeys;
911
+ }
912
+ _dispose() {
913
+ console.log("DISPOSE LIST QUERY");
914
+ this.store.batch({}, (batch) => {
915
+ const entry = batch.read(this.cacheKey);
916
+ if (entry) {
917
+ for (const objectCacheKey of entry.value?.data ?? []) {
918
+ this.store.release(objectCacheKey);
919
+ }
920
+ }
921
+ });
922
+ }
923
+ };
924
+ var ListQuery = class extends BaseListQuery {
654
925
  // pageSize?: number; // this is the internal page size. we need to track this properly
655
- #client;
656
926
  #type;
927
+ #apiName;
657
928
  #whereClause;
658
929
  // this represents the minimum number of results we need to load if we revalidate
659
930
  #minNumResults = 0;
660
931
  #nextPageToken;
661
932
  #pendingPageFetch;
662
- #toRelease = /* @__PURE__ */ new Set();
663
933
  #orderBy;
664
- constructor(store, subject, objectType, whereClause, orderBy, cacheKey, opts) {
665
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkJPENHIJB_cjs.additionalContext].logger?.child({}, {
934
+ #objectSet;
935
+ #sortFns;
936
+ constructor(store, subject, apiType, apiName, whereClause, orderBy, cacheKey, opts) {
937
+ super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkW5PFESFR_cjs.additionalContext].logger?.child({}, {
666
938
  msgPrefix: `ListQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
667
- }) : undefined);
668
- this.#client = store.client;
669
- this.#type = objectType;
939
+ }) : void 0);
940
+ this.#type = apiType;
941
+ this.#apiName = apiName;
670
942
  this.#whereClause = whereClause;
671
943
  this.#orderBy = orderBy;
672
- rxjs.observeOn(rxjs.asyncScheduler);
944
+ this.#objectSet = store.client({
945
+ type: this.#type,
946
+ apiName: this.#apiName
947
+ }).where(this.#whereClause);
948
+ this.#sortFns = createOrderBySortFns(this.#orderBy);
673
949
  }
674
950
  get canonicalWhere() {
675
951
  return this.#whereClause;
@@ -694,19 +970,20 @@ var ListQuery = class extends Query {
694
970
  });
695
971
  }
696
972
  _preFetch() {
697
- this.#nextPageToken = undefined;
973
+ this.#nextPageToken = void 0;
698
974
  }
699
- async _fetch() {
700
- const objectSet = this.#client({
701
- type: "object",
702
- apiName: this.#type
703
- }).where(this.#whereClause);
975
+ async _fetchAndStore() {
976
+ if (process.env.NODE_ENV !== "production") {
977
+ this.logger?.child({
978
+ methodName: "_fetchAndStore"
979
+ }).info("fetching pages");
980
+ }
704
981
  while (true) {
705
- const entry = await this.#fetchPageAndUpdate(objectSet, "loading", this.abortController?.signal);
982
+ const entry = await this.#fetchPageAndUpdate(this.#objectSet, "loading", this.abortController?.signal);
706
983
  if (!entry) {
707
984
  return;
708
985
  }
709
- !entry.value?.data ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false) : invariant2__default.default(false) : undefined;
986
+ !entry.value?.data ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false) : invariant2__default.default(false) : void 0;
710
987
  const count = entry.value.data.length;
711
988
  if (count > this.#minNumResults || this.#nextPageToken == null) {
712
989
  break;
@@ -734,40 +1011,75 @@ var ListQuery = class extends Query {
734
1011
  this.store.batch({}, (batch) => {
735
1012
  this.setStatus("loading", batch);
736
1013
  });
737
- const objectSet = this.#client({
738
- type: "object",
739
- apiName: this.#type
740
- }).where(this.#whereClause);
741
- this.pendingFetch = this.#fetchPageAndUpdate(objectSet, "loaded", this.abortController?.signal).finally(() => {
742
- this.#pendingPageFetch = undefined;
1014
+ this.pendingFetch = this.#fetchPageAndUpdate(this.#objectSet, "loaded", this.abortController?.signal).finally(() => {
1015
+ this.#pendingPageFetch = void 0;
743
1016
  });
744
1017
  return this.pendingFetch;
745
1018
  };
746
1019
  async #fetchPageAndUpdate(objectSet, status, signal) {
747
1020
  const append = this.#nextPageToken != null;
748
- const {
749
- data,
750
- nextPageToken
751
- } = await objectSet.fetchPage({
752
- $nextPageToken: this.#nextPageToken,
753
- $pageSize: this.options.pageSize,
754
- // For now this keeps the shared test code from falling apart
755
- // but shouldn't be needed ideally
756
- ...Object.keys(this.#orderBy).length > 0 ? {
757
- $orderBy: this.#orderBy
758
- } : {}
1021
+ try {
1022
+ let {
1023
+ data,
1024
+ nextPageToken
1025
+ } = await objectSet.fetchPage({
1026
+ $nextPageToken: this.#nextPageToken,
1027
+ $pageSize: this.options.pageSize,
1028
+ // For now this keeps the shared test code from falling apart
1029
+ // but shouldn't be needed ideally
1030
+ ...Object.keys(this.#orderBy).length > 0 ? {
1031
+ $orderBy: this.#orderBy
1032
+ } : {}
1033
+ });
1034
+ if (signal?.aborted) {
1035
+ return;
1036
+ }
1037
+ this.#nextPageToken = nextPageToken;
1038
+ if (this.#type === "interface") {
1039
+ data = await reloadDataAsFullObjects(this.store.client, data);
1040
+ }
1041
+ const {
1042
+ retVal
1043
+ } = this.store.batch({}, (batch) => {
1044
+ return this._updateList(storeOsdkInstances(this.store, data, batch), append, nextPageToken ? status : "loaded", batch);
1045
+ });
1046
+ return retVal;
1047
+ } catch (e) {
1048
+ this.logger?.error("error", e);
1049
+ this.store.getSubject(this.cacheKey).error(e);
1050
+ }
1051
+ }
1052
+ /**
1053
+ * Will revalidate the list if its query is affected by invalidating the
1054
+ * apiName of the object type passed in.
1055
+ *
1056
+ * @param apiName to invalidate
1057
+ * @returns
1058
+ */
1059
+ revalidateObjectType = async (apiName) => {
1060
+ if (this.#type === "object") {
1061
+ if (this.#apiName === apiName) {
1062
+ await this.revalidate(
1063
+ /* force */
1064
+ true
1065
+ );
1066
+ return;
1067
+ } else {
1068
+ return;
1069
+ }
1070
+ }
1071
+ const objectMetadata = await this.store.client.fetchMetadata({
1072
+ type: "object",
1073
+ apiName
759
1074
  });
760
- if (signal?.aborted) {
1075
+ if (this.#apiName in objectMetadata.interfaceMap) {
1076
+ await this.revalidate(
1077
+ /* force */
1078
+ true
1079
+ );
761
1080
  return;
762
1081
  }
763
- this.#nextPageToken = nextPageToken;
764
- const {
765
- retVal
766
- } = this.store.batch({}, (batch) => {
767
- return this.updateList(this.store.updateObjects(data, batch), append, nextPageToken ? status : "loaded", batch);
768
- });
769
- return retVal;
770
- }
1082
+ };
771
1083
  /**
772
1084
  * Note: This method is not async because I want it to return right after it
773
1085
  * finishes the synchronous updates. The promise that is returned
@@ -779,50 +1091,25 @@ var ListQuery = class extends Query {
779
1091
  */
780
1092
  maybeUpdateAndRevalidate = (changes, optimisticId) => {
781
1093
  if (process.env.NODE_ENV !== "production") {
782
- this.logger?.info({
783
- methodName: "#maybeMaybe"
784
- }, DEBUG_ONLY__changesToString(changes));
1094
+ this.logger?.child({
1095
+ methodName: "maybeUpdateAndRevalidate"
1096
+ }).debug(DEBUG_ONLY__changesToString(changes));
785
1097
  }
786
- if (changes.modifiedLists.has(this.cacheKey)) return;
1098
+ if (changes.modified.has(this.cacheKey)) return;
1099
+ changes.modified.add(this.cacheKey);
787
1100
  try {
788
- const relevantObjects = {
789
- added: {
790
- all: changes.addedObjects.get(this.cacheKey.otherKeys[0]) ?? [],
791
- strictMatches: /* @__PURE__ */ new Set(),
792
- sortaMatches: /* @__PURE__ */ new Set()
793
- },
794
- modified: {
795
- all: changes.modifiedObjects.get(this.cacheKey.otherKeys[0]) ?? [],
796
- strictMatches: /* @__PURE__ */ new Set(),
797
- sortaMatches: /* @__PURE__ */ new Set()
798
- }
799
- };
1101
+ const relevantObjects = this._extractRelevantObjects(changes);
800
1102
  if (relevantObjects.added.all.length === 0 && relevantObjects.modified.all.length === 0) {
801
1103
  return;
802
1104
  }
803
- for (const group of Object.values(relevantObjects)) {
804
- for (const obj of group.all ?? []) {
805
- const strictMatch = objectSortaMatchesWhereClause(obj, this.#whereClause, true);
806
- if (strictMatch) {
807
- group.strictMatches.add(obj);
808
- } else {
809
- const sortaMatch = objectSortaMatchesWhereClause(obj, this.#whereClause, false);
810
- if (sortaMatch) {
811
- group.sortaMatches.add(obj);
812
- }
813
- }
814
- }
815
- }
816
1105
  const status = optimisticId || relevantObjects.added.sortaMatches.size > 0 || relevantObjects.modified.sortaMatches.size > 0 ? "loading" : "loaded";
817
- changes.modifiedLists.add(this.cacheKey);
818
1106
  const newList = [];
819
1107
  let needsRevalidation = false;
820
1108
  this.store.batch({
821
1109
  optimisticId,
822
1110
  changes
823
1111
  }, (batch) => {
824
- const curValue = batch.read(this.cacheKey);
825
- const existingList = new Set(curValue?.value?.data);
1112
+ const existingList = new Set(batch.read(this.cacheKey)?.value?.data);
826
1113
  const toAdd = new Set(
827
1114
  // easy case. objects are new to the cache and they match this filter
828
1115
  relevantObjects.added.strictMatches
@@ -830,15 +1117,15 @@ var ListQuery = class extends Query {
830
1117
  const toRemove = /* @__PURE__ */ new Set();
831
1118
  for (const obj of relevantObjects.modified.all) {
832
1119
  if (relevantObjects.modified.strictMatches.has(obj)) {
833
- const existingObjectCacheKey = this.store.getCacheKey("object", obj.$apiName, obj.$primaryKey);
834
- if (!existingList.has(existingObjectCacheKey)) {
1120
+ const objectCacheKey = this.store.getCacheKey("object", obj.$objectType, obj.$primaryKey);
1121
+ if (!existingList.has(objectCacheKey)) {
835
1122
  toAdd.add(obj);
836
1123
  }
837
1124
  continue;
838
1125
  } else if (batch.optimisticWrite) {
839
1126
  continue;
840
1127
  } else {
841
- const existingObjectCacheKey = this.store.getCacheKey("object", obj.$apiName, obj.$primaryKey);
1128
+ const existingObjectCacheKey = this.store.getCacheKey("object", obj.$objectType, obj.$primaryKey);
842
1129
  toRemove.add(existingObjectCacheKey);
843
1130
  if (relevantObjects.modified.sortaMatches.has(obj)) {
844
1131
  needsRevalidation = true;
@@ -850,9 +1137,9 @@ var ListQuery = class extends Query {
850
1137
  newList.push(key);
851
1138
  }
852
1139
  for (const obj of toAdd) {
853
- newList.push(this.store.getCacheKey("object", obj.$apiName, obj.$primaryKey));
1140
+ newList.push(this.store.getCacheKey("object", obj.$objectType, obj.$primaryKey));
854
1141
  }
855
- this.updateList(
1142
+ this._updateList(
856
1143
  newList,
857
1144
  /* append */
858
1145
  false,
@@ -861,69 +1148,73 @@ var ListQuery = class extends Query {
861
1148
  );
862
1149
  });
863
1150
  if (needsRevalidation) {
864
- changes.modifiedLists.add(this.cacheKey);
865
- return this.revalidate(true).then(() => void 0);
1151
+ return this.revalidate(true);
866
1152
  }
867
1153
  return void 0;
868
1154
  } finally {
869
1155
  if (process.env.NODE_ENV !== "production") {
870
- this.logger?.trace({
871
- methodName: "#maybeMaybe"
872
- }, "in finally");
1156
+ this.logger?.child({
1157
+ methodName: "maybeUpdateAndRevalidate"
1158
+ }).debug("in finally");
873
1159
  }
874
1160
  }
875
1161
  };
876
- updateList(objectCacheKeys, append, status, batch) {
877
- if (process.env.NODE_ENV !== "production") {
878
- this.logger?.trace({
879
- methodName: "updateList"
880
- }, `{status: ${status}}`, JSON.stringify(objectCacheKeys, null, 2));
881
- }
882
- const existingList = batch.read(this.cacheKey);
883
- if (!batch.optimisticWrite) {
884
- if (!append) {
885
- for (const objectCacheKey of existingList?.value?.data ?? []) {
886
- this.store.release(objectCacheKey);
887
- this.#toRelease.delete(objectCacheKey);
1162
+ _extractRelevantObjects(changes) {
1163
+ const relevantObjects = this.#type === "object" ? this.#extractRelevantObjectsForTypeObject(changes) : this.#extractRelevantObjectsForTypeInterface(changes);
1164
+ for (const group of Object.values(relevantObjects)) {
1165
+ for (const obj of group.all ?? []) {
1166
+ const strictMatch = objectSortaMatchesWhereClause(obj, this.#whereClause, true);
1167
+ if (strictMatch) {
1168
+ group.strictMatches.add(obj);
1169
+ } else {
1170
+ const sortaMatch = objectSortaMatchesWhereClause(obj, this.#whereClause, false);
1171
+ if (sortaMatch) {
1172
+ group.sortaMatches.add(obj);
1173
+ }
888
1174
  }
889
1175
  }
890
- for (const objectCacheKey of objectCacheKeys) {
891
- this.#toRelease.add(objectCacheKey);
892
- this.store.retain(objectCacheKey);
893
- }
894
1176
  }
895
- if (append) {
896
- objectCacheKeys = [...existingList?.value?.data ?? [], ...objectCacheKeys];
897
- }
898
- if (Object.keys(this.#orderBy).length > 0) {
899
- if (process.env.NODE_ENV !== "production") {
900
- this.logger?.info({
901
- methodName: "updateList"
902
- }, "Sorting entries");
903
- this.logger?.trace({
904
- methodName: "updateList"
905
- }, DEBUG_ONLY__cacheKeysToString(objectCacheKeys));
1177
+ return relevantObjects;
1178
+ }
1179
+ #extractRelevantObjectsForTypeInterface(changes) {
1180
+ const added = Array.from(changes.addedObjects).filter(([, object]) => {
1181
+ return this.#apiName in object[chunkT4NIFYZS_cjs.ObjectDefRef].interfaceMap;
1182
+ }).map(([, object]) => object.$as(this.#apiName));
1183
+ const modified = Array.from(changes.modifiedObjects).filter(([, object]) => {
1184
+ return this.#apiName in object[chunkT4NIFYZS_cjs.ObjectDefRef].interfaceMap;
1185
+ }).map(([, object]) => object.$as(this.#apiName));
1186
+ return {
1187
+ added: {
1188
+ all: added,
1189
+ strictMatches: /* @__PURE__ */ new Set(),
1190
+ sortaMatches: /* @__PURE__ */ new Set()
1191
+ },
1192
+ modified: {
1193
+ all: modified,
1194
+ strictMatches: /* @__PURE__ */ new Set(),
1195
+ sortaMatches: /* @__PURE__ */ new Set()
906
1196
  }
907
- const sortFns = Object.entries(this.#orderBy).map(([key, order]) => {
908
- return (a, b) => {
909
- const aValue = a?.[key];
910
- const bValue = b?.[key];
911
- if (aValue == null && bValue == null) {
912
- return 0;
913
- }
914
- if (aValue == null) {
915
- return 1;
916
- }
917
- if (bValue == null) {
918
- return -1;
919
- }
920
- const m = order === "asc" ? -1 : 1;
921
- return aValue < bValue ? m : aValue > bValue ? -m : 0;
922
- };
923
- });
1197
+ };
1198
+ }
1199
+ #extractRelevantObjectsForTypeObject(changes) {
1200
+ return {
1201
+ added: {
1202
+ all: changes.addedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
1203
+ strictMatches: /* @__PURE__ */ new Set(),
1204
+ sortaMatches: /* @__PURE__ */ new Set()
1205
+ },
1206
+ modified: {
1207
+ all: changes.modifiedObjects.get(this.cacheKey.otherKeys[API_NAME_IDX]) ?? [],
1208
+ strictMatches: /* @__PURE__ */ new Set(),
1209
+ sortaMatches: /* @__PURE__ */ new Set()
1210
+ }
1211
+ };
1212
+ }
1213
+ _sortCacheKeys(objectCacheKeys, batch) {
1214
+ if (Object.keys(this.#orderBy).length > 0) {
924
1215
  objectCacheKeys = objectCacheKeys.sort((a, b) => {
925
- for (const sortFn of sortFns) {
926
- const ret = sortFn(batch.read(a)?.value, batch.read(b)?.value);
1216
+ for (const sortFn of this.#sortFns) {
1217
+ const ret = sortFn(batch.read(a)?.value?.$as(this.#apiName), batch.read(b)?.value?.$as(this.#apiName));
927
1218
  if (ret !== 0) {
928
1219
  return ret;
929
1220
  }
@@ -931,108 +1222,209 @@ var ListQuery = class extends Query {
931
1222
  return 0;
932
1223
  });
933
1224
  }
934
- const visited = /* @__PURE__ */ new Set();
935
- objectCacheKeys = objectCacheKeys.filter((key) => {
936
- batch.read(key);
937
- if (visited.has(key)) {
938
- return false;
1225
+ return objectCacheKeys;
1226
+ }
1227
+ registerStreamUpdates(sub) {
1228
+ const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
1229
+ methodName: "registerStreamUpdates"
1230
+ }) : this.logger;
1231
+ if (process.env.NODE_ENV !== "production") {
1232
+ logger?.child({
1233
+ methodName: "observeList"
1234
+ }).info("Subscribing from websocket");
1235
+ }
1236
+ const websocketSubscription = this.#objectSet.subscribe({
1237
+ onChange: this.#onOswChange.bind(this),
1238
+ onError: this.#onOswError.bind(this),
1239
+ onOutOfDate: this.#onOswOutOfDate.bind(this),
1240
+ onSuccessfulSubscription: this.#onOswSuccessfulSubscription.bind(this)
1241
+ });
1242
+ sub.add(() => {
1243
+ if (process.env.NODE_ENV !== "production") {
1244
+ logger?.child({
1245
+ methodName: "observeList"
1246
+ }).info("Unsubscribing from websocket");
939
1247
  }
940
- visited.add(key);
941
- return true;
1248
+ websocketSubscription.unsubscribe();
942
1249
  });
943
- return this.writeToStore({
944
- data: objectCacheKeys
945
- }, status, batch);
946
1250
  }
947
- writeToStore(data, status, batch) {
1251
+ #onOswSuccessfulSubscription() {
948
1252
  if (process.env.NODE_ENV !== "production") {
949
- this.logger?.trace({
950
- methodName: "writeToStore"
951
- }, `{status: ${status}},`, DEBUG_ONLY__cacheKeysToString(data.data));
1253
+ this.logger?.child({
1254
+ methodName: "onSuccessfulSubscription"
1255
+ }).debug("");
952
1256
  }
953
- const entry = batch.read(this.cacheKey);
954
- if (entry && deepEqual__default.default(data, entry.value)) {
955
- return batch.write(this.cacheKey, entry.value, status);
1257
+ }
1258
+ #onOswOutOfDate() {
1259
+ if (process.env.NODE_ENV !== "production") {
1260
+ this.logger?.child({
1261
+ methodName: "onOutOfDate"
1262
+ }).info("");
956
1263
  }
957
- const ret = batch.write(this.cacheKey, data, status);
958
- batch.changes.modifiedLists.add(this.cacheKey);
959
- return ret;
960
1264
  }
961
- _dispose() {
962
- console.log("DISPOSE LIST QUERY");
1265
+ #onOswError(errors) {
1266
+ if (this.logger) {
1267
+ this.logger?.child({
1268
+ methodName: "onError"
1269
+ }).error("subscription errors", errors);
1270
+ }
1271
+ }
1272
+ #onOswChange({
1273
+ object: objOrIface,
1274
+ state
1275
+ }) {
1276
+ const logger = process.env.NODE_ENV !== "production" ? this.logger?.child({
1277
+ methodName: "registerStreamUpdates"
1278
+ }) : this.logger;
1279
+ if (process.env.NODE_ENV !== "production") {
1280
+ logger?.child({
1281
+ methodName: "onChange"
1282
+ }).debug(`Got an update of type: ${state}`, objOrIface);
1283
+ }
1284
+ if (state === "ADDED_OR_UPDATED") {
1285
+ const object = objOrIface.$apiName !== objOrIface.$objectType ? objOrIface.$as(objOrIface.$objectType) : objOrIface;
1286
+ this.store.batch({}, (batch) => {
1287
+ storeOsdkInstances(this.store, [object], batch);
1288
+ });
1289
+ } else if (state === "REMOVED") {
1290
+ this.#onOswRemoved(objOrIface, logger);
1291
+ }
1292
+ }
1293
+ #onOswRemoved(objOrIface, logger) {
963
1294
  this.store.batch({}, (batch) => {
964
- const entry = batch.read(this.cacheKey);
965
- if (entry) {
966
- for (const objectCacheKey of entry.value?.data ?? []) {
967
- this.store.release(objectCacheKey);
1295
+ const existing = batch.read(this.cacheKey);
1296
+ !existing ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "the truth value for our list should exist as we already subscribed") : invariant2__default.default(false) : void 0;
1297
+ if (existing.status === "loaded") {
1298
+ const objectCacheKey = this.store.getCacheKey("object", objOrIface.$objectType, objOrIface.$primaryKey);
1299
+ const newObjects = existing.value?.data.filter((o) => o !== objectCacheKey);
1300
+ if (newObjects?.length !== existing.value?.data.length) {
1301
+ batch.changes.registerList(this.cacheKey);
1302
+ batch.write(this.cacheKey, {
1303
+ data: newObjects ?? []
1304
+ }, "loaded");
968
1305
  }
1306
+ return;
969
1307
  }
1308
+ if (process.env.NODE_ENV !== "production") {
1309
+ logger?.info("Removing an object from an object list that is in the middle of being loaded.", existing);
1310
+ }
1311
+ this.revalidate(
1312
+ /* force */
1313
+ true
1314
+ ).catch((e) => {
1315
+ if (logger) {
1316
+ logger?.error("Uncaught error while revalidating list", e);
1317
+ } else {
1318
+ console.error("Uncaught error while revalidating list", e);
1319
+ }
1320
+ });
970
1321
  });
971
1322
  }
972
1323
  };
973
- function isListCacheKey(cacheKey, apiName) {
974
- return cacheKey.type === "list" && (apiName == null || cacheKey.otherKeys[0] === apiName);
1324
+ function removeDuplicates(objectCacheKeys, batch) {
1325
+ const visited = /* @__PURE__ */ new Set();
1326
+ objectCacheKeys = objectCacheKeys.filter((key) => {
1327
+ batch.read(key);
1328
+ if (visited.has(key)) {
1329
+ return false;
1330
+ }
1331
+ visited.add(key);
1332
+ return true;
1333
+ });
1334
+ return objectCacheKeys;
975
1335
  }
976
- var ObjectQuery = class extends Query {
977
- #apiName;
978
- #pk;
979
- constructor(store, subject, type, pk, cacheKey, opts) {
980
- super(store, subject, opts, cacheKey, process.env.NODE_ENV !== "production" ? store.client[chunkJPENHIJB_cjs.additionalContext].logger?.child({}, {
981
- msgPrefix: `ObjectQuery<${cacheKey.otherKeys.map((x) => JSON.stringify(x)).join(", ")}>`
982
- }) : undefined);
983
- this.#apiName = type;
984
- this.#pk = pk;
985
- }
986
- _createConnectable(subject) {
987
- return rxjs.connectable(subject.pipe(rxjs.map((x) => {
988
- return {
989
- status: x.status,
990
- object: x.value,
991
- lastUpdated: x.lastUpdated,
992
- isOptimistic: x.isOptimistic
993
- };
994
- })), {
995
- connector: () => new rxjs.BehaviorSubject({
996
- status: "init",
997
- object: undefined,
998
- lastUpdated: 0,
999
- isOptimistic: false
1000
- })
1336
+ function createOrderBySortFns(orderBy) {
1337
+ return Object.entries(orderBy).map(([key, order]) => {
1338
+ return (a, b) => {
1339
+ const aValue = a?.[key];
1340
+ const bValue = b?.[key];
1341
+ if (aValue == null && bValue == null) {
1342
+ return 0;
1343
+ }
1344
+ if (aValue == null) {
1345
+ return 1;
1346
+ }
1347
+ if (bValue == null) {
1348
+ return -1;
1349
+ }
1350
+ const m = order === "asc" ? -1 : 1;
1351
+ return aValue < bValue ? m : aValue > bValue ? -m : 0;
1352
+ };
1353
+ });
1354
+ }
1355
+ async function reloadDataAsFullObjects(client, data) {
1356
+ const groups = groupBy__default.default(data, (x) => x.$objectType);
1357
+ const objectTypeToPrimaryKeyToObject = Object.fromEntries(await Promise.all(Object.entries(groups).map(async ([apiName, objects]) => {
1358
+ const objectDef = objects[0][chunkT4NIFYZS_cjs.UnderlyingOsdkObject][chunkT4NIFYZS_cjs.ObjectDefRef];
1359
+ const where = {
1360
+ [objectDef.primaryKeyApiName]: {
1361
+ $in: objects.map((x) => x.$primaryKey)
1362
+ }
1363
+ };
1364
+ const result = await client(objectDef).where(where).fetchPage();
1365
+ return [apiName, Object.fromEntries(result.data.map((x) => [x.$primaryKey, x]))];
1366
+ })));
1367
+ data = data.map((obj) => {
1368
+ !objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey] ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, `Could not find object ${obj.$objectType} ${obj.$primaryKey}`) : invariant2__default.default(false) : void 0;
1369
+ return objectTypeToPrimaryKeyToObject[obj.$objectType][obj.$primaryKey];
1370
+ });
1371
+ return data;
1372
+ }
1373
+ function isListCacheKey(cacheKey) {
1374
+ return cacheKey.type === "list";
1375
+ }
1376
+ var defaultMakeData = () => /* @__PURE__ */ Object.create(null);
1377
+ var WeakRefTrie = class {
1378
+ #finalizer = new FinalizationRegistry((orderBy) => {
1379
+ this.#trie.removeArray(Object.entries(orderBy).flat());
1380
+ });
1381
+ #trie;
1382
+ constructor(makeData = defaultMakeData) {
1383
+ this.#trie = new trie.Trie(false, (array) => {
1384
+ const data = makeData(array);
1385
+ this.#finalizer.register(data, array);
1386
+ return new WeakRef(data);
1001
1387
  });
1002
1388
  }
1003
- async _fetch() {
1004
- if (process.env.NODE_ENV !== "production") {
1005
- this.logger?.info({
1006
- methodName: "_fetch"
1007
- });
1389
+ lookupArray(array) {
1390
+ const maybe = this.#trie.lookupArray(array);
1391
+ let ret = maybe.deref();
1392
+ if (maybe && !ret) {
1393
+ this.#trie.removeArray(array);
1394
+ ret = this.#trie.lookupArray(array).deref();
1008
1395
  }
1009
- const objectSet = this.store.client({
1010
- type: "object",
1011
- apiName: this.#apiName
1012
- });
1013
- const obj = await objectSet.fetchOne(this.#pk);
1014
- this.store.batch({}, (batch) => {
1015
- this.writeToStore(obj, "loaded", batch);
1016
- });
1396
+ return ret;
1017
1397
  }
1018
- writeToStore(data, status, batch) {
1019
- if (process.env.NODE_ENV !== "production") {
1020
- this.logger?.trace({
1021
- methodName: "writeToStore"
1022
- }, `{status: ${status}},`, data);
1023
- }
1024
- const entry = batch.read(this.cacheKey);
1025
- if (entry && deepEqual__default.default(data, entry.value)) {
1026
- return batch.write(this.cacheKey, entry.value, status);
1027
- }
1028
- const ret = batch.write(this.cacheKey, data, status);
1029
- if (entry) {
1030
- batch.changes.modifiedObjects.set(data.$apiName, data);
1031
- } else {
1032
- batch.changes.addedObjects.set(data.$apiName, data);
1398
+ peekArray(array) {
1399
+ const maybe = this.#trie.peekArray(array);
1400
+ const ret = maybe?.deref();
1401
+ if (maybe && !ret) {
1402
+ this.#trie.removeArray(array);
1033
1403
  }
1034
1404
  return ret;
1035
1405
  }
1406
+ removeArray(array) {
1407
+ return this.#trie.removeArray(array)?.deref();
1408
+ }
1409
+ };
1410
+ var OrderByCanonicalizer = class {
1411
+ #trie = new WeakRefTrie((array) => {
1412
+ const pairs = array.reduce(function(result, _, index, array2) {
1413
+ if (index % 2 === 0 && array2[index] != null) {
1414
+ result.push(array2.slice(index, index + 2));
1415
+ }
1416
+ return result;
1417
+ }, []);
1418
+ let data = Object.fromEntries(pairs);
1419
+ if (process.env.NODE_ENV !== "production") {
1420
+ data = Object.freeze(data);
1421
+ }
1422
+ return data;
1423
+ });
1424
+ canonicalize = (orderBy) => {
1425
+ const strings = Object.entries(orderBy).flat();
1426
+ return this.#trie.lookupArray(strings);
1427
+ };
1036
1428
  };
1037
1429
 
1038
1430
  // src/observable/internal/RefCounts.ts
@@ -1059,8 +1451,8 @@ var RefCounts = class {
1059
1451
  }
1060
1452
  }
1061
1453
  release(key) {
1062
- const count = this.refCounts.get(key) ?? 0;
1063
- if (count === 1) {
1454
+ const count = this.refCounts.get(key);
1455
+ if (count === void 0) ; else if (count === 1) {
1064
1456
  this.refCounts.delete(key);
1065
1457
  this.gcMap.set(key, Date.now() + this.keepAlive);
1066
1458
  } else {
@@ -1081,6 +1473,14 @@ var RefCounts = class {
1081
1473
  }
1082
1474
  };
1083
1475
  var WhereClauseCanonicalizer = class {
1476
+ /**
1477
+ * This is a shortcut cache for any WhereClause's that we have
1478
+ * seen and already canonicalized. The theory behind this
1479
+ * is that well behaving React applications will either `useMemo`
1480
+ * their where clause, or store it in state or pass it through as
1481
+ * props such that we are likely to get the same WhereClause
1482
+ * object multiple times and we can skip unnecessary work.
1483
+ */
1084
1484
  #cache = /* @__PURE__ */ new WeakMap();
1085
1485
  /**
1086
1486
  * This is a trie that stores the sorted collapsed keys of a where clause to
@@ -1098,14 +1498,14 @@ var WhereClauseCanonicalizer = class {
1098
1498
  return this.#cache.get(where);
1099
1499
  }
1100
1500
  const keysSet = /* @__PURE__ */ new Set();
1101
- const tmpCanon = this.#toCanon(where, keysSet);
1501
+ const calculatedCanon = this.#toCanon(where, keysSet);
1102
1502
  const cacheKey = this.#trie.lookupArray(Array.from(keysSet).sort());
1103
1503
  const lookupEntry = this.#existingOptions.get(cacheKey) ?? {
1104
1504
  options: []
1105
1505
  };
1106
1506
  this.#existingOptions.set(cacheKey, lookupEntry);
1107
- const canon = lookupEntry.options.find((ref) => deepEqual__default.default(ref.deref(), tmpCanon))?.deref() ?? tmpCanon;
1108
- if (canon === tmpCanon) {
1507
+ const canon = lookupEntry.options.find((ref) => deepEqual__default.default(ref.deref(), calculatedCanon))?.deref() ?? calculatedCanon;
1508
+ if (canon === calculatedCanon) {
1109
1509
  lookupEntry.options.push(new WeakRef(canon));
1110
1510
  }
1111
1511
  this.#cache.set(where, canon);
@@ -1114,8 +1514,8 @@ var WhereClauseCanonicalizer = class {
1114
1514
  #toCanon = (where, set = /* @__PURE__ */ new Set()) => {
1115
1515
  if ("$and" in where) {
1116
1516
  if (process.env.NODE_ENV !== "production") {
1117
- !Array.isArray(where.$and) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $and to be an array") : invariant2__default.default(false) : undefined;
1118
- !(Object.keys(where).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $and to be present") : invariant2__default.default(false) : undefined;
1517
+ !Array.isArray(where.$and) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected $and to be an array") : invariant2__default.default(false) : void 0;
1518
+ !(Object.keys(where).length === 1) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "expected only $and to be present") : invariant2__default.default(false) : void 0;
1119
1519
  }
1120
1520
  if (where.$and.length === 0) {
1121
1521
  return {};
@@ -1142,36 +1542,28 @@ function createInitEntry(cacheKey) {
1142
1542
  return {
1143
1543
  cacheKey,
1144
1544
  status: "init",
1145
- value: undefined,
1545
+ value: void 0,
1146
1546
  lastUpdated: 0
1147
1547
  };
1148
1548
  }
1149
- var OrderByCanonicalizer = class {
1150
- // crappy version
1151
- #map = /* @__PURE__ */ new Map();
1152
- canonicalize = (orderBy) => {
1153
- if (this.#map.has(JSON.stringify(orderBy))) {
1154
- return this.#map.get(JSON.stringify(orderBy));
1155
- } else {
1156
- this.#map.set(JSON.stringify(orderBy), orderBy);
1157
- return orderBy;
1158
- }
1159
- };
1160
- };
1161
1549
  var Store = class {
1162
1550
  whereCanonicalizer = new WhereClauseCanonicalizer();
1163
1551
  orderByCanonicalizer = new OrderByCanonicalizer();
1164
- #truthLayer = new Layer(undefined, undefined);
1552
+ #truthLayer = new Layer(void 0, void 0);
1165
1553
  #topLayer;
1166
1554
  /** @internal */
1167
- #queries = new WeakMapWithEntries();
1555
+ // we can use a regular Map here because the refCounting will
1556
+ // handle cleanup.
1557
+ #queries = /* @__PURE__ */ new Map();
1168
1558
  #cacheKeyToSubject = /* @__PURE__ */ new WeakMap();
1169
1559
  #cacheKeys;
1170
1560
  #refCounts = new RefCounts(6e4, (k) => this.#cleanupCacheKey(k));
1561
+ // we are currently only using this for debug logging and should just remove it in the future if that
1562
+ // continues to be true
1171
1563
  #finalizationRegistry;
1172
1564
  constructor(client) {
1173
1565
  this.client = client;
1174
- this.logger = client[chunkJPENHIJB_cjs.additionalContext].logger?.child({}, {
1566
+ this.logger = client[chunkW5PFESFR_cjs.additionalContext].logger?.child({}, {
1175
1567
  msgPrefix: "Store"
1176
1568
  });
1177
1569
  this.#topLayer = this.#truthLayer;
@@ -1197,7 +1589,7 @@ var Store = class {
1197
1589
  const subject = this.peekSubject(key);
1198
1590
  this.#cacheKeys.remove(key);
1199
1591
  if (process.env.NODE_ENV !== "production") {
1200
- !subject ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false) : invariant2__default.default(false) : undefined;
1592
+ !subject ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false) : invariant2__default.default(false) : void 0;
1201
1593
  }
1202
1594
  if (subject) {
1203
1595
  subject.complete();
@@ -1206,11 +1598,11 @@ var Store = class {
1206
1598
  this.#queries.get(key)?.dispose();
1207
1599
  this.#queries.delete(key);
1208
1600
  };
1209
- applyAction = (action, args, opts) => {
1210
- return new ActionApplication(this).applyAction(action, args, opts);
1601
+ applyAction = async (action, args, opts) => {
1602
+ return await new ActionApplication(this).applyAction(action, args, opts);
1211
1603
  };
1212
1604
  removeLayer(layerId) {
1213
- !(layerId != null) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "undefined is the reserved layerId for the truth layer") : invariant2__default.default(false) : undefined;
1605
+ !(layerId != null) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "undefined is the reserved layerId for the truth layer") : invariant2__default.default(false) : void 0;
1214
1606
  let currentLayer = this.#topLayer;
1215
1607
  const cacheKeys = /* @__PURE__ */ new Map();
1216
1608
  while (currentLayer != null && currentLayer.parentLayer != null) {
@@ -1253,14 +1645,18 @@ var Store = class {
1253
1645
  }
1254
1646
  return subject;
1255
1647
  };
1648
+ canonicalizeWhereClause(where) {
1649
+ return this.whereCanonicalizer.canonicalize(where);
1650
+ }
1256
1651
  observeObject(apiName, pk, options, subFn) {
1257
1652
  if (typeof apiName !== "string") {
1258
1653
  apiName = apiName.apiName;
1259
1654
  }
1260
1655
  const query = this.getObjectQuery(apiName, pk);
1261
- this.#refCounts.retain(query.cacheKey);
1656
+ this.retain(query.cacheKey);
1262
1657
  if (options.mode !== "offline") {
1263
1658
  query.revalidate(options.mode === "force").catch((e) => {
1659
+ subFn.error(e);
1264
1660
  if (this.logger) {
1265
1661
  this.logger.error("Unhandled error in observeObject", e);
1266
1662
  } else {
@@ -1268,145 +1664,54 @@ var Store = class {
1268
1664
  }
1269
1665
  });
1270
1666
  }
1271
- const sub = query.subscribe({
1272
- next: subFn
1273
- });
1667
+ const sub = query.subscribe(subFn);
1274
1668
  return {
1275
1669
  unsubscribe: () => {
1276
1670
  sub.unsubscribe();
1277
- this.#refCounts.release(query.cacheKey);
1671
+ this.release(query.cacheKey);
1278
1672
  }
1279
1673
  };
1280
1674
  }
1281
1675
  observeList(options, subFn) {
1282
- const query = this.getListQuery(options.objectType, options.where ?? {}, options.orderBy ?? {}, options);
1283
- this.#refCounts.retain(query.cacheKey);
1676
+ const query = this.getListQuery(options.type, options.where ?? {}, options.orderBy ?? {}, options);
1677
+ this.retain(query.cacheKey);
1284
1678
  if (options.mode !== "offline") {
1285
- void query.revalidate(options.mode === "force");
1679
+ query.revalidate(options.mode === "force").catch((x) => {
1680
+ subFn.error(x);
1681
+ });
1286
1682
  }
1287
- const sub = query.subscribe({
1288
- next: subFn
1289
- });
1683
+ const sub = query.subscribe(subFn);
1290
1684
  if (options.streamUpdates) {
1291
- const miniDef = {
1292
- type: "object",
1293
- apiName: typeof options.objectType === "string" ? options.objectType : options.objectType.apiName
1294
- };
1295
- let objectSet = this.client(miniDef);
1296
- if (options.where) {
1297
- objectSet = objectSet.where(options.where ?? {});
1298
- }
1299
- const store = this;
1300
- const websocketSubscription = objectSet.subscribe({
1301
- onChange({
1302
- object,
1303
- state
1304
- }) {
1305
- if (process.env.NODE_ENV !== "production") {
1306
- store.logger?.debug({
1307
- methodName: "onError"
1308
- }, "updates", state, object);
1309
- }
1310
- const cacheKey = store.getCacheKey("object", object.$objectType, object.$primaryKey);
1311
- const type = store.#peekQuery(cacheKey) == null ? "addedObjects" : "modifiedObjects";
1312
- const changes = createChangedObjects();
1313
- changes[type].set(object.$objectType, object);
1314
- if (state === "ADDED_OR_UPDATED") {
1315
- store.updateObject(object.$objectType, object);
1316
- store.maybeRevalidateLists(changes).catch((err) => {
1317
- console.error("Unhandled error in maybeRevalidateLists", err);
1318
- });
1319
- } else if (state === "REMOVED") {
1320
- const changes2 = createChangedObjects();
1321
- store.batch({
1322
- changes: changes2
1323
- }, (batch) => {
1324
- const existing = batch.read(query.cacheKey);
1325
- const cacheKeyToRemove = store.getCacheKey("object", object.$objectType, object.$primaryKey);
1326
- if (existing?.status === "loaded") {
1327
- const newObjects = existing.value?.data.filter((o) => o !== cacheKeyToRemove);
1328
- if (newObjects?.length !== existing.value?.data.length) {
1329
- batch.changes.modifiedLists.add(query.cacheKey);
1330
- batch.write(query.cacheKey, {
1331
- data: newObjects ?? []
1332
- }, "loaded");
1333
- }
1334
- } else {
1335
- if (process.env.NODE_ENV !== "production") {
1336
- store.logger?.info("Removing an object from an object list that is in the middle of being loaded.", existing);
1337
- }
1338
- query.revalidate(
1339
- /* force */
1340
- true
1341
- ).catch((e) => {
1342
- if (store.logger) {
1343
- store.logger?.error("Uncaught error while revalidating list", e);
1344
- } else {
1345
- console.error("Uncaught error while revalidating list", e);
1346
- }
1347
- });
1348
- }
1349
- });
1350
- }
1351
- },
1352
- onError(errors) {
1353
- if (process.env.NODE_ENV !== "production") {
1354
- store.logger?.info({
1355
- methodName: "onError"
1356
- }, "subscription errors", errors);
1357
- }
1358
- },
1359
- onOutOfDate() {
1360
- if (process.env.NODE_ENV !== "production") {
1361
- store.logger?.info({
1362
- methodName: "onOutOfDate"
1363
- });
1364
- }
1365
- },
1366
- onSuccessfulSubscription() {
1367
- if (process.env.NODE_ENV !== "production") {
1368
- store.logger?.info({
1369
- methodName: "onSuccessfulSubscription"
1370
- });
1371
- }
1372
- }
1373
- });
1374
- sub.add(() => {
1375
- if (process.env.NODE_ENV !== "production") {
1376
- store.logger?.info({
1377
- methodName: "observeList"
1378
- }, "Unsubscribing from websocket");
1379
- }
1380
- websocketSubscription.unsubscribe();
1381
- });
1685
+ query.registerStreamUpdates(sub);
1382
1686
  }
1383
1687
  return {
1384
1688
  unsubscribe: () => {
1385
1689
  sub.unsubscribe();
1386
- this.#refCounts.release(query.cacheKey);
1690
+ this.release(query.cacheKey);
1387
1691
  }
1388
1692
  };
1389
1693
  }
1390
- #peekQuery(cacheKey) {
1694
+ peekQuery(cacheKey) {
1391
1695
  return this.#queries.get(cacheKey);
1392
1696
  }
1393
1697
  #getQuery(cacheKey, createQuery) {
1394
- let query = this.#peekQuery(cacheKey);
1698
+ let query = this.peekQuery(cacheKey);
1395
1699
  if (!query) {
1396
1700
  query = createQuery();
1397
1701
  this.#queries.set(cacheKey, query);
1398
1702
  }
1399
1703
  return query;
1400
1704
  }
1401
- getListQuery(apiName, where, orderBy, opts) {
1402
- if (typeof apiName !== "string") {
1403
- apiName = apiName.apiName;
1404
- }
1705
+ getListQuery(def, where, orderBy, opts) {
1706
+ const {
1707
+ apiName,
1708
+ type
1709
+ } = def;
1405
1710
  const canonWhere = this.whereCanonicalizer.canonicalize(where);
1406
1711
  const canonOrderBy = this.orderByCanonicalizer.canonicalize(orderBy);
1407
- const listCacheKey = this.getCacheKey("list", apiName, canonWhere, canonOrderBy);
1712
+ const listCacheKey = this.getCacheKey("list", type, apiName, canonWhere, canonOrderBy);
1408
1713
  return this.#getQuery(listCacheKey, () => {
1409
- return new ListQuery(this, this.getSubject(listCacheKey), apiName, canonWhere, canonOrderBy, listCacheKey, opts);
1714
+ return new ListQuery(this, this.getSubject(listCacheKey), type, apiName, canonWhere, canonOrderBy, listCacheKey, opts);
1410
1715
  });
1411
1716
  }
1412
1717
  getObjectQuery(apiName, pk) {
@@ -1418,20 +1723,15 @@ var Store = class {
1418
1723
  dedupeInterval: 0
1419
1724
  }));
1420
1725
  }
1421
- getObject(apiName, pk) {
1422
- if (typeof apiName !== "string") {
1423
- apiName = apiName.apiName;
1424
- }
1425
- const objectCacheKey = this.getCacheKey("object", apiName, pk);
1426
- const objEntry = this.#topLayer.get(objectCacheKey);
1427
- return objEntry?.value;
1726
+ getValue(cacheKey) {
1727
+ return this.#topLayer.get(cacheKey);
1428
1728
  }
1429
1729
  batch = ({
1430
1730
  optimisticId,
1431
1731
  changes = createChangedObjects()
1432
1732
  }, batchFn) => {
1433
- !(optimisticId === undefined || !!optimisticId) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "optimistic must be undefined or not falsy") : invariant2__default.default(false) : undefined;
1434
- let needsLayer = optimisticId !== undefined;
1733
+ !(optimisticId === void 0 || !!optimisticId) ? process.env.NODE_ENV !== "production" ? invariant2__default.default(false, "optimistic must be undefined or not falsy") : invariant2__default.default(false) : void 0;
1734
+ let needsLayer = optimisticId !== void 0;
1435
1735
  const batchContext = {
1436
1736
  changes,
1437
1737
  createLayerIfNeeded: () => {
@@ -1462,64 +1762,60 @@ var Store = class {
1462
1762
  }
1463
1763
  };
1464
1764
  const retVal = batchFn(batchContext);
1465
- void this.maybeUpdateLists(changes, optimisticId);
1765
+ this.maybeRevalidateQueries(changes, optimisticId).catch((e) => {
1766
+ if (this.logger) {
1767
+ this.logger.error("Unhandled error in batch", e);
1768
+ } else {
1769
+ console.error("Unhandled error in batch", e);
1770
+ throw e;
1771
+ }
1772
+ });
1466
1773
  return {
1467
1774
  batchResult: batchContext,
1468
- retVal
1775
+ retVal,
1776
+ changes: batchContext.changes
1469
1777
  };
1470
1778
  };
1471
1779
  invalidateObject(apiName, pk) {
1472
1780
  if (typeof apiName !== "string") {
1473
1781
  apiName = apiName.apiName;
1474
1782
  }
1475
- const query = this.getObjectQuery(apiName, pk);
1476
- return query.revalidate(true);
1783
+ return this.getObjectQuery(apiName, pk).revalidate(
1784
+ /* force */
1785
+ true
1786
+ );
1477
1787
  }
1478
- async maybeRevalidateLists(changes) {
1788
+ async maybeRevalidateQueries(changes, optimisticId) {
1789
+ if (changes.isEmpty()) {
1790
+ if (process.env.NODE_ENV !== "production") {
1791
+ this.logger?.child({
1792
+ methodName: "maybeRevalidateQueries"
1793
+ }).debug("No changes, aborting");
1794
+ }
1795
+ return;
1796
+ }
1479
1797
  if (process.env.NODE_ENV !== "production") {
1480
- this.logger?.trace({
1481
- methodName: "maybeRevalidateList"
1482
- }, DEBUG_ONLY__changesToString(changes));
1798
+ this.logger?.child({
1799
+ methodName: "maybeRevalidateQueries"
1800
+ }).debug(DEBUG_ONLY__changesToString(changes), {
1801
+ optimisticId
1802
+ });
1483
1803
  }
1484
1804
  try {
1485
1805
  const promises = [];
1486
- for (const [cacheKey, v] of this.#truthLayer.entries()) {
1487
- if (isListCacheKey(cacheKey)) {
1488
- const promise = this.#peekQuery(cacheKey)?.maybeUpdateAndRevalidate(changes, void 0);
1489
- if (promise) promises.push(promise);
1490
- }
1806
+ for (const cacheKey of this.#queries.keys()) {
1807
+ const promise = this.peekQuery(cacheKey)?.maybeUpdateAndRevalidate?.(changes, optimisticId);
1808
+ if (promise) promises.push(promise);
1491
1809
  }
1492
1810
  await Promise.all(promises);
1493
1811
  } finally {
1494
1812
  if (process.env.NODE_ENV !== "production") {
1495
- this.logger?.trace({
1496
- methodName: "maybeRevalidateList"
1497
- }, "in finally", DEBUG_ONLY__changesToString(changes));
1813
+ this.logger?.child({
1814
+ methodName: "maybeRevalidateQueries"
1815
+ }).debug("in finally", DEBUG_ONLY__changesToString(changes));
1498
1816
  }
1499
1817
  }
1500
1818
  }
1501
- maybeUpdateLists(changes, optimisticId) {
1502
- if (process.env.NODE_ENV !== "production") {
1503
- this.logger?.trace({
1504
- methodName: "maybeUpdateLists"
1505
- }, DEBUG_ONLY__changesToString(changes), {
1506
- optimisticId
1507
- });
1508
- }
1509
- if (changes.addedObjects.size === 0 && changes.modifiedObjects.size === 0) {
1510
- return Promise.resolve([]);
1511
- }
1512
- const promises = [];
1513
- for (const cacheKey of this.#queries.keys()) {
1514
- if (isListCacheKey(cacheKey)) {
1515
- if (!changes.modifiedLists.has(cacheKey)) {
1516
- const promise = this.#peekQuery(cacheKey)?.maybeUpdateAndRevalidate(changes, optimisticId);
1517
- if (promise) promises.push(promise);
1518
- }
1519
- }
1520
- }
1521
- return Promise.all(promises);
1522
- }
1523
1819
  /**
1524
1820
  * @param apiName
1525
1821
  * @param changes The changes we know about / to update
@@ -1530,90 +1826,23 @@ var Store = class {
1530
1826
  apiName = apiName.apiName;
1531
1827
  }
1532
1828
  if (process.env.NODE_ENV !== "production") {
1533
- this.logger?.info({
1829
+ this.logger?.child({
1534
1830
  methodName: "invalidateObjectType"
1535
- }, changes ? DEBUG_ONLY__changesToString(changes) : undefined);
1831
+ }).info(changes ? DEBUG_ONLY__changesToString(changes) : void 0);
1536
1832
  }
1537
1833
  const promises = [];
1538
- for (const [cacheKey, v] of this.#truthLayer.entries()) {
1539
- if (isListCacheKey(cacheKey, apiName)) {
1540
- if (!changes || !changes.modifiedLists.has(cacheKey)) {
1541
- const promise = this.#peekQuery(cacheKey)?.revalidate(true);
1834
+ for (const cacheKey of this.#truthLayer.keys()) {
1835
+ if (isListCacheKey(cacheKey)) {
1836
+ if (!changes || !changes.modified.has(cacheKey)) {
1837
+ const promise = this.peekQuery(cacheKey)?.revalidate(true);
1542
1838
  if (promise) {
1543
1839
  promises.push(promise);
1544
- changes?.modifiedLists.add(cacheKey);
1840
+ changes?.modified.add(cacheKey);
1545
1841
  }
1546
1842
  }
1547
1843
  }
1548
1844
  }
1549
- return Promise.all(promises);
1550
- }
1551
- invalidateList({
1552
- objectType,
1553
- where,
1554
- orderBy
1555
- }) {
1556
- if (typeof objectType !== "string") {
1557
- objectType = objectType.apiName;
1558
- }
1559
- where = this.whereCanonicalizer.canonicalize(where ?? {});
1560
- orderBy = this.orderByCanonicalizer.canonicalize(orderBy ?? {});
1561
- const cacheKey = this.getCacheKey("list", objectType, where, orderBy);
1562
- void this.#peekQuery(cacheKey)?.revalidate(true);
1563
- }
1564
- updateObject(apiName, value, {
1565
- optimisticId
1566
- } = {}) {
1567
- if (typeof apiName !== "string") {
1568
- apiName = apiName.apiName;
1569
- }
1570
- const query = this.getObjectQuery(apiName, value.$primaryKey);
1571
- return this.batch({
1572
- optimisticId
1573
- }, (batch) => {
1574
- return query.writeToStore(value, "loaded", batch);
1575
- }).retVal.value;
1576
- }
1577
- updateObjects(values, batch) {
1578
- return values.map((v) => {
1579
- return this.getObjectQuery(v.$apiName, v.$primaryKey).writeToStore(v, "loaded", batch).cacheKey;
1580
- });
1581
- }
1582
- /**
1583
- * Updates the internal state of a list and will create a new internal query if needed.
1584
- *
1585
- * Helper method only for tests right now. May be removed later.
1586
- *
1587
- * @param apiName
1588
- * @param where
1589
- * @param orderBy
1590
- * @param objects
1591
- * @param param4
1592
- * @param opts
1593
- */
1594
- updateList({
1595
- objectType: apiName,
1596
- where,
1597
- orderBy
1598
- }, objects, {
1599
- optimisticId
1600
- } = {}, opts = {
1601
- dedupeInterval: 0
1602
- }) {
1603
- if (process.env.NODE_ENV !== "production") {
1604
- this.logger?.info({
1605
- methodName: "updateList"
1606
- }, "", {
1607
- optimisticId
1608
- });
1609
- }
1610
- const query = this.getListQuery(apiName, where ?? {}, orderBy ?? {}, opts);
1611
- this.batch({
1612
- optimisticId
1613
- }, (batch) => {
1614
- const objectCacheKeys = this.updateObjects(objects, batch);
1615
- query.updateList(objectCacheKeys, false, "loaded", batch);
1616
- });
1845
+ return Promise.all(promises).then(() => void 0);
1617
1846
  }
1618
1847
  retain(cacheKey) {
1619
1848
  this.#refCounts.retain(cacheKey);
@@ -1628,10 +1857,46 @@ function createObservableClient(client) {
1628
1857
  return new ObservableClientImpl(new Store(client));
1629
1858
  }
1630
1859
 
1860
+ // src/public-utils/osdkConfig.ts
1861
+ function getMetaTagContent(name) {
1862
+ const element = document.querySelector(`meta[name="${name}"]`);
1863
+ const val = element ? element.getAttribute("content") : null;
1864
+ if (val == null) {
1865
+ throw new Error(`Missing meta tag: ${name}`);
1866
+ }
1867
+ return val;
1868
+ }
1869
+ function getViteEnvVar(name) {
1870
+ const val = undefined[name];
1871
+ if (val == null) {
1872
+ throw new Error(`Missing environment variable: ${name}`);
1873
+ }
1874
+ return val;
1875
+ }
1876
+ function isProduction() {
1877
+ return process.env.NODE_ENV === "production";
1878
+ }
1879
+ function getConfigValue(metaTagName, viteEnvVarName) {
1880
+ return isProduction() ? getMetaTagContent(metaTagName) : getViteEnvVar(viteEnvVarName);
1881
+ }
1882
+ function getOntologyRid(ontologyRid) {
1883
+ return isProduction() ? getMetaTagContent("osdk-ontologyRid") : ontologyRid;
1884
+ }
1885
+ function getOsdkConfig(ontologyRid) {
1886
+ return {
1887
+ clientId: getConfigValue("osdk-clientId", "VITE_FOUNDRY_CLIENT_ID"),
1888
+ redirectUrl: getConfigValue("osdk-redirectUrl", "VITE_FOUNDRY_REDIRECT_URL"),
1889
+ foundryUrl: getConfigValue("osdk-foundryUrl", "VITE_FOUNDRY_API_URL"),
1890
+ ontologyRid: getOntologyRid(ontologyRid)
1891
+ };
1892
+ }
1893
+
1631
1894
  Object.defineProperty(exports, "augment", {
1632
1895
  enumerable: true,
1633
- get: function () { return chunkJPENHIJB_cjs.augment; }
1896
+ get: function () { return chunkW5PFESFR_cjs.augment; }
1634
1897
  });
1635
1898
  exports.createObservableClient = createObservableClient;
1899
+ exports.getMetaTagContent = getMetaTagContent;
1900
+ exports.getOsdkConfig = getOsdkConfig;
1636
1901
  //# sourceMappingURL=unstable-do-not-use.cjs.map
1637
1902
  //# sourceMappingURL=unstable-do-not-use.cjs.map