@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,44 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Admin } from "@osdk/foundry";
18
+ import React from "react";
19
+ import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
+ import { OsdkContext2 } from "../../OsdkContext2.js";
21
+ /**
22
+ * Get the currently signed in User.
23
+ * @param options Options to control the query.
24
+ */
25
+ export function useCurrentFoundryUser({
26
+ enabled = true
27
+ } = {}) {
28
+ const {
29
+ client
30
+ } = React.useContext(OsdkContext2);
31
+ const handleQuery = React.useCallback(() => Admin.Users.getCurrent(client), [client]);
32
+ const query = usePlatformQuery({
33
+ query: handleQuery,
34
+ enabled,
35
+ queryName: "foundry-current-user"
36
+ });
37
+ return {
38
+ currentUser: query.data,
39
+ isLoading: query.isLoading,
40
+ error: query.error,
41
+ refetch: query.refetch
42
+ };
43
+ }
44
+ //# sourceMappingURL=useCurrentFoundryUser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentFoundryUser.js","names":["Admin","React","usePlatformQuery","OsdkContext2","useCurrentFoundryUser","enabled","client","useContext","handleQuery","useCallback","Users","getCurrent","query","queryName","currentUser","data","isLoading","error","refetch"],"sources":["useCurrentFoundryUser.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 { Admin } from \"@osdk/foundry\";\n\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseCurrentFoundryUserOptions {\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}\n\nexport interface UseCurrentFoundryUserResult {\n currentUser: Admin.User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the currently signed in User.\n * @param options Options to control the query.\n */\nexport function useCurrentFoundryUser(\n { enabled = true }: UseCurrentFoundryUserOptions = {},\n): UseCurrentFoundryUserResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(\n () => Admin.Users.getCurrent(client),\n [client],\n );\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-current-user\",\n });\n\n return {\n currentUser: query.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,eAAe;AAErC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AA4BpD;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnC;EAAEC,OAAO,GAAG;AAAmC,CAAC,GAAG,CAAC,CAAC,EACxB;EAC7B,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;EAEjD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CACnC,MAAMT,KAAK,CAACU,KAAK,CAACC,UAAU,CAACL,MAAM,CAAC,EACpC,CAACA,MAAM,CACT,CAAC;EAED,MAAMM,KAAK,GAAGV,gBAAgB,CAAC;IAC7BU,KAAK,EAAEJ,WAAW;IAClBH,OAAO;IACPQ,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,WAAW,EAAEF,KAAK,CAACG,IAAI;IACvBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Admin } from "@osdk/foundry";
18
+ import React from "react";
19
+ import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
+ import { OsdkContext2 } from "../../OsdkContext2.js";
21
+ /**
22
+ * Get the User with the specified id.
23
+ * @param userId A Foundry User ID.
24
+ * @param options Options to control the query.
25
+ */
26
+ export function useFoundryUser(userId, {
27
+ enabled = true,
28
+ status = "ACTIVE"
29
+ } = {}) {
30
+ const {
31
+ client
32
+ } = React.useContext(OsdkContext2);
33
+ const handleQuery = React.useCallback(() => {
34
+ return Admin.Users.get(client, userId, {
35
+ status
36
+ });
37
+ }, [client, userId, status]);
38
+ const query = usePlatformQuery({
39
+ query: handleQuery,
40
+ enabled,
41
+ queryName: "foundry-user"
42
+ });
43
+ return {
44
+ user: query.data,
45
+ isLoading: query.isLoading,
46
+ error: query.error,
47
+ refetch: query.refetch
48
+ };
49
+ }
50
+ //# sourceMappingURL=useFoundryUser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFoundryUser.js","names":["Admin","React","usePlatformQuery","OsdkContext2","useFoundryUser","userId","enabled","status","client","useContext","handleQuery","useCallback","Users","get","query","queryName","user","data","isLoading","error","refetch"],"sources":["useFoundryUser.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 { Core } from \"@osdk/foundry\";\nimport { Admin } from \"@osdk/foundry\";\n\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseFoundryUserOptions {\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\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n status?: Core.UserStatus;\n}\n\nexport interface UseFoundryUserResult {\n user: Admin.User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the User with the specified id.\n * @param userId A Foundry User ID.\n * @param options Options to control the query.\n */\nexport function useFoundryUser(\n userId: string,\n { enabled = true, status = \"ACTIVE\" }: UseFoundryUserOptions = {},\n): UseFoundryUserResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(() => {\n return Admin.Users.get(client, userId, { status });\n }, [client, userId, status]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-user\",\n });\n\n return {\n user: query.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,KAAK,QAAQ,eAAe;AAErC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AAmCpD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,MAAc,EACd;EAAEC,OAAO,GAAG,IAAI;EAAEC,MAAM,GAAG;AAAgC,CAAC,GAAG,CAAC,CAAC,EAC3C;EACtB,MAAM;IAAEC;EAAO,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,YAAY,CAAC;EAEjD,MAAMO,WAAW,GAAGT,KAAK,CAACU,WAAW,CAAC,MAAM;IAC1C,OAAOX,KAAK,CAACY,KAAK,CAACC,GAAG,CAACL,MAAM,EAAEH,MAAM,EAAE;MAAEE;IAAO,CAAC,CAAC;EACpD,CAAC,EAAE,CAACC,MAAM,EAAEH,MAAM,EAAEE,MAAM,CAAC,CAAC;EAE5B,MAAMO,KAAK,GAAGZ,gBAAgB,CAAC;IAC7BY,KAAK,EAAEJ,WAAW;IAClBJ,OAAO;IACPS,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,IAAI,EAAEF,KAAK,CAACG,IAAI;IAChBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Admin } from "@osdk/foundry";
18
+ import React from "react";
19
+ import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
+ import { OsdkContext2 } from "../../OsdkContext2.js";
21
+ /**
22
+ * Lists all Users. This is a paged endpoint. Each page may be smaller or larger than the requested page size.
23
+ * @param options Options to control the query.
24
+ */
25
+ export function useFoundryUsersList({
26
+ enabled = true,
27
+ include = "ACTIVE",
28
+ pageSize = 1000,
29
+ pageToken
30
+ } = {}) {
31
+ const {
32
+ client
33
+ } = React.useContext(OsdkContext2);
34
+ const handleQuery = React.useCallback(() => {
35
+ return Admin.Users.list(client, {
36
+ include,
37
+ pageSize,
38
+ pageToken
39
+ });
40
+ }, [client, include, pageSize, pageToken]);
41
+ const query = usePlatformQuery({
42
+ query: handleQuery,
43
+ enabled,
44
+ queryName: "foundry-users-list"
45
+ });
46
+ return {
47
+ users: query.data?.data,
48
+ nextPageToken: query.data?.nextPageToken,
49
+ isLoading: query.isLoading,
50
+ error: query.error,
51
+ refetch: query.refetch
52
+ };
53
+ }
54
+ //# sourceMappingURL=useFoundryUsersList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFoundryUsersList.js","names":["Admin","React","usePlatformQuery","OsdkContext2","useFoundryUsersList","enabled","include","pageSize","pageToken","client","useContext","handleQuery","useCallback","Users","list","query","queryName","users","data","nextPageToken","isLoading","error","refetch"],"sources":["useFoundryUsersList.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 { Core } from \"@osdk/foundry\";\nimport { Admin } from \"@osdk/foundry\";\n\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseFoundryUsersListOptions {\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\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n include?: Core.UserStatus;\n\n /**\n * The preferred page size for the list.\n *\n * @default 1000\n */\n pageSize?: number;\n\n /**\n * The page token indicates where to start paging. This should be omitted from the first page's request.\n * To fetch the next page, clients should take the value from the nextPageToken field of the previous\n * response and use it to populate the pageToken field of the next request.\n */\n pageToken?: string;\n}\n\nexport interface UseFoundryUsersListResult {\n users: Admin.ListUsersResponse[\"data\"] | undefined;\n /**\n * The page token to be used for the next page of users. If this is undefined, there are no more\n * pages of users to load.\n */\n nextPageToken: string | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Lists all Users. This is a paged endpoint. Each page may be smaller or larger than the requested page size.\n * @param options Options to control the query.\n */\nexport function useFoundryUsersList(\n { enabled = true, include = \"ACTIVE\", pageSize = 1000, pageToken }:\n UseFoundryUsersListOptions = {},\n): UseFoundryUsersListResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(() => {\n return Admin.Users.list(client, { include, pageSize, pageToken });\n }, [client, include, pageSize, pageToken]);\n\n const query = usePlatformQuery(\n {\n query: handleQuery,\n enabled,\n queryName: \"foundry-users-list\",\n },\n );\n\n return {\n users: query.data?.data,\n nextPageToken: query.data?.nextPageToken,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,KAAK,QAAQ,eAAe;AAErC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AAsDpD;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjC;EAAEC,OAAO,GAAG,IAAI;EAAEC,OAAO,GAAG,QAAQ;EAAEC,QAAQ,GAAG,IAAI;EAAEC;AAC5B,CAAC,GAAG,CAAC,CAAC,EACN;EAC3B,MAAM;IAAEC;EAAO,CAAC,GAAGR,KAAK,CAACS,UAAU,CAACP,YAAY,CAAC;EAEjD,MAAMQ,WAAW,GAAGV,KAAK,CAACW,WAAW,CAAC,MAAM;IAC1C,OAAOZ,KAAK,CAACa,KAAK,CAACC,IAAI,CAACL,MAAM,EAAE;MAAEH,OAAO;MAAEC,QAAQ;MAAEC;IAAU,CAAC,CAAC;EACnE,CAAC,EAAE,CAACC,MAAM,EAAEH,OAAO,EAAEC,QAAQ,EAAEC,SAAS,CAAC,CAAC;EAE1C,MAAMO,KAAK,GAAGb,gBAAgB,CAC5B;IACEa,KAAK,EAAEJ,WAAW;IAClBN,OAAO;IACPW,SAAS,EAAE;EACb,CACF,CAAC;EAED,OAAO;IACLC,KAAK,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IACvBC,aAAa,EAAEJ,KAAK,CAACG,IAAI,EAAEC,aAAa;IACxCC,SAAS,EAAEL,KAAK,CAACK,SAAS;IAC1BC,KAAK,EAAEN,KAAK,CAACM,KAAK;IAClBC,OAAO,EAAEP,KAAK,CAACO;EACjB,CAAC;AACH","ignoreList":[]}
@@ -39,6 +39,15 @@ export function useObjectSet(baseObjectSet, options = {}) {
39
39
  ...otherOptions
40
40
  } = options;
