@aiquants/daily-report 0.20.0 → 0.21.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.
Files changed (116) hide show
  1. package/README.md +229 -8
  2. package/dist/client.d.mts +201 -739
  3. package/dist/client.d.ts +201 -739
  4. package/dist/client.js +5 -6
  5. package/dist/client.mjs +5 -6
  6. package/dist/index.d.mts +5 -197
  7. package/dist/index.d.ts +5 -197
  8. package/dist/index.js +1 -2
  9. package/dist/index.mjs +1 -2
  10. package/dist/logger-D3krZrNK.d.mts +0 -14
  11. package/dist/logger-D3krZrNK.d.ts +0 -14
  12. package/dist/server.d.mts +114 -744
  13. package/dist/server.d.ts +114 -744
  14. package/dist/server.js +1 -2
  15. package/dist/server.mjs +1 -2
  16. package/dist/{sse-schema-ChSFm-4q.d.mts → sse-schema-DCxpdETM.d.mts} +1106 -1090
  17. package/dist/{sse-schema-BdUGThiz.d.ts → sse-schema-DoQw8_om.d.ts} +1106 -1090
  18. package/dist/types-CqgYQgbH.d.mts +0 -34
  19. package/dist/types-CqgYQgbH.d.ts +0 -34
  20. package/package.json +9 -10
  21. package/dist/client.js.map +0 -1
  22. package/dist/client.mjs.map +0 -1
  23. package/dist/index.js.map +0 -1
  24. package/dist/index.mjs.map +0 -1
  25. package/dist/server.js.map +0 -1
  26. package/dist/server.mjs.map +0 -1
  27. package/src/client/components/business-day-thumb-overlay.tsx +0 -19
  28. package/src/client/components/daily-report-attachment-indicator.spec.tsx +0 -51
  29. package/src/client/components/daily-report-attachment-indicator.tsx +0 -45
  30. package/src/client/components/daily-report-attachment-list.spec.tsx +0 -94
  31. package/src/client/components/daily-report-attachment-list.tsx +0 -112
  32. package/src/client/components/daily-report-comment-item.tsx +0 -89
  33. package/src/client/components/daily-report-comment-section.tsx +0 -166
  34. package/src/client/components/daily-report-detail-list.tsx +0 -842
  35. package/src/client/components/daily-report-edit-form.tsx +0 -87
  36. package/src/client/components/daily-report-ids-stream-status.spec.tsx +0 -93
  37. package/src/client/components/daily-report-ids-stream-status.tsx +0 -67
  38. package/src/client/components/daily-report-list.tsx +0 -1232
  39. package/src/client/components/daily-report-page.spec.tsx +0 -119
  40. package/src/client/components/daily-report-page.tsx +0 -140
  41. package/src/client/components/daily-report-resize-panels.spec.tsx +0 -307
  42. package/src/client/components/daily-report-resolved-content.tsx +0 -207
  43. package/src/client/components/daily-report-scroll-restoration.spec.tsx +0 -422
  44. package/src/client/components/report-views.spec.tsx +0 -375
  45. package/src/client/components/unread-indicator.tsx +0 -13
  46. package/src/client/config-context.tsx +0 -184
  47. package/src/client/contexts/daily-report-action-context.spec.tsx +0 -433
  48. package/src/client/contexts/daily-report-action-context.tsx +0 -1147
  49. package/src/client/contexts/daily-report-error-context.spec.tsx +0 -66
  50. package/src/client/contexts/daily-report-error-context.tsx +0 -98
  51. package/src/client/hooks/use-animated-number.spec.ts +0 -103
  52. package/src/client/hooks/use-animated-number.ts +0 -69
  53. package/src/client/hooks/use-daily-report-comments.ts +0 -73
  54. package/src/client/hooks/use-daily-report-sse-connection.ts +0 -86
  55. package/src/client/hooks/use-daily-report.spec.ts +0 -546
  56. package/src/client/hooks/use-daily-report.ts +0 -549
  57. package/src/client/hooks/use-dynamic-viewport-height.ts +0 -127
  58. package/src/client/hooks/use-responsive-layout.spec.ts +0 -74
  59. package/src/client/hooks/use-responsive-layout.ts +0 -63
  60. package/src/client/route-helpers.spec.ts +0 -100
  61. package/src/client/route-helpers.ts +0 -61
  62. package/src/client/streaming/daily-report-ids-stream-client.spec.ts +0 -910
  63. package/src/client/streaming/daily-report-ids-stream-client.ts +0 -730
  64. package/src/client/streaming/daily-report-ids-stream-session.spec.ts +0 -401
  65. package/src/client/streaming/daily-report-ids-stream-session.ts +0 -319
  66. package/src/client/ui/button.tsx +0 -42
  67. package/src/client/ui/cn.ts +0 -14
  68. package/src/client/ui/input.tsx +0 -21
  69. package/src/client/ui/label.tsx +0 -16
  70. package/src/client/ui/switch.tsx +0 -19
  71. package/src/client/ui/tabs.tsx +0 -40
  72. package/src/client/ui/textarea.tsx +0 -19
  73. package/src/client/utils/constants.spec.ts +0 -96
  74. package/src/client/utils/constants.ts +0 -84
  75. package/src/client.ts +0 -28
  76. package/src/index.ts +0 -11
  77. package/src/lucide-icons.d.ts +0 -6
  78. package/src/server/authz.spec.ts +0 -57
  79. package/src/server/authz.ts +0 -99
  80. package/src/server/cache.spec.ts +0 -556
  81. package/src/server/cache.ts +0 -303
  82. package/src/server/etag.ts +0 -18
  83. package/src/server/external-source.ts +0 -60
  84. package/src/server/handlers.action.spec.ts +0 -44
  85. package/src/server/handlers.attachment.spec.ts +0 -470
  86. package/src/server/handlers.ids-stream.spec.ts +0 -618
  87. package/src/server/handlers.ts +0 -1638
  88. package/src/server/handlers.unauthorized-cookie.spec.ts +0 -187
  89. package/src/server/handlers.visibility.spec.ts +0 -774
  90. package/src/server/ports.ts +0 -222
  91. package/src/server/response.ts +0 -37
  92. package/src/server/schema.spec.ts +0 -30
  93. package/src/server/schema.ts +0 -344
  94. package/src/server/service.spec.ts +0 -1130
  95. package/src/server/service.ts +0 -2045
  96. package/src/server/sse-reader.spec.ts +0 -302
  97. package/src/server/sse-reader.ts +0 -267
  98. package/src/server/test-helpers/handlers-config.ts +0 -321
  99. package/src/server/transaction-retry.spec.ts +0 -63
  100. package/src/server/visibility.spec.ts +0 -403
  101. package/src/server/visibility.ts +0 -373
  102. package/src/server.spec.ts +0 -160
  103. package/src/server.ts +0 -131
  104. package/src/shared/business-date.spec.ts +0 -82
  105. package/src/shared/business-date.ts +0 -104
  106. package/src/shared/comment-adapter.spec.ts +0 -38
  107. package/src/shared/comment-adapter.ts +0 -80
  108. package/src/shared/ids-stream.spec.ts +0 -154
  109. package/src/shared/ids-stream.ts +0 -279
  110. package/src/shared/logger.ts +0 -47
  111. package/src/shared/sse-schema.spec.ts +0 -50
  112. package/src/shared/sse-schema.ts +0 -198
  113. package/src/shared/text-utils.spec.ts +0 -42
  114. package/src/shared/text-utils.ts +0 -65
  115. package/src/shared/types.ts +0 -109
  116. package/src/styles/standalone.entry.css +0 -51
package/dist/index.d.mts CHANGED
@@ -1,231 +1,39 @@
1
- export { D as DailyReportSseMessage, U as UIComment, c as commentAddMessageSchema, a as commentDeleteMessageSchema, b as connectedMessageSchema, d as dailyReportAttachmentItemSchema, e as dailyReportDetailSchema, f as dailyReportExternalCommentSchema, g as dailyReportInterviewerSchema, h as dailyReportLabelDefSchema, i as dailyReportPostedCommentSchema, j as dailyReportSseMessageSchema, m as mergeComments, r as reportCreateMessageSchema, k as reportDeleteMessageSchema, l as reportPublishMessageSchema, n as reportUpdateMessageSchema, o as resolveCommentColorClass, s as statusUpdateMessageSchema } from './sse-schema-ChSFm-4q.mjs';
2
- import { a as DailyReportItem } from './types-CqgYQgbH.mjs';
3
- export { d as DailyReportAttachmentState, D as DailyReportAttachmentSummary, b as DailyReportDetail, e as DailyReportExternalComment, f as DailyReportInterviewer, g as DailyReportLabelDef, h as DailyReportPostedComment, c as DailyReportUser } from './types-CqgYQgbH.mjs';
4
- export { D as DailyReportLogger, L as LogLevel, c as createLogger } from './logger-D3krZrNK.mjs';
5
- import 'zod';
6
-
7
- /**
8
- * Business date normalization and formatting helper functions.
9
- * 営業日の正規化とフォーマットを支援するユーティリティ群。
10
- */
1
+ export { D as DailyReportSseMessage, U as UIComment, c as commentAddMessageSchema, a as commentDeleteMessageSchema, b as connectedMessageSchema, d as dailyReportAttachmentItemSchema, e as dailyReportDetailSchema, f as dailyReportExternalCommentSchema, g as dailyReportInterviewerSchema, h as dailyReportLabelDefSchema, i as dailyReportPostedCommentSchema, j as dailyReportSseMessageSchema, m as mergeComments, r as reportCreateMessageSchema, k as reportDeleteMessageSchema, l as reportPublishMessageSchema, n as reportUpdateMessageSchema, o as resolveCommentColorClass, s as statusUpdateMessageSchema } from "./sse-schema-DCxpdETM.mjs";
2
+ import { a as DailyReportItem } from "./types-CqgYQgbH.mjs";
3
+ export { d as DailyReportAttachmentState, D as DailyReportAttachmentSummary, b as DailyReportDetail, e as DailyReportExternalComment, f as DailyReportInterviewer, g as DailyReportLabelDef, h as DailyReportPostedComment, c as DailyReportUser } from "./types-CqgYQgbH.mjs";
4
+ export { D as DailyReportLogger, L as LogLevel, c as createLogger } from "./logger-D3krZrNK.mjs";
5
+ import "zod";
11
6
  type BusinessDateInput = string | Date | null | undefined;
