@osdk/react 0.4.0-beta.2 → 0.4.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/build/browser/new/OsdkContext2.js +1 -1
  3. package/build/browser/new/OsdkContext2.js.map +1 -1
  4. package/build/browser/new/OsdkProvider2.js +5 -3
  5. package/build/browser/new/OsdkProvider2.js.map +1 -1
  6. package/build/browser/new/useOsdkAction.js +3 -3
  7. package/build/browser/new/useOsdkAction.js.map +1 -1
  8. package/build/browser/new/useOsdkObject.js +3 -3
  9. package/build/browser/new/useOsdkObject.js.map +1 -1
  10. package/build/browser/new/{useOsdkList.js → useOsdkObjects.js} +9 -9
  11. package/build/browser/new/useOsdkObjects.js.map +1 -0
  12. package/build/browser/public/experimental.js +1 -1
  13. package/build/browser/public/experimental.js.map +1 -1
  14. package/build/cjs/public/experimental.cjs +40 -39
  15. package/build/cjs/public/experimental.cjs.map +1 -1
  16. package/build/cjs/public/experimental.d.cts +31 -32
  17. package/build/esm/new/OsdkContext2.js +1 -1
  18. package/build/esm/new/OsdkContext2.js.map +1 -1
  19. package/build/esm/new/OsdkProvider2.js +5 -3
  20. package/build/esm/new/OsdkProvider2.js.map +1 -1
  21. package/build/esm/new/useOsdkAction.js +3 -3
  22. package/build/esm/new/useOsdkAction.js.map +1 -1
  23. package/build/esm/new/useOsdkObject.js +3 -3
  24. package/build/esm/new/useOsdkObject.js.map +1 -1
  25. package/build/esm/new/{useOsdkList.js → useOsdkObjects.js} +9 -9
  26. package/build/esm/new/useOsdkObjects.js.map +1 -0
  27. package/build/esm/public/experimental.js +1 -1
  28. package/build/esm/public/experimental.js.map +1 -1
  29. package/build/types/new/OsdkContext2.d.ts +1 -1
  30. package/build/types/new/OsdkContext2.d.ts.map +1 -1
  31. package/build/types/new/OsdkProvider2.d.ts +3 -3
  32. package/build/types/new/OsdkProvider2.d.ts.map +1 -1
  33. package/build/types/new/{useOsdkList.d.ts → useOsdkObjects.d.ts} +4 -5
  34. package/build/types/new/useOsdkObjects.d.ts.map +1 -0
  35. package/build/types/public/experimental.d.ts +1 -1
  36. package/build/types/public/experimental.d.ts.map +1 -1
  37. package/package.json +5 -5
  38. package/build/browser/new/useOsdkList.js.map +0 -1
  39. package/build/esm/new/useOsdkList.js.map +0 -1
  40. package/build/types/new/useOsdkList.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @osdkkit/react
2
2
 
3
+ ## 0.4.0-beta.3
4
+
5
+ ### Minor Changes
6
+
7
+ - 2f6206c: Improvements to @osdk/react
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [62e5965]
12
+ - Updated dependencies [2f6206c]
13
+ - @osdk/client@2.2.0-beta.5
14
+ - @osdk/api@2.2.0-beta.5
15
+
3
16
  ## 0.4.0-beta.2
4
17
 
5
18
  ### Minor Changes
@@ -23,6 +23,6 @@ const fakeClient = Object.assign(fakeClientFn, {
23
23
  });
24
24
  export const OsdkContext2 = /*#__PURE__*/React.createContext({
25
25
  client: fakeClient,
26
- store: undefined
26
+ observableClient: undefined
27
27
  });
28
28
  //# sourceMappingURL=OsdkContext2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OsdkContext2.js","names":["React","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","OsdkContext2","createContext","client","store","undefined"],"sources":["OsdkContext2.ts"],"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 type { Client } from \"@osdk/client\";\nimport type { ObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\n\nfunction fakeClientFn(..._args: any[]) {\n throw new Error(\n \"This is not a real client. Did you forget to <OsdkContext.Provider>?\",\n );\n}\n\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn,\n} as Client);\n\ninterface OsdkContextContents {\n client: Client;\n // keeping the old name for now intentionally\n // in case i need both for a while\n // in the future we can just make\n // this `client: ObservableClient`\n store: ObservableClient;\n}\n\nexport const OsdkContext2: React.Context<OsdkContextContents> = React\n .createContext<OsdkContextContents>({\n client: fakeClient,\n store: undefined!,\n });\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAYA,CAAC,GAAGC,KAAY,EAAE;EACrC,MAAM,IAAIC,KAAK,CACb,sEACF,CAAC;AACH;AAEA,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC7CM,aAAa,EAAEN;AACjB,CAAW,CAAC;AAWZ,OAAO,MAAMO,YAAgD,gBAAGR,KAAK,CAClES,aAAa,CAAsB;EAClCC,MAAM,EAAEN,UAAU;EAClBO,KAAK,EAAEC;AACT,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"OsdkContext2.js","names":["React","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","OsdkContext2","createContext","client","observableClient","undefined"],"sources":["OsdkContext2.ts"],"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 type { Client } from \"@osdk/client\";\nimport type { ObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\n\nfunction fakeClientFn(..._args: any[]) {\n throw new Error(\n \"This is not a real client. Did you forget to <OsdkContext.Provider>?\",\n );\n}\n\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn,\n} as Client);\n\ninterface OsdkContextContents {\n client: Client;\n // keeping the old name for now intentionally\n // in case i need both for a while\n // in the future we can just make\n // this `client: ObservableClient`\n observableClient: ObservableClient;\n}\n\nexport const OsdkContext2: React.Context<OsdkContextContents> = React\n .createContext<OsdkContextContents>({\n client: fakeClient,\n observableClient: undefined!,\n });\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAYA,CAAC,GAAGC,KAAY,EAAE;EACrC,MAAM,IAAIC,KAAK,CACb,sEACF,CAAC;AACH;AAEA,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC7CM,aAAa,EAAEN;AACjB,CAAW,CAAC;AAWZ,OAAO,MAAMO,YAAgD,gBAAGR,KAAK,CAClES,aAAa,CAAsB;EAClCC,MAAM,EAAEN,UAAU;EAClBO,gBAAgB,EAAEC;AACpB,CAAC,CAAC","ignoreList":[]}
@@ -14,17 +14,19 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React from "react";
17
+ import { createObservableClient } from "@osdk/client/unstable-do-not-use";
18
+ import React, { useMemo } from "react";
18
19
  import { OsdkContext2 } from "./OsdkContext2.js";
19
20
  export function OsdkProvider2({
20
21
  children,
21
22
  client,
22
- store
23
+ observableClient
23
24
  }) {
25
+ observableClient = useMemo(() => observableClient ?? createObservableClient(client), [client, observableClient]);
24
26
  return /*#__PURE__*/React.createElement(OsdkContext2.Provider, {
25
27
  value: {
26
28
  client,
27
- store
29
+ observableClient
28
30
  }
29
31
  }, children);
30
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OsdkProvider2.js","names":["React","OsdkContext2","OsdkProvider2","children","client","store","createElement","Provider","value"],"sources":["OsdkProvider2.tsx"],"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 type { Client } from \"@osdk/client\";\nimport type { ObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ninterface OsdkProviderOptions {\n children: React.ReactNode;\n client: Client;\n store: ObservableClient;\n}\n\nexport function OsdkProvider2({\n children,\n client,\n store,\n}: OsdkProviderOptions): React.JSX.Element {\n return (\n <OsdkContext2.Provider value={{ client, store }}>\n {children}\n </OsdkContext2.Provider>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,mBAAmB;AAQhD,OAAO,SAASC,aAAaA,CAAC;EAC5BC,QAAQ;EACRC,MAAM;EACNC;AACmB,CAAC,EAAqB;EACzC,oBACEL,KAAA,CAAAM,aAAA,CAACL,YAAY,CAACM,QAAQ;IAACC,KAAK,EAAE;MAAEJ,MAAM;MAAEC;IAAM;EAAE,GAC7CF,QACoB,CAAC;AAE5B","ignoreList":[]}
1
+ {"version":3,"file":"OsdkProvider2.js","names":["createObservableClient","React","useMemo","OsdkContext2","OsdkProvider2","children","client","observableClient","createElement","Provider","value"],"sources":["OsdkProvider2.tsx"],"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 type { Client } from \"@osdk/client\";\nimport {\n createObservableClient,\n type ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React, { useMemo } from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ninterface OsdkProviderOptions {\n children: React.ReactNode;\n client: Client;\n observableClient?: ObservableClient;\n}\n\nexport function OsdkProvider2({\n children,\n client,\n observableClient,\n}: OsdkProviderOptions): React.JSX.Element {\n observableClient = useMemo(\n () => observableClient ?? createObservableClient(client),\n [client, observableClient],\n );\n return (\n <OsdkContext2.Provider value={{ client, observableClient }}>\n {children}\n </OsdkContext2.Provider>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,sBAAsB,QAEjB,kCAAkC;AACzC,OAAOC,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,YAAY,QAAQ,mBAAmB;AAQhD,OAAO,SAASC,aAAaA,CAAC;EAC5BC,QAAQ;EACRC,MAAM;EACNC;AACmB,CAAC,EAAqB;EACzCA,gBAAgB,GAAGL,OAAO,CACxB,MAAMK,gBAAgB,IAAIP,sBAAsB,CAACM,MAAM,CAAC,EACxD,CAACA,MAAM,EAAEC,gBAAgB,CAC3B,CAAC;EACD,oBACEN,KAAA,CAAAO,aAAA,CAACL,YAAY,CAACM,QAAQ;IAACC,KAAK,EAAE;MAAEJ,MAAM;MAAEC;IAAiB;EAAE,GACxDF,QACoB,CAAC;AAE5B","ignoreList":[]}
@@ -19,7 +19,7 @@ import React from "react";
19
19
  import { OsdkContext2 } from "./OsdkContext2.js";
