@osdk/react 0.10.0-beta.9 → 0.10.1-main-20260406220320

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/build/browser/new/OsdkContext2.js +22 -2
  3. package/build/browser/new/OsdkContext2.js.map +1 -1
  4. package/build/browser/new/hookUtils.js +32 -0
  5. package/build/browser/new/hookUtils.js.map +1 -0
  6. package/build/browser/new/platform-apis/admin/useCbacBanner.js +63 -0
  7. package/build/browser/new/platform-apis/admin/useCbacBanner.js.map +1 -0
  8. package/build/browser/new/platform-apis/admin/useCbacMarkingRestrictions.js +64 -0
  9. package/build/browser/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -0
  10. package/build/browser/new/platform-apis/admin/useMarkingCategories.js +46 -0
  11. package/build/browser/new/platform-apis/admin/useMarkingCategories.js.map +1 -0
  12. package/build/browser/new/platform-apis/admin/useMarkings.js +46 -0
  13. package/build/browser/new/platform-apis/admin/useMarkings.js.map +1 -0
  14. package/build/browser/new/platform-apis/admin/useUserMarkings.js +50 -0
  15. package/build/browser/new/platform-apis/admin/useUserMarkings.js.map +1 -0
  16. package/build/browser/new/useLinks.js +13 -10
  17. package/build/browser/new/useLinks.js.map +1 -1
  18. package/build/browser/new/useObjectSet.js +45 -26
  19. package/build/browser/new/useObjectSet.js.map +1 -1
  20. package/build/browser/new/useOsdkAction.js +3 -6
  21. package/build/browser/new/useOsdkAction.js.map +1 -1
  22. package/build/browser/new/useOsdkAggregation.js +32 -38
  23. package/build/browser/new/useOsdkAggregation.js.map +1 -1
  24. package/build/browser/new/useOsdkFunctions.js +137 -0
  25. package/build/browser/new/useOsdkFunctions.js.map +1 -0
  26. package/build/browser/new/useOsdkObject.js +6 -2
  27. package/build/browser/new/useOsdkObject.js.map +1 -1
  28. package/build/browser/new/useOsdkObjects.js +36 -33
  29. package/build/browser/new/useOsdkObjects.js.map +1 -1
  30. package/build/browser/public/experimental/admin.js +5 -0
  31. package/build/browser/public/experimental/admin.js.map +1 -1
  32. package/build/browser/public/unstable-do-not-use.js +18 -0
  33. package/build/browser/public/unstable-do-not-use.js.map +1 -0
  34. package/build/cjs/chunk-2N32USW5.cjs +28 -0
  35. package/build/cjs/chunk-2N32USW5.cjs.map +1 -0
  36. package/build/cjs/chunk-R4FZ5MUH.cjs +34 -0
  37. package/build/cjs/chunk-R4FZ5MUH.cjs.map +1 -0
  38. package/build/cjs/{chunk-SVVMLSKN.cjs → chunk-ZUNR45SJ.cjs} +15 -4
  39. package/build/cjs/chunk-ZUNR45SJ.cjs.map +1 -0
  40. package/build/cjs/index.cjs +7 -6
  41. package/build/cjs/index.cjs.map +1 -1
  42. package/build/cjs/public/experimental/admin.cjs +154 -7
  43. package/build/cjs/public/experimental/admin.cjs.map +1 -1
  44. package/build/cjs/public/experimental/admin.d.cts +159 -2
  45. package/build/cjs/public/experimental.cjs +170 -135
  46. package/build/cjs/public/experimental.cjs.map +1 -1
  47. package/build/cjs/public/experimental.d.cts +21 -124
  48. package/build/cjs/public/unstable-do-not-use.cjs +114 -0
  49. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -0
  50. package/build/cjs/public/unstable-do-not-use.d.cts +35 -0
  51. package/build/cjs/useOsdkFunction-B0s7lqgN.d.cts +121 -0
  52. package/build/esm/new/OsdkContext2.js +22 -2
  53. package/build/esm/new/OsdkContext2.js.map +1 -1
  54. package/build/esm/new/hookUtils.js +32 -0
  55. package/build/esm/new/hookUtils.js.map +1 -0
  56. package/build/esm/new/platform-apis/admin/useCbacBanner.js +63 -0
  57. package/build/esm/new/platform-apis/admin/useCbacBanner.js.map +1 -0
  58. package/build/esm/new/platform-apis/admin/useCbacMarkingRestrictions.js +64 -0
  59. package/build/esm/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -0
  60. package/build/esm/new/platform-apis/admin/useMarkingCategories.js +46 -0
  61. package/build/esm/new/platform-apis/admin/useMarkingCategories.js.map +1 -0
  62. package/build/esm/new/platform-apis/admin/useMarkings.js +46 -0
  63. package/build/esm/new/platform-apis/admin/useMarkings.js.map +1 -0
  64. package/build/esm/new/platform-apis/admin/useUserMarkings.js +50 -0
  65. package/build/esm/new/platform-apis/admin/useUserMarkings.js.map +1 -0
  66. package/build/esm/new/useLinks.js +13 -10
  67. package/build/esm/new/useLinks.js.map +1 -1
  68. package/build/esm/new/useObjectSet.js +45 -26
  69. package/build/esm/new/useObjectSet.js.map +1 -1
  70. package/build/esm/new/useOsdkAction.js +3 -6
  71. package/build/esm/new/useOsdkAction.js.map +1 -1
  72. package/build/esm/new/useOsdkAggregation.js +32 -38
  73. package/build/esm/new/useOsdkAggregation.js.map +1 -1
  74. package/build/esm/new/useOsdkFunctions.js +137 -0
  75. package/build/esm/new/useOsdkFunctions.js.map +1 -0
  76. package/build/esm/new/useOsdkObject.js +6 -2
  77. package/build/esm/new/useOsdkObject.js.map +1 -1
  78. package/build/esm/new/useOsdkObjects.js +36 -33
  79. package/build/esm/new/useOsdkObjects.js.map +1 -1
  80. package/build/esm/public/experimental/admin.js +5 -0
  81. package/build/esm/public/experimental/admin.js.map +1 -1
  82. package/build/esm/public/unstable-do-not-use.js +18 -0
  83. package/build/esm/public/unstable-do-not-use.js.map +1 -0
  84. package/build/types/new/OsdkContext2.d.ts +1 -0
  85. package/build/types/new/OsdkContext2.d.ts.map +1 -1
  86. package/build/types/new/hookUtils.d.ts +7 -0
  87. package/build/types/new/hookUtils.d.ts.map +1 -0
  88. package/build/types/new/platform-apis/admin/useCbacBanner.d.ts +33 -0
  89. package/build/types/new/platform-apis/admin/useCbacBanner.d.ts.map +1 -0
  90. package/build/types/new/platform-apis/admin/useCbacMarkingRestrictions.d.ts +34 -0
  91. package/build/types/new/platform-apis/admin/useCbacMarkingRestrictions.d.ts.map +1 -0
  92. package/build/types/new/platform-apis/admin/useMarkingCategories.d.ts +27 -0
  93. package/build/types/new/platform-apis/admin/useMarkingCategories.d.ts.map +1 -0
  94. package/build/types/new/platform-apis/admin/useMarkings.d.ts +27 -0
  95. package/build/types/new/platform-apis/admin/useMarkings.d.ts.map +1 -0
  96. package/build/types/new/platform-apis/admin/useUserMarkings.d.ts +33 -0
  97. package/build/types/new/platform-apis/admin/useUserMarkings.d.ts.map +1 -0
  98. package/build/types/new/useLinks.d.ts.map +1 -1
  99. package/build/types/new/useObjectSet.d.ts +5 -2
  100. package/build/types/new/useObjectSet.d.ts.map +1 -1
  101. package/build/types/new/useOsdkAggregation.d.ts +1 -1
  102. package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
  103. package/build/types/new/useOsdkFunctions.d.ts +31 -0
  104. package/build/types/new/useOsdkFunctions.d.ts.map +1 -0
  105. package/build/types/new/useOsdkObject.d.ts +2 -1
  106. package/build/types/new/useOsdkObject.d.ts.map +1 -1
  107. package/build/types/new/useOsdkObjects.d.ts +10 -1
  108. package/build/types/new/useOsdkObjects.d.ts.map +1 -1
  109. package/build/types/public/experimental/admin.d.ts +8 -0
  110. package/build/types/public/experimental/admin.d.ts.map +1 -1
  111. package/build/types/public/unstable-do-not-use.d.ts +2 -0
  112. package/build/types/public/unstable-do-not-use.d.ts.map +1 -0
  113. package/package.json +19 -10
  114. package/unstable-do-not-use.d.ts +17 -0
  115. package/build/cjs/chunk-OVBG5VXE.cjs +0 -50
  116. package/build/cjs/chunk-OVBG5VXE.cjs.map +0 -1
  117. package/build/cjs/chunk-SVVMLSKN.cjs.map +0 -1