41
41
 
42
+ // Track object type to detect when we switch to a different object type
43
+ const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;
44
+ const previousObjectTypeRef = React.useRef(objectTypeKey);
45
+ const previousPayloadRef = React.useRef();
46
+ const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;
47
+ if (objectTypeChanged) {
48
+ previousObjectTypeRef.current = objectTypeKey;
49
+ }
50
+
42
51
  // Compute a stable cache key for the ObjectSet and options
43
52
  // dedupeIntervalMs and enabled are excluded as they don't affect the data
44
53
  const stableKey = computeObjectSetCacheKey(baseObjectSet, {
@@ -60,6 +69,7 @@ export function useObjectSet(baseObjectSet, options = {}) {
60
69
  unsubscribe: () => {}
61
70
  }), process.env.NODE_ENV !== "production" ? `objectSet ${stableKey} [DISABLED]` : void 0);
62
71
  }
72
+ const initialValue = objectTypeChanged ? undefined : previousPayloadRef.current;
63
73
  return makeExternalStore(observer => {
64
74
  const subscription = observableClient.observeObjectSet(baseObjectSet, {
65
75
  where: otherOptions.where,
@@ -75,9 +85,14 @@ export function useObjectSet(baseObjectSet, options = {}) {
75
85
  streamUpdates
76
86
  }, observer);
77
87
  return subscription;
78
- }, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0);
79
- }, [enabled, observableClient, stableKey, streamUpdates]);
88
+ }, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0, initialValue);
89
+ }, [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged]);
80
90
  const payload = React.useSyncExternalStore(subscribe, getSnapShot);
