@osdk/react 0.8.0-beta.2 → 0.8.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/browser/intellisense.test.helpers/useOsdkObjectsWithPivot.js +35 -0
  3. package/build/browser/intellisense.test.helpers/useOsdkObjectsWithPivot.js.map +1 -0
  4. package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js +34 -0
  5. package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +1 -0
  6. package/build/browser/intellisense.test.js +148 -0
  7. package/build/browser/intellisense.test.js.map +1 -0
  8. package/build/browser/new/types.js +2 -0
  9. package/build/browser/new/types.js.map +1 -0
  10. package/build/browser/new/useLinks.js +14 -5
  11. package/build/browser/new/useLinks.js.map +1 -1
  12. package/build/browser/new/useObjectSet.js +31 -19
  13. package/build/browser/new/useObjectSet.js.map +1 -1
  14. package/build/browser/new/useOsdkAggregation.js +83 -0
  15. package/build/browser/new/useOsdkAggregation.js.map +1 -0
  16. package/build/browser/new/useOsdkObject.js +23 -6
  17. package/build/browser/new/useOsdkObject.js.map +1 -1
  18. package/build/browser/new/useOsdkObjects.js +29 -12
  19. package/build/browser/new/useOsdkObjects.js.map +1 -1
  20. package/build/browser/public/experimental.js +1 -0
  21. package/build/browser/public/experimental.js.map +1 -1
  22. package/build/cjs/public/experimental.cjs +132 -39
  23. package/build/cjs/public/experimental.cjs.map +1 -1
  24. package/build/cjs/public/experimental.d.cts +183 -19
  25. package/build/esm/intellisense.test.helpers/useOsdkObjectsWithPivot.js +35 -0
  26. package/build/esm/intellisense.test.helpers/useOsdkObjectsWithPivot.js.map +1 -0
  27. package/build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js +34 -0
  28. package/build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +1 -0
  29. package/build/esm/intellisense.test.js +148 -0
  30. package/build/esm/intellisense.test.js.map +1 -0
  31. package/build/esm/new/types.js +2 -0
  32. package/build/esm/new/types.js.map +1 -0
  33. package/build/esm/new/useLinks.js +14 -5
  34. package/build/esm/new/useLinks.js.map +1 -1
  35. package/build/esm/new/useObjectSet.js +31 -19
  36. package/build/esm/new/useObjectSet.js.map +1 -1
  37. package/build/esm/new/useOsdkAggregation.js +83 -0
  38. package/build/esm/new/useOsdkAggregation.js.map +1 -0
  39. package/build/esm/new/useOsdkObject.js +23 -6
  40. package/build/esm/new/useOsdkObject.js.map +1 -1
  41. package/build/esm/new/useOsdkObjects.js +29 -12
  42. package/build/esm/new/useOsdkObjects.js.map +1 -1
  43. package/build/esm/public/experimental.js +1 -0
  44. package/build/esm/public/experimental.js.map +1 -1
  45. package/build/types/intellisense.test.d.ts +1 -0
  46. package/build/types/intellisense.test.d.ts.map +1 -0
  47. package/build/types/intellisense.test.helpers/useOsdkObjectsWithPivot.d.ts +1 -0
  48. package/build/types/intellisense.test.helpers/useOsdkObjectsWithPivot.d.ts.map +1 -0
  49. package/build/types/intellisense.test.helpers/useOsdkObjectsWithProperties.d.ts +1 -0
  50. package/build/types/intellisense.test.helpers/useOsdkObjectsWithProperties.d.ts.map +1 -0
  51. package/build/types/new/types.d.ts +5 -0
  52. package/build/types/new/types.d.ts.map +1 -0
  53. package/build/types/new/useLinks.d.ts +20 -0
  54. package/build/types/new/useLinks.d.ts.map +1 -1
  55. package/build/types/new/useObjectSet.d.ts +36 -0
  56. package/build/types/new/useObjectSet.d.ts.map +1 -1
  57. package/build/types/new/useOsdkAggregation.d.ts +67 -0
  58. package/build/types/new/useOsdkAggregation.d.ts.map +1 -0
  59. package/build/types/new/useOsdkObject.d.ts +4 -2
  60. package/build/types/new/useOsdkObject.d.ts.map +1 -1
  61. package/build/types/new/useOsdkObjects.d.ts +63 -14
  62. package/build/types/new/useOsdkObjects.d.ts.map +1 -1
  63. package/build/types/public/experimental.d.ts +2 -0
  64. package/build/types/public/experimental.d.ts.map +1 -1
  65. package/package.json +10 -4
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","options","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","withProperties","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","subscribe","getSnapShot","observer","observeList","dedupeInterval","process","env","NODE_ENV","apiName","listPayload","useSyncExternalStore","error","status","Error","fetchMore","data","resolvedList","isLoading","isOptimistic"],"sources":["useOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WhereClause } from \"@osdk/api\";\nimport type {\n DerivedProperty,\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n} from \"@osdk/client\";\nimport type { ObserveObjectsArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype InferRdpTypes<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined,\n> = WP extends DerivedProperty.Clause<Q> ? {\n [K in keyof WP]: WP[K] extends DerivedProperty.Creator<Q, infer T> ? T\n : never;\n }\n : {};\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 * 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 // 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 /**\n * If provided, the list will be considered this length for the purposes of\n * `invalidationMode` when using the `wait` option. If not provided,\n * the internal expectedLength will be determined by the number of times\n * `fetchMore` has been called.\n */\n // expectedLength?: number | undefined;\n\n streamUpdates?: boolean;\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n fetchMore: (() => Promise<unknown>) | undefined;\n data: Osdk.Instance<T>[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined = undefined,\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, WP>,\n): UseOsdkListResult<Q> {\n const {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n withProperties,\n } = options ?? {};\n const { observableClient } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause<Q>(where ?? {});\n\n // TODO: replace with improved stabilization\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObserveObjectsArgs<Q>>(\n (observer) =>\n observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates,\n withProperties: stableWithProperties,\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [\n observableClient,\n type,\n canonWhere,\n dedupeIntervalMs,\n stableWithProperties,\n ],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n\n return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList as Osdk.Instance<Q>[],\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;;AAWA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AA4GhD,OAAO,SAASC,cAAcA,CAI5BC,IAAO,EACPC,OAAsC,EAChB;EACtB,MAAM;IACJC,QAAQ;IACRC,OAAO;IACPC,gBAAgB;IAChBC,KAAK,GAAG,CAAC,CAAC;IACVC,aAAa;IACbC;EACF,CAAC,GAAGN,OAAO,IAAI,CAAC,CAAC;EACjB,MAAM;IAAEO;EAAiB,CAAC,GAAGZ,KAAK,CAACa,UAAU,CAACX,YAAY,CAAC;;EAE3D;AACF;AACA;AACA;EACE,MAAMY,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAAIN,KAAK,IAAI,CAAC,CAAC,CAAC;;EAE3E;EACA,MAAMO,oBAAoB,GAAGhB,KAAK,CAACiB,OAAO,CACxC,MAAMN,cAAc,EACpB,CAACO,IAAI,CAACC,SAAS,CAACR,cAAc,CAAC,CACjC,CAAC;EAED,MAAM;IAAES,SAAS;IAAEC;EAAY,CAAC,GAAGrB,KAAK,CAACiB,OAAO,CAC9C,MACEhB,iBAAiB,CACdqB,QAAQ,IACPV,gBAAgB,CAACW,WAAW,CAAC;IAC3BnB,IAAI;IACJK,KAAK,EAAEK,UAAU;IACjBU,cAAc,EAAEhB,gBAAgB,IAAI,KAAK;IACzCF,QAAQ;IACRC,OAAO;IACPG,aAAa;IACbC,cAAc,EAAEK;EAClB,CAAC,EAAEM,QAAQ,CAAC,EACdG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQvB,IAAI,CAACwB,OAAO,IAAIV,IAAI,CAACC,SAAS,CAACL,UAAU,CAAC,EAAE,GACpD,KAAK,CACX,CAAC,EACH,CACEF,gBAAgB,EAChBR,IAAI,EACJU,UAAU,EACVN,gBAAgB,EAChBQ,oBAAoB,CAExB,CAAC;EAED,MAAMa,WAAW,GAAG7B,KAAK,CAAC8B,oBAAoB,CAACV,SAAS,EAAEC,WAAW,CAAC;EAEtE,IAAIU,KAAwB;EAC5B,IAAIF,WAAW,IAAI,OAAO,IAAIA,WAAW,IAAIA,WAAW,CAACE,KAAK,EAAE;IAC9DA,KAAK,GAAGF,WAAW,CAACE,KAAK;EAC3B,CAAC,MAAM,IAAIF,WAAW,EAAEG,MAAM,KAAK,OAAO,EAAE;IAC1CD,KAAK,GAAG,IAAIE,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEA,OAAO;IACLC,SAAS,EAAEL,WAAW,EAAEK,SAAS;IACjCH,KAAK;IACLI,IAAI,EAAEN,WAAW,EAAEO,YAAkC;IACrDC,SAAS,EAAER,WAAW,EAAEG,MAAM,KAAK,SAAS;IAC5CM,YAAY,EAAET,WAAW,EAAES,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","options","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","withProperties","autoFetchMore","intersectWith","pivotTo","enabled","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","stableIntersectWith","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","apiName","observer","observeList","dedupeInterval","listPayload","useSyncExternalStore","error","status","Error","fetchMore","data","resolvedList","isLoading","isOptimistic"],"sources":["useOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n InterfaceDefinition,\n LinkedType,\n LinkNames,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObserveObjectsArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nimport type { InferRdpTypes } from \"./types.js\";\n\nexport interface UseOsdkObjectsOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n WithProps extends DerivedProperty.Clause<T> | undefined = undefined,\n> {\n /**\n * Standard OSDK Where with RDP support\n */\n where?: WhereClause<T, InferRdpTypes<T, WithProps>>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Define derived properties (RDPs) to be computed server-side and attached to each object.\n * These properties will be available on the returned objects alongside their regular properties.\n */\n withProperties?: WithProps;\n\n /**\n * Intersect the results with additional object sets.\n * Each element defines a where clause for an object set to intersect with.\n * The final result will only include objects that match ALL conditions.\n */\n intersectWith?: Array<{\n where: WhereClause<T, InferRdpTypes<T, WithProps>>;\n }>;\n\n /**\n * Pivot to related objects through a link.\n * This changes the return type from T to the linked object type.\n */\n pivotTo?: LinkNames<T>;\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n *\n * Note: When using `autoFetchMore: true` with large datasets, the initial\n * load may take significant time. Consider using a specific number instead\n * or implementing virtual scrolling.\n *\n * @example\n * // Fetch all todos at once\n * const { data } = useOsdkObjects(Todo, { autoFetchMore: true })\n *\n * @example\n * // Fetch at least 100 todos (with 25 per page, fetches 4 pages)\n * const { data } = useOsdkObjects(Todo, {\n * autoFetchMore: 100,\n * pageSize: 25\n * })\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for parent data\n * const { data: employee } = useOsdkObject(Employee, employeeId);\n * const { data: reports } = useOsdkObjects(Employee, {\n * where: { managerId: employee?.id },\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n fetchMore: (() => Promise<void>) | undefined;\n data: Osdk.Instance<T>[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition,\n L extends LinkNames<Q>,\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q> & { pivotTo: L },\n): UseOsdkListResult<LinkedType<Q, L>>;\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined,\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, WP>,\n): UseOsdkListResult<Q>;\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined,\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, WP>,\n): UseOsdkListResult<Q> | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>> {\n const {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n withProperties,\n autoFetchMore,\n intersectWith,\n pivotTo,\n enabled = true,\n } = options ?? {};\n const { observableClient } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause<Q>(where ?? {});\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableIntersectWith = React.useMemo(\n () => intersectWith,\n [JSON.stringify(intersectWith)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectsArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)} [DISABLED]`\n : void 0,\n );\n }\n return makeExternalStore<ObserveObjectsArgs<Q>>(\n (observer) =>\n observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\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 orderBy,\n streamUpdates,\n stableWithProperties,\n autoFetchMore,\n stableIntersectWith,\n pivotTo,\n ],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n\n return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAoKhD,OAAO,SAASC,cAAcA,CAI5BC,IAAO,EACPC,OAAsC,EACiC;EACvE,MAAM;IACJC,QAAQ;IACRC,OAAO;IACPC,gBAAgB;IAChBC,KAAK,GAAG,CAAC,CAAC;IACVC,aAAa;IACbC,cAAc;IACdC,aAAa;IACbC,aAAa;IACbC,OAAO;IACPC,OAAO,GAAG;EACZ,CAAC,GAAGV,OAAO,IAAI,CAAC,CAAC;EACjB,MAAM;IAAEW;EAAiB,CAAC,GAAGhB,KAAK,CAACiB,UAAU,CAACf,YAAY,CAAC;;EAE3D;AACF;AACA;AACA;EACE,MAAMgB,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAAIV,KAAK,IAAI,CAAC,CAAC,CAAC;EAE3E,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,MAAM;IAAEY,SAAS;IAAEC;EAAY,CAAC,GAAG1B,KAAK,CAACqB,OAAO,CAC9C,MAAM;IACJ,IAAI,CAACN,OAAO,EAAE;MACZ,OAAOd,iBAAiB,CACtB,OAAO;QAAE0B,WAAW,EAAEA,CAAA,KAAM,CAAC;MAAE,CAAC,CAAC,EACjCC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQ1B,IAAI,CAAC2B,OAAO,IAAIT,IAAI,CAACC,SAAS,CAACL,UAAU,CAAC,aAAa,GAC/D,KAAK,CACX,CAAC;IACH;IACA,OAAOjB,iBAAiB,CACrB+B,QAAQ,IACPhB,gBAAgB,CAACiB,WAAW,CAAC;MAC3B7B,IAAI;MACJK,KAAK,EAAES,UAAU;MACjBgB,cAAc,EAAE1B,gBAAgB,IAAI,KAAK;MACzCF,QAAQ;MACRC,OAAO;MACPG,aAAa;MACbC,cAAc,EAAES,oBAAoB;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,EAAEkB,QAAQ,CAAC,EACdJ,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQ1B,IAAI,CAAC2B,OAAO,IAAIT,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,EACRC,OAAO,EACPG,aAAa,EACbU,oBAAoB,EACpBR,aAAa,EACbY,mBAAmB,EACnBV,OAAO,CAEX,CAAC;EAED,MAAMqB,WAAW,GAAGnC,KAAK,CAACoC,oBAAoB,CAACX,SAAS,EAAEC,WAAW,CAAC;EAEtE,IAAIW,KAAwB;EAC5B,IAAIF,WAAW,IAAI,OAAO,IAAIA,WAAW,IAAIA,WAAW,CAACE,KAAK,EAAE;IAC9DA,KAAK,GAAGF,WAAW,CAACE,KAAK;EAC3B,CAAC,MAAM,IAAIF,WAAW,EAAEG,MAAM,KAAK,OAAO,EAAE;IAC1CD,KAAK,GAAG,IAAIE,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEA,OAAO;IACLC,SAAS,EAAEL,WAAW,EAAEK,SAAS;IACjCH,KAAK;IACLI,IAAI,EAAEN,WAAW,EAAEO,YAAY;IAC/BC,SAAS,EAAER,WAAW,EAAEG,MAAM,KAAK,SAAS;IAC5CM,YAAY,EAAET,WAAW,EAAES,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
@@ -18,6 +18,7 @@ export { OsdkProvider2 } from "../new/OsdkProvider2.js";
18
18
  export { useLinks } from "../new/useLinks.js";
19
19
  export { useObjectSet } from "../new/useObjectSet.js";
20
20
  export { useOsdkAction } from "../new/useOsdkAction.js";
21
+ export { useOsdkAggregation } from "../new/useOsdkAggregation.js";
21
22
  export { useOsdkObject } from "../new/useOsdkObject.js";
22
23
  export { useOsdkObjects } from "../new/useOsdkObjects.js";
23
24
  export { useOsdkClient } from "../useOsdkClient.js";
@@ -1 +1 @@
1
- {"version":3,"file":"experimental.js","names":["OsdkProvider2","useLinks","useObjectSet","useOsdkAction","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata","useDebouncedCallback"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useLinks } from \"../new/useLinks.js\";\nexport { useObjectSet } from \"../new/useObjectSet.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\nexport { useDebouncedCallback } from \"../utils/useDebouncedCallback.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
1
+ {"version":3,"file":"experimental.js","names":["OsdkProvider2","useLinks","useObjectSet","useOsdkAction","useOsdkAggregation","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata","useDebouncedCallback"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useLinks } from \"../new/useLinks.js\";\nexport { useObjectSet } from \"../new/useObjectSet.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport type { UseOsdkAggregationResult } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkAggregation } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\nexport { useDebouncedCallback } from \"../utils/useDebouncedCallback.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../src/intellisense.test.ts"],"version":3,"file":"intellisense.test.d.ts"}
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../../src/intellisense.test.helpers/useOsdkObjectsWithPivot.ts"],"version":3,"file":"useOsdkObjectsWithPivot.d.ts"}
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../../src/intellisense.test.helpers/useOsdkObjectsWithProperties.ts"],"version":3,"file":"useOsdkObjectsWithProperties.d.ts"}
@@ -0,0 +1,5 @@
1
+ import type { DerivedProperty, InterfaceDefinition, ObjectTypeDefinition } from "@osdk/api";
2
+ export type InferRdpTypes<
3
+ Q extends ObjectTypeDefinition | InterfaceDefinition,
4
+ WP extends DerivedProperty.Clause<Q> | undefined
5
+ > = WP extends DerivedProperty.Clause<Q> ? { [K in keyof WP] : WP[K] extends DerivedProperty.Creator<Q, infer T> ? T : never } : {};
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cACE,iBACA,qBACA,4BACK,WAAY;AAEnB,YAAY;CACV,UAAU,uBAAuB;CACjC,WAAW,gBAAgB,OAAO;IAChC,WAAW,gBAAgB,OAAO,QACjC,WAAW,MAAK,GAAG,WAAW,gBAAgB,QAAQ,SAAS,KAAK,cAGrE,CAAE","names":[],"sources":["../../../src/new/types.ts"],"version":3,"file":"types.d.ts"}
@@ -18,6 +18,26 @@ export interface UseLinksOptions<T extends ObjectTypeDefinition | InterfaceDefin
18
18
  * - "offline": Only use cached data, don't make network requests
19
19
  */
20
20
  mode?: "force" | "offline";
21
+ /**
22
+ * Enable or disable the query.
23
+ *
24
+ * When `false`, the query will not automatically execute. It will still
25
+ * return any cached data, but will not fetch from the server.
26
+ *
27
+ * This is useful for:
28
+ * - Lazy/on-demand queries that should wait for user interaction
29
+ * - Dependent queries that need data from another query first
30
+ * - Conditional queries based on component state
31
+ *
32
+ * @default true
33
+ * @example
34
+ * // Dependent query - wait for employee data
35
+ * const { object: employee } = useOsdkObject(Employee, employeeId);
36
+ * const { links: reports } = useLinks(employee, "reports", {
37
+ * enabled: !!employee
38
+ * });
39
+ */
40
+ enabled?: boolean;
21
41
  }
