@osdk/react 0.3.0-beta.2 → 0.3.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/build/browser/OsdkContext.js +2 -1
- package/build/browser/OsdkContext.js.map +1 -1
- package/build/browser/OsdkProvider.js +2 -1
- package/build/browser/OsdkProvider.js.map +1 -1
- package/build/browser/index.js +5 -0
- package/build/browser/index.js.map +1 -1
- package/build/browser/new/OsdkContext2.js +28 -0
- package/build/browser/new/OsdkContext2.js.map +1 -0
- package/build/browser/new/OsdkProvider2.js +31 -0
- package/build/browser/new/OsdkProvider2.js.map +1 -0
- package/build/browser/new/makeExternalStore.js +39 -0
- package/build/browser/new/makeExternalStore.js.map +1 -0
- package/build/browser/new/useOsdkAction.js +49 -0
- package/build/browser/new/useOsdkAction.js.map +1 -0
- package/build/browser/new/useOsdkList.js +40 -0
- package/build/browser/new/useOsdkList.js.map +1 -0
- package/build/browser/new/useOsdkObject.js +60 -0
- package/build/browser/new/useOsdkObject.js.map +1 -0
- package/build/browser/public/experimental.js +22 -0
- package/build/browser/public/experimental.js.map +1 -0
- package/build/browser/useOsdkClient.js +1 -0
- package/build/browser/useOsdkClient.js.map +1 -1
- package/build/browser/useOsdkMetadata.js +1 -0
- package/build/browser/useOsdkMetadata.js.map +1 -1
- package/build/cjs/chunk-2N32USW5.cjs +28 -0
- package/build/cjs/chunk-2N32USW5.cjs.map +1 -0
- package/build/cjs/index.cjs +27 -0
- package/build/cjs/index.cjs.map +1 -0
- package/build/cjs/index.d.cts +10 -0
- package/build/cjs/public/experimental.cjs +142 -0
- package/build/cjs/public/experimental.cjs.map +1 -0
- package/build/cjs/public/experimental.d.cts +71 -0
- package/build/cjs/useOsdkClient-B4iwHO1H.d.cts +5 -0
- package/build/esm/OsdkContext.js +2 -1
- package/build/esm/OsdkContext.js.map +1 -1
- package/build/esm/OsdkProvider.js +2 -1
- package/build/esm/OsdkProvider.js.map +1 -1
- package/build/esm/index.js +5 -0
- package/build/esm/index.js.map +1 -1
- package/build/esm/new/OsdkContext2.js +28 -0
- package/build/esm/new/OsdkContext2.js.map +1 -0
- package/build/esm/new/OsdkProvider2.js +31 -0
- package/build/esm/new/OsdkProvider2.js.map +1 -0
- package/build/esm/new/makeExternalStore.js +39 -0
- package/build/esm/new/makeExternalStore.js.map +1 -0
- package/build/esm/new/useOsdkAction.js +49 -0
- package/build/esm/new/useOsdkAction.js.map +1 -0
- package/build/esm/new/useOsdkList.js +40 -0
- package/build/esm/new/useOsdkList.js.map +1 -0
- package/build/esm/new/useOsdkObject.js +60 -0
- package/build/esm/new/useOsdkObject.js.map +1 -0
- package/build/esm/public/experimental.js +22 -0
- package/build/esm/public/experimental.js.map +1 -0
- package/build/esm/useOsdkClient.js +1 -0
- package/build/esm/useOsdkClient.js.map +1 -1
- package/build/esm/useOsdkMetadata.js +1 -0
- package/build/esm/useOsdkMetadata.js.map +1 -1
- package/build/{browser → types}/OsdkContext.d.ts +1 -2
- package/build/types/OsdkContext.d.ts.map +1 -0
- package/build/types/OsdkProvider.d.ts +6 -0
- package/build/types/OsdkProvider.d.ts.map +1 -0
- package/build/{browser → types}/index.d.ts +3 -1
- package/build/types/index.d.ts.map +1 -0
- package/build/types/new/OsdkContext2.d.ts +9 -0
- package/build/types/new/OsdkContext2.d.ts.map +1 -0
- package/build/types/new/OsdkProvider2.d.ts +10 -0
- package/build/types/new/OsdkProvider2.d.ts.map +1 -0
- package/build/types/new/makeExternalStore.d.ts +5 -0
- package/build/types/new/makeExternalStore.d.ts.map +1 -0
- package/build/types/new/useOsdkAction.d.ts +12 -0
- package/build/types/new/useOsdkAction.d.ts.map +1 -0
- package/build/types/new/useOsdkList.d.ts +26 -0
- package/build/types/new/useOsdkList.d.ts.map +1 -0
- package/build/types/new/useOsdkObject.d.ts +21 -0
- package/build/types/new/useOsdkObject.d.ts.map +1 -0
- package/build/types/public/experimental.d.ts +5 -0
- package/build/types/public/experimental.d.ts.map +1 -0
- package/build/{browser → types}/useOsdkClient.d.ts +0 -1
- package/build/types/useOsdkClient.d.ts.map +1 -0
- package/build/{browser → types}/useOsdkMetadata.d.ts +2 -3
- package/build/types/useOsdkMetadata.d.ts.map +1 -0
- package/experimental.d.ts +17 -0
- package/package.json +34 -11
- package/build/browser/OsdkContext.d.ts.map +0 -1
- package/build/browser/OsdkProvider.d.ts +0 -7
- package/build/browser/OsdkProvider.d.ts.map +0 -1
- package/build/browser/index.d.ts.map +0 -1
- package/build/browser/useOsdkClient.d.ts.map +0 -1
- package/build/browser/useOsdkMetadata.d.ts.map +0 -1
- package/build/esm/OsdkContext.d.ts +0 -6
- package/build/esm/OsdkContext.d.ts.map +0 -1
- package/build/esm/OsdkProvider.d.ts +0 -7
- package/build/esm/OsdkProvider.d.ts.map +0 -1
- package/build/esm/index.d.ts +0 -3
- package/build/esm/index.d.ts.map +0 -1
- package/build/esm/useOsdkClient.d.ts +0 -3
- package/build/esm/useOsdkClient.d.ts.map +0 -1
- package/build/esm/useOsdkMetadata.d.ts +0 -8
- package/build/esm/useOsdkMetadata.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @osdkkit/react
|
|
2
2
|
|
|
3
|
+
## 0.3.0-rc.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 66a8ee4: Adding support for react caching work.
|
|
8
|
+
|
|
9
|
+
## 0.3.0-beta.3
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- c691c8b: Package now has experimental support for commonjs
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [03f95eb]
|
|
18
|
+
- Updated dependencies [c691c8b]
|
|
19
|
+
- Updated dependencies [3c9ac22]
|
|
20
|
+
- @osdk/client@2.1.0-beta.24
|
|
21
|
+
- @osdk/api@2.1.0-beta.24
|
|
22
|
+
|
|
3
23
|
## 0.3.0-beta.2
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
|
|
16
17
|
import React from "react";
|
|
17
18
|
function fakeClientFn(..._args) {
|
|
18
19
|
throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
|
|
@@ -20,7 +21,7 @@ function fakeClientFn(..._args) {
|
|
|
20
21
|
const fakeClient = Object.assign(fakeClientFn, {
|
|
21
22
|
fetchMetadata: fakeClientFn
|
|
22
23
|
});
|
|
23
|
-
export const OsdkContext = React.createContext({
|
|
24
|
+
export const OsdkContext = /*#__PURE__*/React.createContext({
|
|
24
25
|
client: fakeClient
|
|
25
26
|
});
|
|
26
27
|
//# sourceMappingURL=OsdkContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OsdkContext.js","names":["React","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","OsdkContext","createContext","client"],"sources":["OsdkContext.
|
|
1
|
+
{"version":3,"file":"OsdkContext.js","names":["React","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","OsdkContext","createContext","client"],"sources":["OsdkContext.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 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\nexport const OsdkContext: React.Context<{\n client: Client;\n}> = React.createContext<{ client: Client }>({\n client: fakeClient,\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,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;AAEZ,OAAO,MAAMO,WAEX,gBAAGR,KAAK,CAACS,aAAa,CAAqB;EAC3CC,MAAM,EAAEN;AACV,CAAC,CAAC","ignoreList":[]}
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
|
|
16
17
|
import React from "react";
|
|
17
18
|
import { OsdkContext } from "./OsdkContext.js";
|
|
18
19
|
export function OsdkProvider({
|
|
19
20
|
children,
|
|
20
21
|
client
|
|
21
22
|
}) {
|
|
22
|
-
return React.createElement(OsdkContext.Provider, {
|
|
23
|
+
return /*#__PURE__*/React.createElement(OsdkContext.Provider, {
|
|
23
24
|
value: {
|
|
24
25
|
client
|
|
25
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OsdkProvider.js","names":["React","OsdkContext","OsdkProvider","children","client","createElement","Provider","value"],"sources":["OsdkProvider.
|
|
1
|
+
{"version":3,"file":"OsdkProvider.js","names":["React","OsdkContext","OsdkProvider","children","client","createElement","Provider","value"],"sources":["OsdkProvider.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 React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\n\nexport function OsdkProvider({\n children,\n client,\n}: {\n children: React.ReactNode;\n client: Client;\n}): React.JSX.Element {\n return (\n <OsdkContext.Provider value={{ client }}>{children}</OsdkContext.Provider>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,OAAO,SAASC,YAAYA,CAAC;EAC3BC,QAAQ;EACRC;AAIF,CAAC,EAAqB;EACpB,oBACEJ,KAAA,CAAAK,aAAA,CAACJ,WAAW,CAACK,QAAQ;IAACC,KAAK,EAAE;MAAEH;IAAO;EAAE,GAAED,QAA+B,CAAC;AAE9E","ignoreList":[]}
|
package/build/browser/index.js
CHANGED
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @module @osdk/react
|
|
19
|
+
*/
|
|
20
|
+
|
|
16
21
|
export { OsdkProvider } from "./OsdkProvider.js";
|
|
17
22
|
export { useOsdkClient } from "./useOsdkClient.js";
|
|
18
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["OsdkProvider","useOsdkClient"],"sources":["index.
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkClient.js","names":["React","OsdkContext","useOsdkClient","useContext","client"],"sources":["useOsdkClient.
|
|
1
|
+
{"version":3,"file":"useOsdkClient.js","names":["React","OsdkContext","useOsdkClient","useContext","client"],"sources":["useOsdkClient.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 React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\n\nexport function useOsdkClient(): Client {\n return React.useContext(OsdkContext).client;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,OAAO,SAASC,aAAaA,CAAA,EAAW;EACtC,OAAOF,KAAK,CAACG,UAAU,CAACF,WAAW,CAAC,CAACG,MAAM;AAC7C","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkMetadata.js","names":["React","useOsdkClient","useOsdkMetadata","type","client","metadata","setMetadata","useState","undefined","fetchMetadata","then","fetchedMetadata","catch","error","console","loading"],"sources":["useOsdkMetadata.
|
|
1
|
+
{"version":3,"file":"useOsdkMetadata.js","names":["React","useOsdkClient","useOsdkMetadata","type","client","metadata","setMetadata","useState","undefined","fetchMetadata","then","fetchedMetadata","catch","error","console","loading"],"sources":["useOsdkMetadata.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 {\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n} from \"@osdk/api\";\nimport React from \"react\";\nimport { useOsdkClient } from \"./useOsdkClient.js\";\n\ntype MetadataFor<T extends ObjectOrInterfaceDefinition> = T extends\n InterfaceDefinition ? InterfaceMetadata\n : T extends ObjectTypeDefinition ? ObjectMetadata\n : never;\n\nexport function useOsdkMetadata<T extends ObjectOrInterfaceDefinition>(\n type: T,\n): {\n loading: boolean;\n metadata?: MetadataFor<T>;\n} {\n const client = useOsdkClient();\n const [metadata, setMetadata] = React.useState<\n MetadataFor<T> | undefined\n >(undefined);\n\n if (!metadata) {\n client.fetchMetadata(type).then((fetchedMetadata) => {\n setMetadata(fetchedMetadata as MetadataFor<T>);\n }).catch((error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\"Failed to fetch metadata\", error);\n });\n return { loading: true };\n }\n\n return { loading: false, metadata };\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,aAAa,QAAQ,oBAAoB;AAOlD,OAAO,SAASC,eAAeA,CAC7BC,IAAO,EAIP;EACA,MAAMC,MAAM,GAAGH,aAAa,CAAC,CAAC;EAC9B,MAAM,CAACI,QAAQ,EAAEC,WAAW,CAAC,GAAGN,KAAK,CAACO,QAAQ,CAE5CC,SAAS,CAAC;EAEZ,IAAI,CAACH,QAAQ,EAAE;IACbD,MAAM,CAACK,aAAa,CAACN,IAAI,CAAC,CAACO,IAAI,CAAEC,eAAe,IAAK;MACnDL,WAAW,CAACK,eAAiC,CAAC;IAChD,CAAC,CAAC,CAACC,KAAK,CAAEC,KAAc,IAAK;MAC3B;MACAC,OAAO,CAACD,KAAK,CAAC,0BAA0B,EAAEA,KAAK,CAAC;IAClD,CAAC,CAAC;IACF,OAAO;MAAEE,OAAO,EAAE;IAAK,CAAC;EAC1B;EAEA,OAAO;IAAEA,OAAO,EAAE,KAAK;IAAEV;EAAS,CAAC;AACrC","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
8
|
+
|
|
9
|
+
// src/useOsdkClient.ts
|
|
10
|
+
function fakeClientFn(..._args) {
|
|
11
|
+
throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
|
|
12
|
+
}
|
|
13
|
+
var fakeClient = Object.assign(fakeClientFn, {
|
|
14
|
+
fetchMetadata: fakeClientFn
|
|
15
|
+
});
|
|
16
|
+
var OsdkContext = /* @__PURE__ */ React__default.default.createContext({
|
|
17
|
+
client: fakeClient
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// src/useOsdkClient.ts
|
|
21
|
+
function useOsdkClient() {
|
|
22
|
+
return React__default.default.useContext(OsdkContext).client;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.OsdkContext = OsdkContext;
|
|
26
|
+
exports.useOsdkClient = useOsdkClient;
|
|
27
|
+
//# sourceMappingURL=chunk-2N32USW5.cjs.map
|
|
28
|
+
//# sourceMappingURL=chunk-2N32USW5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/OsdkContext.ts","../../src/useOsdkClient.ts"],"names":["React"],"mappings":";;;;;;;;;AAiBA,SAAS,gBAAgB,KAAO,EAAA;AAC9B,EAAM,MAAA,IAAI,MAAM,sEAAsE,CAAA;AACxF;AACA,IAAM,UAAA,GAAa,MAAO,CAAA,MAAA,CAAO,YAAc,EAAA;AAAA,EAC7C,aAAe,EAAA;AACjB,CAAC,CAAA;AACY,IAAA,WAAA,0CAAiC,aAAc,CAAA;AAAA,EAC1D,MAAQ,EAAA;AACV,CAAC;;;ACPM,SAAS,aAAgB,GAAA;AAC9B,EAAOA,OAAAA,sBAAAA,CAAM,UAAW,CAAA,WAAW,CAAE,CAAA,MAAA;AACvC","file":"chunk-2N32USW5.cjs","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nfunction fakeClientFn(..._args) {\n throw new Error(\"This is not a real client. Did you forget to <OsdkContext.Provider>?\");\n}\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn\n});\nexport const OsdkContext = /*#__PURE__*/React.createContext({\n client: fakeClient\n});","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nexport function useOsdkClient() {\n return React.useContext(OsdkContext).client;\n}"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk2N32USW5_cjs = require('./chunk-2N32USW5.cjs');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
9
|
+
|
|
10
|
+
function OsdkProvider({
|
|
11
|
+
children,
|
|
12
|
+
client
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ React__default.default.createElement(chunk2N32USW5_cjs.OsdkContext.Provider, {
|
|
15
|
+
value: {
|
|
16
|
+
client
|
|
17
|
+
}
|
|
18
|
+
}, children);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Object.defineProperty(exports, "useOsdkClient", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunk2N32USW5_cjs.useOsdkClient; }
|
|
24
|
+
});
|
|
25
|
+
exports.OsdkProvider = OsdkProvider;
|
|
26
|
+
//# sourceMappingURL=index.cjs.map
|
|
27
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/OsdkProvider.tsx"],"names":["React","OsdkContext"],"mappings":";;;;;;;;;AAkBO,SAAS,YAAa,CAAA;AAAA,EAC3B,QAAA;AAAA,EACA;AACF,CAAG,EAAA;AACD,EAAoB,uBAAAA,sBAAA,CAAM,aAAc,CAAAC,6BAAA,CAAY,QAAU,EAAA;AAAA,IAC5D,KAAO,EAAA;AAAA,MACL;AAAA;AACF,KACC,QAAQ,CAAA;AACb","file":"index.cjs","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nexport function OsdkProvider({\n children,\n client\n}) {\n return /*#__PURE__*/React.createElement(OsdkContext.Provider, {\n value: {\n client\n }\n }, children);\n}"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Client } from '@osdk/client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export { u as useOsdkClient } from './useOsdkClient-B4iwHO1H.cjs';
|
|
4
|
+
|
|
5
|
+
declare function OsdkProvider({ children, client, }: {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
client: Client;
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { OsdkProvider };
|