20
20
  export function useOsdkAction(actionDef) {
21
21
  const {
22
- store
22
+ observableClient
23
23
  } = React.useContext(OsdkContext2);
24
24
  const [error, setError] = React.useState();
25
25
  const [data, setData] = React.useState();
@@ -32,7 +32,7 @@ export function useOsdkAction(actionDef) {
32
32
  try {
33
33
  setPending(true);
34
34
  setError(undefined);
35
- const r = await store.applyAction(actionDef, args, {
35
+ const r = await observableClient.applyAction(actionDef, args, {
36
36
  optimisticUpdate: $optimisticUpdate
37
37
  });
38
38
  setData(r);
@@ -50,7 +50,7 @@ export function useOsdkAction(actionDef) {
50
50
  } finally {
51
51
  setPending(false);
52
52
  }
53
- }, [store, setError]);
53
+ }, [observableClient, setError]);
54
54
  return {
55
55
  applyAction,
56
56
  error,
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","OsdkContext2","useOsdkAction","actionDef","store","useContext","error","setError","useState","data","setData","isPending","setPending","applyAction","useCallback","hookArgs","$optimisticUpdate","args","undefined","r","optimisticUpdate","e","actionValidation","unknown"],"sources":["useOsdkAction.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 { ActionDefinition } from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> =\n & Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]:\n ObservableClient.ApplyActionOptions[K];\n };\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q>,\n ) => Promise<unknown>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: unknown;\n\n isPending: boolean;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q,\n): UseOsdkActionResult<Q> {\n const { store } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<unknown>();\n const [isPending, setPending] = React.useState(false);\n\n const applyAction = React.useCallback(async function applyAction(\n hookArgs: ApplyActionParams<Q>,\n ) {\n const { $optimisticUpdate, ...args } = hookArgs;\n try {\n setPending(true);\n setError(undefined);\n const r = await store.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n } finally {\n setPending(false);\n }\n }, [store, setError]);\n\n return { applyAction, error, data, isPending };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,qBAAqB,QAAQ,cAAc;AAKpD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,mBAAmB;AAyBhD,OAAO,SAASC,aAAaA,CAC3BC,SAAY,EACY;EACxB,MAAM;IAAEC;EAAM,CAAC,GAAGJ,KAAK,CAACK,UAAU,CAACJ,YAAY,CAAC;EAChD,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAGP,KAAK,CAACQ,QAAQ,CAAkC,CAAC;EAC3E,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,KAAK,CAACQ,QAAQ,CAAU,CAAC;EACjD,MAAM,CAACG,SAAS,EAAEC,UAAU,CAAC,GAAGZ,KAAK,CAACQ,QAAQ,CAAC,KAAK,CAAC;EAErD,MAAMK,WAAW,GAAGb,KAAK,CAACc,WAAW,CAAC,gBACpCC,QAA8B,EAC9B;IACA,MAAM;MAAEC,iBAAiB;MAAE,GAAGC;IAAK,CAAC,GAAGF,QAAQ;IAC/C,IAAI;MACFH,UAAU,CAAC,IAAI,CAAC;MAChBL,QAAQ,CAACW,SAAS,CAAC;MACnB,MAAMC,CAAC,GAAG,MAAMf,KAAK,CAACS,WAAW,CAACV,SAAS,EAAEc,IAAI,EAAE;QACjDG,gBAAgB,EAAEJ;MACpB,CAAC,CAAC;MACFN,OAAO,CAACS,CAAC,CAAC;MACV,OAAOA,CAAC;IACV,CAAC,CAAC,OAAOE,CAAC,EAAE;MACV,IAAIA,CAAC,YAAYtB,qBAAqB,EAAE;QACtCQ,QAAQ,CAAC;UACPe,gBAAgB,EAAED;QACpB,CAAC,CAAC;MACJ,CAAC,MAAM;QACLd,QAAQ,CAAC;UAAEgB,OAAO,EAAEF;QAAE,CAAC,CAAC;MAC1B;IACF,CAAC,SAAS;MACRT,UAAU,CAAC,KAAK,CAAC;IACnB;EACF,CAAC,EAAE,CAACR,KAAK,EAAEG,QAAQ,CAAC,CAAC;EAErB,OAAO;IAAEM,WAAW;IAAEP,KAAK;IAAEG,IAAI;IAAEE;EAAU,CAAC;AAChD","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","OsdkContext2","useOsdkAction","actionDef","observableClient","useContext","error","setError","useState","data","setData","isPending","setPending","applyAction","useCallback","hookArgs","$optimisticUpdate","args","undefined","r","optimisticUpdate","e","actionValidation","unknown"],"sources":["useOsdkAction.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 { ActionDefinition } from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> =\n & Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]:\n ObservableClient.ApplyActionOptions[K];\n };\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q>,\n ) => Promise<unknown>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: unknown;\n\n isPending: boolean;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q,\n): UseOsdkActionResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<unknown>();\n const [isPending, setPending] = React.useState(false);\n\n const applyAction = React.useCallback(async function applyAction(\n hookArgs: ApplyActionParams<Q>,\n ) {\n const { $optimisticUpdate, ...args } = hookArgs;\n try {\n setPending(true);\n setError(undefined);\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n } finally {\n setPending(false);\n }\n }, [observableClient, setError]);\n\n return { applyAction, error, data, isPending };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,qBAAqB,QAAQ,cAAc;AAKpD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,mBAAmB;AAyBhD,OAAO,SAASC,aAAaA,CAC3BC,SAAY,EACY;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGJ,KAAK,CAACK,UAAU,CAACJ,YAAY,CAAC;EAC3D,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAGP,KAAK,CAACQ,QAAQ,CAAkC,CAAC;EAC3E,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,KAAK,CAACQ,QAAQ,CAAU,CAAC;EACjD,MAAM,CAACG,SAAS,EAAEC,UAAU,CAAC,GAAGZ,KAAK,CAACQ,QAAQ,CAAC,KAAK,CAAC;EAErD,MAAMK,WAAW,GAAGb,KAAK,CAACc,WAAW,CAAC,gBACpCC,QAA8B,EAC9B;IACA,MAAM;MAAEC,iBAAiB;MAAE,GAAGC;IAAK,CAAC,GAAGF,QAAQ;IAC/C,IAAI;MACFH,UAAU,CAAC,IAAI,CAAC;MAChBL,QAAQ,CAACW,SAAS,CAAC;MACnB,MAAMC,CAAC,GAAG,MAAMf,gBAAgB,CAACS,WAAW,CAACV,SAAS,EAAEc,IAAI,EAAE;QAC5DG,gBAAgB,EAAEJ;MACpB,CAAC,CAAC;MACFN,OAAO,CAACS,CAAC,CAAC;MACV,OAAOA,CAAC;IACV,CAAC,CAAC,OAAOE,CAAC,EAAE;MACV,IAAIA,CAAC,YAAYtB,qBAAqB,EAAE;QACtCQ,QAAQ,CAAC;UACPe,gBAAgB,EAAED;QACpB,CAAC,CAAC;MACJ,CAAC,MAAM;QACLd,QAAQ,CAAC;UAAEgB,OAAO,EAAEF;QAAE,CAAC,CAAC;MAC1B;IACF,CAAC,SAAS;MACRT,UAAU,CAAC,KAAK,CAAC;IACnB;EACF,CAAC,EAAE,CAACR,gBAAgB,EAAEG,QAAQ,CAAC,CAAC;EAEhC,OAAO;IAAEM,WAAW;IAAEP,KAAK;IAAEG,IAAI;IAAEE;EAAU,CAAC;AAChD","ignoreList":[]}
@@ -34,7 +34,7 @@ import { OsdkContext2 } from "./OsdkContext2.js";
34
34
  */
