@aiquants/daily-report 0.31.0 → 0.33.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,9 +1,9 @@
1
1
  import * as react from "react";
2
2
  import { RefObject, ReactNode, Context } from "react";
3
- import { D as DailyReportItem, a as DailyReportUser, b as DailyReportDetail } from "./types-DkERw8NE.mjs";
3
+ import { D as DailyReportItem, a as DailyReportUser, b as DailyReportSseTerminalEvent, c as DailyReportSseMessage, d as DailyReportDetail } from "./sse-schema-DcOgQr_O.mjs";
4
4
  import { VirtualScrollLocale, VirtualScrollLabels, VirtualScrollHandle } from "@aiquants/virtualscroll";
5
5
  import { UseReopeningEventSourceResult } from "@aiquants/sse/react";
6
- import { D as DailyReportSseTerminalEvent, a as DailyReportSseMessage, U as UIComment, b as DailyReportSseStreamAnchor } from "./ids-stream-DvB2h1dj.mjs";
6
+ import { U as UIComment, D as DailyReportSseStreamAnchor } from "./ids-stream-CyK2upgD.mjs";
7
7
  import { ShouldRevalidateFunction } from "react-router";
8
8
  import "zod";
9
9
  type DailyReportAttachmentIndicatorProps = {
@@ -41,8 +41,20 @@ type DailyReportListProps = {
41
41
  scrollOffsetRef?: RefObject<number>;
42
42
  };
43
43
  declare const DailyReportList: (props: DailyReportListProps) => react.JSX.Element;
44
+ declare const DAILY_REPORT_ACTION_INTENTS: readonly [
45
+ "create",
46
+ "update",
47
+ "publish",
48
+ "delete",
49
+ "toggleStar",
50
+ "toggleRead",
51
+ "addComment",
52
+ "deleteComment",
53
+ "clearCache"
54
+ ];
55
+ type DailyReportActionIntent = (typeof DAILY_REPORT_ACTION_INTENTS)[number];
44
56
  type DailyReportLocale = VirtualScrollLocale;
45
- type DailyReportOperation = "create" | "update" | "publish" | "delete" | "addComment" | "deleteComment" | "toggleStar" | "toggleRead";
57
+ type DailyReportOperation = Exclude<DailyReportActionIntent, "clearCache">;
46
58
  type DailyReportLabels = VirtualScrollLabels & {
47
59
  readonly id: string;
48
60
  readonly businessDate: string;
@@ -307,26 +319,16 @@ type UseDailyReportSseConnectionOptions = {
307
319
  };
308
320
  declare const useDailyReportSseConnection: ({ isSseEnabled, onMessage }: UseDailyReportSseConnectionOptions) => DailyReportSseConnectionStatus;
309
321
  type ReportBusinessDate = DailyReportDetail["date"];
310
- type DailyReportActionContextType = {
311
- user?: DailyReportUser;
312
- pendingAddCommentIds: React.MutableRefObject<Map<number, Map<number, string>>>;
313
- pendingDeleteCommentIds: React.MutableRefObject<Map<number, Set<number>>>;
314
- pendingStarUpdates: React.MutableRefObject<Map<number, boolean>>;
315
- pendingReadUpdates: React.MutableRefObject<Map<number, boolean>>;
316
- resolvedIdMap: React.MutableRefObject<Map<number, number>>;
317
- version: number;
318
- items: DailyReportItem[];
319
- isSseEnabled: boolean;
322
+ type DailyReportActionFunctions = {
320
323
  toggleSse: () => void;
321
- sseStatus: DailyReportSseConnectionStatus;
322
324
  addComment: (reportHubId: number, content: string, businessDate: ReportBusinessDate) => Promise<void>;
323
325
  deleteComment: (reportHubId: number, commentId: number, businessDate: ReportBusinessDate) => Promise<void>;
324
326
  toggleStar: (reportHubId: number, isStarred: boolean, businessDate: ReportBusinessDate) => Promise<void>;
325
327
  toggleRead: (reportHubId: number, isRead: boolean, businessDate: ReportBusinessDate) => Promise<void>;
326
328
  createReport: (businessDate: string) => Promise<number>;
327
329
  updateReport: (reportHubId: number, data: {
328
- title?: string;
329
- content?: string;
330
+ title: string;
331
+ content: string;
330
332
  }, businessDate: ReportBusinessDate) => Promise<void>;
331
333
  publishReport: (reportHubId: number, businessDate: ReportBusinessDate) => Promise<void>;
332
334
  deleteReport: (reportHubId: number, businessDate: ReportBusinessDate) => Promise<void>;
@@ -334,8 +336,26 @@ type DailyReportActionContextType = {
334
336
  refetchData: () => Promise<void>;
335
337
  clearCacheAndRefetch: () => Promise<void>;
336
338
  };
339
+ type DailyReportActionLedgers = {
340
+ pendingAddCommentIds: React.MutableRefObject<Map<number, Map<number, string>>>;
341
+ pendingDeleteCommentIds: React.MutableRefObject<Map<number, Set<number>>>;
342
+ pendingStarUpdates: React.MutableRefObject<Map<number, boolean>>;
343
+ pendingReadUpdates: React.MutableRefObject<Map<number, boolean>>;
344
+ resolvedIdMap: React.MutableRefObject<Map<number, number>>;
345
+ };
346
+ type DailyReportActions = DailyReportActionFunctions & DailyReportActionLedgers & {
347
+ user?: DailyReportUser;
348
+ };
349
+ type DailyReportActionState = {
350
+ version: number;
351
+ items: DailyReportItem[];
352
+ isSseEnabled: boolean;
353
+ sseStatus: DailyReportSseConnectionStatus;
354
+ };
355
+ type DailyReportActionContextType = DailyReportActions & DailyReportActionState;
337
356
  declare global {
338
- var __DailyReportActionContext: Context<DailyReportActionContextType | null> | undefined;
357
+ var __DailyReportActionsContext: Context<DailyReportActions | null> | undefined;
358
+ var __DailyReportActionStateContext: Context<DailyReportActionState | null> | undefined;
339
359
  }
340
360
  declare const useDailyReportActionContext: () => DailyReportActionContextType;
341
361
  declare const DailyReportActionProvider: ({ children, user, userId }: {
@@ -394,7 +414,6 @@ type DailyReportIdsStreamItemsChange = {
394
414
  };
395
415
  type DailyReportIdsStreamPhase = "idle" | "streaming" | "retrying" | "complete" | "failed" | "auth-required";
396
416
  type DailyReportIdsStreamState = {
397
- items: DailyReportItem[];
398
417
  loadedCount: number;
399
418
  itemsRevision: number;
400
419
  itemsChanges: readonly DailyReportIdsStreamItemsChange[];
@@ -460,6 +479,7 @@ declare class DailyReportIdsStreamClient {
460
479
  applyExternalUpsert(item: DailyReportItem): void;
461
480
  applyExternalRemoval(reportHubId: number): void;
462
481
  has(reportHubId: number): boolean;
482
+ readItems(): DailyReportItem[];
463
483
  dispose(): void;
464
484
  private runStreamLoop;
465
485
  private pruneUnseenItems;
package/dist/client.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from "react";
2
2
  import { RefObject, ReactNode, Context } from "react";
3
- import { D as DailyReportItem, a as DailyReportUser, b as DailyReportDetail } from "./types-DkERw8NE.js";
3
+ import { D as DailyReportItem, a as DailyReportUser, b as DailyReportSseTerminalEvent, c as DailyReportSseMessage, d as DailyReportDetail } from "./sse-schema-DcOgQr_O.js";
4
4
  import { VirtualScrollLocale, VirtualScrollLabels, VirtualScrollHandle } from "@aiquants/virtualscroll";
5
5
  import { UseReopeningEventSourceResult } from "@aiquants/sse/react";
6
- import { D as DailyReportSseTerminalEvent, a as DailyReportSseMessage, U as UIComment, b as DailyReportSseStreamAnchor } from "./ids-stream-BR5RSj5u.js";
6
+ import { U as UIComment, D as DailyReportSseStreamAnchor } from "./ids-stream-CtlszCHr.js";
7
7
  import { ShouldRevalidateFunction } from "react-router";
8
8
  import "zod";
9
9
  type DailyReportAttachmentIndicatorProps = {
@@ -41,8 +41,20 @@ type DailyReportListProps = {
41
41
  scrollOffsetRef?: RefObject<number>;
42
42
  };
43
43
  declare const DailyReportList: (props: DailyReportListProps) => react.JSX.Element;
44
+ declare const DAILY_REPORT_ACTION_INTENTS: readonly [
45
+ "create",
46
+ "update",
47
+ "publish",
48
+ "delete",
49
+ "toggleStar",
50
+ "toggleRead",
51
+ "addComment",
52
+ "deleteComment",
53
+ "clearCache"
54
+ ];
55
+ type DailyReportActionIntent = (typeof DAILY_REPORT_ACTION_INTENTS)[number];
44
56
  type DailyReportLocale = VirtualScrollLocale;
45
- type DailyReportOperation = "create" | "update" | "publish" | "delete" | "addComment" | "deleteComment" | "toggleStar" | "toggleRead";
57
+ type DailyReportOperation = Exclude<DailyReportActionIntent, "clearCache">;
46
58
  type DailyReportLabels = VirtualScrollLabels & {
47
59
  readonly id: string;
48
60
  readonly businessDate: string;
@@ -307,26 +319,16 @@ type UseDailyReportSseConnectionOptions = {
307
319
  };
308
320
  declare const useDailyReportSseConnection: ({ isSseEnabled, onMessage }: UseDailyReportSseConnectionOptions) => DailyReportSseConnectionStatus;
309
321
  type ReportBusinessDate = DailyReportDetail["date"];
310
- type DailyReportActionContextType = {
311
- user?: DailyReportUser;
312
- pendingAddCommentIds: React.MutableRefObject<Map<number, Map<number, string>>>;
313
- pendingDeleteCommentIds: React.MutableRefObject<Map<number, Set<number>>>;
314
- pendingStarUpdates: React.MutableRefObject<Map<number, boolean>>;
315
- pendingReadUpdates: React.MutableRefObject<Map<number, boolean>>;
316
- resolvedIdMap: React.MutableRefObject<Map<number, number>>;
317
- version: number;
318
- items: DailyReportItem[];
319
- isSseEnabled: boolean;
322
+ type DailyReportActionFunctions = {
320
323
  toggleSse: () => void;
321
- sseStatus: DailyReportSseConnectionStatus;
322
324
  addComment: (reportHubId: number, content: string, businessDate: ReportBusinessDate) => Promise<void>;
323
325
  deleteComment: (reportHubId: number, commentId: number, businessDate: ReportBusinessDate) => Promise<void>;
324
326
  toggleStar: (reportHubId: number, isStarred: boolean, businessDate: ReportBusinessDate) => Promise<void>;
325
327
  toggleRead: (reportHubId: number, isRead: boolean, businessDate: ReportBusinessDate) => Promise<void>;
326
328
  createReport: (businessDate: string) => Promise<number>;
327
329
  updateReport: (reportHubId: number, data: {
328
- title?: string;
329
- content?: string;
330
+ title: string;
331
+ content: string;
330
332
  }, businessDate: ReportBusinessDate) => Promise<void>;
331
333
  publishReport: (reportHubId: number, businessDate: ReportBusinessDate) => Promise<void>;
332
334
  deleteReport: (reportHubId: number, businessDate: ReportBusinessDate) => Promise<void>;
@@ -334,8 +336,26 @@ type DailyReportActionContextType = {
334
336
  refetchData: () => Promise<void>;
335
337
  clearCacheAndRefetch: () => Promise<void>;
336
338
  };
339
+ type DailyReportActionLedgers = {
340
+ pendingAddCommentIds: React.MutableRefObject<Map<number, Map<number, string>>>;
341
+ pendingDeleteCommentIds: React.MutableRefObject<Map<number, Set<number>>>;
342
+ pendingStarUpdates: React.MutableRefObject<Map<number, boolean>>;
343
+ pendingReadUpdates: React.MutableRefObject<Map<number, boolean>>;
344
+ resolvedIdMap: React.MutableRefObject<Map<number, number>>;
345
+ };
346
+ type DailyReportActions = DailyReportActionFunctions & DailyReportActionLedgers & {
347
+ user?: DailyReportUser;
348
+ };
349
+ type DailyReportActionState = {
350
+ version: number;
351
+ items: DailyReportItem[];
352
+ isSseEnabled: boolean;
353
+ sseStatus: DailyReportSseConnectionStatus;
354
+ };
355
+ type DailyReportActionContextType = DailyReportActions & DailyReportActionState;
337
356
  declare global {
338
- var __DailyReportActionContext: Context<DailyReportActionContextType | null> | undefined;
357
+ var __DailyReportActionsContext: Context<DailyReportActions | null> | undefined;
358
+ var __DailyReportActionStateContext: Context<DailyReportActionState | null> | undefined;
339
359
  }
340
360
  declare const useDailyReportActionContext: () => DailyReportActionContextType;
341
361
  declare const DailyReportActionProvider: ({ children, user, userId }: {
@@ -394,7 +414,6 @@ type DailyReportIdsStreamItemsChange = {
394
414
  };
395
415
  type DailyReportIdsStreamPhase = "idle" | "streaming" | "retrying" | "complete" | "failed" | "auth-required";
396
416
  type DailyReportIdsStreamState = {
397
- items: DailyReportItem[];
398
417
  loadedCount: number;
399
418
  itemsRevision: number;
400
419
  itemsChanges: readonly DailyReportIdsStreamItemsChange[];
@@ -460,6 +479,7 @@ declare class DailyReportIdsStreamClient {
460
479
  applyExternalUpsert(item: DailyReportItem): void;
461
480
  applyExternalRemoval(reportHubId: number): void;
462
481
  has(reportHubId: number): boolean;
482
+ readItems(): DailyReportItem[];
463
483
  dispose(): void;
464
484
  private runStreamLoop;
465
485
  private pruneUnseenItems;