@osdk/client 2.5.0-beta.9 → 2.5.0-rc.15

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 (190) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/build/browser/MinimalClientContext.js.map +1 -1
  3. package/build/browser/actions/applyAction.js +0 -4
  4. package/build/browser/actions/applyAction.js.map +1 -1
  5. package/build/browser/createClient.js +1 -2
  6. package/build/browser/createClient.js.map +1 -1
  7. package/build/browser/createMinimalClient.js +1 -2
  8. package/build/browser/createMinimalClient.js.map +1 -1
  9. package/build/browser/definitions/LinkDefinitions.test.js.map +1 -1
  10. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js +0 -17
  11. package/build/browser/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  12. package/build/browser/fetchMetadata.test.js +4 -0
  13. package/build/browser/fetchMetadata.test.js.map +1 -1
  14. package/build/browser/index.js +1 -1
  15. package/build/browser/index.js.map +1 -1
  16. package/build/browser/object/aggregate.js +0 -2
  17. package/build/browser/object/aggregate.js.map +1 -1
  18. package/build/browser/object/convertWireToOsdkObjects.test.js +5 -1
  19. package/build/browser/object/convertWireToOsdkObjects.test.js.map +1 -1
  20. package/build/browser/object/fetchPage.js +5 -7
  21. package/build/browser/object/fetchPage.js.map +1 -1
  22. package/build/browser/object/mediaUpload.js +0 -3
  23. package/build/browser/object/mediaUpload.js.map +1 -1
  24. package/build/browser/objectSet/ObjectSetListenerWebsocket.js +31 -9
  25. package/build/browser/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  26. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js +69 -4
  27. package/build/browser/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  28. package/build/browser/objectSet/createObjectSet.js.map +1 -1
  29. package/build/browser/observable/ObjectSetPayload.js +2 -0
  30. package/build/browser/observable/ObjectSetPayload.js.map +1 -0
  31. package/build/browser/observable/ObservableClient.js.map +1 -1
  32. package/build/browser/observable/computeObjectSetCacheKey.js +64 -0
  33. package/build/browser/observable/computeObjectSetCacheKey.js.map +1 -0
  34. package/build/browser/observable/internal/Changes.js +3 -0
  35. package/build/browser/observable/internal/Changes.js.map +1 -1
  36. package/build/browser/observable/internal/KnownCacheKey.js.map +1 -1
  37. package/build/browser/observable/internal/ObservableClientImpl.js +17 -0
  38. package/build/browser/observable/internal/ObservableClientImpl.js.map +1 -1
  39. package/build/browser/observable/internal/Query.js +18 -1
  40. package/build/browser/observable/internal/Query.js.map +1 -1
  41. package/build/browser/observable/internal/Store.invalidation.test.js +165 -0
  42. package/build/browser/observable/internal/Store.invalidation.test.js.map +1 -1
  43. package/build/browser/observable/internal/Store.js +23 -0
  44. package/build/browser/observable/internal/Store.js.map +1 -1
  45. package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js +2 -0
  46. package/build/browser/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -0
  47. package/build/browser/observable/internal/objectset/ObjectSetHelper.js +69 -0
  48. package/build/browser/observable/internal/objectset/ObjectSetHelper.js.map +1 -0
  49. package/build/browser/observable/internal/objectset/ObjectSetQuery.js +151 -0
  50. package/build/browser/observable/internal/objectset/ObjectSetQuery.js.map +1 -0
  51. package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js +2 -0
  52. package/build/browser/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -0
  53. package/build/browser/ontology/loadActionMetadata.js +1 -3
  54. package/build/browser/ontology/loadActionMetadata.js.map +1 -1
  55. package/build/browser/ontology/loadFullObjectMetadata.js +1 -2
  56. package/build/browser/ontology/loadFullObjectMetadata.js.map +1 -1
  57. package/build/browser/ontology/loadInterfaceMetadata.js +1 -2
  58. package/build/browser/ontology/loadInterfaceMetadata.js.map +1 -1
  59. package/build/browser/public/unstable-do-not-use.js +1 -0
  60. package/build/browser/public/unstable-do-not-use.js.map +1 -1
  61. package/build/browser/util/UserAgent.js +2 -2
  62. package/build/browser/util/UserAgent.js.map +1 -1
  63. package/build/browser/util/exponentialBackoff.js +51 -0
  64. package/build/browser/util/exponentialBackoff.js.map +1 -0
  65. package/build/browser/util/exponentialBackoff.test.js +81 -0
  66. package/build/browser/util/exponentialBackoff.test.js.map +1 -0
  67. package/build/browser/util/toDataValue.js +1 -15
  68. package/build/browser/util/toDataValue.js.map +1 -1
  69. package/build/browser/util/toDataValue.test.js +2 -42
  70. package/build/browser/util/toDataValue.test.js.map +1 -1
  71. package/build/cjs/{chunk-HCCGD2AP.cjs → chunk-56O6U7K6.cjs} +68 -91
  72. package/build/cjs/chunk-56O6U7K6.cjs.map +1 -0
  73. package/build/cjs/{chunk-MKL3HEQ5.cjs → chunk-KODTFRP3.cjs} +105 -71
  74. package/build/cjs/chunk-KODTFRP3.cjs.map +1 -0
  75. package/build/cjs/{createClient-mOlFts15.d.cts → createClient-BJo8T7Js.d.cts} +0 -1
  76. package/build/cjs/index.cjs +7 -11
  77. package/build/cjs/index.d.cts +2 -2
  78. package/build/cjs/public/internal.cjs +8 -8
  79. package/build/cjs/public/unstable-do-not-use.cjs +429 -156
  80. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -1
  81. package/build/cjs/public/unstable-do-not-use.d.cts +79 -7
  82. package/build/esm/MinimalClientContext.js.map +1 -1
  83. package/build/esm/actions/applyAction.js +0 -4
  84. package/build/esm/actions/applyAction.js.map +1 -1
  85. package/build/esm/createClient.js +1 -2
  86. package/build/esm/createClient.js.map +1 -1
  87. package/build/esm/createMinimalClient.js +1 -2
  88. package/build/esm/createMinimalClient.js.map +1 -1
  89. package/build/esm/definitions/LinkDefinitions.test.js.map +1 -1
  90. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js +0 -17
  91. package/build/esm/derivedProperties/createWithPropertiesObjectSet.js.map +1 -1
  92. package/build/esm/fetchMetadata.test.js +4 -0
  93. package/build/esm/fetchMetadata.test.js.map +1 -1
  94. package/build/esm/index.js +1 -1
  95. package/build/esm/index.js.map +1 -1
  96. package/build/esm/object/aggregate.js +0 -2
  97. package/build/esm/object/aggregate.js.map +1 -1
  98. package/build/esm/object/convertWireToOsdkObjects.test.js +5 -1
  99. package/build/esm/object/convertWireToOsdkObjects.test.js.map +1 -1
  100. package/build/esm/object/fetchPage.js +5 -7
  101. package/build/esm/object/fetchPage.js.map +1 -1
  102. package/build/esm/object/mediaUpload.js +0 -3
  103. package/build/esm/object/mediaUpload.js.map +1 -1
  104. package/build/esm/objectSet/ObjectSetListenerWebsocket.js +31 -9
  105. package/build/esm/objectSet/ObjectSetListenerWebsocket.js.map +1 -1
  106. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js +69 -4
  107. package/build/esm/objectSet/ObjectSetListenerWebsocket.test.js.map +1 -1
  108. package/build/esm/objectSet/createObjectSet.js.map +1 -1
  109. package/build/esm/observable/ObjectSetPayload.js +2 -0
  110. package/build/esm/observable/ObjectSetPayload.js.map +1 -0
  111. package/build/esm/observable/ObservableClient.js.map +1 -1
  112. package/build/esm/observable/computeObjectSetCacheKey.js +64 -0
  113. package/build/esm/observable/computeObjectSetCacheKey.js.map +1 -0
  114. package/build/esm/observable/internal/Changes.js +3 -0
  115. package/build/esm/observable/internal/Changes.js.map +1 -1
  116. package/build/esm/observable/internal/KnownCacheKey.js.map +1 -1
  117. package/build/esm/observable/internal/ObservableClientImpl.js +17 -0
  118. package/build/esm/observable/internal/ObservableClientImpl.js.map +1 -1
  119. package/build/esm/observable/internal/Query.js +18 -1
  120. package/build/esm/observable/internal/Query.js.map +1 -1
  121. package/build/esm/observable/internal/Store.invalidation.test.js +165 -0
  122. package/build/esm/observable/internal/Store.invalidation.test.js.map +1 -1
  123. package/build/esm/observable/internal/Store.js +23 -0
  124. package/build/esm/observable/internal/Store.js.map +1 -1
  125. package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js +2 -0
  126. package/build/esm/observable/internal/objectset/ObjectSetCacheKey.js.map +1 -0
  127. package/build/esm/observable/internal/objectset/ObjectSetHelper.js +69 -0
  128. package/build/esm/observable/internal/objectset/ObjectSetHelper.js.map +1 -0
  129. package/build/esm/observable/internal/objectset/ObjectSetQuery.js +151 -0
  130. package/build/esm/observable/internal/objectset/ObjectSetQuery.js.map +1 -0
  131. package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js +2 -0
  132. package/build/esm/observable/internal/objectset/ObjectSetQueryOptions.js.map +1 -0
  133. package/build/esm/ontology/loadActionMetadata.js +1 -3
  134. package/build/esm/ontology/loadActionMetadata.js.map +1 -1
  135. package/build/esm/ontology/loadFullObjectMetadata.js +1 -2
  136. package/build/esm/ontology/loadFullObjectMetadata.js.map +1 -1
  137. package/build/esm/ontology/loadInterfaceMetadata.js +1 -2
  138. package/build/esm/ontology/loadInterfaceMetadata.js.map +1 -1
  139. package/build/esm/public/unstable-do-not-use.js +1 -0
  140. package/build/esm/public/unstable-do-not-use.js.map +1 -1
  141. package/build/esm/util/UserAgent.js +2 -2
  142. package/build/esm/util/UserAgent.js.map +1 -1
  143. package/build/esm/util/exponentialBackoff.js +51 -0
  144. package/build/esm/util/exponentialBackoff.js.map +1 -0
  145. package/build/esm/util/exponentialBackoff.test.js +81 -0
  146. package/build/esm/util/exponentialBackoff.test.js.map +1 -0
  147. package/build/esm/util/toDataValue.js +1 -15
  148. package/build/esm/util/toDataValue.js.map +1 -1
  149. package/build/esm/util/toDataValue.test.js +2 -42
  150. package/build/esm/util/toDataValue.test.js.map +1 -1
  151. package/build/types/MinimalClientContext.d.ts +0 -1
  152. package/build/types/MinimalClientContext.d.ts.map +1 -1
  153. package/build/types/actions/applyAction.d.ts.map +1 -1
  154. package/build/types/createClient.d.ts +0 -1
  155. package/build/types/createClient.d.ts.map +1 -1
  156. package/build/types/index.d.ts +1 -1
  157. package/build/types/index.d.ts.map +1 -1
  158. package/build/types/object/fetchPage.d.ts.map +1 -1
  159. package/build/types/object/mediaUpload.d.ts +1 -2
  160. package/build/types/object/mediaUpload.d.ts.map +1 -1
  161. package/build/types/observable/ObjectSetPayload.d.ts +5 -0
  162. package/build/types/observable/ObjectSetPayload.d.ts.map +1 -0
  163. package/build/types/observable/ObservableClient.d.ts +54 -1
  164. package/build/types/observable/ObservableClient.d.ts.map +1 -1
  165. package/build/types/observable/computeObjectSetCacheKey.d.ts +16 -0
  166. package/build/types/observable/computeObjectSetCacheKey.d.ts.map +1 -0
  167. package/build/types/observable/internal/Changes.d.ts +5 -3
  168. package/build/types/observable/internal/Changes.d.ts.map +1 -1
  169. package/build/types/observable/internal/KnownCacheKey.d.ts +2 -1
  170. package/build/types/observable/internal/KnownCacheKey.d.ts.map +1 -1
  171. package/build/types/observable/internal/Query.d.ts.map +1 -1
  172. package/build/types/observable/internal/Store.d.ts +5 -1
  173. package/build/types/observable/internal/Store.d.ts.map +1 -1
  174. package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts +16 -0
  175. package/build/types/observable/internal/objectset/ObjectSetCacheKey.d.ts.map +1 -0
  176. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts +19 -0
  177. package/build/types/observable/internal/objectset/ObjectSetHelper.d.ts.map +1 -0
  178. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts +34 -0
  179. package/build/types/observable/internal/objectset/ObjectSetQuery.d.ts.map +1 -0
  180. package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts +18 -0
  181. package/build/types/observable/internal/objectset/ObjectSetQueryOptions.d.ts.map +1 -0
  182. package/build/types/public/unstable-do-not-use.d.ts +2 -1
  183. package/build/types/public/unstable-do-not-use.d.ts.map +1 -1
  184. package/build/types/util/exponentialBackoff.d.ts +14 -0
  185. package/build/types/util/exponentialBackoff.d.ts.map +1 -0
  186. package/build/types/util/exponentialBackoff.test.d.ts +1 -0
  187. package/build/types/util/exponentialBackoff.test.d.ts.map +1 -0
  188. package/package.json +8 -8
  189. package/build/cjs/chunk-HCCGD2AP.cjs.map +0 -1
  190. package/build/cjs/chunk-MKL3HEQ5.cjs.map +0 -1
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ObjectSetPayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectSetPayload.js","names":[],"sources":["ObjectSetPayload.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet } from \"@osdk/api\";\nimport type { BaseCollectionPayload } from \"./internal/base-list/BaseCollectionQuery.js\";\n\nexport interface ObjectSetPayload extends BaseCollectionPayload {\n objectSet: ObjectSet<any, any>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableClient.js","names":["createFetchHeaderMutator","additionalContext","createClientFromContext","OBSERVABLE_USER_AGENT","ObservableClientImpl","Store","ObservableClient","createObservableClient","client","tweakedClient","fetch","headers","set","get","filter","x","length","join"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionValidationResponse,\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport { createFetchHeaderMutator } from \"@osdk/shared.net.fetch\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientFromContext } from \"../createClient.js\";\nimport { OBSERVABLE_USER_AGENT } from \"../util/UserAgent.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type {\n CommonObserveOptions,\n InvalidationMode,\n ObserveOptions,\n Observer,\n Status,\n} from \"./ObservableClient/common.js\";\nimport type { ObserveLinks } from \"./ObservableClient/ObserveLink.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\n\nexport interface ObserveObjectOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> extends ObserveOptions {\n apiName: T[\"apiName\"] | T;\n pk: PrimaryKeyType<T>;\n select?: PropertyKeys<T>[];\n}\n\nexport type OrderBy<Q extends ObjectTypeDefinition | InterfaceDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\nexport interface ObserveListOptions<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n> extends CommonObserveOptions, ObserveOptions {\n type: Pick<Q, \"apiName\" | \"type\">;\n where?: WhereClause<Q>;\n pageSize?: number;\n orderBy?: OrderBy<Q>;\n invalidationMode?: InvalidationMode;\n expectedLength?: number;\n streamUpdates?: boolean;\n}\n\n// TODO: Rename this from `ObserveObjectArgs` => `ObserveObjectCallbackArgs`. Not doing it now to reduce churn\n// in repo.\nexport interface ObserveObjectArgs<T extends ObjectTypeDefinition> {\n object: Osdk.Instance<T> | undefined;\n isOptimistic: boolean;\n status: Status;\n lastUpdated: number;\n}\n\n// TODO: Rename this from `ObserveObjectsArgs` => `ObserveObjectsCallbackArgs`. Not doing it now to reduce churn\nexport interface ObserveObjectsArgs<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n resolvedList: Array<Osdk.Instance<T>>;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n}\n\n/**\n * User facing callback args for `observeLink`\n */\nexport interface ObserveLinkCallbackArgs<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n resolvedList: Osdk.Instance<T>[];\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n}\n\n/**\n * Public interface for reactive data management with automatic updates.\n *\n * The ObservableClient provides a reactive data layer with:\n * - Real-time object and collection observation\n * - Automatic cache updates when data changes\n * - Optimistic updates for immediate UI feedback\n * - Pagination support for large collections\n * - Link traversal for relationship navigation\n */\nexport interface ObservableClient extends ObserveLinks {\n /**\n * Observe a single object with automatic updates when it changes.\n *\n * @param apiName - The object type definition or name\n * @param pk - The object's primary key\n * @param options - Observation options including deduplication interval\n * @param subFn - Observer that receives object state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * The observer will receive:\n * - Initial loading state if data not cached\n * - Loaded state with the object data\n * - Updates when the object changes\n * - Error state if fetch fails\n */\n observeObject<T extends ObjectTypeDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: ObserveOptions,\n subFn: Observer<ObserveObjectArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Observe a filtered and sorted collection of objects.\n *\n * @param options - Filter, sort, and pagination options\n * @param subFn - Observer that receives collection state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Filtering with where clauses\n * - Sorting with orderBy\n * - Pagination via fetchMore() in the payload\n * - Automatic updates when any matching object changes\n */\n observeList<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ObserveObjectsArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Execute an action with optional optimistic updates.\n *\n * @param action - Action definition to execute\n * @param args - Arguments for the action\n * @param opts - Options including optimistic updates\n * @returns Promise that resolves when the action completes\n *\n * When providing optimistic updates:\n * - Changes appear immediately in the UI\n * - Server request still happens in background\n * - On success, server data replaces optimistic data\n * - On failure, optimistic changes automatically roll back\n */\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args:\n | Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n | Array<Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]>,\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n /**\n * Validate action parameters without executing the action.\n *\n * @param action - Action definition to validate\n * @param args - Arguments to validate\n * @returns Promise with validation result\n *\n * Use this to:\n * - Pre-validate forms before submission\n * - Display warnings or errors in the UI\n * - Enable/disable action buttons based on validity\n */\n validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n canonicalizeWhereClause: <\n T extends ObjectTypeDefinition | InterfaceDefinition,\n >(\n where: WhereClause<T>,\n ) => Canonical<WhereClause<T>>;\n}\n\nexport function createObservableClient(client: Client): ObservableClient {\n // First we need a modified client that adds an extra header so we know its\n // an observable client\n const tweakedClient = createClientFromContext({\n ...client[additionalContext],\n\n fetch: createFetchHeaderMutator(\n client[additionalContext].fetch,\n (headers) => {\n headers.set(\n \"Fetch-User-Agent\",\n [\n headers.get(\"Fetch-User-Agent\"),\n OBSERVABLE_USER_AGENT,\n ].filter(x => x && x?.length > 0).join(\" \"),\n );\n return headers;\n },\n ),\n });\n\n // Then we use that client instead. Because the `client` does not hold\n // any real state, this whole thing works.\n return new ObservableClientImpl(new Store(tweakedClient));\n}\n\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,wBAAwB,QAAQ,wBAAwB;AAEjE,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,uBAAuB,QAAQ,oBAAoB;AAC5D,SAASC,qBAAqB,QAAQ,sBAAsB;AAE5D,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,KAAK,QAAQ,qBAAqB;AAAC,WAW3BC,gBAAgB;AA8BjC;AACA;;AAQA;;AAYA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAwFA,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAoB;EACvE;EACA;EACA,MAAMC,aAAa,GAAGP,uBAAuB,CAAC;IAC5C,GAAGM,MAAM,CAACP,iBAAiB,CAAC;IAE5BS,KAAK,EAAEV,wBAAwB,CAC7BQ,MAAM,CAACP,iBAAiB,CAAC,CAACS,KAAK,EAC9BC,OAAO,IAAK;MACXA,OAAO,CAACC,GAAG,CACT,kBAAkB,EAClB,CACED,OAAO,CAACE,GAAG,CAAC,kBAAkB,CAAC,EAC/BV,qBAAqB,CACtB,CAACW,MAAM,CAACC,CAAC,IAAIA,CAAC,IAAIA,CAAC,EAAEC,MAAM,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAC5C,CAAC;MACD,OAAON,OAAO;IAChB,CACF;EACF,CAAC,CAAC;;EAEF;EACA;EACA,OAAO,IAAIP,oBAAoB,CAAC,IAAIC,KAAK,CAACI,aAAa,CAAC,CAAC;AAC3D","ignoreList":[]}
1
+ {"version":3,"file":"ObservableClient.js","names":["createFetchHeaderMutator","additionalContext","createClientFromContext","OBSERVABLE_USER_AGENT","ObservableClientImpl","Store","ObservableClient","createObservableClient","client","tweakedClient","fetch","headers","set","get","filter","x","length","join"],"sources":["ObservableClient.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionValidationResponse,\n InterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport { createFetchHeaderMutator } from \"@osdk/shared.net.fetch\";\nimport type { ActionSignatureFromDef } from \"../actions/applyAction.js\";\nimport { additionalContext, type Client } from \"../Client.js\";\nimport { createClientFromContext } from \"../createClient.js\";\nimport { OBSERVABLE_USER_AGENT } from \"../util/UserAgent.js\";\nimport type { Canonical } from \"./internal/Canonical.js\";\nimport type { ObserveObjectSetOptions } from \"./internal/objectset/ObjectSetQueryOptions.js\";\nimport { ObservableClientImpl } from \"./internal/ObservableClientImpl.js\";\nimport { Store } from \"./internal/Store.js\";\nimport type {\n CommonObserveOptions,\n InvalidationMode,\n ObserveOptions,\n Observer,\n Status,\n} from \"./ObservableClient/common.js\";\nimport type { ObserveLinks } from \"./ObservableClient/ObserveLink.js\";\nimport type { OptimisticBuilder } from \"./OptimisticBuilder.js\";\n\nexport namespace ObservableClient {\n export interface ApplyActionOptions {\n optimisticUpdate?: (ctx: OptimisticBuilder) => void;\n }\n}\n\nexport interface ObserveObjectOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> extends ObserveOptions {\n apiName: T[\"apiName\"] | T;\n pk: PrimaryKeyType<T>;\n select?: PropertyKeys<T>[];\n}\n\nexport type OrderBy<Q extends ObjectTypeDefinition | InterfaceDefinition> = {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" | undefined;\n};\n\nexport interface ObserveListOptions<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n> extends CommonObserveOptions, ObserveOptions {\n type: Pick<Q, \"apiName\" | \"type\">;\n where?: WhereClause<Q>;\n pageSize?: number;\n orderBy?: OrderBy<Q>;\n invalidationMode?: InvalidationMode;\n expectedLength?: number;\n streamUpdates?: boolean;\n}\n\n// TODO: Rename this from `ObserveObjectArgs` => `ObserveObjectCallbackArgs`. Not doing it now to reduce churn\n// in repo.\nexport interface ObserveObjectArgs<T extends ObjectTypeDefinition> {\n object: Osdk.Instance<T> | undefined;\n isOptimistic: boolean;\n status: Status;\n lastUpdated: number;\n}\n\n// TODO: Rename this from `ObserveObjectsArgs` => `ObserveObjectsCallbackArgs`. Not doing it now to reduce churn\nexport interface ObserveObjectsArgs<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n resolvedList: Array<Osdk.Instance<T>>;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n}\n\nexport interface ObserveObjectSetArgs<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n> {\n resolvedList: Array<\n Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>\n >;\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n objectSet: ObjectSet<T, RDPs>;\n}\n\n/**\n * User facing callback args for `observeLink`\n */\nexport interface ObserveLinkCallbackArgs<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n resolvedList: Osdk.Instance<T>[];\n isOptimistic: boolean;\n lastUpdated: number;\n fetchMore: () => Promise<void>;\n hasMore: boolean;\n status: Status;\n}\n\n/**\n * Public interface for reactive data management with automatic updates.\n *\n * The ObservableClient provides a reactive data layer with:\n * - Real-time object and collection observation\n * - Automatic cache updates when data changes\n * - Optimistic updates for immediate UI feedback\n * - Pagination support for large collections\n * - Link traversal for relationship navigation\n */\nexport interface ObservableClient extends ObserveLinks {\n /**\n * Observe a single object with automatic updates when it changes.\n *\n * @param apiName - The object type definition or name\n * @param pk - The object's primary key\n * @param options - Observation options including deduplication interval\n * @param subFn - Observer that receives object state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * The observer will receive:\n * - Initial loading state if data not cached\n * - Loaded state with the object data\n * - Updates when the object changes\n * - Error state if fetch fails\n */\n observeObject<T extends ObjectTypeDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: ObserveOptions,\n subFn: Observer<ObserveObjectArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Observe a filtered and sorted collection of objects.\n *\n * @param options - Filter, sort, and pagination options\n * @param subFn - Observer that receives collection state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports:\n * - Filtering with where clauses\n * - Sorting with orderBy\n * - Pagination via fetchMore() in the payload\n * - Automatic updates when any matching object changes\n */\n observeList<T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ObserveObjectsArgs<T>>,\n ): Unsubscribable;\n\n /**\n * Observe an ObjectSet with automatic updates when matching objects change.\n *\n * @param baseObjectSet - The base ObjectSet to observe\n * @param options - Options for transforming and observing the ObjectSet\n * @param subFn - Observer that receives ObjectSet state updates\n * @returns Subscription that can be unsubscribed to stop updates\n *\n * Supports all ObjectSet operations:\n * - Filtering with where clauses\n * - Derived properties with withProperties\n * - Set operations (union, intersect, subtract)\n * - Link traversal with pivotTo\n * - Sorting and pagination\n */\n observeObjectSet<\n T extends ObjectTypeDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n >(\n baseObjectSet: ObjectSet<T>,\n options: ObserveObjectSetOptions<T, RDPs>,\n subFn: Observer<ObserveObjectSetArgs<T, RDPs>>,\n ): Unsubscribable;\n\n /**\n * Execute an action with optional optimistic updates.\n *\n * @param action - Action definition to execute\n * @param args - Arguments for the action\n * @param opts - Options including optimistic updates\n * @returns Promise that resolves when the action completes\n *\n * When providing optimistic updates:\n * - Changes appear immediately in the UI\n * - Server request still happens in background\n * - On success, server data replaces optimistic data\n * - On failure, optimistic changes automatically roll back\n */\n applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args:\n | Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n | Array<Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]>,\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n /**\n * Validate action parameters without executing the action.\n *\n * @param action - Action definition to validate\n * @param args - Arguments to validate\n * @returns Promise with validation result\n *\n * Use this to:\n * - Pre-validate forms before submission\n * - Display warnings or errors in the UI\n * - Enable/disable action buttons based on validity\n */\n validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n /**\n * Invalidates the entire cache, forcing all queries to refetch.\n * Use sparingly as this can cause significant network traffic.\n */\n invalidateAll(): Promise<void>;\n\n /**\n * Invalidates specific objects in the cache.\n * @param objects - Single object or array of objects to invalidate\n */\n invalidateObjects(\n objects:\n | Osdk.Instance<ObjectTypeDefinition>\n | ReadonlyArray<Osdk.Instance<ObjectTypeDefinition>>,\n ): Promise<void>;\n\n /**\n * Invalidates all cached data for a specific object type.\n * This includes:\n * - All objects of the specified type\n * - All lists containing objects of this type\n * - All links where the source is of this type\n *\n * @param type - Object type definition or API name string\n * @returns Promise that resolves when invalidation is complete\n */\n invalidateObjectType<T extends ObjectTypeDefinition>(\n type: T | T[\"apiName\"],\n ): Promise<void>;\n\n canonicalizeWhereClause: <\n T extends ObjectTypeDefinition | InterfaceDefinition,\n >(\n where: WhereClause<T>,\n ) => Canonical<WhereClause<T>>;\n}\n\nexport function createObservableClient(client: Client): ObservableClient {\n // First we need a modified client that adds an extra header so we know its\n // an observable client\n const tweakedClient = createClientFromContext({\n ...client[additionalContext],\n\n fetch: createFetchHeaderMutator(\n client[additionalContext].fetch,\n (headers) => {\n headers.set(\n \"Fetch-User-Agent\",\n [\n headers.get(\"Fetch-User-Agent\"),\n OBSERVABLE_USER_AGENT,\n ].filter(x => x && x?.length > 0).join(\" \"),\n );\n return headers;\n },\n ),\n });\n\n // Then we use that client instead. Because the `client` does not hold\n // any real state, this whole thing works.\n return new ObservableClientImpl(new Store(tweakedClient));\n}\n\nexport interface Unsubscribable {\n unsubscribe: () => void;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,SAASA,wBAAwB,QAAQ,wBAAwB;AAEjE,SAASC,iBAAiB,QAAqB,cAAc;AAC7D,SAASC,uBAAuB,QAAQ,oBAAoB;AAC5D,SAASC,qBAAqB,QAAQ,sBAAsB;AAG5D,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,KAAK,QAAQ,qBAAqB;AAAC,WAW3BC,gBAAgB;AA8BjC;AACA;;AAQA;;AA8BA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiJA,OAAO,SAASC,sBAAsBA,CAACC,MAAc,EAAoB;EACvE;EACA;EACA,MAAMC,aAAa,GAAGP,uBAAuB,CAAC;IAC5C,GAAGM,MAAM,CAACP,iBAAiB,CAAC;IAE5BS,KAAK,EAAEV,wBAAwB,CAC7BQ,MAAM,CAACP,iBAAiB,CAAC,CAACS,KAAK,EAC9BC,OAAO,IAAK;MACXA,OAAO,CAACC,GAAG,CACT,kBAAkB,EAClB,CACED,OAAO,CAACE,GAAG,CAAC,kBAAkB,CAAC,EAC/BV,qBAAqB,CACtB,CAACW,MAAM,CAACC,CAAC,IAAIA,CAAC,IAAIA,CAAC,EAAEC,MAAM,GAAG,CAAC,CAAC,CAACC,IAAI,CAAC,GAAG,CAC5C,CAAC;MACD,OAAON,OAAO;IAChB,CACF;EACF,CAAC,CAAC;;EAEF;EACA;EACA,OAAO,IAAIP,oBAAoB,CAAC,IAAIC,KAAK,CAACI,aAAa,CAAC,CAAC;AAC3D","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { getWireObjectSet } from "../objectSet/createObjectSet.js";
18
+ import { OrderByCanonicalizer } from "./internal/OrderByCanonicalizer.js";
19
+ import { WhereClauseCanonicalizer } from "./internal/WhereClauseCanonicalizer.js";
20
+ const whereCanonicalizer = new WhereClauseCanonicalizer();
21
+ const orderByCanonicalizer = new OrderByCanonicalizer();
22
+
23
+ /**
24
+ * Computes a stable cache key for an ObjectSet with options.
25
+ *
26
+ * Note: dedupeInterval is excluded as it doesn't affect the data, only the refresh rate.
27
+ *
28
+ * @param objectSet - The base ObjectSet
29
+ * @param options - Optional observation options (where, orderBy, etc.)
30
+ * @returns A stable string key representing the ObjectSet and options
31
+ */
32
+ export function computeObjectSetCacheKey(objectSet, options) {
33
+ const keyParts = ["objectSet", getWireObjectSet(objectSet)];
34
+ if (!options) {
35
+ return JSON.stringify(keyParts);
36
+ }
37
+ if (options.where) {
38
+ keyParts.push("where", whereCanonicalizer.canonicalize(options.where));
39
+ }
40
+ if (options.withProperties) {
41
+ const propKeys = Object.keys(options.withProperties).sort();
42
+ keyParts.push("props", propKeys);
43
+ }
44
+ if (options.union && options.union.length > 0) {
45
+ keyParts.push("union", options.union.map(os => getWireObjectSet(os)));
46
+ }
47
+ if (options.intersect && options.intersect.length > 0) {
48
+ keyParts.push("intersect", options.intersect.map(os => getWireObjectSet(os)));
49
+ }
50
+ if (options.subtract && options.subtract.length > 0) {
51
+ keyParts.push("subtract", options.subtract.map(os => getWireObjectSet(os)));
52
+ }
53
+ if (options.pivotTo) {
54
+ keyParts.push("pivotTo", options.pivotTo);
55
+ }
56
+ if (options.orderBy) {
57
+ keyParts.push("orderBy", orderByCanonicalizer.canonicalize(options.orderBy));
58
+ }
59
+ if (options.pageSize) {
60
+ keyParts.push("pageSize", options.pageSize);
61
+ }
62
+ return JSON.stringify(keyParts);
63
+ }
64
+ //# sourceMappingURL=computeObjectSetCacheKey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"computeObjectSetCacheKey.js","names":["getWireObjectSet","OrderByCanonicalizer","WhereClauseCanonicalizer","whereCanonicalizer","orderByCanonicalizer","computeObjectSetCacheKey","objectSet","options","keyParts","JSON","stringify","where","push","canonicalize","withProperties","propKeys","Object","keys","sort","union","length","map","os","intersect","subtract","pivotTo","orderBy","pageSize"],"sources":["computeObjectSetCacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n BaseObjectSet,\n ObjectSet,\n ObjectTypeDefinition,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport { getWireObjectSet } from \"../objectSet/createObjectSet.js\";\nimport type { ObserveObjectSetOptions } from \"./internal/objectset/ObjectSetQueryOptions.js\";\nimport { OrderByCanonicalizer } from \"./internal/OrderByCanonicalizer.js\";\nimport { WhereClauseCanonicalizer } from \"./internal/WhereClauseCanonicalizer.js\";\n\nconst whereCanonicalizer = new WhereClauseCanonicalizer();\nconst orderByCanonicalizer = new OrderByCanonicalizer();\n\n/**\n * Computes a stable cache key for an ObjectSet with options.\n *\n * Note: dedupeInterval is excluded as it doesn't affect the data, only the refresh rate.\n *\n * @param objectSet - The base ObjectSet\n * @param options - Optional observation options (where, orderBy, etc.)\n * @returns A stable string key representing the ObjectSet and options\n */\nexport function computeObjectSetCacheKey<\n T extends ObjectTypeDefinition,\n BaseRDPs extends\n | Record<string, WirePropertyTypes | undefined | Array<WirePropertyTypes>>\n | BaseObjectSet<T> = never,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n>(\n objectSet: ObjectSet<T, BaseRDPs>,\n options?: ObserveObjectSetOptions<T, RDPs>,\n): string {\n const keyParts: Array<unknown> = [\n \"objectSet\",\n getWireObjectSet(objectSet as unknown as ObjectSet<any>),\n ];\n\n if (!options) {\n return JSON.stringify(keyParts);\n }\n\n if (options.where) {\n keyParts.push(\"where\", whereCanonicalizer.canonicalize(options.where));\n }\n\n if (options.withProperties) {\n const propKeys = Object.keys(options.withProperties).sort();\n keyParts.push(\"props\", propKeys);\n }\n\n if (options.union && options.union.length > 0) {\n keyParts.push(\n \"union\",\n options.union.map((os: ObjectSet<T>) =>\n getWireObjectSet(os as unknown as ObjectSet<any>)\n ),\n );\n }\n\n if (options.intersect && options.intersect.length > 0) {\n keyParts.push(\n \"intersect\",\n options.intersect.map((os: ObjectSet<T>) =>\n getWireObjectSet(os as unknown as ObjectSet<any>)\n ),\n );\n }\n\n if (options.subtract && options.subtract.length > 0) {\n keyParts.push(\n \"subtract\",\n options.subtract.map((os: ObjectSet<T>) =>\n getWireObjectSet(os as unknown as ObjectSet<any>)\n ),\n );\n }\n\n if (options.pivotTo) {\n keyParts.push(\"pivotTo\", options.pivotTo);\n }\n\n if (options.orderBy) {\n keyParts.push(\n \"orderBy\",\n orderByCanonicalizer.canonicalize(options.orderBy),\n );\n }\n\n if (options.pageSize) {\n keyParts.push(\"pageSize\", options.pageSize);\n }\n\n return JSON.stringify(keyParts);\n}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AG,CAAC,EAAE;IACrDZ,QAAQ,CAACI,IAAI,CACX,WAAW,EACXL,OAAO,CAACgB,SAAS,CAACF,GAAG,CAAEC,EAAgB,IACrCtB,gBAAgB,CAACsB,EAA+B,CAClD,CACF,CAAC;EACH;EAEA,IAAIf,OAAO,CAACiB,QAAQ,IAAIjB,OAAO,CAACiB,QAAQ,CAACJ,MAAM,GAAG,CAAC,EAAE;IACnDZ,QAAQ,CAACI,IAAI,CACX,UAAU,EACVL,OAAO,CAACiB,QAAQ,CAACH,GAAG,CAAEC,EAAgB,IACpCtB,gBAAgB,CAACsB,EAA+B,CAClD,CACF,CAAC;EACH;EAEA,IAAIf,OAAO,CAACkB,OAAO,EAAE;IACnBjB,QAAQ,CAACI,IAAI,CAAC,SAAS,EAAEL,OAAO,CAACkB,OAAO,CAAC;EAC3C;EAEA,IAAIlB,OAAO,CAACmB,OAAO,EAAE;IACnBlB,QAAQ,CAACI,IAAI,CACX,SAAS,EACTR,oBAAoB,CAACS,YAAY,CAACN,OAAO,CAACmB,OAAO,CACnD,CAAC;EACH;EAEA,IAAInB,OAAO,CAACoB,QAAQ,EAAE;IACpBnB,QAAQ,CAACI,IAAI,CAAC,UAAU,EAAEL,OAAO,CAACoB,QAAQ,CAAC;EAC7C;EAEA,OAAOlB,IAAI,CAACC,SAAS,CAACF,QAAQ,CAAC;AACjC","ignoreList":[]}
@@ -38,6 +38,9 @@ export class Changes {
38
38
  deleteLink = cacheKey => {
39
39
  this.deleted.add(cacheKey);
40
40
  };
41
+ registerObjectSet = key => {
42
+ this.modified.add(key);
43
+ };
41
44
  isEmpty() {
42
45
  return this.modifiedObjects.size === 0 && this.addedObjects.size === 0 && this.added.size === 0 && this.modified.size === 0 && this.deleted.size === 0;
43
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Changes.js","names":["MultiMap","DEBUG_ONLY__cacheKeyToString","Changes","modifiedObjects","addedObjects","added","Set","modified","deleted","registerObject","cacheKey","data","isNew","set","$apiName","add","deleteObject","registerList","key","registerLink","deleteLink","isEmpty","size","createChangedObjects","DEBUG_ONLY__changesToString","changes","process","env","NODE_ENV","JSON","stringify","multimapHelper","listHelper","Error","Array","from","map","multimap","Object","fromEntries","associations","type","objects","o","$primaryKey"],"sources":["Changes.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiMap } from \"mnemonist\";\nimport type { ObjectHolder } from \"../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { DEBUG_ONLY__cacheKeyToString } from \"./CacheKey.js\";\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\n\nexport class Changes {\n modifiedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n addedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n\n added: Set<ListCacheKey | ObjectCacheKey | SpecificLinkCacheKey> = new Set();\n modified: Set<ListCacheKey | ObjectCacheKey | SpecificLinkCacheKey> =\n new Set();\n deleted: Set<ListCacheKey | ObjectCacheKey | SpecificLinkCacheKey> =\n new Set();\n\n registerObject = (\n cacheKey: ObjectCacheKey,\n data: ObjectHolder,\n isNew: boolean,\n ): void => {\n this[isNew ? \"addedObjects\" : \"modifiedObjects\"].set(data.$apiName, data);\n this[isNew ? \"added\" : \"modified\"].add(cacheKey);\n };\n\n deleteObject = (cacheKey: ObjectCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n registerList = (key: ListCacheKey): void => {\n this.modified.add(key);\n };\n\n registerLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.modified.add(cacheKey);\n };\n\n deleteLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n isEmpty(): boolean {\n return (\n this.modifiedObjects.size === 0\n && this.addedObjects.size === 0\n && this.added.size === 0\n && this.modified.size === 0\n && this.deleted.size === 0\n );\n }\n}\n\nexport function createChangedObjects(): Changes {\n return new Changes();\n}\n\nexport function DEBUG_ONLY__changesToString(changes: Changes): string {\n if (process.env.NODE_ENV !== \"production\") {\n return JSON.stringify(\n {\n modifiedObjects: multimapHelper(changes.modifiedObjects),\n addedObjects: multimapHelper(changes.addedObjects),\n added: listHelper(changes.added),\n modified: listHelper(changes.modified),\n },\n null,\n 2,\n );\n } else {\n throw new Error(\"not implemented\");\n }\n}\n\nfunction listHelper(set: Set<CacheKey>) {\n return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);\n}\n\nfunction multimapHelper(\n multimap: MultiMap<string, ObjectHolder>,\n) {\n return Object.fromEntries(\n Array.from(multimap.associations()).map(\n ([type, objects]) => {\n return [type, objects.map(o => o.$primaryKey)];\n },\n ),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,WAAW;AAGpC,SAASC,4BAA4B,QAAQ,eAAe;AAK5D,OAAO,MAAMC,OAAO,CAAC;EACnBC,eAAe,GAAmC,IAAIH,QAAQ,CAAC,CAAC;EAChEI,YAAY,GAAmC,IAAIJ,QAAQ,CAAC,CAAC;EAE7DK,KAAK,GAA8D,IAAIC,GAAG,CAAC,CAAC;EAC5EC,QAAQ,GACN,IAAID,GAAG,CAAC,CAAC;EACXE,OAAO,GACL,IAAIF,GAAG,CAAC,CAAC;EAEXG,cAAc,GAAGA,CACfC,QAAwB,EACxBC,IAAkB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DC,YAAY,EAAE2B,cAAc,CAACN,OAAO,CAACrB,YAAY,CAAC;MAClDC,KAAK,EAAE2B,UAAU,CAACP,OAAO,CAACpB,KAAK,CAAC;MAChCE,QAAQ,EAAEyB,UAAU,CAACP,OAAO,CAAClB,QAAQ;IACvC,CAAC,EACD,IAAI,EACJ,CACF,CAAC;EACH,CAAC,MAAM;IACL,MAAM,IAAI0B,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF;AAEA,SAASD,UAAUA,CAACnB,GAAkB,EAAE;EACtC,OAAOqB,KAAK,CAACC,IAAI,CAACtB,GAAG,CAAC,CAACuB,GAAG,CAACnC,4BAA4B,CAAC;AAC1D;AAEA,SAAS8B,cAAcA,CACrBM,QAAwC,EACxC;EACA,OAAOC,MAAM,CAACC,WAAW,CACvBL,KAAK,CAACC,IAAI,CAACE,QAAQ,CAACG,YAAY,CAAC,CAAC,CAAC,CAACJ,GAAG,CACrC,CAAC,CAACK,IAAI,EAAEC,OAAO,CAAC,KAAK;IACnB,OAAO,CAACD,IAAI,EAAEC,OAAO,CAACN,GAAG,CAACO,CAAC,IAAIA,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,CACF,CACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"Changes.js","names":["MultiMap","DEBUG_ONLY__cacheKeyToString","Changes","modifiedObjects","addedObjects","added","Set","modified","deleted","registerObject","cacheKey","data","isNew","set","$apiName","add","deleteObject","registerList","key","registerLink","deleteLink","registerObjectSet","isEmpty","size","createChangedObjects","DEBUG_ONLY__changesToString","changes","process","env","NODE_ENV","JSON","stringify","multimapHelper","listHelper","Error","Array","from","map","multimap","Object","fromEntries","associations","type","objects","o","$primaryKey"],"sources":["Changes.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { MultiMap } from \"mnemonist\";\nimport type { ObjectHolder } from \"../../object/convertWireToOsdkObjects/ObjectHolder.js\";\nimport type { CacheKey } from \"./CacheKey.js\";\nimport { DEBUG_ONLY__cacheKeyToString } from \"./CacheKey.js\";\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport class Changes {\n modifiedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n addedObjects: MultiMap<string, ObjectHolder> = new MultiMap();\n\n added: Set<\n ListCacheKey | ObjectCacheKey | SpecificLinkCacheKey | ObjectSetCacheKey\n > = new Set();\n modified: Set<\n ListCacheKey | ObjectCacheKey | SpecificLinkCacheKey | ObjectSetCacheKey\n > = new Set();\n deleted: Set<\n ListCacheKey | ObjectCacheKey | SpecificLinkCacheKey | ObjectSetCacheKey\n > = new Set();\n\n registerObject = (\n cacheKey: ObjectCacheKey,\n data: ObjectHolder,\n isNew: boolean,\n ): void => {\n this[isNew ? \"addedObjects\" : \"modifiedObjects\"].set(data.$apiName, data);\n this[isNew ? \"added\" : \"modified\"].add(cacheKey);\n };\n\n deleteObject = (cacheKey: ObjectCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n registerList = (key: ListCacheKey): void => {\n this.modified.add(key);\n };\n\n registerLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.modified.add(cacheKey);\n };\n\n deleteLink = (cacheKey: SpecificLinkCacheKey): void => {\n this.deleted.add(cacheKey);\n };\n\n registerObjectSet = (key: ObjectSetCacheKey): void => {\n this.modified.add(key);\n };\n\n isEmpty(): boolean {\n return (\n this.modifiedObjects.size === 0\n && this.addedObjects.size === 0\n && this.added.size === 0\n && this.modified.size === 0\n && this.deleted.size === 0\n );\n }\n}\n\nexport function createChangedObjects(): Changes {\n return new Changes();\n}\n\nexport function DEBUG_ONLY__changesToString(changes: Changes): string {\n if (process.env.NODE_ENV !== \"production\") {\n return JSON.stringify(\n {\n modifiedObjects: multimapHelper(changes.modifiedObjects),\n addedObjects: multimapHelper(changes.addedObjects),\n added: listHelper(changes.added),\n modified: listHelper(changes.modified),\n },\n null,\n 2,\n );\n } else {\n throw new Error(\"not implemented\");\n }\n}\n\nfunction listHelper(set: Set<CacheKey>) {\n return Array.from(set).map(DEBUG_ONLY__cacheKeyToString);\n}\n\nfunction multimapHelper(\n multimap: MultiMap<string, ObjectHolder>,\n) {\n return Object.fromEntries(\n Array.from(multimap.associations()).map(\n ([type, objects]) => {\n return [type, objects.map(o => o.$primaryKey)];\n },\n ),\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,WAAW;AAGpC,SAASC,4BAA4B,QAAQ,eAAe;AAM5D,OAAO,MAAMC,OAAO,CAAC;EACnBC,eAAe,GAAmC,IAAIH,QAAQ,CAAC,CAAC;EAChEI,YAAY,GAAmC,IAAIJ,QAAQ,CAAC,CAAC;EAE7DK,KAAK,GAED,IAAIC,GAAG,CAAC,CAAC;EACbC,QAAQ,GAEJ,IAAID,GAAG,CAAC,CAAC;EACbE,OAAO,GAEH,IAAIF,GAAG,CAAC,CAAC;EAEbG,cAAc,GAAGA,CACfC,QAAwB,EACxBC,IAAkB,EAClBC,KAAc,KACL;IACT,IAAI,CAACA,KAAK,GAAG,cAAc,GAAG,iBAAiB,CAAC,CAACC,GAAG,CAACF,IAAI,CAACG,QAAQ,EAAEH,IAAI,CAAC;IACzE,IAAI,CAACC,KAAK,GAAG,OAAO,GAAG,UAAU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E4B,UAAU,CAACP,OAAO,CAACrB,KAAK,CAAC;MAChCE,QAAQ,EAAE0B,UAAU,CAACP,OAAO,CAACnB,QAAQ;IACvC,CAAC,EACD,IAAI,EACJ,CACF,CAAC;EACH,CAAC,MAAM;IACL,MAAM,IAAI2B,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF;AAEA,SAASD,UAAUA,CAACpB,GAAkB,EAAE;EACtC,OAAOsB,KAAK,CAACC,IAAI,CAACvB,GAAG,CAAC,CAACwB,GAAG,CAACpC,4BAA4B,CAAC;AAC1D;AAEA,SAAS+B,cAAcA,CACrBM,QAAwC,EACxC;EACA,OAAOC,MAAM,CAACC,WAAW,CACvBL,KAAK,CAACC,IAAI,CAACE,QAAQ,CAACG,YAAY,CAAC,CAAC,CAAC,CAACJ,GAAG,CACrC,CAAC,CAACK,IAAI,EAAEC,OAAO,CAAC,KAAK;IACnB,OAAO,CAACD,IAAI,EAAEC,OAAO,CAACN,GAAG,CAACO,CAAC,IAAIA,CAAC,CAACC,WAAW,CAAC,CAAC;EAChD,CACF,CACF,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"KnownCacheKey.js","names":[],"sources":["KnownCacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\n\nexport type KnownCacheKey =\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ListCacheKey;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"KnownCacheKey.js","names":[],"sources":["KnownCacheKey.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { SpecificLinkCacheKey } from \"./links/SpecificLinkCacheKey.js\";\nimport type { ListCacheKey } from \"./list/ListCacheKey.js\";\nimport type { ObjectCacheKey } from \"./object/ObjectCacheKey.js\";\nimport type { ObjectSetCacheKey } from \"./objectset/ObjectSetCacheKey.js\";\n\nexport type KnownCacheKey =\n | ObjectCacheKey\n | SpecificLinkCacheKey\n | ListCacheKey\n | ObjectSetCacheKey;\n"],"mappings":"","ignoreList":[]}
@@ -65,6 +65,23 @@ export class ObservableClientImpl {
65
65
  }
66
66
  return new UnsubscribableWrapper(parentSub);
67
67
  };
68
+ observeObjectSet(baseObjectSet, options, subFn) {
69
+ return this.__experimentalStore.objectSets.observe({
70
+ baseObjectSet,
71
+ ...options
72
+ },
73
+ // cast to cross typed to untyped barrier
74
+ subFn);
75
+ }
76
+ invalidateAll() {
77
+ return this.__experimentalStore.invalidateAll();
78
+ }
79
+ invalidateObjects(objects) {
80
+ return this.__experimentalStore.invalidateObjects(objects);
81
+ }
82
+ invalidateObjectType(type) {
83
+ return this.__experimentalStore.invalidateObjectType(type, undefined);
84
+ }
68
85
  canonicalizeWhereClause(where) {
69
86
  return this.__experimentalStore.whereCanonicalizer.canonicalize(where);
70
87
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ObservableClientImpl.js","names":["Subscription","UnsubscribableWrapper","ObservableClientImpl","constructor","store","__experimentalStore","applyAction","bind","validateAction","observeObject","apiName","pk","options","subFn","objects","observe","observeList","lists","observeLinks","linkName","objectsArray","Array","isArray","parentSub","obj","querySubscription","links","srcType","type","$apiName","$primaryKey","add","canonicalizeWhereClause","where","whereCanonicalizer","canonicalize"],"sources":["ObservableClientImpl.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionValidationResponse,\n CompileTimeMetadata,\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n WhereClause,\n} from \"@osdk/api\";\nimport { Subscription } from \"rxjs\";\nimport type { ActionSignatureFromDef } from \"../../actions/applyAction.js\";\nimport type { SpecificLinkPayload } from \"../LinkPayload.js\";\nimport type { ListPayload } from \"../ListPayload.js\";\nimport type { ObjectPayload } from \"../ObjectPayload.js\";\nimport type {\n ObservableClient,\n ObserveListOptions,\n ObserveObjectArgs,\n ObserveObjectOptions,\n ObserveObjectsArgs,\n Unsubscribable,\n} from \"../ObservableClient.js\";\nimport type { Observer } from \"../ObservableClient/common.js\";\nimport type { ObserveLinks } from \"../ObservableClient/ObserveLink.js\";\nimport type { Canonical } from \"./Canonical.js\";\nimport type { Store } from \"./Store.js\";\nimport { UnsubscribableWrapper } from \"./UnsubscribableWrapper.js\";\n\n/**\n * Implementation of the public ObservableClient interface.\n * - Delegates all operations to the Store for consistency\n * - Serves as the entry point for reactive data management\n * - Ensures proper method binding and API exposure\n *\n * @internal\n */\nexport class ObservableClientImpl implements ObservableClient {\n __experimentalStore: Store;\n\n constructor(store: Store) {\n this.__experimentalStore = store;\n\n this.applyAction = store.applyAction.bind(store);\n this.validateAction = store.validateAction.bind(store);\n }\n\n public observeObject: <T extends ObjectTypeDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: Omit<ObserveObjectOptions<T>, \"apiName\" | \"pk\">,\n subFn: Observer<ObserveObjectArgs<T>>,\n ) => Unsubscribable = (apiName, pk, options, subFn) => {\n return this.__experimentalStore.objects.observe(\n {\n ...options,\n apiName,\n pk,\n },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ObjectPayload>,\n );\n };\n\n public observeList: <T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ObserveObjectsArgs<T>>,\n ) => Unsubscribable = (options, subFn) => {\n return this.__experimentalStore.lists.observe(\n options,\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ListPayload>,\n );\n };\n\n public observeLinks: <\n T extends ObjectTypeDefinition | InterfaceDefinition,\n L extends keyof CompileTimeMetadata<T>[\"links\"] & string,\n >(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>>,\n linkName: L,\n options: ObserveLinks.Options<T, L>,\n subFn: Observer<\n ObserveLinks.CallbackArgs<\n CompileTimeMetadata<T>[\"links\"][L][\"targetType\"]\n >\n >,\n ) => Unsubscribable = (objects, linkName, options, subFn) => {\n // Convert to array if single object provided\n const objectsArray = Array.isArray(objects) ? objects : [objects];\n\n const parentSub = new Subscription();\n\n for (const obj of objectsArray) {\n const querySubscription = this.__experimentalStore.links\n .observe(\n {\n ...options,\n srcType: {\n type: \"object\",\n apiName: obj.$apiName,\n },\n linkName,\n pk: obj.$primaryKey,\n },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<SpecificLinkPayload>,\n );\n\n parentSub.add(querySubscription);\n }\n\n return new UnsubscribableWrapper(parentSub);\n };\n\n public applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n public validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n public canonicalizeWhereClause<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n >(where: WhereClause<T>): Canonical<WhereClause<T>> {\n return this.__experimentalStore.whereCanonicalizer\n .canonicalize(where) as Canonical<WhereClause<T>>;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,YAAY,QAAQ,MAAM;AAiBnC,SAASC,qBAAqB,QAAQ,4BAA4B;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAA6B;EAG5DC,WAAWA,CAACC,KAAY,EAAE;IACxB,IAAI,CAACC,mBAAmB,GAAGD,KAAK;IAEhC,IAAI,CAACE,WAAW,GAAGF,KAAK,CAACE,WAAW,CAACC,IAAI,CAACH,KAAK,CAAC;IAChD,IAAI,CAACI,cAAc,GAAGJ,KAAK,CAACI,cAAc,CAACD,IAAI,CAACH,KAAK,CAAC;EACxD;EAEOK,aAAa,GAKEA,CAACC,OAAO,EAAEC,EAAE,EAAEC,OAAO,EAAEC,KAAK,KAAK;IACrD,OAAO,IAAI,CAACR,mBAAmB,CAACS,OAAO,CAACC,OAAO,CAC7C;MACE,GAAGH,OAAO;MACVF,OAAO;MACPC;IACF,CAAC;IACD;IACAE,KACF,CAAC;EACH,CAAC;EAEMG,WAAW,GAGIA,CAACJ,OAAO,EAAEC,KAAK,KAAK;IACxC,OAAO,IAAI,CAACR,mBAAmB,CAACY,KAAK,CAACF,OAAO,CAC3CH,OAAO;IACP;IACAC,KACF,CAAC;EACH,CAAC;EAEMK,YAAY,GAYGA,CAACJ,OAAO,EAAEK,QAAQ,EAAEP,OAAO,EAAEC,KAAK,KAAK;IAC3D;IACA,MAAMO,YAAY,GAAGC,KAAK,CAACC,OAAO,CAACR,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC;IAEjE,MAAMS,SAAS,GAAG,IAAIvB,YAAY,CAAC,CAAC;IAEpC,KAAK,MAAMwB,GAAG,IAAIJ,YAAY,EAAE;MAC9B,MAAMK,iBAAiB,GAAG,IAAI,CAACpB,mBAAmB,CAACqB,KAAK,CACrDX,OAAO,CACN;QACE,GAAGH,OAAO;QACVe,OAAO,EAAE;UACPC,IAAI,EAAE,QAAQ;UACdlB,OAAO,EAAEc,GAAG,CAACK;QACf,CAAC;QACDV,QAAQ;QACRR,EAAE,EAAEa,GAAG,CAACM;MACV,CAAC;MACD;MACAjB,KACF,CAAC;MAEHU,SAAS,CAACQ,GAAG,CAACN,iBAAiB,CAAC;IAClC;IAEA,OAAO,IAAIxB,qBAAqB,CAACsB,SAAS,CAAC;EAC7C,CAAC;EAaMS,uBAAuBA,CAE5BC,KAAqB,EAA6B;IAClD,OAAO,IAAI,CAAC5B,mBAAmB,CAAC6B,kBAAkB,CAC/CC,YAAY,CAACF,KAAK,CAAC;EACxB;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ObservableClientImpl.js","names":["Subscription","UnsubscribableWrapper","ObservableClientImpl","constructor","store","__experimentalStore","applyAction","bind","validateAction","observeObject","apiName","pk","options","subFn","objects","observe","observeList","lists","observeLinks","linkName","objectsArray","Array","isArray","parentSub","obj","querySubscription","links","srcType","type","$apiName","$primaryKey","add","observeObjectSet","baseObjectSet","objectSets","invalidateAll","invalidateObjects","invalidateObjectType","undefined","canonicalizeWhereClause","where","whereCanonicalizer","canonicalize"],"sources":["ObservableClientImpl.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionValidationResponse,\n CompileTimeMetadata,\n InterfaceDefinition,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PrimaryKeyType,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\nimport { Subscription } from \"rxjs\";\nimport type { ActionSignatureFromDef } from \"../../actions/applyAction.js\";\nimport type { SpecificLinkPayload } from \"../LinkPayload.js\";\nimport type { ListPayload } from \"../ListPayload.js\";\nimport type { ObjectPayload } from \"../ObjectPayload.js\";\nimport type { ObjectSetPayload } from \"../ObjectSetPayload.js\";\nimport type {\n ObservableClient,\n ObserveListOptions,\n ObserveObjectArgs,\n ObserveObjectOptions,\n ObserveObjectsArgs,\n ObserveObjectSetArgs,\n Unsubscribable,\n} from \"../ObservableClient.js\";\nimport type { Observer } from \"../ObservableClient/common.js\";\nimport type { ObserveLinks } from \"../ObservableClient/ObserveLink.js\";\nimport type { Canonical } from \"./Canonical.js\";\nimport type { ObserveObjectSetOptions } from \"./objectset/ObjectSetQueryOptions.js\";\nimport type { Store } from \"./Store.js\";\nimport { UnsubscribableWrapper } from \"./UnsubscribableWrapper.js\";\n\n/**\n * Implementation of the public ObservableClient interface.\n * - Delegates all operations to the Store for consistency\n * - Serves as the entry point for reactive data management\n * - Ensures proper method binding and API exposure\n *\n * @internal\n */\nexport class ObservableClientImpl implements ObservableClient {\n __experimentalStore: Store;\n\n constructor(store: Store) {\n this.__experimentalStore = store;\n\n this.applyAction = store.applyAction.bind(store);\n this.validateAction = store.validateAction.bind(store);\n }\n\n public observeObject: <T extends ObjectTypeDefinition>(\n apiName: T[\"apiName\"] | T,\n pk: PrimaryKeyType<T>,\n options: Omit<ObserveObjectOptions<T>, \"apiName\" | \"pk\">,\n subFn: Observer<ObserveObjectArgs<T>>,\n ) => Unsubscribable = (apiName, pk, options, subFn) => {\n return this.__experimentalStore.objects.observe(\n {\n ...options,\n apiName,\n pk,\n },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ObjectPayload>,\n );\n };\n\n public observeList: <T extends ObjectTypeDefinition | InterfaceDefinition>(\n options: ObserveListOptions<T>,\n subFn: Observer<ObserveObjectsArgs<T>>,\n ) => Unsubscribable = (options, subFn) => {\n return this.__experimentalStore.lists.observe(\n options,\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ListPayload>,\n );\n };\n\n public observeLinks: <\n T extends ObjectTypeDefinition | InterfaceDefinition,\n L extends keyof CompileTimeMetadata<T>[\"links\"] & string,\n >(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>>,\n linkName: L,\n options: ObserveLinks.Options<T, L>,\n subFn: Observer<\n ObserveLinks.CallbackArgs<\n CompileTimeMetadata<T>[\"links\"][L][\"targetType\"]\n >\n >,\n ) => Unsubscribable = (objects, linkName, options, subFn) => {\n // Convert to array if single object provided\n const objectsArray = Array.isArray(objects) ? objects : [objects];\n\n const parentSub = new Subscription();\n\n for (const obj of objectsArray) {\n const querySubscription = this.__experimentalStore.links\n .observe(\n {\n ...options,\n srcType: {\n type: \"object\",\n apiName: obj.$apiName,\n },\n linkName,\n pk: obj.$primaryKey,\n },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<SpecificLinkPayload>,\n );\n\n parentSub.add(querySubscription);\n }\n\n return new UnsubscribableWrapper(parentSub);\n };\n\n public applyAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts?: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n public validateAction: <Q extends ActionDefinition<any>>(\n action: Q,\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse>;\n\n public observeObjectSet<\n T extends ObjectTypeDefinition,\n RDPs extends Record<\n string,\n WirePropertyTypes | undefined | Array<WirePropertyTypes>\n > = {},\n >(\n baseObjectSet: ObjectSet<T>,\n options: ObserveObjectSetOptions<T, RDPs>,\n subFn: Observer<ObserveObjectSetArgs<T, RDPs>>,\n ): Unsubscribable {\n return this.__experimentalStore.objectSets.observe(\n { baseObjectSet, ...options },\n // cast to cross typed to untyped barrier\n subFn as unknown as Observer<ObjectSetPayload>,\n );\n }\n\n public invalidateAll(): Promise<void> {\n return this.__experimentalStore.invalidateAll();\n }\n\n public invalidateObjects(\n objects:\n | Osdk.Instance<ObjectTypeDefinition>\n | ReadonlyArray<Osdk.Instance<ObjectTypeDefinition>>,\n ): Promise<void> {\n return this.__experimentalStore.invalidateObjects(objects);\n }\n\n public invalidateObjectType<T extends ObjectTypeDefinition>(\n type: T | T[\"apiName\"],\n ): Promise<void> {\n return this.__experimentalStore.invalidateObjectType(type, undefined);\n }\n\n public canonicalizeWhereClause<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n >(where: WhereClause<T>): Canonical<WhereClause<T>> {\n return this.__experimentalStore.whereCanonicalizer\n .canonicalize(where) as Canonical<WhereClause<T>>;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,SAASA,YAAY,QAAQ,MAAM;AAoBnC,SAASC,qBAAqB,QAAQ,4BAA4B;;AAElE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,CAA6B;EAG5DC,WAAWA,CAACC,KAAY,EAAE;IACxB,IAAI,CAACC,mBAAmB,GAAGD,KAAK;IAEhC,IAAI,CAACE,WAAW,GAAGF,KAAK,CAACE,WAAW,CAACC,IAAI,CAACH,KAAK,CAAC;IAChD,IAAI,CAACI,cAAc,GAAGJ,KAAK,CAACI,cAAc,CAACD,IAAI,C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;IAAQ,CAAC;IAC7B;IACAC,KACF,CAAC;EACH;EAEOsB,aAAaA,CAAA,EAAkB;IACpC,OAAO,IAAI,CAAC9B,mBAAmB,CAAC8B,aAAa,CAAC,CAAC;EACjD;EAEOC,iBAAiBA,CACtBtB,OAEsD,EACvC;IACf,OAAO,IAAI,CAACT,mBAAmB,CAAC+B,iBAAiB,CAACtB,OAAO,CAAC;EAC5D;EAEOuB,oBAAoBA,CACzBT,IAAsB,EACP;IACf,OAAO,IAAI,CAACvB,mBAAmB,CAACgC,oBAAoB,CAACT,IAAI,EAAEU,SAAS,CAAC;EACvE;EAEOC,uBAAuBA,CAE5BC,KAAqB,EAA6B;IAClD,OAAO,IAAI,CAACnC,mBAAmB,CAACoC,kBAAkB,CAC/CC,YAAY,CAACF,KAAK,CAAC;EACxB;AACF","ignoreList":[]}
@@ -37,7 +37,24 @@ export class Query {
37
37
  subscribe(observer) {
38
38
  this.#connectable ??= this._createConnectable(this.#subject);
39
39
  this.#subscription = this.#connectable.connect();
40
- return this.#connectable.subscribe(observer);
40
+ const sub = this.#connectable.subscribe({
41
+ next: value => {
42
+ if (observer.next) {
43
+ observer.next(value);
44
+ }
45
+ },
46
+ error: err => {
47
+ if (observer.error) {
48
+ observer.error(err);
49
+ }
50
+ },
51
+ complete: () => {
52
+ if (observer.complete) {
53
+ observer.complete();
54
+ }
55
+ }
56
+ });
57
+ return sub;
41
58
  }
