@osdk/react 0.9.0-beta.5 → 0.9.0-beta.6

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 (43) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js +2 -2
  3. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
  4. package/build/browser/new/platform-apis/admin/useFoundryUser.js +2 -2
  5. package/build/browser/new/platform-apis/admin/useFoundryUser.js.map +1 -1
  6. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js +2 -2
  7. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
  8. package/build/browser/new/useLinks.js +1 -1
  9. package/build/browser/new/useLinks.js.map +1 -1
  10. package/build/browser/new/useOsdkAggregation.js +1 -1
  11. package/build/browser/new/useOsdkAggregation.js.map +1 -1
  12. package/build/browser/new/useOsdkObject.js +1 -1
  13. package/build/browser/new/useOsdkObject.js.map +1 -1
  14. package/build/browser/new/useOsdkObjects.js +1 -1
  15. package/build/browser/new/useOsdkObjects.js.map +1 -1
  16. package/build/browser/utils/usePlatformQuery.js +1 -1
  17. package/build/browser/utils/usePlatformQuery.js.map +1 -1
  18. package/build/cjs/public/experimental.cjs +28 -378
  19. package/build/cjs/public/experimental.cjs.map +1 -1
  20. package/build/cjs/public/experimental.d.cts +7 -6
  21. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js +2 -2
  22. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
  23. package/build/esm/new/platform-apis/admin/useFoundryUser.js +2 -2
  24. package/build/esm/new/platform-apis/admin/useFoundryUser.js.map +1 -1
  25. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js +2 -2
  26. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
  27. package/build/esm/new/useLinks.js +1 -1
  28. package/build/esm/new/useLinks.js.map +1 -1
  29. package/build/esm/new/useOsdkAggregation.js +1 -1
  30. package/build/esm/new/useOsdkAggregation.js.map +1 -1
  31. package/build/esm/new/useOsdkObject.js +1 -1
  32. package/build/esm/new/useOsdkObject.js.map +1 -1
  33. package/build/esm/new/useOsdkObjects.js +1 -1
  34. package/build/esm/new/useOsdkObjects.js.map +1 -1
  35. package/build/esm/utils/usePlatformQuery.js +1 -1
  36. package/build/esm/utils/usePlatformQuery.js.map +1 -1
  37. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts +2 -2
  38. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts.map +1 -1
  39. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts +4 -4
  40. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts.map +1 -1
  41. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts +4 -4
  42. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts.map +1 -1
  43. package/package.json +8 -7
