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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/build/browser/OsdkContext.js +2 -1
  3. package/build/browser/OsdkContext.js.map +1 -1
  4. package/build/browser/OsdkProvider.js +2 -1
  5. package/build/browser/OsdkProvider.js.map +1 -1
  6. package/build/browser/index.js +1 -0
  7. package/build/browser/index.js.map +1 -1
  8. package/build/browser/useOsdkClient.js +1 -0
  9. package/build/browser/useOsdkClient.js.map +1 -1
  10. package/build/browser/useOsdkMetadata.js +4 -0
  11. package/build/browser/useOsdkMetadata.js.map +1 -1
  12. package/build/cjs/index.cjs +38 -0
  13. package/build/cjs/index.cjs.map +1 -0
  14. package/build/cjs/index.d.cts +11 -0
  15. package/build/esm/OsdkContext.js +2 -1
  16. package/build/esm/OsdkContext.js.map +1 -1
  17. package/build/esm/OsdkProvider.js +2 -1
  18. package/build/esm/OsdkProvider.js.map +1 -1
  19. package/build/esm/index.js +1 -0
  20. package/build/esm/index.js.map +1 -1
  21. package/build/esm/useOsdkClient.js +1 -0
  22. package/build/esm/useOsdkClient.js.map +1 -1
  23. package/build/esm/useOsdkMetadata.js +4 -0
  24. package/build/esm/useOsdkMetadata.js.map +1 -1
  25. package/build/types/OsdkContext.d.ts +3 -0
  26. package/build/types/OsdkProvider.d.ts +6 -0
  27. package/build/{browser → types}/index.d.ts +0 -1
  28. package/build/{browser → types}/useOsdkClient.d.ts +0 -1
  29. package/build/{browser → types}/useOsdkMetadata.d.ts +2 -3
  30. package/package.json +23 -10
  31. package/build/browser/OsdkContext.d.ts +0 -6
  32. package/build/browser/OsdkContext.d.ts.map +0 -1
  33. package/build/browser/OsdkProvider.d.ts +0 -7
  34. package/build/browser/OsdkProvider.d.ts.map +0 -1
  35. package/build/browser/index.d.ts.map +0 -1
  36. package/build/browser/useOsdkClient.d.ts.map +0 -1
  37. package/build/browser/useOsdkMetadata.d.ts.map +0 -1
  38. package/build/esm/OsdkContext.d.ts +0 -6
  39. package/build/esm/OsdkContext.d.ts.map +0 -1
  40. package/build/esm/OsdkProvider.d.ts +0 -7
  41. package/build/esm/OsdkProvider.d.ts.map +0 -1
  42. package/build/esm/index.d.ts +0 -3
  43. package/build/esm/index.d.ts.map +0 -1
  44. package/build/esm/useOsdkClient.d.ts +0 -3
  45. package/build/esm/useOsdkClient.d.ts.map +0 -1
  46. package/build/esm/useOsdkMetadata.d.ts +0 -8
  47. package/build/esm/useOsdkMetadata.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @osdkkit/react
2
2
 
3
+ ## 0.3.0-beta.3
4
+
5
+ ### Minor Changes
6
+
7
+ - c691c8b: Package now has experimental support for commonjs
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [03f95eb]
12
+ - Updated dependencies [c691c8b]
13
+ - Updated dependencies [3c9ac22]
14
+ - @osdk/client@2.1.0-beta.24
15
+ - @osdk/api@2.1.0-beta.24
16
+
17
+ ## 0.3.0-beta.2
18
+
19
+ ### Minor Changes
20
+
21
+ - c9da74c: Improves code quality by fixing linting errors
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [c9da74c]
26
+ - Updated dependencies [73fa373]
27
+ - @osdk/client@2.1.0-beta.22
28
+ - @osdk/api@2.1.0-beta.22
29
+
3
30
  ## 0.3.0-beta.1
4
31
 
5
32
  ### 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.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":[]}
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.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":[]}
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":[]}
@@ -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
  export { OsdkProvider } from "./OsdkProvider.js";
17
18
  export { useOsdkClient } from "./useOsdkClient.js";
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +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":[]}
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":[]}
@@ -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
  import { OsdkContext } from "./OsdkContext.js";