@@ -0,0 +1,35 @@
1
+ import { QueryDefinition } from '@osdk/api';
2
+ import { U as UseOsdkFunctionOptions, a as UseOsdkFunctionResult } from '../useOsdkFunction-B0s7lqgN.cjs';
3
+ import '@osdk/client/unstable-do-not-use';
4
+
5
+ interface FunctionQueryParams<Q extends QueryDefinition<unknown>> {
6
+ queryDefinition: Q;
7
+ /**
8
+ * Only allow params and enabled options at the query level,
9
+ * other options are not yet supported in this batch context
10
+ */
11
+ options?: Pick<UseOsdkFunctionOptions<Q>, "params" | "enabled">;
12
+ }
13
+ interface UseOsdkFunctionsProps {
14
+ /**
15
+ * Array of query configurations to execute
16
+ */
17
+ queries: Array<FunctionQueryParams<QueryDefinition<unknown>>>;
18
+ /**
19
+ * Whether to enable all queries. When false, no queries will execute.
20
+ * Individual query enabled states are also respected.
21
+ * @default true
22
+ */
23
+ enabled?: boolean;
24
+ }
25
+ type UseOsdkFunctionsResult = Array<Omit<UseOsdkFunctionResult<QueryDefinition<unknown>>, "refetch">>;
26
+ /**
27
+ * React hook for executing multiple OSDK function queries in parallel.
28
+ * Results are returned in the same order as the input queries.
29
+ *
30
+ * @param options - Configuration options containing the queries to execute
31
+ * @returns Array of results in the same order as input queries, each with the same shape as useOsdkFunction
32
+ */
33
+ declare function useOsdkFunctions({ queries, enabled }: UseOsdkFunctionsProps): UseOsdkFunctionsResult;
34
+
35
+ export { type FunctionQueryParams, type UseOsdkFunctionsProps, type UseOsdkFunctionsResult, useOsdkFunctions };
@@ -0,0 +1,121 @@
1
+ import { QueryDefinition, CompileTimeMetadata, ObjectTypeDefinition, Osdk, ObjectSet } from '@osdk/api';
2
+ import { QueryParameterType } from '@osdk/client/unstable-do-not-use';
3
+
4
+ interface UseOsdkFunctionOptions<Q extends QueryDefinition<unknown>> {
5
+ /**
6
+ * Parameters to pass to the function.
7
+ * Must include all required parameters; optional parameters can be omitted.
8
+ */
9
+ params?: CompileTimeMetadata<Q>["parameters"] extends Record<string, never> ? undefined : QueryParameterType<CompileTimeMetadata<Q>["parameters"]>;
10
+ /**
11
+ * Object types this function depends on.
12
+ * When actions modify objects of these types, the function will automatically refetch.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * // Refetch when any Employee object changes
17
+ * { dependsOn: [Employee] }
18
+ * ```
19
+ */
20
+ dependsOn?: Array<ObjectTypeDefinition | string>;
21
+ /**
22
+ * Specific object instances or ObjectSets this function depends on.
23
+ * When any of these specific objects change, the function will refetch.
24
+ * More fine-grained than dependsOn for precise invalidation control.
25
+ *
26
+ * For ObjectSets, the object type is extracted asynchronously and changes
27
+ * to any object of that type will trigger a refetch.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * // Refetch when this specific employee changes
32
+ * { dependsOnObjects: [employee] }
33
+ *
34
+ * // Refetch when any object in the ObjectSet's type changes
35
+ * { dependsOnObjects: [employeeObjectSet] }
36
+ * ```
37
+ */
38
+ dependsOnObjects?: Array<Osdk.Instance<ObjectTypeDefinition> | ObjectSet<ObjectTypeDefinition>>;
39
+ /**
40
+ * The number of milliseconds to dedupe identical function calls.
41
+ * Two calls with the same function and params will share results
42
+ * if the second call is within this interval of the first.
43
+ * @default 2000
44
+ */
45
+ dedupeIntervalMs?: number;
46
+ /**
47
+ * Whether to enable the query. When false, the query will not execute.
48
+ * Useful for:
49
+ * - Dependent queries that need to wait for other data
50
+ * - Conditional queries based on component state
51
+ *
52
+ * @default true
53
+ * @example
54
+ * // Dependent query - wait for required data
55
+ * const { data: employee } = useOsdkObject(Employee, employeeId);
56
+ * const { data: report } = useOsdkFunction(getEmployeeReport, {
57
+ * params: { employeeId: employee?.$primaryKey },
58
+ * enabled: !!employee
59
+ * });
60
+ */
61
+ enabled?: boolean;
62
+ }
63
+ interface UseOsdkFunctionResult<Q extends QueryDefinition<unknown>> {
64
+ /**
65
+ * The function result, or undefined if not yet loaded or on error.
66
+ */
67
+ data: (CompileTimeMetadata<Q>["signature"] extends (...args: never[]) => infer R ? Awaited<R> : never) | undefined;
68
+ /**
69
+ * True while the function is executing.
70
+ */
71
+ isLoading: boolean;
72
+ /**
73
+ * Error if the function execution failed.
74
+ */
75
+ error: Error | undefined;
76
+ /**
77
+ * Timestamp (ms since epoch) of when the result was last fetched.
78
+ */
79
+ lastUpdated: number;
80
+ /**
81
+ * Manually refetch the function.
82
+ * Useful for "pull to refresh" or retry patterns.
83
+ */
84
+ refetch: () => void;
85
+ }
86
+ /**
87
+ * React hook for executing and observing OSDK functions.
88
+ *
89
+ * Provides automatic caching, deduplication, and reactive updates for function calls.
90
+ * Functions are automatically re-fetched when dependencies change (configured via options).
91
+ *
92
+ * @param queryDef - The QueryDefinition to execute
93
+ * @param options - Configuration options for the function call
94
+ * @returns Object containing result, loading state, error, and refetch function
95
+ *
96
+ * @example Basic usage
97
+ * ```tsx
98
+ * const { data, isLoading, error } = useOsdkFunction(getEmployeeStats, {
99
+ * params: { departmentId: "engineering" }
100
+ * });
101
+ * ```
102
+ *
103
+ * @example With dependency tracking
104
+ * ```tsx
105
+ * const { data, refetch } = useOsdkFunction(calculateMetrics, {
106
+ * params: { startDate, endDate },
107
+ * dependsOn: [Employee, Project],
108
+ * });
109
+ * ```
110
+ *
111
+ * @example With specific object dependencies
112
+ * ```tsx
113
+ * const { data } = useOsdkFunction(getEmployeeReport, {
114
+ * params: { employeeId: employee.$primaryKey },
115
+ * dependsOnObjects: [employee],
116
+ * });
117
+ * ```
118
+ */
119
+ declare function useOsdkFunction<Q extends QueryDefinition<unknown>>(queryDef: Q, options?: UseOsdkFunctionOptions<Q>): UseOsdkFunctionResult<Q>;
120
+
121
+ export { type UseOsdkFunctionOptions as U, type UseOsdkFunctionResult as a, useOsdkFunction as u };
@@ -15,14 +15,34 @@
15
15
  */
