@osdk/react 0.3.0-beta.3 → 0.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/build/browser/index.js +4 -0
  2. package/build/browser/index.js.map +1 -1
  3. package/build/browser/new/OsdkContext2.js +28 -0
  4. package/build/browser/new/OsdkContext2.js.map +1 -0
  5. package/build/browser/new/OsdkProvider2.js +31 -0
  6. package/build/browser/new/OsdkProvider2.js.map +1 -0
  7. package/build/browser/new/makeExternalStore.js +39 -0
  8. package/build/browser/new/makeExternalStore.js.map +1 -0
  9. package/build/browser/new/useOsdkAction.js +49 -0
  10. package/build/browser/new/useOsdkAction.js.map +1 -0
  11. package/build/browser/new/useOsdkList.js +40 -0
  12. package/build/browser/new/useOsdkList.js.map +1 -0
  13. package/build/browser/new/useOsdkObject.js +60 -0
  14. package/build/browser/new/useOsdkObject.js.map +1 -0
  15. package/build/browser/public/experimental.js +22 -0
  16. package/build/browser/public/experimental.js.map +1 -0
  17. package/build/cjs/chunk-2N32USW5.cjs +28 -0
  18. package/build/cjs/chunk-2N32USW5.cjs.map +1 -0
  19. package/build/cjs/index.cjs +6 -17
  20. package/build/cjs/index.cjs.map +1 -1
  21. package/build/cjs/index.d.cts +2 -3
  22. package/build/cjs/public/experimental.cjs +142 -0
  23. package/build/cjs/public/experimental.cjs.map +1 -0
  24. package/build/cjs/public/experimental.d.cts +71 -0
  25. package/build/cjs/useOsdkClient-B4iwHO1H.d.cts +5 -0
  26. package/build/esm/index.js +4 -0
  27. package/build/esm/index.js.map +1 -1
  28. package/build/esm/new/OsdkContext2.js +28 -0
  29. package/build/esm/new/OsdkContext2.js.map +1 -0
  30. package/build/esm/new/OsdkProvider2.js +31 -0
  31. package/build/esm/new/OsdkProvider2.js.map +1 -0
  32. package/build/esm/new/makeExternalStore.js +39 -0
  33. package/build/esm/new/makeExternalStore.js.map +1 -0
  34. package/build/esm/new/useOsdkAction.js +49 -0
  35. package/build/esm/new/useOsdkAction.js.map +1 -0
  36. package/build/esm/new/useOsdkList.js +40 -0
  37. package/build/esm/new/useOsdkList.js.map +1 -0
  38. package/build/esm/new/useOsdkObject.js +60 -0
  39. package/build/esm/new/useOsdkObject.js.map +1 -0
  40. package/build/esm/public/experimental.js +22 -0
  41. package/build/esm/public/experimental.js.map +1 -0
  42. package/build/types/OsdkContext.d.ts +3 -1
  43. package/build/types/OsdkContext.d.ts.map +1 -0
  44. package/build/types/OsdkProvider.d.ts +2 -2
  45. package/build/types/OsdkProvider.d.ts.map +1 -0
  46. package/build/types/index.d.ts +3 -0
  47. package/build/types/index.d.ts.map +1 -0
  48. package/build/types/new/OsdkContext2.d.ts +9 -0
  49. package/build/types/new/OsdkContext2.d.ts.map +1 -0
  50. package/build/types/new/OsdkProvider2.d.ts +10 -0
  51. package/build/types/new/OsdkProvider2.d.ts.map +1 -0
  52. package/build/types/new/makeExternalStore.d.ts +5 -0
  53. package/build/types/new/makeExternalStore.d.ts.map +1 -0
  54. package/build/types/new/useOsdkAction.d.ts +12 -0
  55. package/build/types/new/useOsdkAction.d.ts.map +1 -0
  56. package/build/types/new/useOsdkList.d.ts +26 -0
  57. package/build/types/new/useOsdkList.d.ts.map +1 -0
  58. package/build/types/new/useOsdkObject.d.ts +21 -0
  59. package/build/types/new/useOsdkObject.d.ts.map +1 -0
  60. package/build/types/public/experimental.d.ts +5 -0
  61. package/build/types/public/experimental.d.ts.map +1 -0
  62. package/build/types/useOsdkClient.d.ts.map +1 -0
  63. package/build/types/useOsdkMetadata.d.ts +2 -2
  64. package/build/types/useOsdkMetadata.d.ts.map +1 -0
  65. package/experimental.d.ts +17 -0
  66. package/package.json +16 -6
