@aiquants/daily-report 0.5.0 → 0.6.1

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 (42) hide show
  1. package/README.md +38 -38
  2. package/dist/client.d.mts +11 -5
  3. package/dist/client.d.ts +11 -5
  4. package/dist/client.js +4 -4
  5. package/dist/client.js.map +1 -1
  6. package/dist/client.mjs +4 -4
  7. package/dist/client.mjs.map +1 -1
  8. package/dist/index.d.mts +2 -2
  9. package/dist/index.d.ts +2 -2
  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 +35 -5
  15. package/dist/server.d.ts +35 -5
  16. package/dist/server.js +6 -6
  17. package/dist/server.js.map +1 -1
  18. package/dist/server.mjs +6 -6
  19. package/dist/server.mjs.map +1 -1
  20. package/dist/sse-schema-eXcMG-Ej.d.ts +2025 -0
  21. package/dist/sse-schema-rbG114od.d.mts +2025 -0
  22. package/dist/{types-BNhYC2j9.d.mts → types-D1PKubyo.d.mts} +26 -26
  23. package/dist/{types-BNhYC2j9.d.ts → types-D1PKubyo.d.ts} +26 -26
  24. package/package.json +4 -4
  25. package/src/client/components/daily-report-detail-list.tsx +29 -7
  26. package/src/client/components/daily-report-list.tsx +26 -5
  27. package/src/client/components/daily-report-resolved-content.tsx +28 -4
  28. package/src/client/config-context.tsx +2 -0
  29. package/src/client/contexts/daily-report-action-context.tsx +6 -2
  30. package/src/client/hooks/use-daily-report-sse-connection.ts +1 -1
  31. package/src/client/hooks/use-daily-report.ts +2 -2
  32. package/src/client/route-helpers.ts +8 -2
  33. package/src/server/authz.spec.ts +57 -0
  34. package/src/server/authz.ts +99 -0
  35. package/src/server/handlers.ts +5 -4
  36. package/src/server/service.ts +31 -13
  37. package/src/server.ts +1 -0
  38. package/src/shared/comment-adapter.ts +3 -3
  39. package/src/shared/sse-schema.ts +27 -26
  40. package/src/shared/types.ts +26 -26
  41. package/dist/sse-schema-ChCypDPj.d.ts +0 -2019
  42. package/dist/sse-schema-Cs1oC2DP.d.mts +0 -2019
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
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-Cs1oC2DP.mjs';
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';
2
2
  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-BNhYC2j9.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
4
  import 'zod';
5
5
 