16
16
 
17
17
  import React from "react";
18
+ export const MISSING_PROVIDER_MESSAGE = "No OsdkProvider2 found. Did you forget to wrap your component tree with <OsdkProvider2>?";
18
19
  function fakeClientFn(..._args) {
19
- throw new Error("This is not a real client. Did you forget to <OsdkContext.Provider>?");
20
+ throw new Error(MISSING_PROVIDER_MESSAGE);
20
21
  }
21
22
  const fakeClient = Object.assign(fakeClientFn, {
22
23
  fetchMetadata: fakeClientFn
23
24
  });
25
+
26
+ // Proxy that throws a clear error when any method is called, so hooks like
27
+ // useOsdkObjects get "Did you forget <OsdkProvider2>?" instead of
28
+ // "cannot read canonicalizeWhereClause of undefined".
29
+ // We intercept `get` so every property access returns a throwing function,
30
+ // without needing to enumerate every ObservableClient method.
31
+ // Symbol.toPrimitive and Symbol.toStringTag are accessed by React/devtools
32
+ // during rendering and logging — returning undefined for these avoids
33
+ // spurious throws in contexts unrelated to the user's code.
34
+ const fakeObservableClient = new Proxy({}, {
35
+ get(_target, prop) {
36
+ if (prop === Symbol.toPrimitive || prop === Symbol.toStringTag) {
37
+ return undefined;
38
+ }
39
+ return (..._args) => {
40
+ throw new Error(MISSING_PROVIDER_MESSAGE);
41
+ };
42
+ }
43
+ });
24
44
  export const OsdkContext2 = /*#__PURE__*/React.createContext({
25
45
  client: fakeClient,
26
- observableClient: undefined
46
+ observableClient: fakeObservableClient
27
47
  });
