@osdk/react 0.8.0-beta.5 → 0.8.0-rc.7

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @osdkkit/react
2
2
 
3
+ ## 0.8.0-rc.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 13f229d: preserve object set data on rid change
8
+ - @osdk/api@2.6.0-rc.18
9
+ - @osdk/client@2.6.0-rc.18
10
+
11
+ ## 0.8.0-rc.6
12
+
13
+ ### Patch Changes
14
+
15
+ - af4f3bf: Remove the following features for RC:
16
+ - Property formatting
17
+ - Branching
18
+ - Constant RDPs
19
+
20
+ - Updated dependencies [b313525]
21
+ - Updated dependencies [af4f3bf]
22
+ - @osdk/client@2.6.0-rc.14
23
+ - @osdk/api@2.6.0-rc.14
24
+
3
25
  ## 0.8.0-beta.5
4
26
 
5
27
  ### Minor Changes
@@ -51,6 +73,16 @@
51
73
  - @osdk/client@2.6.0-beta.4
52
74
  - @osdk/api@2.6.0-beta.4
53
75
 
76
+ ## 0.7.0
77
+
78
+ ### Patch Changes
79
+
80
+ - 322c5bc: Simulated release
81
+ - 2348ddc: Make useOsdkAction validate less restrictive
82
+ - 46ae415: improve useOsdkObject, useOsdkObjects error handling
83
+ - 7b97128: add useObjectSet hook
84
+ - ccc85a3: Export useOsdkMetadata hook experimentally
85
+
54
86
  ## 0.7.0-beta.5
55
87
 
56
88
  ### Minor Changes
@@ -26,7 +26,7 @@ function TestComponent() {
26
26
  data
27
27
  } = useOsdkObjects(Employee, {
28
28
  withProperties: {
29
- constantValue: employee => employee.constant.integer(42)
29
+ constantValue: employee => employee.selectProperty("class")
30
30
  }
31
31
  });
32
32
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkObjectsWithProperties.js","names":["Employee","useOsdkObjects","TestComponent","data","withProperties","constantValue","employee","constant","integer"],"sources":["useOsdkObjectsWithProperties.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\n// WARNING!\n// WARNING!\n// This file is used for tests that check intellisense. Editing this file by hand will likely\n// break tests that have hard coded line numbers and line offsets.\n\nimport type { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport { useOsdkObjects } from \"@osdk/react/experimental\";\n\nfunction TestComponent() {\n const withProps: DerivedProperty.Clause<typeof Employee> = {\n constantValue: (employee) => employee.constant.integer(42),\n };\n\n const { data } = useOsdkObjects(Employee, {\n withProperties: withProps,\n });\n\n return null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,4BAA4B;AACrD,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,SAASC,aAAaA,CAAA,EAAG;EAKvB,MAAM;IAAEC;EAAK,CAAC,GAAGF,cAAc,CAACD,QAAQ,EAAE;IACxCI,cAAc,EAL2C;MACzDC,aAAa,EAAGC,QAAQ,IAAKA,QAAQ,CAACC,QAAQ,CAACC,OAAO,CAAC,EAAE;IAC3D;EAIA,CAAC,CAAC;EAEF,OAAO,IAAI;AACb","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkObjectsWithProperties.js","names":["Employee","useOsdkObjects","TestComponent","data","withProperties","constantValue","employee","selectProperty"],"sources":["useOsdkObjectsWithProperties.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\n// WARNING!\n// WARNING!\n// This file is used for tests that check intellisense. Editing this file by hand will likely\n// break tests that have hard coded line numbers and line offsets.\n\nimport type { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport { useOsdkObjects } from \"@osdk/react/experimental\";\n\nfunction TestComponent() {\n const withProps: DerivedProperty.Clause<typeof Employee> = {\n constantValue: (employee) => employee.selectProperty(\"class\"),\n };\n\n const { data } = useOsdkObjects(Employee, {\n withProperties: withProps,\n });\n\n return null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,4BAA4B;AACrD,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,SAASC,aAAaA,CAAA,EAAG;EAKvB,MAAM;IAAEC;EAAK,CAAC,GAAGF,cAAc,CAACD,QAAQ,EAAE;IACxCI,cAAc,EAL2C;MACzDC,aAAa,EAAGC,QAAQ,IAAKA,QAAQ,CAACC,cAAc,CAAC,OAAO;IAC9D;EAIA,CAAC,CAAC;EAEF,OAAO,IAAI;AACb","ignoreList":[]}
@@ -14,8 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export function makeExternalStore(createObservation) {
18
- let lastResult;
17
+ export function makeExternalStore(createObservation, _name, initialValue) {
18
+ let lastResult = initialValue;
19
19
  function getSnapShot() {
20
20
  return lastResult;
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"makeExternalStore.js","names":["makeExternalStore","createObservation","lastResult","getSnapShot","subscribe","notifyUpdate","obs","next","payload","error","Error","String","complete","unsubscribe"],"sources":["makeExternalStore.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 Observer,\n Unsubscribable,\n} from \"@osdk/client/unstable-do-not-use\";\n\nexport type Snapshot<X> =\n | X & { error?: Error }\n | (Partial<X> & { error?: Error })\n | undefined;\n\nexport function makeExternalStore<X>(\n createObservation: (callback: Observer<X | undefined>) => Unsubscribable,\n name?: string,\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => Snapshot<X>;\n} {\n let lastResult: Snapshot<X>;\n\n function getSnapShot(): Snapshot<X> {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n const obs = createObservation({\n next: (payload) => {\n lastResult = payload as Snapshot<X>;\n notifyUpdate();\n },\n error: (error: unknown) => {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n },\n complete: () => {},\n });\n\n return (): void => {\n obs.unsubscribe();\n };\n }\n\n return {\n subscribe,\n getSnapShot,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAO,SAASA,iBAAiBA,CAC/BC,iBAAwE,EAKxE;EACA,IAAIC,UAAuB;EAE3B,SAASC,WAAWA,CAAA,EAAgB;IAClC,OAAOD,UAAU;EACnB;EAuBA,OAAO;IACLE,SAAS,EAtBX,SAASA,SAASA,CAACC,YAAwB,EAAE;MAC3C,MAAMC,GAAG,GAAGL,iBAAiB,CAAC;QAC5BM,IAAI,EAAGC,OAAO,IAAK;UACjBN,UAAU,GAAGM,OAAsB;UACnCH,YAAY,CAAC,CAAC;QAChB,CAAC;QACDI,KAAK,EAAGA,KAAc,IAAK;UACzBP,UAAU,GAAG;YACX,IAAIA,UAAU,IAAI,CAAC,CAAC,CAAC;YACrBO,KAAK,EAAEA,KAAK,YAAYC,KAAK,GAAGD,KAAK,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,KAAK,CAAC;UACjE,CAAgB;UAChBJ,YAAY,CAAC,CAAC;QAChB,CAAC;QACDO,QAAQ,EAAEA,CAAA,KAAM,CAAC;MACnB,CAAC,CAAC;MAEF,OAAO,MAAY;QACjBN,GAAG,CAACO,WAAW,CAAC,CAAC;MACnB,CAAC;IACH,CAGW;IACTV;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"makeExternalStore.js","names":["makeExternalStore","createObservation","_name","initialValue","lastResult","getSnapShot","subscribe","notifyUpdate","obs","next","payload","error","Error","String","complete","unsubscribe"],"sources":["makeExternalStore.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 Observer,\n Unsubscribable,\n} from \"@osdk/client/unstable-do-not-use\";\n\nexport type Snapshot<X> =\n | X & { error?: Error }\n | (Partial<X> & { error?: Error })\n | undefined;\n\nexport function makeExternalStore<X>(\n createObservation: (callback: Observer<X | undefined>) => Unsubscribable,\n _name?: string,\n initialValue?: Snapshot<X>,\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => Snapshot<X>;\n} {\n let lastResult: Snapshot<X> = initialValue;\n\n function getSnapShot(): Snapshot<X> {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n const obs = createObservation({\n next: (payload) => {\n lastResult = payload as Snapshot<X>;\n notifyUpdate();\n },\n error: (error: unknown) => {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n },\n complete: () => {},\n });\n\n return (): void => {\n obs.unsubscribe();\n };\n }\n\n return {\n subscribe,\n getSnapShot,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAO,SAASA,iBAAiBA,CAC/BC,iBAAwE,EACxEC,KAAc,EACdC,YAA0B,EAI1B;EACA,IAAIC,UAAuB,GAAGD,YAAY;EAE1C,SAASE,WAAWA,CAAA,EAAgB;IAClC,OAAOD,UAAU;EACnB;EAuBA,OAAO;IACLE,SAAS,EAtBX,SAASA,SAASA,CAACC,YAAwB,EAAE;MAC3C,MAAMC,GAAG,GAAGP,iBAAiB,CAAC;QAC5BQ,IAAI,EAAGC,OAAO,IAAK;UACjBN,UAAU,GAAGM,OAAsB;UACnCH,YAAY,CAAC,CAAC;QAChB,CAAC;QACDI,KAAK,EAAGA,KAAc,IAAK;UACzBP,UAAU,GAAG;YACX,IAAIA,UAAU,IAAI,CAAC,CAAC,CAAC;YACrBO,KAAK,EAAEA,KAAK,YAAYC,KAAK,GAAGD,KAAK,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,KAAK,CAAC;UACjE,CAAgB;UAChBJ,YAAY,CAAC,CAAC;QAChB,CAAC;QACDO,QAAQ,EAAEA,CAAA,KAAM,CAAC;MACnB,CAAC,CAAC;MAEF,OAAO,MAAY;QACjBN,GAAG,CAACO,WAAW,CAAC,CAAC;MACnB,CAAC;IACH,CAGW;IACTV;EACF,CAAC;AACH","ignoreList":[]}
@@ -39,6 +39,15 @@ export function useObjectSet(baseObjectSet, options = {}) {
39
39
  ...otherOptions
40
40
  } = options;
41
41
 
42
+ // Track object type to detect when we switch to a different object type
43
+ const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;
44
+ const previousObjectTypeRef = React.useRef(objectTypeKey);
45
+ const previousPayloadRef = React.useRef();
46
+ const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;
47
+ if (objectTypeChanged) {
48
+ previousObjectTypeRef.current = objectTypeKey;
49
+ }
50
+
42
51
  // Compute a stable cache key for the ObjectSet and options
43
52
  // dedupeIntervalMs and enabled are excluded as they don't affect the data
44
53
  const stableKey = computeObjectSetCacheKey(baseObjectSet, {
@@ -60,6 +69,7 @@ export function useObjectSet(baseObjectSet, options = {}) {
60
69
  unsubscribe: () => {}
61
70
  }), process.env.NODE_ENV !== "production" ? `objectSet ${stableKey} [DISABLED]` : void 0);
62
71
  }
72
+ const initialValue = objectTypeChanged ? undefined : previousPayloadRef.current;
63
73
  return makeExternalStore(observer => {
64
74
  const subscription = observableClient.observeObjectSet(baseObjectSet, {
65
75
  where: otherOptions.where,
@@ -75,9 +85,14 @@ export function useObjectSet(baseObjectSet, options = {}) {
75
85
  streamUpdates
76
86
  }, observer);
77
87
  return subscription;
78
- }, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0);
79
- }, [enabled, observableClient, stableKey, streamUpdates]);
88
+ }, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0, initialValue);
89
+ }, [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged]);
80
90
  const payload = React.useSyncExternalStore(subscribe, getSnapShot);
