@osdk/react 2.41.0 → 2.41.1-main-e39a72892d538f3130e2cd51cee05d83d11fa493

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 (142) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/build/browser/aip/chatStore.js.map +1 -1
  3. package/build/browser/aip/chatStream.js +1 -1
  4. package/build/browser/aip/chatStream.js.map +1 -1
  5. package/build/browser/aip/useChat.js +1 -1
  6. package/build/browser/aip/useChat.js.map +1 -1
  7. package/build/browser/new/OsdkContext.js.map +1 -1
  8. package/build/browser/new/OsdkProvider.js.map +1 -1
  9. package/build/browser/new/UserAgentContext.js.map +1 -1
  10. package/build/browser/new/core/stableSerialize.js.map +1 -1
  11. package/build/browser/new/core/useStableObjectSet.js.map +1 -1
  12. package/build/browser/new/createCompositeExternalStore.js +1 -1
  13. package/build/browser/new/createCompositeExternalStore.js.map +1 -1
  14. package/build/browser/new/hookUtils.js.map +1 -1
  15. package/build/browser/new/makeExternalStore.js +3 -3
  16. package/build/browser/new/makeExternalStore.js.map +1 -1
  17. package/build/browser/new/platform-apis/admin/useCbacBanner.js.map +1 -1
  18. package/build/browser/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -1
  19. package/build/browser/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
  20. package/build/browser/new/platform-apis/admin/useFoundryUser.js.map +1 -1
  21. package/build/browser/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
  22. package/build/browser/new/platform-apis/admin/useMarkingCategories.js.map +1 -1
  23. package/build/browser/new/platform-apis/admin/useMarkings.js.map +1 -1
  24. package/build/browser/new/platform-apis/admin/useUserMarkings.js.map +1 -1
  25. package/build/browser/new/shapes/derivedLinksStore.js.map +1 -1
  26. package/build/browser/new/shapes/types.js.map +1 -1
  27. package/build/browser/new/shapes/useShape.js.map +1 -1
  28. package/build/browser/new/shared/storeUtils.js.map +1 -1
  29. package/build/browser/new/useDevToolsClient.js.map +1 -1
  30. package/build/browser/new/useLinks.js.map +1 -1
  31. package/build/browser/new/useObjectSet.js.map +1 -1
  32. package/build/browser/new/useOsdkAction.js.map +1 -1
  33. package/build/browser/new/useOsdkAggregation.js.map +1 -1
  34. package/build/browser/new/useOsdkFunction.js.map +1 -1
  35. package/build/browser/new/useOsdkFunctions.js.map +1 -1
  36. package/build/browser/new/useOsdkObject.js.map +1 -1
  37. package/build/browser/new/useOsdkObjects.js.map +1 -1
  38. package/build/browser/new/useRegisterUserAgent.js.map +1 -1
  39. package/build/browser/public/testing.js.map +1 -1
  40. package/build/browser/useObservableClient.js.map +1 -1
  41. package/build/browser/useOsdkClient.js.map +1 -1
  42. package/build/browser/useOsdkMetadata.js.map +1 -1
  43. package/build/browser/util/UserAgent.js +1 -1
  44. package/build/browser/util/UserAgent.js.map +1 -1
  45. package/build/browser/utils/useDebouncedCallback.js.map +1 -1
  46. package/build/browser/utils/usePlatformQuery.js.map +1 -1
  47. package/build/cjs/{chunk-SEFARM7Y.cjs → chunk-ICSJXGFL.cjs} +32 -32
  48. package/build/cjs/chunk-ICSJXGFL.cjs.map +1 -0
  49. package/build/cjs/{chunk-UKQGMTMG.cjs → chunk-O5ISVU2U.cjs} +5 -5
  50. package/build/cjs/chunk-O5ISVU2U.cjs.map +1 -0
  51. package/build/cjs/{chunk-HJHKH4B6.cjs → chunk-VQ4PS6U2.cjs} +7 -7
  52. package/build/cjs/{chunk-HJHKH4B6.cjs.map → chunk-VQ4PS6U2.cjs.map} +1 -1
  53. package/build/cjs/index.cjs +16 -16
  54. package/build/cjs/public/experimental/admin.cjs +10 -10
  55. package/build/cjs/public/experimental/aip.cjs +2 -2
  56. package/build/cjs/public/experimental/aip.cjs.map +1 -1
  57. package/build/cjs/public/experimental.cjs +17 -17
  58. package/build/cjs/public/experimental.d.cts +1 -1
  59. package/build/cjs/public/platform-apis.cjs +10 -10
  60. package/build/cjs/public/platform-apis.d.cts +7 -7
  61. package/build/esm/aip/chatStore.js.map +1 -1
  62. package/build/esm/aip/chatStream.js +1 -1
  63. package/build/esm/aip/chatStream.js.map +1 -1
  64. package/build/esm/aip/useChat.js +1 -1
  65. package/build/esm/aip/useChat.js.map +1 -1
  66. package/build/esm/new/OsdkContext.js.map +1 -1
  67. package/build/esm/new/OsdkProvider.js.map +1 -1
  68. package/build/esm/new/UserAgentContext.js.map +1 -1
  69. package/build/esm/new/core/stableSerialize.js.map +1 -1
  70. package/build/esm/new/core/useStableObjectSet.js.map +1 -1
  71. package/build/esm/new/createCompositeExternalStore.js +1 -1
  72. package/build/esm/new/createCompositeExternalStore.js.map +1 -1
  73. package/build/esm/new/hookUtils.js.map +1 -1
  74. package/build/esm/new/makeExternalStore.js +3 -3
  75. package/build/esm/new/makeExternalStore.js.map +1 -1
  76. package/build/esm/new/platform-apis/admin/useCbacBanner.js.map +1 -1
  77. package/build/esm/new/platform-apis/admin/useCbacMarkingRestrictions.js.map +1 -1
  78. package/build/esm/new/platform-apis/admin/useCurrentFoundryUser.js.map +1 -1
  79. package/build/esm/new/platform-apis/admin/useFoundryUser.js.map +1 -1
  80. package/build/esm/new/platform-apis/admin/useFoundryUsersList.js.map +1 -1
  81. package/build/esm/new/platform-apis/admin/useMarkingCategories.js.map +1 -1
  82. package/build/esm/new/platform-apis/admin/useMarkings.js.map +1 -1
  83. package/build/esm/new/platform-apis/admin/useUserMarkings.js.map +1 -1
  84. package/build/esm/new/shapes/derivedLinksStore.js.map +1 -1
  85. package/build/esm/new/shapes/types.js.map +1 -1
  86. package/build/esm/new/shapes/useShape.js.map +1 -1
  87. package/build/esm/new/shared/storeUtils.js.map +1 -1
  88. package/build/esm/new/useDevToolsClient.js.map +1 -1
  89. package/build/esm/new/useLinks.js.map +1 -1
  90. package/build/esm/new/useObjectSet.js.map +1 -1
  91. package/build/esm/new/useOsdkAction.js.map +1 -1
  92. package/build/esm/new/useOsdkAggregation.js.map +1 -1
  93. package/build/esm/new/useOsdkFunction.js.map +1 -1
  94. package/build/esm/new/useOsdkFunctions.js.map +1 -1
  95. package/build/esm/new/useOsdkObject.js.map +1 -1
  96. package/build/esm/new/useOsdkObjects.js.map +1 -1
  97. package/build/esm/new/useRegisterUserAgent.js.map +1 -1
  98. package/build/esm/public/testing.js.map +1 -1
  99. package/build/esm/useObservableClient.js.map +1 -1
  100. package/build/esm/useOsdkClient.js.map +1 -1
  101. package/build/esm/useOsdkMetadata.js.map +1 -1
  102. package/build/esm/util/UserAgent.js +1 -1
  103. package/build/esm/util/UserAgent.js.map +1 -1
  104. package/build/esm/utils/useDebouncedCallback.js.map +1 -1
  105. package/build/esm/utils/usePlatformQuery.js.map +1 -1
  106. package/build/types/aip/chatStore.d.ts.map +1 -1
  107. package/build/types/aip/chatStream.d.ts.map +1 -1
  108. package/build/types/aip/useChat.d.ts.map +1 -1
  109. package/build/types/new/OsdkProvider.d.ts.map +1 -1
  110. package/build/types/new/core/stableSerialize.d.ts.map +1 -1
  111. package/build/types/new/core/useStableObjectSet.d.ts.map +1 -1
  112. package/build/types/new/createCompositeExternalStore.d.ts +1 -1
  113. package/build/types/new/createCompositeExternalStore.d.ts.map +1 -1
  114. package/build/types/new/makeExternalStore.d.ts +2 -2
  115. package/build/types/new/makeExternalStore.d.ts.map +1 -1
  116. package/build/types/new/platform-apis/admin/useCbacBanner.d.ts.map +1 -1
  117. package/build/types/new/platform-apis/admin/useCbacMarkingRestrictions.d.ts.map +1 -1
  118. package/build/types/new/platform-apis/admin/useCurrentFoundryUser.d.ts.map +1 -1
  119. package/build/types/new/platform-apis/admin/useFoundryUser.d.ts.map +1 -1
  120. package/build/types/new/platform-apis/admin/useFoundryUsersList.d.ts.map +1 -1
  121. package/build/types/new/platform-apis/admin/useMarkingCategories.d.ts.map +1 -1
  122. package/build/types/new/platform-apis/admin/useMarkings.d.ts.map +1 -1
  123. package/build/types/new/platform-apis/admin/useUserMarkings.d.ts.map +1 -1
  124. package/build/types/new/shapes/derivedLinksStore.d.ts.map +1 -1
  125. package/build/types/new/shapes/useShape.d.ts.map +1 -1
  126. package/build/types/new/useDevToolsClient.d.ts.map +1 -1
  127. package/build/types/new/useLinks.d.ts.map +1 -1
  128. package/build/types/new/useOsdkAction.d.ts.map +1 -1
  129. package/build/types/new/useOsdkAggregation.d.ts.map +1 -1
  130. package/build/types/new/useOsdkFunction.d.ts.map +1 -1
  131. package/build/types/new/useOsdkFunctions.d.ts.map +1 -1
  132. package/build/types/new/useOsdkObject.d.ts.map +1 -1
  133. package/build/types/new/useOsdkObjects.d.ts.map +1 -1
  134. package/build/types/new/useRegisterUserAgent.d.ts.map +1 -1
  135. package/build/types/public/testing.d.ts.map +1 -1
  136. package/build/types/useObservableClient.d.ts.map +1 -1
  137. package/build/types/useOsdkClient.d.ts.map +1 -1
  138. package/build/types/useOsdkMetadata.d.ts.map +1 -1
  139. package/build/types/utils/usePlatformQuery.d.ts.map +1 -1
  140. package/package.json +9 -9
  141. package/build/cjs/chunk-SEFARM7Y.cjs.map +0 -1
  142. package/build/cjs/chunk-UKQGMTMG.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"chatStore.js","names":["createChatStore","options","state","messages","initialMessages","status","error","undefined","subscribers","Set","throttleMs","pendingNotify","notifyNow","clearTimeout","s","notifyThrottled","setTimeout","getSnapshot","subscribe","notify","add","delete","setState","next","setStateThrottled"],"sources":["chatStore.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 { UIMessage } from \"@osdk/aip-core\";\n\nexport type ChatStatus = \"ready\" | \"submitted\" | \"streaming\" | \"error\";\n\nexport interface ChatState {\n messages: ReadonlyArray<UIMessage>;\n status: ChatStatus;\n error: Error | undefined;\n}\n\nexport interface ChatStore {\n getSnapshot: () => ChatState;\n /** Subscribe to state changes. Returns the unsubscribe function. */\n subscribe: (notify: () => void) => () => void;\n /** Replace state and notify subscribers synchronously. */\n setState: (\n next: ChatState | ((prev: ChatState) => ChatState),\n ) => void;\n /**\n * Replace state and coalesce subscriber notifications across rapid calls.\n * Notifications fire `throttleMs` after the first change in a quiet window.\n * Use for high-frequency updates (e.g. token streaming) where one render per\n * change is wasteful.\n */\n setStateThrottled: (\n next: ChatState | ((prev: ChatState) => ChatState),\n ) => void;\n}\n\nexport interface CreateChatStoreOptions {\n initialMessages?: ReadonlyArray<UIMessage>;\n /** Min ms between subscriber notifications. 0 = synchronous. Defaults to 0. */\n throttleMs?: number;\n}\n\n/**\n * Tiny pub-sub store backing `useChat`. Throttles subscriber notifications so\n * fast token-delta streams don't trigger one render per token.\n */\nexport function createChatStore(options: CreateChatStoreOptions): ChatStore {\n let state: ChatState = {\n messages: options.initialMessages ?? [],\n status: \"ready\",\n error: undefined,\n };\n\n const subscribers = new Set<() => void>();\n const throttleMs = options.throttleMs ?? 0;\n let pendingNotify: ReturnType<typeof setTimeout> | undefined;\n\n const notifyNow = (): void => {\n if (pendingNotify != null) {\n clearTimeout(pendingNotify);\n pendingNotify = undefined;\n }\n for (const s of subscribers) {\n s();\n }\n };\n\n const notifyThrottled = (): void => {\n if (throttleMs <= 0) {\n notifyNow();\n return;\n }\n if (pendingNotify != null) {\n return;\n }\n pendingNotify = setTimeout(notifyNow, throttleMs);\n };\n\n return {\n getSnapshot: () => state,\n subscribe: (notify) => {\n subscribers.add(notify);\n return () => {\n subscribers.delete(notify);\n };\n },\n setState: (next) => {\n state = typeof next === \"function\" ? next(state) : next;\n notifyNow();\n },\n setStateThrottled: (next) => {\n state = typeof next === \"function\" ? next(state) : next;\n notifyThrottled();\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;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IAAK;MAC3BrB,KAAK,GAAG,OAAOqB,IAAI,KAAK,UAAU,GAAGA,IAAI,CAACrB,KAAK,CAAC,GAAGqB,IAAI;MACvDR,eAAe,CAAC,CAAC;IACnB;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"chatStore.js","names":["createChatStore","options","state","messages","initialMessages","status","error","undefined","subscribers","Set","throttleMs","pendingNotify","notifyNow","clearTimeout","s","notifyThrottled","setTimeout","getSnapshot","subscribe","notify","add","delete","setState","next","setStateThrottled"],"sources":["chatStore.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 { UIMessage } from \"@osdk/aip-core\";\n\nexport type ChatStatus = \"ready\" | \"submitted\" | \"streaming\" | \"error\";\n\nexport interface ChatState {\n messages: ReadonlyArray<UIMessage>;\n status: ChatStatus;\n error: Error | undefined;\n}\n\nexport interface ChatStore {\n getSnapshot: () => ChatState;\n /** Subscribe to state changes. Returns the unsubscribe function. */\n subscribe: (notify: () => void) => () => void;\n /** Replace state and notify subscribers synchronously. */\n setState: (next: ChatState | ((prev: ChatState) => ChatState)) => void;\n /**\n * Replace state and coalesce subscriber notifications across rapid calls.\n * Notifications fire `throttleMs` after the first change in a quiet window.\n * Use for high-frequency updates (e.g. token streaming) where one render per\n * change is wasteful.\n */\n setStateThrottled: (\n next: ChatState | ((prev: ChatState) => ChatState)\n ) => void;\n}\n\nexport interface CreateChatStoreOptions {\n initialMessages?: ReadonlyArray<UIMessage>;\n /** Min ms between subscriber notifications. 0 = synchronous. Defaults to 0. */\n throttleMs?: number;\n}\n\n/**\n * Tiny pub-sub store backing `useChat`. Throttles subscriber notifications so\n * fast token-delta streams don't trigger one render per token.\n */\nexport function createChatStore(options: CreateChatStoreOptions): ChatStore {\n let state: ChatState = {\n messages: options.initialMessages ?? [],\n status: \"ready\",\n error: undefined,\n };\n\n const subscribers = new Set<() => void>();\n const throttleMs = options.throttleMs ?? 0;\n let pendingNotify: ReturnType<typeof setTimeout> | undefined;\n\n const notifyNow = (): void => {\n if (pendingNotify != null) {\n clearTimeout(pendingNotify);\n pendingNotify = undefined;\n }\n for (const s of subscribers) {\n s();\n }\n };\n\n const notifyThrottled = (): void => {\n if (throttleMs <= 0) {\n notifyNow();\n return;\n }\n if (pendingNotify != null) {\n return;\n }\n pendingNotify = setTimeout(notifyNow, throttleMs);\n };\n\n return {\n getSnapshot: () => state,\n subscribe: (notify) => {\n subscribers.add(notify);\n return () => {\n subscribers.delete(notify);\n };\n },\n setState: (next) => {\n state = typeof next === \"function\" ? next(state) : next;\n notifyNow();\n },\n setStateThrottled: (next) => {\n state = typeof next === \"function\" ? next(state) : next;\n notifyThrottled();\n },\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA,OAAO,SAASA,eAAeA,CAACC,OAA+B,EAAa;EAC1E,IAAIC,KAAgB,GAAG;IACrBC,QAAQ,EAAEF,OAAO,CAACG,eAAe,IAAI,EAAE;IACvCC,MAAM,EAAE,OAAO;IACfC,KAAK,EAAEC;EACT,CAAC;EAED,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAAa,CAAC;EACzC,MAAMC,UAAU,GAAGT,OAAO,CAACS,UAAU,IAAI,CAAC;EAC1C,IAAIC,aAAwD;EAE5D,MAAMC,SAAS,GAAGA,CAAA,KAAY;IAC5B,IAAID,aAAa,IAAI,IAAI,EAAE;MACzBE,YAAY,CAACF,aAAa,CAAC;MAC3BA,aAAa,GAAGJ,SAAS;IAC3B;IACA,KAAK,MAAMO,CAAC,IAAIN,WAAW,EAAE;MAC3BM,CAAC,CAAC,CAAC;IACL;EACF,CAAC;EAED,MAAMC,eAAe,GAAGA,CAAA,KAAY;IAClC,IAAIL,UAAU,IAAI,CAAC,EAAE;MACnBE,SAAS,CAAC,CAAC;MACX;IACF;IACA,IAAID,aAAa,IAAI,IAAI,EAAE;MACzB;IACF;IACAA,aAAa,GAAGK,UAAU,CAACJ,SAAS,EAAEF,UAAU,CAAC;EACnD,CAAC;EAED,OAAO;IACLO,WAAW,EAAEA,CAAA,KAAMf,KAAK;IACxBgB,SAAS,EAAGC,MAAM,IAAK;MACrBX,WAAW,CAACY,GAAG,CAACD,MAAM,CAAC;MACvB,OAAO,MAAM;QACXX,WAAW,CAACa,MAAM,CAACF,MAAM,CAAC;MAC5B,CAAC;IACH,CAAC;IACDG,QAAQ,EAAGC,IAAI,IAAK;MAClBrB,KAAK,GAAG,OAAOqB,IAAI,KAAK,UAAU,GAAGA,IAAI,CAACrB,KAAK,CAAC,GAAGqB,IAAI;MACvDX,SAAS,CAAC,CAAC;IACb,CAAC;IACDY,iBAAiB,EAAGD,IAAI,IAAK;MAC3BrB,KAAK,GAAG,OAAOqB,IAAI,KAAK,UAAU,GAAGA,IAAI,CAACrB,KAAK,CAAC,GAAGqB,IAAI;MACvDR,eAAe,CAAC,CAAC;IACnB;EACF,CAAC;AACH","ignoreList":[]}