6
6
  /**
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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-ChCypDPj.js';
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';
2
2
  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-BNhYC2j9.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
4
  import 'zod';
5
5
 
6
6
  /**
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var l=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var U=(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))!j.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={};U(Y,{LogLevel:()=>g,commentAddMessageSchema:()=>x,commentDeleteMessageSchema:()=>S,connectedMessageSchema:()=>D,createLogger:()=>G,dailyReportCommentItemSchema:()=>u,dailyReportCommentSchema:()=>y,dailyReportDetailSchema:()=>a,dailyReportInterviewerSchema:()=>b,dailyReportLabelDefSchema:()=>f,dailyReportSseMessageSchema:()=>K,fallbackText:()=>W,formatBusinessDateDisplay:()=>E,formatToIsoDate:()=>T,mergeComments:()=>O,normalizeBusinessDateKey:()=>m,parseBusinessDateKeyToDate:()=>P,reportCreateMessageSchema:()=>w,reportDeleteMessageSchema:()=>C,reportPublishMessageSchema:()=>R,reportUpdateMessageSchema:()=>h,resolveCommentColorClass:()=>F,statusUpdateMessageSchema:()=>I});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"),b=e.z.object({name:e.z.string(),affiliation:e.z.string().nullable()}),y=e.z.object({name:e.z.string().nullable(),text:e.z.string().nullable(),color:e.z.string().nullable()}),f=e.z.object({id:e.z.number(),name:e.z.string(),color:e.z.string().nullable()}),u=e.z.object({id:e.z.number(),userId:e.z.string(),userName:e.z.string(),content:e.z.string(),createdAt:e.z.string(),isMine:e.z.boolean()}),a=e.z.object({reportHubId:e.z.number(),date:e.z.string().nullable(),createdAt:e.z.string().nullable(),author:e.z.string(),userId:e.z.string(),sourceType:e.z.string().nullable(),employeeName:e.z.string().nullable(),updatedBy:e.z.string().nullable(),updatedAt:e.z.string().nullable(),category:e.z.string().nullable(),creationCategory:e.z.string().nullable(),visitTimeFrom:e.z.string().nullable(),visitTimeTo:e.z.string().nullable(),customerName:e.z.string().nullable(),interviewers:e.z.array(b),subject:e.z.string().nullable(),content:e.z.string().nullable(),comments:e.z.array(y),isRead:e.z.boolean(),isStarred:e.z.boolean(),labels:e.z.array(f),commentItems:e.z.array(u)}),D=e.z.object({type:e.z.literal("connected")}),I=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()}),x=e.z.object({type:e.z.literal("comment-add"),reportHubId:e.z.number(),comment:u,clientTempId:e.z.string()}),S=e.z.object({type:e.z.literal("comment-delete"),reportHubId:e.z.number(),commentId:e.z.number(),clientTempId:e.z.string()}),w=e.z.object({type:e.z.literal("report-create"),reportHubId:e.z.number(),report:a,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),h=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()}),C=e.z.object({type:e.z.literal("report-delete"),reportHubId:e.z.number(),clientTempId:e.z.string()}),K=e.z.discriminatedUnion("type",[D,I,x,S,w,h,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 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});
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(),\n affiliation: z.string().nullable(),\n})\n\nexport const dailyReportCommentSchema = z.object({\n name: z.string().nullable(),\n text: z.string().nullable(),\n color: z.string().nullable(),\n})\n\nexport const dailyReportLabelDefSchema = z.object({\n id: z.number(),\n name: z.string(),\n color: z.string().nullable(),\n})\n\nexport const dailyReportCommentItemSchema = z.object({\n id: z.number(),\n userId: z.string(),\n userName: z.string(),\n content: z.string(),\n createdAt: z.string(),\n isMine: z.boolean(),\n})\n\nexport const dailyReportDetailSchema = z.object({\n reportHubId: z.number(),\n date: z.string().nullable(),\n createdAt: z.string().nullable(),\n author: z.string(),\n userId: z.string(),\n sourceType: z.string().nullable(),\n employeeName: z.string().nullable(),\n updatedBy: z.string().nullable(),\n updatedAt: z.string().nullable(),\n category: z.string().nullable(),\n creationCategory: z.string().nullable(),\n visitTimeFrom: z.string().nullable(),\n visitTimeTo: z.string().nullable(),\n customerName: z.string().nullable(),\n interviewers: z.array(dailyReportInterviewerSchema),\n subject: z.string().nullable(),\n content: z.string().nullable(),\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})\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,KAAK,EAC3B,GAAIM,IAAY,GACZ,OAAO,KAGX,GAAIT,EAAiB,KAAKS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C,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","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/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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,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","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"]}
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var y=/^\d{4}-\d{2}-\d{2}$/,f=/^\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(y.test(t))return t;if(f.test(t))return t.replaceAll("/","-");let o=new Date(t);return u(o)},$=n=>{let t=c(n);return t||null},j=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 D=(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))(D||{}),_=(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 I=e.object({name:e.string(),affiliation:e.string().nullable()}),x=e.object({name:e.string().nullable(),text:e.string().nullable(),color:e.string().nullable()}),S=e.object({id:e.number(),name:e.string(),color:e.string().nullable()}),p=e.object({id:e.number(),userId:e.string(),userName:e.string(),content:e.string(),createdAt:e.string(),isMine:e.boolean()}),a=e.object({reportHubId:e.number(),date:e.string().nullable(),createdAt:e.string().nullable(),author:e.string(),userId:e.string(),sourceType:e.string().nullable(),employeeName:e.string().nullable(),updatedBy:e.string().nullable(),updatedAt:e.string().nullable(),category:e.string().nullable(),creationCategory:e.string().nullable(),visitTimeFrom:e.string().nullable(),visitTimeTo:e.string().nullable(),customerName:e.string().nullable(),interviewers:e.array(I),subject:e.string().nullable(),content:e.string().nullable(),comments:e.array(x),isRead:e.boolean(),isStarred:e.boolean(),labels:e.array(S),commentItems:e.array(p)}),w=e.object({type:e.literal("connected")}),h=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()}),A=e.object({type:e.literal("report-delete"),reportHubId:e.number(),clientTempId:e.string()}),O=e.discriminatedUnion("type",[w,h,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"),b=String(o.getSeconds()).padStart(2,"0");return`${i}-${s}-${r}T${d}:${g}:${b}`}return`${i}-${s}-${r}`};export{D as LogLevel,R as commentAddMessageSchema,C as commentDeleteMessageSchema,w as connectedMessageSchema,_ as createLogger,p as dailyReportCommentItemSchema,x as dailyReportCommentSchema,a as dailyReportDetailSchema,I as dailyReportInterviewerSchema,S as dailyReportLabelDefSchema,O as dailyReportSseMessageSchema,G as fallbackText,$ as formatBusinessDateDisplay,M as formatToIsoDate,z as mergeComments,c as normalizeBusinessDateKey,j as parseBusinessDateKeyToDate,T as reportCreateMessageSchema,A as reportDeleteMessageSchema,k as reportPublishMessageSchema,N as reportUpdateMessageSchema,B as resolveCommentColorClass,h as statusUpdateMessageSchema};
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};
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(),\n affiliation: z.string().nullable(),\n})\n\nexport const dailyReportCommentSchema = z.object({\n name: z.string().nullable(),\n text: z.string().nullable(),\n color: z.string().nullable(),\n})\n\nexport const dailyReportLabelDefSchema = z.object({\n id: z.number(),\n name: z.string(),\n color: z.string().nullable(),\n})\n\nexport const dailyReportCommentItemSchema = z.object({\n id: z.number(),\n userId: z.string(),\n userName: z.string(),\n content: z.string(),\n createdAt: z.string(),\n isMine: z.boolean(),\n})\n\nexport const dailyReportDetailSchema = z.object({\n reportHubId: z.number(),\n date: z.string().nullable(),\n createdAt: z.string().nullable(),\n author: z.string(),\n userId: z.string(),\n sourceType: z.string().nullable(),\n employeeName: z.string().nullable(),\n updatedBy: z.string().nullable(),\n updatedAt: z.string().nullable(),\n category: z.string().nullable(),\n creationCategory: z.string().nullable(),\n visitTimeFrom: z.string().nullable(),\n visitTimeTo: z.string().nullable(),\n customerName: z.string().nullable(),\n interviewers: z.array(dailyReportInterviewerSchema),\n subject: z.string().nullable(),\n content: z.string().nullable(),\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})\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,EACpC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ACzD,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/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,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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mBAAmB,OAAQ,CACpEM,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,CACJ,CAAC,EC5HM,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":["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"]}
package/dist/server.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { e as DailyReportInterviewer, c as DailyReportComment, D as DailyReportItem, a as DailyReportDetail, d as DailyReportCommentItem } from './types-BNhYC2j9.mjs';
1
+ import { e as DailyReportInterviewer, c as DailyReportComment, D as DailyReportItem, a as DailyReportDetail, d as DailyReportCommentItem } from './types-D1PKubyo.mjs';
2
2
  import * as drizzle_orm_mssql_core from 'drizzle-orm/mssql-core';
3
3
  import { AnyMsSqlColumn } from 'drizzle-orm/mssql-core';
4
4
  import { D as DailyReportLogger } from './logger-D3krZrNK.mjs';
@@ -1239,10 +1239,11 @@ type DailyReportServiceConfig = {
1239
1239
  /** クロスワーカー epoch ストア (facade が生成して注入)。 */