@@ -0,0 +1,71 @@
1
+ import { Client, ActionDefinition, ActionValidationError, ObjectTypeDefinition, WhereClause, Osdk } from '@osdk/client';
2
+ import { ObservableClient, ActionSignatureFromDef } from '@osdk/client/unstable-do-not-use';
3
+ import React from 'react';
4
+ import { ObjectTypeDefinition as ObjectTypeDefinition$1, Osdk as Osdk$1, PrimaryKeyType } from '@osdk/api';
5
+ export { u as useOsdkClient } from '../useOsdkClient-B4iwHO1H.cjs';
6
+
7
+ interface OsdkProviderOptions {
8
+ children: React.ReactNode;
9
+ client: Client;
10
+ store: ObservableClient;
11
+ }
12
+ declare function OsdkProvider2({ children, client, store, }: OsdkProviderOptions): React.JSX.Element;
13
+
14
+ interface UseOsdkActionResult<Q extends ActionDefinition<any>> {
15
+ applyAction: (args: Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0], opts: ObservableClient.ApplyActionOptions) => Promise<unknown>;
16
+ error: undefined | Partial<{
17
+ actionValidation: ActionValidationError;
18
+ unknown: unknown;
19
+ }>;
20
+ data: unknown;
21
+ }
22
+ declare function useOsdkAction<Q extends ActionDefinition<any>>(actionDef: Q): UseOsdkActionResult<Q>;
23
+
24
+ interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
25
+ where: WhereClause<T>;
26
+ /**
27
+ * The number of milliseconds to wait after the last observed list change.
28
+ *
29
+ * Two uses of `useOsdkList` with the where clause will only trigger one
30
+ * network request if the second is within `dedupeIntervalMs`.
31
+ */
32
+ dedupeIntervalMs?: number;
33
+ }
34
+ interface UseOsdkListResult<T extends ObjectTypeDefinition> {
35
+ fetchMore: (() => Promise<unknown>) | undefined;
36
+ data: Osdk.Instance<T>[];
37
+ isLoading: boolean;
38
+ error: undefined;
39
+ /**
40
+ * Refers to whether the ordered list of objects (only considering the $primaryKey)
41
+ * is optimistic or not.
42
+ *
43
+ * If you need to know if the contents of the list are optimistic you can
44
+ * do that on a per object basis with useOsdkObject
45
+ */
46
+ isOptimistic: boolean;
47
+ }
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>;
70
+
71
+ export { OsdkProvider2, useOsdkAction, useOsdkList, useOsdkObject };
@@ -0,0 +1,5 @@
1
+ import { Client } from '@osdk/client';
2
+
3
+ declare function useOsdkClient(): Client;
4
+
5
+ export { useOsdkClient as u };
@@ -14,6 +14,10 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
+ /**
18
+ * @module @osdk/react
19
+ */
20
+
17
21
  export { OsdkProvider } from "./OsdkProvider.js";
18
22
  export { useOsdkClient } from "./useOsdkClient.js";