91
+ React.useEffect(() => {
92
+ if (payload) {
93
+ previousPayloadRef.current = payload;
94
+ }
95
+ }, [payload]);
81
96
  return {
82
97
  data: payload?.resolvedList,
83
98
  isLoading: payload?.status === "loading" || !payload && true || false,
@@ -1 +1 @@
1
- {"version":3,"file":"useObjectSet.js","names":["computeObjectSetCacheKey","React","makeExternalStore","OsdkContext2","useObjectSet","baseObjectSet","options","observableClient","useContext","enabled","streamUpdates","otherOptions","stableKey","where","withProperties","union","intersect","subtract","pivotTo","pageSize","orderBy","subscribe","getSnapShot","useMemo","unsubscribe","process","env","NODE_ENV","observer","subscription","observeObjectSet","dedupeInterval","dedupeIntervalMs","autoFetchMore","payload","useSyncExternalStore","data","resolvedList","isLoading","status","error","undefined","fetchMore","objectSet"],"sources":["useObjectSet.tsx"],"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 DerivedProperty,\n LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport {\n computeObjectSetCacheKey,\n type ObserveObjectSetArgs,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseObjectSetOptions<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q, RDPs>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type)\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Enable streaming updates via websocket subscription.\n * When true, the object set will automatically update when matching objects are\n * added, updated, or removed.\n *\n * @default false\n */\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for filter selection\n * const { data: filteredObjects } = useObjectSet(MyObject.all(), {\n * where: { status: selectedStatus },\n * enabled: !!selectedStatus\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs>;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet<\n Q extends ObjectTypeDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs>,\n options: UseObjectSetOptions<Q, RDPs> = {},\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, streamUpdates, ...otherOptions } = options;\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs and enabled are excluded as they don't affect the data\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n });\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey} [DISABLED]`\n : void 0,\n );\n }\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n const subscription = observableClient.observeObjectSet(\n baseObjectSet as ObjectSet<Q>,\n {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates,\n },\n observer,\n );\n return subscription;\n },\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey}`\n : void 0,\n );\n },\n [enabled, observableClient, stableKey, streamUpdates],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n data: payload?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: payload?.status === \"loading\" || (!payload && true) || false,\n error: payload && \"error\" in payload\n ? payload.error\n : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet as ObjectSet<Q, RDPs> || baseObjectSet,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SACEA,wBAAwB,QAEnB,kCAAkC;AACzC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAmIhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAK1BC,aAAqC,EACrCC,OAAqC,GAAG,CAAC,CAAC,EACb;EAC7B,MAAM;IAAEC;EAAiB,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,YAAY,CAAC;EAE3D,MAAM;IAAEM,OAAO,GAAG,IAAI;IAAEC,aAAa;IAAE,GAAGC;EAAa,CAAC,GAAGL,OAAO;;EAElE;EACA;EACA,MAAMM,SAAS,GAAGZ,wBAAwB,CAACK,aAAa,EAAE;IACxDQ,KAAK,EAAEF,YAAY,CAACE,KAAK;IACzBC,cAAc,EAAEH,YAAY,CAACG,cAAc;IAC3CC,KAAK,EAAEJ,YAAY,CAACI,KAAK;IACzBC,SAAS,EAAEL,YAAY,CAACK,SAAS;IACjCC,QAAQ,EAAEN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,CAAC;EAED,MAAMwB,OAAO,GAAGjC,KAAK,CAACkC,oBAAoB,CAACd,SAAS,EAAEC,WAAW,CAAC;EAElE,OAAO;IACLc,IAAI,EAAEF,OAAO,EAAEG,YAKZ;IACHC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS,IAAK,CAACL,OAAO,IAAI,IAAK,IAAI,KAAK;IACvEM,KAAK,EAAEN,OAAO,IAAI,OAAO,IAAIA,OAAO,GAChCA,OAAO,CAACM,KAAK,GACbC,SAAS;IACbC,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,SAAS,EAAET,OAAO,EAAES,SAAS,IAA0BtC;EACzD,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useObjectSet.js","names":["computeObjectSetCacheKey","React","makeExternalStore","OsdkContext2","useObjectSet","baseObjectSet","options","observableClient","useContext","enabled","streamUpdates","otherOptions","objectTypeKey","$objectSetInternals","def","apiName","previousObjectTypeRef","useRef","previousPayloadRef","objectTypeChanged","current","stableKey","where","withProperties","union","intersect","subtract","pivotTo","pageSize","orderBy","subscribe","getSnapShot","useMemo","unsubscribe","process","env","NODE_ENV","initialValue","undefined","observer","subscription","observeObjectSet","dedupeInterval","dedupeIntervalMs","autoFetchMore","payload","useSyncExternalStore","useEffect","data","resolvedList","isLoading","status","error","fetchMore","objectSet"],"sources":["useObjectSet.tsx"],"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 DerivedProperty,\n LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport {\n computeObjectSetCacheKey,\n type ObserveObjectSetArgs,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore, type Snapshot } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseObjectSetOptions<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q, RDPs>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type)\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Enable streaming updates via websocket subscription.\n * When true, the object set will automatically update when matching objects are\n * added, updated, or removed.\n *\n * @default false\n */\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for filter selection\n * const { data: filteredObjects } = useObjectSet(MyObject.all(), {\n * where: { status: selectedStatus },\n * enabled: !!selectedStatus\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs>;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet<\n Q extends ObjectTypeDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs>,\n options: UseObjectSetOptions<Q, RDPs> = {},\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, streamUpdates, ...otherOptions } = options;\n\n // Track object type to detect when we switch to a different object type\n const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;\n const previousObjectTypeRef = React.useRef<string>(objectTypeKey);\n const previousPayloadRef = React.useRef<\n Snapshot<ObserveObjectSetArgs<Q, RDPs>> | undefined\n >();\n\n const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;\n if (objectTypeChanged) {\n previousObjectTypeRef.current = objectTypeKey;\n }\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs and enabled are excluded as they don't affect the data\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n });\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey} [DISABLED]`\n : void 0,\n );\n }\n\n const initialValue = objectTypeChanged\n ? undefined\n : previousPayloadRef.current;\n\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n const subscription = observableClient.observeObjectSet(\n baseObjectSet as ObjectSet<Q>,\n {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates,\n },\n observer,\n );\n return subscription;\n },\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey}`\n : void 0,\n initialValue,\n );\n },\n [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n React.useEffect(() => {\n if (payload) {\n previousPayloadRef.current = payload;\n }\n }, [payload]);\n\n return {\n data: payload?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: payload?.status === \"loading\" || (!payload && true) || false,\n error: payload && \"error\" in payload\n ? payload.error\n : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet as ObjectSet<Q, RDPs> || baseObjectSet,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SACEA,wBAAwB,QAEnB,kCAAkC;AACzC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAuB,wBAAwB;AACzE,SAASC,YAAY,QAAQ,mBAAmB;AAmIhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAK1BC,aAAqC,EACrCC,OAAqC,GAAG,CAAC,CAAC,EACb;EAC7B,MAAM;IAAEC;EAAiB,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,YAAY,CAAC;EAE3D,MAAM;IAAEM,OAAO,GAAG,IAAI;IAAEC,aAAa;IAAE,GAAGC;EAAa,CAAC,GAAGL,OAAO;;EAElE;EACA,MAAMM,aAAa,GAAGP,aAAa,CAACQ,mBAAmB,CAACC,GAAG,CAACC,OAAO;EACnE,MAAMC,qBAAqB,GAAGf,KAAK,CAACgB,MAAM,CAASL,aAAa,CAAC;EACjE,MAAMM,kBAAkB,GAAGjB,KAAK,CAACgB,MAAM,CAErC,CAAC;EAEH,MAAME,iBAAiB,GAAGH,qBAAqB,CAACI,OAAO,KAAKR,aAAa;EACzE,IAAIO,iBAAiB,EAAE;IACrBH,qBAAqB,CAACI,OAAO,GAAGR,aAAa;EAC/C;;EAEA;EACA;EACA,MAAMS,SAAS,GAAGrB,wBAAwB,CAACK,aAAa,EAAE;IACxDiB,KAAK,EAAEX,YAAY,CAACW,KAAK;IACzBC,cAAc,EAAEZ,YAAY,CAACY,cAAc;IAC3CC,KAAK,EAAEb,YAAY,CAACa,KAAK;IACzBC,SAAS,EAAEd,YAAY,CAACc,SAAS;IACjCC,Q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,SAAS,EAAE,GACxB,KAAK,CAAC,EACVgB,YACF,CAAC;EACH,CAAC,EACD,CAAC5B,OAAO,EAAEF,gBAAgB,EAAEc,SAAS,EAAEX,aAAa,EAAES,iBAAiB,CACzE,CAAC;EAED,MAAM0B,OAAO,GAAG5C,KAAK,CAAC6C,oBAAoB,CAAChB,SAAS,EAAEC,WAAW,CAAC;EAClE9B,KAAK,CAAC8C,SAAS,CAAC,MAAM;IACpB,IAAIF,OAAO,EAAE;MACX3B,kBAAkB,CAACE,OAAO,GAAGyB,OAAO;IACtC;EACF,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,OAAO;IACLG,IAAI,EAAEH,OAAO,EAAEI,YAKZ;IACHC,SAAS,EAAEL,OAAO,EAAEM,MAAM,KAAK,SAAS,IAAK,CAACN,OAAO,IAAI,IAAK,IAAI,KAAK;IACvEO,KAAK,EAAEP,OAAO,IAAI,OAAO,IAAIA,OAAO,GAChCA,OAAO,CAACO,KAAK,GACbd,SAAS;IACbe,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,SAAS,EAAET,OAAO,EAAES,SAAS,IAA0BjD;EACzD,CAAC;AACH","ignoreList":[]}
@@ -40,8 +40,8 @@ function OsdkProvider2({
40
40
  }
41
41
 
42
42
  // src/new/makeExternalStore.ts
43
- function makeExternalStore(createObservation, name) {
44
- let lastResult;
43
+ function makeExternalStore(createObservation, _name, initialValue) {
44
+ let lastResult = initialValue;
45
45
  function getSnapShot() {
46
46
  return lastResult;
47
47
  }
@@ -121,6 +121,13 @@ function useObjectSet(baseObjectSet, options = {}) {
121
121
  streamUpdates,
122
122
  ...otherOptions
123
123
  } = options;
124
+ const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;
125
+ const previousObjectTypeRef = React5__default.default.useRef(objectTypeKey);
126
+ const previousPayloadRef = React5__default.default.useRef();
127
+ const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;
128
+ if (objectTypeChanged) {
129
+ previousObjectTypeRef.current = objectTypeKey;
130
+ }
124
131
  const stableKey = unstableDoNotUse.computeObjectSetCacheKey(baseObjectSet, {
125
132
  where: otherOptions.where,
126
133
  withProperties: otherOptions.withProperties,
@@ -141,6 +148,7 @@ function useObjectSet(baseObjectSet, options = {}) {
141
148
  }
142
149
  }), process.env.NODE_ENV !== "production" ? `objectSet ${stableKey} [DISABLED]` : void 0);
143
150
  }
151
+ const initialValue = objectTypeChanged ? void 0 : previousPayloadRef.current;
144
152
  return makeExternalStore((observer) => {
145
153
  const subscription = observableClient.observeObjectSet(baseObjectSet, {
146
154
  where: otherOptions.where,
@@ -156,9 +164,14 @@ function useObjectSet(baseObjectSet, options = {}) {
156
164
  streamUpdates
157
165
  }, observer);
158
166
  return subscription;
159
- }, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0);
160
- }, [enabled, observableClient, stableKey, streamUpdates]);
167
+ }, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0, initialValue);
168
+ }, [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged]);
161
169
  const payload = React5__default.default.useSyncExternalStore(subscribe, getSnapShot);
