@smartspace/chat-ui 1.13.1-dev.3184d8f → 1.13.1-dev.8f17e91

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
@@ -1019,6 +1019,23 @@ declare function unmarkDraftThreadId(threadId: string): void;
1019
1019
  declare function isDraftThreadId(threadId?: string | null): boolean;
1020
1020
  declare function createDraftThreadId(): string;
1021
1021
 
1022
+ /**
1023
+ * Treat an API date string as UTC even when it lacks a trailing "Z".
1024
+ * If already a Date, returns it as-is (Date stores UTC internally).
1025
+ */
1026
+ declare function utcDate(value: string | Date): Date;
1027
+ /**
1028
+ * Zod schema that coerces a Date, ISO string, or numeric timestamp
1029
+ * from the API into a Date object, ensuring timezone-less strings
1030
+ * are treated as UTC.
1031
+ */
1032
+ declare const DateFromApi: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodCoercedDate<unknown>>;
1033
+
1034
+ declare function parseDateTime(date: Date | string, customFormat?: string): string;
1035
+ declare function parseDateTimeHuman(date: Date | string): string;
1036
+
1037
+ declare function getUserPhotoUrl(userId: string | null | undefined): string | undefined;
1038
+
1022
1039
  declare const messagesKeys: {
1023
1040
  all: readonly ["messages"];
1024
1041
  lists: () => readonly ["messages", "list"];
@@ -1147,11 +1164,7 @@ declare const messagesListOptions: (service: ChatService, threadId: string, opts
1147
1164
  [dataTagErrorSymbol]: Error;
1148
1165
  };
1149
1166
  };
1150
- declare function useMessages(threadId: string, opts?: {
1151
- take?: number;
1152
- skip?: number;
1153
- skipWhenNewThread?: boolean;
1154
- }): _tanstack_react_query.UseQueryResult<Message[], Error>;
1167
+ declare function useMessages(threadId: string): _tanstack_react_query.UseQueryResult<Message[], Error>;
1155
1168
 
1156
1169
  declare const useFileMutations: (scope: FileScope) => {
1157
1170
  uploadFilesMutation: _tanstack_react_query.UseMutationResult<FileInfo$1[], Error, File[], unknown>;
@@ -1305,4 +1318,4 @@ declare function useModels({ search, take, skip, }?: {
1305
1318
  total: number;
1306
1319
  }, Error>;
1307
1320
 
1308
- export { type ChatContextIds, type ChatIdentity, ChatProvider, type ChatProviderProps, type ChatService, ChatVariablesForm, DRAFT_THREAD_PREFIX, 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, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, workspaceDetailOptions, workspaceKeys };
1321
+ 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 };
package/dist/index.js CHANGED
@@ -3310,7 +3310,7 @@ function utcDate(value) {
3310
3310
  }
3311
3311
  return new Date(value);
3312
3312
  }
