@osdk/react 0.9.0-beta.1 → 0.9.0-beta.10

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 (100) hide show
  1. package/AGENTS.md +253 -0
  2. package/CHANGELOG.md +118 -0
  3. package/build/browser/intellisense.test.js +1 -1
  4. package/build/browser/intellisense.test.js.map +1 -1
  5. package/build/browser/new/makeExternalStore.js +2 -2
  6. package/build/browser/new/makeExternalStore.js.map +1 -1
  7. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js +44 -0
  8. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -0
  9. package/build/browser/new/platform-apis/admin/useFoundryUser.js +50 -0
  10. package/build/browser/new/platform-apis/admin/useFoundryUser.js.map +1 -0
  11. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js +54 -0
  12. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js.map +1 -0
  13. package/build/browser/new/useLinks.js +15 -8
  14. package/build/browser/new/useLinks.js.map +1 -1
  15. package/build/browser/new/useObjectSet.js +20 -4
  16. package/build/browser/new/useObjectSet.js.map +1 -1
  17. package/build/browser/new/useOsdkAction.js.map +1 -1
  18. package/build/browser/new/useOsdkAggregation.js +1 -1
  19. package/build/browser/new/useOsdkAggregation.js.map +1 -1
  20. package/build/browser/new/useOsdkFunction.js +101 -0
  21. package/build/browser/new/useOsdkFunction.js.map +1 -0
  22. package/build/browser/new/useOsdkObject.js +1 -1
  23. package/build/browser/new/useOsdkObject.js.map +1 -1
  24. package/build/browser/new/useOsdkObjects.js +4 -3
  25. package/build/browser/new/useOsdkObjects.js.map +1 -1
  26. package/build/browser/public/experimental.js +4 -0
  27. package/build/browser/public/experimental.js.map +1 -1
  28. package/build/browser/utils/usePlatformQuery.js +74 -0
  29. package/build/browser/utils/usePlatformQuery.js.map +1 -0
  30. package/build/cjs/{chunk-OVBG5VXE.cjs → chunk-V32JHU3O.cjs} +8 -3
  31. package/build/cjs/chunk-V32JHU3O.cjs.map +1 -0
  32. package/build/cjs/index.cjs +4 -4
  33. package/build/cjs/public/experimental.cjs +413 -67
  34. package/build/cjs/public/experimental.cjs.map +1 -1
  35. package/build/cjs/public/experimental.d.cts +279 -32
  36. package/build/esm/intellisense.test.js +1 -1
  37. package/build/esm/intellisense.test.js.map +1 -1
  38. package/build/esm/new/makeExternalStore.js +2 -2
  39. package/build/esm/new/makeExternalStore.js.map +1 -1
  40. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js +44 -0
  41. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -0
  42. package/build/esm/new/platform-apis/admin/useFoundryUser.js +50 -0
  43. package/build/esm/new/platform-apis/admin/useFoundryUser.js.map +1 -0
  44. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js +54 -0
  45. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js.map +1 -0
  46. package/build/esm/new/useLinks.js +15 -8
  47. package/build/esm/new/useLinks.js.map +1 -1
  48. package/build/esm/new/useObjectSet.js +20 -4
  49. package/build/esm/new/useObjectSet.js.map +1 -1
  50. package/build/esm/new/useOsdkAction.js.map +1 -1
  51. package/build/esm/new/useOsdkAggregation.js +1 -1
  52. package/build/esm/new/useOsdkAggregation.js.map +1 -1
  53. package/build/esm/new/useOsdkFunction.js +101 -0
  54. package/build/esm/new/useOsdkFunction.js.map +1 -0
  55. package/build/esm/new/useOsdkObject.js +1 -1
  56. package/build/esm/new/useOsdkObject.js.map +1 -1
  57. package/build/esm/new/useOsdkObjects.js +4 -3
  58. package/build/esm/new/useOsdkObjects.js.map +1 -1
  59. package/build/esm/public/experimental.js +4 -0
  60. package/build/esm/public/experimental.js.map +1 -1
  61. package/build/esm/utils/usePlatformQuery.js +74 -0
  62. package/build/esm/utils/usePlatformQuery.js.map +1 -0
  63. package/build/types/new/makeExternalStore.d.ts +1 -1
  64. package/build/types/new/makeExternalStore.d.ts.map +1 -1
  65. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts +28 -0
  66. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts.map +1 -0
  67. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts +36 -0
  68. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts.map +1 -0
  69. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts +52 -0
  70. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts.map +1 -0
  71. package/build/types/new/useLinks.d.ts +5 -5
  72. package/build/types/new/useLinks.d.ts.map +1 -1
  73. package/build/types/new/useObjectSet.d.ts +4 -0
  74. package/build/types/new/useObjectSet.d.ts.map +1 -1
  75. package/build/types/new/useOsdkAction.d.ts +3 -3
  76. package/build/types/new/useOsdkAction.d.ts.map +1 -1
  77. package/build/types/new/useOsdkAggregation.d.ts +10 -12
  78. package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
  79. package/build/types/new/useOsdkFunction.d.ts +112 -0
  80. package/build/types/new/useOsdkFunction.d.ts.map +1 -0
  81. package/build/types/new/useOsdkObjects.d.ts +31 -13
  82. package/build/types/new/useOsdkObjects.d.ts.map +1 -1
  83. package/build/types/public/experimental.d.ts +5 -0
  84. package/build/types/public/experimental.d.ts.map +1 -1
  85. package/build/types/utils/usePlatformQuery.d.ts +25 -0
  86. package/build/types/utils/usePlatformQuery.d.ts.map +1 -0
  87. package/docs/actions.md +414 -0
  88. package/docs/advanced-queries.md +663 -0
  89. package/docs/cache-management.md +213 -0
  90. package/docs/getting-started.md +382 -0
  91. package/docs/platform-apis.md +203 -0
  92. package/docs/querying-data.md +648 -0
  93. package/package.json +8 -4
  94. package/build/browser/new/types.js +0 -2
  95. package/build/browser/new/types.js.map +0 -1
  96. package/build/cjs/chunk-OVBG5VXE.cjs.map +0 -1
  97. package/build/esm/new/types.js +0 -2
  98. package/build/esm/new/types.js.map +0 -1
  99. package/build/types/new/types.d.ts +0 -5
  100. package/build/types/new/types.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","options","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","withProperties","autoFetchMore","intersectWith","pivotTo","enabled","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","stableIntersectWith","stableOrderBy","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","apiName","observer","observeList","dedupeInterval","listPayload","useSyncExternalStore","error","status","Error","fetchMore","data","resolvedList","isLoading","isOptimistic"],"sources":["useOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n InterfaceDefinition,\n LinkedType,\n LinkNames,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObserveObjectsArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nimport type { InferRdpTypes } from \"./types.js\";\n\nexport interface UseOsdkObjectsOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n WithProps extends DerivedProperty.Clause<T> | undefined = undefined,\n> {\n /**\n * Standard OSDK Where with RDP support\n */\n where?: WhereClause<T, InferRdpTypes<T, WithProps>>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Define derived properties (RDPs) to be computed server-side and attached to each object.\n * These properties will be available on the returned objects alongside their regular properties.\n */\n withProperties?: WithProps;\n\n /**\n * Intersect the results with additional object sets.\n * Each element defines a where clause for an object set to intersect with.\n * The final result will only include objects that match ALL conditions.\n */\n intersectWith?: Array<{\n where: WhereClause<T, InferRdpTypes<T, WithProps>>;\n }>;\n\n /**\n * Pivot to related objects through a link.\n * This changes the return type from T to the linked object type.\n */\n pivotTo?: LinkNames<T>;\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n *\n * Note: When using `autoFetchMore: true` with large datasets, the initial\n * load may take significant time. Consider using a specific number instead\n * or implementing virtual scrolling.\n *\n * @example\n * // Fetch all todos at once\n * const { data } = useOsdkObjects(Todo, { autoFetchMore: true })\n *\n * @example\n * // Fetch at least 100 todos (with 25 per page, fetches 4 pages)\n * const { data } = useOsdkObjects(Todo, {\n * autoFetchMore: 100,\n * pageSize: 25\n * })\n */\n autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n streamUpdates?: boolean;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for parent data\n * const { data: employee } = useOsdkObject(Employee, employeeId);\n * const { data: reports } = useOsdkObjects(Employee, {\n * where: { managerId: employee?.id },\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n fetchMore: (() => Promise<void>) | undefined;\n data: Osdk.Instance<T>[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition,\n L extends LinkNames<Q>,\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q> & { pivotTo: L },\n): UseOsdkListResult<LinkedType<Q, L>>;\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined,\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, WP>,\n): UseOsdkListResult<Q>;\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n WP extends DerivedProperty.Clause<Q> | undefined,\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, WP>,\n): UseOsdkListResult<Q> | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>> {\n const {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n withProperties,\n autoFetchMore,\n intersectWith,\n pivotTo,\n enabled = true,\n } = options ?? {};\n const { observableClient } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause<Q>(where ?? {});\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableIntersectWith = React.useMemo(\n () => intersectWith,\n [JSON.stringify(intersectWith)],\n );\n\n const stableOrderBy = React.useMemo(\n () => orderBy,\n [JSON.stringify(orderBy)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectsArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)} [DISABLED]`\n : void 0,\n );\n }\n return makeExternalStore<ObserveObjectsArgs<Q>>(\n (observer) =>\n observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy: stableOrderBy,\n streamUpdates,\n withProperties: stableWithProperties,\n autoFetchMore,\n ...(stableIntersectWith\n ? { intersectWith: stableIntersectWith }\n : {}),\n ...(pivotTo ? { pivotTo } : {}),\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n );\n },\n [\n enabled,\n observableClient,\n type,\n canonWhere,\n dedupeIntervalMs,\n pageSize,\n stableOrderBy,\n streamUpdates,\n stableWithProperties,\n autoFetchMore,\n stableIntersectWith,\n pivotTo,\n ],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n\n return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAoKhD,OAAO,SAASC,cAAcA,CAI5BC,IAAO,EACPC,OAAsC,EACiC;EACvE,MAAM;IACJC,QAAQ;IACRC,OAAO;IACPC,gBAAgB;IAChBC,KAAK,GAAG,CAAC,CAAC;IACVC,aAAa;IACbC,cAAc;IACdC,aAAa;IACbC,aAAa;IACbC,OAAO;IACPC,OAAO,GAAG;EACZ,CAAC,GAAGV,OAAO,IAAI,CAAC,CAAC;EACjB,MAAM;IAAEW;EAAiB,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,MAAMY,aAAa,GAAGzB,KAAK,CAACqB,OAAO,CACjC,MAAMd,OAAO,EACb,CAACe,IAAI,CAACC,SAAS,CAAChB,OAAO,CAAC,CAC1B,CAAC;EAED,MAAM;IAAEmB,SAAS;IAAEC;EAAY,CAAC,GAAG3B,KAAK,CAACqB,OAAO,CAC9C,MAAM;IACJ,IAAI,CAACN,OAAO,EAAE;MACZ,OAAOd,iBAAiB,C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AC3B,CAAC,MAAM,IAAIF,WAAW,EAAEG,MAAM,KAAK,OAAO,EAAE;IAC1CD,KAAK,GAAG,IAAIE,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEA,OAAO;IACLC,SAAS,EAAEL,WAAW,EAAEK,SAAS;IACjCH,KAAK;IACLI,IAAI,EAAEN,WAAW,EAAEO,YAAY;IAC/BC,SAAS,EAAER,WAAW,EAAEG,MAAM,KAAK,SAAS;IAC5CM,YAAY,EAAET,WAAW,EAAES,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","options","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","withProperties","autoFetchMore","intersectWith","pivotTo","enabled","observableClient","useContext","canonWhere","canonicalizeWhereClause","stableWithProperties","useMemo","JSON","stringify","stableIntersectWith","stableOrderBy","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","apiName","observer","observeList","dedupeInterval","listPayload","useSyncExternalStore","error","status","Error","fetchMore","hasMore","undefined","data","resolvedList","isLoading","isOptimistic","totalCount"],"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 LinkedType,\n LinkNames,\n ObjectOrInterfaceDefinition,\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\";\n\nexport interface UseOsdkObjectsOptions<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Standard OSDK Where with RDP support\n */\n where?: WhereClause<T, RDPs>;\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?: { [K in keyof RDPs]: DerivedProperty.Creator<T, RDPs[K]> };\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, RDPs>;\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 ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<T, \"$allBaseProperties\", PropertyKeys<T>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * 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 /**\n * The total count of objects matching the query (if available from the API)\n */\n totalCount?: string;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\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 ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, RDPs>,\n): UseOsdkListResult<Q, RDPs>;\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, RDPs>,\n):\n | UseOsdkListResult<Q, RDPs>\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 RDPs\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, RDPs>\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, RDPs>\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 totalCount: listPayload?.totalCount,\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;AAyLhD,OAAO,SAASC,cAAcA,CAI5BC,IAAO,EACPC,OAAwC,EAI1C;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,IAA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reList":[]}