22
42
  export interface UseLinksResult<Q extends ObjectTypeDefinition | InterfaceDefinition> {
23
43
  links: Osdk.Instance<Q>[] | undefined;
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,YAAY,iBAAiB,WAAY;AACvD,cACE,qBACA,sBACA,MACA,cACA,mBACK,cAAe;AAMtB,iBAAiB,gBACf,UAAU,uBAAuB,qBACjC;;;;CAIA,QAAQ,YAAY;;;;CAKpB;;CAGA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;;;;CASnC,OAAO,UAAU;AAClB;AAED,iBAAiB,eACf,UAAU,uBAAuB,qBACjC;CACA,OAAO,KAAK,SAAS;CACrB;CACA,OAAO;;;;CAKP;;;;CAKA,kBAAkB;;;;CAKlB;AACD;;;;;;;;;AAYD,OAAO,iBAAS;CACd,UAAU;CACV,UAAU,UAAU;EAEpBA,SAAS,KAAK,SAAS,KAAK,MAAM,KAAK,SAAS,iBAChDC,UAAU,GACVC,UAAS,gBAAgB,WAAW,GAAG,MACtC,eAAe,WAAW,GAAG","names":["objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined","linkName: L","options: UseLinksOptions<LinkedType<T, L>>"],"sources":["../../../src/new/useLinks.ts"],"version":3,"file":"useLinks.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,YAAY,iBAAiB,WAAY;AACvD,cACE,qBACA,sBACA,MACA,cACA,mBACK,cAAe;AAMtB,iBAAiB,gBACf,UAAU,uBAAuB,qBACjC;;;;CAIA,QAAQ,YAAY;;;;CAKpB;;CAGA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;;;;CASnC,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;CAqBjB;AACD;AAED,iBAAiB,eACf,UAAU,uBAAuB,qBACjC;CACA,OAAO,KAAK,SAAS;CACrB;CACA,OAAO;;;;CAKP;;;;CAKA,kBAAkB;;;;CAKlB;AACD;;;;;;;;;AAYD,OAAO,iBAAS;CACd,UAAU;CACV,UAAU,UAAU;EAEpBA,SAAS,KAAK,SAAS,KAAK,MAAM,KAAK,SAAS,iBAChDC,UAAU,GACVC,UAAS,gBAAgB,WAAW,GAAG,MACtC,eAAe,WAAW,GAAG","names":["objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined","linkName: L","options: UseLinksOptions<LinkedType<T, L>>"],"sources":["../../../src/new/useLinks.ts"],"version":3,"file":"useLinks.d.ts"}
@@ -39,6 +39,42 @@ export interface UseObjectSetOptions<
39
39
  * Minimum time between fetch requests in milliseconds (defaults to 2000ms)
40
40
  */
41
41
  dedupeIntervalMs?: number;
42
+ /**
43
+ * Automatically fetch additional pages on initial load.
44
+ *
45
+ * - `true`: Fetch all available pages automatically
46
+ * - `number`: Fetch pages until at least this many items are loaded
47
+ * - `undefined` (default): Only fetch the first page, user must call fetchMore()
48
+ */
49
+ autoFetchMore?: boolean | number;
50
+ /**
51
+ * Enable streaming updates via websocket subscription.
52
+ * When true, the object set will automatically update when matching objects are
53
+ * added, updated, or removed.
54
+ *
55
+ * @default false
56
+ */
57
+ streamUpdates?: boolean;
58
+ /**
59
+ * Enable or disable the query.
60
+ *
61
+ * When `false`, the query will not automatically execute. It will still
62
+ * return any cached data, but will not fetch from the server.
63
+ *
64
+ * This is useful for:
65
+ * - Lazy/on-demand queries that should wait for user interaction
66
+ * - Dependent queries that need data from another query first
67
+ * - Conditional queries based on component state
68
+ *
69
+ * @default true
70
+ * @example
71
+ * // Dependent query - wait for filter selection
72
+ * const { data: filteredObjects } = useObjectSet(MyObject.all(), {
73
+ * where: { status: selectedStatus },
74
+ * enabled: !!selectedStatus
75
+ * });
76
+ */
77
+ enabled?: boolean;
42
78
  }