19
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["OsdkProvider","useOsdkClient"],"sources":["index.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\nexport { OsdkProvider } from \"./OsdkProvider.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,YAAY,QAAQ,mBAAmB;AAChD,SAASC,aAAa,QAAQ,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["OsdkProvider","useOsdkClient"],"sources":["index.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\n/**\n * @module @osdk/react\n */\n\nexport { OsdkProvider } from \"./OsdkProvider.js\";\nexport { useOsdkClient } from \"./useOsdkClient.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,aAAa,QAAQ,oBAAoB","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React from "react";
18
+ function fakeClientFn(..._args) {
19
+ throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
20
+ }
21
+ const fakeClient = Object.assign(fakeClientFn, {
22
+ fetchMetadata: fakeClientFn
23
+ });
24
+ export const OsdkContext2 = /*#__PURE__*/React.createContext({
25
+ client: fakeClient,
26
+ store: undefined
27
+ });
28
+ //# sourceMappingURL=OsdkContext2.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React from "react";
18
+ import { OsdkContext2 } from "./OsdkContext2.js";
19
+ export function OsdkProvider2({
20
+ children,
21
+ client,
22
+ store
23
+ }) {
24
+ return /*#__PURE__*/React.createElement(OsdkContext2.Provider, {
25
+ value: {
26
+ client,
27
+ store
28
+ }
29
+ }, children);
30
+ }
31
+ //# sourceMappingURL=OsdkProvider2.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export function makeExternalStore(createObservation, name) {
18
+ let lastResult;
19
+ function getSnapShot() {
20
+ return lastResult;
21
+ }
22
+ return {
23
+ subscribe: function subscribe(notifyUpdate) {
24
+ // eslint-disable-next-line no-console
25
+ console.log("Subscribing", name);
26
+ const obs = createObservation(payload => {
27
+ lastResult = payload;
28
+ notifyUpdate();
29
+ });
30
+ return () => {
31
+ // eslint-disable-next-line no-console
32
+ console.log("Unsubscribing", name);
33
+ obs.unsubscribe();
34
+ };
35
+ },
36
+ getSnapShot
37
+ };
38
+ }
39
+ //# sourceMappingURL=makeExternalStore.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { ActionValidationError } from "@osdk/client";
18
+ import React from "react";
19
+ import { OsdkContext2 } from "./OsdkContext2.js";
20
+ export function useOsdkAction(actionDef) {
21
+ const {
22
+ store
23
+ } = React.useContext(OsdkContext2);
24
+ const [error, setError] = React.useState();
25
+ const [data, setData] = React.useState();
26
+ const applyAction = React.useCallback(async function (args, opts) {
27
+ try {
28
+ const r = await store.applyAction(actionDef, args, opts);
29
+ setData(r);
30
+ return r;
31
+ } catch (e) {
32
+ if (e instanceof ActionValidationError) {
33
+ setError({
34
+ actionValidation: e
35
+ });
36
+ } else {
37
+ setError({
38
+ unknown: e
39
+ });
40
+ }
41
+ }
42
+ }, [store, setError]);
43
+ return {
44
+ applyAction,
45
+ error,
46
+ data
47
+ };
48
+ }
49
+ //# sourceMappingURL=useOsdkAction.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React from "react";
18
+ import { makeExternalStore } from "./makeExternalStore.js";
19
+ import { OsdkContext2 } from "./OsdkContext2.js";
20
+ export function useOsdkList(type, opts) {
21
+ const {
22
+ store
23
+ } = React.useContext(OsdkContext2);
24
+ const where = store.canonicalizeWhereClause(opts.where);
25
+ const {
26
+ subscribe,
27
+ 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]);
31
+ const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);
32
+ return {
33
+ fetchMore: listPayload?.fetchMore,
34
+ data: listPayload?.resolvedList,
35
+ isLoading: listPayload?.status === "loading",
36
+ error: undefined,
37
+ isOptimistic: listPayload?.isOptimistic ?? false
38
+ };
39
+ }
40
+ //# sourceMappingURL=useOsdkList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkList.js","names":["React","makeExternalStore","OsdkContext2","useOsdkList","type","opts","store","useContext","where","canonicalizeWhereClause","subscribe","getSnapShot","useMemo","x","observeList","dedupeInterval","dedupeIntervalMs","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 { ObjectTypeDefinition, Osdk, WhereClause } 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 where: WhereClause<T>;\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}\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\nexport function useOsdkList<T extends ObjectTypeDefinition>(\n type: T,\n opts: UseOsdkListOptions<T>,\n): UseOsdkListResult<T> {\n const { store } = React.useContext(OsdkContext2);\n const where = store.canonicalizeWhereClause(opts.where);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ListPayload>((x) =>\n store.observeList(\n type,\n where,\n {\n dedupeInterval: opts.dedupeIntervalMs ?? 2_000,\n },\n x,\n ), `list ${type.apiName} ${JSON.stringify(where)}`),\n [store, type, where, opts.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;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AA+BhD,OAAO,SAASC,WAAWA,CACzBC,IAAO,EACPC,IAA2B,EACL;EACtB,MAAM;IAAEC;EAAM,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,YAAY,CAAC;EAChD,MAAMM,KAAK,GAAGF,KAAK,CAACG,uBAAuB,CAACJ,IAAI,CAACG,KAAK,CAAC;EAEvD,MAAM;IAAEE,SAAS;IAAEC;EAAY,CAAC,GAAGX,KAAK,CAACY,OAAO,CAC9C,MACEX,iBAAiB,CAAeY,CAAC,IAC/BP,KAAK,CAACQ,WAAW,CACfV,IAAI,EACJI,KAAK,EACL;IACEO,cAAc,EAAEV,IAAI,CAACW,gBAAgB,IAAI;EAC3C,CAAC,EACDH,CACF,CAAC,EAAE,QAAQT,IAAI,CAACa,OAAO,IAAIC,IAAI,CAACC,SAAS,CAACX,KAAK,CAAC,EAAE,CAAC,EACvD,CAACF,KAAK,EAAEF,IAAI,EAAEI,KAAK,EAAEH,IAAI,CAACW,gBAAgB,CAC5C,CAAC;EAED,MAAMI,WAAW,GAAGpB,KAAK,CAACqB,oBAAoB,CAACX,SAAS,EAAEC,WAAW,CAAC;EAEtE,OAAO;IACLW,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":[]}
@@ -0,0 +1,60 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React from "react";
18
+ import { makeExternalStore } from "./makeExternalStore.js";
19
+ import { OsdkContext2 } from "./OsdkContext2.js";
20
+
21
+ /**
22
+ * @param obj an existing `Osdk.Instance` object to get metadata for.
23
+ */
24
+
25
+ /**
26
+ * Loads an object by type and primary key.
27
+ *
28
+ * @param type
29
+ * @param primaryKey
30
+ */
31
+
32
+ /*
33
+ Implementation of useOsdkObject
34
+ */
35
+ export function useOsdkObject(...args) {
36
+ const {
37
+ store
38
+ } = React.useContext(OsdkContext2);
39
+
40
+ // TODO: Figure out what the correct default behavior is for the various scenarios
41
+ const mode = args.length === 1 ? "offline" : undefined;
42
+ const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;
43
+ const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];
44
+ const {
45
+ subscribe,
46
+ getSnapShot
47
+ } = React.useMemo(() => makeExternalStore(payload => store.observeObject(objectType, primaryKey, {
48
+ mode
49
+ }, payload), `object ${objectType} ${primaryKey}`), [store, objectType, primaryKey, mode]);
50
+ const payload = React.useSyncExternalStore(subscribe, getSnapShot);
51
+ return {
52
+ object: payload?.object,
53
+ isLoading: payload?.status === "loading",
54
+ isOptimistic: payload?.isOptimistic ?? false,
55
+ forceUpdate: () => {
56
+ throw "not implemented";
57
+ }
58
+ };
59
+ }
60
+ //# sourceMappingURL=useOsdkObject.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export { OsdkProvider2 } from "../new/OsdkProvider2.js";
18
+ export { useOsdkAction } from "../new/useOsdkAction.js";
19
+ export { useOsdkList } from "../new/useOsdkList.js";
20
+ export { useOsdkObject } from "../new/useOsdkObject.js";
21
+ export { useOsdkClient } from "../useOsdkClient.js";
22
+ //# sourceMappingURL=experimental.js.map
@@ -0,0 +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,3 +1,5 @@
1
1
  import type { Client } from "@osdk/client";