42
59
 
43
60
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Query.js","names":["additionalContext","Query","retainCount","connectable","subscription","subject","subscriptionDedupeIntervals","Map","constructor","store","observable","opts","cacheKey","logger","options","cacheKeys","process","env","NODE_ENV","client","child","msgPrefix","type","otherKeys","map","x","JSON","stringify","join","subscribe","observer","_createConnectable","connect","registerSubscriptionDedupeInterval","subscriptionId","dedupeInterval","set","unregisterSubscriptionDedupeInterval","delete","getMinimumDedupeInterval","size","Math","min","values","revalidate","force","methodName","abortController","abort","pendingFetch","debug","minDedupeInterval","lastFetchStarted","Date","now","Promise","resolve","batch","setStatus","_preFetch","_fetchAndStore","finally","undefined","status","existing","read","write","value","dispose","unsubscribe","_dispose"],"sources":["Query.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Logger } from \"@osdk/api\";\nimport type {\n Connectable,\n Observable,\n Observer,\n Subscribable,\n Subscription,\n} from \"rxjs\";\nimport { additionalContext } from \"../../Client.js\";\nimport type {\n CommonObserveOptions,\n Status,\n} from \"../ObservableClient/common.js\";\nimport type { BatchContext } from \"./BatchContext.js\";\nimport type { CacheKeys } from \"./CacheKeys.js\";\nimport type { Changes } from \"./Changes.js\";\nimport type { KnownCacheKey } from \"./KnownCacheKey.js\";\nimport type { Entry } from \"./Layer.js\";\nimport type { OptimisticId } from \"./OptimisticId.js\";\nimport type { Store } from \"./Store.js\";\nimport type { SubjectPayload } from \"./SubjectPayload.js\";\n\nexport abstract class Query<\n KEY extends KnownCacheKey,\n PAYLOAD,\n O extends CommonObserveOptions,\n> implements Subscribable<PAYLOAD> {\n lastFetchStarted?: number;\n pendingFetch?: Promise<void>;\n retainCount: number = 0;\n options: O;\n cacheKey: KEY;\n store: Store;\n abortController?: AbortController;\n #connectable?: Connectable<PAYLOAD>;\n #subscription?: Subscription;\n #subject: Observable<SubjectPayload<KEY>>;\n #subscriptionDedupeIntervals: Map<string, number> = new Map();\n\n /** @internal */\n protected logger: Logger | undefined;\n\n protected readonly cacheKeys: CacheKeys<KnownCacheKey>;\n\n constructor(\n store: Store,\n observable: Observable<SubjectPayload<KEY>>,\n opts: O,\n cacheKey: KEY,\n logger?: Logger,\n ) {\n this.options = opts;\n this.cacheKey = cacheKey;\n this.store = store;\n this.cacheKeys = store.cacheKeys;\n this.#subject = observable;\n\n this.logger = logger ?? (\n process.env.NODE_ENV === \"production\"\n ? store.client[additionalContext].logger\n : store.client[additionalContext].logger?.child({}, {\n msgPrefix: process.env.NODE_ENV !== \"production\"\n ? (`Query<${cacheKey.type}, ${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`)\n : \"Query\",\n })\n );\n }\n\n protected abstract _createConnectable(\n subject: Observable<SubjectPayload<KEY>>,\n ): Connectable<PAYLOAD>;\n\n public subscribe(\n observer: Observer<PAYLOAD>,\n ): Subscription {\n this.#connectable ??= this._createConnectable(this.#subject);\n this.#subscription = this.#connectable.connect();\n return this.#connectable.subscribe(observer);\n }\n\n /**\n * Register a subscription's dedupeInterval value\n */\n registerSubscriptionDedupeInterval(\n subscriptionId: string,\n dedupeInterval: number | undefined,\n ): void {\n if (dedupeInterval != null && dedupeInterval > 0) {\n this.#subscriptionDedupeIntervals.set(subscriptionId, dedupeInterval);\n }\n }\n\n /**\n * Unregister a subscription's dedupeInterval value\n */\n unregisterSubscriptionDedupeInterval(subscriptionId: string): void {\n this.#subscriptionDedupeIntervals.delete(subscriptionId);\n }\n\n /**\n * Get the minimum dedupeInterval from all active subscriptions\n */\n private getMinimumDedupeInterval(): number {\n if (this.#subscriptionDedupeIntervals.size === 0) {\n return this.options.dedupeInterval ?? 0;\n }\n\n return Math.min(...this.#subscriptionDedupeIntervals.values());\n }\n\n /**\n * Causes the query to revalidate. This will cause the query to fetch\n * the latest data from the server and update the store if it is deemed\n * \"stale\" or if `force` is true.\n *\n * @param force\n * @returns\n */\n async revalidate(force?: boolean): Promise<void> {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.logger?.child({ methodName: \"revalidate\" })\n : this.logger;\n\n if (force) {\n this.abortController?.abort();\n }\n\n // n.b. I think this isn't quite right since we may require multiple\n // pages to properly \"revalidate\" for someone. This only really works if you\n // have a single page/object. It needs to be redone. FIXME\n\n // if we are pending the first page/object we can just ignore this\n if (this.pendingFetch) {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"Fetch is already pending, using it\");\n }\n await this.pendingFetch;\n return;\n }\n\n const minDedupeInterval = this.getMinimumDedupeInterval();\n if (\n minDedupeInterval > 0 && (\n this.lastFetchStarted != null\n && Date.now() - this.lastFetchStarted < minDedupeInterval\n )\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"Within dupeInterval, aborting revalidate\");\n }\n\n return Promise.resolve();\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"Starting actual revalidate\");\n }\n\n this.store.batch({}, (batch) => {\n // make sure the truth layer knows we are loading\n\n // this will not trigger an update to `changes` so it cannot trigger an\n // update of a list either. This may not be the behavior we want.\n this.setStatus(\"loading\", batch);\n });\n\n this._preFetch();\n\n this.lastFetchStarted = Date.now();\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"calling _fetchAndStore()\");\n }\n this.pendingFetch = this._fetchAndStore()\n .finally(() => {\n logger?.debug(\"promise's finally for _fetchAndStore()\");\n this.pendingFetch = undefined;\n });\n\n await this.pendingFetch;\n return;\n }\n\n protected _preFetch(): void {}\n\n protected abstract _fetchAndStore(): Promise<void>;\n\n /**\n * Sets the status of the query in the store (but does not store that in `changes`).\n *\n * @param status\n * @param batch\n * @returns\n */\n setStatus(\n status: Status,\n batch: BatchContext,\n ): void {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"setStatus\" }).debug(\n `Attempting to set status to '${status}'`,\n );\n }\n const existing = batch.read(this.cacheKey);\n if (existing?.status === status) {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"setStatus\" }).debug(\n `Status is already set to '${status}'; aborting`,\n );\n }\n return;\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"setStatus\" }).debug(\n `Writing status '${status}' to cache`,\n );\n }\n batch.write(this.cacheKey, existing?.value, status);\n }\n\n dispose(): void {\n if (this.abortController) {\n this.abortController.abort();\n }\n this.#subscription?.unsubscribe();\n this._dispose();\n }\n\n /**\n * Per query type dispose functionality\n */\n protected _dispose(): void {}\n\n /**\n * The purpose of this method is to provide a way for others to write\n * directly into the store for this query.\n *\n * @param data\n * @param status\n * @param batch\n */\n abstract writeToStore(\n data: KEY[\"__cacheKey\"][\"value\"],\n status: Status,\n batch: BatchContext,\n ): Entry<KEY>;\n\n /**\n * @param changes\n * @param optimisticId\n * @returns If revalidation is needed, a promise that resolves after the\n * revalidation is complete. Otherwise, undefined.\n */\n maybeUpdateAndRevalidate?: (\n changes: Changes,\n optimisticId: OptimisticId | undefined,\n ) => Promise<void> | undefined;\n\n abstract invalidateObjectType(\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,iBAAiB,QAAQ,iBAAiB;AAcnD,OAAO,MAAeC,KAAK,CAIQ;EAGjCC,WAAW,GAAW,CAAC;EAKvB,CAACC,WAAW;EACZ,CAACC,YAAY;EACb,CAACC,OAAO;EACR,CAACC,2BAA2B,GAAwB,IAAIC,GAAG,CAAC,CAAC;;EAE7D;;EAKAC,WAAWA,CACTC,KAAY,EACZC,UAA2C,EAC3CC,IAAO,EACPC,QAAa,EACbC,MAAe,EACf;IACA,IAAI,CAACC,OAAO,GAAGH,IAAI;IACnB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACH,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACM,SAAS,GAAGN,KAAK,CAACM,SAAS;IAChC,IAAI,CAAC,CAACV,OAAO,GAAGK,UAAU;IAE1B,IAAI,CAACG,MAAM,GAAGA,MAAM,KAClBG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK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CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;MACzC,IAAI,CAACL,MAAM,EAAEO,KAAK,CAAC;QAAE0B,UAAU,EAAE;MAAY,CAAC,CAAC,CAACI,KAAK,CACnD,mBAAmBa,MAAM,YAC3B,CAAC;IACH;IACAN,KAAK,CAACS,KAAK,CAAC,IAAI,CAACtD,QAAQ,EAAEoD,QAAQ,EAAEG,KAAK,EAAEJ,MAAM,CAAC;EACrD;EAEAK,OAAOA,CAAA,EAAS;IACd,IAAI,IAAI,CAACrB,eAAe,EAAE;MACxB,IAAI,CAACA,eAAe,CAACC,KAAK,CAAC,CAAC;IAC9B;IACA,IAAI,CAAC,CAAC5C,YAAY,EAAEiE,WAAW,CAAC,CAAC;IACjC,IAAI,CAACC,QAAQ,CAAC,CAAC;EACjB;;EAEA;AACF;AACA;EACYA,QAAQA,CAAA,EAAS,CAAC;;EAE5B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;EAOE;AACF;AACA;AACA;AACA;AACA;AAUA","ignoreList":[]}
1
+ {"version":3,"file":"Query.js","names":["additionalContext","Query","retainCount","connectable","subscription","subject","subscriptionDedupeIntervals","Map","constructor","store","observable","opts","cacheKey","logger","options","cacheKeys","process","env","NODE_ENV","client","child","msgPrefix","type","otherKeys","map","x","JSON","stringify","join","subscribe","observer","_createConnectable","connect","sub","next","value","error","err","complete","registerSubscriptionDedupeInterval","subscriptionId","dedupeInterval","set","unregisterSubscriptionDedupeInterval","delete","getMinimumDedupeInterval","size","Math","min","values","revalidate","force","methodName","abortController","abort","pendingFetch","debug","minDedupeInterval","lastFetchStarted","Date","now","Promise","resolve","batch","setStatus","_preFetch","_fetchAndStore","finally","undefined","status","existing","read","write","dispose","unsubscribe","_dispose"],"sources":["Query.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Logger } from \"@osdk/api\";\nimport type {\n Connectable,\n Observable,\n Observer,\n Subscribable,\n Subscription,\n} from \"rxjs\";\nimport { additionalContext } from \"../../Client.js\";\nimport type {\n CommonObserveOptions,\n Status,\n} from \"../ObservableClient/common.js\";\nimport type { BatchContext } from \"./BatchContext.js\";\nimport type { CacheKeys } from \"./CacheKeys.js\";\nimport type { Changes } from \"./Changes.js\";\nimport type { KnownCacheKey } from \"./KnownCacheKey.js\";\nimport type { Entry } from \"./Layer.js\";\nimport type { OptimisticId } from \"./OptimisticId.js\";\nimport type { Store } from \"./Store.js\";\nimport type { SubjectPayload } from \"./SubjectPayload.js\";\n\nexport abstract class Query<\n KEY extends KnownCacheKey,\n PAYLOAD,\n O extends CommonObserveOptions,\n> implements Subscribable<PAYLOAD> {\n lastFetchStarted?: number;\n pendingFetch?: Promise<void>;\n retainCount: number = 0;\n options: O;\n cacheKey: KEY;\n store: Store;\n abortController?: AbortController;\n #connectable?: Connectable<PAYLOAD>;\n #subscription?: Subscription;\n #subject: Observable<SubjectPayload<KEY>>;\n #subscriptionDedupeIntervals: Map<string, number> = new Map();\n\n /** @internal */\n protected logger: Logger | undefined;\n\n protected readonly cacheKeys: CacheKeys<KnownCacheKey>;\n\n constructor(\n store: Store,\n observable: Observable<SubjectPayload<KEY>>,\n opts: O,\n cacheKey: KEY,\n logger?: Logger,\n ) {\n this.options = opts;\n this.cacheKey = cacheKey;\n this.store = store;\n this.cacheKeys = store.cacheKeys;\n this.#subject = observable;\n\n this.logger = logger ?? (\n process.env.NODE_ENV === \"production\"\n ? store.client[additionalContext].logger\n : store.client[additionalContext].logger?.child({}, {\n msgPrefix: process.env.NODE_ENV !== \"production\"\n ? (`Query<${cacheKey.type}, ${\n cacheKey.otherKeys.map(x => JSON.stringify(x)).join(\", \")\n }>`)\n : \"Query\",\n })\n );\n }\n\n protected abstract _createConnectable(\n subject: Observable<SubjectPayload<KEY>>,\n ): Connectable<PAYLOAD>;\n\n public subscribe(\n observer: Observer<PAYLOAD>,\n ): Subscription {\n this.#connectable ??= this._createConnectable(this.#subject);\n this.#subscription = this.#connectable.connect();\n const sub = this.#connectable.subscribe({\n next: (value) => {\n if (observer.next) {\n observer.next(value);\n }\n },\n error: (err) => {\n if (observer.error) {\n observer.error(err);\n }\n },\n complete: () => {\n if (observer.complete) {\n observer.complete();\n }\n },\n });\n return sub;\n }\n\n /**\n * Register a subscription's dedupeInterval value\n */\n registerSubscriptionDedupeInterval(\n subscriptionId: string,\n dedupeInterval: number | undefined,\n ): void {\n if (dedupeInterval != null && dedupeInterval > 0) {\n this.#subscriptionDedupeIntervals.set(subscriptionId, dedupeInterval);\n }\n }\n\n /**\n * Unregister a subscription's dedupeInterval value\n */\n unregisterSubscriptionDedupeInterval(subscriptionId: string): void {\n this.#subscriptionDedupeIntervals.delete(subscriptionId);\n }\n\n /**\n * Get the minimum dedupeInterval from all active subscriptions\n */\n private getMinimumDedupeInterval(): number {\n if (this.#subscriptionDedupeIntervals.size === 0) {\n return this.options.dedupeInterval ?? 0;\n }\n\n return Math.min(...this.#subscriptionDedupeIntervals.values());\n }\n\n /**\n * Causes the query to revalidate. This will cause the query to fetch\n * the latest data from the server and update the store if it is deemed\n * \"stale\" or if `force` is true.\n *\n * @param force\n * @returns\n */\n async revalidate(force?: boolean): Promise<void> {\n const logger = process.env.NODE_ENV !== \"production\"\n ? this.logger?.child({ methodName: \"revalidate\" })\n : this.logger;\n\n if (force) {\n this.abortController?.abort();\n }\n\n // n.b. I think this isn't quite right since we may require multiple\n // pages to properly \"revalidate\" for someone. This only really works if you\n // have a single page/object. It needs to be redone. FIXME\n\n // if we are pending the first page/object we can just ignore this\n if (this.pendingFetch) {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"Fetch is already pending, using it\");\n }\n await this.pendingFetch;\n return;\n }\n\n const minDedupeInterval = this.getMinimumDedupeInterval();\n if (\n minDedupeInterval > 0 && (\n this.lastFetchStarted != null\n && Date.now() - this.lastFetchStarted < minDedupeInterval\n )\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"Within dupeInterval, aborting revalidate\");\n }\n\n return Promise.resolve();\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"Starting actual revalidate\");\n }\n\n this.store.batch({}, (batch) => {\n // make sure the truth layer knows we are loading\n\n // this will not trigger an update to `changes` so it cannot trigger an\n // update of a list either. This may not be the behavior we want.\n this.setStatus(\"loading\", batch);\n });\n\n this._preFetch();\n\n this.lastFetchStarted = Date.now();\n\n if (process.env.NODE_ENV !== \"production\") {\n logger?.debug(\"calling _fetchAndStore()\");\n }\n this.pendingFetch = this._fetchAndStore()\n .finally(() => {\n logger?.debug(\"promise's finally for _fetchAndStore()\");\n this.pendingFetch = undefined;\n });\n\n await this.pendingFetch;\n return;\n }\n\n protected _preFetch(): void {}\n\n protected abstract _fetchAndStore(): Promise<void>;\n\n /**\n * Sets the status of the query in the store (but does not store that in `changes`).\n *\n * @param status\n * @param batch\n * @returns\n */\n setStatus(\n status: Status,\n batch: BatchContext,\n ): void {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"setStatus\" }).debug(\n `Attempting to set status to '${status}'`,\n );\n }\n const existing = batch.read(this.cacheKey);\n if (existing?.status === status) {\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"setStatus\" }).debug(\n `Status is already set to '${status}'; aborting`,\n );\n }\n return;\n }\n\n if (process.env.NODE_ENV !== \"production\") {\n this.logger?.child({ methodName: \"setStatus\" }).debug(\n `Writing status '${status}' to cache`,\n );\n }\n batch.write(this.cacheKey, existing?.value, status);\n }\n\n dispose(): void {\n if (this.abortController) {\n this.abortController.abort();\n }\n this.#subscription?.unsubscribe();\n this._dispose();\n }\n\n /**\n * Per query type dispose functionality\n */\n protected _dispose(): void {}\n\n /**\n * The purpose of this method is to provide a way for others to write\n * directly into the store for this query.\n *\n * @param data\n * @param status\n * @param batch\n */\n abstract writeToStore(\n data: KEY[\"__cacheKey\"][\"value\"],\n status: Status,\n batch: BatchContext,\n ): Entry<KEY>;\n\n /**\n * @param changes\n * @param optimisticId\n * @returns If revalidation is needed, a promise that resolves after the\n * revalidation is complete. Otherwise, undefined.\n */\n maybeUpdateAndRevalidate?: (\n changes: Changes,\n optimisticId: OptimisticId | undefined,\n ) => Promise<void> | undefined;\n\n abstract invalidateObjectType(\n objectType: string,\n changes: Changes | undefined,\n ): Promise<void>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,iBAAiB,QAAQ,iBAAiB;AAcnD,OAAO,MAAeC,KAAK,CAIQ;EAGjCC,WAAW,GAAW,CAAC;EAKvB,CAACC,WAAW;EACZ,CAACC,YAAY;EACb,CAACC,OAAO;EACR,CAACC,2BAA2B,GAAwB,IAAIC,GAAG,CAAC,CAAC;;EAE7D;;EAKAC,WAAWA,CACTC,KAAY,EACZC,UAA2C,EAC3CC,IAAO,EACPC,QAAa,EACbC,MAAe,EACf;IACA,IAAI,CAACC,OAAO,GAAGH,IAAI;IACnB,IAAI,CAACC,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACH,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACM,SAAS,GAAGN,KAAK,CAACM,SAAS;IAChC,IAAI,CAAC,CAACV,OAAO,GAAGK,UAAU;IAE1B,IAAI,CAACG,MAAM,GAAGA,MAAM,KAClBG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjCT,KAAK,CAACU,MAAM,CAACnB,iBAAiB,CAAC,CAACa,MAAM,GACtCJ,KAAK,CAACU,MAAM,CAACnB,iBAAiB,CAAC,C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AI,CAAC3D,QAAQ,CAAC;IAC1C,IAAI0D,QAAQ,EAAED,MAAM,KAAKA,MAAM,EAAE;MAC/B,IAAIrD,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAI,CAACL,MAAM,EAAEO,KAAK,CAAC;UAAEgC,UAAU,EAAE;QAAY,CAAC,CAAC,CAACI,KAAK,CACnD,6BAA6Ba,MAAM,aACrC,CAAC;MACH;MACA;IACF;IAEA,IAAIrD,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;MACzC,IAAI,CAACL,MAAM,EAAEO,KAAK,CAAC;QAAEgC,UAAU,EAAE;MAAY,CAAC,CAAC,CAACI,KAAK,CACnD,mBAAmBa,MAAM,YAC3B,CAAC;IACH;IACAN,KAAK,CAACS,KAAK,CAAC,IAAI,CAAC5D,QAAQ,EAAE0D,QAAQ,EAAEnC,KAAK,EAAEkC,MAAM,CAAC;EACrD;EAEAI,OAAOA,CAAA,EAAS;IACd,IAAI,IAAI,CAACpB,eAAe,EAAE;MACxB,IAAI,CAACA,eAAe,CAACC,KAAK,CAAC,CAAC;IAC9B;IACA,IAAI,CAAC,CAAClD,YAAY,EAAEsE,WAAW,CAAC,CAAC;IACjC,IAAI,CAACC,QAAQ,CAAC,CAAC;EACjB;;EAEA;AACF;AACA;EACYA,QAAQA,CAAA,EAAS,CAAC;;EAE5B;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;EAOE;AACF;AACA;AACA;AACA;AACA;AAUA","ignoreList":[]}
@@ -477,5 +477,170 @@ describe("Store Invalidation Type Isolation", () => {
477
477
  expect(officeOccupantsLinkSubFn.next).not.toHaveBeenCalled();
478
478
  });
479
479
  });