3313
- z.preprocess((val) => {
3313
+ var DateFromApi = z.preprocess((val) => {
3314
3314
  if (typeof val === "string" && !hasTimezone(val)) {
3315
3315
  return val + "Z";
3316
3316
  }
@@ -3818,11 +3818,13 @@ function MessageComposer({
3818
3818
  workspaceId,
3819
3819
  threadId: isDraftThread ? void 0 : threadId
3820
3820
  });
3821
- if (typeof window !== "undefined") {
3822
- window.__ssDownloadFile = async (id) => {
3823
- return await getFileBlobUrl(id);
3821
+ useEffect(() => {
3822
+ if (typeof window === "undefined") return;
3823
+ window.__ssDownloadFile = (id) => getFileBlobUrl(id);
3824
+ return () => {
3825
+ if (window.__ssDownloadFile) delete window.__ssDownloadFile;
3824
3826
  };
3825
- }
3827
+ }, [getFileBlobUrl]);
3826
3828
  const onUploadFiles = async (files) => {
3827
3829
  const res = await uploadFilesMutation.mutateAsync(files);
3828
3830
  return res.map(({ id, name }) => ({ id, name }));
@@ -4245,15 +4247,13 @@ var messagesListOptions = (service, threadId, opts) => queryOptions({
4245
4247
  // Avoid re-fetching the entire thread on every small navigation.
4246
4248
  staleTime: 3e4
4247
4249
  });
4248
- function useMessages(threadId, opts) {
4250
+ function useMessages(threadId) {
4249
4251
  const service = useChatService();
4250
4252
  const isDraft = isDraftThreadId(threadId);
4251
- const skipFetch = opts?.skipWhenNewThread || !threadId || isDraft;
4252
- const listOpts = opts?.take != null || opts?.skip != null ? { take: opts.take, skip: opts.skip } : void 0;
4253
4253
  return useQuery({
4254
- ...messagesListOptions(service, threadId, listOpts),
4255
- enabled: !opts?.skipWhenNewThread && !!threadId && !isDraft,
4256
- initialData: skipFetch ? [] : void 0
4254
+ ...messagesListOptions(service, threadId),
4255
+ enabled: !!threadId && !isDraft,
4256
+ initialData: !threadId || isDraft ? [] : void 0
4257
4257
  });
4258
4258
  }
4259
4259
 
@@ -19086,14 +19086,20 @@ dayjs.extend(relativeTime);
19086
19086
  dayjs.extend(advancedFormat);
19087
19087
  function parseDateTime(date, customFormat) {
19088
19088
  const d = dayjs.utc(date).local();
19089
- return d.format(customFormat);
19089
+ if (customFormat === "X") return Math.floor(d.valueOf() / 1e3).toString();
19090
+ if (customFormat === "x") return d.valueOf().toString();
19091
+ return d.format(customFormat ?? "YYYY-MM-DD HH:mm:ss");
19092
+ }
19093
+ function parseDateTimeHuman(date) {
19094
+ return dayjs.utc(date).local().fromNow();
19090
19095
  }
19091
19096
 
19092
19097
  // src/shared/utils/userPhoto.ts
19093
19098
  function getChatApiBaseUrl() {
19094
19099
  try {
19095
19100
  const w = window;
19096
- const cfg = w?.ssconfig?.Chat_Api_Uri ?? import.meta.env.VITE_CHAT_API_URI;
19101
+ const env2 = import.meta.env;
19102
+ const cfg = w?.ssconfig?.Chat_Api_Uri ?? env2?.VITE_CHAT_API_URI;
19097
19103
  return typeof cfg === "string" && cfg.trim() ? cfg.trim() : "";
19098
19104
  } catch {
19099
19105
  return "";
@@ -20146,6 +20152,6 @@ function mapWorkspaceDtoToModel(dto) {
20146
20152
  }
20147
20153
  var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
20148
20154
 
20149
- export { ChatProvider, ChatVariablesForm, DRAFT_THREAD_PREFIX, MarkdownEditor, MessageComposer, MessageList, MessageListSkeleton, MessageMarkdown, MessageValueType, NEW_THREAD_ID, THREAD_LIST_PAGE_SIZE, applyDeltaToMessage, applyThreadToCache, createDraftThreadId, createThreadId, downloadFileBlobOptions, filesKeys, flowRunsKeys, getModelIcon, getThreadPlaceholderFromListCache, invalidateWorkspaceThreadLists, isDraftThreadId, mapFileInfoDtoToModel, mapMentionUserDtoToModel, mapMessageDtoToModel, mapMessageErrorDtoToModel, mapMessageValueDtoToModel, mapMessagesDtoToModels, mapSignalRThreadSummaryToModel, mapThreadDtoToModel, mapThreadsResponseDtoToModel, mapWorkspaceDtoToModel, mapWorkspacesDtoToModels, markDraftThreadId, messagesKeys, messagesListOptions, messagesMutationsKeys, modelsKeys, setThreadOptimisticRunning, setThreadRunningInLists, taggableUsersOptions, threadDetailOptions, threadsKeys, unmarkDraftThreadId, useAddInputToMessage, useChatContext, useChatIdentity, useChatService, useDownloadFileBlobQuery, useFileMutations, useFlowRunVariables, useMessages, useModels, useSendMessage, useTaggableWorkspaceUsers, useThread, useThreadIsRunning, useUpdateFlowRunVariable, useWorkspace, workspaceDetailOptions, workspaceKeys };
20155
+ 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 };
20150
20156
  //# sourceMappingURL=index.js.map
20151
20157
  //# sourceMappingURL=index.js.map