91
+ React.useEffect(() => {
92
+ if (payload) {
93
+ previousPayloadRef.current = payload;
94
+ }
95
+ }, [payload]);
81
96
  return {
82
97
  data: payload?.resolvedList,
83
98
  isLoading: payload?.status === "loading" || !payload && true || false,
@@ -1 +1 @@
1
- {"version":3,"file":"useObjectSet.js","names":["computeObjectSetCacheKey","React","makeExternalStore","OsdkContext2","useObjectSet","baseObjectSet","options","observableClient","useContext","enabled","streamUpdates","otherOptions","stableKey","where","withProperties","union","intersect","subtract","pivotTo","pageSize","orderBy","subscribe","getSnapShot","useMemo","unsubscribe","process","env","NODE_ENV","observer","subscription","observeObjectSet","dedupeInterval","dedupeIntervalMs","autoFetchMore","payload","useSyncExternalStore","data","resolvedList","isLoading","status","error","undefined","fetchMore","objectSet"],"sources":["useObjectSet.tsx"],"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 {\n DerivedProperty,\n LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport {\n computeObjectSetCacheKey,\n type ObserveObjectSetArgs,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseObjectSetOptions<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q, RDPs>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type)\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Enable streaming updates via websocket subscription.\n * When true, the object set will automatically update when matching objects are\n * added, updated, or removed.\n *\n * @default false\n */\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\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 * @example\n * // Dependent query - wait for filter selection\n * const { data: filteredObjects } = useObjectSet(MyObject.all(), {\n * where: { status: selectedStatus },\n * enabled: !!selectedStatus\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs>;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet<\n Q extends ObjectTypeDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs>,\n options: UseObjectSetOptions<Q, RDPs> = {},\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, streamUpdates, ...otherOptions } = options;\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs and enabled are excluded as they don't affect the data\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n });\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey} [DISABLED]`\n : void 0,\n );\n }\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n const subscription = observableClient.observeObjectSet(\n baseObjectSet as ObjectSet<Q>,\n {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates,\n },\n observer,\n );\n return subscription;\n },\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey}`\n : void 0,\n );\n },\n [enabled, observableClient, stableKey, streamUpdates],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n data: payload?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: payload?.status === \"loading\" || (!payload && true) || false,\n error: payload && \"error\" in payload\n ? payload.error\n : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet as ObjectSet<Q, RDPs> || baseObjectSet,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SACEA,wBAAwB,QAEnB,kCAAkC;AACzC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAmIhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAK1BC,aAAqC,EACrCC,OAAqC,GAAG,CAAC,CAAC,EACb;EAC7B,MAAM;IAAEC;EAAiB,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,YAAY,CAAC;EAE3D,MAAM;IAAEM,OAAO,GAAG,IAAI;IAAEC,aAAa;IAAE,GAAGC;EAAa,CAAC,GAAGL,OAAO;;EAElE;EACA;EACA,MAAMM,SAAS,GAAGZ,wBAAwB,CAACK,aAAa,EAAE;IACxDQ,KAAK,EAAEF,YAAY,CAACE,KAAK;IACzBC,cAAc,EAAEH,YAAY,CAAC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AAS,EAAE,GACxB,KAAK,CACX,CAAC;EACH,CAAC,EACD,CAACH,OAAO,EAAEF,gBAAgB,EAAEK,SAAS,EAAEF,aAAa,CACtD,CAAC;EAED,MAAMwB,OAAO,GAAGjC,KAAK,CAACkC,oBAAoB,CAACd,SAAS,EAAEC,WAAW,CAAC;EAElE,OAAO;IACLc,IAAI,EAAEF,OAAO,EAAEG,YAKZ;IACHC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS,IAAK,CAACL,OAAO,IAAI,IAAK,IAAI,KAAK;IACvEM,KAAK,EAAEN,OAAO,IAAI,OAAO,IAAIA,OAAO,GAChCA,OAAO,CAACM,KAAK,GACbC,SAAS;IACbC,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,SAAS,EAAET,OAAO,EAAES,SAAS,IAA0BtC;EACzD,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useObjectSet.js","names":["computeObjectSetCacheKey","React","makeExternalStore","OsdkContext2","useObjectSet","baseObjectSet","options","observableClient","useContext","enabled","streamUpdates","otherOptions","objectTypeKey","$objectSetInternals","def","apiName","previousObjectTypeRef","useRef","previousPayloadRef","objectTypeChanged","current","stableKey","where","withProperties","union","intersect","subtract","pivotTo","pageSize","orderBy","subscribe","getSnapShot","useMemo","unsubscribe","process","env","NODE_ENV","initialValue","undefined","observer","subscription","observeObjectSet","dedupeInterval","dedupeIntervalMs","autoFetchMore","payload","useSyncExternalStore","useEffect","data","resolvedList","isLoading","status","error","fetchMore","objectSet"],"sources":["useObjectSet.tsx"],"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 {\n DerivedProperty,\n LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\n\nimport {\n computeObjectSetCacheKey,\n type ObserveObjectSetArgs,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore, type Snapshot } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseObjectSetOptions<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q, RDPs>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type)\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n\n /**\n * Automatically fetch additional pages on initial load.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Enable streaming updates via websocket subscription.\n * When true, the object set will automatically update when matching objects are\n * added, updated, or removed.\n *\n * @default false\n */\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\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 * @example\n * // Dependent query - wait for filter selection\n * const { data: filteredObjects } = useObjectSet(MyObject.all(), {\n * where: { status: selectedStatus },\n * enabled: !!selectedStatus\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs>;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet<\n Q extends ObjectTypeDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs>,\n options: UseObjectSetOptions<Q, RDPs> = {},\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, streamUpdates, ...otherOptions } = options;\n\n // Track object type to detect when we switch to a different object type\n const objectTypeKey = baseObjectSet.$objectSetInternals.def.apiName;\n const previousObjectTypeRef = React.useRef<string>(objectTypeKey);\n const previousPayloadRef = React.useRef<\n Snapshot<ObserveObjectSetArgs<Q, RDPs>> | undefined\n >();\n\n const objectTypeChanged = previousObjectTypeRef.current !== objectTypeKey;\n if (objectTypeChanged) {\n previousObjectTypeRef.current = objectTypeKey;\n }\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs and enabled are excluded as they don't affect the data\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n });\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey} [DISABLED]`\n : void 0,\n );\n }\n\n const initialValue = objectTypeChanged\n ? undefined\n : previousPayloadRef.current;\n\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n const subscription = observableClient.observeObjectSet(\n baseObjectSet as ObjectSet<Q>,\n {\n where: otherOptions.where,\n withProperties: otherOptions.withProperties,\n union: otherOptions.union,\n intersect: otherOptions.intersect,\n subtract: otherOptions.subtract,\n pivotTo: otherOptions.pivotTo,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,\n autoFetchMore: otherOptions.autoFetchMore,\n streamUpdates,\n },\n observer,\n );\n return subscription;\n },\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey}`\n : void 0,\n initialValue,\n );\n },\n [enabled, observableClient, stableKey, streamUpdates, objectTypeChanged],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n React.useEffect(() => {\n if (payload) {\n previousPayloadRef.current = payload;\n }\n }, [payload]);\n\n return {\n data: payload?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: payload?.status === \"loading\" || (!payload && true) || false,\n error: payload && \"error\" in payload\n ? payload.error\n : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet as ObjectSet<Q, RDPs> || baseObjectSet,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SACEA,wBAAwB,QAEnB,kCAAkC;AACzC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAuB,wBAAwB;AACzE,SAASC,YAAY,QAAQ,mBAAmB;AAmIhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAK1BC,aAAqC,EACrCC,OAAqC,GAAG,CAAC,CAAC,EACb;EAC7B,MAAM;IAAEC;EAAiB,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,YAAY,CAAC;EAE3D,MAAM;IAAEM,OAAO,GAAG,IAAI;IAAEC,aAAa;IAAE,GAAGC;EAAa,CAAC,GAAGL,OAAO;;EAElE;EACA,MAAMM,aAAa,GAAGP,aAAa,CAACQ,mBAAmB,CAACC,GAAG,CAACC,OAAO;EACnE,MAAMC,qBAAqB,GAAGf,KAAK,CAACgB,MAAM,CAASL,aAAa,CAAC;EACjE,MAAMM,kBAAkB,GAAGjB,KAAK,CAACgB,MAAM,CAErC,CAAC;EAEH,MAAME,iBAAiB,GAAGH,qBAAqB,CAACI,OAAO,KAAKR,aAAa;EACzE,IAAIO,iBAAiB,EAAE;IACrBH,qBAAqB,CAACI,OAAO,GAAGR,aAAa;EAC/C;;EAEA;EACA;EACA,MAAMS,SAAS,GAAGrB,wBAAwB,CAACK,aAAa,EAAE;IACxDiB,KAAK,EAAEX,YAAY,CAACW,KAAK;IACzBC,cAAc,EAAE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ACD6B,QACF,CAAC;MACD,OAAOC,YAAY;IACrB,CAAC,EACDN,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,aAAaf,SAAS,EAAE,GACxB,KAAK,CAAC,EACVgB,YACF,CAAC;EACH,CAAC,EACD,CAAC5B,OAAO,EAAEF,gBAAgB,EAAEc,SAAS,EAAEX,aAAa,EAAES,iBAAiB,CACzE,CAAC;EAED,MAAM0B,OAAO,GAAG5C,KAAK,CAAC6C,oBAAoB,CAAChB,SAAS,EAAEC,WAAW,CAAC;EAClE9B,KAAK,CAAC8C,SAAS,CAAC,MAAM;IACpB,IAAIF,OAAO,EAAE;MACX3B,kBAAkB,CAACE,OAAO,GAAGyB,OAAO;IACtC;EACF,CAAC,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,OAAO;IACLG,IAAI,EAAEH,OAAO,EAAEI,YAKZ;IACHC,SAAS,EAAEL,OAAO,EAAEM,MAAM,KAAK,SAAS,IAAK,CAACN,OAAO,IAAI,IAAK,IAAI,KAAK;IACvEO,KAAK,EAAEP,OAAO,IAAI,OAAO,IAAIA,OAAO,GAChCA,OAAO,CAACO,KAAK,GACbd,SAAS;IACbe,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,SAAS,EAAET,OAAO,EAAES,SAAS,IAA0BjD;EACzD,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","OsdkContext2","useOsdkAction","actionDef","observableClient","useContext","error","setError","useState","data","setData","isPending","setPending","isValidating","setValidating","validationResult","setValidationResult","abortControllerRef","useRef","applyAction","useCallback","hookArgs","current","abort","undefined","Array","isArray","updates","args","map","a","$optimisticUpdate","push","r","optimisticUpdate","ctx","update","e","actionValidation","unknown","validateAction","abortController","AbortController","result","signal","aborted","Error","name","useEffect"],"sources":["useOsdkAction.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ActionDefinition, ActionValidationResponse } from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> =\n & Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]:\n ObservableClient.ApplyActionOptions[K];\n };\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) => Promise<unknown>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: unknown;\n\n isPending: boolean;\n isValidating: boolean;\n\n /**\n * Validates the action with the provided arguments without executing it.\n * Calling this function again before the previous validation finishes will cancel\n * the first validation and start a new one.\n * @param args The action arguments to validate\n * @returns A promise that resolves to the validation response, or undefined if aborted\n */\n validateAction: (\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse | undefined>;\n\n validationResult?: ActionValidationResponse;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q,\n): UseOsdkActionResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<unknown>();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState<\n ActionValidationResponse | undefined\n >();\n const abortControllerRef = React.useRef<AbortController | null>(null);\n\n const applyAction = React.useCallback(async function applyAction(\n hookArgs: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n\n setPending(true);\n setError(undefined);\n\n if (Array.isArray(hookArgs)) {\n const updates: Array<\n ObservableClient.ApplyActionOptions[\"optimisticUpdate\"]\n > = [];\n const args = hookArgs.map(a => {\n const { $optimisticUpdate, ...args } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: (ctx) => {\n for (const update of updates) {\n update?.(ctx);\n }\n },\n });\n setData(r);\n return r;\n } else {\n const { $optimisticUpdate, ...args } = hookArgs;\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n } finally {\n setPending(false);\n }\n }, [observableClient, actionDef, isValidating]);\n\n const validateAction = React.useCallback(async function validateAction(\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ): Promise<ActionValidationResponse | undefined> {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n setValidating(true);\n setError(undefined);\n\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n }, [observableClient, actionDef, isPending]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n };\n }, []);\n\n return {\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,qBAAqB,QAAQ,cAAc;AAKpD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,mBAAmB;AAuChD,OAAO,SAASC,aAAaA,CAC3BC,SAAY,EACY;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGJ,KAAK,CAACK,UAAU,CAACJ,YAAY,CAAC;EAC3D,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAGP,KAAK,CAACQ,QAAQ,CAAkC,CAAC;EAC3E,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,KAAK,CAACQ,QAAQ,CAAU,CAAC;EACjD,MAAM,CAACG,SAAS,EAAEC,UAAU,CAAC,GAAGZ,KAAK,CAACQ,QAAQ,CAAC,KAAK,CAAC;EACrD,MAAM,CAACK,YAAY,EAAEC,aAAa,CAAC,GAAGd,KAAK,CAACQ,QAAQ,CAAC,KAAK,CAAC;EAC3D,MAAM,CAACO,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGhB,KAAK,CAACQ,QAAQ,CAE5D,CAAC;EACH,MAAMS,kBAAkB,GAAGjB,KAAK,CAACkB,MAAM,CAAyB,IAAI,CAAC;EAErE,MAAMC,WAAW,GAAGnB,KAAK,CAACoB,WAAW,CAAC,gBACpCC,QAA4D,EAC5D;IACA,IAAI;MACF;MACA,IAAIR,YAAY,IAAII,kBAAkB,CAACK,OAAO,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V,gBAAgB,EAAED,SAAS,EAAEQ,SAAS,CAAC,CAAC;;EAE5C;EACAX,KAAK,CAACgD,SAAS,CAAC,MAAM;IACpB,OAAO,MAAM;MACX,IAAI/B,kBAAkB,CAACK,OAAO,EAAE;QAC9BL,kBAAkB,CAACK,OAAO,CAACC,KAAK,CAAC,CAAC;MACpC;IACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACLJ,WAAW;IACXqB,cAAc;IACdlC,KAAK;IACLG,IAAI;IACJE,SAAS;IACTE,YAAY;IACZE;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","OsdkContext2","useOsdkAction","actionDef","observableClient","useContext","error","setError","useState","data","setData","isPending","setPending","isValidating","setValidating","validationResult","setValidationResult","abortControllerRef","useRef","applyAction","useCallback","hookArgs","current","abort","undefined","Array","isArray","updates","args","map","a","$optimisticUpdate","push","r","optimisticUpdate","ctx","update","e","actionValidation","unknown","validateAction","abortController","AbortController","result","signal","aborted","Error","name","useEffect"],"sources":["useOsdkAction.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionEditResponse,\n ActionValidationResponse,\n} from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> =\n & Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]:\n ObservableClient.ApplyActionOptions[K];\n };\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) => Promise<ActionEditResponse | undefined>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: ActionEditResponse | undefined;\n\n isPending: boolean;\n isValidating: boolean;\n\n /**\n * Validates the action with the provided arguments without executing it.\n * Calling this function again before the previous validation finishes will cancel\n * the first validation and start a new one.\n * @param args The action arguments to validate\n * @returns A promise that resolves to the validation response, or undefined if aborted\n */\n validateAction: (\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse | undefined>;\n\n validationResult?: ActionValidationResponse;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q,\n): UseOsdkActionResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<ActionEditResponse | undefined>();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState<\n ActionValidationResponse | undefined\n >();\n const abortControllerRef = React.useRef<AbortController | null>(null);\n\n const applyAction = React.useCallback(async function applyAction(\n hookArgs: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n\n setPending(true);\n setError(undefined);\n\n if (Array.isArray(hookArgs)) {\n const updates: Array<\n ObservableClient.ApplyActionOptions[\"optimisticUpdate\"]\n > = [];\n const args = hookArgs.map(a => {\n const { $optimisticUpdate, ...args } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: (ctx) => {\n for (const update of updates) {\n update?.(ctx);\n }\n },\n });\n setData(r);\n return r;\n } else {\n const { $optimisticUpdate, ...args } = hookArgs;\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n } finally {\n setPending(false);\n }\n }, [observableClient, actionDef, isValidating]);\n\n const validateAction = React.useCallback(async function validateAction(\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ): Promise<ActionValidationResponse | undefined> {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n setValidating(true);\n setError(undefined);\n\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n }, [observableClient, actionDef, isPending]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n };\n }, []);\n\n return {\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,qBAAqB,QAAQ,cAAc;AAKpD,OAAOC,KAAK,MAAM,OAAO;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ore","OsdkContext2","useOsdkObject","args","observableClient","useContext","isInstanceSignature","enabled","mode","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","unsubscribe","observer","observeObject","payload","useSyncExternalStore","error","status","Error","object","isLoading","isOptimistic","forceUpdate"],"sources":["useOsdkObject.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeDefinition, Osdk, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObserveObjectArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n obj: Osdk.Instance<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n ...args:\n | [obj: Osdk.Instance<Q>, enabled?: boolean]\n | [type: Q, primaryKey: PrimaryKeyType<Q>, enabled?: boolean]\n): UseOsdkObjectResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // Check if first arg is an instance to discriminate signatures\n // TypeScript cannot narrow rest parameter unions with optional parameters,\n // so we must use type assertions after runtime discrimination\n const isInstanceSignature = \"$objectType\" in args[0];\n\n // Extract enabled flag - 2nd param for instance signature, 3rd for type signature\n const enabled = isInstanceSignature\n ? (typeof args[1] === \"boolean\" ? args[1] : true)\n : (typeof args[2] === \"boolean\" ? args[2] : true);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = isInstanceSignature ? \"offline\" : undefined;\n const objectType = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$objectType\n : (args[0] as Q).apiName;\n const primaryKey = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$primaryKey\n : (args[1] as PrimaryKeyType<Q>);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n `object ${objectType} ${primaryKey} [DISABLED]`,\n );\n }\n return makeExternalStore<ObserveObjectArgs<Q>>(\n (observer) =>\n observableClient.observeObject(\n objectType,\n primaryKey,\n {\n mode,\n },\n observer,\n ),\n `object ${objectType} ${primaryKey}`,\n );\n },\n [enabled, observableClient, objectType, primaryKey, mode],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to load object\");\n }\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: payload?.status === \"loading\",\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate: () => {\n throw new Error(\"not implemented\");\n },\n };\n}\n"],"m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IAAIG,UAAU,aACpC,CAAC;IACH;IACA,OAAOb,iBAAiB,CACrBmB,QAAQ,IACPf,gBAAgB,CAACgB,aAAa,CAC5BV,UAAU,EACVG,UAAU,EACV;MACEL;IACF,CAAC,EACDW,QACF,CAAC,EACH,UAAUT,UAAU,IAAIG,UAAU,EACpC,CAAC;EACH,CAAC,EACD,CAACN,OAAO,EAAEH,gBAAgB,EAAEM,UAAU,EAAEG,UAAU,EAAEL,IAAI,CAC1D,CAAC;EAED,MAAMa,OAAO,GAAGtB,KAAK,CAACuB,oBAAoB,CAACP,SAAS,EAAEC,WAAW,CAAC;EAElE,IAAIO,KAAwB;EAC5B,IAAIF,OAAO,IAAI,OAAO,IAAIA,OAAO,IAAIA,OAAO,CAACE,KAAK,EAAE;IAClDA,KAAK,GAAGF,OAAO,CAACE,KAAK;EACvB,CAAC,MAAM,IAAIF,OAAO,EAAEG,MAAM,KAAK,OAAO,EAAE;IACtCD,KAAK,GAAG,IAAIE,KAAK,CAAC,uBAAuB,CAAC;EAC5C;EAEA,OAAO;IACLC,MAAM,EAAEL,OAAO,EAAEK,MAAsC;IACvDC,SAAS,EAAEN,OAAO,EAAEG,MAAM,KAAK,SAAS;IACxCI,YAAY,EAAE,CAAC,CAACP,OAAO,EAAEO,YAAY;IACrCL,KAAK;IACLM,WAAW,EAAEA,CAAA,KAAM;MACjB,MAAM,IAAIJ,KAAK,CAAC,iBAAiB,CAAC;IACpC;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","isInstanceSignature","enabled","mode","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","unsubscribe","observer","observeObject","payload","useSyncExternalStore","error","status","Error","object","isLoading","isOptimistic","forceUpdate"],"sources":["useOsdkObject.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeDefinition, Osdk, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObserveObjectCallbackArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n obj: Osdk.Instance<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n ...args:\n | [obj: Osdk.Instance<Q>, enabled?: boolean]\n | [type: Q, primaryKey: PrimaryKeyType<Q>, enabled?: boolean]\n): UseOsdkObjectResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // Check if first arg is an instance to discriminate signatures\n // TypeScript cannot narrow rest parameter unions with optional parameters,\n // so we must use type assertions after runtime discrimination\n const isInstanceSignature = \"$objectType\" in args[0];\n\n // Extract enabled flag - 2nd param for instance signature, 3rd for type signature\n const enabled = isInstanceSignature\n ? (typeof args[1] === \"boolean\" ? args[1] : true)\n : (typeof args[2] === \"boolean\" ? args[2] : true);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = isInstanceSignature ? \"offline\" : undefined;\n const objectType = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$objectType\n : (args[0] as Q).apiName;\n const primaryKey = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$primaryKey\n : (args[1] as PrimaryKeyType<Q>);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectCallbackArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n `object ${objectType} ${primaryKey} [DISABLED]`,\n );\n }\n return makeExternalStore<ObserveObjectCallbackArgs<Q>>(\n (observer) =>\n observableClient.observeObject(\n objectType,\n primaryKey,\n {\n mode,\n },\n observer,\n ),\n `object ${objectType} ${primaryKey}`,\n );\n },\n [enabled, observableClient, objectType, primaryKey, mode],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to load object\");\n }\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: payload?.status === \"loading\",\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate: () => {\n throw new Error(\"not implemented\");\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;;AAehD;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA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AAEG,UAAU,EAAEL,IAAI,CAC1D,CAAC;EAED,MAAMa,OAAO,GAAGtB,KAAK,CAACuB,oBAAoB,CAACP,SAAS,EAAEC,WAAW,CAAC;EAElE,IAAIO,KAAwB;EAC5B,IAAIF,OAAO,IAAI,OAAO,IAAIA,OAAO,IAAIA,OAAO,CAACE,KAAK,EAAE;IAClDA,KAAK,GAAGF,OAAO,CAACE,KAAK;EACvB,CAAC,MAAM,IAAIF,OAAO,EAAEG,MAAM,KAAK,OAAO,EAAE;IACtCD,KAAK,GAAG,IAAIE,KAAK,CAAC,uBAAuB,CAAC;EAC5C;EAEA,OAAO;IACLC,MAAM,EAAEL,OAAO,EAAEK,MAAsC;IACvDC,SAAS,EAAEN,OAAO,EAAEG,MAAM,KAAK,SAAS;IACxCI,YAAY,EAAE,CAAC,CAACP,OAAO,EAAEO,YAAY;IACrCL,KAAK;IACLM,WAAW,EAAEA,CAAA,KAAM;MACjB,MAAM,IAAIJ,KAAK,CAAC,iBAAiB,CAAC;IACpC;EACF,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","options","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","withProperties","autoFetchMore","intersectWith","pivotTo","enabled","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","stableIntersectWith","stableOrderBy","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","apiName","observer","observeList","dedupeInterval","listPayload","useSyncExternalStore","error","status","Error","fetchMore","data","resolvedList","isLoading","isOptimistic"],"sources":["useOsdkObjects.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 {\n DerivedProperty,\n InterfaceDefinition,\n LinkedType,\n LinkNames,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObserveObjectsArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nimport type { InferRdpTypes } from \"./types.js\";\n\nexport interface UseOsdkObjectsOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n WithProps extends DerivedProperty.Clause<T> | undefined = undefined,\n> {\n /**\n * Standard OSDK Where with RDP support\n */\n where?: WhereClause<T, InferRdpTypes<T, WithProps>>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Define derived properties (RDPs) to be computed server-side and attached to each object.\n * These properties will be available on the returned objects alongside their regular properties.\n */\n withProperties?: WithProps;\n\n /**\n * Intersect the results with additional object sets.\n * Each element defines a where clause for an object set to intersect with.\n * The final result will only include objects that match ALL conditions.\n */\n intersectWith?: Array<{\n where: WhereClause<T, InferRdpTypes<T, WithProps>>;\n }>;\n\n /**\n * Pivot to related objects through a link.\n * This changes the return type from T to the linked object type.\n */\n pivotTo?: LinkNames<T>;\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n *\n * Note: When using `autoFetchMore: true` with large datasets, the initial\n * load may take significant time. Consider using a specific number instead\n * or implementing virtual scrolling.\n *\n * @example\n * // Fetch all todos at once\n * const { data } = useOsdkObjects(Todo, { autoFetchMore: true })\n *\n * @example\n * // Fetch at least 100 todos (with 25 per page, fetches 4 pages)\n * const { data } = useOsdkObjects(Todo, {\n * autoFetchMore: 100,\n * pageSize: 25\n * })\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\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 * @example\n * // Dependent query - wait for parent data\n * const { data: employee } = useOsdkObject(Employee, employeeId);\n * const { data: reports } = useOsdkObjects(Employee, {\n * where: { managerId: employee?.id },\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n fetchMore: (() => Promise<void>) | undefined;\n data: Osdk.Instance<T>[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition,\n L extends LinkNames<Q>,\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q> & { pivotTo: L },\n): UseOsdkListResult<LinkedType<Q, L>>;\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined,\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, WP>,\n): UseOsdkListResult<Q>;\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined,\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, WP>,\n): UseOsdkListResult<Q> | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>> {\n const {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n withProperties,\n autoFetchMore,\n intersectWith,\n pivotTo,\n enabled = true,\n } = options ?? {};\n const { observableClient } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause<Q>(where ?? {});\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableIntersectWith = React.useMemo(\n () => intersectWith,\n [JSON.stringify(intersectWith)],\n );\n\n const stableOrderBy = React.useMemo(\n () => orderBy,\n [JSON.stringify(orderBy)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectsArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)} [DISABLED]`\n : void 0,\n );\n }\n return makeExternalStore<ObserveObjectsArgs<Q>>(\n (observer) =>\n observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy: stableOrderBy,\n streamUpdates,\n withProperties: stableWithProperties,\n autoFetchMore,\n ...(stableIntersectWith\n ? { intersectWith: stableIntersectWith }\n : {}),\n ...(pivotTo ? { pivotTo } : {}),\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n );\n },\n [\n enabled,\n observableClient,\n type,\n canonWhere,\n dedupeIntervalMs,\n pageSize,\n stableOrderBy,\n streamUpdates,\n stableWithProperties,\n autoFetchMore,\n stableIntersectWith,\n pivotTo,\n ],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n\n return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAoKhD,OAAO,SAASC,cAAcA,CAI5BC,IAAO,EACPC,OAAsC,EACiC;EACvE,MAAM;IACJC,QAAQ;IACRC,OAAO;IACPC,gBAAgB;IAChBC,KAAK,GAAG,CAAC,CAAC;IACVC,aAAa;IACbC,cAAc;IACdC,aAAa;IACbC,aAAa;IACbC,OAAO;IACPC,OAAO,GAAG;EACZ,CAAC,GAAGV,OAAO,IAAI,CAAC,CAAC;EACjB,MAAM;IAAEW;EAAiB,CAA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AC,CAAC,CAAC;MACP,IAAIV,OAAO,GAAG;QAAEA;MAAQ,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC,EAAEmB,QAAQ,CAAC,EACdJ,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQ3B,IAAI,CAAC4B,OAAO,IAAIV,IAAI,CAACC,SAAS,CAACL,UAAU,CAAC,EAAE,GACpD,KAAK,CACX,CAAC;EACH,CAAC,EACD,CACEH,OAAO,EACPC,gBAAgB,EAChBZ,IAAI,EACJc,UAAU,EACVV,gBAAgB,EAChBF,QAAQ,EACRmB,aAAa,EACbf,aAAa,EACbU,oBAAoB,EACpBR,aAAa,EACbY,mBAAmB,EACnBV,OAAO,CAEX,CAAC;EAED,MAAMsB,WAAW,GAAGpC,KAAK,CAACqC,oBAAoB,CAACX,SAAS,EAAEC,WAAW,CAAC;EAEtE,IAAIW,KAAwB;EAC5B,IAAIF,WAAW,IAAI,OAAO,IAAIA,WAAW,IAAIA,WAAW,CAACE,KAAK,EAAE;IAC9DA,KAAK,GAAGF,WAAW,CAACE,KAAK;EAC3B,CAAC,MAAM,IAAIF,WAAW,EAAEG,MAAM,KAAK,OAAO,EAAE;IAC1CD,KAAK,GAAG,IAAIE,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEA,OAAO;IACLC,SAAS,EAAEL,WAAW,EAAEK,SAAS;IACjCH,KAAK;IACLI,IAAI,EAAEN,WAAW,EAAEO,YAAY;IAC/BC,SAAS,EAAER,WAAW,EAAEG,MAAM,KAAK,SAAS;IAC5CM,YAAY,EAAET,WAAW,EAAES,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","options","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","withProperties","autoFetchMore","intersectWith","pivotTo","enabled","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","stableIntersectWith","stableOrderBy","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","apiName","observer","observeList","dedupeInterval","listPayload","useSyncExternalStore","error","status","Error","fetchMore","data","resolvedList","isLoading","isOptimistic"],"sources":["useOsdkObjects.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 {\n DerivedProperty,\n InterfaceDefinition,\n LinkedType,\n LinkNames,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObserveObjectsCallbackArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nimport type { InferRdpTypes } from \"./types.js\";\n\nexport interface UseOsdkObjectsOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n WithProps extends DerivedProperty.Clause<T> | undefined = undefined,\n> {\n /**\n * Standard OSDK Where with RDP support\n */\n where?: WhereClause<T, InferRdpTypes<T, WithProps>>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Define derived properties (RDPs) to be computed server-side and attached to each object.\n * These properties will be available on the returned objects alongside their regular properties.\n */\n withProperties?: WithProps;\n\n /**\n * Intersect the results with additional object sets.\n * Each element defines a where clause for an object set to intersect with.\n * The final result will only include objects that match ALL conditions.\n */\n intersectWith?: Array<{\n where: WhereClause<T, InferRdpTypes<T, WithProps>>;\n }>;\n\n /**\n * Pivot to related objects through a link.\n * This changes the return type from T to the linked object type.\n */\n pivotTo?: LinkNames<T>;\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n *\n * Note: When using `autoFetchMore: true` with large datasets, the initial\n * load may take significant time. Consider using a specific number instead\n * or implementing virtual scrolling.\n *\n * @example\n * // Fetch all todos at once\n * const { data } = useOsdkObjects(Todo, { autoFetchMore: true })\n *\n * @example\n * // Fetch at least 100 todos (with 25 per page, fetches 4 pages)\n * const { data } = useOsdkObjects(Todo, {\n * autoFetchMore: 100,\n * pageSize: 25\n * })\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\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 * @example\n * // Dependent query - wait for parent data\n * const { data: employee } = useOsdkObject(Employee, employeeId);\n * const { data: reports } = useOsdkObjects(Employee, {\n * where: { managerId: employee?.id },\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n fetchMore: (() => Promise<void>) | undefined;\n data:\n | Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>[]\n | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition,\n L extends LinkNames<Q>,\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q> & { pivotTo: L },\n): UseOsdkListResult<LinkedType<Q, L>>;\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined,\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, WP>,\n): UseOsdkListResult<Q, InferRdpTypes<Q, WP>>;\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined,\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, WP>,\n):\n | UseOsdkListResult<Q, InferRdpTypes<Q, WP>>\n | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>>\n{\n const {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n withProperties,\n autoFetchMore,\n intersectWith,\n pivotTo,\n enabled = true,\n } = options ?? {};\n const { observableClient } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause<\n Q,\n InferRdpTypes<Q, WP>\n >(where ?? {});\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableIntersectWith = React.useMemo(\n () => intersectWith,\n [JSON.stringify(intersectWith)],\n );\n\n const stableOrderBy = React.useMemo(\n () => orderBy,\n [JSON.stringify(orderBy)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<\n ObserveObjectsCallbackArgs<Q, InferRdpTypes<Q, WP>>\n >(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)} [DISABLED]`\n : void 0,\n );\n }\n return makeExternalStore<\n ObserveObjectsCallbackArgs<Q, InferRdpTypes<Q, WP>>\n >(\n (observer) =>\n observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy: stableOrderBy,\n streamUpdates,\n withProperties: stableWithProperties,\n autoFetchMore,\n ...(stableIntersectWith\n ? { intersectWith: stableIntersectWith }\n : {}),\n ...(pivotTo ? { pivotTo } : {}),\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n );\n },\n [\n enabled,\n observableClient,\n type,\n canonWhere,\n dedupeIntervalMs,\n pageSize,\n stableOrderBy,\n streamUpdates,\n stableWithProperties,\n autoFetchMore,\n stableIntersectWith,\n pivotTo,\n ],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n\n return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\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,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAuKhD,OAAO,SAASC,cAAcA,CAI5BC,IAAO,EACPC,OAAsC,EAIxC;EACE,MAAM;IACJC,QAAQ;IACRC,OAAO;IACPC,gBAAgB;IAChBC,KAAK,GAAG,CAAC,CAAC;IACVC,aAAa;IACbC,cAAc;IACdC,aAAa;IACbC,aAAa;IACbC,OAAO;IACPC,OAAO,GAAG;EACZ,CAAC,GAAGV,OAAO,IAAI,CAAC,CAAC;EACjB,MAAM;IAAEW;EAAiB,CAAC,GAAGhB,KAAK,CAACiB,UAAU,CAACf,YAAY,CAAC;;EAE3D;AACF;AACA;AACA;EACE,MAAMgB,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAGzDV,KAAK,IAAI,CAAC,CAAC,CAAC;EAEd,MAAMW,oBAAoB,GAAGpB,KAAK,CAACqB,OAAO,CACxC,MAAMV,cAAc,EACpB,CAACW,IAAI,CAACC,SAAS,CAACZ,cAAc,CAAC,CACjC,CAAC;EAED,MAAMa,mBAAmB,GAAGxB,KAAK,CAACqB,OAAO,CACvC,MAAMR,aAAa,EACnB,CAACS,IAAI,CAACC,SAAS,CAACV,aAAa,CAAC,CAChC,CAAC;EAED,MAAMY,aAAa,GAAGzB,KAAK,CAACqB,OAAO,CACjC,MAAMd,OAAO,EACb,CAACe,IAAI,CAACC,SAAS,CAAChB,OAAO,CAAC,CAC1B,CAAC;EAED,MAAM;IAAEmB,SAAS;IAAEC;EAAY,CAAC,GAAG3B,KAAK,CAACqB,OAAO,CAC9C,MAAM;IACJ,IAAI,CAACN,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9DA,KAAK,GAAGF,WAAW,CAACE,KAAK;EAC3B,CAAC,MAAM,IAAIF,WAAW,EAAEG,MAAM,KAAK,OAAO,EAAE;IAC1CD,KAAK,GAAG,IAAIE,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEA,OAAO;IACLC,SAAS,EAAEL,WAAW,EAAEK,SAAS;IACjCH,KAAK;IACLI,IAAI,EAAEN,WAAW,EAAEO,YAAY;IAC/BC,SAAS,EAAER,WAAW,EAAEG,MAAM,KAAK,SAAS;IAC5CM,YAAY,EAAET,WAAW,EAAES,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
@@ -15,6 +15,9 @@
15
15
  */
16
16
 
17
17
  export { OsdkProvider2 } from "../new/OsdkProvider2.js";
18
+ export { useCurrentFoundryUser } from "../new/platform-apis/admin/useCurrentFoundryUser.js";
19
+ export { useFoundryUser } from "../new/platform-apis/admin/useFoundryUser.js";
20
+ export { useFoundryUsersList } from "../new/platform-apis/admin/useFoundryUsersList.js";
18
21
  export { useLinks } from "../new/useLinks.js";
19
22
  export { useObjectSet } from "../new/useObjectSet.js";
20
23
  export { useOsdkAction } from "../new/useOsdkAction.js";
@@ -1 +1 @@
1
- {"version":3,"file":"experimental.js","names":["OsdkProvider2","useLinks","useObjectSet","useOsdkAction","useOsdkAggregation","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata","useDebouncedCallback"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useLinks } from \"../new/useLinks.js\";\nexport { useObjectSet } from \"../new/useObjectSet.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport type { UseOsdkAggregationResult } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkAggregation } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\nexport { useDebouncedCallback } from \"../utils/useDebouncedCallback.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
1
+ {"version":3,"file":"experimental.js","names":["OsdkProvider2","useCurrentFoundryUser","useFoundryUser","useFoundryUsersList","useLinks","useObjectSet","useOsdkAction","useOsdkAggregation","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata","useDebouncedCallback"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useCurrentFoundryUser } from \"../new/platform-apis/admin/useCurrentFoundryUser.js\";\nexport { useFoundryUser } from \"../new/platform-apis/admin/useFoundryUser.js\";\nexport { useFoundryUsersList } from \"../new/platform-apis/admin/useFoundryUsersList.js\";\nexport { useLinks } from \"../new/useLinks.js\";\nexport { useObjectSet } from \"../new/useObjectSet.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport type { UseOsdkAggregationResult } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkAggregation } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\nexport { useDebouncedCallback } from \"../utils/useDebouncedCallback.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,qBAAqB,QAAQ,qDAAqD;AAC3F,SAASC,cAAc,QAAQ,8CAA8C;AAC7E,SAASC,mBAAmB,QAAQ,mDAAmD;AACvF,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
@@ -0,0 +1,74 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React from "react";
18
+ import { makeExternalStore } from "../new/makeExternalStore.js";
19
+ export function usePlatformQuery({
20
+ query,
21
+ queryName,
22
+ enabled = true
23
+ }) {
24
+ const observerRef = React.useRef();
25
+ const handleQuery = React.useCallback(() => {
26
+ const observer = observerRef.current;
27
+ if (observer == null) return;
28
+ observer.next({
29
+ status: "loading",
30
+ data: undefined
31
+ });
32
+ query().then(data => {
33
+ observer.next({
34
+ status: "success",
35
+ data
36
+ });
37
+ }).catch(err => {
38
+ observer.error(err);
39
+ });
40
+ }, [query]);
41
+ const {
42
+ subscribe,
43
+ getSnapShot
44
+ } = React.useMemo(() => {
45
+ if (!enabled) {
46
+ return makeExternalStore(() => ({
47
+ unsubscribe: () => {}
48
+ }), process.env.NODE_ENV !== "production" ? `${queryName} Query [DISABLED]` : undefined);
49
+ }
50
+ return makeExternalStore(observer => {
51
+ observerRef.current = observer;
52
+ handleQuery();
53
+ return {
54
+ unsubscribe: () => {
55
+ observerRef.current = undefined;
56
+ }
57
+ };
58
+ }, queryName);
59
+ }, [enabled, queryName, handleQuery]);
60
+ const payload = React.useSyncExternalStore(subscribe, getSnapShot);
61
+ let error;
62
+ if (payload && "error" in payload && payload.error != null) {
63
+ error = payload.error;
64
+ } else if (payload?.status === "error") {
65
+ error = new Error(`Failed to query platform API: ${queryName}`);
66
+ }
67
+ return {
68
+ data: payload?.data,
69
+ isLoading: payload?.status === "loading",
70
+ error,
71
+ refetch: handleQuery
72
+ };
73
+ }
74
+ //# sourceMappingURL=usePlatformQuery.js.map
@@ -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,WA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I,IAAI,EAAE;IAC1DA,KAAK,GAAGQ,OAAO,CAACR,KAAK;EACvB,CAAC,MAAM,IAAIQ,OAAO,EAAEd,MAAM,KAAK,OAAO,EAAE;IACtCM,KAAK,GAAG,IAAIU,KAAK,CAAC,iCAAiCzB,SAAS,EAAE,CAAC;EACjE;EAEA,OAAO;IACLU,IAAI,EAAEa,OAAO,EAAEb,IAAI;IACnBgB,SAAS,EAAEH,OAAO,EAAEd,MAAM,KAAK,SAAS;IACxCM,KAAK;IACLY,OAAO,EAAEvB;EACX,CAAC;AACH","ignoreList":[]}
@@ -4,7 +4,7 @@ export type Snapshot<X> = X & {
4
4
  } | (Partial<X> & {
5
5
  error?: Error
6
6
  }) | undefined;
7
- export declare function makeExternalStore<X>(createObservation: (callback: Observer<X | undefined>) => Unsubscribable, name?: string): {
7
+ export declare function makeExternalStore<X>(createObservation: (callback: Observer<X | undefined>) => Unsubscribable, _name?: string, initialValue?: Snapshot<X>): {
8
8
  subscribe: (notifyUpdate: () => void) => () => void
9
9
  getSnapShot: () => Snapshot<X>
10
10
  };
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cACE,UACA,sBACK,kCAAmC;AAE1C,YAAY,SAAS,KACjB,IAAI;CAAE,QAAQ;AAAO,KACpB,QAAQ,KAAK;CAAE,QAAQ;AAAO;AAGnC,OAAO,iBAAS,kBAAkB,GAChCA,oBAAoBC,UAAU,SAAS,mBAAmB,gBAC1DC,gBACC;CACD,YAAYC;CACZ,mBAAmB,SAAS;AAC7B","names":["createObservation: (callback: Observer<X | undefined>) => Unsubscribable","callback: Observer<X | undefined>","name?: string","notifyUpdate: () => void"],"sources":["../../../src/new/makeExternalStore.ts"],"version":3,"file":"makeExternalStore.d.ts"}
1
+ {"mappings":"AAgBA,cACE,UACA,sBACK,kCAAmC;AAE1C,YAAY,SAAS,KACjB,IAAI;CAAE,QAAQ;AAAO,KACpB,QAAQ,KAAK;CAAE,QAAQ;AAAO;AAGnC,OAAO,iBAAS,kBAAkB,GAChCA,oBAAoBC,UAAU,SAAS,mBAAmB,gBAC1DC,gBACAC,eAAe,SAAS,KACvB;CACD,YAAYC;CACZ,mBAAmB,SAAS;AAC7B","names":["createObservation: (callback: Observer<X | undefined>) => Unsubscribable","callback: Observer<X | undefined>","_name?: string","initialValue?: Snapshot<X>","notifyUpdate: () => void"],"sources":["../../../src/new/makeExternalStore.ts"],"version":3,"file":"makeExternalStore.d.ts"}
@@ -0,0 +1,28 @@
1
+ import { Admin } from "@osdk/foundry";
2
+ export interface UseCurrentFoundryUserOptions {
3
+ /**
4
+ * Enable or disable the query.
5
+ *
6
+ * When `false`, the query will not automatically execute.
7
+ *
8
+ * This is useful for:
9
+ * - Lazy/on-demand queries that should wait for user interaction
10
+ * - Dependent queries that need data from another query first
11
+ * - Conditional queries based on component state
12
+ *
13
+ * @default true
14
+ * });
15
+ */
16
+ enabled?: boolean;
17
+ }
18
+ export interface UseCurrentFoundryUserResult {
19
+ currentUser: Admin.User | undefined;
20
+ isLoading: boolean;
21
+ error: Error | undefined;
22
+ refetch: () => void;
23
+ }
24
+ /**
25
+ * Get the currently signed in User.
26
+ * @param options Options to control the query.
27
+ */
28
+ export declare function useCurrentFoundryUser({ enabled }?: UseCurrentFoundryUserOptions): UseCurrentFoundryUserResult;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,SAAS,aAAa,eAAgB;AAMtC,iBAAiB,6BAA6B;;;;;;;;;;;;;;CAc5C;AACD;AAED,iBAAiB,4BAA4B;CAC3C,aAAa,MAAM;CACnB;CAEA,OAAO;CAEP;AACD;;;;;AAMD,OAAO,iBAAS,sBACd,EAAE,SAA8C,GAA5B,+BACnB","names":[],"sources":["../../../../../src/new/platform-apis/admin/useCurrentFoundryUser.ts"],"version":3,"file":"useCurrentFoundryUser.d.ts"}