@osdk/react 0.10.0-beta.9 → 0.10.1-main-20260406220320
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 +109 -0
- package/build/browser/new/OsdkContext2.js +22 -2
- package/build/browser/new/OsdkContext2.js.map +1 -1
- package/build/browser/new/hookUtils.js +32 -0
- package/build/browser/new/hookUtils.js.map +1 -0
- package/build/browser/new/platform-apis/admin/useCbacBanner.js +63 -0
- package/build/browser/new/platform-apis/admin/useCbacBanner.js.map +1 -0
- package/build/browser/new/platform-apis/admin/useCbacMarkingRestrictions.js +64 -0
- package/build/browser/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -0
- package/build/browser/new/platform-apis/admin/useMarkingCategories.js +46 -0
- package/build/browser/new/platform-apis/admin/useMarkingCategories.js.map +1 -0
- package/build/browser/new/platform-apis/admin/useMarkings.js +46 -0
- package/build/browser/new/platform-apis/admin/useMarkings.js.map +1 -0
- package/build/browser/new/platform-apis/admin/useUserMarkings.js +50 -0
- package/build/browser/new/platform-apis/admin/useUserMarkings.js.map +1 -0
- package/build/browser/new/useLinks.js +13 -10
- package/build/browser/new/useLinks.js.map +1 -1
- package/build/browser/new/useObjectSet.js +45 -26
- package/build/browser/new/useObjectSet.js.map +1 -1
- package/build/browser/new/useOsdkAction.js +3 -6
- package/build/browser/new/useOsdkAction.js.map +1 -1
- package/build/browser/new/useOsdkAggregation.js +32 -38
- package/build/browser/new/useOsdkAggregation.js.map +1 -1
- package/build/browser/new/useOsdkFunctions.js +137 -0
- package/build/browser/new/useOsdkFunctions.js.map +1 -0
- package/build/browser/new/useOsdkObject.js +6 -2
- package/build/browser/new/useOsdkObject.js.map +1 -1
- package/build/browser/new/useOsdkObjects.js +36 -33
- package/build/browser/new/useOsdkObjects.js.map +1 -1
- package/build/browser/public/experimental/admin.js +5 -0
- package/build/browser/public/experimental/admin.js.map +1 -1
- package/build/browser/public/unstable-do-not-use.js +18 -0
- package/build/browser/public/unstable-do-not-use.js.map +1 -0
- package/build/cjs/chunk-2N32USW5.cjs +28 -0
- package/build/cjs/chunk-2N32USW5.cjs.map +1 -0
- package/build/cjs/chunk-R4FZ5MUH.cjs +34 -0
- package/build/cjs/chunk-R4FZ5MUH.cjs.map +1 -0
- package/build/cjs/{chunk-SVVMLSKN.cjs → chunk-ZUNR45SJ.cjs} +15 -4
- package/build/cjs/chunk-ZUNR45SJ.cjs.map +1 -0
- package/build/cjs/index.cjs +7 -6
- package/build/cjs/index.cjs.map +1 -1
- package/build/cjs/public/experimental/admin.cjs +154 -7
- package/build/cjs/public/experimental/admin.cjs.map +1 -1
- package/build/cjs/public/experimental/admin.d.cts +159 -2
- package/build/cjs/public/experimental.cjs +170 -135
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +21 -124
- package/build/cjs/public/unstable-do-not-use.cjs +114 -0
- package/build/cjs/public/unstable-do-not-use.cjs.map +1 -0
- package/build/cjs/public/unstable-do-not-use.d.cts +35 -0
- package/build/cjs/useOsdkFunction-B0s7lqgN.d.cts +121 -0
- package/build/esm/new/OsdkContext2.js +22 -2
- package/build/esm/new/OsdkContext2.js.map +1 -1
- package/build/esm/new/hookUtils.js +32 -0
- package/build/esm/new/hookUtils.js.map +1 -0
- package/build/esm/new/platform-apis/admin/useCbacBanner.js +63 -0
- package/build/esm/new/platform-apis/admin/useCbacBanner.js.map +1 -0
- package/build/esm/new/platform-apis/admin/useCbacMarkingRestrictions.js +64 -0
- package/build/esm/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -0
- package/build/esm/new/platform-apis/admin/useMarkingCategories.js +46 -0
- package/build/esm/new/platform-apis/admin/useMarkingCategories.js.map +1 -0
- package/build/esm/new/platform-apis/admin/useMarkings.js +46 -0
- package/build/esm/new/platform-apis/admin/useMarkings.js.map +1 -0
- package/build/esm/new/platform-apis/admin/useUserMarkings.js +50 -0
- package/build/esm/new/platform-apis/admin/useUserMarkings.js.map +1 -0
- package/build/esm/new/useLinks.js +13 -10
- package/build/esm/new/useLinks.js.map +1 -1
- package/build/esm/new/useObjectSet.js +45 -26
- package/build/esm/new/useObjectSet.js.map +1 -1
- package/build/esm/new/useOsdkAction.js +3 -6
- package/build/esm/new/useOsdkAction.js.map +1 -1
- package/build/esm/new/useOsdkAggregation.js +32 -38
- package/build/esm/new/useOsdkAggregation.js.map +1 -1
- package/build/esm/new/useOsdkFunctions.js +137 -0
- package/build/esm/new/useOsdkFunctions.js.map +1 -0
- package/build/esm/new/useOsdkObject.js +6 -2
- package/build/esm/new/useOsdkObject.js.map +1 -1
- package/build/esm/new/useOsdkObjects.js +36 -33
- package/build/esm/new/useOsdkObjects.js.map +1 -1
- package/build/esm/public/experimental/admin.js +5 -0
- package/build/esm/public/experimental/admin.js.map +1 -1
- package/build/esm/public/unstable-do-not-use.js +18 -0
- package/build/esm/public/unstable-do-not-use.js.map +1 -0
- package/build/types/new/OsdkContext2.d.ts +1 -0
- package/build/types/new/OsdkContext2.d.ts.map +1 -1
- package/build/types/new/hookUtils.d.ts +7 -0
- package/build/types/new/hookUtils.d.ts.map +1 -0
- package/build/types/new/platform-apis/admin/useCbacBanner.d.ts +33 -0
- package/build/types/new/platform-apis/admin/useCbacBanner.d.ts.map +1 -0
- package/build/types/new/platform-apis/admin/useCbacMarkingRestrictions.d.ts +34 -0
- package/build/types/new/platform-apis/admin/useCbacMarkingRestrictions.d.ts.map +1 -0
- package/build/types/new/platform-apis/admin/useMarkingCategories.d.ts +27 -0
- package/build/types/new/platform-apis/admin/useMarkingCategories.d.ts.map +1 -0
- package/build/types/new/platform-apis/admin/useMarkings.d.ts +27 -0
- package/build/types/new/platform-apis/admin/useMarkings.d.ts.map +1 -0
- package/build/types/new/platform-apis/admin/useUserMarkings.d.ts +33 -0
- package/build/types/new/platform-apis/admin/useUserMarkings.d.ts.map +1 -0
- package/build/types/new/useLinks.d.ts.map +1 -1
- package/build/types/new/useObjectSet.d.ts +5 -2
- package/build/types/new/useObjectSet.d.ts.map +1 -1
- package/build/types/new/useOsdkAggregation.d.ts +1 -1
- package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
- package/build/types/new/useOsdkFunctions.d.ts +31 -0
- package/build/types/new/useOsdkFunctions.d.ts.map +1 -0
- package/build/types/new/useOsdkObject.d.ts +2 -1
- package/build/types/new/useOsdkObject.d.ts.map +1 -1
- package/build/types/new/useOsdkObjects.d.ts +10 -1
- package/build/types/new/useOsdkObjects.d.ts.map +1 -1
- package/build/types/public/experimental/admin.d.ts +8 -0
- package/build/types/public/experimental/admin.d.ts.map +1 -1
- package/build/types/public/unstable-do-not-use.d.ts +2 -0
- package/build/types/public/unstable-do-not-use.d.ts.map +1 -0
- package/package.json +19 -10
- package/unstable-do-not-use.d.ts +17 -0
- package/build/cjs/chunk-OVBG5VXE.cjs +0 -50
- package/build/cjs/chunk-OVBG5VXE.cjs.map +0 -1
- package/build/cjs/chunk-SVVMLSKN.cjs.map +0 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 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 { useOsdkClient } from "../useOsdkClient.js";
|
|
19
|
+
/**
|
|
20
|
+
* React hook for executing multiple OSDK function queries in parallel.
|
|
21
|
+
* Results are returned in the same order as the input queries.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Configuration options containing the queries to execute
|
|
24
|
+
* @returns Array of results in the same order as input queries, each with the same shape as useOsdkFunction
|
|
25
|
+
*/
|
|
26
|
+
export function useOsdkFunctions({
|
|
27
|
+
queries,
|
|
28
|
+
enabled = true
|
|
29
|
+
}) {
|
|
30
|
+
const client = useOsdkClient();
|
|
31
|
+
const [results, setResults] = React.useState(() => queries.map(() => ({
|
|
32
|
+
data: undefined,
|
|
33
|
+
isLoading: false,
|
|
34
|
+
error: undefined,
|
|
35
|
+
lastUpdated: 0
|
|
36
|
+
})));
|
|
37
|
+
const abortControllerRef = React.useRef(null);
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
if (!enabled || queries.length === 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Cancel previous requests
|
|
44
|
+
abortControllerRef.current?.abort();
|
|
45
|
+
const abortController = new AbortController();
|
|
46
|
+
abortControllerRef.current = abortController;
|
|
47
|
+
void (async () => {
|
|
48
|
+
// Initialize loading state for all queries
|
|
49
|
+
setResults(prev => queries.map((_, index) => ({
|
|
50
|
+
data: prev[index]?.data,
|
|
51
|
+
// Preserving existing data
|
|
52
|
+
isLoading: queries[index].options?.enabled !== false,
|
|
53
|
+
error: undefined,
|
|
54
|
+
lastUpdated: prev[index]?.lastUpdated || 0
|
|
55
|
+
})));
|
|
56
|
+
for await (const queryResult of executeQueriesGenerator(queries, client)) {
|
|
57
|
+
const {
|
|
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;
|
|
68
|
+
}
|
|
69
|
+
const newResults = [...prev];
|
|
70
|
+
newResults[index] = {
|
|
71
|
+
data: result,
|
|
72
|
+
isLoading: false,
|
|
73
|
+
error: error instanceof Error ? error : error ? new Error(typeof error === "string" ? error : JSON.stringify(error)) : undefined,
|
|
74
|
+
lastUpdated: Date.now()
|
|
75
|
+
};
|
|
76
|
+
return newResults;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
})();
|
|
80
|
+
return () => {
|
|
81
|
+
abortController.abort();
|
|
82
|
+
};
|
|
83
|
+
}, [enabled, client, queries]);
|
|
84
|
+
return results;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Generator function that executes queries and yields results as they complete
|
|
88
|
+
*/
|
|
89
|
+
async function* executeQueriesGenerator(queries, client) {
|
|
90
|
+
const queryPromises = queries.map((query, index) => createQueryPromise(query, index, client));
|
|
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) {
|
|
108
|
+
return {
|
|
109
|
+
index,
|
|
110
|
+
result: undefined,
|
|
111
|
+
error: undefined
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const queryClient = client(query.queryDefinition);
|
|
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
|
+
};
|
|
137
|
+
//# sourceMappingURL=useOsdkFunctions.js.map
|
|
@@ -0,0 +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;AAC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OAAO,EAAEC,GAAG,KAC/BD,OAAO,CAACE,IAAI,CAAClB,MAAM,KAAK;MAAEA,MAAM;MAAEiB;IAAI,CAAC,CAAC,CAC1C,CACF,CAAC;IAED,MAAMJ,UAAU,CAACb,MAAM;;IAEvB;IACA,KAAKY,eAAe,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":[]}
|
|
@@ -36,7 +36,7 @@ import { OsdkContext2 } from "./OsdkContext2.js";
|
|
|
36
36
|
*
|
|
37
37
|
* @param type The object type or interface definition
|
|
38
38
|
* @param primaryKey The primary key of the object
|
|
39
|
-
* @param options Options including $select and
|
|
39
|
+
* @param options Options including $select, enabled, and $loadPropertySecurityMetadata
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
42
|
/*
|
|
@@ -58,6 +58,7 @@ export function useOsdkObject(...args) {
|
|
|
58
58
|
// Extract enabled flag - 2nd param for instance signature, 3rd for type signature
|
|
59
59
|
const enabled = isInstanceSignature ? typeof args[1] === "boolean" ? args[1] : true : optionsArg ? optionsArg.enabled ?? true : typeof args[2] === "boolean" ? args[2] : true;
|
|
60
60
|
const selectArg = optionsArg?.$select;
|
|
61
|
+
const loadPropertySecurityMetadata = optionsArg?.$loadPropertySecurityMetadata;
|
|
61
62
|
const mode = isInstanceSignature ? "offline" : undefined;
|
|
62
63
|
const typeOrApiName = isInstanceSignature ? args[0].$objectType : args[0];
|
|
63
64
|
const primaryKey = isInstanceSignature ? args[0].$primaryKey : args[1];
|
|
@@ -76,9 +77,12 @@ export function useOsdkObject(...args) {
|
|
|
76
77
|
mode,
|
|
77
78
|
...(stableSelect ? {
|
|
78
79
|
select: stableSelect
|
|
80
|
+
} : {}),
|
|
81
|
+
...(loadPropertySecurityMetadata ? {
|
|
82
|
+
$loadPropertySecurityMetadata: loadPropertySecurityMetadata
|
|
79
83
|
} : {})
|
|
80
84
|
}, observer), `object ${apiNameString} ${primaryKey}`);
|
|
81
|
-
}, [enabled, observableClient, typeOrApiName, apiNameString, primaryKey, mode, stableSelect]);
|
|
85
|
+
}, [enabled, observableClient, typeOrApiName, apiNameString, primaryKey, mode, stableSelect, loadPropertySecurityMetadata]);
|
|
82
86
|
const payload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
83
87
|
const forceUpdate = React.useCallback(() => {
|
|
84
88
|
throw new Error("not implemented");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","isInstanceSignature","optionsArg","undefined","enabled","selectArg","$select","mode","typeOrApiName","$objectType","primaryKey","$primaryKey","apiNameString","apiName","stableSelect","useMemo","JSON","stringify","subscribe","getSnapShot","unsubscribe","observer","observeObject","select","payload","useSyncExternalStore","forceUpdate","useCallback","Error","error","status","object","isLoading","isOptimistic"],"sources":["useOsdkObject.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n} from \"@osdk/api\";\nimport type { ObserveObjectCallbackArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<\n Q extends ObjectOrInterfaceDefinition,\n> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n obj: Osdk.Instance<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object or interface instance by type and primary key.\n *\n * @param type The object type or interface definition\n * @param primaryKey The primary key of the object\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object or interface instance by type and primary key with options.\n *\n * @param type The object type or interface definition\n * @param primaryKey The primary key of the object\n * @param options Options including $select and enabled\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n options?: { $select?: readonly PropertyKeys<Q>[]; enabled?: boolean },\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n ...args:\n | [obj: Osdk.Instance<Q>, enabled?: boolean]\n | [type: Q, primaryKey: PrimaryKeyType<Q>, enabled?: boolean]\n | [\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n options?: { $select?: readonly PropertyKeys<Q>[]; enabled?: boolean },\n ]\n): UseOsdkObjectResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // Check if first arg is an instance to discriminate signatures\n // TypeScript cannot narrow rest parameter unions with optional parameters,\n // so we must use type assertions after runtime discrimination\n const isInstanceSignature = \"$objectType\" in args[0];\n\n // Extract options object if provided (3rd arg is an object with $select or enabled)\n const optionsArg = !isInstanceSignature\n && args[2] != null\n && typeof args[2] === \"object\"\n ? args[2] as { $select?: readonly string[]; enabled?: boolean }\n : undefined;\n\n // Extract enabled flag - 2nd param for instance signature, 3rd for type signature\n const enabled = isInstanceSignature\n ? (typeof args[1] === \"boolean\" ? args[1] : true)\n : optionsArg\n ? (optionsArg.enabled ?? true)\n : (typeof args[2] === \"boolean\" ? args[2] : true);\n\n const selectArg = optionsArg?.$select;\n\n const mode = isInstanceSignature ? \"offline\" : undefined;\n\n const typeOrApiName = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$objectType\n : (args[0] as Q);\n\n const primaryKey = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$primaryKey\n : (args[1] as PrimaryKeyType<Q>);\n\n const apiNameString = typeof typeOrApiName === \"string\"\n ? typeOrApiName\n : typeOrApiName.apiName;\n\n const stableSelect = React.useMemo(\n () => selectArg,\n [JSON.stringify(selectArg)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectCallbackArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n `object ${apiNameString} ${primaryKey} [DISABLED]`,\n );\n }\n return makeExternalStore<ObserveObjectCallbackArgs<Q>>(\n (observer) =>\n observableClient.observeObject(\n typeOrApiName,\n primaryKey,\n {\n mode,\n ...(stableSelect ? { select: stableSelect } : {}),\n },\n observer,\n ),\n `object ${apiNameString} ${primaryKey}`,\n );\n },\n [\n enabled,\n observableClient,\n typeOrApiName,\n apiNameString,\n primaryKey,\n mode,\n stableSelect,\n ],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n const forceUpdate = React.useCallback(() => {\n throw new Error(\"not implemented\");\n }, []);\n\n return React.useMemo(() => {\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to load object\");\n }\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: enabled\n ? (payload?.status === \"loading\" || payload?.status === \"init\"\n || !payload)\n : false,\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate,\n };\n }, [payload, enabled, forceUpdate]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;;AAiBhD;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAG3B,GAAGC,IAOA,EACqB;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGL,K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TS,YAAY,EAAE,CAAC,CAACT,OAAO,EAAES,YAAY;MACrCJ,KAAK;MACLH;IACF,CAAC;EACH,CAAC,EAAE,CAACF,OAAO,EAAEpB,OAAO,EAAEsB,WAAW,CAAC,CAAC;AACrC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","isInstanceSignature","optionsArg","undefined","enabled","selectArg","$select","loadPropertySecurityMetadata","$loadPropertySecurityMetadata","mode","typeOrApiName","$objectType","primaryKey","$primaryKey","apiNameString","apiName","stableSelect","useMemo","JSON","stringify","subscribe","getSnapShot","unsubscribe","observer","observeObject","select","payload","useSyncExternalStore","forceUpdate","useCallback","Error","error","status","object","isLoading","isOptimistic"],"sources":["useOsdkObject.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n} from \"@osdk/api\";\nimport type { ObserveObjectCallbackArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<\n Q extends ObjectOrInterfaceDefinition,\n> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n obj: Osdk.Instance<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object or interface instance by type and primary key.\n *\n * @param type The object type or interface definition\n * @param primaryKey The primary key of the object\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object or interface instance by type and primary key with options.\n *\n * @param type The object type or interface definition\n * @param primaryKey The primary key of the object\n * @param options Options including $select, enabled, and $loadPropertySecurityMetadata\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n options?: {\n $select?: readonly PropertyKeys<Q>[];\n enabled?: boolean;\n $loadPropertySecurityMetadata?: boolean;\n },\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n ...args:\n | [obj: Osdk.Instance<Q>, enabled?: boolean]\n | [type: Q, primaryKey: PrimaryKeyType<Q>, enabled?: boolean]\n | [\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n options?: {\n $select?: readonly PropertyKeys<Q>[];\n enabled?: boolean;\n $loadPropertySecurityMetadata?: boolean;\n },\n ]\n): UseOsdkObjectResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // Check if first arg is an instance to discriminate signatures\n // TypeScript cannot narrow rest parameter unions with optional parameters,\n // so we must use type assertions after runtime discrimination\n const isInstanceSignature = \"$objectType\" in args[0];\n\n // Extract options object if provided (3rd arg is an object with $select or enabled)\n const optionsArg = !isInstanceSignature\n && args[2] != null\n && typeof args[2] === \"object\"\n ? args[2] as {\n $select?: readonly string[];\n enabled?: boolean;\n $loadPropertySecurityMetadata?: boolean;\n }\n : undefined;\n\n // Extract enabled flag - 2nd param for instance signature, 3rd for type signature\n const enabled = isInstanceSignature\n ? (typeof args[1] === \"boolean\" ? args[1] : true)\n : optionsArg\n ? (optionsArg.enabled ?? true)\n : (typeof args[2] === \"boolean\" ? args[2] : true);\n\n const selectArg = optionsArg?.$select;\n const loadPropertySecurityMetadata = optionsArg\n ?.$loadPropertySecurityMetadata;\n\n const mode = isInstanceSignature ? \"offline\" : undefined;\n\n const typeOrApiName = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$objectType\n : (args[0] as Q);\n\n const primaryKey = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$primaryKey\n : (args[1] as PrimaryKeyType<Q>);\n\n const apiNameString = typeof typeOrApiName === \"string\"\n ? typeOrApiName\n : typeOrApiName.apiName;\n\n const stableSelect = React.useMemo(\n () => selectArg,\n [JSON.stringify(selectArg)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectCallbackArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n `object ${apiNameString} ${primaryKey} [DISABLED]`,\n );\n }\n return makeExternalStore<ObserveObjectCallbackArgs<Q>>(\n (observer) =>\n observableClient.observeObject(\n typeOrApiName,\n primaryKey,\n {\n mode,\n ...(stableSelect ? { select: stableSelect } : {}),\n ...(loadPropertySecurityMetadata\n ? {\n $loadPropertySecurityMetadata: loadPropertySecurityMetadata,\n }\n : {}),\n },\n observer,\n ),\n `object ${apiNameString} ${primaryKey}`,\n );\n },\n [\n enabled,\n observableClient,\n typeOrApiName,\n apiNameString,\n primaryKey,\n mode,\n stableSelect,\n loadPropertySecurityMetadata,\n ],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n const forceUpdate = React.useCallback(() => {\n throw new Error(\"not implemented\");\n }, []);\n\n return React.useMemo(() => {\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to load object\");\n }\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: enabled\n ? (payload?.status === \"loading\" || payload?.status === \"init\"\n || !payload)\n : false,\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate,\n };\n }, [payload, enabled, forceUpdate]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;;AAiBhD;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAG3B,GAAGC,IAWA,EACqB;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;;EAE3D;EACA;EACA;EACA,MAAMK,mBAAmB,GAAG,aAAa,IAAIH,IAAI,CAAC,CAAC,CAAC;;EAEpD;EACA,MAAMI,UAAU,GAAG,CAACD,mBAAmB,IAChCH,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,IACf,OAAOA,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,GAC9BA,IAAI,CAAC,CAAC,CAAC,GAKPK,SAAS;;EAEb;EACA,MAAMC,OAAO,GAAGH,mBAAmB,GAC9B,OAAOH,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,GAAGA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAC9CI,UAAU,GACTA,UAAU,CAACE,OAAO,IAAI,IAAI,GAC1B,OAAON,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,GAAGA,IAAI,CAAC,CAAC,CAAC,GAAG,IAAK;EAEnD,MAAMO,SAAS,GA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EACbI,aAAa,EACbF,UAAU,EACVH,IAAI,EACJO,YAAY,EACZT,4BAA4B,CAEhC,CAAC;EAED,MAAMmB,OAAO,GAAGhC,KAAK,CAACiC,oBAAoB,CAACP,SAAS,EAAEC,WAAW,CAAC;EAElE,MAAMO,WAAW,GAAGlC,KAAK,CAACmC,WAAW,CAAC,MAAM;IAC1C,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;EACpC,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOpC,KAAK,CAACuB,OAAO,CAAC,MAAM;IACzB,IAAIc,KAAwB;IAC5B,IAAIL,OAAO,IAAI,OAAO,IAAIA,OAAO,IAAIA,OAAO,CAACK,KAAK,EAAE;MAClDA,KAAK,GAAGL,OAAO,CAACK,KAAK;IACvB,CAAC,MAAM,IAAIL,OAAO,EAAEM,MAAM,KAAK,OAAO,EAAE;MACtCD,KAAK,GAAG,IAAID,KAAK,CAAC,uBAAuB,CAAC;IAC5C;IAEA,OAAO;MACLG,MAAM,EAAEP,OAAO,EAAEO,MAAsC;MACvDC,SAAS,EAAE9B,OAAO,GACbsB,OAAO,EAAEM,MAAM,KAAK,SAAS,IAAIN,OAAO,EAAEM,MAAM,KAAK,MAAM,IACzD,CAACN,OAAO,GACX,KAAK;MACTS,YAAY,EAAE,CAAC,CAACT,OAAO,EAAES,YAAY;MACrCJ,KAAK;MACLH;IACF,CAAC;EACH,CAAC,EAAE,CAACF,OAAO,EAAEtB,OAAO,EAAEwB,WAAW,CAAC,CAAC;AACrC","ignoreList":[]}
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import React from "react";
|
|
18
|
+
import { extractPayloadError, isPayloadLoading } from "./hookUtils.js";
|
|
18
19
|
import { makeExternalStore } from "./makeExternalStore.js";
|
|
19
20
|
import { OsdkContext2 } from "./OsdkContext2.js";
|
|
20
|
-
const EMPTY_WHERE = {};
|
|
21
21
|
export function useOsdkObjects(type, options) {
|
|
22
22
|
const {
|
|
23
23
|
observableClient
|
|
@@ -34,15 +34,17 @@ export function useOsdkObjects(type, options) {
|
|
|
34
34
|
autoFetchMore,
|
|
35
35
|
intersectWith,
|
|
36
36
|
pivotTo,
|
|
37
|
-
$select
|
|
37
|
+
$select,
|
|
38
|
+
$loadPropertySecurityMetadata
|
|
38
39
|
} = options ?? {};
|
|
39
|
-
const
|
|
40
|
-
|
|
40
|
+
const canonOptions = observableClient.canonicalizeOptions({
|
|
41
|
+
where,
|
|
42
|
+
withProperties,
|
|
43
|
+
orderBy,
|
|
44
|
+
intersectWith,
|
|
45
|
+
$select
|
|
46
|
+
});
|
|
41
47
|
const stableRids = React.useMemo(() => rids, [JSON.stringify(rids)]);
|
|
42
|
-
const stableWithProperties = React.useMemo(() => withProperties, [JSON.stringify(withProperties)]);
|
|
43
|
-
const stableIntersectWith = React.useMemo(() => intersectWith, [JSON.stringify(intersectWith)]);
|
|
44
|
-
const stableOrderBy = React.useMemo(() => orderBy, [JSON.stringify(orderBy)]);
|
|
45
|
-
const stableSelect = React.useMemo(() => $select, [JSON.stringify($select)]);
|
|
46
48
|
const {
|
|
47
49
|
subscribe,
|
|
48
50
|
getSnapShot
|
|
@@ -55,40 +57,41 @@ export function useOsdkObjects(type, options) {
|
|
|
55
57
|
return makeExternalStore(observer => observableClient.observeList({
|
|
56
58
|
type,
|
|
57
59
|
rids: stableRids,
|
|
58
|
-
where:
|
|
60
|
+
where: canonOptions.where,
|
|
59
61
|
dedupeInterval: dedupeIntervalMs ?? 2_000,
|
|
60
62
|
pageSize,
|
|
61
|
-
orderBy:
|
|
63
|
+
orderBy: canonOptions.orderBy,
|
|
62
64
|
streamUpdates,
|
|
63
|
-
withProperties:
|
|
65
|
+
withProperties: canonOptions.withProperties,
|
|
64
66
|
autoFetchMore,
|
|
65
|
-
...(
|
|
66
|
-
intersectWith:
|
|
67
|
+
...(canonOptions.intersectWith ? {
|
|
68
|
+
intersectWith: canonOptions.intersectWith
|
|
67
69
|
} : {}),
|
|
68
70
|
...(pivotTo ? {
|
|
69
71
|
pivotTo
|
|
70
72
|
} : {}),
|
|
71
|
-
...(
|
|
72
|
-
select:
|
|
73
|
+
...(canonOptions.$select ? {
|
|
74
|
+
select: canonOptions.$select
|
|
75
|
+
} : {}),
|
|
76
|
+
...($loadPropertySecurityMetadata ? {
|
|
77
|
+
$loadPropertySecurityMetadata
|
|
73
78
|
} : {})
|
|
74
|
-
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${stableRids ? `[${stableRids.length} rids]` : ""} ${JSON.stringify(
|
|
75
|
-
}, [enabled, observableClient, type.apiName, type.type, stableRids,
|
|
79
|
+
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${stableRids ? `[${stableRids.length} rids]` : ""} ${JSON.stringify(canonOptions.where)}` : void 0);
|
|
80
|
+
}, [enabled, observableClient, type.apiName, type.type, stableRids, canonOptions.where, dedupeIntervalMs, pageSize, canonOptions.orderBy, streamUpdates, canonOptions.withProperties, autoFetchMore, canonOptions.intersectWith, pivotTo, canonOptions.$select, $loadPropertySecurityMetadata]);
|
|
76
81
|
const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
}, [listPayload, enabled]);
|
|
82
|
+
const refetch = React.useCallback(async () => {
|
|
83
|
+
await observableClient.invalidateObjectType(type.apiName);
|
|
84
|
+
}, [observableClient, type.apiName]);
|
|
85
|
+
return React.useMemo(() => ({
|
|
86
|
+
fetchMore: listPayload?.hasMore ? listPayload.fetchMore : undefined,
|
|
87
|
+
error: extractPayloadError(listPayload, "Failed to load objects"),
|
|
88
|
+
data: listPayload?.resolvedList,
|
|
89
|
+
isLoading: isPayloadLoading(listPayload, enabled),
|
|
90
|
+
isOptimistic: listPayload?.isOptimistic ?? false,
|
|
91
|
+
totalCount: listPayload?.totalCount,
|
|
92
|
+
hasMore: listPayload?.hasMore ?? false,
|
|
93
|
+
objectSet: listPayload?.objectSet,
|
|
94
|
+
refetch
|
|
95
|
+
}), [listPayload, enabled, refetch]);
|
|
93
96
|
}
|
|
94
97
|
//# sourceMappingURL=useOsdkObjects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","EMPTY_WHERE","useOsdkObjects","type","options","observableClient","useContext","pageSize","dedupeIntervalMs","withProperties","enabled","rids","where","orderBy","streamUpdates","autoFetchMore","intersectWith","pivotTo","$select","canonWhere","canonicalizeWhereClause","stableCanonWhere","useMemo","JSON","stringify","stableRids","stableWithProperties","stableIntersectWith","stableOrderBy","stableSelect","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","apiName","observer","observeList","dedupeInterval","select","length","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 * Fetch objects by their RIDs (Resource Identifiers).\n * When provided, starts with a static objectset containing these RIDs.\n * Can be combined with `where` to filter the RID set, and with `orderBy` to sort results.\n *\n * @example\n * // Fetch specific objects by RID\n * useOsdkObjects(Employee, { rids: ['ri.foo.123', 'ri.foo.456'] })\n *\n * @example\n * // Fetch specific objects by RID, filtered by status\n * useOsdkObjects(Employee, {\n * rids: ['ri.foo.123', 'ri.foo.456', 'ri.foo.789'],\n * where: { status: 'active' }\n * })\n */\n rids?: readonly string[];\n\n /**\n * Standard OSDK Where clause with RDP support.\n * When used with `rids`, filters the RID set.\n * When used alone, filters all objects of the type.\n */\n where?: WhereClause<T, RDPs>;\n\n /**\n * Sort results by one or more properties.\n */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\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 * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\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 * @default true\n */\n enabled?: boolean;\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 autoFetchMore?: boolean | number;\n\n streamUpdates?: boolean;\n\n /**\n * Restrict which properties are returned for each object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n *\n * @example\n * // Only fetch name and status properties\n * useOsdkObjects(Employee, { $select: [\"name\", \"status\"] })\n */\n $select?: readonly PropertyKeys<T>[];\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n EXTRA_OPTIONS extends never | \"$rid\" = never,\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<\n T,\n \"$allBaseProperties\" | EXTRA_OPTIONS,\n PropertyKeys<T>,\n RDPs\n >[]\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\nconst EMPTY_WHERE = {};\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; rids: readonly string[] },\n): UseOsdkListResult<LinkedType<Q, L>, {}, \"$rid\">;\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> & { rids: readonly string[] },\n): UseOsdkListResult<Q, RDPs, \"$rid\">;\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<Q, RDPs, \"$rid\">\n | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>>\n | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>, {}, \"$rid\">\n{\n const { observableClient } = React.useContext(OsdkContext2);\n\n const {\n pageSize,\n dedupeIntervalMs,\n withProperties,\n enabled = true,\n rids,\n where,\n orderBy,\n streamUpdates,\n autoFetchMore,\n intersectWith,\n pivotTo,\n $select,\n } = options ?? {};\n\n const canonWhere = observableClient.canonicalizeWhereClause<\n Q,\n RDPs\n >(where ?? EMPTY_WHERE);\n\n const stableCanonWhere = React.useMemo(\n () => canonWhere,\n [JSON.stringify(canonWhere)],\n );\n\n const stableRids = React.useMemo(\n () => rids,\n [JSON.stringify(rids)],\n );\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 stableSelect = React.useMemo(\n () => $select,\n [JSON.stringify($select)],\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} [DISABLED]`\n : void 0,\n );\n }\n\n return makeExternalStore<\n ObserveObjectsCallbackArgs<Q, RDPs>\n >(\n (observer) =>\n observableClient.observeList({\n type,\n rids: stableRids,\n where: stableCanonWhere,\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 ...(stableSelect ? { select: stableSelect } : {}),\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${\n stableRids ? `[${stableRids.length} rids]` : \"\"\n } ${JSON.stringify(stableCanonWhere)}`\n : void 0,\n );\n },\n [\n enabled,\n observableClient,\n type.apiName,\n type.type,\n stableRids,\n stableCanonWhere,\n dedupeIntervalMs,\n pageSize,\n stableOrderBy,\n streamUpdates,\n stableWithProperties,\n autoFetchMore,\n stableIntersectWith,\n pivotTo,\n stableSelect,\n ],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return React.useMemo(() => {\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 }, [listPayload, enabled]);\n}\n"],"mappings":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S,CAACH,gBAAgB,CAAC,EAAE,GACpC,KAAK,CACX,CAAC;EACH,CAAC,EACD,CACEX,OAAO,EACPL,gBAAgB,EAChBF,IAAI,CAACiC,OAAO,EACZjC,IAAI,CAACA,IAAI,EACTsB,UAAU,EACVJ,gBAAgB,EAChBb,gBAAgB,EAChBD,QAAQ,EACRqB,aAAa,EACbd,aAAa,EACbY,oBAAoB,EACpBX,aAAa,EACbY,mBAAmB,EACnBV,OAAO,EACPY,YAAY,CAEhB,CAAC;EAED,MAAMa,WAAW,GAAG5C,KAAK,CAAC6C,oBAAoB,CAACb,SAAS,EAAEC,WAAW,CAAC;EAEtE,OAAOjC,KAAK,CAACwB,OAAO,CAAC,MAAM;IACzB,IAAIsB,KAAwB;IAC5B,IAAIF,WAAW,IAAI,OAAO,IAAIA,WAAW,IAAIA,WAAW,CAACE,KAAK,EAAE;MAC9DA,KAAK,GAAGF,WAAW,CAACE,KAAK;IAC3B,CAAC,MAAM,IAAIF,WAAW,EAAEG,MAAM,KAAK,OAAO,EAAE;MAC1CD,KAAK,GAAG,IAAIE,KAAK,CAAC,wBAAwB,CAAC;IAC7C;IAEA,OAAO;MACLC,SAAS,EAAEL,WAAW,EAAEM,OAAO,GAAGN,WAAW,CAACK,SAAS,GAAGE,SAAS;MACnEL,KAAK;MACLM,IAAI,EAAER,WAAW,EAAES,YAAY;MAC/BC,SAAS,EAAE1C,OAAO,GACbgC,WAAW,EAAEG,MAAM,KAAK,SAAS,IAAIH,WAAW,EAAEG,MAAM,KAAK,MAAM,IACjE,CAACH,WAAW,GACf,KAAK;MACTW,YAAY,EAAEX,WAAW,EAAEW,YAAY,IAAI,KAAK;MAChDC,UAAU,EAAEZ,WAAW,EAAEY;IAC3B,CAAC;EACH,CAAC,EAAE,CAACZ,WAAW,EAAEhC,OAAO,CAAC,CAAC;AAC5B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useOsdkObjects.js","names":["React","extractPayloadError","isPayloadLoading","makeExternalStore","OsdkContext2","useOsdkObjects","type","options","observableClient","useContext","pageSize","dedupeIntervalMs","withProperties","enabled","rids","where","orderBy","streamUpdates","autoFetchMore","intersectWith","pivotTo","$select","$loadPropertySecurityMetadata","canonOptions","canonicalizeOptions","stableRids","useMemo","JSON","stringify","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","apiName","observer","observeList","dedupeInterval","select","length","listPayload","useSyncExternalStore","refetch","useCallback","invalidateObjectType","fetchMore","hasMore","undefined","error","data","resolvedList","isLoading","isOptimistic","totalCount","objectSet"],"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 ObjectSet,\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 { extractPayloadError, isPayloadLoading } from \"./hookUtils.js\";\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 * Fetch objects by their RIDs (Resource Identifiers).\n * When provided, starts with a static objectset containing these RIDs.\n * Can be combined with `where` to filter the RID set, and with `orderBy` to sort results.\n *\n * @example\n * // Fetch specific objects by RID\n * useOsdkObjects(Employee, { rids: ['ri.foo.123', 'ri.foo.456'] })\n *\n * @example\n * // Fetch specific objects by RID, filtered by status\n * useOsdkObjects(Employee, {\n * rids: ['ri.foo.123', 'ri.foo.456', 'ri.foo.789'],\n * where: { status: 'active' }\n * })\n */\n rids?: readonly string[];\n\n /**\n * Standard OSDK Where clause with RDP support.\n * When used with `rids`, filters the RID set.\n * When used alone, filters all objects of the type.\n */\n where?: WhereClause<T, RDPs>;\n\n /**\n * Sort results by one or more properties.\n */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\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 * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\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 * @default true\n */\n enabled?: boolean;\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 autoFetchMore?: boolean | number;\n\n streamUpdates?: boolean;\n\n /**\n * Restrict which properties are returned for each object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n *\n * @example\n * // Only fetch name and status properties\n * useOsdkObjects(Employee, { $select: [\"name\", \"status\"] })\n */\n $select?: readonly PropertyKeys<T>[];\n\n /**\n * When true, loads per-property security metadata (marking requirements)\n * alongside each object. The returned objects will have `$propertySecurities`\n * populated with conjunctive/disjunctive marking requirements per property.\n */\n $loadPropertySecurityMetadata?: boolean;\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n EXTRA_OPTIONS extends never | \"$rid\" = never,\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<\n T,\n \"$allBaseProperties\" | EXTRA_OPTIONS,\n PropertyKeys<T>,\n RDPs\n >[]\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 hasMore: boolean;\n\n objectSet: ObjectSet<T, RDPs> | undefined;\n\n refetch: () => Promise<void>;\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; rids: readonly string[] },\n): UseOsdkListResult<LinkedType<Q, L>, {}, \"$rid\">;\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> & { rids: readonly string[] },\n): UseOsdkListResult<Q, RDPs, \"$rid\">;\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<Q, RDPs, \"$rid\">\n | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>>\n | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>, {}, \"$rid\">\n{\n const { observableClient } = React.useContext(OsdkContext2);\n\n const {\n pageSize,\n dedupeIntervalMs,\n withProperties,\n enabled = true,\n rids,\n where,\n orderBy,\n streamUpdates,\n autoFetchMore,\n intersectWith,\n pivotTo,\n $select,\n $loadPropertySecurityMetadata,\n } = options ?? {};\n\n const canonOptions = observableClient.canonicalizeOptions({\n where,\n withProperties,\n orderBy,\n intersectWith,\n $select,\n });\n\n const stableRids = React.useMemo(\n () => rids,\n [JSON.stringify(rids)],\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} [DISABLED]`\n : void 0,\n );\n }\n\n return makeExternalStore<\n ObserveObjectsCallbackArgs<Q, RDPs>\n >(\n (observer) =>\n observableClient.observeList({\n type,\n rids: stableRids,\n where: canonOptions.where,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy: canonOptions.orderBy,\n streamUpdates,\n withProperties: canonOptions.withProperties,\n autoFetchMore,\n ...(canonOptions.intersectWith\n ? { intersectWith: canonOptions.intersectWith }\n : {}),\n ...(pivotTo ? { pivotTo } : {}),\n ...(canonOptions.$select ? { select: canonOptions.$select } : {}),\n ...($loadPropertySecurityMetadata\n ? { $loadPropertySecurityMetadata }\n : {}),\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${\n stableRids ? `[${stableRids.length} rids]` : \"\"\n } ${JSON.stringify(canonOptions.where)}`\n : void 0,\n );\n },\n [\n enabled,\n observableClient,\n type.apiName,\n type.type,\n stableRids,\n canonOptions.where,\n dedupeIntervalMs,\n pageSize,\n canonOptions.orderBy,\n streamUpdates,\n canonOptions.withProperties,\n autoFetchMore,\n canonOptions.intersectWith,\n pivotTo,\n canonOptions.$select,\n $loadPropertySecurityMetadata,\n ],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n const refetch = React.useCallback(async () => {\n await observableClient.invalidateObjectType(type.apiName);\n }, [observableClient, type.apiName]);\n\n return React.useMemo(() => ({\n fetchMore: listPayload?.hasMore ? listPayload.fetchMore : undefined,\n error: extractPayloadError(listPayload, \"Failed to load objects\"),\n data: listPayload?.resolvedList,\n isLoading: isPayloadLoading(listPayload, enabled),\n isOptimistic: listPayload?.isOptimistic ?? false,\n totalCount: listPayload?.totalCount,\n hasMore: listPayload?.hasMore ?? false,\n objectSet: listPayload?.objectSet,\n refetch,\n }), [listPayload, enabled, refetch]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,mBAAmB,EAAEC,gBAAgB,QAAQ,gBAAgB;AACtE,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AA6MhD,OAAO,SAASC,cAAcA,CAI5BC,IAAO,EACPC,OAAwC,EAM1C;EACE,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,KAAK,CAAC0B,OAAO,CAAC,OAAO;IAC1BoB,SAAS,EAAEL,WAAW,EAAEM,OAAO,GAAGN,WAAW,CAACK,SAAS,GAAGE,SAAS;IACnEC,KAAK,EAAEhD,mBAAmB,CAACwC,WAAW,EAAE,wBAAwB,CAAC;IACjES,IAAI,EAAET,WAAW,EAAEU,YAAY;IAC/BC,SAAS,EAAElD,gBAAgB,CAACuC,WAAW,EAAE5B,OAAO,CAAC;IACjDwC,YAAY,EAAEZ,WAAW,EAAEY,YAAY,IAAI,KAAK;IAChDC,UAAU,EAAEb,WAAW,EAAEa,UAAU;IACnCP,OAAO,EAAEN,WAAW,EAAEM,OAAO,IAAI,KAAK;IACtCQ,SAAS,EAAEd,WAAW,EAAEc,SAAS;IACjCZ;EACF,CAAC,CAAC,EAAE,CAACF,WAAW,EAAE5B,OAAO,EAAE8B,OAAO,CAAC,CAAC;AACtC","ignoreList":[]}
|
|
@@ -14,7 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
export { useCbacBanner } from "../../new/platform-apis/admin/useCbacBanner.js";
|
|
18
|
+
export { useCbacMarkingRestrictions } from "../../new/platform-apis/admin/useCbacMarkingRestrictions.js";
|
|
17
19
|
export { useCurrentFoundryUser } from "../../new/platform-apis/admin/useCurrentFoundryUser.js";
|
|
18
20
|
export { useFoundryUser } from "../../new/platform-apis/admin/useFoundryUser.js";
|
|
19
21
|
export { useFoundryUsersList } from "../../new/platform-apis/admin/useFoundryUsersList.js";
|
|
22
|
+
export { useMarkingCategories } from "../../new/platform-apis/admin/useMarkingCategories.js";
|
|
23
|
+
export { useMarkings } from "../../new/platform-apis/admin/useMarkings.js";
|
|
24
|
+
export { useUserViewMarkings } from "../../new/platform-apis/admin/useUserMarkings.js";
|
|
20
25
|
//# sourceMappingURL=admin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","names":["useCurrentFoundryUser","useFoundryUser","useFoundryUsersList"],"sources":["admin.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 { 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\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,wDAAwD;AAC9F,SAASC,cAAc,QAAQ,iDAAiD;AAChF,SAASC,mBAAmB,QAAQ,sDAAsD","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"admin.js","names":["useCbacBanner","useCbacMarkingRestrictions","useCurrentFoundryUser","useFoundryUser","useFoundryUsersList","useMarkingCategories","useMarkings","useUserViewMarkings"],"sources":["admin.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 { useCbacBanner } from \"../../new/platform-apis/admin/useCbacBanner.js\";\nexport type {\n CbacBannerData,\n UseCbacBannerOptions,\n UseCbacBannerResult,\n} from \"../../new/platform-apis/admin/useCbacBanner.js\";\nexport { useCbacMarkingRestrictions } from \"../../new/platform-apis/admin/useCbacMarkingRestrictions.js\";\nexport type {\n CbacMarkingRestrictionsData,\n UseCbacMarkingRestrictionsOptions,\n UseCbacMarkingRestrictionsResult,\n} from \"../../new/platform-apis/admin/useCbacMarkingRestrictions.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 { useMarkingCategories } from \"../../new/platform-apis/admin/useMarkingCategories.js\";\nexport { useMarkings } from \"../../new/platform-apis/admin/useMarkings.js\";\nexport { useUserViewMarkings } from \"../../new/platform-apis/admin/useUserMarkings.js\";\nexport type {\n UseUserViewMarkingsOptions,\n UseUserViewMarkingsResult,\n} from \"../../new/platform-apis/admin/useUserMarkings.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,gDAAgD;AAM9E,SAASC,0BAA0B,QAAQ,6DAA6D;AAMxG,SAASC,qBAAqB,QAAQ,wDAAwD;AAC9F,SAASC,cAAc,QAAQ,iDAAiD;AAChF,SAASC,mBAAmB,QAAQ,sDAAsD;AAC1F,SAASC,oBAAoB,QAAQ,uDAAuD;AAC5F,SAASC,WAAW,QAAQ,8CAA8C;AAC1E,SAASC,mBAAmB,QAAQ,kDAAkD","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 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
|
+
export { useOsdkFunctions } from "../new/useOsdkFunctions.js";
|
|
18
|
+
//# sourceMappingURL=unstable-do-not-use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unstable-do-not-use.js","names":["useOsdkFunctions"],"sources":["unstable-do-not-use.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\nexport { useOsdkFunctions } from \"../new/useOsdkFunctions.js\";\nexport type {\n FunctionQueryParams,\n UseOsdkFunctionsProps,\n UseOsdkFunctionsResult,\n} from \"../new/useOsdkFunctions.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,gBAAgB,QAAQ,4BAA4B","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
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__ */ React__default.default.createContext({
|
|
17
|
+
client: fakeClient
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// src/useOsdkClient.ts
|
|
21
|
+
function useOsdkClient() {
|
|
22
|
+
return React__default.default.useContext(OsdkContext).client;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.OsdkContext = OsdkContext;
|
|
26
|
+
exports.useOsdkClient = useOsdkClient;
|
|
27
|
+
//# sourceMappingURL=chunk-2N32USW5.cjs.map
|
|
28
|
+
//# sourceMappingURL=chunk-2N32USW5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/OsdkContext.ts","../../src/useOsdkClient.ts"],"names":["React"],"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,0CAAiC,aAAc,CAAA;AAAA,EAC1D,MAAQ,EAAA;AACV,CAAC;;;ACPM,SAAS,aAAgB,GAAA;AAC9B,EAAOA,OAAAA,sBAAAA,CAAM,UAAW,CAAA,WAAW,CAAE,CAAA,MAAA;AACvC","file":"chunk-2N32USW5.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}"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk2N32USW5_cjs = require('./chunk-2N32USW5.cjs');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
9
|
+
|
|
10
|
+
function useOsdkMetadata(type) {
|
|
11
|
+
const client = chunk2N32USW5_cjs.useOsdkClient();
|
|
12
|
+
const [metadata, setMetadata] = React__default.default.useState(void 0);
|
|
13
|
+
const [error, setError] = React__default.default.useState();
|
|
14
|
+
if (!metadata && !error) {
|
|
15
|
+
client.fetchMetadata(type).then((fetchedMetadata) => {
|
|
16
|
+
setMetadata(fetchedMetadata);
|
|
17
|
+
}).catch((error2) => {
|
|
18
|
+
const errorMessage = error2 instanceof Error ? error2.message : String(error2);
|
|
19
|
+
setError(errorMessage);
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
loading: true
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
loading: false,
|
|
27
|
+
metadata,
|
|
28
|
+
error
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.useOsdkMetadata = useOsdkMetadata;
|
|
33
|
+
//# sourceMappingURL=chunk-R4FZ5MUH.cjs.map
|
|
34
|
+
//# sourceMappingURL=chunk-R4FZ5MUH.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/useOsdkMetadata.ts"],"names":["useOsdkClient","React","error"],"mappings":";;;;;;;;;AAkBO,SAAS,gBAAgB,IAAM,EAAA;AACpC,EAAA,MAAM,SAASA,+BAAc,EAAA;AAC7B,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAI,GAAAC,sBAAA,CAAM,SAAS,MAAS,CAAA;AACxD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAIA,uBAAM,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-R4FZ5MUH.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 { 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}"]}
|
|
@@ -7,15 +7,26 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
7
7
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
8
8
|
|
|
9
9
|
// src/new/OsdkContext2.ts
|
|
10
|
+
var MISSING_PROVIDER_MESSAGE = "No OsdkProvider2 found. Did you forget to wrap your component tree with <OsdkProvider2>?";
|
|
10
11
|
function fakeClientFn(..._args) {
|
|
11
|
-
throw new Error(
|
|
12
|
+
throw new Error(MISSING_PROVIDER_MESSAGE);
|
|
12
13
|
}
|
|
13
14
|
var fakeClient = Object.assign(fakeClientFn, {
|
|
14
15
|
fetchMetadata: fakeClientFn
|
|
15
16
|
});
|
|
17
|
+
var fakeObservableClient = new Proxy({}, {
|
|
18
|
+
get(_target, prop) {
|
|
19
|
+
if (prop === Symbol.toPrimitive || prop === Symbol.toStringTag) {
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
return (..._args) => {
|
|
23
|
+
throw new Error(MISSING_PROVIDER_MESSAGE);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
16
27
|
var OsdkContext2 = /* @__PURE__ */ React__default.default.createContext({
|
|
17
28
|
client: fakeClient,
|
|
18
|
-
observableClient:
|
|
29
|
+
observableClient: fakeObservableClient
|
|
19
30
|
});
|
|
20
31
|
|
|
21
32
|
// src/new/makeExternalStore.ts
|
|
@@ -107,5 +118,5 @@ function makeExternalStoreAsync(createObservation, _name, initialValue) {
|
|
|
107
118
|
exports.OsdkContext2 = OsdkContext2;
|
|
108
119
|
exports.makeExternalStore = makeExternalStore;
|
|
109
120
|
exports.makeExternalStoreAsync = makeExternalStoreAsync;
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
111
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-ZUNR45SJ.cjs.map
|
|
122
|
+
//# sourceMappingURL=chunk-ZUNR45SJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/new/OsdkContext2.ts","../../src/new/makeExternalStore.ts"],"names":[],"mappings":";;;;;;;;;AAiBO,IAAM,wBAA2B,GAAA,0FAAA;AACxC,SAAS,gBAAgB,KAAO,EAAA;AAC9B,EAAM,MAAA,IAAI,MAAM,wBAAwB,CAAA;AAC1C;AACA,IAAM,UAAA,GAAa,MAAO,CAAA,MAAA,CAAO,YAAc,EAAA;AAAA,EAC7C,aAAe,EAAA;AACjB,CAAC,CAAA;AAUD,IAAM,oBAAuB,GAAA,IAAI,KAAM,CAAA,EAAI,EAAA;AAAA,EACzC,GAAA,CAAI,SAAS,IAAM,EAAA;AACjB,IAAA,IAAI,IAAS,KAAA,MAAA,CAAO,WAAe,IAAA,IAAA,KA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ZUNR45SJ.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\";\nexport const MISSING_PROVIDER_MESSAGE = \"No OsdkProvider2 found. Did you forget to wrap your component tree with <OsdkProvider2>?\";\nfunction fakeClientFn(..._args) {\n throw new Error(MISSING_PROVIDER_MESSAGE);\n}\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn\n});\n\n// Proxy that throws a clear error when any method is called, so hooks like\n// useOsdkObjects get \"Did you forget <OsdkProvider2>?\" instead of\n// \"cannot read canonicalizeWhereClause of undefined\".\n// We intercept `get` so every property access returns a throwing function,\n// without needing to enumerate every ObservableClient method.\n// Symbol.toPrimitive and Symbol.toStringTag are accessed by React/devtools\n// during rendering and logging — returning undefined for these avoids\n// spurious throws in contexts unrelated to the user's code.\nconst fakeObservableClient = new Proxy({}, {\n get(_target, prop) {\n if (prop === Symbol.toPrimitive || prop === Symbol.toStringTag) {\n return undefined;\n }\n return (..._args) => {\n throw new Error(MISSING_PROVIDER_MESSAGE);\n };\n }\n});\nexport const OsdkContext2 = /*#__PURE__*/React.createContext({\n client: fakeClient,\n observableClient: fakeObservableClient\n});","/*\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 function makeExternalStore(createObservation, _name, initialValue) {\n let lastResult = initialValue;\n function getSnapShot() {\n return lastResult;\n }\n function subscribe(notifyUpdate) {\n const obs = createObservation({\n next: payload => {\n lastResult = payload;\n notifyUpdate();\n },\n error: error => {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error))\n };\n notifyUpdate();\n },\n complete: () => {}\n });\n return () => {\n obs.unsubscribe();\n };\n }\n return {\n subscribe,\n getSnapShot\n };\n}\n\n/**\n * Like makeExternalStore but for async subscription creation.\n *\n * Uses an isActive flag to handle race conditions:\n * If cleanup runs before promise resolves, the stale subscription is\n * immediately unsubscribed when it eventually resolves\n */\nexport function makeExternalStoreAsync(createObservation, _name, initialValue) {\n let lastResult = initialValue;\n function getSnapShot() {\n return lastResult;\n }\n function subscribe(notifyUpdate) {\n let isActive = true;\n let currentSubscription;\n const subscriptionPromise = createObservation({\n next: payload => {\n if (isActive) {\n lastResult = payload;\n notifyUpdate();\n }\n },\n error: error => {\n if (isActive) {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error))\n };\n notifyUpdate();\n }\n },\n complete: () => {}\n });\n subscriptionPromise.then(sub => {\n if (isActive) {\n currentSubscription = sub;\n } else {\n sub.unsubscribe();\n }\n }).catch(error => {\n if (isActive) {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error))\n };\n notifyUpdate();\n }\n });\n return () => {\n isActive = false;\n if (currentSubscription) {\n currentSubscription.unsubscribe();\n }\n };\n }\n return {\n subscribe,\n getSnapShot\n };\n}"]}
|