43
79
  export interface UseObjectSetResult<
44
80
  Q extends ObjectTypeDefinition,
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cACE,iBACA,WACA,WACA,sBACA,MACA,cACA,mBACA,mBACK,WAAY;AAUnB,iBAAiB;CACf,UAAU;CACV,aAAa,eAAe,qBAAqB,CAAE;EACnD;;;;CAIA,QAAQ,YAAY,GAAG;;;;CAKvB,oBAAoB,WAAW,QAAO,gBAAgB,QAAQ,GAAG,KAAK;;;;CAKtE,QAAQ,UAAU;;;;CAKlB,YAAY,UAAU;;;;CAKtB,WAAW,UAAU;;;;CAKrB,UAAU,UAAU;;;;CAKpB;;;;CAKA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;CAMnC;AACD;AAED,iBAAiB;CACf,UAAU;CACV,aAAa,eAAe,qBAAqB,CAAE;EACnD;;;;CAIA,MACI,KAAK,SAAS,GAAG,sBAAsB,aAAa,IAAI;;;;CAM5D;;;;CAKA,OAAO;;;;CAKP,kBAAkB;;;;CAKlB,WAAW,UAAU,GAAG;AACzB;;;;;;;;;;;;AAmBD,OAAO,iBAAS;CACd,UAAU;CACV,iBAAiB,eAAe;CAChC,aAAa,eAAe,qBAAqB,CAAE;EAEnDA,eAAe,UAAU,GAAG,WAC5BC,UAAS,oBAAoB,GAAG,QAC/B,mBAAmB,GAAG","names":["baseObjectSet: ObjectSet<Q, BaseRDPs>","options: UseObjectSetOptions<Q, RDPs>"],"sources":["../../../src/new/useObjectSet.tsx"],"version":3,"file":"useObjectSet.d.ts"}
1
+ {"mappings":"AAgBA,cACE,iBACA,WACA,WACA,sBACA,MACA,cACA,mBACA,mBACK,WAAY;AAUnB,iBAAiB;CACf,UAAU;CACV,aAAa,eAAe,qBAAqB,CAAE;EACnD;;;;CAIA,QAAQ,YAAY,GAAG;;;;CAKvB,oBAAoB,WAAW,QAAO,gBAAgB,QAAQ,GAAG,KAAK;;;;CAKtE,QAAQ,UAAU;;;;CAKlB,YAAY,UAAU;;;;CAKtB,WAAW,UAAU;;;;CAKrB,UAAU,UAAU;;;;CAKpB;;;;CAKA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;CAMnC;;;;;;;;CASA;;;;;;;;CASA;;;;;;;;;;;;;;;;;;;;CAqBA;AACD;AAED,iBAAiB;CACf,UAAU;CACV,aAAa,eAAe,qBAAqB,CAAE;EACnD;;;;CAIA,MACI,KAAK,SAAS,GAAG,sBAAsB,aAAa,IAAI;;;;CAM5D;;;;CAKA,OAAO;;;;CAKP,kBAAkB;;;;CAKlB,WAAW,UAAU,GAAG;AACzB;;;;;;;;;;;;AAmBD,OAAO,iBAAS;CACd,UAAU;CACV,iBAAiB,eAAe;CAChC,aAAa,eAAe,qBAAqB,CAAE;EAEnDA,eAAe,UAAU,GAAG,WAC5BC,UAAS,oBAAoB,GAAG,QAC/B,mBAAmB,GAAG","names":["baseObjectSet: ObjectSet<Q, BaseRDPs>","options: UseObjectSetOptions<Q, RDPs>"],"sources":["../../../src/new/useObjectSet.tsx"],"version":3,"file":"useObjectSet.d.ts"}
@@ -0,0 +1,67 @@
1
+ import type { AggregateOpts, AggregationsResults, DerivedProperty, WhereClause } from "@osdk/api";
2
+ import type { ObjectTypeDefinition } from "@osdk/client";
3
+ import type { InferRdpTypes } from "./types.js";
4
+ export interface UseOsdkAggregationOptions<
5
+ T extends ObjectTypeDefinition,
6
+ A extends AggregateOpts<T>,
7
+ WithProps extends DerivedProperty.Clause<T> | undefined = undefined
8
+ > {
9
+ /**
10
+ * Standard OSDK Where clause to filter objects before aggregation
11
+ */
12
+ where?: WhereClause<T, InferRdpTypes<T, WithProps>>;
13
+ /**
14
+ * Define derived properties (RDPs) to be computed server-side.
15
+ * The derived properties can be used in the where clause and aggregation groupBy/select.
16
+ */
17
+ withProperties?: WithProps;
18
+ /**
19
+ * Aggregation options including groupBy and select
20
+ */
21
+ aggregate: A;
22
+ /**
23
+ * The number of milliseconds to wait after the last observed aggregation change.
24
+ *
25
+ * Two uses of `useOsdkAggregation` with the same parameters will only trigger one
26
+ * network request if the second is within `dedupeIntervalMs`.
27
+ */
28
+ dedupeIntervalMs?: number;
29
+ }
30
+ export interface UseOsdkAggregationResult<
31
+ T extends ObjectTypeDefinition,
32
+ A extends AggregateOpts<T>
33
+ > {
34
+ data: AggregationsResults<T, A> | undefined;
35
+ isLoading: boolean;
36
+ error: Error | undefined;
37
+ refetch: () => void;
38
+ }
39
+ /**
40
+ * React hook for performing aggregations on OSDK object sets.
41
+ *
42
+ * Executes server-side aggregations with groupBy and metric calculations on filtered object sets.
43
+ * Supports runtime derived properties and where clauses.
44
+ *
45
+ * @param type - The object or interface type to aggregate
46
+ * @param options - Aggregation configuration including where clause, aggregation spec, and optional derived properties
47
+ * @returns Object containing aggregation results, loading state, error state, and refetch function
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * const { data, isLoading, error } = useOsdkAggregation(Employee, {
52
+ * where: { department: "Engineering" },
53
+ * aggregate: {
54
+ * groupBy: { department: "exact" },
55
+ * select: {
56
+ * avgSalary: { $avg: "salary" },
57
+ * count: { $count: {} }
58
+ * }
59
+ * }
60
+ * });
61
+ * ```
62
+ */
63
+ export declare function useOsdkAggregation<
64
+ Q extends ObjectTypeDefinition,
65
+ A extends AggregateOpts<Q>,
66
+ WP extends DerivedProperty.Clause<Q> | undefined = undefined
67
+ >(type: Q, { where, withProperties, aggregate, dedupeIntervalMs }: UseOsdkAggregationOptions<Q, A, WP>): UseOsdkAggregationResult<Q, A>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cACE,eACA,qBACA,iBACA,mBACK,WAAY;AACnB,cAAc,4BAA4B,cAAe;AAKzD,cAAc,qBAAqB,YAAa;AAEhD,iBAAiB;CACf,UAAU;CACV,UAAU,cAAc;CACxB,kBAAkB,gBAAgB,OAAO;EACzC;;;;CAIA,QAAQ,YAAY,GAAG,cAAc,GAAG;;;;;CAMxC,iBAAiB;;;;CAKjB,WAAW;;;;;;;CAQX;AACD;AAED,iBAAiB;CACf,UAAU;CACV,UAAU,cAAc;EACxB;CACA,MAAM,oBAAoB,GAAG;CAC7B;CACA,OAAO;CACP;AACD;;;;;;;;;;;;;;;;;;;;;;;;;AAgCD,OAAO,iBAAS;CACd,UAAU;CACV,UAAU,cAAc;CACxB,WAAW,gBAAgB,OAAO;EAElCA,MAAM,GACN,EACE,OACA,gBACA,WACA,kBACoC,EAAnC,0BAA0B,GAAG,GAAG,MAClC,yBAAyB,GAAG","names":["type: Q"],"sources":["../../../src/new/useOsdkAggregation.ts"],"version":3,"file":"useOsdkAggregation.d.ts"}
@@ -11,12 +11,14 @@ export interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {
11
11
  }