35
35
  export function useOsdkObject(...args) {
36
36
  const {
37
- store
37
+ observableClient
38
38
  } = React.useContext(OsdkContext2);
39
39
 
40
40
  // TODO: Figure out what the correct default behavior is for the various scenarios
@@ -44,9 +44,9 @@ export function useOsdkObject(...args) {
44
44
  const {
45
45
  subscribe,
46
46
  getSnapShot
47
- } = React.useMemo(() => makeExternalStore(payload => store.observeObject(objectType, primaryKey, {
47
+ } = React.useMemo(() => makeExternalStore(payload => observableClient.observeObject(objectType, primaryKey, {
48
48
  mode
49
- }, payload), `object ${objectType} ${primaryKey}`), [store, objectType, primaryKey, mode]);
49
+ }, payload), `object ${objectType} ${primaryKey}`), [observableClient, objectType, primaryKey, mode]);
50
50
  const payload = React.useSyncExternalStore(subscribe, getSnapShot);
51
51
  return {
52
52
  object: payload?.object,
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","store","useContext","mode","length","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","payload","observeObject","useSyncExternalStore","object","isLoading","status","isOptimistic","forceUpdate"],"sources":["useOsdkObject.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 { ObjectTypeDefinition, Osdk, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObjectPayload } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n obj: Osdk.Instance<Q>,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n ...args: [obj: Osdk.Instance<Q>] | [type: Q, primaryKey: PrimaryKeyType<Q>]\n): UseOsdkObjectResult<Q> {\n const { store } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObjectPayload>((payload) =>\n store.observeObject(\n objectType,\n primaryKey,\n {\n mode,\n },\n payload,\n ), `object ${objectType} ${primaryKey}`),\n [store, objectType, primaryKey, mode],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n forceUpdate: () => {\n throw \"not implemented\";\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;;AAahD;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3B,GAAGC,IAAwE,EACnD;EACxB,MAAM;IAAEC;EAAM,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;;EAEhD;EACA,MAAMK,IAAI,GAAGH,IAAI,CAACI,MAAM,KAAK,CAAC,GAAG,SAAS,GAAGC,SAAS;EACtD,MAAMC,UAAU,GAAGN,IAAI,CAACI,MAAM,KAAK,CAAC,GAAGJ,IAAI,CAAC,CAAC,CAAC,CAACO,WAAW,GAAGP,IAAI,CAAC,CAAC,CAAC,CAACQ,OAAO;EAC5E,MAAMC,UAAU,GAAGT,IAAI,CAACI,MAAM,KAAK,CAAC,GAAGJ,IAAI,CAAC,CAAC,CAAC,CAACU,WAAW,GAAGV,IAAI,CAAC,CAAC,CAAC;EAEpE,MAAM;IAAEW,SAAS;IAAEC;EAAY,CAAC,GAAGhB,KAAK,CAACiB,OAAO,CAC9C,MACEhB,iBAAiB,CAAiBiB,OAAO,IACvCb,KAAK,CAACc,aAAa,CACjBT,UAAU,EACVG,UAAU,EACV;IACEN;EACF,CAAC,EACDW,OACF,CAAC,EAAE,UAAUR,UAAU,IAAIG,UAAU,EAAE,CAAC,EAC5C,CAACR,KAAK,EAAEK,UAAU,EAAEG,UAAU,EAAEN,IAAI,CACtC,CAAC;EAED,MAAMW,OAAO,GAAGlB,KAAK,CAACoB,oBAAoB,CAACL,SAAS,EAAEC,WAAW,CAAC;EAElE,OAAO;IACLK,MAAM,EAAEH,OAAO,EAAEG,MAAsC;IACvDC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS;IACxCC,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,WAAW,EAAEA,CAAA,KAAM;MACjB,MAAM,iBAAiB;IACzB;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","mode","length","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","payload","observeObject","useSyncExternalStore","object","isLoading","status","isOptimistic","forceUpdate"],"sources":["useOsdkObject.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 { ObjectTypeDefinition, Osdk, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObjectPayload } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n obj: Osdk.Instance<Q>,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n ...args: [obj: Osdk.Instance<Q>] | [type: Q, primaryKey: PrimaryKeyType<Q>]\n): UseOsdkObjectResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObjectPayload>(\n (payload) =>\n observableClient.observeObject(\n objectType,\n primaryKey,\n {\n mode,\n },\n payload,\n ),\n `object ${objectType} ${primaryKey}`,\n ),\n [observableClient, objectType, primaryKey, mode],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n forceUpdate: () => {\n throw \"not implemented\";\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;;AAahD;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3B,GAAGC,IAAwE,EACnD;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;;EAE3D;EACA,MAAMK,IAAI,GAAGH,IAAI,CAACI,MAAM,KAAK,CAAC,GAAG,SAAS,GAAGC,SAAS;EACtD,MAAMC,UAAU,GAAGN,IAAI,CAACI,MAAM,KAAK,CAAC,GAAGJ,IAAI,CAAC,CAAC,CAAC,CAACO,WAAW,GAAGP,IAAI,CAAC,CAAC,CAAC,CAACQ,OAAO;EAC5E,MAAMC,UAAU,GAAGT,IAAI,CAACI,MAAM,KAAK,CAAC,GAAGJ,IAAI,CAAC,CAAC,CAAC,CAACU,WAAW,GAAGV,IAAI,CAAC,CAAC,CAAC;EAEpE,MAAM;IAAEW,SAAS;IAAEC;EAAY,CAAC,GAAGhB,KAAK,CAACiB,OAAO,CAC9C,MACEhB,iBAAiB,CACdiB,OAAO,IACNb,gBAAgB,CAACc,aAAa,CAC5BT,UAAU,EACVG,UAAU,EACV;IACEN;EACF,CAAC,EACDW,OACF,CAAC,EACH,UAAUR,UAAU,IAAIG,UAAU,EACpC,CAAC,EACH,CAACR,gBAAgB,EAAEK,UAAU,EAAEG,UAAU,EAAEN,IAAI,CACjD,CAAC;EAED,MAAMW,OAAO,GAAGlB,KAAK,CAACoB,oBAAoB,CAACL,SAAS,EAAEC,WAAW,CAAC;EAElE,OAAO;IACLK,MAAM,EAAEH,OAAO,EAAEG,MAAsC;IACvDC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS;IACxCC,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,WAAW,EAAEA,CAAA,KAAM;MACjB,MAAM,iBAAiB;IACzB;EACF,CAAC;AACH","ignoreList":[]}
@@ -17,40 +17,40 @@
17
17
  import React from "react";
18
18
  import { makeExternalStore } from "./makeExternalStore.js";
19
19
  import { OsdkContext2 } from "./OsdkContext2.js";
20
- export function useOsdkList(objectType, {
20
+ export function useOsdkObjects(objectType, {
21
21
  pageSize,
22
22
  orderBy,
23
23
  dedupeIntervalMs,
24
- where,
24
+ where = {},
25
25
  streamUpdates
26
- }) {
26
+ } = {}) {
27
27
  const {
28
- store
28
+ observableClient
29
29
  } = React.useContext(OsdkContext2);
30
30
 
31
31
  /* We want the canonical where clause so that the use of `React.useMemo`
32
32
  is stable. No real added cost as we canonicalize internal to
33
33
  the ObservableClient anyway.
34
34
  */
35
- const canonWhere = store.canonicalizeWhereClause(where ?? {});
35
+ const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});
36
36
  const {
37
37
  subscribe,
38
38
  getSnapShot
39
- } = React.useMemo(() => makeExternalStore(x => store.observeList({
39
+ } = React.useMemo(() => makeExternalStore(x => observableClient.observeList({
40
40
  objectType,
41
41
  where: canonWhere,
42
42
  dedupeInterval: dedupeIntervalMs ?? 2_000,
43
43
  pageSize,
44
44
  orderBy,
45
45
  streamUpdates
46
- }, x), process.env.NODE_ENV !== "production" ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}` : void 0), [store, objectType, canonWhere, dedupeIntervalMs]);
46
+ }, x), process.env.NODE_ENV !== "production" ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, objectType, canonWhere, dedupeIntervalMs]);
47
47
  const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);
48
+ // TODO: we need to expose the error in the result
48
49
  return {
49
50
  fetchMore: listPayload?.fetchMore,
50
51
  data: listPayload?.resolvedList,
51
52
  isLoading: listPayload?.status === "loading",
52
- error: undefined,
53
53
  isOptimistic: listPayload?.isOptimistic ?? false
54
54
  };
55
55
  }
56
- //# sourceMappingURL=useOsdkList.js.map
56
+ //# sourceMappingURL=useOsdkObjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","objectType","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","observableClient","useContext","canonWhere","canonicalizeWhereClause","subscribe","getSnapShot","useMemo","x","observeList","dedupeInterval","process","env","NODE_ENV","apiName","JSON","stringify","listPayload","useSyncExternalStore","fetchMore","data","resolvedList","isLoading","status","isOptimistic"],"sources":["useOsdkObjects.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 ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/client\";\nimport type { ListPayload } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectsOptions<T extends ObjectTypeDefinition> {\n /**\n * Standard OSDK Where\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n */\n // autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * If provided, the list will be considered this length for the purposes of\n * `invalidationMode` when using the `wait` option. If not provided,\n * the internal expectedLength will be determined by the number of times\n * `fetchMore` has been called.\n */\n // expectedLength?: number | undefined;\n\n streamUpdates?: boolean;\n}\n\nexport interface UseOsdkListResult<T extends ObjectTypeDefinition> {\n fetchMore: (() => Promise<unknown>) | undefined;\n data: Osdk.Instance<T>[] | undefined;\n isLoading: boolean;\n\n // FIXME populate error!\n // error: undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<T extends ObjectTypeDefinition>(\n objectType: T,\n {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n }: UseOsdkObjectsOptions<T> = {},\n): UseOsdkListResult<T> {\n const { observableClient } = 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\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ListPayload>(\n (x) =>\n observableClient.observeList({\n objectType,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates,\n }, x),\n process.env.NODE_ENV !== \"production\"\n ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [observableClient, objectType, canonWhere, dedupeIntervalMs],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n // TODO: we need to expose the error in the result\n return {\n fetchMore: listPayload?.fetchMore,\n data: listPayload?.resolvedList as Osdk.Instance<T>[],\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAyFhD,OAAO,SAASC,cAAcA,CAC5BC,UAAa,EACb;EACEC,QAAQ;EACRC,OAAO;EACPC,gBAAgB;EAChBC,KAAK,GAAG,CAAC,CAAC;EACVC;AACwB,CAAC,GAAG,CAAC,CAAC,EACV;EACtB,MAAM;IAAEC;EAAiB,CAAC,GAAGV,KAAK,CAACW,UAAU,CAACT,YAAY,CAAC;;EAE3D;AACF;AACA;AACA;EACE,MAAMU,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAACL,KAAK,IAAI,CAAC,CAAC,CAAC;EAExE,MAAM;IAAEM,SAAS;IAAEC;EAAY,CAAC,GAAGf,KAAK,CAACgB,OAAO,CAC9C,MACEf,iBAAiB,CACdgB,CAAC,IACAP,gBAAgB,CAACQ,WAAW,CAAC;IAC3Bd,UAAU;IACVI,KAAK,EAAEI,UAAU;IACjBO,cAAc,EAAEZ,gBAAgB,IAAI,KAAK;IACzCF,QAAQ;IACRC,OAAO;IACPG;EACF,CAAC,EAAEQ,CAAC,CAAC,EACPG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQlB,UAAU,CAACmB,OAAO,IAAIC,IAAI,CAACC,SAAS,CAACb,UAAU,CAAC,EAAE,GAC1D,KAAK,CACX,CAAC,EACH,CAACF,gBAAgB,EAAEN,UAAU,EAAEQ,UAAU,EAAEL,gBAAgB,CAC7D,CAAC;EAED,MAAMmB,WAAW,GAAG1B,KAAK,CAAC2B,oBAAoB,CAACb,SAAS,EAAEC,WAAW,CAAC;EACtE;EACA,OAAO;IACLa,SAAS,EAAEF,WAAW,EAAEE,SAAS;IACjCC,IAAI,EAAEH,WAAW,EAAEI,YAAkC;IACrDC,SAAS,EAAEL,WAAW,EAAEM,MAAM,KAAK,SAAS;IAC5CC,YAAY,EAAEP,WAAW,EAAEO,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
@@ -16,7 +16,7 @@
16
16
 
17
17
  export { OsdkProvider2 } from "../new/OsdkProvider2.js";
18
18
  export { useOsdkAction } from "../new/useOsdkAction.js";
19
- export { useOsdkList } from "../new/useOsdkList.js";
20
19
  export { useOsdkObject } from "../new/useOsdkObject.js";
20
+ export { useOsdkObjects } from "../new/useOsdkObjects.js";
21
21
  export { useOsdkClient } from "../useOsdkClient.js";
22
22
  //# sourceMappingURL=experimental.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"experimental.js","names":["OsdkProvider2","useOsdkAction","useOsdkList","useOsdkObject","useOsdkClient"],"sources":["experimental.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\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport { useOsdkList } from \"../new/useOsdkList.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,qBAAqB","ignoreList":[]}
1
+ {"version":3,"file":"experimental.js","names":["OsdkProvider2","useOsdkAction","useOsdkObject","useOsdkObjects","useOsdkClient"],"sources":["experimental.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\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk2N32USW5_cjs = require('../chunk-2N32USW5.cjs');
4
+ var unstableDoNotUse = require('@osdk/client/unstable-do-not-use');
4
5
  var React3 = require('react');
5
6
  var client = require('@osdk/client');
6
7
 
@@ -16,25 +17,26 @@ var fakeClient = Object.assign(fakeClientFn, {
16
17
  });
17
18
  var OsdkContext2 = /* @__PURE__ */ React3__default.default.createContext({
18
19
  client: fakeClient,
19
- store: undefined
20
+ observableClient: undefined
20
21
  });
21
22
 
22
23
  // src/new/OsdkProvider2.tsx
23
24
  function OsdkProvider2({
24
25
  children,
25
26
  client,
26
- store
27
+ observableClient
27
28
  }) {
29
+ observableClient = React3.useMemo(() => observableClient ?? unstableDoNotUse.createObservableClient(client), [client, observableClient]);
28
30
  return /* @__PURE__ */ React3__default.default.createElement(OsdkContext2.Provider, {
29
31
  value: {
30
32
  client,
31
- store
33
+ observableClient
32
34
  }
33
35
  }, children);
34
36
  }
35
37
  function useOsdkAction(actionDef) {
36
38
  const {
37
- store
39
+ observableClient
38
40
  } = React3__default.default.useContext(OsdkContext2);
39
41
  const [error, setError] = React3__default.default.useState();
40
42
  const [data, setData] = React3__default.default.useState();
@@ -47,7 +49,7 @@ function useOsdkAction(actionDef) {
47
49
  try {
48
50
  setPending(true);
49
51
  setError(void 0);
50
- const r = await store.applyAction(actionDef, args, {
52
+ const r = await observableClient.applyAction(actionDef, args, {
51
53
  optimisticUpdate: $optimisticUpdate
52
54
  });
53
55
  setData(r);
@@ -65,7 +67,7 @@ function useOsdkAction(actionDef) {
65
67
  } finally {
66
68
  setPending(false);
67
69
  }
68
- }, [store, setError]);
70
+ }, [observableClient, setError]);
69
71
  return {
70
72
  applyAction,
71
73
  error,
@@ -95,61 +97,60 @@ function makeExternalStore(createObservation, name) {
95
97
  };
96
98
  }
97
99
 
98
- // src/new/useOsdkList.ts
99
- function useOsdkList(objectType, {
100
+ // src/new/useOsdkObject.ts
101
+ function useOsdkObject(...args) {
102
+ const {
103
+ observableClient
104
+ } = React3__default.default.useContext(OsdkContext2);
105
+ const mode = args.length === 1 ? "offline" : undefined;
106
+ const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;
107
+ const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];
108
+ const {
109
+ subscribe,
110
+ getSnapShot
111
+ } = React3__default.default.useMemo(() => makeExternalStore((payload2) => observableClient.observeObject(objectType, primaryKey, {
112
+ mode
113
+ }, payload2)), [observableClient, objectType, primaryKey, mode]);
114
+ const payload = React3__default.default.useSyncExternalStore(subscribe, getSnapShot);
115
+ return {
116
+ object: payload?.object,
117
+ isLoading: payload?.status === "loading",
118
+ isOptimistic: payload?.isOptimistic ?? false,
119
+ forceUpdate: () => {
120
+ throw "not implemented";
121
+ }
122
+ };
123
+ }
124
+ function useOsdkObjects(objectType, {
100
125
  pageSize,
101
126
  orderBy,
102
127
  dedupeIntervalMs,
103
- where,
128
+ where = {},
104
129
  streamUpdates
105
- }) {
130
+ } = {}) {
106
131
  const {
107
- store
132
+ observableClient
108
133
  } = React3__default.default.useContext(OsdkContext2);
109
- const canonWhere = store.canonicalizeWhereClause(where ?? {});
134
+ const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});
110
135
  const {
111
136
  subscribe,
112
137
  getSnapShot
113
- } = React3__default.default.useMemo(() => makeExternalStore((x) => store.observeList({
138
+ } = React3__default.default.useMemo(() => makeExternalStore((x) => observableClient.observeList({
114
139
  objectType,
115
140
  where: canonWhere,
116
141
  dedupeInterval: dedupeIntervalMs ?? 2e3,
117
142
  pageSize,
118
143
  orderBy,
119
144
  streamUpdates
120
- }, x), process.env.NODE_ENV !== "production" ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}` : undefined), [store, objectType, canonWhere, dedupeIntervalMs]);
145
+ }, x), process.env.NODE_ENV !== "production" ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}` : undefined), [observableClient, objectType, canonWhere, dedupeIntervalMs]);
121
146
  const listPayload = React3__default.default.useSyncExternalStore(subscribe, getSnapShot);
122
147
  return {
123
148
  fetchMore: listPayload?.fetchMore,
124
149
  data: listPayload?.resolvedList,
125
150
  isLoading: listPayload?.status === "loading",
126
- error: undefined,
127
151
  isOptimistic: listPayload?.isOptimistic ?? false
128
152
  };
129
153
  }
130
- function useOsdkObject(...args) {
131
- const {
132
- store
133
- } = React3__default.default.useContext(OsdkContext2);
134
- const mode = args.length === 1 ? "offline" : undefined;
135
- const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;
136
- const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];
137
- const {
138
- subscribe,
139
- getSnapShot
140
- } = React3__default.default.useMemo(() => makeExternalStore((payload2) => store.observeObject(objectType, primaryKey, {
141
- mode
142
- }, payload2)), [store, objectType, primaryKey, mode]);
143
- const payload = React3__default.default.useSyncExternalStore(subscribe, getSnapShot);
144
- return {
145
- object: payload?.object,
146
- isLoading: payload?.status === "loading",
147
- isOptimistic: payload?.isOptimistic ?? false,
148
- forceUpdate: () => {
149
- throw "not implemented";
150
- }
151
- };
152
- }
153
154
 
154
155
  Object.defineProperty(exports, "useOsdkClient", {
155
156
  enumerable: true,
@@ -157,7 +158,7 @@ Object.defineProperty(exports, "useOsdkClient", {
157
158
  });
158
159
  exports.OsdkProvider2 = OsdkProvider2;
159
160
  exports.useOsdkAction = useOsdkAction;
160
- exports.useOsdkList = useOsdkList;
161
161
  exports.useOsdkObject = useOsdkObject;
162
+ exports.useOsdkObjects = useOsdkObjects;
162
163
  //# sourceMappingURL=experimental.cjs.map
163
164
  //# sourceMappingURL=experimental.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/new/OsdkContext2.ts","../../../src/new/OsdkProvider2.tsx","../../../src/new/useOsdkAction.ts","../../../src/new/makeExternalStore.ts","../../../src/new/useOsdkList.ts","../../../src/new/useOsdkObject.ts"],"names":["React","applyAction","ActionValidationError","payload"],"mappings":"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","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 store: 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 React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function OsdkProvider2({\n children,\n client,\n store\n}) {\n return /*#__PURE__*/React.createElement(OsdkContext2.Provider, {\n value: {\n client,\n store\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\nimport { ActionValidationError } from \"@osdk/client\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function useOsdkAction(actionDef) {\n const {\n store\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 applyAction = React.useCallback(async function applyAction(hookArgs) {\n const {\n $optimisticUpdate,\n ...args\n } = hookArgs;\n try {\n setPending(true);\n setError(undefined);\n const r = await store.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate\n });\n setData(r);\n return r;\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 }, [store, setError]);\n return {\n applyAction,\n error,\n data,\n isPending\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\nexport function makeExternalStore(createObservation, name) {\n let lastResult;\n function getSnapShot() {\n return lastResult;\n }\n function subscribe(notifyUpdate) {\n const obs = createObservation(payload => {\n lastResult = payload;\n notifyUpdate();\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\";\nexport function useOsdkList(objectType, {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where,\n streamUpdates\n}) {\n const {\n store\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 = store.canonicalizeWhereClause(where ?? {});\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(x => store.observeList({\n objectType,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates\n }, x), process.env.NODE_ENV !== \"production\" ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}` : void 0), [store, objectType, canonWhere, dedupeIntervalMs]);\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n fetchMore: listPayload?.fetchMore,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n error: undefined,\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\";\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 */\n\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\n\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject(...args) {\n const {\n store\n } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(payload => store.observeObject(objectType, primaryKey, {\n mode\n }, payload), `object ${objectType} ${primaryKey}`), [store, objectType, primaryKey, mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n object: payload?.object,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n forceUpdate: () => {\n throw \"not implemented\";\n }\n };\n}"]}