@@ -33,7 +33,7 @@ export async function runChatStream(ctx, transport, chatId, seed, trigger) {
33
33
  trigger,
34
34
  chatId,
35
35
  messageId: assistantId,
36
- messages: seed.slice(),
36
+ messages: [...seed],
37
37
  abortSignal: ctrl.signal
38
38
  });
39
39
  await drainStream(ctx, stream, assistantId, ctrl);
@@ -1 +1 @@
1
- {"version":3,"file":"chatStream.js","names":["generateMessageId","runChatStream","ctx","transport","chatId","seed","trigger","abortRef","current","abort","ctrl","AbortController","stoppedRef","assistantId","stream","sendMessages","messageId","messages","slice","abortSignal","signal","drainStream","err","handleStreamError","assistantMessageId","capturedCtrl","store","reader","getReader","textBuf","isStale","isOrphaned","getSnapshot","length","some","m","id","done","value","read","cancel","setState","prev","status","type","delta","upsertAssistantText","aborted","Error","errorText","finalSnap","finalMessage","find","onFinish","message","releaseLock","text","setStateThrottled","exists","map","parts","role","error","String","name","undefined","onError"],"sources":["chatStream.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 {\n type ChatTransport,\n generateMessageId,\n type UIMessage,\n type UIMessageChunk,\n} from \"@osdk/aip-core\";\nimport type React from \"react\";\nimport type { ChatStore } from \"./chatStore.js\";\n\n/**\n * Mutable orchestration handle threaded through the streaming functions.\n * Holds everything they need to read snapshots, mutate state, and check\n * whether their stream is still the active one.\n */\nexport interface StreamContext {\n store: ChatStore;\n abortRef: React.MutableRefObject<AbortController | undefined>;\n stoppedRef: React.MutableRefObject<boolean>;\n onFinish:\n | ((event: {\n message: UIMessage;\n messages: ReadonlyArray<UIMessage>;\n }) => void)\n | undefined;\n onError: ((error: Error) => void) | undefined;\n}\n\nexport async function runChatStream(\n ctx: StreamContext,\n transport: ChatTransport<UIMessage>,\n chatId: string,\n seed: ReadonlyArray<UIMessage>,\n trigger: \"submit-message\" | \"regenerate-message\",\n): Promise<void> {\n ctx.abortRef.current?.abort();\n const ctrl = new AbortController();\n ctx.abortRef.current = ctrl;\n ctx.stoppedRef.current = false;\n\n const assistantId = generateMessageId();\n try {\n const stream = await transport.sendMessages({\n trigger,\n chatId,\n messageId: assistantId,\n messages: seed.slice(),\n abortSignal: ctrl.signal,\n });\n await drainStream(ctx, stream, assistantId, ctrl);\n } catch (err) {\n handleStreamError(ctx, err, ctrl);\n }\n}\n\nexport async function drainStream(\n ctx: StreamContext,\n stream: ReadableStream<UIMessageChunk>,\n assistantMessageId: string,\n capturedCtrl: AbortController,\n): Promise<void> {\n const { store } = ctx;\n const reader = stream.getReader();\n let textBuf = \"\";\n\n const isStale = (): boolean =>\n ctx.abortRef.current != null && ctx.abortRef.current !== capturedCtrl;\n\n // Caller dropped our assistant message via `setMessages` mid-stream.\n // Treat as \"the consumer no longer wants this stream\" — quietly stop.\n const isOrphaned = (): boolean => {\n const messages = store.getSnapshot().messages;\n return textBuf.length > 0\n && !messages.some((m) => m.id === assistantMessageId);\n };\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n if (isStale()) {\n await reader.cancel();\n return;\n }\n if (isOrphaned()) {\n await reader.cancel();\n store.setState((prev) => ({ ...prev, status: \"ready\" }));\n return;\n }\n if (value.type === \"text-delta\") {\n textBuf += value.delta;\n upsertAssistantText(store, assistantMessageId, textBuf);\n } else if (value.type === \"error\") {\n if (ctx.stoppedRef.current || capturedCtrl.signal.aborted) {\n return;\n }\n await reader.cancel();\n throw new Error(value.errorText);\n }\n }\n if (isStale()) {\n return;\n }\n store.setState((prev) => ({ ...prev, status: \"ready\" }));\n const finalSnap = store.getSnapshot();\n const finalMessage = finalSnap.messages.find(\n (m) => m.id === assistantMessageId,\n );\n if (finalMessage != null && ctx.onFinish != null) {\n ctx.onFinish({ message: finalMessage, messages: finalSnap.messages });\n }\n } catch (err) {\n handleStreamError(ctx, err, capturedCtrl);\n } finally {\n reader.releaseLock();\n }\n}\n\nfunction upsertAssistantText(\n store: ChatStore,\n assistantMessageId: string,\n text: string,\n): void {\n store.setStateThrottled((prev) => {\n const exists = prev.messages.some((m) => m.id === assistantMessageId);\n const messages = exists\n ? prev.messages.map((m) =>\n m.id === assistantMessageId\n ? { ...m, parts: [{ type: \"text\" as const, text }] }\n : m\n )\n : [\n ...prev.messages,\n {\n id: assistantMessageId,\n role: \"assistant\" as const,\n parts: [{ type: \"text\" as const, text }],\n },\n ];\n return { ...prev, status: \"streaming\", messages };\n });\n}\n\nfunction handleStreamError(\n ctx: StreamContext,\n err: unknown,\n capturedCtrl: AbortController,\n): void {\n if (ctx.abortRef.current != null && ctx.abortRef.current !== capturedCtrl) {\n return;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n if (\n ctx.stoppedRef.current\n || error.name === \"AbortError\"\n || capturedCtrl.signal.aborted\n ) {\n ctx.store.setState((prev) => ({\n ...prev,\n status: \"ready\",\n error: undefined,\n }));\n return;\n }\n ctx.store.setState((prev) => ({ ...prev, status: \"error\", error }));\n ctx.onError?.(error);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,iBAAiB,QAGZ,gBAAgB;;AAIvB;AACA;AACA;AACA;AACA;;AAcA,OAAO,eAAeC,aAAaA,CACjCC,GAAkB,EAClBC,SAAmC,EACnCC,MAAc,EACdC,IAA8B,EAC9BC,OAAgD,EACjC;EACfJ,GAAG,CAACK,QAAQ,CAACC,OAAO,EAAEC,KAAK,CAAC,CAAC;EAC7B,MAAMC,IAAI,GAAG,IAAIC,eAAe,CAAC,CAAC;EAClCT,GAAG,CAACK,QAAQ,CAACC,OAAO,GAAGE,IAAI;EAC3BR,GAAG,CAACU,UAAU,CAACJ,OAAO,GAAG,KAAK;EAE9B,MAAMK,WAAW,GAAGb,iBAAiB,CAAC,CAAC;EACvC,IAAI;IACF,MAAMc,MAAM,GAAG,MAAMX,SAAS,CAACY,YAAY,CAAC;MAC1CT,OAAO;MACPF,MAAM;MACNY,SAAS,EAAEH,WAAW;MACtBI,QAAQ,EAAEZ,IAAI,CAACa,KAAK,CAAC,CAAC;MACtBC,WAAW,EAAET,IAAI,CAACU;IACpB,CAAC,CAAC;IACF,MAAMC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M;MAC5B,GAAGA,IAAI;MACPC,MAAM,EAAE,OAAO;MACfmB,KAAK,EAAEG;IACT,CAAC,CAAC,CAAC;IACH;EACF;EACA/D,GAAG,CAACwB,KAAK,CAACe,QAAQ,CAAEC,IAAI,KAAM;IAAE,GAAGA,IAAI;IAAEC,MAAM,EAAE,OAAO;IAAEmB;EAAM,CAAC,CAAC,CAAC;EACnE5D,GAAG,CAACgE,OAAO,GAAGJ,KAAK,CAAC;AACtB","ignoreList":[]}
1
+ {"version":3,"file":"chatStream.js","names":["generateMessageId","runChatStream","ctx","transport","chatId","seed","trigger","abortRef","current","abort","ctrl","AbortController","stoppedRef","assistantId","stream","sendMessages","messageId","messages","abortSignal","signal","drainStream","err","handleStreamError","assistantMessageId","capturedCtrl","store","reader","getReader","textBuf","isStale","isOrphaned","getSnapshot","length","some","m","id","done","value","read","cancel","setState","prev","status","type","delta","upsertAssistantText","aborted","Error","errorText","finalSnap","finalMessage","find","onFinish","message","releaseLock","text","setStateThrottled","exists","map","parts","role","error","String","name","undefined","onError"],"sources":["chatStream.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 {\n type ChatTransport,\n generateMessageId,\n type UIMessage,\n type UIMessageChunk,\n} from \"@osdk/aip-core\";\nimport type React from \"react\";\n\nimport type { ChatStore } from \"./chatStore.js\";\n\n/**\n * Mutable orchestration handle threaded through the streaming functions.\n * Holds everything they need to read snapshots, mutate state, and check\n * whether their stream is still the active one.\n */\nexport interface StreamContext {\n store: ChatStore;\n abortRef: React.MutableRefObject<AbortController | undefined>;\n stoppedRef: React.MutableRefObject<boolean>;\n onFinish:\n | ((event: {\n message: UIMessage;\n messages: ReadonlyArray<UIMessage>;\n }) => void)\n | undefined;\n onError: ((error: Error) => void) | undefined;\n}\n\nexport async function runChatStream(\n ctx: StreamContext,\n transport: ChatTransport<UIMessage>,\n chatId: string,\n seed: ReadonlyArray<UIMessage>,\n trigger: \"submit-message\" | \"regenerate-message\"\n): Promise<void> {\n ctx.abortRef.current?.abort();\n const ctrl = new AbortController();\n ctx.abortRef.current = ctrl;\n ctx.stoppedRef.current = false;\n\n const assistantId = generateMessageId();\n try {\n const stream = await transport.sendMessages({\n trigger,\n chatId,\n messageId: assistantId,\n messages: [...seed],\n abortSignal: ctrl.signal,\n });\n await drainStream(ctx, stream, assistantId, ctrl);\n } catch (err) {\n handleStreamError(ctx, err, ctrl);\n }\n}\n\nexport async function drainStream(\n ctx: StreamContext,\n stream: ReadableStream<UIMessageChunk>,\n assistantMessageId: string,\n capturedCtrl: AbortController\n): Promise<void> {\n const { store } = ctx;\n const reader = stream.getReader();\n let textBuf = \"\";\n\n const isStale = (): boolean =>\n ctx.abortRef.current != null && ctx.abortRef.current !== capturedCtrl;\n\n // Caller dropped our assistant message via `setMessages` mid-stream.\n // Treat as \"the consumer no longer wants this stream\" — quietly stop.\n const isOrphaned = (): boolean => {\n const messages = store.getSnapshot().messages;\n return (\n textBuf.length > 0 && !messages.some((m) => m.id === assistantMessageId)\n );\n };\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n if (isStale()) {\n await reader.cancel();\n return;\n }\n if (isOrphaned()) {\n await reader.cancel();\n store.setState((prev) => ({ ...prev, status: \"ready\" }));\n return;\n }\n if (value.type === \"text-delta\") {\n textBuf += value.delta;\n upsertAssistantText(store, assistantMessageId, textBuf);\n } else if (value.type === \"error\") {\n if (ctx.stoppedRef.current || capturedCtrl.signal.aborted) {\n return;\n }\n await reader.cancel();\n throw new Error(value.errorText);\n }\n }\n if (isStale()) {\n return;\n }\n store.setState((prev) => ({ ...prev, status: \"ready\" }));\n const finalSnap = store.getSnapshot();\n const finalMessage = finalSnap.messages.find(\n (m) => m.id === assistantMessageId\n );\n if (finalMessage != null && ctx.onFinish != null) {\n ctx.onFinish({ message: finalMessage, messages: finalSnap.messages });\n }\n } catch (err) {\n handleStreamError(ctx, err, capturedCtrl);\n } finally {\n reader.releaseLock();\n }\n}\n\nfunction upsertAssistantText(\n store: ChatStore,\n assistantMessageId: string,\n text: string\n): void {\n store.setStateThrottled((prev) => {\n const exists = prev.messages.some((m) => m.id === assistantMessageId);\n const messages = exists\n ? prev.messages.map((m) =>\n m.id === assistantMessageId\n ? { ...m, parts: [{ type: \"text\" as const, text }] }\n : m\n )\n : [\n ...prev.messages,\n {\n id: assistantMessageId,\n role: \"assistant\" as const,\n parts: [{ type: \"text\" as const, text }],\n },\n ];\n return { ...prev, status: \"streaming\", messages };\n });\n}\n\nfunction handleStreamError(\n ctx: StreamContext,\n err: unknown,\n capturedCtrl: AbortController\n): void {\n if (ctx.abortRef.current != null && ctx.abortRef.current !== capturedCtrl) {\n return;\n }\n const error = err instanceof Error ? err : new Error(String(err));\n if (\n ctx.stoppedRef.current ||\n error.name === \"AbortError\" ||\n capturedCtrl.signal.aborted\n ) {\n ctx.store.setState((prev) => ({\n ...prev,\n status: \"ready\",\n error: undefined,\n }));\n return;\n }\n ctx.store.setState((prev) => ({ ...prev, status: \"error\", error }));\n ctx.onError?.(error);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,iBAAiB,QAGZ,gBAAgB;;AAKvB;AACA;AACA;AACA;AACA;;AAcA,OAAO,eAAeC,aAAaA,CACjCC,GAAkB,EAClBC,SAAmC,EACnCC,MAAc,EACdC,IAA8B,EAC9BC,OAAgD,EACjC;EACfJ,GAAG,CAACK,QAAQ,CAACC,OAAO,EAAEC,KAAK,CAAC,CAAC;EAC7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,GAAG,CAACK,QAAQ,CAACC,OAAO,IAAI,IAAI,IAAIN,GAAG,CAACK,QAAQ,CAACC,OAAO,KAAKgB,YAAY,EAAE;IACzE;EACF;EACA,MAAMqC,KAAK,GAAGxC,GAAG,YAAY0B,KAAK,GAAG1B,GAAG,GAAG,IAAI0B,KAAK,CAACe,MAAM,CAACzC,GAAG,CAAC,CAAC;EACjE,IACEnB,GAAG,CAACU,UAAU,CAACJ,OAAO,IACtBqD,KAAK,CAACE,IAAI,KAAK,YAAY,IAC3BvC,YAAY,CAACL,MAAM,CAAC2B,OAAO,EAC3B;IACA5C,GAAG,CAACuB,KAAK,CAACe,QAAQ,CAAEC,IAAI,KAAM;MAC5B,GAAGA,IAAI;MACPC,MAAM,EAAE,OAAO;MACfmB,KAAK,EAAEG;IACT,CAAC,CAAC,CAAC;IACH;EACF;EACA9D,GAAG,CAACuB,KAAK,CAACe,QAAQ,CAAEC,IAAI,KAAM;IAAE,GAAGA,IAAI;IAAEC,MAAM,EAAE,OAAO;IAAEmB;EAAM,CAAC,CAAC,CAAC;EACnE3D,GAAG,CAAC+D,OAAO,GAAGJ,KAAK,CAAC;AACtB","ignoreList":[]}
@@ -187,7 +187,7 @@ export function useChat(options) {
187
187
  function resolveRegenerateCutoff(messages, messageId) {
188
188
  if (messageId != null) {
189
189
  const index = messages.findIndex(m => m.id === messageId);
190
- if (index < 0) {
190
+ if (index === -1) {
191
191
  return {
192
192
  kind: "noop"
193
193
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useChat.js","names":["generateMessageId","LmsChatTransport","React","createChatStore","drainStream","runChatStream","useChat","options","onFinish","onError","id","useMemo","headersKey","JSON","stringify","headers","stopSequencesKey","stopSequences","transport","model","Error","built","system","temperature","maxOutputTokens","topP","presencePenalty","frequencyPenalty","seed","store","initialMessages","messages","throttleMs","experimentalThrottle","state","useSyncExternalStore","subscribe","getSnapshot","abortRef","useRef","undefined","stoppedRef","ctxRef","current","runStream","useCallback","trigger","sendMessage","input","userMsg","normalizeUserMessage","seeded","setState","status","error","regenerate","regenerateOpts","cutoff","resolveRegenerateCutoff","messageId","kind","prev","truncated","slice","index","stop","abort","resumeStream","stream","reconnectToStream","chatId","ctrl","AbortController","assistantId","clearError","setMessages","next","findIndex","m","target","role","lastAssistant","findLastAssistantIndex","parts","type","text","arr","i","length"],"sources":["useChat.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 {\n type ChatTransport,\n generateMessageId,\n type LanguageModel,\n LmsChatTransport,\n type LmsChatTransportOptions,\n type UIMessage,\n} from \"@osdk/aip-core\";\nimport React from \"react\";\nimport {\n type ChatStatus,\n type ChatStore,\n createChatStore,\n} from \"./chatStore.js\";\nimport {\n drainStream,\n runChatStream,\n type StreamContext,\n} from \"./chatStream.js\";\n\nexport type { ChatStatus } from \"./chatStore.js\";\n\n/**\n * Options for {@link useChat}.\n *\n * v0 covers text-only chat. Tools, multi-step agent loops, and stream\n * resume are not supported.\n */\nexport interface UseChatOptions {\n /** Required when no `transport` is provided: the LMS-backed model. */\n model?: LanguageModel;\n\n /** System prompt prepended to every request. Forwarded to the default transport. */\n system?: string;\n\n /** Sampling controls. Forwarded to the default transport. */\n temperature?: number;\n maxOutputTokens?: number;\n topP?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n stopSequences?: Array<string>;\n seed?: number;\n headers?: Record<string, string | undefined>;\n\n /** Stable chat id. A stable id is generated if not provided. */\n id?: string;\n\n /** Initial messages — used as the seed snapshot. */\n messages?: ReadonlyArray<UIMessage>;\n\n /** Override the transport. Defaults to a new `LmsChatTransport(options)`. */\n transport?: ChatTransport<UIMessage>;\n\n /**\n * Throttle subscriber notifications during streaming (ms). Default 50ms,\n * which keeps token-by-token rendering smooth without rerendering per token.\n */\n experimentalThrottle?: number;\n\n /** Fires when an in-flight stream errors out. */\n onError?: (error: Error) => void;\n\n /** Fires once after a stream completes successfully. */\n onFinish?: (event: {\n message: UIMessage;\n messages: ReadonlyArray<UIMessage>;\n }) => void;\n}\n\n/** Return value of {@link useChat}. */\nexport interface UseChatReturn {\n id: string;\n messages: ReadonlyArray<UIMessage>;\n /** No-op while a stream is in flight (`status === \"streaming\" | \"submitted\"`). Call `stop()` first to mutate during a stream. */\n setMessages: (\n messages:\n | ReadonlyArray<UIMessage>\n | ((prev: ReadonlyArray<UIMessage>) => ReadonlyArray<UIMessage>),\n ) => void;\n\n status: ChatStatus;\n error: Error | undefined;\n\n sendMessage: (message: SendMessageInput) => Promise<void>;\n regenerate: (options?: { messageId?: string }) => Promise<void>;\n stop: () => void;\n /** Calls `transport.reconnectToStream`. v0: LMS returns null, so this is a no-op. */\n resumeStream: () => Promise<void>;\n clearError: () => void;\n}\n\n/** Input shape accepted by `sendMessage`. */\nexport type SendMessageInput =\n | { text: string }\n | { role: \"user\"; parts: UIMessage[\"parts\"] };\n\n/**\n * React hook for streaming chat completions through `@osdk/aip-core`'s\n * `streamText`.\n *\n * @example\n * ```tsx\n * const { messages, status, sendMessage, stop, error } = useChat({\n * model: foundryModel({ client, model: \"gpt-4o\" }),\n * system: \"You are a concise assistant.\",\n * });\n * ```\n */\nexport function useChat(options: UseChatOptions): UseChatReturn {\n const { onFinish, onError } = options;\n\n const id = React.useMemo(\n () => options.id ?? generateMessageId(),\n [options.id],\n );\n\n // JSON-stringify keys keep the memo stable when callers pass inline objects.\n const headersKey = JSON.stringify(options.headers ?? null);\n const stopSequencesKey = JSON.stringify(options.stopSequences ?? null);\n const transport = React.useMemo<ChatTransport<UIMessage>>(\n () => {\n if (options.transport != null) {\n return options.transport;\n }\n if (options.model == null) {\n throw new Error(\n \"useChat: `model` is required when no `transport` is provided.\",\n );\n }\n const built: LmsChatTransportOptions = {\n model: options.model,\n system: options.system,\n temperature: options.temperature,\n maxOutputTokens: options.maxOutputTokens,\n topP: options.topP,\n presencePenalty: options.presencePenalty,\n frequencyPenalty: options.frequencyPenalty,\n stopSequences: options.stopSequences,\n seed: options.seed,\n headers: options.headers,\n };\n return new LmsChatTransport(built);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n options.transport,\n options.model,\n options.system,\n options.temperature,\n options.maxOutputTokens,\n options.topP,\n options.presencePenalty,\n options.frequencyPenalty,\n options.seed,\n headersKey,\n stopSequencesKey,\n ],\n );\n\n const store = React.useMemo<ChatStore>(\n () =>\n createChatStore({\n initialMessages: options.messages,\n throttleMs: options.experimentalThrottle ?? 50,\n }),\n // Recreating the store mid-session would drop chat state, so it's keyed\n // only by `id`. Use `setMessages` to mutate messages at runtime.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [id],\n );\n\n const state = React.useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n store.getSnapshot,\n );\n\n const abortRef = React.useRef<AbortController | undefined>(undefined);\n const stoppedRef = React.useRef<boolean>(false);\n\n const ctxRef = React.useRef<StreamContext>({\n store,\n abortRef,\n stoppedRef,\n onFinish,\n onError,\n });\n ctxRef.current = { store, abortRef, stoppedRef, onFinish, onError };\n\n const runStream = React.useCallback(\n (\n seed: ReadonlyArray<UIMessage>,\n trigger: \"submit-message\" | \"regenerate-message\",\n ): Promise<void> =>\n runChatStream(ctxRef.current, transport, id, seed, trigger),\n [transport, id],\n );\n\n const sendMessage = React.useCallback(\n async (input: SendMessageInput): Promise<void> => {\n const userMsg = normalizeUserMessage(input);\n const seeded = [...store.getSnapshot().messages, userMsg];\n store.setState({\n messages: seeded,\n status: \"submitted\",\n error: undefined,\n });\n await runStream(seeded, \"submit-message\");\n },\n [store, runStream],\n );\n\n const regenerate = React.useCallback(\n async (regenerateOpts?: { messageId?: string }): Promise<void> => {\n const messages = store.getSnapshot().messages;\n const cutoff = resolveRegenerateCutoff(\n messages,\n regenerateOpts?.messageId,\n );\n if (cutoff.kind === \"noop\") {\n return;\n }\n if (cutoff.kind === \"error\") {\n store.setState((prev) => ({\n ...prev,\n status: \"error\",\n error: cutoff.error,\n }));\n return;\n }\n const truncated = messages.slice(0, cutoff.index);\n store.setState({\n messages: truncated,\n status: \"submitted\",\n error: undefined,\n });\n await runStream(truncated, \"regenerate-message\");\n },\n [store, runStream],\n );\n\n const stop = React.useCallback((): void => {\n stoppedRef.current = true;\n abortRef.current?.abort();\n abortRef.current = undefined;\n }, []);\n\n const resumeStream = React.useCallback(async (): Promise<void> => {\n const stream = await transport.reconnectToStream({ chatId: id });\n if (stream == null) {\n return;\n }\n abortRef.current?.abort();\n const ctrl = new AbortController();\n abortRef.current = ctrl;\n const assistantId = generateMessageId();\n await drainStream(ctxRef.current, stream, assistantId, ctrl);\n }, [transport, id]);\n\n const clearError = React.useCallback((): void => {\n // Resetting from streaming/submitted would race the in-flight stream, so\n // only reset when status === \"error\".\n store.setState(\n (prev) =>\n prev.status === \"error\"\n ? { ...prev, status: \"ready\", error: undefined }\n : prev,\n );\n }, [store]);\n\n const setMessages = React.useCallback(\n (\n next:\n | ReadonlyArray<UIMessage>\n | ((prev: ReadonlyArray<UIMessage>) => ReadonlyArray<UIMessage>),\n ): void => {\n store.setState((prev) => {\n if (prev.status === \"streaming\" || prev.status === \"submitted\") {\n return prev;\n }\n return {\n ...prev,\n messages: typeof next === \"function\" ? next(prev.messages) : next,\n };\n });\n },\n [store],\n );\n\n return React.useMemo(\n () => ({\n id,\n messages: state.messages,\n setMessages,\n status: state.status,\n error: state.error,\n sendMessage,\n regenerate,\n stop,\n resumeStream,\n clearError,\n }),\n [\n id,\n state.messages,\n state.status,\n state.error,\n setMessages,\n sendMessage,\n regenerate,\n stop,\n resumeStream,\n clearError,\n ],\n );\n}\n\ntype RegenerateCutoff =\n | { kind: \"noop\" }\n | { kind: \"error\"; error: Error }\n | { kind: \"ok\"; index: number };\n\nfunction resolveRegenerateCutoff(\n messages: ReadonlyArray<UIMessage>,\n messageId: string | undefined,\n): RegenerateCutoff {\n if (messageId != null) {\n const index = messages.findIndex((m) => m.id === messageId);\n if (index < 0) {\n return { kind: \"noop\" };\n }\n const target = messages[index];\n if (target == null || target.role !== \"assistant\") {\n return {\n kind: \"error\",\n error: new Error(\n `useChat.regenerate: messageId \"${messageId}\" is `\n + `not an assistant message; only assistant messages can be regenerated.`,\n ),\n };\n }\n return { kind: \"ok\", index };\n }\n const lastAssistant = findLastAssistantIndex(messages);\n if (lastAssistant < 0) {\n return { kind: \"noop\" };\n }\n return { kind: \"ok\", index: lastAssistant };\n}\n\nfunction normalizeUserMessage(input: SendMessageInput): UIMessage {\n if (\"text\" in input) {\n return {\n id: generateMessageId(),\n role: \"user\",\n parts: [{ type: \"text\", text: input.text }],\n };\n }\n return {\n id: generateMessageId(),\n role: input.role,\n parts: input.parts,\n };\n}\n\nfunction findLastAssistantIndex(arr: ReadonlyArray<UIMessage>): number {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (arr[i]?.role === \"assistant\") {\n return i;\n }\n }\n return -1;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,iBAAiB,EAEjBC,gBAAgB,QAGX,gBAAgB;AACvB,OAAOC,KAAK,MAAM,OAAO;AACzB,SAGEC,eAAe,QACV,gBAAgB;AACvB,SACEC,WAAW,EACXC,aAAa,QAER,iBAAiB;;AAIxB;AACA;AACA;AACA;AACA;AACA;;AA2CA;;AAsBA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAACC,OAAuB,EAAiB;EAC9D,MAAM;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EAErC,MAAMG,EAA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AC9B;EACA,MAAMiB,aAAa,GAAGC,sBAAsB,CAACnD,QAAQ,CAAC;EACtD,IAAIkD,aAAa,GAAG,CAAC,EAAE;IACrB,OAAO;MAAErB,IAAI,EAAE;IAAO,CAAC;EACzB;EACA,OAAO;IAAEA,IAAI,EAAE,IAAI;IAAEI,KAAK,EAAEiB;EAAc,CAAC;AAC7C;AAEA,SAAS/B,oBAAoBA,CAACF,KAAuB,EAAa;EAChE,IAAI,MAAM,IAAIA,KAAK,EAAE;IACnB,OAAO;MACLtC,EAAE,EAAEV,iBAAiB,CAAC,CAAC;MACvBgF,IAAI,EAAE,MAAM;MACZG,KAAK,EAAE,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEC,IAAI,EAAErC,KAAK,CAACqC;MAAK,CAAC;IAC5C,CAAC;EACH;EACA,OAAO;IACL3E,EAAE,EAAEV,iBAAiB,CAAC,CAAC;IACvBgF,IAAI,EAAEhC,KAAK,CAACgC,IAAI;IAChBG,KAAK,EAAEnC,KAAK,CAACmC;EACf,CAAC;AACH;AAEA,SAASD,sBAAsBA,CAACI,GAA6B,EAAU;EACrE,KAAK,IAAIC,CAAC,GAAGD,GAAG,CAACE,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;IACxC,IAAID,GAAG,CAACC,CAAC,CAAC,EAAEP,IAAI,KAAK,WAAW,EAAE;MAChC,OAAOO,CAAC;IACV;EACF;EACA,OAAO,CAAC,CAAC;AACX","ignoreList":[]}
1
+ {"version":3,"file":"useChat.js","names":["generateMessageId","LmsChatTransport","React","createChatStore","drainStream","runChatStream","useChat","options","onFinish","onError","id","useMemo","headersKey","JSON","stringify","headers","stopSequencesKey","stopSequences","transport","model","Error","built","system","temperature","maxOutputTokens","topP","presencePenalty","frequencyPenalty","seed","store","initialMessages","messages","throttleMs","experimentalThrottle","state","useSyncExternalStore","subscribe","getSnapshot","abortRef","useRef","undefined","stoppedRef","ctxRef","current","runStream","useCallback","trigger","sendMessage","input","userMsg","normalizeUserMessage","seeded","setState","status","error","regenerate","regenerateOpts","cutoff","resolveRegenerateCutoff","messageId","kind","prev","truncated","slice","index","stop","abort","resumeStream","stream","reconnectToStream","chatId","ctrl","AbortController","assistantId","clearError","setMessages","next","findIndex","m","target","role","lastAssistant","findLastAssistantIndex","parts","type","text","arr","i","length"],"sources":["useChat.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 {\n type ChatTransport,\n generateMessageId,\n type LanguageModel,\n LmsChatTransport,\n type LmsChatTransportOptions,\n type UIMessage,\n} from \"@osdk/aip-core\";\nimport React from \"react\";\n\nimport {\n type ChatStatus,\n type ChatStore,\n createChatStore,\n} from \"./chatStore.js\";\nimport {\n drainStream,\n runChatStream,\n type StreamContext,\n} from \"./chatStream.js\";\n\nexport type { ChatStatus } from \"./chatStore.js\";\n\n/**\n * Options for {@link useChat}.\n *\n * v0 covers text-only chat. Tools, multi-step agent loops, and stream\n * resume are not supported.\n */\nexport interface UseChatOptions {\n /** Required when no `transport` is provided: the LMS-backed model. */\n model?: LanguageModel;\n\n /** System prompt prepended to every request. Forwarded to the default transport. */\n system?: string;\n\n /** Sampling controls. Forwarded to the default transport. */\n temperature?: number;\n maxOutputTokens?: number;\n topP?: number;\n presencePenalty?: number;\n frequencyPenalty?: number;\n stopSequences?: Array<string>;\n seed?: number;\n headers?: Record<string, string | undefined>;\n\n /** Stable chat id. A stable id is generated if not provided. */\n id?: string;\n\n /** Initial messages — used as the seed snapshot. */\n messages?: ReadonlyArray<UIMessage>;\n\n /** Override the transport. Defaults to a new `LmsChatTransport(options)`. */\n transport?: ChatTransport<UIMessage>;\n\n /**\n * Throttle subscriber notifications during streaming (ms). Default 50ms,\n * which keeps token-by-token rendering smooth without rerendering per token.\n */\n experimentalThrottle?: number;\n\n /** Fires when an in-flight stream errors out. */\n onError?: (error: Error) => void;\n\n /** Fires once after a stream completes successfully. */\n onFinish?: (event: {\n message: UIMessage;\n messages: ReadonlyArray<UIMessage>;\n }) => void;\n}\n\n/** Return value of {@link useChat}. */\nexport interface UseChatReturn {\n id: string;\n messages: ReadonlyArray<UIMessage>;\n /** No-op while a stream is in flight (`status === \"streaming\" | \"submitted\"`). Call `stop()` first to mutate during a stream. */\n setMessages: (\n messages:\n | ReadonlyArray<UIMessage>\n | ((prev: ReadonlyArray<UIMessage>) => ReadonlyArray<UIMessage>)\n ) => void;\n\n status: ChatStatus;\n error: Error | undefined;\n\n sendMessage: (message: SendMessageInput) => Promise<void>;\n regenerate: (options?: { messageId?: string }) => Promise<void>;\n stop: () => void;\n /** Calls `transport.reconnectToStream`. v0: LMS returns null, so this is a no-op. */\n resumeStream: () => Promise<void>;\n clearError: () => void;\n}\n\n/** Input shape accepted by `sendMessage`. */\nexport type SendMessageInput =\n | { text: string }\n | { role: \"user\"; parts: UIMessage[\"parts\"] };\n\n/**\n * React hook for streaming chat completions through `@osdk/aip-core`'s\n * `streamText`.\n *\n * @example\n * ```tsx\n * const { messages, status, sendMessage, stop, error } = useChat({\n * model: foundryModel({ client, model: \"gpt-4o\" }),\n * system: \"You are a concise assistant.\",\n * });\n * ```\n */\nexport function useChat(options: UseChatOptions): UseChatReturn {\n const { onFinish, onError } = options;\n\n const id = React.useMemo(\n () => options.id ?? generateMessageId(),\n [options.id]\n );\n\n // JSON-stringify keys keep the memo stable when callers pass inline objects.\n const headersKey = JSON.stringify(options.headers ?? null);\n const stopSequencesKey = JSON.stringify(options.stopSequences ?? null);\n const transport = React.useMemo<ChatTransport<UIMessage>>(\n () => {\n if (options.transport != null) {\n return options.transport;\n }\n if (options.model == null) {\n throw new Error(\n \"useChat: `model` is required when no `transport` is provided.\"\n );\n }\n const built: LmsChatTransportOptions = {\n model: options.model,\n system: options.system,\n temperature: options.temperature,\n maxOutputTokens: options.maxOutputTokens,\n topP: options.topP,\n presencePenalty: options.presencePenalty,\n frequencyPenalty: options.frequencyPenalty,\n stopSequences: options.stopSequences,\n seed: options.seed,\n headers: options.headers,\n };\n return new LmsChatTransport(built);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n options.transport,\n options.model,\n options.system,\n options.temperature,\n options.maxOutputTokens,\n options.topP,\n options.presencePenalty,\n options.frequencyPenalty,\n options.seed,\n headersKey,\n stopSequencesKey,\n ]\n );\n\n const store = React.useMemo<ChatStore>(\n () =>\n createChatStore({\n initialMessages: options.messages,\n throttleMs: options.experimentalThrottle ?? 50,\n }),\n // Recreating the store mid-session would drop chat state, so it's keyed\n // only by `id`. Use `setMessages` to mutate messages at runtime.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [id]\n );\n\n const state = React.useSyncExternalStore(\n store.subscribe,\n store.getSnapshot,\n store.getSnapshot\n );\n\n const abortRef = React.useRef<AbortController | undefined>(undefined);\n const stoppedRef = React.useRef<boolean>(false);\n\n const ctxRef = React.useRef<StreamContext>({\n store,\n abortRef,\n stoppedRef,\n onFinish,\n onError,\n });\n ctxRef.current = { store, abortRef, stoppedRef, onFinish, onError };\n\n const runStream = React.useCallback(\n (\n seed: ReadonlyArray<UIMessage>,\n trigger: \"submit-message\" | \"regenerate-message\"\n ): Promise<void> =>\n runChatStream(ctxRef.current, transport, id, seed, trigger),\n [transport, id]\n );\n\n const sendMessage = React.useCallback(\n async (input: SendMessageInput): Promise<void> => {\n const userMsg = normalizeUserMessage(input);\n const seeded = [...store.getSnapshot().messages, userMsg];\n store.setState({\n messages: seeded,\n status: \"submitted\",\n error: undefined,\n });\n await runStream(seeded, \"submit-message\");\n },\n [store, runStream]\n );\n\n const regenerate = React.useCallback(\n async (regenerateOpts?: { messageId?: string }): Promise<void> => {\n const messages = store.getSnapshot().messages;\n const cutoff = resolveRegenerateCutoff(\n messages,\n regenerateOpts?.messageId\n );\n if (cutoff.kind === \"noop\") {\n return;\n }\n if (cutoff.kind === \"error\") {\n store.setState((prev) => ({\n ...prev,\n status: \"error\",\n error: cutoff.error,\n }));\n return;\n }\n const truncated = messages.slice(0, cutoff.index);\n store.setState({\n messages: truncated,\n status: \"submitted\",\n error: undefined,\n });\n await runStream(truncated, \"regenerate-message\");\n },\n [store, runStream]\n );\n\n const stop = React.useCallback((): void => {\n stoppedRef.current = true;\n abortRef.current?.abort();\n abortRef.current = undefined;\n }, []);\n\n const resumeStream = React.useCallback(async (): Promise<void> => {\n const stream = await transport.reconnectToStream({ chatId: id });\n if (stream == null) {\n return;\n }\n abortRef.current?.abort();\n const ctrl = new AbortController();\n abortRef.current = ctrl;\n const assistantId = generateMessageId();\n await drainStream(ctxRef.current, stream, assistantId, ctrl);\n }, [transport, id]);\n\n const clearError = React.useCallback((): void => {\n // Resetting from streaming/submitted would race the in-flight stream, so\n // only reset when status === \"error\".\n store.setState((prev) =>\n prev.status === \"error\"\n ? { ...prev, status: \"ready\", error: undefined }\n : prev\n );\n }, [store]);\n\n const setMessages = React.useCallback(\n (\n next:\n | ReadonlyArray<UIMessage>\n | ((prev: ReadonlyArray<UIMessage>) => ReadonlyArray<UIMessage>)\n ): void => {\n store.setState((prev) => {\n if (prev.status === \"streaming\" || prev.status === \"submitted\") {\n return prev;\n }\n return {\n ...prev,\n messages: typeof next === \"function\" ? next(prev.messages) : next,\n };\n });\n },\n [store]\n );\n\n return React.useMemo(\n () => ({\n id,\n messages: state.messages,\n setMessages,\n status: state.status,\n error: state.error,\n sendMessage,\n regenerate,\n stop,\n resumeStream,\n clearError,\n }),\n [\n id,\n state.messages,\n state.status,\n state.error,\n setMessages,\n sendMessage,\n regenerate,\n stop,\n resumeStream,\n clearError,\n ]\n );\n}\n\ntype RegenerateCutoff =\n | { kind: \"noop\" }\n | { kind: \"error\"; error: Error }\n | { kind: \"ok\"; index: number };\n\nfunction resolveRegenerateCutoff(\n messages: ReadonlyArray<UIMessage>,\n messageId: string | undefined\n): RegenerateCutoff {\n if (messageId != null) {\n const index = messages.findIndex((m) => m.id === messageId);\n if (index === -1) {\n return { kind: \"noop\" };\n }\n const target = messages[index];\n if (target == null || target.role !== \"assistant\") {\n return {\n kind: \"error\",\n error: new Error(\n `useChat.regenerate: messageId \"${messageId}\" is ` +\n `not an assistant message; only assistant messages can be regenerated.`\n ),\n };\n }\n return { kind: \"ok\", index };\n }\n const lastAssistant = findLastAssistantIndex(messages);\n if (lastAssistant < 0) {\n return { kind: \"noop\" };\n }\n return { kind: \"ok\", index: lastAssistant };\n}\n\nfunction normalizeUserMessage(input: SendMessageInput): UIMessage {\n if (\"text\" in input) {\n return {\n id: generateMessageId(),\n role: \"user\",\n parts: [{ type: \"text\", text: input.text }],\n };\n }\n return {\n id: generateMessageId(),\n role: input.role,\n parts: input.parts,\n };\n}\n\nfunction findLastAssistantIndex(arr: ReadonlyArray<UIMessage>): number {\n for (let i = arr.length - 1; i >= 0; i--) {\n if (arr[i]?.role === \"assistant\") {\n return i;\n }\n }\n return -1;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAEEA,iBAAiB,EAEjBC,gBAAgB,QAGX,gBAAgB;AACvB,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAGEC,eAAe,QACV,gBAAgB;AACvB,SACEC,WAAW,EACXC,aAAa,QAER,iBAAiB;;AAIxB;AACA;AACA;AACA;AACA;AACA;;AA2CA;;AAsBA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAACC,OAAuB,EAAiB;EAC9D,MAAM;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,GAAGF,OAAO;EAErC,MA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EI;IAAM,CAAC;EAC9B;EACA,MAAMiB,aAAa,GAAGC,sBAAsB,CAACnD,QAAQ,CAAC;EACtD,IAAIkD,aAAa,GAAG,CAAC,EAAE;IACrB,OAAO;MAAErB,IAAI,EAAE;IAAO,CAAC;EACzB;EACA,OAAO;IAAEA,IAAI,EAAE,IAAI;IAAEI,KAAK,EAAEiB;EAAc,CAAC;AAC7C;AAEA,SAAS/B,oBAAoBA,CAACF,KAAuB,EAAa;EAChE,IAAI,MAAM,IAAIA,KAAK,EAAE;IACnB,OAAO;MACLtC,EAAE,EAAEV,iBAAiB,CAAC,CAAC;MACvBgF,IAAI,EAAE,MAAM;MACZG,KAAK,EAAE,CAAC;QAAEC,IAAI,EAAE,MAAM;QAAEC,IAAI,EAAErC,KAAK,CAACqC;MAAK,CAAC;IAC5C,CAAC;EACH;EACA,OAAO;IACL3E,EAAE,EAAEV,iBAAiB,CAAC,CAAC;IACvBgF,IAAI,EAAEhC,KAAK,CAACgC,IAAI;IAChBG,KAAK,EAAEnC,KAAK,CAACmC;EACf,CAAC;AACH;AAEA,SAASD,sBAAsBA,CAACI,GAA6B,EAAU;EACrE,KAAK,IAAIC,CAAC,GAAGD,GAAG,CAACE,MAAM,GAAG,CAAC,EAAED,CAAC,IAAI,CAAC,EAAEA,CAAC,EAAE,EAAE;IACxC,IAAID,GAAG,CAACC,CAAC,CAAC,EAAEP,IAAI,KAAK,WAAW,EAAE;MAChC,OAAOO,CAAC;IACV;EACF;EACA,OAAO,CAAC,CAAC;AACX","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"OsdkContext.js","names":["React","MISSING_PROVIDER_MESSAGE","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","fakeObservableClient","Proxy","get","_target","prop","Symbol","toPrimitive","toStringTag","undefined","OsdkContext","createContext","client","observableClient","devtoolsEnabled"],"sources":["OsdkContext.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/observable\";\nimport React from \"react\";\n\nexport const MISSING_PROVIDER_MESSAGE =\n \"No OsdkProvider found. Did you forget to wrap your component tree with <OsdkProvider>?\";\n\nfunction fakeClientFn(..._args: unknown[]): never {\n throw new Error(MISSING_PROVIDER_MESSAGE);\n}\n\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn,\n}) as unknown as Client;\n\n// Proxy that throws a clear error when any method is called, so hooks like\n// useOsdkObjects get \"Did you forget <OsdkProvider>?\" 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: unknown[]): never => {\n throw new Error(MISSING_PROVIDER_MESSAGE);\n };\n },\n});\n\ninterface OsdkContextContents {\n client: Client;\n observableClient: ObservableClient;\n devtoolsEnabled: boolean;\n}\n\nexport const OsdkContext: React.Context<OsdkContextContents> = React\n .createContext<OsdkContextContents>({\n client: fakeClient,\n observableClient: fakeObservableClient,\n devtoolsEnabled: false,\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,wFAAwF;AAE1F,SAASC,YAAYA,CAAC,GAAGC,KAAgB,EAAS;EAChD,MAAM,IAAIC,KAAK,CAACH,wBAAwB,CAAC;AAC3C;AAEA,MAAMI,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC7CM,aAAa,EAAEN;AACjB,CAAC,CAAsB;;AAEvB;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,KAAgB,KAAY;MACrC,MAAM,IAAIC,KAAK,CAACH,wBAAwB,CAAC;IAC3C,CAAC;EACH;AACF,CAAC,CAAC;AAQF,OAAO,MAAMiB,WAA+C,gBAAGlB,KAAK,CACjEmB,aAAa,CAAsB;EAClCC,MAAM,EAAEf,UAAU;EAClBgB,gBAAgB,EAAEZ,oBAAoB;EACtCa,eAAe,EAAE;AACnB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"OsdkContext.js","names":["React","MISSING_PROVIDER_MESSAGE","fakeClientFn","_args","Error","fakeClient","Object","assign","fetchMetadata","fakeObservableClient","Proxy","get","_target","prop","Symbol","toPrimitive","toStringTag","undefined","OsdkContext","createContext","client","observableClient","devtoolsEnabled"],"sources":["OsdkContext.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/observable\";\nimport React from \"react\";\n\nexport const MISSING_PROVIDER_MESSAGE =\n \"No OsdkProvider found. Did you forget to wrap your component tree with <OsdkProvider>?\";\n\nfunction fakeClientFn(..._args: unknown[]): never {\n throw new Error(MISSING_PROVIDER_MESSAGE);\n}\n\nconst fakeClient = Object.assign(fakeClientFn, {\n fetchMetadata: fakeClientFn,\n}) as unknown as Client;\n\n// Proxy that throws a clear error when any method is called, so hooks like\n// useOsdkObjects get \"Did you forget <OsdkProvider>?\" 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: unknown[]): never => {\n throw new Error(MISSING_PROVIDER_MESSAGE);\n };\n },\n});\n\ninterface OsdkContextContents {\n client: Client;\n observableClient: ObservableClient;\n devtoolsEnabled: boolean;\n}\n\nexport const OsdkContext: React.Context<OsdkContextContents> =\n React.createContext<OsdkContextContents>({\n client: fakeClient,\n observableClient: fakeObservableClient,\n devtoolsEnabled: false,\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,wFAAwF;AAE1F,SAASC,YAAYA,CAAC,GAAGC,KAAgB,EAAS;EAChD,MAAM,IAAIC,KAAK,CAACH,wBAAwB,CAAC;AAC3C;AAEA,MAAMI,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACL,YAAY,EAAE;EAC7CM,aAAa,EAAEN;AACjB,CAAC,CAAsB;;AAEvB;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,KAAgB,KAAY;MACrC,MAAM,IAAIC,KAAK,CAACH,wBAAwB,CAAC;IAC3C,CAAC;EACH;AACF,CAAC,CAAC;AAQF,OAAO,MAAMiB,WAA+C,gBAC1DlB,KAAK,CAACmB,aAAa,CAAsB;EACvCC,MAAM,EAAEf,UAAU;EAClBgB,gBAAgB,EAAEZ,oBAAoB;EACtCa,eAAe,EAAE;AACnB,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"OsdkProvider.js","names":["createObservableClient","React","useCallback","useMemo","useRef","getRegisteredDevTools","REACT_USER_AGENT","OsdkContext","useDevToolsClient","UserAgentContext","__DEV__","process","env","NODE_ENV","OsdkProvider","children","client","enableDevTools","devMode","devtoolsEnabled","userAgentsRef","Set","addUserAgent","agent","current","add","delete","actionDelayMs","logLevel","debugRefCounts","debug","refCounts","debugCacheKeys","cacheKeys","baseObservableClient","devToolsClient","wrapChildren","content","contextValue","observableClient","createElement","Provider","value"],"sources":["OsdkProvider.tsx"],"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 { ObservableClientOptions } from \"@osdk/client/observable\";\nimport { createObservableClient } from \"@osdk/client/observable\";\nimport React, { useCallback, useMemo, useRef } from \"react\";\nimport { getRegisteredDevTools } from \"../public/devtools-registry.js\";\nimport { REACT_USER_AGENT } from \"../util/UserAgent.js\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nimport { useDevToolsClient } from \"./useDevToolsClient.js\";\nimport { UserAgentContext } from \"./UserAgentContext.js\";\n\ndeclare const process: { env: { NODE_ENV: string } };\nconst __DEV__ = typeof process === \"undefined\"\n || process.env.NODE_ENV !== \"production\";\n\ninterface OsdkProviderOptions {\n children: React.ReactNode;\n client: Client;\n enableDevTools?: boolean;\n /**\n * Dev-only behaviors of the underlying observable client. Has no effect in\n * production builds. Use `devMode={{ actionDelayMs: 0 }}` to disable the\n * artificial action delay that makes optimistic updates visible in dev,\n * `devMode={{ logLevel: \"debug\" }}` to surface the observable client's debug\n * tracing, or `devMode={{ debug: { refCounts: true } }}` to log cache\n * internals.\n */\n devMode?: ObservableClientOptions[\"devMode\"];\n}\n\nexport function OsdkProvider({\n children,\n client,\n enableDevTools,\n devMode,\n}: OsdkProviderOptions): React.JSX.Element {\n const devtoolsEnabled = __DEV__\n && (enableDevTools ?? getRegisteredDevTools() != null);\n\n const userAgentsRef = useRef(new Set<string>([REACT_USER_AGENT]));\n\n const addUserAgent = useCallback((agent: string) => {\n userAgentsRef.current.add(agent);\n return () => {\n userAgentsRef.current.delete(agent);\n };\n }, []);\n\n const actionDelayMs = devMode?.actionDelayMs;\n const logLevel = devMode?.logLevel;\n const debugRefCounts = devMode?.debug?.refCounts;\n const debugCacheKeys = devMode?.debug?.cacheKeys;\n const baseObservableClient = useMemo(\n () =>\n createObservableClient(\n client,\n () => [...userAgentsRef.current],\n {\n devMode: {\n actionDelayMs,\n logLevel,\n debug: { refCounts: debugRefCounts, cacheKeys: debugCacheKeys },\n },\n },\n ),\n [client, actionDelayMs, logLevel, debugRefCounts, debugCacheKeys],\n );\n\n const { client: devToolsClient, wrapChildren } = useDevToolsClient(\n baseObservableClient,\n devtoolsEnabled,\n );\n\n const content = wrapChildren?.(children) ?? children;\n\n const contextValue = useMemo(\n () => ({ client, observableClient: devToolsClient, devtoolsEnabled }),\n [client, devToolsClient, devtoolsEnabled],\n );\n\n return (\n <UserAgentContext.Provider value={addUserAgent}>\n <OsdkContext.Provider\n value={contextValue}\n >\n {content}\n </OsdkContext.Provider>\n </UserAgentContext.Provider>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,sBAAsB,QAAQ,yBAAyB;AAChE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC3D,SAASC,qBAAqB,QAAQ,gCAAgC;AACtE,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,gBAAgB,QAAQ,uBAAuB;AAGxD,MAAMC,OAAO,GAAG,OAAOC,OAAO,KAAK,WAAW,IACzCA,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAiB1C,OAAO,SAASC,YAAYA,CAAC;EAC3BC,QAAQ;EACRC,MAAM;EACNC,cAAc;EACdC;AACmB,CAAC,EAAqB;EACzC,MAAMC,eAAe,GAAGT,OAAO,KACzBO,cAAc,IAAIZ,qBAAqB,CAAC,CAAC,IAAI,IAAI,CAAC;EAExD,MAAMe,aAAa,GAAGhB,MAAM,CAAC,IAAIiB,GAAG,CAAS,CAACf,gBAAgB,CAAC,CAAC,CAAC;EAEjE,MAAMgB,YAAY,GAAGpB,WAAW,CAAEqB,KA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ACkC,QAAQ;IACnBC,KAAK,EAAEJ;EAAa,GAEnBD,OACmB,CACG,CAAC;AAEhC","ignoreList":[]}
1
+ {"version":3,"file":"OsdkProvider.js","names":["createObservableClient","React","useCallback","useMemo","useRef","getRegisteredDevTools","REACT_USER_AGENT","OsdkContext","useDevToolsClient","UserAgentContext","__DEV__","process","env","NODE_ENV","OsdkProvider","children","client","enableDevTools","devMode","devtoolsEnabled","userAgentsRef","Set","addUserAgent","agent","current","add","delete","actionDelayMs","logLevel","debugRefCounts","debug","refCounts","debugCacheKeys","cacheKeys","baseObservableClient","devToolsClient","wrapChildren","content","contextValue","observableClient","createElement","Provider","value"],"sources":["OsdkProvider.tsx"],"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 { ObservableClientOptions } from \"@osdk/client/observable\";\nimport { createObservableClient } from \"@osdk/client/observable\";\nimport React, { useCallback, useMemo, useRef } from \"react\";\n\nimport { getRegisteredDevTools } from \"../public/devtools-registry.js\";\nimport { REACT_USER_AGENT } from \"../util/UserAgent.js\";\nimport { OsdkContext } from \"./OsdkContext.js\";\nimport { useDevToolsClient } from \"./useDevToolsClient.js\";\nimport { UserAgentContext } from \"./UserAgentContext.js\";\n\ndeclare const process: { env: { NODE_ENV: string } };\nconst __DEV__ =\n typeof process === \"undefined\" || process.env.NODE_ENV !== \"production\";\n\ninterface OsdkProviderOptions {\n children: React.ReactNode;\n client: Client;\n enableDevTools?: boolean;\n /**\n * Dev-only behaviors of the underlying observable client. Has no effect in\n * production builds. Use `devMode={{ actionDelayMs: 0 }}` to disable the\n * artificial action delay that makes optimistic updates visible in dev,\n * `devMode={{ logLevel: \"debug\" }}` to surface the observable client's debug\n * tracing, or `devMode={{ debug: { refCounts: true } }}` to log cache\n * internals.\n */\n devMode?: ObservableClientOptions[\"devMode\"];\n}\n\nexport function OsdkProvider({\n children,\n client,\n enableDevTools,\n devMode,\n}: OsdkProviderOptions): React.JSX.Element {\n const devtoolsEnabled =\n __DEV__ && (enableDevTools ?? getRegisteredDevTools() != null);\n\n const userAgentsRef = useRef(new Set<string>([REACT_USER_AGENT]));\n\n const addUserAgent = useCallback((agent: string) => {\n userAgentsRef.current.add(agent);\n return () => {\n userAgentsRef.current.delete(agent);\n };\n }, []);\n\n const actionDelayMs = devMode?.actionDelayMs;\n const logLevel = devMode?.logLevel;\n const debugRefCounts = devMode?.debug?.refCounts;\n const debugCacheKeys = devMode?.debug?.cacheKeys;\n const baseObservableClient = useMemo(\n () =>\n createObservableClient(client, () => [...userAgentsRef.current], {\n devMode: {\n actionDelayMs,\n logLevel,\n debug: { refCounts: debugRefCounts, cacheKeys: debugCacheKeys },\n },\n }),\n [client, actionDelayMs, logLevel, debugRefCounts, debugCacheKeys]\n );\n\n const { client: devToolsClient, wrapChildren } = useDevToolsClient(\n baseObservableClient,\n devtoolsEnabled\n );\n\n const content = wrapChildren?.(children) ?? children;\n\n const contextValue = useMemo(\n () => ({ client, observableClient: devToolsClient, devtoolsEnabled }),\n [client, devToolsClient, devtoolsEnabled]\n );\n\n return (\n <UserAgentContext.Provider value={addUserAgent}>\n <OsdkContext.Provider value={contextValue}>\n {content}\n </OsdkContext.Provider>\n </UserAgentContext.Provider>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAASA,sBAAsB,QAAQ,yBAAyB;AAChE,OAAOC,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OA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AAS,EAAED;MAAe;IAChE;EACF,CAAC,CAAC,EACJ,CAAChB,MAAM,EAAEW,aAAa,EAAEC,QAAQ,EAAEC,cAAc,EAAEG,cAAc,CAClE,CAAC;EAED,MAAM;IAAEhB,MAAM,EAAEmB,cAAc;IAAEC;EAAa,CAAC,GAAG5B,iBAAiB,CAChE0B,oBAAoB,EACpBf,eACF,CAAC;EAED,MAAMkB,OAAO,GAAGD,YAAY,GAAGrB,QAAQ,CAAC,IAAIA,QAAQ;EAEpD,MAAMuB,YAAY,GAAGnC,OAAO,CAC1B,OAAO;IAAEa,MAAM;IAAEuB,gBAAgB,EAAEJ,cAAc;IAAEhB;EAAgB,CAAC,CAAC,EACrE,CAACH,MAAM,EAAEmB,cAAc,EAAEhB,eAAe,CAC1C,CAAC;EAED,oBACElB,KAAA,CAAAuC,aAAA,CAAC/B,gBAAgB,CAACgC,QAAQ;IAACC,KAAK,EAAEpB;EAAa,gBAC7CrB,KAAA,CAAAuC,aAAA,CAACjC,WAAW,CAACkC,QAAQ;IAACC,KAAK,EAAEJ;EAAa,GACvCD,OACmB,CACG,CAAC;AAEhC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"UserAgentContext.js","names":["React","UserAgentContext","createContext"],"sources":["UserAgentContext.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 React from \"react\";\n\nexport type AddUserAgent = (agent: string) => () => void;\n\nexport const UserAgentContext: React.Context<AddUserAgent> = React\n .createContext<AddUserAgent>(\n () => () => {},\n );\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AAIzB,OAAO,MAAMC,gBAA6C,gBAAGD,KAAK,CAC/DE,aAAa,CACZ,MAAM,MAAM,CAAC,CACf,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"UserAgentContext.js","names":["React","UserAgentContext","createContext"],"sources":["UserAgentContext.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 React from \"react\";\n\nexport type AddUserAgent = (agent: string) => () => void;\n\nexport const UserAgentContext: React.Context<AddUserAgent> =\n React.createContext<AddUserAgent>(() => () => {});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AAIzB,OAAO,MAAMC,gBAA6C,gBACxDD,KAAK,CAACE,aAAa,CAAe,MAAM,MAAM,CAAC,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"stableSerialize.js","names":["getWireObjectSet","isObjectSet","stableSerialize","value","JSON","stringify","stableSerializeReplacer","_key","__objectSet"],"sources":["stableSerialize.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 { getWireObjectSet, isObjectSet } from \"@osdk/client\";\n\n/**\n * Serialize a value to a stable string for React.useMemo dependency arrays.\n * Uses {@link stableSerializeReplacer} so OSDK `ObjectSet`s normalize to a\n * discriminative wire form before stringification.\n */\nexport function stableSerialize(value: unknown): string | undefined {\n return JSON.stringify(value, stableSerializeReplacer);\n}\n\n/**\n * `JSON.stringify` replacer that normalizes OSDK `ObjectSet` instances to\n * their wire-form definition (via `getWireObjectSet`) wrapped in\n * `{ __objectSet: ... }`, so composed operations (`.where`, `.union`,\n * `.intersect`, ...) participate in the key.\n */\nexport function stableSerializeReplacer(\n _key: string,\n value: unknown,\n): unknown {\n if (value != null && typeof value === \"object\" && isObjectSet(value)) {\n return { __objectSet: getWireObjectSet(value) };\n }\n return value;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,gBAAgB,EAAEC,WAAW,QAAQ,cAAc;;AAE5D;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,KAAc,EAAsB;EAClE,OAAOC,IAAI,CAACC,SAAS,CAACF,KAAK,EAAEG,uBAAuB,CAAC;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,uBAAuBA,CACrCC,IAAY,EACZJ,KAAc,EACL;EACT,IAAIA,KAAK,IAAI,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIF,WAAW,CAACE,KAAK,CAAC,EAAE;IACpE,OAAO;MAAEK,WAAW,EAAER,gBAAgB,CAACG,KAAK;IAAE,CAAC;EACjD;EACA,OAAOA,KAAK;AACd","ignoreList":[]}
1
+ {"version":3,"file":"stableSerialize.js","names":["getWireObjectSet","isObjectSet","stableSerialize","value","JSON","stringify","stableSerializeReplacer","_key","__objectSet"],"sources":["stableSerialize.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 { getWireObjectSet, isObjectSet } from \"@osdk/client\";\n\n/**\n * Serialize a value to a stable string for React.useMemo dependency arrays.\n * Uses {@link stableSerializeReplacer} so OSDK `ObjectSet`s normalize to a\n * discriminative wire form before stringification.\n */\nexport function stableSerialize(value: unknown): string | undefined {\n return JSON.stringify(value, stableSerializeReplacer);\n}\n\n/**\n * `JSON.stringify` replacer that normalizes OSDK `ObjectSet` instances to\n * their wire-form definition (via `getWireObjectSet`) wrapped in\n * `{ __objectSet: ... }`, so composed operations (`.where`, `.union`,\n * `.intersect`, ...) participate in the key.\n */\nexport function stableSerializeReplacer(_key: string, value: unknown): unknown {\n if (value != null && typeof value === \"object\" && isObjectSet(value)) {\n return { __objectSet: getWireObjectSet(value) };\n }\n return value;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,gBAAgB,EAAEC,WAAW,QAAQ,cAAc;;AAE5D;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,KAAc,EAAsB;EAClE,OAAOC,IAAI,CAACC,SAAS,CAACF,KAAK,EAAEG,uBAAuB,CAAC;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,uBAAuBA,CAACC,IAAY,EAAEJ,KAAc,EAAW;EAC7E,IAAIA,KAAK,IAAI,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIF,WAAW,CAACE,KAAK,CAAC,EAAE;IACpE,OAAO;MAAEK,WAAW,EAAER,gBAAgB,CAACG,KAAK;IAAE,CAAC;EACjD;EACA,OAAOA,KAAK;AACd","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useStableObjectSet.js","names":["useMemo","stableSerialize","useStableObjectSet","objectSet"],"sources":["useStableObjectSet.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 {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { useMemo } from \"react\";\nimport { stableSerialize } from \"./stableSerialize.js\";\n\n/**\n * Returns a referentially stable ObjectSet that only changes when the\n * wire representation changes. This uses {@link stableSerialize} which\n * includes composed operations (where, union, intersect, etc.) in the\n * serialized form\n */\nexport function useStableObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(\n objectSet: ObjectSet<Q, RDPs> | undefined,\n): ObjectSet<Q, RDPs> | undefined {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => objectSet, [stableSerialize(objectSet)]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,eAAe,QAAQ,sBAAsB;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAIhCC,SAAyC,EACT;EAChC;EACA,OAAOH,OAAO,CAAC,MAAMG,SAAS,EAAE,CAACF,eAAe,CAACE,SAAS,CAAC,CAAC,CAAC;AAC/D","ignoreList":[]}
1
+ {"version":3,"file":"useStableObjectSet.js","names":["useMemo","stableSerialize","useStableObjectSet","objectSet"],"sources":["useStableObjectSet.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 {\n ObjectOrInterfaceDefinition,\n ObjectSet,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { useMemo } from \"react\";\n\nimport { stableSerialize } from \"./stableSerialize.js\";\n\n/**\n * Returns a referentially stable ObjectSet that only changes when the\n * wire representation changes. This uses {@link stableSerialize} which\n * includes composed operations (where, union, intersect, etc.) in the\n * serialized form\n */\nexport function useStableObjectSet<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n>(objectSet: ObjectSet<Q, RDPs> | undefined): ObjectSet<Q, RDPs> | undefined {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return useMemo(() => objectSet, [stableSerialize(objectSet)]);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,OAAO,QAAQ,OAAO;AAE/B,SAASC,eAAe,QAAQ,sBAAsB;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAGhCC,SAAyC,EAAkC;EAC3E;EACA,OAAOH,OAAO,CAAC,MAAMG,SAAS,EAAE,CAACF,eAAe,CAACE,SAAS,CAAC,CAAC,CAAC;AAC/D","ignoreList":[]}
@@ -52,7 +52,7 @@ export function createCompositeExternalStore(queries, observableClient, maxConcu
52
52
  },
53
53
  error: error => {
54
54
  updateSlot(index, {
55
- ...(current[index] ?? {}),
55
+ ...current[index],
56
56
  error: error instanceof Error ? error : new Error(String(error))
57
57
  });
58
58
  notifyUpdate();
@@ -1 +1 @@
1
- {"version":3,"file":"createCompositeExternalStore.js","names":["createCompositeExternalStore","queries","observableClient","maxConcurrent","current","map","undefined","updateSlot","index","value","next","observeQuery","query","notifyUpdate","onSettled","params","dedupeIntervalMs","dependsOn","dependsOnObjects","options","observeFunction","queryDefinition","dedupeInterval","payload","status","error","Error","String","complete","getEnabledIndices","q","i","enabled","filter","getSnapshot","subscribe","subscriptions","enabledIndices","subscribeAt","queueIdx","length","push","initialCount","Math","min","forEach","sub","unsubscribe","EMPTY_SNAPSHOTS","EMPTY_STORE"],"sources":["createCompositeExternalStore.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 { QueryDefinition } from \"@osdk/api\";\nimport type {\n ObservableClient,\n ObserveFunctionCallbackArgs,\n} from \"@osdk/client/observable\";\nimport type { Snapshot } from \"./makeExternalStore.js\";\nimport type { FunctionQueryParams } from \"./useOsdkFunctions.js\";\n\ntype FunctionPayload = ObserveFunctionCallbackArgs<QueryDefinition<unknown>>;\n\n/**\n * Creates a composite external store that manages N function subscriptions\n * through a single `useSyncExternalStore` interface.\n *\n * Unlike `makeExternalStore` (which wraps a single Observer), this manages\n * N observers funneled into one snapshot array. Supports optional concurrency\n * limiting via `maxConcurrent` to stagger subscriptions.\n */\nexport function createCompositeExternalStore(\n queries: Array<FunctionQueryParams<QueryDefinition<unknown>>>,\n observableClient: ObservableClient,\n maxConcurrent: number | undefined,\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapshot: () => Array<Snapshot<FunctionPayload>>;\n} {\n // Mutable snapshot array — replaced (never mutated in place) on each\n // observer callback so that useSyncExternalStore sees a new reference.\n let current: Array<Snapshot<FunctionPayload>> = queries.map(\n () => undefined,\n );\n\n const updateSlot = (\n index: number,\n value: Snapshot<FunctionPayload>,\n ) => {\n const next = [...current];\n next[index] = value;\n current = next;\n };\n\n function observeQuery(\n query: FunctionQueryParams<QueryDefinition<unknown>>,\n index: number,\n notifyUpdate: () => void,\n onSettled: () => void,\n ): { unsubscribe: () => void } {\n const { params, dedupeIntervalMs, dependsOn, dependsOnObjects } =\n query.options ?? {};\n\n return observableClient.observeFunction(\n query.queryDefinition,\n params,\n {\n dependsOn,\n dependsOnObjects,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n },\n {\n next: (payload: FunctionPayload | undefined) => {\n updateSlot(index, payload as Snapshot<FunctionPayload>);\n notifyUpdate();\n\n if (\n payload?.status === \"loaded\" || payload?.status === \"error\"\n ) {\n onSettled();\n }\n },\n error: (error: unknown) => {\n updateSlot(index, {\n ...(current[index] ?? {}),\n error: error instanceof Error\n ? error\n : new Error(String(error)),\n } as Snapshot<FunctionPayload>);\n notifyUpdate();\n onSettled();\n },\n complete: () => {},\n },\n );\n }\n\n function getEnabledIndices(): number[] {\n return queries\n .map((q, i) => q.options?.enabled !== false ? i : -1)\n .filter(i => i !== -1);\n }\n\n function subscribe(notifyUpdate: () => void): () => void {\n const subscriptions: Array<{ unsubscribe: () => void }> = [];\n const enabledIndices = getEnabledIndices();\n\n const subscribeAt = (queueIdx: number) => {\n if (queueIdx >= enabledIndices.length) return;\n\n const index = enabledIndices[queueIdx];\n const onSettled = maxConcurrent != null\n ? () => subscribeAt(queueIdx + maxConcurrent)\n : () => {};\n\n subscriptions.push(\n observeQuery(queries[index], index, notifyUpdate, onSettled),\n );\n };\n\n // When staggering, only start the first `maxConcurrent` queries.\n // Each calls subscribeAt(queueIdx + maxConcurrent) when it settles,\n // creating a sliding window of concurrent subscriptions.\n const initialCount = maxConcurrent != null\n ? Math.min(maxConcurrent, enabledIndices.length)\n : enabledIndices.length;\n\n for (let i = 0; i < initialCount; i++) {\n subscribeAt(i);\n }\n\n return () => subscriptions.forEach(sub => sub.unsubscribe());\n }\n\n return {\n getSnapshot: () => current,\n subscribe,\n };\n}\n\nconst EMPTY_SNAPSHOTS: Array<Snapshot<FunctionPayload>> = [];\n\nexport const EMPTY_STORE = {\n subscribe: (): () => void => () => {},\n getSnapshot: (): Snapshot<FunctionPayload>[] => EMPTY_SNAPSHOTS,\n} as const;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,4BAA4BA,CAC1CC,OAA6D,EAC7DC,gBAAkC,EAClCC,aAAiC,EAIjC;EACA;EACA;EACA,IAAIC,OAAyC,GAAGH,OAAO,CAACI,GAAG,CACzD,MAAMC,SACR,CAAC;EAED,MAAMC,UAAU,GAAGA,CACjBC,KAAa,EACbC,KAAgC,KAC7B;IACH,MAAMC,IAAI,GAAG,CAAC,GAAGN,OAAO,CAAC;IACzBM,IAAI,CAACF,KAAK,CAAC,GAAGC,KAAK;IACnBL,OAAO,GAAGM,IAAI;EAChB,CAAC;EAED,SAASC,YAAYA,CACnBC,KAAoD,EACpDJ,KAAa,EACbK,YAAwB,EACxBC,SAAqB,EACQ;IAC7B,MAAM;MAAEC,MAAM;MAAEC,gBAAgB;MAAEC,SAAS;MAAEC;IAAiB,CAAC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,iBAAiB,CAAC,CAAC;MAE1C,MAAMS,WAAW,GAAIC,QAAgB,IAAK;QACxC,IAAIA,QAAQ,IAAIF,cAAc,CAACG,MAAM,EAAE;QAEvC,MAAMhC,KAAK,GAAG6B,cAAc,CAACE,QAAQ,CAAC;QACtC,MAAMzB,SAAS,GAAGX,aAAa,IAAI,IAAI,GACnC,MAAMmC,WAAW,CAACC,QAAQ,GAAGpC,aAAa,CAAC,GAC3C,MAAM,CAAC,CAAC;QAEZiC,aAAa,CAACK,IAAI,CAChB9B,YAAY,CAACV,OAAO,CAACO,KAAK,CAAC,EAAEA,KAAK,EAAEK,YAAY,EAAEC,SAAS,CAC7D,CAAC;MACH,CAAC;;MAED;MACA;MACA;MACA,MAAM4B,YAAY,GAAGvC,aAAa,IAAI,IAAI,GACtCwC,IAAI,CAACC,GAAG,CAACzC,aAAa,EAAEkC,cAAc,CAACG,MAAM,CAAC,GAC9CH,cAAc,CAACG,MAAM;MAEzB,KAAK,IAAIT,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGW,YAAY,EAAEX,CAAC,EAAE,EAAE;QACrCO,WAAW,CAACP,CAAC,CAAC;MAChB;MAEA,OAAO,MAAMK,aAAa,CAACS,OAAO,CAACC,GAAG,IAAIA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;IAC9D;EAKA,CAAC;AACH;AAEA,MAAMC,eAAiD,GAAG,EAAE;AAE5D,OAAO,MAAMC,WAAW,GAAG;EACzBd,SAAS,EAAEA,CAAA,KAAkB,MAAM,CAAC,CAAC;EACrCD,WAAW,EAAEA,CAAA,KAAmCc;AAClD,CAAU","ignoreList":[]}
1
+ {"version":3,"file":"createCompositeExternalStore.js","names":["createCompositeExternalStore","queries","observableClient","maxConcurrent","current","map","undefined","updateSlot","index","value","next","observeQuery","query","notifyUpdate","onSettled","params","dedupeIntervalMs","dependsOn","dependsOnObjects","options","observeFunction","queryDefinition","dedupeInterval","payload","status","error","Error","String","complete","getEnabledIndices","q","i","enabled","filter","getSnapshot","subscribe","subscriptions","enabledIndices","subscribeAt","queueIdx","length","push","initialCount","Math","min","forEach","sub","unsubscribe","EMPTY_SNAPSHOTS","EMPTY_STORE"],"sources":["createCompositeExternalStore.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 { QueryDefinition } from \"@osdk/api\";\nimport type {\n ObservableClient,\n ObserveFunctionCallbackArgs,\n} from \"@osdk/client/observable\";\n\nimport type { Snapshot } from \"./makeExternalStore.js\";\nimport type { FunctionQueryParams } from \"./useOsdkFunctions.js\";\n\ntype FunctionPayload = ObserveFunctionCallbackArgs<QueryDefinition<unknown>>;\n\n/**\n * Creates a composite external store that manages N function subscriptions\n * through a single `useSyncExternalStore` interface.\n *\n * Unlike `makeExternalStore` (which wraps a single Observer), this manages\n * N observers funneled into one snapshot array. Supports optional concurrency\n * limiting via `maxConcurrent` to stagger subscriptions.\n */\nexport function createCompositeExternalStore(\n queries: Array<FunctionQueryParams<QueryDefinition<unknown>>>,\n observableClient: ObservableClient,\n maxConcurrent: number | undefined\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapshot: () => Array<Snapshot<FunctionPayload>>;\n} {\n // Mutable snapshot array — replaced (never mutated in place) on each\n // observer callback so that useSyncExternalStore sees a new reference.\n let current: Array<Snapshot<FunctionPayload>> = queries.map(() => undefined);\n\n const updateSlot = (index: number, value: Snapshot<FunctionPayload>) => {\n const next = [...current];\n next[index] = value;\n current = next;\n };\n\n function observeQuery(\n query: FunctionQueryParams<QueryDefinition<unknown>>,\n index: number,\n notifyUpdate: () => void,\n onSettled: () => void\n ): { unsubscribe: () => void } {\n const { params, dedupeIntervalMs, dependsOn, dependsOnObjects } =\n query.options ?? {};\n\n return observableClient.observeFunction(\n query.queryDefinition,\n params,\n {\n dependsOn,\n dependsOnObjects,\n dedupeInterval: dedupeIntervalMs ?? 2_000,\n },\n {\n next: (payload: FunctionPayload | undefined) => {\n updateSlot(index, payload as Snapshot<FunctionPayload>);\n notifyUpdate();\n\n if (payload?.status === \"loaded\" || payload?.status === \"error\") {\n onSettled();\n }\n },\n error: (error: unknown) => {\n updateSlot(index, {\n ...current[index],\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<FunctionPayload>);\n notifyUpdate();\n onSettled();\n },\n complete: () => {},\n }\n );\n }\n\n function getEnabledIndices(): number[] {\n return queries\n .map((q, i) => (q.options?.enabled !== false ? i : -1))\n .filter((i) => i !== -1);\n }\n\n function subscribe(notifyUpdate: () => void): () => void {\n const subscriptions: Array<{ unsubscribe: () => void }> = [];\n const enabledIndices = getEnabledIndices();\n\n const subscribeAt = (queueIdx: number) => {\n if (queueIdx >= enabledIndices.length) return;\n\n const index = enabledIndices[queueIdx];\n const onSettled =\n maxConcurrent != null\n ? () => subscribeAt(queueIdx + maxConcurrent)\n : () => {};\n\n subscriptions.push(\n observeQuery(queries[index], index, notifyUpdate, onSettled)\n );\n };\n\n // When staggering, only start the first `maxConcurrent` queries.\n // Each calls subscribeAt(queueIdx + maxConcurrent) when it settles,\n // creating a sliding window of concurrent subscriptions.\n const initialCount =\n maxConcurrent != null\n ? Math.min(maxConcurrent, enabledIndices.length)\n : enabledIndices.length;\n\n for (let i = 0; i < initialCount; i++) {\n subscribeAt(i);\n }\n\n return () => subscriptions.forEach((sub) => sub.unsubscribe());\n }\n\n return {\n getSnapshot: () => current,\n subscribe,\n };\n}\n\nconst EMPTY_SNAPSHOTS: Array<Snapshot<FunctionPayload>> = [];\n\nexport const EMPTY_STORE = {\n subscribe: (): (() => void) => () => {},\n getSnapshot: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H,cAAc,CAACG,MAAM;MAE3B,KAAK,IAAIT,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGW,YAAY,EAAEX,CAAC,EAAE,EAAE;QACrCO,WAAW,CAACP,CAAC,CAAC;MAChB;MAEA,OAAO,MAAMK,aAAa,CAACS,OAAO,CAAEC,GAAG,IAAKA,GAAG,CAACC,WAAW,CAAC,CAAC,CAAC;IAChE;EAKA,CAAC;AACH;AAEA,MAAMC,eAAiD,GAAG,EAAE;AAE5D,OAAO,MAAMC,WAAW,GAAG;EACzBd,SAAS,EAAEA,CAAA,KAAoB,MAAM,CAAC,CAAC;EACvCD,WAAW,EAAEA,CAAA,KAAmCc;AAClD,CAAU","ignoreList":[]}
@@ -1 +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":[]}
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 (\n payload?.status === \"loading\" || payload?.status === \"init\" || !payload\n );\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,OACEP,OAAO,EAAEG,MAAM,KAAK,SAAS,IAAIH,OAAO,EAAEG,MAAM,KAAK,MAAM,IAAI,CAACH,OAAO;AAE3E","ignoreList":[]}
@@ -46,7 +46,7 @@ export function makeExternalStore(createObservation, _metadata, initialValue) {
46
46
  },
47
47
  error: error => {
48
48
  lastResult = {
49
- ...(lastResult ?? {}),
49
+ ...lastResult,
50
50
  error: error instanceof Error ? error : new Error(String(error))
51
51
  };
52
52
  notifyUpdate();
@@ -93,7 +93,7 @@ export function makeExternalStoreAsync(createObservation, _metadata, initialValu
93
93
  error: error => {
94
94
  if (isActive) {
95
95
  lastResult = {
96
- ...(lastResult ?? {}),
96
+ ...lastResult,
97
97
  error: error instanceof Error ? error : new Error(String(error))
98
98
  };
99
99
  notifyUpdate();
@@ -110,7 +110,7 @@ export function makeExternalStoreAsync(createObservation, _metadata, initialValu
110
110
  }).catch(error => {
111
111
  if (isActive) {
112
112
  lastResult = {
113
- ...(lastResult ?? {}),
113
+ ...lastResult,
114
114
  error: error instanceof Error ? error : new Error(String(error))
115
115
  };
116
116
  notifyUpdate();
@@ -1 +1 @@
1
- {"version":3,"file":"makeExternalStore.js","names":["React","__DEV__","process","env","NODE_ENV","OSDK_HOOK_METADATA","Symbol","for","devToolsMetadata","meta","undefined","useDevToolsMetadata","devtoolsEnabled","hookType","key","ref","useRef","current","makeExternalStore","createObservation","_metadata","initialValue","lastResult","getSnapShot","store","subscribe","notifyUpdate","obs","next","payload","error","Error","String","complete","unsubscribe","Object","defineProperty","value","enumerable","makeExternalStoreAsync","isActive","currentSubscription","subscriptionPromise","then","sub","catch"],"sources":["makeExternalStore.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 { Observer, Unsubscribable } from \"@osdk/client/observable\";\nimport React from \"react\";\n\ndeclare const process: { env: { NODE_ENV: string } };\nconst __DEV__ = typeof process === \"undefined\"\n || process.env.NODE_ENV !== \"production\";\n\nexport const OSDK_HOOK_METADATA: symbol = Symbol.for(\n \"__OSDK_HOOK_METADATA__\",\n);\n\nexport interface OsdkStoreMetadata {\n hookType: string;\n objectType?: string;\n primaryKey?: string;\n actionName?: string;\n sourceObjectType?: string;\n linkName?: string;\n where?: unknown;\n orderBy?: unknown;\n pageSize?: number;\n aggregate?: unknown;\n}\n\nexport const devToolsMetadata: (\n meta: OsdkStoreMetadata,\n) => OsdkStoreMetadata | undefined = __DEV__\n ? (meta) => meta\n : (_meta) => undefined;\n\nexport function useDevToolsMetadata(\n devtoolsEnabled: boolean,\n hookType: string,\n key: string,\n): void {\n const ref = React.useRef<\n { [k: symbol]: true; hookType: string; key: string } | null\n >(null);\n if (devtoolsEnabled) {\n if (ref.current == null || ref.current.key !== key) {\n ref.current = { [OSDK_HOOK_METADATA]: true, hookType, key };\n }\n } else if (ref.current != null) {\n ref.current = null;\n }\n}\n\nexport type Snapshot<X> =\n | X & { error?: Error }\n | (Partial<X> & { error?: Error })\n | undefined;\n\nexport function makeExternalStore<X>(\n createObservation: (callback: Observer<X | undefined>) => Unsubscribable,\n _metadata?: OsdkStoreMetadata,\n initialValue?: Snapshot<X>,\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => Snapshot<X>;\n} {\n let lastResult: Snapshot<X> = initialValue;\n\n function getSnapShot(): Snapshot<X> {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n const obs = createObservation({\n next: (payload) => {\n lastResult = payload as Snapshot<X>;\n notifyUpdate();\n },\n error: (error: unknown) => {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n },\n complete: () => {},\n });\n\n return (): void => {\n obs.unsubscribe();\n };\n }\n\n const store = { subscribe, getSnapShot };\n if (__DEV__ && _metadata != null) {\n Object.defineProperty(store, OSDK_HOOK_METADATA, {\n value: _metadata,\n enumerable: false,\n });\n }\n return store;\n}\n\n/**\n * Like makeExternalStore but for async subscription creation.\n *\n * Uses an isActive flag to handle race conditions:\n * If cleanup runs before promise resolves, the stale subscription is\n * immediately unsubscribed when it eventually resolves\n */\nexport function makeExternalStoreAsync<X>(\n createObservation: (\n callback: Observer<X | undefined>,\n ) => Promise<Unsubscribable>,\n _metadata?: OsdkStoreMetadata,\n initialValue?: Snapshot<X>,\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => Snapshot<X>;\n} {\n let lastResult: Snapshot<X> = initialValue;\n\n function getSnapShot(): Snapshot<X> {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n let isActive = true;\n let currentSubscription: Unsubscribable | undefined;\n\n const subscriptionPromise = createObservation({\n next: (payload) => {\n if (isActive) {\n lastResult = payload as Snapshot<X>;\n notifyUpdate();\n }\n },\n error: (error: unknown) => {\n if (isActive) {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n }\n },\n complete: () => {},\n });\n\n subscriptionPromise.then((sub) => {\n if (isActive) {\n currentSubscription = sub;\n } else {\n sub.unsubscribe();\n }\n }).catch((error: unknown) => {\n if (isActive) {\n lastResult = {\n ...(lastResult ?? {}),\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n }\n });\n\n return (): void => {\n isActive = false;\n if (currentSubscription) {\n currentSubscription.unsubscribe();\n }\n };\n }\n\n const store = { subscribe, getSnapShot };\n if (__DEV__ && _metadata != null) {\n Object.defineProperty(store, OSDK_HOOK_METADATA, {\n value: _metadata,\n enumerable: false,\n });\n }\n return store;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,MAAM,OAAO;AAGzB,MAAMC,OAAO,GAAG,OAAOC,OAAO,KAAK,WAAW,IACzCA,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAE1C,OAAO,MAAMC,kBAA0B,GAAGC,MAAM,CAACC,GAAG,CAClD,wBACF,CAAC;AAeD,OAAO,MAAMC,gBAEqB,GAAGP,OAAO,GACvCQ,IAAI,IAAKA,IAAI,GACd,MAAWC,SAAS;AAExB,OAAO,SAASC,mBAAmBA,CACjCC,eAAwB,EACxBC,QAAgB,EAChBC,GAAW,EACL;EACN,MAAMC,GAAG,GAAGf,KAAK,CAACgB,MAAM,CAEtB,IAAI,CAAC;EACP,IAAIJ,eAAe,EAAE;IACnB,IAAIG,GAAG,CAACE,OAAO,IAAI,IAAI,IAAIF,GAAG,CAACE,OAAO,CAACH,GAAG,KAAKA,GAAG,EAAE;MAClDC,GAAG,CAACE,OAAO,GAAG;QAAE,CAACZ,kBA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AAY;MACjBc,QAAQ,GAAG,KAAK;MAChB,IAAIC,mBAAmB,EAAE;QACvBA,mBAAmB,CAACP,WAAW,CAAC,CAAC;MACnC;IACF,CAAC;EACH;EAEA,MAAMV,KAAK,GAAG;IAAEC,SAAS;IAAEF;EAAY,CAAC;EACxC,IAAItB,OAAO,IAAImB,SAAS,IAAI,IAAI,EAAE;IAChCe,MAAM,CAACC,cAAc,CAACZ,KAAK,EAAEnB,kBAAkB,EAAE;MAC/CgC,KAAK,EAAEjB,SAAS;MAChBkB,UAAU,EAAE;IACd,CAAC,CAAC;EACJ;EACA,OAAOd,KAAK;AACd","ignoreList":[]}
1
+ {"version":3,"file":"makeExternalStore.js","names":["React","__DEV__","process","env","NODE_ENV","OSDK_HOOK_METADATA","Symbol","for","devToolsMetadata","meta","undefined","useDevToolsMetadata","devtoolsEnabled","hookType","key","ref","useRef","current","makeExternalStore","createObservation","_metadata","initialValue","lastResult","getSnapShot","store","subscribe","notifyUpdate","obs","next","payload","error","Error","String","complete","unsubscribe","Object","defineProperty","value","enumerable","makeExternalStoreAsync","isActive","currentSubscription","subscriptionPromise","then","sub","catch"],"sources":["makeExternalStore.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 { Observer, Unsubscribable } from \"@osdk/client/observable\";\nimport React from \"react\";\n\ndeclare const process: { env: { NODE_ENV: string } };\nconst __DEV__ =\n typeof process === \"undefined\" || process.env.NODE_ENV !== \"production\";\n\nexport const OSDK_HOOK_METADATA: symbol = Symbol.for(\"__OSDK_HOOK_METADATA__\");\n\nexport interface OsdkStoreMetadata {\n hookType: string;\n objectType?: string;\n primaryKey?: string;\n actionName?: string;\n sourceObjectType?: string;\n linkName?: string;\n where?: unknown;\n orderBy?: unknown;\n pageSize?: number;\n aggregate?: unknown;\n}\n\nexport const devToolsMetadata: (\n meta: OsdkStoreMetadata\n) => OsdkStoreMetadata | undefined = __DEV__\n ? (meta) => meta\n : (_meta) => undefined;\n\nexport function useDevToolsMetadata(\n devtoolsEnabled: boolean,\n hookType: string,\n key: string\n): void {\n const ref = React.useRef<{\n [k: symbol]: true;\n hookType: string;\n key: string;\n } | null>(null);\n if (devtoolsEnabled) {\n if (ref.current == null || ref.current.key !== key) {\n ref.current = { [OSDK_HOOK_METADATA]: true, hookType, key };\n }\n } else if (ref.current != null) {\n ref.current = null;\n }\n}\n\nexport type Snapshot<X> =\n | (X & { error?: Error })\n | (Partial<X> & { error?: Error })\n | undefined;\n\nexport function makeExternalStore<X>(\n createObservation: (callback: Observer<X | undefined>) => Unsubscribable,\n _metadata?: OsdkStoreMetadata,\n initialValue?: Snapshot<X>\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => Snapshot<X>;\n} {\n let lastResult: Snapshot<X> = initialValue;\n\n function getSnapShot(): Snapshot<X> {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n const obs = createObservation({\n next: (payload) => {\n lastResult = payload as Snapshot<X>;\n notifyUpdate();\n },\n error: (error: unknown) => {\n lastResult = {\n ...lastResult,\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n },\n complete: () => {},\n });\n\n return (): void => {\n obs.unsubscribe();\n };\n }\n\n const store = { subscribe, getSnapShot };\n if (__DEV__ && _metadata != null) {\n Object.defineProperty(store, OSDK_HOOK_METADATA, {\n value: _metadata,\n enumerable: false,\n });\n }\n return store;\n}\n\n/**\n * Like makeExternalStore but for async subscription creation.\n *\n * Uses an isActive flag to handle race conditions:\n * If cleanup runs before promise resolves, the stale subscription is\n * immediately unsubscribed when it eventually resolves\n */\nexport function makeExternalStoreAsync<X>(\n createObservation: (\n callback: Observer<X | undefined>\n ) => Promise<Unsubscribable>,\n _metadata?: OsdkStoreMetadata,\n initialValue?: Snapshot<X>\n): {\n subscribe: (notifyUpdate: () => void) => () => void;\n getSnapShot: () => Snapshot<X>;\n} {\n let lastResult: Snapshot<X> = initialValue;\n\n function getSnapShot(): Snapshot<X> {\n return lastResult;\n }\n\n function subscribe(notifyUpdate: () => void) {\n let isActive = true;\n let currentSubscription: Unsubscribable | undefined;\n\n const subscriptionPromise = createObservation({\n next: (payload) => {\n if (isActive) {\n lastResult = payload as Snapshot<X>;\n notifyUpdate();\n }\n },\n error: (error: unknown) => {\n if (isActive) {\n lastResult = {\n ...lastResult,\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n }\n },\n complete: () => {},\n });\n\n subscriptionPromise\n .then((sub) => {\n if (isActive) {\n currentSubscription = sub;\n } else {\n sub.unsubscribe();\n }\n })\n .catch((error: unknown) => {\n if (isActive) {\n lastResult = {\n ...lastResult,\n error: error instanceof Error ? error : new Error(String(error)),\n } as Snapshot<X>;\n notifyUpdate();\n }\n });\n\n return (): void => {\n isActive = false;\n if (currentSubscription) {\n currentSubscription.unsubscribe();\n }\n };\n }\n\n const store = { subscribe, getSnapShot };\n if (__DEV__ && _metadata != null) {\n Object.defineProperty(store, OSDK_HOOK_METADATA, {\n value: _metadata,\n enumerable: false,\n });\n }\n return store;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,MAAM,OAAO;AAGzB,MAAMC,OAAO,GACX,OAAOC,OAAO,KAAK,WAAW,IAAIA,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;AAEzE,OAAO,MAAMC,kBAA0B,GAAGC,MAAM,CAACC,GAAG,CAAC,wBAAwB,CAAC;AAe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V,WAAW,CAAC,CAAC;MACnB;IACF,CAAC,CAAC,CACDW,KAAK,CAAEf,KAAc,IAAK;MACzB,IAAIU,QAAQ,EAAE;QACZlB,UAAU,GAAG;UACX,GAAGA,UAAU;UACbQ,KAAK,EAAEA,KAAK,YAAYC,KAAK,GAAGD,KAAK,GAAG,IAAIC,KAAK,CAACC,MAAM,CAACF,KAAK,CAAC;QACjE,CAAgB;QAChBJ,YAAY,CAAC,CAAC;MAChB;IACF,CAAC,CAAC;IAEJ,OAAO,MAAY;MACjBc,QAAQ,GAAG,KAAK;MAChB,IAAIC,mBAAmB,EAAE;QACvBA,mBAAmB,CAACP,WAAW,CAAC,CAAC;MACnC;IACF,CAAC;EACH;EAEA,MAAMV,KAAK,GAAG;IAAEC,SAAS;IAAEF;EAAY,CAAC;EACxC,IAAItB,OAAO,IAAImB,SAAS,IAAI,IAAI,EAAE;IAChCe,MAAM,CAACC,cAAc,CAACZ,KAAK,EAAEnB,kBAAkB,EAAE;MAC/CgC,KAAK,EAAEjB,SAAS;MAChBkB,UAAU,EAAE;IACd,CAAC,CAAC;EACJ;EACA,OAAOd,KAAK;AACd","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useCbacBanner.js","names":["CbacBanners","React","usePlatformQuery","OsdkContext","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 { OsdkContext } from \"../../OsdkContext.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(OsdkContext);\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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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":[]}
1
+ {"version":3,"file":"useCbacBanner.js","names":["CbacBanners","React","usePlatformQuery","OsdkContext","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\";\n\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.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,\n enabled: externalEnabled = true,\n}: UseCbacBannerOptions): UseCbacBannerResult {\n const { client } = React.useContext(OsdkContext);\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;AAEzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AAmClD;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAC;EAC5BC,UAAU;EACVC,OAAO,EAAEC,eAAe,GAAG;AACP,CAAC,EAAuB;EAC5C,MAAM;IAAEC;EAAO,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,WAAW,CAAC;EAEhD,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":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useCbacMarkingRestrictions.js","names":["CbacMarkingRestrictionsObjects","React","usePlatformQuery","OsdkContext","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 { OsdkContext } from \"../../OsdkContext.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(OsdkContext);\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,WAAW,QAAQ,sBAAsB;AAoClD;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,WAAW,CAAC;EAEhD,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":[]}
1
+ {"version":3,"file":"useCbacMarkingRestrictions.js","names":["CbacMarkingRestrictionsObjects","React","usePlatformQuery","OsdkContext","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\";\n\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.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,\n enabled: externalEnabled = true,\n}: UseCbacMarkingRestrictionsOptions): UseCbacMarkingRestrictionsResult {\n const { client } = React.useContext(OsdkContext);\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\n | 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 }, [query.data]);\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;AAEzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AAoClD;AACA;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA,CAAC;EACzCC,UAAU;EACVC,OAAO,EAAEC,eAAe,GAAG;AACM,CAAC,EAAoC;EACtE,MAAM;IAAEC;EAAO,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,WAAW,CAAC;EAEhD,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,CAAC,MAElB;IACf,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,CAAEI,KAAK,IACtDA,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,EAAE,CAACZ,KAAK,CAACG,IAAI,CAAC,CAAC;EAEhB,OAAO;IACLD,YAAY;IACZW,SAAS,EAAEb,KAAK,CAACa,SAAS;IAC1BC,KAAK,EAAEd,KAAK,CAACc,KAAK;IAClBC,OAAO,EAAEf,KAAK,CAACe;EACjB,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrentFoundryUser.js","names":["Users","React","usePlatformQuery","OsdkContext","useCurrentFoundryUser","enabled","client","useContext","handleQuery","useCallback","getCurrent","query","queryName","currentUser","data","isLoading","error","refetch"],"sources":["useCurrentFoundryUser.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 User, Users } from \"@osdk/foundry.admin\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseCurrentFoundryUserOptions {\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 */\n enabled?: boolean;\n}\n\nexport interface UseCurrentFoundryUserResult {\n currentUser: User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the currently signed in User.\n * @param options Options to control the query.\n */\nexport function useCurrentFoundryUser(\n { enabled = true }: UseCurrentFoundryUserOptions = {},\n): UseCurrentFoundryUserResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(\n () => Users.getCurrent(client),\n [client],\n );\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-current-user\",\n });\n\n return {\n currentUser: query.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;;AAEA,SAAoBA,KAAK,QAAQ,qBAAqB;AACtD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AA4BlD;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CACnC;EAAEC,OAAO,GAAG;AAAmC,CAAC,GAAG,CAAC,CAAC,EACxB;EAC7B,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,WAAW,CAAC;EAEhD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CACnC,MAAMT,KAAK,CAACU,UAAU,CAACJ,MAAM,CAAC,EAC9B,CAACA,MAAM,CACT,CAAC;EAED,MAAMK,KAAK,GAAGT,gBAAgB,CAAC;IAC7BS,KAAK,EAAEH,WAAW;IAClBH,OAAO;IACPO,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,WAAW,EAAEF,KAAK,CAACG,IAAI;IACvBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useCurrentFoundryUser.js","names":["Users","React","usePlatformQuery","OsdkContext","useCurrentFoundryUser","enabled","client","useContext","handleQuery","useCallback","getCurrent","query","queryName","currentUser","data","isLoading","error","refetch"],"sources":["useCurrentFoundryUser.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 User, Users } from \"@osdk/foundry.admin\";\nimport React from \"react\";\n\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseCurrentFoundryUserOptions {\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 */\n enabled?: boolean;\n}\n\nexport interface UseCurrentFoundryUserResult {\n currentUser: User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the currently signed in User.\n * @param options Options to control the query.\n */\nexport function useCurrentFoundryUser({\n enabled = true,\n}: UseCurrentFoundryUserOptions = {}): UseCurrentFoundryUserResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(\n () => Users.getCurrent(client),\n [client]\n );\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-current-user\",\n });\n\n return {\n currentUser: query.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;;AAEA,SAAoBA,KAAK,QAAQ,qBAAqB;AACtD,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AA4BlD;AACA;AACA;AACA;AACA,OAAO,SAASC,qBAAqBA,CAAC;EACpCC,OAAO,GAAG;AACkB,CAAC,GAAG,CAAC,CAAC,EAA+B;EACjE,MAAM;IAAEC;EAAO,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,WAAW,CAAC;EAEhD,MAAMK,WAAW,GAAGP,KAAK,CAACQ,WAAW,CACnC,MAAMT,KAAK,CAACU,UAAU,CAACJ,MAAM,CAAC,EAC9B,CAACA,MAAM,CACT,CAAC;EAED,MAAMK,KAAK,GAAGT,gBAAgB,CAAC;IAC7BS,KAAK,EAAEH,WAAW;IAClBH,OAAO;IACPO,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,WAAW,EAAEF,KAAK,CAACG,IAAI;IACvBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useFoundryUser.js","names":["Users","React","usePlatformQuery","OsdkContext","useFoundryUser","userId","enabled","status","client","useContext","handleQuery","useCallback","get","query","queryName","user","data","isLoading","error","refetch"],"sources":["useFoundryUser.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 User, Users } from \"@osdk/foundry.admin\";\nimport type { UserStatus } from \"@osdk/foundry.core\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseFoundryUserOptions {\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 */\n enabled?: boolean;\n\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n status?: UserStatus;\n}\n\nexport interface UseFoundryUserResult {\n user: User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the User with the specified id.\n * @param userId A Foundry User ID.\n * @param options Options to control the query.\n */\nexport function useFoundryUser(\n userId: string,\n { enabled = true, status = \"ACTIVE\" }: UseFoundryUserOptions = {},\n): UseFoundryUserResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(() => {\n return Users.get(client, userId, { status });\n }, [client, userId, status]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-user\",\n });\n\n return {\n user: query.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;;AAEA,SAAoBA,KAAK,QAAQ,qBAAqB;AAEtD,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AAmClD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,MAAc,EACd;EAAEC,OAAO,GAAG,IAAI;EAAEC,MAAM,GAAG;AAAgC,CAAC,GAAG,CAAC,CAAC,EAC3C;EACtB,MAAM;IAAEC;EAAO,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,WAAW,CAAC;EAEhD,MAAMO,WAAW,GAAGT,KAAK,CAACU,WAAW,CAAC,MAAM;IAC1C,OAAOX,KAAK,CAACY,GAAG,CAACJ,MAAM,EAAEH,MAAM,EAAE;MAAEE;IAAO,CAAC,CAAC;EAC9C,CAAC,EAAE,CAACC,MAAM,EAAEH,MAAM,EAAEE,MAAM,CAAC,CAAC;EAE5B,MAAMM,KAAK,GAAGX,gBAAgB,CAAC;IAC7BW,KAAK,EAAEH,WAAW;IAClBJ,OAAO;IACPQ,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,IAAI,EAAEF,KAAK,CAACG,IAAI;IAChBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useFoundryUser.js","names":["Users","React","usePlatformQuery","OsdkContext","useFoundryUser","userId","enabled","status","client","useContext","handleQuery","useCallback","get","query","queryName","user","data","isLoading","error","refetch"],"sources":["useFoundryUser.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 User, Users } from \"@osdk/foundry.admin\";\nimport type { UserStatus } from \"@osdk/foundry.core\";\nimport React from \"react\";\n\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseFoundryUserOptions {\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 */\n enabled?: boolean;\n\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n status?: UserStatus;\n}\n\nexport interface UseFoundryUserResult {\n user: User | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Get the User with the specified id.\n * @param userId A Foundry User ID.\n * @param options Options to control the query.\n */\nexport function useFoundryUser(\n userId: string,\n { enabled = true, status = \"ACTIVE\" }: UseFoundryUserOptions = {}\n): UseFoundryUserResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(() => {\n return Users.get(client, userId, { status });\n }, [client, userId, status]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-user\",\n });\n\n return {\n user: query.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;;AAEA,SAAoBA,KAAK,QAAQ,qBAAqB;AAEtD,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AAmClD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAC5BC,MAAc,EACd;EAAEC,OAAO,GAAG,IAAI;EAAEC,MAAM,GAAG;AAAgC,CAAC,GAAG,CAAC,CAAC,EAC3C;EACtB,MAAM;IAAEC;EAAO,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,WAAW,CAAC;EAEhD,MAAMO,WAAW,GAAGT,KAAK,CAACU,WAAW,CAAC,MAAM;IAC1C,OAAOX,KAAK,CAACY,GAAG,CAACJ,MAAM,EAAEH,MAAM,EAAE;MAAEE;IAAO,CAAC,CAAC;EAC9C,CAAC,EAAE,CAACC,MAAM,EAAEH,MAAM,EAAEE,MAAM,CAAC,CAAC;EAE5B,MAAMM,KAAK,GAAGX,gBAAgB,CAAC;IAC7BW,KAAK,EAAEH,WAAW;IAClBJ,OAAO;IACPQ,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,IAAI,EAAEF,KAAK,CAACG,IAAI;IAChBC,SAAS,EAAEJ,KAAK,CAACI,SAAS;IAC1BC,KAAK,EAAEL,KAAK,CAACK,KAAK;IAClBC,OAAO,EAAEN,KAAK,CAACM;EACjB,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"useFoundryUsersList.js","names":["Users","React","usePlatformQuery","OsdkContext","useFoundryUsersList","enabled","include","pageSize","pageToken","client","useContext","handleQuery","useCallback","list","query","queryName","users","data","nextPageToken","isLoading","error","refetch"],"sources":["useFoundryUsersList.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 ListUsersResponse, Users } from \"@osdk/foundry.admin\";\nimport type { UserStatus } from \"@osdk/foundry.core\";\nimport React from \"react\";\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseFoundryUsersListOptions {\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 */\n enabled?: boolean;\n\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n include?: UserStatus;\n\n /**\n * The preferred page size for the list.\n *\n * @default 1000\n */\n pageSize?: number;\n\n /**\n * The page token indicates where to start paging. This should be omitted from the first page's request.\n * To fetch the next page, clients should take the value from the nextPageToken field of the previous\n * response and use it to populate the pageToken field of the next request.\n */\n pageToken?: string;\n}\n\nexport interface UseFoundryUsersListResult {\n users: ListUsersResponse[\"data\"] | undefined;\n /**\n * The page token to be used for the next page of users. If this is undefined, there are no more\n * pages of users to load.\n */\n nextPageToken: string | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Lists all Users. This is a paged endpoint. Each page may be smaller or larger than the requested page size.\n * @param options Options to control the query.\n */\nexport function useFoundryUsersList(\n { enabled = true, include = \"ACTIVE\", pageSize = 1000, pageToken }:\n UseFoundryUsersListOptions = {},\n): UseFoundryUsersListResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(() => {\n return Users.list(client, { include, pageSize, pageToken });\n }, [client, include, pageSize, pageToken]);\n\n const query = usePlatformQuery(\n {\n query: handleQuery,\n enabled,\n queryName: \"foundry-users-list\",\n },\n );\n\n return {\n users: query.data?.data,\n nextPageToken: query.data?.nextPageToken,\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,SAAiCA,KAAK,QAAQ,qBAAqB;AAEnE,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AAsDlD;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CACjC;EAAEC,OAAO,GAAG,IAAI;EAAEC,OAAO,GAAG,QAAQ;EAAEC,QAAQ,GAAG,IAAI;EAAEC;AAC5B,CAAC,GAAG,CAAC,CAAC,EACN;EAC3B,MAAM;IAAEC;EAAO,CAAC,GAAGR,KAAK,CAACS,UAAU,CAACP,WAAW,CAAC;EAEhD,MAAMQ,WAAW,GAAGV,KAAK,CAACW,WAAW,CAAC,MAAM;IAC1C,OAAOZ,KAAK,CAACa,IAAI,CAACJ,MAAM,EAAE;MAAEH,OAAO;MAAEC,QAAQ;MAAEC;IAAU,CAAC,CAAC;EAC7D,CAAC,EAAE,CAACC,MAAM,EAAEH,OAAO,EAAEC,QAAQ,EAAEC,SAAS,CAAC,CAAC;EAE1C,MAAMM,KAAK,GAAGZ,gBAAgB,CAC5B;IACEY,KAAK,EAAEH,WAAW;IAClBN,OAAO;IACPU,SAAS,EAAE;EACb,CACF,CAAC;EAED,OAAO;IACLC,KAAK,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IACvBC,aAAa,EAAEJ,KAAK,CAACG,IAAI,EAAEC,aAAa;IACxCC,SAAS,EAAEL,KAAK,CAACK,SAAS;IAC1BC,KAAK,EAAEN,KAAK,CAACM,KAAK;IAClBC,OAAO,EAAEP,KAAK,CAACO;EACjB,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"useFoundryUsersList.js","names":["Users","React","usePlatformQuery","OsdkContext","useFoundryUsersList","enabled","include","pageSize","pageToken","client","useContext","handleQuery","useCallback","list","query","queryName","users","data","nextPageToken","isLoading","error","refetch"],"sources":["useFoundryUsersList.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 ListUsersResponse, Users } from \"@osdk/foundry.admin\";\nimport type { UserStatus } from \"@osdk/foundry.core\";\nimport React from \"react\";\n\nimport { usePlatformQuery } from \"../../../utils/usePlatformQuery.js\";\nimport { OsdkContext } from \"../../OsdkContext.js\";\n\nexport interface UseFoundryUsersListOptions {\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 */\n enabled?: boolean;\n\n /**\n * The default status of the users returned in the list.\n *\n * @default \"ACTIVE\"\n */\n include?: UserStatus;\n\n /**\n * The preferred page size for the list.\n *\n * @default 1000\n */\n pageSize?: number;\n\n /**\n * The page token indicates where to start paging. This should be omitted from the first page's request.\n * To fetch the next page, clients should take the value from the nextPageToken field of the previous\n * response and use it to populate the pageToken field of the next request.\n */\n pageToken?: string;\n}\n\nexport interface UseFoundryUsersListResult {\n users: ListUsersResponse[\"data\"] | undefined;\n /**\n * The page token to be used for the next page of users. If this is undefined, there are no more\n * pages of users to load.\n */\n nextPageToken: string | undefined;\n isLoading: boolean;\n\n error: Error | undefined;\n\n refetch: () => void;\n}\n\n/**\n * Lists all Users. This is a paged endpoint. Each page may be smaller or larger than the requested page size.\n * @param options Options to control the query.\n */\nexport function useFoundryUsersList({\n enabled = true,\n include = \"ACTIVE\",\n pageSize = 1000,\n pageToken,\n}: UseFoundryUsersListOptions = {}): UseFoundryUsersListResult {\n const { client } = React.useContext(OsdkContext);\n\n const handleQuery = React.useCallback(() => {\n return Users.list(client, { include, pageSize, pageToken });\n }, [client, include, pageSize, pageToken]);\n\n const query = usePlatformQuery({\n query: handleQuery,\n enabled,\n queryName: \"foundry-users-list\",\n });\n\n return {\n users: query.data?.data,\n nextPageToken: query.data?.nextPageToken,\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,SAAiCA,KAAK,QAAQ,qBAAqB;AAEnE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,gBAAgB,QAAQ,oCAAoC;AACrE,SAASC,WAAW,QAAQ,sBAAsB;AAsDlD;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAC;EAClCC,OAAO,GAAG,IAAI;EACdC,OAAO,GAAG,QAAQ;EAClBC,QAAQ,GAAG,IAAI;EACfC;AAC0B,CAAC,GAAG,CAAC,CAAC,EAA6B;EAC7D,MAAM;IAAEC;EAAO,CAAC,GAAGR,KAAK,CAACS,UAAU,CAACP,WAAW,CAAC;EAEhD,MAAMQ,WAAW,GAAGV,KAAK,CAACW,WAAW,CAAC,MAAM;IAC1C,OAAOZ,KAAK,CAACa,IAAI,CAACJ,MAAM,EAAE;MAAEH,OAAO;MAAEC,QAAQ;MAAEC;IAAU,CAAC,CAAC;EAC7D,CAAC,EAAE,CAACC,MAAM,EAAEH,OAAO,EAAEC,QAAQ,EAAEC,SAAS,CAAC,CAAC;EAE1C,MAAMM,KAAK,GAAGZ,gBAAgB,CAAC;IAC7BY,KAAK,EAAEH,WAAW;IAClBN,OAAO;IACPU,SAAS,EAAE;EACb,CAAC,CAAC;EAEF,OAAO;IACLC,KAAK,EAAEF,KAAK,CAACG,IAAI,EAAEA,IAAI;IACvBC,aAAa,EAAEJ,KAAK,CAACG,IAAI,EAAEC,aAAa;IACxCC,SAAS,EAAEL,KAAK,CAACK,SAAS;IAC1BC,KAAK,EAAEN,KAAK,CAACM,KAAK;IAClBC,OAAO,EAAEP,KAAK,CAACO;EACjB,CAAC;AACH","ignoreList":[]}