170
+ React5__default.default.useEffect(() => {
171
+ if (payload) {
172
+ previousPayloadRef.current = payload;
173
+ }
174
+ }, [payload]);
162
175
  return {
163
176
  data: payload?.resolvedList,
164
177
  isLoading: payload?.status === "loading" || !payload && true || false,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/new/OsdkContext2.ts","../../../src/new/OsdkProvider2.tsx","../../../src/new/makeExternalStore.ts","../../../src/new/useLinks.ts","../../../src/new/useObjectSet.tsx","../../../src/new/useOsdkAction.ts","../../../src/new/useOsdkAggregation.ts","../../../src/new/useOsdkObject.ts","../../../src/new/useOsdkObjects.ts","../../../src/utils/useDebouncedCallback.ts"],"names":["useMemo","createObservableClient","React","OsdkContext","computeObjectSetCacheKey","applyAction","args","ActionValidationError","validateAction"],"mappings":";;;;;;;;;;;AAiBA,SAAS,gBAAgB,KAAO,EAAA;AAC9B,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GAAA,MAAA;AACrB,MAAA,KAAK,WAAY,CAAA,OAAA,CAAQ,GAAG,WAAA,CAAY,OAAO,CAAA;AAAA;AACjD,GACF,EAAG,EAAE,CAAA;AACL,EAAA,MAAM,iBAAoBA,GAAAA,uBAAAA,CAAM,WAAY,CAAA,CAAA,GAAI,IAAS,KAAA;AACvD,IAAA,WAAA,CAAY,OAAU,GAAA,IAAA;AACtB,IAAO,MAAA,EAAA;AACP,IAAW,UAAA,CAAA,OAAA,GAAU,WAAW,MAAM;AACpC,MAAK,KAAA,WAAA,CAAY,OAAQ,CAAA,GAAG,IAAI,CAAA;AAAA,OAC/B,KAAK,CAAA;AAAA,GACP,EAAA,CAAC,KAAO,EAAA,MAAM,CAAC,CAAA;AAClB,EAAAA,uBAAAA,CAAM,UAAU,MAAM;AACpB,IAAA,OAAO,MAAM;AACX,MAAO,MAAA,EAAA;AAAA,KACT;AAAA,GACF,EAAG,CAAC,MAAM,CAAC,CAAA;AACX,EAAO,OAAA,MAAA,CAAO,OAAO,iBAAmB,EAAA;AAAA,IACtC,MAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH","file":"experimental.cjs","sourcesContent":["/*\n * Copyright 2024 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 React from \"react\";\nfunction fakeClientFn(..._args) {\n throw new Error(\"This is not a real client. Did you forget to <OsdkContext.Provider>?\");\n}\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn\n});\nexport const OsdkContext2 = /*#__PURE__*/React.createContext({\n client: fakeClient,\n observableClient: undefined\n});","/*\n * Copyright 2024 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 { createObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React, { useMemo } from \"react\";\nimport { OsdkContext } from \"../OsdkContext.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function OsdkProvider2({\n children,\n client,\n observableClient\n}) {\n observableClient = useMemo(() => observableClient ?? createObservableClient(client), [client, observableClient]);\n return /*#__PURE__*/React.createElement(OsdkContext2.Provider, {\n value: {\n client,\n observableClient\n }\n }, /*#__PURE__*/React.createElement(OsdkContext.Provider, {\n value: {\n client\n }\n }, children));\n}","/*\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\nexport function makeExternalStore(createObservation, name) {\n let lastResult;\n function getSnapShot() {\n return lastResult;\n }\n function subscribe(notifyUpdate) {\n const obs = createObservation({\n next: payload => {\n lastResult = payload;\n notifyUpdate();\n },\n error: error => {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error))\n };\n notifyUpdate();\n },\n complete: () => {}\n });\n return () => {\n obs.unsubscribe();\n };\n }\n return {\n subscribe,\n getSnapShot\n };\n}","/*\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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nconst emptyArray = Object.freeze([]);\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks(objects, linkName, options = {}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const {\n enabled = true,\n ...otherOptions\n } = options;\n\n // Convert single object to array for consistent handling\n const objectsArray = React.useMemo(() => {\n return objects === undefined ? emptyArray : Array.isArray(objects) ? objects : [objects];\n }, [objects]);\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore(() => ({\n unsubscribe: () => {}\n }), `links ${linkName} for ${objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\",\")} [DISABLED]`);\n }\n return makeExternalStore(observer => observableClient.observeLinks(objectsArray, linkName, {\n linkName,\n where: otherOptions.where,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n mode: otherOptions.mode\n }, observer), `links ${linkName} for ${objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\",\")}`);\n }, [enabled, observableClient, objectsArray, linkName, otherOptions.where, otherOptions.pageSize, otherOptions.orderBy, otherOptions.mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n links: payload?.resolvedList,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n error: payload?.error,\n fetchMore: payload?.fetchMore,\n hasMore: payload?.hasMore ?? false\n };\n}","/*\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 { computeObjectSetCacheKey } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet(baseObjectSet, options = {}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const {\n enabled = true,\n streamUpdates,\n ...otherOptions\n } = options;\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs and enabled are excluded as they don't affect the data\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy\n });\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore(() => ({\n unsubscribe: () => {}\n }), process.env.NODE_ENV !== \"production\" ? `objectSet ${stableKey} [DISABLED]` : void 0);\n }\n return makeExternalStore(observer => {\n const subscription = observableClient.observeObjectSet(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates\n }, observer);\n return subscription;\n }, process.env.NODE_ENV !== \"production\" ? `objectSet ${stableKey}` : void 0);\n }, [enabled, observableClient, stableKey, streamUpdates]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n data: payload?.resolvedList,\n isLoading: payload?.status === \"loading\" || !payload && true || false,\n error: payload && \"error\" in payload ? payload.error : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet || baseObjectSet\n };\n}","/*\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 { ActionValidationError } from \"@osdk/client\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function useOsdkAction(actionDef) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState();\n const [data, setData] = React.useState();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState();\n const abortControllerRef = React.useRef(null);\n const applyAction = React.useCallback(async function applyAction(hookArgs) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n setPending(true);\n setError(undefined);\n if (Array.isArray(hookArgs)) {\n const updates = [];\n const args = hookArgs.map(a => {\n const {\n $optimisticUpdate,\n ...args\n } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: ctx => {\n for (const update of updates) {\n update?.(ctx);\n }\n }\n });\n setData(r);\n return r;\n } else {\n const {\n $optimisticUpdate,\n ...args\n } = hookArgs;\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e\n });\n } else {\n setError({\n unknown: e\n });\n }\n } finally {\n setPending(false);\n }\n }, [observableClient, actionDef, isValidating]);\n const validateAction = React.useCallback(async function validateAction(args) {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n setValidating(true);\n setError(undefined);\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e\n });\n } else {\n setError({\n unknown: e\n });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n }, [observableClient, actionDef, isPending]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n };\n }, []);\n return {\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult\n };\n}","/*\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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n/**\n * React hook for performing aggregations on OSDK object sets.\n *\n * Executes server-side aggregations with groupBy and metric calculations on filtered object sets.\n * Supports runtime derived properties and where clauses.\n *\n * @param type - The object or interface type to aggregate\n * @param options - Aggregation configuration including where clause, aggregation spec, and optional derived properties\n * @returns Object containing aggregation results, loading state, error state, and refetch function\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = useOsdkAggregation(Employee, {\n * where: { department: \"Engineering\" },\n * aggregate: {\n * groupBy: { department: \"exact\" },\n * select: {\n * avgSalary: { $avg: \"salary\" },\n * count: { $count: {} }\n * }\n * }\n * });\n * ```\n */\nexport function useOsdkAggregation(type, {\n where = {},\n withProperties,\n aggregate,\n dedupeIntervalMs\n}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});\n const stableWithProperties = React.useMemo(() => withProperties, [JSON.stringify(withProperties)]);\n const stableAggregate = React.useMemo(() => aggregate, [JSON.stringify(aggregate)]);\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(observer => observableClient.observeAggregation({\n type: type,\n where: canonWhere,\n withProperties: stableWithProperties,\n aggregate: stableAggregate,\n dedupeInterval: dedupeIntervalMs ?? 2_000\n }, observer), process.env.NODE_ENV !== \"production\" ? `aggregation ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, type.apiName, type.type, canonWhere, stableWithProperties, stableAggregate, dedupeIntervalMs]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n let error;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to execute aggregation\");\n }\n const refetch = React.useCallback(async () => {\n await observableClient.invalidateObjectType(type.apiName);\n }, [observableClient, type.apiName]);\n return {\n data: payload?.result,\n isLoading: payload?.status === \"loading\",\n error,\n refetch\n };\n}","/*\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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n * @param enabled Enable or disable the query (defaults to true)\n */\n\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n * @param enabled Enable or disable the query (defaults to true)\n */\n\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject(...args) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n // Check if first arg is an instance to discriminate signatures\n // TypeScript cannot narrow rest parameter unions with optional parameters,\n // so we must use type assertions after runtime discrimination\n const isInstanceSignature = \"$objectType\" in args[0];\n\n // Extract enabled flag - 2nd param for instance signature, 3rd for type signature\n const enabled = isInstanceSignature ? typeof args[1] === \"boolean\" ? args[1] : true : typeof args[2] === \"boolean\" ? args[2] : true;\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = isInstanceSignature ? \"offline\" : undefined;\n const objectType = isInstanceSignature ? args[0].$objectType : args[0].apiName;\n const primaryKey = isInstanceSignature ? args[0].$primaryKey : args[1];\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore(() => ({\n unsubscribe: () => {}\n }), `object ${objectType} ${primaryKey} [DISABLED]`);\n }\n return makeExternalStore(observer => observableClient.observeObject(objectType, primaryKey, {\n mode\n }, observer), `object ${objectType} ${primaryKey}`);\n }, [enabled, observableClient, objectType, primaryKey, mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n let error;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to load object\");\n }\n return {\n object: payload?.object,\n isLoading: payload?.status === \"loading\",\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate: () => {\n throw new Error(\"not implemented\");\n }\n };\n}","/*\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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function useOsdkObjects(type, options) {\n const {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n withProperties,\n autoFetchMore,\n intersectWith,\n pivotTo,\n enabled = true\n } = options ?? {};\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});\n const stableWithProperties = React.useMemo(() => withProperties, [JSON.stringify(withProperties)]);\n const stableIntersectWith = React.useMemo(() => intersectWith, [JSON.stringify(intersectWith)]);\n const stableOrderBy = React.useMemo(() => orderBy, [JSON.stringify(orderBy)]);\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore(() => ({\n unsubscribe: () => {}\n }), process.env.NODE_ENV !== \"production\" ? `list ${type.apiName} ${JSON.stringify(canonWhere)} [DISABLED]` : void 0);\n }\n return makeExternalStore(observer => observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy: stableOrderBy,\n streamUpdates,\n withProperties: stableWithProperties,\n autoFetchMore,\n ...(stableIntersectWith ? {\n intersectWith: stableIntersectWith\n } : {}),\n ...(pivotTo ? {\n pivotTo\n } : {})\n }, observer), process.env.NODE_ENV !== \"production\" ? `list ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0);\n }, [enabled, observableClient, type, canonWhere, dedupeIntervalMs, pageSize, stableOrderBy, streamUpdates, stableWithProperties, autoFetchMore, stableIntersectWith, pivotTo]);\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n let error;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false\n };\n}","/*\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 React from \"react\";\n/**\n * Creates a debounced version of a callback function.\n *\n * @param callback The function to debounce\n * @param delay The delay in milliseconds\n * @returns A debounced function with cancel() and flush() methods\n *\n * @example\n * ```tsx\n * const { applyAction } = useOsdkAction(editOffice);\n *\n * const debouncedSave = useDebouncedCallback(\n * async (name: string) => {\n * await applyAction({\n * Office: office,\n * name,\n * location: office.location!,\n * $optimisticUpdate: (ctx) => {\n * ctx.updateObject(office.$clone({ name }));\n * },\n * });\n * },\n * 1000\n * );\n *\n * <input onChange={(e) => debouncedSave(e.target.value)} />\n * ```\n */\nexport function useDebouncedCallback(callback, delay) {\n const timeoutRef = React.useRef();\n const callbackRef = React.useRef(callback);\n const lastArgsRef = React.useRef();\n callbackRef.current = callback;\n const cancel = React.useCallback(() => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = undefined;\n }\n }, []);\n const flush = React.useCallback(() => {\n if (timeoutRef.current && lastArgsRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = undefined;\n void callbackRef.current(...lastArgsRef.current);\n }\n }, []);\n const debouncedCallback = React.useCallback((...args) => {\n lastArgsRef.current = args;\n cancel();\n timeoutRef.current = setTimeout(() => {\n void callbackRef.current(...args);\n }, delay);\n }, [delay, cancel]);\n React.useEffect(() => {\n return () => {\n cancel();\n };\n }, [cancel]);\n return Object.assign(debouncedCallback, {\n cancel,\n flush\n });\n}"]}