12
12
  /**
13
13
  * @param obj an existing `Osdk.Instance` object to get metadata for.
14
+ * @param enabled Enable or disable the query (defaults to true)
14
15
  */
15
- export declare function useOsdkObject<Q extends ObjectTypeDefinition>(obj: Osdk.Instance<Q>): UseOsdkObjectResult<Q>;
16
+ export declare function useOsdkObject<Q extends ObjectTypeDefinition>(obj: Osdk.Instance<Q>, enabled?: boolean): UseOsdkObjectResult<Q>;
16
17
  /**
17
18
  * Loads an object by type and primary key.
18
19
  *
19
20
  * @param type
20
21
  * @param primaryKey
22
+ * @param enabled Enable or disable the query (defaults to true)
21
23
  */
22
- export declare function useOsdkObject<Q extends ObjectTypeDefinition>(type: Q, primaryKey: PrimaryKeyType<Q>): UseOsdkObjectResult<Q>;
24
+ export declare function useOsdkObject<Q extends ObjectTypeDefinition>(type: Q, primaryKey: PrimaryKeyType<Q>, enabled?: boolean): UseOsdkObjectResult<Q>;
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,sBAAsB,MAAM,sBAAsB,WAAY;AAM5E,iBAAiB,oBAAoB,UAAU,sBAAsB;CACnE,QAAQ,KAAK,SAAS;CACtB;CAEA,OAAO;;;;CAKP;CACA;AACD;;;;AAKD,OAAO,iBAAS,cAAc,UAAU,sBACtCA,KAAK,KAAK,SAAS,KAClB,oBAAoB;;;;;;;AAOvB,OAAO,iBAAS,cAAc,UAAU,sBACtCC,MAAM,GACNC,YAAY,eAAe,KAC1B,oBAAoB","names":["obj: Osdk.Instance<Q>","type: Q","primaryKey: PrimaryKeyType<Q>"],"sources":["../../../src/new/useOsdkObject.ts"],"version":3,"file":"useOsdkObject.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,sBAAsB,MAAM,sBAAsB,WAAY;AAM5E,iBAAiB,oBAAoB,UAAU,sBAAsB;CACnE,QAAQ,KAAK,SAAS;CACtB;CAEA,OAAO;;;;CAKP;CACA;AACD;;;;;AAMD,OAAO,iBAAS,cAAc,UAAU,sBACtCA,KAAK,KAAK,SAAS,IACnBC,oBACC,oBAAoB;;;;;;;;AAQvB,OAAO,iBAAS,cAAc,UAAU,sBACtCC,MAAM,GACNC,YAAY,eAAe,IAC3BF,oBACC,oBAAoB","names":["obj: Osdk.Instance<Q>","enabled?: boolean","type: Q","primaryKey: PrimaryKeyType<Q>"],"sources":["../../../src/new/useOsdkObject.ts"],"version":3,"file":"useOsdkObject.d.ts"}
@@ -1,9 +1,5 @@
1
- import type { WhereClause } from "@osdk/api";
2
- import type { DerivedProperty, InterfaceDefinition, ObjectTypeDefinition, Osdk, PropertyKeys } from "@osdk/client";
3
- type InferRdpTypes<
4
- Q extends ObjectTypeDefinition | InterfaceDefinition,
5
- WP extends DerivedProperty.Clause<Q> | undefined
6
- > = WP extends DerivedProperty.Clause<Q> ? { [K in keyof WP] : WP[K] extends DerivedProperty.Creator<Q, infer T> ? T : never } : {};
1
+ import type { DerivedProperty, InterfaceDefinition, LinkedType, LinkNames, ObjectTypeDefinition, Osdk, PropertyKeys, WhereClause } from "@osdk/api";
2
+ import type { InferRdpTypes } from "./types.js";
7
3
  export interface UseOsdkObjectsOptions<