2
2
  import React from "react";
3
- export declare const OsdkContext: React.Context<{ client: Client }>;
3
+ export declare const OsdkContext: React.Context<{
4
+ client: Client
5
+ }>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,cAAc,cAAe;AAC3C,OAAO,WAAW,OAAQ;AAY1B,OAAO,cAAMA,aAAa,MAAM,QAAQ;CACtC,QAAQ;AACT","names":["OsdkContext: React.Context<{\n client: Client;\n}>"],"sources":["../../src/OsdkContext.ts"],"version":3,"file":"OsdkContext.d.ts"}
@@ -1,6 +1,6 @@
1
1
  import type { Client } from "@osdk/client";
2
2
  import React from "react";
3
3
  export declare function OsdkProvider({ children, client }: {
4
- children: React.ReactNode;
5
- client: Client;
4
+ children: React.ReactNode
5
+ client: Client
6
6
  }): React.JSX.Element;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,cAAc,cAAe;AAC3C,OAAO,WAAW,OAAQ;AAG1B,OAAO,iBAAS,aAAa,EAC3B,UACA,QAID,EAHE;CACD,UAAU,MAAM;CAChB,QAAQ;AACT,IAAG,MAAM,IAAI","names":[],"sources":["../../src/OsdkProvider.tsx"],"version":3,"file":"OsdkProvider.d.ts"}
@@ -1,2 +1,5 @@
1
+ /**
2
+ * @module @osdk/react
3
+ */
1
4
  export { OsdkProvider } from "./OsdkProvider.js";