1
+ {"version":3,"sources":["../../../src/new/OsdkContext2.ts","../../../src/new/OsdkProvider2.tsx","../../../src/new/makeExternalStore.ts","../../../src/new/useLinks.ts","../../../src/new/useObjectSet.tsx","../../../src/new/useOsdkAction.ts","../../../src/new/useOsdkAggregation.ts","../../../src/new/useOsdkObject.ts","../../../src/new/useOsdkObjects.ts","../../../src/utils/useDebouncedCallback.ts"],"names":["useMemo","createObservableClient","React","OsdkContext","computeObjectSetCacheKey","applyAction","args","ActionValidationError","validateAction"],"mappings":";;;;;;;;;;;AAiBA,SAAS,gBAAgB,KAAO,EAAA;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MAAM,CAAC,CAAA;AACX,EAAO,OAAA,MAAA,CAAO,OAAO,iBAAmB,EAAA;AAAA,IACtC,MAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH","file":"experimental.cjs","sourcesContent":["/*\n * Copyright 2024 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 React from \"react\";\nfunction fakeClientFn(..._args) {\n throw new Error(\"This is not a real client. Did you forget to <OsdkContext.Provider>?\");\n}\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn\n});\nexport const OsdkContext2 = /*#__PURE__*/React.createContext({\n client: fakeClient,\n observableClient: undefined\n});","/*\n * Copyright 2024 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 { createObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React, { useMemo } from \"react\";\nimport { OsdkContext } from \"../OsdkContext.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function OsdkProvider2({\n children,\n client,\n observableClient\n}) {\n observableClient = useMemo(() => observableClient ?? createObservableClient(client), [client, observableClient]);\n return /*#__PURE__*/React.createElement(OsdkContext2.Provider, {\n value: {\n client,\n observableClient\n }\n }, /*#__PURE__*/React.createElement(OsdkContext.Provider, {\n value: {\n client\n }\n }, children));\n}","/*\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\nexport function makeExternalStore(createObservation, _name, initialValue) {\n let lastResult = initialValue;\n function getSnapShot() {\n return lastResult;\n }\n function subscribe(notifyUpdate) {\n const obs = createObservation({\n next: payload => {\n lastResult = payload;\n notifyUpdate();\n },\n error: error => {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error))\n };\n notifyUpdate();\n },\n complete: () => {}\n });\n return () => {\n obs.unsubscribe();\n };\n }\n return {\n subscribe,\n getSnapShot\n };\n}","/*\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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nconst emptyArray = Object.freeze([]);\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks(objects, linkName, options = {}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const {\n enabled = true,\n ...otherOptions\n } = options;\n\n // Convert single object to array for consistent handling\n const objectsArray = React.useMemo(() => {\n return objects === undefined ? emptyArray : Array.isArray(objects) ? objects : [objects];\n }, [objects]);\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore(() => ({\n unsubscribe: () => {}\n }), `links ${linkName} for ${objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\",\")} [DISABLED]`);\n }\n return makeExternalStore(observer => observableClient.observeLinks(objectsArray, linkName, {\n linkName,\n where: otherOptions.where,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n mode: otherOptions.mode\n }, observer), `links ${linkName} for ${objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\",\")}`);\n }, [enabled, observableClient, objectsArray, linkName, otherOptions.where, otherOptions.pageSize, otherOptions.orderBy, otherOptions.mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n links: payload?.resolvedList,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n error: payload?.error,\n fetchMore: payload?.fetchMore,\n hasMore: payload?.hasMore ?? false\n };\n}","/*\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 { computeObjectSetCacheKey } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet(baseObjectSet, options = {}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const {\n enabled = true,\n streamUpdates,\n ...otherOptions\n } = options;\n\n // Track object type to detect when we switch to a different object type\n const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;\n const previousObjectTypeRef = React.useRef(objectTypeKey);\n const previousPayloadRef = React.useRef();\n const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;\n if (objectTypeChanged) {\n previousObjectTypeRef.current = objectTypeKey;\n }\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs and enabled are excluded as they don't affect the data\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy\n });\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore(() => ({\n unsubscribe: () => {}\n }), process.env.NODE_ENV !== \"production\" ? `objectSet ${stableKey} [DISABLED]` : void 0);\n }\n const initialValue = objectTypeChanged ? undefined : previousPayloadRef.current;\n return makeExternalStore(observer => {\n const subscription = observableClient.observeObjectSet(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates\n }, observer);\n return subscription;\n }, process.env.NODE_ENV !== \"production\" ? `objectSet ${stableKey}` : void 0, initialValue);\n }, [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n React.useEffect(() => {\n if (payload) {\n previousPayloadRef.current = payload;\n }\n }, [payload]);\n return {\n data: payload?.resolvedList,\n isLoading: payload?.status === \"loading\" || !payload && true || false,\n error: payload && \"error\" in payload ? payload.error : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet || baseObjectSet\n };\n}","/*\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 { ActionValidationError } from \"@osdk/client\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function useOsdkAction(actionDef) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState();\n const [data, setData] = React.useState();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState();\n const abortControllerRef = React.useRef(null);\n const applyAction = React.useCallback(async function applyAction(hookArgs) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n setPending(true);\n setError(undefined);\n if (Array.isArray(hookArgs)) {\n const updates = [];\n const args = hookArgs.map(a => {\n const {\n $optimisticUpdate,\n ...args\n } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: ctx => {\n for (const update of updates) {\n update?.(ctx);\n }\n }\n });\n setData(r);\n return r;\n } else {\n const {\n $optimisticUpdate,\n ...args\n } = hookArgs;\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e\n });\n } else {\n setError({\n unknown: e\n });\n }\n } finally {\n setPending(false);\n }\n }, [observableClient, actionDef, isValidating]);\n const validateAction = React.useCallback(async function validateAction(args) {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n setValidating(true);\n setError(undefined);\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e\n });\n } else {\n setError({\n unknown: e\n });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n }, [observableClient, actionDef, isPending]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n };\n }, []);\n return {\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult\n };\n}","/*\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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n/**\n * React hook for performing aggregations on OSDK object sets.\n *\n * Executes server-side aggregations with groupBy and metric calculations on filtered object sets.\n * Supports runtime derived properties and where clauses.\n *\n * @param type - The object or interface type to aggregate\n * @param options - Aggregation configuration including where clause, aggregation spec, and optional derived properties\n * @returns Object containing aggregation results, loading state, error state, and refetch function\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = useOsdkAggregation(Employee, {\n * where: { department: \"Engineering\" },\n * aggregate: {\n * groupBy: { department: \"exact\" },\n * select: {\n * avgSalary: { $avg: \"salary\" },\n * count: { $count: {} }\n * }\n * }\n * });\n * ```\n */\nexport function useOsdkAggregation(type, {\n where = {},\n withProperties,\n aggregate,\n dedupeIntervalMs\n}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});\n const stableWithProperties = React.useMemo(() => withProperties, [JSON.stringify(withProperties)]);\n const stableAggregate = React.useMemo(() => aggregate, [JSON.stringify(aggregate)]);\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(observer => observableClient.observeAggregation({\n type: type,\n where: canonWhere,\n withProperties: stableWithProperties,\n aggregate: stableAggregate,\n dedupeInterval: dedupeIntervalMs ?? 2_000\n }, observer), process.env.NODE_ENV !== \"production\" ? `aggregation ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, type.apiName, type.type, canonWhere, stableWithProperties, stableAggregate, dedupeIntervalMs]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n let error;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to execute aggregation\");\n }\n const refetch = React.useCallback(async () => {\n await observableClient.invalidateObjectType(type.apiName);\n }, [observableClient, type.apiName]);\n return {\n data: payload?.result,\n isLoading: payload?.status === \"loading\",\n error,\n refetch\n };\n}","/*\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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n * @param enabled Enable or disable the query (defaults to true)\n */\n\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n * @param enabled Enable or disable the query (defaults to true)\n */\n\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject(...args) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n // Check if first arg is an instance to discriminate signatures\n // TypeScript cannot narrow rest parameter unions with optional parameters,\n // so we must use type assertions after runtime discrimination\n const isInstanceSignature = \"$objectType\" in args[0];\n\n // Extract enabled flag - 2nd param for instance signature, 3rd for type signature\n const enabled = isInstanceSignature ? typeof args[1] === \"boolean\" ? args[1] : true : typeof args[2] === \"boolean\" ? args[2] : true;\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = isInstanceSignature ? \"offline\" : undefined;\n const objectType = isInstanceSignature ? args[0].$objectType : args[0].apiName;\n const primaryKey = isInstanceSignature ? args[0].$primaryKey : args[1];\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore(() => ({\n unsubscribe: () => {}\n }), `object ${objectType} ${primaryKey} [DISABLED]`);\n }\n return makeExternalStore(observer => observableClient.observeObject(objectType, primaryKey, {\n mode\n }, observer), `object ${objectType} ${primaryKey}`);\n }, [enabled, observableClient, objectType, primaryKey, mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n let error;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to load object\");\n }\n return {\n object: payload?.object,\n isLoading: payload?.status === \"loading\",\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate: () => {\n throw new Error(\"not implemented\");\n }\n };\n}","/*\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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function useOsdkObjects(type, options) {\n const {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n withProperties,\n autoFetchMore,\n intersectWith,\n pivotTo,\n enabled = true\n } = options ?? {};\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});\n const stableWithProperties = React.useMemo(() => withProperties, [JSON.stringify(withProperties)]);\n const stableIntersectWith = React.useMemo(() => intersectWith, [JSON.stringify(intersectWith)]);\n const stableOrderBy = React.useMemo(() => orderBy, [JSON.stringify(orderBy)]);\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n if (!enabled) {\n return makeExternalStore(() => ({\n unsubscribe: () => {}\n }), process.env.NODE_ENV !== \"production\" ? `list ${type.apiName} ${JSON.stringify(canonWhere)} [DISABLED]` : void 0);\n }\n return makeExternalStore(observer => observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy: stableOrderBy,\n streamUpdates,\n withProperties: stableWithProperties,\n autoFetchMore,\n ...(stableIntersectWith ? {\n intersectWith: stableIntersectWith\n } : {}),\n ...(pivotTo ? {\n pivotTo\n } : {})\n }, observer), process.env.NODE_ENV !== \"production\" ? `list ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0);\n }, [enabled, observableClient, type, canonWhere, dedupeIntervalMs, pageSize, stableOrderBy, streamUpdates, stableWithProperties, autoFetchMore, stableIntersectWith, pivotTo]);\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n let error;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false\n };\n}","/*\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 React from \"react\";\n/**\n * Creates a debounced version of a callback function.\n *\n * @param callback The function to debounce\n * @param delay The delay in milliseconds\n * @returns A debounced function with cancel() and flush() methods\n *\n * @example\n * ```tsx\n * const { applyAction } = useOsdkAction(editOffice);\n *\n * const debouncedSave = useDebouncedCallback(\n * async (name: string) => {\n * await applyAction({\n * Office: office,\n * name,\n * location: office.location!,\n * $optimisticUpdate: (ctx) => {\n * ctx.updateObject(office.$clone({ name }));\n * },\n * });\n * },\n * 1000\n * );\n *\n * <input onChange={(e) => debouncedSave(e.target.value)} />\n * ```\n */\nexport function useDebouncedCallback(callback, delay) {\n const timeoutRef = React.useRef();\n const callbackRef = React.useRef(callback);\n const lastArgsRef = React.useRef();\n callbackRef.current = callback;\n const cancel = React.useCallback(() => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = undefined;\n }\n }, []);\n const flush = React.useCallback(() => {\n if (timeoutRef.current && lastArgsRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = undefined;\n void callbackRef.current(...lastArgsRef.current);\n }\n }, []);\n const debouncedCallback = React.useCallback((...args) => {\n lastArgsRef.current = args;\n cancel();\n timeoutRef.current = setTimeout(() => {\n void callbackRef.current(...args);\n }, delay);\n }, [delay, cancel]);\n React.useEffect(() => {\n return () => {\n cancel();\n };\n }, [cancel]);\n return Object.assign(debouncedCallback, {\n cancel,\n flush\n });\n}"]}
@@ -26,7 +26,7 @@ function TestComponent() {
26
26
  data
27
27
  } = useOsdkObjects(Employee, {
28
28
  withProperties: {
29
- constantValue: employee => employee.constant.integer(42)
29
+ constantValue: employee => employee.selectProperty("class")
30
30
  }
31
31
  });
