@osdk/react 0.2.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 (42) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/build/browser/OsdkContext.d.ts +6 -0
  3. package/build/browser/OsdkContext.d.ts.map +1 -0
  4. package/build/browser/OsdkContext.js +26 -0
  5. package/build/browser/OsdkContext.js.map +1 -0
  6. package/build/browser/OsdkProvider.d.ts +7 -0
  7. package/build/browser/OsdkProvider.d.ts.map +1 -0
  8. package/build/browser/OsdkProvider.js +28 -0
  9. package/build/browser/OsdkProvider.js.map +1 -0
  10. package/build/browser/index.d.ts +3 -0
  11. package/build/browser/index.d.ts.map +1 -0
  12. package/build/browser/index.js +18 -0
  13. package/build/browser/index.js.map +1 -0
  14. package/build/browser/useOsdkClient.d.ts +3 -0
  15. package/build/browser/useOsdkClient.d.ts.map +1 -0
  16. package/build/browser/useOsdkClient.js +21 -0
  17. package/build/browser/useOsdkClient.js.map +1 -0
  18. package/build/browser/useOsdkMetadata.d.ts +8 -0
  19. package/build/browser/useOsdkMetadata.d.ts.map +1 -0
  20. package/build/browser/useOsdkMetadata.js +34 -0
  21. package/build/browser/useOsdkMetadata.js.map +1 -0
  22. package/build/esm/OsdkContext.d.ts +6 -0
  23. package/build/esm/OsdkContext.d.ts.map +1 -0
  24. package/build/esm/OsdkContext.js +26 -0
  25. package/build/esm/OsdkContext.js.map +1 -0
  26. package/build/esm/OsdkProvider.d.ts +7 -0
  27. package/build/esm/OsdkProvider.d.ts.map +1 -0
  28. package/build/esm/OsdkProvider.js +28 -0
  29. package/build/esm/OsdkProvider.js.map +1 -0
  30. package/build/esm/index.d.ts +3 -0
  31. package/build/esm/index.d.ts.map +1 -0
  32. package/build/esm/index.js +18 -0
  33. package/build/esm/index.js.map +1 -0
  34. package/build/esm/useOsdkClient.d.ts +3 -0
  35. package/build/esm/useOsdkClient.d.ts.map +1 -0
  36. package/build/esm/useOsdkClient.js +21 -0
  37. package/build/esm/useOsdkClient.js.map +1 -0
  38. package/build/esm/useOsdkMetadata.d.ts +8 -0
  39. package/build/esm/useOsdkMetadata.d.ts.map +1 -0
  40. package/build/esm/useOsdkMetadata.js +34 -0
  41. package/build/esm/useOsdkMetadata.js.map +1 -0
  42. package/package.json +65 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @osdkkit/react
