@osdk/react 0.10.0-beta.9 → 0.10.0

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 (94) hide show
  1. package/CHANGELOG.md +99 -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/platform-apis/admin/useCbacBanner.js +63 -0
  5. package/build/browser/new/platform-apis/admin/useCbacBanner.js.map +1 -0
  6. package/build/browser/new/platform-apis/admin/useCbacMarkingRestrictions.js +64 -0
  7. package/build/browser/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -0
  8. package/build/browser/new/platform-apis/admin/useMarkingCategories.js +46 -0
  9. package/build/browser/new/platform-apis/admin/useMarkingCategories.js.map +1 -0
  10. package/build/browser/new/platform-apis/admin/useMarkings.js +46 -0
  11. package/build/browser/new/platform-apis/admin/useMarkings.js.map +1 -0
  12. package/build/browser/new/platform-apis/admin/useUserMarkings.js +50 -0
  13. package/build/browser/new/platform-apis/admin/useUserMarkings.js.map +1 -0
  14. package/build/browser/new/useOsdkAction.js +3 -6
  15. package/build/browser/new/useOsdkAction.js.map +1 -1
  16. package/build/browser/new/useOsdkFunctions.js +137 -0
  17. package/build/browser/new/useOsdkFunctions.js.map +1 -0
  18. package/build/browser/new/useOsdkObject.js +6 -2
  19. package/build/browser/new/useOsdkObject.js.map +1 -1
  20. package/build/browser/new/useOsdkObjects.js +6 -2
  21. package/build/browser/new/useOsdkObjects.js.map +1 -1
  22. package/build/browser/public/experimental/admin.js +5 -0
  23. package/build/browser/public/experimental/admin.js.map +1 -1
  24. package/build/browser/public/unstable-do-not-use.js +18 -0
  25. package/build/browser/public/unstable-do-not-use.js.map +1 -0
  26. package/build/cjs/chunk-2N32USW5.cjs +28 -0
  27. package/build/cjs/chunk-2N32USW5.cjs.map +1 -0
  28. package/build/cjs/chunk-R4FZ5MUH.cjs +34 -0
  29. package/build/cjs/chunk-R4FZ5MUH.cjs.map +1 -0
  30. package/build/cjs/{chunk-SVVMLSKN.cjs → chunk-ZUNR45SJ.cjs} +15 -4
  31. package/build/cjs/chunk-ZUNR45SJ.cjs.map +1 -0
  32. package/build/cjs/index.cjs +7 -6
  33. package/build/cjs/index.cjs.map +1 -1
  34. package/build/cjs/public/experimental/admin.cjs +154 -7
  35. package/build/cjs/public/experimental/admin.cjs.map +1 -1
  36. package/build/cjs/public/experimental/admin.d.cts +159 -2
  37. package/build/cjs/public/experimental.cjs +42 -36
  38. package/build/cjs/public/experimental.cjs.map +1 -1
  39. package/build/cjs/public/experimental.d.cts +12 -121
  40. package/build/cjs/public/unstable-do-not-use.cjs +114 -0
  41. package/build/cjs/public/unstable-do-not-use.cjs.map +1 -0
  42. package/build/cjs/public/unstable-do-not-use.d.cts +35 -0
  43. package/build/cjs/useOsdkFunction-B0s7lqgN.d.cts +121 -0
  44. package/build/esm/new/OsdkContext2.js +22 -2
  45. package/build/esm/new/OsdkContext2.js.map +1 -1
  46. package/build/esm/new/platform-apis/admin/useCbacBanner.js +63 -0
  47. package/build/esm/new/platform-apis/admin/useCbacBanner.js.map +1 -0
  48. package/build/esm/new/platform-apis/admin/useCbacMarkingRestrictions.js +64 -0
  49. package/build/esm/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -0
  50. package/build/esm/new/platform-apis/admin/useMarkingCategories.js +46 -0
  51. package/build/esm/new/platform-apis/admin/useMarkingCategories.js.map +1 -0
  52. package/build/esm/new/platform-apis/admin/useMarkings.js +46 -0
  53. package/build/esm/new/platform-apis/admin/useMarkings.js.map +1 -0
  54. package/build/esm/new/platform-apis/admin/useUserMarkings.js +50 -0
  55. package/build/esm/new/platform-apis/admin/useUserMarkings.js.map +1 -0
  56. package/build/esm/new/useOsdkAction.js +3 -6
  57. package/build/esm/new/useOsdkAction.js.map +1 -1
  58. package/build/esm/new/useOsdkFunctions.js +137 -0
  59. package/build/esm/new/useOsdkFunctions.js.map +1 -0
  60. package/build/esm/new/useOsdkObject.js +6 -2
  61. package/build/esm/new/useOsdkObject.js.map +1 -1
  62. package/build/esm/new/useOsdkObjects.js +6 -2
  63. package/build/esm/new/useOsdkObjects.js.map +1 -1
  64. package/build/esm/public/experimental/admin.js +5 -0
  65. package/build/esm/public/experimental/admin.js.map +1 -1
  66. package/build/esm/public/unstable-do-not-use.js +18 -0
  67. package/build/esm/public/unstable-do-not-use.js.map +1 -0
  68. package/build/types/new/OsdkContext2.d.ts +1 -0
  69. package/build/types/new/OsdkContext2.d.ts.map +1 -1
  70. package/build/types/new/platform-apis/admin/useCbacBanner.d.ts +33 -0
  71. package/build/types/new/platform-apis/admin/useCbacBanner.d.ts.map +1 -0
  72. package/build/types/new/platform-apis/admin/useCbacMarkingRestrictions.d.ts +34 -0
  73. package/build/types/new/platform-apis/admin/useCbacMarkingRestrictions.d.ts.map +1 -0
  74. package/build/types/new/platform-apis/admin/useMarkingCategories.d.ts +27 -0
  75. package/build/types/new/platform-apis/admin/useMarkingCategories.d.ts.map +1 -0
  76. package/build/types/new/platform-apis/admin/useMarkings.d.ts +27 -0
  77. package/build/types/new/platform-apis/admin/useMarkings.d.ts.map +1 -0
  78. package/build/types/new/platform-apis/admin/useUserMarkings.d.ts +33 -0
  79. package/build/types/new/platform-apis/admin/useUserMarkings.d.ts.map +1 -0
  80. package/build/types/new/useOsdkFunctions.d.ts +31 -0
  81. package/build/types/new/useOsdkFunctions.d.ts.map +1 -0
  82. package/build/types/new/useOsdkObject.d.ts +2 -1
  83. package/build/types/new/useOsdkObject.d.ts.map +1 -1
  84. package/build/types/new/useOsdkObjects.d.ts +6 -0
  85. package/build/types/new/useOsdkObjects.d.ts.map +1 -1
  86. package/build/types/public/experimental/admin.d.ts +8 -0
  87. package/build/types/public/experimental/admin.d.ts.map +1 -1
  88. package/build/types/public/unstable-do-not-use.d.ts +2 -0
  89. package/build/types/public/unstable-do-not-use.d.ts.map +1 -0
  90. package/package.json +19 -10
  91. package/unstable-do-not-use.d.ts +17 -0
  92. package/build/cjs/chunk-OVBG5VXE.cjs +0 -50
  93. package/build/cjs/chunk-OVBG5VXE.cjs.map +0 -1
  94. package/build/cjs/chunk-SVVMLSKN.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,104 @@
