@smartspace/chat-ui 1.14.0-main.b0380b4 → 1.14.0-main.ed0d80f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -259,6 +259,8 @@ type Variables = Record<string, {
259
259
  }>;
260
260
  type MentionUser = {
261
261
  id: string;
262
+ /** AppUser id (the principal id used by thread-membership endpoints). */
263
+ userId: string;
262
264
  displayName: string;
263
265
  initials: string;
264
266
  };
@@ -582,6 +584,11 @@ declare const workspaceResponseSchema: z.ZodObject<{
582
584
  triggers: z.ZodArray<z.ZodObject<{
583
585
  dataSourceContainer: z.ZodObject<{
584
586
  dataSourceId: z.ZodString;
587
+ filters: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
588
+ operator: z.ZodString;
589
+ propertyName: z.ZodString;
590
+ value: z.ZodString;
591
+ }, z.core.$strip>>>>;
585
592
  id: z.ZodString;
586
593
  name: z.ZodString;
587
594
  path: z.ZodString;
@@ -812,6 +819,11 @@ declare const workspacesListResponseSchema: z.ZodObject<{
812
819
  triggers: z.ZodArray<z.ZodObject<{
813
820
  dataSourceContainer: z.ZodObject<{
814
821
  dataSourceId: z.ZodString;
822
+ filters: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
823
+ operator: z.ZodString;
824
+ propertyName: z.ZodString;
825
+ value: z.ZodString;
826
+ }, z.core.$strip>>>>;
815
827
  id: z.ZodString;
816
828
  name: z.ZodString;
817
829
  path: z.ZodString;
@@ -1010,6 +1022,19 @@ declare function unmarkDraftThreadId(threadId: string): void;
1010
1022
  declare function isDraftThreadId(threadId?: string | null): boolean;
1011
1023
  declare function createDraftThreadId(): string;
1012
1024
 
1025
+ /**
1026
+ * Safe wrapper around `crypto.randomUUID()` with a timestamp-based fallback
1027
+ * for environments that don't expose the Web Crypto API (e.g. non-secure
1028
+ * contexts, old Node test runners, JSDOM without the flag).
1029
+ *
1030
+ * The fallback is intentionally detectable: IDs start with the current
1031
+ * millisecond timestamp, making it trivially obvious in logs/tests when the
1032
+ * real API is unavailable. It is not cryptographically strong — use it only
1033
+ * for transient optimistic-UI identifiers that are discarded once the server
1034
+ * responds.
1035
+ */
1036
+ declare function randomUUID(): string;
1037
+
1013
1038
  /**
1014
1039
  * Treat an API date string as UTC even when it lacks a trailing "Z".
1015
1040
  * If already a Date, returns it as-is (Date stores UTC internally).
@@ -1208,7 +1233,9 @@ type AddInputArgs = {
1208
1233
  channels: Record<string, number> | null;
1209
1234
  };
1210
1235
  declare function useAddInputToMessage(): {
1211
- addInputToMessageMutation: _tanstack_react_query.UseMutationResult<Message, Error, AddInputArgs, unknown>;
1236
+ addInputToMessageMutation: _tanstack_react_query.UseMutationResult<Message, Error, AddInputArgs, {
1237
+ previousMessages: Message[];
1238
+ }>;
1212
1239
  };
1213
1240
 
1214
1241
  declare const threadDetailOptions: ({ service, workspaceId, threadId, }: {
@@ -1309,4 +1336,4 @@ declare function useModels({ search, take, skip, }?: {
1309
1336
  total: number;
1310
1337
  }, Error>;
1311
1338
 
1312
- export { type ChatContextIds, type ChatIdentity, ChatProvider, type ChatProviderProps, type ChatService, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, type FileInfo$1 as FileInfo, type FileScope, type FlowRunVariables, MarkdownEditor, type MarkdownEditorHandle, type MentionUser, type Message, MessageComposer, type MessageComposerProps, type MessageContentItem, type MessageError, MessageList, type MessageListProps, MessageListSkeleton, MessageMarkdown, type MessageThread, type MessageValue, MessageValueType, type Model, type ModelProperty, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, type ThreadsResponse, type Variables, type Workspace, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
1339
+ export { type ChatContextIds, type ChatIdentity, ChatProvider, type ChatProviderProps, type ChatService, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, type FileInfo$1 as FileInfo, type FileScope, type FlowRunVariables, MarkdownEditor, type MarkdownEditorHandle, type MentionUser, type Message, MessageComposer, type MessageComposerProps, type MessageContentItem, type MessageError, MessageList, type MessageListProps, MessageListSkeleton, MessageMarkdown, type MessageThread, type MessageValue, MessageValueType, type Model, type ModelProperty, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, type ThreadsResponse, type Variables, type Workspace, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
package/dist/index.js CHANGED
@@ -756,7 +756,7 @@ var mention = $node("mention", () => ({
756
756
  match: (node2) => node2.type.name === "mention",
757
757
  runner: (state, node2) => {
758
758
  const { id, label } = node2.attrs;
759
- state.addNode("mention", void 0, `${id}|${label}`);
759
+ state.addNode("text", void 0, label || `@${id}`);
760
760
  }
761
761
  }
762
762
  }));
@@ -3576,6 +3576,12 @@ var useThreadIsRunning = (workspaceId, threadId) => {
3576
3576
  return !!optimistic || !!(detailThread ?? listThread)?.isFlowRunning;
3577
3577
  };
3578
3578
 
3579
+ // src/shared/utils/randomUUID.ts
3580
+ function randomUUID() {
3581
+ const cryptoObj = globalThis?.crypto;
3582
+ return typeof cryptoObj?.randomUUID === "function" ? cryptoObj.randomUUID() : `${Date.now()}-${Math.random().toString(16).slice(2)}`;
3583
+ }
3584
+
3579
3585
  // src/domains/messages/enums.ts
3580
3586
  var MessageValueType = /* @__PURE__ */ ((MessageValueType2) => {
3581
3587
  MessageValueType2["OUTPUT"] = "Output";
@@ -3623,10 +3629,10 @@ function useSendMessage() {
3623
3629
  if (!threadId) throw new Error("Thread ID is required");
3624
3630
  if (!workspaceId) throw new Error("Workspace ID is required");
3625
3631
  const optimistic = {
3626
- id: `temp-${crypto.randomUUID()}`,
3632
+ id: `temp-${randomUUID()}`,
3627
3633
  values: [
3628
3634
  {
3629
- id: `temp-${crypto.randomUUID()}-prompt`,
3635
+ id: `temp-${randomUUID()}-prompt`,
3630
3636
  type: "Input" /* INPUT */,
3631
3637
  name: "prompt",
3632
3638
  value: contentList,
@@ -3637,7 +3643,7 @@ function useSendMessage() {
3637
3643
  },
3638
3644
  ...files?.length ? [
3639
3645
  {
3640
- id: `temp-${crypto.randomUUID()}-files`,
3646
+ id: `temp-${randomUUID()}-files`,
3641
3647
  type: "Input" /* INPUT */,
3642
3648
  name: "files",
3643
3649
  value: files,
@@ -3649,7 +3655,7 @@ function useSendMessage() {
3649
3655
  ] : [],
3650
3656
  ...variables && Object.keys(variables).length ? [
3651
3657
  {
3652
- id: `temp-${crypto.randomUUID()}-vars`,
3658
+ id: `temp-${randomUUID()}-vars`,
3653
3659
  type: "Input" /* INPUT */,
3654
3660
  name: "variables",
3655
3661
  value: variables,
@@ -3718,8 +3724,9 @@ function useAddInputToMessage() {
3718
3724
  const { userId, displayName: userName } = useChatIdentity();
3719
3725
  const service = useChatService();
3720
3726
  const addInputToMessageMutation = useMutation({
3721
- mutationFn: async ({ threadId, messageId, name, value, channels }) => {
3722
- if (!threadId) throw new Error("Thread ID is required");
3727
+ onMutate: async ({ threadId, messageId, name, value, channels }) => {
3728
+ await qc.cancelQueries({ queryKey: messagesKeys.list(threadId) });
3729
+ const previousMessages = qc.getQueryData(messagesKeys.list(threadId)) ?? [];
3723
3730
  qc.setQueryData(
3724
3731
  messagesKeys.list(threadId),
3725
3732
  (old = []) => old.map(
@@ -3728,7 +3735,7 @@ function useAddInputToMessage() {
3728
3735
  values: [
3729
3736
  ...m.values ?? [],
3730
3737
  {
3731
- id: `temp-${Date.now()}-add`,
3738
+ id: `temp-${randomUUID()}-add`,
3732
3739
  type: "Input" /* INPUT */,
3733
3740
  name,
3734
3741
  value,
@@ -3741,7 +3748,10 @@ function useAddInputToMessage() {
3741
3748
  } : m
3742
3749
  )
3743
3750
  );
3744
- await qc.cancelQueries({ queryKey: messagesKeys.list(threadId) });
3751
+ return { previousMessages };
3752
+ },
3753
+ mutationFn: async ({ threadId, messageId, name, value, channels }) => {
3754
+ if (!threadId) throw new Error("Thread ID is required");
3745
3755
  return await service.addInputToMessage({
3746
3756
  messageId,
3747
3757
  name,
@@ -3755,11 +3765,13 @@ function useAddInputToMessage() {
3755
3765
  (old = []) => reconcileWithMessage(old, message, "replace")
3756
3766
  );
3757
3767
  },
3758
- onError: (_e, { threadId }) => {
3759
- qc.setQueryData(
3760
- messagesKeys.list(threadId),
3761
- (old = []) => old.filter((m) => !m.optimistic)
3762
- );
3768
+ onError: (_e, { threadId }, context) => {
3769
+ if (context) {
3770
+ qc.setQueryData(
3771
+ messagesKeys.list(threadId),
3772
+ context.previousMessages
3773
+ );
3774
+ }
3763
3775
  toast.error("There was an error posting your form input");
3764
3776
  },
3765
3777
  retry: false
@@ -20284,6 +20296,7 @@ var computeAvatar = (name, fallback) => {
20284
20296
  function mapMentionUserDtoToModel(dto) {
20285
20297
  return {
20286
20298
  id: dto.id,
20299
+ userId: dto.userId,
20287
20300
  displayName: dto.displayName ?? "",
20288
20301
  initials: getInitials(dto.displayName ?? "")
20289
20302
  };
@@ -20326,6 +20339,6 @@ function mapWorkspaceDtoToModel(dto) {
20326
20339
  }
20327
20340
  var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
20328
20341
 
20329
- export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
20342
+ export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, DateFromApi, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, getUserPhotoUrl, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, parseDateTime, parseDateTimeHuman, randomUUID, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, utcDate, workspaceDetailOptions, workspaceKeys };
20330
20343
  //# sourceMappingURL=index.js.map
20331
20344
  //# sourceMappingURL=index.js.map