12
- /**
13
- * Returns today's business-date key (YYYY-MM-DD) in the local calendar.
14
- * ローカルカレンダー上の「本日」の営業日キー (YYYY-MM-DD) を返す。
15
- *
16
- * `new Date().toISOString()` の日付部は UTC 日付になり、UTC より東のタイムゾーン
17
- * (JST など) では深夜〜午前帯に前日へずれる。営業日はブラウザのローカル暦日で判定する
18
- * ため、ローカル getter から直接組む。タイムゾーンはパッケージに固定しない (消費側の
19
- * 実行環境が決める) 方針に沿う。
20
- *
21
- * @param now Clock injection for tests (defaults to the current time). テスト用の時刻注入 (既定は現在時刻)。
22
- * @returns Local calendar day as YYYY-MM-DD. ローカル暦日の YYYY-MM-DD。
23
- */
24
7
  declare const resolveTodayBusinessDateKey: (now?: Date) => string;
25
- /**
26
- * Normalizes business date input into YYYY-MM-DD format string.
27
- * 営業日を YYYY-MM-DD 形式の文字列へ正規化する。
28
- */
29
8
  declare const normalizeBusinessDateKey: (value: BusinessDateInput) => string | null;
30
- /**
31
- * Converts normalized business date into display format YYYY-MM-DD.
32
- * 正規化済みの営業日を YYYY-MM-DD 形式の表示文字列へ変換する。
33
- */
34
9
  declare const formatBusinessDateDisplay: (value: BusinessDateInput) => string | null;
35
- /**
36
- * Parses normalized business date into Date object.
37
- * 正規化した営業日を Date オブジェクトへ変換する。
38
- */
39
10
  declare const parseBusinessDateKeyToDate: (value: BusinessDateInput) => Date | null;
40
-
41
- /**
42
- * Wire contract and ordering helpers for the daily-report ids NDJSON stream.
43
- * 日報 ID 一覧 NDJSON ストリームのワイヤ契約と並び順ヘルパー。
44
- *
45
- * サーバーは `GET {apiBasePath}/ids-stream` で 1 行 1 JSON の NDJSON を返す。
46
- * 行は原則 {@link DailyReportIdsStreamChunkLine} で、送出中に予期しない失敗が
47
- * 起きた場合のみ {@link DailyReportIdsStreamErrorLine} を 1 行流して正常クローズする
48
- * (クライアントは「isLast 無しで終端」を再開シグナルとして扱う)。
49
- *
50
- * 並び順は SQL の `ORDER BY business_date DESC, id DESC` (MSSQL の DESC は NULL を
51
- * 末尾に置く) と完全一致させる。カーソル再開はこの全順序に対する「厳密に後」の
52
- * 位置からのスライスとして定義する。
53
- */
54
-
55
- /** ストリーム再開カーソル。直前チャンク末尾アイテムの並び順キー。 */
56
11
  type DailyReportIdsStreamCursor = {
57
- /** 営業日 (YYYY-MM-DD)。null は「営業日なし領域」(並び順の末尾) を表す。 */
58
12
  businessDate: string | null;
59
- /** 日報 Hub ID。 */
60
13
  reportHubId: number;
61
14
  };
62
- /** データを運ぶ NDJSON 行。 */
63
15
  type DailyReportIdsStreamChunkLine = {
64
- /**
65
- * 行種別。判別可能ユニオンの識別子。
66
- *
67
- * ❗ 行の意味は `kind` が宣言する。「`items` を持つかどうか」で判定していた時代は、
68
- * 新しい行種別を足すと既存クライアントがそれをエラー行と解釈して走査を中断した。
69
- * `kind` を欠く行は本識別子の導入前の送信元とみなし、分類器が従来判定へ落とす。
70
- */
71
16
  kind: "chunk";
72
- /** このチャンクのアイテム群 (並び順どおり)。 */
73
17
  items: DailyReportItem[];
74
- /** 次チャンクの再開カーソル。最終チャンクでは null。 */
75
18
  nextCursor: DailyReportIdsStreamCursor | null;
76
- /** これが最終チャンクかどうか。 */
77
19
  isLast: boolean;
78
- /** 全体件数。接続ごとの先頭行にのみ載る。 */
79
20
  total?: number;
80
- /**
81
- * この行が**暫定** (未確認スナップショット) かどうか。既定 (未指定) は権威。
82
- *
83
- * 高速先頭ページは全量配列とは別のスナップショットなので、そのまま「観測した」と
84
- * 扱うと、送出後に消えた行が完走剪定を免れて幽霊行になる。暫定行はクライアント側で
85
- * 描画はするが観測集合へ刻まないため、権威パス (全量配列を先頭から流し直す) に
86
- * 現れなかった行が完走時に正確に落ちる。
87
- *
88
- * ❗ 暫定行には `nextCursor` を載せない (常に null)。未確認領域を指すカーソルで再開すると、
89
- * 三つ目のスナップショットへ継ぎ目が移るだけになる。
90
- */
91
21
  provisional?: boolean;
92
- /**
93
- * この行を切り出した全量配列の同一性トークン ({@link computeIdsStreamSnapshotToken})。
94
- *
95
- * クライアントは再接続時にカーソルと**対で**送り返し、サーバーは現在の配列のトークンと
96
- * 照合して、同じ配列のときだけカーソルを信用する。別の配列にカーソルを当てると、
97
- * カーソルより前に入った行が丸ごと飛ぶ (再接続のたびの欠損)。
98
- *
99
- * ❗ resume 経路を含む**全ての権威行**に載せる。載せ忘れると最初の再開成功でクライアントの
100
- * トークンが失われ、2 度目以降の切断が全て全量再送へ退化する。
101
- * ❗ 暫定行と短絡行には載せない (全量配列を代表しないため、再開起点にしてはならない)。
102
- */
103
22
  snapshot?: string;
104
- /**
105
- * 送られたカーソルを破棄して先頭から流し直したことの明示 (先頭行にのみ載る)。
106
- *
107
- * クライアントはこれを受けたらカーソル・トークン・観測集合・トゥームストーンを初期化する
108
- * (処理は行の吸収関数の内部で行われ、呼び出し側に順序の自由度は無い)。
109
- */
110
23
  restarted?: boolean;
111
24
  };
112
- /** サーバー側の予期しない失敗を伝える NDJSON 行 (内部情報は含めない)。 */
113
25
  type DailyReportIdsStreamErrorLine = {
114
- /** 行種別。判別可能ユニオンの識別子。 */
115
26
  kind: "error";
116
27
  error: string;
117
28
  };
118
- /** NDJSON 1 行のユニオン。 */
119
29
  type DailyReportIdsStreamLine = DailyReportIdsStreamChunkLine | DailyReportIdsStreamErrorLine;
120
- /**
121
- * Classifies one parsed NDJSON line by its declared kind.
122
- * パース済みの NDJSON 行を宣言された種別で分類する処理。
123
- *
124
- * クライアントとテストはこの分類器**だけ**を使う。契約:
125
- *
126
- * - `"chunk"` / `"error"`: 宣言どおりに扱う。
127
- * - **未知の `kind` は `"unknown"`** — 将来のワイヤ拡張であり、エラー扱いすると
128
- * 走査が中断する (旧判定の罠が 1 段上で再発する)。呼び出し側は警告して読み飛ばす。
129
- * - `kind` を欠く行は本識別子の導入前の送信元 (配備入れ替わり窓)。従来判定
130
- * (`items` 配列の有無 → チャンク、`error` 文字列 → エラー) へ落とす。
131
- *
132
- * @param line Parsed NDJSON line. パース済みの NDJSON 行。
133
- * @returns Line classification. 行の分類。
134
- */
135
30
  declare const classifyIdsStreamLine: (line: unknown) => "chunk" | "error" | "unknown";
136
- /**
137
- * Type guard for chunk lines (thin wrapper over the classifier).
138
- * チャンク行の型ガード ({@link classifyIdsStreamLine} の薄い包み)。
139
- *
140
- * @param line Parsed NDJSON line. パース済みの NDJSON 行。
141
- * @returns True when the line is a chunk line. チャンク行なら true。
142
- */
143
31
  declare const isIdsStreamChunkLine: (line: unknown) => line is DailyReportIdsStreamChunkLine;
144
- /**
145
- * Computes the identity token of a materialized ids array.
146
- * 確定済み ids 配列の同一性トークンを算出する処理。
147
- *
148
- * 内容から決まる値にする — プロセスごとにキャッシュバケットが別なので、別ワーカーが
149
- * 応答しても同じ配列なら同じトークンにならなければならない。畳み込むのは各行の
150
- * `reportHubId` と `businessDate` (= カーソルの位置を決める全順序の構成要素) + 件数。
151
- * `sourceType` は順序に関与しないため畳み込まない (変わっても位置は不変)。
152
- *
153
- * ❗ 衝突の方向を取り違えないこと。決定的ハッシュに「同じ配列なのに別トークン」(偽不一致 =
154
- * 無駄な再送) は構造上起こり得ない。危険なのはその逆 — **異なる配列が同一トークンになる
155
- * 偽一致**であり、その場合カーソルが変化後の配列に対して信用され、欠損・重複が無音で発生する
156
- * (認可には影響しない — 再開行は常に現在の認可済み配列から切り出される)。この確率を議論の
157
- * 余地なく無視できる水準 (~2^-64) にするため、オフセット基底の異なる FNV-1a 32bit を
158
- * 2 レーン走らせて連結する。費用は 22 万件で数 ms。
159
- *
160
- * @param items Stream-ordered items. ストリーム順のアイテム配列。
161
- * @returns Hex token (up to 16 chars). 16 進トークン (最長 16 桁)。
162
- */
163
32
  declare const computeIdsStreamSnapshotToken: (items: readonly DailyReportItem[]) => string;
164
- /**
165
- * Total order of the ids stream: businessDate DESC (NULL last), then id DESC.
166
- * ids ストリームの全順序。営業日降順 (NULL は末尾)、同日内は ID 降順。
167
- *
168
- * MSSQL の `ORDER BY business_date DESC, id DESC` と一致させることが唯一の存在理由。
169
- * 営業日は正規化済みの `YYYY-MM-DD` 文字列なので辞書順比較 = 時系列比較になる。
170
- *
171
- * @param a Left key. 左辺キー。
172
- * @param b Right key. 右辺キー。
173
- * @returns Negative when `a` streams before `b`. `a` が先に流れるなら負値。
174
- */
175
33
  declare const compareIdsStreamOrder: (a: DailyReportIdsStreamCursor, b: DailyReportIdsStreamCursor) => number;
176
- /**
177
- * Checks whether items already follow the ids-stream total order.
178
- * アイテム配列が ids ストリームの全順序に既に従っているかを検査する処理。
179
- *
180
- * ストリームはソート順どおりに届いて末尾へ追記されるため通常は整列済みで、
181
- * この O(n) 検査で全件ソート (O(n log n)) を省略できる。
182
- *
183
- * @param items Items to probe. 検査対象のアイテム配列。
184
- * @returns True when already ordered. 整列済みなら true。
185
- */
186
34
  declare const isIdsStreamOrdered: (items: readonly DailyReportItem[]) => boolean;