2
+
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 0fec606: Code properly compiles under isolatedDeclarations
8
+
9
+ ## 0.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 03be047: Introduce useOsdkMetadata()
14
+
15
+ ## 0.1.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 6a6444f: Removes false browser entry from exports
@@ -0,0 +1,6 @@
1
+ import type { Client } from "@osdk/client";
2
+ import React from "react";
3
+ export declare const OsdkContext: React.Context<{
4
+ client: Client;
5
+ }>;
6
+ //# sourceMappingURL=OsdkContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OsdkContext.d.ts","sourceRoot":"","sources":["../../src/OsdkContext.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB,CAEC,CAAC"}
@@ -0,0 +1,26 @@
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
+ import React from "react";
17
+ function fakeClientFn(..._args) {
18
+ throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
19
+ }
20
+ const fakeClient = Object.assign(fakeClientFn, {
21
+ fetchMetadata: fakeClientFn
22
+ });
23
+ export const OsdkContext = React.createContext({
24
+ client: fakeClient
25
+ });
26
+ //# sourceMappingURL=OsdkContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OsdkContext.js","names":["React","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","OsdkContext","createContext","client"],"sources":["OsdkContext.js"],"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 */\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 = React.createContext({\n client: fakeClient,\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAYA,CAAC,GAAGC,KAAK,EAAE;EAC5B,MAAM,IAAIC,KAAK,CAAC,sEAAsE,CAAC;AAC3F;AACA,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC3CM,aAAa,EAAEN;AACnB,CAAC,CAAC;AACF,OAAO,MAAMO,WAAW,GAAGR,KAAK,CAACS,aAAa,CAAC;EAC3CC,MAAM,EAAEN;AACZ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import type { Client } from "@osdk/client";
2
+ import React from "react";
3
+ export declare function OsdkProvider({ children, client, }: {
4
+ children: React.ReactNode;
5
+ client: Client;
6
+ }): React.JSX.Element;
7
+ //# sourceMappingURL=OsdkProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OsdkProvider.d.ts","sourceRoot":"","sources":["../../src/OsdkProvider.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,qBAIA"}
@@ -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
+ import React from "react";
17
+ import { OsdkContext } from "./OsdkContext.js";
18
+ export function OsdkProvider({
19
+ children,
20
+ client
21
+ }) {
22
+ return React.createElement(OsdkContext.Provider, {
23
+ value: {
24
+ client
25
+ }
26
+ }, children);
27
+ }
28
+ //# sourceMappingURL=OsdkProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OsdkProvider.js","names":["React","OsdkContext","OsdkProvider","children","client","createElement","Provider","value"],"sources":["OsdkProvider.js"],"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 */\nimport React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nexport function OsdkProvider({ children, client, }) {\n return (React.createElement(OsdkContext.Provider, { value: { client } }, children));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,OAAO,SAASC,YAAYA,CAAC;EAAEC,QAAQ;EAAEC;AAAQ,CAAC,EAAE;EAChD,OAAQJ,KAAK,CAACK,aAAa,CAACJ,WAAW,CAACK,QAAQ,EAAE;IAAEC,KAAK,EAAE;MAAEH;IAAO;EAAE,CAAC,EAAED,QAAQ,CAAC;AACtF","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export { OsdkProvider } from "./OsdkProvider.js";
2
+ export { useOsdkClient } from "./useOsdkClient.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,18 @@
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
+ export { OsdkProvider } from "./OsdkProvider.js";
17
+ export { useOsdkClient } from "./useOsdkClient.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["OsdkProvider","useOsdkClient"],"sources":["index.js"],"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 */\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;AACA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,aAAa,QAAQ,oBAAoB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { Client } from "@osdk/client";
2
+ export declare function useOsdkClient(): Client;
3
+ //# sourceMappingURL=useOsdkClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkClient.d.ts","sourceRoot":"","sources":["../../src/useOsdkClient.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
@@ -0,0 +1,21 @@
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
+ import React from "react";
17
+ import { OsdkContext } from "./OsdkContext.js";
18
+ export function useOsdkClient() {
19
+ return React.useContext(OsdkContext).client;
20
+ }
21
+ //# sourceMappingURL=useOsdkClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkClient.js","names":["React","OsdkContext","useOsdkClient","useContext","client"],"sources":["useOsdkClient.js"],"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 */\nimport React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nexport function useOsdkClient() {\n return React.useContext(OsdkContext).client;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC5B,OAAOF,KAAK,CAACG,UAAU,CAACF,WAAW,CAAC,CAACG,MAAM;AAC/C","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type { InterfaceDefinition, InterfaceMetadata, ObjectMetadata, ObjectOrInterfaceDefinition, ObjectTypeDefinition } from "@osdk/api";
2
+ type MetadataFor<T extends ObjectOrInterfaceDefinition> = T extends InterfaceDefinition ? InterfaceMetadata : T extends ObjectTypeDefinition ? ObjectMetadata : never;
3
+ export declare function useOsdkMetadata<T extends ObjectOrInterfaceDefinition>(type: T): {
4
+ loading: boolean;
5
+ metadata?: MetadataFor<T>;
6
+ };
7
+ export {};
8
+ //# sourceMappingURL=useOsdkMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkMetadata.d.ts","sourceRoot":"","sources":["../../src/useOsdkMetadata.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,WAAW,CAAC;AAInB,KAAK,WAAW,CAAC,CAAC,SAAS,2BAA2B,IAAI,CAAC,SACzD,mBAAmB,GAAG,iBAAiB,GACrC,CAAC,SAAS,oBAAoB,GAAG,cAAc,GAC/C,KAAK,CAAC;AAEV,wBAAgB,eAAe,CAAC,CAAC,SAAS,2BAA2B,EACnE,IAAI,EAAE,CAAC,GACN;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CAC3B,CAcA"}
@@ -0,0 +1,34 @@
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
+ import React from "react";
17
+ import { useOsdkClient } from "./useOsdkClient.js";
18
+ export function useOsdkMetadata(type) {
19
+ const client = useOsdkClient();
20
+ const [metadata, setMetadata] = React.useState(undefined);
21
+ if (!metadata) {
22
+ client.fetchMetadata(type).then(fetchedMetadata => {
23
+ setMetadata(fetchedMetadata);
24
+ });
25
+ return {
26
+ loading: true
27
+ };
28
+ }
29
+ return {
30
+ loading: false,
31
+ metadata
32
+ };
33
+ }
34
+ //# sourceMappingURL=useOsdkMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkMetadata.js","names":["React","useOsdkClient","useOsdkMetadata","type","client","metadata","setMetadata","useState","undefined","fetchMetadata","then","fetchedMetadata","loading"],"sources":["useOsdkMetadata.js"],"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 */\nimport React from \"react\";\nimport { useOsdkClient } from \"./useOsdkClient.js\";\nexport function useOsdkMetadata(type) {\n const client = useOsdkClient();\n const [metadata, setMetadata] = React.useState(undefined);\n if (!metadata) {\n client.fetchMetadata(type).then((fetchedMetadata) => {\n setMetadata(fetchedMetadata);\n });\n return { loading: true };\n }\n return { loading: false, metadata };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,oBAAoB;AAClD,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAE;EAClC,MAAMC,MAAM,GAAGH,aAAa,CAAC,CAAC;EAC9B,MAAM,CAACI,QAAQ,EAAEC,WAAW,CAAC,GAAGN,KAAK,CAACO,QAAQ,CAACC,SAAS,CAAC;EACzD,IAAI,CAACH,QAAQ,EAAE;IACXD,MAAM,CAACK,aAAa,CAACN,IAAI,CAAC,CAACO,IAAI,CAAEC,eAAe,IAAK;MACjDL,WAAW,CAACK,eAAe,CAAC;IAChC,CAAC,CAAC;IACF,OAAO;MAAEC,OAAO,EAAE;IAAK,CAAC;EAC5B;EACA,OAAO;IAAEA,OAAO,EAAE,KAAK;IAAEP;EAAS,CAAC;AACvC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { Client } from "@osdk/client";
2
+ import React from "react";
3
+ export declare const OsdkContext: React.Context<{
4
+ client: Client;
5
+ }>;
6
+ //# sourceMappingURL=OsdkContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OsdkContext.d.ts","sourceRoot":"","sources":["../../src/OsdkContext.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;CAChB,CAEC,CAAC"}
@@ -0,0 +1,26 @@
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
+ import React from "react";
17
+ function fakeClientFn(..._args) {
18
+ throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
19
+ }
20
+ const fakeClient = Object.assign(fakeClientFn, {
21
+ fetchMetadata: fakeClientFn
22
+ });
23
+ export const OsdkContext = React.createContext({
24
+ client: fakeClient
25
+ });
26
+ //# sourceMappingURL=OsdkContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OsdkContext.js","names":["React","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","OsdkContext","createContext","client"],"sources":["OsdkContext.js"],"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 */\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 = React.createContext({\n client: fakeClient,\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAYA,CAAC,GAAGC,KAAK,EAAE;EAC5B,MAAM,IAAIC,KAAK,CAAC,sEAAsE,CAAC;AAC3F;AACA,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC3CM,aAAa,EAAEN;AACnB,CAAC,CAAC;AACF,OAAO,MAAMO,WAAW,GAAGR,KAAK,CAACS,aAAa,CAAC;EAC3CC,MAAM,EAAEN;AACZ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import type { Client } from "@osdk/client";
2
+ import React from "react";
3
+ export declare function OsdkProvider({ children, client, }: {
4
+ children: React.ReactNode;
5
+ client: Client;
6
+ }): React.JSX.Element;
7
+ //# sourceMappingURL=OsdkProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OsdkProvider.d.ts","sourceRoot":"","sources":["../../src/OsdkProvider.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;CAChB,qBAIA"}
@@ -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
+ import React from "react";
17
+ import { OsdkContext } from "./OsdkContext.js";
18
+ export function OsdkProvider({
19
+ children,
20
+ client
21
+ }) {
22
+ return React.createElement(OsdkContext.Provider, {
23
+ value: {
24
+ client
25
+ }
26
+ }, children);
27
+ }
28
+ //# sourceMappingURL=OsdkProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OsdkProvider.js","names":["React","OsdkContext","OsdkProvider","children","client","createElement","Provider","value"],"sources":["OsdkProvider.js"],"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 */\nimport React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nexport function OsdkProvider({ children, client, }) {\n return (React.createElement(OsdkContext.Provider, { value: { client } }, children));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,OAAO,SAASC,YAAYA,CAAC;EAAEC,QAAQ;EAAEC;AAAQ,CAAC,EAAE;EAChD,OAAQJ,KAAK,CAACK,aAAa,CAACJ,WAAW,CAACK,QAAQ,EAAE;IAAEC,KAAK,EAAE;MAAEH;IAAO;EAAE,CAAC,EAAED,QAAQ,CAAC;AACtF","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export { OsdkProvider } from "./OsdkProvider.js";
2
+ export { useOsdkClient } from "./useOsdkClient.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,18 @@
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
+ export { OsdkProvider } from "./OsdkProvider.js";
17
+ export { useOsdkClient } from "./useOsdkClient.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["OsdkProvider","useOsdkClient"],"sources":["index.js"],"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 */\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;AACA,SAASA,YAAY,QAAQ,mBAAmB;AAChD,SAASC,aAAa,QAAQ,oBAAoB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { Client } from "@osdk/client";
2
+ export declare function useOsdkClient(): Client;
3
+ //# sourceMappingURL=useOsdkClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkClient.d.ts","sourceRoot":"","sources":["../../src/useOsdkClient.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
@@ -0,0 +1,21 @@
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
+ import React from "react";
17
+ import { OsdkContext } from "./OsdkContext.js";
18
+ export function useOsdkClient() {
19
+ return React.useContext(OsdkContext).client;
20
+ }
21
+ //# sourceMappingURL=useOsdkClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkClient.js","names":["React","OsdkContext","useOsdkClient","useContext","client"],"sources":["useOsdkClient.js"],"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 */\nimport React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nexport function useOsdkClient() {\n return React.useContext(OsdkContext).client;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC5B,OAAOF,KAAK,CAACG,UAAU,CAACF,WAAW,CAAC,CAACG,MAAM;AAC/C","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type { InterfaceDefinition, InterfaceMetadata, ObjectMetadata, ObjectOrInterfaceDefinition, ObjectTypeDefinition } from "@osdk/api";
2
+ type MetadataFor<T extends ObjectOrInterfaceDefinition> = T extends InterfaceDefinition ? InterfaceMetadata : T extends ObjectTypeDefinition ? ObjectMetadata : never;
3
+ export declare function useOsdkMetadata<T extends ObjectOrInterfaceDefinition>(type: T): {
4
+ loading: boolean;
5
+ metadata?: MetadataFor<T>;
6
+ };
7
+ export {};
8
+ //# sourceMappingURL=useOsdkMetadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkMetadata.d.ts","sourceRoot":"","sources":["../../src/useOsdkMetadata.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,WAAW,CAAC;AAInB,KAAK,WAAW,CAAC,CAAC,SAAS,2BAA2B,IAAI,CAAC,SACzD,mBAAmB,GAAG,iBAAiB,GACrC,CAAC,SAAS,oBAAoB,GAAG,cAAc,GAC/C,KAAK,CAAC;AAEV,wBAAgB,eAAe,CAAC,CAAC,SAAS,2BAA2B,EACnE,IAAI,EAAE,CAAC,GACN;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;CAC3B,CAcA"}
@@ -0,0 +1,34 @@
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
+ import React from "react";
17
+ import { useOsdkClient } from "./useOsdkClient.js";
18
+ export function useOsdkMetadata(type) {
19
+ const client = useOsdkClient();
20
+ const [metadata, setMetadata] = React.useState(undefined);
21
+ if (!metadata) {
22
+ client.fetchMetadata(type).then(fetchedMetadata => {
23
+ setMetadata(fetchedMetadata);
24
+ });
25
+ return {
26
+ loading: true
27
+ };
28
+ }
29
+ return {
30
+ loading: false,
31
+ metadata
32
+ };
33
+ }
34
+ //# sourceMappingURL=useOsdkMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOsdkMetadata.js","names":["React","useOsdkClient","useOsdkMetadata","type","client","metadata","setMetadata","useState","undefined","fetchMetadata","then","fetchedMetadata","loading"],"sources":["useOsdkMetadata.js"],"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 */\nimport React from \"react\";\nimport { useOsdkClient } from \"./useOsdkClient.js\";\nexport function useOsdkMetadata(type) {\n const client = useOsdkClient();\n const [metadata, setMetadata] = React.useState(undefined);\n if (!metadata) {\n client.fetchMetadata(type).then((fetchedMetadata) => {\n setMetadata(fetchedMetadata);\n });\n return { loading: true };\n }\n return { loading: false, metadata };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,oBAAoB;AAClD,OAAO,SAASC,eAAeA,CAACC,IAAI,EAAE;EAClC,MAAMC,MAAM,GAAGH,aAAa,CAAC,CAAC;EAC9B,MAAM,CAACI,QAAQ,EAAEC,WAAW,CAAC,GAAGN,KAAK,CAACO,QAAQ,CAACC,SAAS,CAAC;EACzD,IAAI,CAACH,QAAQ,EAAE;IACXD,MAAM,CAACK,aAAa,CAACN,IAAI,CAAC,CAACO,IAAI,CAAEC,eAAe,IAAK;MACjDL,WAAW,CAACK,eAAe,CAAC;IAChC,CAAC,CAAC;IACF,OAAO;MAAEC,OAAO,EAAE;IAAK,CAAC;EAC5B;EACA,OAAO;IAAEA,OAAO,EAAE,KAAK;IAAEP;EAAS,CAAC;AACvC","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@osdk/react",
3
+ "version": "0.2.1",
4
+ "license": "Apache-2.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/palantir/osdk-ts.git"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "browser": "./build/browser/index.js",
12
+ "import": "./build/esm/index.js",
13
+ "default": "./build/browser/index.js"
14
+ },
15
+ "./*": {
16
+ "browser": "./build/browser/public/*.js",
17
+ "import": "./build/esm/public/*.js",
18
+ "default": "./build/browser/public/*.js"
19
+ }
20
+ },
21
+ "peerDependencies": {
22
+ "@osdk/api": "^2.0.9",
23
+ "@osdk/client": "^2.0.9",
24
+ "@types/react": "^18",
25
+ "react": "^17 || ^18",
26
+ "react-dom": "^17 || ^18"
27
+ },
28
+ "devDependencies": {
29
+ "@testing-library/react": "^16.0.1",
30
+ "@types/react": "^18.3.12",
31
+ "happy-dom": "^15.7.4",
32
+ "p-defer": "^4.0.1",
33
+ "react": "^18.0.0",
34
+ "typescript": "~5.5.4",
35
+ "@osdk/client": "2.1.0-beta.13",
36
+ "@osdk/monorepo.api-extractor": "~0.0.0",
37
+ "@osdk/monorepo.tsup": "~0.0.0",
38
+ "@osdk/api": "2.1.0-beta.13",
39
+ "@osdk/monorepo.tsconfig": "~0.0.0"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "files": [
45
+ "build/cjs",
46
+ "build/esm",
47
+ "build/browser",
48
+ "CHANGELOG.md",
49
+ "package.json",
50
+ "templates",
51
+ "*.d.ts"
52
+ ],
53
+ "module": "./build/esm/index.js",
54
+ "types": "./build/esm/index.d.ts",
55
+ "type": "module",
56
+ "scripts": {
57
+ "check-attw": "monorepo.tool.attw esm",
58
+ "check-spelling": "cspell --quiet .",
59
+ "clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
60
+ "fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
61
+ "lint": "eslint . && dprint check --config $(find-up dprint.json)",
62
+ "test": "vitest run",
63
+ "transpile": "monorepo.tool.transpile"
64
+ }
65
+ }