2
5
  export { useOsdkClient } from "./useOsdkClient.js";
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAoBA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB","names":[],"sources":["../../src/index.ts"],"version":3,"file":"index.d.ts"}
@@ -0,0 +1,9 @@
1
+ import type { Client } from "@osdk/client";
2
+ import type { ObservableClient } from "@osdk/client/unstable-do-not-use";
3
+ import React from "react";
4
+ interface OsdkContextContents {
5
+ client: Client;
6
+ store: ObservableClient;
7
+ }
8
+ export declare const OsdkContext2: React.Context<OsdkContextContents>;
9
+ export {};
@@ -0,0 +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"}
@@ -0,0 +1,10 @@
1
+ import type { Client } from "@osdk/client";
2
+ import type { ObservableClient } from "@osdk/client/unstable-do-not-use";
3
+ import React from "react";
4
+ interface OsdkProviderOptions {
5
+ children: React.ReactNode;
6
+ client: Client;
7
+ store: ObservableClient;
8
+ }
9
+ export declare function OsdkProvider2({ children, client, store }: OsdkProviderOptions): React.JSX.Element;
10
+ export {};
@@ -0,0 +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"}
@@ -0,0 +1,5 @@
1
+ import type { Unsubscribable } from "@osdk/client/unstable-do-not-use";
2
+ export declare function makeExternalStore<X>(createObservation: (callback: (x: X | undefined) => void) => Unsubscribable, name?: string): {
3
+ subscribe: (notifyUpdate: () => void) => () => void
4
+ getSnapShot: () => X | undefined
5
+ };
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,sBAAsB,kCAAmC;AAEvE,OAAO,iBAAS,kBAAkB,GAChCA,oBAAoBC,WAAWC,GAAG,2BAA2B,gBAC7DC,gBACC;CACD,YAAYC;CACZ,mBAAmB;AACpB","names":["createObservation: (callback: (x: X | undefined) => void) => Unsubscribable","callback: (x: X | undefined) => void","x: X | undefined","name?: string","notifyUpdate: () => void"],"sources":["../../../src/new/makeExternalStore.ts"],"version":3,"file":"makeExternalStore.d.ts"}
@@ -0,0 +1,12 @@
1
+ import type { ActionDefinition } from "@osdk/client";
2
+ import { ActionValidationError } from "@osdk/client";
3
+ import type { ActionSignatureFromDef, ObservableClient } from "@osdk/client/unstable-do-not-use";
4
+ export interface UseOsdkActionResult<Q extends ActionDefinition<any>> {
5
+ applyAction: (args: Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0], opts: ObservableClient.ApplyActionOptions) => Promise<unknown>;
6
+ error: undefined | Partial<{
7
+ actionValidation: ActionValidationError
8
+ unknown: unknown
9
+ }>;
10
+ data: unknown;
11
+ }
12
+ export declare function useOsdkAction<Q extends ActionDefinition<any>>(actionDef: Q): UseOsdkActionResult<Q>;
@@ -0,0 +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"}
@@ -0,0 +1,26 @@
1
+ import type { ObjectTypeDefinition, Osdk, WhereClause } from "@osdk/client";
2
+ export interface UseOsdkListOptions<T extends ObjectTypeDefinition> {
3
+ where: WhereClause<T>;
4
+ /**
5
+ * The number of milliseconds to wait after the last observed list change.
6
+ *
7
+ * Two uses of `useOsdkList` with the where clause will only trigger one
8
+ * network request if the second is within `dedupeIntervalMs`.
9
+ */
10
+ dedupeIntervalMs?: number;
11
+ }
12
+ export interface UseOsdkListResult<T extends ObjectTypeDefinition> {
13
+ fetchMore: (() => Promise<unknown>) | undefined;
14
+ data: Osdk.Instance<T>[];
15
+ isLoading: boolean;
16
+ error: undefined;
17
+ /**
18
+ * Refers to whether the ordered list of objects (only considering the $primaryKey)
19
+ * is optimistic or not.
20
+ *
21
+ * If you need to know if the contents of the list are optimistic you can
22
+ * do that on a per object basis with useOsdkObject
23
+ */
24
+ isOptimistic: boolean;
25
+ }
26
+ export declare function useOsdkList<T extends ObjectTypeDefinition>(type: T, opts: UseOsdkListOptions<T>): UseOsdkListResult<T>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,sBAAsB,MAAM,mBAAmB,cAAe;AAM5E,iBAAiB,mBAAmB,UAAU,sBAAsB;CAClE,OAAO,YAAY;;;;;;;CAQnB;AACD;AACD,iBAAiB,kBAAkB,UAAU,sBAAsB;CACjE,kBAAkB;CAClB,MAAM,KAAK,SAAS;CACpB;CAGA;;;;;;;;CASA;AACD;AAED,OAAO,iBAAS,YAAY,UAAU,sBACpCA,MAAM,GACNC,MAAM,mBAAmB,KACxB,kBAAkB","names":["type: T","opts: UseOsdkListOptions<T>"],"sources":["../../../src/new/useOsdkList.ts"],"version":3,"file":"useOsdkList.d.ts"}
@@ -0,0 +1,21 @@
1
+ import type { ObjectTypeDefinition, Osdk, PrimaryKeyType } from "@osdk/api";
2
+ export interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {
3
+ object: Osdk.Instance<Q> | undefined;
4
+ isLoading: boolean;
5
+ /**
6
+ * Refers to whether the object is optimistic or not.
7
+ */
8
+ isOptimistic: boolean;
9
+ forceUpdate: () => void;
10
+ }
11
+ /**
12
+ * @param obj an existing `Osdk.Instance` object to get metadata for.
13
+ */
14
+ export declare function useOsdkObject<Q extends ObjectTypeDefinition>(obj: Osdk.Instance<Q>): UseOsdkObjectResult<Q>;
15
+ /**
16
+ * Loads an object by type and primary key.
17
+ *
18
+ * @param type
19
+ * @param primaryKey
20
+ */
21
+ export declare function useOsdkObject<Q extends ObjectTypeDefinition>(type: Q, primaryKey: PrimaryKeyType<Q>): UseOsdkObjectResult<Q>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,sBAAsB,MAAM,sBAAsB,WAAY;AAM5E,iBAAiB,oBAAoB,UAAU,sBAAsB;CACnE,QAAQ,KAAK,SAAS;CACtB;;;;CAKA;CACA;AACD;;;;AAKD,OAAO,iBAAS,cAAc,UAAU,sBACtCA,KAAK,KAAK,SAAS,KAClB,oBAAoB;;;;;;;AAOvB,OAAO,iBAAS,cAAc,UAAU,sBACtCC,MAAM,GACNC,YAAY,eAAe,KAC1B,oBAAoB","names":["obj: Osdk.Instance<Q>","type: Q","primaryKey: PrimaryKeyType<Q>"],"sources":["../../../src/new/useOsdkObject.ts"],"version":3,"file":"useOsdkObject.d.ts"}
@@ -0,0 +1,5 @@
1
+ export { OsdkProvider2 } from "../new/OsdkProvider2.js";
2
+ export { useOsdkAction } from "../new/useOsdkAction.js";
3
+ export { useOsdkList } from "../new/useOsdkList.js";
4
+ export { useOsdkObject } from "../new/useOsdkObject.js";
5
+ export { useOsdkClient } from "../useOsdkClient.js";
@@ -0,0 +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"}
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAAc,cAAc,cAAe;AAI3C,OAAO,iBAAS,iBAAiB","names":[],"sources":["../../src/useOsdkClient.ts"],"version":3,"file":"useOsdkClient.d.ts"}
@@ -1,7 +1,7 @@
1
1
  import type { InterfaceDefinition, InterfaceMetadata, ObjectMetadata, ObjectOrInterfaceDefinition, ObjectTypeDefinition } from "@osdk/api";
2
2
  type MetadataFor<T extends ObjectOrInterfaceDefinition> = T extends InterfaceDefinition ? InterfaceMetadata : T extends ObjectTypeDefinition ? ObjectMetadata : never;
3
3
  export declare function useOsdkMetadata<T extends ObjectOrInterfaceDefinition>(type: T): {
4
- loading: boolean;
5
- metadata?: MetadataFor<T>;
4
+ loading: boolean
5
+ metadata?: MetadataFor<T>
6
6
  };
7
7
  export {};
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cACE,qBACA,mBACA,gBACA,6BACA,4BACK,WAAY;KAId,YAAY,UAAU,+BAA+B,UACxD,sBAAsB,oBACpB,UAAU,uBAAuB;AAGrC,OAAO,iBAAS,gBAAgB,UAAU,6BACxCA,MAAM,IACL;CACD;CACA,WAAW,YAAY;AACxB","names":["type: T"],"sources":["../../src/useOsdkMetadata.ts"],"version":3,"file":"useOsdkMetadata.d.ts"}