187
- /**
188
- * Returns a copy with the item upserted at its ids-stream-ordered position.
189
- * アイテムを ids ストリーム順の正しい位置へ upsert した複製配列を返す処理。
190
- *
191
- * 前提: `items` は ids ストリーム順に整列済み (このモジュールの比較器を使う全書き込み元が
192
- * 維持する不変条件)。既存の同 ID は除去してから二分探索で挿入位置を求めるため、
193
- * 全件ソート無しの O(n) で並び順を保てる (以前は SSE 1 件ごとに 20 万件超を
194
- * localeCompare で全ソートしていた)。
195
- *
196
- * @param items Ordered items. 整列済みアイテム配列。
197
- * @param item Item to upsert. upsert するアイテム。
198
- * @returns New ordered array. 新しい整列済み配列。
199
- */
200
35
  declare const upsertInIdsStreamOrder: (items: readonly DailyReportItem[], item: DailyReportItem) => DailyReportItem[];
201
- /**
202
- * Finds the first index that streams strictly after the cursor.
203
- * カーソルより厳密に後ろへ並ぶ最初のインデックスを求める処理。
204
- *
205
- * 配列は必ずストリーム順 (SQL の ORDER BY) で渡されるが、比較器とのズレが
206
- * あっても壊れない線形走査で決定する (件数は高々数万・再開時のみの実行)。
207
- * 該当なし (カーソルが末尾以降) は `items.length` を返し、空チャンク +
208
- * `isLast: true` の正常終端に落ちる。
209
- *
210
- * @param items Stream-ordered items. ストリーム順のアイテム配列。
211
- * @param cursor Resume cursor. 再開カーソル。
212
- * @returns Index to resume emission from. 送出を再開するインデックス。
213
- */
214
36
  declare const findIdsStreamResumeIndex: (items: readonly DailyReportItem[], cursor: DailyReportIdsStreamCursor) => number;
215
-
216
- /**
217
- * Shared text helpers for daily report view components.
218
- * 日報ビューコンポーネント向けの共通テキストヘルパー。
219
- */
220
- /**
221
- * Normalizes nullable text by trimming whitespace and applying fallback.
222
- * null 許容の文字列をトリムしつつフォールバック値を適用する関数。
223
- */
224
37
  declare const fallbackText: (value: string | null | undefined) => string;
225
- /**
226
- * Formats a date string to ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss).
227
- * 日付文字列を ISO 8601 形式 (YYYY-MM-DD または YYYY-MM-DDTHH:mm:ss) に整形する関数。
228
- */
229
38
  declare const formatToIsoDate: (value: unknown) => string;
230
-
231
39
  export { type DailyReportIdsStreamChunkLine, type DailyReportIdsStreamCursor, type DailyReportIdsStreamErrorLine, type DailyReportIdsStreamLine, DailyReportItem, classifyIdsStreamLine, compareIdsStreamOrder, computeIdsStreamSnapshotToken, fallbackText, findIdsStreamResumeIndex, formatBusinessDateDisplay, formatToIsoDate, isIdsStreamChunkLine, isIdsStreamOrdered, normalizeBusinessDateKey, parseBusinessDateKeyToDate, resolveTodayBusinessDateKey, upsertInIdsStreamOrder };
package/dist/index.d.ts CHANGED
@@ -1,231 +1,39 @@
1
- export { D as DailyReportSseMessage, U as UIComment, c as commentAddMessageSchema, a as commentDeleteMessageSchema, b as connectedMessageSchema, d as dailyReportAttachmentItemSchema, e as dailyReportDetailSchema, f as dailyReportExternalCommentSchema, g as dailyReportInterviewerSchema, h as dailyReportLabelDefSchema, i as dailyReportPostedCommentSchema, j as dailyReportSseMessageSchema, m as mergeComments, r as reportCreateMessageSchema, k as reportDeleteMessageSchema, l as reportPublishMessageSchema, n as reportUpdateMessageSchema, o as resolveCommentColorClass, s as statusUpdateMessageSchema } from './sse-schema-BdUGThiz.js';
2
- import { a as DailyReportItem } from './types-CqgYQgbH.js';
3
- export { d as DailyReportAttachmentState, D as DailyReportAttachmentSummary, b as DailyReportDetail, e as DailyReportExternalComment, f as DailyReportInterviewer, g as DailyReportLabelDef, h as DailyReportPostedComment, c as DailyReportUser } from './types-CqgYQgbH.js';
4
- export { D as DailyReportLogger, L as LogLevel, c as createLogger } from './logger-D3krZrNK.js';
5
- import 'zod';
6
-
7
- /**
8
- * Business date normalization and formatting helper functions.
9
- * 営業日の正規化とフォーマットを支援するユーティリティ群。
10
- */
1
+ export { D as DailyReportSseMessage, U as UIComment, c as commentAddMessageSchema, a as commentDeleteMessageSchema, b as connectedMessageSchema, d as dailyReportAttachmentItemSchema, e as dailyReportDetailSchema, f as dailyReportExternalCommentSchema, g as dailyReportInterviewerSchema, h as dailyReportLabelDefSchema, i as dailyReportPostedCommentSchema, j as dailyReportSseMessageSchema, m as mergeComments, r as reportCreateMessageSchema, k as reportDeleteMessageSchema, l as reportPublishMessageSchema, n as reportUpdateMessageSchema, o as resolveCommentColorClass, s as statusUpdateMessageSchema } from "./sse-schema-DoQw8_om.js";
2
+ import { a as DailyReportItem } from "./types-CqgYQgbH.js";
3
+ export { d as DailyReportAttachmentState, D as DailyReportAttachmentSummary, b as DailyReportDetail, e as DailyReportExternalComment, f as DailyReportInterviewer, g as DailyReportLabelDef, h as DailyReportPostedComment, c as DailyReportUser } from "./types-CqgYQgbH.js";
4
+ export { D as DailyReportLogger, L as LogLevel, c as createLogger } from "./logger-D3krZrNK.js";
5
+ import "zod";
11
6
  type BusinessDateInput = string | Date | null | undefined;
12
- /**
13
- * Returns today's business-date key (YYYY-MM-DD) in the local calendar.
14
- * ローカルカレンダー上の「本日」の営業日キー (YYYY-MM-DD) を返す。
15
- *
16
- * `new Date().toISOString()` の日付部は UTC 日付になり、UTC より東のタイムゾーン
17
- * (JST など) では深夜〜午前帯に前日へずれる。営業日はブラウザのローカル暦日で判定する
18
- * ため、ローカル getter から直接組む。タイムゾーンはパッケージに固定しない (消費側の
19
- * 実行環境が決める) 方針に沿う。
20
- *
21
- * @param now Clock injection for tests (defaults to the current time). テスト用の時刻注入 (既定は現在時刻)。
22
- * @returns Local calendar day as YYYY-MM-DD. ローカル暦日の YYYY-MM-DD。
23
- */
24
7
  declare const resolveTodayBusinessDateKey: (now?: Date) => string;
25
- /**
26
- * Normalizes business date input into YYYY-MM-DD format string.
27
- * 営業日を YYYY-MM-DD 形式の文字列へ正規化する。
28
- */
29
8
  declare const normalizeBusinessDateKey: (value: BusinessDateInput) => string | null;
30
- /**
31
- * Converts normalized business date into display format YYYY-MM-DD.
32
- * 正規化済みの営業日を YYYY-MM-DD 形式の表示文字列へ変換する。
33
- */
34
9
  declare const formatBusinessDateDisplay: (value: BusinessDateInput) => string | null;
35
- /**
36
- * Parses normalized business date into Date object.
37
- * 正規化した営業日を Date オブジェクトへ変換する。
38
- */
39
10
  declare const parseBusinessDateKeyToDate: (value: BusinessDateInput) => Date | null;
40
-
41
- /**
42
- * Wire contract and ordering helpers for the daily-report ids NDJSON stream.
43
- * 日報 ID 一覧 NDJSON ストリームのワイヤ契約と並び順ヘルパー。
44
- *
45
- * サーバーは `GET {apiBasePath}/ids-stream` で 1 行 1 JSON の NDJSON を返す。
46
- * 行は原則 {@link DailyReportIdsStreamChunkLine} で、送出中に予期しない失敗が
47
- * 起きた場合のみ {@link DailyReportIdsStreamErrorLine} を 1 行流して正常クローズする
48
- * (クライアントは「isLast 無しで終端」を再開シグナルとして扱う)。
49
- *
50
- * 並び順は SQL の `ORDER BY business_date DESC, id DESC` (MSSQL の DESC は NULL を
51
- * 末尾に置く) と完全一致させる。カーソル再開はこの全順序に対する「厳密に後」の
52
- * 位置からのスライスとして定義する。
53
- */
54
-
55
- /** ストリーム再開カーソル。直前チャンク末尾アイテムの並び順キー。 */
56
11
  type DailyReportIdsStreamCursor = {
57
- /** 営業日 (YYYY-MM-DD)。null は「営業日なし領域」(並び順の末尾) を表す。 */
58
12
  businessDate: string | null;
59
- /** 日報 Hub ID。 */
60
13
  reportHubId: number;
61
14
  };
62
- /** データを運ぶ NDJSON 行。 */
63
15
  type DailyReportIdsStreamChunkLine = {
64
- /**
65
- * 行種別。判別可能ユニオンの識別子。
66
- *
67
- * ❗ 行の意味は `kind` が宣言する。「`items` を持つかどうか」で判定していた時代は、
68
- * 新しい行種別を足すと既存クライアントがそれをエラー行と解釈して走査を中断した。
69
- * `kind` を欠く行は本識別子の導入前の送信元とみなし、分類器が従来判定へ落とす。
70
- */
71
16
  kind: "chunk";
72
- /** このチャンクのアイテム群 (並び順どおり)。 */
73
17
  items: DailyReportItem[];
74
- /** 次チャンクの再開カーソル。最終チャンクでは null。 */
75
18
  nextCursor: DailyReportIdsStreamCursor | null;
76
- /** これが最終チャンクかどうか。 */
77
19
  isLast: boolean;
78
- /** 全体件数。接続ごとの先頭行にのみ載る。 */
79
20
  total?: number;
80
- /**
81
- * この行が**暫定** (未確認スナップショット) かどうか。既定 (未指定) は権威。
82
- *
83
- * 高速先頭ページは全量配列とは別のスナップショットなので、そのまま「観測した」と
84
- * 扱うと、送出後に消えた行が完走剪定を免れて幽霊行になる。暫定行はクライアント側で
85
- * 描画はするが観測集合へ刻まないため、権威パス (全量配列を先頭から流し直す) に
86
- * 現れなかった行が完走時に正確に落ちる。
87
- *
88
- * ❗ 暫定行には `nextCursor` を載せない (常に null)。未確認領域を指すカーソルで再開すると、
89
- * 三つ目のスナップショットへ継ぎ目が移るだけになる。
90
- */
91
21
  provisional?: boolean;
92
- /**
93
- * この行を切り出した全量配列の同一性トークン ({@link computeIdsStreamSnapshotToken})。
94
- *
95
- * クライアントは再接続時にカーソルと**対で**送り返し、サーバーは現在の配列のトークンと
96
- * 照合して、同じ配列のときだけカーソルを信用する。別の配列にカーソルを当てると、
97
- * カーソルより前に入った行が丸ごと飛ぶ (再接続のたびの欠損)。
98
- *
99
- * ❗ resume 経路を含む**全ての権威行**に載せる。載せ忘れると最初の再開成功でクライアントの
100
- * トークンが失われ、2 度目以降の切断が全て全量再送へ退化する。
101
- * ❗ 暫定行と短絡行には載せない (全量配列を代表しないため、再開起点にしてはならない)。
102
- */
103
22
  snapshot?: string;
104
- /**
105
- * 送られたカーソルを破棄して先頭から流し直したことの明示 (先頭行にのみ載る)。
106
- *
107
- * クライアントはこれを受けたらカーソル・トークン・観測集合・トゥームストーンを初期化する
108
- * (処理は行の吸収関数の内部で行われ、呼び出し側に順序の自由度は無い)。
109
- */
110
23
  restarted?: boolean;
111
24
  };