@@ -15,10 +15,14 @@
15
15
  */
16
16
 
17
17
  export { OsdkProvider2 } from "../new/OsdkProvider2.js";
18
+ export { useCurrentFoundryUser } from "../new/platform-apis/admin/useCurrentFoundryUser.js";
19
+ export { useFoundryUser } from "../new/platform-apis/admin/useFoundryUser.js";
20
+ export { useFoundryUsersList } from "../new/platform-apis/admin/useFoundryUsersList.js";
18
21
  export { useLinks } from "../new/useLinks.js";
19
22
  export { useObjectSet } from "../new/useObjectSet.js";
20
23
  export { useOsdkAction } from "../new/useOsdkAction.js";
21
24
  export { useOsdkAggregation } from "../new/useOsdkAggregation.js";
25
+ export { useOsdkFunction } from "../new/useOsdkFunction.js";
22
26
  export { useOsdkObject } from "../new/useOsdkObject.js";
23
27
  export { useOsdkObjects } from "../new/useOsdkObjects.js";
24
28
  export { useOsdkClient } from "../useOsdkClient.js";
@@ -1 +1 @@
1
- {"version":3,"file":"experimental.js","names":["OsdkProvider2","useLinks","useObjectSet","useOsdkAction","useOsdkAggregation","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata","useDebouncedCallback"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useLinks } from \"../new/useLinks.js\";\nexport { useObjectSet } from \"../new/useObjectSet.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport type { UseOsdkAggregationResult } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkAggregation } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\nexport { useDebouncedCallback } from \"../utils/useDebouncedCallback.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
1
+ {"version":3,"file":"experimental.js","names":["OsdkProvider2","useCurrentFoundryUser","useFoundryUser","useFoundryUsersList","useLinks","useObjectSet","useOsdkAction","useOsdkAggregation","useOsdkFunction","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata","useDebouncedCallback"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useCurrentFoundryUser } from \"../new/platform-apis/admin/useCurrentFoundryUser.js\";\nexport { useFoundryUser } from \"../new/platform-apis/admin/useFoundryUser.js\";\nexport { useFoundryUsersList } from \"../new/platform-apis/admin/useFoundryUsersList.js\";\nexport { useLinks } from \"../new/useLinks.js\";\nexport { useObjectSet } from \"../new/useObjectSet.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport type { UseOsdkAggregationResult } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkAggregation } from \"../new/useOsdkAggregation.js\";\nexport type {\n UseOsdkFunctionOptions,\n UseOsdkFunctionResult,\n} from \"../new/useOsdkFunction.js\";\nexport { useOsdkFunction } from \"../new/useOsdkFunction.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\nexport { useDebouncedCallback } from \"../utils/useDebouncedCallback.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,qBAAqB,QAAQ,qDAAqD;AAC3F,SAASC,cAAc,QAAQ,8CAA8C;AAC7E,SAASC,mBAAmB,QAAQ,mDAAmD;AACvF,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,kBAAkB,QAAQ,8BAA8B;AAKjE,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
@@ -0,0 +1,74 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React from "react";
18
+ import { makeExternalStore } from "../new/makeExternalStore.js";
19
+ export function usePlatformQuery({
20
+ query,
21
+ queryName,
22
+ enabled = true
23
+ }) {
24
+ const observerRef = React.useRef();
25
+ const handleQuery = React.useCallback(() => {
26
+ const observer = observerRef.current;
27
+ if (observer == null) return;
28
+ observer.next({
29
+ status: "loading",
30
+ data: undefined
31
+ });
32
+ query().then(data => {
33
+ observer.next({
34
+ status: "success",
35
+ data
36
+ });
37
+ }).catch(err => {
38
+ observer.error(err);
39
+ });
40
+ }, [query]);
41
+ const {
42
+ subscribe,
43
+ getSnapShot
44
+ } = React.useMemo(() => {
45
+ if (!enabled) {
46
+ return makeExternalStore(() => ({
47
+ unsubscribe: () => {}
48
+ }), process.env.NODE_ENV !== "production" ? `${queryName} Query [DISABLED]` : undefined);
49
+ }
50
+ return makeExternalStore(observer => {
51
+ observerRef.current = observer;
52
+ handleQuery();
53
+ return {
54
+ unsubscribe: () => {
55
+ observerRef.current = undefined;
56
+ }
57
+ };
58
+ }, queryName);
59
+ }, [enabled, queryName, handleQuery]);
60
+ const payload = React.useSyncExternalStore(subscribe, getSnapShot);
61
+ let error;
62
+ if (payload && "error" in payload && payload.error != null) {
63
+ error = payload.error;
64
+ } else if (payload?.status === "error") {
65
+ error = new Error(`Failed to query platform API: ${queryName}`);
66
+ }
67
+ return {
68
+ data: payload?.data,
69
+ isLoading: enabled ? payload?.status === "loading" || !payload : false,
70
+ error,
71
+ refetch: handleQuery
72
+ };
73
+ }
74
+ //# sourceMappingURL=usePlatformQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePlatformQuery.js","names":["React","makeExternalStore","usePlatformQuery","query","queryName","enabled","observerRef","useRef","handleQuery","useCallback","observer","current","next","status","data","undefined","then","catch","err","error","subscribe","getSnapShot","useMemo","unsubscribe","process","env","NODE_ENV","payload","useSyncExternalStore","Error","isLoading","refetch"],"sources":["usePlatformQuery.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Observer } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"../new/makeExternalStore.js\";\n\nexport interface UseQueryOptions<T> {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n * });\n */\n enabled?: boolean;\n queryName: string;\n query: () => Promise<T>;\n}\n\nexport interface QueryResult<T> {\n data: T | undefined;\n isLoading: boolean;\n error: Error | undefined;\n refetch: () => void;\n}\n\ninterface QueryPayload<T> {\n data: T | undefined;\n status: \"loading\" | \"success\" | \"error\";\n}\n\nexport function usePlatformQuery<T>(\n { query, queryName, enabled = true }: UseQueryOptions<T>,\n): QueryResult<T> {\n const observerRef = React.useRef<Observer<QueryPayload<T> | undefined>>();\n\n const handleQuery = React.useCallback(() => {\n const observer = observerRef.current;\n if (observer == null) return;\n\n observer.next({\n status: \"loading\",\n data: undefined,\n });\n\n query()\n .then((data) => {\n observer.next({\n status: \"success\",\n data,\n });\n })\n .catch((err: unknown) => {\n observer.error(err);\n });\n }, [query]);\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<QueryPayload<T>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `${queryName} Query [DISABLED]`\n : undefined,\n );\n }\n\n return makeExternalStore<QueryPayload<T>>(\n (observer: Observer<QueryPayload<T> | undefined>) => {\n observerRef.current = observer;\n handleQuery();\n return {\n unsubscribe: () => {\n observerRef.current = undefined;\n },\n };\n },\n queryName,\n );\n },\n [enabled, queryName, handleQuery],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error != null) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(`Failed to query platform API: ${queryName}`);\n }\n\n return {\n data: payload?.data,\n isLoading: 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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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,EAAEzB,OAAO,GAAIsB,OAAO,EAAEd,MAAM,KAAK,SAAS,IAAI,CAACc,OAAO,GAAI,KAAK;IACxER,KAAK;IACLY,OAAO,EAAEvB;EACX,CAAC;AACH","ignoreList":[]}
@@ -4,7 +4,7 @@ export type Snapshot<X> = X & {
4
4
  } | (Partial<X> & {
5
5
  error?: Error
6
6
  }) | undefined;
7
- export declare function makeExternalStore<X>(createObservation: (callback: Observer<X | undefined>) => Unsubscribable, name?: string): {
7
+ export declare function makeExternalStore<X>(createObservation: (callback: Observer<X | undefined>) => Unsubscribable, _name?: string, initialValue?: Snapshot<X>): {
8
8
  subscribe: (notifyUpdate: () => void) => () => void
9
9
  getSnapShot: () => Snapshot<X>
10
10
  };
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cACE,UACA,sBACK,kCAAmC;AAE1C,YAAY,SAAS,KACjB,IAAI;CAAE,QAAQ;AAAO,KACpB,QAAQ,KAAK;CAAE,QAAQ;AAAO;AAGnC,OAAO,iBAAS,kBAAkB,GAChCA,oBAAoBC,UAAU,SAAS,mBAAmB,gBAC1DC,gBACC;CACD,YAAYC;CACZ,mBAAmB,SAAS;AAC7B","names":["createObservation: (callback: Observer<X | undefined>) => Unsubscribable","callback: Observer<X | undefined>","name?: string","notifyUpdate: () => void"],"sources":["../../../src/new/makeExternalStore.ts"],"version":3,"file":"makeExternalStore.d.ts"}
1
+ {"mappings":"AAgBA,cACE,UACA,sBACK,kCAAmC;AAE1C,YAAY,SAAS,KACjB,IAAI;CAAE,QAAQ;AAAO,KACpB,QAAQ,KAAK;CAAE,QAAQ;AAAO;AAGnC,OAAO,iBAAS,kBAAkB,GAChCA,oBAAoBC,UAAU,SAAS,mBAAmB,gBAC1DC,gBACAC,eAAe,SAAS,KACvB;CACD,YAAYC;CACZ,mBAAmB,SAAS;AAC7B","names":["createObservation: (callback: Observer<X | undefined>) => Unsubscribable","callback: Observer<X | undefined>","_name?: string","initialValue?: Snapshot<X>","notifyUpdate: () => void"],"sources":["../../../src/new/makeExternalStore.ts"],"version":3,"file":"makeExternalStore.d.ts"}
@@ -0,0 +1,28 @@
1
+ import { type User } from "@osdk/foundry.admin";
2
+ export interface UseCurrentFoundryUserOptions {
3
+ /**
4
+ * Enable or disable the query.
5
+ *
6
+ * When `false`, the query will not automatically execute.
7
+ *
8
+ * This is useful for:
9
+ * - Lazy/on-demand queries that should wait for user interaction
10
+ * - Dependent queries that need data from another query first
11
+ * - Conditional queries based on component state
12
+ *
13
+ * @default true
14
+ * });
15
+ */
16
+ enabled?: boolean;
17
+ }
18
+ export interface UseCurrentFoundryUserResult {
19
+ currentUser: User | undefined;
20
+ isLoading: boolean;
21
+ error: Error | undefined;
22
+ refetch: () => void;
23
+ }
24
+ /**
25
+ * Get the currently signed in User.
26
+ * @param options Options to control the query.
27
+ */
28
+ export declare function useCurrentFoundryUser({ enabled }?: UseCurrentFoundryUserOptions): UseCurrentFoundryUserResult;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,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"}
@@ -0,0 +1,36 @@
1
+ import { type User } from "@osdk/foundry.admin";
2
+ import type { UserStatus } from "@osdk/foundry.core";
3
+ export interface UseFoundryUserOptions {
4
+ /**
5
+ * Enable or disable the query.
6
+ *
7
+ * When `false`, the query will not automatically execute.
8
+ *
9
+ * This is useful for:
10
+ * - Lazy/on-demand queries that should wait for user interaction
11
+ * - Dependent queries that need data from another query first
12
+ * - Conditional queries based on component state
13
+ *
14
+ * @default true
15
+ * });
16
+ */
17
+ enabled?: boolean;
18
+ /**
19
+ * The default status of the users returned in the list.
20
+ *
21
+ * @default "ACTIVE"
22
+ */
23
+ status?: UserStatus;
24
+ }
25
+ export interface UseFoundryUserResult {
26
+ user: User | undefined;
27
+ isLoading: boolean;
28
+ error: Error | undefined;
29
+ refetch: () => void;
30
+ }
31
+ /**
32
+ * Get the User with the specified id.
33
+ * @param userId A Foundry User ID.
34
+ * @param options Options to control the query.
35
+ */
36
+ export declare function useFoundryUser(userId: string, { enabled, status }?: UseFoundryUserOptions): UseFoundryUserResult;
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,52 @@
1
+ import { type ListUsersResponse } from "@osdk/foundry.admin";
2
+ import type { UserStatus } from "@osdk/foundry.core";
3
+ export interface UseFoundryUsersListOptions {
4
+ /**
5
+ * Enable or disable the query.
6
+ *
7
+ * When `false`, the query will not automatically execute.
8
+ *
9
+ * This is useful for:
10
+ * - Lazy/on-demand queries that should wait for user interaction
11
+ * - Dependent queries that need data from another query first
12
+ * - Conditional queries based on component state
13
+ *
14
+ * @default true
15
+ * });
16
+ */
17
+ enabled?: boolean;
18
+ /**
19
+ * The default status of the users returned in the list.
20
+ *
21
+ * @default "ACTIVE"
22
+ */
23
+ include?: UserStatus;
24
+ /**
25
+ * The preferred page size for the list.
26
+ *
27
+ * @default 1000
28
+ */
29
+ pageSize?: number;
30
+ /**
31
+ * The page token indicates where to start paging. This should be omitted from the first page's request.
32
+ * To fetch the next page, clients should take the value from the nextPageToken field of the previous
33
+ * response and use it to populate the pageToken field of the next request.
34
+ */
35
+ pageToken?: string;
36
+ }
37
+ export interface UseFoundryUsersListResult {
38
+ users: ListUsersResponse["data"] | undefined;
39
+ /**
40
+ * The page token to be used for the next page of users. If this is undefined, there are no more
41
+ * pages of users to load.
42
+ */
43
+ nextPageToken: string | undefined;
44
+ isLoading: boolean;
45
+ error: Error | undefined;
46
+ refetch: () => void;
47
+ }
48
+ /**
49
+ * Lists all Users. This is a paged endpoint. Each page may be smaller or larger than the requested page size.
50
+ * @param options Options to control the query.
51
+ */
52
+ export declare function useFoundryUsersList({ enabled, include, pageSize, pageToken }?: UseFoundryUsersListOptions): UseFoundryUsersListResult;
@@ -0,0 +1 @@
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"}
@@ -1,6 +1,6 @@
1
- import type { LinkedType, LinkNames } from "@osdk/api";
2
- import type { InterfaceDefinition, ObjectTypeDefinition, Osdk, PropertyKeys, WhereClause } from "@osdk/client";
3
- export interface UseLinksOptions<T extends ObjectTypeDefinition | InterfaceDefinition> {
1
+ import type { LinkedType, LinkNames, ObjectOrInterfaceDefinition } from "@osdk/api";
2
+ import type { Osdk, PropertyKeys, WhereClause } from "@osdk/client";
3
+ export interface UseLinksOptions<T extends ObjectOrInterfaceDefinition> {
4
4
  /**
5
5
  * Standard OSDK Where clause for filtering linked objects
6
6
  */
@@ -39,7 +39,7 @@ export interface UseLinksOptions<T extends ObjectTypeDefinition | InterfaceDefin
39
39
  */
40
40
  enabled?: boolean;
41
41
  }
42
- export interface UseLinksResult<Q extends ObjectTypeDefinition | InterfaceDefinition> {
42
+ export interface UseLinksResult<Q extends ObjectOrInterfaceDefinition> {
43
43
  links: Osdk.Instance<Q>[] | undefined;
44
44
  isLoading: boolean;
45
45
  error: Error | undefined;
@@ -65,6 +65,6 @@ export interface UseLinksResult<Q extends ObjectTypeDefinition | InterfaceDefini
65
65
  * @returns UseLinksResult with links data and metadata
66
66
  */
67
67
  export declare function useLinks<
68
- T extends ObjectTypeDefinition,
68
+ T extends ObjectOrInterfaceDefinition,
69
69
  L extends LinkNames<T>
70
70
  >(objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined, linkName: L, options?: UseLinksOptions<LinkedType<T, L>>): UseLinksResult<LinkedType<T, L>>;
@@ -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;;;;;;;;;;;;;;;;;;;;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"}
1
+ {"mappings":"AAgBA,cACE,YACA,WACA,mCACK,WAAY;AACnB,cAAc,MAAM,cAAc,mBAAmB,cAAe;AAMpE,iBAAiB,gBACf,UAAU,6BACV;;;;CAIA,QAAQ,YAAY;;;;CAKpB;;CAGA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;;;;CASnC,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;CAqBjB;AACD;AAED,iBAAiB,eACf,UAAU,6BACV;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"}
@@ -100,6 +100,10 @@ export interface UseObjectSetResult<
100
100
  * The final ObjectSet after all transformations
101
101
  */
102
102
  objectSet: ObjectSet<Q, RDPs>;
103
+ /**
104
+ * The total count of objects matching the query (if available from the API)
105
+ */
106
+ totalCount?: string;
103
107
  }
104
108
  /**
105
109
  * React hook for observing and interacting with OSDK object sets.
@@ -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;;;;;;;;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"}
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;;;;CAKxB;AACD;;;;;;;;;;;;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,14 +1,14 @@
1
- import type { ActionDefinition, ActionValidationResponse } from "@osdk/client";
1
+ import type { ActionDefinition, ActionEditResponse, ActionValidationResponse } from "@osdk/client";
2
2
  import { ActionValidationError } from "@osdk/client";
3
3
  import type { ActionSignatureFromDef, ObservableClient } from "@osdk/client/unstable-do-not-use";
4
4
  type ApplyActionParams<Q extends ActionDefinition<any>> = Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0] & { [K in keyof ObservableClient.ApplyActionOptions as `$${K}`] : ObservableClient.ApplyActionOptions[K] };
5
5
  export interface UseOsdkActionResult<Q extends ActionDefinition<any>> {
6
- applyAction: (args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>) => Promise<unknown>;
6
+ applyAction: (args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>) => Promise<ActionEditResponse | undefined>;
7
7
  error: undefined | Partial<{
8
8
  actionValidation: ActionValidationError
9
9
  unknown: unknown
10
10
  }>;
11
- data: unknown;
11
+ data: ActionEditResponse | undefined;
12
12
  isPending: boolean;
13
13
  isValidating: boolean;
14
14
  /**
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,kBAAkB,gCAAgC,cAAe;AAC/E,SAAS,6BAA6B,cAAe;AACrD,cACE,wBACA,wBACK,kCAAmC;KAIrC,kBAAkB,UAAU,yBAC7B,WAAW,uBAAuB,GAAG,gBAAgB,QAEpD,WAAW,iBAAiB,0BAA0B,OACrD,iBAAiB,mBAAmB;AAG1C,iBAAiB,oBAAoB,UAAU,uBAAuB;CACpE,cACEA,MAAM,kBAAkB,KAAK,MAAM,kBAAkB,QAClD;CAEL,mBAEI,QAAQ;EACR,kBAAkB;EAClB;CACD;CACH;CAEA;CACA;;;;;;;;CASA,iBACEC,MAAM,WAAW,uBAAuB,GAAG,gBAAgB,OACxD,QAAQ;CAEb,mBAAmB;AACpB;AAED,OAAO,iBAAS,cAAc,UAAU,uBACtCC,WAAW,IACV,oBAAoB","names":["args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>","args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]","actionDef: Q"],"sources":["../../../src/new/useOsdkAction.ts"],"version":3,"file":"useOsdkAction.d.ts"}
1
+ {"mappings":"AAgBA,cACE,kBACA,oBACA,gCACK,cAAe;AACtB,SAAS,6BAA6B,cAAe;AACrD,cACE,wBACA,wBACK,kCAAmC;KAIrC,kBAAkB,UAAU,yBAC7B,WAAW,uBAAuB,GAAG,gBAAgB,QAEpD,WAAW,iBAAiB,0BAA0B,OACrD,iBAAiB,mBAAmB;AAG1C,iBAAiB,oBAAoB,UAAU,uBAAuB;CACpE,cACEA,MAAM,kBAAkB,KAAK,MAAM,kBAAkB,QAClD,QAAQ;CAEb,mBAEI,QAAQ;EACR,kBAAkB;EAClB;CACD;CACH,MAAM;CAEN;CACA;;;;;;;;CASA,iBACEC,MAAM,WAAW,uBAAuB,GAAG,gBAAgB,OACxD,QAAQ;CAEb,mBAAmB;AACpB;AAED,OAAO,iBAAS,cAAc,UAAU,uBACtCC,WAAW,IACV,oBAAoB","names":["args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>","args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]","actionDef: Q"],"sources":["../../../src/new/useOsdkAction.ts"],"version":3,"file":"useOsdkAction.d.ts"}
@@ -1,20 +1,18 @@
1
- import type { AggregateOpts, AggregationsResults, DerivedProperty, WhereClause } from "@osdk/api";
2
- import type { ObjectTypeDefinition } from "@osdk/client";
3
- import type { InferRdpTypes } from "./types.js";
1
+ import type { AggregateOpts, AggregationsResults, DerivedProperty, ObjectOrInterfaceDefinition, SimplePropertyDef, WhereClause } from "@osdk/api";
4
2
  export interface UseOsdkAggregationOptions<
5
- T extends ObjectTypeDefinition,
3
+ T extends ObjectOrInterfaceDefinition,
6
4
  A extends AggregateOpts<T>,
7
- WithProps extends DerivedProperty.Clause<T> | undefined = undefined
5
+ RDPs extends Record<string, SimplePropertyDef> = {}
8
6
  > {
9
7
  /**
10
8
  * Standard OSDK Where clause to filter objects before aggregation
11
9
  */
12
- where?: WhereClause<T, InferRdpTypes<T, WithProps>>;
10
+ where?: WhereClause<T, RDPs>;
13
11
  /**
14
12
  * Define derived properties (RDPs) to be computed server-side.
15
13
  * The derived properties can be used in the where clause and aggregation groupBy/select.
16
14
  */
17
- withProperties?: WithProps;
15
+ withProperties?: { [K in keyof RDPs] : DerivedProperty.Creator<T, RDPs[K]> };
18
16
  /**
19
17
  * Aggregation options including groupBy and select
20
18
  */
@@ -28,7 +26,7 @@ export interface UseOsdkAggregationOptions<
28
26
  dedupeIntervalMs?: number;
29
27
  }
30
28
  export interface UseOsdkAggregationResult<
31
- T extends ObjectTypeDefinition,
29
+ T extends ObjectOrInterfaceDefinition,
32
30
  A extends AggregateOpts<T>
33
31
  > {
34
32
  data: AggregationsResults<T, A> | undefined;
@@ -61,7 +59,7 @@ export interface UseOsdkAggregationResult<
61
59
  * ```
62
60
  */
63
61
  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>;
62
+ Q extends ObjectOrInterfaceDefinition,
63
+ const A extends AggregateOpts<Q>,
64
+ RDPs extends Record<string, SimplePropertyDef> = {}
65
+ >(type: Q, { where, withProperties, aggregate, dedupeIntervalMs }: UseOsdkAggregationOptions<Q, A, RDPs>): UseOsdkAggregationResult<Q, A>;
@@ -1 +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"}
1
+ {"mappings":"AAgBA,cACE,eACA,qBACA,iBACA,6BACA,mBACA,mBACK,WAAY;AAMnB,iBAAiB;CACf,UAAU;CACV,UAAU,cAAc;CACxB,aAAa,eAAe,qBAAqB,CAAE;EACnD;;;;CAIA,QAAQ,YAAY,GAAG;;;;;CAMvB,oBAAoB,WAAW,QAAO,gBAAgB,QAAQ,GAAG,KAAK;;;;CAKtE,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;OACJ,UAAU,cAAc;CAC9B,aAAa,eAAe,qBAAqB,CAAE;EAEnDA,MAAM,GACN,EACE,OACA,gBACA,WACA,kBACsC,EAArC,0BAA0B,GAAG,GAAG,QAClC,yBAAyB,GAAG","names":["type: Q"],"sources":["../../../src/new/useOsdkAggregation.ts"],"version":3,"file":"useOsdkAggregation.d.ts"}
@@ -0,0 +1,112 @@
1
+ import type { CompileTimeMetadata, ObjectTypeDefinition, Osdk, QueryDefinition } from "@osdk/api";
2
+ import type { QueryParameterType, QueryReturnType } from "@osdk/client/unstable-do-not-use";
3
+ export interface UseOsdkFunctionOptions<Q extends QueryDefinition<unknown>> {
4
+ /**
5
+ * Parameters to pass to the function.
6
+ * Must include all required parameters; optional parameters can be omitted.
7
+ */
8
+ params?: CompileTimeMetadata<Q>["parameters"] extends Record<string, never> ? undefined : QueryParameterType<CompileTimeMetadata<Q>["parameters"]>;
9
+ /**
10
+ * Object types this function depends on.
11
+ * When actions modify objects of these types, the function will automatically refetch.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * // Refetch when any Employee object changes
16
+ * { dependsOn: [Employee] }
17
+ * ```
18
+ */
19
+ dependsOn?: Array<ObjectTypeDefinition | string>;
20
+ /**
21
+ * Specific object instances this function depends on.
22
+ * When any of these specific objects change, the function will refetch.
23
+ * More fine-grained than dependsOn for precise invalidation control.
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * // Refetch when this specific employee changes
28
+ * { dependsOnObjects: [employee] }
29
+ * ```
30
+ */
31
+ dependsOnObjects?: Array<Osdk.Instance<ObjectTypeDefinition>>;
32
+ /**
33
+ * The number of milliseconds to dedupe identical function calls.
34
+ * Two calls with the same function and params will share results
35
+ * if the second call is within this interval of the first.
36
+ * @default 2000
37
+ */
38
+ dedupeIntervalMs?: number;
39
+ /**
40
+ * Whether to enable the query. When false, the query will not execute.
41
+ * Useful for:
42
+ * - Dependent queries that need to wait for other data
43
+ * - Conditional queries based on component state
44
+ *
45
+ * @default true
46
+ * @example
47
+ * // Dependent query - wait for required data
48
+ * const { data: employee } = useOsdkObject(Employee, employeeId);
49
+ * const { data: report } = useOsdkFunction(getEmployeeReport, {
50
+ * params: { employeeId: employee?.$primaryKey },
51
+ * enabled: !!employee
52
+ * });
53
+ */
54
+ enabled?: boolean;
55
+ }
56
+ export interface UseOsdkFunctionResult<Q extends QueryDefinition<unknown>> {
57
+ /**
58
+ * The function result, or undefined if not yet loaded or on error.
59
+ */
60
+ data: QueryReturnType<CompileTimeMetadata<Q>["output"]> | undefined;
61
+ /**
62
+ * True while the function is executing.
63
+ */
64
+ isLoading: boolean;
65
+ /**
66
+ * Error if the function execution failed.
67
+ */
68
+ error: Error | undefined;
69
+ /**
70
+ * Timestamp (ms since epoch) of when the result was last fetched.
71
+ */
72
+ lastUpdated: number;
73
+ /**
74
+ * Manually refetch the function.
75
+ * Useful for "pull to refresh" or retry patterns.
76
+ */
77
+ refetch: () => void;
78
+ }
79
+ /**
80
+ * React hook for executing and observing OSDK functions.
81
+ *
82
+ * Provides automatic caching, deduplication, and reactive updates for function calls.
83
+ * Functions are automatically re-fetched when dependencies change (configured via options).
84
+ *
85
+ * @param queryDef - The QueryDefinition to execute
86
+ * @param options - Configuration options for the function call
87
+ * @returns Object containing result, loading state, error, and refetch function
88
+ *
89
+ * @example Basic usage
90
+ * ```tsx
91
+ * const { data, isLoading, error } = useOsdkFunction(getEmployeeStats, {
92
+ * params: { departmentId: "engineering" }
93
+ * });
94
+ * ```
95
+ *
96
+ * @example With dependency tracking
97
+ * ```tsx
98
+ * const { data, refetch } = useOsdkFunction(calculateMetrics, {
99
+ * params: { startDate, endDate },
100
+ * dependsOn: [Employee, Project],
101
+ * });
102
+ * ```
103
+ *
104
+ * @example With specific object dependencies
105
+ * ```tsx
106
+ * const { data } = useOsdkFunction(getEmployeeReport, {
107
+ * params: { employeeId: employee.$primaryKey },
108
+ * dependsOnObjects: [employee],
109
+ * });
110
+ * ```
111
+ */
112
+ export declare function useOsdkFunction<Q extends QueryDefinition<unknown>>(queryDef: Q, options?: UseOsdkFunctionOptions<Q>): UseOsdkFunctionResult<Q>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cACE,qBACA,sBACA,MACA,uBACK,WAAY;AACnB,cAEE,oBACA,uBACK,kCAAmC;AAK1C,iBAAiB,uBAAuB,UAAU,0BAA0B;;;;;CAK1E,SAAS,oBAAoB,GAAG,sBAAsB,oCAElD,mBAAmB,oBAAoB,GAAG;;;;;;;;;;;CAY9C,YAAY,MAAM;;;;;;;;;;;;CAalB,mBAAmB,MAAM,KAAK,SAAS;;;;;;;CAQvC;;;;;;;;;;;;;;;;CAiBA;AACD;AAED,iBAAiB,sBAAsB,UAAU,0BAA0B;;;;CAIzE,MAAM,gBAAgB,oBAAoB,GAAG;;;;CAK7C;;;;CAKA,OAAO;;;;CAKP;;;;;CAMA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCD,OAAO,iBAAS,gBAAgB,UAAU,0BACxCA,UAAU,GACVC,UAAS,uBAAuB,KAC/B,sBAAsB","names":["queryDef: Q","options: UseOsdkFunctionOptions<Q>"],"sources":["../../../src/new/useOsdkFunction.ts"],"version":3,"file":"useOsdkFunction.d.ts"}