@osdk/react 0.9.0-beta.2 → 0.9.0-beta.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/build/browser/new/makeExternalStore.js +2 -2
  3. package/build/browser/new/makeExternalStore.js.map +1 -1
  4. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js +44 -0
  5. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -0
  6. package/build/browser/new/platform-apis/admin/useFoundryUser.js +50 -0
  7. package/build/browser/new/platform-apis/admin/useFoundryUser.js.map +1 -0
  8. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js +54 -0
  9. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js.map +1 -0
  10. package/build/browser/new/useObjectSet.js +17 -2
  11. package/build/browser/new/useObjectSet.js.map +1 -1
  12. package/build/browser/new/useOsdkAction.js.map +1 -1
  13. package/build/browser/new/useOsdkObject.js.map +1 -1
  14. package/build/browser/new/useOsdkObjects.js.map +1 -1
  15. package/build/browser/public/experimental.js +3 -0
  16. package/build/browser/public/experimental.js.map +1 -1
  17. package/build/browser/utils/usePlatformQuery.js +74 -0
  18. package/build/browser/utils/usePlatformQuery.js.map +1 -0
  19. package/build/cjs/{chunk-OVBG5VXE.cjs → chunk-V32JHU3O.cjs} +8 -3
  20. package/build/cjs/chunk-V32JHU3O.cjs.map +1 -0
  21. package/build/cjs/index.cjs +4 -4
  22. package/build/cjs/public/experimental.cjs +692 -53
  23. package/build/cjs/public/experimental.cjs.map +1 -1
  24. package/build/cjs/public/experimental.d.cts +122 -7
  25. package/build/esm/new/makeExternalStore.js +2 -2
  26. package/build/esm/new/makeExternalStore.js.map +1 -1
  27. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js +44 -0
  28. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -0
  29. package/build/esm/new/platform-apis/admin/useFoundryUser.js +50 -0
  30. package/build/esm/new/platform-apis/admin/useFoundryUser.js.map +1 -0
  31. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js +54 -0
  32. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js.map +1 -0
  33. package/build/esm/new/useObjectSet.js +17 -2
  34. package/build/esm/new/useObjectSet.js.map +1 -1
  35. package/build/esm/new/useOsdkAction.js.map +1 -1
  36. package/build/esm/new/useOsdkObject.js.map +1 -1
  37. package/build/esm/new/useOsdkObjects.js.map +1 -1
  38. package/build/esm/public/experimental.js +3 -0
  39. package/build/esm/public/experimental.js.map +1 -1
  40. package/build/esm/utils/usePlatformQuery.js +74 -0
  41. package/build/esm/utils/usePlatformQuery.js.map +1 -0
  42. package/build/types/new/makeExternalStore.d.ts +1 -1
  43. package/build/types/new/makeExternalStore.d.ts.map +1 -1
  44. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts +28 -0
  45. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts.map +1 -0
  46. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts +36 -0
  47. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts.map +1 -0
  48. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts +52 -0
  49. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts.map +1 -0
  50. package/build/types/new/useOsdkAction.d.ts +3 -3
  51. package/build/types/new/useOsdkAction.d.ts.map +1 -1
  52. package/build/types/new/useOsdkObjects.d.ts +7 -4
  53. package/build/types/new/useOsdkObjects.d.ts.map +1 -1
  54. package/build/types/public/experimental.d.ts +3 -0
  55. package/build/types/public/experimental.d.ts.map +1 -1
  56. package/build/types/utils/usePlatformQuery.d.ts +25 -0
  57. package/build/types/utils/usePlatformQuery.d.ts.map +1 -0
  58. package/package.json +5 -4
  59. package/build/cjs/chunk-OVBG5VXE.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePlatformQuery.js","names":["React","makeExternalStore","usePlatformQuery","query","queryName","enabled","observerRef","useRef","handleQuery","useCallback","observer","current","next","status","data","undefined","then","catch","err","error","subscribe","getSnapShot","useMemo","unsubscribe","process","env","NODE_ENV","payload","useSyncExternalStore","Error","isLoading","refetch"],"sources":["usePlatformQuery.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 { Observer } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"../new/makeExternalStore.js\";\n\nexport interface UseQueryOptions<T> {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * });\n */\n enabled?: boolean;\n queryName: string;\n query: () => Promise<T>;\n}\n\nexport interface QueryResult<T> {\n data: T | undefined;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => void;\n}\n\ninterface QueryPayload<T> {\n data: T | undefined;\n status: \"loading\" | \"success\" | \"error\";\n}\n\nexport function usePlatformQuery<T>(\n { query, queryName, enabled = true }: UseQueryOptions<T>,\n): QueryResult<T> {\n const observerRef = React.useRef<Observer<QueryPayload<T> | undefined>>();\n\n const handleQuery = React.useCallback(() => {\n const observer = observerRef.current;\n if (observer == null) return;\n\n observer.next({\n status: \"loading\",\n data: undefined,\n });\n\n query()\n .then((data) => {\n observer.next({\n status: \"success\",\n data,\n });\n })\n .catch((err: unknown) => {\n observer.error(err);\n });\n }, [query]);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<QueryPayload<T>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `${queryName} Query [DISABLED]`\n : undefined,\n );\n }\n\n return makeExternalStore<QueryPayload<T>>(\n (observer: Observer<QueryPayload<T> | undefined>) => {\n observerRef.current = observer;\n handleQuery();\n return {\n unsubscribe: () => {\n observerRef.current = undefined;\n },\n };\n },\n queryName,\n );\n },\n [enabled, queryName, handleQuery],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error != null) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(`Failed to query platform API: ${queryName}`);\n }\n\n return {\n data: payload?.data,\n isLoading: payload?.status === \"loading\",\n error,\n refetch: handleQuery,\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,iBAAiB,QAAQ,6BAA6B;AAiC/D,OAAO,SAASC,gBAAgBA,CAC9B;EAAEC,KAAK;EAAEC,SAAS;EAAEC,OAAO,GAAG;AAAyB,CAAC,EACxC;EAChB,MAAMC,WAAW,GAAGN,KAAK,CAACO,MAAM,CAAwC,CAAC;EAEzE,MAAMC,WAAW,GAAGR,KAAK,CAACS,WAAW,CAAC,MAAM;IAC1C,MAAMC,QAAQ,GAAGJ,WAAW,CAACK,OAAO;IACpC,IAAID,QAAQ,IAAI,IAAI,EAAE;IAEtBA,QAAQ,CAACE,IAAI,CAAC;MACZC,MAAM,EAAE,SAAS;MACjBC,IAAI,EAAEC;IACR,CAAC,CAAC;IAEFZ,KAAK,CAAC,CAAC,CACJa,IAAI,CAAEF,IAAI,IAAK;MACdJ,QAAQ,CAACE,IAAI,CAAC;QACZC,MAAM,EAAE,SAAS;QACjBC;MACF,CAAC,CAAC;IACJ,CAAC,CA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M,KAAK;IACLY,OAAO,EAAEvB;EACX,CAAC;AACH","ignoreList":[]}