8
4
  T extends ObjectTypeDefinition | InterfaceDefinition,
9
5
  WithProps extends DerivedProperty.Clause<T> | undefined = undefined
@@ -24,10 +20,43 @@ export interface UseOsdkObjectsOptions<
24
20
  */
25
21
  withProperties?: WithProps;
26
22
  /**
23
+ * Intersect the results with additional object sets.
24
+ * Each element defines a where clause for an object set to intersect with.
25
+ * The final result will only include objects that match ALL conditions.
26
+ */
27
+ intersectWith?: Array<{
28
+ where: WhereClause<T, InferRdpTypes<T, WithProps>>
29
+ }>;
30
+ /**
31
+ * Pivot to related objects through a link.
32
+ * This changes the return type from T to the linked object type.
33
+ */
34
+ pivotTo?: LinkNames<T>;
35
+ /**
27
36
  * Causes the list to automatically fetch more as soon as the previous page
28
37
  * has been loaded. If a number is provided, it will continue to automatically
29
38
  * fetch more until the list is at least that long.
39
+ *
40
+ * - `true`: Fetch all available pages automatically
41
+ * - `number`: Fetch pages until at least this many items are loaded
42
+ * - `undefined` (default): Only fetch the first page, user must call fetchMore()
43
+ *
44
+ * Note: When using `autoFetchMore: true` with large datasets, the initial
45
+ * load may take significant time. Consider using a specific number instead
46
+ * or implementing virtual scrolling.
47
+ *
48
+ * @example
49
+ * // Fetch all todos at once
50
+ * const { data } = useOsdkObjects(Todo, { autoFetchMore: true })
51
+ *
52
+ * @example
53
+ * // Fetch at least 100 todos (with 25 per page, fetches 4 pages)
54
+ * const { data } = useOsdkObjects(Todo, {
55
+ * autoFetchMore: 100,
56
+ * pageSize: 25
57
+ * })
30
58
  */
