@osdk/react 0.4.0-beta.1 → 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 (47) hide show
  1. package/CHANGELOG.md +25 -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/makeExternalStore.js +1 -5
  7. package/build/browser/new/makeExternalStore.js.map +1 -1
  8. package/build/browser/new/useOsdkAction.js +17 -5
  9. package/build/browser/new/useOsdkAction.js.map +1 -1
  10. package/build/browser/new/useOsdkObject.js +3 -3
  11. package/build/browser/new/useOsdkObject.js.map +1 -1
  12. package/build/browser/new/{useOsdkList.js → useOsdkObjects.js} +24 -8
  13. package/build/browser/new/useOsdkObjects.js.map +1 -0
  14. package/build/browser/public/experimental.js +1 -1
  15. package/build/browser/public/experimental.js.map +1 -1
  16. package/build/cjs/public/experimental.cjs +57 -35
  17. package/build/cjs/public/experimental.cjs.map +1 -1
  18. package/build/cjs/public/experimental.d.cts +79 -34
  19. package/build/esm/new/OsdkContext2.js +1 -1
  20. package/build/esm/new/OsdkContext2.js.map +1 -1
  21. package/build/esm/new/OsdkProvider2.js +5 -3
  22. package/build/esm/new/OsdkProvider2.js.map +1 -1
  23. package/build/esm/new/makeExternalStore.js +1 -5
  24. package/build/esm/new/makeExternalStore.js.map +1 -1
  25. package/build/esm/new/useOsdkAction.js +17 -5
  26. package/build/esm/new/useOsdkAction.js.map +1 -1
  27. package/build/esm/new/useOsdkObject.js +3 -3
  28. package/build/esm/new/useOsdkObject.js.map +1 -1
  29. package/build/esm/new/{useOsdkList.js → useOsdkObjects.js} +24 -8
  30. package/build/esm/new/useOsdkObjects.js.map +1 -0
  31. package/build/esm/public/experimental.js +1 -1
  32. package/build/esm/public/experimental.js.map +1 -1
  33. package/build/types/new/OsdkContext2.d.ts +1 -1
  34. package/build/types/new/OsdkContext2.d.ts.map +1 -1
  35. package/build/types/new/OsdkProvider2.d.ts +3 -3
  36. package/build/types/new/OsdkProvider2.d.ts.map +1 -1
  37. package/build/types/new/useOsdkAction.d.ts +4 -1
  38. package/build/types/new/useOsdkAction.d.ts.map +1 -1
  39. package/build/types/new/useOsdkObjects.d.ts +65 -0
  40. package/build/types/new/useOsdkObjects.d.ts.map +1 -0
  41. package/build/types/public/experimental.d.ts +1 -1
  42. package/build/types/public/experimental.d.ts.map +1 -1
  43. package/package.json +5 -5
  44. package/build/browser/new/useOsdkList.js.map +0 -1
  45. package/build/esm/new/useOsdkList.js.map +0 -1
  46. package/build/types/new/useOsdkList.d.ts +0 -26
  47. package/build/types/new/useOsdkList.d.ts.map +0 -1
@@ -1,41 +1,107 @@
1
- import { Client, ActionDefinition, ActionValidationError, ObjectTypeDefinition, WhereClause, 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
+ type ApplyActionParams<Q extends ActionDefinition<any>> = Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0] & {
15
+ [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]: ObservableClient.ApplyActionOptions[K];
16
+ };
14
17
  interface UseOsdkActionResult<Q extends ActionDefinition<any>> {
15
- applyAction: (args: Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0], opts: ObservableClient.ApplyActionOptions) => Promise<unknown>;
18
+ applyAction: (args: ApplyActionParams<Q>) => Promise<unknown>;
16
19
  error: undefined | Partial<{
17
20
  actionValidation: ActionValidationError;
18
21
  unknown: unknown;
19
22
  }>;
20
23
  data: unknown;
24
+ isPending: boolean;
21
25
  }
22
26
  declare function useOsdkAction<Q extends ActionDefinition<any>>(actionDef: Q): UseOsdkActionResult<Q>;
23
27
 