32
32
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkObjectsWithProperties.js","names":["Employee","useOsdkObjects","TestComponent","data","withProperties","constantValue","employee","constant","integer"],"sources":["useOsdkObjectsWithProperties.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\n// WARNING!\n// WARNING!\n// This file is used for tests that check intellisense. Editing this file by hand will likely\n// break tests that have hard coded line numbers and line offsets.\n\nimport type { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport { useOsdkObjects } from \"@osdk/react/experimental\";\n\nfunction TestComponent() {\n const withProps: DerivedProperty.Clause<typeof Employee> = {\n constantValue: (employee) => employee.constant.integer(42),\n };\n\n const { data } = useOsdkObjects(Employee, {\n withProperties: withProps,\n });\n\n return null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,4BAA4B;AACrD,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,SAASC,aAAaA,CAAA,EAAG;EAKvB,MAAM;IAAEC;EAAK,CAAC,GAAGF,cAAc,CAACD,QAAQ,EAAE;IACxCI,cAAc,EAL2C;MACzDC,aAAa,EAAGC,QAAQ,IAAKA,QAAQ,CAACC,QAAQ,CAACC,OAAO,CAAC,EAAE;IAC3D;EAIA,CAAC,CAAC;EAEF,OAAO,IAAI;AACb","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkObjectsWithProperties.js","names":["Employee","useOsdkObjects","TestComponent","data","withProperties","constantValue","employee","selectProperty"],"sources":["useOsdkObjectsWithProperties.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\n// WARNING!\n// WARNING!\n// This file is used for tests that check intellisense. Editing this file by hand will likely\n// break tests that have hard coded line numbers and line offsets.\n\nimport type { DerivedProperty } from \"@osdk/api\";\nimport { Employee } from \"@osdk/client.test.ontology\";\nimport { useOsdkObjects } from \"@osdk/react/experimental\";\n\nfunction TestComponent() {\n const withProps: DerivedProperty.Clause<typeof Employee> = {\n constantValue: (employee) => employee.selectProperty(\"class\"),\n };\n\n const { data } = useOsdkObjects(Employee, {\n withProperties: withProps,\n });\n\n return null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,4BAA4B;AACrD,SAASC,cAAc,QAAQ,0BAA0B;AAEzD,SAASC,aAAaA,CAAA,EAAG;EAKvB,MAAM;IAAEC;EAAK,CAAC,GAAGF,cAAc,CAACD,QAAQ,EAAE;IACxCI,cAAc,EAL2C;MACzDC,aAAa,EAAGC,QAAQ,IAAKA,QAAQ,CAACC,cAAc,CAAC,OAAO;IAC9D;EAIA,CAAC,CAAC;EAEF,OAAO,IAAI;AACb","ignoreList":[]}
@@ -14,8 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export function makeExternalStore(createObservation) {
18
- let lastResult;
17
+ export function makeExternalStore(createObservation, _name, initialValue) {
18
+ let lastResult = initialValue;
19
19
  function getSnapShot() {
20
20
  return lastResult;
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"makeExternalStore.js","names":["makeExternalStore","createObservation","lastResult","getSnapShot","subscribe","notifyUpdate","obs","next","payload","error","Error","String","complete","unsubscribe"],"sources":["makeExternalStore.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 Observer,\n Unsubscribable,\n} from \"@osdk/client/unstable-do-not-use\";\n\nexport type Snapshot<X> =\n | X & { error?: Error }\n | (Partial<X> & { error?: Error })\n | undefined;\n\nexport function makeExternalStore<X>(\n createObservation: (callback: Observer<X | undefined>) => Unsubscribable,\n name?: string,\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => Snapshot<X>;\n} {\n let lastResult: Snapshot<X>;\n\n function getSnapShot(): Snapshot<X> {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n const obs = createObservation({\n next: (payload) => {\n lastResult = payload as Snapshot<X>;\n notifyUpdate();\n },\n error: (error: unknown) => {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n },\n complete: () => {},\n });\n\n return (): void => {\n obs.unsubscribe();\n };\n }\n\n return {\n subscribe,\n getSnapShot,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAO,SAASA,iBAAiBA,CAC/BC,iBAAwE,EAKxE;EACA,IAAIC,UAAuB;EAE3B,SAASC,WAAWA,CAAA,EAAgB;IAClC,OAAOD,UAAU;EACnB;EAuBA,OAAO;IACLE,SAAS,EAtBX,SAASA,SAASA,CAACC,YAAwB,EAAE;MAC3C,MAAMC,GAAG,GAAGL,iBAAiB,CAAC;QAC5BM,IAAI,EAAGC,OAAO,IAAK;UACjBN,UAAU,GAAGM,OAAsB;UACnCH,YAAY,CAAC,CAAC;QAChB,CAAC;QACDI,KAAK,EAAGA,KAAc,IAAK;UACzBP,UAAU,GAAG;YACX,IAAIA,UAAU,IAAI,CAAC,CAAC,CAAC;YACrBO,KAAK,EAAEA,KAAK,YAAYC,KAAK,GAAGD,KAAK,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,KAAK,CAAC;UACjE,CAAgB;UAChBJ,YAAY,CAAC,CAAC;QAChB,CAAC;QACDO,QAAQ,EAAEA,CAAA,KAAM,CAAC;MACnB,CAAC,CAAC;MAEF,OAAO,MAAY;QACjBN,GAAG,CAACO,WAAW,CAAC,CAAC;MACnB,CAAC;IACH,CAGW;IACTV;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"makeExternalStore.js","names":["makeExternalStore","createObservation","_name","initialValue","lastResult","getSnapShot","subscribe","notifyUpdate","obs","next","payload","error","Error","String","complete","unsubscribe"],"sources":["makeExternalStore.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 Observer,\n Unsubscribable,\n} from \"@osdk/client/unstable-do-not-use\";\n\nexport type Snapshot<X> =\n | X & { error?: Error }\n | (Partial<X> & { error?: Error })\n | undefined;\n\nexport function makeExternalStore<X>(\n createObservation: (callback: Observer<X | undefined>) => Unsubscribable,\n _name?: string,\n initialValue?: Snapshot<X>,\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => Snapshot<X>;\n} {\n let lastResult: Snapshot<X> = initialValue;\n\n function getSnapShot(): Snapshot<X> {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n const obs = createObservation({\n next: (payload) => {\n lastResult = payload as Snapshot<X>;\n notifyUpdate();\n },\n error: (error: unknown) => {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n },\n complete: () => {},\n });\n\n return (): void => {\n obs.unsubscribe();\n };\n }\n\n return {\n subscribe,\n getSnapShot,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,OAAO,SAASA,iBAAiBA,CAC/BC,iBAAwE,EACxEC,KAAc,EACdC,YAA0B,EAI1B;EACA,IAAIC,UAAuB,GAAGD,YAAY;EAE1C,SAASE,WAAWA,CAAA,EAAgB;IAClC,OAAOD,UAAU;EACnB;EAuBA,OAAO;IACLE,SAAS,EAtBX,SAASA,SAASA,CAACC,YAAwB,EAAE;MAC3C,MAAMC,GAAG,GAAGP,iBAAiB,CAAC;QAC5BQ,IAAI,EAAGC,OAAO,IAAK;UACjBN,UAAU,GAAGM,OAAsB;UACnCH,YAAY,CAAC,CAAC;QAChB,CAAC;QACDI,KAAK,EAAGA,KAAc,IAAK;UACzBP,UAAU,GAAG;YACX,IAAIA,UAAU,IAAI,CAAC,CAAC,CAAC;YACrBO,KAAK,EAAEA,KAAK,YAAYC,KAAK,GAAGD,KAAK,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,KAAK,CAAC;UACjE,CAAgB;UAChBJ,YAAY,CAAC,CAAC;QAChB,CAAC;QACDO,QAAQ,EAAEA,CAAA,KAAM,CAAC;MACnB,CAAC,CAAC;MAEF,OAAO,MAAY;QACjBN,GAAG,CAACO,WAAW,CAAC,CAAC;MACnB,CAAC;IACH,CAGW;IACTV;EACF,CAAC;AACH","ignoreList":[]}
@@ -39,6 +39,15 @@ export function useObjectSet(baseObjectSet, options = {}) {
39
39
  ...otherOptions
40
40
  } = options;
41
41
 
42
+ // Track object type to detect when we switch to a different object type
43
+ const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;
44
+ const previousObjectTypeRef = React.useRef(objectTypeKey);
45
+ const previousPayloadRef = React.useRef();
46
+ const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;
47
+ if (objectTypeChanged) {
48
+ previousObjectTypeRef.current = objectTypeKey;
49
+ }
50
+
42
51
  // Compute a stable cache key for the ObjectSet and options
43
52
  // dedupeIntervalMs and enabled are excluded as they don't affect the data
44
53
  const stableKey = computeObjectSetCacheKey(baseObjectSet, {
@@ -60,6 +69,7 @@ export function useObjectSet(baseObjectSet, options = {}) {
60
69
  unsubscribe: () => {}
61
70
  }), process.env.NODE_ENV !== "production" ? `objectSet ${stableKey} [DISABLED]` : void 0);
62
71
  }
72
+ const initialValue = objectTypeChanged ? undefined : previousPayloadRef.current;
63
73
  return makeExternalStore(observer => {
64
74
  const subscription = observableClient.observeObjectSet(baseObjectSet, {
65
75
  where: otherOptions.where,
@@ -75,9 +85,14 @@ export function useObjectSet(baseObjectSet, options = {}) {
75
85
  streamUpdates
76
86
  }, observer);
77
87
  return subscription;
78
- }, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0);
79
- }, [enabled, observableClient, stableKey, streamUpdates]);
88
+ }, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0, initialValue);
89
+ }, [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged]);
80
90
  const payload = React.useSyncExternalStore(subscribe, getSnapShot);