59
+ autoFetchMore?: boolean | number;
31
60
  /**
32
61
  * Upon a list being revalidated, this option determines how the component
33
62
  * will be re-rendered with the data.
@@ -54,16 +83,31 @@ export interface UseOsdkObjectsOptions<
54
83
  * network request if the second is within `dedupeIntervalMs`.
55
84
  */
56
85
  dedupeIntervalMs?: number;
86
+ streamUpdates?: boolean;
57
87
  /**
58
- * If provided, the list will be considered this length for the purposes of
59
- * `invalidationMode` when using the `wait` option. If not provided,
60
- * the internal expectedLength will be determined by the number of times
61
- * `fetchMore` has been called.
88
+ * Enable or disable the query.
89
+ *
90
+ * When `false`, the query will not automatically execute. It will still
91
+ * return any cached data, but will not fetch from the server.
92
+ *
93
+ * This is useful for:
94
+ * - Lazy/on-demand queries that should wait for user interaction
95
+ * - Dependent queries that need data from another query first
96
+ * - Conditional queries based on component state
97
+ *
98
+ * @default true
99
+ * @example
100
+ * // Dependent query - wait for parent data
101
+ * const { data: employee } = useOsdkObject(Employee, employeeId);
102
+ * const { data: reports } = useOsdkObjects(Employee, {
103
+ * where: { managerId: employee?.id },
104
+ * enabled: !!employee
105
+ * });
62
106
  */