24
- interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
25
- where: WhereClause<T>;
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> {
50
+ /**
51
+ * Standard OSDK Where
52
+ */
53
+ where?: WhereClause<T>;
54
+ /**
55
+ * The preferred page size for the list.
56
+ */
57
+ pageSize?: number;
58
+ /** */
59
+ orderBy?: {
60
+ [K in PropertyKeys<T>]?: "asc" | "desc";
61
+ };
62
+ /**
63
+ * Causes the list to automatically fetch more as soon as the previous page
64
+ * has been loaded. If a number is provided, it will continue to automatically
65
+ * fetch more until the list is at least that long.
66
+ */
67
+ /**
68
+ * Upon a list being revalidated, this option determines how the component
69
+ * will be re-rendered with the data.
70
+ *
71
+ * An example to help understand the options:
72
+ *
73
+ * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is
74
+ * now 30 items long.
75
+ *
76
+ * Upon revalidation, we get the first 10 items of the list. The options behave
77
+ * as follows:
78
+ *
79
+ * - `"in-place"`: The first 10 items of the list are replaced with the new 10
80
+ * items. The list is now 30 items long, but only the first 10 items are valid.
81
+ * - `"wait"`: The old list is returned until after the next 20 items are loaded
82
+ * (which will happen automatically). The list is now 30 items long.
83
+ * - `"reset"`: The entire list is replaced with the new 10 items. The list is
84
+ * now 10 items long.
85
+ */
26
86
  /**
27
87
  * The number of milliseconds to wait after the last observed list change.
28
88
  *
29
- * 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
30
90
  * network request if the second is within `dedupeIntervalMs`.
31
91
  */
32
92
  dedupeIntervalMs?: number;
93
+ /**
94
+ * If provided, the list will be considered this length for the purposes of
95
+ * `invalidationMode` when using the `wait` option. If not provided,
96
+ * the internal expectedLength will be determined by the number of times
97
+ * `fetchMore` has been called.
98
+ */
99
+ streamUpdates?: boolean;
33
100
  }