1240
1240
  epochs: EpochStore;
1241
1241
  /**
1242
- * 下書きラベル名 (必須)。ドラフトのクロスユーザー可視性フィルタに使うため、
1243
- * サイレントな既定値を持たせず消費アプリが自 DB のラベル名を必ず注入する。
1242
+ * 下書きラベル名 (単一または配列で指定可能)。
1243
+ * 消費アプリ側で自 DB のラベル名や作成区分の候補名 ("下書き", "DRAFT" など) を注入できる。
1244
1244
  */
1245
- draftLabelName: string;
1245
+ draftLabelName?: string;
1246
+ draftLabelNames?: string[];
1246
1247
  /** SSE Redis Stream キー (既定 "daily-report:sse-stream")。 */
1247
1248
  streamKey?: string;
1248
1249
  /** SSE Stream の MAXLEN (既定 10000)。 */
@@ -1363,6 +1364,35 @@ declare class DailyReportSseReader {
1363
1364
  private _stopLoop;
1364
1365
  }
1365
1366
 
1367
+ type AuthzResourceItem = {
1368
+ resourceKey: string;
1369
+ name: string;
1370
+ description?: string | null;
1371
+ };
1372
+ type DailyReportSourceTypeInput = {
1373
+ key: string;
1374
+ name: string;
1375
+ description?: string | null;
1376
+ includeCommentResource?: boolean;
1377
+ };
1378
+ /**
1379
+ * Dynamically builds neutral Authz resource definitions from provided source type inputs.
1380
+ * 指定されたソース種別定義から中立な認可リソース定義リストを生成するファクトリ。
1381
+ */
1382
+ declare function defineDailyReportAuthzResources(sources?: DailyReportSourceTypeInput[]): AuthzResourceItem[];
1383
+ /**
1384
+ * Ensures all daily-report standard resources exist in the authz TMResource table idempotently.
1385
+ * authz データベース内に日報機能の標準認可リソースが存在することを自動保証(冪等シード)する処理。
1386
+ */
1387
+ declare function seedDailyReportAuthzResources(db: unknown, authzTables: {
1388
+ TMResource: unknown;
1389
+ }, opts: {
1390
+ appKey: string;
1391
+ actor?: string;
1392
+ sources?: DailyReportSourceTypeInput[];
1393
+ resources?: AuthzResourceItem[];
1394
+ }): Promise<void>;
1395
+
1366
1396
  /**
1367
1397
  * Generates a SHA-256 ETag for the given data.
1368
1398
  * 指定されたデータの SHA-256 ETag を生成します。
@@ -1524,4 +1554,4 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1524
1554
  streamKey: string;
1525
1555
  };
1526
1556
 
1527
- export { type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportCommentRow, type DailyReportCommentTable, type DailyReportDb, type DailyReportEncodeUserId, type DailyReportExternalSource, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubRow, type DailyReportHubTable, type DailyReportInternalRow, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type DailyReportResolveUserId, type DailyReportServerConfig, type DailyReportService, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, type EpochStore, type ExternalReportFields, type RedisStreamMessage, SqlResultCache, type SqlResultCacheQueryOptions, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, transformJsonArray };
1557
+ export { type AuthzResourceItem, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportCommentRow, type DailyReportCommentTable, type DailyReportDb, type DailyReportEncodeUserId, type DailyReportExternalSource, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubRow, type DailyReportHubTable, type DailyReportInternalRow, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type DailyReportResolveUserId, type DailyReportServerConfig, type DailyReportService, type DailyReportServiceConfig, type DailyReportSourceTypeInput, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, type EpochStore, type ExternalReportFields, type RedisStreamMessage, SqlResultCache, type SqlResultCacheQueryOptions, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, defineDailyReportAuthzResources, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, seedDailyReportAuthzResources, transformJsonArray };
package/dist/server.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { e as DailyReportInterviewer, c as DailyReportComment, D as DailyReportItem, a as DailyReportDetail, d as DailyReportCommentItem } from './types-BNhYC2j9.js';
1
+ import { e as DailyReportInterviewer, c as DailyReportComment, D as DailyReportItem, a as DailyReportDetail, d as DailyReportCommentItem } from './types-D1PKubyo.js';
2
2
  import * as drizzle_orm_mssql_core from 'drizzle-orm/mssql-core';
3
3
  import { AnyMsSqlColumn } from 'drizzle-orm/mssql-core';
4
4
  import { D as DailyReportLogger } from './logger-D3krZrNK.js';
@@ -1239,10 +1239,11 @@ type DailyReportServiceConfig = {
1239
1239
  /** クロスワーカー epoch ストア (facade が生成して注入)。 */