112
- /** サーバー側の予期しない失敗を伝える NDJSON 行 (内部情報は含めない)。 */
113
25
  type DailyReportIdsStreamErrorLine = {
114
- /** 行種別。判別可能ユニオンの識別子。 */
115
26
  kind: "error";
116
27
  error: string;
117
28
  };
118
- /** NDJSON 1 行のユニオン。 */
119
29
  type DailyReportIdsStreamLine = DailyReportIdsStreamChunkLine | DailyReportIdsStreamErrorLine;
120
- /**
121
- * Classifies one parsed NDJSON line by its declared kind.
122
- * パース済みの NDJSON 行を宣言された種別で分類する処理。
123
- *
124
- * クライアントとテストはこの分類器**だけ**を使う。契約:
125
- *
126
- * - `"chunk"` / `"error"`: 宣言どおりに扱う。
127
- * - **未知の `kind` は `"unknown"`** — 将来のワイヤ拡張であり、エラー扱いすると
128
- * 走査が中断する (旧判定の罠が 1 段上で再発する)。呼び出し側は警告して読み飛ばす。
129
- * - `kind` を欠く行は本識別子の導入前の送信元 (配備入れ替わり窓)。従来判定
130
- * (`items` 配列の有無 → チャンク、`error` 文字列 → エラー) へ落とす。
131
- *
132
- * @param line Parsed NDJSON line. パース済みの NDJSON 行。
133
- * @returns Line classification. 行の分類。
134
- */
135
30
  declare const classifyIdsStreamLine: (line: unknown) => "chunk" | "error" | "unknown";
136
- /**
137
- * Type guard for chunk lines (thin wrapper over the classifier).
138
- * チャンク行の型ガード ({@link classifyIdsStreamLine} の薄い包み)。
139
- *
140
- * @param line Parsed NDJSON line. パース済みの NDJSON 行。
141
- * @returns True when the line is a chunk line. チャンク行なら true。
142
- */
143
31
  declare const isIdsStreamChunkLine: (line: unknown) => line is DailyReportIdsStreamChunkLine;
144
- /**
145
- * Computes the identity token of a materialized ids array.
146
- * 確定済み ids 配列の同一性トークンを算出する処理。
147
- *
148
- * 内容から決まる値にする — プロセスごとにキャッシュバケットが別なので、別ワーカーが
149
- * 応答しても同じ配列なら同じトークンにならなければならない。畳み込むのは各行の
150
- * `reportHubId` と `businessDate` (= カーソルの位置を決める全順序の構成要素) + 件数。
151
- * `sourceType` は順序に関与しないため畳み込まない (変わっても位置は不変)。
152
- *
153
- * ❗ 衝突の方向を取り違えないこと。決定的ハッシュに「同じ配列なのに別トークン」(偽不一致 =
154
- * 無駄な再送) は構造上起こり得ない。危険なのはその逆 — **異なる配列が同一トークンになる
155
- * 偽一致**であり、その場合カーソルが変化後の配列に対して信用され、欠損・重複が無音で発生する
156
- * (認可には影響しない — 再開行は常に現在の認可済み配列から切り出される)。この確率を議論の
157
- * 余地なく無視できる水準 (~2^-64) にするため、オフセット基底の異なる FNV-1a 32bit を
158
- * 2 レーン走らせて連結する。費用は 22 万件で数 ms。
159
- *
160
- * @param items Stream-ordered items. ストリーム順のアイテム配列。
161
- * @returns Hex token (up to 16 chars). 16 進トークン (最長 16 桁)。
162
- */
163
32
  declare const computeIdsStreamSnapshotToken: (items: readonly DailyReportItem[]) => string;
164
- /**
165
- * Total order of the ids stream: businessDate DESC (NULL last), then id DESC.
166
- * ids ストリームの全順序。営業日降順 (NULL は末尾)、同日内は ID 降順。
167
- *
168
- * MSSQL の `ORDER BY business_date DESC, id DESC` と一致させることが唯一の存在理由。
169
- * 営業日は正規化済みの `YYYY-MM-DD` 文字列なので辞書順比較 = 時系列比較になる。
170
- *
171
- * @param a Left key. 左辺キー。
172
- * @param b Right key. 右辺キー。
173
- * @returns Negative when `a` streams before `b`. `a` が先に流れるなら負値。
174
- */
175
33
  declare const compareIdsStreamOrder: (a: DailyReportIdsStreamCursor, b: DailyReportIdsStreamCursor) => number;
176
- /**
177
- * Checks whether items already follow the ids-stream total order.
178
- * アイテム配列が ids ストリームの全順序に既に従っているかを検査する処理。
179
- *
180
- * ストリームはソート順どおりに届いて末尾へ追記されるため通常は整列済みで、
181
- * この O(n) 検査で全件ソート (O(n log n)) を省略できる。
182
- *
183
- * @param items Items to probe. 検査対象のアイテム配列。
184
- * @returns True when already ordered. 整列済みなら true。
185
- */
186
34
  declare const isIdsStreamOrdered: (items: readonly DailyReportItem[]) => boolean;
187
- /**
188
- * Returns a copy with the item upserted at its ids-stream-ordered position.
189
- * アイテムを ids ストリーム順の正しい位置へ upsert した複製配列を返す処理。
190
- *
191
- * 前提: `items` は ids ストリーム順に整列済み (このモジュールの比較器を使う全書き込み元が
192
- * 維持する不変条件)。既存の同 ID は除去してから二分探索で挿入位置を求めるため、
193
- * 全件ソート無しの O(n) で並び順を保てる (以前は SSE 1 件ごとに 20 万件超を
194
- * localeCompare で全ソートしていた)。
195
- *
196
- * @param items Ordered items. 整列済みアイテム配列。
197
- * @param item Item to upsert. upsert するアイテム。
198
- * @returns New ordered array. 新しい整列済み配列。
199
- */
200
35
  declare const upsertInIdsStreamOrder: (items: readonly DailyReportItem[], item: DailyReportItem) => DailyReportItem[];
201
- /**
202
- * Finds the first index that streams strictly after the cursor.
203
- * カーソルより厳密に後ろへ並ぶ最初のインデックスを求める処理。
204
- *
205
- * 配列は必ずストリーム順 (SQL の ORDER BY) で渡されるが、比較器とのズレが
206
- * あっても壊れない線形走査で決定する (件数は高々数万・再開時のみの実行)。
207
- * 該当なし (カーソルが末尾以降) は `items.length` を返し、空チャンク +
208
- * `isLast: true` の正常終端に落ちる。
209
- *
210
- * @param items Stream-ordered items. ストリーム順のアイテム配列。
211
- * @param cursor Resume cursor. 再開カーソル。
212
- * @returns Index to resume emission from. 送出を再開するインデックス。
213
- */
214
36
  declare const findIdsStreamResumeIndex: (items: readonly DailyReportItem[], cursor: DailyReportIdsStreamCursor) => number;
215
-
216
- /**
217
- * Shared text helpers for daily report view components.
218
- * 日報ビューコンポーネント向けの共通テキストヘルパー。
219
- */
220
- /**
221
- * Normalizes nullable text by trimming whitespace and applying fallback.
222
- * null 許容の文字列をトリムしつつフォールバック値を適用する関数。
223
- */
224
37
  declare const fallbackText: (value: string | null | undefined) => string;
225
- /**
226
- * Formats a date string to ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss).
227
- * 日付文字列を ISO 8601 形式 (YYYY-MM-DD または YYYY-MM-DDTHH:mm:ss) に整形する関数。
228
- */
229
38
  declare const formatToIsoDate: (value: unknown) => string;
230
-
231
39
  export { type DailyReportIdsStreamChunkLine, type DailyReportIdsStreamCursor, type DailyReportIdsStreamErrorLine, type DailyReportIdsStreamLine, DailyReportItem, classifyIdsStreamLine, compareIdsStreamOrder, computeIdsStreamSnapshotToken, fallbackText, findIdsStreamResumeIndex, formatBusinessDateDisplay, formatToIsoDate, isIdsStreamChunkLine, isIdsStreamOrdered, normalizeBusinessDateKey, parseBusinessDateKeyToDate, resolveTodayBusinessDateKey, upsertInIdsStreamOrder };