1
1
  # @osdkkit/react
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 322c5bc: Simulated release
8
+ - 9720083: Add AGENTS.md files for AI IDE context
9
+ - c40444b: Add linkedObjectsBySourcePrimaryKey to link observation responses
10
+ - 09e5659: add $select support to observable client and react hooks
11
+ - 993c023: ObjectTable supports objectSet input
12
+ - 32c27d7: Added useOsdkFunctions to @osdk/react to execute multiple functions in parallel. This is used by ObjectTable to fetch function-backed columns
13
+ - dbbfb6f: Add experimental ActionForm component with field renderers, form state hook, and tests
14
+ - b1e8bba: add cbac admin hooks for markings, categories, and restrictions
15
+ - 73e617e: expose dedupeInterval on useLinks and fix forced revalidation bypassing dedupeInterval
16
+ - f294f5a: Remove literal support before GA.
17
+ - 9156827: Preserve object set data between loads
18
+ - 599426b: expose $loadPropertySecurityMetadata option in observable client and react hooks
19
+ - 46dfbec: fix useOsdkAction applyAction to re-throw errors instead of silently swallowing them
20
+ - a027f3c: stabilize subscription deps in useOsdkObjects and useOsdkAggregation
21
+ - 0d174a2: useOsdkFunction typing updates
22
+ - 727fd0e: fix dual @types/react version mismatch
23
+ - 8a82492: Move admin hooks to @osdk/react/experimental/admin subpath to avoid bundler crash when @osdk/foundry.admin is not installed
24
+ - 2ebe62c: package and bundle size optimizations
25
+ - 6019278: auto-compute peer dependency ranges from changelog history for react and react-components
26
+ - 35f2f1a: Add Media inputs/outputs for Queries
27
+ - b0930e4: Show helpful error message when hooks are used without OsdkProvider2
28
+ - d80c234: add interface support to useOsdkObject
29
+ - 996d8e4: memoize hook responses
30
+ - 71e28ef: Allow interface object sets in useObjectSet
31
+
32
+ ## 0.10.0-beta.15
33
+
34
+ ### Minor Changes
35
+
36
+ - 32c27d7: Added useOsdkFunctions to @osdk/react to execute multiple functions in parallel. This is used by ObjectTable to fetch function-backed columns
37
+ - 6019278: auto-compute peer dependency ranges from changelog history for react and react-components
38
+
39
+ ## 0.10.0-beta.14
40
+
41
+ ### Minor Changes
42
+
43
+ - b0930e4: Show helpful error message when hooks are used without OsdkProvider2
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [520398c]
48
+ - Updated dependencies [ffc6efe]
49
+ - Updated dependencies [4a856cb]
50
+ - @osdk/client@2.8.0-beta.29
51
+ - @osdk/api@2.8.0-beta.29
52
+
53
+ ## 0.10.0-beta.13
54
+
55
+ ### Minor Changes
56
+
57
+ - f294f5a: Remove literal support before GA.
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [f294f5a]
62
+ - Updated dependencies [2855223]
63
+ - Updated dependencies [d284bf2]
64
+ - Updated dependencies [b68cebd]
65
+ - @osdk/client@2.8.0-beta.28
66
+ - @osdk/api@2.8.0-beta.28
67
+
68
+ ## 0.10.0-beta.12
69
+
70
+ ### Minor Changes
71
+
72
+ - 46dfbec: fix useOsdkAction applyAction to re-throw errors instead of silently swallowing them
73
+
74
+ ## 0.10.0-beta.11
75
+
76
+ ### Minor Changes
77
+
78
+ - b1e8bba: add cbac admin hooks for markings, categories, and restrictions
79
+ - 599426b: expose $loadPropertySecurityMetadata option in observable client and react hooks
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies [599426b]
84
+ - Updated dependencies [60b5ffb]
85
+ - Updated dependencies [61e33ab]
86
+ - @osdk/client@2.8.0-beta.26
87
+ - @osdk/api@2.8.0-beta.26
88
+
89
+ ## 0.10.0-beta.10
90
+
91
+ ### Minor Changes
92
+
93
+ - dbbfb6f: Add experimental ActionForm component with field renderers, form state hook, and tests
94
+
95
+ ### Patch Changes
96
+
97
+ - Updated dependencies [cbfa135]
98
+ - Updated dependencies [f4604c2]
99
+ - @osdk/client@2.8.0-beta.22
100
+ - @osdk/api@2.8.0-beta.22
101
+
3
102
  ## 0.10.0-beta.9