@@ -6,7 +6,11 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
6
 
7
7
  var React3__default = /*#__PURE__*/_interopDefault(React3);
8
8
 
9
- // src/useOsdkClient.ts
9
+ var __defProp = Object.defineProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
10
14
  function fakeClientFn(..._args) {
11
15
  throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
12
16
  }
@@ -44,7 +48,8 @@ function useOsdkMetadata(type) {
44
48
  }
45
49
 
46
50
  exports.OsdkContext = OsdkContext;
51
+ exports.__export = __export;
47
52
  exports.useOsdkClient = useOsdkClient;
48
53
  exports.useOsdkMetadata = useOsdkMetadata;
49
- //# sourceMappingURL=chunk-OVBG5VXE.cjs.map
50
- //# sourceMappingURL=chunk-OVBG5VXE.cjs.map
54
+ //# sourceMappingURL=chunk-V32JHU3O.cjs.map
55
+ //# sourceMappingURL=chunk-V32JHU3O.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/OsdkContext.ts","../../src/useOsdkClient.ts","../../src/useOsdkMetadata.ts"],"names":["React","error"],"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,2CAAiC,aAAc,CAAA;AAAA,EAC1D,MAAQ,EAAA;AACV,CAAC;;;ACPM,SAAS,aAAgB,GAAA;AAC9B,EAAOA,OAAAA,uBAAAA,CAAM,UAAW,CAAA,WAAW,CAAE,CAAA,MAAA;AACvC;ACFO,SAAS,gBAAgB,IAAM,EAAA;AACpC,EAAA,MAAM,SAAS,aAAc,EAAA;AAC7B,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAIA,GAAAA,uBAAAA,CAAM,SAAS,MAAS,CAAA;AACxD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,wBAAM,QAAS,EAAA;AACzC,EAAI,IAAA,CAAC,QAAY,IAAA,CAAC,KAAO,EAAA;AACvB,IAAA,MAAA,CAAO,aAAc,CAAA,IAAI,CAAE,CAAA,IAAA,CAAK,CAAmB,eAAA,KAAA;AACjD,MAAA,WAAA,CAAY,eAAe,CAAA;AAAA,KAC5B,CAAA,CAAE,KAAM,CAAA,CAAAC,MAAS,KAAA;AAChB,MAAA,MAAM,eAAeA,MAAiB,YAAA,KAAA,GAAQA,MAAM,CAAA,OAAA,GAAU,OAAOA,MAAK,CAAA;AAC1E,MAAA,QAAA,CAAS,YAAY,CAAA;AAAA,KACtB,CAAA;AACD,IAAO,OAAA;AAAA,MACL,OAAS,EAAA;AAAA,KACX;AAAA;AAEF,EAAO,OAAA;AAAA,IACL,OAAS,EAAA,KAAA;AAAA,IACT,QAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-V32JHU3O.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}","/*\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 { useOsdkClient } from \"./useOsdkClient.js\";\nexport function useOsdkMetadata(type) {\n const client = useOsdkClient();\n const [metadata, setMetadata] = React.useState(undefined);\n const [error, setError] = React.useState();\n if (!metadata && !error) {\n client.fetchMetadata(type).then(fetchedMetadata => {\n setMetadata(fetchedMetadata);\n }).catch(error => {\n const errorMessage = error instanceof Error ? error.message : String(error);\n setError(errorMessage);\n });\n return {\n loading: true\n };\n }\n return {\n loading: false,\n metadata,\n error\n };\n}"]}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkOVBG5VXE_cjs = require('./chunk-OVBG5VXE.cjs');
3
+ var chunkV32JHU3O_cjs = require('./chunk-V32JHU3O.cjs');
4
4
  var React = require('react');
5
5
 
6
6
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -11,7 +11,7 @@ function OsdkProvider({
11
11
  children,
12
12
  client
13
13
  }) {
14
- return /* @__PURE__ */ React__default.default.createElement(chunkOVBG5VXE_cjs.OsdkContext.Provider, {
14
+ return /* @__PURE__ */ React__default.default.createElement(chunkV32JHU3O_cjs.OsdkContext.Provider, {
15
15
  value: {
16
16
  client
17
17
  }
@@ -20,11 +20,11 @@ function OsdkProvider({
20
20
 
21
21
  Object.defineProperty(exports, "useOsdkClient", {
22
22
  enumerable: true,
23
- get: function () { return chunkOVBG5VXE_cjs.useOsdkClient; }
23
+ get: function () { return chunkV32JHU3O_cjs.useOsdkClient; }
24
24
  });
25
25
  Object.defineProperty(exports, "useOsdkMetadata", {
26
26
  enumerable: true,
27
- get: function () { return chunkOVBG5VXE_cjs.useOsdkMetadata; }
27
+ get: function () { return chunkV32JHU3O_cjs.useOsdkMetadata; }
28
28
  });
29
29
  exports.OsdkProvider = OsdkProvider;
30
30
  //# sourceMappingURL=index.cjs.map