480
+ describe("invalidateAll", () => {
481
+ it("should invalidate all cached queries", async () => {
482
+ const {
483
+ subFn: empSubFn
484
+ } = await expectStandardObserveObject({
485
+ cache,
486
+ type: Employee,
487
+ primaryKey: EMPLOYEE_1_ID
488
+ });
489
+ const {
490
+ subFn: officeSubFn
491
+ } = await expectStandardObserveObject({
492
+ cache,
493
+ type: Office,
494
+ primaryKey: OFFICE_1_ID
495
+ });
496
+ const {
497
+ subFn: todoSubFn
498
+ } = await expectStandardObserveObject({
499
+ cache,
500
+ type: Todo,
501
+ primaryKey: TODO_1_ID
502
+ });
503
+ empSubFn.next.mockClear();
504
+ officeSubFn.next.mockClear();
505
+ todoSubFn.next.mockClear();
506
+ await cache.invalidateAll();
507
+ await new Promise(resolve => setTimeout(resolve, 500));
508
+ expect(empSubFn.next).toHaveBeenCalled();
509
+ expect(officeSubFn.next).toHaveBeenCalled();
510
+ expect(todoSubFn.next).toHaveBeenCalled();
511
+ });
512
+ it("should invalidate all list queries", async () => {
513
+ const empListSubFn = mockListSubCallback();
514
+ defer(cache.lists.observe({
515
+ type: Employee,
516
+ where: {},
517
+ orderBy: {},
518
+ pageSize: 10
519
+ }, empListSubFn));
520
+ const officeListSubFn = mockListSubCallback();
521
+ defer(cache.lists.observe({
522
+ type: Office,
523
+ where: {},
524
+ orderBy: {},
525
+ pageSize: 10
526
+ }, officeListSubFn));
527
+ await new Promise(resolve => setTimeout(resolve, 100));
528
+ empListSubFn.next.mockClear();
529
+ officeListSubFn.next.mockClear();
530
+ await cache.invalidateAll();
531
+ await new Promise(resolve => setTimeout(resolve, 500));
532
+ expect(empListSubFn.next).toHaveBeenCalled();
533
+ expect(officeListSubFn.next).toHaveBeenCalled();
534
+ });
535
+ });
536
+ describe("invalidateObjects", () => {
537
+ it("should invalidate a single object", async () => {
538
+ const {
539
+ subFn: empSubFn
540
+ } = await expectStandardObserveObject({
541
+ cache,
542
+ type: Employee,
543
+ primaryKey: EMPLOYEE_1_ID
544
+ });
545
+ const {
546
+ subFn: emp2SubFn
547
+ } = await expectStandardObserveObject({
548
+ cache,
549
+ type: Employee,
550
+ primaryKey: EMPLOYEE_2_ID
551
+ });
552
+ empSubFn.next.mockClear();
553
+ emp2SubFn.next.mockClear();
554
+ const emp1 = await client(Employee).fetchOne(EMPLOYEE_1_ID);
555
+ !emp1 ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
556
+ await cache.invalidateObjects(emp1);
557
+ await new Promise(resolve => setTimeout(resolve, 500));
558
+ expect(empSubFn.next).toHaveBeenCalled();
559
+ expect(emp2SubFn.next).not.toHaveBeenCalled();
560
+ });
561
+ it("should invalidate multiple objects", async () => {
562
+ const {
563
+ subFn: empSubFn
564
+ } = await expectStandardObserveObject({
565
+ cache,
566
+ type: Employee,
567
+ primaryKey: EMPLOYEE_1_ID
568
+ });
569
+ const {
570
+ subFn: emp2SubFn
571
+ } = await expectStandardObserveObject({
572
+ cache,
573
+ type: Employee,
574
+ primaryKey: EMPLOYEE_2_ID
575
+ });
576
+ const {
577
+ subFn: officeSubFn
578
+ } = await expectStandardObserveObject({
579
+ cache,
580
+ type: Office,
581
+ primaryKey: OFFICE_1_ID
582
+ });
583
+ empSubFn.next.mockClear();
584
+ emp2SubFn.next.mockClear();
585
+ officeSubFn.next.mockClear();
586
+ const emp1 = await client(Employee).fetchOne(EMPLOYEE_1_ID);
587
+ const emp2 = await client(Employee).fetchOne(EMPLOYEE_2_ID);
588
+ !emp1 ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
589
+ !emp2 ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
590
+ await cache.invalidateObjects([emp1, emp2]);
591
+ await new Promise(resolve => setTimeout(resolve, 500));
592
+ expect(empSubFn.next).toHaveBeenCalled();
593
+ expect(emp2SubFn.next).toHaveBeenCalled();
594
+ expect(officeSubFn.next).not.toHaveBeenCalled();
595
+ });
596
+ it("should invalidate mixed object types", async () => {
597
+ const {
598
+ subFn: empSubFn
599
+ } = await expectStandardObserveObject({
600
+ cache,
601
+ type: Employee,
602
+ primaryKey: EMPLOYEE_1_ID
603
+ });
604
+ const {
605
+ subFn: officeSubFn
606
+ } = await expectStandardObserveObject({
607
+ cache,
608
+ type: Office,
609
+ primaryKey: OFFICE_1_ID
610
+ });
611
+ const {
612
+ subFn: todoSubFn
613
+ } = await expectStandardObserveObject({
614
+ cache,
615
+ type: Todo,
616
+ primaryKey: TODO_1_ID
617
+ });
618
+ empSubFn.next.mockClear();
619
+ officeSubFn.next.mockClear();
620
+ todoSubFn.next.mockClear();
621
+ const emp1 = await client(Employee).fetchOne(EMPLOYEE_1_ID);
622
+ const office1 = await client(Office).fetchOne(OFFICE_1_ID);
623
+ !emp1 ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
624
+ !office1 ? process.env.NODE_ENV !== "production" ? invariant(false) : invariant(false) : void 0;
625
+ await cache.invalidateObjects([emp1, office1]);
626
+ await new Promise(resolve => setTimeout(resolve, 500));
627
+ expect(empSubFn.next).toHaveBeenCalled();
628
+ expect(officeSubFn.next).toHaveBeenCalled();
629
+ expect(todoSubFn.next).not.toHaveBeenCalled();
630
+ });
631
+ it("should handle empty array", async () => {
632
+ const {
633
+ subFn: empSubFn
634
+ } = await expectStandardObserveObject({
635
+ cache,
636
+ type: Employee,
637
+ primaryKey: EMPLOYEE_1_ID
638
+ });
639
+ empSubFn.next.mockClear();
640
+ await cache.invalidateObjects([]);
641
+ await new Promise(resolve => setTimeout(resolve, 500));
642
+ expect(empSubFn.next).not.toHaveBeenCalled();
643
+ });
644
+ });
480
645
  });
481
646
  //# sourceMappingURL=Store.invalidation.test.js.map