package/dist/index.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";var d=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var O=(r,e)=>{for(var n in e)d(r,n,{get:e[n],enumerable:!0})},_=(r,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of B(e))!z.call(r,s)&&s!==n&&d(r,s,{get:()=>e[s],enumerable:!(i=P(e,s))||i.enumerable});return r};var L=r=>_(d({},"__esModule",{value:!0}),r);var re={};O(re,{LogLevel:()=>b,classifyIdsStreamLine:()=>h,commentAddMessageSchema:()=>C,commentDeleteMessageSchema:()=>T,compareIdsStreamOrder:()=>u,computeIdsStreamSnapshotToken:()=>Q,connectedMessageSchema:()=>R,createLogger:()=>v,dailyReportAttachmentItemSchema:()=>k,dailyReportDetailSchema:()=>m,dailyReportExternalCommentSchema:()=>I,dailyReportInterviewerSchema:()=>D,dailyReportLabelDefSchema:()=>S,dailyReportPostedCommentSchema:()=>g,dailyReportSseMessageSchema:()=>ee,fallbackText:()=>te,findIdsStreamResumeIndex:()=>Z,formatBusinessDateDisplay:()=>Y,formatToIsoDate:()=>H,isIdsStreamChunkLine:()=>J,isIdsStreamOrdered:()=>V,mergeComments:()=>W,normalizeBusinessDateKey:()=>c,parseBusinessDateKeyToDate:()=>G,reportCreateMessageSchema:()=>M,reportDeleteMessageSchema:()=>A,reportPublishMessageSchema:()=>$,reportUpdateMessageSchema:()=>N,resolveCommentColorClass:()=>q,resolveTodayBusinessDateKey:()=>x,statusUpdateMessageSchema:()=>w,upsertInIdsStreamOrder:()=>X});module.exports=L(re);var F=/^\d{4}-\d{2}-\d{2}$/,K=/^\d{4}\/\d{2}\/\d{2}$/,l=r=>r<10?`0${r}`:`${r}`,f=r=>{if(Number.isNaN(r.getTime()))return null;let e=r.getFullYear(),n=l(r.getMonth()+1),i=l(r.getDate());return`${e}-${n}-${i}`},x=(r=new Date)=>Number.isNaN(r.getTime())?x(new Date):`${r.getFullYear()}-${l(r.getMonth()+1)}-${l(r.getDate())}`,c=r=>{if(r==null)return null;if(r instanceof Date)return f(r);let e=r.trim();if(e==="")return null;if(F.test(e))return e;if(K.test(e))return e.replaceAll("/","-");let n=new Date(e);return f(n)},Y=r=>{let e=c(r);return e||null},G=r=>{let e=c(r);if(!e)return null;let[n,i,s]=e.split("-").map(o=>Number.parseInt(o,10));return[n,i,s].some(o=>Number.isNaN(o))?null:new Date(n,i-1,s)};var W=(r,e,n)=>{let i=r.map((o,a)=>({id:`legacy-${a}`,authorName:o.name||"Unknown",content:o.text||"",isMine:!1,color:o.color||void 0,isLegacy:!0})),s=e.map(o=>({id:o.id,authorName:o.userName??"",content:o.content??"",createdAt:o.createdAt??"",isMine:n?o.userId===n:o.isMine,isLegacy:!1}));return[...i,...s]},q=r=>{if(!r)return"text-gray-700 dark:text-gray-300";let e=r.toLowerCase();return e.includes("red")||e.includes("\u8D64")?"text-red-600 dark:text-red-400":e.includes("green")||e.includes("\u7DD1")?"text-green-600 dark:text-green-400":e.includes("blue")||e.includes("\u9752")?"text-blue-600 dark:text-blue-400":e.includes("yellow")||e.includes("\u9EC4")?"text-yellow-600 dark:text-yellow-400":e.includes("orange")||e.includes("\u6A59")?"text-orange-500 dark:text-orange-400":"text-gray-700 dark:text-gray-300"};var h=r=>{if(typeof r!="object"||r===null)return"unknown";let e=r;return typeof e.kind=="string"?e.kind==="chunk"?"chunk":e.kind==="error"?"error":"unknown":Array.isArray(e.items)?"chunk":typeof e.error=="string"?"error":"unknown"},J=r=>h(r)==="chunk",Q=r=>{let e=2166136261,n=-624069552;for(let i of r){let s=i.reportHubId;e^=s&255,e=Math.imul(e,16777619),e^=s>>>8&255,e=Math.imul(e,16777619),e^=s>>>16&255,e=Math.imul(e,16777619),e^=s>>>24&255,e=Math.imul(e,16777619),n^=s>>>24&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s&255,n=Math.imul(n,16777619);let o=i.businessDate;if(o===null)e^=1,e=Math.imul(e,16777619),n^=1,n=Math.imul(n,16777619);else for(let a=0;a<o.length;a++){let p=o.charCodeAt(a);e^=p&255,e=Math.imul(e,16777619),n^=p&255,n=Math.imul(n,16777619)}}return e^=r.length,e=Math.imul(e,16777619),n^=r.length,n=Math.imul(n,16777619),((e>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")).replace(/^0+(?=.)/,"")},u=(r,e)=>r.businessDate!==e.businessDate?r.businessDate===null?1:e.businessDate===null||r.businessDate>e.businessDate?-1:1:e.reportHubId-r.reportHubId,V=r=>{for(let e=1;e<r.length;e++)if(u(r[e-1],r[e])>0)return!1;return!0},X=(r,e)=>{let n=r.filter(o=>o.reportHubId!==e.reportHubId),i=0,s=n.length;for(;i<s;){let o=i+s>>1;u(n[o],e)<=0?i=o+1:s=o}return n.splice(i,0,e),n},Z=(r,e)=>{let n=r.findIndex(i=>u({businessDate:i.businessDate,reportHubId:i.reportHubId},e)>0);return n===-1?r.length:n};var b=(o=>(o[o.DEBUG=0]="DEBUG",o[o.INFO=1]="INFO",o[o.WARN=2]="WARN",o[o.ERROR=3]="ERROR",o[o.NONE=4]="NONE",o))(b||{}),v=(r,e,n=console)=>{let i=s=>typeof s=="string"?[`${e} ${s}`]:[e,s];return{debug:(s,...o)=>{r<=0&&n.debug(...i(s),...o)},info:(s,...o)=>{r<=1&&n.info(...i(s),...o)},warn:(s,...o)=>{r<=2&&n.warn(...i(s),...o)},error:(s,...o)=>{r<=3&&n.error(...i(s),...o)}}};var t=require("zod"),D=t.z.object({name:t.z.string().nullish(),affiliation:t.z.string().nullish()}),I=t.z.object({name:t.z.string().nullish(),text:t.z.string().nullish(),color:t.z.string().nullish()}),S=t.z.object({id:t.z.number(),name:t.z.string().nullish(),color:t.z.string().nullish()}),g=t.z.object({id:t.z.number(),userId:t.z.string().nullish(),userName:t.z.string().nullish(),content:t.z.string().nullish(),createdAt:t.z.string().nullish(),isMine:t.z.boolean()}),k=t.z.object({id:t.z.string(),fileName:t.z.string(),fileType:t.z.string().nullable(),fileSize:t.z.number().nullable(),createdAt:t.z.string().nullable(),state:t.z.enum(["present","absent","unknown"])}),m=t.z.object({reportHubId:t.z.number(),date:t.z.string().nullish(),createdAt:t.z.string().nullish(),author:t.z.string().nullish(),userId:t.z.string().nullish(),sourceType:t.z.string().nullish(),employeeName:t.z.string().nullish(),updatedBy:t.z.string().nullish(),updatedAt:t.z.string().nullish(),category:t.z.string().nullish(),creationCategory:t.z.string().nullish(),visitTimeFrom:t.z.string().nullish(),visitTimeTo:t.z.string().nullish(),customerName:t.z.string().nullish(),interviewers:t.z.array(D),subject:t.z.string().nullish(),content:t.z.string().nullish(),externalComments:t.z.array(I),isRead:t.z.boolean(),isStarred:t.z.boolean(),labels:t.z.array(S),postedComments:t.z.array(g),attachments:t.z.array(k).default([])}),R=t.z.object({type:t.z.literal("connected")}),w=t.z.object({type:t.z.literal("status-update"),reportHubId:t.z.number(),statusType:t.z.enum(["star","read"]),value:t.z.boolean(),clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),y=t.z.string().optional(),C=t.z.object({type:t.z.literal("comment-add"),reportHubId:t.z.number(),comment:g,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional(),sourceType:y}),T=t.z.object({type:t.z.literal("comment-delete"),reportHubId:t.z.number(),commentId:t.z.number(),clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional(),sourceType:y}),M=t.z.object({type:t.z.literal("report-create"),reportHubId:t.z.number(),report:m,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),N=t.z.object({type:t.z.literal("report-update"),reportHubId:t.z.number(),report:m,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),$=t.z.object({type:t.z.literal("report-publish"),reportHubId:t.z.number(),report:m,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),A=t.z.object({type:t.z.literal("report-delete"),reportHubId:t.z.number(),clientTempId:t.z.string(),sourceType:y}),ee=t.z.discriminatedUnion("type",[R,w,C,T,M,N,$,A]);var te=r=>{if(!r)return"-";let e=r.trim();return e===""?"-":e},H=r=>{if(!r)return"-";if(typeof r!="string")return r instanceof Date?H(r.toISOString()):String(r);let e=r.trim();if(e==="")return"-";let n=e.match(/^(\d{4})[-/](\d{2})[-/](\d{2})$/);if(n)return`${n[1]}-${n[2]}-${n[3]}`;let i=new Date(e);if(Number.isNaN(i.getTime()))return e;let s=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),a=String(i.getDate()).padStart(2,"0");if(e.includes(":")||e.includes("T")){let U=String(i.getHours()).padStart(2,"0"),j=String(i.getMinutes()).padStart(2,"0"),E=String(i.getSeconds()).padStart(2,"0");return`${s}-${o}-${a}T${U}:${j}:${E}`}return`${s}-${o}-${a}`};0&&(module.exports={LogLevel,classifyIdsStreamLine,commentAddMessageSchema,commentDeleteMessageSchema,compareIdsStreamOrder,computeIdsStreamSnapshotToken,connectedMessageSchema,createLogger,dailyReportAttachmentItemSchema,dailyReportDetailSchema,dailyReportExternalCommentSchema,dailyReportInterviewerSchema,dailyReportLabelDefSchema,dailyReportPostedCommentSchema,dailyReportSseMessageSchema,fallbackText,findIdsStreamResumeIndex,formatBusinessDateDisplay,formatToIsoDate,isIdsStreamChunkLine,isIdsStreamOrdered,mergeComments,normalizeBusinessDateKey,parseBusinessDateKeyToDate,reportCreateMessageSchema,reportDeleteMessageSchema,reportPublishMessageSchema,reportUpdateMessageSchema,resolveCommentColorClass,resolveTodayBusinessDateKey,statusUpdateMessageSchema,upsertInIdsStreamOrder});
2
- //# sourceMappingURL=index.js.map
1
+ "use strict";var d=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var z=(r,e)=>{for(var n in e)d(r,n,{get:e[n],enumerable:!0})},_=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of B(e))!O.call(r,s)&&s!==n&&d(r,s,{get:()=>e[s],enumerable:!(o=P(e,s))||o.enumerable});return r};var L=r=>_(d({},"__esModule",{value:!0}),r);var re={};z(re,{LogLevel:()=>b,classifyIdsStreamLine:()=>h,commentAddMessageSchema:()=>C,commentDeleteMessageSchema:()=>T,compareIdsStreamOrder:()=>m,computeIdsStreamSnapshotToken:()=>Q,connectedMessageSchema:()=>k,createLogger:()=>v,dailyReportAttachmentItemSchema:()=>R,dailyReportDetailSchema:()=>p,dailyReportExternalCommentSchema:()=>I,dailyReportInterviewerSchema:()=>D,dailyReportLabelDefSchema:()=>S,dailyReportPostedCommentSchema:()=>g,dailyReportSseMessageSchema:()=>ee,fallbackText:()=>te,findIdsStreamResumeIndex:()=>Z,formatBusinessDateDisplay:()=>Y,formatToIsoDate:()=>H,isIdsStreamChunkLine:()=>q,isIdsStreamOrdered:()=>V,mergeComments:()=>W,normalizeBusinessDateKey:()=>c,parseBusinessDateKeyToDate:()=>G,reportCreateMessageSchema:()=>M,reportDeleteMessageSchema:()=>A,reportPublishMessageSchema:()=>N,reportUpdateMessageSchema:()=>$,resolveCommentColorClass:()=>J,resolveTodayBusinessDateKey:()=>x,statusUpdateMessageSchema:()=>w,upsertInIdsStreamOrder:()=>X});module.exports=L(re);var F=/^\d{4}-\d{2}-\d{2}$/,K=/^\d{4}\/\d{2}\/\d{2}$/,u=r=>r<10?`0${r}`:`${r}`,f=r=>{if(Number.isNaN(r.getTime()))return null;let e=r.getFullYear(),n=u(r.getMonth()+1),o=u(r.getDate());return`${e}-${n}-${o}`},x=(r=new Date)=>Number.isNaN(r.getTime())?x(new Date):`${r.getFullYear()}-${u(r.getMonth()+1)}-${u(r.getDate())}`,c=r=>{if(r==null)return null;if(r instanceof Date)return f(r);let e=r.trim();if(e==="")return null;if(F.test(e))return e;if(K.test(e))return e.replaceAll("/","-");let n=new Date(e);return f(n)},Y=r=>{let e=c(r);return e||null},G=r=>{let e=c(r);if(!e)return null;let[n,o,s]=e.split("-").map(i=>Number.parseInt(i,10));return[n,o,s].some(i=>Number.isNaN(i))?null:new Date(n,o-1,s)};var W=(r,e,n,o)=>{if(typeof o!="string"||o.trim()==="")throw new RangeError(`[daily-report] mergeComments: unknownAuthorName must be a non-blank string; got ${typeof o=="string"?JSON.stringify(o):typeof o}`);let s=r.map((a,l)=>({id:`legacy-${l}`,authorName:a.name||o,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),i=e.map(a=>({id:a.id,authorName:a.userName||o,content:a.content??"",createdAt:a.createdAt??"",isMine:n?a.userId===n:a.isMine,isLegacy:!1}));return[...s,...i]},J=r=>{if(!r)return"text-gray-700 dark:text-gray-300";let e=r.toLowerCase();return e.includes("red")||e.includes("\u8D64")?"text-red-600 dark:text-red-400":e.includes("green")||e.includes("\u7DD1")?"text-green-600 dark:text-green-400":e.includes("blue")||e.includes("\u9752")?"text-blue-600 dark:text-blue-400":e.includes("yellow")||e.includes("\u9EC4")?"text-yellow-600 dark:text-yellow-400":e.includes("orange")||e.includes("\u6A59")?"text-orange-500 dark:text-orange-400":"text-gray-700 dark:text-gray-300"};var h=r=>{if(typeof r!="object"||r===null)return"unknown";let e=r;return typeof e.kind=="string"?e.kind==="chunk"?"chunk":e.kind==="error"?"error":"unknown":Array.isArray(e.items)?"chunk":typeof e.error=="string"?"error":"unknown"},q=r=>h(r)==="chunk",Q=r=>{let e=2166136261,n=-624069552;for(let o of r){let s=o.reportHubId;e^=s&255,e=Math.imul(e,16777619),e^=s>>>8&255,e=Math.imul(e,16777619),e^=s>>>16&255,e=Math.imul(e,16777619),e^=s>>>24&255,e=Math.imul(e,16777619),n^=s>>>24&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s&255,n=Math.imul(n,16777619);let i=o.businessDate;if(i===null)e^=1,e=Math.imul(e,16777619),n^=1,n=Math.imul(n,16777619);else for(let a=0;a<i.length;a++){let l=i.charCodeAt(a);e^=l&255,e=Math.imul(e,16777619),n^=l&255,n=Math.imul(n,16777619)}}return e^=r.length,e=Math.imul(e,16777619),n^=r.length,n=Math.imul(n,16777619),((e>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")).replace(/^0+(?=.)/,"")},m=(r,e)=>r.businessDate!==e.businessDate?r.businessDate===null?1:e.businessDate===null||r.businessDate>e.businessDate?-1:1:e.reportHubId-r.reportHubId,V=r=>{for(let e=1;e<r.length;e++)if(m(r[e-1],r[e])>0)return!1;return!0},X=(r,e)=>{let n=r.filter(i=>i.reportHubId!==e.reportHubId),o=0,s=n.length;for(;o<s;){let i=o+s>>1;m(n[i],e)<=0?o=i+1:s=i}return n.splice(o,0,e),n},Z=(r,e)=>{let n=r.findIndex(o=>m({businessDate:o.businessDate,reportHubId:o.reportHubId},e)>0);return n===-1?r.length:n};var b=(i=>(i[i.DEBUG=0]="DEBUG",i[i.INFO=1]="INFO",i[i.WARN=2]="WARN",i[i.ERROR=3]="ERROR",i[i.NONE=4]="NONE",i))(b||{}),v=(r,e,n=console)=>{let o=s=>typeof s=="string"?[`${e} ${s}`]:[e,s];return{debug:(s,...i)=>{r<=0&&n.debug(...o(s),...i)},info:(s,...i)=>{r<=1&&n.info(...o(s),...i)},warn:(s,...i)=>{r<=2&&n.warn(...o(s),...i)},error:(s,...i)=>{r<=3&&n.error(...o(s),...i)}}};var t=require("zod"),D=t.z.object({name:t.z.string().nullish(),affiliation:t.z.string().nullish()}),I=t.z.object({name:t.z.string().nullish(),text:t.z.string().nullish(),color:t.z.string().nullish()}),S=t.z.object({id:t.z.number(),name:t.z.string().nullish(),color:t.z.string().nullish()}),g=t.z.object({id:t.z.number(),userId:t.z.string().nullish(),userName:t.z.string().nullish(),content:t.z.string().nullish(),createdAt:t.z.string().nullish(),isMine:t.z.boolean()}),R=t.z.object({id:t.z.string(),fileName:t.z.string(),fileType:t.z.string().nullable(),fileSize:t.z.number().nullable(),createdAt:t.z.string().nullable(),state:t.z.enum(["present","absent","unknown"])}),p=t.z.object({reportHubId:t.z.number(),date:t.z.string().nullish(),createdAt:t.z.string().nullish(),author:t.z.string().nullish(),userId:t.z.string().nullish(),sourceType:t.z.string().nullish(),employeeName:t.z.string().nullish(),updatedBy:t.z.string().nullish(),updatedAt:t.z.string().nullish(),category:t.z.string().nullish(),creationCategory:t.z.string().nullish(),visitTimeFrom:t.z.string().nullish(),visitTimeTo:t.z.string().nullish(),customerName:t.z.string().nullish(),interviewers:t.z.array(D),subject:t.z.string().nullish(),content:t.z.string().nullish(),externalComments:t.z.array(I),isRead:t.z.boolean(),isStarred:t.z.boolean(),labels:t.z.array(S),postedComments:t.z.array(g),attachments:t.z.array(R).default([])}),k=t.z.object({type:t.z.literal("connected")}),w=t.z.object({type:t.z.literal("status-update"),reportHubId:t.z.number(),statusType:t.z.enum(["star","read"]),value:t.z.boolean(),clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),y=t.z.string().optional(),C=t.z.object({type:t.z.literal("comment-add"),reportHubId:t.z.number(),comment:g,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional(),sourceType:y}),T=t.z.object({type:t.z.literal("comment-delete"),reportHubId:t.z.number(),commentId:t.z.number(),clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional(),sourceType:y}),M=t.z.object({type:t.z.literal("report-create"),reportHubId:t.z.number(),report:p,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),$=t.z.object({type:t.z.literal("report-update"),reportHubId:t.z.number(),report:p,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),N=t.z.object({type:t.z.literal("report-publish"),reportHubId:t.z.number(),report:p,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),A=t.z.object({type:t.z.literal("report-delete"),reportHubId:t.z.number(),clientTempId:t.z.string(),sourceType:y}),ee=t.z.discriminatedUnion("type",[k,w,C,T,M,$,N,A]);var te=r=>{if(!r)return"-";let e=r.trim();return e===""?"-":e},H=r=>{if(!r)return"-";if(typeof r!="string")return r instanceof Date?H(r.toISOString()):String(r);let e=r.trim();if(e==="")return"-";let n=e.match(/^(\d{4})[-/](\d{2})[-/](\d{2})$/);if(n)return`${n[1]}-${n[2]}-${n[3]}`;let o=new Date(e);if(Number.isNaN(o.getTime()))return e;let s=o.getFullYear(),i=String(o.getMonth()+1).padStart(2,"0"),a=String(o.getDate()).padStart(2,"0");if(e.includes(":")||e.includes("T")){let j=String(o.getHours()).padStart(2,"0"),U=String(o.getMinutes()).padStart(2,"0"),E=String(o.getSeconds()).padStart(2,"0");return`${s}-${i}-${a}T${j}:${U}:${E}`}return`${s}-${i}-${a}`};0&&(module.exports={LogLevel,classifyIdsStreamLine,commentAddMessageSchema,commentDeleteMessageSchema,compareIdsStreamOrder,computeIdsStreamSnapshotToken,connectedMessageSchema,createLogger,dailyReportAttachmentItemSchema,dailyReportDetailSchema,dailyReportExternalCommentSchema,dailyReportInterviewerSchema,dailyReportLabelDefSchema,dailyReportPostedCommentSchema,dailyReportSseMessageSchema,fallbackText,findIdsStreamResumeIndex,formatBusinessDateDisplay,formatToIsoDate,isIdsStreamChunkLine,isIdsStreamOrdered,mergeComments,normalizeBusinessDateKey,parseBusinessDateKeyToDate,reportCreateMessageSchema,reportDeleteMessageSchema,reportPublishMessageSchema,reportUpdateMessageSchema,resolveCommentColorClass,resolveTodayBusinessDateKey,statusUpdateMessageSchema,upsertInIdsStreamOrder});
package/dist/index.mjs CHANGED
@@ -1,2 +1 @@
1
- var b=/^\d{4}-\d{2}-\d{2}$/,D=/^\d{4}\/\d{2}\/\d{2}$/,l=r=>r<10?`0${r}`:`${r}`,c=r=>{if(Number.isNaN(r.getTime()))return null;let t=r.getFullYear(),n=l(r.getMonth()+1),i=l(r.getDate());return`${t}-${n}-${i}`},I=(r=new Date)=>Number.isNaN(r.getTime())?I(new Date):`${r.getFullYear()}-${l(r.getMonth()+1)}-${l(r.getDate())}`,g=r=>{if(r==null)return null;if(r instanceof Date)return c(r);let t=r.trim();if(t==="")return null;if(b.test(t))return t;if(D.test(t))return t.replaceAll("/","-");let n=new Date(t);return c(n)},B=r=>{let t=g(r);return t||null},z=r=>{let t=g(r);if(!t)return null;let[n,i,s]=t.split("-").map(o=>Number.parseInt(o,10));return[n,i,s].some(o=>Number.isNaN(o))?null:new Date(n,i-1,s)};var _=(r,t,n)=>{let i=r.map((o,a)=>({id:`legacy-${a}`,authorName:o.name||"Unknown",content:o.text||"",isMine:!1,color:o.color||void 0,isLegacy:!0})),s=t.map(o=>({id:o.id,authorName:o.userName??"",content:o.content??"",createdAt:o.createdAt??"",isMine:n?o.userId===n:o.isMine,isLegacy:!1}));return[...i,...s]},L=r=>{if(!r)return"text-gray-700 dark:text-gray-300";let t=r.toLowerCase();return t.includes("red")||t.includes("\u8D64")?"text-red-600 dark:text-red-400":t.includes("green")||t.includes("\u7DD1")?"text-green-600 dark:text-green-400":t.includes("blue")||t.includes("\u9752")?"text-blue-600 dark:text-blue-400":t.includes("yellow")||t.includes("\u9EC4")?"text-yellow-600 dark:text-yellow-400":t.includes("orange")||t.includes("\u6A59")?"text-orange-500 dark:text-orange-400":"text-gray-700 dark:text-gray-300"};var S=r=>{if(typeof r!="object"||r===null)return"unknown";let t=r;return typeof t.kind=="string"?t.kind==="chunk"?"chunk":t.kind==="error"?"error":"unknown":Array.isArray(t.items)?"chunk":typeof t.error=="string"?"error":"unknown"},K=r=>S(r)==="chunk",Y=r=>{let t=2166136261,n=-624069552;for(let i of r){let s=i.reportHubId;t^=s&255,t=Math.imul(t,16777619),t^=s>>>8&255,t=Math.imul(t,16777619),t^=s>>>16&255,t=Math.imul(t,16777619),t^=s>>>24&255,t=Math.imul(t,16777619),n^=s>>>24&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s&255,n=Math.imul(n,16777619);let o=i.businessDate;if(o===null)t^=1,t=Math.imul(t,16777619),n^=1,n=Math.imul(n,16777619);else for(let a=0;a<o.length;a++){let u=o.charCodeAt(a);t^=u&255,t=Math.imul(t,16777619),n^=u&255,n=Math.imul(n,16777619)}}return t^=r.length,t=Math.imul(t,16777619),n^=r.length,n=Math.imul(n,16777619),((t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")).replace(/^0+(?=.)/,"")},m=(r,t)=>r.businessDate!==t.businessDate?r.businessDate===null?1:t.businessDate===null||r.businessDate>t.businessDate?-1:1:t.reportHubId-r.reportHubId,G=r=>{for(let t=1;t<r.length;t++)if(m(r[t-1],r[t])>0)return!1;return!0},W=(r,t)=>{let n=r.filter(o=>o.reportHubId!==t.reportHubId),i=0,s=n.length;for(;i<s;){let o=i+s>>1;m(n[o],t)<=0?i=o+1:s=o}return n.splice(i,0,t),n},q=(r,t)=>{let n=r.findIndex(i=>m({businessDate:i.businessDate,reportHubId:i.reportHubId},t)>0);return n===-1?r.length:n};var k=(o=>(o[o.DEBUG=0]="DEBUG",o[o.INFO=1]="INFO",o[o.WARN=2]="WARN",o[o.ERROR=3]="ERROR",o[o.NONE=4]="NONE",o))(k||{}),Q=(r,t,n=console)=>{let i=s=>typeof s=="string"?[`${t} ${s}`]:[t,s];return{debug:(s,...o)=>{r<=0&&n.debug(...i(s),...o)},info:(s,...o)=>{r<=1&&n.info(...i(s),...o)},warn:(s,...o)=>{r<=2&&n.warn(...i(s),...o)},error:(s,...o)=>{r<=3&&n.error(...i(s),...o)}}};import{z as e}from"zod";var R=e.object({name:e.string().nullish(),affiliation:e.string().nullish()}),w=e.object({name:e.string().nullish(),text:e.string().nullish(),color:e.string().nullish()}),C=e.object({id:e.number(),name:e.string().nullish(),color:e.string().nullish()}),y=e.object({id:e.number(),userId:e.string().nullish(),userName:e.string().nullish(),content:e.string().nullish(),createdAt:e.string().nullish(),isMine:e.boolean()}),T=e.object({id:e.string(),fileName:e.string(),fileType:e.string().nullable(),fileSize:e.number().nullable(),createdAt:e.string().nullable(),state:e.enum(["present","absent","unknown"])}),p=e.object({reportHubId:e.number(),date:e.string().nullish(),createdAt:e.string().nullish(),author:e.string().nullish(),userId:e.string().nullish(),sourceType:e.string().nullish(),employeeName:e.string().nullish(),updatedBy:e.string().nullish(),updatedAt:e.string().nullish(),category:e.string().nullish(),creationCategory:e.string().nullish(),visitTimeFrom:e.string().nullish(),visitTimeTo:e.string().nullish(),customerName:e.string().nullish(),interviewers:e.array(R),subject:e.string().nullish(),content:e.string().nullish(),externalComments:e.array(w),isRead:e.boolean(),isStarred:e.boolean(),labels:e.array(C),postedComments:e.array(y),attachments:e.array(T).default([])}),M=e.object({type:e.literal("connected")}),N=e.object({type:e.literal("status-update"),reportHubId:e.number(),statusType:e.enum(["star","read"]),value:e.boolean(),clientTempId:e.string(),recipientRawUserId:e.number().optional()}),d=e.string().optional(),$=e.object({type:e.literal("comment-add"),reportHubId:e.number(),comment:y,clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:d}),A=e.object({type:e.literal("comment-delete"),reportHubId:e.number(),commentId:e.number(),clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:d}),H=e.object({type:e.literal("report-create"),reportHubId:e.number(),report:p,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),U=e.object({type:e.literal("report-update"),reportHubId:e.number(),report:p,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),j=e.object({type:e.literal("report-publish"),reportHubId:e.number(),report:p,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),E=e.object({type:e.literal("report-delete"),reportHubId:e.number(),clientTempId:e.string(),sourceType:d}),Z=e.discriminatedUnion("type",[M,N,$,A,H,U,j,E]);var ee=r=>{if(!r)return"-";let t=r.trim();return t===""?"-":t},P=r=>{if(!r)return"-";if(typeof r!="string")return r instanceof Date?P(r.toISOString()):String(r);let t=r.trim();if(t==="")return"-";let n=t.match(/^(\d{4})[-/](\d{2})[-/](\d{2})$/);if(n)return`${n[1]}-${n[2]}-${n[3]}`;let i=new Date(t);if(Number.isNaN(i.getTime()))return t;let s=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),a=String(i.getDate()).padStart(2,"0");if(t.includes(":")||t.includes("T")){let f=String(i.getHours()).padStart(2,"0"),x=String(i.getMinutes()).padStart(2,"0"),h=String(i.getSeconds()).padStart(2,"0");return`${s}-${o}-${a}T${f}:${x}:${h}`}return`${s}-${o}-${a}`};export{k as LogLevel,S as classifyIdsStreamLine,$ as commentAddMessageSchema,A as commentDeleteMessageSchema,m as compareIdsStreamOrder,Y as computeIdsStreamSnapshotToken,M as connectedMessageSchema,Q as createLogger,T as dailyReportAttachmentItemSchema,p as dailyReportDetailSchema,w as dailyReportExternalCommentSchema,R as dailyReportInterviewerSchema,C as dailyReportLabelDefSchema,y as dailyReportPostedCommentSchema,Z as dailyReportSseMessageSchema,ee as fallbackText,q as findIdsStreamResumeIndex,B as formatBusinessDateDisplay,P as formatToIsoDate,K as isIdsStreamChunkLine,G as isIdsStreamOrdered,_ as mergeComments,g as normalizeBusinessDateKey,z as parseBusinessDateKeyToDate,H as reportCreateMessageSchema,E as reportDeleteMessageSchema,j as reportPublishMessageSchema,U as reportUpdateMessageSchema,L as resolveCommentColorClass,I as resolveTodayBusinessDateKey,N as statusUpdateMessageSchema,W as upsertInIdsStreamOrder};
2
- //# sourceMappingURL=index.mjs.map
1
+ var b=/^\d{4}-\d{2}-\d{2}$/,D=/^\d{4}\/\d{2}\/\d{2}$/,u=r=>r<10?`0${r}`:`${r}`,c=r=>{if(Number.isNaN(r.getTime()))return null;let t=r.getFullYear(),n=u(r.getMonth()+1),s=u(r.getDate());return`${t}-${n}-${s}`},I=(r=new Date)=>Number.isNaN(r.getTime())?I(new Date):`${r.getFullYear()}-${u(r.getMonth()+1)}-${u(r.getDate())}`,g=r=>{if(r==null)return null;if(r instanceof Date)return c(r);let t=r.trim();if(t==="")return null;if(b.test(t))return t;if(D.test(t))return t.replaceAll("/","-");let n=new Date(t);return c(n)},B=r=>{let t=g(r);return t||null},O=r=>{let t=g(r);if(!t)return null;let[n,s,i]=t.split("-").map(o=>Number.parseInt(o,10));return[n,s,i].some(o=>Number.isNaN(o))?null:new Date(n,s-1,i)};var _=(r,t,n,s)=>{if(typeof s!="string"||s.trim()==="")throw new RangeError(`[daily-report] mergeComments: unknownAuthorName must be a non-blank string; got ${typeof s=="string"?JSON.stringify(s):typeof s}`);let i=r.map((a,l)=>({id:`legacy-${l}`,authorName:a.name||s,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),o=t.map(a=>({id:a.id,authorName:a.userName||s,content:a.content??"",createdAt:a.createdAt??"",isMine:n?a.userId===n:a.isMine,isLegacy:!1}));return[...i,...o]},L=r=>{if(!r)return"text-gray-700 dark:text-gray-300";let t=r.toLowerCase();return t.includes("red")||t.includes("\u8D64")?"text-red-600 dark:text-red-400":t.includes("green")||t.includes("\u7DD1")?"text-green-600 dark:text-green-400":t.includes("blue")||t.includes("\u9752")?"text-blue-600 dark:text-blue-400":t.includes("yellow")||t.includes("\u9EC4")?"text-yellow-600 dark:text-yellow-400":t.includes("orange")||t.includes("\u6A59")?"text-orange-500 dark:text-orange-400":"text-gray-700 dark:text-gray-300"};var S=r=>{if(typeof r!="object"||r===null)return"unknown";let t=r;return typeof t.kind=="string"?t.kind==="chunk"?"chunk":t.kind==="error"?"error":"unknown":Array.isArray(t.items)?"chunk":typeof t.error=="string"?"error":"unknown"},K=r=>S(r)==="chunk",Y=r=>{let t=2166136261,n=-624069552;for(let s of r){let i=s.reportHubId;t^=i&255,t=Math.imul(t,16777619),t^=i>>>8&255,t=Math.imul(t,16777619),t^=i>>>16&255,t=Math.imul(t,16777619),t^=i>>>24&255,t=Math.imul(t,16777619),n^=i>>>24&255,n=Math.imul(n,16777619),n^=i>>>16&255,n=Math.imul(n,16777619),n^=i>>>8&255,n=Math.imul(n,16777619),n^=i&255,n=Math.imul(n,16777619);let o=s.businessDate;if(o===null)t^=1,t=Math.imul(t,16777619),n^=1,n=Math.imul(n,16777619);else for(let a=0;a<o.length;a++){let l=o.charCodeAt(a);t^=l&255,t=Math.imul(t,16777619),n^=l&255,n=Math.imul(n,16777619)}}return t^=r.length,t=Math.imul(t,16777619),n^=r.length,n=Math.imul(n,16777619),((t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")).replace(/^0+(?=.)/,"")},m=(r,t)=>r.businessDate!==t.businessDate?r.businessDate===null?1:t.businessDate===null||r.businessDate>t.businessDate?-1:1:t.reportHubId-r.reportHubId,G=r=>{for(let t=1;t<r.length;t++)if(m(r[t-1],r[t])>0)return!1;return!0},W=(r,t)=>{let n=r.filter(o=>o.reportHubId!==t.reportHubId),s=0,i=n.length;for(;s<i;){let o=s+i>>1;m(n[o],t)<=0?s=o+1:i=o}return n.splice(s,0,t),n},J=(r,t)=>{let n=r.findIndex(s=>m({businessDate:s.businessDate,reportHubId:s.reportHubId},t)>0);return n===-1?r.length:n};var R=(o=>(o[o.DEBUG=0]="DEBUG",o[o.INFO=1]="INFO",o[o.WARN=2]="WARN",o[o.ERROR=3]="ERROR",o[o.NONE=4]="NONE",o))(R||{}),Q=(r,t,n=console)=>{let s=i=>typeof i=="string"?[`${t} ${i}`]:[t,i];return{debug:(i,...o)=>{r<=0&&n.debug(...s(i),...o)},info:(i,...o)=>{r<=1&&n.info(...s(i),...o)},warn:(i,...o)=>{r<=2&&n.warn(...s(i),...o)},error:(i,...o)=>{r<=3&&n.error(...s(i),...o)}}};import{z as e}from"zod";var k=e.object({name:e.string().nullish(),affiliation:e.string().nullish()}),w=e.object({name:e.string().nullish(),text:e.string().nullish(),color:e.string().nullish()}),C=e.object({id:e.number(),name:e.string().nullish(),color:e.string().nullish()}),y=e.object({id:e.number(),userId:e.string().nullish(),userName:e.string().nullish(),content:e.string().nullish(),createdAt:e.string().nullish(),isMine:e.boolean()}),T=e.object({id:e.string(),fileName:e.string(),fileType:e.string().nullable(),fileSize:e.number().nullable(),createdAt:e.string().nullable(),state:e.enum(["present","absent","unknown"])}),p=e.object({reportHubId:e.number(),date:e.string().nullish(),createdAt:e.string().nullish(),author:e.string().nullish(),userId:e.string().nullish(),sourceType:e.string().nullish(),employeeName:e.string().nullish(),updatedBy:e.string().nullish(),updatedAt:e.string().nullish(),category:e.string().nullish(),creationCategory:e.string().nullish(),visitTimeFrom:e.string().nullish(),visitTimeTo:e.string().nullish(),customerName:e.string().nullish(),interviewers:e.array(k),subject:e.string().nullish(),content:e.string().nullish(),externalComments:e.array(w),isRead:e.boolean(),isStarred:e.boolean(),labels:e.array(C),postedComments:e.array(y),attachments:e.array(T).default([])}),M=e.object({type:e.literal("connected")}),$=e.object({type:e.literal("status-update"),reportHubId:e.number(),statusType:e.enum(["star","read"]),value:e.boolean(),clientTempId:e.string(),recipientRawUserId:e.number().optional()}),d=e.string().optional(),N=e.object({type:e.literal("comment-add"),reportHubId:e.number(),comment:y,clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:d}),A=e.object({type:e.literal("comment-delete"),reportHubId:e.number(),commentId:e.number(),clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:d}),H=e.object({type:e.literal("report-create"),reportHubId:e.number(),report:p,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),j=e.object({type:e.literal("report-update"),reportHubId:e.number(),report:p,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),U=e.object({type:e.literal("report-publish"),reportHubId:e.number(),report:p,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),E=e.object({type:e.literal("report-delete"),reportHubId:e.number(),clientTempId:e.string(),sourceType:d}),Z=e.discriminatedUnion("type",[M,$,N,A,H,j,U,E]);var ee=r=>{if(!r)return"-";let t=r.trim();return t===""?"-":t},P=r=>{if(!r)return"-";if(typeof r!="string")return r instanceof Date?P(r.toISOString()):String(r);let t=r.trim();if(t==="")return"-";let n=t.match(/^(\d{4})[-/](\d{2})[-/](\d{2})$/);if(n)return`${n[1]}-${n[2]}-${n[3]}`;let s=new Date(t);if(Number.isNaN(s.getTime()))return t;let i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0");if(t.includes(":")||t.includes("T")){let f=String(s.getHours()).padStart(2,"0"),x=String(s.getMinutes()).padStart(2,"0"),h=String(s.getSeconds()).padStart(2,"0");return`${i}-${o}-${a}T${f}:${x}:${h}`}return`${i}-${o}-${a}`};export{R as LogLevel,S as classifyIdsStreamLine,N as commentAddMessageSchema,A as commentDeleteMessageSchema,m as compareIdsStreamOrder,Y as computeIdsStreamSnapshotToken,M as connectedMessageSchema,Q as createLogger,T as dailyReportAttachmentItemSchema,p as dailyReportDetailSchema,w as dailyReportExternalCommentSchema,k as dailyReportInterviewerSchema,C as dailyReportLabelDefSchema,y as dailyReportPostedCommentSchema,Z as dailyReportSseMessageSchema,ee as fallbackText,J as findIdsStreamResumeIndex,B as formatBusinessDateDisplay,P as formatToIsoDate,K as isIdsStreamChunkLine,G as isIdsStreamOrdered,_ as mergeComments,g as normalizeBusinessDateKey,O as parseBusinessDateKeyToDate,H as reportCreateMessageSchema,E as reportDeleteMessageSchema,U as reportPublishMessageSchema,j as reportUpdateMessageSchema,L as resolveCommentColorClass,I as resolveTodayBusinessDateKey,$ as statusUpdateMessageSchema,W as upsertInIdsStreamOrder};
@@ -1,11 +1,3 @@
1
- /**
2
- * Minimal level-filtered logger used internally by the daily-report package.
3
- * daily-report パッケージ内部で使う最小のレベルフィルタ付きロガー。
4
- *
5
- * 消費アプリのロガー実装 (console 互換の debug/info/warn/error) を注入でき、
6
- * 未注入時は console にフォールバックする。
7
- */
8
- /** 出力フィルタリング用のログレベル。 */
9
1
  declare enum LogLevel {
10
2
  DEBUG = 0,
11
3
  INFO = 1,
@@ -13,17 +5,11 @@ declare enum LogLevel {
13
5
  ERROR = 3,
14
6
  NONE = 4
15
7
  }
16
- /** Console 互換のロガーインターフェース。 */
17
8
  interface DailyReportLogger {
18
9
  debug(message?: unknown, ...optionalParams: unknown[]): void;
19
10
  info(message?: unknown, ...optionalParams: unknown[]): void;
20
11
  warn(message?: unknown, ...optionalParams: unknown[]): void;
21
12
  error(message?: unknown, ...optionalParams: unknown[]): void;
22
13
  }
23
- /**
24
- * Creates a prefixed, level-filtered logger delegating to the given implementation.
25
- * 指定実装へ委譲するプレフィックス付き・レベルフィルタ付きロガーを生成する処理。
26
- */
27
14
  declare const createLogger: (level: LogLevel, prefix: string, impl?: DailyReportLogger) => DailyReportLogger;
28
-
29
15
  export { type DailyReportLogger as D, LogLevel as L, createLogger as c };
@@ -1,11 +1,3 @@
1
- /**
2
- * Minimal level-filtered logger used internally by the daily-report package.
3
- * daily-report パッケージ内部で使う最小のレベルフィルタ付きロガー。
4
- *
5
- * 消費アプリのロガー実装 (console 互換の debug/info/warn/error) を注入でき、
6
- * 未注入時は console にフォールバックする。
7
- */
8
- /** 出力フィルタリング用のログレベル。 */
9
1
  declare enum LogLevel {
10
2
  DEBUG = 0,
11
3
  INFO = 1,
@@ -13,17 +5,11 @@ declare enum LogLevel {
13
5
  ERROR = 3,
14
6
  NONE = 4
15
7
  }
16
- /** Console 互換のロガーインターフェース。 */
17
8
  interface DailyReportLogger {
18
9
  debug(message?: unknown, ...optionalParams: unknown[]): void;
19
10
  info(message?: unknown, ...optionalParams: unknown[]): void;
20
11
  warn(message?: unknown, ...optionalParams: unknown[]): void;
21
12
  error(message?: unknown, ...optionalParams: unknown[]): void;
22
13
  }
23
- /**
24
- * Creates a prefixed, level-filtered logger delegating to the given implementation.
25
- * 指定実装へ委譲するプレフィックス付き・レベルフィルタ付きロガーを生成する処理。
26
- */
27
14
  declare const createLogger: (level: LogLevel, prefix: string, impl?: DailyReportLogger) => DailyReportLogger;
28
-
29
15
  export { type DailyReportLogger as D, LogLevel as L, createLogger as c };