1
+ {"version":3,"sources":["../../../src/new/OsdkContext2.ts","../../../src/new/OsdkProvider2.tsx","../../../src/new/useOsdkAction.ts","../../../src/new/makeExternalStore.ts","../../../src/new/useOsdkObject.ts","../../../src/new/useOsdkObjects.ts"],"names":["useMemo","createObservableClient","React","applyAction","ActionValidationError","payload"],"mappings":"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","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 { 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 }, 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\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 applyAction = React.useCallback(async function applyAction(hookArgs) {\n const {\n $optimisticUpdate,\n ...args\n } = hookArgs;\n try {\n setPending(true);\n setError(undefined);\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate\n });\n setData(r);\n return r;\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, setError]);\n return {\n applyAction,\n error,\n data,\n isPending\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\nexport function makeExternalStore(createObservation, name) {\n let lastResult;\n function getSnapShot() {\n return lastResult;\n }\n function subscribe(notifyUpdate) {\n const obs = createObservation(payload => {\n lastResult = payload;\n notifyUpdate();\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\";\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n */\n\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\n\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject(...args) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(payload => observableClient.observeObject(objectType, primaryKey, {\n mode\n }, payload), `object ${objectType} ${primaryKey}`), [observableClient, objectType, primaryKey, mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n object: payload?.object,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n forceUpdate: () => {\n throw \"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(objectType, {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates\n} = {}) {\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 {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(x => observableClient.observeList({\n objectType,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates\n }, x), process.env.NODE_ENV !== \"production\" ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, objectType, canonWhere, dedupeIntervalMs]);\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n // TODO: we need to expose the error in the result\n return {\n fetchMore: listPayload?.fetchMore,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false\n };\n}"]}
@@ -1,15 +1,15 @@
1
- import { Client, ActionDefinition, ActionValidationError, ObjectTypeDefinition, WhereClause, PropertyKeys, Osdk } from '@osdk/client';
1
+ import { Client, ActionDefinition, ActionValidationError, ObjectTypeDefinition as ObjectTypeDefinition$1, WhereClause, PropertyKeys, Osdk as Osdk$1 } from '@osdk/client';
2
2
  import { ObservableClient, ActionSignatureFromDef } from '@osdk/client/unstable-do-not-use';
3
3
  import React from 'react';
4
- import { ObjectTypeDefinition as ObjectTypeDefinition$1, Osdk as Osdk$1, PrimaryKeyType } from '@osdk/api';
4
+ import { ObjectTypeDefinition, Osdk, PrimaryKeyType } from '@osdk/api';
5
5
  export { u as useOsdkClient } from '../useOsdkClient-B4iwHO1H.cjs';
6
6
 
7
7
  interface OsdkProviderOptions {
8
8
  children: React.ReactNode;
9
9
  client: Client;
10
- store: ObservableClient;
10
+ observableClient?: ObservableClient;
11
11
  }
12
- declare function OsdkProvider2({ children, client, store, }: OsdkProviderOptions): React.JSX.Element;
12
+ declare function OsdkProvider2({ children, client, observableClient, }: OsdkProviderOptions): React.JSX.Element;
13
13
 