1240
1240
  epochs: EpochStore;
1241
1241
  /**
1242
- * 下書きラベル名 (必須)。ドラフトのクロスユーザー可視性フィルタに使うため、
1243
- * サイレントな既定値を持たせず消費アプリが自 DB のラベル名を必ず注入する。
1242
+ * 下書きラベル名 (単一または配列で指定可能)。
1243
+ * 消費アプリ側で自 DB のラベル名や作成区分の候補名 ("下書き", "DRAFT" など) を注入できる。
1244
1244
  */
1245
- draftLabelName: string;
1245
+ draftLabelName?: string;
1246
+ draftLabelNames?: string[];
1246
1247
  /** SSE Redis Stream キー (既定 "daily-report:sse-stream")。 */
1247
1248
  streamKey?: string;
1248
1249
  /** SSE Stream の MAXLEN (既定 10000)。 */
@@ -1363,6 +1364,35 @@ declare class DailyReportSseReader {
1363
1364
  private _stopLoop;
1364
1365
  }
1365
1366
 
1367
+ type AuthzResourceItem = {
1368
+ resourceKey: string;
1369
+ name: string;
1370
+ description?: string | null;
1371
+ };
1372
+ type DailyReportSourceTypeInput = {
1373
+ key: string;
1374
+ name: string;
1375
+ description?: string | null;
1376
+ includeCommentResource?: boolean;
1377
+ };
1378
+ /**
1379
+ * Dynamically builds neutral Authz resource definitions from provided source type inputs.
1380
+ * 指定されたソース種別定義から中立な認可リソース定義リストを生成するファクトリ。
1381
+ */
1382
+ declare function defineDailyReportAuthzResources(sources?: DailyReportSourceTypeInput[]): AuthzResourceItem[];
1383
+ /**
1384
+ * Ensures all daily-report standard resources exist in the authz TMResource table idempotently.
1385
+ * authz データベース内に日報機能の標準認可リソースが存在することを自動保証(冪等シード)する処理。
1386
+ */
1387
+ declare function seedDailyReportAuthzResources(db: unknown, authzTables: {
1388
+ TMResource: unknown;
1389
+ }, opts: {
1390
+ appKey: string;
1391
+ actor?: string;
1392
+ sources?: DailyReportSourceTypeInput[];
1393
+ resources?: AuthzResourceItem[];
1394
+ }): Promise<void>;
1395
+
1366
1396
  /**
1367
1397
  * Generates a SHA-256 ETag for the given data.
1368
1398
  * 指定されたデータの SHA-256 ETag を生成します。
@@ -1524,4 +1554,4 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1524
1554
  streamKey: string;
1525
1555
  };
1526
1556
 
1527
- export { type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportCommentRow, type DailyReportCommentTable, type DailyReportDb, type DailyReportEncodeUserId, type DailyReportExternalSource, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubRow, type DailyReportHubTable, type DailyReportInternalRow, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type DailyReportResolveUserId, type DailyReportServerConfig, type DailyReportService, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, type EpochStore, type ExternalReportFields, type RedisStreamMessage, SqlResultCache, type SqlResultCacheQueryOptions, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, transformJsonArray };
1557
+ export { type AuthzResourceItem, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportCommentRow, type DailyReportCommentTable, type DailyReportDb, type DailyReportEncodeUserId, type DailyReportExternalSource, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubRow, type DailyReportHubTable, type DailyReportInternalRow, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type DailyReportResolveUserId, type DailyReportServerConfig, type DailyReportService, type DailyReportServiceConfig, type DailyReportSourceTypeInput, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, type EpochStore, type ExternalReportFields, type RedisStreamMessage, SqlResultCache, type SqlResultCacheQueryOptions, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, defineDailyReportAuthzResources, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, seedDailyReportAuthzResources, transformJsonArray };