28
48
  //# sourceMappingURL=OsdkContext2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OsdkContext2.js","names":["React","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","OsdkContext2","createContext","client","observableClient","undefined"],"sources":["OsdkContext2.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 { Client } from \"@osdk/client\";\nimport type { ObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\n\nfunction fakeClientFn(..._args: any[]) {\n throw new Error(\n \"This is not a real client. Did you forget to <OsdkContext.Provider>?\",\n );\n}\n\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn,\n} as Client);\n\ninterface OsdkContextContents {\n client: Client;\n // keeping the old name for now intentionally\n // in case i need both for a while\n // in the future we can just make\n // this `client: ObservableClient`\n observableClient: ObservableClient;\n}\n\nexport const OsdkContext2: React.Context<OsdkContextContents> = React\n .createContext<OsdkContextContents>({\n client: fakeClient,\n observableClient: undefined!,\n });\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAYA,CAAC,GAAGC,KAAY,EAAE;EACrC,MAAM,IAAIC,KAAK,CACb,sEACF,CAAC;AACH;AAEA,MAAMC,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC7CM,aAAa,EAAEN;AACjB,CAAW,CAAC;AAWZ,OAAO,MAAMO,YAAgD,gBAAGR,KAAK,CAClES,aAAa,CAAsB;EAClCC,MAAM,EAAEN,UAAU;EAClBO,gBAAgB,EAAEC;AACpB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"OsdkContext2.js","names":["React","MISSING_PROVIDER_MESSAGE","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","fakeObservableClient","Proxy","get","_target","prop","Symbol","toPrimitive","toStringTag","undefined","OsdkContext2","createContext","client","observableClient"],"sources":["OsdkContext2.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 { Client } from \"@osdk/client\";\nimport type { ObservableClient } from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\n\nexport const MISSING_PROVIDER_MESSAGE =\n \"No OsdkProvider2 found. Did you forget to wrap your component tree with <OsdkProvider2>?\";\n\nfunction fakeClientFn(..._args: any[]) {\n throw new Error(MISSING_PROVIDER_MESSAGE);\n}\n\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn,\n} as Client);\n\n// Proxy that throws a clear error when any method is called, so hooks like\n// useOsdkObjects get \"Did you forget <OsdkProvider2>?\" instead of\n// \"cannot read canonicalizeWhereClause of undefined\".\n// We intercept `get` so every property access returns a throwing function,\n// without needing to enumerate every ObservableClient method.\n// Symbol.toPrimitive and Symbol.toStringTag are accessed by React/devtools\n// during rendering and logging — returning undefined for these avoids\n// spurious throws in contexts unrelated to the user's code.\nconst fakeObservableClient = new Proxy({} as ObservableClient, {\n get(_target, prop) {\n if (prop === Symbol.toPrimitive || prop === Symbol.toStringTag) {\n return undefined;\n }\n return (..._args: any[]) => {\n throw new Error(MISSING_PROVIDER_MESSAGE);\n };\n },\n});\n\ninterface OsdkContextContents {\n client: Client;\n // keeping the old name for now intentionally\n // in case i need both for a while\n // in the future we can just make\n // this `client: ObservableClient`\n observableClient: ObservableClient;\n}\n\nexport const OsdkContext2: React.Context<OsdkContextContents> = React\n .createContext<OsdkContextContents>({\n client: fakeClient,\n observableClient: fakeObservableClient,\n });\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAO,MAAMC,wBAAwB,GACnC,0FAA0F;AAE5F,SAASC,YAAYA,CAAC,GAAGC,KAAY,EAAE;EACrC,MAAM,IAAIC,KAAK,CAACH,wBAAwB,CAAC;AAC3C;AAEA,MAAMI,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC7CM,aAAa,EAAEN;AACjB,CAAW,CAAC;;AAEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMO,oBAAoB,GAAG,IAAIC,KAAK,CAAC,CAAC,CAAC,EAAsB;EAC7DC,GAAGA,CAACC,OAAO,EAAEC,IAAI,EAAE;IACjB,IAAIA,IAAI,KAAKC,MAAM,CAACC,WAAW,IAAIF,IAAI,KAAKC,MAAM,CAACE,WAAW,EAAE;MAC9D,OAAOC,SAAS;IAClB;IACA,OAAO,CAAC,GAAGd,KAAY,KAAK;MAC1B,MAAM,IAAIC,KAAK,CAACH,wBAAwB,CAAC;IAC3C,CAAC;EACH;AACF,CAAC,CAAC;AAWF,OAAO,MAAMiB,YAAgD,gBAAGlB,KAAK,CAClEmB,aAAa,CAAsB;EAClCC,MAAM,EAAEf,UAAU;EAClBgB,gBAAgB,EAAEZ;AACpB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export function extractPayloadError(payload, fallbackMessage) {