4
103
 
5
104
  ### Minor Changes
@@ -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,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":[]}
@@ -78,6 +78,7 @@ export function useOsdkAction(actionDef) {
78
78
  unknown: e
79
79
  });
80
80
  }
81
+ throw e;
81
82
  } finally {
82
83
  setPending(false);
83
84
  }
@@ -90,9 +91,7 @@ export function useOsdkAction(actionDef) {
90
91
  }
91
92
 
92
93
  // Abort any existing validation
93
- if (abortControllerRef.current) {
94
- abortControllerRef.current.abort();
95
- }
94
+ abortControllerRef.current?.abort();
96
95
 
97
96
  // Create new AbortController
98
97
  const abortController = new AbortController();
@@ -130,9 +129,7 @@ export function useOsdkAction(actionDef) {
130
129
  // Cleanup on unmount
131
130
  React.useEffect(() => {
132
131
  return () => {
133
- if (abortControllerRef.current) {
134
- abortControllerRef.current.abort();
135
- }
132
+ abortControllerRef.current?.abort();
136
133
  };
137
134
  }, []);
138
135
  return React.useMemo(() => ({
@@ -1 +1 @@
1
- {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","OsdkContext2","useOsdkAction","actionDef","observableClient","useContext","error","setError","useState","data","setData","isPending","setPending","isValidating","setValidating","validationResult","setValidationResult","abortControllerRef","useRef","applyAction","useCallback","hookArgs","current","abort","undefined","Array","isArray","updates","args","map","a","$optimisticUpdate","push","r","optimisticUpdate","ctx","update","e","actionValidation","unknown","validateAction","abortController","AbortController","result","signal","aborted","Error","name","useEffect","useMemo"],"sources":["useOsdkAction.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 ActionDefinition,\n ActionEditResponse,\n ActionValidationResponse,\n} from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> =\n & Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]:\n ObservableClient.ApplyActionOptions[K];\n };\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) => Promise<ActionEditResponse | undefined>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: ActionEditResponse | undefined;\n\n isPending: boolean;\n isValidating: boolean;\n\n /**\n * Validates the action with the provided arguments without executing it.\n * Calling this function again before the previous validation finishes will cancel\n * the first validation and start a new one.\n * @param args The action arguments to validate\n * @returns A promise that resolves to the validation response, or undefined if aborted\n */\n validateAction: (\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse | undefined>;\n\n validationResult?: ActionValidationResponse;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q,\n): UseOsdkActionResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<ActionEditResponse | undefined>();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState<\n ActionValidationResponse | undefined\n >();\n const abortControllerRef = React.useRef<AbortController | null>(null);\n\n const applyAction = React.useCallback(async function applyAction(\n hookArgs: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n\n setPending(true);\n setError(undefined);\n\n if (Array.isArray(hookArgs)) {\n const updates: Array<\n ObservableClient.ApplyActionOptions[\"optimisticUpdate\"]\n > = [];\n const args = hookArgs.map(a => {\n const { $optimisticUpdate, ...args } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: (ctx) => {\n for (const update of updates) {\n update?.(ctx);\n }\n },\n });\n setData(r);\n return r;\n } else {\n const { $optimisticUpdate, ...args } = hookArgs;\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n } finally {\n setPending(false);\n }\n }, [observableClient, actionDef, isValidating]);\n\n const validateAction = React.useCallback(async function validateAction(\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ): Promise<ActionValidationResponse | undefined> {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n setValidating(true);\n setError(undefined);\n\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n }, [observableClient, actionDef, isPending]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n };\n }, []);\n\n return React.useMemo(() => ({\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n }), [\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n ]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,qBAAqB,QAAQ,cAAc;AAKpD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,QAAQ,mBAAmB;AAuChD,OAAO,SAASC,aAAaA,CAC3BC,SAAY,EACY;EACxB,MAAM;IAAEC;EAAiB,CAAC,GAAGJ,KAAK,CAACK,UAAU,CAACJ,YAAY,CAAC;EAC3D,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAGP,KAAK,CAACQ,QAAQ,CAAkC,CAAC;EAC3E,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGV,KAAK,CAACQ,QAAQ,CAAiC,CAAC;EACxE,MAAM,CAACG,SAAS,EAAEC,UAAU,CAAC,GAAGZ,KAAK,CAACQ,QAAQ,CAAC,KAAK,CAAC;EACrD,MAAM,CAACK,YAAY,EAAEC,aAAa,CAAC,GAAGd,KAAK,CAACQ,QAAQ,CAAC,KAAK,CAAC;EAC3D,MAAM,CAACO,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGhB,KAAK,CAACQ,QAAQ,CAE5D,CAAC;EACH,MAAMS,kBAAkB,GAAGjB,KAAK,CAACkB,MAAM,CAAyB,IAAI,CAAC;EAErE,MAAMC,WAAW,GAAGnB,KAAK,CAACoB,WAAW,CAAC,gBACpCC,QAA4D,EAC5D;IACA,IAAI;MACF;MACA,IAAIR,YAAY,IAAII,kBAAkB,CAACK,OAAO,EAAE;QAC9CL,kBAAkB,CAACK,OAAO,CAACC,KAAK,CAAC,CA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C;EACAX,KAAK,CAACgD,SAAS,CAAC,MAAM;IACpB,OAAO,MAAM;MACX,IAAI/B,kBAAkB,CAACK,OAAO,EAAE;QAC9BL,kBAAkB,CAACK,OAAO,CAACC,KAAK,CAAC,CAAC;MACpC;IACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOvB,KAAK,CAACiD,OAAO,CAAC,OAAO;IAC1B9B,WAAW;IACXqB,cAAc;IACdlC,KAAK;IACLG,IAAI;IACJE,SAAS;IACTE,YAAY;IACZE;EACF,CAAC,CAAC,EAAE,CACFI,WAAW,EACXqB,cAAc,EACdlC,KAAK,EACLG,IAAI,EACJE,SAAS,EACTE,YAAY,EACZE,gBAAgB,CACjB,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"useOsdkAction.js","names":["ActionValidationError","React","OsdkContext2","useOsdkAction","actionDef","observableClient","useContext","error","setError","useState","data","setData","isPending","setPending","isValidating","setValidating","validationResult","setValidationResult","abortControllerRef","useRef","applyAction","useCallback","hookArgs","current","abort","undefined","Array","isArray","updates","args","map","a","$optimisticUpdate","push","r","optimisticUpdate","ctx","update","e","actionValidation","unknown","validateAction","abortController","AbortController","result","signal","aborted","Error","name","useEffect","useMemo"],"sources":["useOsdkAction.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 ActionDefinition,\n ActionEditResponse,\n ActionValidationResponse,\n} from \"@osdk/client\";\nimport { ActionValidationError } from \"@osdk/client\";\nimport type {\n ActionSignatureFromDef,\n ObservableClient,\n} from \"@osdk/client/unstable-do-not-use\";\nimport React from \"react\";\nimport { OsdkContext2 } from \"./OsdkContext2.js\";\n\ntype ApplyActionParams<Q extends ActionDefinition<any>> =\n & Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0]\n & {\n [K in keyof ObservableClient.ApplyActionOptions as `$${K}`]:\n ObservableClient.ApplyActionOptions[K];\n };\n\nexport interface UseOsdkActionResult<Q extends ActionDefinition<any>> {\n applyAction: (\n args: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) => Promise<ActionEditResponse | undefined>;\n\n error:\n | undefined\n | Partial<{\n actionValidation: ActionValidationError;\n unknown: unknown;\n }>;\n data: ActionEditResponse | undefined;\n\n isPending: boolean;\n isValidating: boolean;\n\n /**\n * Validates the action with the provided arguments without executing it.\n * Calling this function again before the previous validation finishes will cancel\n * the first validation and start a new one.\n * @param args The action arguments to validate\n * @returns A promise that resolves to the validation response, or undefined if aborted\n */\n validateAction: (\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ) => Promise<ActionValidationResponse | undefined>;\n\n validationResult?: ActionValidationResponse;\n}\n\nexport function useOsdkAction<Q extends ActionDefinition<any>>(\n actionDef: Q,\n): UseOsdkActionResult<Q> {\n const { observableClient } = React.useContext(OsdkContext2);\n const [error, setError] = React.useState<UseOsdkActionResult<Q>[\"error\"]>();\n const [data, setData] = React.useState<ActionEditResponse | undefined>();\n const [isPending, setPending] = React.useState(false);\n const [isValidating, setValidating] = React.useState(false);\n const [validationResult, setValidationResult] = React.useState<\n ActionValidationResponse | undefined\n >();\n const abortControllerRef = React.useRef<AbortController | null>(null);\n\n const applyAction = React.useCallback(async function applyAction(\n hookArgs: ApplyActionParams<Q> | Array<ApplyActionParams<Q>>,\n ) {\n try {\n // If validation is in progress, abort it\n if (isValidating && abortControllerRef.current) {\n abortControllerRef.current.abort();\n setValidating(false);\n }\n\n setPending(true);\n setError(undefined);\n\n if (Array.isArray(hookArgs)) {\n const updates: Array<\n ObservableClient.ApplyActionOptions[\"optimisticUpdate\"]\n > = [];\n const args = hookArgs.map(a => {\n const { $optimisticUpdate, ...args } = a;\n if ($optimisticUpdate) {\n updates.push($optimisticUpdate);\n }\n return args;\n });\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: (ctx) => {\n for (const update of updates) {\n update?.(ctx);\n }\n },\n });\n setData(r);\n return r;\n } else {\n const { $optimisticUpdate, ...args } = hookArgs;\n\n const r = await observableClient.applyAction(actionDef, args, {\n optimisticUpdate: $optimisticUpdate,\n });\n setData(r);\n return r;\n }\n } catch (e) {\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n throw e;\n } finally {\n setPending(false);\n }\n }, [observableClient, actionDef, isValidating]);\n\n const validateAction = React.useCallback(async function validateAction(\n args: Parameters<ActionSignatureFromDef<Q>[\"applyAction\"]>[0],\n ): Promise<ActionValidationResponse | undefined> {\n try {\n // Check if action is being applied\n if (isPending) {\n return undefined;\n }\n\n // Abort any existing validation\n abortControllerRef.current?.abort();\n\n // Create new AbortController\n const abortController = new AbortController();\n abortControllerRef.current = abortController;\n\n setValidating(true);\n setError(undefined);\n\n const result = await observableClient.validateAction(actionDef, args);\n\n // Check if aborted\n if (abortController.signal.aborted) {\n return undefined;\n }\n\n setValidationResult(result);\n return result;\n } catch (e) {\n // Check if it was aborted\n if (e instanceof Error && e.name === \"AbortError\") {\n return undefined;\n }\n\n if (e instanceof ActionValidationError) {\n setError({\n actionValidation: e,\n });\n } else {\n setError({ unknown: e });\n }\n throw e;\n } finally {\n setValidating(false);\n }\n }, [observableClient, actionDef, isPending]);\n\n // Cleanup on unmount\n React.useEffect(() => {\n return () => {\n abortControllerRef.current?.abort();\n };\n }, []);\n\n return React.useMemo(() => ({\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n }), [\n applyAction,\n validateAction,\n error,\n data,\n isPending,\n isValidating,\n validationResult,\n ]);\n}\n"],"mappings":"AA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