@aiquants/daily-report 0.20.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.d.mts CHANGED
@@ -1,8 +1,9 @@
1
1
  import * as react from "react";
2
2
  import { RefObject, ReactNode, Context } from "react";
3
- import { ScrollBarThumbOverlayRenderProps, ScrollPaneInertiaOptions, ScrollBarTapCircleOptions } from "@aiquants/virtualscroll";
3
+ import { ScrollBarThumbOverlayRenderProps, VirtualScrollLocale, VirtualScrollLabels, ScrollPaneInertiaOptions, ScrollBarTapCircleOptions } from "@aiquants/virtualscroll";
4
4
  import { D as DailyReportAttachmentSummary, a as DailyReportItem, b as DailyReportDetail, c as DailyReportUser } from "./types-CqgYQgbH.mjs";
5
- import { U as UIComment, D as DailyReportSseMessage } from "./sse-schema-ChSFm-4q.mjs";
5
+ import { U as UIComment, D as DailyReportSseTerminalEvent, a as DailyReportSseMessage, b as DailyReportSseStreamAnchor } from "./ids-stream-DCuiaTit.mjs";
6
+ import { UseReopeningEventSourceResult } from "@aiquants/sse/react";
6
7
  import { ShouldRevalidateFunction } from "react-router";
7
8
  import "zod";