18
19
  export function useOsdkClient() {
@@ -1 +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":[]}
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":[]}
@@ -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
  import { useOsdkClient } from "./useOsdkClient.js";
18
19
  export function useOsdkMetadata(type) {
@@ -21,6 +22,9 @@ export function useOsdkMetadata(type) {
21
22
  if (!metadata) {
22
23
  client.fetchMetadata(type).then(fetchedMetadata => {
23
24
  setMetadata(fetchedMetadata);
25
+ }).catch(error => {
26
+ // eslint-disable-next-line no-console
27
+ console.error("Failed to fetch metadata", error);
24
28
  });
25
29
  return {
26
30
  loading: true
@@ -1 +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":[]}
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,38 @@
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/OsdkProvider.tsx
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/OsdkProvider.tsx
21
+ function OsdkProvider({
22
+ children,
23
+ client
24
+ }) {
25
+ return /* @__PURE__ */ React__default.default.createElement(OsdkContext.Provider, {
26
+ value: {
27
+ client
28
+ }
29
+ }, children);
30
+ }
31
+ function useOsdkClient() {
32
+ return React__default.default.useContext(OsdkContext).client;
33
+ }
34
+
35
+ exports.OsdkProvider = OsdkProvider;
36
+ exports.useOsdkClient = useOsdkClient;
37
+ //# sourceMappingURL=index.cjs.map
38
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/OsdkContext.ts","../../src/OsdkProvider.tsx","../../src/useOsdkClient.ts"],"names":["React"],"mappings":";;;;;;;;;AAiBA,SAAS,gBAAgB,KAAO,EAAA;AAC9B,EAAM,MAAA,IAAI,MAAM,sEAAsE,CAAA,CAAA;AACxF,CAAA;AACA,IAAM,UAAA,GAAa,MAAO,CAAA,MAAA,CAAO,YAAc,EAAA;AAAA,EAC7C,aAAe,EAAA,YAAA;AACjB,CAAC,CAAA,CAAA;AACM,IAAM,WAAA,0CAAiC,aAAc,CAAA;AAAA,EAC1D,MAAQ,EAAA,UAAA;AACV,CAAC,CAAA,CAAA;;;ACPM,SAAS,YAAa,CAAA;AAAA,EAC3B,QAAA;AAAA,EACA,MAAA;AACF,CAAG,EAAA;AACD,EAAA,uBAAoBA,sBAAAA,CAAM,aAAc,CAAA,WAAA,CAAY,QAAU,EAAA;AAAA,IAC5D,KAAO,EAAA;AAAA,MACL,MAAA;AAAA,KACF;AAAA,KACC,QAAQ,CAAA,CAAA;AACb,CAAA;ACTO,SAAS,aAAgB,GAAA;AAC9B,EAAOA,OAAAA,sBAAAA,CAAM,UAAW,CAAA,WAAW,CAAE,CAAA,MAAA,CAAA;AACvC","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\";\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 OsdkProvider({\n children,\n client\n}) {\n return /*#__PURE__*/React.createElement(OsdkContext.Provider, {\n value: {\n client\n }\n }, children);\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,11 @@
1
+ import { Client } from '@osdk/client';
2
+ import React from 'react';
3
+
4
+ declare function OsdkProvider({ children, client, }: {
5
+ children: React.ReactNode;
6
+ client: Client;
7
+ }): React.JSX.Element;
8
+
9
+ declare function useOsdkClient(): Client;
10
+
11
+ export { OsdkProvider, useOsdkClient };
@@ -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.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":[]}
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.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":[]}
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":[]}
@@ -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
  export { OsdkProvider } from "./OsdkProvider.js";
17
18
  export { useOsdkClient } from "./useOsdkClient.js";
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +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":[]}
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":[]}
@@ -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
  import { OsdkContext } from "./OsdkContext.js";
18
19
  export function useOsdkClient() {
@@ -1 +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":[]}
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":[]}
@@ -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
  import { useOsdkClient } from "./useOsdkClient.js";
18
19
  export function useOsdkMetadata(type) {
@@ -21,6 +22,9 @@ export function useOsdkMetadata(type) {
21
22
  if (!metadata) {
22
23
  client.fetchMetadata(type).then(fetchedMetadata => {
23
24
  setMetadata(fetchedMetadata);
25
+ }).catch(error => {
26
+ // eslint-disable-next-line no-console
27
+ console.error("Failed to fetch metadata", error);
24
28
  });
25
29
  return {
26
30
  loading: true
@@ -1 +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":[]}
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,3 @@
1
+ import type { Client } from "@osdk/client";
2
+ import React from "react";
3
+ export declare const OsdkContext: React.Context<{ client: Client }>;
@@ -0,0 +1,6 @@
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;
@@ -1,3 +1,2 @@
1
1
  export { OsdkProvider } from "./OsdkProvider.js";
2
2
  export { useOsdkClient } from "./useOsdkClient.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,2 @@
1
1
  import type { Client } from "@osdk/client";
2
2
  export declare function useOsdkClient(): Client;
3
- //# sourceMappingURL=useOsdkClient.d.ts.map
@@ -1,8 +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 {};
8
- //# sourceMappingURL=useOsdkMetadata.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/react",
3
- "version": "0.3.0-beta.1",
3
+ "version": "0.3.0-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,12 +9,20 @@
9
9
  "exports": {
10
10
  ".": {
11
11
  "browser": "./build/browser/index.js",
12
- "import": "./build/esm/index.js",
12
+ "import": {
13
+ "types": "./build/types/index.d.ts",
14
+ "default": "./build/esm/index.js"
15
+ },
16
+ "require": "./build/cjs/index.cjs",
13
17
  "default": "./build/browser/index.js"
14
18
  },
15
19
  "./*": {
16
20
  "browser": "./build/browser/public/*.js",
17
- "import": "./build/esm/public/*.js",
21
+ "import": {
22
+ "types": "./build/types/public/*.d.ts",
23
+ "default": "./build/esm/public/*.js"
24
+ },
25
+ "require": "./build/cjs/public/*.cjs",
18
26
  "default": "./build/browser/public/*.js"
19
27
  }
20
28
  },
@@ -32,11 +40,10 @@
32
40
  "p-defer": "^4.0.1",
33
41
  "react": "^18.0.0",
34
42
  "typescript": "~5.5.4",
43
+ "@osdk/api": "2.1.0-beta.24",
35
44
  "@osdk/monorepo.api-extractor": "~0.0.0",
36
- "@osdk/api": "2.1.0-beta.20",
37
- "@osdk/client": "2.1.0-beta.20",
38
- "@osdk/monorepo.tsconfig": "~0.0.0",
39
- "@osdk/monorepo.tsup": "~0.0.0"
45
+ "@osdk/client": "2.1.0-beta.24",
46
+ "@osdk/monorepo.tsconfig": "~0.0.0"
40
47
  },
41
48
  "publishConfig": {
42
49
  "access": "public"
@@ -45,21 +52,27 @@
45
52
  "build/cjs",
46
53
  "build/esm",
47
54
  "build/browser",
55
+ "build/types",
48
56
  "CHANGELOG.md",
49
57
  "package.json",
50
58
  "templates",
51
59
  "*.d.ts"
52
60
  ],
61
+ "main": "./build/cjs/index.cjs",
53
62
  "module": "./build/esm/index.js",
54
- "types": "./build/esm/index.d.ts",
63
+ "types": "./build/cjs/index.d.cts",
55
64
  "type": "module",
56
65
  "scripts": {
57
- "check-attw": "monorepo.tool.attw esm",
66
+ "check-attw": "attw --pack .",
58
67
  "check-spelling": "cspell --quiet .",
59
68
  "clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
60
69
  "fix-lint": "eslint . --fix && dprint fmt --config $(find-up dprint.json)",
61
70
  "lint": "eslint . && dprint check --config $(find-up dprint.json)",
62
71
  "test": "vitest run",
63
- "transpile": "monorepo.tool.transpile"
72
+ "transpileBrowser": "monorepo.tool.transpile -f esm -m normal -t browser",
73
+ "transpileCjs": "monorepo.tool.transpile -f cjs -m bundle -t node",
74
+ "transpileEsm": "monorepo.tool.transpile -f esm -m normal -t node",
75
+ "transpileTypes": "monorepo.tool.transpile -f esm -m types -t node",
76
+ "typecheck": "tsc --noEmit --emitDeclarationOnly false"
64
77
  }
65
78
  }
@@ -1,6 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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"}
@@ -1,6 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,3 +0,0 @@
1
- export { OsdkProvider } from "./OsdkProvider.js";
2
- export { useOsdkClient } from "./useOsdkClient.js";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,3 +0,0 @@
1
- import type { Client } from "@osdk/client";
2
- export declare function useOsdkClient(): Client;
3
- //# sourceMappingURL=useOsdkClient.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
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"}