63
- streamUpdates?: boolean;
107
+ enabled?: boolean;
64
108
  }
65
109
  export interface UseOsdkListResult<T extends ObjectTypeDefinition | InterfaceDefinition> {
66
- fetchMore: (() => Promise<unknown>) | undefined;
110
+ fetchMore: (() => Promise<void>) | undefined;
67
111
  data: Osdk.Instance<T>[] | undefined;
68
112
  isLoading: boolean;
69
113
  error: Error | undefined;
@@ -76,8 +120,13 @@ export interface UseOsdkListResult<T extends ObjectTypeDefinition | InterfaceDef
76
120
  */
77
121
  isOptimistic: boolean;
78
122
  }
123
+ export declare function useOsdkObjects<
124
+ Q extends ObjectTypeDefinition,
125
+ L extends LinkNames<Q>
126
+ >(type: Q, options: UseOsdkObjectsOptions<Q> & {
127
+ pivotTo: L
128
+ }): UseOsdkListResult<LinkedType<Q, L>>;
79
129
  export declare function useOsdkObjects<
80
130
  Q extends ObjectTypeDefinition | InterfaceDefinition,
81
- WP extends DerivedProperty.Clause<Q> | undefined = undefined
131
+ WP extends DerivedProperty.Clause<Q> | undefined
82
132
  >(type: Q, options?: UseOsdkObjectsOptions<Q, WP>): UseOsdkListResult<Q>;