8
9
  declare const BusinessDayThumbOverlay: ({ orientation, thumbCenter, label, isDragging, isTapScrollActive, isWheelScrollActive }: ScrollBarThumbOverlayRenderProps & {
@@ -78,35 +79,192 @@ type DailyReportListProps = {
78
79
  scrollOffsetRef?: RefObject<number>;
79
80
  };
80
81
  declare const DailyReportList: ({ dailyReportItems, autoMarkRead, selectedReportHubId, onSelectItem, userId, scrollOffsetRef }: DailyReportListProps) => react.JSX.Element;
82
+ type DailyReportLocale = VirtualScrollLocale;
83
+ type DailyReportOperation = "create" | "update" | "publish" | "delete" | "addComment" | "deleteComment" | "toggleStar" | "toggleRead";
84
+ type DailyReportLabels = VirtualScrollLabels & {
85
+ readonly id: string;
86
+ readonly businessDate: string;
87
+ readonly author: string;
88
+ readonly visitTime: string;
89
+ readonly createdAt: string;
90
+ readonly updatedAt: string;
91
+ readonly updatedBy: string;
92
+ readonly category: string;
93
+ readonly categoryInfo: string;
94
+ readonly creationCategory: string;
95
+ readonly customer: string;
96
+ readonly subject: string;
97
+ readonly content: string;
98
+ readonly interviewers: string;
99
+ readonly comments: string;
100
+ readonly attachments: string;
101
+ readonly attachmentMissing: string;
102
+ readonly attachmentDownload: string;
103
+ readonly tabArticle: string;
104
+ readonly tabRelations: string;
105
+ readonly relationsEmpty: string;
106
+ readonly title: string;
107
+ readonly tabList: string;
108
+ readonly tabTree: string;
109
+ readonly tabDetailList: string;
110
+ readonly treeComingSoon: string;
111
+ readonly totalCountLoading: string;
112
+ readonly createReport: string;
113
+ readonly createReportTitle: string;
114
+ readonly devControls: string;
115
+ readonly devSseToggle: string;
116
+ readonly devReload: string;
117
+ readonly devClearCache: string;
118
+ readonly autoRead: string;
119
+ readonly autoReadTitle: string;
120
+ readonly loadErrorBadge: string;
121
+ readonly loadError: string;
122
+ readonly reload: string;
123
+ readonly loadingIds: string;
124
+ readonly streamFailed: string;
125
+ readonly streamRetry: string;
126
+ readonly streamRevalidating: string;
127
+ readonly listEmpty: string;
128
+ readonly selectPrompt: string;
129
+ readonly loading: string;
130
+ readonly reportNotFound: string;
131
+ readonly contentEmpty: string;
132
+ readonly contentEmptyPreview: string;
133
+ readonly confirmDelete: string;
134
+ readonly deleteFailed: string;
135
+ readonly starAdd: string;
136
+ readonly starRemove: string;
137
+ readonly markRead: string;
138
+ readonly markUnread: string;
139
+ readonly deleteReport: string;
140
+ readonly resizeHandle: string;
141
+ readonly overlayBackdrop: string;
142
+ readonly overlayDialog: string;
143
+ readonly close: string;
144
+ readonly formTitle: string;
145
+ readonly formTitlePlaceholder: string;
146
+ readonly formContent: string;
147
+ readonly formContentPlaceholder: string;
148
+ readonly formCancel: string;
149
+ readonly formSave: string;
150
+ readonly formPublish: string;
151
+ readonly commentPlaceholder: string;
152
+ readonly commentSend: string;
153
+ readonly commentDelete: string;
154
+ readonly commentDeleteConfirm: string;
155
+ readonly unknownUser: string;
156
+ readonly sourceInternal: string;
157
+ readonly totalCount: (count: number) => string;
158
+ readonly debounce: (milliseconds: number) => string;
159
+ readonly streamProgressCount: (loaded: number) => string;
160
+ readonly streamProgressRatio: (loaded: number, total: number, percent: number) => string;
161
+ readonly streamRetrying: (loaded: number) => string;
162
+ readonly reportLoadFailed: (reportHubId: number) => string;
163
+ readonly reportSummaryLoadFailed: (reportHubId: number) => string;
164
+ readonly interviewerWithAffiliation: (name: string, affiliation: string) => string;
165
+ readonly operationFailed: (operation: DailyReportOperation) => string;
166
+ };
167
+ type DailyReportLabelOverrides = {
168
+ readonly [K in keyof DailyReportLabels]?: DailyReportLabels[K];
169
+ };
170
+ declare const DAILY_REPORT_LABEL_KEYS: readonly [
171
+ "scrollUp",
172
+ "scrollDown",
173
+ "scrollLeft",
174
+ "scrollRight",
175
+ "scrollToTop",
176
+ "scrollToBottom",
177
+ "noItems",
178
+ "id",
179
+ "businessDate",
180
+ "author",
181
+ "visitTime",
182
+ "createdAt",
183
+ "updatedAt",
184
+ "updatedBy",
185
+ "category",
186
+ "categoryInfo",
187
+ "creationCategory",
188
+ "customer",
189
+ "subject",
190
+ "content",
191
+ "interviewers",
192
+ "comments",
193
+ "attachments",
194
+ "attachmentMissing",
195
+ "attachmentDownload",
196
+ "tabArticle",
197
+ "tabRelations",
198
+ "relationsEmpty",
199
+ "title",
200
+ "tabList",
201
+ "tabTree",
202
+ "tabDetailList",
203
+ "treeComingSoon",
204
+ "totalCountLoading",
205
+ "createReport",
206
+ "createReportTitle",
207
+ "devControls",
208
+ "devSseToggle",
209
+ "devReload",
210
+ "devClearCache",
211
+ "autoRead",
212
+ "autoReadTitle",
213
+ "loadErrorBadge",
214
+ "loadError",
215
+ "reload",
216
+ "loadingIds",
217
+ "streamFailed",
218
+ "streamRetry",
219
+ "streamRevalidating",
220
+ "listEmpty",
221
+ "selectPrompt",
222
+ "loading",
223
+ "reportNotFound",
224
+ "contentEmpty",
225
+ "contentEmptyPreview",
226
+ "confirmDelete",
227
+ "deleteFailed",
228
+ "starAdd",
229
+ "starRemove",
230
+ "markRead",
231
+ "markUnread",
232
+ "deleteReport",
233
+ "resizeHandle",
234
+ "overlayBackdrop",
235
+ "overlayDialog",
236
+ "close",
237
+ "formTitle",
238
+ "formTitlePlaceholder",
239
+ "formContent",
240
+ "formContentPlaceholder",
241
+ "formCancel",
242
+ "formSave",
243
+ "formPublish",
244
+ "commentPlaceholder",
245
+ "commentSend",
246
+ "commentDelete",
247
+ "commentDeleteConfirm",
248
+ "unknownUser",
249
+ "sourceInternal",
250
+ "totalCount",
251
+ "debounce",
252
+ "streamProgressCount",
253
+ "streamProgressRatio",
254
+ "streamRetrying",
255
+ "reportLoadFailed",
256
+ "reportSummaryLoadFailed",
257
+ "interviewerWithAffiliation",
258
+ "operationFailed"
259
+ ];
260
+ declare const DAILY_REPORT_LABEL_CATALOGS: Readonly<Record<DailyReportLocale, DailyReportLabels>>;
261
+ declare const resolveDailyReportLabels: (locale: DailyReportLocale | undefined, overrides: DailyReportLabelOverrides | undefined) => DailyReportLabels;
81
262
  type DailyReportHeaderProps = {
82
263
  title: string;
83
264
  annotation?: ReactNode;
84
265
  };
85
- type DailyReportFieldLabels = {
86
- id: string;
87
- businessDate: string;
88
- author: string;
89
- visitTime: string;
90
- createdAt: string;
91
- updatedAt: string;
92
- updatedBy: string;
93
- category: string;
94
- categoryInfo: string;
95
- creationCategory: string;
96
- customer: string;
97
- subject: string;
98
- content: string;
99
- interviewers: string;
100
- comments: string;
101
- attachments: string;
102
- attachmentMissing: string;
103
- attachmentDownload: string;
104
- tabArticle: string;
105
- tabRelations: string;
106
- relationsEmpty: string;
107
- };
108
266
  type DailyReportErrorInfo = {
109
- operation: string;
267
+ operation: DailyReportOperation;
110
268
  message: string;
111
269
  cause?: unknown;
112
270
  };
@@ -116,24 +274,26 @@ type SourceTypeConfig = {
116
274
  allowComment?: boolean;
117
275
  };
118
276
  type DailyReportClientConfig = {
119
- title: string;
120
277
  apiBasePath: string;
121
278
  ssePath: string;
122
279
  draftLabelName: string;
123
- fieldLabels: DailyReportFieldLabels;
124
- sourceTypeConfigs?: Record<string, SourceTypeConfig>;
280
+ locale: DailyReportLocale;
281
+ labels: DailyReportLabels;
282
+ sourceTypeConfigs: Record<string, SourceTypeConfig>;
125
283
  renderHeader: (props: DailyReportHeaderProps) => ReactNode;
126
284
  showDevControls: boolean;
127
285
  onError?: (info: DailyReportErrorInfo) => void;
286
+ onSessionExpired: () => void;
128
287
  };
129
- type DailyReportClientConfigInput = Partial<Omit<DailyReportClientConfig, "fieldLabels">> & {
130
- fieldLabels?: Partial<DailyReportFieldLabels>;
131
- sourceTypeConfigs?: Record<string, SourceTypeConfig>;
288
+ type DailyReportClientConfigInput = Partial<Omit<DailyReportClientConfig, "locale" | "labels" | "onSessionExpired">> & {
289
+ locale?: DailyReportLocale;
290
+ labels?: DailyReportLabelOverrides;
291
+ onSessionExpired: () => void;
132
292
  };
133
- declare const defaultDailyReportFieldLabels: DailyReportFieldLabels;
134
- declare const defaultDailyReportClientConfig: DailyReportClientConfig;
293
+ type DailyReportClientConfigDefaults = Readonly<Pick<DailyReportClientConfig, "apiBasePath" | "ssePath" | "draftLabelName" | "renderHeader" | "showDevControls">>;
294
+ declare const defaultDailyReportClientConfig: DailyReportClientConfigDefaults;
135
295
  declare const DailyReportConfigProvider: ({ config, children }: {
136
- config?: DailyReportClientConfigInput;
296
+ config: DailyReportClientConfigInput;
137
297
  children: ReactNode;
138
298
  }) => react.JSX.Element;
139
299
  declare const useDailyReportConfig: () => DailyReportClientConfig;
@@ -143,7 +303,7 @@ declare const DailyReportLoading: () => react.JSX.Element;
143
303
  type DailyReportPageProps = {
144
304
  user?: DailyReportUser;
145
305
  userId?: string | null;
146
- config?: DailyReportClientConfigInput;
306
+ config: DailyReportClientConfigInput;
147
307
  };
148
308
  declare const DailyReportPage: ({ config, ...rest }: DailyReportPageProps) => react.JSX.Element;
149
309
  type DailyReportResolvedContentProps = {
@@ -154,6 +314,16 @@ type UnreadIndicatorProps = {
154
314
  className?: string;
155
315
  };
156
316
  declare const UnreadIndicator: ({ className }: UnreadIndicatorProps) => react.JSX.Element;
317
+ type DailyReportSseConnectionStatus = UseReopeningEventSourceResult<DailyReportSseTerminalEvent>["status"] | {
318
+ readonly kind: "resyncing";
319
+ };
320
+ type UseDailyReportSseConnectionOptions = {
321
+ isSseEnabled: boolean;
322
+ onMessage: (payload: Exclude<DailyReportSseMessage, {
323
+ type: "connected";
324
+ }>) => void;
325
+ };
326
+ declare const useDailyReportSseConnection: ({ isSseEnabled, onMessage }: UseDailyReportSseConnectionOptions) => DailyReportSseConnectionStatus;
157
327
  type DailyReportActionContextType = {
158
328
  user?: DailyReportUser;
159
329
  pendingAddCommentIds: React.MutableRefObject<Map<number, Map<number, string>>>;
@@ -165,6 +335,7 @@ type DailyReportActionContextType = {
165
335
  items: DailyReportItem[];
166
336
  isSseEnabled: boolean;
167
337
  toggleSse: () => void;
338
+ sseStatus: DailyReportSseConnectionStatus;
168
339
  addComment: (reportHubId: number, content: string, businessDate: string) => Promise<void>;
169
340
  deleteComment: (reportHubId: number, commentId: number, businessDate: string) => Promise<void>;
170
341
  toggleStar: (reportHubId: number, isStarred: boolean, businessDate: string) => Promise<void>;
@@ -263,13 +434,6 @@ declare const useDailyReportComments: (report: DailyReportDetail | null, user: U
263
434
  setPendingDeleteId: react.Dispatch<react.SetStateAction<string | number | null>>;
264
435
  resolvedIdMap: Map<number, number>;
265
436
  };
266
- type UseDailyReportSseConnectionOptions = {
267
- isSseEnabled: boolean;
268
- onMessage: (payload: Exclude<DailyReportSseMessage, {
269
- type: "connected";
270
- }>) => void;
271
- };
272
- declare const useDailyReportSseConnection: ({ isSseEnabled, onMessage }: UseDailyReportSseConnectionOptions) => void;
273
437
  type UseDynamicViewportHeightOptions = {
274
438
  enableMutationObserver?: boolean;
275
439
  bottomGap?: number;
@@ -299,6 +463,7 @@ type DailyReportIdsStreamState = {
299
463
  hasCompletedOnce: boolean;
300
464
  completedAt: number | null;
301
465
  error: Error | null;
466
+ streamAnchor: DailyReportSseStreamAnchor | null;
302
467
  };
303
468
  type DailyReportIdsStreamClientOptions = {
304
469
  apiBasePath?: string;
@@ -323,6 +488,7 @@ declare class DailyReportIdsStreamClient {
323
488
  private readonly itemMap;
324
489
  private readonly listeners;
325
490
  private state;
491
+ private streamAnchorRevision;
326
492
  private lastCursor;
327
493
  private lastSnapshot;
328
494
  private consecutiveFailures;
@@ -346,6 +512,7 @@ declare class DailyReportIdsStreamClient {
346
512
  refresh(options?: {
347
513
  forceRefresh?: boolean;
348
514
  }): void;
515
+ resync(): void;
349
516
  applyExternalUpsert(item: DailyReportItem): void;
350
517
  applyExternalRemoval(reportHubId: number): void;
351
518
  dispose(): void;
@@ -354,6 +521,7 @@ declare class DailyReportIdsStreamClient {
354
521
  private streamOnce;
355
522
  private readWithStallGuard;
356
523
  private absorbChunkLine;
524
+ private absorbStreamAnchor;
357
525
  private publishItems;
358
526
  private schedulePublishItems;
359
527
  private cancelScheduledPublishItems;
@@ -361,7 +529,6 @@ declare class DailyReportIdsStreamClient {
361
529
  private buildStreamUrl;
362
530
  private waitBeforeRetry;
363
531
  }
364
- declare const reloadDocument: () => void;
365
532
  declare const ensureDailyReportIdsStreamSession: (options: {
366
533
  apiBasePath?: string;
367
534
  userKey: string | null;
@@ -374,6 +541,7 @@ declare const primeDailyReportIdsStreamSession: () => void;
374
541
  declare const upsertDailyReportIdsStreamItem: (item: DailyReportItem) => void;
375
542
  declare const removeDailyReportIdsStreamItem: (reportHubId: number) => void;
376
543
  declare const retryDailyReportIdsStream: () => void;
544
+ declare const resyncDailyReportIdsStream: () => void;
377
545
  declare const refreshDailyReportIdsStream: (options?: {
378
546
  forceRefresh?: boolean;
379
547
  }) => void;
@@ -400,4 +568,4 @@ declare const CONTENT_DRAG_POINTER_INPUTS: readonly [
400
568
  "pen",
401
569
  "touch"
402
570
  ];
403
- export { BusinessDayThumbOverlay, CONTENT_DRAG_POINTER_INPUTS, DAILY_REPORT_FETCH_DEBOUNCE_MS, DEFAULT_ITEM_HEIGHT, type DailyReportActionContextType, DailyReportActionProvider, DailyReportAttachmentIndicator, DailyReportAttachmentList, DailyReportCache, type DailyReportClientConfig, type DailyReportClientConfigInput, DailyReportCommentForm, DailyReportCommentList, DailyReportConfigProvider, DailyReportDetailList, type DailyReportDetailListScrollRestore, type DailyReportDetailResource, DailyReportEditForm, type DailyReportErrorInfo, DailyReportErrorProvider, type DailyReportFieldLabels, type DailyReportHeaderProps, DailyReportIdsStreamClient, type DailyReportIdsStreamClientOptions, type DailyReportIdsStreamPhase, type DailyReportIdsStreamState, DailyReportIdsStreamStatus, DailyReportList, DailyReportLoadError, DailyReportLoading, DailyReportPage, type DailyReportPageProps, DailyReportPostedComment, DailyReportResolvedContent, EMPTY_DETAIL, EMPTY_ITEM, FAST_SCROLL_INERTIA_OPTIONS, FAST_SCROLL_WHEEL_MULTIPLIER, ITEM_CONTAINER_HEIGHT, ITEM_VERTICAL_PADDING, MAX_PREVIEW_LINES, PREFETCH_LOOKAHEAD, PREFETCH_MAX_DATES, SCROLL_BAR_WIDTH, SSE_INITIAL_CONNECT_DEFER_MS, type SourceTypeConfig, TAP_SCROLL_CIRCLE_OPTIONS, UnreadIndicator, VIRTUAL_SCROLL_OVERSCAN_COUNT, WHEEL_RESET_TIMEOUT_MS, acquireMutationLock, applyBroadcastReportUpdate, applyDailyReportServerUpdates, bootstrapDailyReportIdsStreamSession, clearDailyReportCache, createDailyReportClientLoader, dailyReportShouldRevalidate, defaultDailyReportClientConfig, defaultDailyReportFieldLabels, deleteDailyReportCache, ensureDailyReportIdsStreamSession, getCachedReport, getDailyReportIdsStreamSessionUserKey, primeDailyReportIdsStreamSession, refreshDailyReportIdsStream, registerRecentDeletion, releaseMutationLock, reloadDocument, removeDailyReportIdsStreamItem, resetDailyReportIdsStreamSessionForTesting, resolveSourceTypeConfig, retryDailyReportIdsStream, subscribeCacheReady, updateDailyReportCache, upsertDailyReportIdsStreamItem, useAnimatedNumber, useDailyReportActionContext, useDailyReportComments, useDailyReportConfig, useDailyReportDetail, useDailyReportErrorSurface, useDailyReportIdsStream, useDailyReportPrefetch, useDailyReportSseConnection, useDynamicViewportHeight, writeCache };
571
+ export { BusinessDayThumbOverlay, CONTENT_DRAG_POINTER_INPUTS, DAILY_REPORT_FETCH_DEBOUNCE_MS, DAILY_REPORT_LABEL_CATALOGS, DAILY_REPORT_LABEL_KEYS, DEFAULT_ITEM_HEIGHT, type DailyReportActionContextType, DailyReportActionProvider, DailyReportAttachmentIndicator, DailyReportAttachmentList, DailyReportCache, type DailyReportClientConfig, type DailyReportClientConfigDefaults, type DailyReportClientConfigInput, DailyReportCommentForm, DailyReportCommentList, DailyReportConfigProvider, DailyReportDetailList, type DailyReportDetailListScrollRestore, type DailyReportDetailResource, DailyReportEditForm, type DailyReportErrorInfo, DailyReportErrorProvider, type DailyReportHeaderProps, DailyReportIdsStreamClient, type DailyReportIdsStreamClientOptions, type DailyReportIdsStreamPhase, type DailyReportIdsStreamState, DailyReportIdsStreamStatus, type DailyReportLabelOverrides, type DailyReportLabels, DailyReportList, DailyReportLoadError, DailyReportLoading, type DailyReportLocale, type DailyReportOperation, DailyReportPage, type DailyReportPageProps, DailyReportPostedComment, DailyReportResolvedContent, type DailyReportSseConnectionStatus, EMPTY_DETAIL, EMPTY_ITEM, FAST_SCROLL_INERTIA_OPTIONS, FAST_SCROLL_WHEEL_MULTIPLIER, ITEM_CONTAINER_HEIGHT, ITEM_VERTICAL_PADDING, MAX_PREVIEW_LINES, PREFETCH_LOOKAHEAD, PREFETCH_MAX_DATES, SCROLL_BAR_WIDTH, SSE_INITIAL_CONNECT_DEFER_MS, type SourceTypeConfig, TAP_SCROLL_CIRCLE_OPTIONS, UnreadIndicator, type UseDailyReportSseConnectionOptions, VIRTUAL_SCROLL_OVERSCAN_COUNT, WHEEL_RESET_TIMEOUT_MS, acquireMutationLock, applyBroadcastReportUpdate, applyDailyReportServerUpdates, bootstrapDailyReportIdsStreamSession, clearDailyReportCache, createDailyReportClientLoader, dailyReportShouldRevalidate, defaultDailyReportClientConfig, deleteDailyReportCache, ensureDailyReportIdsStreamSession, getCachedReport, getDailyReportIdsStreamSessionUserKey, primeDailyReportIdsStreamSession, refreshDailyReportIdsStream, registerRecentDeletion, releaseMutationLock, removeDailyReportIdsStreamItem, resetDailyReportIdsStreamSessionForTesting, resolveDailyReportLabels, resolveSourceTypeConfig, resyncDailyReportIdsStream, retryDailyReportIdsStream, subscribeCacheReady, updateDailyReportCache, upsertDailyReportIdsStreamItem, useAnimatedNumber, useDailyReportActionContext, useDailyReportComments, useDailyReportConfig, useDailyReportDetail, useDailyReportErrorSurface, useDailyReportIdsStream, useDailyReportPrefetch, useDailyReportSseConnection, useDynamicViewportHeight, writeCache };