34
- interface UseOsdkListResult<T extends ObjectTypeDefinition> {
101
+ interface UseOsdkListResult<T extends ObjectTypeDefinition$1> {
35
102
  fetchMore: (() => Promise<unknown>) | undefined;
36
- data: Osdk.Instance<T>[];
103
+ data: Osdk$1.Instance<T>[] | undefined;
37
104
  isLoading: boolean;
38
- error: undefined;
39
105
  /**
40
106
  * Refers to whether the ordered list of objects (only considering the $primaryKey)
41
107
  * is optimistic or not.
@@ -45,27 +111,6 @@ interface UseOsdkListResult<T extends ObjectTypeDefinition> {
45
111
  */
46
112
  isOptimistic: boolean;
47
113
  }
48
- declare function useOsdkList<T extends ObjectTypeDefinition>(type: T, opts: UseOsdkListOptions<T>): UseOsdkListResult<T>;
49
-
50
- interface UseOsdkObjectResult<Q extends ObjectTypeDefinition$1> {
51
- object: Osdk$1.Instance<Q> | undefined;
52
- isLoading: boolean;
53
- /**
54
- * Refers to whether the object is optimistic or not.
55
- */
56
- isOptimistic: boolean;
57
- forceUpdate: () => void;
58
- }
59
- /**
60
- * @param obj an existing `Osdk.Instance` object to get metadata for.
61
- */
62
- declare function useOsdkObject<Q extends ObjectTypeDefinition$1>(obj: Osdk$1.Instance<Q>): UseOsdkObjectResult<Q>;
63
- /**
64
- * Loads an object by type and primary key.
65
- *
66
- * @param type
67
- * @param primaryKey
68
- */
69
- 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>;
70
115
 
71
- 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":[]}
@@ -14,22 +14,18 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export function makeExternalStore(createObservation, name) {
17
+ export function makeExternalStore(createObservation) {
18
18
  let lastResult;
19
19
  function getSnapShot() {
20
20
  return lastResult;
21
21
  }
22
22
  return {
23
23
  subscribe: function subscribe(notifyUpdate) {
24
- // eslint-disable-next-line no-console
25
- console.log("Subscribing", name);
26
24
  const obs = createObservation(payload => {
27
25
  lastResult = payload;
28
26
  notifyUpdate();
29
27
  });
30
28
  return () => {
31
- // eslint-disable-next-line no-console
32
- console.log("Unsubscribing", name);
33
29
  obs.unsubscribe();
34
30
  };
35
31
  },
@@ -1 +1 @@
1
- {"version":3,"file":"makeExternalStore.js","names":["makeExternalStore","createObservation","name","lastResult","getSnapShot","subscribe","notifyUpdate","console","log","obs","payload","unsubscribe"],"sources":["makeExternalStore.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Unsubscribable } from \"@osdk/client/unstable-do-not-use\";\n\nexport function makeExternalStore<X>(\n createObservation: (callback: (x: X | undefined) => void) => Unsubscribable,\n name?: string,\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => X | undefined;\n} {\n let lastResult: X | undefined;\n\n function getSnapShot(): X | undefined {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n // eslint-disable-next-line no-console\n console.log(\"Subscribing\", name);\n const obs = createObservation((payload) => {\n lastResult = payload;\n notifyUpdate();\n });\n\n return (): void => {\n // eslint-disable-next-line no-console\n console.log(\"Unsubscribing\", name);\n obs.unsubscribe();\n };\n }\n\n return {\n subscribe,\n getSnapShot,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,iBAAiBA,CAC/BC,iBAA2E,EAC3EC,IAAa,EAIb;EACA,IAAIC,UAAyB;EAE7B,SAASC,WAAWA,CAAA,EAAkB;IACpC,OAAOD,UAAU;EACnB;EAiBA,OAAO;IACLE,SAAS,EAhBX,SAASA,SAASA,CAACC,YAAwB,EAAE;MAC3C;MACAC,OAAO,CAACC,GAAG,CAAC,aAAa,EAAEN,IAAI,CAAC;MAChC,MAAMO,GAAG,GAAGR,iBAAiB,CAAES,OAAO,IAAK;QACzCP,UAAU,GAAGO,OAAO;QACpBJ,YAAY,CAAC,CAAC;MAChB,CAAC,CAAC;MAEF,OAAO,MAAY;QACjB;QACAC,OAAO,CAACC,GAAG,CAAC,eAAe,EAAEN,IAAI,CAAC;QAClCO,GAAG,CAACE,WAAW,CAAC,CAAC;MACnB,CAAC;IACH,CAGW;IACTP;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"makeExternalStore.js","names":["makeExternalStore","createObservation","lastResult","getSnapShot","subscribe","notifyUpdate","obs","payload","unsubscribe"],"sources":["makeExternalStore.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Unsubscribable } from \"@osdk/client/unstable-do-not-use\";\n\nexport function makeExternalStore<X>(\n createObservation: (callback: (x: X | undefined) => void) => Unsubscribable,\n name?: string,\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => X | undefined;\n} {\n let lastResult: X | undefined;\n\n function getSnapShot(): X | undefined {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n const obs = createObservation((payload) => {\n lastResult = payload;\n notifyUpdate();\n });\n\n return (): void => {\n obs.unsubscribe();\n };\n }\n\n return {\n subscribe,\n getSnapShot,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,iBAAiBA,CAC/BC,iBAA2E,EAK3E;EACA,IAAIC,UAAyB;EAE7B,SAASC,WAAWA,CAAA,EAAkB;IACpC,OAAOD,UAAU;EACnB;EAaA,OAAO;IACLE,SAAS,EAZX,SAASA,SAASA,CAACC,YAAwB,EAAE;MAC3C,MAAMC,GAAG,GAAGL,iBAAiB,CAAEM,OAAO,IAAK;QACzCL,UAAU,GAAGK,OAAO;QACpBF,YAAY,CAAC,CAAC;MAChB,CAAC,CAAC;MAEF,OAAO,MAAY;QACjBC,GAAG,CAACE,WAAW,CAAC,CAAC;MACnB,CAAC;IACH,CAGW;IACTL;EACF,CAAC;AACH","ignoreList":[]}
@@ -19,13 +19,22 @@ 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();
26
- const applyAction = React.useCallback(async function (args, opts) {
26
+ const [isPending, setPending] = React.useState(false);
27
+ const applyAction = React.useCallback(async function (hookArgs) {
28
+ const {
29
+ $optimisticUpdate,
30
+ ...args
31
+ } = hookArgs;
27
32
  try {
28
- const r = await store.applyAction(actionDef, args, opts);
33
+ setPending(true);
34
+ setError(undefined);
35
+ const r = await observableClient.applyAction(actionDef, args, {
36
+ optimisticUpdate: $optimisticUpdate
37
+ });
29
38
  setData(r);
30
39
  return r;
31
40
  } catch (e) {
@@ -38,12 +47,15 @@ export function useOsdkAction(actionDef) {
38
47
  unknown: e
39
48
  });
40
49
  }
50
+ } finally {
51
+ setPending(false);
41
52
  }
42
- }, [store, setError]);
53
+ }, [observableClient, setError]);
43
54
  return {
44
55
  applyAction,
45
56
  error,
46
- data
57
+ data,
58
+ isPending
47
59
  };
48
60
  }
49
61
  //# sourceMappingURL=useOsdkAction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","OsdkContext2","useOsdkAction","actionDef","store","useContext","error","setError","useState","data","setData","applyAction","useCallback","args","opts","r","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\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts: ObservableClient.ApplyActionOptions,\n ) => Promise<unknown>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: unknown;\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\n const applyAction = React.useCallback(async function applyAction(\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n opts: ObservableClient.ApplyActionOptions,\n ) {\n try {\n const r = await store.applyAction(actionDef, args, opts);\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 }\n }, [store, setError]);\n\n return { applyAction, error, data };\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;AAiBhD,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;EAEjD,MAAMG,WAAW,GAAGX,KAAK,CAACY,WAAW,CAAC,gBACpCC,IAA6D,EAC7DC,IAAyC,EACzC;IACA,IAAI;MACF,MAAMC,CAAC,GAAG,MAAMX,KAAK,CAACO,WAAW,CAACR,SAAS,EAAEU,IAAI,EAAEC,IAAI,CAAC;MACxDJ,OAAO,CAACK,CAAC,CAAC;MACV,OAAOA,CAAC;IACV,CAAC,CAAC,OAAOC,CAAC,EAAE;MACV,IAAIA,CAAC,YAAYjB,qBAAqB,EAAE;QACtCQ,QAAQ,CAAC;UACPU,gBAAgB,EAAED;QACpB,CAAC,CAAC;MACJ,CAAC,MAAM;QACLT,QAAQ,CAAC;UAAEW,OAAO,EAAEF;QAAE,CAAC,CAAC;MAC1B;IACF;EACF,CAAC,EAAE,CAACZ,KAAK,EAAEG,QAAQ,CAAC,CAAC;EAErB,OAAO;IAAEI,WAAW;IAAEL,KAAK;IAAEG;EAAK,CAAC;AACrC","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,24 +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(type, opts) {
20
+ export function useOsdkObjects(objectType, {
21
+ pageSize,
22
+ orderBy,
23
+ dedupeIntervalMs,
24
+ where = {},
25
+ streamUpdates
26
+ } = {}) {
21
27
  const {
22
- store
28
+ observableClient
23
29
  } = React.useContext(OsdkContext2);
24
- const where = store.canonicalizeWhereClause(opts.where);
30
+
31
+ /* We want the canonical where clause so that the use of `React.useMemo`
32
+ is stable. No real added cost as we canonicalize internal to
33
+ the ObservableClient anyway.
34
+ */
35
+ const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});
25
36
  const {
26
37
  subscribe,
27
38
  getSnapShot
28
- } = React.useMemo(() => makeExternalStore(x => store.observeList(type, where, {
29
- dedupeInterval: opts.dedupeIntervalMs ?? 2_000
30
- }, x), `list ${type.apiName} ${JSON.stringify(where)}`), [store, type, where, opts.dedupeIntervalMs]);
39
+ } = React.useMemo(() => makeExternalStore(x => observableClient.observeList({
40
+ objectType,
41
+ where: canonWhere,
42
+ dedupeInterval: dedupeIntervalMs ?? 2_000,
43
+ pageSize,
44
+ orderBy,
45
+ streamUpdates
46
+ }, x), process.env.NODE_ENV !== "production" ? `list ${objectType.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, objectType, canonWhere, dedupeIntervalMs]);
31
47
  const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);
48
+ // TODO: we need to expose the error in the result
32
49
  return {
33
50
  fetchMore: listPayload?.fetchMore,
34
51
  data: listPayload?.resolvedList,
35
52
  isLoading: listPayload?.status === "loading",
36
- error: undefined,
37
53
  isOptimistic: listPayload?.isOptimistic ?? false
38
54
  };
39
55
  }
40
- //# 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,12 +1,15 @@
1
1
  import type { ActionDefinition } from "@osdk/client";
2
2
  import { ActionValidationError } from "@osdk/client";
3
3
  import type { ActionSignatureFromDef, ObservableClient } from "@osdk/client/unstable-do-not-use";
4
+ type ApplyActionParams<Q extends ActionDefinition<any>> = Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0] & { [K in keyof ObservableClient.ApplyActionOptions as `$${K}`] : ObservableClient.ApplyActionOptions[K] };
4
5
  export interface UseOsdkActionResult<Q extends ActionDefinition<any>> {
5
- applyAction: (args: Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0], opts: ObservableClient.ApplyActionOptions) => Promise<unknown>;
6
+ applyAction: (args: ApplyActionParams<Q>) => Promise<unknown>;
6
7
  error: undefined | Partial<{
7
8
  actionValidation: ActionValidationError
8
9
  unknown: unknown
9
10
  }>;
10
11
  data: unknown;
12
+ isPending: boolean;
11
13
  }
12
14
  export declare function useOsdkAction<Q extends ActionDefinition<any>>(actionDef: Q): UseOsdkActionResult<Q>;
15
+ export {};
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,wBAAwB,cAAe;AACrD,SAAS,6BAA6B,cAAe;AACrD,cACE,wBACA,wBACK,kCAAmC;AAI1C,iBAAiB,oBAAoB,UAAU,uBAAuB;CACpE,cACEA,MAAM,WAAW,uBAAuB,GAAG,gBAAgB,IAC3DC,MAAM,iBAAiB,uBACpB;CAEL,mBAEI,QAAQ;EACR,kBAAkB;EAClB;CACD;CACH;AACD;AAED,OAAO,iBAAS,cAAc,UAAU,uBACtCC,WAAW,IACV,oBAAoB","names":["args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]","opts: ObservableClient.ApplyActionOptions","actionDef: Q"],"sources":["../../../src/new/useOsdkAction.ts"],"version":3,"file":"useOsdkAction.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,wBAAwB,cAAe;AACrD,SAAS,6BAA6B,cAAe;AACrD,cACE,wBACA,wBACK,kCAAmC;KAIrC,kBAAkB,UAAU,yBAC7B,WAAW,uBAAuB,GAAG,gBAAgB,QAEpD,WAAW,iBAAiB,0BAA0B,OACrD,iBAAiB,mBAAmB;AAG1C,iBAAiB,oBAAoB,UAAU,uBAAuB;CACpE,cACEA,MAAM,kBAAkB,OACrB;CAEL,mBAEI,QAAQ;EACR,kBAAkB;EAClB;CACD;CACH;CAEA;AACD;AAED,OAAO,iBAAS,cAAc,UAAU,uBACtCC,WAAW,IACV,oBAAoB","names":["args: ApplyActionParams<Q>","actionDef: Q"],"sources":["../../../src/new/useOsdkAction.ts"],"version":3,"file":"useOsdkAction.d.ts"}
@@ -0,0 +1,65 @@
1
+ import type { ObjectTypeDefinition, Osdk, PropertyKeys, WhereClause } from "@osdk/client";
2
+ export interface UseOsdkObjectsOptions<T extends ObjectTypeDefinition> {
3
+ /**
4
+ * Standard OSDK Where
5
+ */
6
+ where?: WhereClause<T>;
7
+ /**
8
+ * The preferred page size for the list.
9
+ */
10
+ pageSize?: number;
11
+ /** */
12
+ orderBy?: { [K in PropertyKeys<T>]? : "asc" | "desc" };
13
+ /**
14
+ * Causes the list to automatically fetch more as soon as the previous page
15
+ * has been loaded. If a number is provided, it will continue to automatically
16
+ * fetch more until the list is at least that long.
17
+ */
18
+ /**
19
+ * Upon a list being revalidated, this option determines how the component
20
+ * will be re-rendered with the data.
21
+ *
22
+ * An example to help understand the options:
23
+ *
24
+ * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is
25
+ * now 30 items long.
26
+ *
27
+ * Upon revalidation, we get the first 10 items of the list. The options behave
28
+ * as follows:
29
+ *
30
+ * - `"in-place"`: The first 10 items of the list are replaced with the new 10
31
+ * items. The list is now 30 items long, but only the first 10 items are valid.
32
+ * - `"wait"`: The old list is returned until after the next 20 items are loaded
33
+ * (which will happen automatically). The list is now 30 items long.
34
+ * - `"reset"`: The entire list is replaced with the new 10 items. The list is
35
+ * now 10 items long.
36
+ */
37
+ /**
38
+ * The number of milliseconds to wait after the last observed list change.
39
+ *
40
+ * Two uses of `useOsdkObjects` with the where clause will only trigger one
41
+ * network request if the second is within `dedupeIntervalMs`.
42
+ */
43
+ dedupeIntervalMs?: number;
44
+ /**
45
+ * If provided, the list will be considered this length for the purposes of
46
+ * `invalidationMode` when using the `wait` option. If not provided,
47
+ * the internal expectedLength will be determined by the number of times
48
+ * `fetchMore` has been called.
49
+ */
50
+ streamUpdates?: boolean;
51
+ }
52
+ export interface UseOsdkListResult<T extends ObjectTypeDefinition> {
53
+ fetchMore: (() => Promise<unknown>) | undefined;
54
+ data: Osdk.Instance<T>[] | undefined;
55
+ isLoading: boolean;
56
+ /**
57
+ * Refers to whether the ordered list of objects (only considering the $primaryKey)
58
+ * is optimistic or not.
59
+ *
60
+ * If you need to know if the contents of the list are optimistic you can
61
+ * do that on a per object basis with useOsdkObject
62
+ */
63
+ isOptimistic: boolean;
64
+ }
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.1",
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.1",
53
- "@osdk/client": "2.2.0-beta.1",
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"