@osdk/react 0.7.0-beta.3 → 0.7.0-beta.5
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 +24 -0
- package/build/browser/new/useObjectSet.js +77 -0
- package/build/browser/new/useObjectSet.js.map +1 -0
- package/build/browser/new/useOsdkObject.js +8 -2
- package/build/browser/new/useOsdkObject.js.map +1 -1
- package/build/browser/new/useOsdkObjects.js +7 -2
- package/build/browser/new/useOsdkObjects.js.map +1 -1
- package/build/browser/public/experimental.js +1 -0
- package/build/browser/public/experimental.js.map +1 -1
- package/build/cjs/public/experimental.cjs +84 -29
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +80 -2
- package/build/esm/new/useObjectSet.js +77 -0
- package/build/esm/new/useObjectSet.js.map +1 -0
- package/build/esm/new/useOsdkObject.js +8 -2
- package/build/esm/new/useOsdkObject.js.map +1 -1
- package/build/esm/new/useOsdkObjects.js +7 -2
- package/build/esm/new/useOsdkObjects.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/useObjectSet.d.ts +85 -0
- package/build/types/new/useObjectSet.d.ts.map +1 -0
- package/build/types/new/useOsdkObjects.d.ts.map +1 -1
- package/build/types/public/experimental.d.ts +1 -0
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @osdkkit/react
|
|
2
2
|
|
|
3
|
+
## 0.7.0-beta.5
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7b97128: add useObjectSet hook
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [7b97128]
|
|
12
|
+
- @osdk/client@2.5.0-beta.11
|
|
13
|
+
- @osdk/api@2.5.0-beta.11
|
|
14
|
+
|
|
15
|
+
## 0.7.0-beta.4
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 46ae415: improve useOsdkObject, useOsdkObjects error handling
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [ab29baa]
|
|
24
|
+
- @osdk/client@2.5.0-beta.7
|
|
25
|
+
- @osdk/api@2.5.0-beta.7
|
|
26
|
+
|
|
3
27
|
## 0.7.0-beta.3
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { computeObjectSetCacheKey } from "@osdk/client/unstable-do-not-use";
|
|
18
|
+
import React from "react";
|
|
19
|
+
import { makeExternalStore } from "./makeExternalStore.js";
|
|
20
|
+
import { OsdkContext2 } from "./OsdkContext2.js";
|
|
21
|
+
/**
|
|
22
|
+
* React hook for observing and interacting with OSDK object sets.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam Q - The object type definition
|
|
25
|
+
* @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet
|
|
26
|
+
* @typeParam RDPs - New derived properties to be added via options.withProperties
|
|
27
|
+
*
|
|
28
|
+
* @param baseObjectSet - The ObjectSet to observe (may already have derived properties)
|
|
29
|
+
* @param options - Options for filtering, sorting, and adding new derived properties
|
|
30
|
+
* @returns Object set data with both existing and new derived properties
|
|
31
|
+
*/
|
|
32
|
+
export function useObjectSet(baseObjectSet, options = {}) {
|
|
33
|
+
const {
|
|
34
|
+
observableClient
|
|
35
|
+
} = React.useContext(OsdkContext2);
|
|
36
|
+
|
|
37
|
+
// Compute a stable cache key for the ObjectSet and options
|
|
38
|
+
// dedupeIntervalMs is excluded as it doesn't affect the data, only the refresh rate
|
|
39
|
+
const stableKey = computeObjectSetCacheKey(baseObjectSet, {
|
|
40
|
+
where: options.where,
|
|
41
|
+
withProperties: options.withProperties,
|
|
42
|
+
union: options.union,
|
|
43
|
+
intersect: options.intersect,
|
|
44
|
+
subtract: options.subtract,
|
|
45
|
+
pivotTo: options.pivotTo,
|
|
46
|
+
pageSize: options.pageSize,
|
|
47
|
+
orderBy: options.orderBy
|
|
48
|
+
});
|
|
49
|
+
const {
|
|
50
|
+
subscribe,
|
|
51
|
+
getSnapShot
|
|
52
|
+
} = React.useMemo(() => {
|
|
53
|
+
return makeExternalStore(observer => {
|
|
54
|
+
const subscription = observableClient.observeObjectSet(baseObjectSet, {
|
|
55
|
+
where: options.where,
|
|
56
|
+
withProperties: options.withProperties,
|
|
57
|
+
union: options.union,
|
|
58
|
+
intersect: options.intersect,
|
|
59
|
+
subtract: options.subtract,
|
|
60
|
+
pivotTo: options.pivotTo,
|
|
61
|
+
pageSize: options.pageSize,
|
|
62
|
+
orderBy: options.orderBy,
|
|
63
|
+
dedupeInterval: options.dedupeIntervalMs ?? 2_000
|
|
64
|
+
}, observer);
|
|
65
|
+
return subscription;
|
|
66
|
+
}, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0);
|
|
67
|
+
}, [observableClient, stableKey]);
|
|
68
|
+
const payload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
69
|
+
return {
|
|
70
|
+
data: payload?.resolvedList,
|
|
71
|
+
isLoading: payload?.status === "loading" || !payload && true || false,
|
|
72
|
+
error: payload && "error" in payload ? payload.error : undefined,
|
|
73
|
+
fetchMore: payload?.fetchMore,
|
|
74
|
+
objectSet: payload?.objectSet || baseObjectSet
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=useObjectSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useObjectSet.js","names":["computeObjectSetCacheKey","React","makeExternalStore","OsdkContext2","useObjectSet","baseObjectSet","options","observableClient","useContext","stableKey","where","withProperties","union","intersect","subtract","pivotTo","pageSize","orderBy","subscribe","getSnapShot","useMemo","observer","subscription","observeObjectSet","dedupeInterval","dedupeIntervalMs","process","env","NODE_ENV","payload","useSyncExternalStore","data","resolvedList","isLoading","status","error","undefined","fetchMore","objectSet"],"sources":["useObjectSet.tsx"],"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 LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\n\nimport {\n computeObjectSetCacheKey,\n type ObserveObjectSetArgs,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype SimplePropertyDef =\n | WirePropertyTypes\n | undefined\n | Array<WirePropertyTypes>;\n\nexport interface UseObjectSetOptions<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type)\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs>;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet<\n Q extends ObjectTypeDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs>,\n options: UseObjectSetOptions<Q, RDPs> = {},\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs is excluded as it doesn't affect the data, only the refresh rate\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: options.where,\n withProperties: options.withProperties,\n union: options.union,\n intersect: options.intersect,\n subtract: options.subtract,\n pivotTo: options.pivotTo,\n pageSize: options.pageSize,\n orderBy: options.orderBy,\n });\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n const subscription = observableClient.observeObjectSet(\n baseObjectSet as ObjectSet<Q>,\n {\n where: options.where,\n withProperties: options.withProperties,\n union: options.union,\n intersect: options.intersect,\n subtract: options.subtract,\n pivotTo: options.pivotTo,\n pageSize: options.pageSize,\n orderBy: options.orderBy,\n dedupeInterval: options.dedupeIntervalMs ?? 2_000,\n },\n observer,\n );\n return subscription;\n },\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey}`\n : void 0,\n );\n },\n [observableClient, stableKey],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n data: payload?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: payload?.status === \"loading\" || (!payload && true) || false,\n error: payload && \"error\" in payload\n ? payload.error\n : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet as ObjectSet<Q, RDPs> || baseObjectSet,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SACEA,wBAAwB,QAEnB,kCAAkC;AACzC,OAAOC,KAAK,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mB,gBAAgB,IAAI;MAC9C,CAAC,EACDJ,QACF,CAAC;MACD,OAAOC,YAAY;IACrB,CAAC,EACDI,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,aAAanB,SAAS,EAAE,GACxB,KAAK,CACX,CAAC;EACH,CAAC,EACD,CAACF,gBAAgB,EAAEE,SAAS,CAC9B,CAAC;EAED,MAAMoB,OAAO,GAAG5B,KAAK,CAAC6B,oBAAoB,CAACZ,SAAS,EAAEC,WAAW,CAAC;EAElE,OAAO;IACLY,IAAI,EAAEF,OAAO,EAAEG,YAKZ;IACHC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS,IAAK,CAACL,OAAO,IAAI,IAAK,IAAI,KAAK;IACvEM,KAAK,EAAEN,OAAO,IAAI,OAAO,IAAIA,OAAO,GAChCA,OAAO,CAACM,KAAK,GACbC,SAAS;IACbC,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,SAAS,EAAET,OAAO,EAAES,SAAS,IAA0BjC;EACzD,CAAC;AACH","ignoreList":[]}
|
|
@@ -48,13 +48,19 @@ export function useOsdkObject(...args) {
|
|
|
48
48
|
mode
|
|
49
49
|
}, observer), `object ${objectType} ${primaryKey}`), [observableClient, objectType, primaryKey, mode]);
|
|
50
50
|
const payload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
51
|
+
let error;
|
|
52
|
+
if (payload && "error" in payload && payload.error) {
|
|
53
|
+
error = payload.error;
|
|
54
|
+
} else if (payload?.status === "error") {
|
|
55
|
+
error = new Error("Failed to load object");
|
|
56
|
+
}
|
|
51
57
|
return {
|
|
52
58
|
object: payload?.object,
|
|
53
59
|
isLoading: payload?.status === "loading",
|
|
54
60
|
isOptimistic: !!payload?.isOptimistic,
|
|
55
|
-
error
|
|
61
|
+
error,
|
|
56
62
|
forceUpdate: () => {
|
|
57
|
-
throw "not implemented";
|
|
63
|
+
throw new Error("not implemented");
|
|
58
64
|
}
|
|
59
65
|
};
|
|
60
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","mode","length","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","observer","observeObject","payload","useSyncExternalStore","
|
|
1
|
+
{"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","mode","length","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","observer","observeObject","payload","useSyncExternalStore","error","status","Error","object","isLoading","isOptimistic","forceUpdate"],"sources":["useOsdkObject.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeDefinition, Osdk, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObserveObjectArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n obj: Osdk.Instance<Q>,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n ...args: [obj: Osdk.Instance<Q>] | [type: Q, primaryKey: PrimaryKeyType<Q>]\n): UseOsdkObjectResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObserveObjectArgs<Q>>(\n (observer) =>\n observableClient.observeObject(\n objectType,\n primaryKey,\n {\n mode,\n },\n observer,\n ),\n `object ${objectType} ${primaryKey}`,\n ),\n [observableClient, objectType, primaryKey, mode],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to load object\");\n }\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: payload?.status === \"loading\",\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate: () => {\n throw new Error(\"not implemented\");\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;;AAehD;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3B,GAAGC,IAAwE,EACnD;EACxB,MAAM;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EO,YAAY;IACrCL,KAAK;IACLM,WAAW,EAAEA,CAAA,KAAM;MACjB,MAAM,IAAIJ,KAAK,CAAC,iBAAiB,CAAC;IACpC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -45,10 +45,15 @@ export function useOsdkObjects(type, {
|
|
|
45
45
|
streamUpdates
|
|
46
46
|
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, type, canonWhere, dedupeIntervalMs]);
|
|
47
47
|
const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
48
|
-
|
|
48
|
+
let error;
|
|
49
|
+
if (listPayload && "error" in listPayload && listPayload.error) {
|
|
50
|
+
error = listPayload.error;
|
|
51
|
+
} else if (listPayload?.status === "error") {
|
|
52
|
+
error = new Error("Failed to load objects");
|
|
53
|
+
}
|
|
49
54
|
return {
|
|
50
55
|
fetchMore: listPayload?.fetchMore,
|
|
51
|
-
error
|
|
56
|
+
error,
|
|
52
57
|
data: listPayload?.resolvedList,
|
|
53
58
|
isLoading: listPayload?.status === "loading",
|
|
54
59
|
isOptimistic: listPayload?.isOptimistic ?? false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","observableClient","useContext","canonWhere","canonicalizeWhereClause","subscribe","getSnapShot","useMemo","observer","observeList","dedupeInterval","process","env","NODE_ENV","apiName","JSON","stringify","listPayload","useSyncExternalStore","
|
|
1
|
+
{"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","observableClient","useContext","canonWhere","canonicalizeWhereClause","subscribe","getSnapShot","useMemo","observer","observeList","dedupeInterval","process","env","NODE_ENV","apiName","JSON","stringify","listPayload","useSyncExternalStore","error","status","Error","fetchMore","data","resolvedList","isLoading","isOptimistic"],"sources":["useOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/client\";\nimport type { ObserveObjectsArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectsOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n /**\n * Standard OSDK Where\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n */\n // autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * If provided, the list will be considered this length for the purposes of\n * `invalidationMode` when using the `wait` option. If not provided,\n * the internal expectedLength will be determined by the number of times\n * `fetchMore` has been called.\n */\n // expectedLength?: number | undefined;\n\n streamUpdates?: boolean;\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n fetchMore: (() => Promise<unknown>) | undefined;\n data: Osdk.Instance<T>[] | undefined;\n isLoading: boolean;\n error: Error | undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n>(\n type: Q,\n {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n }: UseOsdkObjectsOptions<Q> = {},\n): UseOsdkListResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObserveObjectsArgs<Q>>(\n (observer) =>\n observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates,\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [observableClient, type, canonWhere, dedupeIntervalMs],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n\n return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList as Osdk.Instance<Q>[],\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AA2FhD,OAAO,SAASC,cAAcA,CAG5BC,IAAO,EACP;EACEC,QAAQ;EACRC,OAAO;EACPC,gBAAgB;EAChBC,KAAK,GAAG,CAAC,CAAC;EACVC;AACwB,CAAC,GAAG,CAAC,CAAC,EACV;EACtB,MAAM;IAAEC;EAAiB,CAAC,GAAGV,KAAK,CAACW,UAAU,CAACT,YAAY,CAAC;;EAE3D;AACF;AACA;AACA;EACE,MAAMU,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAACL,KAAK,IAAI,CAAC,CAAC,CAAC;EAExE,MAAM;IAAEM,SAAS;IAAEC;EAAY,CAAC,GAAGf,KAAK,CAACgB,OAAO,CAC9C,MACEf,iBAAiB,CACdgB,QAAQ,IACPP,gBAAgB,CAACQ,WAAW,CAAC;IAC3Bd,IAAI;IACJI,KAAK,EAAEI,UAAU;IACjBO,cAAc,EAAEZ,gBAAgB,IAAI,KAAK;IACzCF,QAAQ;IACRC,OAAO;IACPG;EACF,CAAC,EAAEQ,QAAQ,CAAC,EACdG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQlB,IAAI,CAACmB,OAAO,IAAIC,IAAI,CAACC,SAAS,CAACb,UAAU,CAAC,EAAE,GACpD,KAAK,CACX,CAAC,EACH,CAACF,gBAAgB,EAAEN,IAAI,EAAEQ,UAAU,EAAEL,gBAAgB,CACvD,CAAC;EAED,MAAMmB,WAAW,GAAG1B,KAAK,CAAC2B,oBAAoB,CAACb,SAAS,EAAEC,WAAW,CAAC;EAEtE,IAAIa,KAAwB;EAC5B,IAAIF,WAAW,IAAI,OAAO,IAAIA,WAAW,IAAIA,WAAW,CAACE,KAAK,EAAE;IAC9DA,KAAK,GAAGF,WAAW,CAACE,KAAK;EAC3B,CAAC,MAAM,IAAIF,WAAW,EAAEG,MAAM,KAAK,OAAO,EAAE;IAC1CD,KAAK,GAAG,IAAIE,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEA,OAAO;IACLC,SAAS,EAAEL,WAAW,EAAEK,SAAS;IACjCH,KAAK;IACLI,IAAI,EAAEN,WAAW,EAAEO,YAAkC;IACrDC,SAAS,EAAER,WAAW,EAAEG,MAAM,KAAK,SAAS;IAC5CM,YAAY,EAAET,WAAW,EAAES,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
export { OsdkProvider2 } from "../new/OsdkProvider2.js";
|
|
18
18
|
export { useLinks } from "../new/useLinks.js";
|
|
19
|
+
export { useObjectSet } from "../new/useObjectSet.js";
|
|
19
20
|
export { useOsdkAction } from "../new/useOsdkAction.js";
|
|
20
21
|
export { useOsdkObject } from "../new/useOsdkObject.js";
|
|
21
22
|
export { useOsdkObjects } from "../new/useOsdkObjects.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","names":["OsdkProvider2","useLinks","useOsdkAction","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata"],"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 { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\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,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"experimental.js","names":["OsdkProvider2","useLinks","useObjectSet","useOsdkAction","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useLinks } from \"../new/useLinks.js\";\nexport { useObjectSet } from \"../new/useObjectSet.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB","ignoreList":[]}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkOVBG5VXE_cjs = require('../chunk-OVBG5VXE.cjs');
|
|
4
4
|
var unstableDoNotUse = require('@osdk/client/unstable-do-not-use');
|
|
5
|
-
var
|
|
5
|
+
var React5 = require('react');
|
|
6
6
|
var client = require('@osdk/client');
|
|
7
7
|
|
|
8
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var React5__default = /*#__PURE__*/_interopDefault(React5);
|
|
11
11
|
|
|
12
12
|
function fakeClientFn(..._args) {
|
|
13
13
|
throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
|
|
@@ -15,7 +15,7 @@ function fakeClientFn(..._args) {
|
|
|
15
15
|
var fakeClient = Object.assign(fakeClientFn, {
|
|
16
16
|
fetchMetadata: fakeClientFn
|
|
17
17
|
});
|
|
18
|
-
var OsdkContext2 = /* @__PURE__ */
|
|
18
|
+
var OsdkContext2 = /* @__PURE__ */ React5__default.default.createContext({
|
|
19
19
|
client: fakeClient,
|
|
20
20
|
observableClient: void 0
|
|
21
21
|
});
|
|
@@ -26,13 +26,13 @@ function OsdkProvider2({
|
|
|
26
26
|
client,
|
|
27
27
|
observableClient
|
|
28
28
|
}) {
|
|
29
|
-
observableClient =
|
|
30
|
-
return /* @__PURE__ */
|
|
29
|
+
observableClient = React5.useMemo(() => observableClient ?? unstableDoNotUse.createObservableClient(client), [client, observableClient]);
|
|
30
|
+
return /* @__PURE__ */ React5__default.default.createElement(OsdkContext2.Provider, {
|
|
31
31
|
value: {
|
|
32
32
|
client,
|
|
33
33
|
observableClient
|
|
34
34
|
}
|
|
35
|
-
}, /* @__PURE__ */
|
|
35
|
+
}, /* @__PURE__ */ React5__default.default.createElement(chunkOVBG5VXE_cjs.OsdkContext.Provider, {
|
|
36
36
|
value: {
|
|
37
37
|
client
|
|
38
38
|
}
|
|
@@ -76,14 +76,14 @@ var emptyArray = Object.freeze([]);
|
|
|
76
76
|
function useLinks(objects, linkName, options = {}) {
|
|
77
77
|
const {
|
|
78
78
|
observableClient
|
|
79
|
-
} =
|
|
80
|
-
const objectsArray =
|
|
79
|
+
} = React5__default.default.useContext(OsdkContext2);
|
|
80
|
+
const objectsArray = React5__default.default.useMemo(() => {
|
|
81
81
|
return objects === void 0 ? emptyArray : Array.isArray(objects) ? objects : [objects];
|
|
82
82
|
}, [objects]);
|
|
83
83
|
const {
|
|
84
84
|
subscribe,
|
|
85
85
|
getSnapShot
|
|
86
|
-
} =
|
|
86
|
+
} = React5__default.default.useMemo(() => {
|
|
87
87
|
return makeExternalStore((observer) => observableClient.observeLinks(objectsArray, linkName, {
|
|
88
88
|
linkName,
|
|
89
89
|
where: options.where,
|
|
@@ -92,7 +92,7 @@ function useLinks(objects, linkName, options = {}) {
|
|
|
92
92
|
mode: options.mode
|
|
93
93
|
}, observer), `links ${linkName} for ${objectsArray.map((obj) => `${obj.$apiName}:${obj.$primaryKey}`).join(",")}`);
|
|
94
94
|
}, [observableClient, objectsArray, linkName, options.where, options.pageSize, options.orderBy, options.mode]);
|
|
95
|
-
const payload =
|
|
95
|
+
const payload = React5__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
96
96
|
return {
|
|
97
97
|
links: payload?.resolvedList,
|
|
98
98
|
isLoading: payload?.status === "loading",
|
|
@@ -102,17 +102,59 @@ function useLinks(objects, linkName, options = {}) {
|
|
|
102
102
|
hasMore: payload?.hasMore ?? false
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
|
+
function useObjectSet(baseObjectSet, options = {}) {
|
|
106
|
+
const {
|
|
107
|
+
observableClient
|
|
108
|
+
} = React5__default.default.useContext(OsdkContext2);
|
|
109
|
+
const stableKey = unstableDoNotUse.computeObjectSetCacheKey(baseObjectSet, {
|
|
110
|
+
where: options.where,
|
|
111
|
+
withProperties: options.withProperties,
|
|
112
|
+
union: options.union,
|
|
113
|
+
intersect: options.intersect,
|
|
114
|
+
subtract: options.subtract,
|
|
115
|
+
pivotTo: options.pivotTo,
|
|
116
|
+
pageSize: options.pageSize,
|
|
117
|
+
orderBy: options.orderBy
|
|
118
|
+
});
|
|
119
|
+
const {
|
|
120
|
+
subscribe,
|
|
121
|
+
getSnapShot
|
|
122
|
+
} = React5__default.default.useMemo(() => {
|
|
123
|
+
return makeExternalStore((observer) => {
|
|
124
|
+
const subscription = observableClient.observeObjectSet(baseObjectSet, {
|
|
125
|
+
where: options.where,
|
|
126
|
+
withProperties: options.withProperties,
|
|
127
|
+
union: options.union,
|
|
128
|
+
intersect: options.intersect,
|
|
129
|
+
subtract: options.subtract,
|
|
130
|
+
pivotTo: options.pivotTo,
|
|
131
|
+
pageSize: options.pageSize,
|
|
132
|
+
orderBy: options.orderBy,
|
|
133
|
+
dedupeInterval: options.dedupeIntervalMs ?? 2e3
|
|
134
|
+
}, observer);
|
|
135
|
+
return subscription;
|
|
136
|
+
}, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0);
|
|
137
|
+
}, [observableClient, stableKey]);
|
|
138
|
+
const payload = React5__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
139
|
+
return {
|
|
140
|
+
data: payload?.resolvedList,
|
|
141
|
+
isLoading: payload?.status === "loading" || !payload && true || false,
|
|
142
|
+
error: payload && "error" in payload ? payload.error : void 0,
|
|
143
|
+
fetchMore: payload?.fetchMore,
|
|
144
|
+
objectSet: payload?.objectSet || baseObjectSet
|
|
145
|
+
};
|
|
146
|
+
}
|
|
105
147
|
function useOsdkAction(actionDef) {
|
|
106
148
|
const {
|
|
107
149
|
observableClient
|
|
108
|
-
} =
|
|
109
|
-
const [error, setError] =
|
|
110
|
-
const [data, setData] =
|
|
111
|
-
const [isPending, setPending] =
|
|
112
|
-
const [isValidating, setValidating] =
|
|
113
|
-
const [validationResult, setValidationResult] =
|
|
114
|
-
const abortControllerRef =
|
|
115
|
-
const applyAction =
|
|
150
|
+
} = React5__default.default.useContext(OsdkContext2);
|
|
151
|
+
const [error, setError] = React5__default.default.useState();
|
|
152
|
+
const [data, setData] = React5__default.default.useState();
|
|
153
|
+
const [isPending, setPending] = React5__default.default.useState(false);
|
|
154
|
+
const [isValidating, setValidating] = React5__default.default.useState(false);
|
|
155
|
+
const [validationResult, setValidationResult] = React5__default.default.useState();
|
|
156
|
+
const abortControllerRef = React5__default.default.useRef(null);
|
|
157
|
+
const applyAction = React5__default.default.useCallback(async function applyAction2(hookArgs) {
|
|
116
158
|
try {
|
|
117
159
|
if (isValidating && abortControllerRef.current) {
|
|
118
160
|
abortControllerRef.current.abort();
|
|
@@ -166,7 +208,7 @@ function useOsdkAction(actionDef) {
|
|
|
166
208
|
setPending(false);
|
|
167
209
|
}
|
|
168
210
|
}, [observableClient, actionDef, isValidating]);
|
|
169
|
-
const validateAction =
|
|
211
|
+
const validateAction = React5__default.default.useCallback(async function validateAction2(args) {
|
|
170
212
|
try {
|
|
171
213
|
if (isPending) {
|
|
172
214
|
return void 0;
|
|
@@ -202,7 +244,7 @@ function useOsdkAction(actionDef) {
|
|
|
202
244
|
setValidating(false);
|
|
203
245
|
}
|
|
204
246
|
}, [observableClient, actionDef, isPending]);
|
|
205
|
-
|
|
247
|
+
React5__default.default.useEffect(() => {
|
|
206
248
|
return () => {
|
|
207
249
|
if (abortControllerRef.current) {
|
|
208
250
|
abortControllerRef.current.abort();
|
|
@@ -222,24 +264,30 @@ function useOsdkAction(actionDef) {
|
|
|
222
264
|
function useOsdkObject(...args) {
|
|
223
265
|
const {
|
|
224
266
|
observableClient
|
|
225
|
-
} =
|
|
267
|
+
} = React5__default.default.useContext(OsdkContext2);
|
|
226
268
|
const mode = args.length === 1 ? "offline" : void 0;
|
|
227
269
|
const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;
|
|
228
270
|
const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];
|
|
229
271
|
const {
|
|
230
272
|
subscribe,
|
|
231
273
|
getSnapShot
|
|
232
|
-
} =
|
|
274
|
+
} = React5__default.default.useMemo(() => makeExternalStore((observer) => observableClient.observeObject(objectType, primaryKey, {
|
|
233
275
|
mode
|
|
234
276
|
}, observer)), [observableClient, objectType, primaryKey, mode]);
|
|
235
|
-
const payload =
|
|
277
|
+
const payload = React5__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
278
|
+
let error;
|
|
279
|
+
if (payload && "error" in payload && payload.error) {
|
|
280
|
+
error = payload.error;
|
|
281
|
+
} else if (payload?.status === "error") {
|
|
282
|
+
error = new Error("Failed to load object");
|
|
283
|
+
}
|
|
236
284
|
return {
|
|
237
285
|
object: payload?.object,
|
|
238
286
|
isLoading: payload?.status === "loading",
|
|
239
287
|
isOptimistic: !!payload?.isOptimistic,
|
|
240
|
-
error
|
|
288
|
+
error,
|
|
241
289
|
forceUpdate: () => {
|
|
242
|
-
throw "not implemented";
|
|
290
|
+
throw new Error("not implemented");
|
|
243
291
|
}
|
|
244
292
|
};
|
|
245
293
|
}
|
|
@@ -252,12 +300,12 @@ function useOsdkObjects(type, {
|
|
|
252
300
|
} = {}) {
|
|
253
301
|
const {
|
|
254
302
|
observableClient
|
|
255
|
-
} =
|
|
303
|
+
} = React5__default.default.useContext(OsdkContext2);
|
|
256
304
|
const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});
|
|
257
305
|
const {
|
|
258
306
|
subscribe,
|
|
259
307
|
getSnapShot
|
|
260
|
-
} =
|
|
308
|
+
} = React5__default.default.useMemo(() => makeExternalStore((observer) => observableClient.observeList({
|
|
261
309
|
type,
|
|
262
310
|
where: canonWhere,
|
|
263
311
|
dedupeInterval: dedupeIntervalMs ?? 2e3,
|
|
@@ -265,10 +313,16 @@ function useOsdkObjects(type, {
|
|
|
265
313
|
orderBy,
|
|
266
314
|
streamUpdates
|
|
267
315
|
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, type, canonWhere, dedupeIntervalMs]);
|
|
268
|
-
const listPayload =
|
|
316
|
+
const listPayload = React5__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
317
|
+
let error;
|
|
318
|
+
if (listPayload && "error" in listPayload && listPayload.error) {
|
|
319
|
+
error = listPayload.error;
|
|
320
|
+
} else if (listPayload?.status === "error") {
|
|
321
|
+
error = new Error("Failed to load objects");
|
|
322
|
+
}
|
|
269
323
|
return {
|
|
270
324
|
fetchMore: listPayload?.fetchMore,
|
|
271
|
-
error
|
|
325
|
+
error,
|
|
272
326
|
data: listPayload?.resolvedList,
|
|
273
327
|
isLoading: listPayload?.status === "loading",
|
|
274
328
|
isOptimistic: listPayload?.isOptimistic ?? false
|
|
@@ -285,6 +339,7 @@ Object.defineProperty(exports, "useOsdkMetadata", {
|
|
|
285
339
|
});
|
|
286
340
|
exports.OsdkProvider2 = OsdkProvider2;
|
|
287
341
|
exports.useLinks = useLinks;
|
|
342
|
+
exports.useObjectSet = useObjectSet;
|
|
288
343
|
exports.useOsdkAction = useOsdkAction;
|
|
289
344
|
exports.useOsdkObject = useOsdkObject;
|
|
290
345
|
exports.useOsdkObjects = useOsdkObjects;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/new/OsdkContext2.ts","../../../src/new/OsdkProvider2.tsx","../../../src/new/makeExternalStore.ts","../../../src/new/useLinks.ts","../../../src/new/useOsdkAction.ts","../../../src/new/useOsdkObject.ts","../../../src/new/useOsdkObjects.ts"],"names":["useMemo","createObservableClient","React","OsdkContext","applyAction","args","ActionValidationError","validateAction"],"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;AACM,IAAM,YAAA,2CAAkC,aAAc,CAAA;AAAA,EAC3D,MAAQ,EAAA,UAAA;AAAA,EACR,gBAAkB,EAAA;AACpB,CAAC,CAAA;;;ACNM,SAAS,aAAc,CAAA;AAAA,EAC5B,QAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAG,EAAA;AACD,EAAmB,gBAAA,GAAAA,cAAA,CAAQ,MAAM,gBAAoB,IAAAC,uCAAA,CAAuB,MAAM,CAAG,EAAA,CAAC,MAAQ,EAAA,gBAAgB,CAAC,CAAA;AAC/G,EAAA,uBAAoBC,uBAAAA,CAAM,aAAc,CAAA,YAAA,CAAa,QAAU,EAAA;AAAA,IAC7D,KAAO,EAAA;AAAA,MACL,MAAA;AAAA,MACA;AAAA;AACF,GACc,kBAAAA,uBAAM,CAAA,aA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;AACN,EAAM,MAAA;AAAA,IACJ;AAAA,GACF,GAAIA,uBAAM,CAAA,UAAA,CAAW,YAAY,CAAA;AAMjC,EAAA,MAAM,UAAa,GAAA,gBAAA,CAAiB,uBAAwB,CAAA,KAAA,IAAS,EAAE,CAAA;AACvE,EAAM,MAAA;AAAA,IACJ,SAAA;AAAA,IACA;AAAA,MACEA,uBAAM,CAAA,OAAA,CAAQ,MAAM,iBAAkB,CAAA,CAAA,QAAA,KAAY,iBAAiB,WAAY,CAAA;AAAA,IACjF,IAAA;AAAA,IACA,KAAO,EAAA,UAAA;AAAA,IACP,gBAAgB,gBAAoB,IAAA,GAAA;AAAA,IACpC,QAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF,EAAG,QAAQ,CAAG,EAAA,OAAA,CAAQ,IAAI,QAAa,KAAA,YAAA,GAAe,CAAQ,KAAA,EAAA,IAAA,CAAK,OAAO,CAAA,CAAA,EAAI,KAAK,SAAU,CAAA,UAAU,CAAC,CAAA,CAAA,GAAK,MAAM,CAAA,EAAG,CAAC,gBAAkB,EAAA,IAAA,EAAM,UAAY,EAAA,gBAAgB,CAAC,CAAA;AAC5K,EAAA,MAAM,WAAcA,GAAAA,uBAAAA,CAAM,oBAAqB,CAAA,SAAA,EAAW,WAAW,CAAA;AAErE,EAAO,OAAA;AAAA,IACL,WAAW,WAAa,EAAA,SAAA;AAAA,IACxB,KAAO,EAAA,WAAA,IAAe,OAAW,IAAA,WAAA,GAAc,aAAa,KAAQ,GAAA,MAAA;AAAA,IACpE,MAAM,WAAa,EAAA,YAAA;AAAA,IACnB,SAAA,EAAW,aAAa,MAAW,KAAA,SAAA;AAAA,IACnC,YAAA,EAAc,aAAa,YAAgB,IAAA;AAAA,GAC7C;AACF","file":"experimental.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 OsdkContext2 = /*#__PURE__*/React.createContext({\n client: fakeClient,\n observableClient: undefined\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 { createObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React, { useMemo } from \"react\";\nimport { OsdkContext } from \"../OsdkContext.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function OsdkProvider2({\n children,\n client,\n observableClient\n}) {\n observableClient = useMemo(() => observableClient ?? createObservableClient(client), [client, observableClient]);\n return /*#__PURE__*/React.createElement(OsdkContext2.Provider, {\n value: {\n client,\n observableClient\n }\n }, /*#__PURE__*/React.createElement(OsdkContext.Provider, {\n value: {\n client\n }\n }, children));\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) {\n let lastResult;\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 * 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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nconst emptyArray = Object.freeze([]);\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks(objects, linkName, options = {}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n // Convert single object to array for consistent handling\n const objectsArray = React.useMemo(() => {\n return objects === undefined ? emptyArray : Array.isArray(objects) ? objects : [objects];\n }, [objects]);\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n return makeExternalStore(observer => observableClient.observeLinks(objectsArray, linkName, {\n linkName,\n where: options.where,\n pageSize: options.pageSize,\n orderBy: options.orderBy,\n mode: options.mode\n }, observer), `links ${linkName} for ${objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\",\")}`);\n }, [observableClient, objectsArray, linkName, options.where, options.pageSize, options.orderBy, options.mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n links: payload?.resolvedList,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n error: payload?.error,\n fetchMore: payload?.fetchMore,\n hasMore: payload?.hasMore ?? false\n };\n}","/*\n * 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 { ActionValidationError } from \"@osdk/client\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function useOsdkAction(actionDef) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState();\n const [data, setData] = React.useState();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState();\n const abortControllerRef = React.useRef(null);\n const applyAction = React.useCallback(async function applyAction(hookArgs) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n setPending(true);\n setError(undefined);\n if (Array.isArray(hookArgs)) {\n const updates = [];\n const args = hookArgs.map(a => {\n const {\n $optimisticUpdate,\n ...args\n } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: ctx => {\n for (const update of updates) {\n update?.(ctx);\n }\n }\n });\n setData(r);\n return r;\n } else {\n const {\n $optimisticUpdate,\n ...args\n } = hookArgs;\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e\n });\n } else {\n setError({\n unknown: e\n });\n }\n } finally {\n setPending(false);\n }\n }, [observableClient, actionDef, isValidating]);\n const validateAction = React.useCallback(async function validateAction(args) {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n setValidating(true);\n setError(undefined);\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e\n });\n } else {\n setError({\n unknown: e\n });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n }, [observableClient, actionDef, isPending]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n };\n }, []);\n return {\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult\n };\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\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n */\n\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\n\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject(...args) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(observer => observableClient.observeObject(objectType, primaryKey, {\n mode\n }, observer), `object ${objectType} ${primaryKey}`), [observableClient, objectType, primaryKey, mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n object: payload?.object,\n isLoading: payload?.status === \"loading\",\n isOptimistic: !!payload?.isOptimistic,\n error: payload && \"error\" in payload ? payload.error : undefined,\n forceUpdate: () => {\n throw \"not implemented\";\n }\n };\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\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function useOsdkObjects(type, {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates\n} = {}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(observer => observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates\n }, observer), process.env.NODE_ENV !== \"production\" ? `list ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, type, canonWhere, dedupeIntervalMs]);\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n // TODO: we need to expose the error in the result\n return {\n fetchMore: listPayload?.fetchMore,\n error: listPayload && \"error\" in listPayload ? listPayload?.error : undefined,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false\n };\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/new/OsdkContext2.ts","../../../src/new/OsdkProvider2.tsx","../../../src/new/makeExternalStore.ts","../../../src/new/useLinks.ts","../../../src/new/useObjectSet.tsx","../../../src/new/useOsdkAction.ts","../../../src/new/useOsdkObject.ts","../../../src/new/useOsdkObjects.ts"],"names":["useMemo","createObservableClient","React","OsdkContext","computeObjectSetCacheKey","applyAction","args","ActionValidationError","validateAction"],"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;AACM,IAAM,YAAA,2CAAkC,aAAc,CAAA;AAAA,EAC3D,MAAQ,EAAA,UAAA;AAAA,EACR,gBAAkB,EAAA;AACpB,CAAC,CAAA;;;ACNM,SAAS,aAAc,CAAA;AAAA,EAC5B,QAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAG,EAAA;AACD,EAAmB,gBAAA,GAAAA,cAAA,CAAQ,MAAM,gBAAoB,IAAAC,uCAAA,CAAu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,EAAA,UAAA;AAAA,IACP,gBAAgB,gBAAoB,IAAA,GAAA;AAAA,IACpC,QAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF,EAAG,QAAQ,CAAG,EAAA,OAAA,CAAQ,IAAI,QAAa,KAAA,YAAA,GAAe,CAAQ,KAAA,EAAA,IAAA,CAAK,OAAO,CAAA,CAAA,EAAI,KAAK,SAAU,CAAA,UAAU,CAAC,CAAA,CAAA,GAAK,MAAM,CAAA,EAAG,CAAC,gBAAkB,EAAA,IAAA,EAAM,UAAY,EAAA,gBAAgB,CAAC,CAAA;AAC5K,EAAA,MAAM,WAAcA,GAAAA,uBAAAA,CAAM,oBAAqB,CAAA,SAAA,EAAW,WAAW,CAAA;AACrE,EAAI,IAAA,KAAA;AACJ,EAAA,IAAI,WAAe,IAAA,OAAA,IAAW,WAAe,IAAA,WAAA,CAAY,KAAO,EAAA;AAC9D,IAAA,KAAA,GAAQ,WAAY,CAAA,KAAA;AAAA,GACtB,MAAA,IAAW,WAAa,EAAA,MAAA,KAAW,OAAS,EAAA;AAC1C,IAAQ,KAAA,GAAA,IAAI,MAAM,wBAAwB,CAAA;AAAA;AAE5C,EAAO,OAAA;AAAA,IACL,WAAW,WAAa,EAAA,SAAA;AAAA,IACxB,KAAA;AAAA,IACA,MAAM,WAAa,EAAA,YAAA;AAAA,IACnB,SAAA,EAAW,aAAa,MAAW,KAAA,SAAA;AAAA,IACnC,YAAA,EAAc,aAAa,YAAgB,IAAA;AAAA,GAC7C;AACF","file":"experimental.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 OsdkContext2 = /*#__PURE__*/React.createContext({\n client: fakeClient,\n observableClient: undefined\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 { createObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React, { useMemo } from \"react\";\nimport { OsdkContext } from \"../OsdkContext.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function OsdkProvider2({\n children,\n client,\n observableClient\n}) {\n observableClient = useMemo(() => observableClient ?? createObservableClient(client), [client, observableClient]);\n return /*#__PURE__*/React.createElement(OsdkContext2.Provider, {\n value: {\n client,\n observableClient\n }\n }, /*#__PURE__*/React.createElement(OsdkContext.Provider, {\n value: {\n client\n }\n }, children));\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) {\n let lastResult;\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 * 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 React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nconst emptyArray = Object.freeze([]);\n\n/**\n * Hook to observe links from an object or array of objects.\n *\n * @param objects The source object(s) to observe links from\n * @param linkName The name of the link to observe\n * @param options Optional configuration for the link query\n * @returns UseLinksResult with links data and metadata\n */\nexport function useLinks(objects, linkName, options = {}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n // Convert single object to array for consistent handling\n const objectsArray = React.useMemo(() => {\n return objects === undefined ? emptyArray : Array.isArray(objects) ? objects : [objects];\n }, [objects]);\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n return makeExternalStore(observer => observableClient.observeLinks(objectsArray, linkName, {\n linkName,\n where: options.where,\n pageSize: options.pageSize,\n orderBy: options.orderBy,\n mode: options.mode\n }, observer), `links ${linkName} for ${objectsArray.map(obj => `${obj.$apiName}:${obj.$primaryKey}`).join(\",\")}`);\n }, [observableClient, objectsArray, linkName, options.where, options.pageSize, options.orderBy, options.mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n links: payload?.resolvedList,\n isLoading: payload?.status === \"loading\",\n isOptimistic: payload?.isOptimistic ?? false,\n error: payload?.error,\n fetchMore: payload?.fetchMore,\n hasMore: payload?.hasMore ?? false\n };\n}","/*\n * 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 { computeObjectSetCacheKey } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet(baseObjectSet, options = {}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs is excluded as it doesn't affect the data, only the refresh rate\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: options.where,\n withProperties: options.withProperties,\n union: options.union,\n intersect: options.intersect,\n subtract: options.subtract,\n pivotTo: options.pivotTo,\n pageSize: options.pageSize,\n orderBy: options.orderBy\n });\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => {\n return makeExternalStore(observer => {\n const subscription = observableClient.observeObjectSet(baseObjectSet, {\n where: options.where,\n withProperties: options.withProperties,\n union: options.union,\n intersect: options.intersect,\n subtract: options.subtract,\n pivotTo: options.pivotTo,\n pageSize: options.pageSize,\n orderBy: options.orderBy,\n dedupeInterval: options.dedupeIntervalMs ?? 2_000\n }, observer);\n return subscription;\n }, process.env.NODE_ENV !== \"production\" ? `objectSet ${stableKey}` : void 0);\n }, [observableClient, stableKey]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n return {\n data: payload?.resolvedList,\n isLoading: payload?.status === \"loading\" || !payload && true || false,\n error: payload && \"error\" in payload ? payload.error : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet || baseObjectSet\n };\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\nimport { ActionValidationError } from \"@osdk/client\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function useOsdkAction(actionDef) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState();\n const [data, setData] = React.useState();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState();\n const abortControllerRef = React.useRef(null);\n const applyAction = React.useCallback(async function applyAction(hookArgs) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n setPending(true);\n setError(undefined);\n if (Array.isArray(hookArgs)) {\n const updates = [];\n const args = hookArgs.map(a => {\n const {\n $optimisticUpdate,\n ...args\n } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: ctx => {\n for (const update of updates) {\n update?.(ctx);\n }\n }\n });\n setData(r);\n return r;\n } else {\n const {\n $optimisticUpdate,\n ...args\n } = hookArgs;\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e\n });\n } else {\n setError({\n unknown: e\n });\n }\n } finally {\n setPending(false);\n }\n }, [observableClient, actionDef, isValidating]);\n const validateAction = React.useCallback(async function validateAction(args) {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n setValidating(true);\n setError(undefined);\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e\n });\n } else {\n setError({\n unknown: e\n });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n }, [observableClient, actionDef, isPending]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n };\n }, []);\n return {\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult\n };\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\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n */\n\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\n\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject(...args) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(observer => observableClient.observeObject(objectType, primaryKey, {\n mode\n }, observer), `object ${objectType} ${primaryKey}`), [observableClient, objectType, primaryKey, mode]);\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n let error;\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 return {\n object: payload?.object,\n isLoading: payload?.status === \"loading\",\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate: () => {\n throw new Error(\"not implemented\");\n }\n };\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\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\nexport function useOsdkObjects(type, {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates\n} = {}) {\n const {\n observableClient\n } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});\n const {\n subscribe,\n getSnapShot\n } = React.useMemo(() => makeExternalStore(observer => observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates\n }, observer), process.env.NODE_ENV !== \"production\" ? `list ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, type, canonWhere, dedupeIntervalMs]);\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n let error;\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 return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList,\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false\n };\n}"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Client, ObjectTypeDefinition, Osdk, InterfaceDefinition, WhereClause, PropertyKeys, ActionDefinition, ActionValidationError, ActionValidationResponse } from '@osdk/client';
|
|
2
2
|
import { ObservableClient, ActionSignatureFromDef } from '@osdk/client/unstable-do-not-use';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { LinkNames, LinkedType, ObjectTypeDefinition as ObjectTypeDefinition$1, Osdk as Osdk$1, PrimaryKeyType } from '@osdk/api';
|
|
4
|
+
import { LinkNames, LinkedType, ObjectTypeDefinition as ObjectTypeDefinition$1, WirePropertyTypes, ObjectSet, WhereClause as WhereClause$1, DerivedProperty, PropertyKeys as PropertyKeys$1, Osdk as Osdk$1, PrimaryKeyType } from '@osdk/api';
|
|
5
5
|
export { U as UseOsdkMetadataResult, u as useOsdkClient, a as useOsdkMetadata } from '../useOsdkMetadata-DFZhnhGZ.cjs';
|
|
6
6
|
|
|
7
7
|
interface OsdkProviderOptions {
|
|
@@ -59,6 +59,84 @@ interface UseLinksResult<Q extends ObjectTypeDefinition | InterfaceDefinition> {
|
|
|
59
59
|
*/
|
|
60
60
|
declare function useLinks<T extends ObjectTypeDefinition, L extends LinkNames<T>>(objects: Osdk.Instance<T> | Array<Osdk.Instance<T>> | undefined, linkName: L, options?: UseLinksOptions<LinkedType<T, L>>): UseLinksResult<LinkedType<T, L>>;
|
|
61
61
|
|
|
62
|
+
type SimplePropertyDef = WirePropertyTypes | undefined | Array<WirePropertyTypes>;
|
|
63
|
+
interface UseObjectSetOptions<Q extends ObjectTypeDefinition$1, RDPs extends Record<string, SimplePropertyDef> = {}> {
|
|
64
|
+
/**
|
|
65
|
+
* Where clause for filtering
|
|
66
|
+
*/
|
|
67
|
+
where?: WhereClause$1<Q>;
|
|
68
|
+
/**
|
|
69
|
+
* Derived properties to add to the object set
|
|
70
|
+
*/
|
|
71
|
+
withProperties?: {
|
|
72
|
+
[K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Object sets to union with
|
|
76
|
+
*/
|
|
77
|
+
union?: ObjectSet<Q>[];
|
|
78
|
+
/**
|
|
79
|
+
* Object sets to intersect with
|
|
80
|
+
*/
|
|
81
|
+
intersect?: ObjectSet<Q>[];
|
|
82
|
+
/**
|
|
83
|
+
* Object sets to subtract from
|
|
84
|
+
*/
|
|
85
|
+
subtract?: ObjectSet<Q>[];
|
|
86
|
+
/**
|
|
87
|
+
* Link to pivot to (changes the type)
|
|
88
|
+
*/
|
|
89
|
+
pivotTo?: LinkNames<Q>;
|
|
90
|
+
/**
|
|
91
|
+
* The preferred page size for the list
|
|
92
|
+
*/
|
|
93
|
+
pageSize?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Sort order for the results
|
|
96
|
+
*/
|
|
97
|
+
orderBy?: {
|
|
98
|
+
[K in PropertyKeys$1<Q>]?: "asc" | "desc";
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Minimum time between fetch requests in milliseconds (defaults to 2000ms)
|
|
102
|
+
*/
|
|
103
|
+
dedupeIntervalMs?: number;
|
|
104
|
+
}
|
|
105
|
+
interface UseObjectSetResult<Q extends ObjectTypeDefinition$1, RDPs extends Record<string, SimplePropertyDef> = {}> {
|
|
106
|
+
/**
|
|
107
|
+
* The fetched data with derived properties
|
|
108
|
+
*/
|
|
109
|
+
data: Osdk$1.Instance<Q, "$allBaseProperties", PropertyKeys$1<Q>, RDPs>[] | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* Whether data is currently being loaded
|
|
112
|
+
*/
|
|
113
|
+
isLoading: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Any error that occurred during fetching
|
|
116
|
+
*/
|
|
117
|
+
error: Error | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Function to fetch more pages (undefined if no more pages)
|
|
120
|
+
*/
|
|
121
|
+
fetchMore: (() => Promise<void>) | undefined;
|
|
122
|
+
/**
|
|
123
|
+
* The final ObjectSet after all transformations
|
|
124
|
+
*/
|
|
125
|
+
objectSet: ObjectSet<Q, RDPs>;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* React hook for observing and interacting with OSDK object sets.
|
|
129
|
+
*
|
|
130
|
+
* @typeParam Q - The object type definition
|
|
131
|
+
* @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet
|
|
132
|
+
* @typeParam RDPs - New derived properties to be added via options.withProperties
|
|
133
|
+
*
|
|
134
|
+
* @param baseObjectSet - The ObjectSet to observe (may already have derived properties)
|
|
135
|
+
* @param options - Options for filtering, sorting, and adding new derived properties
|
|
136
|
+
* @returns Object set data with both existing and new derived properties
|
|
137
|
+
*/
|
|
138
|
+
declare function useObjectSet<Q extends ObjectTypeDefinition$1, BaseRDPs extends Record<string, SimplePropertyDef> = never, RDPs extends Record<string, SimplePropertyDef> = {}>(baseObjectSet: ObjectSet<Q, BaseRDPs>, options?: UseObjectSetOptions<Q, RDPs>): UseObjectSetResult<Q, RDPs>;
|
|
139
|
+
|
|
62
140
|
type ApplyActionParams<Q extends ActionDefinition<any>> = Parameters<ActionSignatureFromDef<Q>["applyAction"]>[0] & {
|
|
63
141
|
[K in keyof ObservableClient.ApplyActionOptions as `$${K}`]: ObservableClient.ApplyActionOptions[K];
|
|
64
142
|
};
|
|
@@ -173,4 +251,4 @@ interface UseOsdkListResult<T extends ObjectTypeDefinition | InterfaceDefinition
|
|
|
173
251
|
}
|
|
174
252
|
declare function useOsdkObjects<Q extends ObjectTypeDefinition | InterfaceDefinition>(type: Q, { pageSize, orderBy, dedupeIntervalMs, where, streamUpdates, }?: UseOsdkObjectsOptions<Q>): UseOsdkListResult<Q>;
|
|
175
253
|
|
|
176
|
-
export { OsdkProvider2, type UseOsdkListResult, useLinks, useOsdkAction, useOsdkObject, useOsdkObjects };
|
|
254
|
+
export { OsdkProvider2, type UseOsdkListResult, useLinks, useObjectSet, useOsdkAction, useOsdkObject, useOsdkObjects };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { computeObjectSetCacheKey } from "@osdk/client/unstable-do-not-use";
|
|
18
|
+
import React from "react";
|
|
19
|
+
import { makeExternalStore } from "./makeExternalStore.js";
|
|
20
|
+
import { OsdkContext2 } from "./OsdkContext2.js";
|
|
21
|
+
/**
|
|
22
|
+
* React hook for observing and interacting with OSDK object sets.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam Q - The object type definition
|
|
25
|
+
* @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet
|
|
26
|
+
* @typeParam RDPs - New derived properties to be added via options.withProperties
|
|
27
|
+
*
|
|
28
|
+
* @param baseObjectSet - The ObjectSet to observe (may already have derived properties)
|
|
29
|
+
* @param options - Options for filtering, sorting, and adding new derived properties
|
|
30
|
+
* @returns Object set data with both existing and new derived properties
|
|
31
|
+
*/
|
|
32
|
+
export function useObjectSet(baseObjectSet, options = {}) {
|
|
33
|
+
const {
|
|
34
|
+
observableClient
|
|
35
|
+
} = React.useContext(OsdkContext2);
|
|
36
|
+
|
|
37
|
+
// Compute a stable cache key for the ObjectSet and options
|
|
38
|
+
// dedupeIntervalMs is excluded as it doesn't affect the data, only the refresh rate
|
|
39
|
+
const stableKey = computeObjectSetCacheKey(baseObjectSet, {
|
|
40
|
+
where: options.where,
|
|
41
|
+
withProperties: options.withProperties,
|
|
42
|
+
union: options.union,
|
|
43
|
+
intersect: options.intersect,
|
|
44
|
+
subtract: options.subtract,
|
|
45
|
+
pivotTo: options.pivotTo,
|
|
46
|
+
pageSize: options.pageSize,
|
|
47
|
+
orderBy: options.orderBy
|
|
48
|
+
});
|
|
49
|
+
const {
|
|
50
|
+
subscribe,
|
|
51
|
+
getSnapShot
|
|
52
|
+
} = React.useMemo(() => {
|
|
53
|
+
return makeExternalStore(observer => {
|
|
54
|
+
const subscription = observableClient.observeObjectSet(baseObjectSet, {
|
|
55
|
+
where: options.where,
|
|
56
|
+
withProperties: options.withProperties,
|
|
57
|
+
union: options.union,
|
|
58
|
+
intersect: options.intersect,
|
|
59
|
+
subtract: options.subtract,
|
|
60
|
+
pivotTo: options.pivotTo,
|
|
61
|
+
pageSize: options.pageSize,
|
|
62
|
+
orderBy: options.orderBy,
|
|
63
|
+
dedupeInterval: options.dedupeIntervalMs ?? 2_000
|
|
64
|
+
}, observer);
|
|
65
|
+
return subscription;
|
|
66
|
+
}, process.env.NODE_ENV !== "production" ? `objectSet ${stableKey}` : void 0);
|
|
67
|
+
}, [observableClient, stableKey]);
|
|
68
|
+
const payload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
69
|
+
return {
|
|
70
|
+
data: payload?.resolvedList,
|
|
71
|
+
isLoading: payload?.status === "loading" || !payload && true || false,
|
|
72
|
+
error: payload && "error" in payload ? payload.error : undefined,
|
|
73
|
+
fetchMore: payload?.fetchMore,
|
|
74
|
+
objectSet: payload?.objectSet || baseObjectSet
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=useObjectSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useObjectSet.js","names":["computeObjectSetCacheKey","React","makeExternalStore","OsdkContext2","useObjectSet","baseObjectSet","options","observableClient","useContext","stableKey","where","withProperties","union","intersect","subtract","pivotTo","pageSize","orderBy","subscribe","getSnapShot","useMemo","observer","subscription","observeObjectSet","dedupeInterval","dedupeIntervalMs","process","env","NODE_ENV","payload","useSyncExternalStore","data","resolvedList","isLoading","status","error","undefined","fetchMore","objectSet"],"sources":["useObjectSet.tsx"],"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 LinkNames,\n ObjectSet,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n WirePropertyTypes,\n} from \"@osdk/api\";\n\nimport {\n computeObjectSetCacheKey,\n type ObserveObjectSetArgs,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype SimplePropertyDef =\n | WirePropertyTypes\n | undefined\n | Array<WirePropertyTypes>;\n\nexport interface UseObjectSetOptions<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Where clause for filtering\n */\n where?: WhereClause<Q>;\n\n /**\n * Derived properties to add to the object set\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]> };\n\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n\n /**\n * Link to pivot to (changes the type)\n */\n pivotTo?: LinkNames<Q>;\n\n /**\n * The preferred page size for the list\n */\n pageSize?: number;\n\n /**\n * Sort order for the results\n */\n orderBy?: {\n [K in PropertyKeys<Q>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Minimum time between fetch requests in milliseconds (defaults to 2000ms)\n */\n dedupeIntervalMs?: number;\n}\n\nexport interface UseObjectSetResult<\n Q extends ObjectTypeDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The final ObjectSet after all transformations\n */\n objectSet: ObjectSet<Q, RDPs>;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\n/**\n * React hook for observing and interacting with OSDK object sets.\n *\n * @typeParam Q - The object type definition\n * @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet\n * @typeParam RDPs - New derived properties to be added via options.withProperties\n *\n * @param baseObjectSet - The ObjectSet to observe (may already have derived properties)\n * @param options - Options for filtering, sorting, and adding new derived properties\n * @returns Object set data with both existing and new derived properties\n */\nexport function useObjectSet<\n Q extends ObjectTypeDefinition,\n BaseRDPs extends Record<string, SimplePropertyDef> = never,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n baseObjectSet: ObjectSet<Q, BaseRDPs>,\n options: UseObjectSetOptions<Q, RDPs> = {},\n): UseObjectSetResult<Q, RDPs> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // Compute a stable cache key for the ObjectSet and options\n // dedupeIntervalMs is excluded as it doesn't affect the data, only the refresh rate\n const stableKey = computeObjectSetCacheKey(baseObjectSet, {\n where: options.where,\n withProperties: options.withProperties,\n union: options.union,\n intersect: options.intersect,\n subtract: options.subtract,\n pivotTo: options.pivotTo,\n pageSize: options.pageSize,\n orderBy: options.orderBy,\n });\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n return makeExternalStore<ObserveObjectSetArgs<Q, RDPs>>(\n (observer) => {\n const subscription = observableClient.observeObjectSet(\n baseObjectSet as ObjectSet<Q>,\n {\n where: options.where,\n withProperties: options.withProperties,\n union: options.union,\n intersect: options.intersect,\n subtract: options.subtract,\n pivotTo: options.pivotTo,\n pageSize: options.pageSize,\n orderBy: options.orderBy,\n dedupeInterval: options.dedupeIntervalMs ?? 2_000,\n },\n observer,\n );\n return subscription;\n },\n process.env.NODE_ENV !== \"production\"\n ? `objectSet ${stableKey}`\n : void 0,\n );\n },\n [observableClient, stableKey],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return {\n data: payload?.resolvedList as Osdk.Instance<\n Q,\n \"$allBaseProperties\",\n PropertyKeys<Q>,\n RDPs\n >[],\n isLoading: payload?.status === \"loading\" || (!payload && true) || false,\n error: payload && \"error\" in payload\n ? payload.error\n : undefined,\n fetchMore: payload?.fetchMore,\n objectSet: payload?.objectSet as ObjectSet<Q, RDPs> || baseObjectSet,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,SACEA,wBAAwB,QAEnB,kCAAkC;AACzC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AAiGhD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAK1BC,aAAqC,EACrCC,OAAqC,GAAG,CAAC,CAAC,EACb;EAC7B,MAAM;IAAEC;EAAiB,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,YAAY,CAAC;;EAE3D;EACA;EACA,MAAMM,SAAS,GAAGT,wBAAwB,CAACK,aAAa,EAAE;IACxDK,KAAK,EAAEJ,OAAO,CAACI,KAAK;IACpBC,cAAc,EAAEL,OAAO,CAACK,cAAc;IACtCC,KAAK,EAAEN,OAAO,CAACM,KAAK;IACpBC,SAAS,EAAEP,OAAO,CAACO,SAAS;IAC5BC,QAAQ,EAAER,OAAO,CAACQ,QAAQ;IAC1BC,OAAO,EAAET,OAAO,CAACS,OAAO;IACxBC,QAAQ,EAAEV,OAAO,CAACU,QAAQ;IAC1BC,OAAO,EAAEX,OAAO,CAACW;EACnB,CAAC,CAAC;EAEF,MAAM;IAAEC,SAAS;IAAEC;EAAY,CAAC,GAAGlB,KAAK,CAACmB,OAAO,CAC9C,MAAM;IACJ,OAAOlB,iBAAiB,CACrBmB,QAAQ,IAAK;MACZ,MAAMC,YAAY,GAAGf,gBAAgB,CAACgB,gBAAgB,CACpDlB,aAAa,EACb;QACEK,KAAK,EAAEJ,OAAO,CAACI,KAAK;QACpBC,cAAc,EAAEL,OAAO,CAACK,cAAc;QACtCC,KAAK,EAAEN,OAAO,CAACM,KAAK;QACpBC,SAAS,EAAEP,OAAO,CAACO,SAAS;QAC5BC,QAAQ,EAAER,OAAO,CAACQ,QAAQ;QAC1BC,OAAO,EAAET,OAAO,CAACS,OAAO;QACxBC,QAAQ,EAAEV,OAAO,CAACU,QAAQ;QAC1BC,OAAO,EAAEX,OAAO,CAACW,OAAO;QACxBO,cAAc,EAAElB,OAAO,CAACmB,gBAAgB,IAAI;MAC9C,CAAC,EACDJ,QACF,CAAC;MACD,OAAOC,YAAY;IACrB,CAAC,EACDI,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,aAAanB,SAAS,EAAE,GACxB,KAAK,CACX,CAAC;EACH,CAAC,EACD,CAACF,gBAAgB,EAAEE,SAAS,CAC9B,CAAC;EAED,MAAMoB,OAAO,GAAG5B,KAAK,CAAC6B,oBAAoB,CAACZ,SAAS,EAAEC,WAAW,CAAC;EAElE,OAAO;IACLY,IAAI,EAAEF,OAAO,EAAEG,YAKZ;IACHC,SAAS,EAAEJ,OAAO,EAAEK,MAAM,KAAK,SAAS,IAAK,CAACL,OAAO,IAAI,IAAK,IAAI,KAAK;IACvEM,KAAK,EAAEN,OAAO,IAAI,OAAO,IAAIA,OAAO,GAChCA,OAAO,CAACM,KAAK,GACbC,SAAS;IACbC,SAAS,EAAER,OAAO,EAAEQ,SAAS;IAC7BC,SAAS,EAAET,OAAO,EAAES,SAAS,IAA0BjC;EACzD,CAAC;AACH","ignoreList":[]}
|
|
@@ -48,13 +48,19 @@ export function useOsdkObject(...args) {
|
|
|
48
48
|
mode
|
|
49
49
|
}, observer), `object ${objectType} ${primaryKey}`), [observableClient, objectType, primaryKey, mode]);
|
|
50
50
|
const payload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
51
|
+
let error;
|
|
52
|
+
if (payload && "error" in payload && payload.error) {
|
|
53
|
+
error = payload.error;
|
|
54
|
+
} else if (payload?.status === "error") {
|
|
55
|
+
error = new Error("Failed to load object");
|
|
56
|
+
}
|
|
51
57
|
return {
|
|
52
58
|
object: payload?.object,
|
|
53
59
|
isLoading: payload?.status === "loading",
|
|
54
60
|
isOptimistic: !!payload?.isOptimistic,
|
|
55
|
-
error
|
|
61
|
+
error,
|
|
56
62
|
forceUpdate: () => {
|
|
57
|
-
throw "not implemented";
|
|
63
|
+
throw new Error("not implemented");
|
|
58
64
|
}
|
|
59
65
|
};
|
|
60
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","mode","length","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","observer","observeObject","payload","useSyncExternalStore","
|
|
1
|
+
{"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","mode","length","undefined","objectType","$objectType","apiName","primaryKey","$primaryKey","subscribe","getSnapShot","useMemo","observer","observeObject","payload","useSyncExternalStore","error","status","Error","object","isLoading","isOptimistic","forceUpdate"],"sources":["useOsdkObject.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectTypeDefinition, Osdk, PrimaryKeyType } from \"@osdk/api\";\nimport type { ObserveObjectArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<Q extends ObjectTypeDefinition> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n obj: Osdk.Instance<Q>,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object by type and primary key.\n *\n * @param type\n * @param primaryKey\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<Q extends ObjectTypeDefinition>(\n ...args: [obj: Osdk.Instance<Q>] | [type: Q, primaryKey: PrimaryKeyType<Q>]\n): UseOsdkObjectResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // TODO: Figure out what the correct default behavior is for the various scenarios\n const mode = args.length === 1 ? \"offline\" : undefined;\n const objectType = args.length === 1 ? args[0].$objectType : args[0].apiName;\n const primaryKey = args.length === 1 ? args[0].$primaryKey : args[1];\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObserveObjectArgs<Q>>(\n (observer) =>\n observableClient.observeObject(\n objectType,\n primaryKey,\n {\n mode,\n },\n observer,\n ),\n `object ${objectType} ${primaryKey}`,\n ),\n [observableClient, objectType, primaryKey, mode],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to load object\");\n }\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: payload?.status === \"loading\",\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate: () => {\n throw new Error(\"not impl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IA,OAAO,CAACE,KAAK,EAAE;IAClDA,KAAK,GAAGF,OAAO,CAACE,KAAK;EACvB,CAAC,MAAM,IAAIF,OAAO,EAAEG,MAAM,KAAK,OAAO,EAAE;IACtCD,KAAK,GAAG,IAAIE,KAAK,CAAC,uBAAuB,CAAC;EAC5C;EAEA,OAAO;IACLC,MAAM,EAAEL,OAAO,EAAEK,MAAsC;IACvDC,SAAS,EAAEN,OAAO,EAAEG,MAAM,KAAK,SAAS;IACxCI,YAAY,EAAE,CAAC,CAACP,OAAO,EAAEO,YAAY;IACrCL,KAAK;IACLM,WAAW,EAAEA,CAAA,KAAM;MACjB,MAAM,IAAIJ,KAAK,CAAC,iBAAiB,CAAC;IACpC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -45,10 +45,15 @@ export function useOsdkObjects(type, {
|
|
|
45
45
|
streamUpdates
|
|
46
46
|
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${JSON.stringify(canonWhere)}` : void 0), [observableClient, type, canonWhere, dedupeIntervalMs]);
|
|
47
47
|
const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
48
|
-
|
|
48
|
+
let error;
|
|
49
|
+
if (listPayload && "error" in listPayload && listPayload.error) {
|
|
50
|
+
error = listPayload.error;
|
|
51
|
+
} else if (listPayload?.status === "error") {
|
|
52
|
+
error = new Error("Failed to load objects");
|
|
53
|
+
}
|
|
49
54
|
return {
|
|
50
55
|
fetchMore: listPayload?.fetchMore,
|
|
51
|
-
error
|
|
56
|
+
error,
|
|
52
57
|
data: listPayload?.resolvedList,
|
|
53
58
|
isLoading: listPayload?.status === "loading",
|
|
54
59
|
isOptimistic: listPayload?.isOptimistic ?? false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","observableClient","useContext","canonWhere","canonicalizeWhereClause","subscribe","getSnapShot","useMemo","observer","observeList","dedupeInterval","process","env","NODE_ENV","apiName","JSON","stringify","listPayload","useSyncExternalStore","
|
|
1
|
+
{"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","pageSize","orderBy","dedupeIntervalMs","where","streamUpdates","observableClient","useContext","canonWhere","canonicalizeWhereClause","subscribe","getSnapShot","useMemo","observer","observeList","dedupeInterval","process","env","NODE_ENV","apiName","JSON","stringify","listPayload","useSyncExternalStore","error","status","Error","fetchMore","data","resolvedList","isLoading","isOptimistic"],"sources":["useOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n InterfaceDefinition,\n ObjectTypeDefinition,\n Osdk,\n PropertyKeys,\n WhereClause,\n} from \"@osdk/client\";\nimport type { ObserveObjectsArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectsOptions<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n /**\n * Standard OSDK Where\n */\n where?: WhereClause<T>;\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /** */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n */\n // autoFetchMore?: boolean | number;\n\n /**\n * Upon a list being revalidated, this option determines how the component\n * will be re-rendered with the data.\n *\n * An example to help understand the options:\n *\n * Suppose pageSize is 10 and we have called `fetchMore()` twice. The list is\n * now 30 items long.\n *\n * Upon revalidation, we get the first 10 items of the list. The options behave\n * as follows:\n *\n * - `\"in-place\"`: The first 10 items of the list are replaced with the new 10\n * items. The list is now 30 items long, but only the first 10 items are valid.\n * - `\"wait\"`: The old list is returned until after the next 20 items are loaded\n * (which will happen automatically). The list is now 30 items long.\n * - `\"reset\"`: The entire list is replaced with the new 10 items. The list is\n * now 10 items long.\n */\n // invalidationMode?: \"in-place\" | \"wait\" | \"reset\";\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the where clause will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * If provided, the list will be considered this length for the purposes of\n * `invalidationMode` when using the `wait` option. If not provided,\n * the internal expectedLength will be determined by the number of times\n * `fetchMore` has been called.\n */\n // expectedLength?: number | undefined;\n\n streamUpdates?: boolean;\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectTypeDefinition | InterfaceDefinition,\n> {\n fetchMore: (() => Promise<unknown>) | undefined;\n data: Osdk.Instance<T>[] | undefined;\n isLoading: boolean;\n error: Error | undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectTypeDefinition | InterfaceDefinition,\n>(\n type: Q,\n {\n pageSize,\n orderBy,\n dedupeIntervalMs,\n where = {},\n streamUpdates,\n }: UseOsdkObjectsOptions<Q> = {},\n): UseOsdkListResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n /* We want the canonical where clause so that the use of `React.useMemo`\n is stable. No real added cost as we canonicalize internal to\n the ObservableClient anyway.\n */\n const canonWhere = observableClient.canonicalizeWhereClause(where ?? {});\n\n const { subscribe, getSnapShot } = React.useMemo(\n () =>\n makeExternalStore<ObserveObjectsArgs<Q>>(\n (observer) =>\n observableClient.observeList({\n type,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy,\n streamUpdates,\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${JSON.stringify(canonWhere)}`\n : void 0,\n ),\n [observableClient, type, canonWhere, dedupeIntervalMs],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n\n return {\n fetchMore: listPayload?.fetchMore,\n error,\n data: listPayload?.resolvedList as Osdk.Instance<Q>[],\n isLoading: listPayload?.status === \"loading\",\n isOptimistic: listPayload?.isOptimistic ?? false,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AA2FhD,OAAO,SAASC,cAAcA,CAG5BC,IAAO,EACP;EACEC,QAAQ;EACRC,OAAO;EACPC,gBAAgB;EAChBC,KAAK,GAAG,CAAC,CAAC;EACVC;AACwB,CAAC,GAAG,CAAC,CAAC,EACV;EACtB,MAAM;IAAEC;EAAiB,CAAC,GAAGV,KAAK,CAACW,UAAU,CAACT,YAAY,CAAC;;EAE3D;AACF;AACA;AACA;EACE,MAAMU,UAAU,GAAGF,gBAAgB,CAACG,uBAAuB,CAACL,KAAK,IAAI,CAAC,CAAC,CAAC;EAExE,MAAM;IAAEM,SAAS;IAAEC;EAAY,CAAC,GAAGf,KAAK,CAACgB,OAAO,CAC9C,MACEf,iBAAiB,CACdgB,QAAQ,IACPP,gBAAgB,CAACQ,WAAW,CAAC;IAC3Bd,IAAI;IACJI,KAAK,EAAEI,UAAU;IACjBO,cAAc,EAAEZ,gBAAgB,IAAI,KAAK;IACzCF,QAAQ;IACRC,OAAO;IACPG;EACF,CAAC,EAAEQ,QAAQ,CAAC,EACdG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACjC,QAAQlB,IAAI,CAACmB,OAAO,IAAIC,IAAI,CAACC,SAAS,CAACb,UAAU,CAAC,EAAE,GACpD,KAAK,CACX,CAAC,EACH,CAACF,gBAAgB,EAAEN,IAAI,EAAEQ,UAAU,EAAEL,gBAAgB,CACvD,CAAC;EAED,MAAMmB,WAAW,GAAG1B,KAAK,CAAC2B,oBAAoB,CAACb,SAAS,EAAEC,WAAW,CAAC;EAEtE,IAAIa,KAAwB;EAC5B,IAAIF,WAAW,IAAI,OAAO,IAAIA,WAAW,IAAIA,WAAW,CAACE,KAAK,EAAE;IAC9DA,KAAK,GAAGF,WAAW,CAACE,KAAK;EAC3B,CAAC,MAAM,IAAIF,WAAW,EAAEG,MAAM,KAAK,OAAO,EAAE;IAC1CD,KAAK,GAAG,IAAIE,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEA,OAAO;IACLC,SAAS,EAAEL,WAAW,EAAEK,SAAS;IACjCH,KAAK;IACLI,IAAI,EAAEN,WAAW,EAAEO,YAAkC;IACrDC,SAAS,EAAER,WAAW,EAAEG,MAAM,KAAK,SAAS;IAC5CM,YAAY,EAAET,WAAW,EAAES,YAAY,IAAI;EAC7C,CAAC;AACH","ignoreList":[]}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
export { OsdkProvider2 } from "../new/OsdkProvider2.js";
|
|
18
18
|
export { useLinks } from "../new/useLinks.js";
|
|
19
|
+
export { useObjectSet } from "../new/useObjectSet.js";
|
|
19
20
|
export { useOsdkAction } from "../new/useOsdkAction.js";
|
|
20
21
|
export { useOsdkObject } from "../new/useOsdkObject.js";
|
|
21
22
|
export { useOsdkObjects } from "../new/useOsdkObjects.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","names":["OsdkProvider2","useLinks","useOsdkAction","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata"],"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 { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\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,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"experimental.js","names":["OsdkProvider2","useLinks","useObjectSet","useOsdkAction","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useLinks } from \"../new/useLinks.js\";\nexport { useObjectSet } from \"../new/useObjectSet.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type { UseOsdkListResult } from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,yBAAyB;AACvD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB","ignoreList":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { DerivedProperty, LinkNames, ObjectSet, ObjectTypeDefinition, Osdk, PropertyKeys, WhereClause, WirePropertyTypes } from "@osdk/api";
|
|
2
|
+
type SimplePropertyDef = WirePropertyTypes | undefined | Array<WirePropertyTypes>;
|
|
3
|
+
export interface UseObjectSetOptions<
|
|
4
|
+
Q extends ObjectTypeDefinition,
|
|
5
|
+
RDPs extends Record<string, SimplePropertyDef> = {}
|
|
6
|
+
> {
|
|
7
|
+
/**
|
|
8
|
+
* Where clause for filtering
|
|
9
|
+
*/
|
|
10
|
+
where?: WhereClause<Q>;
|
|
11
|
+
/**
|
|
12
|
+
* Derived properties to add to the object set
|
|
13
|
+
*/
|
|
14
|
+
withProperties?: { [K in keyof RDPs] : DerivedProperty.Creator<Q, RDPs[K]> };
|
|
15
|
+
/**
|
|
16
|
+
* Object sets to union with
|
|
17
|
+
*/
|
|
18
|
+
union?: ObjectSet<Q>[];
|
|
19
|
+
/**
|
|
20
|
+
* Object sets to intersect with
|
|
21
|
+
*/
|
|
22
|
+
intersect?: ObjectSet<Q>[];
|
|
23
|
+
/**
|
|
24
|
+
* Object sets to subtract from
|
|
25
|
+
*/
|
|
26
|
+
subtract?: ObjectSet<Q>[];
|
|
27
|
+
/**
|
|
28
|
+
* Link to pivot to (changes the type)
|
|
29
|
+
*/
|
|
30
|
+
pivotTo?: LinkNames<Q>;
|
|
31
|
+
/**
|
|
32
|
+
* The preferred page size for the list
|
|
33
|
+
*/
|
|
34
|
+
pageSize?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Sort order for the results
|
|
37
|
+
*/
|
|
38
|
+
orderBy?: { [K in PropertyKeys<Q>]? : "asc" | "desc" };
|
|
39
|
+
/**
|
|
40
|
+
* Minimum time between fetch requests in milliseconds (defaults to 2000ms)
|
|
41
|
+
*/
|
|
42
|
+
dedupeIntervalMs?: number;
|
|
43
|
+
}
|
|
44
|
+
export interface UseObjectSetResult<
|
|
45
|
+
Q extends ObjectTypeDefinition,
|
|
46
|
+
RDPs extends Record<string, SimplePropertyDef> = {}
|
|
47
|
+
> {
|
|
48
|
+
/**
|
|
49
|
+
* The fetched data with derived properties
|
|
50
|
+
*/
|
|
51
|
+
data: Osdk.Instance<Q, "$allBaseProperties", PropertyKeys<Q>, RDPs>[] | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Whether data is currently being loaded
|
|
54
|
+
*/
|
|
55
|
+
isLoading: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Any error that occurred during fetching
|
|
58
|
+
*/
|
|
59
|
+
error: Error | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Function to fetch more pages (undefined if no more pages)
|
|
62
|
+
*/
|
|
63
|
+
fetchMore: (() => Promise<void>) | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* The final ObjectSet after all transformations
|
|
66
|
+
*/
|
|
67
|
+
objectSet: ObjectSet<Q, RDPs>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* React hook for observing and interacting with OSDK object sets.
|
|
71
|
+
*
|
|
72
|
+
* @typeParam Q - The object type definition
|
|
73
|
+
* @typeParam BaseRDPs - Derived properties that already exist on the input ObjectSet
|
|
74
|
+
* @typeParam RDPs - New derived properties to be added via options.withProperties
|
|
75
|
+
*
|
|
76
|
+
* @param baseObjectSet - The ObjectSet to observe (may already have derived properties)
|
|
77
|
+
* @param options - Options for filtering, sorting, and adding new derived properties
|
|
78
|
+
* @returns Object set data with both existing and new derived properties
|
|
79
|
+
*/
|
|
80
|
+
export declare function useObjectSet<
|
|
81
|
+
Q extends ObjectTypeDefinition,
|
|
82
|
+
BaseRDPs extends Record<string, SimplePropertyDef> = never,
|
|
83
|
+
RDPs extends Record<string, SimplePropertyDef> = {}
|
|
84
|
+
>(baseObjectSet: ObjectSet<Q, BaseRDPs>, options?: UseObjectSetOptions<Q, RDPs>): UseObjectSetResult<Q, RDPs>;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAgBA,cACE,iBACA,WACA,WACA,sBACA,MACA,cACA,aACA,yBACK,WAAY;KAUd,oBACD,gCAEA,MAAM;AAEV,iBAAiB;CACf,UAAU;CACV,aAAa,eAAe,qBAAqB,CAAE;EACnD;;;;CAIA,QAAQ,YAAY;;;;CAKpB,oBAAoB,WAAW,QAAO,gBAAgB,QAAQ,GAAG,KAAK;;;;CAKtE,QAAQ,UAAU;;;;CAKlB,YAAY,UAAU;;;;CAKtB,WAAW,UAAU;;;;CAKrB,UAAU,UAAU;;;;CAKpB;;;;CAKA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;CAMnC;AACD;AAED,iBAAiB;CACf,UAAU;CACV,aAAa,eAAe,qBAAqB,CAAE;EACnD;;;;CAIA,MACI,KAAK,SAAS,GAAG,sBAAsB,aAAa,IAAI;;;;CAM5D;;;;CAKA,OAAO;;;;CAKP,kBAAkB;;;;CAKlB,WAAW,UAAU,GAAG;AACzB;;;;;;;;;;;;AAmBD,OAAO,iBAAS;CACd,UAAU;CACV,iBAAiB,eAAe;CAChC,aAAa,eAAe,qBAAqB,CAAE;EAEnDA,eAAe,UAAU,GAAG,WAC5BC,UAAS,oBAAoB,GAAG,QAC/B,mBAAmB,GAAG","names":["baseObjectSet: ObjectSet<Q, BaseRDPs>","options: UseObjectSetOptions<Q, RDPs>"],"sources":["../../../src/new/useObjectSet.tsx"],"version":3,"file":"useObjectSet.d.ts"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,cACE,qBACA,sBACA,MACA,cACA,mBACK,cAAe;AAMtB,iBAAiB,sBACf,UAAU,uBAAuB,qBACjC;;;;CAIA,QAAQ,YAAY;;;;CAKpB;;CAGA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCnC;;;;;;;CAUA;AACD;AAED,iBAAiB,kBACf,UAAU,uBAAuB,qBACjC;CACA,kBAAkB;CAClB,MAAM,KAAK,SAAS;CACpB;
|
|
1
|
+
{"mappings":"AAgBA,cACE,qBACA,sBACA,MACA,cACA,mBACK,cAAe;AAMtB,iBAAiB,sBACf,UAAU,uBAAuB,qBACjC;;;;CAIA,QAAQ,YAAY;;;;CAKpB;;CAGA,aACG,KAAK,aAAa,OAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCnC;;;;;;;CAUA;AACD;AAED,iBAAiB,kBACf,UAAU,uBAAuB,qBACjC;CACA,kBAAkB;CAClB,MAAM,KAAK,SAAS;CACpB;CACA,OAAO;;;;;;;;CASP;AACD;AAQD,OAAO,iBAAS,eACd,UAAU,uBAAuB,qBAEjCA,MAAM,GACN,EACE,UACA,SACA,kBACA,OACA,eACyB,GAAxB,sBAAsB,KACxB,kBAAkB","names":["type: Q"],"sources":["../../../src/new/useOsdkObjects.ts"],"version":3,"file":"useOsdkObjects.d.ts"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { OsdkProvider2 } from "../new/OsdkProvider2.js";
|
|
2
2
|
export { useLinks } from "../new/useLinks.js";
|
|
3
|
+
export { useObjectSet } from "../new/useObjectSet.js";
|
|
3
4
|
export { useOsdkAction } from "../new/useOsdkAction.js";
|
|
4
5
|
export { useOsdkObject } from "../new/useOsdkObject.js";
|
|
5
6
|
export type { UseOsdkListResult } from "../new/useOsdkObjects.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAgBA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,cAAc,yBAAyB;AACvC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,cAAc,6BAA6B","names":[],"sources":["../../../src/public/experimental.ts"],"version":3,"file":"experimental.d.ts"}
|
|
1
|
+
{"mappings":"AAgBA,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,cAAc,yBAAyB;AACvC,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAC9B,SAAS,uBAAuB;AAChC,cAAc,6BAA6B","names":[],"sources":["../../../src/public/experimental.ts"],"version":3,"file":"experimental.d.ts"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdk/react",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.5",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"react": "^18.3.1",
|
|
51
51
|
"tiny-invariant": "^1.3.3",
|
|
52
52
|
"typescript": "~5.5.4",
|
|
53
|
-
"@osdk/api": "2.5.0-beta.
|
|
53
|
+
"@osdk/api": "2.5.0-beta.11",
|
|
54
|
+
"@osdk/client": "2.5.0-beta.11",
|
|
54
55
|
"@osdk/monorepo.api-extractor": "~0.4.0-beta.1",
|
|
55
|
-
"@osdk/client": "2.5.0-beta.5",
|
|
56
56
|
"@osdk/monorepo.tsconfig": "~0.4.0-beta.1"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|