91
+ React.useEffect(() => {
92
+ if (payload) {
93
+ previousPayloadRef.current = payload;
94
+ }
95
+ }, [payload]);
81
96
  return {
82
97
  data: payload?.resolvedList,
83
98
  isLoading: payload?.status === "loading" || !payload && true || false,
@@ -1 +1 @@
1
- {"version":3,"file":"useObjectSet.js","names":["computeObjectSetCacheKey","React","makeExternalStore","OsdkContext2","useObjectSet","baseObjectSet","options","observableClient","useContext","enabled","streamUpdates","otherOptions","stableKey","where","withProperties","union","intersect","subtract","pivotTo","pageSize","orderBy","subscribe","getSnapShot","useMemo","unsubscribe","process","env","NODE_ENV","observer","subscription","observeObjectSet","dedupeInterval","dedupeIntervalMs","autoFetchMore","payload","useSyncExternalStore","data","resolvedList","isLoading","status","error","undefined","fetchMore","objectSet"],"sources":["useObjectSet.tsx"],"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 DerivedProperty,\n LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport {\n computeObjectSetCacheKey,\n type ObserveObjectSetArgs,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseObjectSetOptions<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q, RDPs>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type)\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Enable streaming updates via websocket subscription.\n * When true, the object set will automatically update when matching objects are\n * added, updated, or removed.\n *\n * @default false\n */\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for filter selection\n * const { data: filteredObjects } = useObjectSet(MyObject.all(), {\n * where: { status: selectedStatus },\n * enabled: !!selectedStatus\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs>;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet<\n Q extends ObjectTypeDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs>,\n options: UseObjectSetOptions<Q, RDPs> = {},\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, streamUpdates, ...otherOptions } = options;\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs and enabled are excluded as they don't affect the data\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n });\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey} [DISABLED]`\n : void 0,\n );\n }\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n const subscription = observableClient.observeObjectSet(\n baseObjectSet as ObjectSet<Q>,\n {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates,\n },\n observer,\n );\n return subscription;\n },\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey}`\n : void 0,\n );\n },\n [enabled, observableClient, stableKey, streamUpdates],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n data: payload?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: payload?.status === \"loading\" || (!payload && true) || false,\n error: payload && \"error\" in payload\n ? payload.error\n : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet as ObjectSet<Q, RDPs> || baseObjectSet,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SACEA,wBAAwB,QAEnB,kCAAkC;AACzC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAmIhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAK1BC,aAAqC,EACrCC,OAAqC,GAAG,CAAC,CAAC,EACb;EAC7B,MAAM;IAAEC;EAAiB,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,YAAY,CAAC;EAE3D,MAAM;IAAEM,OAAO,GAAG,IAAI;IAAEC,aAAa;IAAE,GAAGC;EAAa,CAAC,GAAGL,OAAO;;EAElE;EACA;EACA,MAAMM,SAAS,GAAGZ,wBAAwB,CAACK,aAAa,EAAE;IACxDQ,KAAK,EAAEF,YAAY,CAACE,KAAK;IACzBC,cAAc,EAAEH,YAAY,CAACG,cAAc;IAC3CC,KAAK,EAAEJ,YAAY,CAACI,KAAK;IACzBC,SAAS,EAAEL,YAAY,CAACK,SAAS;IACjCC,QAAQ,EAAEN,YAAY,CAACM,QAAQ;IAC/BC,OAAO,EAAEP,YAAY,CAACO,OAAO;IAC7BC,QAAQ,EAAER,YAAY,CAACQ,QAAQ;IAC/BC,OAAO,EAAET,YAAY,CAACS;EACxB,CAAC,CAAC;EAEF,MAAM;IAAEC,SAAS;IAAEC;EAAY,CAAC,GAAGrB,KAAK,CAACsB,OAAO,CAC9C,MAAM;IACJ,IAAI,CAACd,OAAO,EAAE;MACZ,OAAOP,iBAAiB,CACtB,OAA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AACM,KAAK,GACbC,SAAS;IACbC,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,SAAS,EAAET,OAAO,EAAES,SAAS,IAA0BtC;EACzD,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useObjectSet.js","names":["computeObjectSetCacheKey","React","makeExternalStore","OsdkContext2","useObjectSet","baseObjectSet","options","observableClient","useContext","enabled","streamUpdates","otherOptions","objectTypeKey","$objectSetInternals","def","apiName","previousObjectTypeRef","useRef","previousPayloadRef","objectTypeChanged","current","stableKey","where","withProperties","union","intersect","subtract","pivotTo","pageSize","orderBy","subscribe","getSnapShot","useMemo","unsubscribe","process","env","NODE_ENV","initialValue","undefined","observer","subscription","observeObjectSet","dedupeInterval","dedupeIntervalMs","autoFetchMore","payload","useSyncExternalStore","useEffect","data","resolvedList","isLoading","status","error","fetchMore","objectSet"],"sources":["useObjectSet.tsx"],"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 DerivedProperty,\n LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport {\n computeObjectSetCacheKey,\n type ObserveObjectSetArgs,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore, type Snapshot } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseObjectSetOptions<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q, RDPs>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type)\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Enable streaming updates via websocket subscription.\n * When true, the object set will automatically update when matching objects are\n * added, updated, or removed.\n *\n * @default false\n */\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for filter selection\n * const { data: filteredObjects } = useObjectSet(MyObject.all(), {\n * where: { status: selectedStatus },\n * enabled: !!selectedStatus\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs>;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet<\n Q extends ObjectTypeDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs>,\n options: UseObjectSetOptions<Q, RDPs> = {},\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, streamUpdates, ...otherOptions } = options;\n\n // Track object type to detect when we switch to a different object type\n const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;\n const previousObjectTypeRef = React.useRef<string>(objectTypeKey);\n const previousPayloadRef = React.useRef<\n Snapshot<ObserveObjectSetArgs<Q, RDPs>> | undefined\n >();\n\n const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;\n if (objectTypeChanged) {\n previousObjectTypeRef.current = objectTypeKey;\n }\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs and enabled are excluded as they don't affect the data\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n });\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey} [DISABLED]`\n : void 0,\n );\n }\n\n const initialValue = objectTypeChanged\n ? undefined\n : previousPayloadRef.current;\n\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n const subscription = observableClient.observeObjectSet(\n baseObjectSet as ObjectSet<Q>,\n {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates,\n },\n observer,\n );\n return subscription;\n },\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey}`\n : void 0,\n initialValue,\n );\n },\n [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n React.useEffect(() => {\n if (payload) {\n previousPayloadRef.current = payload;\n }\n }, [payload]);\n\n return {\n data: payload?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: payload?.status === \"loading\" || (!payload && true) || false,\n error: payload && \"error\" in payload\n ? payload.error\n : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet as ObjectSet<Q, RDPs> || baseObjectSet,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SACEA,wBAAwB,QAEnB,kCAAkC;AACzC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,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X3B,kBAAkB,CAACE,OAAO,GAAGyB,OAAO;IACtC;EACF,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,OAAO;IACLG,IAAI,EAAEH,OAAO,EAAEI,YAKZ;IACHC,SAAS,EAAEL,OAAO,EAAEM,MAAM,KAAK,SAAS,IAAK,CAACN,OAAO,IAAI,IAAK,IAAI,KAAK;IACvEO,KAAK,EAAEP,OAAO,IAAI,OAAO,IAAIA,OAAO,GAChCA,OAAO,CAACO,KAAK,GACbd,SAAS;IACbe,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,SAAS,EAAET,OAAO,EAAES,SAAS,IAA0BjD;EACzD,CAAC;AACH","ignoreList":[]}
@@ -4,7 +4,7 @@ export type Snapshot<X> = X & {
4
4
  } | (Partial<X> & {
5
5
  error?: Error
6
6
  }) | undefined;
7
- export declare function makeExternalStore<X>(createObservation: (callback: Observer<X | undefined>) => Unsubscribable, name?: string): {
7
+ export declare function makeExternalStore<X>(createObservation: (callback: Observer<X | undefined>) => Unsubscribable, _name?: string, initialValue?: Snapshot<X>): {
8
8
  subscribe: (notifyUpdate: () => void) => () => void
9
9
  getSnapShot: () => Snapshot<X>
10
10
  };
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cACE,UACA,sBACK,kCAAmC;AAE1C,YAAY,SAAS,KACjB,IAAI;CAAE,QAAQ;AAAO,KACpB,QAAQ,KAAK;CAAE,QAAQ;AAAO;AAGnC,OAAO,iBAAS,kBAAkB,GAChCA,oBAAoBC,UAAU,SAAS,mBAAmB,gBAC1DC,gBACC;CACD,YAAYC;CACZ,mBAAmB,SAAS;AAC7B","names":["createObservation: (callback: Observer<X | undefined>) => Unsubscribable","callback: Observer<X | undefined>","name?: string","notifyUpdate: () => void"],"sources":["../../../src/new/makeExternalStore.ts"],"version":3,"file":"makeExternalStore.d.ts"}
1
+ {"mappings":"AAgBA,cACE,UACA,sBACK,kCAAmC;AAE1C,YAAY,SAAS,KACjB,IAAI;CAAE,QAAQ;AAAO,KACpB,QAAQ,KAAK;CAAE,QAAQ;AAAO;AAGnC,OAAO,iBAAS,kBAAkB,GAChCA,oBAAoBC,UAAU,SAAS,mBAAmB,gBAC1DC,gBACAC,eAAe,SAAS,KACvB;CACD,YAAYC;CACZ,mBAAmB,SAAS;AAC7B","names":["createObservation: (callback: Observer<X | undefined>) => Unsubscribable","callback: Observer<X | undefined>","_name?: string","initialValue?: Snapshot<X>","notifyUpdate: () => void"],"sources":["../../../src/new/makeExternalStore.ts"],"version":3,"file":"makeExternalStore.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/react",
3
- "version": "0.8.0-beta.5",
3
+ "version": "0.8.0-rc.7",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -55,11 +55,11 @@
55
55
  "react": "^18.3.1",
56
56
  "tiny-invariant": "^1.3.3",
57
57
  "typescript": "~5.5.4",
58
- "@osdk/api": "2.6.0-beta.13",
59
- "@osdk/client": "2.6.0-beta.13",
60
- "@osdk/client.test.ontology": "2.6.0-beta.13",
61
- "@osdk/monorepo.tsconfig": "~0.5.0-beta.1",
62
- "@osdk/monorepo.api-extractor": "~0.5.0-beta.1"
58
+ "@osdk/api": "2.6.0-rc.18",
59
+ "@osdk/client": "2.6.0-rc.18",
60
+ "@osdk/monorepo.api-extractor": "~0.5.0-beta.1",
61
+ "@osdk/client.test.ontology": "2.6.0-rc.18",
62
+ "@osdk/monorepo.tsconfig": "~0.5.0-beta.1"
63
63
  },
64
64
  "publishConfig": {
65
65
  "access": "public"