@osdk/react 0.9.3 → 0.10.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +46 -221
- package/CHANGELOG.md +109 -51
- package/build/browser/new/makeExternalStore.js +61 -0
- package/build/browser/new/makeExternalStore.js.map +1 -1
- package/build/browser/new/useLinks.js +11 -4
- package/build/browser/new/useLinks.js.map +1 -1
- package/build/browser/new/useObjectSet.js +6 -3
- package/build/browser/new/useObjectSet.js.map +1 -1
- package/build/browser/new/useOsdkAction.js +2 -2
- package/build/browser/new/useOsdkAction.js.map +1 -1
- package/build/browser/new/useOsdkAggregation.js +65 -27
- package/build/browser/new/useOsdkAggregation.js.map +1 -1
- package/build/browser/new/useOsdkFunction.js +17 -12
- package/build/browser/new/useOsdkFunction.js.map +1 -1
- package/build/browser/new/useOsdkObject.js +36 -17
- package/build/browser/new/useOsdkObject.js.map +1 -1
- package/build/browser/new/useOsdkObjects.js +28 -19
- package/build/browser/new/useOsdkObjects.js.map +1 -1
- package/build/browser/{intellisense.test.helpers/useOsdkObjectsWithPivot.js → public/experimental/admin.js} +4 -19
- package/build/browser/public/experimental/admin.js.map +1 -0
- package/build/browser/public/experimental.js +0 -3
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/useOsdkMetadata.js.map +1 -1
- package/build/cjs/{chunk-V32JHU3O.cjs → chunk-OVBG5VXE.cjs} +3 -8
- package/build/cjs/chunk-OVBG5VXE.cjs.map +1 -0
- package/build/cjs/chunk-SVVMLSKN.cjs +111 -0
- package/build/cjs/chunk-SVVMLSKN.cjs.map +1 -0
- package/build/cjs/index.cjs +4 -4
- package/build/cjs/index.d.cts +1 -1
- package/build/cjs/public/experimental/admin.cjs +146 -0
- package/build/cjs/public/experimental/admin.cjs.map +1 -0
- package/build/cjs/public/experimental/admin.d.cts +118 -0
- package/build/cjs/public/experimental.cjs +217 -478
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.d.cts +88 -127
- package/build/cjs/useOsdkMetadata-BElt3F5s.d.cts +15 -0
- package/build/esm/new/makeExternalStore.js +61 -0
- package/build/esm/new/makeExternalStore.js.map +1 -1
- package/build/esm/new/useLinks.js +11 -4
- package/build/esm/new/useLinks.js.map +1 -1
- package/build/esm/new/useObjectSet.js +6 -3
- package/build/esm/new/useObjectSet.js.map +1 -1
- package/build/esm/new/useOsdkAction.js +2 -2
- package/build/esm/new/useOsdkAction.js.map +1 -1
- package/build/esm/new/useOsdkAggregation.js +65 -27
- package/build/esm/new/useOsdkAggregation.js.map +1 -1
- package/build/esm/new/useOsdkFunction.js +17 -12
- package/build/esm/new/useOsdkFunction.js.map +1 -1
- package/build/esm/new/useOsdkObject.js +36 -17
- package/build/esm/new/useOsdkObject.js.map +1 -1
- package/build/esm/new/useOsdkObjects.js +28 -19
- package/build/esm/new/useOsdkObjects.js.map +1 -1
- package/build/esm/{intellisense.test.helpers/useOsdkObjectsWithPivot.js → public/experimental/admin.js} +4 -19
- package/build/esm/public/experimental/admin.js.map +1 -0
- package/build/esm/public/experimental.js +0 -3
- package/build/esm/public/experimental.js.map +1 -1
- package/build/esm/useOsdkMetadata.js.map +1 -1
- package/build/types/new/makeExternalStore.d.ts +11 -0
- package/build/types/new/makeExternalStore.d.ts.map +1 -1
- package/build/types/new/useLinks.d.ts +19 -0
- package/build/types/new/useLinks.d.ts.map +1 -1
- package/build/types/new/useObjectSet.d.ts +6 -0
- package/build/types/new/useObjectSet.d.ts.map +1 -1
- package/build/types/new/useOsdkAggregation.d.ts +41 -3
- package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
- package/build/types/new/useOsdkFunction.d.ts +11 -5
- package/build/types/new/useOsdkFunction.d.ts.map +1 -1
- package/build/types/new/useOsdkObject.d.ts +12 -1
- package/build/types/new/useOsdkObject.d.ts.map +1 -1
- package/build/types/new/useOsdkObjects.d.ts +10 -0
- package/build/types/new/useOsdkObjects.d.ts.map +1 -1
- package/build/types/public/experimental/admin.d.ts +3 -0
- package/build/types/public/experimental/admin.d.ts.map +1 -0
- package/build/types/public/experimental.d.ts +0 -3
- package/build/types/public/experimental.d.ts.map +1 -1
- package/build/types/useOsdkMetadata.d.ts +5 -4
- package/build/types/useOsdkMetadata.d.ts.map +1 -1
- package/docs/querying-data.md +19 -0
- package/{build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js → experimental/admin.d.ts} +1 -18
- package/package.json +29 -8
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithPivot.js.map +0 -1
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js +0 -34
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +0 -1
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithRids.js +0 -37
- package/build/browser/intellisense.test.helpers/useOsdkObjectsWithRids.js.map +0 -1
- package/build/browser/intellisense.test.js +0 -172
- package/build/browser/intellisense.test.js.map +0 -1
- package/build/cjs/chunk-V32JHU3O.cjs.map +0 -1
- package/build/cjs/useOsdkMetadata-DFZhnhGZ.d.cts +0 -14
- package/build/esm/intellisense.test.helpers/useOsdkObjectsWithPivot.js.map +0 -1
- package/build/esm/intellisense.test.helpers/useOsdkObjectsWithProperties.js.map +0 -1
- package/build/esm/intellisense.test.helpers/useOsdkObjectsWithRids.js +0 -37
- package/build/esm/intellisense.test.helpers/useOsdkObjectsWithRids.js.map +0 -1
- package/build/esm/intellisense.test.js +0 -172
- package/build/esm/intellisense.test.js.map +0 -1
- package/build/types/intellisense.test.d.ts +0 -1
- package/build/types/intellisense.test.d.ts.map +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithPivot.d.ts +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithPivot.d.ts.map +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithProperties.d.ts +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithProperties.d.ts.map +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithRids.d.ts +0 -1
- package/build/types/intellisense.test.helpers/useOsdkObjectsWithRids.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","isInstanceSignature","enabled","
|
|
1
|
+
{"version":3,"file":"useOsdkObject.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObject","args","observableClient","useContext","isInstanceSignature","optionsArg","undefined","enabled","selectArg","$select","mode","typeOrApiName","$objectType","primaryKey","$primaryKey","apiNameString","apiName","stableSelect","useMemo","JSON","stringify","subscribe","getSnapShot","unsubscribe","observer","observeObject","select","payload","useSyncExternalStore","forceUpdate","useCallback","Error","error","status","object","isLoading","isOptimistic"],"sources":["useOsdkObject.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n} from \"@osdk/api\";\nimport type { ObserveObjectCallbackArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectResult<\n Q extends ObjectOrInterfaceDefinition,\n> {\n object: Osdk.Instance<Q> | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n /**\n * Refers to whether the object is optimistic or not.\n */\n isOptimistic: boolean;\n forceUpdate: () => void;\n}\n\n/**\n * @param obj an existing `Osdk.Instance` object to get metadata for.\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n obj: Osdk.Instance<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object or interface instance by type and primary key.\n *\n * @param type The object type or interface definition\n * @param primaryKey The primary key of the object\n * @param enabled Enable or disable the query (defaults to true)\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n enabled?: boolean,\n): UseOsdkObjectResult<Q>;\n/**\n * Loads an object or interface instance by type and primary key with options.\n *\n * @param type The object type or interface definition\n * @param primaryKey The primary key of the object\n * @param options Options including $select and enabled\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n options?: { $select?: readonly PropertyKeys<Q>[]; enabled?: boolean },\n): UseOsdkObjectResult<Q>;\n/*\n Implementation of useOsdkObject\n */\nexport function useOsdkObject<\n Q extends ObjectOrInterfaceDefinition,\n>(\n ...args:\n | [obj: Osdk.Instance<Q>, enabled?: boolean]\n | [type: Q, primaryKey: PrimaryKeyType<Q>, enabled?: boolean]\n | [\n type: Q,\n primaryKey: PrimaryKeyType<Q>,\n options?: { $select?: readonly PropertyKeys<Q>[]; enabled?: boolean },\n ]\n): UseOsdkObjectResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n\n // Check if first arg is an instance to discriminate signatures\n // TypeScript cannot narrow rest parameter unions with optional parameters,\n // so we must use type assertions after runtime discrimination\n const isInstanceSignature = \"$objectType\" in args[0];\n\n // Extract options object if provided (3rd arg is an object with $select or enabled)\n const optionsArg = !isInstanceSignature\n && args[2] != null\n && typeof args[2] === \"object\"\n ? args[2] as { $select?: readonly string[]; enabled?: boolean }\n : undefined;\n\n // Extract enabled flag - 2nd param for instance signature, 3rd for type signature\n const enabled = isInstanceSignature\n ? (typeof args[1] === \"boolean\" ? args[1] : true)\n : optionsArg\n ? (optionsArg.enabled ?? true)\n : (typeof args[2] === \"boolean\" ? args[2] : true);\n\n const selectArg = optionsArg?.$select;\n\n const mode = isInstanceSignature ? \"offline\" : undefined;\n\n const typeOrApiName = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$objectType\n : (args[0] as Q);\n\n const primaryKey = isInstanceSignature\n ? (args[0] as Osdk.Instance<Q>).$primaryKey\n : (args[1] as PrimaryKeyType<Q>);\n\n const apiNameString = typeof typeOrApiName === \"string\"\n ? typeOrApiName\n : typeOrApiName.apiName;\n\n const stableSelect = React.useMemo(\n () => selectArg,\n [JSON.stringify(selectArg)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<ObserveObjectCallbackArgs<Q>>(\n () => ({ unsubscribe: () => {} }),\n `object ${apiNameString} ${primaryKey} [DISABLED]`,\n );\n }\n return makeExternalStore<ObserveObjectCallbackArgs<Q>>(\n (observer) =>\n observableClient.observeObject(\n typeOrApiName,\n primaryKey,\n {\n mode,\n ...(stableSelect ? { select: stableSelect } : {}),\n },\n observer,\n ),\n `object ${apiNameString} ${primaryKey}`,\n );\n },\n [\n enabled,\n observableClient,\n typeOrApiName,\n apiNameString,\n primaryKey,\n mode,\n stableSelect,\n ],\n );\n\n const payload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n const forceUpdate = React.useCallback(() => {\n throw new Error(\"not implemented\");\n }, []);\n\n return React.useMemo(() => {\n let error: Error | undefined;\n if (payload && \"error\" in payload && payload.error) {\n error = payload.error;\n } else if (payload?.status === \"error\") {\n error = new Error(\"Failed to load object\");\n }\n\n return {\n object: payload?.object as Osdk.Instance<Q> | undefined,\n isLoading: enabled\n ? (payload?.status === \"loading\" || payload?.status === \"init\"\n || !payload)\n : false,\n isOptimistic: !!payload?.isOptimistic,\n error,\n forceUpdate,\n };\n }, [payload, enabled, forceUpdate]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA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AK,EAAE;MAClDA,KAAK,GAAGL,OAAO,CAACK,KAAK;IACvB,CAAC,MAAM,IAAIL,OAAO,EAAEM,MAAM,KAAK,OAAO,EAAE;MACtCD,KAAK,GAAG,IAAID,KAAK,CAAC,uBAAuB,CAAC;IAC5C;IAEA,OAAO;MACLG,MAAM,EAAEP,OAAO,EAAEO,MAAsC;MACvDC,SAAS,EAAE5B,OAAO,GACboB,OAAO,EAAEM,MAAM,KAAK,SAAS,IAAIN,OAAO,EAAEM,MAAM,KAAK,MAAM,IACzD,CAACN,OAAO,GACX,KAAK;MACTS,YAAY,EAAE,CAAC,CAACT,OAAO,EAAES,YAAY;MACrCJ,KAAK;MACLH;IACF,CAAC;EACH,CAAC,EAAE,CAACF,OAAO,EAAEpB,OAAO,EAAEsB,WAAW,CAAC,CAAC;AACrC","ignoreList":[]}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import React from "react";
|
|
18
18
|
import { makeExternalStore } from "./makeExternalStore.js";
|
|
19
19
|
import { OsdkContext2 } from "./OsdkContext2.js";
|
|
20
|
+
const EMPTY_WHERE = {};
|
|
20
21
|
export function useOsdkObjects(type, options) {
|
|
21
22
|
const {
|
|
22
23
|
observableClient
|
|
@@ -32,13 +33,16 @@ export function useOsdkObjects(type, options) {
|
|
|
32
33
|
streamUpdates,
|
|
33
34
|
autoFetchMore,
|
|
34
35
|
intersectWith,
|
|
35
|
-
pivotTo
|
|
36
|
+
pivotTo,
|
|
37
|
+
$select
|
|
36
38
|
} = options ?? {};
|
|
37
|
-
const canonWhere = observableClient.canonicalizeWhereClause(where ??
|
|
39
|
+
const canonWhere = observableClient.canonicalizeWhereClause(where ?? EMPTY_WHERE);
|
|
40
|
+
const stableCanonWhere = React.useMemo(() => canonWhere, [JSON.stringify(canonWhere)]);
|
|
38
41
|
const stableRids = React.useMemo(() => rids, [JSON.stringify(rids)]);
|
|
39
42
|
const stableWithProperties = React.useMemo(() => withProperties, [JSON.stringify(withProperties)]);
|
|
40
43
|
const stableIntersectWith = React.useMemo(() => intersectWith, [JSON.stringify(intersectWith)]);
|
|
41
44
|
const stableOrderBy = React.useMemo(() => orderBy, [JSON.stringify(orderBy)]);
|
|
45
|
+
const stableSelect = React.useMemo(() => $select, [JSON.stringify($select)]);
|
|
42
46
|
const {
|
|
43
47
|
subscribe,
|
|
44
48
|
getSnapShot
|
|
@@ -51,7 +55,7 @@ export function useOsdkObjects(type, options) {
|
|
|
51
55
|
return makeExternalStore(observer => observableClient.observeList({
|
|
52
56
|
type,
|
|
53
57
|
rids: stableRids,
|
|
54
|
-
where:
|
|
58
|
+
where: stableCanonWhere,
|
|
55
59
|
dedupeInterval: dedupeIntervalMs ?? 2_000,
|
|
56
60
|
pageSize,
|
|
57
61
|
orderBy: stableOrderBy,
|
|
@@ -63,23 +67,28 @@ export function useOsdkObjects(type, options) {
|
|
|
63
67
|
} : {}),
|
|
64
68
|
...(pivotTo ? {
|
|
65
69
|
pivotTo
|
|
70
|
+
} : {}),
|
|
71
|
+
...(stableSelect ? {
|
|
72
|
+
select: stableSelect
|
|
66
73
|
} : {})
|
|
67
|
-
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${stableRids ? `[${stableRids.length} rids]` : ""} ${JSON.stringify(
|
|
68
|
-
}, [enabled, observableClient, type, stableRids,
|
|
74
|
+
}, observer), process.env.NODE_ENV !== "production" ? `list ${type.apiName} ${stableRids ? `[${stableRids.length} rids]` : ""} ${JSON.stringify(stableCanonWhere)}` : void 0);
|
|
75
|
+
}, [enabled, observableClient, type.apiName, type.type, stableRids, stableCanonWhere, dedupeIntervalMs, pageSize, stableOrderBy, streamUpdates, stableWithProperties, autoFetchMore, stableIntersectWith, pivotTo, stableSelect]);
|
|
69
76
|
const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
error
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
return React.useMemo(() => {
|
|
78
|
+
let error;
|
|
79
|
+
if (listPayload && "error" in listPayload && listPayload.error) {
|
|
80
|
+
error = listPayload.error;
|
|
81
|
+
} else if (listPayload?.status === "error") {
|
|
82
|
+
error = new Error("Failed to load objects");
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
fetchMore: listPayload?.hasMore ? listPayload.fetchMore : undefined,
|
|
86
|
+
error,
|
|
87
|
+
data: listPayload?.resolvedList,
|
|
88
|
+
isLoading: enabled ? listPayload?.status === "loading" || listPayload?.status === "init" || !listPayload : false,
|
|
89
|
+
isOptimistic: listPayload?.isOptimistic ?? false,
|
|
90
|
+
totalCount: listPayload?.totalCount
|
|
91
|
+
};
|
|
92
|
+
}, [listPayload, enabled]);
|
|
84
93
|
}
|
|
85
94
|
//# sourceMappingURL=useOsdkObjects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","useOsdkObjects","type","options","observableClient","useContext","pageSize","dedupeIntervalMs","withProperties","enabled","rids","where","orderBy","streamUpdates","autoFetchMore","intersectWith","pivotTo","canonWhere","canonicalizeWhereClause","stableRids","useMemo","JSON","stringify","stableWithProperties","stableIntersectWith","stableOrderBy","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","apiName","observer","observeList","dedupeInterval","length","listPayload","useSyncExternalStore","error","status","Error","fetchMore","hasMore","undefined","data","resolvedList","isLoading","isOptimistic","totalCount"],"sources":["useOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n LinkedType,\n LinkNames,\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObserveObjectsCallbackArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectsOptions<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Fetch objects by their RIDs (Resource Identifiers).\n * When provided, starts with a static objectset containing these RIDs.\n * Can be combined with `where` to filter the RID set, and with `orderBy` to sort results.\n *\n * @example\n * // Fetch specific objects by RID\n * useOsdkObjects(Employee, { rids: ['ri.foo.123', 'ri.foo.456'] })\n *\n * @example\n * // Fetch specific objects by RID, filtered by status\n * useOsdkObjects(Employee, {\n * rids: ['ri.foo.123', 'ri.foo.456', 'ri.foo.789'],\n * where: { status: 'active' }\n * })\n */\n rids?: readonly string[];\n\n /**\n * Standard OSDK Where clause with RDP support.\n * When used with `rids`, filters the RID set.\n * When used alone, filters all objects of the type.\n */\n where?: WhereClause<T, RDPs>;\n\n /**\n * Sort results by one or more properties.\n */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /**\n * Define derived properties (RDPs) to be computed server-side and attached to each object.\n * These properties will be available on the returned objects alongside their regular properties.\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<T, RDPs[K]> };\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Intersect the results with additional object sets.\n * Each element defines a where clause for an object set to intersect with.\n * The final result will only include objects that match ALL conditions.\n */\n intersectWith?: Array<{\n where: WhereClause<T, RDPs>;\n }>;\n\n /**\n * Pivot to related objects through a link.\n * This changes the return type from T to the linked object type.\n */\n pivotTo?: LinkNames<T>;\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n streamUpdates?: boolean;\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n EXTRA_OPTIONS extends never | \"$rid\" = never,\n> {\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<\n T,\n \"$allBaseProperties\" | EXTRA_OPTIONS,\n PropertyKeys<T>,\n RDPs\n >[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n\n /**\n * The total count of objects matching the query (if available from the API)\n */\n totalCount?: string;\n}\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n L extends LinkNames<Q>,\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q> & { pivotTo: L; rids: readonly string[] },\n): UseOsdkListResult<LinkedType<Q, L>, {}, \"$rid\">;\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n L extends LinkNames<Q>,\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q> & { pivotTo: L },\n): UseOsdkListResult<LinkedType<Q, L>>;\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q, RDPs> & { rids: readonly string[] },\n): UseOsdkListResult<Q, RDPs, \"$rid\">;\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, RDPs>,\n): UseOsdkListResult<Q, RDPs>;\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, RDPs>,\n):\n | UseOsdkListResult<Q, RDPs>\n | UseOsdkListResult<Q, RDPs, \"$rid\">\n | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>>\n | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>, {}, \"$rid\">\n{\n const { observableClient } = React.useContext(OsdkContext2);\n\n const {\n pageSize,\n dedupeIntervalMs,\n withProperties,\n enabled = true,\n rids,\n where,\n orderBy,\n streamUpdates,\n autoFetchMore,\n intersectWith,\n pivotTo,\n } = options ?? {};\n\n const canonWhere = observableClient.canonicalizeWhereClause<\n Q,\n RDPs\n >(where ?? {});\n\n const stableRids = React.useMemo(\n () => rids,\n [JSON.stringify(rids)],\n );\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableIntersectWith = React.useMemo(\n () => intersectWith,\n [JSON.stringify(intersectWith)],\n );\n\n const stableOrderBy = React.useMemo(\n () => orderBy,\n [JSON.stringify(orderBy)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<\n ObserveObjectsCallbackArgs<Q, RDPs>\n >(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} [DISABLED]`\n : void 0,\n );\n }\n\n return makeExternalStore<\n ObserveObjectsCallbackArgs<Q, RDPs>\n >(\n (observer) =>\n observableClient.observeList({\n type,\n rids: stableRids,\n where: canonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy: stableOrderBy,\n streamUpdates,\n withProperties: stableWithProperties,\n autoFetchMore,\n ...(stableIntersectWith\n ? { intersectWith: stableIntersectWith }\n : {}),\n ...(pivotTo ? { pivotTo } : {}),\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${\n stableRids ? `[${stableRids.length} rids]` : \"\"\n } ${JSON.stringify(canonWhere)}`\n : void 0,\n );\n },\n [\n enabled,\n observableClient,\n type,\n stableRids,\n canonWhere,\n dedupeIntervalMs,\n pageSize,\n stableOrderBy,\n streamUpdates,\n stableWithProperties,\n autoFetchMore,\n stableIntersectWith,\n pivotTo,\n ],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n let error: Error | undefined;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n\n return {\n fetchMore: listPayload?.hasMore ? listPayload.fetchMore : undefined,\n error,\n data: listPayload?.resolvedList,\n isLoading: enabled\n ? (listPayload?.status === \"loading\" || listPayload?.status === \"init\"\n || !listPayload)\n : false,\n isOptimistic: listPayload?.isOptimistic ?? false,\n totalCount: listPayload?.totalCount,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,OAAOA,KAAK,MAAM,OAAO;AACzB,SA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W,EAAEG,MAAM,KAAK,OAAO,EAAE;IAC1CD,KAAK,GAAG,IAAIE,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEA,OAAO;IACLC,SAAS,EAAEL,WAAW,EAAEM,OAAO,GAAGN,WAAW,CAACK,SAAS,GAAGE,SAAS;IACnEL,KAAK;IACLM,IAAI,EAAER,WAAW,EAAES,YAAY;IAC/BC,SAAS,EAAEtC,OAAO,GACb4B,WAAW,EAAEG,MAAM,KAAK,SAAS,IAAIH,WAAW,EAAEG,MAAM,KAAK,MAAM,IACjE,CAACH,WAAW,GACf,KAAK;IACTW,YAAY,EAAEX,WAAW,EAAEW,YAAY,IAAI,KAAK;IAChDC,UAAU,EAAEZ,WAAW,EAAEY;EAC3B,CAAC;AACH","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"useOsdkObjects.js","names":["React","makeExternalStore","OsdkContext2","EMPTY_WHERE","useOsdkObjects","type","options","observableClient","useContext","pageSize","dedupeIntervalMs","withProperties","enabled","rids","where","orderBy","streamUpdates","autoFetchMore","intersectWith","pivotTo","$select","canonWhere","canonicalizeWhereClause","stableCanonWhere","useMemo","JSON","stringify","stableRids","stableWithProperties","stableIntersectWith","stableOrderBy","stableSelect","subscribe","getSnapShot","unsubscribe","process","env","NODE_ENV","apiName","observer","observeList","dedupeInterval","select","length","listPayload","useSyncExternalStore","error","status","Error","fetchMore","hasMore","undefined","data","resolvedList","isLoading","isOptimistic","totalCount"],"sources":["useOsdkObjects.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n LinkedType,\n LinkNames,\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { ObserveObjectsCallbackArgs } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { makeExternalStore } from \"./makeExternalStore.js\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\nexport interface UseOsdkObjectsOptions<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n> {\n /**\n * Fetch objects by their RIDs (Resource Identifiers).\n * When provided, starts with a static objectset containing these RIDs.\n * Can be combined with `where` to filter the RID set, and with `orderBy` to sort results.\n *\n * @example\n * // Fetch specific objects by RID\n * useOsdkObjects(Employee, { rids: ['ri.foo.123', 'ri.foo.456'] })\n *\n * @example\n * // Fetch specific objects by RID, filtered by status\n * useOsdkObjects(Employee, {\n * rids: ['ri.foo.123', 'ri.foo.456', 'ri.foo.789'],\n * where: { status: 'active' }\n * })\n */\n rids?: readonly string[];\n\n /**\n * Standard OSDK Where clause with RDP support.\n * When used with `rids`, filters the RID set.\n * When used alone, filters all objects of the type.\n */\n where?: WhereClause<T, RDPs>;\n\n /**\n * Sort results by one or more properties.\n */\n orderBy?: {\n [K in PropertyKeys<T>]?: \"asc\" | \"desc\";\n };\n\n /**\n * The preferred page size for the list.\n */\n pageSize?: number;\n\n /**\n * Define derived properties (RDPs) to be computed server-side and attached to each object.\n * These properties will be available on the returned objects alongside their regular properties.\n */\n withProperties?: { [K in keyof RDPs]: DerivedProperty.Creator<T, RDPs[K]> };\n\n /**\n * The number of milliseconds to wait after the last observed list change.\n *\n * Two uses of `useOsdkObjects` with the same parameters will only trigger one\n * network request if the second is within `dedupeIntervalMs`.\n */\n dedupeIntervalMs?: number;\n\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute. It will still\n * return any cached data, but will not fetch from the server.\n *\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Intersect the results with additional object sets.\n * Each element defines a where clause for an object set to intersect with.\n * The final result will only include objects that match ALL conditions.\n */\n intersectWith?: Array<{\n where: WhereClause<T, RDPs>;\n }>;\n\n /**\n * Pivot to related objects through a link.\n * This changes the return type from T to the linked object type.\n */\n pivotTo?: LinkNames<T>;\n\n /**\n * Causes the list to automatically fetch more as soon as the previous page\n * has been loaded. If a number is provided, it will continue to automatically\n * fetch more until the list is at least that long.\n *\n * - `true`: Fetch all available pages automatically\n * - `number`: Fetch pages until at least this many items are loaded\n * - `undefined` (default): Only fetch the first page, user must call fetchMore()\n */\n autoFetchMore?: boolean | number;\n\n streamUpdates?: boolean;\n\n /**\n * Restrict which properties are returned for each object.\n * When provided, only the specified properties will be fetched,\n * reducing payload sizes for list views.\n *\n * @example\n * // Only fetch name and status properties\n * useOsdkObjects(Employee, { $select: [\"name\", \"status\"] })\n */\n $select?: readonly PropertyKeys<T>[];\n}\n\nexport interface UseOsdkListResult<\n T extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n EXTRA_OPTIONS extends never | \"$rid\" = never,\n> {\n /**\n * Function to fetch more pages (undefined if no more pages)\n */\n fetchMore: (() => Promise<void>) | undefined;\n\n /**\n * The fetched data with derived properties\n */\n data:\n | Osdk.Instance<\n T,\n \"$allBaseProperties\" | EXTRA_OPTIONS,\n PropertyKeys<T>,\n RDPs\n >[]\n | undefined;\n\n /**\n * Whether data is currently being loaded\n */\n isLoading: boolean;\n\n /**\n * Any error that occurred during fetching\n */\n error: Error | undefined;\n\n /**\n * Refers to whether the ordered list of objects (only considering the $primaryKey)\n * is optimistic or not.\n *\n * If you need to know if the contents of the list are optimistic you can\n * do that on a per object basis with useOsdkObject\n */\n isOptimistic: boolean;\n\n /**\n * The total count of objects matching the query (if available from the API)\n */\n totalCount?: string;\n}\n\nconst EMPTY_WHERE = {};\n\ndeclare const process: {\n env: {\n NODE_ENV: \"development\" | \"production\";\n };\n};\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n L extends LinkNames<Q>,\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q> & { pivotTo: L; rids: readonly string[] },\n): UseOsdkListResult<LinkedType<Q, L>, {}, \"$rid\">;\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n L extends LinkNames<Q>,\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q> & { pivotTo: L },\n): UseOsdkListResult<LinkedType<Q, L>>;\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n type: Q,\n options: UseOsdkObjectsOptions<Q, RDPs> & { rids: readonly string[] },\n): UseOsdkListResult<Q, RDPs, \"$rid\">;\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, RDPs>,\n): UseOsdkListResult<Q, RDPs>;\n\nexport function useOsdkObjects<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = {},\n>(\n type: Q,\n options?: UseOsdkObjectsOptions<Q, RDPs>,\n):\n | UseOsdkListResult<Q, RDPs>\n | UseOsdkListResult<Q, RDPs, \"$rid\">\n | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>>\n | UseOsdkListResult<LinkedType<Q, LinkNames<Q>>, {}, \"$rid\">\n{\n const { observableClient } = React.useContext(OsdkContext2);\n\n const {\n pageSize,\n dedupeIntervalMs,\n withProperties,\n enabled = true,\n rids,\n where,\n orderBy,\n streamUpdates,\n autoFetchMore,\n intersectWith,\n pivotTo,\n $select,\n } = options ?? {};\n\n const canonWhere = observableClient.canonicalizeWhereClause<\n Q,\n RDPs\n >(where ?? EMPTY_WHERE);\n\n const stableCanonWhere = React.useMemo(\n () => canonWhere,\n [JSON.stringify(canonWhere)],\n );\n\n const stableRids = React.useMemo(\n () => rids,\n [JSON.stringify(rids)],\n );\n\n const stableWithProperties = React.useMemo(\n () => withProperties,\n [JSON.stringify(withProperties)],\n );\n\n const stableIntersectWith = React.useMemo(\n () => intersectWith,\n [JSON.stringify(intersectWith)],\n );\n\n const stableOrderBy = React.useMemo(\n () => orderBy,\n [JSON.stringify(orderBy)],\n );\n\n const stableSelect = React.useMemo(\n () => $select,\n [JSON.stringify($select)],\n );\n\n const { subscribe, getSnapShot } = React.useMemo(\n () => {\n if (!enabled) {\n return makeExternalStore<\n ObserveObjectsCallbackArgs<Q, RDPs>\n >(\n () => ({ unsubscribe: () => {} }),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} [DISABLED]`\n : void 0,\n );\n }\n\n return makeExternalStore<\n ObserveObjectsCallbackArgs<Q, RDPs>\n >(\n (observer) =>\n observableClient.observeList({\n type,\n rids: stableRids,\n where: stableCanonWhere,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n pageSize,\n orderBy: stableOrderBy,\n streamUpdates,\n withProperties: stableWithProperties,\n autoFetchMore,\n ...(stableIntersectWith\n ? { intersectWith: stableIntersectWith }\n : {}),\n ...(pivotTo ? { pivotTo } : {}),\n ...(stableSelect ? { select: stableSelect } : {}),\n }, observer),\n process.env.NODE_ENV !== \"production\"\n ? `list ${type.apiName} ${\n stableRids ? `[${stableRids.length} rids]` : \"\"\n } ${JSON.stringify(stableCanonWhere)}`\n : void 0,\n );\n },\n [\n enabled,\n observableClient,\n type.apiName,\n type.type,\n stableRids,\n stableCanonWhere,\n dedupeIntervalMs,\n pageSize,\n stableOrderBy,\n streamUpdates,\n stableWithProperties,\n autoFetchMore,\n stableIntersectWith,\n pivotTo,\n stableSelect,\n ],\n );\n\n const listPayload = React.useSyncExternalStore(subscribe, getSnapShot);\n\n return React.useMemo(() => {\n let error: Error | undefined;\n if (listPayload && \"error\" in listPayload && listPayload.error) {\n error = listPayload.error;\n } else if (listPayload?.status === \"error\") {\n error = new Error(\"Failed to load objects\");\n }\n\n return {\n fetchMore: listPayload?.hasMore ? listPayload.fetchMore : undefined,\n error,\n data: listPayload?.resolvedList,\n isLoading: enabled\n ? (listPayload?.status === \"loading\" || listPayload?.status === \"init\"\n || !listPayload)\n : false,\n isOptimistic: listPayload?.isOptimistic ?? false,\n totalCount: listPayload?.totalCount,\n };\n }, [listPayload, enabled]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAaA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,YAAY,QAAQ,mBAAmB;AA0JhD,MAAMC,WAAW,GAAG,CAAC,CAAC;AAwCtB,OAAO,SAASC,cAAcA,CAI5BC,IAAO,EACPC,OAAwC,EAM1C;EACE,MAAM;IAAEC;EAAiB,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,YAAY,CAAC;EAE3D,MAAM;IACJO,QAAQ;IACRC,gBAAgB;IAChBC,cAAc;IACdC,OAAO,GAAG,IAAI;IACdC,IAAI;IACJC,KAAK;IACLC,OAAO;IACPC,aAAa;IACbC,aAAa;IACbC,aAAa;IACbC,OAAO;IACPC;EACF,CAAC,GAAGd,OAAO,IAAI,CAAC,CAAC;EAEjB,MAAMe,UAAU,GAAGd,gBAAgB,CAACe,uBAAuB,CAGzDR,KAAK,IAAIX,WAAW,CAAC;EAEvB,MAAMoB,gBAAgB,GAAGvB,KAAK,CAACwB,OAAO,CACpC,MAAMH,UAAU,EAChB,CAACI,IAAI,CAACC,SAAS,CAACL,UAAU,CAAC,CAC7B,CAAC;EAED,MAAMM,UAAU,GAAG3B,KAAK,CAACwB,OAAO,CAC9B,MAAMX,IAAI,EACV,CAACY,IAAI,CAACC,SAAS,CAACb,IAAI,CAAC,CACvB,CAAC;EAED,MAAMe,oBAAoB,GAAG5B,KAAK,CAACwB,OAAO,CACxC,MAAMb,cAAc,EACpB,CAACc,IAAI,CAACC,SAAS,CAACf,cAAc,CA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AAK;MAChDC,UAAU,EAAEZ,WAAW,EAAEY;IAC3B,CAAC;EACH,CAAC,EAAE,CAACZ,WAAW,EAAEhC,OAAO,CAAC,CAAC;AAC5B","ignoreList":[]}
|
|
@@ -14,22 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import { Employee } from "@osdk/client.test.ontology";
|
|
23
|
-
import { useOsdkObjects } from "@osdk/react/experimental";
|
|
24
|
-
function TestComponent() {
|
|
25
|
-
const {
|
|
26
|
-
data
|
|
27
|
-
} = useOsdkObjects(Employee, {
|
|
28
|
-
pivotTo: "lead"
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Line 31: Check that data has the correct pivoted type
|
|
32
|
-
data?.[0];
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=useOsdkObjectsWithPivot.js.map
|
|
17
|
+
export { useCurrentFoundryUser } from "../../new/platform-apis/admin/useCurrentFoundryUser.js";
|
|
18
|
+
export { useFoundryUser } from "../../new/platform-apis/admin/useFoundryUser.js";
|
|
19
|
+
export { useFoundryUsersList } from "../../new/platform-apis/admin/useFoundryUsersList.js";
|
|
20
|
+
//# sourceMappingURL=admin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.js","names":["useCurrentFoundryUser","useFoundryUser","useFoundryUsersList"],"sources":["admin.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { useCurrentFoundryUser } from \"../../new/platform-apis/admin/useCurrentFoundryUser.js\";\nexport { useFoundryUser } from \"../../new/platform-apis/admin/useFoundryUser.js\";\nexport { useFoundryUsersList } from \"../../new/platform-apis/admin/useFoundryUsersList.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,wDAAwD;AAC9F,SAASC,cAAc,QAAQ,iDAAiD;AAChF,SAASC,mBAAmB,QAAQ,sDAAsD","ignoreList":[]}
|
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
export { OsdkProvider2 } from "../new/OsdkProvider2.js";
|
|
18
|
-
export { useCurrentFoundryUser } from "../new/platform-apis/admin/useCurrentFoundryUser.js";
|
|
19
|
-
export { useFoundryUser } from "../new/platform-apis/admin/useFoundryUser.js";
|
|
20
|
-
export { useFoundryUsersList } from "../new/platform-apis/admin/useFoundryUsersList.js";
|
|
21
18
|
export { useLinks } from "../new/useLinks.js";
|
|
22
19
|
export { useObjectSet } from "../new/useObjectSet.js";
|
|
23
20
|
export { useOsdkAction } from "../new/useOsdkAction.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","names":["OsdkProvider2","
|
|
1
|
+
{"version":3,"file":"experimental.js","names":["OsdkProvider2","useLinks","useObjectSet","useOsdkAction","useOsdkAggregation","useOsdkFunction","useOsdkObject","useOsdkObjects","useOsdkClient","useOsdkMetadata","useDebouncedCallback"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { OsdkProvider2 } from \"../new/OsdkProvider2.js\";\nexport { useLinks } from \"../new/useLinks.js\";\nexport { useObjectSet } from \"../new/useObjectSet.js\";\nexport { useOsdkAction } from \"../new/useOsdkAction.js\";\nexport type { UseOsdkAggregationResult } from \"../new/useOsdkAggregation.js\";\nexport { useOsdkAggregation } from \"../new/useOsdkAggregation.js\";\nexport type {\n UseOsdkFunctionOptions,\n UseOsdkFunctionResult,\n} from \"../new/useOsdkFunction.js\";\nexport { useOsdkFunction } from \"../new/useOsdkFunction.js\";\nexport { useOsdkObject } from \"../new/useOsdkObject.js\";\nexport type {\n UseOsdkListResult,\n UseOsdkObjectsOptions,\n} from \"../new/useOsdkObjects.js\";\nexport { useOsdkObjects } from \"../new/useOsdkObjects.js\";\nexport { useOsdkClient } from \"../useOsdkClient.js\";\nexport { useOsdkMetadata } from \"../useOsdkMetadata.js\";\nexport type { UseOsdkMetadataResult } from \"../useOsdkMetadata.js\";\nexport { useDebouncedCallback } from \"../utils/useDebouncedCallback.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,QAAQ,yBAAyB;AACvD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,aAAa,QAAQ,yBAAyB;AAEvD,SAASC,kBAAkB,QAAQ,8BAA8B;AAKjE,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,aAAa,QAAQ,yBAAyB;AAKvD,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,SAASC,oBAAoB,QAAQ,kCAAkC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOsdkMetadata.js","names":["React","useOsdkClient","useOsdkMetadata","type","client","metadata","setMetadata","useState","undefined","error","setError","fetchMetadata","then","fetchedMetadata","catch","errorMessage","Error","message","String","loading"],"sources":["useOsdkMetadata.ts"],"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 type {\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n} from \"@osdk/api\";\nimport React from \"react\";\nimport { useOsdkClient } from \"./useOsdkClient.js\";\n\ntype MetadataFor<T extends
|
|
1
|
+
{"version":3,"file":"useOsdkMetadata.js","names":["React","useOsdkClient","useOsdkMetadata","type","client","metadata","setMetadata","useState","undefined","error","setError","fetchMetadata","then","fetchedMetadata","catch","errorMessage","Error","message","String","loading"],"sources":["useOsdkMetadata.ts"],"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 type {\n ActionDefinition,\n ActionMetadata,\n InterfaceDefinition,\n InterfaceMetadata,\n ObjectMetadata,\n ObjectOrInterfaceDefinition,\n ObjectTypeDefinition,\n} from \"@osdk/api\";\nimport React from \"react\";\nimport { useOsdkClient } from \"./useOsdkClient.js\";\n\ntype MetadataFetchableDefinition =\n | ObjectOrInterfaceDefinition\n | ActionDefinition<any>;\n\ntype MetadataFor<T extends MetadataFetchableDefinition> = T extends\n ObjectTypeDefinition ? ObjectMetadata\n : T extends InterfaceDefinition ? InterfaceMetadata\n : T extends ActionDefinition<any> ? ActionMetadata\n : never;\n\nexport interface UseOsdkMetadataResult<T extends MetadataFetchableDefinition> {\n loading: boolean;\n metadata?: MetadataFor<T>;\n error?: string;\n}\n\nexport function useOsdkMetadata<T extends MetadataFetchableDefinition>(\n type: T,\n): UseOsdkMetadataResult<T> {\n const client = useOsdkClient();\n const [metadata, setMetadata] = React.useState<\n MetadataFor<T> | undefined\n >(undefined);\n const [error, setError] = React.useState<UseOsdkMetadataResult<T>[\"error\"]>();\n\n if (!metadata && !error) {\n client.fetchMetadata(type).then((fetchedMetadata) => {\n setMetadata(fetchedMetadata as MetadataFor<T>);\n }).catch((error: unknown) => {\n const errorMessage = error instanceof Error\n ? error.message\n : String(error);\n setError(errorMessage);\n });\n return { loading: true };\n }\n\n return { loading: false, metadata, error };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,aAAa,QAAQ,oBAAoB;AAkBlD,OAAO,SAASC,eAAeA,CAC7BC,IAAO,EACmB;EAC1B,MAAMC,MAAM,GAAGH,aAAa,CAAC,CAAC;EAC9B,MAAM,CAACI,QAAQ,EAAEC,WAAW,CAAC,GAAGN,KAAK,CAACO,QAAQ,CAE5CC,SAAS,CAAC;EACZ,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGV,KAAK,CAACO,QAAQ,CAAoC,CAAC;EAE7E,IAAI,CAACF,QAAQ,IAAI,CAACI,KAAK,EAAE;IACvBL,MAAM,CAACO,aAAa,CAACR,IAAI,CAAC,CAACS,IAAI,CAAEC,eAAe,IAAK;MACnDP,WAAW,CAACO,eAAiC,CAAC;IAChD,CAAC,CAAC,CAACC,KAAK,CAAEL,KAAc,IAAK;MAC3B,MAAMM,YAAY,GAAGN,KAAK,YAAYO,KAAK,GACvCP,KAAK,CAACQ,OAAO,GACbC,MAAM,CAACT,KAAK,CAAC;MACjBC,QAAQ,CAACK,YAAY,CAAC;IACxB,CAAC,CAAC;IACF,OAAO;MAAEI,OAAO,EAAE;IAAK,CAAC;EAC1B;EAEA,OAAO;IAAEA,OAAO,EAAE,KAAK;IAAEd,QAAQ;IAAEI;EAAM,CAAC;AAC5C","ignoreList":[]}
|
|
@@ -6,11 +6,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
6
6
|
|
|
7
7
|
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name in all)
|
|
12
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
13
|
-
};
|
|
9
|
+
// src/useOsdkClient.ts
|
|
14
10
|
function fakeClientFn(..._args) {
|
|
15
11
|
throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
|
|
16
12
|
}
|
|
@@ -48,8 +44,7 @@ function useOsdkMetadata(type) {
|
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
exports.OsdkContext = OsdkContext;
|
|
51
|
-
exports.__export = __export;
|
|
52
47
|
exports.useOsdkClient = useOsdkClient;
|
|
53
48
|
exports.useOsdkMetadata = useOsdkMetadata;
|
|
54
|
-
//# sourceMappingURL=chunk-
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-OVBG5VXE.cjs.map
|
|
50
|
+
//# sourceMappingURL=chunk-OVBG5VXE.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/OsdkContext.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ent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nfunction fakeClientFn(..._args) {\n throw new Error(\"This is not a real client. Did you forget to <OsdkContext.Provider>?\");\n}\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn\n});\nexport const OsdkContext = /*#__PURE__*/React.createContext({\n client: fakeClient\n});","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nexport function useOsdkClient() {\n return React.useContext(OsdkContext).client;\n}","/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\nimport { useOsdkClient } from \"./useOsdkClient.js\";\nexport function useOsdkMetadata(type) {\n const client = useOsdkClient();\n const [metadata, setMetadata] = React.useState(undefined);\n const [error, setError] = React.useState();\n if (!metadata && !error) {\n client.fetchMetadata(type).then(fetchedMetadata => {\n setMetadata(fetchedMetadata);\n }).catch(error => {\n const errorMessage = error instanceof Error ? error.message : String(error);\n setError(errorMessage);\n });\n return {\n loading: true\n };\n }\n return {\n loading: false,\n metadata,\n error\n };\n}"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
|
+
|
|
7
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
8
|
+
|
|
9
|
+
// src/new/OsdkContext2.ts
|
|
10
|
+
function fakeClientFn(..._args) {
|
|
11
|
+
throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
|
|
12
|
+
}
|
|
13
|
+
var fakeClient = Object.assign(fakeClientFn, {
|
|
14
|
+
fetchMetadata: fakeClientFn
|
|
15
|
+
});
|
|
16
|
+
var OsdkContext2 = /* @__PURE__ */ React__default.default.createContext({
|
|
17
|
+
client: fakeClient,
|
|
18
|
+
observableClient: void 0
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// src/new/makeExternalStore.ts
|
|
22
|
+
function makeExternalStore(createObservation, _name, initialValue) {
|
|
23
|
+
let lastResult = initialValue;
|
|
24
|
+
function getSnapShot() {
|
|
25
|
+
return lastResult;
|
|
26
|
+
}
|
|
27
|
+
function subscribe(notifyUpdate) {
|
|
28
|
+
const obs = createObservation({
|
|
29
|
+
next: (payload) => {
|
|
30
|
+
lastResult = payload;
|
|
31
|
+
notifyUpdate();
|
|
32
|
+
},
|
|
33
|
+
error: (error) => {
|
|
34
|
+
lastResult = {
|
|
35
|
+
...lastResult ?? {},
|
|
36
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
37
|
+
};
|
|
38
|
+
notifyUpdate();
|
|
39
|
+
},
|
|
40
|
+
complete: () => {
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return () => {
|
|
44
|
+
obs.unsubscribe();
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
subscribe,
|
|
49
|
+
getSnapShot
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function makeExternalStoreAsync(createObservation, _name, initialValue) {
|
|
53
|
+
let lastResult = initialValue;
|
|
54
|
+
function getSnapShot() {
|
|
55
|
+
return lastResult;
|
|
56
|
+
}
|
|
57
|
+
function subscribe(notifyUpdate) {
|
|
58
|
+
let isActive = true;
|
|
59
|
+
let currentSubscription;
|
|
60
|
+
const subscriptionPromise = createObservation({
|
|
61
|
+
next: (payload) => {
|
|
62
|
+
if (isActive) {
|
|
63
|
+
lastResult = payload;
|
|
64
|
+
notifyUpdate();
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
error: (error) => {
|
|
68
|
+
if (isActive) {
|
|
69
|
+
lastResult = {
|
|
70
|
+
...lastResult ?? {},
|
|
71
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
72
|
+
};
|
|
73
|
+
notifyUpdate();
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
complete: () => {
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
subscriptionPromise.then((sub) => {
|
|
80
|
+
if (isActive) {
|
|
81
|
+
currentSubscription = sub;
|
|
82
|
+
} else {
|
|
83
|
+
sub.unsubscribe();
|
|
84
|
+
}
|
|
85
|
+
}).catch((error) => {
|
|
86
|
+
if (isActive) {
|
|
87
|
+
lastResult = {
|
|
88
|
+
...lastResult ?? {},
|
|
89
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
90
|
+
};
|
|
91
|
+
notifyUpdate();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return () => {
|
|
95
|
+
isActive = false;
|
|
96
|
+
if (currentSubscription) {
|
|
97
|
+
currentSubscription.unsubscribe();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
subscribe,
|
|
103
|
+
getSnapShot
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
exports.OsdkContext2 = OsdkContext2;
|
|
108
|
+
exports.makeExternalStore = makeExternalStore;
|
|
109
|
+
exports.makeExternalStoreAsync = makeExternalStoreAsync;
|
|
110
|
+
//# sourceMappingURL=chunk-SVVMLSKN.cjs.map
|
|
111
|
+
//# sourceMappingURL=chunk-SVVMLSKN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/new/OsdkContext2.ts","../../src/new/makeExternalStore.ts"],"names":[],"mappings":";;;;;;;;;AAiBA,SAAS,gBAAgB,KAAO,EAAA;AAC9B,EAAM,MAAA,IAAI,MAAM,sEAAsE,CAAA;AACxF;AACA,IAAM,UAAA,GAAa,MAAO,CAAA,MAAA,CAAO,YAAc,EAAA;AAAA,EAC7C,aAAe,EAAA;AACjB,CAAC,CAAA;AACY,IAAA,YAAA,0CAAkC,aAAc,CAAA;AAAA,EAC3D,MAAQ,EAAA,UAAA;AAAA,EACR,gBAAkB,EAAA;AACpB,CAAC;;;ACVM,SAAS,iBAAA,CAAkB,iBAAmB,EAAA,KAAA,EAAO,YAAc,EAAA;AACxE,EAAA,IAAI,UAAa,GAAA,YAAA;AACjB,EAAA,SAAS,WAAc,GAAA;AACrB,IAAO,OAAA,UAAA;AAAA;AAET,EAAA,SAAS,UAAU,YAAc,EAAA;AAC/B,IAAA,MAAM,MAAM,iBAAkB,CAAA;AAAA,MAC5B,MAAM,CAAW,OAAA,KAAA;AACf,QAAa,UAAA,GAAA,OAAA;AACb,QAAa,YAAA,EAAA;AAAA,OACf;AAAA,MACA,OAAO,CAAS,KAAA,KAAA;AACd,QAAa,UAAA,GAAA;AAAA,UACX,GAAI,cAAc,EAAC;AAAA,UACnB,K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AAAA;AAClB,KACD,CAAE,CAAA,KAAA,CAAM,CAAS,KAAA,KAAA;AAChB,MAAA,IAAI,QAAU,EAAA;AACZ,QAAa,UAAA,GAAA;AAAA,UACX,GAAI,cAAc,EAAC;AAAA,UACnB,KAAA,EAAO,iBAAiB,KAAQ,GAAA,KAAA,GAAQ,IAAI,KAAM,CAAA,MAAA,CAAO,KAAK,CAAC;AAAA,SACjE;AACA,QAAa,YAAA,EAAA;AAAA;AACf,KACD,CAAA;AACD,IAAA,OAAO,MAAM;AACX,MAAW,QAAA,GAAA,KAAA;AACX,MAAA,IAAI,mBAAqB,EAAA;AACvB,QAAA,mBAAA,CAAoB,WAAY,EAAA;AAAA;AAClC,KACF;AAAA;AAEF,EAAO,OAAA;AAAA,IACL,SAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-SVVMLSKN.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 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function makeExternalStore(createObservation, _name, initialValue) {\n let lastResult = initialValue;\n function getSnapShot() {\n return lastResult;\n }\n function subscribe(notifyUpdate) {\n const obs = createObservation({\n next: payload => {\n lastResult = payload;\n notifyUpdate();\n },\n error: error => {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error))\n };\n notifyUpdate();\n },\n complete: () => {}\n });\n return () => {\n obs.unsubscribe();\n };\n }\n return {\n subscribe,\n getSnapShot\n };\n}\n\n/**\n * Like makeExternalStore but for async subscription creation.\n *\n * Uses an isActive flag to handle race conditions:\n * If cleanup runs before promise resolves, the stale subscription is\n * immediately unsubscribed when it eventually resolves\n */\nexport function makeExternalStoreAsync(createObservation, _name, initialValue) {\n let lastResult = initialValue;\n function getSnapShot() {\n return lastResult;\n }\n function subscribe(notifyUpdate) {\n let isActive = true;\n let currentSubscription;\n const subscriptionPromise = createObservation({\n next: payload => {\n if (isActive) {\n lastResult = payload;\n notifyUpdate();\n }\n },\n error: error => {\n if (isActive) {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error))\n };\n notifyUpdate();\n }\n },\n complete: () => {}\n });\n subscriptionPromise.then(sub => {\n if (isActive) {\n currentSubscription = sub;\n } else {\n sub.unsubscribe();\n }\n }).catch(error => {\n if (isActive) {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error))\n };\n notifyUpdate();\n }\n });\n return () => {\n isActive = false;\n if (currentSubscription) {\n currentSubscription.unsubscribe();\n }\n };\n }\n return {\n subscribe,\n getSnapShot\n };\n}"]}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkOVBG5VXE_cjs = require('./chunk-OVBG5VXE.cjs');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
|
|
6
6
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -11,7 +11,7 @@ function OsdkProvider({
|
|
|
11
11
|
children,
|
|
12
12
|
client
|
|
13
13
|
}) {
|
|
14
|
-
return /* @__PURE__ */ React__default.default.createElement(
|
|
14
|
+
return /* @__PURE__ */ React__default.default.createElement(chunkOVBG5VXE_cjs.OsdkContext.Provider, {
|
|
15
15
|
value: {
|
|
16
16
|
client
|
|
17
17
|
}
|
|
@@ -20,11 +20,11 @@ function OsdkProvider({
|
|
|
20
20
|
|
|
21
21
|
Object.defineProperty(exports, "useOsdkClient", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkClient; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "useOsdkMetadata", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkOVBG5VXE_cjs.useOsdkMetadata; }
|
|
28
28
|
});
|
|
29
29
|
exports.OsdkProvider = OsdkProvider;
|
|
30
30
|
//# sourceMappingURL=index.cjs.map
|
package/build/cjs/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Client } from '@osdk/client';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export { u as useOsdkClient, a as useOsdkMetadata } from './useOsdkMetadata-
|
|
3
|
+
export { u as useOsdkClient, a as useOsdkMetadata } from './useOsdkMetadata-BElt3F5s.cjs';
|
|
4
4
|
import '@osdk/api';
|
|
5
5
|
|
|
6
6
|
declare function OsdkProvider({ children, client, }: {
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkSVVMLSKN_cjs = require('../../chunk-SVVMLSKN.cjs');
|
|
4
|
+
var foundry_admin = require('@osdk/foundry.admin');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
10
|
+
|
|
11
|
+
function usePlatformQuery({
|
|
12
|
+
query,
|
|
13
|
+
queryName,
|
|
14
|
+
enabled = true
|
|
15
|
+
}) {
|
|
16
|
+
const observerRef = React__default.default.useRef();
|
|
17
|
+
const handleQuery = React__default.default.useCallback(() => {
|
|
18
|
+
const observer = observerRef.current;
|
|
19
|
+
if (observer == null) return;
|
|
20
|
+
observer.next({
|
|
21
|
+
status: "loading",
|
|
22
|
+
data: void 0
|
|
23
|
+
});
|
|
24
|
+
query().then((data) => {
|
|
25
|
+
observer.next({
|
|
26
|
+
status: "success",
|
|
27
|
+
data
|
|
28
|
+
});
|
|
29
|
+
}).catch((err) => {
|
|
30
|
+
observer.error(err);
|
|
31
|
+
});
|
|
32
|
+
}, [query]);
|
|
33
|
+
const {
|
|
34
|
+
subscribe,
|
|
35
|
+
getSnapShot
|
|
36
|
+
} = React__default.default.useMemo(() => {
|
|
37
|
+
if (!enabled) {
|
|
38
|
+
return chunkSVVMLSKN_cjs.makeExternalStore(() => ({
|
|
39
|
+
unsubscribe: () => {
|
|
40
|
+
}
|
|
41
|
+
}), process.env.NODE_ENV !== "production" ? `${queryName} Query [DISABLED]` : void 0);
|
|
42
|
+
}
|
|
43
|
+
return chunkSVVMLSKN_cjs.makeExternalStore((observer) => {
|
|
44
|
+
observerRef.current = observer;
|
|
45
|
+
handleQuery();
|
|
46
|
+
return {
|
|
47
|
+
unsubscribe: () => {
|
|
48
|
+
observerRef.current = void 0;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}, queryName);
|
|
52
|
+
}, [enabled, queryName, handleQuery]);
|
|
53
|
+
const payload = React__default.default.useSyncExternalStore(subscribe, getSnapShot);
|
|
54
|
+
let error;
|
|
55
|
+
if (payload && "error" in payload && payload.error != null) {
|
|
56
|
+
error = payload.error;
|
|
57
|
+
} else if (payload?.status === "error") {
|
|
58
|
+
error = new Error(`Failed to query platform API: ${queryName}`);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
data: payload?.data,
|
|
62
|
+
isLoading: enabled ? payload?.status === "loading" || !payload : false,
|
|
63
|
+
error,
|
|
64
|
+
refetch: handleQuery
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/new/platform-apis/admin/useCurrentFoundryUser.ts
|
|
69
|
+
function useCurrentFoundryUser({
|
|
70
|
+
enabled = true
|
|
71
|
+
} = {}) {
|
|
72
|
+
const {
|
|
73
|
+
client
|
|
74
|
+
} = React__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
75
|
+
const handleQuery = React__default.default.useCallback(() => foundry_admin.Users.getCurrent(client), [client]);
|
|
76
|
+
const query = usePlatformQuery({
|
|
77
|
+
query: handleQuery,
|
|
78
|
+
enabled,
|
|
79
|
+
queryName: "foundry-current-user"
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
currentUser: query.data,
|
|
83
|
+
isLoading: query.isLoading,
|
|
84
|
+
error: query.error,
|
|
85
|
+
refetch: query.refetch
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function useFoundryUser(userId, {
|
|
89
|
+
enabled = true,
|
|
90
|
+
status = "ACTIVE"
|
|
91
|
+
} = {}) {
|
|
92
|
+
const {
|
|
93
|
+
client
|
|
94
|
+
} = React__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
95
|
+
const handleQuery = React__default.default.useCallback(() => {
|
|
96
|
+
return foundry_admin.Users.get(client, userId, {
|
|
97
|
+
status
|
|
98
|
+
});
|
|
99
|
+
}, [client, userId, status]);
|
|
100
|
+
const query = usePlatformQuery({
|
|
101
|
+
query: handleQuery,
|
|
102
|
+
enabled,
|
|
103
|
+
queryName: "foundry-user"
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
user: query.data,
|
|
107
|
+
isLoading: query.isLoading,
|
|
108
|
+
error: query.error,
|
|
109
|
+
refetch: query.refetch
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function useFoundryUsersList({
|
|
113
|
+
enabled = true,
|
|
114
|
+
include = "ACTIVE",
|
|
115
|
+
pageSize = 1e3,
|
|
116
|
+
pageToken
|
|
117
|
+
} = {}) {
|
|
118
|
+
const {
|
|
119
|
+
client
|
|
120
|
+
} = React__default.default.useContext(chunkSVVMLSKN_cjs.OsdkContext2);
|
|
121
|
+
const handleQuery = React__default.default.useCallback(() => {
|
|
122
|
+
return foundry_admin.Users.list(client, {
|
|
123
|
+
include,
|
|
124
|
+
pageSize,
|
|
125
|
+
pageToken
|
|
126
|
+
});
|
|
127
|
+
}, [client, include, pageSize, pageToken]);
|
|
128
|
+
const query = usePlatformQuery({
|
|
129
|
+
query: handleQuery,
|
|
130
|
+
enabled,
|
|
131
|
+
queryName: "foundry-users-list"
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
users: query.data?.data,
|
|
135
|
+
nextPageToken: query.data?.nextPageToken,
|
|
136
|
+
isLoading: query.isLoading,
|
|
137
|
+
error: query.error,
|
|
138
|
+
refetch: query.refetch
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
exports.useCurrentFoundryUser = useCurrentFoundryUser;
|
|
143
|
+
exports.useFoundryUser = useFoundryUser;
|
|
144
|
+
exports.useFoundryUsersList = useFoundryUsersList;
|
|
145
|
+
//# sourceMappingURL=admin.cjs.map
|
|
146
|
+
//# sourceMappingURL=admin.cjs.map
|