83
- export {};
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,mBAAmB,WAAY;AAC7C,cACE,iBACA,qBACA,sBACA,MACA,oBACK,cAAe;KAMjB;CACH,UAAU,uBAAuB;CACjC,WAAW,gBAAgB,OAAO;IAChC,WAAW,gBAAgB,OAAO,QACjC,WAAW,MAAK,GAAG,WAAW,gBAAgB,QAAQ,SAAS,KAAK,cAGrE,CAAE;AAEN,iBAAiB;CACf,UAAU,uBAAuB;CACjC,kBAAkB,gBAAgB,OAAO;EACzC;;;;CAIA,QAAQ,YAAY,GAAG,cAAc,GAAG;;;;CAKxC;;CAGA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;;CAOnC,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCjB;;;;;;;CAUA;AACD;AAED,iBAAiB,kBACf,UAAU,uBAAuB,qBACjC;CACA,kBAAkB;CAClB,MAAM,KAAK,SAAS;CACpB;CAEA,OAAO;;;;;;;;CASP;AACD;AAQD,OAAO,iBAAS;CACd,UAAU,uBAAuB;CACjC,WAAW,gBAAgB,OAAO;EAElCA,MAAM,GACNC,UAAU,sBAAsB,GAAG,MAClC,kBAAkB","names":["type: Q","options?: UseOsdkObjectsOptions<Q, WP>"],"sources":["../../../src/new/useOsdkObjects.ts"],"version":3,"file":"useOsdkObjects.d.ts"}
1
+ {"mappings":"AAgBA,cACE,iBACA,qBACA,YACA,WACA,sBACA,MACA,cACA,mBACK,WAAY;AAKnB,cAAc,qBAAqB,YAAa;AAEhD,iBAAiB;CACf,UAAU,uBAAuB;CACjC,kBAAkB,gBAAgB,OAAO;EACzC;;;;CAIA,QAAQ,YAAY,GAAG,cAAc,GAAG;;;;CAKxC;;CAGA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;;CAOnC,iBAAiB;;;;;;CAOjB,gBAAgB,MAAM;EACpB,OAAO,YAAY,GAAG,cAAc,GAAG;CACxC;;;;;CAMD,UAAU,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;CA0BpB;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BA;CAEA;;;;;;;;;;;;;;;;;;;;;CAsBA;AACD;AAED,iBAAiB,kBACf,UAAU,uBAAuB,qBACjC;CACA,kBAAkB;CAClB,MAAM,KAAK,SAAS;CACpB;CAEA,OAAO;;;;;;;;CASP;AACD;AAQD,OAAO,iBAAS;CACd,UAAU;CACV,UAAU,UAAU;EAEpBA,MAAM,GACNC,SAAS,sBAAsB,KAAK;CAAE,SAAS;AAAG,IACjD,kBAAkB,WAAW,GAAG;AAEnC,OAAO,iBAAS;CACd,UAAU,uBAAuB;CACjC,WAAW,gBAAgB,OAAO;EAElCD,MAAM,GACNE,UAAU,sBAAsB,GAAG,MAClC,kBAAkB","names":["type: Q","options: UseOsdkObjectsOptions<Q> & { pivotTo: L }","options?: UseOsdkObjectsOptions<Q, WP>"],"sources":["../../../src/new/useOsdkObjects.ts"],"version":3,"file":"useOsdkObjects.d.ts"}
@@ -2,6 +2,8 @@ export { OsdkProvider2 } from "../new/OsdkProvider2.js";
2
2
  export { useLinks } from "../new/useLinks.js";
3
3
  export { useObjectSet } from "../new/useObjectSet.js";
4
4
  export { useOsdkAction } from "../new/useOsdkAction.js";
5
+ export type { UseOsdkAggregationResult } from "../new/useOsdkAggregation.js";
6
+ export { useOsdkAggregation } from "../new/useOsdkAggregation.js";
5
7
  export { useOsdkObject } from "../new/useOsdkObject.js";
6
8
  export type { UseOsdkListResult } from "../new/useOsdkObjects.js";
7
9
  export { useOsdkObjects } from "../new/useOsdkObjects.js";
@@ -1 +1 @@
1
- {"mappings":"AAgBA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,cAAc,yBAAyB;AACvC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,cAAc,6BAA6B;AAC3C,SAAS,4BAA4B","names":[],"sources":["../../../src/public/experimental.ts"],"version":3,"file":"experimental.d.ts"}
1
+ {"mappings":"AAgBA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,cAAc,gCAAgC;AAC9C,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAC9B,cAAc,yBAAyB;AACvC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,cAAc,6BAA6B;AAC3C,SAAS,4BAA4B","names":[],"sources":["../../../src/public/experimental.ts"],"version":3,"file":"experimental.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/react",
3
- "version": "0.8.0-beta.2",
3
+ "version": "0.8.0-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,15 +45,21 @@
45
45
  "devDependencies": {
46
46
  "@testing-library/react": "^16.3.0",
47
47
  "@types/react": "^18.3.24",
48
+ "find-up": "^8.0.0",
48
49
  "happy-dom": "^16.8.1",
49
50
  "p-defer": "^4.0.1",
51
+ "p-locate": "^6.0.0",
52
+ "p-map": "^7.0.3",
53
+ "pino": "^9.9.4",
54
+ "pino-pretty": "^11.3.0",
50
55
  "react": "^18.3.1",
51
56
  "tiny-invariant": "^1.3.3",
52
57
  "typescript": "~5.5.4",
53
- "@osdk/api": "2.6.0-beta.4",
58
+ "@osdk/api": "2.6.0-beta.11",
59
+ "@osdk/client": "2.6.0-beta.11",
60
+ "@osdk/monorepo.api-extractor": "~0.5.0-beta.1",
54
61
  "@osdk/monorepo.tsconfig": "~0.5.0-beta.1",
55
- "@osdk/client": "2.6.0-beta.4",
56
- "@osdk/monorepo.api-extractor": "~0.5.0-beta.1"
62
+ "@osdk/client.test.ontology": "2.6.0-beta.11"
57
63
  },
58
64
  "publishConfig": {
59
65
  "access": "public"