14
14
  type ApplyActionParams<Q extends ActionDefinition<any>> = Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0] & {
15
15
  [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]: ObservableClient.ApplyActionOptions[K];
@@ -25,7 +25,28 @@ interface UseOsdkActionResult<Q extends ActionDefinition<any>> {
25
25
  }
26
26
  declare function useOsdkAction<Q extends ActionDefinition<any>>(actionDef: Q): UseOsdkActionResult<Q>;
27
27
 
28
- interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
28
+ interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {
29
+ object: Osdk.Instance<Q> | undefined;
30
+ isLoading: boolean;
31
+ /**
32
+ * Refers to whether the object is optimistic or not.
33
+ */
34
+ isOptimistic: boolean;
35
+ forceUpdate: () => void;
36
+ }
37
+ /**
38
+ * @param obj an existing `Osdk.Instance` object to get metadata for.
39
+ */
40
+ declare function useOsdkObject<Q extends ObjectTypeDefinition>(obj: Osdk.Instance<Q>): UseOsdkObjectResult<Q>;
41
+ /**
42
+ * Loads an object by type and primary key.
43
+ *
44
+ * @param type
45
+ * @param primaryKey
46
+ */
47
+ declare function useOsdkObject<Q extends ObjectTypeDefinition>(type: Q, primaryKey: PrimaryKeyType<Q>): UseOsdkObjectResult<Q>;
48
+
49
+ interface UseOsdkObjectsOptions<T extends ObjectTypeDefinition$1> {
29
50
  /**
30
51
  * Standard OSDK Where
31
52
  */
@@ -65,7 +86,7 @@ interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
65
86
  /**
66
87
  * The number of milliseconds to wait after the last observed list change.
67
88
  *
68
- * Two uses of `useOsdkList` with the where clause will only trigger one
89
+ * Two uses of `useOsdkObjects` with the where clause will only trigger one
69
90
  * network request if the second is within `dedupeIntervalMs`.
70
91
  */
71
92
  dedupeIntervalMs?: number;
@@ -77,11 +98,10 @@ interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
77
98
  */
78
99
  streamUpdates?: boolean;
79
100
  }
80
- interface UseOsdkListResult<T extends ObjectTypeDefinition> {
101
+ interface UseOsdkListResult<T extends ObjectTypeDefinition$1> {
81
102
  fetchMore: (() => Promise<unknown>) | undefined;
82
- data: Osdk.Instance<T>[];
103
+ data: Osdk$1.Instance<T>[] | undefined;
83
104
  isLoading: boolean;
84
- error: undefined;
85
105
  /**
86
106
  * Refers to whether the ordered list of objects (only considering the $primaryKey)
87
107
  * is optimistic or not.
@@ -91,27 +111,6 @@ interface UseOsdkListResult<T extends ObjectTypeDefinition> {
91
111
  */
92
112
  isOptimistic: boolean;
93
113
  }
94
- declare function useOsdkList<T extends ObjectTypeDefinition>(objectType: T, { pageSize, orderBy, dedupeIntervalMs, where, streamUpdates }: UseOsdkListOptions<T>): UseOsdkListResult<T>;
95
-
96
- interface UseOsdkObjectResult<Q extends ObjectTypeDefinition$1> {
97
- object: Osdk$1.Instance<Q> | undefined;
98
- isLoading: boolean;
99
- /**
100
- * Refers to whether the object is optimistic or not.
101
- */
102
- isOptimistic: boolean;
103
- forceUpdate: () => void;
104
- }
105
- /**
106
- * @param obj an existing `Osdk.Instance` object to get metadata for.
107
- */
108
- declare function useOsdkObject<Q extends ObjectTypeDefinition$1>(obj: Osdk$1.Instance<Q>): UseOsdkObjectResult<Q>;
109
- /**
110
- * Loads an object by type and primary key.
111
- *
112
- * @param type
113
- * @param primaryKey
114
- */
115
- declare function useOsdkObject<Q extends ObjectTypeDefinition$1>(type: Q, primaryKey: PrimaryKeyType<Q>): UseOsdkObjectResult<Q>;
114
+ declare function useOsdkObjects<T extends ObjectTypeDefinition$1>(objectType: T, { pageSize, orderBy, dedupeIntervalMs, where, streamUpdates, }?: UseOsdkObjectsOptions<T>): UseOsdkListResult<T>;
116
115
 
117
- export { OsdkProvider2, useOsdkAction, useOsdkList, useOsdkObject };
116
+ export { OsdkProvider2, useOsdkAction, useOsdkObject, useOsdkObjects };
@@ -23,6 +23,6 @@ const fakeClient = Object.assign(fakeClientFn, {
23
23
  });
24
24
  export const OsdkContext2 = /*#__PURE__*/React.createContext({
25
25
  client: fakeClient,
26
- store: undefined
26
+ observableClient: undefined
27
27
  });
28
28
  //# sourceMappingURL=OsdkContext2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OsdkContext2.js","names":["React","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","OsdkContext2","createContext","client","store","undefined"],"sources":["OsdkContext2.ts"],"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 type { Client } from \"@osdk/client\";\nimport type { ObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\n\nfunction fakeClientFn(..._args: any[]) {\n throw new Error(\n \"This is not a real client. Did you forget to <OsdkContext.Provider>?\",\n );\n}\n\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn,\n} as Client);\n\ninterface OsdkContextContents {\n client: Client;\n // keeping the old name for now intentionally\n // in case i need both for a while\n // in the future we can just make\n // this `client: ObservableClient`\n store: ObservableClient;\n}\n\nexport const OsdkContext2: React.Context<OsdkContextContents> = React\n .createContext<OsdkContextContents>({\n client: fakeClient,\n store: undefined!,\n });\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAYA,CAAC,GAAGC,KAAY,EAAE;EACrC,MAAM,IAAIC,KAAK,CACb,sEACF,CAAC;AACH;AAEA,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC7CM,aAAa,EAAEN;AACjB,CAAW,CAAC;AAWZ,OAAO,MAAMO,YAAgD,gBAAGR,KAAK,CAClES,aAAa,CAAsB;EAClCC,MAAM,EAAEN,UAAU;EAClBO,KAAK,EAAEC;AACT,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"OsdkContext2.js","names":["React","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","OsdkContext2","createContext","client","observableClient","undefined"],"sources":["OsdkContext2.ts"],"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 type { Client } from \"@osdk/client\";\nimport type { ObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\n\nfunction fakeClientFn(..._args: any[]) {\n throw new Error(\n \"This is not a real client. Did you forget to <OsdkContext.Provider>?\",\n );\n}\n\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn,\n} as Client);\n\ninterface OsdkContextContents {\n client: Client;\n // keeping the old name for now intentionally\n // in case i need both for a while\n // in the future we can just make\n // this `client: ObservableClient`\n observableClient: ObservableClient;\n}\n\nexport const OsdkContext2: React.Context<OsdkContextContents> = React\n .createContext<OsdkContextContents>({\n client: fakeClient,\n observableClient: undefined!,\n });\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAYA,CAAC,GAAGC,KAAY,EAAE;EACrC,MAAM,IAAIC,KAAK,CACb,sEACF,CAAC;AACH;AAEA,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC7CM,aAAa,EAAEN;AACjB,CAAW,CAAC;AAWZ,OAAO,MAAMO,YAAgD,gBAAGR,KAAK,CAClES,aAAa,CAAsB;EAClCC,MAAM,EAAEN,UAAU;EAClBO,gBAAgB,EAAEC;AACpB,CAAC,CAAC","ignoreList":[]}
@@ -14,17 +14,19 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import React from "react";
17
+ import { createObservableClient } from "@osdk/client/unstable-do-not-use";
18
+ import React, { useMemo } from "react";
18
19
  import { OsdkContext2 } from "./OsdkContext2.js";
19
20
  export function OsdkProvider2({
20
21
  children,
21
22
  client,
22
- store
23
+ observableClient
23
24
  }) {
25
+ observableClient = useMemo(() => observableClient ?? createObservableClient(client), [client, observableClient]);
24
26
  return /*#__PURE__*/React.createElement(OsdkContext2.Provider, {
25
27
  value: {
26
28
  client,
27
- store
29
+ observableClient
28
30
  }
29
31
  }, children);
30
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OsdkProvider2.js","names":["React","OsdkContext2","OsdkProvider2","children","client","store","createElement","Provider","value"],"sources":["OsdkProvider2.tsx"],"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 type { Client } from \"@osdk/client\";\nimport type { ObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ninterface OsdkProviderOptions {\n children: React.ReactNode;\n client: Client;\n store: ObservableClient;\n}\n\nexport function OsdkProvider2({\n children,\n client,\n store,\n}: OsdkProviderOptions): React.JSX.Element {\n return (\n <OsdkContext2.Provider value={{ client, store }}>\n {children}\n </OsdkContext2.Provider>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,mBAAmB;AAQhD,OAAO,SAASC,aAAaA,CAAC;EAC5BC,QAAQ;EACRC,MAAM;EACNC;AACmB,CAAC,EAAqB;EACzC,oBACEL,KAAA,CAAAM,aAAA,CAACL,YAAY,CAACM,QAAQ;IAACC,KAAK,EAAE;MAAEJ,MAAM;MAAEC;IAAM;EAAE,GAC7CF,QACoB,CAAC;AAE5B","ignoreList":[]}
1
+ {"version":3,"file":"OsdkProvider2.js","names":["createObservableClient","React","useMemo","OsdkContext2","OsdkProvider2","children","client","observableClient","createElement","Provider","value"],"sources":["OsdkProvider2.tsx"],"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 type { Client } from \"@osdk/client\";\nimport {\n createObservableClient,\n type ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React, { useMemo } from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ninterface OsdkProviderOptions {\n children: React.ReactNode;\n client: Client;\n observableClient?: ObservableClient;\n}\n\nexport function OsdkProvider2({\n children,\n client,\n observableClient,\n}: OsdkProviderOptions): React.JSX.Element {\n observableClient = useMemo(\n () => observableClient ?? createObservableClient(client),\n [client, observableClient],\n );\n return (\n <OsdkContext2.Provider value={{ client, observableClient }}>\n {children}\n </OsdkContext2.Provider>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SACEA,sBAAsB,QAEjB,kCAAkC;AACzC,OAAOC,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,YAAY,QAAQ,mBAAmB;AAQhD,OAAO,SAASC,aAAaA,CAAC;EAC5BC,QAAQ;EACRC,MAAM;EACNC;AACmB,CAAC,EAAqB;EACzCA,gBAAgB,GAAGL,OAAO,CACxB,MAAMK,gBAAgB,IAAIP,sBAAsB,CAACM,MAAM,CAAC,EACxD,CAACA,MAAM,EAAEC,gBAAgB,CAC3B,CAAC;EACD,oBACEN,KAAA,CAAAO,aAAA,CAACL,YAAY,CAACM,QAAQ;IAACC,KAAK,EAAE;MAAEJ,MAAM;MAAEC;IAAiB;EAAE,GACxDF,QACoB,CAAC;AAE5B","ignoreList":[]}
@@ -19,7 +19,7 @@ import React from "react";
19
19
  import { OsdkContext2 } from "./OsdkContext2.js";
20
20
  export function useOsdkAction(actionDef) {
21
21
  const {
22
- store
22
+ observableClient
23
23
  } = React.useContext(OsdkContext2);
24
24
  const [error, setError] = React.useState();
25
25
  const [data, setData] = React.useState();
@@ -32,7 +32,7 @@ export function useOsdkAction(actionDef) {
32
32
  try {
33
33
  setPending(true);
34
34
  setError(undefined);
35
- const r = await store.applyAction(actionDef, args, {
35
+ const r = await observableClient.applyAction(actionDef, args, {
36
36
  optimisticUpdate: $optimisticUpdate
37
37
  });
38
38
  setData(r);
@@ -50,7 +50,7 @@ export function useOsdkAction(actionDef) {
50
50
  } finally {
51
51
  setPending(false);
52
52
  }
53
- }, [store, setError]);
53
+ }, [observableClient, setError]);
54
54
  return {
55
55
  applyAction,
56
56
  error,
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","OsdkContext2","useOsdkAction","actionDef","store","useContext","error","setError","useState","data","setData","isPending","setPending","applyAction","useCallback","hookArgs","$optimisticUpdate","args","undefined","r","optimisticUpdate","e","actionValidation","unknown"],"sources":["useOsdkAction.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 { ActionDefinition } from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> =\n & Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]:\n ObservableClient.ApplyActionOptions[K];\n };\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q>,\n ) => Promise<unknown>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: unknown;\n\n isPending: boolean;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q,\n): UseOsdkActionResult<Q> {\n const { store } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<unknown>();\n const [isPending, setPending] = React.useState(false);\n\n const applyAction = React.useCallback(async function applyAction(\n hookArgs: ApplyActionParams<Q>,\n ) {\n const { $optimisticUpdate, ...args } = hookArgs;\n try {\n setPending(true);\n setError(undefined);\n const r = await store.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n } finally {\n setPending(false);\n }\n }, [store, setError]);\n\n return { applyAction, error, data, isPending };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,qBAAqB,QAAQ,cAAc;AAKpD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,mBAAmB;AAyBhD,OAAO,SAASC,aAAaA,CAC3BC,SAAY,EACY;EACxB,MAAM;IAAEC;EAAM,CAAC,GAAGJ,KAAK,CAACK,UAAU,CAACJ,YAAY,CAAC;EAChD,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAGP,KAAK,CAACQ,QAAQ,CAAkC,CAAC;EAC3E,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,KAAK,CAACQ,QAAQ,CAAU,CAAC;EACjD,MAAM,CAACG,SAAS,EAAEC,UAAU,CAAC,GAAGZ,KAAK,CAACQ,QAAQ,CAAC,KAAK,CAAC;EAErD,MAAMK,WAAW,GAAGb,KAAK,CAACc,WAAW,CAAC,gBACpCC,QAA8B,EAC9B;IACA,MAAM;MAAEC,iBAAiB;MAAE,GAAGC;IAAK,CAAC,GAAGF,QAAQ;IAC/C,IAAI;MACFH,UAAU,CAAC,IAAI,CAAC;MAChBL,QAAQ,CAACW,SAAS,CAAC;MACnB,MAAMC,CAAC,GAAG,MAAMf,KAAK,CAACS,WAAW,CAACV,SAAS,EAAEc,IAAI,EAAE;QACjDG,gBAAgB,EAAEJ;MACpB,CAAC,CAAC;MACFN,OAAO,CAACS,CAAC,CAAC;MACV,OAAOA,CAAC;IACV,CAAC,CAAC,OAAOE,CAAC,EAAE;MACV,IAAIA,CAAC,YAAYtB,qBAAqB,EAAE;QACtCQ,QAAQ,CAAC;UACPe,gBAAgB,EAAED;QACpB,CAAC,CAAC;MACJ,CAAC,MAAM;QACLd,QAAQ,CAAC;UAAEgB,OAAO,EAAEF;QAAE,CAAC,CAAC;MAC1B;IACF,CAAC,SAAS;MACRT,UAAU,CAAC,KAAK,CAAC;IACnB;EACF,CAAC,EAAE,CAACR,KAAK,EAAEG,QAAQ,CAAC,CAAC;EAErB,OAAO;IAAEM,WAAW;IAAEP,KAAK;IAAEG,IAAI;IAAEE;EAAU,CAAC;AAChD","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","OsdkContext2","useOsdkAction","actionDef","observableClient","useContext","error","setError","useState","data","setData","isPending","setPending","applyAction","useCallback","hookArgs","$optimisticUpdate","args","undefined","r","optimisticUpdate","e","actionValidation","unknown"],"sources":["useOsdkAction.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 { ActionDefinition } from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> =\n & Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]:\n ObservableClient.ApplyActionOptions[K];\n };\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q>,\n ) => Promise<unknown>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: unknown;\n\n isPending: boolean;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q,\n): UseOsdkActionResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<unknown>();\n const [isPending, setPending] = React.useState(false);\n\n const applyAction = React.useCallback(async function applyAction(\n hookArgs: ApplyActionParams<Q>,\n ) {\n const { $optimisticUpdate, ...args } = hookArgs;\n try {\n setPending(true);\n setError(undefined);\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n } finally {\n setPending(false);\n }\n }, [observableClient, setError]);\n\n return { applyAction, error, data, isPending };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,qBAAqB,QAAQ,cAAc;AAKpD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,mBAAmB;AAyBhD,OAAO,SAASC,aAAaA,CAC3BC,SAAY,EACY;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGJ,KAAK,CAACK,UAAU,CAACJ,YAAY,CAAC;EAC3D,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAGP,KAAK,CAACQ,QAAQ,CAAkC,CAAC;EAC3E,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,KAAK,CAACQ,QAAQ,CAAU,CAAC;EACjD,MAAM,CAACG,SAAS,EAAEC,UAAU,CAAC,GAAGZ,KAAK,CAACQ,QAAQ,CAAC,KAAK,CAAC;EAErD,MAAMK,WAAW,GAAGb,KAAK,CAACc,WAAW,CAAC,gBACpCC,QAA8B,EAC9B;IACA,MAAM;MAAEC,iBAAiB;MAAE,GAAGC;IAAK,CAAC,GAAGF,QAAQ;IAC/C,IAAI;MACFH,UAAU,CAAC,IAAI,CAAC;MAChBL,QAAQ,CAACW,SAAS,CAAC;MACnB,MAAMC,CAAC,GAAG,MAAMf,gBAAgB,CAACS,WAAW,CAACV,SAAS,EAAEc,IAAI,EAAE;QAC5DG,gBAAgB,EAAEJ;MACpB,CAAC,CAAC;MACFN,OAAO,CAACS,CAAC,CAAC;MACV,OAAOA,CAAC;IACV,CAAC,CAAC,OAAOE,CAAC,EAAE;MACV,IAAIA,CAAC,YAAYtB,qBAAqB,EAAE;QACtCQ,QAAQ,CAAC;UACPe,gBAAgB,EAAED;QACpB,CAAC,CAAC;MACJ,CAAC,MAAM;QACLd,QAAQ,CAAC;UAAEgB,OAAO,EAAEF;QAAE,CAAC,CAAC;MAC1B;IACF,CAAC,SAAS;MACRT,UAAU,CAAC,KAAK,CAAC;IACnB;EACF,CAAC,EAAE,CAACR,gBAAgB,EAAEG,QAAQ,CAAC,CAAC;EAEhC,OAAO;IAAEM,WAAW;IAAEP,KAAK;IAAEG,IAAI;IAAEE;EAAU,CAAC;AAChD","ignoreList":[]}
@@ -34,7 +34,7 @@ import { OsdkContext2 } from "./OsdkContext2.js";
34
34
  */
