@aiquants/daily-report 0.6.2 → 0.8.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 (67) hide show
  1. package/README.md +13 -6
  2. package/dist/client.d.mts +443 -23
  3. package/dist/client.d.ts +443 -23
  4. package/dist/client.js +5 -4
  5. package/dist/client.js.map +1 -1
  6. package/dist/client.mjs +5 -4
  7. package/dist/client.mjs.map +1 -1
  8. package/dist/index.d.mts +77 -3
  9. package/dist/index.d.ts +77 -3
  10. package/dist/index.js +1 -1
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +1 -1
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/server.d.mts +436 -6
  15. package/dist/server.d.ts +436 -6
  16. package/dist/server.js +8 -6
  17. package/dist/server.js.map +1 -1
  18. package/dist/server.mjs +8 -6
  19. package/dist/server.mjs.map +1 -1
  20. package/dist/{sse-schema-rbG114od.d.mts → sse-schema-Df49KA7B.d.mts} +643 -249
  21. package/dist/{sse-schema-eXcMG-Ej.d.ts → sse-schema-RHckD7TS.d.ts} +643 -249
  22. package/dist/styles/daily-report.standalone.css +1 -1
  23. package/dist/{types-D1PKubyo.d.mts → types-Ct1ggzy-.d.mts} +30 -1
  24. package/dist/{types-D1PKubyo.d.ts → types-Ct1ggzy-.d.ts} +30 -1
  25. package/package.json +3 -3
  26. package/src/client/components/daily-report-attachment-indicator.spec.tsx +51 -0
  27. package/src/client/components/daily-report-attachment-indicator.tsx +45 -0
  28. package/src/client/components/daily-report-attachment-list.spec.tsx +94 -0
  29. package/src/client/components/daily-report-attachment-list.tsx +112 -0
  30. package/src/client/components/daily-report-detail-list.tsx +14 -7
  31. package/src/client/components/daily-report-ids-stream-status.spec.tsx +93 -0
  32. package/src/client/components/daily-report-ids-stream-status.tsx +67 -0
  33. package/src/client/components/daily-report-list.tsx +19 -11
  34. package/src/client/components/daily-report-page.spec.tsx +119 -0
  35. package/src/client/components/daily-report-page.tsx +56 -68
  36. package/src/client/components/daily-report-resolved-content.tsx +31 -7
  37. package/src/client/components/report-views.spec.tsx +340 -0
  38. package/src/client/config-context.tsx +8 -0
  39. package/src/client/contexts/daily-report-action-context.spec.tsx +262 -0
  40. package/src/client/contexts/daily-report-action-context.tsx +151 -52
  41. package/src/client/hooks/use-animated-number.spec.ts +103 -0
  42. package/src/client/hooks/use-animated-number.ts +69 -0
  43. package/src/client/hooks/use-responsive-layout.spec.ts +74 -0
  44. package/src/client/hooks/use-responsive-layout.ts +56 -0
  45. package/src/client/route-helpers.spec.ts +100 -0
  46. package/src/client/route-helpers.ts +20 -41
  47. package/src/client/streaming/daily-report-ids-stream-client.spec.ts +641 -0
  48. package/src/client/streaming/daily-report-ids-stream-client.ts +599 -0
  49. package/src/client/streaming/daily-report-ids-stream-session.spec.ts +360 -0
  50. package/src/client/streaming/daily-report-ids-stream-session.ts +280 -0
  51. package/src/client/utils/constants.spec.ts +96 -0
  52. package/src/client/utils/constants.ts +47 -2
  53. package/src/client.ts +6 -0
  54. package/src/index.ts +1 -0
  55. package/src/server/handlers.attachment.spec.ts +470 -0
  56. package/src/server/handlers.ids-stream.spec.ts +362 -0
  57. package/src/server/handlers.ts +671 -6
  58. package/src/server/ports.ts +74 -0
  59. package/src/server/schema.ts +80 -5
  60. package/src/server/service.spec.ts +280 -14
  61. package/src/server/service.ts +348 -25
  62. package/src/server/test-helpers/handlers-config.ts +181 -0
  63. package/src/server.ts +16 -1
  64. package/src/shared/ids-stream.ts +92 -0
  65. package/src/shared/sse-schema.spec.ts +50 -0
  66. package/src/shared/sse-schema.ts +27 -0
  67. package/src/shared/types.ts +31 -0
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- export { D as DailyReportSseMessage, U as UIComment, c as commentAddMessageSchema, a as commentDeleteMessageSchema, b as connectedMessageSchema, d as dailyReportCommentItemSchema, e as dailyReportCommentSchema, f as dailyReportDetailSchema, g as dailyReportInterviewerSchema, h as dailyReportLabelDefSchema, i as dailyReportSseMessageSchema, m as mergeComments, r as reportCreateMessageSchema, j as reportDeleteMessageSchema, k as reportPublishMessageSchema, l as reportUpdateMessageSchema, n as resolveCommentColorClass, s as statusUpdateMessageSchema } from './sse-schema-rbG114od.mjs';
1
+ export { D as DailyReportSseMessage, U as UIComment, c as commentAddMessageSchema, a as commentDeleteMessageSchema, b as connectedMessageSchema, d as dailyReportAttachmentItemSchema, e as dailyReportCommentItemSchema, f as dailyReportCommentSchema, g as dailyReportDetailSchema, h as dailyReportInterviewerSchema, i as dailyReportLabelDefSchema, 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-Df49KA7B.mjs';
2
+ import { a as DailyReportItem } from './types-Ct1ggzy-.mjs';
3
+ export { d as DailyReportAttachmentState, D as DailyReportAttachmentSummary, e as DailyReportComment, f as DailyReportCommentItem, b as DailyReportDetail, g as DailyReportInterviewer, h as DailyReportLabelDef, c as DailyReportUser } from './types-Ct1ggzy-.mjs';
2
4
  export { D as DailyReportLogger, L as LogLevel, c as createLogger } from './logger-D3krZrNK.mjs';
3
- export { c as DailyReportComment, d as DailyReportCommentItem, a as DailyReportDetail, e as DailyReportInterviewer, D as DailyReportItem, f as DailyReportLabelDef, b as DailyReportUser } from './types-D1PKubyo.mjs';
4
5
  import 'zod';
5
6
 
6
7
  /**
@@ -24,6 +25,79 @@ declare const formatBusinessDateDisplay: (value: BusinessDateInput) => string |
24
25
  */
25
26
  declare const parseBusinessDateKeyToDate: (value: BusinessDateInput) => Date | null;
26
27
 
28
+ /**
29
+ * Wire contract and ordering helpers for the daily-report ids NDJSON stream.
30
+ * 日報 ID 一覧 NDJSON ストリームのワイヤ契約と並び順ヘルパー。
31
+ *
32
+ * サーバーは `GET {apiBasePath}/ids-stream` で 1 行 1 JSON の NDJSON を返す。
33
+ * 行は原則 {@link DailyReportIdsStreamChunkLine} で、送出中に予期しない失敗が
34
+ * 起きた場合のみ {@link DailyReportIdsStreamErrorLine} を 1 行流して正常クローズする
35
+ * (クライアントは「isLast 無しで終端」を再開シグナルとして扱う)。
36
+ *
37
+ * 並び順は SQL の `ORDER BY business_date DESC, id DESC` (MSSQL の DESC は NULL を
38
+ * 末尾に置く) と完全一致させる。カーソル再開はこの全順序に対する「厳密に後」の
39
+ * 位置からのスライスとして定義する。
40
+ */
41
+
42
+ /** ストリーム再開カーソル。直前チャンク末尾アイテムの並び順キー。 */
43
+ type DailyReportIdsStreamCursor = {
44
+ /** 営業日 (YYYY-MM-DD)。null は「営業日なし領域」(並び順の末尾) を表す。 */
45
+ businessDate: string | null;
46
+ /** 日報 Hub ID。 */
47
+ reportHubId: number;
48
+ };
49
+ /** データを運ぶ NDJSON 行。 */
50
+ type DailyReportIdsStreamChunkLine = {
51
+ /** このチャンクのアイテム群 (並び順どおり)。 */
52
+ items: DailyReportItem[];
53
+ /** 次チャンクの再開カーソル。最終チャンクでは null。 */
54
+ nextCursor: DailyReportIdsStreamCursor | null;
55
+ /** これが最終チャンクかどうか。 */
56
+ isLast: boolean;
57
+ /** 全体件数。接続ごとの先頭行にのみ載る。 */
58
+ total?: number;
59
+ };
60
+ /** サーバー側の予期しない失敗を伝える NDJSON 行 (内部情報は含めない)。 */
61
+ type DailyReportIdsStreamErrorLine = {
62
+ error: string;
63
+ };
64
+ /** NDJSON 1 行のユニオン。 */
65
+ type DailyReportIdsStreamLine = DailyReportIdsStreamChunkLine | DailyReportIdsStreamErrorLine;
66
+ /**
67
+ * Type guard for chunk lines (anything else is treated as an error line).
68
+ * チャンク行の型ガード (それ以外はエラー行として扱う)。
69
+ *
70
+ * @param line Parsed NDJSON line. パース済みの NDJSON 行。
71
+ * @returns True when the line carries items. アイテムを運ぶ行なら true。
72
+ */
73
+ declare const isIdsStreamChunkLine: (line: unknown) => line is DailyReportIdsStreamChunkLine;
74
+ /**
75
+ * Total order of the ids stream: businessDate DESC (NULL last), then id DESC.
76
+ * ids ストリームの全順序。営業日降順 (NULL は末尾)、同日内は ID 降順。
77
+ *
78
+ * MSSQL の `ORDER BY business_date DESC, id DESC` と一致させることが唯一の存在理由。
79
+ * 営業日は正規化済みの `YYYY-MM-DD` 文字列なので辞書順比較 = 時系列比較になる。
80
+ *
81
+ * @param a Left key. 左辺キー。
82
+ * @param b Right key. 右辺キー。
83
+ * @returns Negative when `a` streams before `b`. `a` が先に流れるなら負値。
84
+ */
85
+ declare const compareIdsStreamOrder: (a: DailyReportIdsStreamCursor, b: DailyReportIdsStreamCursor) => number;
86
+ /**
87
+ * Finds the first index that streams strictly after the cursor.
88
+ * カーソルより厳密に後ろへ並ぶ最初のインデックスを求める処理。
89
+ *
90
+ * 配列は必ずストリーム順 (SQL の ORDER BY) で渡されるが、比較器とのズレが
91
+ * あっても壊れない線形走査で決定する (件数は高々数万・再開時のみの実行)。
92
+ * 該当なし (カーソルが末尾以降) は `items.length` を返し、空チャンク +
93
+ * `isLast: true` の正常終端に落ちる。
94
+ *
95
+ * @param items Stream-ordered items. ストリーム順のアイテム配列。
96
+ * @param cursor Resume cursor. 再開カーソル。
97
+ * @returns Index to resume emission from. 送出を再開するインデックス。
98
+ */
99
+ declare const findIdsStreamResumeIndex: (items: readonly DailyReportItem[], cursor: DailyReportIdsStreamCursor) => number;
100
+
27
101
  /**
28
102
  * Shared text helpers for daily report view components.
29
103
  * 日報ビューコンポーネント向けの共通テキストヘルパー。
@@ -39,4 +113,4 @@ declare const fallbackText: (value: string | null | undefined) => string;
39
113
  */
40
114
  declare const formatToIsoDate: (value: unknown) => string;
41
115
 
42
- export { fallbackText, formatBusinessDateDisplay, formatToIsoDate, normalizeBusinessDateKey, parseBusinessDateKeyToDate };
116
+ export { type DailyReportIdsStreamChunkLine, type DailyReportIdsStreamCursor, type DailyReportIdsStreamErrorLine, type DailyReportIdsStreamLine, DailyReportItem, compareIdsStreamOrder, fallbackText, findIdsStreamResumeIndex, formatBusinessDateDisplay, formatToIsoDate, isIdsStreamChunkLine, normalizeBusinessDateKey, parseBusinessDateKeyToDate };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- export { D as DailyReportSseMessage, U as UIComment, c as commentAddMessageSchema, a as commentDeleteMessageSchema, b as connectedMessageSchema, d as dailyReportCommentItemSchema, e as dailyReportCommentSchema, f as dailyReportDetailSchema, g as dailyReportInterviewerSchema, h as dailyReportLabelDefSchema, i as dailyReportSseMessageSchema, m as mergeComments, r as reportCreateMessageSchema, j as reportDeleteMessageSchema, k as reportPublishMessageSchema, l as reportUpdateMessageSchema, n as resolveCommentColorClass, s as statusUpdateMessageSchema } from './sse-schema-eXcMG-Ej.js';
1
+ export { D as DailyReportSseMessage, U as UIComment, c as commentAddMessageSchema, a as commentDeleteMessageSchema, b as connectedMessageSchema, d as dailyReportAttachmentItemSchema, e as dailyReportCommentItemSchema, f as dailyReportCommentSchema, g as dailyReportDetailSchema, h as dailyReportInterviewerSchema, i as dailyReportLabelDefSchema, 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-RHckD7TS.js';
2
+ import { a as DailyReportItem } from './types-Ct1ggzy-.js';
3
+ export { d as DailyReportAttachmentState, D as DailyReportAttachmentSummary, e as DailyReportComment, f as DailyReportCommentItem, b as DailyReportDetail, g as DailyReportInterviewer, h as DailyReportLabelDef, c as DailyReportUser } from './types-Ct1ggzy-.js';
2
4
  export { D as DailyReportLogger, L as LogLevel, c as createLogger } from './logger-D3krZrNK.js';
3
- export { c as DailyReportComment, d as DailyReportCommentItem, a as DailyReportDetail, e as DailyReportInterviewer, D as DailyReportItem, f as DailyReportLabelDef, b as DailyReportUser } from './types-D1PKubyo.js';
4
5
  import 'zod';
5
6
 
6
7
  /**
@@ -24,6 +25,79 @@ declare const formatBusinessDateDisplay: (value: BusinessDateInput) => string |
24
25
  */
25
26
  declare const parseBusinessDateKeyToDate: (value: BusinessDateInput) => Date | null;
26
27
 
28
+ /**
29
+ * Wire contract and ordering helpers for the daily-report ids NDJSON stream.
30
+ * 日報 ID 一覧 NDJSON ストリームのワイヤ契約と並び順ヘルパー。
31
+ *
32
+ * サーバーは `GET {apiBasePath}/ids-stream` で 1 行 1 JSON の NDJSON を返す。
33
+ * 行は原則 {@link DailyReportIdsStreamChunkLine} で、送出中に予期しない失敗が
34
+ * 起きた場合のみ {@link DailyReportIdsStreamErrorLine} を 1 行流して正常クローズする
35
+ * (クライアントは「isLast 無しで終端」を再開シグナルとして扱う)。
36
+ *
37
+ * 並び順は SQL の `ORDER BY business_date DESC, id DESC` (MSSQL の DESC は NULL を
38
+ * 末尾に置く) と完全一致させる。カーソル再開はこの全順序に対する「厳密に後」の
39
+ * 位置からのスライスとして定義する。
40
+ */
41
+
42
+ /** ストリーム再開カーソル。直前チャンク末尾アイテムの並び順キー。 */
43
+ type DailyReportIdsStreamCursor = {
44
+ /** 営業日 (YYYY-MM-DD)。null は「営業日なし領域」(並び順の末尾) を表す。 */
45
+ businessDate: string | null;
46
+ /** 日報 Hub ID。 */
47
+ reportHubId: number;
48
+ };
49
+ /** データを運ぶ NDJSON 行。 */
50
+ type DailyReportIdsStreamChunkLine = {
51
+ /** このチャンクのアイテム群 (並び順どおり)。 */
52
+ items: DailyReportItem[];
53
+ /** 次チャンクの再開カーソル。最終チャンクでは null。 */
54
+ nextCursor: DailyReportIdsStreamCursor | null;
55
+ /** これが最終チャンクかどうか。 */
56
+ isLast: boolean;
57
+ /** 全体件数。接続ごとの先頭行にのみ載る。 */
58
+ total?: number;
59
+ };
60
+ /** サーバー側の予期しない失敗を伝える NDJSON 行 (内部情報は含めない)。 */
61
+ type DailyReportIdsStreamErrorLine = {
62
+ error: string;
63
+ };
64
+ /** NDJSON 1 行のユニオン。 */
65
+ type DailyReportIdsStreamLine = DailyReportIdsStreamChunkLine | DailyReportIdsStreamErrorLine;
66
+ /**
67
+ * Type guard for chunk lines (anything else is treated as an error line).
68
+ * チャンク行の型ガード (それ以外はエラー行として扱う)。
69
+ *
70
+ * @param line Parsed NDJSON line. パース済みの NDJSON 行。
71
+ * @returns True when the line carries items. アイテムを運ぶ行なら true。
72
+ */
73
+ declare const isIdsStreamChunkLine: (line: unknown) => line is DailyReportIdsStreamChunkLine;
74
+ /**
75
+ * Total order of the ids stream: businessDate DESC (NULL last), then id DESC.
76
+ * ids ストリームの全順序。営業日降順 (NULL は末尾)、同日内は ID 降順。
77
+ *
78
+ * MSSQL の `ORDER BY business_date DESC, id DESC` と一致させることが唯一の存在理由。
79
+ * 営業日は正規化済みの `YYYY-MM-DD` 文字列なので辞書順比較 = 時系列比較になる。
80
+ *
81
+ * @param a Left key. 左辺キー。
82
+ * @param b Right key. 右辺キー。
83
+ * @returns Negative when `a` streams before `b`. `a` が先に流れるなら負値。
84
+ */
85
+ declare const compareIdsStreamOrder: (a: DailyReportIdsStreamCursor, b: DailyReportIdsStreamCursor) => number;
86
+ /**
87
+ * Finds the first index that streams strictly after the cursor.
88
+ * カーソルより厳密に後ろへ並ぶ最初のインデックスを求める処理。
89
+ *
90
+ * 配列は必ずストリーム順 (SQL の ORDER BY) で渡されるが、比較器とのズレが
91
+ * あっても壊れない線形走査で決定する (件数は高々数万・再開時のみの実行)。
92
+ * 該当なし (カーソルが末尾以降) は `items.length` を返し、空チャンク +
93
+ * `isLast: true` の正常終端に落ちる。
94
+ *
95
+ * @param items Stream-ordered items. ストリーム順のアイテム配列。
96
+ * @param cursor Resume cursor. 再開カーソル。
97
+ * @returns Index to resume emission from. 送出を再開するインデックス。
98
+ */
99
+ declare const findIdsStreamResumeIndex: (items: readonly DailyReportItem[], cursor: DailyReportIdsStreamCursor) => number;
100
+
27
101
  /**
28
102
  * Shared text helpers for daily report view components.
29
103
  * 日報ビューコンポーネント向けの共通テキストヘルパー。
@@ -39,4 +113,4 @@ declare const fallbackText: (value: string | null | undefined) => string;
39
113
  */
40
114
  declare const formatToIsoDate: (value: unknown) => string;
41
115
 
42
- export { fallbackText, formatBusinessDateDisplay, formatToIsoDate, normalizeBusinessDateKey, parseBusinessDateKeyToDate };
116
+ export { type DailyReportIdsStreamChunkLine, type DailyReportIdsStreamCursor, type DailyReportIdsStreamErrorLine, type DailyReportIdsStreamLine, DailyReportItem, compareIdsStreamOrder, fallbackText, findIdsStreamResumeIndex, formatBusinessDateDisplay, formatToIsoDate, isIdsStreamChunkLine, normalizeBusinessDateKey, parseBusinessDateKeyToDate };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var j=(n,t)=>{for(var o in t)l(n,o,{get:t[o],enumerable:!0})},z=(n,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of $(t))!U.call(n,s)&&s!==o&&l(n,s,{get:()=>t[s],enumerable:!(i=M(t,s))||i.enumerable});return n};var B=n=>z(l({},"__esModule",{value:!0}),n);var Y={};j(Y,{LogLevel:()=>g,commentAddMessageSchema:()=>I,commentDeleteMessageSchema:()=>x,connectedMessageSchema:()=>h,createLogger:()=>G,dailyReportCommentItemSchema:()=>u,dailyReportCommentSchema:()=>f,dailyReportDetailSchema:()=>a,dailyReportInterviewerSchema:()=>y,dailyReportLabelDefSchema:()=>b,dailyReportSseMessageSchema:()=>K,fallbackText:()=>W,formatBusinessDateDisplay:()=>E,formatToIsoDate:()=>T,mergeComments:()=>O,normalizeBusinessDateKey:()=>m,parseBusinessDateKeyToDate:()=>P,reportCreateMessageSchema:()=>S,reportDeleteMessageSchema:()=>C,reportPublishMessageSchema:()=>R,reportUpdateMessageSchema:()=>w,resolveCommentColorClass:()=>F,statusUpdateMessageSchema:()=>D});module.exports=B(Y);var H=/^\d{4}-\d{2}-\d{2}$/,_=/^\d{4}\/\d{2}\/\d{2}$/,p=n=>n<10?`0${n}`:`${n}`,d=n=>{if(Number.isNaN(n.getTime()))return null;let t=n.getFullYear(),o=p(n.getMonth()+1),i=p(n.getDate());return`${t}-${o}-${i}`},m=n=>{if(n==null)return null;if(n instanceof Date)return d(n);let t=n.trim();if(t==="")return null;if(H.test(t))return t;if(_.test(t))return t.replaceAll("/","-");let o=new Date(t);return d(o)},E=n=>{let t=m(n);return t||null},P=n=>{let t=m(n);if(!t)return null;let[o,i,s]=t.split("-").map(r=>Number.parseInt(r,10));return[o,i,s].some(r=>Number.isNaN(r))?null:new Date(o,i-1,s)};var O=(n,t,o)=>{let i=n.map((r,c)=>({id:`legacy-${c}`,authorName:r.name||"Unknown",content:r.text||"",isMine:!1,color:r.color||void 0,isLegacy:!0})),s=t.map(r=>({id:r.id,authorName:r.userName??"",content:r.content??"",createdAt:r.createdAt??"",isMine:o?r.userId===o:r.isMine,isLegacy:!1}));return[...i,...s]},F=n=>{if(!n)return"text-gray-700";let t=n.toLowerCase();return t.includes("red")||t.includes("\u8D64")?"text-red-600":t.includes("green")||t.includes("\u7DD1")?"text-green-600":t.includes("blue")||t.includes("\u9752")?"text-blue-600":t.includes("yellow")||t.includes("\u9EC4")?"text-yellow-600":t.includes("orange")||t.includes("\u6A59")?"text-orange-500":"text-gray-700"};var g=(r=>(r[r.DEBUG=0]="DEBUG",r[r.INFO=1]="INFO",r[r.WARN=2]="WARN",r[r.ERROR=3]="ERROR",r[r.NONE=4]="NONE",r))(g||{}),G=(n,t,o=console)=>{let i=s=>typeof s=="string"?[`${t} ${s}`]:[t,s];return{debug:(s,...r)=>{n<=0&&o.debug(...i(s),...r)},info:(s,...r)=>{n<=1&&o.info(...i(s),...r)},warn:(s,...r)=>{n<=2&&o.warn(...i(s),...r)},error:(s,...r)=>{n<=3&&o.error(...i(s),...r)}}};var e=require("zod"),y=e.z.object({name:e.z.string().nullish(),affiliation:e.z.string().nullish()}),f=e.z.object({name:e.z.string().nullish(),text:e.z.string().nullish(),color:e.z.string().nullish()}),b=e.z.object({id:e.z.number(),name:e.z.string().nullish(),color:e.z.string().nullish()}),u=e.z.object({id:e.z.number(),userId:e.z.string().nullish(),userName:e.z.string().nullish(),content:e.z.string().nullish(),createdAt:e.z.string().nullish(),isMine:e.z.boolean()}),a=e.z.object({reportHubId:e.z.number(),date:e.z.string().nullish(),createdAt:e.z.string().nullish(),author:e.z.string().nullish(),userId:e.z.string().nullish(),sourceType:e.z.string().nullish(),employeeName:e.z.string().nullish(),updatedBy:e.z.string().nullish(),updatedAt:e.z.string().nullish(),category:e.z.string().nullish(),creationCategory:e.z.string().nullish(),visitTimeFrom:e.z.string().nullish(),visitTimeTo:e.z.string().nullish(),customerName:e.z.string().nullish(),interviewers:e.z.array(y),subject:e.z.string().nullish(),content:e.z.string().nullish(),comments:e.z.array(f),isRead:e.z.boolean(),isStarred:e.z.boolean(),labels:e.z.array(b),commentItems:e.z.array(u)}),h=e.z.object({type:e.z.literal("connected")}),D=e.z.object({type:e.z.literal("status-update"),reportHubId:e.z.number(),statusType:e.z.enum(["star","read"]),value:e.z.boolean(),clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),I=e.z.object({type:e.z.literal("comment-add"),reportHubId:e.z.number(),comment:u,clientTempId:e.z.string()}),x=e.z.object({type:e.z.literal("comment-delete"),reportHubId:e.z.number(),commentId:e.z.number(),clientTempId:e.z.string()}),S=e.z.object({type:e.z.literal("report-create"),reportHubId:e.z.number(),report:a,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),w=e.z.object({type:e.z.literal("report-update"),reportHubId:e.z.number(),report:a,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),R=e.z.object({type:e.z.literal("report-publish"),reportHubId:e.z.number(),report:a,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),C=e.z.object({type:e.z.literal("report-delete"),reportHubId:e.z.number(),clientTempId:e.z.string()}),K=e.z.discriminatedUnion("type",[h,D,I,x,S,w,R,C]);var W=n=>{if(!n)return"-";let t=n.trim();return t===""?"-":t},T=n=>{if(!n)return"-";if(typeof n!="string")return n instanceof Date?T(n.toISOString()):String(n);let t=n.trim();if(t==="")return"-";let o=new Date(t);if(Number.isNaN(o.getTime()))return t;let i=o.getFullYear(),s=String(o.getMonth()+1).padStart(2,"0"),r=String(o.getDate()).padStart(2,"0");if(t.includes(":")||t.includes("T")){let N=String(o.getHours()).padStart(2,"0"),k=String(o.getMinutes()).padStart(2,"0"),A=String(o.getSeconds()).padStart(2,"0");return`${i}-${s}-${r}T${N}:${k}:${A}`}return`${i}-${s}-${r}`};0&&(module.exports={LogLevel,commentAddMessageSchema,commentDeleteMessageSchema,connectedMessageSchema,createLogger,dailyReportCommentItemSchema,dailyReportCommentSchema,dailyReportDetailSchema,dailyReportInterviewerSchema,dailyReportLabelDefSchema,dailyReportSseMessageSchema,fallbackText,formatBusinessDateDisplay,formatToIsoDate,mergeComments,normalizeBusinessDateKey,parseBusinessDateKeyToDate,reportCreateMessageSchema,reportDeleteMessageSchema,reportPublishMessageSchema,reportUpdateMessageSchema,resolveCommentColorClass,statusUpdateMessageSchema});
1
+ "use strict";var u=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var z=(t,n)=>{for(var o in n)u(t,o,{get:n[o],enumerable:!0})},E=(t,n,o,i)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of H(n))!U.call(t,s)&&s!==o&&u(t,s,{get:()=>n[s],enumerable:!(i=j(n,s))||i.enumerable});return t};var B=t=>E(u({},"__esModule",{value:!0}),t);var Q={};z(Q,{LogLevel:()=>y,commentAddMessageSchema:()=>S,commentDeleteMessageSchema:()=>R,compareIdsStreamOrder:()=>g,connectedMessageSchema:()=>h,createLogger:()=>Y,dailyReportAttachmentItemSchema:()=>I,dailyReportCommentItemSchema:()=>m,dailyReportCommentSchema:()=>f,dailyReportDetailSchema:()=>a,dailyReportInterviewerSchema:()=>b,dailyReportLabelDefSchema:()=>D,dailyReportSseMessageSchema:()=>q,fallbackText:()=>J,findIdsStreamResumeIndex:()=>W,formatBusinessDateDisplay:()=>O,formatToIsoDate:()=>N,isIdsStreamChunkLine:()=>K,mergeComments:()=>F,normalizeBusinessDateKey:()=>l,parseBusinessDateKeyToDate:()=>P,reportCreateMessageSchema:()=>C,reportDeleteMessageSchema:()=>T,reportPublishMessageSchema:()=>k,reportUpdateMessageSchema:()=>w,resolveCommentColorClass:()=>G,statusUpdateMessageSchema:()=>x});module.exports=B(Q);var _=/^\d{4}-\d{2}-\d{2}$/,L=/^\d{4}\/\d{2}\/\d{2}$/,c=t=>t<10?`0${t}`:`${t}`,d=t=>{if(Number.isNaN(t.getTime()))return null;let n=t.getFullYear(),o=c(t.getMonth()+1),i=c(t.getDate());return`${n}-${o}-${i}`},l=t=>{if(t==null)return null;if(t instanceof Date)return d(t);let n=t.trim();if(n==="")return null;if(_.test(n))return n;if(L.test(n))return n.replaceAll("/","-");let o=new Date(n);return d(o)},O=t=>{let n=l(t);return n||null},P=t=>{let n=l(t);if(!n)return null;let[o,i,s]=n.split("-").map(r=>Number.parseInt(r,10));return[o,i,s].some(r=>Number.isNaN(r))?null:new Date(o,i-1,s)};var F=(t,n,o)=>{let i=t.map((r,p)=>({id:`legacy-${p}`,authorName:r.name||"Unknown",content:r.text||"",isMine:!1,color:r.color||void 0,isLegacy:!0})),s=n.map(r=>({id:r.id,authorName:r.userName??"",content:r.content??"",createdAt:r.createdAt??"",isMine:o?r.userId===o:r.isMine,isLegacy:!1}));return[...i,...s]},G=t=>{if(!t)return"text-gray-700";let n=t.toLowerCase();return n.includes("red")||n.includes("\u8D64")?"text-red-600":n.includes("green")||n.includes("\u7DD1")?"text-green-600":n.includes("blue")||n.includes("\u9752")?"text-blue-600":n.includes("yellow")||n.includes("\u9EC4")?"text-yellow-600":n.includes("orange")||n.includes("\u6A59")?"text-orange-500":"text-gray-700"};var K=t=>typeof t=="object"&&t!==null&&Array.isArray(t.items),g=(t,n)=>t.businessDate!==n.businessDate?t.businessDate===null?1:n.businessDate===null||t.businessDate>n.businessDate?-1:1:n.reportHubId-t.reportHubId,W=(t,n)=>{let o=t.findIndex(i=>g({businessDate:i.businessDate,reportHubId:i.reportHubId},n)>0);return o===-1?t.length:o};var y=(r=>(r[r.DEBUG=0]="DEBUG",r[r.INFO=1]="INFO",r[r.WARN=2]="WARN",r[r.ERROR=3]="ERROR",r[r.NONE=4]="NONE",r))(y||{}),Y=(t,n,o=console)=>{let i=s=>typeof s=="string"?[`${n} ${s}`]:[n,s];return{debug:(s,...r)=>{t<=0&&o.debug(...i(s),...r)},info:(s,...r)=>{t<=1&&o.info(...i(s),...r)},warn:(s,...r)=>{t<=2&&o.warn(...i(s),...r)},error:(s,...r)=>{t<=3&&o.error(...i(s),...r)}}};var e=require("zod"),b=e.z.object({name:e.z.string().nullish(),affiliation:e.z.string().nullish()}),f=e.z.object({name:e.z.string().nullish(),text:e.z.string().nullish(),color:e.z.string().nullish()}),D=e.z.object({id:e.z.number(),name:e.z.string().nullish(),color:e.z.string().nullish()}),m=e.z.object({id:e.z.number(),userId:e.z.string().nullish(),userName:e.z.string().nullish(),content:e.z.string().nullish(),createdAt:e.z.string().nullish(),isMine:e.z.boolean()}),I=e.z.object({id:e.z.string(),fileName:e.z.string(),fileType:e.z.string().nullable(),fileSize:e.z.number().nullable(),createdAt:e.z.string().nullable(),state:e.z.enum(["present","absent","unknown"])}),a=e.z.object({reportHubId:e.z.number(),date:e.z.string().nullish(),createdAt:e.z.string().nullish(),author:e.z.string().nullish(),userId:e.z.string().nullish(),sourceType:e.z.string().nullish(),employeeName:e.z.string().nullish(),updatedBy:e.z.string().nullish(),updatedAt:e.z.string().nullish(),category:e.z.string().nullish(),creationCategory:e.z.string().nullish(),visitTimeFrom:e.z.string().nullish(),visitTimeTo:e.z.string().nullish(),customerName:e.z.string().nullish(),interviewers:e.z.array(b),subject:e.z.string().nullish(),content:e.z.string().nullish(),comments:e.z.array(f),isRead:e.z.boolean(),isStarred:e.z.boolean(),labels:e.z.array(D),commentItems:e.z.array(m),attachments:e.z.array(I).default([])}),h=e.z.object({type:e.z.literal("connected")}),x=e.z.object({type:e.z.literal("status-update"),reportHubId:e.z.number(),statusType:e.z.enum(["star","read"]),value:e.z.boolean(),clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),S=e.z.object({type:e.z.literal("comment-add"),reportHubId:e.z.number(),comment:m,clientTempId:e.z.string()}),R=e.z.object({type:e.z.literal("comment-delete"),reportHubId:e.z.number(),commentId:e.z.number(),clientTempId:e.z.string()}),C=e.z.object({type:e.z.literal("report-create"),reportHubId:e.z.number(),report:a,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),w=e.z.object({type:e.z.literal("report-update"),reportHubId:e.z.number(),report:a,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),k=e.z.object({type:e.z.literal("report-publish"),reportHubId:e.z.number(),report:a,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),T=e.z.object({type:e.z.literal("report-delete"),reportHubId:e.z.number(),clientTempId:e.z.string()}),q=e.z.discriminatedUnion("type",[h,x,S,R,C,w,k,T]);var J=t=>{if(!t)return"-";let n=t.trim();return n===""?"-":n},N=t=>{if(!t)return"-";if(typeof t!="string")return t instanceof Date?N(t.toISOString()):String(t);let n=t.trim();if(n==="")return"-";let o=new Date(n);if(Number.isNaN(o.getTime()))return n;let i=o.getFullYear(),s=String(o.getMonth()+1).padStart(2,"0"),r=String(o.getDate()).padStart(2,"0");if(n.includes(":")||n.includes("T")){let A=String(o.getHours()).padStart(2,"0"),M=String(o.getMinutes()).padStart(2,"0"),$=String(o.getSeconds()).padStart(2,"0");return`${i}-${s}-${r}T${A}:${M}:${$}`}return`${i}-${s}-${r}`};0&&(module.exports={LogLevel,commentAddMessageSchema,commentDeleteMessageSchema,compareIdsStreamOrder,connectedMessageSchema,createLogger,dailyReportAttachmentItemSchema,dailyReportCommentItemSchema,dailyReportCommentSchema,dailyReportDetailSchema,dailyReportInterviewerSchema,dailyReportLabelDefSchema,dailyReportSseMessageSchema,fallbackText,findIdsStreamResumeIndex,formatBusinessDateDisplay,formatToIsoDate,isIdsStreamChunkLine,mergeComments,normalizeBusinessDateKey,parseBusinessDateKeyToDate,reportCreateMessageSchema,reportDeleteMessageSchema,reportPublishMessageSchema,reportUpdateMessageSchema,resolveCommentColorClass,statusUpdateMessageSchema});
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/shared/business-date.ts","../src/shared/comment-adapter.ts","../src/shared/logger.ts","../src/shared/sse-schema.ts","../src/shared/text-utils.ts"],"sourcesContent":["/**\n * Shared (isomorphic) entry of @aiquants/daily-report: types, SSE schemas, and pure utilities.\n * @aiquants/daily-report の共有 (isomorphic) エントリ。型・SSE スキーマ・純粋ユーティリティを公開。\n */\nexport * from \"./shared/business-date\"\nexport * from \"./shared/comment-adapter\"\nexport * from \"./shared/logger\"\nexport * from \"./shared/sse-schema\"\nexport * from \"./shared/text-utils\"\nexport * from \"./shared/types\"\n","/**\n * Business date normalization and formatting helper functions.\n * 営業日の正規化とフォーマットを支援するユーティリティ群。\n */\n\ntype BusinessDateInput = string | Date | null | undefined\n\nconst ISO_DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/\nconst SLASH_DATE_PATTERN = /^\\d{4}\\/\\d{2}\\/\\d{2}$/\n\nconst zeroPad = (value: number): string => {\n return value < 10 ? `0${value}` : `${value}`\n}\n\nconst normalizeFromDate = (value: Date): string | null => {\n if (Number.isNaN(value.getTime())) {\n return null\n }\n\n const year = value.getFullYear()\n const month = zeroPad(value.getMonth() + 1)\n const day = zeroPad(value.getDate())\n return `${year}-${month}-${day}`\n}\n\n/**\n * Normalizes business date input into YYYY-MM-DD format string.\n * 営業日を YYYY-MM-DD 形式の文字列へ正規化する。\n */\nexport const normalizeBusinessDateKey = (value: BusinessDateInput): string | null => {\n if (value === null || value === undefined) {\n return null\n }\n\n if (value instanceof Date) {\n return normalizeFromDate(value)\n }\n\n const trimmed = value.trim()\n if (trimmed === \"\") {\n return null\n }\n\n if (ISO_DATE_PATTERN.test(trimmed)) {\n return trimmed\n }\n\n if (SLASH_DATE_PATTERN.test(trimmed)) {\n return trimmed.replaceAll(\"/\", \"-\")\n }\n\n const parsed = new Date(trimmed)\n return normalizeFromDate(parsed)\n}\n\n/**\n * Converts normalized business date into display format YYYY-MM-DD.\n * 正規化済みの営業日を YYYY-MM-DD 形式の表示文字列へ変換する。\n */\nexport const formatBusinessDateDisplay = (value: BusinessDateInput): string | null => {\n const normalized = normalizeBusinessDateKey(value)\n if (!normalized) {\n return null\n }\n return normalized\n}\n\n/**\n * Parses normalized business date into Date object.\n * 正規化した営業日を Date オブジェクトへ変換する。\n */\nexport const parseBusinessDateKeyToDate = (value: BusinessDateInput): Date | null => {\n const normalized = normalizeBusinessDateKey(value)\n if (!normalized) {\n return null\n }\n\n const [year, month, day] = normalized.split(\"-\").map((part) => Number.parseInt(part, 10))\n if ([year, month, day].some((component) => Number.isNaN(component))) {\n return null\n }\n\n return new Date(year, month - 1, day)\n}\n","/**\n * Adapters merging legacy JSON comments and relational comments for the UI.\n * レガシー JSON コメントとリレーショナルコメントを UI 向けに統合するアダプタ群。\n */\nimport type { DailyReportComment, DailyReportCommentItem } from \"./types\"\n\nexport type UIComment = {\n id: string | number\n authorName: string\n content: string\n createdAt?: string\n isMine: boolean\n color?: string\n isLegacy: boolean\n}\n\n/**\n * Merges legacy JSON comments and modern relational comments into a unified UI format.\n * レガシーな JSON コメントとモダンなリレーショナルコメントを統合された UI 形式にマージする。\n */\nexport const mergeComments = (legacyComments: DailyReportComment[], modernComments: DailyReportCommentItem[], currentUserId?: string | null): UIComment[] => {\n // 1. Legacy コメントの変換\n const legacyUIComments: UIComment[] = legacyComments.map((c, index) => ({\n id: `legacy-${index}`,\n authorName: c.name || \"Unknown\",\n content: c.text || \"\",\n isMine: false,\n color: c.color || undefined,\n isLegacy: true,\n }))\n\n // 2. Modern コメントの変換\n const modernUIComments: UIComment[] = modernComments.map((c) => ({\n id: c.id,\n authorName: c.userName ?? \"\",\n content: c.content ?? \"\",\n createdAt: c.createdAt ?? \"\",\n isMine: currentUserId ? c.userId === currentUserId : c.isMine,\n isLegacy: false,\n }))\n\n // 3. 結合 (Legacy を先に表示)\n return [...legacyUIComments, ...modernUIComments]\n}\n\n/**\n * Resolves comment color tokens into Tailwind text classes.\n * コメント色のキーワードを Tailwind のテキストクラスに変換する関数。\n */\nexport const resolveCommentColorClass = (color: string | null | undefined): string => {\n if (!color) {\n return \"text-gray-700\"\n }\n\n const normalized = color.toLowerCase()\n\n if (normalized.includes(\"red\") || normalized.includes(\"赤\")) {\n return \"text-red-600\"\n }\n\n if (normalized.includes(\"green\") || normalized.includes(\"緑\")) {\n return \"text-green-600\"\n }\n\n if (normalized.includes(\"blue\") || normalized.includes(\"青\")) {\n return \"text-blue-600\"\n }\n\n if (normalized.includes(\"yellow\") || normalized.includes(\"黄\")) {\n return \"text-yellow-600\"\n }\n\n if (normalized.includes(\"orange\") || normalized.includes(\"橙\")) {\n return \"text-orange-500\"\n }\n\n return \"text-gray-700\"\n}\n","/**\n * Minimal level-filtered logger used internally by the daily-report package.\n * daily-report パッケージ内部で使う最小のレベルフィルタ付きロガー。\n *\n * 消費アプリのロガー実装 (console 互換の debug/info/warn/error) を注入でき、\n * 未注入時は console にフォールバックする。\n */\n\n/** 出力フィルタリング用のログレベル。 */\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n NONE = 4,\n}\n\n/** Console 互換のロガーインターフェース。 */\nexport interface DailyReportLogger {\n debug(message?: unknown, ...optionalParams: unknown[]): void\n info(message?: unknown, ...optionalParams: unknown[]): void\n warn(message?: unknown, ...optionalParams: unknown[]): void\n error(message?: unknown, ...optionalParams: unknown[]): void\n}\n\n/**\n * Creates a prefixed, level-filtered logger delegating to the given implementation.\n * 指定実装へ委譲するプレフィックス付き・レベルフィルタ付きロガーを生成する処理。\n */\nexport const createLogger = (level: LogLevel, prefix: string, impl: DailyReportLogger = console): DailyReportLogger => {\n // 文字列メッセージはプレフィックスを連結、それ以外は先頭引数として付加する\n const format = (message: unknown): unknown[] => (typeof message === \"string\" ? [`${prefix} ${message}`] : [prefix, message])\n return {\n debug: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.DEBUG) impl.debug(...format(message), ...rest)\n },\n info: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.INFO) impl.info(...format(message), ...rest)\n },\n warn: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.WARN) impl.warn(...format(message), ...rest)\n },\n error: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.ERROR) impl.error(...format(message), ...rest)\n },\n }\n}\n","/**\n * Zod schemas for daily-report SSE messages (client/server shared contract).\n * 日報 SSE メッセージの zod スキーマ (client / server 共有契約)。\n */\nimport { z } from \"zod\"\nimport type { DailyReportCommentItem as DeclaredComment, DailyReportDetail as DeclaredDetail } from \"./types\"\n\n// --- サブスキーマ(types.ts の型と構造的に一致させる) ---\n\nexport const dailyReportInterviewerSchema = z.object({\n name: z.string().nullish(),\n affiliation: z.string().nullish(),\n})\n\nexport const dailyReportCommentSchema = z.object({\n name: z.string().nullish(),\n text: z.string().nullish(),\n color: z.string().nullish(),\n})\n\nexport const dailyReportLabelDefSchema = z.object({\n id: z.number(),\n name: z.string().nullish(),\n color: z.string().nullish(),\n})\n\nexport const dailyReportCommentItemSchema = z.object({\n id: z.number(),\n userId: z.string().nullish(),\n userName: z.string().nullish(),\n content: z.string().nullish(),\n createdAt: z.string().nullish(),\n isMine: z.boolean(),\n})\n\nexport const dailyReportDetailSchema = z.object({\n reportHubId: z.number(),\n date: z.string().nullish(),\n createdAt: z.string().nullish(),\n author: z.string().nullish(),\n userId: z.string().nullish(),\n sourceType: z.string().nullish(),\n employeeName: z.string().nullish(),\n updatedBy: z.string().nullish(),\n updatedAt: z.string().nullish(),\n category: z.string().nullish(),\n creationCategory: z.string().nullish(),\n visitTimeFrom: z.string().nullish(),\n visitTimeTo: z.string().nullish(),\n customerName: z.string().nullish(),\n interviewers: z.array(dailyReportInterviewerSchema),\n subject: z.string().nullish(),\n content: z.string().nullish(),\n comments: z.array(dailyReportCommentSchema),\n isRead: z.boolean(),\n isStarred: z.boolean(),\n labels: z.array(dailyReportLabelDefSchema),\n commentItems: z.array(dailyReportCommentItemSchema),\n})\n\n// --- SSE メッセージスキーマ(8種) ---\n\nexport const connectedMessageSchema = z.object({\n type: z.literal(\"connected\"),\n})\n\nexport const statusUpdateMessageSchema = z.object({\n type: z.literal(\"status-update\"),\n reportHubId: z.number(),\n statusType: z.enum([\"star\", \"read\"]),\n value: z.boolean(),\n clientTempId: z.string(),\n // recipientRawUserId はサーバーサイドフィルタリング専用。\n // SSE ルートが raw JSON から取得してフィルタ後に除去する。\n // クライアントには到達しないが、サーバー側の publish で .parse() を通すため定義が必要。\n recipientRawUserId: z.number().optional(),\n})\n\nexport const commentAddMessageSchema = z.object({\n type: z.literal(\"comment-add\"),\n reportHubId: z.number(),\n comment: dailyReportCommentItemSchema,\n clientTempId: z.string(),\n})\n\nexport const commentDeleteMessageSchema = z.object({\n type: z.literal(\"comment-delete\"),\n reportHubId: z.number(),\n commentId: z.number(),\n clientTempId: z.string(),\n})\n\nexport const reportCreateMessageSchema = z.object({\n type: z.literal(\"report-create\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportUpdateMessageSchema = z.object({\n type: z.literal(\"report-update\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportPublishMessageSchema = z.object({\n type: z.literal(\"report-publish\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportDeleteMessageSchema = z.object({\n type: z.literal(\"report-delete\"),\n reportHubId: z.number(),\n clientTempId: z.string(),\n})\n\n// --- Discriminated Union ---\n\nexport const dailyReportSseMessageSchema = z.discriminatedUnion(\"type\", [\n connectedMessageSchema,\n statusUpdateMessageSchema,\n commentAddMessageSchema,\n commentDeleteMessageSchema,\n reportCreateMessageSchema,\n reportUpdateMessageSchema,\n reportPublishMessageSchema,\n reportDeleteMessageSchema,\n])\n\n// --- 型エクスポート ---\n\nexport type DailyReportSseMessage = z.infer<typeof dailyReportSseMessageSchema>\n\n// --- コンパイル時の型互換チェック ---\n// Zod推論型が既存の型定義に代入可能であることを保証する。\n// ここでエラーが出たらスキーマと types.ts がずれている。\n\ntype _AssertDetailCompat = z.infer<typeof dailyReportDetailSchema> extends DeclaredDetail ? true : never\ntype _AssertCommentCompat = z.infer<typeof dailyReportCommentItemSchema> extends DeclaredComment ? true : never\nconst _detailCheck: _AssertDetailCompat = true\nconst _commentCheck: _AssertCommentCompat = true\nvoid _detailCheck\nvoid _commentCheck\n","/**\n * Shared text helpers for daily report view components.\n * 日報ビューコンポーネント向けの共通テキストヘルパー。\n */\n\n/**\n * Normalizes nullable text by trimming whitespace and applying fallback.\n * null 許容の文字列をトリムしつつフォールバック値を適用する関数。\n */\nexport const fallbackText = (value: string | null | undefined): string => {\n if (!value) {\n return \"-\"\n }\n const trimmed = value.trim()\n return trimmed === \"\" ? \"-\" : trimmed\n}\n\n/**\n * Formats a date string to ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss).\n * 日付文字列を ISO 8601 形式 (YYYY-MM-DD または YYYY-MM-DDTHH:mm:ss) に整形する関数。\n */\nexport const formatToIsoDate = (value: unknown): string => {\n if (!value) {\n return \"-\"\n }\n if (typeof value !== \"string\") {\n // If value is not a string (e.g. Date object), try to convert it to string or handle it\n if (value instanceof Date) {\n return formatToIsoDate(value.toISOString())\n }\n return String(value)\n }\n const trimmed = value.trim()\n if (trimmed === \"\") {\n return \"-\"\n }\n\n const date = new Date(trimmed)\n if (Number.isNaN(date.getTime())) {\n return trimmed\n }\n\n const year = date.getFullYear()\n const month = String(date.getMonth() + 1).padStart(2, \"0\")\n const day = String(date.getDate()).padStart(2, \"0\")\n\n const hasTime = trimmed.includes(\":\") || trimmed.includes(\"T\")\n\n if (hasTime) {\n const hours = String(date.getHours()).padStart(2, \"0\")\n const minutes = String(date.getMinutes()).padStart(2, \"0\")\n const seconds = String(date.getSeconds()).padStart(2, \"0\")\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`\n }\n\n return `${year}-${month}-${day}`\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,4BAAAC,EAAA,+BAAAC,EAAA,2BAAAC,EAAA,iBAAAC,EAAA,iCAAAC,EAAA,6BAAAC,EAAA,4BAAAC,EAAA,iCAAAC,EAAA,8BAAAC,EAAA,gCAAAC,EAAA,iBAAAC,EAAA,8BAAAC,EAAA,oBAAAC,EAAA,kBAAAC,EAAA,6BAAAC,EAAA,+BAAAC,EAAA,8BAAAC,EAAA,8BAAAC,EAAA,+BAAAC,EAAA,8BAAAC,EAAA,6BAAAC,EAAA,8BAAAC,IAAA,eAAAC,EAAAzB,GCOA,IAAM0B,EAAmB,sBACnBC,EAAqB,wBAErBC,EAAWC,GACNA,EAAQ,GAAK,IAAIA,CAAK,GAAK,GAAGA,CAAK,GAGxCC,EAAqBD,GAA+B,CACtD,GAAI,OAAO,MAAMA,EAAM,QAAQ,CAAC,EAC5B,OAAO,KAGX,IAAME,EAAOF,EAAM,YAAY,EACzBG,EAAQJ,EAAQC,EAAM,SAAS,EAAI,CAAC,EACpCI,EAAML,EAAQC,EAAM,QAAQ,CAAC,EACnC,MAAO,GAAGE,CAAI,IAAIC,CAAK,IAAIC,CAAG,EAClC,EAMaC,EAA4BL,GAA4C,CACjF,GAAIA,GAAU,KACV,OAAO,KAGX,GAAIA,aAAiB,KACjB,OAAOC,EAAkBD,CAAK,EAGlC,IAAMM,EAAUN,EAAM,K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AAIC,CAAK,IAAIC,CAAG,EAClC","names":["index_exports","__export","LogLevel","commentAddMessageSchema","commentDeleteMessageSchema","connectedMessageSchema","createLogger","dailyReportCommentItemSchema","dailyReportCommentSchema","dailyReportDetailSchema","dailyReportInterviewerSchema","dailyReportLabelDefSchema","dailyReportSseMessageSchema","fallbackText","formatBusinessDateDisplay","formatToIsoDate","mergeComments","normalizeBusinessDateKey","parseBusinessDateKeyToDate","reportCreateMessageSchema","reportDeleteMessageSchema","reportPublishMessageSchema","reportUpdateMessageSchema","resolveCommentColorClass","statusUpdateMessageSchema","__toCommonJS","ISO_DATE_PATTERN","SLASH_DATE_PATTERN","zeroPad","value","normalizeFromDate","year","month","day","normalizeBusinessDateKey","trimmed","parsed","formatBusinessDateDisplay","normalized","parseBusinessDateKeyToDate","part","component","mergeComments","legacyComments","modernComments","currentUserId","legacyUIComments","c","index","modernUIComments","resolveCommentColorClass","color","normalized","LogLevel","createLogger","level","prefix","impl","format","message","rest","import_zod","dailyReportInterviewerSchema","dailyReportCommentSchema","dailyReportLabelDefSchema","dailyReportCommentItemSchema","dailyReportDetailSchema","connectedMessageSchema","statusUpdateMessageSchema","commentAddMessageSchema","commentDeleteMessageSchema","reportCreateMessageSchema","reportUpdateMessageSchema","reportPublishMessageSchema","reportDeleteMessageSchema","dailyReportSseMessageSchema","fallbackText","value","trimmed","formatToIsoDate","date","year","month","day","hours","minutes","seconds"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/shared/business-date.ts","../src/shared/comment-adapter.ts","../src/shared/ids-stream.ts","../src/shared/logger.ts","../src/shared/sse-schema.ts","../src/shared/text-utils.ts"],"sourcesContent":["/**\n * Shared (isomorphic) entry of @aiquants/daily-report: types, SSE schemas, and pure utilities.\n * @aiquants/daily-report の共有 (isomorphic) エントリ。型・SSE スキーマ・純粋ユーティリティを公開。\n */\nexport * from \"./shared/business-date\"\nexport * from \"./shared/comment-adapter\"\nexport * from \"./shared/ids-stream\"\nexport * from \"./shared/logger\"\nexport * from \"./shared/sse-schema\"\nexport * from \"./shared/text-utils\"\nexport * from \"./shared/types\"\n","/**\n * Business date normalization and formatting helper functions.\n * 営業日の正規化とフォーマットを支援するユーティリティ群。\n */\n\ntype BusinessDateInput = string | Date | null | undefined\n\nconst ISO_DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/\nconst SLASH_DATE_PATTERN = /^\\d{4}\\/\\d{2}\\/\\d{2}$/\n\nconst zeroPad = (value: number): string => {\n return value < 10 ? `0${value}` : `${value}`\n}\n\nconst normalizeFromDate = (value: Date): string | null => {\n if (Number.isNaN(value.getTime())) {\n return null\n }\n\n const year = value.getFullYear()\n const month = zeroPad(value.getMonth() + 1)\n const day = zeroPad(value.getDate())\n return `${year}-${month}-${day}`\n}\n\n/**\n * Normalizes business date input into YYYY-MM-DD format string.\n * 営業日を YYYY-MM-DD 形式の文字列へ正規化する。\n */\nexport const normalizeBusinessDateKey = (value: BusinessDateInput): string | null => {\n if (value === null || value === undefined) {\n return null\n }\n\n if (value instanceof Date) {\n return normalizeFromDate(value)\n }\n\n const trimmed = value.trim()\n if (trimmed === \"\") {\n return null\n }\n\n if (ISO_DATE_PATTERN.test(trimmed)) {\n return trimmed\n }\n\n if (SLASH_DATE_PATTERN.test(trimmed)) {\n return trimmed.replaceAll(\"/\", \"-\")\n }\n\n const parsed = new Date(trimmed)\n return normalizeFromDate(parsed)\n}\n\n/**\n * Converts normalized business date into display format YYYY-MM-DD.\n * 正規化済みの営業日を YYYY-MM-DD 形式の表示文字列へ変換する。\n */\nexport const formatBusinessDateDisplay = (value: BusinessDateInput): string | null => {\n const normalized = normalizeBusinessDateKey(value)\n if (!normalized) {\n return null\n }\n return normalized\n}\n\n/**\n * Parses normalized business date into Date object.\n * 正規化した営業日を Date オブジェクトへ変換する。\n */\nexport const parseBusinessDateKeyToDate = (value: BusinessDateInput): Date | null => {\n const normalized = normalizeBusinessDateKey(value)\n if (!normalized) {\n return null\n }\n\n const [year, month, day] = normalized.split(\"-\").map((part) => Number.parseInt(part, 10))\n if ([year, month, day].some((component) => Number.isNaN(component))) {\n return null\n }\n\n return new Date(year, month - 1, day)\n}\n","/**\n * Adapters merging legacy JSON comments and relational comments for the UI.\n * レガシー JSON コメントとリレーショナルコメントを UI 向けに統合するアダプタ群。\n */\nimport type { DailyReportComment, DailyReportCommentItem } from \"./types\"\n\nexport type UIComment = {\n id: string | number\n authorName: string\n content: string\n createdAt?: string\n isMine: boolean\n color?: string\n isLegacy: boolean\n}\n\n/**\n * Merges legacy JSON comments and modern relational comments into a unified UI format.\n * レガシーな JSON コメントとモダンなリレーショナルコメントを統合された UI 形式にマージする。\n */\nexport const mergeComments = (legacyComments: DailyReportComment[], modernComments: DailyReportCommentItem[], currentUserId?: string | null): UIComment[] => {\n // 1. Legacy コメントの変換\n const legacyUIComments: UIComment[] = legacyComments.map((c, index) => ({\n id: `legacy-${index}`,\n authorName: c.name || \"Unknown\",\n content: c.text || \"\",\n isMine: false,\n color: c.color || undefined,\n isLegacy: true,\n }))\n\n // 2. Modern コメントの変換\n const modernUIComments: UIComment[] = modernComments.map((c) => ({\n id: c.id,\n authorName: c.userName ?? \"\",\n content: c.content ?? \"\",\n createdAt: c.createdAt ?? \"\",\n isMine: currentUserId ? c.userId === currentUserId : c.isMine,\n isLegacy: false,\n }))\n\n // 3. 結合 (Legacy を先に表示)\n return [...legacyUIComments, ...modernUIComments]\n}\n\n/**\n * Resolves comment color tokens into Tailwind text classes.\n * コメント色のキーワードを Tailwind のテキストクラスに変換する関数。\n */\nexport const resolveCommentColorClass = (color: string | null | undefined): string => {\n if (!color) {\n return \"text-gray-700\"\n }\n\n const normalized = color.toLowerCase()\n\n if (normalized.includes(\"red\") || normalized.includes(\"赤\")) {\n return \"text-red-600\"\n }\n\n if (normalized.includes(\"green\") || normalized.includes(\"緑\")) {\n return \"text-green-600\"\n }\n\n if (normalized.includes(\"blue\") || normalized.includes(\"青\")) {\n return \"text-blue-600\"\n }\n\n if (normalized.includes(\"yellow\") || normalized.includes(\"黄\")) {\n return \"text-yellow-600\"\n }\n\n if (normalized.includes(\"orange\") || normalized.includes(\"橙\")) {\n return \"text-orange-500\"\n }\n\n return \"text-gray-700\"\n}\n","/**\n * Wire contract and ordering helpers for the daily-report ids NDJSON stream.\n * 日報 ID 一覧 NDJSON ストリームのワイヤ契約と並び順ヘルパー。\n *\n * サーバーは `GET {apiBasePath}/ids-stream` で 1 行 1 JSON の NDJSON を返す。\n * 行は原則 {@link DailyReportIdsStreamChunkLine} で、送出中に予期しない失敗が\n * 起きた場合のみ {@link DailyReportIdsStreamErrorLine} を 1 行流して正常クローズする\n * (クライアントは「isLast 無しで終端」を再開シグナルとして扱う)。\n *\n * 並び順は SQL の `ORDER BY business_date DESC, id DESC` (MSSQL の DESC は NULL を\n * 末尾に置く) と完全一致させる。カーソル再開はこの全順序に対する「厳密に後」の\n * 位置からのスライスとして定義する。\n */\nimport type { DailyReportItem } from \"./types\"\n\n/** ストリーム再開カーソル。直前チャンク末尾アイテムの並び順キー。 */\nexport type DailyReportIdsStreamCursor = {\n /** 営業日 (YYYY-MM-DD)。null は「営業日なし領域」(並び順の末尾) を表す。 */\n businessDate: string | null\n /** 日報 Hub ID。 */\n reportHubId: number\n}\n\n/** データを運ぶ NDJSON 行。 */\nexport type DailyReportIdsStreamChunkLine = {\n /** このチャンクのアイテム群 (並び順どおり)。 */\n items: DailyReportItem[]\n /** 次チャンクの再開カーソル。最終チャンクでは null。 */\n nextCursor: DailyReportIdsStreamCursor | null\n /** これが最終チャンクかどうか。 */\n isLast: boolean\n /** 全体件数。接続ごとの先頭行にのみ載る。 */\n total?: number\n}\n\n/** サーバー側の予期しない失敗を伝える NDJSON 行 (内部情報は含めない)。 */\nexport type DailyReportIdsStreamErrorLine = {\n error: string\n}\n\n/** NDJSON 1 行のユニオン。 */\nexport type DailyReportIdsStreamLine = DailyReportIdsStreamChunkLine | DailyReportIdsStreamErrorLine\n\n/**\n * Type guard for chunk lines (anything else is treated as an error line).\n * チャンク行の型ガード (それ以外はエラー行として扱う)。\n *\n * @param line Parsed NDJSON line. パース済みの NDJSON 行。\n * @returns True when the line carries items. アイテムを運ぶ行なら true。\n */\nexport const isIdsStreamChunkLine = (line: unknown): line is DailyReportIdsStreamChunkLine => {\n return typeof line === \"object\" && line !== null && Array.isArray((line as { items?: unknown }).items)\n}\n\n/**\n * Total order of the ids stream: businessDate DESC (NULL last), then id DESC.\n * ids ストリームの全順序。営業日降順 (NULL は末尾)、同日内は ID 降順。\n *\n * MSSQL の `ORDER BY business_date DESC, id DESC` と一致させることが唯一の存在理由。\n * 営業日は正規化済みの `YYYY-MM-DD` 文字列なので辞書順比較 = 時系列比較になる。\n *\n * @param a Left key. 左辺キー。\n * @param b Right key. 右辺キー。\n * @returns Negative when `a` streams before `b`. `a` が先に流れるなら負値。\n */\nexport const compareIdsStreamOrder = (a: DailyReportIdsStreamCursor, b: DailyReportIdsStreamCursor): number => {\n if (a.businessDate !== b.businessDate) {\n // null 営業日は並び順の末尾 (MSSQL DESC の NULL 末尾挙動へ揃える)\n if (a.businessDate === null) return 1\n if (b.businessDate === null) return -1\n return a.businessDate > b.businessDate ? -1 : 1\n }\n return b.reportHubId - a.reportHubId\n}\n\n/**\n * Finds the first index that streams strictly after the cursor.\n * カーソルより厳密に後ろへ並ぶ最初のインデックスを求める処理。\n *\n * 配列は必ずストリーム順 (SQL の ORDER BY) で渡されるが、比較器とのズレが\n * あっても壊れない線形走査で決定する (件数は高々数万・再開時のみの実行)。\n * 該当なし (カーソルが末尾以降) は `items.length` を返し、空チャンク +\n * `isLast: true` の正常終端に落ちる。\n *\n * @param items Stream-ordered items. ストリーム順のアイテム配列。\n * @param cursor Resume cursor. 再開カーソル。\n * @returns Index to resume emission from. 送出を再開するインデックス。\n */\nexport const findIdsStreamResumeIndex = (items: readonly DailyReportItem[], cursor: DailyReportIdsStreamCursor): number => {\n const index = items.findIndex((item) => compareIdsStreamOrder({ businessDate: item.businessDate, reportHubId: item.reportHubId }, cursor) > 0)\n return index === -1 ? items.length : index\n}\n","/**\n * Minimal level-filtered logger used internally by the daily-report package.\n * daily-report パッケージ内部で使う最小のレベルフィルタ付きロガー。\n *\n * 消費アプリのロガー実装 (console 互換の debug/info/warn/error) を注入でき、\n * 未注入時は console にフォールバックする。\n */\n\n/** 出力フィルタリング用のログレベル。 */\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n NONE = 4,\n}\n\n/** Console 互換のロガーインターフェース。 */\nexport interface DailyReportLogger {\n debug(message?: unknown, ...optionalParams: unknown[]): void\n info(message?: unknown, ...optionalParams: unknown[]): void\n warn(message?: unknown, ...optionalParams: unknown[]): void\n error(message?: unknown, ...optionalParams: unknown[]): void\n}\n\n/**\n * Creates a prefixed, level-filtered logger delegating to the given implementation.\n * 指定実装へ委譲するプレフィックス付き・レベルフィルタ付きロガーを生成する処理。\n */\nexport const createLogger = (level: LogLevel, prefix: string, impl: DailyReportLogger = console): DailyReportLogger => {\n // 文字列メッセージはプレフィックスを連結、それ以外は先頭引数として付加する\n const format = (message: unknown): unknown[] => (typeof message === \"string\" ? [`${prefix} ${message}`] : [prefix, message])\n return {\n debug: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.DEBUG) impl.debug(...format(message), ...rest)\n },\n info: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.INFO) impl.info(...format(message), ...rest)\n },\n warn: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.WARN) impl.warn(...format(message), ...rest)\n },\n error: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.ERROR) impl.error(...format(message), ...rest)\n },\n }\n}\n","/**\n * Zod schemas for daily-report SSE messages (client/server shared contract).\n * 日報 SSE メッセージの zod スキーマ (client / server 共有契約)。\n */\nimport { z } from \"zod\"\nimport type { DailyReportCommentItem as DeclaredComment, DailyReportDetail as DeclaredDetail } from \"./types\"\n\n// --- サブスキーマ(types.ts の型と構造的に一致させる) ---\n\nexport const dailyReportInterviewerSchema = z.object({\n name: z.string().nullish(),\n affiliation: z.string().nullish(),\n})\n\nexport const dailyReportCommentSchema = z.object({\n name: z.string().nullish(),\n text: z.string().nullish(),\n color: z.string().nullish(),\n})\n\nexport const dailyReportLabelDefSchema = z.object({\n id: z.number(),\n name: z.string().nullish(),\n color: z.string().nullish(),\n})\n\nexport const dailyReportCommentItemSchema = z.object({\n id: z.number(),\n userId: z.string().nullish(),\n userName: z.string().nullish(),\n content: z.string().nullish(),\n createdAt: z.string().nullish(),\n isMine: z.boolean(),\n})\n\n/**\n * 添付ファイル 1 件のスキーマ。\n *\n * 周囲のフィールドは `.nullish()` だが、ここは意図して `.nullable()` を使う。\n * `.nullish()` は推論キーを任意 (`?`) にするため、`types.ts` 側の必須 `fileType: string | null`\n * へ代入できず、ファイル末尾の `_AssertDetailCompat` が `never` に落ちてコンパイルエラーになる。\n * 既存の `.nullish()` フィールドはいずれも `types.ts` 側が `?` 付きの任意キーとペアになっており、\n * 「`.nullish()` ↔ 任意キー」「`.nullable()` ↔ 必須 `| null`」の対応で揃っている。\n * `| undefined` を混ぜないことは、詳細型を消費する DuckDB ステージ行の要請でもある。\n */\nexport const dailyReportAttachmentItemSchema = z.object({\n id: z.string(),\n fileName: z.string(),\n fileType: z.string().nullable(),\n fileSize: z.number().nullable(),\n createdAt: z.string().nullable(),\n state: z.enum([\"present\", \"absent\", \"unknown\"]),\n})\n\nexport const dailyReportDetailSchema = z.object({\n reportHubId: z.number(),\n date: z.string().nullish(),\n createdAt: z.string().nullish(),\n author: z.string().nullish(),\n userId: z.string().nullish(),\n sourceType: z.string().nullish(),\n employeeName: z.string().nullish(),\n updatedBy: z.string().nullish(),\n updatedAt: z.string().nullish(),\n category: z.string().nullish(),\n creationCategory: z.string().nullish(),\n visitTimeFrom: z.string().nullish(),\n visitTimeTo: z.string().nullish(),\n customerName: z.string().nullish(),\n interviewers: z.array(dailyReportInterviewerSchema),\n subject: z.string().nullish(),\n content: z.string().nullish(),\n comments: z.array(dailyReportCommentSchema),\n isRead: z.boolean(),\n isStarred: z.boolean(),\n labels: z.array(dailyReportLabelDefSchema),\n commentItems: z.array(dailyReportCommentItemSchema),\n // ❗ `.default([])` は必須。SSE の実体は永続 Redis Stream (MAXLEN 保持) であり、\n // 配備をまたいで**旧形式のエントリが残る**。共有リーダーはプロセス起動時に先頭から\n // 再生し、再接続クライアントの catch-up も同じエントリを読み直すため、\n // このキーを必須にすると添付機能を入れる前に publish された全エントリが\n // fail-closed で捨てられ、再接続タブへ更新が永久に届かなくなる。\n // 送信側の詰め忘れ検知は types.ts の必須フィールドと `_AssertDetailCompat`\n // (出力型は既定値適用後なので必須のまま) が担っており、ここを緩めても失われない。\n attachments: z.array(dailyReportAttachmentItemSchema).default([]),\n})\n\n// --- SSE メッセージスキーマ(8種) ---\n\nexport const connectedMessageSchema = z.object({\n type: z.literal(\"connected\"),\n})\n\nexport const statusUpdateMessageSchema = z.object({\n type: z.literal(\"status-update\"),\n reportHubId: z.number(),\n statusType: z.enum([\"star\", \"read\"]),\n value: z.boolean(),\n clientTempId: z.string(),\n // recipientRawUserId はサーバーサイドフィルタリング専用。\n // SSE ルートが raw JSON から取得してフィルタ後に除去する。\n // クライアントには到達しないが、サーバー側の publish で .parse() を通すため定義が必要。\n recipientRawUserId: z.number().optional(),\n})\n\nexport const commentAddMessageSchema = z.object({\n type: z.literal(\"comment-add\"),\n reportHubId: z.number(),\n comment: dailyReportCommentItemSchema,\n clientTempId: z.string(),\n})\n\nexport const commentDeleteMessageSchema = z.object({\n type: z.literal(\"comment-delete\"),\n reportHubId: z.number(),\n commentId: z.number(),\n clientTempId: z.string(),\n})\n\nexport const reportCreateMessageSchema = z.object({\n type: z.literal(\"report-create\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportUpdateMessageSchema = z.object({\n type: z.literal(\"report-update\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportPublishMessageSchema = z.object({\n type: z.literal(\"report-publish\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportDeleteMessageSchema = z.object({\n type: z.literal(\"report-delete\"),\n reportHubId: z.number(),\n clientTempId: z.string(),\n})\n\n// --- Discriminated Union ---\n\nexport const dailyReportSseMessageSchema = z.discriminatedUnion(\"type\", [\n connectedMessageSchema,\n statusUpdateMessageSchema,\n commentAddMessageSchema,\n commentDeleteMessageSchema,\n reportCreateMessageSchema,\n reportUpdateMessageSchema,\n reportPublishMessageSchema,\n reportDeleteMessageSchema,\n])\n\n// --- 型エクスポート ---\n\nexport type DailyReportSseMessage = z.infer<typeof dailyReportSseMessageSchema>\n\n// --- コンパイル時の型互換チェック ---\n// Zod推論型が既存の型定義に代入可能であることを保証する。\n// ここでエラーが出たらスキーマと types.ts がずれている。\n\ntype _AssertDetailCompat = z.infer<typeof dailyReportDetailSchema> extends DeclaredDetail ? true : never\ntype _AssertCommentCompat = z.infer<typeof dailyReportCommentItemSchema> extends DeclaredComment ? true : never\nconst _detailCheck: _AssertDetailCompat = true\nconst _commentCheck: _AssertCommentCompat = true\nvoid _detailCheck\nvoid _commentCheck\n","/**\n * Shared text helpers for daily report view components.\n * 日報ビューコンポーネント向けの共通テキストヘルパー。\n */\n\n/**\n * Normalizes nullable text by trimming whitespace and applying fallback.\n * null 許容の文字列をトリムしつつフォールバック値を適用する関数。\n */\nexport const fallbackText = (value: string | null | undefined): string => {\n if (!value) {\n return \"-\"\n }\n const trimmed = value.trim()\n return trimmed === \"\" ? \"-\" : trimmed\n}\n\n/**\n * Formats a date string to ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss).\n * 日付文字列を ISO 8601 形式 (YYYY-MM-DD または YYYY-MM-DDTHH:mm:ss) に整形する関数。\n */\nexport const formatToIsoDate = (value: unknown): string => {\n if (!value) {\n return \"-\"\n }\n if (typeof value !== \"string\") {\n // If value is not a string (e.g. Date object), try to convert it to string or handle it\n if (value instanceof Date) {\n return formatToIsoDate(value.toISOString())\n }\n return String(value)\n }\n const trimmed = value.trim()\n if (trimmed === \"\") {\n return \"-\"\n }\n\n const date = new Date(trimmed)\n if (Number.isNaN(date.getTime())) {\n return trimmed\n }\n\n const year = date.getFullYear()\n const month = String(date.getMonth() + 1).padStart(2, \"0\")\n const day = String(date.getDate()).padStart(2, \"0\")\n\n const hasTime = trimmed.includes(\":\") || trimmed.includes(\"T\")\n\n if (hasTime) {\n const hours = String(date.getHours()).padStart(2, \"0\")\n const minutes = String(date.getMinutes()).padStart(2, \"0\")\n const seconds = String(date.getSeconds()).padStart(2, \"0\")\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`\n }\n\n return `${year}-${month}-${day}`\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,4BAAAC,EAAA,+BAAAC,EAAA,0BAAAC,EAAA,2BAAAC,EAAA,iBAAAC,EAAA,oCAAAC,EAAA,iCAAAC,EAAA,6BAAAC,EAAA,4BAAAC,EAAA,iCAAAC,EAAA,8BAAAC,EAAA,gCAAAC,EAAA,iBAAAC,EAAA,6BAAAC,EAAA,8BAAAC,EAAA,oBAAAC,EAAA,yBAAAC,EAAA,kBAAAC,EAAA,6BAAAC,EAAA,+BAAAC,EAAA,8BAAAC,EAAA,8BAAAC,EAAA,+BAAAC,EAAA,8BAAAC,EAAA,6BAAAC,EAAA,8BAAAC,IAAA,eAAAC,EAAA7B,GCOA,IAAM8B,EAAmB,sBACnBC,EAAqB,wBAErBC,EAAWC,GACNA,EAAQ,GAAK,IAAIA,CAAK,GAAK,GAAGA,CAAK,GAGxCC,EAAqBD,GAA+B,CACtD,GAAI,OAAO,MAAMA,EAAM,QAAQ,CAAC,EAC5B,OAAO,KAGX,IAAME,EAAOF,EAAM,YAAY,EACzBG,E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ACAC,EACAC,EACAC,EACAC,CACJ,CAAC,ECvJM,IAAME,EAAgBC,GAA6C,CACtE,GAAI,CAACA,EACD,MAAO,IAEX,IAAMC,EAAUD,EAAM,KAAK,EAC3B,OAAOC,IAAY,GAAK,IAAMA,CAClC,EAMaC,EAAmBF,GAA2B,CACvD,GAAI,CAACA,EACD,MAAO,IAEX,GAAI,OAAOA,GAAU,SAEjB,OAAIA,aAAiB,KACVE,EAAgBF,EAAM,YAAY,CAAC,EAEvC,OAAOA,CAAK,EAEvB,IAAMC,EAAUD,EAAM,KAAK,EAC3B,GAAIC,IAAY,GACZ,MAAO,IAGX,IAAME,EAAO,IAAI,KAAKF,CAAO,EAC7B,GAAI,OAAO,MAAME,EAAK,QAAQ,CAAC,EAC3B,OAAOF,EAGX,IAAMG,EAAOD,EAAK,YAAY,EACxBE,EAAQ,OAAOF,EAAK,SAAS,EAAI,CAAC,EAAE,SAAS,EAAG,GAAG,EACnDG,EAAM,OAAOH,EAAK,QAAQ,CAAC,EAAE,SAAS,EAAG,GAAG,EAIlD,GAFgBF,EAAQ,SAAS,GAAG,GAAKA,EAAQ,SAAS,GAAG,EAEhD,CACT,IAAMM,EAAQ,OAAOJ,EAAK,SAAS,CAAC,EAAE,SAAS,EAAG,GAAG,EAC/CK,EAAU,OAAOL,EAAK,WAAW,CAAC,EAAE,SAAS,EAAG,GAAG,EACnDM,EAAU,OAAON,EAAK,WAAW,CAAC,EAAE,SAAS,EAAG,GAAG,EACzD,MAAO,GAAGC,CAAI,IAAIC,CAAK,IAAIC,CAAG,IAAIC,CAAK,IAAIC,CAAO,IAAIC,CAAO,EACjE,CAEA,MAAO,GAAGL,CAAI,IAAIC,CAAK,IAAIC,CAAG,EAClC","names":["index_exports","__export","LogLevel","commentAddMessageSchema","commentDeleteMessageSchema","compareIdsStreamOrder","connectedMessageSchema","createLogger","dailyReportAttachmentItemSchema","dailyReportCommentItemSchema","dailyReportCommentSchema","dailyReportDetailSchema","dailyReportInterviewerSchema","dailyReportLabelDefSchema","dailyReportSseMessageSchema","fallbackText","findIdsStreamResumeIndex","formatBusinessDateDisplay","formatToIsoDate","isIdsStreamChunkLine","mergeComments","normalizeBusinessDateKey","parseBusinessDateKeyToDate","reportCreateMessageSchema","reportDeleteMessageSchema","reportPublishMessageSchema","reportUpdateMessageSchema","resolveCommentColorClass","statusUpdateMessageSchema","__toCommonJS","ISO_DATE_PATTERN","SLASH_DATE_PATTERN","zeroPad","value","normalizeFromDate","year","month","day","normalizeBusinessDateKey","trimmed","parsed","formatBusinessDateDisplay","normalized","parseBusinessDateKeyToDate","part","component","mergeComments","legacyComments","modernComments","currentUserId","legacyUIComments","c","index","modernUIComments","resolveCommentColorClass","color","normalized","isIdsStreamChunkLine","line","compareIdsStreamOrder","a","b","findIdsStreamResumeIndex","items","cursor","index","item","LogLevel","createLogger","level","prefix","impl","format","message","rest","import_zod","dailyReportInterviewerSchema","dailyReportCommentSchema","dailyReportLabelDefSchema","dailyReportCommentItemSchema","dailyReportAttachmentItemSchema","dailyReportDetailSchema","connectedMessageSchema","statusUpdateMessageSchema","commentAddMessageSchema","commentDeleteMessageSchema","reportCreateMessageSchema","reportUpdateMessageSchema","reportPublishMessageSchema","reportDeleteMessageSchema","dailyReportSseMessageSchema","fallbackText","value","trimmed","formatToIsoDate","date","year","month","day","hours","minutes","seconds"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var f=/^\d{4}-\d{2}-\d{2}$/,b=/^\d{4}\/\d{2}\/\d{2}$/,m=n=>n<10?`0${n}`:`${n}`,u=n=>{if(Number.isNaN(n.getTime()))return null;let t=n.getFullYear(),o=m(n.getMonth()+1),i=m(n.getDate());return`${t}-${o}-${i}`},c=n=>{if(n==null)return null;if(n instanceof Date)return u(n);let t=n.trim();if(t==="")return null;if(f.test(t))return t;if(b.test(t))return t.replaceAll("/","-");let o=new Date(t);return u(o)},$=n=>{let t=c(n);return t||null},U=n=>{let t=c(n);if(!t)return null;let[o,i,s]=t.split("-").map(r=>Number.parseInt(r,10));return[o,i,s].some(r=>Number.isNaN(r))?null:new Date(o,i-1,s)};var z=(n,t,o)=>{let i=n.map((r,l)=>({id:`legacy-${l}`,authorName:r.name||"Unknown",content:r.text||"",isMine:!1,color:r.color||void 0,isLegacy:!0})),s=t.map(r=>({id:r.id,authorName:r.userName??"",content:r.content??"",createdAt:r.createdAt??"",isMine:o?r.userId===o:r.isMine,isLegacy:!1}));return[...i,...s]},B=n=>{if(!n)return"text-gray-700";let t=n.toLowerCase();return t.includes("red")||t.includes("\u8D64")?"text-red-600":t.includes("green")||t.includes("\u7DD1")?"text-green-600":t.includes("blue")||t.includes("\u9752")?"text-blue-600":t.includes("yellow")||t.includes("\u9EC4")?"text-yellow-600":t.includes("orange")||t.includes("\u6A59")?"text-orange-500":"text-gray-700"};var h=(r=>(r[r.DEBUG=0]="DEBUG",r[r.INFO=1]="INFO",r[r.WARN=2]="WARN",r[r.ERROR=3]="ERROR",r[r.NONE=4]="NONE",r))(h||{}),_=(n,t,o=console)=>{let i=s=>typeof s=="string"?[`${t} ${s}`]:[t,s];return{debug:(s,...r)=>{n<=0&&o.debug(...i(s),...r)},info:(s,...r)=>{n<=1&&o.info(...i(s),...r)},warn:(s,...r)=>{n<=2&&o.warn(...i(s),...r)},error:(s,...r)=>{n<=3&&o.error(...i(s),...r)}}};import{z as e}from"zod";var D=e.object({name:e.string().nullish(),affiliation:e.string().nullish()}),I=e.object({name:e.string().nullish(),text:e.string().nullish(),color:e.string().nullish()}),x=e.object({id:e.number(),name:e.string().nullish(),color:e.string().nullish()}),p=e.object({id:e.number(),userId:e.string().nullish(),userName:e.string().nullish(),content:e.string().nullish(),createdAt:e.string().nullish(),isMine:e.boolean()}),a=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(D),subject:e.string().nullish(),content:e.string().nullish(),comments:e.array(I),isRead:e.boolean(),isStarred:e.boolean(),labels:e.array(x),commentItems:e.array(p)}),S=e.object({type:e.literal("connected")}),w=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()}),R=e.object({type:e.literal("comment-add"),reportHubId:e.number(),comment:p,clientTempId:e.string()}),C=e.object({type:e.literal("comment-delete"),reportHubId:e.number(),commentId:e.number(),clientTempId:e.string()}),T=e.object({type:e.literal("report-create"),reportHubId:e.number(),report:a,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),N=e.object({type:e.literal("report-update"),reportHubId:e.number(),report:a,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),k=e.object({type:e.literal("report-publish"),reportHubId:e.number(),report:a,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),A=e.object({type:e.literal("report-delete"),reportHubId:e.number(),clientTempId:e.string()}),O=e.discriminatedUnion("type",[S,w,R,C,T,N,k,A]);var G=n=>{if(!n)return"-";let t=n.trim();return t===""?"-":t},M=n=>{if(!n)return"-";if(typeof n!="string")return n instanceof Date?M(n.toISOString()):String(n);let t=n.trim();if(t==="")return"-";let o=new Date(t);if(Number.isNaN(o.getTime()))return t;let i=o.getFullYear(),s=String(o.getMonth()+1).padStart(2,"0"),r=String(o.getDate()).padStart(2,"0");if(t.includes(":")||t.includes("T")){let d=String(o.getHours()).padStart(2,"0"),g=String(o.getMinutes()).padStart(2,"0"),y=String(o.getSeconds()).padStart(2,"0");return`${i}-${s}-${r}T${d}:${g}:${y}`}return`${i}-${s}-${r}`};export{h as LogLevel,R as commentAddMessageSchema,C as commentDeleteMessageSchema,S as connectedMessageSchema,_ as createLogger,p as dailyReportCommentItemSchema,I as dailyReportCommentSchema,a as dailyReportDetailSchema,D as dailyReportInterviewerSchema,x as dailyReportLabelDefSchema,O as dailyReportSseMessageSchema,G as fallbackText,$ as formatBusinessDateDisplay,M as formatToIsoDate,z as mergeComments,c as normalizeBusinessDateKey,U as parseBusinessDateKeyToDate,T as reportCreateMessageSchema,A as reportDeleteMessageSchema,k as reportPublishMessageSchema,N as reportUpdateMessageSchema,B as resolveCommentColorClass,w as statusUpdateMessageSchema};
1
+ var b=/^\d{4}-\d{2}-\d{2}$/,f=/^\d{4}\/\d{2}\/\d{2}$/,l=t=>t<10?`0${t}`:`${t}`,m=t=>{if(Number.isNaN(t.getTime()))return null;let n=t.getFullYear(),o=l(t.getMonth()+1),i=l(t.getDate());return`${n}-${o}-${i}`},p=t=>{if(t==null)return null;if(t instanceof Date)return m(t);let n=t.trim();if(n==="")return null;if(b.test(n))return n;if(f.test(n))return n.replaceAll("/","-");let o=new Date(n);return m(o)},H=t=>{let n=p(t);return n||null},U=t=>{let n=p(t);if(!n)return null;let[o,i,s]=n.split("-").map(r=>Number.parseInt(r,10));return[o,i,s].some(r=>Number.isNaN(r))?null:new Date(o,i-1,s)};var E=(t,n,o)=>{let i=t.map((r,u)=>({id:`legacy-${u}`,authorName:r.name||"Unknown",content:r.text||"",isMine:!1,color:r.color||void 0,isLegacy:!0})),s=n.map(r=>({id:r.id,authorName:r.userName??"",content:r.content??"",createdAt:r.createdAt??"",isMine:o?r.userId===o:r.isMine,isLegacy:!1}));return[...i,...s]},B=t=>{if(!t)return"text-gray-700";let n=t.toLowerCase();return n.includes("red")||n.includes("\u8D64")?"text-red-600":n.includes("green")||n.includes("\u7DD1")?"text-green-600":n.includes("blue")||n.includes("\u9752")?"text-blue-600":n.includes("yellow")||n.includes("\u9EC4")?"text-yellow-600":n.includes("orange")||n.includes("\u6A59")?"text-orange-500":"text-gray-700"};var L=t=>typeof t=="object"&&t!==null&&Array.isArray(t.items),D=(t,n)=>t.businessDate!==n.businessDate?t.businessDate===null?1:n.businessDate===null||t.businessDate>n.businessDate?-1:1:n.reportHubId-t.reportHubId,O=(t,n)=>{let o=t.findIndex(i=>D({businessDate:i.businessDate,reportHubId:i.reportHubId},n)>0);return o===-1?t.length:o};var I=(r=>(r[r.DEBUG=0]="DEBUG",r[r.INFO=1]="INFO",r[r.WARN=2]="WARN",r[r.ERROR=3]="ERROR",r[r.NONE=4]="NONE",r))(I||{}),F=(t,n,o=console)=>{let i=s=>typeof s=="string"?[`${n} ${s}`]:[n,s];return{debug:(s,...r)=>{t<=0&&o.debug(...i(s),...r)},info:(s,...r)=>{t<=1&&o.info(...i(s),...r)},warn:(s,...r)=>{t<=2&&o.warn(...i(s),...r)},error:(s,...r)=>{t<=3&&o.error(...i(s),...r)}}};import{z as e}from"zod";var h=e.object({name:e.string().nullish(),affiliation:e.string().nullish()}),x=e.object({name:e.string().nullish(),text:e.string().nullish(),color:e.string().nullish()}),S=e.object({id:e.number(),name:e.string().nullish(),color:e.string().nullish()}),c=e.object({id:e.number(),userId:e.string().nullish(),userName:e.string().nullish(),content:e.string().nullish(),createdAt:e.string().nullish(),isMine:e.boolean()}),R=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"])}),a=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(h),subject:e.string().nullish(),content:e.string().nullish(),comments:e.array(x),isRead:e.boolean(),isStarred:e.boolean(),labels:e.array(S),commentItems:e.array(c),attachments:e.array(R).default([])}),C=e.object({type:e.literal("connected")}),w=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()}),k=e.object({type:e.literal("comment-add"),reportHubId:e.number(),comment:c,clientTempId:e.string()}),T=e.object({type:e.literal("comment-delete"),reportHubId:e.number(),commentId:e.number(),clientTempId:e.string()}),N=e.object({type:e.literal("report-create"),reportHubId:e.number(),report:a,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),A=e.object({type:e.literal("report-update"),reportHubId:e.number(),report:a,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),M=e.object({type:e.literal("report-publish"),reportHubId:e.number(),report:a,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),$=e.object({type:e.literal("report-delete"),reportHubId:e.number(),clientTempId:e.string()}),W=e.discriminatedUnion("type",[C,w,k,T,N,A,M,$]);var q=t=>{if(!t)return"-";let n=t.trim();return n===""?"-":n},j=t=>{if(!t)return"-";if(typeof t!="string")return t instanceof Date?j(t.toISOString()):String(t);let n=t.trim();if(n==="")return"-";let o=new Date(n);if(Number.isNaN(o.getTime()))return n;let i=o.getFullYear(),s=String(o.getMonth()+1).padStart(2,"0"),r=String(o.getDate()).padStart(2,"0");if(n.includes(":")||n.includes("T")){let d=String(o.getHours()).padStart(2,"0"),g=String(o.getMinutes()).padStart(2,"0"),y=String(o.getSeconds()).padStart(2,"0");return`${i}-${s}-${r}T${d}:${g}:${y}`}return`${i}-${s}-${r}`};export{I as LogLevel,k as commentAddMessageSchema,T as commentDeleteMessageSchema,D as compareIdsStreamOrder,C as connectedMessageSchema,F as createLogger,R as dailyReportAttachmentItemSchema,c as dailyReportCommentItemSchema,x as dailyReportCommentSchema,a as dailyReportDetailSchema,h as dailyReportInterviewerSchema,S as dailyReportLabelDefSchema,W as dailyReportSseMessageSchema,q as fallbackText,O as findIdsStreamResumeIndex,H as formatBusinessDateDisplay,j as formatToIsoDate,L as isIdsStreamChunkLine,E as mergeComments,p as normalizeBusinessDateKey,U as parseBusinessDateKeyToDate,N as reportCreateMessageSchema,$ as reportDeleteMessageSchema,M as reportPublishMessageSchema,A as reportUpdateMessageSchema,B as resolveCommentColorClass,w as statusUpdateMessageSchema};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shared/business-date.ts","../src/shared/comment-adapter.ts","../src/shared/logger.ts","../src/shared/sse-schema.ts","../src/shared/text-utils.ts"],"sourcesContent":["/**\n * Business date normalization and formatting helper functions.\n * 営業日の正規化とフォーマットを支援するユーティリティ群。\n */\n\ntype BusinessDateInput = string | Date | null | undefined\n\nconst ISO_DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/\nconst SLASH_DATE_PATTERN = /^\\d{4}\\/\\d{2}\\/\\d{2}$/\n\nconst zeroPad = (value: number): string => {\n return value < 10 ? `0${value}` : `${value}`\n}\n\nconst normalizeFromDate = (value: Date): string | null => {\n if (Number.isNaN(value.getTime())) {\n return null\n }\n\n const year = value.getFullYear()\n const month = zeroPad(value.getMonth() + 1)\n const day = zeroPad(value.getDate())\n return `${year}-${month}-${day}`\n}\n\n/**\n * Normalizes business date input into YYYY-MM-DD format string.\n * 営業日を YYYY-MM-DD 形式の文字列へ正規化する。\n */\nexport const normalizeBusinessDateKey = (value: BusinessDateInput): string | null => {\n if (value === null || value === undefined) {\n return null\n }\n\n if (value instanceof Date) {\n return normalizeFromDate(value)\n }\n\n const trimmed = value.trim()\n if (trimmed === \"\") {\n return null\n }\n\n if (ISO_DATE_PATTERN.test(trimmed)) {\n return trimmed\n }\n\n if (SLASH_DATE_PATTERN.test(trimmed)) {\n return trimmed.replaceAll(\"/\", \"-\")\n }\n\n const parsed = new Date(trimmed)\n return normalizeFromDate(parsed)\n}\n\n/**\n * Converts normalized business date into display format YYYY-MM-DD.\n * 正規化済みの営業日を YYYY-MM-DD 形式の表示文字列へ変換する。\n */\nexport const formatBusinessDateDisplay = (value: BusinessDateInput): string | null => {\n const normalized = normalizeBusinessDateKey(value)\n if (!normalized) {\n return null\n }\n return normalized\n}\n\n/**\n * Parses normalized business date into Date object.\n * 正規化した営業日を Date オブジェクトへ変換する。\n */\nexport const parseBusinessDateKeyToDate = (value: BusinessDateInput): Date | null => {\n const normalized = normalizeBusinessDateKey(value)\n if (!normalized) {\n return null\n }\n\n const [year, month, day] = normalized.split(\"-\").map((part) => Number.parseInt(part, 10))\n if ([year, month, day].some((component) => Number.isNaN(component))) {\n return null\n }\n\n return new Date(year, month - 1, day)\n}\n","/**\n * Adapters merging legacy JSON comments and relational comments for the UI.\n * レガシー JSON コメントとリレーショナルコメントを UI 向けに統合するアダプタ群。\n */\nimport type { DailyReportComment, DailyReportCommentItem } from \"./types\"\n\nexport type UIComment = {\n id: string | number\n authorName: string\n content: string\n createdAt?: string\n isMine: boolean\n color?: string\n isLegacy: boolean\n}\n\n/**\n * Merges legacy JSON comments and modern relational comments into a unified UI format.\n * レガシーな JSON コメントとモダンなリレーショナルコメントを統合された UI 形式にマージする。\n */\nexport const mergeComments = (legacyComments: DailyReportComment[], modernComments: DailyReportCommentItem[], currentUserId?: string | null): UIComment[] => {\n // 1. Legacy コメントの変換\n const legacyUIComments: UIComment[] = legacyComments.map((c, index) => ({\n id: `legacy-${index}`,\n authorName: c.name || \"Unknown\",\n content: c.text || \"\",\n isMine: false,\n color: c.color || undefined,\n isLegacy: true,\n }))\n\n // 2. Modern コメントの変換\n const modernUIComments: UIComment[] = modernComments.map((c) => ({\n id: c.id,\n authorName: c.userName ?? \"\",\n content: c.content ?? \"\",\n createdAt: c.createdAt ?? \"\",\n isMine: currentUserId ? c.userId === currentUserId : c.isMine,\n isLegacy: false,\n }))\n\n // 3. 結合 (Legacy を先に表示)\n return [...legacyUIComments, ...modernUIComments]\n}\n\n/**\n * Resolves comment color tokens into Tailwind text classes.\n * コメント色のキーワードを Tailwind のテキストクラスに変換する関数。\n */\nexport const resolveCommentColorClass = (color: string | null | undefined): string => {\n if (!color) {\n return \"text-gray-700\"\n }\n\n const normalized = color.toLowerCase()\n\n if (normalized.includes(\"red\") || normalized.includes(\"赤\")) {\n return \"text-red-600\"\n }\n\n if (normalized.includes(\"green\") || normalized.includes(\"緑\")) {\n return \"text-green-600\"\n }\n\n if (normalized.includes(\"blue\") || normalized.includes(\"青\")) {\n return \"text-blue-600\"\n }\n\n if (normalized.includes(\"yellow\") || normalized.includes(\"黄\")) {\n return \"text-yellow-600\"\n }\n\n if (normalized.includes(\"orange\") || normalized.includes(\"橙\")) {\n return \"text-orange-500\"\n }\n\n return \"text-gray-700\"\n}\n","/**\n * Minimal level-filtered logger used internally by the daily-report package.\n * daily-report パッケージ内部で使う最小のレベルフィルタ付きロガー。\n *\n * 消費アプリのロガー実装 (console 互換の debug/info/warn/error) を注入でき、\n * 未注入時は console にフォールバックする。\n */\n\n/** 出力フィルタリング用のログレベル。 */\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n NONE = 4,\n}\n\n/** Console 互換のロガーインターフェース。 */\nexport interface DailyReportLogger {\n debug(message?: unknown, ...optionalParams: unknown[]): void\n info(message?: unknown, ...optionalParams: unknown[]): void\n warn(message?: unknown, ...optionalParams: unknown[]): void\n error(message?: unknown, ...optionalParams: unknown[]): void\n}\n\n/**\n * Creates a prefixed, level-filtered logger delegating to the given implementation.\n * 指定実装へ委譲するプレフィックス付き・レベルフィルタ付きロガーを生成する処理。\n */\nexport const createLogger = (level: LogLevel, prefix: string, impl: DailyReportLogger = console): DailyReportLogger => {\n // 文字列メッセージはプレフィックスを連結、それ以外は先頭引数として付加する\n const format = (message: unknown): unknown[] => (typeof message === \"string\" ? [`${prefix} ${message}`] : [prefix, message])\n return {\n debug: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.DEBUG) impl.debug(...format(message), ...rest)\n },\n info: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.INFO) impl.info(...format(message), ...rest)\n },\n warn: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.WARN) impl.warn(...format(message), ...rest)\n },\n error: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.ERROR) impl.error(...format(message), ...rest)\n },\n }\n}\n","/**\n * Zod schemas for daily-report SSE messages (client/server shared contract).\n * 日報 SSE メッセージの zod スキーマ (client / server 共有契約)。\n */\nimport { z } from \"zod\"\nimport type { DailyReportCommentItem as DeclaredComment, DailyReportDetail as DeclaredDetail } from \"./types\"\n\n// --- サブスキーマ(types.ts の型と構造的に一致させる) ---\n\nexport const dailyReportInterviewerSchema = z.object({\n name: z.string().nullish(),\n affiliation: z.string().nullish(),\n})\n\nexport const dailyReportCommentSchema = z.object({\n name: z.string().nullish(),\n text: z.string().nullish(),\n color: z.string().nullish(),\n})\n\nexport const dailyReportLabelDefSchema = z.object({\n id: z.number(),\n name: z.string().nullish(),\n color: z.string().nullish(),\n})\n\nexport const dailyReportCommentItemSchema = z.object({\n id: z.number(),\n userId: z.string().nullish(),\n userName: z.string().nullish(),\n content: z.string().nullish(),\n createdAt: z.string().nullish(),\n isMine: z.boolean(),\n})\n\nexport const dailyReportDetailSchema = z.object({\n reportHubId: z.number(),\n date: z.string().nullish(),\n createdAt: z.string().nullish(),\n author: z.string().nullish(),\n userId: z.string().nullish(),\n sourceType: z.string().nullish(),\n employeeName: z.string().nullish(),\n updatedBy: z.string().nullish(),\n updatedAt: z.string().nullish(),\n category: z.string().nullish(),\n creationCategory: z.string().nullish(),\n visitTimeFrom: z.string().nullish(),\n visitTimeTo: z.string().nullish(),\n customerName: z.string().nullish(),\n interviewers: z.array(dailyReportInterviewerSchema),\n subject: z.string().nullish(),\n content: z.string().nullish(),\n comments: z.array(dailyReportCommentSchema),\n isRead: z.boolean(),\n isStarred: z.boolean(),\n labels: z.array(dailyReportLabelDefSchema),\n commentItems: z.array(dailyReportCommentItemSchema),\n})\n\n// --- SSE メッセージスキーマ(8種) ---\n\nexport const connectedMessageSchema = z.object({\n type: z.literal(\"connected\"),\n})\n\nexport const statusUpdateMessageSchema = z.object({\n type: z.literal(\"status-update\"),\n reportHubId: z.number(),\n statusType: z.enum([\"star\", \"read\"]),\n value: z.boolean(),\n clientTempId: z.string(),\n // recipientRawUserId はサーバーサイドフィルタリング専用。\n // SSE ルートが raw JSON から取得してフィルタ後に除去する。\n // クライアントには到達しないが、サーバー側の publish で .parse() を通すため定義が必要。\n recipientRawUserId: z.number().optional(),\n})\n\nexport const commentAddMessageSchema = z.object({\n type: z.literal(\"comment-add\"),\n reportHubId: z.number(),\n comment: dailyReportCommentItemSchema,\n clientTempId: z.string(),\n})\n\nexport const commentDeleteMessageSchema = z.object({\n type: z.literal(\"comment-delete\"),\n reportHubId: z.number(),\n commentId: z.number(),\n clientTempId: z.string(),\n})\n\nexport const reportCreateMessageSchema = z.object({\n type: z.literal(\"report-create\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportUpdateMessageSchema = z.object({\n type: z.literal(\"report-update\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportPublishMessageSchema = z.object({\n type: z.literal(\"report-publish\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportDeleteMessageSchema = z.object({\n type: z.literal(\"report-delete\"),\n reportHubId: z.number(),\n clientTempId: z.string(),\n})\n\n// --- Discriminated Union ---\n\nexport const dailyReportSseMessageSchema = z.discriminatedUnion(\"type\", [\n connectedMessageSchema,\n statusUpdateMessageSchema,\n commentAddMessageSchema,\n commentDeleteMessageSchema,\n reportCreateMessageSchema,\n reportUpdateMessageSchema,\n reportPublishMessageSchema,\n reportDeleteMessageSchema,\n])\n\n// --- 型エクスポート ---\n\nexport type DailyReportSseMessage = z.infer<typeof dailyReportSseMessageSchema>\n\n// --- コンパイル時の型互換チェック ---\n// Zod推論型が既存の型定義に代入可能であることを保証する。\n// ここでエラーが出たらスキーマと types.ts がずれている。\n\ntype _AssertDetailCompat = z.infer<typeof dailyReportDetailSchema> extends DeclaredDetail ? true : never\ntype _AssertCommentCompat = z.infer<typeof dailyReportCommentItemSchema> extends DeclaredComment ? true : never\nconst _detailCheck: _AssertDetailCompat = true\nconst _commentCheck: _AssertCommentCompat = true\nvoid _detailCheck\nvoid _commentCheck\n","/**\n * Shared text helpers for daily report view components.\n * 日報ビューコンポーネント向けの共通テキストヘルパー。\n */\n\n/**\n * Normalizes nullable text by trimming whitespace and applying fallback.\n * null 許容の文字列をトリムしつつフォールバック値を適用する関数。\n */\nexport const fallbackText = (value: string | null | undefined): string => {\n if (!value) {\n return \"-\"\n }\n const trimmed = value.trim()\n return trimmed === \"\" ? \"-\" : trimmed\n}\n\n/**\n * Formats a date string to ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss).\n * 日付文字列を ISO 8601 形式 (YYYY-MM-DD または YYYY-MM-DDTHH:mm:ss) に整形する関数。\n */\nexport const formatToIsoDate = (value: unknown): string => {\n if (!value) {\n return \"-\"\n }\n if (typeof value !== \"string\") {\n // If value is not a string (e.g. Date object), try to convert it to string or handle it\n if (value instanceof Date) {\n return formatToIsoDate(value.toISOString())\n }\n return String(value)\n }\n const trimmed = value.trim()\n if (trimmed === \"\") {\n return \"-\"\n }\n\n const date = new Date(trimmed)\n if (Number.isNaN(date.getTime())) {\n return trimmed\n }\n\n const year = date.getFullYear()\n const month = String(date.getMonth() + 1).padStart(2, \"0\")\n const day = String(date.getDate()).padStart(2, \"0\")\n\n const hasTime = trimmed.includes(\":\") || trimmed.includes(\"T\")\n\n if (hasTime) {\n const hours = String(date.getHours()).padStart(2, \"0\")\n const minutes = String(date.getMinutes()).padStart(2, \"0\")\n const seconds = String(date.getSeconds()).padStart(2, \"0\")\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`\n }\n\n return `${year}-${month}-${day}`\n}\n"],"mappings":"AAOA,IAAMA,EAAmB,sBACnBC,EAAqB,wBAErBC,EAAWC,GACNA,EAAQ,GAAK,IAAIA,CAAK,GAAK,GAAGA,CAAK,GAG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,CAAC,EAAE,SAAS,EAAG,GAAG,EACnDG,EAAM,OAAOH,EAAK,QAAQ,CAAC,EAAE,SAAS,EAAG,GAAG,EAIlD,GAFgBF,EAAQ,SAAS,GAAG,GAAKA,EAAQ,SAAS,GAAG,EAEhD,CACT,IAAMM,EAAQ,OAAOJ,EAAK,SAAS,CAAC,EAAE,SAAS,EAAG,GAAG,EAC/CK,EAAU,OAAOL,EAAK,WAAW,CAAC,EAAE,SAAS,EAAG,GAAG,EACnDM,EAAU,OAAON,EAAK,WAAW,CAAC,EAAE,SAAS,EAAG,GAAG,EACzD,MAAO,GAAGC,CAAI,IAAIC,CAAK,IAAIC,CAAG,IAAIC,CAAK,IAAIC,CAAO,IAAIC,CAAO,EACjE,CAEA,MAAO,GAAGL,CAAI,IAAIC,CAAK,IAAIC,CAAG,EAClC","names":["ISO_DATE_PATTERN","SLASH_DATE_PATTERN","zeroPad","value","normalizeFromDate","year","month","day","normalizeBusinessDateKey","trimmed","parsed","formatBusinessDateDisplay","normalized","parseBusinessDateKeyToDate","part","component","mergeComments","legacyComments","modernComments","currentUserId","legacyUIComments","c","index","modernUIComments","resolveCommentColorClass","color","normalized","LogLevel","createLogger","level","prefix","impl","format","message","rest","z","dailyReportInterviewerSchema","dailyReportCommentSchema","dailyReportLabelDefSchema","dailyReportCommentItemSchema","dailyReportDetailSchema","connectedMessageSchema","statusUpdateMessageSchema","commentAddMessageSchema","commentDeleteMessageSchema","reportCreateMessageSchema","reportUpdateMessageSchema","reportPublishMessageSchema","reportDeleteMessageSchema","dailyReportSseMessageSchema","fallbackText","value","trimmed","formatToIsoDate","date","year","month","day","hours","minutes","seconds"]}
1
+ {"version":3,"sources":["../src/shared/business-date.ts","../src/shared/comment-adapter.ts","../src/shared/ids-stream.ts","../src/shared/logger.ts","../src/shared/sse-schema.ts","../src/shared/text-utils.ts"],"sourcesContent":["/**\n * Business date normalization and formatting helper functions.\n * 営業日の正規化とフォーマットを支援するユーティリティ群。\n */\n\ntype BusinessDateInput = string | Date | null | undefined\n\nconst ISO_DATE_PATTERN = /^\\d{4}-\\d{2}-\\d{2}$/\nconst SLASH_DATE_PATTERN = /^\\d{4}\\/\\d{2}\\/\\d{2}$/\n\nconst zeroPad = (value: number): string => {\n return value < 10 ? `0${value}` : `${value}`\n}\n\nconst normalizeFromDate = (value: Date): string | null => {\n if (Number.isNaN(value.getTime())) {\n return null\n }\n\n const year = value.getFullYear()\n const month = zeroPad(value.getMonth() + 1)\n const day = zeroPad(value.getDate())\n return `${year}-${month}-${day}`\n}\n\n/**\n * Normalizes business date input into YYYY-MM-DD format string.\n * 営業日を YYYY-MM-DD 形式の文字列へ正規化する。\n */\nexport const normalizeBusinessDateKey = (value: BusinessDateInput): string | null => {\n if (value === null || value === undefined) {\n return null\n }\n\n if (value instanceof Date) {\n return normalizeFromDate(value)\n }\n\n const trimmed = value.trim()\n if (trimmed === \"\") {\n return null\n }\n\n if (ISO_DATE_PATTERN.test(trimmed)) {\n return trimmed\n }\n\n if (SLASH_DATE_PATTERN.test(trimmed)) {\n return trimmed.replaceAll(\"/\", \"-\")\n }\n\n const parsed = new Date(trimmed)\n return normalizeFromDate(parsed)\n}\n\n/**\n * Converts normalized business date into display format YYYY-MM-DD.\n * 正規化済みの営業日を YYYY-MM-DD 形式の表示文字列へ変換する。\n */\nexport const formatBusinessDateDisplay = (value: BusinessDateInput): string | null => {\n const normalized = normalizeBusinessDateKey(value)\n if (!normalized) {\n return null\n }\n return normalized\n}\n\n/**\n * Parses normalized business date into Date object.\n * 正規化した営業日を Date オブジェクトへ変換する。\n */\nexport const parseBusinessDateKeyToDate = (value: BusinessDateInput): Date | null => {\n const normalized = normalizeBusinessDateKey(value)\n if (!normalized) {\n return null\n }\n\n const [year, month, day] = normalized.split(\"-\").map((part) => Number.parseInt(part, 10))\n if ([year, month, day].some((component) => Number.isNaN(component))) {\n return null\n }\n\n return new Date(year, month - 1, day)\n}\n","/**\n * Adapters merging legacy JSON comments and relational comments for the UI.\n * レガシー JSON コメントとリレーショナルコメントを UI 向けに統合するアダプタ群。\n */\nimport type { DailyReportComment, DailyReportCommentItem } from \"./types\"\n\nexport type UIComment = {\n id: string | number\n authorName: string\n content: string\n createdAt?: string\n isMine: boolean\n color?: string\n isLegacy: boolean\n}\n\n/**\n * Merges legacy JSON comments and modern relational comments into a unified UI format.\n * レガシーな JSON コメントとモダンなリレーショナルコメントを統合された UI 形式にマージする。\n */\nexport const mergeComments = (legacyComments: DailyReportComment[], modernComments: DailyReportCommentItem[], currentUserId?: string | null): UIComment[] => {\n // 1. Legacy コメントの変換\n const legacyUIComments: UIComment[] = legacyComments.map((c, index) => ({\n id: `legacy-${index}`,\n authorName: c.name || \"Unknown\",\n content: c.text || \"\",\n isMine: false,\n color: c.color || undefined,\n isLegacy: true,\n }))\n\n // 2. Modern コメントの変換\n const modernUIComments: UIComment[] = modernComments.map((c) => ({\n id: c.id,\n authorName: c.userName ?? \"\",\n content: c.content ?? \"\",\n createdAt: c.createdAt ?? \"\",\n isMine: currentUserId ? c.userId === currentUserId : c.isMine,\n isLegacy: false,\n }))\n\n // 3. 結合 (Legacy を先に表示)\n return [...legacyUIComments, ...modernUIComments]\n}\n\n/**\n * Resolves comment color tokens into Tailwind text classes.\n * コメント色のキーワードを Tailwind のテキストクラスに変換する関数。\n */\nexport const resolveCommentColorClass = (color: string | null | undefined): string => {\n if (!color) {\n return \"text-gray-700\"\n }\n\n const normalized = color.toLowerCase()\n\n if (normalized.includes(\"red\") || normalized.includes(\"赤\")) {\n return \"text-red-600\"\n }\n\n if (normalized.includes(\"green\") || normalized.includes(\"緑\")) {\n return \"text-green-600\"\n }\n\n if (normalized.includes(\"blue\") || normalized.includes(\"青\")) {\n return \"text-blue-600\"\n }\n\n if (normalized.includes(\"yellow\") || normalized.includes(\"黄\")) {\n return \"text-yellow-600\"\n }\n\n if (normalized.includes(\"orange\") || normalized.includes(\"橙\")) {\n return \"text-orange-500\"\n }\n\n return \"text-gray-700\"\n}\n","/**\n * Wire contract and ordering helpers for the daily-report ids NDJSON stream.\n * 日報 ID 一覧 NDJSON ストリームのワイヤ契約と並び順ヘルパー。\n *\n * サーバーは `GET {apiBasePath}/ids-stream` で 1 行 1 JSON の NDJSON を返す。\n * 行は原則 {@link DailyReportIdsStreamChunkLine} で、送出中に予期しない失敗が\n * 起きた場合のみ {@link DailyReportIdsStreamErrorLine} を 1 行流して正常クローズする\n * (クライアントは「isLast 無しで終端」を再開シグナルとして扱う)。\n *\n * 並び順は SQL の `ORDER BY business_date DESC, id DESC` (MSSQL の DESC は NULL を\n * 末尾に置く) と完全一致させる。カーソル再開はこの全順序に対する「厳密に後」の\n * 位置からのスライスとして定義する。\n */\nimport type { DailyReportItem } from \"./types\"\n\n/** ストリーム再開カーソル。直前チャンク末尾アイテムの並び順キー。 */\nexport type DailyReportIdsStreamCursor = {\n /** 営業日 (YYYY-MM-DD)。null は「営業日なし領域」(並び順の末尾) を表す。 */\n businessDate: string | null\n /** 日報 Hub ID。 */\n reportHubId: number\n}\n\n/** データを運ぶ NDJSON 行。 */\nexport type DailyReportIdsStreamChunkLine = {\n /** このチャンクのアイテム群 (並び順どおり)。 */\n items: DailyReportItem[]\n /** 次チャンクの再開カーソル。最終チャンクでは null。 */\n nextCursor: DailyReportIdsStreamCursor | null\n /** これが最終チャンクかどうか。 */\n isLast: boolean\n /** 全体件数。接続ごとの先頭行にのみ載る。 */\n total?: number\n}\n\n/** サーバー側の予期しない失敗を伝える NDJSON 行 (内部情報は含めない)。 */\nexport type DailyReportIdsStreamErrorLine = {\n error: string\n}\n\n/** NDJSON 1 行のユニオン。 */\nexport type DailyReportIdsStreamLine = DailyReportIdsStreamChunkLine | DailyReportIdsStreamErrorLine\n\n/**\n * Type guard for chunk lines (anything else is treated as an error line).\n * チャンク行の型ガード (それ以外はエラー行として扱う)。\n *\n * @param line Parsed NDJSON line. パース済みの NDJSON 行。\n * @returns True when the line carries items. アイテムを運ぶ行なら true。\n */\nexport const isIdsStreamChunkLine = (line: unknown): line is DailyReportIdsStreamChunkLine => {\n return typeof line === \"object\" && line !== null && Array.isArray((line as { items?: unknown }).items)\n}\n\n/**\n * Total order of the ids stream: businessDate DESC (NULL last), then id DESC.\n * ids ストリームの全順序。営業日降順 (NULL は末尾)、同日内は ID 降順。\n *\n * MSSQL の `ORDER BY business_date DESC, id DESC` と一致させることが唯一の存在理由。\n * 営業日は正規化済みの `YYYY-MM-DD` 文字列なので辞書順比較 = 時系列比較になる。\n *\n * @param a Left key. 左辺キー。\n * @param b Right key. 右辺キー。\n * @returns Negative when `a` streams before `b`. `a` が先に流れるなら負値。\n */\nexport const compareIdsStreamOrder = (a: DailyReportIdsStreamCursor, b: DailyReportIdsStreamCursor): number => {\n if (a.businessDate !== b.businessDate) {\n // null 営業日は並び順の末尾 (MSSQL DESC の NULL 末尾挙動へ揃える)\n if (a.businessDate === null) return 1\n if (b.businessDate === null) return -1\n return a.businessDate > b.businessDate ? -1 : 1\n }\n return b.reportHubId - a.reportHubId\n}\n\n/**\n * Finds the first index that streams strictly after the cursor.\n * カーソルより厳密に後ろへ並ぶ最初のインデックスを求める処理。\n *\n * 配列は必ずストリーム順 (SQL の ORDER BY) で渡されるが、比較器とのズレが\n * あっても壊れない線形走査で決定する (件数は高々数万・再開時のみの実行)。\n * 該当なし (カーソルが末尾以降) は `items.length` を返し、空チャンク +\n * `isLast: true` の正常終端に落ちる。\n *\n * @param items Stream-ordered items. ストリーム順のアイテム配列。\n * @param cursor Resume cursor. 再開カーソル。\n * @returns Index to resume emission from. 送出を再開するインデックス。\n */\nexport const findIdsStreamResumeIndex = (items: readonly DailyReportItem[], cursor: DailyReportIdsStreamCursor): number => {\n const index = items.findIndex((item) => compareIdsStreamOrder({ businessDate: item.businessDate, reportHubId: item.reportHubId }, cursor) > 0)\n return index === -1 ? items.length : index\n}\n","/**\n * Minimal level-filtered logger used internally by the daily-report package.\n * daily-report パッケージ内部で使う最小のレベルフィルタ付きロガー。\n *\n * 消費アプリのロガー実装 (console 互換の debug/info/warn/error) を注入でき、\n * 未注入時は console にフォールバックする。\n */\n\n/** 出力フィルタリング用のログレベル。 */\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n NONE = 4,\n}\n\n/** Console 互換のロガーインターフェース。 */\nexport interface DailyReportLogger {\n debug(message?: unknown, ...optionalParams: unknown[]): void\n info(message?: unknown, ...optionalParams: unknown[]): void\n warn(message?: unknown, ...optionalParams: unknown[]): void\n error(message?: unknown, ...optionalParams: unknown[]): void\n}\n\n/**\n * Creates a prefixed, level-filtered logger delegating to the given implementation.\n * 指定実装へ委譲するプレフィックス付き・レベルフィルタ付きロガーを生成する処理。\n */\nexport const createLogger = (level: LogLevel, prefix: string, impl: DailyReportLogger = console): DailyReportLogger => {\n // 文字列メッセージはプレフィックスを連結、それ以外は先頭引数として付加する\n const format = (message: unknown): unknown[] => (typeof message === \"string\" ? [`${prefix} ${message}`] : [prefix, message])\n return {\n debug: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.DEBUG) impl.debug(...format(message), ...rest)\n },\n info: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.INFO) impl.info(...format(message), ...rest)\n },\n warn: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.WARN) impl.warn(...format(message), ...rest)\n },\n error: (message?: unknown, ...rest: unknown[]) => {\n if (level <= LogLevel.ERROR) impl.error(...format(message), ...rest)\n },\n }\n}\n","/**\n * Zod schemas for daily-report SSE messages (client/server shared contract).\n * 日報 SSE メッセージの zod スキーマ (client / server 共有契約)。\n */\nimport { z } from \"zod\"\nimport type { DailyReportCommentItem as DeclaredComment, DailyReportDetail as DeclaredDetail } from \"./types\"\n\n// --- サブスキーマ(types.ts の型と構造的に一致させる) ---\n\nexport const dailyReportInterviewerSchema = z.object({\n name: z.string().nullish(),\n affiliation: z.string().nullish(),\n})\n\nexport const dailyReportCommentSchema = z.object({\n name: z.string().nullish(),\n text: z.string().nullish(),\n color: z.string().nullish(),\n})\n\nexport const dailyReportLabelDefSchema = z.object({\n id: z.number(),\n name: z.string().nullish(),\n color: z.string().nullish(),\n})\n\nexport const dailyReportCommentItemSchema = z.object({\n id: z.number(),\n userId: z.string().nullish(),\n userName: z.string().nullish(),\n content: z.string().nullish(),\n createdAt: z.string().nullish(),\n isMine: z.boolean(),\n})\n\n/**\n * 添付ファイル 1 件のスキーマ。\n *\n * 周囲のフィールドは `.nullish()` だが、ここは意図して `.nullable()` を使う。\n * `.nullish()` は推論キーを任意 (`?`) にするため、`types.ts` 側の必須 `fileType: string | null`\n * へ代入できず、ファイル末尾の `_AssertDetailCompat` が `never` に落ちてコンパイルエラーになる。\n * 既存の `.nullish()` フィールドはいずれも `types.ts` 側が `?` 付きの任意キーとペアになっており、\n * 「`.nullish()` ↔ 任意キー」「`.nullable()` ↔ 必須 `| null`」の対応で揃っている。\n * `| undefined` を混ぜないことは、詳細型を消費する DuckDB ステージ行の要請でもある。\n */\nexport const dailyReportAttachmentItemSchema = z.object({\n id: z.string(),\n fileName: z.string(),\n fileType: z.string().nullable(),\n fileSize: z.number().nullable(),\n createdAt: z.string().nullable(),\n state: z.enum([\"present\", \"absent\", \"unknown\"]),\n})\n\nexport const dailyReportDetailSchema = z.object({\n reportHubId: z.number(),\n date: z.string().nullish(),\n createdAt: z.string().nullish(),\n author: z.string().nullish(),\n userId: z.string().nullish(),\n sourceType: z.string().nullish(),\n employeeName: z.string().nullish(),\n updatedBy: z.string().nullish(),\n updatedAt: z.string().nullish(),\n category: z.string().nullish(),\n creationCategory: z.string().nullish(),\n visitTimeFrom: z.string().nullish(),\n visitTimeTo: z.string().nullish(),\n customerName: z.string().nullish(),\n interviewers: z.array(dailyReportInterviewerSchema),\n subject: z.string().nullish(),\n content: z.string().nullish(),\n comments: z.array(dailyReportCommentSchema),\n isRead: z.boolean(),\n isStarred: z.boolean(),\n labels: z.array(dailyReportLabelDefSchema),\n commentItems: z.array(dailyReportCommentItemSchema),\n // ❗ `.default([])` は必須。SSE の実体は永続 Redis Stream (MAXLEN 保持) であり、\n // 配備をまたいで**旧形式のエントリが残る**。共有リーダーはプロセス起動時に先頭から\n // 再生し、再接続クライアントの catch-up も同じエントリを読み直すため、\n // このキーを必須にすると添付機能を入れる前に publish された全エントリが\n // fail-closed で捨てられ、再接続タブへ更新が永久に届かなくなる。\n // 送信側の詰め忘れ検知は types.ts の必須フィールドと `_AssertDetailCompat`\n // (出力型は既定値適用後なので必須のまま) が担っており、ここを緩めても失われない。\n attachments: z.array(dailyReportAttachmentItemSchema).default([]),\n})\n\n// --- SSE メッセージスキーマ(8種) ---\n\nexport const connectedMessageSchema = z.object({\n type: z.literal(\"connected\"),\n})\n\nexport const statusUpdateMessageSchema = z.object({\n type: z.literal(\"status-update\"),\n reportHubId: z.number(),\n statusType: z.enum([\"star\", \"read\"]),\n value: z.boolean(),\n clientTempId: z.string(),\n // recipientRawUserId はサーバーサイドフィルタリング専用。\n // SSE ルートが raw JSON から取得してフィルタ後に除去する。\n // クライアントには到達しないが、サーバー側の publish で .parse() を通すため定義が必要。\n recipientRawUserId: z.number().optional(),\n})\n\nexport const commentAddMessageSchema = z.object({\n type: z.literal(\"comment-add\"),\n reportHubId: z.number(),\n comment: dailyReportCommentItemSchema,\n clientTempId: z.string(),\n})\n\nexport const commentDeleteMessageSchema = z.object({\n type: z.literal(\"comment-delete\"),\n reportHubId: z.number(),\n commentId: z.number(),\n clientTempId: z.string(),\n})\n\nexport const reportCreateMessageSchema = z.object({\n type: z.literal(\"report-create\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportUpdateMessageSchema = z.object({\n type: z.literal(\"report-update\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportPublishMessageSchema = z.object({\n type: z.literal(\"report-publish\"),\n reportHubId: z.number(),\n report: dailyReportDetailSchema,\n clientTempId: z.string(),\n recipientRawUserId: z.number().optional(),\n})\n\nexport const reportDeleteMessageSchema = z.object({\n type: z.literal(\"report-delete\"),\n reportHubId: z.number(),\n clientTempId: z.string(),\n})\n\n// --- Discriminated Union ---\n\nexport const dailyReportSseMessageSchema = z.discriminatedUnion(\"type\", [\n connectedMessageSchema,\n statusUpdateMessageSchema,\n commentAddMessageSchema,\n commentDeleteMessageSchema,\n reportCreateMessageSchema,\n reportUpdateMessageSchema,\n reportPublishMessageSchema,\n reportDeleteMessageSchema,\n])\n\n// --- 型エクスポート ---\n\nexport type DailyReportSseMessage = z.infer<typeof dailyReportSseMessageSchema>\n\n// --- コンパイル時の型互換チェック ---\n// Zod推論型が既存の型定義に代入可能であることを保証する。\n// ここでエラーが出たらスキーマと types.ts がずれている。\n\ntype _AssertDetailCompat = z.infer<typeof dailyReportDetailSchema> extends DeclaredDetail ? true : never\ntype _AssertCommentCompat = z.infer<typeof dailyReportCommentItemSchema> extends DeclaredComment ? true : never\nconst _detailCheck: _AssertDetailCompat = true\nconst _commentCheck: _AssertCommentCompat = true\nvoid _detailCheck\nvoid _commentCheck\n","/**\n * Shared text helpers for daily report view components.\n * 日報ビューコンポーネント向けの共通テキストヘルパー。\n */\n\n/**\n * Normalizes nullable text by trimming whitespace and applying fallback.\n * null 許容の文字列をトリムしつつフォールバック値を適用する関数。\n */\nexport const fallbackText = (value: string | null | undefined): string => {\n if (!value) {\n return \"-\"\n }\n const trimmed = value.trim()\n return trimmed === \"\" ? \"-\" : trimmed\n}\n\n/**\n * Formats a date string to ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss).\n * 日付文字列を ISO 8601 形式 (YYYY-MM-DD または YYYY-MM-DDTHH:mm:ss) に整形する関数。\n */\nexport const formatToIsoDate = (value: unknown): string => {\n if (!value) {\n return \"-\"\n }\n if (typeof value !== \"string\") {\n // If value is not a string (e.g. Date object), try to convert it to string or handle it\n if (value instanceof Date) {\n return formatToIsoDate(value.toISOString())\n }\n return String(value)\n }\n const trimmed = value.trim()\n if (trimmed === \"\") {\n return \"-\"\n }\n\n const date = new Date(trimmed)\n if (Number.isNaN(date.getTime())) {\n return trimmed\n }\n\n const year = date.getFullYear()\n const month = String(date.getMonth() + 1).padStart(2, \"0\")\n const day = String(date.getDate()).padStart(2, \"0\")\n\n const hasTime = trimmed.includes(\":\") || trimmed.includes(\"T\")\n\n if (hasTime) {\n const hours = String(date.getHours()).padStart(2, \"0\")\n const minutes = String(date.getMinutes()).padStart(2, \"0\")\n const seconds = String(date.getSeconds()).padStart(2, \"0\")\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`\n }\n\n return `${year}-${month}-${day}`\n}\n"],"mappings":"AAOA,IAAMA,EAAmB,sBACnBC,EAAqB,wBAErBC,EAAWC,GACNA,EAAQ,GAAK,IAAIA,CAAK,GAAK,GAAGA,CAAK,GAGxCC,EAAqBD,GAA+B,CACtD,GAAI,OAAO,MAAMA,EAAM,QAAQ,CAAC,EAC5B,OAAO,KAGX,IAAME,EAAOF,EAAM,YAAY,EACzBG,EAAQJ,EAAQC,EAAM,SAAS,EAAI,CAAC,EACpCI,EAAML,EAAQC,EAAM,QAAQ,CAAC,EACnC,MAAO,GAAGE,CAAI,IAAIC,CAAK,IAAIC,CAAG,EAClC,EAMaC,EAA4BL,GAA4C,CACjF,GAAIA,GAAU,KACV,OAAO,KAGX,GAAIA,aAAiB,KACjB,OAAOC,EAAkBD,CAAK,EAGlC,IAAMM,EAAUN,EAAM,KAAK,EAC3B,GAAIM,IAAY,GACZ,OAAO,KAGX,GAAIT,EAAiB,KAAKS,CAAO,EAC7B,OAAOA,EAGX,GAAIR,EAAmB,KAAKQ,CAAO,EAC/B,OAAOA,EAAQ,WAAW,IAAK,GAAG,EAGtC,IAAMC,EAAS,IAAI,KAAKD,CAAO,EAC/B,OAAOL,EAAkBM,CAAM,CACnC,EAMaC,EAA6BR,GAA4C,CAClF,IAAMS,EAAaJ,EAAyBL,CAAK,EACjD,OAAKS,GACM,IAGf,E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,OAAOF,EAGX,IAAMG,EAAOD,EAAK,YAAY,EACxBE,EAAQ,OAAOF,EAAK,SAAS,EAAI,CAAC,EAAE,SAAS,EAAG,GAAG,EACnDG,EAAM,OAAOH,EAAK,QAAQ,CAAC,EAAE,SAAS,EAAG,GAAG,EAIlD,GAFgBF,EAAQ,SAAS,GAAG,GAAKA,EAAQ,SAAS,GAAG,EAEhD,CACT,IAAMM,EAAQ,OAAOJ,EAAK,SAAS,CAAC,EAAE,SAAS,EAAG,GAAG,EAC/CK,EAAU,OAAOL,EAAK,WAAW,CAAC,EAAE,SAAS,EAAG,GAAG,EACnDM,EAAU,OAAON,EAAK,WAAW,CAAC,EAAE,SAAS,EAAG,GAAG,EACzD,MAAO,GAAGC,CAAI,IAAIC,CAAK,IAAIC,CAAG,IAAIC,CAAK,IAAIC,CAAO,IAAIC,CAAO,EACjE,CAEA,MAAO,GAAGL,CAAI,IAAIC,CAAK,IAAIC,CAAG,EAClC","names":["ISO_DATE_PATTERN","SLASH_DATE_PATTERN","zeroPad","value","normalizeFromDate","year","month","day","normalizeBusinessDateKey","trimmed","parsed","formatBusinessDateDisplay","normalized","parseBusinessDateKeyToDate","part","component","mergeComments","legacyComments","modernComments","currentUserId","legacyUIComments","c","index","modernUIComments","resolveCommentColorClass","color","normalized","isIdsStreamChunkLine","line","compareIdsStreamOrder","a","b","findIdsStreamResumeIndex","items","cursor","index","item","LogLevel","createLogger","level","prefix","impl","format","message","rest","z","dailyReportInterviewerSchema","dailyReportCommentSchema","dailyReportLabelDefSchema","dailyReportCommentItemSchema","dailyReportAttachmentItemSchema","dailyReportDetailSchema","connectedMessageSchema","statusUpdateMessageSchema","commentAddMessageSchema","commentDeleteMessageSchema","reportCreateMessageSchema","reportUpdateMessageSchema","reportPublishMessageSchema","reportDeleteMessageSchema","dailyReportSseMessageSchema","fallbackText","value","trimmed","formatToIsoDate","date","year","month","day","hours","minutes","seconds"]}