18
+ if (payload && "error" in payload && payload.error) {
19
+ return payload.error;
20
+ }
21
+ if (payload?.status === "error") {
22
+ return new Error(fallbackMessage);
23
+ }
24
+ return undefined;
25
+ }
26
+ export function isPayloadLoading(payload, enabled) {
27
+ if (!enabled) {
28
+ return false;
29
+ }
30
+ return payload?.status === "loading" || payload?.status === "init" || !payload;
31
+ }
32
+ //# sourceMappingURL=hookUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hookUtils.js","names":["extractPayloadError","payload","fallbackMessage","error","status","Error","undefined","isPayloadLoading","enabled"],"sources":["hookUtils.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport function extractPayloadError(\n payload: { error?: Error; status?: string } | undefined | null,\n fallbackMessage: string,\n): Error | undefined {\n if (payload && \"error\" in payload && payload.error) {\n return payload.error;\n }\n if (payload?.status === \"error\") {\n return new Error(fallbackMessage);\n }\n return undefined;\n}\n\nexport function isPayloadLoading(\n payload: { status?: string } | undefined | null,\n enabled: boolean,\n): boolean {\n if (!enabled) {\n return false;\n }\n return payload?.status === \"loading\" || payload?.status === \"init\"\n || !payload;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASA,mBAAmBA,CACjCC,OAA8D,EAC9DC,eAAuB,EACJ;EACnB,IAAID,OAAO,IAAI,OAAO,IAAIA,OAAO,IAAIA,OAAO,CAACE,KAAK,EAAE;IAClD,OAAOF,OAAO,CAACE,KAAK;EACtB;EACA,IAAIF,OAAO,EAAEG,MAAM,KAAK,OAAO,EAAE;IAC/B,OAAO,IAAIC,KAAK,CAACH,eAAe,CAAC;EACnC;EACA,OAAOI,SAAS;AAClB;AAEA,OAAO,SAASC,gBAAgBA,CAC9BN,OAA+C,EAC/CO,OAAgB,EACP;EACT,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,KAAK;EACd;EACA,OAAOP,OAAO,EAAEG,MAAM,KAAK,SAAS,IAAIH,OAAO,EAAEG,MAAM,KAAK,MAAM,IAC7D,CAACH,OAAO;AACf","ignoreList":[]}
@@ -0,0 +1,63 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { CbacBanners } from "@osdk/foundry.admin";
18
+ import React from "react";
19
+ import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
+ import { OsdkContext2 } from "../../OsdkContext2.js";
21
+ /**
22
+ * Get the CBAC banner data for the given marking IDs.
23
+ * @param options Options to control the query.
24
+ */
25
+ export function useCbacBanner({
26
+ markingIds,
27
+ enabled: externalEnabled = true
28
+ }) {
29
+ const {
30
+ client
31
+ } = React.useContext(OsdkContext2);
32
+ const stableMarkingIds = React.useMemo(() => markingIds, [JSON.stringify(markingIds)]);
33
+ const enabled = stableMarkingIds.length > 0 && externalEnabled;
34
+ const handleQuery = React.useCallback(() => {
35
+ return CbacBanners.get(client, {
36
+ markingIds: stableMarkingIds,
37
+ preview: true
38
+ });
39
+ }, [client, stableMarkingIds]);
40
+ const query = usePlatformQuery({
41
+ query: handleQuery,
42
+ enabled,
43
+ queryName: "cbac-banner"
44
+ });
45
+ const banner = React.useMemo(() => {
46
+ if (query.data == null) {
47
+ return undefined;
48
+ }
49
+ return {
50
+ classificationString: query.data.classificationString,
51
+ textColor: query.data.textColor,
52
+ backgroundColors: query.data.backgroundColors,
53
+ markingIds: query.data.markings
54
+ };
55
+ }, [query.data]);
56
+ return {
57
+ banner,
58
+ isLoading: query.isLoading,
59
+ error: query.error,
60
+ refetch: query.refetch
61
+ };
62
+ }
63
+ //# sourceMappingURL=useCbacBanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCbacBanner.js","names":["CbacBanners","React","usePlatformQuery","OsdkContext2","useCbacBanner","markingIds","enabled","externalEnabled","client","useContext","stableMarkingIds","useMemo","JSON","stringify","length","handleQuery","useCallback","get","preview","query","queryName","banner","data","undefined","classificationString","textColor","backgroundColors","markings","isLoading","error","refetch"],"sources":["useCbacBanner.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CbacBanners } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface CbacBannerData {\n classificationString: string;\n textColor: string;\n backgroundColors: string[];\n markingIds: string[];\n}\n\nexport interface UseCbacBannerOptions {\n markingIds: string[];\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseCbacBannerResult {\n banner: CbacBannerData | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the CBAC banner data for the given marking IDs.\n * @param options Options to control the query.\n */\nexport function useCbacBanner(\n { markingIds, enabled: externalEnabled = true }: UseCbacBannerOptions,\n): UseCbacBannerResult {\n const { client } = React.useContext(OsdkContext2);\n\n const stableMarkingIds = React.useMemo(\n () => markingIds,\n [JSON.stringify(markingIds)],\n );\n\n const enabled = stableMarkingIds.length > 0 && externalEnabled;\n\n const handleQuery = React.useCallback(() => {\n return CbacBanners.get(client, {\n markingIds: stableMarkingIds,\n preview: true,\n });\n }, [client, stableMarkingIds]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"cbac-banner\",\n });\n\n const banner = React.useMemo((): CbacBannerData | undefined => {\n if (query.data == null) {\n return undefined;\n }\n return {\n classificationString: query.data.classificationString,\n textColor: query.data.textColor,\n backgroundColors: query.data.backgroundColors,\n markingIds: query.data.markings,\n };\n }, [query.data]);\n\n return {\n banner,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,qBAAqB;AACjD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AAmCpD;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3B;EAAEC,UAAU;EAAEC,OAAO,EAAEC,eAAe,GAAG;AAA2B,CAAC,EAChD;EACrB,MAAM;IAAEC;EAAO,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,YAAY,CAAC;EAEjD,MAAMO,gBAAgB,GAAGT,KAAK,CAACU,OAAO,CACpC,MAAMN,UAAU,EAChB,CAACO,IAAI,CAACC,SAAS,CAACR,UAAU,CAAC,CAC7B,CAAC;EAED,MAAMC,OAAO,GAAGI,gBAAgB,CAACI,MAAM,GAAG,CAAC,IAAIP,eAAe;EAE9D,MAAMQ,WAAW,GAAGd,KAAK,CAACe,WAAW,CAAC,MAAM;IAC1C,OAAOhB,WAAW,CAACiB,GAAG,CAACT,MAAM,EAAE;MAC7BH,UAAU,EAAEK,gBAAgB;MAC5BQ,OAAO,EAAE;IACX,CAAC,CAAC;EACJ,CAAC,EAAE,CAACV,MAAM,EAAEE,gBAAgB,CAAC,CAAC;EAE9B,MAAMS,KAAK,GAAGjB,gBAAgB,CAAC;IAC7BiB,KAAK,EAAEJ,WAAW;IAClBT,OAAO;IACPc,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,MAAMC,MAAM,GAAGpB,KAAK,CAACU,OAAO,CAAC,MAAkC;IAC7D,IAAIQ,KAAK,CAACG,IAAI,IAAI,IAAI,EAAE;MACtB,OAAOC,SAAS;IAClB;IACA,OAAO;MACLC,oBAAoB,EAAEL,KAAK,CAACG,IAAI,CAACE,oBAAoB;MACrDC,SAAS,EAAEN,KAAK,CAACG,IAAI,CAACG,SAAS;MAC/BC,gBAAgB,EAAEP,KAAK,CAACG,IAAI,CAACI,gBAAgB;MAC7CrB,UAAU,EAAEc,KAAK,CAACG,IAAI,CAACK;IACzB,CAAC;EACH,CAAC,EAAE,CAACR,KAAK,CAACG,IAAI,CAAC,CAAC;EAEhB,OAAO;IACLD,MAAM;IACNO,SAAS,EAAET,KAAK,CAACS,SAAS;IAC1BC,KAAK,EAAEV,KAAK,CAACU,KAAK;IAClBC,OAAO,EAAEX,KAAK,CAACW;EACjB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { CbacMarkingRestrictionsObjects } from "@osdk/foundry.admin";
18
+ import React from "react";
19
+ import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
+ import { OsdkContext2 } from "../../OsdkContext2.js";
21
+ /**
22
+ * Get CBAC marking restrictions (implied, disallowed, required) for the given marking IDs.
23
+ * @param options Options to control the query.
24
+ */
25
+ export function useCbacMarkingRestrictions({
26
+ markingIds,
27
+ enabled: externalEnabled = true
28
+ }) {
29
+ const {
30
+ client
31
+ } = React.useContext(OsdkContext2);
32
+ const stableMarkingIds = React.useMemo(() => markingIds, [JSON.stringify(markingIds)]);
33
+ const enabled = stableMarkingIds.length > 0 && externalEnabled;
34
+ const handleQuery = React.useCallback(() => {
35
+ return CbacMarkingRestrictionsObjects.get(client, {
36
+ markingIds: stableMarkingIds,
37
+ preview: true
38
+ });
39
+ }, [client, stableMarkingIds]);
40
+ const query = usePlatformQuery({
41
+ query: handleQuery,
42
+ enabled,
43
+ queryName: "cbac-marking-restrictions"
44
+ });
45
+ const restrictions = React.useMemo(() => {
46
+ if (query.data == null) {
47
+ return undefined;
48
+ }
49
+ return {
50
+ disallowedMarkings: query.data.disallowedMarkings.map(String),
51
+ impliedMarkings: query.data.impliedMarkings.map(String),
52
+ requiredMarkings: query.data.requiredMarkings.map(group => group.map(String)),
53
+ userSatisfiesMarkings: query.data.userSatisfiesMarkings,
54
+ isValid: query.data.isValid
55
+ };
56
+ }, [query.data]);
57
+ return {
58
+ restrictions,
59
+ isLoading: query.isLoading,
60
+ error: query.error,
61
+ refetch: query.refetch
62
+ };
63
+ }
64
+ //# sourceMappingURL=useCbacMarkingRestrictions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCbacMarkingRestrictions.js","names":["CbacMarkingRestrictionsObjects","React","usePlatformQuery","OsdkContext2","useCbacMarkingRestrictions","markingIds","enabled","externalEnabled","client","useContext","stableMarkingIds","useMemo","JSON","stringify","length","handleQuery","useCallback","get","preview","query","queryName","restrictions","data","undefined","disallowedMarkings","map","String","impliedMarkings","requiredMarkings","group","userSatisfiesMarkings","isValid","isLoading","error","refetch"],"sources":["useCbacMarkingRestrictions.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CbacMarkingRestrictionsObjects } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface CbacMarkingRestrictionsData {\n disallowedMarkings: string[];\n impliedMarkings: string[];\n requiredMarkings: string[][];\n userSatisfiesMarkings: boolean;\n isValid: boolean;\n}\n\nexport interface UseCbacMarkingRestrictionsOptions {\n markingIds: string[];\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseCbacMarkingRestrictionsResult {\n restrictions: CbacMarkingRestrictionsData | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get CBAC marking restrictions (implied, disallowed, required) for the given marking IDs.\n * @param options Options to control the query.\n */\nexport function useCbacMarkingRestrictions(\n { markingIds, enabled: externalEnabled = true }:\n UseCbacMarkingRestrictionsOptions,\n): UseCbacMarkingRestrictionsResult {\n const { client } = React.useContext(OsdkContext2);\n\n const stableMarkingIds = React.useMemo(\n () => markingIds,\n [JSON.stringify(markingIds)],\n );\n\n const enabled = stableMarkingIds.length > 0 && externalEnabled;\n\n const handleQuery = React.useCallback(() => {\n return CbacMarkingRestrictionsObjects.get(client, {\n markingIds: stableMarkingIds,\n preview: true,\n });\n }, [client, stableMarkingIds]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"cbac-marking-restrictions\",\n });\n\n const restrictions = React.useMemo(\n (): CbacMarkingRestrictionsData | undefined => {\n if (query.data == null) {\n return undefined;\n }\n return {\n disallowedMarkings: query.data.disallowedMarkings.map(String),\n impliedMarkings: query.data.impliedMarkings.map(String),\n requiredMarkings: query.data.requiredMarkings.map(group =>\n group.map(String)\n ),\n userSatisfiesMarkings: query.data.userSatisfiesMarkings,\n isValid: query.data.isValid,\n };\n },\n [query.data],\n );\n\n return {\n restrictions,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,8BAA8B,QAAQ,qBAAqB;AACpE,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AAoCpD;AACA;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA,CACxC;EAAEC,UAAU;EAAEC,OAAO,EAAEC,eAAe,GAAG;AACP,CAAC,EACD;EAClC,MAAM;IAAEC;EAAO,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,YAAY,CAAC;EAEjD,MAAMO,gBAAgB,GAAGT,KAAK,CAACU,OAAO,CACpC,MAAMN,UAAU,EAChB,CAACO,IAAI,CAACC,SAAS,CAACR,UAAU,CAAC,CAC7B,CAAC;EAED,MAAMC,OAAO,GAAGI,gBAAgB,CAACI,MAAM,GAAG,CAAC,IAAIP,eAAe;EAE9D,MAAMQ,WAAW,GAAGd,KAAK,CAACe,WAAW,CAAC,MAAM;IAC1C,OAAOhB,8BAA8B,CAACiB,GAAG,CAACT,MAAM,EAAE;MAChDH,UAAU,EAAEK,gBAAgB;MAC5BQ,OAAO,EAAE;IACX,CAAC,CAAC;EACJ,CAAC,EAAE,CAACV,MAAM,EAAEE,gBAAgB,CAAC,CAAC;EAE9B,MAAMS,KAAK,GAAGjB,gBAAgB,CAAC;IAC7BiB,KAAK,EAAEJ,WAAW;IAClBT,OAAO;IACPc,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,MAAMC,YAAY,GAAGpB,KAAK,CAACU,OAAO,CAChC,MAA+C;IAC7C,IAAIQ,KAAK,CAACG,IAAI,IAAI,IAAI,EAAE;MACtB,OAAOC,SAAS;IAClB;IACA,OAAO;MACLC,kBAAkB,EAAEL,KAAK,CAACG,IAAI,CAACE,kBAAkB,CAACC,GAAG,CAACC,MAAM,CAAC;MAC7DC,eAAe,EAAER,KAAK,CAACG,IAAI,CAACK,eAAe,CAACF,GAAG,CAACC,MAAM,CAAC;MACvDE,gBAAgB,EAAET,KAAK,CAACG,IAAI,CAACM,gBAAgB,CAACH,GAAG,CAACI,KAAK,IACrDA,KAAK,CAACJ,GAAG,CAACC,MAAM,CAClB,CAAC;MACDI,qBAAqB,EAAEX,KAAK,CAACG,IAAI,CAACQ,qBAAqB;MACvDC,OAAO,EAAEZ,KAAK,CAACG,IAAI,CAACS;IACtB,CAAC;EACH,CAAC,EACD,CAACZ,KAAK,CAACG,IAAI,CACb,CAAC;EAED,OAAO;IACLD,YAAY;IACZW,SAAS,EAAEb,KAAK,CAACa,SAAS;IAC1BC,KAAK,EAAEd,KAAK,CAACc,KAAK;IAClBC,OAAO,EAAEf,KAAK,CAACe;EACjB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { MarkingCategories } from "@osdk/foundry.admin";
18
+ import React from "react";
19
+ import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
+ import { OsdkContext2 } from "../../OsdkContext2.js";
21
+ /**
22
+ * List all marking categories.
23
+ * @param options Options to control the query.
24
+ */
25
+ export function useMarkingCategories({
26
+ enabled = true
27
+ } = {}) {
28
+ const {
29
+ client
30
+ } = React.useContext(OsdkContext2);
31
+ const handleQuery = React.useCallback(() => {
32
+ return MarkingCategories.list(client);
33
+ }, [client]);
34
+ const query = usePlatformQuery({
35
+ query: handleQuery,
36
+ enabled,
37
+ queryName: "marking-categories"
38
+ });
39
+ return {
40
+ categories: query.data?.data,
41
+ isLoading: query.isLoading,
42
+ error: query.error,
43
+ refetch: query.refetch
44
+ };
45
+ }
46
+ //# sourceMappingURL=useMarkingCategories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMarkingCategories.js","names":["MarkingCategories","React","usePlatformQuery","OsdkContext2","useMarkingCategories","enabled","client","useContext","handleQuery","useCallback","list","query","queryName","categories","data","isLoading","error","refetch"],"sources":["useMarkingCategories.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { MarkingCategory } from \"@osdk/foundry.admin\";\nimport { MarkingCategories } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseMarkingCategoriesOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseMarkingCategoriesResult {\n categories: MarkingCategory[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * List all marking categories.\n * @param options Options to control the query.\n */\nexport function useMarkingCategories(\n { enabled = true }: UseMarkingCategoriesOptions = {},\n): UseMarkingCategoriesResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(() => {\n return MarkingCategories.list(client);\n }, [client]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"marking-categories\",\n });\n\n return {\n categories: query.data?.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AA2BpD;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAClC;EAAEC,OAAO,GAAG;AAAkC,CAAC,GAAG,CAAC,CAAC,EACxB;EAC5B,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;EAEjD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CAAC,MAAM;IAC1C,OAAOT,iBAAiB,CAACU,IAAI,CAACJ,MAAM,CAAC;EACvC,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMK,KAAK,GAAGT,gBAAgB,CAAC;IAC7BS,KAAK,EAAEH,WAAW;IAClBH,OAAO;IACPO,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,UAAU,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IAC5BC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Markings } from "@osdk/foundry.admin";
18
+ import React from "react";
19
+ import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
+ import { OsdkContext2 } from "../../OsdkContext2.js";
21
+ /**
22
+ * List all markings.
23
+ * @param options Options to control the query.
24
+ */
25
+ export function useMarkings({
26
+ enabled = true
27
+ } = {}) {
28
+ const {
29
+ client
30
+ } = React.useContext(OsdkContext2);
31
+ const handleQuery = React.useCallback(() => {
32
+ return Markings.list(client);
33
+ }, [client]);
34
+ const query = usePlatformQuery({
35
+ query: handleQuery,
36
+ enabled,
37
+ queryName: "markings"
38
+ });
39
+ return {
40
+ markings: query.data?.data,
41
+ isLoading: query.isLoading,
42
+ error: query.error,
43
+ refetch: query.refetch
44
+ };
45
+ }
46
+ //# sourceMappingURL=useMarkings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMarkings.js","names":["Markings","React","usePlatformQuery","OsdkContext2","useMarkings","enabled","client","useContext","handleQuery","useCallback","list","query","queryName","markings","data","isLoading","error","refetch"],"sources":["useMarkings.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Marking } from \"@osdk/foundry.admin\";\nimport { Markings } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseMarkingsOptions {\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseMarkingsResult {\n markings: Marking[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * List all markings.\n * @param options Options to control the query.\n */\nexport function useMarkings(\n { enabled = true }: UseMarkingsOptions = {},\n): UseMarkingsResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(() => {\n return Markings.list(client);\n }, [client]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"markings\",\n });\n\n return {\n markings: query.data?.data,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AA2BpD;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CACzB;EAAEC,OAAO,GAAG;AAAyB,CAAC,GAAG,CAAC,CAAC,EACxB;EACnB,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,YAAY,CAAC;EAEjD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CAAC,MAAM;IAC1C,OAAOT,QAAQ,CAACU,IAAI,CAACJ,MAAM,CAAC;EAC9B,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EAEZ,MAAMK,KAAK,GAAGT,gBAAgB,CAAC;IAC7BS,KAAK,EAAEH,WAAW;IAClBH,OAAO;IACPO,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,QAAQ,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IAC1BC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright 2026 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { Users } from "@osdk/foundry.admin";
18
+ import React from "react";
19
+ import { usePlatformQuery } from "../../../utils/usePlatformQuery.js";
20
+ import { OsdkContext2 } from "../../OsdkContext2.js";
21
+ /**
22
+ * Get view-accessible markings for a user.
23
+ * When `userId` is provided, fetches markings for that user.
24
+ * When omitted, fetches markings for the current user.
25
+ * @param options Options to control the query.
26
+ */
27
+ export function useUserViewMarkings({
28
+ userId,
29
+ enabled = true
30
+ } = {}) {
31
+ const {
32
+ client
33
+ } = React.useContext(OsdkContext2);
34
+ const handleQuery = React.useCallback(async () => {
35
+ const resolvedUserId = userId ?? (await Users.getCurrent(client)).id;
36
+ return Users.getMarkings(client, resolvedUserId);
37
+ }, [client, userId]);
38
+ const query = usePlatformQuery({
39
+ query: handleQuery,
40
+ enabled,
41
+ queryName: "user-view-markings"
42
+ });
43
+ return {
44
+ markingIds: query.data?.view,
45
+ isLoading: query.isLoading,
46
+ error: query.error,
47
+ refetch: query.refetch
48
+ };
49
+ }
50
+ //# sourceMappingURL=useUserMarkings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUserMarkings.js","names":["Users","React","usePlatformQuery","OsdkContext2","useUserViewMarkings","userId","enabled","client","useContext","handleQuery","useCallback","resolvedUserId","getCurrent","id","getMarkings","query","queryName","markingIds","data","view","isLoading","error","refetch"],"sources":["useUserMarkings.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Users } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext2 } from \"../../OsdkContext2.js\";\n\nexport interface UseUserViewMarkingsOptions {\n /**\n * The user ID to fetch view markings for.\n * When omitted, fetches markings for the current user.\n */\n userId?: string;\n /**\n * Enable or disable the query.\n *\n * When `false`, the query will not automatically execute.\n *\n * This is useful for:\n * - Lazy/on-demand queries that should wait for user interaction\n * - Dependent queries that need data from another query first\n * - Conditional queries based on component state\n *\n * @default true\n */\n enabled?: boolean;\n}\n\nexport interface UseUserViewMarkingsResult {\n markingIds: string[] | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get view-accessible markings for a user.\n * When `userId` is provided, fetches markings for that user.\n * When omitted, fetches markings for the current user.\n * @param options Options to control the query.\n */\nexport function useUserViewMarkings(\n { userId, enabled = true }: UseUserViewMarkingsOptions = {},\n): UseUserViewMarkingsResult {\n const { client } = React.useContext(OsdkContext2);\n\n const handleQuery = React.useCallback(async () => {\n const resolvedUserId = userId\n ?? (await Users.getCurrent(client)).id;\n return Users.getMarkings(client, resolvedUserId);\n }, [client, userId]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"user-view-markings\",\n });\n\n return {\n markingIds: query.data?.view,\n isLoading: query.isLoading,\n error: query.error,\n refetch: query.refetch,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,qBAAqB;AAC3C,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,YAAY,QAAQ,uBAAuB;AAgCpD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjC;EAAEC,MAAM;EAAEC,OAAO,GAAG;AAAiC,CAAC,GAAG,CAAC,CAAC,EAChC;EAC3B,MAAM;IAAEC;EAAO,CAAC,GAAGN,KAAK,CAACO,UAAU,CAACL,YAAY,CAAC;EAEjD,MAAMM,WAAW,GAAGR,KAAK,CAACS,WAAW,CAAC,YAAY;IAChD,MAAMC,cAAc,GAAGN,MAAM,IACxB,CAAC,MAAML,KAAK,CAACY,UAAU,CAACL,MAAM,CAAC,EAAEM,EAAE;IACxC,OAAOb,KAAK,CAACc,WAAW,CAACP,MAAM,EAAEI,cAAc,CAAC;EAClD,CAAC,EAAE,CAACJ,MAAM,EAAEF,MAAM,CAAC,CAAC;EAEpB,MAAMU,KAAK,GAAGb,gBAAgB,CAAC;IAC7Ba,KAAK,EAAEN,WAAW;IAClBH,OAAO;IACPU,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,UAAU,EAAEF,KAAK,CAACG,IAAI,EAAEC,IAAI;IAC5BC,SAAS,EAAEL,KAAK,CAACK,SAAS;IAC1BC,KAAK,EAAEN,KAAK,CAACM,KAAK;IAClBC,OAAO,EAAEP,KAAK,CAACO;EACjB,CAAC;AACH","ignoreList":[]}
@@ -15,6 +15,7 @@
15
15
  */