35
35
  export function useOsdkObject(...args) {
36
36
  const {
37
- store
37
+ observableClient
38
38
  } = React.useContext(OsdkContext2);
39
39
 
40
40
  // TODO: Figure out what the correct default behavior is for the various scenarios
@@ -44,9 +44,9 @@ export function useOsdkObject(...args) {
44
44
  const {
45
45
  subscribe,
46
46
  getSnapShot
47
- } = React.useMemo(() => makeExternalStore(payload => store.observeObject(objectType, primaryKey, {
47
+ } = React.useMemo(() => makeExternalStore(payload => observableClient.observeObject(objectType, primaryKey, {
48
48
  mode
49
- }, payload), `object ${objectType} ${primaryKey}`), [store, objectType, primaryKey, mode]);
49
+ }, payload), `object ${objectType} ${primaryKey}`), [observableClient, objectType, primaryKey, mode]);
50
50
  const payload = React.useSyncExternalStore(subscribe, getSnapShot);
51
51
  return {
52
52
  object: payload?.object,
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","store","useContext","mode","length","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","payload","observeObject","useSyncExternalStore","object","isLoading","status","isOptimistic","forceUpdate"],"sources":["useOsdkObject.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 { ObjectTypeDefinition, Osdk, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObjectPayload } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n obj: Osdk.Instance<Q>,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n ...args: [obj: Osdk.Instance<Q>] | [type: Q, primaryKey: PrimaryKeyType<Q>]\n): UseOsdkObjectResult<Q> {\n const { store } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObjectPayload>((payload) =>\n store.observeObject(\n objectType,\n primaryKey,\n {\n mode,\n },\n payload,\n ), `object ${objectType} ${primaryKey}`),\n [store, objectType, primaryKey, mode],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n forceUpdate: () => {\n throw \"not implemented\";\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;;AAahD;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3B,GAAGC,IAAwE,EACnD;EACxB,MAAM;IAAEC;EAAM,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;;EAEhD;EACA,MAAMK,IAAI,GAAGH,IAAI,CAACI,MAAM,KAAK,CAAC,GAAG,SAAS,GAAGC,SAAS;EACtD,MAAMC,UAAU,GAAGN,IAAI,CAACI,MAAM,KAAK,CAAC,GAAGJ,IAAI,CAAC,CAAC,CAAC,CAACO,WAAW,GAAGP,IAAI,CAAC,CAAC,CAAC,CAACQ,OAAO;EAC5E,MAAMC,UAAU,GAAGT,IAAI,CAACI,MAAM,KAAK,CAAC,GAAGJ,IAAI,CAAC,CAAC,CAAC,CAACU,WAAW,GAAGV,IAAI,CAAC,CAAC,CAAC;EAEpE,MAAM;IAAEW,SAAS;IAAEC;EAAY,CAAC,GAAGhB,KAAK,CAACiB,OAAO,CAC9C,MACEhB,iBAAiB,CAAiBiB,OAAO,IACvCb,KAAK,CAACc,aAAa,CACjBT,UAAU,EACVG,UAAU,EACV;IACEN;EACF,CAAC,EACDW,OACF,CAAC,EAAE,UAAUR,UAAU,IAAIG,UAAU,EAAE,CAAC,EAC5C,CAACR,KAAK,EAAEK,UAAU,EAAEG,UAAU,EAAEN,IAAI,CACtC,CAAC;EAED,MAAMW,OAAO,GAAGlB,KAAK,CAACoB,oBAAoB,CAACL,SAAS,EAAEC,WAAW,CAAC;EAElE,OAAO;IACLK,MAAM,EAAEH,OAAO,EAAEG,MAAsC;IACvDC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS;IACxCC,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,WAAW,EAAEA,CAAA,KAAM;MACjB,MAAM,iBAAiB;IACzB;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","mode","length","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","payload","observeObject","useSyncExternalStore","object","isLoading","status","isOptimistic","forceUpdate"],"sources":["useOsdkObject.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 { ObjectTypeDefinition, Osdk, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObjectPayload } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n obj: Osdk.Instance<Q>,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n ...args: [obj: Osdk.Instance<Q>] | [type: Q, primaryKey: PrimaryKeyType<Q>]\n): UseOsdkObjectResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObjectPayload>(\n (payload) =>\n observableClient.observeObject(\n objectType,\n primaryKey,\n {\n mode,\n },\n payload,\n ),\n `object ${objectType} ${primaryKey}`,\n ),\n [observableClient, objectType, primaryKey, mode],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n forceUpdate: () => {\n throw \"not implemented\";\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;;AAahD;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3B,GAAGC,IAAwE,EACnD;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;;EAE3D;EACA,MAAMK,IAAI,GAAGH,IAAI,CAACI,MAAM,KAAK,CAAC,GAAG,SAAS,GAAGC,SAAS;EACtD,MAAMC,UAAU,GAAGN,IAAI,CAACI,MAAM,KAAK,CAAC,GAAGJ,IAAI,CAAC,CAAC,CAAC,CAACO,WAAW,GAAGP,IAAI,CAAC,CAAC,CAAC,CAACQ,OAAO;EAC5E,MAAMC,UAAU,GAAGT,IAAI,CAACI,MAAM,KAAK,CAAC,GAAGJ,IAAI,CAAC,CAAC,CAAC,CAACU,WAAW,GAAGV,IAAI,CAAC,CAAC,CAAC;EAEpE,MAAM;IAAEW,SAAS;IAAEC;EAAY,CAAC,GAAGhB,KAAK,CAACiB,OAAO,CAC9C,MACEhB,iBAAiB,CACdiB,OAAO,IACNb,gBAAgB,CAACc,aAAa,CAC5BT,UAAU,EACVG,UAAU,EACV;IACEN;EACF,CAAC,EACDW,OACF,CAAC,EACH,UAAUR,UAAU,IAAIG,UAAU,EACpC,CAAC,EACH,CAACR,gBAAgB,EAAEK,UAAU,EAAEG,UAAU,EAAEN,IAAI,CACjD,CAAC;EAED,MAAMW,OAAO,GAAGlB,KAAK,CAACoB,oBAAoB,CAACL,SAAS,EAAEC,WAAW,CAAC;EAElE,OAAO;IACLK,MAAM,EAAEH,OAAO,EAAEG,MAAsC;IACvDC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS;IACxCC,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,WAAW,EAAEA,CAAA,KAAM;MACjB,MAAM,iBAAiB;IACzB;EACF,CAAC;AACH","ignoreList":[]}
@@ -17,40 +17,40 @@
17
17
  import React from "react";
18
18
  import { makeExternalStore } from "./makeExternalStore.js";
19
19
  import { OsdkContext2 } from "./OsdkContext2.js";
20
- export function useOsdkList(objectType, {
20
+ export function useOsdkObjects(objectType, {
21
21
  pageSize,
22
22
  orderBy,
23
23
  dedupeIntervalMs,
24
- where,
24
+ where = {},
25
25
  streamUpdates
26
- }) {
26
+ } = {}) {
27
27
  const {
28
- store
28
+ observableClient
29
29
  } = React.useContext(OsdkContext2);
30
30
 
31
31
  /* We want the canonical where clause so that the use of `React.useMemo`
32
32
  is stable. No real added cost as we canonicalize internal to
33
33
  the ObservableClient anyway.
34
34
  */
35
- const canonWhere = store.canonicalizeWhereClause(where ?? {});
35
+ const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});
36
36
  const {
37
37
  subscribe,
38
38
  getSnapShot
39
- } = React.useMemo(() => makeExternalStore(x => store.observeList({
39
+ } = React.useMemo(() => makeExternalStore(x => observableClient.observeList({
40
40
  objectType,
41
41
  where: canonWhere,
42
42
  dedupeInterval: dedupeIntervalMs ?? 2_000,
43
43
  pageSize,
44
44
  orderBy,
45
45
  streamUpdates
46
- }, x), process.env.NODE_ENV !== "production" ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}` : void 0), [store, objectType, canonWhere, dedupeIntervalMs]);
46
+ }, x), process.env.NODE_ENV !== "production" ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, objectType, canonWhere, dedupeIntervalMs]);
47
47
  const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);
48
+ // TODO: we need to expose the error in the result
48
49
  return {
49
50
  fetchMore: listPayload?.fetchMore,
50
51
  data: listPayload?.resolvedList,
51
52
  isLoading: listPayload?.status === "loading",
52
- error: undefined,
53
53
  isOptimistic: listPayload?.isOptimistic ?? false
54
54
  };
55
55
  }
56
- //# sourceMappingURL=useOsdkList.js.map
56
+ //# sourceMappingURL=useOsdkObjects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","objectType","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","observableClient","useContext","canonWhere","canonicalizeWhereClause","subscribe","getSnapShot","useMemo","x","observeList","dedupeInterval","process","env","NODE_ENV","apiName","JSON","stringify","listPayload","useSyncExternalStore","fetchMore","data","resolvedList","isLoading","status","isOptimistic"],"sources":["useOsdkObjects.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 ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/client\";\nimport type { ListPayload } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectsOptions<T extends ObjectTypeDefinition> {\n /**\n * Standard OSDK Where\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n */\n // autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * If provided, the list will be considered this length for the purposes of\n * `invalidationMode` when using the `wait` option. If not provided,\n * the internal expectedLength will be determined by the number of times\n * `fetchMore` has been called.\n */\n // expectedLength?: number | undefined;\n\n streamUpdates?: boolean;\n}\n\nexport interface UseOsdkListResult<T extends ObjectTypeDefinition> {\n fetchMore: (() => Promise<unknown>) | undefined;\n data: Osdk.Instance<T>[] | undefined;\n isLoading: boolean;\n\n // FIXME populate error!\n // error: undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<T extends ObjectTypeDefinition>(\n objectType: T,\n {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n }: UseOsdkObjectsOptions<T> = {},\n): UseOsdkListResult<T> {\n const { observableClient } = 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\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ListPayload>(\n (x) =>\n observableClient.observeList({\n objectType,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates,\n }, x),\n process.env.NODE_ENV !== \"production\"\n ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [observableClient, objectType, canonWhere, dedupeIntervalMs],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n // TODO: we need to expose the error in the result\n return {\n fetchMore: listPayload?.fetchMore,\n data: listPayload?.resolvedList as Osdk.Instance<T>[],\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAyFhD,OAAO,SAASC,cAAcA,CAC5BC,UAAa,EACb;EACEC,QAAQ;EACRC,OAAO;EACPC,gBAAgB;EAChBC,KAAK,GAAG,CAAC,CAAC;EACVC;AACwB,CAAC,GAAG,CAAC,CAAC,EACV;EACtB,MAAM;IAAEC;EAAiB,CAAC,GAAGV,KAAK,CAACW,UAAU,CAACT,YAAY,CAAC;;EAE3D;AACF;AACA;AACA;EACE,MAAMU,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAACL,KAAK,IAAI,CAAC,CAAC,CAAC;EAExE,MAAM;IAAEM,SAAS;IAAEC;EAAY,CAAC,GAAGf,KAAK,CAACgB,OAAO,CAC9C,MACEf,iBAAiB,CACdgB,CAAC,IACAP,gBAAgB,CAACQ,WAAW,CAAC;IAC3Bd,UAAU;IACVI,KAAK,EAAEI,UAAU;IACjBO,cAAc,EAAEZ,gBAAgB,IAAI,KAAK;IACzCF,QAAQ;IACRC,OAAO;IACPG;EACF,CAAC,EAAEQ,CAAC,CAAC,EACPG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQlB,UAAU,CAACmB,OAAO,IAAIC,IAAI,CAACC,SAAS,CAACb,UAAU,CAAC,EAAE,GAC1D,KAAK,CACX,CAAC,EACH,CAACF,gBAAgB,EAAEN,UAAU,EAAEQ,UAAU,EAAEL,gBAAgB,CAC7D,CAAC;EAED,MAAMmB,WAAW,GAAG1B,KAAK,CAAC2B,oBAAoB,CAACb,SAAS,EAAEC,WAAW,CAAC;EACtE;EACA,OAAO;IACLa,SAAS,EAAEF,WAAW,EAAEE,SAAS;IACjCC,IAAI,EAAEH,WAAW,EAAEI,YAAkC;IACrDC,SAAS,EAAEL,WAAW,EAAEM,MAAM,KAAK,SAAS;IAC5CC,YAAY,EAAEP,WAAW,EAAEO,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
@@ -16,7 +16,7 @@
16
16
 
17
17
  export { OsdkProvider2 } from "../new/OsdkProvider2.js";
18
18
  export { useOsdkAction } from "../new/useOsdkAction.js";
19
- export { useOsdkList } from "../new/useOsdkList.js";
20
19
  export { useOsdkObject } from "../new/useOsdkObject.js";
20
+ export { useOsdkObjects } from "../new/useOsdkObjects.js";
21
21
  export { useOsdkClient } from "../useOsdkClient.js";
22
22
  //# sourceMappingURL=experimental.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"experimental.js","names":["OsdkProvider2","useOsdkAction","useOsdkList","useOsdkObject","useOsdkClient"],"sources":["experimental.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\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport { useOsdkList } from \"../new/useOsdkList.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,qBAAqB","ignoreList":[]}
1
+ {"version":3,"file":"experimental.js","names":["OsdkProvider2","useOsdkAction","useOsdkObject","useOsdkObjects","useOsdkClient"],"sources":["experimental.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\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB","ignoreList":[]}
@@ -3,7 +3,7 @@ import type { ObservableClient } from "@osdk/client/unstable-do-not-use";
3
3
  import React from "react";
4
4
  interface OsdkContextContents {
5
5
  client: Client;
6
- store: ObservableClient;
6
+ observableClient: ObservableClient;
7
7
  }
8
8
  export declare const OsdkContext2: React.Context<OsdkContextContents>;
9
9
  export {};
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,cAAc,cAAe;AAC3C,cAAc,wBAAwB,kCAAmC;AACzE,OAAO,WAAW,OAAQ;UAYhB,oBAAoB;CAC5B,QAAQ;CAKR,OAAO;AACR;AAED,OAAO,cAAMA,cAAc,MAAM,QAAQ","names":["OsdkContext2: React.Context<OsdkContextContents>"],"sources":["../../../src/new/OsdkContext2.ts"],"version":3,"file":"OsdkContext2.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,cAAc,cAAe;AAC3C,cAAc,wBAAwB,kCAAmC;AACzE,OAAO,WAAW,OAAQ;UAYhB,oBAAoB;CAC5B,QAAQ;CAKR,kBAAkB;AACnB;AAED,OAAO,cAAMA,cAAc,MAAM,QAAQ","names":["OsdkContext2: React.Context<OsdkContextContents>"],"sources":["../../../src/new/OsdkContext2.ts"],"version":3,"file":"OsdkContext2.d.ts"}
@@ -1,10 +1,10 @@
1
1
  import type { Client } from "@osdk/client";
2
- import type { ObservableClient } from "@osdk/client/unstable-do-not-use";
2
+ import { type ObservableClient } from "@osdk/client/unstable-do-not-use";
3
3
  import React from "react";
4
4
  interface OsdkProviderOptions {
5
5
  children: React.ReactNode;
6
6
  client: Client;
7
- store: ObservableClient;
7
+ observableClient?: ObservableClient;
8
8
  }
9
- export declare function OsdkProvider2({ children, client, store }: OsdkProviderOptions): React.JSX.Element;
9
+ export declare function OsdkProvider2({ children, client, observableClient }: OsdkProviderOptions): React.JSX.Element;
10
10
  export {};
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,cAAc,cAAe;AAC3C,cAAc,wBAAwB,kCAAmC;AACzE,OAAO,WAAW,OAAQ;UAGhB,oBAAoB;CAC5B,UAAU,MAAM;CAChB,QAAQ;CACR,OAAO;AACR;AAED,OAAO,iBAAS,cAAc,EAC5B,UACA,QACA,OACoB,EAAnB,sBAAsB,MAAM,IAAI","names":[],"sources":["../../../src/new/OsdkProvider2.tsx"],"version":3,"file":"OsdkProvider2.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,cAAc,cAAe;AAC3C,cAEO,wBACA,kCAAmC;AAC1C,OAAO,WAAwB,OAAQ;UAG7B,oBAAoB;CAC5B,UAAU,MAAM;CAChB,QAAQ;CACR,mBAAmB;AACpB;AAED,OAAO,iBAAS,cAAc,EAC5B,UACA,QACA,kBACoB,EAAnB,sBAAsB,MAAM,IAAI","names":[],"sources":["../../../src/new/OsdkProvider2.tsx"],"version":3,"file":"OsdkProvider2.d.ts"}
@@ -1,5 +1,5 @@
1
1
  import type { ObjectTypeDefinition, Osdk, PropertyKeys, WhereClause } from "@osdk/client";
2
- export interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
2
+ export interface UseOsdkObjectsOptions<T extends ObjectTypeDefinition> {
3
3
  /**
4
4
  * Standard OSDK Where
5
5
  */
@@ -37,7 +37,7 @@ export interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
37
37
  /**
38
38
  * The number of milliseconds to wait after the last observed list change.
39
39
  *
40
- * Two uses of `useOsdkList` with the where clause will only trigger one
40
+ * Two uses of `useOsdkObjects` with the where clause will only trigger one
41
41
  * network request if the second is within `dedupeIntervalMs`.
42
42
  */
43
43
  dedupeIntervalMs?: number;
@@ -51,9 +51,8 @@ export interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
51
51
  }
52
52
  export interface UseOsdkListResult<T extends ObjectTypeDefinition> {
53
53
  fetchMore: (() => Promise<unknown>) | undefined;
54
- data: Osdk.Instance<T>[];
54
+ data: Osdk.Instance<T>[] | undefined;
55
55
  isLoading: boolean;
56
- error: undefined;
57
56
  /**
58
57
  * Refers to whether the ordered list of objects (only considering the $primaryKey)
59
58
  * is optimistic or not.
@@ -63,4 +62,4 @@ export interface UseOsdkListResult<T extends ObjectTypeDefinition> {
63
62
  */
64
63
  isOptimistic: boolean;
65
64
  }
66
- export declare function useOsdkList<T extends ObjectTypeDefinition>(objectType: T, { pageSize, orderBy, dedupeIntervalMs, where, streamUpdates }: UseOsdkListOptions<T>): UseOsdkListResult<T>;
65
+ export declare function useOsdkObjects<T extends ObjectTypeDefinition>(objectType: T, { pageSize, orderBy, dedupeIntervalMs, where, streamUpdates }?: UseOsdkObjectsOptions<T>): UseOsdkListResult<T>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cACE,sBACA,MACA,cACA,mBACK,cAAe;AAMtB,iBAAiB,sBAAsB,UAAU,sBAAsB;;;;CAIrE,QAAQ,YAAY;;;;CAKpB;;CAGA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCnC;;;;;;;CAUA;AACD;AAED,iBAAiB,kBAAkB,UAAU,sBAAsB;CACjE,kBAAkB;CAClB,MAAM,KAAK,SAAS;CACpB;;;;;;;;CAYA;AACD;AAQD,OAAO,iBAAS,eAAe,UAAU,sBACvCA,YAAY,GACZ,EACE,UACA,SACA,kBACA,OACA,eACyB,GAAxB,sBAAsB,KACxB,kBAAkB","names":["objectType: T"],"sources":["../../../src/new/useOsdkObjects.ts"],"version":3,"file":"useOsdkObjects.d.ts"}
@@ -1,5 +1,5 @@
1
1
  export { OsdkProvider2 } from "../new/OsdkProvider2.js";
2
2
  export { useOsdkAction } from "../new/useOsdkAction.js";
3
- export { useOsdkList } from "../new/useOsdkList.js";
4
3
  export { useOsdkObject } from "../new/useOsdkObject.js";
4
+ export { useOsdkObjects } from "../new/useOsdkObjects.js";
5
5
  export { useOsdkClient } from "../useOsdkClient.js";
@@ -1 +1 @@
1
- {"mappings":"AAgBA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB","names":[],"sources":["../../../src/public/experimental.ts"],"version":3,"file":"experimental.d.ts"}
1
+ {"mappings":"AAgBA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB","names":[],"sources":["../../../src/public/experimental.ts"],"version":3,"file":"experimental.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/react",
3
- "version": "0.4.0-beta.2",
3
+ "version": "0.4.0-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,10 +49,10 @@
49
49
  "p-defer": "^4.0.1",
50
50
  "react": "^18.0.0",
51
51
  "typescript": "~5.5.4",
52
- "@osdk/api": "2.2.0-beta.4",
53
- "@osdk/client": "2.2.0-beta.4",
54
- "@osdk/monorepo.tsconfig": "~0.1.0-beta.1",
55
- "@osdk/monorepo.api-extractor": "~0.1.0-beta.1"
52
+ "@osdk/api": "2.2.0-beta.5",
53
+ "@osdk/client": "2.2.0-beta.5",
54
+ "@osdk/monorepo.api-extractor": "~0.1.0-beta.1",
55
+ "@osdk/monorepo.tsconfig": "~0.1.0-beta.1"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
@@ -1 +0,0 @@
1
- {"version":3,"file":"useOsdkList.js","names":["React","makeExternalStore","OsdkContext2","useOsdkList","objectType","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","store","useContext","canonWhere","canonicalizeWhereClause","subscribe","getSnapShot","useMemo","x","observeList","dedupeInterval","process","env","NODE_ENV","apiName","JSON","stringify","listPayload","useSyncExternalStore","fetchMore","data","resolvedList","isLoading","status","error","undefined","isOptimistic"],"sources":["useOsdkList.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 ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/client\";\nimport type { ListPayload } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkListOptions<T extends ObjectTypeDefinition> {\n /**\n * Standard OSDK Where\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n */\n // autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkList` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * If provided, the list will be considered this length for the purposes of\n * `invalidationMode` when using the `wait` option. If not provided,\n * the internal expectedLength will be determined by the number of times\n * `fetchMore` has been called.\n */\n // expectedLength?: number | undefined;\n\n streamUpdates?: boolean;\n}\n\nexport interface UseOsdkListResult<T extends ObjectTypeDefinition> {\n fetchMore: (() => Promise<unknown>) | undefined;\n data: Osdk.Instance<T>[];\n isLoading: boolean;\n\n // FIXME populate error!\n error: undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkList<T extends ObjectTypeDefinition>(\n objectType: T,\n { pageSize, orderBy, dedupeIntervalMs, where, streamUpdates }:\n UseOsdkListOptions<T>,\n): UseOsdkListResult<T> {\n const { store } = 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 = store.canonicalizeWhereClause(where ?? {});\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ListPayload>(\n (x) =>\n store.observeList({\n objectType,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates,\n }, x),\n process.env.NODE_ENV !== \"production\"\n ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [store, objectType, canonWhere, dedupeIntervalMs],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n fetchMore: listPayload?.fetchMore,\n data: listPayload?.resolvedList as Osdk.Instance<T>[],\n isLoading: listPayload?.status === \"loading\",\n error: undefined,\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAyFhD,OAAO,SAASC,WAAWA,CACzBC,UAAa,EACb;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,gBAAgB;EAAEC,KAAK;EAAEC;AACxB,CAAC,EACD;EACtB,MAAM;IAAEC;EAAM,CAAC,GAAGV,KAAK,CAACW,UAAU,CAACT,YAAY,CAAC;;EAEhD;AACF;AACA;AACA;EACE,MAAMU,UAAU,GAAGF,KAAK,CAACG,uBAAuB,CAACL,KAAK,IAAI,CAAC,CAAC,CAAC;EAE7D,MAAM;IAAEM,SAAS;IAAEC;EAAY,CAAC,GAAGf,KAAK,CAACgB,OAAO,CAC9C,MACEf,iBAAiB,CACdgB,CAAC,IACAP,KAAK,CAACQ,WAAW,CAAC;IAChBd,UAAU;IACVI,KAAK,EAAEI,UAAU;IACjBO,cAAc,EAAEZ,gBAAgB,IAAI,KAAK;IACzCF,QAAQ;IACRC,OAAO;IACPG;EACF,CAAC,EAAEQ,CAAC,CAAC,EACPG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQlB,UAAU,CAACmB,OAAO,IAAIC,IAAI,CAACC,SAAS,CAACb,UAAU,CAAC,EAAE,GAC1D,KAAK,CACX,CAAC,EACH,CAACF,KAAK,EAAEN,UAAU,EAAEQ,UAAU,EAAEL,gBAAgB,CAClD,CAAC;EAED,MAAMmB,WAAW,GAAG1B,KAAK,CAAC2B,oBAAoB,CAACb,SAAS,EAAEC,WAAW,CAAC;EAEtE,OAAO;IACLa,SAAS,EAAEF,WAAW,EAAEE,SAAS;IACjCC,IAAI,EAAEH,WAAW,EAAEI,YAAkC;IACrDC,SAAS,EAAEL,WAAW,EAAEM,MAAM,KAAK,SAAS;IAC5CC,KAAK,EAAEC,SAAS;IAChBC,YAAY,EAAET,WAAW,EAAES,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useOsdkList.js","names":["React","makeExternalStore","OsdkContext2","useOsdkList","objectType","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","store","useContext","canonWhere","canonicalizeWhereClause","subscribe","getSnapShot","useMemo","x","observeList","dedupeInterval","process","env","NODE_ENV","apiName","JSON","stringify","listPayload","useSyncExternalStore","fetchMore","data","resolvedList","isLoading","status","error","undefined","isOptimistic"],"sources":["useOsdkList.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 ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/client\";\nimport type { ListPayload } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkListOptions<T extends ObjectTypeDefinition> {\n /**\n * Standard OSDK Where\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n */\n // autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkList` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * If provided, the list will be considered this length for the purposes of\n * `invalidationMode` when using the `wait` option. If not provided,\n * the internal expectedLength will be determined by the number of times\n * `fetchMore` has been called.\n */\n // expectedLength?: number | undefined;\n\n streamUpdates?: boolean;\n}\n\nexport interface UseOsdkListResult<T extends ObjectTypeDefinition> {\n fetchMore: (() => Promise<unknown>) | undefined;\n data: Osdk.Instance<T>[];\n isLoading: boolean;\n\n // FIXME populate error!\n error: undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkList<T extends ObjectTypeDefinition>(\n objectType: T,\n { pageSize, orderBy, dedupeIntervalMs, where, streamUpdates }:\n UseOsdkListOptions<T>,\n): UseOsdkListResult<T> {\n const { store } = 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 = store.canonicalizeWhereClause(where ?? {});\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ListPayload>(\n (x) =>\n store.observeList({\n objectType,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates,\n }, x),\n process.env.NODE_ENV !== \"production\"\n ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [store, objectType, canonWhere, dedupeIntervalMs],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n fetchMore: listPayload?.fetchMore,\n data: listPayload?.resolvedList as Osdk.Instance<T>[],\n isLoading: listPayload?.status === \"loading\",\n error: undefined,\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAyFhD,OAAO,SAASC,WAAWA,CACzBC,UAAa,EACb;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,gBAAgB;EAAEC,KAAK;EAAEC;AACxB,CAAC,EACD;EACtB,MAAM;IAAEC;EAAM,CAAC,GAAGV,KAAK,CAACW,UAAU,CAACT,YAAY,CAAC;;EAEhD;AACF;AACA;AACA;EACE,MAAMU,UAAU,GAAGF,KAAK,CAACG,uBAAuB,CAACL,KAAK,IAAI,CAAC,CAAC,CAAC;EAE7D,MAAM;IAAEM,SAAS;IAAEC;EAAY,CAAC,GAAGf,KAAK,CAACgB,OAAO,CAC9C,MACEf,iBAAiB,CACdgB,CAAC,IACAP,KAAK,CAACQ,WAAW,CAAC;IAChBd,UAAU;IACVI,KAAK,EAAEI,UAAU;IACjBO,cAAc,EAAEZ,gBAAgB,IAAI,KAAK;IACzCF,QAAQ;IACRC,OAAO;IACPG;EACF,CAAC,EAAEQ,CAAC,CAAC,EACPG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQlB,UAAU,CAACmB,OAAO,IAAIC,IAAI,CAACC,SAAS,CAACb,UAAU,CAAC,EAAE,GAC1D,KAAK,CACX,CAAC,EACH,CAACF,KAAK,EAAEN,UAAU,EAAEQ,UAAU,EAAEL,gBAAgB,CAClD,CAAC;EAED,MAAMmB,WAAW,GAAG1B,KAAK,CAAC2B,oBAAoB,CAACb,SAAS,EAAEC,WAAW,CAAC;EAEtE,OAAO;IACLa,SAAS,EAAEF,WAAW,EAAEE,SAAS;IACjCC,IAAI,EAAEH,WAAW,EAAEI,YAAkC;IACrDC,SAAS,EAAEL,WAAW,EAAEM,MAAM,KAAK,SAAS;IAC5CC,KAAK,EAAEC,SAAS;IAChBC,YAAY,EAAET,WAAW,EAAES,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"mappings":"AAgBA,cACE,sBACA,MACA,cACA,mBACK,cAAe;AAMtB,iBAAiB,mBAAmB,UAAU,sBAAsB;;;;CAIlE,QAAQ,YAAY;;;;CAKpB;;CAGA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCnC;;;;;;;CAUA;AACD;AAED,iBAAiB,kBAAkB,UAAU,sBAAsB;CACjE,kBAAkB;CAClB,MAAM,KAAK,SAAS;CACpB;CAGA;;;;;;;;CASA;AACD;AAQD,OAAO,iBAAS,YAAY,UAAU,sBACpCA,YAAY,GACZ,EAAE,UAAU,SAAS,kBAAkB,OAAO,eACvB,EAArB,mBAAmB,KACpB,kBAAkB","names":["objectType: T"],"sources":["../../../src/new/useOsdkList.ts"],"version":3,"file":"useOsdkList.d.ts"}