@osdk/react 0.10.1-main-20260407074313 → 0.11.0-main-20260407144723
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.
- package/CHANGELOG.md +8 -3
- package/build/browser/new/useOsdkFunction.js +2 -2
- package/build/browser/new/useOsdkFunction.js.map +1 -1
- package/build/browser/new/useOsdkFunctions.js +84 -99
- package/build/browser/new/useOsdkFunctions.js.map +1 -1
- package/build/browser/public/experimental.js +1 -0
- package/build/browser/public/experimental.js.map +1 -1
- package/build/cjs/chunk-OVBG5VXE.cjs +50 -0
- package/build/cjs/chunk-OVBG5VXE.cjs.map +1 -0
- package/build/cjs/index.cjs +6 -7
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/public/experimental.cjs +92 -9
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +156 -4
- package/build/esm/new/useOsdkFunction.js +2 -2
- package/build/esm/new/useOsdkFunction.js.map +1 -1
- package/build/esm/new/useOsdkFunctions.js +84 -99
- package/build/esm/new/useOsdkFunctions.js.map +1 -1
- package/build/esm/public/experimental.js +1 -0
- package/build/esm/public/experimental.js.map +1 -1
- package/build/types/new/useOsdkFunction.d.ts +1 -1
- package/build/types/new/useOsdkFunction.d.ts.map +1 -1
- package/build/types/new/useOsdkFunctions.d.ts +8 -2
- package/build/types/new/useOsdkFunctions.d.ts.map +1 -1
- package/build/types/public/experimental.d.ts +2 -0
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +6 -15
- package/build/browser/public/unstable-do-not-use.js +0 -18
- package/build/browser/public/unstable-do-not-use.js.map +0 -1
- package/build/cjs/chunk-2N32USW5.cjs +0 -28
- package/build/cjs/chunk-2N32USW5.cjs.map +0 -1
- package/build/cjs/chunk-R4FZ5MUH.cjs +0 -34
- package/build/cjs/chunk-R4FZ5MUH.cjs.map +0 -1
- package/build/cjs/public/unstable-do-not-use.cjs +0 -114
- package/build/cjs/public/unstable-do-not-use.cjs.map +0 -1
- package/build/cjs/public/unstable-do-not-use.d.cts +0 -35
- package/build/cjs/useOsdkFunction-B0s7lqgN.d.cts +0 -121
- package/build/esm/public/unstable-do-not-use.js +0 -18
- package/build/esm/public/unstable-do-not-use.js.map +0 -1
- package/build/types/public/unstable-do-not-use.d.ts +0 -2
- package/build/types/public/unstable-do-not-use.d.ts.map +0 -1
- package/unstable-do-not-use.d.ts +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
# @osdkkit/react
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.11.0-main-20260407144723
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f8b9f12: Cache results from useOsdkFunctions
|
|
4
8
|
|
|
5
9
|
### Patch Changes
|
|
6
10
|
|
|
7
11
|
- 51ccca8: Refactor hooks to use canonicalizeOptions for stable memo keys, add objectSet/hasMore/refetch to useOsdkObjects return, support undefined objectSet in useObjectSet
|
|
12
|
+
- Updated dependencies [f8b9f12]
|
|
8
13
|
- Updated dependencies [bcf359f]
|
|
9
14
|
- Updated dependencies [51ccca8]
|
|
10
|
-
- @osdk/client@2.
|
|
11
|
-
- @osdk/api@2.
|
|
15
|
+
- @osdk/client@2.9.0-main-20260407144723
|
|
16
|
+
- @osdk/api@2.9.0-main-20260407144723
|
|
12
17
|
|
|
13
18
|
## 0.10.0
|
|
14
19
|
|
|
@@ -89,8 +89,8 @@ export function useOsdkFunction(queryDef, options = {}) {
|
|
|
89
89
|
}, observer), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)}` : void 0);
|
|
90
90
|
}, [observableClient, queryDef.apiName, queryDef.version, paramsForApi, stableDependsOn, stableDependsOnObjects, dedupeIntervalMs, enabled]);
|
|
91
91
|
const payload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
92
|
-
const refetch = React.useCallback(() => {
|
|
93
|
-
|
|
92
|
+
const refetch = React.useCallback(async () => {
|
|
93
|
+
await observableClient.invalidateFunction(queryDef, paramsForApi);
|
|
94
94
|
}, [observableClient, queryDef, paramsForApi]);
|
|
95
95
|
return React.useMemo(() => {
|
|
96
96
|
const error = payload?.error ?? (payload?.status === "error" ? new Error("Failed to execute function") : undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkFunction.js","names":["getWireObjectSet","React","makeExternalStore","OsdkContext2","useOsdkFunction","queryDef","options","observableClient","useContext","params","dependsOn","dependsOnObjects","dedupeIntervalMs","enabled","stableParams","useMemo","JSON","stringify","stableDependsOn","map","d","apiName","stableDependsOnObjects","item","$apiName","$primaryKey","__objectSet","paramsForApi","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","observer","observeFunction","dedupeInterval","version","payload","useSyncExternalStore","refetch","useCallback","invalidateFunction","error","status","Error","undefined","data","result","isLoading","lastUpdated"],"sources":["useOsdkFunction.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 CompileTimeMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n QueryDefinition,\n} from \"@osdk/api\";\nimport type {\n ObserveFunctionCallbackArgs,\n QueryParameterType,\n} from \"@osdk/client/unstable-do-not-use\";\nimport { getWireObjectSet } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkFunctionOptions<Q extends QueryDefinition<unknown>> {\n /**\n * Parameters to pass to the function.\n * Must include all required parameters; optional parameters can be omitted.\n */\n params?: CompileTimeMetadata<Q>[\"parameters\"] extends Record<string, never>\n ? undefined\n : QueryParameterType<CompileTimeMetadata<Q>[\"parameters\"]>;\n\n /**\n * Object types this function depends on.\n * When actions modify objects of these types, the function will automatically refetch.\n *\n * @example\n * ```tsx\n * // Refetch when any Employee object changes\n * { dependsOn: [Employee] }\n * ```\n */\n dependsOn?: Array<ObjectTypeDefinition | string>;\n\n /**\n * Specific object instances or ObjectSets this function depends on.\n * When any of these specific objects change, the function will refetch.\n * More fine-grained than dependsOn for precise invalidation control.\n *\n * For ObjectSets, the object type is extracted asynchronously and changes\n * to any object of that type will trigger a refetch.\n *\n * @example\n * ```tsx\n * // Refetch when this specific employee changes\n * { dependsOnObjects: [employee] }\n *\n * // Refetch when any object in the ObjectSet's type changes\n * { dependsOnObjects: [employeeObjectSet] }\n * ```\n */\n dependsOnObjects?: Array<\n Osdk.Instance<ObjectTypeDefinition> | ObjectSet<ObjectTypeDefinition>\n >;\n\n /**\n * The number of milliseconds to dedupe identical function calls.\n * Two calls with the same function and params will share results\n * if the second call is within this interval of the first.\n * @default 2000\n */\n dedupeIntervalMs?: number;\n\n /**\n * Whether to enable the query. When false, the query will not execute.\n * Useful for:\n * - Dependent queries that need to wait for other data\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for required data\n * const { data: employee } = useOsdkObject(Employee, employeeId);\n * const { data: report } = useOsdkFunction(getEmployeeReport, {\n * params: { employeeId: employee?.$primaryKey },\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseOsdkFunctionResult<Q extends QueryDefinition<unknown>> {\n /**\n * The function result, or undefined if not yet loaded or on error.\n */\n data:\n | (CompileTimeMetadata<Q>[\"signature\"] extends (...args: never[]) => infer R\n ? Awaited<R>\n : never)\n | undefined;\n\n /**\n * True while the function is executing.\n */\n isLoading: boolean;\n\n /**\n * Error if the function execution failed.\n */\n error: Error | undefined;\n\n /**\n * Timestamp (ms since epoch) of when the result was last fetched.\n */\n lastUpdated: number;\n\n /**\n * Manually refetch the function.\n * Useful for \"pull to refresh\" or retry patterns.\n */\n refetch: () => void;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for executing and observing OSDK functions.\n *\n * Provides automatic caching, deduplication, and reactive updates for function calls.\n * Functions are automatically re-fetched when dependencies change (configured via options).\n *\n * @param queryDef - The QueryDefinition to execute\n * @param options - Configuration options for the function call\n * @returns Object containing result, loading state, error, and refetch function\n *\n * @example Basic usage\n * ```tsx\n * const { data, isLoading, error } = useOsdkFunction(getEmployeeStats, {\n * params: { departmentId: \"engineering\" }\n * });\n * ```\n *\n * @example With dependency tracking\n * ```tsx\n * const { data, refetch } = useOsdkFunction(calculateMetrics, {\n * params: { startDate, endDate },\n * dependsOn: [Employee, Project],\n * });\n * ```\n *\n * @example With specific object dependencies\n * ```tsx\n * const { data } = useOsdkFunction(getEmployeeReport, {\n * params: { employeeId: employee.$primaryKey },\n * dependsOnObjects: [employee],\n * });\n * ```\n */\nexport function useOsdkFunction<Q extends QueryDefinition<unknown>>(\n queryDef: Q,\n options: UseOsdkFunctionOptions<Q> = {},\n): UseOsdkFunctionResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n const {\n params,\n dependsOn,\n dependsOnObjects,\n dedupeIntervalMs,\n enabled = true,\n } = options;\n\n const stableParams = React.useMemo(\n () => params,\n [JSON.stringify(params)],\n );\n const stableDependsOn = React.useMemo(\n () => dependsOn,\n [JSON.stringify(\n dependsOn?.map(d => typeof d === \"string\" ? d : d.apiName),\n )],\n );\n const stableDependsOnObjects = React.useMemo(\n () => dependsOnObjects,\n [JSON.stringify(\n dependsOnObjects?.map(item =>\n \"$apiName\" in item\n ? { $apiName: item.$apiName, $primaryKey: item.$primaryKey }\n : { __objectSet: getWireObjectSet(item) }\n ),\n )],\n );\n\n // Record<string, unknown> required as typing is figured out at runtime\n const paramsForApi = stableParams as Record<string, unknown> | undefined;\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveFunctionCallbackArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `function ${queryDef.apiName} ${\n JSON.stringify(stableParams)\n } [DISABLED]`\n : void 0,\n );\n }\n return makeExternalStore<ObserveFunctionCallbackArgs<Q>>(\n (observer) =>\n observableClient.observeFunction(\n queryDef,\n paramsForApi,\n {\n dependsOn: stableDependsOn,\n dependsOnObjects: stableDependsOnObjects,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n },\n observer,\n ),\n process.env.NODE_ENV !== \"production\"\n ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)}`\n : void 0,\n );\n },\n [\n observableClient,\n queryDef.apiName,\n queryDef.version,\n paramsForApi,\n stableDependsOn,\n stableDependsOnObjects,\n dedupeIntervalMs,\n enabled,\n ],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n const refetch = React.useCallback(() => {\n void observableClient.invalidateFunction(queryDef, paramsForApi);\n }, [observableClient, queryDef, paramsForApi]);\n\n return React.useMemo(() => {\n const error = payload?.error\n ?? (payload?.status === \"error\"\n ? new Error(\"Failed to execute function\")\n : undefined);\n\n return {\n data: payload?.result as UseOsdkFunctionResult<Q>[\"data\"],\n isLoading: payload?.status === \"loading\",\n error,\n lastUpdated: payload?.lastUpdated ?? 0,\n refetch,\n };\n }, [payload, refetch]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SAASA,gBAAgB,QAAQ,kCAAkC;AACnE,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AA4GhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AA4B,CAAC,GACvCC,SAAS,CAAC;IAEhB,OAAO;MACLC,IAAI,EAAET,OAAO,EAAEU,MAA0C;MACzDC,SAAS,EAAEX,OAAO,EAAEM,MAAM,KAAK,SAAS;MACxCD,KAAK;MACLO,WAAW,EAAEZ,OAAO,EAAEY,WAAW,IAAI,CAAC;MACtCV;IACF,CAAC;EACH,CAAC,EAAE,CAACF,OAAO,EAAEE,OAAO,CAAC,CAAC;AACxB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useOsdkFunction.js","names":["getWireObjectSet","React","makeExternalStore","OsdkContext2","useOsdkFunction","queryDef","options","observableClient","useContext","params","dependsOn","dependsOnObjects","dedupeIntervalMs","enabled","stableParams","useMemo","JSON","stringify","stableDependsOn","map","d","apiName","stableDependsOnObjects","item","$apiName","$primaryKey","__objectSet","paramsForApi","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","observer","observeFunction","dedupeInterval","version","payload","useSyncExternalStore","refetch","useCallback","invalidateFunction","error","status","Error","undefined","data","result","isLoading","lastUpdated"],"sources":["useOsdkFunction.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 CompileTimeMetadata,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n QueryDefinition,\n} from \"@osdk/api\";\nimport type {\n ObserveFunctionCallbackArgs,\n QueryParameterType,\n} from \"@osdk/client/unstable-do-not-use\";\nimport { getWireObjectSet } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkFunctionOptions<Q extends QueryDefinition<unknown>> {\n /**\n * Parameters to pass to the function.\n * Must include all required parameters; optional parameters can be omitted.\n */\n params?: CompileTimeMetadata<Q>[\"parameters\"] extends Record<string, never>\n ? undefined\n : QueryParameterType<CompileTimeMetadata<Q>[\"parameters\"]>;\n\n /**\n * Object types this function depends on.\n * When actions modify objects of these types, the function will automatically refetch.\n *\n * @example\n * ```tsx\n * // Refetch when any Employee object changes\n * { dependsOn: [Employee] }\n * ```\n */\n dependsOn?: Array<ObjectTypeDefinition | string>;\n\n /**\n * Specific object instances or ObjectSets this function depends on.\n * When any of these specific objects change, the function will refetch.\n * More fine-grained than dependsOn for precise invalidation control.\n *\n * For ObjectSets, the object type is extracted asynchronously and changes\n * to any object of that type will trigger a refetch.\n *\n * @example\n * ```tsx\n * // Refetch when this specific employee changes\n * { dependsOnObjects: [employee] }\n *\n * // Refetch when any object in the ObjectSet's type changes\n * { dependsOnObjects: [employeeObjectSet] }\n * ```\n */\n dependsOnObjects?: Array<\n Osdk.Instance<ObjectTypeDefinition> | ObjectSet<ObjectTypeDefinition>\n >;\n\n /**\n * The number of milliseconds to dedupe identical function calls.\n * Two calls with the same function and params will share results\n * if the second call is within this interval of the first.\n * @default 2000\n */\n dedupeIntervalMs?: number;\n\n /**\n * Whether to enable the query. When false, the query will not execute.\n * Useful for:\n * - Dependent queries that need to wait for other data\n * - Conditional queries based on component state\n *\n * @default true\n * @example\n * // Dependent query - wait for required data\n * const { data: employee } = useOsdkObject(Employee, employeeId);\n * const { data: report } = useOsdkFunction(getEmployeeReport, {\n * params: { employeeId: employee?.$primaryKey },\n * enabled: !!employee\n * });\n */\n enabled?: boolean;\n}\n\nexport interface UseOsdkFunctionResult<Q extends QueryDefinition<unknown>> {\n /**\n * The function result, or undefined if not yet loaded or on error.\n */\n data:\n | (CompileTimeMetadata<Q>[\"signature\"] extends (...args: never[]) => infer R\n ? Awaited<R>\n : never)\n | undefined;\n\n /**\n * True while the function is executing.\n */\n isLoading: boolean;\n\n /**\n * Error if the function execution failed.\n */\n error: Error | undefined;\n\n /**\n * Timestamp (ms since epoch) of when the result was last fetched.\n */\n lastUpdated: number;\n\n /**\n * Manually refetch the function.\n * Useful for \"pull to refresh\" or retry patterns.\n */\n refetch: () => Promise<void>;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for executing and observing OSDK functions.\n *\n * Provides automatic caching, deduplication, and reactive updates for function calls.\n * Functions are automatically re-fetched when dependencies change (configured via options).\n *\n * @param queryDef - The QueryDefinition to execute\n * @param options - Configuration options for the function call\n * @returns Object containing result, loading state, error, and refetch function\n *\n * @example Basic usage\n * ```tsx\n * const { data, isLoading, error } = useOsdkFunction(getEmployeeStats, {\n * params: { departmentId: \"engineering\" }\n * });\n * ```\n *\n * @example With dependency tracking\n * ```tsx\n * const { data, refetch } = useOsdkFunction(calculateMetrics, {\n * params: { startDate, endDate },\n * dependsOn: [Employee, Project],\n * });\n * ```\n *\n * @example With specific object dependencies\n * ```tsx\n * const { data } = useOsdkFunction(getEmployeeReport, {\n * params: { employeeId: employee.$primaryKey },\n * dependsOnObjects: [employee],\n * });\n * ```\n */\nexport function useOsdkFunction<Q extends QueryDefinition<unknown>>(\n queryDef: Q,\n options: UseOsdkFunctionOptions<Q> = {},\n): UseOsdkFunctionResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n const {\n params,\n dependsOn,\n dependsOnObjects,\n dedupeIntervalMs,\n enabled = true,\n } = options;\n\n const stableParams = React.useMemo(\n () => params,\n [JSON.stringify(params)],\n );\n const stableDependsOn = React.useMemo(\n () => dependsOn,\n [JSON.stringify(\n dependsOn?.map(d => typeof d === \"string\" ? d : d.apiName),\n )],\n );\n const stableDependsOnObjects = React.useMemo(\n () => dependsOnObjects,\n [JSON.stringify(\n dependsOnObjects?.map(item =>\n \"$apiName\" in item\n ? { $apiName: item.$apiName, $primaryKey: item.$primaryKey }\n : { __objectSet: getWireObjectSet(item) }\n ),\n )],\n );\n\n // Record<string, unknown> required as typing is figured out at runtime\n const paramsForApi = stableParams as Record<string, unknown> | undefined;\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveFunctionCallbackArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `function ${queryDef.apiName} ${\n JSON.stringify(stableParams)\n } [DISABLED]`\n : void 0,\n );\n }\n return makeExternalStore<ObserveFunctionCallbackArgs<Q>>(\n (observer) =>\n observableClient.observeFunction(\n queryDef,\n paramsForApi,\n {\n dependsOn: stableDependsOn,\n dependsOnObjects: stableDependsOnObjects,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n },\n observer,\n ),\n process.env.NODE_ENV !== \"production\"\n ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)}`\n : void 0,\n );\n },\n [\n observableClient,\n queryDef.apiName,\n queryDef.version,\n paramsForApi,\n stableDependsOn,\n stableDependsOnObjects,\n dedupeIntervalMs,\n enabled,\n ],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n const refetch = React.useCallback(async () => {\n await observableClient.invalidateFunction(queryDef, paramsForApi);\n }, [observableClient, queryDef, paramsForApi]);\n\n return React.useMemo(() => {\n const error = payload?.error\n ?? (payload?.status === \"error\"\n ? new Error(\"Failed to execute function\")\n : undefined);\n\n return {\n data: payload?.result as UseOsdkFunctionResult<Q>[\"data\"],\n isLoading: payload?.status === \"loading\",\n error,\n lastUpdated: payload?.lastUpdated ?? 0,\n refetch,\n };\n }, [payload, refetch]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SAASA,gBAAgB,QAAQ,kCAAkC;AACnE,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1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GL,OAAO,EAAEK,KAAK,KACtBL,OAAO,EAAEM,MAAM,KAAK,OAAO,GAC3B,IAAIC,KAAK,CAAC,4BAA4B,CAAC,GACvCC,SAAS,CAAC;IAEhB,OAAO;MACLC,IAAI,EAAET,OAAO,EAAEU,MAA0C;MACzDC,SAAS,EAAEX,OAAO,EAAEM,MAAM,KAAK,SAAS;MACxCD,KAAK;MACLO,WAAW,EAAEZ,OAAO,EAAEY,WAAW,IAAI,CAAC;MACtCV;IACF,CAAC;EACH,CAAC,EAAE,CAACF,OAAO,EAAEE,OAAO,CAAC,CAAC;AACxB","ignoreList":[]}
|
|
@@ -15,11 +15,17 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import React from "react";
|
|
18
|
-
import {
|
|
18
|
+
import { OsdkContext2 } from "./OsdkContext2.js";
|
|
19
19
|
/**
|
|
20
20
|
* React hook for executing multiple OSDK function queries in parallel.
|
|
21
|
+
*
|
|
22
|
+
* This hook executes multiple function queries with individual configurations,
|
|
23
|
+
* with automatic caching and deduplication via the ObservableClient.
|
|
21
24
|
* Results are returned in the same order as the input queries.
|
|
22
25
|
*
|
|
26
|
+
* Queries with identical function+params share cached results through the
|
|
27
|
+
* Store layer, avoiding duplicate network requests across components.
|
|
28
|
+
*
|
|
23
29
|
* @param options - Configuration options containing the queries to execute
|
|
24
30
|
* @returns Array of results in the same order as input queries, each with the same shape as useOsdkFunction
|
|
25
31
|
*/
|
|
@@ -27,111 +33,90 @@ export function useOsdkFunctions({
|
|
|
27
33
|
queries,
|
|
28
34
|
enabled = true
|
|
29
35
|
}) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
const {
|
|
37
|
+
observableClient
|
|
38
|
+
} = React.useContext(OsdkContext2);
|
|
39
|
+
const stableQueriesKey = JSON.stringify(queries.map(q => ({
|
|
40
|
+
apiName: q.queryDefinition.apiName,
|
|
41
|
+
params: q.options?.params,
|
|
42
|
+
enabled: q.options?.enabled,
|
|
43
|
+
dedupeIntervalMs: q.options?.dedupeIntervalMs
|
|
36
44
|
})));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
|
|
46
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
47
|
+
const stableQueries = React.useMemo(() => queries, [stableQueriesKey]);
|
|
48
|
+
|
|
49
|
+
// Create a composite external store that manages N subscriptions
|
|
50
|
+
// We can't reuse makeExternalStore directly because it wraps a
|
|
51
|
+
// single Observer, but we need N observers funneled into one useSyncExternalStore.
|
|
52
|
+
const {
|
|
53
|
+
subscribe,
|
|
54
|
+
getSnapshot
|
|
55
|
+
} = React.useMemo(() => {
|
|
56
|
+
const count = stableQueries.length;
|
|
57
|
+
if (!enabled || count === 0) {
|
|
58
|
+
const empty = [];
|
|
59
|
+
return {
|
|
60
|
+
subscribe: () => () => {},
|
|
61
|
+
getSnapshot: () => empty
|
|
62
|
+
};
|
|
41
63
|
}
|
|
42
64
|
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
index,
|
|
59
|
-
result,
|
|
60
|
-
error
|
|
61
|
-
} = queryResult;
|
|
62
|
-
if (abortController.signal.aborted) {
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
setResults(prev => {
|
|
66
|
-
if (abortController.signal.aborted) {
|
|
67
|
-
return prev;
|
|
65
|
+
// Mutable snapshot array — replaced (never mutated in place) on each
|
|
66
|
+
// observer callback so that useSyncExternalStore sees a new reference.
|
|
67
|
+
let current = stableQueries.map(() => undefined);
|
|
68
|
+
const updateSlot = (index, value) => {
|
|
69
|
+
const next = [...current];
|
|
70
|
+
next[index] = value;
|
|
71
|
+
current = next;
|
|
72
|
+
};
|
|
73
|
+
return {
|
|
74
|
+
getSnapshot: () => current,
|
|
75
|
+
subscribe: notifyUpdate => {
|
|
76
|
+
const subscriptions = [];
|
|
77
|
+
stableQueries.forEach((query, index) => {
|
|
78
|
+
if (query.options?.enabled === false) {
|
|
79
|
+
return;
|
|
68
80
|
}
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
const params = query.options?.params;
|
|
82
|
+
const sub = observableClient.observeFunction(query.queryDefinition, params, {
|
|
83
|
+
dedupeInterval: query.options?.dedupeIntervalMs ?? 2_000
|
|
84
|
+
}, {
|
|
85
|
+
next: payload => {
|
|
86
|
+
updateSlot(index, payload);
|
|
87
|
+
notifyUpdate();
|
|
88
|
+
},
|
|
89
|
+
error: error => {
|
|
90
|
+
updateSlot(index, {
|
|
91
|
+
...(current[index] ?? {}),
|
|
92
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
93
|
+
});
|
|
94
|
+
notifyUpdate();
|
|
95
|
+
},
|
|
96
|
+
complete: () => {}
|
|
97
|
+
});
|
|
98
|
+
subscriptions.push(sub);
|
|
77
99
|
});
|
|
100
|
+
return () => {
|
|
101
|
+
subscriptions.forEach(sub => sub.unsubscribe());
|
|
102
|
+
};
|
|
78
103
|
}
|
|
79
|
-
})();
|
|
80
|
-
return () => {
|
|
81
|
-
abortController.abort();
|
|
82
104
|
};
|
|
83
|
-
}, [enabled,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const pendingPromises = [...queryPromises];
|
|
92
|
-
|
|
93
|
-
// Yield results as they complete using Promise.race
|
|
94
|
-
while (pendingPromises.length > 0) {
|
|
95
|
-
const raceResult = await Promise.race(pendingPromises.map((promise, idx) => promise.then(result => ({
|
|
96
|
-
result,
|
|
97
|
-
idx
|
|
98
|
-
}))));
|
|
99
|
-
yield raceResult.result;
|
|
100
|
-
|
|
101
|
-
// Remove the completed promise from the pending list
|
|
102
|
-
void pendingPromises.splice(raceResult.idx, 1);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
const createQueryPromise = async (query, index, client) => {
|
|
106
|
-
// Skip disabled queries
|
|
107
|
-
if (query.options?.enabled === false) {
|
|
105
|
+
}, [enabled, observableClient, stableQueries]);
|
|
106
|
+
const payloads = React.useSyncExternalStore(subscribe, getSnapshot);
|
|
107
|
+
const refetches = React.useMemo(() => stableQueries.map(query => async () => {
|
|
108
|
+
await observableClient.invalidateFunction(query.queryDefinition, query.options?.params);
|
|
109
|
+
}), [stableQueries, observableClient]);
|
|
110
|
+
return React.useMemo(() => stableQueries.map((_, index) => {
|
|
111
|
+
const payload = payloads[index];
|
|
112
|
+
const error = payload?.error ?? (payload?.status === "error" ? new Error("Failed to execute function") : undefined);
|
|
108
113
|
return {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
error
|
|
114
|
+
data: payload?.result,
|
|
115
|
+
isLoading: payload?.status === "loading",
|
|
116
|
+
error,
|
|
117
|
+
lastUpdated: payload?.lastUpdated ?? 0,
|
|
118
|
+
refetch: refetches[index]
|
|
112
119
|
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if ("executeFunction" in queryClient && typeof queryClient.executeFunction === "function") {
|
|
116
|
-
try {
|
|
117
|
-
const result = await queryClient.executeFunction(query.options?.params);
|
|
118
|
-
return {
|
|
119
|
-
index,
|
|
120
|
-
result,
|
|
121
|
-
error: null
|
|
122
|
-
};
|
|
123
|
-
} catch (error) {
|
|
124
|
-
return {
|
|
125
|
-
index,
|
|
126
|
-
result: undefined,
|
|
127
|
-
error
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
index,
|
|
133
|
-
result: undefined,
|
|
134
|
-
error: new Error("Invalid query client: executeFunction method not found")
|
|
135
|
-
};
|
|
136
|
-
};
|
|
120
|
+
}), [stableQueries, payloads, refetches]);
|
|
121
|
+
}
|
|
137
122
|
//# sourceMappingURL=useOsdkFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkFunctions.js","names":["React","useOsdkClient","useOsdkFunctions","queries","enabled","client","results","setResults","useState","map","data","undefined","isLoading","error","lastUpdated","abortControllerRef","useRef","useEffect","length","current","abort","abortController","AbortController","prev","_","index","options","queryResult","executeQueriesGenerator","result","signal","aborted","newResults","Error","JSON","stringify","Date","now","queryPromises","query","createQueryPromise","pendingPromises","raceResult","Promise","race","promise","idx","then","splice","queryClient","queryDefinition","executeFunction","params"],"sources":["useOsdkFunctions.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { CompileTimeMetadata, QueryDefinition } from \"@osdk/api\";\nimport type { Client } from \"@osdk/client\";\nimport React from \"react\";\nimport { useOsdkClient } from \"../useOsdkClient.js\";\nimport type {\n UseOsdkFunctionOptions,\n UseOsdkFunctionResult,\n} from \"./useOsdkFunction.js\";\n\nexport interface FunctionQueryParams<Q extends QueryDefinition<unknown>> {\n queryDefinition: Q;\n /**\n * Only allow params and enabled options at the query level,\n * other options are not yet supported in this batch context\n */\n options?: Pick<UseOsdkFunctionOptions<Q>, \"params\" | \"enabled\">;\n}\n\nexport interface UseOsdkFunctionsProps {\n /**\n * Array of query configurations to execute\n */\n queries: Array<FunctionQueryParams<QueryDefinition<unknown>>>;\n\n /**\n * Whether to enable all queries. When false, no queries will execute.\n * Individual query enabled states are also respected.\n * @default true\n */\n enabled?: boolean;\n}\n\nexport type UseOsdkFunctionsResult = Array<\n Omit<UseOsdkFunctionResult<QueryDefinition<unknown>>, \"refetch\">\n>;\n\n/**\n * React hook for executing multiple OSDK function queries in parallel.\n * Results are returned in the same order as the input queries.\n *\n * @param options - Configuration options containing the queries to execute\n * @returns Array of results in the same order as input queries, each with the same shape as useOsdkFunction\n */\nexport function useOsdkFunctions(\n { queries, enabled = true }: UseOsdkFunctionsProps,\n): UseOsdkFunctionsResult {\n const client = useOsdkClient();\n\n const [results, setResults] = React.useState<\n UseOsdkFunctionsResult\n >(() =>\n queries.map(() => ({\n data: undefined,\n isLoading: false,\n error: undefined,\n lastUpdated: 0,\n }))\n );\n\n const abortControllerRef = React.useRef<AbortController | null>(null);\n\n React.useEffect(() => {\n if (!enabled || queries.length === 0) {\n return;\n }\n\n // Cancel previous requests\n abortControllerRef.current?.abort();\n\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n const executeQueries = async () => {\n // Initialize loading state for all queries\n setResults(prev =>\n queries.map((_, index) => ({\n data: prev[index]?.data, // Preserving existing data\n isLoading: queries[index].options?.enabled !== false,\n error: undefined,\n lastUpdated: prev[index]?.lastUpdated || 0,\n }))\n );\n\n for await (\n const queryResult of executeQueriesGenerator(\n queries,\n client,\n )\n ) {\n const { index, result, error } = queryResult;\n\n if (abortController.signal.aborted) {\n break;\n }\n\n setResults(prev => {\n if (abortController.signal.aborted) {\n return prev;\n }\n const newResults = [...prev];\n newResults[index] = {\n data: result,\n isLoading: false,\n error: error instanceof Error\n ? error\n : error\n ? new Error(\n typeof error === \"string\" ? error : JSON.stringify(error),\n )\n : undefined,\n lastUpdated: Date.now(),\n };\n return newResults;\n });\n }\n };\n\n void executeQueries();\n\n return () => {\n abortController.abort();\n };\n }, [\n enabled,\n client,\n queries,\n ]);\n\n return results;\n}\n\ninterface QueryResult<Q extends QueryDefinition<unknown>> {\n index: number;\n result?:\n | (CompileTimeMetadata<Q>[\"signature\"] extends (...args: never[]) => infer R\n ? Awaited<R>\n : never)\n | undefined;\n error?: unknown;\n}\n/**\n * Generator function that executes queries and yields results as they complete\n */\nasync function* executeQueriesGenerator(\n queries: Array<FunctionQueryParams<QueryDefinition<unknown>>>,\n client: Client,\n): AsyncGenerator<QueryResult<QueryDefinition<unknown>>> {\n const queryPromises = queries.map((query, index) =>\n createQueryPromise<typeof query.queryDefinition>(query, index, client)\n );\n\n const pendingPromises = [...queryPromises];\n\n // Yield results as they complete using Promise.race\n while (pendingPromises.length > 0) {\n const raceResult = await Promise.race(\n pendingPromises.map((promise, idx) =>\n promise.then(result => ({ result, idx }))\n ),\n );\n\n yield raceResult.result;\n\n // Remove the completed promise from the pending list\n void pendingPromises.splice(raceResult.idx, 1);\n }\n}\n\nconst createQueryPromise = async <Q extends QueryDefinition<unknown>>(\n query: FunctionQueryParams<Q>,\n index: number,\n client: Client,\n): Promise<QueryResult<Q>> => {\n // Skip disabled queries\n if (query.options?.enabled === false) {\n return { index, result: undefined, error: undefined };\n }\n\n const queryClient = client(query.queryDefinition);\n\n if (\n \"executeFunction\" in queryClient\n && typeof queryClient.executeFunction === \"function\"\n ) {\n try {\n const result = await queryClient.executeFunction(query.options?.params);\n return { index, result, error: null };\n } catch (error) {\n return { index, result: undefined, error };\n }\n }\n\n return {\n index,\n result: undefined,\n error: new Error(\"Invalid query client: executeFunction method not found\"),\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,qBAAqB;AAiCnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9B;EAAEC,OAAO;EAAEC,OAAO,GAAG;AAA4B,CAAC,EAC1B;EACxB,MAAMC,MAAM,GAAGJ,aAAa,CAAC,CAAC;EAE9B,MAAM,CAACK,OAAO,EAAEC,UAAU,CAAC,G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CAACO,MAAM,CAACN,UAAU,CAACI,GAAG,EAAE,CAAC,CAAC;EAChD;AACF;AAEA,MAAMN,kBAAkB,GAAG,MAAAA,CACzBD,KAA6B,EAC7Bd,KAAa,EACbpB,MAAc,KACc;EAC5B;EACA,IAAIkC,KAAK,CAACb,OAAO,EAAEtB,OAAO,KAAK,KAAK,EAAE;IACpC,OAAO;MAAEqB,KAAK;MAAEI,MAAM,EAAElB,SAAS;MAAEE,KAAK,EAAEF;IAAU,CAAC;EACvD;EAEA,MAAMsC,WAAW,GAAG5C,MAAM,CAACkC,KAAK,CAACW,eAAe,CAAC;EAEjD,IACE,iBAAiB,IAAID,WAAW,IAC7B,OAAOA,WAAW,CAACE,eAAe,KAAK,UAAU,EACpD;IACA,IAAI;MACF,MAAMtB,MAAM,GAAG,MAAMoB,WAAW,CAACE,eAAe,CAACZ,KAAK,CAACb,OAAO,EAAE0B,MAAM,CAAC;MACvE,OAAO;QAAE3B,KAAK;QAAEI,MAAM;QAAEhB,KAAK,EAAE;MAAK,CAAC;IACvC,CAAC,CAAC,OAAOA,KAAK,EAAE;MACd,OAAO;QAAEY,KAAK;QAAEI,MAAM,EAAElB,SAAS;QAAEE;MAAM,CAAC;IAC5C;EACF;EAEA,OAAO;IACLY,KAAK;IACLI,MAAM,EAAElB,SAAS;IACjBE,KAAK,EAAE,IAAIoB,KAAK,CAAC,wDAAwD;EAC3E,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useOsdkFunctions.js","names":["React","OsdkContext2","useOsdkFunctions","queries","enabled","observableClient","useContext","stableQueriesKey","JSON","stringify","map","q","apiName","queryDefinition","params","options","dedupeIntervalMs","stableQueries","useMemo","subscribe","getSnapshot","count","length","empty","current","undefined","updateSlot","index","value","next","notifyUpdate","subscriptions","forEach","query","sub","observeFunction","dedupeInterval","payload","error","Error","String","complete","push","unsubscribe","payloads","useSyncExternalStore","refetches","invalidateFunction","_","status","data","result","isLoading","lastUpdated","refetch"],"sources":["useOsdkFunctions.ts"],"sourcesContent":["/*\n * Copyright 2026 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 { QueryDefinition } from \"@osdk/api\";\nimport type { ObserveFunctionCallbackArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport type { Snapshot } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nimport type {\n UseOsdkFunctionOptions,\n UseOsdkFunctionResult,\n} from \"./useOsdkFunction.js\";\n\nexport interface FunctionQueryParams<Q extends QueryDefinition<unknown>> {\n queryDefinition: Q;\n /**\n * Only allow params and enabled options at the query level,\n * other options are not yet supported in this batch context\n */\n options?: Pick<\n UseOsdkFunctionOptions<Q>,\n \"params\" | \"enabled\" | \"dedupeIntervalMs\"\n >;\n}\n\nexport interface UseOsdkFunctionsProps {\n /**\n * Array of query configurations to execute\n */\n queries: Array<FunctionQueryParams<QueryDefinition<unknown>>>;\n\n /**\n * Whether to enable all queries. When false, no queries will execute.\n * Individual query enabled states are also respected.\n * @default true\n */\n enabled?: boolean;\n}\n\nexport type UseOsdkFunctionsResult = Array<\n UseOsdkFunctionResult<QueryDefinition<unknown>>\n>;\n\ntype FunctionPayload = ObserveFunctionCallbackArgs<QueryDefinition<unknown>>;\n\n/**\n * React hook for executing multiple OSDK function queries in parallel.\n *\n * This hook executes multiple function queries with individual configurations,\n * with automatic caching and deduplication via the ObservableClient.\n * Results are returned in the same order as the input queries.\n *\n * Queries with identical function+params share cached results through the\n * Store layer, avoiding duplicate network requests across components.\n *\n * @param options - Configuration options containing the queries to execute\n * @returns Array of results in the same order as input queries, each with the same shape as useOsdkFunction\n */\nexport function useOsdkFunctions(\n { queries, enabled = true }: UseOsdkFunctionsProps,\n): UseOsdkFunctionsResult {\n const { observableClient } = React.useContext(OsdkContext2);\n\n const stableQueriesKey = JSON.stringify(queries.map(q => ({\n apiName: q.queryDefinition.apiName,\n params: q.options?.params,\n enabled: q.options?.enabled,\n dedupeIntervalMs: q.options?.dedupeIntervalMs,\n })));\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const stableQueries = React.useMemo(() => queries, [stableQueriesKey]);\n\n // Create a composite external store that manages N subscriptions\n // We can't reuse makeExternalStore directly because it wraps a\n // single Observer, but we need N observers funneled into one useSyncExternalStore.\n const { subscribe, getSnapshot } = React.useMemo(\n () => {\n const count = stableQueries.length;\n\n if (!enabled || count === 0) {\n const empty: Array<Snapshot<FunctionPayload>> = [];\n return {\n subscribe: () => () => {},\n getSnapshot: () => empty,\n };\n }\n\n // Mutable snapshot array — replaced (never mutated in place) on each\n // observer callback so that useSyncExternalStore sees a new reference.\n let current: Array<Snapshot<FunctionPayload>> = stableQueries.map(\n () => undefined,\n );\n\n const updateSlot = (\n index: number,\n value: Snapshot<FunctionPayload>,\n ) => {\n const next = [...current];\n next[index] = value;\n current = next;\n };\n\n return {\n getSnapshot: () => current,\n subscribe: (notifyUpdate: () => void) => {\n const subscriptions: Array<{ unsubscribe: () => void }> = [];\n\n stableQueries.forEach((query, index) => {\n if (query.options?.enabled === false) {\n return;\n }\n\n const params = query.options?.params as\n | Record<string, unknown>\n | undefined;\n\n const sub = observableClient.observeFunction(\n query.queryDefinition,\n params,\n { dedupeInterval: query.options?.dedupeIntervalMs ?? 2_000 },\n {\n next: (payload: FunctionPayload | undefined) => {\n updateSlot(\n index,\n payload as Snapshot<FunctionPayload>,\n );\n notifyUpdate();\n },\n error: (error: unknown) => {\n updateSlot(index, {\n ...(current[index] ?? {}),\n error: error instanceof Error\n ? error\n : new Error(String(error)),\n } as Snapshot<FunctionPayload>);\n notifyUpdate();\n },\n complete: () => {},\n },\n );\n\n subscriptions.push(sub);\n });\n\n return () => {\n subscriptions.forEach(sub => sub.unsubscribe());\n };\n },\n };\n },\n [enabled, observableClient, stableQueries],\n );\n\n const payloads = React.useSyncExternalStore(subscribe, getSnapshot);\n\n const refetches = React.useMemo(\n () =>\n stableQueries.map((query) => async () => {\n await observableClient.invalidateFunction(\n query.queryDefinition,\n query.options?.params as Record<string, unknown> | undefined,\n );\n }),\n [stableQueries, observableClient],\n );\n\n return React.useMemo(\n () =>\n stableQueries.map((_, index): UseOsdkFunctionResult<\n QueryDefinition<unknown>\n > => {\n const payload = payloads[index];\n const error = payload?.error\n ?? (payload?.status === \"error\"\n ? new Error(\"Failed to execute function\")\n : undefined);\n\n return {\n data: payload?.result as UseOsdkFunctionResult<\n QueryDefinition<unknown>\n >[\"data\"],\n isLoading: payload?.status === \"loading\",\n error,\n lastUpdated: payload?.lastUpdated ?? 0,\n refetch: refetches[index],\n };\n }),\n [stableQueries, payloads, refetches],\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAY,QAAQ,mBAAmB;AAsChD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9B;EAAEC,OAAO;EAAEC,OAAO,GAAG;AAA4B,CAAC,EAC1B;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACL,YAAY,CAAC;EAE3D,MAAMM,gBAAgB,GAAGC,IAAI,CAACC,SAAS,CAACN,OAAO,CAACO,GAAG,CAACC,CAAC,KAAK;IACxDC,OAAO,EAAED,CAAC,CAACE,eAAe,CAACD,OAAO;IAClCE,MAAM,EAAEH,CAAC,CAACI,OAAO,EAAED,MAAM;IACzBV,OAAO,EAAEO,CAAC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CAACP,GAAG,CAAC,CAACsC,CAAC,EAAErB,KAAK,KAEtB;IACH,MAAMU,OAAO,GAAGO,QAAQ,CAACjB,KAAK,CAAC;IAC/B,MAAMW,KAAK,GAAGD,OAAO,EAAEC,KAAK,KACtBD,OAAO,EAAEY,MAAM,KAAK,OAAO,GAC3B,IAAIV,KAAK,CAAC,4BAA4B,CAAC,GACvCd,SAAS,CAAC;IAEhB,OAAO;MACLyB,IAAI,EAAEb,OAAO,EAAEc,MAEN;MACTC,SAAS,EAAEf,OAAO,EAAEY,MAAM,KAAK,SAAS;MACxCX,KAAK;MACLe,WAAW,EAAEhB,OAAO,EAAEgB,WAAW,IAAI,CAAC;MACtCC,OAAO,EAAER,SAAS,CAACnB,KAAK;IAC1B,CAAC;EACH,CAAC,CAAC,EACJ,CAACV,aAAa,EAAE2B,QAAQ,EAAEE,SAAS,CACrC,CAAC;AACH","ignoreList":[]}
|
|
@@ -20,6 +20,7 @@ export { useObjectSet } from "../new/useObjectSet.js";
|
|
|
20
20
|
export { useOsdkAction } from "../new/useOsdkAction.js";
|
|
21
21
|
export { useOsdkAggregation } from "../new/useOsdkAggregation.js";
|
|
22
22
|
export { useOsdkFunction } from "../new/useOsdkFunction.js";
|
|
23
|
+
export { useOsdkFunctions } from "../new/useOsdkFunctions.js";
|
|
23
24
|
export { useOsdkObject } from "../new/useOsdkObject.js";
|
|
24
25
|
export { useOsdkObjects } from "../new/useOsdkObjects.js";
|
|
25
26
|
export { useOsdkClient } from "../useOsdkClient.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","names":["OsdkProvider2","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 { 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 {\n UseOsdkListResult,\n UseOsdkObjectsOptions,\n} 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;AAKjE,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,aAAa,QAAQ,yBAAyB;AAKvD,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","useOsdkFunction","useOsdkFunctions","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 type {\n UseOsdkFunctionOptions,\n UseOsdkFunctionResult,\n} from \"../new/useOsdkFunction.js\";\nexport { useOsdkFunction } from \"../new/useOsdkFunction.js\";\nexport { useOsdkFunctions } from \"../new/useOsdkFunctions.js\";\nexport type {\n FunctionQueryParams,\n UseOsdkFunctionsProps,\n UseOsdkFunctionsResult,\n} from \"../new/useOsdkFunctions.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type {\n UseOsdkListResult,\n UseOsdkObjectsOptions,\n} 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;AAKjE,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,gBAAgB,QAAQ,4BAA4B;AAM7D,SAASC,aAAa,QAAQ,yBAAyB;AAKvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React3 = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
8
|
+
|
|
9
|
+
// src/useOsdkClient.ts
|
|
10
|
+
function fakeClientFn(..._args) {
|
|
11
|
+
throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
|
|
12
|
+
}
|
|
13
|
+
var fakeClient = Object.assign(fakeClientFn, {
|
|
14
|
+
fetchMetadata: fakeClientFn
|
|
15
|
+
});
|
|
16
|
+
var OsdkContext = /* @__PURE__ */ React3__default.default.createContext({
|
|
17
|
+
client: fakeClient
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// src/useOsdkClient.ts
|
|
21
|
+
function useOsdkClient() {
|
|
22
|
+
return React3__default.default.useContext(OsdkContext).client;
|
|
23
|
+
}
|
|
24
|
+
function useOsdkMetadata(type) {
|
|
25
|
+
const client = useOsdkClient();
|
|
26
|
+
const [metadata, setMetadata] = React3__default.default.useState(void 0);
|
|
27
|
+
const [error, setError] = React3__default.default.useState();
|
|
28
|
+
if (!metadata && !error) {
|
|
29
|
+
client.fetchMetadata(type).then((fetchedMetadata) => {
|
|
30
|
+
setMetadata(fetchedMetadata);
|
|
31
|
+
}).catch((error2) => {
|
|
32
|
+
const errorMessage = error2 instanceof Error ? error2.message : String(error2);
|
|
33
|
+
setError(errorMessage);
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
loading: true
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
loading: false,
|
|
41
|
+
metadata,
|
|
42
|
+
error
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.OsdkContext = OsdkContext;
|
|
47
|
+
exports.useOsdkClient = useOsdkClient;
|
|
48
|
+
exports.useOsdkMetadata = useOsdkMetadata;
|
|
49
|
+
//# sourceMappingURL=chunk-OVBG5VXE.cjs.map
|
|
50
|
+
//# sourceMappingURL=chunk-OVBG5VXE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/OsdkContext.ts","../../src/useOsdkClient.ts","../../src/useOsdkMetadata.ts"],"names":["React","error"],"mappings":";;;;;;;;;AAiBA,SAAS,gBAAgB,KAAO,EAAA;AAC9B,EAAM,MAAA,IAAI,MAAM,sEAAsE,CAAA;AACxF;AACA,IAAM,UAAA,GAAa,MAAO,CAAA,MAAA,CAAO,YAAc,EAAA;AAAA,EAC7C,aAAe,EAAA;AACjB,CAAC,CAAA;AACY,IAAA,WAAA,2CAAiC,aAAc,CAAA;AAAA,EAC1D,MAAQ,EAAA;AACV,CAAC;;;ACPM,SAAS,aAAgB,GAAA;AAC9B,EAAOA,OAAAA,uBAAAA,CAAM,UAAW,CAAA,WAAW,CAAE,CAAA,MAAA;AACvC;ACFO,SAAS,gBAAgB,IAAM,EAAA;AACpC,EAAA,MAAM,SAAS,aAAc,EAAA;AAC7B,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAIA,GAAAA,uBAAAA,CAAM,SAAS,MAAS,CAAA;AACxD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,wBAAM,QAAS,EAAA;AACzC,EAAI,IAAA,CAAC,QAAY,IAAA,CAAC,KAAO,EAAA;AACvB,IAAA,MAAA,CAAO,aAAc,CAAA,IAAI,CAAE,CAAA,IAAA,CAAK,CAAmB,eAAA,KAAA;AACjD,MAAA,WAAA,CAAY,eAAe,CAAA;AAAA,KAC5B,CAAA,CAAE,KAAM,CAAA,CAAAC,MAAS,KAAA;AAChB,MAAA,MAAM,eAAeA,MAAiB,YAAA,KAAA,GAAQA,MAAM,CAAA,OAAA,GAAU,OAAOA,MAAK,CAAA;AAC1E,MAAA,QAAA,CAAS,YAAY,CAAA;AAAA,KACtB,CAAA;AACD,IAAO,OAAA;AAAA,MACL,OAAS,EAAA;AAAA,KACX;AAAA;AAEF,EAAO,OAAA;AAAA,IACL,OAAS,EAAA,KAAA;AAAA,IACT,QAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-OVBG5VXE.cjs","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nfunction fakeClientFn(..._args) {\n throw new Error(\"This is not a real client. Did you forget to <OsdkContext.Provider>?\");\n}\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn\n});\nexport const OsdkContext = /*#__PURE__*/React.createContext({\n client: fakeClient\n});","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nexport function useOsdkClient() {\n return React.useContext(OsdkContext).client;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nimport { useOsdkClient } from \"./useOsdkClient.js\";\nexport function useOsdkMetadata(type) {\n const client = useOsdkClient();\n const [metadata, setMetadata] = React.useState(undefined);\n const [error, setError] = React.useState();\n if (!metadata && !error) {\n client.fetchMetadata(type).then(fetchedMetadata => {\n setMetadata(fetchedMetadata);\n }).catch(error => {\n const errorMessage = error instanceof Error ? error.message : String(error);\n setError(errorMessage);\n });\n return {\n loading: true\n };\n }\n return {\n loading: false,\n metadata,\n error\n };\n}"]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunk2N32USW5_cjs = require('./chunk-2N32USW5.cjs');
|
|
3
|
+
var chunkOVBG5VXE_cjs = require('./chunk-OVBG5VXE.cjs');
|
|
5
4
|
var React = require('react');
|
|
6
5
|
|
|
7
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -12,20 +11,20 @@ function OsdkProvider({
|
|
|
12
11
|
children,
|
|
13
12
|
client
|
|
14
13
|
}) {
|
|
15
|
-
return /* @__PURE__ */ React__default.default.createElement(
|
|
14
|
+
return /* @__PURE__ */ React__default.default.createElement(chunkOVBG5VXE_cjs.OsdkContext.Provider, {
|
|
16
15
|
value: {
|
|
17
16
|
client
|
|
18
17
|
}
|
|
19
18
|
}, children);
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
Object.defineProperty(exports, "
|
|
21
|
+
Object.defineProperty(exports, "useOsdkClient", {
|
|
23
22
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkClient; }
|
|
25
24
|
});
|
|
26
|
-
Object.defineProperty(exports, "
|
|
25
|
+
Object.defineProperty(exports, "useOsdkMetadata", {
|
|
27
26
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkMetadata; }
|
|
29
28
|
});
|
|
30
29
|
exports.OsdkProvider = OsdkProvider;
|
|
31
30
|
//# sourceMappingURL=index.cjs.map
|
package/build/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/OsdkProvider.tsx"],"names":["React","OsdkContext"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/OsdkProvider.tsx"],"names":["React","OsdkContext"],"mappings":";;;;;;;;;AAkBO,SAAS,YAAa,CAAA;AAAA,EAC3B,QAAA;AAAA,EACA;AACF,CAAG,EAAA;AACD,EAAoB,uBAAAA,sBAAA,CAAM,aAAc,CAAAC,6BAAA,CAAY,QAAU,EAAA;AAAA,IAC5D,KAAO,EAAA;AAAA,MACL;AAAA;AACF,KACC,QAAQ,CAAA;AACb","file":"index.cjs","sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nexport function OsdkProvider({\n children,\n client\n}) {\n return /*#__PURE__*/React.createElement(OsdkContext.Provider, {\n value: {\n client\n }\n }, children);\n}"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var chunk2N32USW5_cjs = require('../chunk-2N32USW5.cjs');
|
|
3
|
+
var chunkOVBG5VXE_cjs = require('../chunk-OVBG5VXE.cjs');
|
|
5
4
|
var chunkZUNR45SJ_cjs = require('../chunk-ZUNR45SJ.cjs');
|
|
6
5
|
var unstableDoNotUse = require('@osdk/client/unstable-do-not-use');
|
|
7
6
|
var React4 = require('react');
|
|
@@ -22,7 +21,7 @@ function OsdkProvider2({
|
|
|
22
21
|
client,
|
|
23
22
|
observableClient
|
|
24
23
|
}
|
|
25
|
-
}, /* @__PURE__ */ React4__default.default.createElement(
|
|
24
|
+
}, /* @__PURE__ */ React4__default.default.createElement(chunkOVBG5VXE_cjs.OsdkContext.Provider, {
|
|
26
25
|
value: {
|
|
27
26
|
client
|
|
28
27
|
}
|
|
@@ -424,8 +423,8 @@ function useOsdkFunction(queryDef, options = {}) {
|
|
|
424
423
|
}, observer), process.env.NODE_ENV !== "production" ? `function ${queryDef.apiName} ${JSON.stringify(stableParams)}` : void 0);
|
|
425
424
|
}, [observableClient, queryDef.apiName, queryDef.version, paramsForApi, stableDependsOn, stableDependsOnObjects, dedupeIntervalMs, enabled]);
|
|
426
425
|
const payload = React4__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
427
|
-
const refetch = React4__default.default.useCallback(() => {
|
|
428
|
-
|
|
426
|
+
const refetch = React4__default.default.useCallback(async () => {
|
|
427
|
+
await observableClient.invalidateFunction(queryDef, paramsForApi);
|
|
429
428
|
}, [observableClient, queryDef, paramsForApi]);
|
|
430
429
|
return React4__default.default.useMemo(() => {
|
|
431
430
|
const error = payload?.error ?? (payload?.status === "error" ? new Error("Failed to execute function") : void 0);
|
|
@@ -438,6 +437,89 @@ function useOsdkFunction(queryDef, options = {}) {
|
|
|
438
437
|
};
|
|
439
438
|
}, [payload, refetch]);
|
|
440
439
|
}
|
|
440
|
+
function useOsdkFunctions({
|
|
441
|
+
queries,
|
|
442
|
+
enabled = true
|
|
443
|
+
}) {
|
|
444
|
+
const {
|
|
445
|
+
observableClient
|
|
446
|
+
} = React4__default.default.useContext(chunkZUNR45SJ_cjs.OsdkContext2);
|
|
447
|
+
const stableQueriesKey = JSON.stringify(queries.map((q) => ({
|
|
448
|
+
apiName: q.queryDefinition.apiName,
|
|
449
|
+
params: q.options?.params,
|
|
450
|
+
enabled: q.options?.enabled,
|
|
451
|
+
dedupeIntervalMs: q.options?.dedupeIntervalMs
|
|
452
|
+
})));
|
|
453
|
+
const stableQueries = React4__default.default.useMemo(() => queries, [stableQueriesKey]);
|
|
454
|
+
const {
|
|
455
|
+
subscribe,
|
|
456
|
+
getSnapshot
|
|
457
|
+
} = React4__default.default.useMemo(() => {
|
|
458
|
+
const count = stableQueries.length;
|
|
459
|
+
if (!enabled || count === 0) {
|
|
460
|
+
const empty = [];
|
|
461
|
+
return {
|
|
462
|
+
subscribe: () => () => {
|
|
463
|
+
},
|
|
464
|
+
getSnapshot: () => empty
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
let current = stableQueries.map(() => void 0);
|
|
468
|
+
const updateSlot = (index, value) => {
|
|
469
|
+
const next = [...current];
|
|
470
|
+
next[index] = value;
|
|
471
|
+
current = next;
|
|
472
|
+
};
|
|
473
|
+
return {
|
|
474
|
+
getSnapshot: () => current,
|
|
475
|
+
subscribe: (notifyUpdate) => {
|
|
476
|
+
const subscriptions = [];
|
|
477
|
+
stableQueries.forEach((query, index) => {
|
|
478
|
+
if (query.options?.enabled === false) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
const params = query.options?.params;
|
|
482
|
+
const sub = observableClient.observeFunction(query.queryDefinition, params, {
|
|
483
|
+
dedupeInterval: query.options?.dedupeIntervalMs ?? 2e3
|
|
484
|
+
}, {
|
|
485
|
+
next: (payload) => {
|
|
486
|
+
updateSlot(index, payload);
|
|
487
|
+
notifyUpdate();
|
|
488
|
+
},
|
|
489
|
+
error: (error) => {
|
|
490
|
+
updateSlot(index, {
|
|
491
|
+
...current[index] ?? {},
|
|
492
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
493
|
+
});
|
|
494
|
+
notifyUpdate();
|
|
495
|
+
},
|
|
496
|
+
complete: () => {
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
subscriptions.push(sub);
|
|
500
|
+
});
|
|
501
|
+
return () => {
|
|
502
|
+
subscriptions.forEach((sub) => sub.unsubscribe());
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
}, [enabled, observableClient, stableQueries]);
|
|
507
|
+
const payloads = React4__default.default.useSyncExternalStore(subscribe, getSnapshot);
|
|
508
|
+
const refetches = React4__default.default.useMemo(() => stableQueries.map((query) => async () => {
|
|
509
|
+
await observableClient.invalidateFunction(query.queryDefinition, query.options?.params);
|
|
510
|
+
}), [stableQueries, observableClient]);
|
|
511
|
+
return React4__default.default.useMemo(() => stableQueries.map((_, index) => {
|
|
512
|
+
const payload = payloads[index];
|
|
513
|
+
const error = payload?.error ?? (payload?.status === "error" ? new Error("Failed to execute function") : void 0);
|
|
514
|
+
return {
|
|
515
|
+
data: payload?.result,
|
|
516
|
+
isLoading: payload?.status === "loading",
|
|
517
|
+
error,
|
|
518
|
+
lastUpdated: payload?.lastUpdated ?? 0,
|
|
519
|
+
refetch: refetches[index]
|
|
520
|
+
};
|
|
521
|
+
}), [stableQueries, payloads, refetches]);
|
|
522
|
+
}
|
|
441
523
|
function useOsdkObject(...args) {
|
|
442
524
|
const {
|
|
443
525
|
observableClient
|
|
@@ -605,13 +687,13 @@ function useDebouncedCallback(callback, delay) {
|
|
|
605
687
|
});
|
|
606
688
|
}
|
|
607
689
|
|
|
608
|
-
Object.defineProperty(exports, "
|
|
690
|
+
Object.defineProperty(exports, "useOsdkClient", {
|
|
609
691
|
enumerable: true,
|
|
610
|
-
get: function () { return
|
|
692
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkClient; }
|
|
611
693
|
});
|
|
612
|
-
Object.defineProperty(exports, "
|
|
694
|
+
Object.defineProperty(exports, "useOsdkMetadata", {
|
|
613
695
|
enumerable: true,
|
|
614
|
-
get: function () { return
|
|
696
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkMetadata; }
|
|
615
697
|
});
|
|
616
698
|
exports.OsdkProvider2 = OsdkProvider2;
|
|
617
699
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
@@ -620,6 +702,7 @@ exports.useObjectSet = useObjectSet;
|
|
|
620
702
|
exports.useOsdkAction = useOsdkAction;
|
|
621
703
|
exports.useOsdkAggregation = useOsdkAggregation;
|
|
622
704
|
exports.useOsdkFunction = useOsdkFunction;
|
|
705
|
+
exports.useOsdkFunctions = useOsdkFunctions;
|
|
623
706
|
exports.useOsdkObject = useOsdkObject;
|
|
624
707
|
exports.useOsdkObjects = useOsdkObjects;
|
|
625
708
|
//# sourceMappingURL=experimental.cjs.map
|