16
16
 
17
17
  import React from "react";
18
+ import { extractPayloadError, isPayloadLoading } from "./hookUtils.js";
18
19
  import { makeExternalStore } from "./makeExternalStore.js";
19
20
  import { OsdkContext2 } from "./OsdkContext2.js";
20
21
  const emptyArray = Object.freeze([]);
@@ -36,9 +37,11 @@ export function useLinks(objects, linkName, options = {}) {
36
37
  enabled = true,
37
38
  ...otherOptions
38
39
  } = options;
39
- const stableWhere = React.useMemo(() => otherOptions.where, [JSON.stringify(otherOptions.where)]);
40
- const stableOrderBy = React.useMemo(() => otherOptions.orderBy, [JSON.stringify(otherOptions.orderBy)]);
41
- const stableSelect = React.useMemo(() => otherOptions.$select, [JSON.stringify(otherOptions.$select)]);
40
+ const canonOptions = observableClient.canonicalizeOptions({
41
+ where: otherOptions.where,
42
+ orderBy: otherOptions.orderBy,
43
+ $select: otherOptions.$select
44
+ });
42
45
  const objectsKey = React.useMemo(() => {
43
46
  if (objects === undefined) return "";
44
47
  const arr = Array.isArray(objects) ? objects : [objects];
@@ -60,23 +63,23 @@ export function useLinks(objects, linkName, options = {}) {
60
63
  }
61
64
  return makeExternalStore(observer => observableClient.observeLinks(objectsArray, linkName, {
62
65
  linkName,
63
- where: stableWhere,
66
+ where: canonOptions.where,
64
67
  pageSize: otherOptions.pageSize,
65
- orderBy: stableOrderBy,
68
+ orderBy: canonOptions.orderBy,
66
69
  mode: otherOptions.mode,
67
70
  dedupeInterval: otherOptions.dedupeIntervalMs ?? 2_000,
68
- ...(stableSelect ? {
69
- select: stableSelect
71
+ ...(canonOptions.$select ? {
72
+ select: canonOptions.$select
70
73
  } : {})
71
74
  }, observer), `links ${linkName} for ${objectsKey}`);
72
- }, [enabled, observableClient, objectsArray, objectsKey, linkName, stableWhere, otherOptions.pageSize, stableOrderBy, otherOptions.mode, otherOptions.dedupeIntervalMs, stableSelect]);
75
+ }, [enabled, observableClient, objectsArray, objectsKey, linkName, canonOptions.where, otherOptions.pageSize, canonOptions.orderBy, otherOptions.mode, otherOptions.dedupeIntervalMs, canonOptions.$select]);
73
76
  const payload = React.useSyncExternalStore(subscribe, getSnapShot);
74
77
  return React.useMemo(() => ({
75
78
  links: payload?.resolvedList,
76
79
  linkedObjectsBySourcePrimaryKey: payload?.linkedObjectsBySourcePrimaryKey ?? emptyMap,
77
- isLoading: enabled ? payload?.status === "loading" || payload?.status === "init" || !payload : false,
80
+ isLoading: isPayloadLoading(payload, enabled),
78
81
  isOptimistic: payload?.isOptimistic ?? false,
79
- error: payload?.error,
82
+ error: extractPayloadError(payload, "Failed to load links"),
80
83
  fetchMore: payload?.hasMore ? payload?.fetchMore : undefined,
81
84
  hasMore: payload?.hasMore ?? false
82
85
  }), [payload, enabled]);