@smartspace/chat-ui 1.13.1-pr.255.41c66f3 → 1.13.1-pr.257.4f1269b

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
@@ -257,22 +257,22 @@ type MentionUser = {
257
257
  type Workspace = {
258
258
  id: string;
259
259
  name: string;
260
- tags?: string[];
261
- showSources?: boolean;
262
- dataSpaces?: unknown[];
260
+ tags: string[];
261
+ showSources: boolean;
262
+ dataSpaces: unknown[];
263
263
  createdByUserId?: string;
264
264
  createdAt?: Date;
265
265
  modifiedByUserId?: string;
266
266
  modifiedAt?: Date;
267
267
  favorited: boolean;
268
- summary?: string;
269
- firstPrompt?: string;
268
+ summary: string;
269
+ firstPrompt: string;
270
270
  outputSchema?: unknown;
271
- isPromptAndResponseLoggingEnabled?: boolean;
272
271
  inputs?: unknown;
272
+ isPromptAndResponseLoggingEnabled: boolean;
273
273
  variables: Variables;
274
274
  sandBoxThreadId?: string;
275
- supportsFiles?: boolean;
275
+ supportsFiles: boolean;
276
276
  avatarName: string;
277
277
  };
278
278
 
@@ -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
  }
@@ -3459,10 +3459,10 @@ function useSendMessage() {
3459
3459
  if (!threadId) throw new Error("Thread ID is required");
3460
3460
  if (!workspaceId) throw new Error("Workspace ID is required");
3461
3461
  const optimistic = {
3462
- id: `temp-${Date.now()}`,
3462
+ id: `temp-${crypto.randomUUID()}`,
3463
3463
  values: [
3464
3464
  {
3465
- id: `temp-${Date.now()}-prompt`,
3465
+ id: `temp-${crypto.randomUUID()}-prompt`,
3466
3466
  type: "Input" /* INPUT */,
3467
3467
  name: "prompt",
3468
3468
  value: contentList,
@@ -3473,7 +3473,7 @@ function useSendMessage() {
3473
3473
  },
3474
3474
  ...files?.length ? [
3475
3475
  {
3476
- id: `temp-${Date.now()}-files`,
3476
+ id: `temp-${crypto.randomUUID()}-files`,
3477
3477
  type: "Input" /* INPUT */,
3478
3478
  name: "files",
3479
3479
  value: files,
@@ -3485,7 +3485,7 @@ function useSendMessage() {
3485
3485
  ] : [],
3486
3486
  ...variables && Object.keys(variables).length ? [
3487
3487
  {
3488
- id: `temp-${Date.now()}-vars`,
3488
+ id: `temp-${crypto.randomUUID()}-vars`,
3489
3489
  type: "Input" /* INPUT */,
3490
3490
  name: "variables",
3491
3491
  value: variables,
@@ -3627,7 +3627,10 @@ var workspaceDetailOptions = ({
3627
3627
  });
3628
3628
  function useWorkspace(workspaceId) {
3629
3629
  const service = useChatService();
3630
- return useQuery(workspaceDetailOptions({ service, workspaceId }));
3630
+ return useQuery({
3631
+ ...workspaceDetailOptions({ service, workspaceId }),
3632
+ enabled: !!workspaceId
3633
+ });
3631
3634
  }
3632
3635
  var taggableUsersOptions = ({
3633
3636
  service,
@@ -4244,15 +4247,13 @@ var messagesListOptions = (service, threadId, opts) => queryOptions({
4244
4247
  // Avoid re-fetching the entire thread on every small navigation.
4245
4248
  staleTime: 3e4
4246
4249
  });
4247
- function useMessages(threadId, opts) {
4250
+ function useMessages(threadId) {
4248
4251
  const service = useChatService();
4249
4252
  const isDraft = isDraftThreadId(threadId);
4250
- const skipFetch = opts?.skipWhenNewThread || !threadId || isDraft;
4251
- const listOpts = opts?.take != null || opts?.skip != null ? { take: opts.take, skip: opts.skip } : void 0;
4252
4253
  return useQuery({
4253
- ...messagesListOptions(service, threadId, listOpts),
4254
- enabled: !opts?.skipWhenNewThread && !!threadId && !isDraft,
4255
- initialData: skipFetch ? [] : void 0
4254
+ ...messagesListOptions(service, threadId),
4255
+ enabled: !!threadId && !isDraft,
4256
+ initialData: !threadId || isDraft ? [] : void 0
4256
4257
  });
4257
4258
  }
4258
4259
 
@@ -19085,14 +19086,20 @@ dayjs.extend(relativeTime);
19085
19086
  dayjs.extend(advancedFormat);
19086
19087
  function parseDateTime(date, customFormat) {
19087
19088
  const d = dayjs.utc(date).local();
19088
- 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();
19089
19095
  }
19090
19096
 
19091
19097
  // src/shared/utils/userPhoto.ts
19092
19098
  function getChatApiBaseUrl() {
19093
19099
  try {
19094
19100
  const w = window;
19095
- 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;
19096
19103
  return typeof cfg === "string" && cfg.trim() ? cfg.trim() : "";
19097
19104
  } catch {
19098
19105
  return "";
@@ -20125,26 +20132,28 @@ function mapWorkspaceDtoToModel(dto) {
20125
20132
  id: dto.id ?? "",
20126
20133
  name: dto.name ?? "",
20127
20134
  tags: dto.tags ?? [],
20128
- showSources: dto.showSources ?? void 0,
20129
- dataSpaces: Array.isArray(dto.dataSpaces) ? dto.dataSpaces : void 0,
20135
+ showSources: truthy(dto.showSources),
20136
+ dataSpaces: Array.isArray(dto.dataSpaces) ? dto.dataSpaces : [],
20130
20137
  createdByUserId: dto.createdByUserId ?? void 0,
20131
20138
  createdAt: dto.createdAt != null ? utcDate(dto.createdAt) : void 0,
20132
20139
  modifiedByUserId: dto.modifiedByUserId ?? void 0,
20133
20140
  modifiedAt: dto.modifiedAt != null ? utcDate(dto.modifiedAt) : void 0,
20134
20141
  favorited: truthy(dto.favorited),
20135
- summary: dto.summary ?? void 0,
20136
- firstPrompt: dto.firstPrompt ?? void 0,
20142
+ summary: dto.summary ?? "",
20143
+ firstPrompt: dto.firstPrompt ?? "",
20137
20144
  outputSchema: dto.outputSchema ?? void 0,
20138
- isPromptAndResponseLoggingEnabled: dto.isPromptAndResponseLoggingEnabled ?? void 0,
20139
20145
  inputs: dto.inputs ?? void 0,
20146
+ isPromptAndResponseLoggingEnabled: truthy(
20147
+ dto.isPromptAndResponseLoggingEnabled
20148
+ ),
20140
20149
  variables,
20141
20150
  sandBoxThreadId: dto.sandBoxThreadId ?? void 0,
20142
- supportsFiles: dto.supportsFiles ?? void 0,
20151
+ supportsFiles: truthy(dto.supportsFiles),
20143
20152
  avatarName: computeAvatar(dto.name ?? "")
20144
20153
  };
20145
20154
  }
20146
20155
  var mapWorkspacesDtoToModels = (arr) => arr.map(mapWorkspaceDtoToModel);
20147
20156
 
20148
- 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 };
20157
+ 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 };
20149
20158
  //# sourceMappingURL=index.js.map
20150
20159
  //# sourceMappingURL=index.js.map