@@ -1 +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":[]}
1
+ {"version":3,"file":"useFoundryUser.js","names":["Users","React","usePlatformQuery","OsdkContext2","useFoundryUser","userId","enabled","status","client","useContext","handleQuery","useCallback","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 User, Users } from \"@osdk/foundry.admin\";\nimport type { UserStatus } from \"@osdk/foundry.core\";\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?: UserStatus;\n}\n\nexport interface UseFoundryUserResult {\n user: 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 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;;AAEA,SAAoBA,KAAK,QAAQ,qBAAqB;AAEtD,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,GAAG,CAACJ,MAAM,EAAEH,MAAM,EAAE;MAAEE;IAAO,CAAC,CAAC;EAC9C,CAAC,EAAE,CAACC,MAAM,EAAEH,MAAM,EAAEE,MAAM,CAAC,CAAC;EAE5B,MAAMM,KAAK,GAAGX,gBAAgB,CAAC;IAC7BW,KAAK,EAAEH,WAAW;IAClBJ,OAAO;IACPQ,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":[]}
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import { Admin } from "@osdk/foundry";
17
+ import { Users } from "@osdk/foundry.admin";
18
18
  import React from "react";
19
19
  import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
20
  import { OsdkContext2 } from "../../OsdkContext2.js";
@@ -32,7 +32,7 @@ export function useFoundryUsersList({
32
32
  client
33
33
  } = React.useContext(OsdkContext2);
34
34
  const handleQuery = React.useCallback(() => {
35
- return Admin.Users.list(client, {
35
+ return Users.list(client, {
36
36
  include,
37
37
  pageSize,
38
38
  pageToken
@@ -1 +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":[]}
1
+ {"version":3,"file":"useFoundryUsersList.js","names":["Users","React","usePlatformQuery","OsdkContext2","useFoundryUsersList","enabled","include","pageSize","pageToken","client","useContext","handleQuery","useCallback","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 ListUsersResponse, Users } from \"@osdk/foundry.admin\";\nimport type { UserStatus } from \"@osdk/foundry.core\";\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?: 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: 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 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;;AAEA,SAAiCA,KAAK,QAAQ,qBAAqB;AAEnE,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,IAAI,CAACJ,MAAM,EAAE;MAAEH,OAAO;MAAEC,QAAQ;MAAEC;IAAU,CAAC,CAAC;EAC7D,CAAC,EAAE,CAACC,MAAM,EAAEH,OAAO,EAAEC,QAAQ,EAAEC,SAAS,CAAC,CAAC;EAE1C,MAAMM,KAAK,GAAGZ,gBAAgB,CAC5B;IACEY,KAAK,EAAEH,WAAW;IAClBN,OAAO;IACPU,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":[]}
@@ -60,7 +60,7 @@ export function useLinks(objects, linkName, options = {}) {
60
60
  const payload = React.useSyncExternalStore(subscribe, getSnapShot);
61
61
  return {
62
62
  links: payload?.resolvedList,
63
- isLoading: payload?.status === "loading",
63
+ isLoading: enabled ? payload?.status === "loading" || payload?.status === "init" || !payload : false,
64
64
  isOptimistic: payload?.isOptimistic ?? false,
65
65
  error: payload?.error,
66
66
  fetchMore: payload?.fetchMore,
@@ -1 +1 @@
1
- {"version":3,"file":"useLinks.js","names":["React","makeExternalStore","OsdkContext2","emptyArray","Object","freeze","useLinks","objects","linkName","options","observableClient","useContext","enabled","otherOptions","objectsArray","useMemo","undefined","Array","isArray","subscribe","getSnapShot","unsubscribe","map","obj","$apiName","$primaryKey","join","observer","observeLinks","where","pageSize","orderBy","mode","payload","useSyncExternalStore","links","resolvedList","isLoading","status","isOptimistic","error","fetchMore","hasMore"],"sources":["useLinks.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 { LinkedType, LinkNames } from \"@osdk/api\";\nimport type {\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/client\";\nimport type { ObserveLinks } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseLinksOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n /**\n * Standard OSDK Where clause for filtering linked objects\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the links list.\n */\n pageSize?: number;\n\n /** Sorting options for the linked objects */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * The mode to use for fetching data.\n * - undefined: Fetch data if not already in cache\n * - \"force\": Always fetch fresh data\n * - \"offline\": Only use cached data, don't make network requests\n */\n mode?: \"force\" | \"offline\";\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 employee data\n * const { object: employee } = useOsdkObject(Employee, employeeId);\n * const { links: reports } = useLinks(employee, \"reports\", {\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseLinksResult<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n links: Osdk.Instance<Q>[] | undefined;\n isLoading: boolean;\n error: Error | undefined;\n\n /**\n * Refers to whether the links are optimistic or not.\n */\n isOptimistic: boolean;\n\n /**\n * Fetch more linked objects if pagination is supported\n */\n fetchMore: (() => Promise<unknown>) | undefined;\n\n /**\n * Indicates if there are more linked objects available to fetch\n */\n hasMore: boolean;\n}\n\nconst emptyArray = Object.freeze([]);\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks<\n T extends ObjectTypeDefinition,\n L extends LinkNames<T>,\n>(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined,\n linkName: L,\n options: UseLinksOptions<LinkedType<T, L>> = {},\n): UseLinksResult<LinkedType<T, L>> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, ...otherOptions } = options;\n\n // Convert single object to array for consistent handling\n const objectsArray: ReadonlyArray<Osdk.Instance<T>> = React.useMemo(() => {\n return objects === undefined\n ? emptyArray\n : Array.isArray(objects)\n ? objects\n : [objects];\n }, [objects]);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveLinks.CallbackArgs<T>>(\n () => ({ unsubscribe: () => {} }),\n `links ${linkName} for ${\n objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\n \",\",\n )\n } [DISABLED]`,\n );\n }\n return makeExternalStore<ObserveLinks.CallbackArgs<T>>(\n (observer) =>\n observableClient.observeLinks(\n objectsArray,\n linkName,\n {\n linkName,\n where: otherOptions.where,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n mode: otherOptions.mode,\n },\n observer,\n ),\n `links ${linkName} for ${\n objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\n \",\",\n )\n }`,\n );\n },\n [\n enabled,\n observableClient,\n objectsArray,\n linkName,\n otherOptions.where,\n otherOptions.pageSize,\n otherOptions.orderBy,\n otherOptions.mode,\n ],\n );\n\n const payload = React.useSyncExternalStore(\n subscribe,\n getSnapShot,\n );\n\n return {\n links: payload?.resolvedList,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n error: payload?.error,\n fetchMore: payload?.fetchMore,\n hasMore: payload?.hasMore ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAyEhD,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,CAAC;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAItBC,OAA+D,EAC/DC,QAAW,E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AI,CAChE,GACF,CAAC,EAEL,CAAC;EACH,CAAC,EACD,CACEd,OAAO,EACPF,gBAAgB,EAChBI,YAAY,EACZN,QAAQ,EACRK,YAAY,CAACgB,KAAK,EAClBhB,YAAY,CAACiB,QAAQ,EACrBjB,YAAY,CAACkB,OAAO,EACpBlB,YAAY,CAACmB,IAAI,CAErB,CAAC;EAED,MAAMC,OAAO,GAAGjC,KAAK,CAACkC,oBAAoB,CACxCf,SAAS,EACTC,WACF,CAAC;EAED,OAAO;IACLe,KAAK,EAAEF,OAAO,EAAEG,YAAY;IAC5BC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS;IACxCC,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,KAAK,EAAEP,OAAO,EAAEO,KAAK;IACrBC,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,OAAO,EAAET,OAAO,EAAES,OAAO,IAAI;EAC/B,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useLinks.js","names":["React","makeExternalStore","OsdkContext2","emptyArray","Object","freeze","useLinks","objects","linkName","options","observableClient","useContext","enabled","otherOptions","objectsArray","useMemo","undefined","Array","isArray","subscribe","getSnapShot","unsubscribe","map","obj","$apiName","$primaryKey","join","observer","observeLinks","where","pageSize","orderBy","mode","payload","useSyncExternalStore","links","resolvedList","isLoading","status","isOptimistic","error","fetchMore","hasMore"],"sources":["useLinks.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 { LinkedType, LinkNames } from \"@osdk/api\";\nimport type {\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/client\";\nimport type { ObserveLinks } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseLinksOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n /**\n * Standard OSDK Where clause for filtering linked objects\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the links list.\n */\n pageSize?: number;\n\n /** Sorting options for the linked objects */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * The mode to use for fetching data.\n * - undefined: Fetch data if not already in cache\n * - \"force\": Always fetch fresh data\n * - \"offline\": Only use cached data, don't make network requests\n */\n mode?: \"force\" | \"offline\";\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 employee data\n * const { object: employee } = useOsdkObject(Employee, employeeId);\n * const { links: reports } = useLinks(employee, \"reports\", {\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseLinksResult<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n links: Osdk.Instance<Q>[] | undefined;\n isLoading: boolean;\n error: Error | undefined;\n\n /**\n * Refers to whether the links are optimistic or not.\n */\n isOptimistic: boolean;\n\n /**\n * Fetch more linked objects if pagination is supported\n */\n fetchMore: (() => Promise<unknown>) | undefined;\n\n /**\n * Indicates if there are more linked objects available to fetch\n */\n hasMore: boolean;\n}\n\nconst emptyArray = Object.freeze([]);\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks<\n T extends ObjectTypeDefinition,\n L extends LinkNames<T>,\n>(\n objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined,\n linkName: L,\n options: UseLinksOptions<LinkedType<T, L>> = {},\n): UseLinksResult<LinkedType<T, L>> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const { enabled = true, ...otherOptions } = options;\n\n // Convert single object to array for consistent handling\n const objectsArray: ReadonlyArray<Osdk.Instance<T>> = React.useMemo(() => {\n return objects === undefined\n ? emptyArray\n : Array.isArray(objects)\n ? objects\n : [objects];\n }, [objects]);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveLinks.CallbackArgs<T>>(\n () => ({ unsubscribe: () => {} }),\n `links ${linkName} for ${\n objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\n \",\",\n )\n } [DISABLED]`,\n );\n }\n return makeExternalStore<ObserveLinks.CallbackArgs<T>>(\n (observer) =>\n observableClient.observeLinks(\n objectsArray,\n linkName,\n {\n linkName,\n where: otherOptions.where,\n pageSize: otherOptions.pageSize,\n orderBy: otherOptions.orderBy,\n mode: otherOptions.mode,\n },\n observer,\n ),\n `links ${linkName} for ${\n objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\n \",\",\n )\n }`,\n );\n },\n [\n enabled,\n observableClient,\n objectsArray,\n linkName,\n otherOptions.where,\n otherOptions.pageSize,\n otherOptions.orderBy,\n otherOptions.mode,\n ],\n );\n\n const payload = React.useSyncExternalStore(\n subscribe,\n getSnapShot,\n );\n\n return {\n links: payload?.resolvedList,\n isLoading: enabled\n ? (payload?.status === \"loading\" || payload?.status === \"init\"\n || !payload)\n : false,\n isOptimistic: payload?.isOptimistic ?? false,\n error: payload?.error,\n fetchMore: payload?.fetchMore,\n hasMore: payload?.hasMore ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA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MACRqB,KAAK,EAAEhB,YAAY,CAACgB,KAAK;MACzBC,QAAQ,EAAEjB,YAAY,CAACiB,QAAQ;MAC/BC,OAAO,EAAElB,YAAY,CAACkB,OAAO;MAC7BC,IAAI,EAAEnB,YAAY,CAACmB;IACrB,CAAC,EACDL,QACF,CAAC,EACH,SAASnB,QAAQ,QACfM,YAAY,CAACQ,GAAG,CAACC,GAAG,IAAI,GAAGA,GAAG,CAACC,QAAQ,IAAID,GAAG,CAACE,WAAW,EAAE,CAAC,CAACC,IAAI,CAChE,GACF,CAAC,EAEL,CAAC;EACH,CAAC,EACD,CACEd,OAAO,EACPF,gBAAgB,EAChBI,YAAY,EACZN,QAAQ,EACRK,YAAY,CAACgB,KAAK,EAClBhB,YAAY,CAACiB,QAAQ,EACrBjB,YAAY,CAACkB,OAAO,EACpBlB,YAAY,CAACmB,IAAI,CAErB,CAAC;EAED,MAAMC,OAAO,GAAGjC,KAAK,CAACkC,oBAAoB,CACxCf,SAAS,EACTC,WACF,CAAC;EAED,OAAO;IACLe,KAAK,EAAEF,OAAO,EAAEG,YAAY;IAC5BC,SAAS,EAAEzB,OAAO,GACbqB,OAAO,EAAEK,MAAM,KAAK,SAAS,IAAIL,OAAO,EAAEK,MAAM,KAAK,MAAM,IACzD,CAACL,OAAO,GACX,KAAK;IACTM,YAAY,EAAEN,OAAO,EAAEM,YAAY,IAAI,KAAK;IAC5CC,KAAK,EAAEP,OAAO,EAAEO,KAAK;IACrBC,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,OAAO,EAAET,OAAO,EAAES,OAAO,IAAI;EAC/B,CAAC;AACH","ignoreList":[]}
@@ -75,7 +75,7 @@ export function useOsdkAggregation(type, {
75
75
  }, [observableClient, type.apiName]);
76
76
  return {
77
77
  data: payload?.result,
78
- isLoading: payload?.status === "loading",
78
+ isLoading: payload?.status === "loading" || payload?.status === "init" || !payload,
79
79
  error,
80
80
  refetch
81
81
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkAggregation.js","names":["React","makeExternalStore","OsdkContext2","useOsdkAggregation","type","where","withProperties","aggregate","dedupeIntervalMs","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","stableAggregate","subscribe","getSnapShot","observer","observeAggregation","dedupeInterval","process","env","NODE_ENV","apiName","payload","useSyncExternalStore","error","status","Error","refetch","useCallback","invalidateObjectType","data","result","isLoading"],"sources":["useOsdkAggregation.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 AggregateOpts,\n AggregationsResults,\n DerivedProperty,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObjectTypeDefinition } from \"@osdk/client\";\nimport type { ObserveAggregationArgs } 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 UseOsdkAggregationOptions<\n T extends ObjectTypeDefinition,\n A extends AggregateOpts<T>,\n WithProps extends DerivedProperty.Clause<T> | undefined = undefined,\n> {\n /**\n * Standard OSDK Where clause to filter objects before aggregation\n */\n where?: WhereClause<T, InferRdpTypes<T, WithProps>>;\n\n /**\n * Define derived properties (RDPs) to be computed server-side.\n * The derived properties can be used in the where clause and aggregation groupBy/select.\n */\n withProperties?: WithProps;\n\n /**\n * Aggregation options including groupBy and select\n */\n aggregate: A;\n\n /**\n * The number of milliseconds to wait after the last observed aggregation change.\n *\n * Two uses of `useOsdkAggregation` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n}\n\nexport interface UseOsdkAggregationResult<\n T extends ObjectTypeDefinition,\n A extends AggregateOpts<T>,\n> {\n data: AggregationsResults<T, A> | undefined;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => void;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for performing aggregations on OSDK object sets.\n *\n * Executes server-side aggregations with groupBy and metric calculations on filtered object sets.\n * Supports runtime derived properties and where clauses.\n *\n * @param type - The object or interface type to aggregate\n * @param options - Aggregation configuration including where clause, aggregation spec, and optional derived properties\n * @returns Object containing aggregation results, loading state, error state, and refetch function\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = useOsdkAggregation(Employee, {\n * where: { department: \"Engineering\" },\n * aggregate: {\n * groupBy: { department: \"exact\" },\n * select: {\n * avgSalary: { $avg: \"salary\" },\n * count: { $count: {} }\n * }\n * }\n * });\n * ```\n */\nexport function useOsdkAggregation<\n Q extends ObjectTypeDefinition,\n A extends AggregateOpts<Q>,\n WP extends DerivedProperty.Clause<Q> | undefined = undefined,\n>(\n type: Q,\n {\n where = {},\n withProperties,\n aggregate,\n dedupeIntervalMs,\n }: UseOsdkAggregationOptions<Q, A, WP>,\n): UseOsdkAggregationResult<Q, A> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const canonWhere = observableClient.canonicalizeWhereClause<Q>(where ?? {});\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableAggregate = React.useMemo(\n () => aggregate,\n [JSON.stringify(aggregate)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObserveAggregationArgs<Q, A>>(\n (observer) =>\n observableClient.observeAggregation(\n {\n type: type,\n where: canonWhere,\n withProperties: stableWithProperties,\n aggregate: stableAggregate,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n },\n observer,\n ),\n process.env.NODE_ENV !== \"production\"\n ? `aggregation ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [\n observableClient,\n type.apiName,\n type.type,\n canonWhere,\n stableWithProperties,\n stableAggregate,\n dedupeIntervalMs,\n ],\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 execute aggregation\");\n }\n\n const refetch = React.useCallback(async () => {\n await observableClient.invalidateObjectType(type.apiName);\n }, [observableClient, type.apiName]);\n\n return {\n data: payload?.result as AggregationsResults<Q, A> | undefined,\n isLoading: payload?.status === \"loading\",\n error,\n refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAiDhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAKhCC,IAAO,EACP;EACEC,KAAK,GAAG,CAAC,CAAC;EACVC,cAAc;EACdC,SAAS;EACTC;AACmC,CAAC,EACN;EAChC,MAAM;IAAEC;EAAiB,CAAC,GAAGT,KAAK,CAACU,UAAU,CAACR,YAAY,CAAC;EAE3D,MAAMS,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAAIP,KAAK,IAAI,CAAC,CAAC,CAAC;EAE3E,MAAMQ,oBAAoB,GAAGb,KAAK,CAACc,OAAO,CACxC,MAAMR,cAAc,EACpB,CAACS,IAAI,CAACC,SAAS,CAACV,cAAc,CAAC,CACjC,CAAC;EAED,MAAMW,eAAe,GAAGjB,KAAK,CA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AC,CAAC;EAEpC,OAAO;IACLS,IAAI,EAAER,OAAO,EAAES,MAA+C;IAC9DC,SAAS,EAAEV,OAAO,EAAEG,MAAM,KAAK,SAAS;IACxCD,KAAK;IACLG;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkAggregation.js","names":["React","makeExternalStore","OsdkContext2","useOsdkAggregation","type","where","withProperties","aggregate","dedupeIntervalMs","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","stableAggregate","subscribe","getSnapShot","observer","observeAggregation","dedupeInterval","process","env","NODE_ENV","apiName","payload","useSyncExternalStore","error","status","Error","refetch","useCallback","invalidateObjectType","data","result","isLoading"],"sources":["useOsdkAggregation.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 AggregateOpts,\n AggregationsResults,\n DerivedProperty,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObjectTypeDefinition } from \"@osdk/client\";\nimport type { ObserveAggregationArgs } 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 UseOsdkAggregationOptions<\n T extends ObjectTypeDefinition,\n A extends AggregateOpts<T>,\n WithProps extends DerivedProperty.Clause<T> | undefined = undefined,\n> {\n /**\n * Standard OSDK Where clause to filter objects before aggregation\n */\n where?: WhereClause<T, InferRdpTypes<T, WithProps>>;\n\n /**\n * Define derived properties (RDPs) to be computed server-side.\n * The derived properties can be used in the where clause and aggregation groupBy/select.\n */\n withProperties?: WithProps;\n\n /**\n * Aggregation options including groupBy and select\n */\n aggregate: A;\n\n /**\n * The number of milliseconds to wait after the last observed aggregation change.\n *\n * Two uses of `useOsdkAggregation` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n}\n\nexport interface UseOsdkAggregationResult<\n T extends ObjectTypeDefinition,\n A extends AggregateOpts<T>,\n> {\n data: AggregationsResults<T, A> | undefined;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => void;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for performing aggregations on OSDK object sets.\n *\n * Executes server-side aggregations with groupBy and metric calculations on filtered object sets.\n * Supports runtime derived properties and where clauses.\n *\n * @param type - The object or interface type to aggregate\n * @param options - Aggregation configuration including where clause, aggregation spec, and optional derived properties\n * @returns Object containing aggregation results, loading state, error state, and refetch function\n *\n * @example\n * ```tsx\n * const { data, isLoading, error } = useOsdkAggregation(Employee, {\n * where: { department: \"Engineering\" },\n * aggregate: {\n * groupBy: { department: \"exact\" },\n * select: {\n * avgSalary: { $avg: \"salary\" },\n * count: { $count: {} }\n * }\n * }\n * });\n * ```\n */\nexport function useOsdkAggregation<\n Q extends ObjectTypeDefinition,\n A extends AggregateOpts<Q>,\n WP extends DerivedProperty.Clause<Q> | undefined = undefined,\n>(\n type: Q,\n {\n where = {},\n withProperties,\n aggregate,\n dedupeIntervalMs,\n }: UseOsdkAggregationOptions<Q, A, WP>,\n): UseOsdkAggregationResult<Q, A> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const canonWhere = observableClient.canonicalizeWhereClause<Q>(where ?? {});\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableAggregate = React.useMemo(\n () => aggregate,\n [JSON.stringify(aggregate)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObserveAggregationArgs<Q, A>>(\n (observer) =>\n observableClient.observeAggregation(\n {\n type: type,\n where: canonWhere,\n withProperties: stableWithProperties,\n aggregate: stableAggregate,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n },\n observer,\n ),\n process.env.NODE_ENV !== \"production\"\n ? `aggregation ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [\n observableClient,\n type.apiName,\n type.type,\n canonWhere,\n stableWithProperties,\n stableAggregate,\n dedupeIntervalMs,\n ],\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 execute aggregation\");\n }\n\n const refetch = React.useCallback(async () => {\n await observableClient.invalidateObjectType(type.apiName);\n }, [observableClient, type.apiName]);\n\n return {\n data: payload?.result as AggregationsResults<Q, A> | undefined,\n isLoading: payload?.status === \"loading\" || payload?.status === \"init\"\n || !payload,\n error,\n refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAiDhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAKhCC,IAAO,EACP;EACEC,KAAK,GAAG,CAAC,CAAC;EACVC,cAAc;EACdC,SAAS;EACTC;AACmC,CAAC,EACN;EAChC,MAAM;IAAEC;EAAiB,CAAC,GAAGT,KAAK,CAACU,UAAU,CAACR,YAAY,CAAC;EAE3D,MAAMS,UAAU,GAAGF,gBAAgB,CAACG,uBAAu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;EACpD;EAEA,MAAMC,OAAO,GAAGhC,KAAK,CAACiC,WAAW,CAAC,YAAY;IAC5C,MAAMxB,gBAAgB,CAACyB,oBAAoB,CAAC9B,IAAI,CAACsB,OAAO,CAAC;EAC3D,CAAC,EAAE,CAACjB,gBAAgB,EAAEL,IAAI,CAACsB,OAAO,CAAC,CAAC;EAEpC,OAAO;IACLS,IAAI,EAAER,OAAO,EAAES,MAA+C;IAC9DC,SAAS,EAAEV,OAAO,EAAEG,MAAM,KAAK,SAAS,IAAIH,OAAO,EAAEG,MAAM,KAAK,MAAM,IACjE,CAACH,OAAO;IACbE,KAAK;IACLG;EACF,CAAC;AACH","ignoreList":[]}
@@ -73,7 +73,7 @@ export function useOsdkObject(...args) {
73
73
  }
74
74
  return {
75
75
  object: payload?.object,
76
- isLoading: payload?.status === "loading",
76
+ isLoading: enabled ? payload?.status === "loading" || payload?.status === "init" || !payload : false,
77
77
  isOptimistic: !!payload?.isOptimistic,
78
78
  error,
79
79
  forceUpdate: () => {
@@ -1 +1 @@
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,OAAO,SAASC,aAAaA,CAC3B,GAAGC,IAE4D,EACvC;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;;EAE3D;EACA;EACA;EACA,MAAMK,mBAAmB,GAAG,aAAa,IAAIH,IAAI,CAAC,CAAC,CAAC;;EAEpD;EACA,MAAMI,OAAO,GAAGD,mBAAmB,GAC9B,OAAOH,IAAI,CAAC,CA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,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: enabled\n ? (payload?.status === \"loading\" || payload?.status === \"init\"\n || !payload)\n : false,\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,OAAO,SAASC,aAAaA,CAC3B,GAAGC,IAE4D,EACvC;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;;EAE3D;EACA;EACA;EACA,MAAMK,mBAAmB,GAAG,aAAa,IAAIH,IAAI,CAAC,CAAC,CAAC;;EAEpD;EACA,MAAMI,OAAO,GAAGD,mBAAmB,GAC9B,OAAOH,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,GAAGA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAC7C,OAAOA,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,GAAGA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAK;;EAEnD;EACA,MAAMK,IAAI,GAAGF,mBAAmB,GAAG,SAAS,GAAGG,S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,OAAO,EAAEG,MAAM,KAAK,MAAM,IACzD,CAACH,OAAO,GACX,KAAK;IACTO,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":[]}
@@ -79,7 +79,7 @@ export function useOsdkObjects(type, options) {
79
79
  fetchMore: listPayload?.hasMore ? listPayload.fetchMore : undefined,
80
80
  error,
81
81
  data: listPayload?.resolvedList,
82
- isLoading: listPayload?.status === "loading",
82
+ isLoading: enabled ? listPayload?.status === "loading" || listPayload?.status === "init" || !listPayload : false,
83
83
  isOptimistic: listPayload?.isOptimistic ?? false
84
84
  };
85
85
  }
@@ -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","hasMore","undefined","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?.hasMore ? listPayload.fetchMore : undefined,\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,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AAoB;MACpCR,aAAa;MACb,IAAIY,mBAAmB,GACnB;QAAEX,aAAa,EAAEW;MAAoB,CAAC,GACtC,CAAC,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,EAAEM,OAAO,GAAGN,WAAW,CAACK,SAAS,GAAGE,SAAS;IACnEL,KAAK;IACLM,IAAI,EAAER,WAAW,EAAES,YAAY;IAC/BC,SAAS,EAAEV,WAAW,EAAEG,MAAM,KAAK,SAAS;IAC5CQ,YAAY,EAAEX,WAAW,EAAEW,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","hasMore","undefined","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?.hasMore ? listPayload.fetchMore : undefined,\n error,\n data: listPayload?.resolvedList,\n isLoading: enabled\n ? (listPayload?.status === \"loading\" || listPayload?.status === \"init\"\n || !listPayload)\n : false,\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,KA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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,EAAEM,OAAO,GAAGN,WAAW,CAACK,SAAS,GAAGE,SAAS;IACnEL,KAAK;IACLM,IAAI,EAAER,WAAW,EAAES,YAAY;IAC/BC,SAAS,EAAE/B,OAAO,GACbqB,WAAW,EAAEG,MAAM,KAAK,SAAS,IAAIH,WAAW,EAAEG,MAAM,KAAK,MAAM,IACjE,CAACH,WAAW,GACf,KAAK;IACTW,YAAY,EAAEX,WAAW,EAAEW,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
@@ -66,7 +66,7 @@ export function usePlatformQuery({
66
66
  }
67
67
  return {
68
68
  data: payload?.data,
69
- isLoading: payload?.status === "loading",
69
+ isLoading: enabled ? payload?.status === "loading" || !payload : false,
70
70
  error,
71
71
  refetch: handleQuery
72
72
  };
@@ -1 +1 @@
1
- {"version":3,"file":"usePlatformQuery.js","names":["React","makeExternalStore","usePlatformQuery","query","queryName","enabled","observerRef","useRef","handleQuery","useCallback","observer","current","next","status","data","undefined","then","catch","err","error","subscribe","getSnapShot","useMemo","unsubscribe","process","env","NODE_ENV","payload","useSyncExternalStore","Error","isLoading","refetch"],"sources":["usePlatformQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Observer } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"../new/makeExternalStore.js\";\n\nexport interface UseQueryOptions<T> {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * });\n */\n enabled?: boolean;\n queryName: string;\n query: () => Promise<T>;\n}\n\nexport interface QueryResult<T> {\n data: T | undefined;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => void;\n}\n\ninterface QueryPayload<T> {\n data: T | undefined;\n status: \"loading\" | \"success\" | \"error\";\n}\n\nexport function usePlatformQuery<T>(\n { query, queryName, enabled = true }: UseQueryOptions<T>,\n): QueryResult<T> {\n const observerRef = React.useRef<Observer<QueryPayload<T> | undefined>>();\n\n const handleQuery = React.useCallback(() => {\n const observer = observerRef.current;\n if (observer == null) return;\n\n observer.next({\n status: \"loading\",\n data: undefined,\n });\n\n query()\n .then((data) => {\n observer.next({\n status: \"success\",\n data,\n });\n })\n .catch((err: unknown) => {\n observer.error(err);\n });\n }, [query]);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<QueryPayload<T>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `${queryName} Query [DISABLED]`\n : undefined,\n );\n }\n\n return makeExternalStore<QueryPayload<T>>(\n (observer: Observer<QueryPayload<T> | undefined>) => {\n observerRef.current = observer;\n handleQuery();\n return {\n unsubscribe: () => {\n observerRef.current = undefined;\n },\n };\n },\n queryName,\n );\n },\n [enabled, queryName, handleQuery],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error != null) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(`Failed to query platform API: ${queryName}`);\n }\n\n return {\n data: payload?.data,\n isLoading: payload?.status === \"loading\",\n error,\n refetch: handleQuery,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,6BAA6B;AAiC/D,OAAO,SAASC,gBAAgBA,CAC9B;EAAEC,KAAK;EAAEC,SAAS;EAAEC,OAAO,GAAG;AAAyB,CAAC,EACxC;EAChB,MAAMC,WAAW,GAAGN,KAAK,CAACO,MAAM,CAAwC,CAAC;EAEzE,MAAMC,WAAW,GAAGR,KAAK,CAACS,WAAW,CAAC,MAAM;IAC1C,MAAMC,QAAQ,GAAGJ,WAAW,CAACK,OAAO;IACpC,IAAID,QAAQ,IAAI,IAAI,EAAE;IAEtBA,QAAQ,CAACE,IAAI,CAAC;MACZC,MAAM,EAAE,SAAS;MACjBC,IAAI,EAAEC;IACR,CAAC,CAAC;IAEFZ,KAAK,CAAC,CAAC,CACJa,IAAI,CAAEF,IAAI,IAAK;MACdJ,QAAQ,CAACE,IAAI,CAAC;QACZC,MAAM,EAAE,SAAS;QACjBC;MACF,CAAC,CAAC;IACJ,CAAC,CAAC,CACDG,KAAK,CAAEC,GAAY,IAAK;MACvBR,QAAQ,CAACS,KAAK,CAACD,GAAG,CAAC;IACrB,CAAC,CAAC;EACN,CAAC,EAAE,CAACf,KAAK,CAAC,CAAC;EAEX,MAAM;IAAEiB,SAAS;IAAEC;EAAY,CAAC,GAAGrB,KAAK,CAACsB,OAAO,CAC9C,MAAM;IACJ,IAAI,CAACjB,OAAO,EAAE;MACZ,OAAOJ,iBAAiB,CACtB,OAAO;QAAEsB,WAAW,EAAEA,CAAA,KAAM,CAAC;MAAE,CAAC,CAAC,EACjCC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,GAAGtB,SAAS,mBAAmB,GAC/BW,SACN,CAAC;IACH;IAEA,OAAOd,iBAAiB,CACrBS,QAA+C,IAAK;MACnDJ,WAAW,CAACK,OAAO,GAAGD,QAAQ;MAC9BF,WAAW,CAAC,CAAC;MACb,OAAO;QACLe,WAAW,EAAEA,CAAA,KAAM;UACjBjB,WAAW,CAACK,OAAO,GAAGI,SAAS;QACjC;MACF,CAAC;IACH,CAAC,EACDX,SACF,CAAC;EACH,CAAC,EACD,CAACC,OAAO,EAAED,SAAS,EAAEI,WAAW,CAClC,CAAC;EAED,MAAMmB,OAAO,GAAG3B,KAAK,CAAC4B,oBAAoB,CAACR,SAAS,EAAEC,WAAW,CAAC;EAElE,IAAIF,KAAwB;EAC5B,IAAIQ,OAAO,IAAI,OAAO,IAAIA,OAAO,IAAIA,OAAO,CAACR,KAAK,IAAI,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":[]}
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: enabled ? (payload?.status === \"loading\" || !payload) : false,\n error,\n refetch: handleQuery,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,6BAA6B;AAiC/D,OAAO,SAASC,gBAAgBA,CAC9B;EAAEC,KAAK;EAAEC,SAAS;EAAEC,OAAO,GAAG;AAAyB,CAAC,EACxC;EAChB,MAAMC,WAAW,GAAGN,KAAK,CAACO,MAAM,CAAwC,CAAC;EAEzE,MAAMC,WAAW,GAAGR,KAAK,CAACS,WAAW,CAAC,MAAM;IAC1C,MAAMC,QAAQ,GAAGJ,WAAW,CAACK,OAAO;IACpC,IAAID,QAAQ,IAAI,IAAI,EAAE;IAEtBA,QAAQ,CAACE,IAAI,CAAC;MACZC,MAAM,EAAE,SAAS;MACjBC,IAAI,EAAEC;IACR,CAAC,CAAC;IAEFZ,KAAK,CAAC,CAAC,CACJa,IAAI,CAAEF,IAAI,IAAK;MACdJ,QAAQ,CAACE,IAAI,CAAC;QACZC,MAAM,EAAE,SAAS;QACjBC;MACF,CAAC,CAAC;IACJ,CAAC,CAAC,CACDG,KAAK,CAAEC,GAAY,IAAK;MACvBR,QAAQ,CAACS,KAAK,CAACD,GAAG,CAAC;IACrB,CAAC,CAAC;EACN,CAAC,EAAE,CAACf,KAAK,CAAC,CAAC;EAEX,MAAM;IAAEiB,SAAS;IAA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.admin";
2
2
  export interface UseCurrentFoundryUserOptions {
3
3
  /**
4
4
  * Enable or disable the query.
@@ -16,7 +16,7 @@ export interface UseCurrentFoundryUserOptions {
16
16
  enabled?: boolean;
17
17
  }
18
18
  export interface UseCurrentFoundryUserResult {
19
- currentUser: Admin.User | undefined;
19
+ currentUser: User | undefined;
20
20
  isLoading: boolean;
21
21
  error: Error | undefined;
22
22
  refetch: () => void;
@@ -1 +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"}
1
+ {"mappings":"AAgBA,cAAc,YAAmB,qBAAsB;AAKvD,iBAAiB,6BAA6B;;;;;;;;;;;;;;CAc5C;AACD;AAED,iBAAiB,4BAA4B;CAC3C,aAAa;CACb;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"}
@@ -1,5 +1,5 @@
1
- import type { Core } from "@osdk/foundry";
2
- import { Admin } from "@osdk/foundry";
1
+ import { type User } from "@osdk/foundry.admin";
2
+ import type { UserStatus } from "@osdk/foundry.core";
3
3
  export interface UseFoundryUserOptions {
4
4
  /**
5
5
  * Enable or disable the query.
@@ -20,10 +20,10 @@ export interface UseFoundryUserOptions {
20
20
  *
21
21
  * @default "ACTIVE"
22
22
  */
23
- status?: Core.UserStatus;
23
+ status?: UserStatus;
24
24
  }
25
25
  export interface UseFoundryUserResult {
26
- user: Admin.User | undefined;
26
+ user: User | undefined;
27
27
  isLoading: boolean;
28
28
  error: Error | undefined;
29
29
  refetch: () => void;
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,YAAY,eAAgB;AAC1C,SAAS,aAAa,eAAgB;AAMtC,iBAAiB,sBAAsB;;;;;;;;;;;;;;CAcrC;;;;;;CAOA,SAAS,KAAK;AACf;AAED,iBAAiB,qBAAqB;CACpC,MAAM,MAAM;CACZ;CAEA,OAAO;CAEP;AACD;;;;;;AAOD,OAAO,iBAAS,eACdA,gBACA,EAAE,SAAgB,QAA0C,GAArB,wBACtC","names":["userId: string"],"sources":["../../../../../src/new/platform-apis/admin/useFoundryUser.ts"],"version":3,"file":"useFoundryUser.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,YAAmB,qBAAsB;AACvD,cAAc,kBAAkB,oBAAqB;AAKrD,iBAAiB,sBAAsB;;;;;;;;;;;;;;CAcrC;;;;;;CAOA,SAAS;AACV;AAED,iBAAiB,qBAAqB;CACpC,MAAM;CACN;CAEA,OAAO;CAEP;AACD;;;;;;AAOD,OAAO,iBAAS,eACdA,gBACA,EAAE,SAAgB,QAA0C,GAArB,wBACtC","names":["userId: string"],"sources":["../../../../../src/new/platform-apis/admin/useFoundryUser.ts"],"version":3,"file":"useFoundryUser.d.ts"}
@@ -1,5 +1,5 @@
1
- import type { Core } from "@osdk/foundry";
2
- import { Admin } from "@osdk/foundry";
1
+ import { type ListUsersResponse } from "@osdk/foundry.admin";
2
+ import type { UserStatus } from "@osdk/foundry.core";
3
3
  export interface UseFoundryUsersListOptions {
4
4
  /**
5
5
  * Enable or disable the query.
@@ -20,7 +20,7 @@ export interface UseFoundryUsersListOptions {
20
20
  *
21
21
  * @default "ACTIVE"
22
22
  */
23
- include?: Core.UserStatus;
23
+ include?: UserStatus;
24
24
  /**
25
25
  * The preferred page size for the list.
26
26
  *
@@ -35,7 +35,7 @@ export interface UseFoundryUsersListOptions {
35
35
  pageToken?: string;
36
36
  }
37
37
  export interface UseFoundryUsersListResult {
38
- users: Admin.ListUsersResponse["data"] | undefined;
38
+ users: ListUsersResponse["data"] | undefined;
39
39
  /**
40
40
  * The page token to be used for the next page of users. If this is undefined, there are no more
41
41
  * pages of users to load.
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,YAAY,eAAgB;AAC1C,SAAS,aAAa,eAAgB;AAMtC,iBAAiB,2BAA2B;;;;;;;;;;;;;;CAc1C;;;;;;CAOA,UAAU,KAAK;;;;;;CAOf;;;;;;CAOA;AACD;AAED,iBAAiB,0BAA0B;CACzC,OAAO,MAAM,kBAAkB;;;;;CAK/B;CACA;CAEA,OAAO;CAEP;AACD;;;;;AAMD,OAAO,iBAAS,oBACd,EAAE,SAAgB,SAAoB,UAAiB,WAC3B,GAA1B,6BACD","names":[],"sources":["../../../../../src/new/platform-apis/admin/useFoundryUsersList.ts"],"version":3,"file":"useFoundryUsersList.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,yBAAgC,qBAAsB;AACpE,cAAc,kBAAkB,oBAAqB;AAKrD,iBAAiB,2BAA2B;;;;;;;;;;;;;;CAc1C;;;;;;CAOA,UAAU;;;;;;CAOV;;;;;;CAOA;AACD;AAED,iBAAiB,0BAA0B;CACzC,OAAO,kBAAkB;;;;;CAKzB;CACA;CAEA,OAAO;CAEP;AACD;;;;;AAMD,OAAO,iBAAS,oBACd,EAAE,SAAgB,SAAoB,UAAiB,WAC3B,GAA1B,6BACD","names":[],"sources":["../../../../../src/new/platform-apis/admin/useFoundryUsersList.ts"],"version":3,"file":"useFoundryUsersList.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/react",
3
- "version": "0.9.0-beta.5",
3
+ "version": "0.9.0-beta.6",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,7 +43,8 @@
43
43
  "react-dom": "^17 || ^18 || ^19"
44
44
  },
45
45
  "devDependencies": {
46
- "@osdk/foundry": "latest",
46
+ "@osdk/foundry.admin": "2.44.0",
47
+ "@osdk/foundry.core": "2.44.0",
47
48
  "@testing-library/react": "^16.3.0",
48
49
  "@types/react": "^18.3.24",
49
50
  "find-up": "^8.0.0",
@@ -56,11 +57,11 @@
56
57
  "react": "^18.3.1",
57
58
  "tiny-invariant": "^1.3.3",
58
59
  "typescript": "~5.5.4",
59
- "@osdk/client": "2.7.0-beta.7",
60
- "@osdk/client.test.ontology": "2.7.0-beta.7",
61
- "@osdk/api": "2.7.0-beta.7",
62
- "@osdk/monorepo.api-extractor": "~0.6.0-beta.1",
63
- "@osdk/monorepo.tsconfig": "~0.6.0-beta.1"
60
+ "@osdk/api": "2.7.0-beta.9",
61
+ "@osdk/client": "2.7.0-beta.9",
62
+ "@osdk/client.test.ontology": "2.7.0-beta.9",
63
+ "@osdk/monorepo.tsconfig": "~0.6.0-beta.1",
64
+ "@osdk/monorepo.api-extractor": "~0.6.0-beta.1"
64
65
  },
65
66
  "publishConfig": {
66
67
  "access": "public"