@aiquants/daily-report 0.22.1 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,12 +1,32 @@
1
- export { c as DAILY_REPORT_SSE_CURSOR_PARAM, d as DAILY_REPORT_SSE_HEARTBEAT_MS, e as DAILY_REPORT_SSE_TERMINAL_EVENTS, f as DailyReportIdsStreamChunkLine, g as DailyReportIdsStreamCursor, h as DailyReportIdsStreamErrorLine, i as DailyReportIdsStreamLine, a as DailyReportSseMessage, b as DailyReportSseStreamAnchor, D as DailyReportSseTerminalEvent, U as UIComment, j as classifyIdsStreamLine, k as commentAddMessageSchema, l as commentDeleteMessageSchema, m as compareIdsStreamOrder, n as computeIdsStreamSnapshotToken, o as connectedMessageSchema, p as dailyReportAttachmentItemSchema, q as dailyReportDetailSchema, r as dailyReportExternalCommentSchema, s as dailyReportInterviewerSchema, t as dailyReportLabelDefSchema, u as dailyReportPostedCommentSchema, v as dailyReportSseMessageSchema, w as findIdsStreamResumeIndex, x as isDailyReportSseStreamId, y as isIdsStreamChunkLine, z as isIdsStreamOrdered, A as mergeComments, B as reportCreateMessageSchema, C as reportDeleteMessageSchema, E as reportPublishMessageSchema, F as reportUpdateMessageSchema, G as resolveCommentColorClass, H as statusUpdateMessageSchema, I as upsertInIdsStreamOrder } from "./ids-stream-DCuiaTit.mjs";
2
- export { D as DailyReportLogger, L as LogLevel, c as createLogger } from "./logger-D3krZrNK.mjs";
3
- export { d as DailyReportAttachmentState, D as DailyReportAttachmentSummary, b as DailyReportDetail, e as DailyReportExternalComment, f as DailyReportInterviewer, a as DailyReportItem, g as DailyReportLabelDef, h as DailyReportPostedComment, c as DailyReportUser } from "./types-CqgYQgbH.mjs";
1
+ export { c as DAILY_REPORT_SSE_CURSOR_PARAM, d as DAILY_REPORT_SSE_HEARTBEAT_MS, e as DAILY_REPORT_SSE_TERMINAL_EVENTS, f as DailyReportIdsStreamChunkLine, a as DailyReportSseMessage, b as DailyReportSseStreamAnchor, g as commentAddMessageSchema, h as commentDeleteMessageSchema, i as connectedMessageSchema, j as dailyReportDetailSchema, k as dailyReportExternalCommentSchema, l as dailyReportInterviewerSchema, m as dailyReportLabelDefSchema, n as dailyReportPostedCommentSchema, o as dailyReportSseMessageSchema, p as isDailyReportSseStreamId, q as isIdsStreamChunkLine, r as mergeComments, s as reportCreateMessageSchema, t as reportDeleteMessageSchema, u as reportPublishMessageSchema, v as reportUpdateMessageSchema, w as statusUpdateMessageSchema } from "./ids-stream-DvB2h1dj.mjs";
2
+ export { c as DailyReportAttachmentSummary, b as DailyReportDetail, d as DailyReportExternalComment, e as DailyReportInterviewer, D as DailyReportItem, f as DailyReportLabelDef, g as DailyReportPostedComment, a as DailyReportUser } from "./types-DkERw8NE.mjs";
4
3
  import "zod";
4
+ type DailyReportAttachmentThumbnailBox = {
5
+ readonly maxWidth: number;
6
+ readonly maxHeight: number;
7
+ };
8
+ declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS: Readonly<{
9
+ tile: Readonly<{
10
+ maxWidth: 480;
11
+ maxHeight: 320;
12
+ }>;
13
+ }>;
14
+ type DailyReportAttachmentThumbnailVariant = keyof typeof DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS;
15
+ declare const isDailyReportAttachmentThumbnailVariant: (value: string) => value is DailyReportAttachmentThumbnailVariant;
16
+ type DailyReportAttachmentDeliveryRequest = {
17
+ kind: "inline";
18
+ } | {
19
+ kind: "download";
20
+ } | {
21
+ kind: "thumbnail";
22
+ variant: DailyReportAttachmentThumbnailVariant;
23
+ };
24
+ type DailyReportAttachmentInvalidQuery = {
25
+ kind: "invalid";
26
+ reason: "thumbnail_variant" | "download_value" | "conflict";
27
+ };
28
+ declare const buildDailyReportAttachmentUrl: (apiBasePath: string, token: string, request: DailyReportAttachmentDeliveryRequest) => string;
29
+ declare const parseDailyReportAttachmentQuery: (params: URLSearchParams) => DailyReportAttachmentDeliveryRequest | DailyReportAttachmentInvalidQuery;
5
30
  type BusinessDateInput = string | Date | null | undefined;
6
- declare const resolveTodayBusinessDateKey: (now?: Date) => string;
7
31
  declare const normalizeBusinessDateKey: (value: BusinessDateInput) => string | null;
8
- declare const formatBusinessDateDisplay: (value: BusinessDateInput) => string | null;
9
- declare const parseBusinessDateKeyToDate: (value: BusinessDateInput) => Date | null;
10
- declare const fallbackText: (value: string | null | undefined) => string;
11
- declare const formatToIsoDate: (value: unknown) => string;
12
- export { fallbackText, formatBusinessDateDisplay, formatToIsoDate, normalizeBusinessDateKey, parseBusinessDateKeyToDate, resolveTodayBusinessDateKey };
32
+ export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS, type DailyReportAttachmentDeliveryRequest, type DailyReportAttachmentInvalidQuery, type DailyReportAttachmentThumbnailBox, type DailyReportAttachmentThumbnailVariant, buildDailyReportAttachmentUrl, isDailyReportAttachmentThumbnailVariant, normalizeBusinessDateKey, parseDailyReportAttachmentQuery };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,32 @@
1
- export { c as DAILY_REPORT_SSE_CURSOR_PARAM, d as DAILY_REPORT_SSE_HEARTBEAT_MS, e as DAILY_REPORT_SSE_TERMINAL_EVENTS, f as DailyReportIdsStreamChunkLine, g as DailyReportIdsStreamCursor, h as DailyReportIdsStreamErrorLine, i as DailyReportIdsStreamLine, a as DailyReportSseMessage, b as DailyReportSseStreamAnchor, D as DailyReportSseTerminalEvent, U as UIComment, j as classifyIdsStreamLine, k as commentAddMessageSchema, l as commentDeleteMessageSchema, m as compareIdsStreamOrder, n as computeIdsStreamSnapshotToken, o as connectedMessageSchema, p as dailyReportAttachmentItemSchema, q as dailyReportDetailSchema, r as dailyReportExternalCommentSchema, s as dailyReportInterviewerSchema, t as dailyReportLabelDefSchema, u as dailyReportPostedCommentSchema, v as dailyReportSseMessageSchema, w as findIdsStreamResumeIndex, x as isDailyReportSseStreamId, y as isIdsStreamChunkLine, z as isIdsStreamOrdered, A as mergeComments, B as reportCreateMessageSchema, C as reportDeleteMessageSchema, E as reportPublishMessageSchema, F as reportUpdateMessageSchema, G as resolveCommentColorClass, H as statusUpdateMessageSchema, I as upsertInIdsStreamOrder } from "./ids-stream-BnM6L-Sk.js";
2
- export { D as DailyReportLogger, L as LogLevel, c as createLogger } from "./logger-D3krZrNK.js";
3
- export { d as DailyReportAttachmentState, D as DailyReportAttachmentSummary, b as DailyReportDetail, e as DailyReportExternalComment, f as DailyReportInterviewer, a as DailyReportItem, g as DailyReportLabelDef, h as DailyReportPostedComment, c as DailyReportUser } from "./types-CqgYQgbH.js";
1
+ export { c as DAILY_REPORT_SSE_CURSOR_PARAM, d as DAILY_REPORT_SSE_HEARTBEAT_MS, e as DAILY_REPORT_SSE_TERMINAL_EVENTS, f as DailyReportIdsStreamChunkLine, a as DailyReportSseMessage, b as DailyReportSseStreamAnchor, g as commentAddMessageSchema, h as commentDeleteMessageSchema, i as connectedMessageSchema, j as dailyReportDetailSchema, k as dailyReportExternalCommentSchema, l as dailyReportInterviewerSchema, m as dailyReportLabelDefSchema, n as dailyReportPostedCommentSchema, o as dailyReportSseMessageSchema, p as isDailyReportSseStreamId, q as isIdsStreamChunkLine, r as mergeComments, s as reportCreateMessageSchema, t as reportDeleteMessageSchema, u as reportPublishMessageSchema, v as reportUpdateMessageSchema, w as statusUpdateMessageSchema } from "./ids-stream-BR5RSj5u.js";
2
+ export { c as DailyReportAttachmentSummary, b as DailyReportDetail, d as DailyReportExternalComment, e as DailyReportInterviewer, D as DailyReportItem, f as DailyReportLabelDef, g as DailyReportPostedComment, a as DailyReportUser } from "./types-DkERw8NE.js";
4
3
  import "zod";
4
+ type DailyReportAttachmentThumbnailBox = {
5
+ readonly maxWidth: number;
6
+ readonly maxHeight: number;
7
+ };
8
+ declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS: Readonly<{
9
+ tile: Readonly<{
10
+ maxWidth: 480;
11
+ maxHeight: 320;
12
+ }>;
13
+ }>;
14
+ type DailyReportAttachmentThumbnailVariant = keyof typeof DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS;
15
+ declare const isDailyReportAttachmentThumbnailVariant: (value: string) => value is DailyReportAttachmentThumbnailVariant;
16
+ type DailyReportAttachmentDeliveryRequest = {
17
+ kind: "inline";
18
+ } | {
19
+ kind: "download";
20
+ } | {
21
+ kind: "thumbnail";
22
+ variant: DailyReportAttachmentThumbnailVariant;
23
+ };
24
+ type DailyReportAttachmentInvalidQuery = {
25
+ kind: "invalid";
26
+ reason: "thumbnail_variant" | "download_value" | "conflict";
27
+ };
28
+ declare const buildDailyReportAttachmentUrl: (apiBasePath: string, token: string, request: DailyReportAttachmentDeliveryRequest) => string;
29
+ declare const parseDailyReportAttachmentQuery: (params: URLSearchParams) => DailyReportAttachmentDeliveryRequest | DailyReportAttachmentInvalidQuery;
5
30
  type BusinessDateInput = string | Date | null | undefined;
6
- declare const resolveTodayBusinessDateKey: (now?: Date) => string;
7
31
  declare const normalizeBusinessDateKey: (value: BusinessDateInput) => string | null;
8
- declare const formatBusinessDateDisplay: (value: BusinessDateInput) => string | null;
9
- declare const parseBusinessDateKeyToDate: (value: BusinessDateInput) => Date | null;
10
- declare const fallbackText: (value: string | null | undefined) => string;
11
- declare const formatToIsoDate: (value: unknown) => string;
12
- export { fallbackText, formatBusinessDateDisplay, formatToIsoDate, normalizeBusinessDateKey, parseBusinessDateKeyToDate, resolveTodayBusinessDateKey };
32
+ export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS, type DailyReportAttachmentDeliveryRequest, type DailyReportAttachmentInvalidQuery, type DailyReportAttachmentThumbnailBox, type DailyReportAttachmentThumbnailVariant, buildDailyReportAttachmentUrl, isDailyReportAttachmentThumbnailVariant, normalizeBusinessDateKey, parseDailyReportAttachmentQuery };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var L=(r,e)=>{for(var n in e)d(r,n,{get:e[n],enumerable:!0})},B=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of U(e))!j.call(r,s)&&s!==n&&d(r,s,{get:()=>e[s],enumerable:!(o=O(e,s))||o.enumerable});return r};var z=r=>B(d({},"__esModule",{value:!0}),r);var ae={};L(ae,{DAILY_REPORT_SSE_CURSOR_PARAM:()=>re,DAILY_REPORT_SSE_HEARTBEAT_MS:()=>te,DAILY_REPORT_SSE_TERMINAL_EVENTS:()=>ee,LogLevel:()=>h,classifyIdsStreamLine:()=>b,commentAddMessageSchema:()=>C,commentDeleteMessageSchema:()=>w,compareIdsStreamOrder:()=>m,computeIdsStreamSnapshotToken:()=>J,connectedMessageSchema:()=>k,createLogger:()=>v,dailyReportAttachmentItemSchema:()=>R,dailyReportDetailSchema:()=>p,dailyReportExternalCommentSchema:()=>I,dailyReportInterviewerSchema:()=>D,dailyReportLabelDefSchema:()=>S,dailyReportPostedCommentSchema:()=>g,dailyReportSseMessageSchema:()=>se,fallbackText:()=>ie,findIdsStreamResumeIndex:()=>Z,formatBusinessDateDisplay:()=>K,formatToIsoDate:()=>N,isDailyReportSseStreamId:()=>oe,isIdsStreamChunkLine:()=>W,isIdsStreamOrdered:()=>Q,mergeComments:()=>G,normalizeBusinessDateKey:()=>c,parseBusinessDateKeyToDate:()=>q,reportCreateMessageSchema:()=>M,reportDeleteMessageSchema:()=>_,reportPublishMessageSchema:()=>A,reportUpdateMessageSchema:()=>E,resolveCommentColorClass:()=>V,resolveTodayBusinessDateKey:()=>x,statusUpdateMessageSchema:()=>T,upsertInIdsStreamOrder:()=>X});module.exports=z(ae);var Y=/^\d{4}-\d{2}-\d{2}$/,F=/^\d{4}\/\d{2}\/\d{2}$/,u=r=>r<10?`0${r}`:`${r}`,f=r=>{if(Number.isNaN(r.getTime()))return null;let e=r.getFullYear(),n=u(r.getMonth()+1),o=u(r.getDate());return`${e}-${n}-${o}`},x=(r=new Date)=>Number.isNaN(r.getTime())?x(new Date):`${r.getFullYear()}-${u(r.getMonth()+1)}-${u(r.getDate())}`,c=r=>{if(r==null)return null;if(r instanceof Date)return f(r);let e=r.trim();if(e==="")return null;if(Y.test(e))return e;if(F.test(e))return e.replaceAll("/","-");let n=new Date(e);return f(n)},K=r=>{let e=c(r);return e||null},q=r=>{let e=c(r);if(!e)return null;let[n,o,s]=e.split("-").map(i=>Number.parseInt(i,10));return[n,o,s].some(i=>Number.isNaN(i))?null:new Date(n,o-1,s)};var G=(r,e,n,o)=>{if(typeof o!="string"||o.trim()==="")throw new RangeError(`[daily-report] mergeComments: unknownAuthorName must be a non-blank string; got ${typeof o=="string"?JSON.stringify(o):typeof o}`);let s=r.map((a,l)=>({id:`legacy-${l}`,authorName:a.name||o,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),i=e.map(a=>({id:a.id,authorName:a.userName||o,content:a.content??"",createdAt:a.createdAt??"",isMine:n?a.userId===n:a.isMine,isLegacy:!1}));return[...s,...i]},V=r=>{if(!r)return"text-gray-700 dark:text-gray-300";let e=r.toLowerCase();return e.includes("red")||e.includes("\u8D64")?"text-red-600 dark:text-red-400":e.includes("green")||e.includes("\u7DD1")?"text-green-600 dark:text-green-400":e.includes("blue")||e.includes("\u9752")?"text-blue-600 dark:text-blue-400":e.includes("yellow")||e.includes("\u9EC4")?"text-yellow-600 dark:text-yellow-400":e.includes("orange")||e.includes("\u6A59")?"text-orange-500 dark:text-orange-400":"text-gray-700 dark:text-gray-300"};var b=r=>{if(typeof r!="object"||r===null)return"unknown";let e=r;return typeof e.kind=="string"?e.kind==="chunk"?"chunk":e.kind==="error"?"error":"unknown":Array.isArray(e.items)?"chunk":typeof e.error=="string"?"error":"unknown"},W=r=>b(r)==="chunk",J=r=>{let e=2166136261,n=-624069552;for(let o of r){let s=o.reportHubId;e^=s&255,e=Math.imul(e,16777619),e^=s>>>8&255,e=Math.imul(e,16777619),e^=s>>>16&255,e=Math.imul(e,16777619),e^=s>>>24&255,e=Math.imul(e,16777619),n^=s>>>24&255,n=Math.imul(n,16777619),n^=s>>>16&255,n=Math.imul(n,16777619),n^=s>>>8&255,n=Math.imul(n,16777619),n^=s&255,n=Math.imul(n,16777619);let i=o.businessDate;if(i===null)e^=1,e=Math.imul(e,16777619),n^=1,n=Math.imul(n,16777619);else for(let a=0;a<i.length;a++){let l=i.charCodeAt(a);e^=l&255,e=Math.imul(e,16777619),n^=l&255,n=Math.imul(n,16777619)}}return e^=r.length,e=Math.imul(e,16777619),n^=r.length,n=Math.imul(n,16777619),((e>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")).replace(/^0+(?=.)/,"")},m=(r,e)=>r.businessDate!==e.businessDate?r.businessDate===null?1:e.businessDate===null||r.businessDate>e.businessDate?-1:1:e.reportHubId-r.reportHubId,Q=r=>{for(let e=1;e<r.length;e++)if(m(r[e-1],r[e])>0)return!1;return!0},X=(r,e)=>{let n=r.filter(i=>i.reportHubId!==e.reportHubId),o=0,s=n.length;for(;o<s;){let i=o+s>>1;m(n[i],e)<=0?o=i+1:s=i}return n.splice(o,0,e),n},Z=(r,e)=>{let n=r.findIndex(o=>m({businessDate:o.businessDate,reportHubId:o.reportHubId},e)>0);return n===-1?r.length:n};var h=(i=>(i[i.DEBUG=0]="DEBUG",i[i.INFO=1]="INFO",i[i.WARN=2]="WARN",i[i.ERROR=3]="ERROR",i[i.NONE=4]="NONE",i))(h||{}),v=(r,e,n=console)=>{let o=s=>typeof s=="string"?[`${e} ${s}`]:[e,s];return{debug:(s,...i)=>{r<=0&&n.debug(...o(s),...i)},info:(s,...i)=>{r<=1&&n.info(...o(s),...i)},warn:(s,...i)=>{r<=2&&n.warn(...o(s),...i)},error:(s,...i)=>{r<=3&&n.error(...o(s),...i)}}};var t=require("zod"),ee=["auth-required","forbidden","resync-required"],te=15e3,re="lastEventId",ne=/^\d{1,15}-\d{1,15}$/,oe=r=>ne.test(r),D=t.z.object({name:t.z.string().nullish(),affiliation:t.z.string().nullish()}),I=t.z.object({name:t.z.string().nullish(),text:t.z.string().nullish(),color:t.z.string().nullish()}),S=t.z.object({id:t.z.number(),name:t.z.string().nullish(),color:t.z.string().nullish()}),g=t.z.object({id:t.z.number(),userId:t.z.string().nullish(),userName:t.z.string().nullish(),content:t.z.string().nullish(),createdAt:t.z.string().nullish(),isMine:t.z.boolean()}),R=t.z.object({id:t.z.string(),fileName:t.z.string(),fileType:t.z.string().nullable(),fileSize:t.z.number().nullable(),createdAt:t.z.string().nullable(),state:t.z.enum(["present","absent","unknown"])}),p=t.z.object({reportHubId:t.z.number(),date:t.z.string().nullish(),createdAt:t.z.string().nullish(),author:t.z.string().nullish(),userId:t.z.string().nullish(),sourceType:t.z.string().nullish(),employeeName:t.z.string().nullish(),updatedBy:t.z.string().nullish(),updatedAt:t.z.string().nullish(),category:t.z.string().nullish(),creationCategory:t.z.string().nullish(),visitTimeFrom:t.z.string().nullish(),visitTimeTo:t.z.string().nullish(),customerName:t.z.string().nullish(),interviewers:t.z.array(D),subject:t.z.string().nullish(),content:t.z.string().nullish(),externalComments:t.z.array(I),isRead:t.z.boolean(),isStarred:t.z.boolean(),labels:t.z.array(S),postedComments:t.z.array(g),attachments:t.z.array(R).default([])}),k=t.z.object({type:t.z.literal("connected")}),T=t.z.object({type:t.z.literal("status-update"),reportHubId:t.z.number(),statusType:t.z.enum(["star","read"]),value:t.z.boolean(),clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),y=t.z.string().optional(),C=t.z.object({type:t.z.literal("comment-add"),reportHubId:t.z.number(),comment:g,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional(),sourceType:y}),w=t.z.object({type:t.z.literal("comment-delete"),reportHubId:t.z.number(),commentId:t.z.number(),clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional(),sourceType:y}),M=t.z.object({type:t.z.literal("report-create"),reportHubId:t.z.number(),report:p,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),E=t.z.object({type:t.z.literal("report-update"),reportHubId:t.z.number(),report:p,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),A=t.z.object({type:t.z.literal("report-publish"),reportHubId:t.z.number(),report:p,clientTempId:t.z.string(),recipientRawUserId:t.z.number().optional()}),_=t.z.object({type:t.z.literal("report-delete"),reportHubId:t.z.number(),clientTempId:t.z.string(),sourceType:y}),se=t.z.discriminatedUnion("type",[k,T,C,w,M,E,A,_]);var ie=r=>{if(!r)return"-";let e=r.trim();return e===""?"-":e},N=r=>{if(!r)return"-";if(typeof r!="string")return r instanceof Date?N(r.toISOString()):String(r);let e=r.trim();if(e==="")return"-";let n=e.match(/^(\d{4})[-/](\d{2})[-/](\d{2})$/);if(n)return`${n[1]}-${n[2]}-${n[3]}`;let o=new Date(e);if(Number.isNaN(o.getTime()))return e;let s=o.getFullYear(),i=String(o.getMonth()+1).padStart(2,"0"),a=String(o.getDate()).padStart(2,"0");if(e.includes(":")||e.includes("T")){let $=String(o.getHours()).padStart(2,"0"),P=String(o.getMinutes()).padStart(2,"0"),H=String(o.getSeconds()).padStart(2,"0");return`${s}-${i}-${a}T${$}:${P}:${H}`}return`${s}-${i}-${a}`};0&&(module.exports={DAILY_REPORT_SSE_CURSOR_PARAM,DAILY_REPORT_SSE_HEARTBEAT_MS,DAILY_REPORT_SSE_TERMINAL_EVENTS,LogLevel,classifyIdsStreamLine,commentAddMessageSchema,commentDeleteMessageSchema,compareIdsStreamOrder,computeIdsStreamSnapshotToken,connectedMessageSchema,createLogger,dailyReportAttachmentItemSchema,dailyReportDetailSchema,dailyReportExternalCommentSchema,dailyReportInterviewerSchema,dailyReportLabelDefSchema,dailyReportPostedCommentSchema,dailyReportSseMessageSchema,fallbackText,findIdsStreamResumeIndex,formatBusinessDateDisplay,formatToIsoDate,isDailyReportSseStreamId,isIdsStreamChunkLine,isIdsStreamOrdered,mergeComments,normalizeBusinessDateKey,parseBusinessDateKeyToDate,reportCreateMessageSchema,reportDeleteMessageSchema,reportPublishMessageSchema,reportUpdateMessageSchema,resolveCommentColorClass,resolveTodayBusinessDateKey,statusUpdateMessageSchema,upsertInIdsStreamOrder});
1
+ "use strict";var p=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var Y=Object.prototype.hasOwnProperty;var q=(t,r)=>{for(var n in r)p(t,n,{get:r[n],enumerable:!0})},F=(t,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of z(r))!Y.call(t,i)&&i!==n&&p(t,i,{get:()=>r[i],enumerable:!(o=V(r,i))||o.enumerable});return t};var K=t=>F(p({},"__esModule",{value:!0}),t);var ee={};q(ee,{DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS:()=>u,DAILY_REPORT_SSE_CURSOR_PARAM:()=>O,DAILY_REPORT_SSE_HEARTBEAT_MS:()=>H,DAILY_REPORT_SSE_TERMINAL_EVENTS:()=>U,buildDailyReportAttachmentUrl:()=>E,commentAddMessageSchema:()=>D,commentDeleteMessageSchema:()=>b,connectedMessageSchema:()=>h,dailyReportDetailSchema:()=>s,dailyReportExternalCommentSchema:()=>c,dailyReportInterviewerSchema:()=>d,dailyReportLabelDefSchema:()=>y,dailyReportPostedCommentSchema:()=>m,dailyReportSseMessageSchema:()=>j,isDailyReportAttachmentThumbnailVariant:()=>l,isDailyReportSseStreamId:()=>$,isIdsStreamChunkLine:()=>P,mergeComments:()=>N,normalizeBusinessDateKey:()=>L,parseDailyReportAttachmentQuery:()=>C,reportCreateMessageSchema:()=>f,reportDeleteMessageSchema:()=>I,reportPublishMessageSchema:()=>S,reportUpdateMessageSchema:()=>x,statusUpdateMessageSchema:()=>g});module.exports=K(ee);var u=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),l=t=>Object.hasOwn(u,t);var A="download",T="thumbnail",_="1",E=(t,r,n)=>{let o=`${t}/attachment/${encodeURIComponent(r)}`;switch(n.kind){case"inline":return o;case"download":return`${o}?${new URLSearchParams({[A]:_})}`;case"thumbnail":return`${o}?${new URLSearchParams({[T]:n.variant})}`}},C=t=>{let r=t.getAll(T),n=t.getAll(A);if(r.length>0&&n.length>0)return{kind:"invalid",reason:"conflict"};if(r.length>0){let[o]=r;return r.length===1&&l(o)?{kind:"thumbnail",variant:o}:{kind:"invalid",reason:"thumbnail_variant"}}return n.length>0?n.length===1&&n[0]===_?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var Q=/^\d{4}-\d{2}-\d{2}$/,W=/^\d{4}\/\d{2}\/\d{2}$/,M=t=>t<10?`0${t}`:`${t}`,k=t=>{if(Number.isNaN(t.getTime()))return null;let r=t.getFullYear(),n=M(t.getMonth()+1),o=M(t.getDate());return`${r}-${n}-${o}`};var L=t=>{if(t==null)return null;if(t instanceof Date)return k(t);let r=t.trim();if(r==="")return null;if(Q.test(r))return r;if(W.test(r))return r.replaceAll("/","-");let n=new Date(r);return k(n)};var J=t=>typeof t=="string"?JSON.stringify(t):typeof t=="number"||typeof t=="boolean"||t===null||t===void 0?String(t):Array.isArray(t)?"array":typeof t,w=(t,r,n)=>new RangeError(`[daily-report] ${t} must be ${r}; got ${J(n)}`);var N=(t,r,n,o)=>{if(typeof o!="string"||o.trim()==="")throw w("mergeComments: unknownAuthorName","a non-blank string",o);let i=t.map((a,B)=>({id:`legacy-${B}`,authorName:a.name||o,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),v=r.map(a=>({id:a.id,authorName:a.userName||o,content:a.content??"",createdAt:a.createdAt??"",isMine:n?a.userId===n:a.isMine,isLegacy:!1}));return[...i,...v]};var G=t=>{if(typeof t!="object"||t===null)return"unknown";let r=t;return typeof r.kind=="string"?r.kind==="chunk"?"chunk":r.kind==="error"?"error":"unknown":Array.isArray(r.items)?"chunk":typeof r.error=="string"?"error":"unknown"},P=t=>G(t)==="chunk";var e=require("zod"),U=["auth-required","forbidden","resync-required"],H=15e3,O="lastEventId",X=/^\d{1,15}-\d{1,15}$/,$=t=>X.test(t),d=e.z.object({name:e.z.string().nullish(),affiliation:e.z.string().nullish()}),c=e.z.object({name:e.z.string().nullish(),text:e.z.string().nullish(),color:e.z.string().nullish()}),y=e.z.object({id:e.z.number(),name:e.z.string().nullish(),color:e.z.string().nullish()}),m=e.z.object({id:e.z.number(),userId:e.z.string().nullish(),userName:e.z.string().nullish(),content:e.z.string().nullish(),createdAt:e.z.string().nullish(),isMine:e.z.boolean()}),Z=e.z.object({id:e.z.string(),fileName:e.z.string(),fileType:e.z.string().nullable(),fileSize:e.z.number().nullable(),createdAt:e.z.string().nullable(),state:e.z.enum(["present","absent","unknown"]),hasThumbnail:e.z.boolean().default(!1)}),s=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(d),subject:e.z.string().nullish(),content:e.z.string().nullish(),externalComments:e.z.array(c),isRead:e.z.boolean(),isStarred:e.z.boolean(),labels:e.z.array(y),postedComments:e.z.array(m),attachments:e.z.array(Z).default([])}),h=e.z.object({type:e.z.literal("connected")}),g=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()}),R=e.z.string().optional(),D=e.z.object({type:e.z.literal("comment-add"),reportHubId:e.z.number(),comment:m,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional(),sourceType:R}),b=e.z.object({type:e.z.literal("comment-delete"),reportHubId:e.z.number(),commentId:e.z.number(),clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional(),sourceType:R}),f=e.z.object({type:e.z.literal("report-create"),reportHubId:e.z.number(),report:s,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),x=e.z.object({type:e.z.literal("report-update"),reportHubId:e.z.number(),report:s,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),S=e.z.object({type:e.z.literal("report-publish"),reportHubId:e.z.number(),report:s,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),I=e.z.object({type:e.z.literal("report-delete"),reportHubId:e.z.number(),clientTempId:e.z.string(),sourceType:R}),j=e.z.discriminatedUnion("type",[h,g,D,b,f,x,S,I]);0&&(module.exports={DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS,DAILY_REPORT_SSE_CURSOR_PARAM,DAILY_REPORT_SSE_HEARTBEAT_MS,DAILY_REPORT_SSE_TERMINAL_EVENTS,buildDailyReportAttachmentUrl,commentAddMessageSchema,commentDeleteMessageSchema,connectedMessageSchema,dailyReportDetailSchema,dailyReportExternalCommentSchema,dailyReportInterviewerSchema,dailyReportLabelDefSchema,dailyReportPostedCommentSchema,dailyReportSseMessageSchema,isDailyReportAttachmentThumbnailVariant,isDailyReportSseStreamId,isIdsStreamChunkLine,mergeComments,normalizeBusinessDateKey,parseDailyReportAttachmentQuery,reportCreateMessageSchema,reportDeleteMessageSchema,reportPublishMessageSchema,reportUpdateMessageSchema,statusUpdateMessageSchema});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var h=/^\d{4}-\d{2}-\d{2}$/,D=/^\d{4}\/\d{2}\/\d{2}$/,u=r=>r<10?`0${r}`:`${r}`,c=r=>{if(Number.isNaN(r.getTime()))return null;let t=r.getFullYear(),n=u(r.getMonth()+1),s=u(r.getDate());return`${t}-${n}-${s}`},I=(r=new Date)=>Number.isNaN(r.getTime())?I(new Date):`${r.getFullYear()}-${u(r.getMonth()+1)}-${u(r.getDate())}`,g=r=>{if(r==null)return null;if(r instanceof Date)return c(r);let t=r.trim();if(t==="")return null;if(h.test(t))return t;if(D.test(t))return t.replaceAll("/","-");let n=new Date(t);return c(n)},j=r=>{let t=g(r);return t||null},L=r=>{let t=g(r);if(!t)return null;let[n,s,i]=t.split("-").map(o=>Number.parseInt(o,10));return[n,s,i].some(o=>Number.isNaN(o))?null:new Date(n,s-1,i)};var z=(r,t,n,s)=>{if(typeof s!="string"||s.trim()==="")throw new RangeError(`[daily-report] mergeComments: unknownAuthorName must be a non-blank string; got ${typeof s=="string"?JSON.stringify(s):typeof s}`);let i=r.map((a,l)=>({id:`legacy-${l}`,authorName:a.name||s,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),o=t.map(a=>({id:a.id,authorName:a.userName||s,content:a.content??"",createdAt:a.createdAt??"",isMine:n?a.userId===n:a.isMine,isLegacy:!1}));return[...i,...o]},Y=r=>{if(!r)return"text-gray-700 dark:text-gray-300";let t=r.toLowerCase();return t.includes("red")||t.includes("\u8D64")?"text-red-600 dark:text-red-400":t.includes("green")||t.includes("\u7DD1")?"text-green-600 dark:text-green-400":t.includes("blue")||t.includes("\u9752")?"text-blue-600 dark:text-blue-400":t.includes("yellow")||t.includes("\u9EC4")?"text-yellow-600 dark:text-yellow-400":t.includes("orange")||t.includes("\u6A59")?"text-orange-500 dark:text-orange-400":"text-gray-700 dark:text-gray-300"};var S=r=>{if(typeof r!="object"||r===null)return"unknown";let t=r;return typeof t.kind=="string"?t.kind==="chunk"?"chunk":t.kind==="error"?"error":"unknown":Array.isArray(t.items)?"chunk":typeof t.error=="string"?"error":"unknown"},K=r=>S(r)==="chunk",q=r=>{let t=2166136261,n=-624069552;for(let s of r){let i=s.reportHubId;t^=i&255,t=Math.imul(t,16777619),t^=i>>>8&255,t=Math.imul(t,16777619),t^=i>>>16&255,t=Math.imul(t,16777619),t^=i>>>24&255,t=Math.imul(t,16777619),n^=i>>>24&255,n=Math.imul(n,16777619),n^=i>>>16&255,n=Math.imul(n,16777619),n^=i>>>8&255,n=Math.imul(n,16777619),n^=i&255,n=Math.imul(n,16777619);let o=s.businessDate;if(o===null)t^=1,t=Math.imul(t,16777619),n^=1,n=Math.imul(n,16777619);else for(let a=0;a<o.length;a++){let l=o.charCodeAt(a);t^=l&255,t=Math.imul(t,16777619),n^=l&255,n=Math.imul(n,16777619)}}return t^=r.length,t=Math.imul(t,16777619),n^=r.length,n=Math.imul(n,16777619),((t>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")).replace(/^0+(?=.)/,"")},m=(r,t)=>r.businessDate!==t.businessDate?r.businessDate===null?1:t.businessDate===null||r.businessDate>t.businessDate?-1:1:t.reportHubId-r.reportHubId,G=r=>{for(let t=1;t<r.length;t++)if(m(r[t-1],r[t])>0)return!1;return!0},V=(r,t)=>{let n=r.filter(o=>o.reportHubId!==t.reportHubId),s=0,i=n.length;for(;s<i;){let o=s+i>>1;m(n[o],t)<=0?s=o+1:i=o}return n.splice(s,0,t),n},W=(r,t)=>{let n=r.findIndex(s=>m({businessDate:s.businessDate,reportHubId:s.reportHubId},t)>0);return n===-1?r.length:n};var R=(o=>(o[o.DEBUG=0]="DEBUG",o[o.INFO=1]="INFO",o[o.WARN=2]="WARN",o[o.ERROR=3]="ERROR",o[o.NONE=4]="NONE",o))(R||{}),Q=(r,t,n=console)=>{let s=i=>typeof i=="string"?[`${t} ${i}`]:[t,i];return{debug:(i,...o)=>{r<=0&&n.debug(...s(i),...o)},info:(i,...o)=>{r<=1&&n.info(...s(i),...o)},warn:(i,...o)=>{r<=2&&n.warn(...s(i),...o)},error:(i,...o)=>{r<=3&&n.error(...s(i),...o)}}};import{z as e}from"zod";var v=["auth-required","forbidden","resync-required"],ee=15e3,te="lastEventId",k=/^\d{1,15}-\d{1,15}$/,re=r=>k.test(r),T=e.object({name:e.string().nullish(),affiliation:e.string().nullish()}),C=e.object({name:e.string().nullish(),text:e.string().nullish(),color:e.string().nullish()}),w=e.object({id:e.number(),name:e.string().nullish(),color:e.string().nullish()}),y=e.object({id:e.number(),userId:e.string().nullish(),userName:e.string().nullish(),content:e.string().nullish(),createdAt:e.string().nullish(),isMine:e.boolean()}),M=e.object({id:e.string(),fileName:e.string(),fileType:e.string().nullable(),fileSize:e.number().nullable(),createdAt:e.string().nullable(),state:e.enum(["present","absent","unknown"])}),p=e.object({reportHubId:e.number(),date:e.string().nullish(),createdAt:e.string().nullish(),author:e.string().nullish(),userId:e.string().nullish(),sourceType:e.string().nullish(),employeeName:e.string().nullish(),updatedBy:e.string().nullish(),updatedAt:e.string().nullish(),category:e.string().nullish(),creationCategory:e.string().nullish(),visitTimeFrom:e.string().nullish(),visitTimeTo:e.string().nullish(),customerName:e.string().nullish(),interviewers:e.array(T),subject:e.string().nullish(),content:e.string().nullish(),externalComments:e.array(C),isRead:e.boolean(),isStarred:e.boolean(),labels:e.array(w),postedComments:e.array(y),attachments:e.array(M).default([])}),E=e.object({type:e.literal("connected")}),A=e.object({type:e.literal("status-update"),reportHubId:e.number(),statusType:e.enum(["star","read"]),value:e.boolean(),clientTempId:e.string(),recipientRawUserId:e.number().optional()}),d=e.string().optional(),_=e.object({type:e.literal("comment-add"),reportHubId:e.number(),comment:y,clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:d}),N=e.object({type:e.literal("comment-delete"),reportHubId:e.number(),commentId:e.number(),clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:d}),$=e.object({type:e.literal("report-create"),reportHubId:e.number(),report:p,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),P=e.object({type:e.literal("report-update"),reportHubId:e.number(),report:p,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),H=e.object({type:e.literal("report-publish"),reportHubId:e.number(),report:p,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),O=e.object({type:e.literal("report-delete"),reportHubId:e.number(),clientTempId:e.string(),sourceType:d}),ne=e.discriminatedUnion("type",[E,A,_,N,$,P,H,O]);var se=r=>{if(!r)return"-";let t=r.trim();return t===""?"-":t},U=r=>{if(!r)return"-";if(typeof r!="string")return r instanceof Date?U(r.toISOString()):String(r);let t=r.trim();if(t==="")return"-";let n=t.match(/^(\d{4})[-/](\d{2})[-/](\d{2})$/);if(n)return`${n[1]}-${n[2]}-${n[3]}`;let s=new Date(t);if(Number.isNaN(s.getTime()))return t;let i=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0");if(t.includes(":")||t.includes("T")){let f=String(s.getHours()).padStart(2,"0"),x=String(s.getMinutes()).padStart(2,"0"),b=String(s.getSeconds()).padStart(2,"0");return`${i}-${o}-${a}T${f}:${x}:${b}`}return`${i}-${o}-${a}`};export{te as DAILY_REPORT_SSE_CURSOR_PARAM,ee as DAILY_REPORT_SSE_HEARTBEAT_MS,v as DAILY_REPORT_SSE_TERMINAL_EVENTS,R as LogLevel,S as classifyIdsStreamLine,_ as commentAddMessageSchema,N as commentDeleteMessageSchema,m as compareIdsStreamOrder,q as computeIdsStreamSnapshotToken,E as connectedMessageSchema,Q as createLogger,M as dailyReportAttachmentItemSchema,p as dailyReportDetailSchema,C as dailyReportExternalCommentSchema,T as dailyReportInterviewerSchema,w as dailyReportLabelDefSchema,y as dailyReportPostedCommentSchema,ne as dailyReportSseMessageSchema,se as fallbackText,W as findIdsStreamResumeIndex,j as formatBusinessDateDisplay,U as formatToIsoDate,re as isDailyReportSseStreamId,K as isIdsStreamChunkLine,G as isIdsStreamOrdered,z as mergeComments,g as normalizeBusinessDateKey,L as parseBusinessDateKeyToDate,$ as reportCreateMessageSchema,O as reportDeleteMessageSchema,H as reportPublishMessageSchema,P as reportUpdateMessageSchema,Y as resolveCommentColorClass,I as resolveTodayBusinessDateKey,A as statusUpdateMessageSchema,V as upsertInIdsStreamOrder};
1
+ var p=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),s=t=>Object.hasOwn(p,t);var u="download",d="thumbnail",c="1",L=(t,r,n)=>{let o=`${t}/attachment/${encodeURIComponent(r)}`;switch(n.kind){case"inline":return o;case"download":return`${o}?${new URLSearchParams({[u]:c})}`;case"thumbnail":return`${o}?${new URLSearchParams({[d]:n.variant})}`}},w=t=>{let r=t.getAll(d),n=t.getAll(u);if(r.length>0&&n.length>0)return{kind:"invalid",reason:"conflict"};if(r.length>0){let[o]=r;return r.length===1&&s(o)?{kind:"thumbnail",variant:o}:{kind:"invalid",reason:"thumbnail_variant"}}return n.length>0?n.length===1&&n[0]===c?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var N=/^\d{4}-\d{2}-\d{2}$/,P=/^\d{4}\/\d{2}\/\d{2}$/,y=t=>t<10?`0${t}`:`${t}`,h=t=>{if(Number.isNaN(t.getTime()))return null;let r=t.getFullYear(),n=y(t.getMonth()+1),o=y(t.getDate());return`${r}-${n}-${o}`};var U=t=>{if(t==null)return null;if(t instanceof Date)return h(t);let r=t.trim();if(r==="")return null;if(N.test(r))return r;if(P.test(r))return r.replaceAll("/","-");let n=new Date(r);return h(n)};var H=t=>typeof t=="string"?JSON.stringify(t):typeof t=="number"||typeof t=="boolean"||t===null||t===void 0?String(t):Array.isArray(t)?"array":typeof t,g=(t,r,n)=>new RangeError(`[daily-report] ${t} must be ${r}; got ${H(n)}`);var O=(t,r,n,o)=>{if(typeof o!="string"||o.trim()==="")throw g("mergeComments: unknownAuthorName","a non-blank string",o);let C=t.map((a,k)=>({id:`legacy-${k}`,authorName:a.name||o,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),M=r.map(a=>({id:a.id,authorName:a.userName||o,content:a.content??"",createdAt:a.createdAt??"",isMine:n?a.userId===n:a.isMine,isLegacy:!1}));return[...C,...M]};var $=t=>{if(typeof t!="object"||t===null)return"unknown";let r=t;return typeof r.kind=="string"?r.kind==="chunk"?"chunk":r.kind==="error"?"error":"unknown":Array.isArray(r.items)?"chunk":typeof r.error=="string"?"error":"unknown"},j=t=>$(t)==="chunk";import{z as e}from"zod";var v=["auth-required","forbidden","resync-required"],B=15e3,V="lastEventId",z=/^\d{1,15}-\d{1,15}$/,Y=t=>z.test(t),R=e.object({name:e.string().nullish(),affiliation:e.string().nullish()}),D=e.object({name:e.string().nullish(),text:e.string().nullish(),color:e.string().nullish()}),b=e.object({id:e.number(),name:e.string().nullish(),color:e.string().nullish()}),l=e.object({id:e.number(),userId:e.string().nullish(),userName:e.string().nullish(),content:e.string().nullish(),createdAt:e.string().nullish(),isMine:e.boolean()}),q=e.object({id:e.string(),fileName:e.string(),fileType:e.string().nullable(),fileSize:e.number().nullable(),createdAt:e.string().nullable(),state:e.enum(["present","absent","unknown"]),hasThumbnail:e.boolean().default(!1)}),i=e.object({reportHubId:e.number(),date:e.string().nullish(),createdAt:e.string().nullish(),author:e.string().nullish(),userId:e.string().nullish(),sourceType:e.string().nullish(),employeeName:e.string().nullish(),updatedBy:e.string().nullish(),updatedAt:e.string().nullish(),category:e.string().nullish(),creationCategory:e.string().nullish(),visitTimeFrom:e.string().nullish(),visitTimeTo:e.string().nullish(),customerName:e.string().nullish(),interviewers:e.array(R),subject:e.string().nullish(),content:e.string().nullish(),externalComments:e.array(D),isRead:e.boolean(),isStarred:e.boolean(),labels:e.array(b),postedComments:e.array(l),attachments:e.array(q).default([])}),f=e.object({type:e.literal("connected")}),x=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()}),m=e.string().optional(),S=e.object({type:e.literal("comment-add"),reportHubId:e.number(),comment:l,clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:m}),I=e.object({type:e.literal("comment-delete"),reportHubId:e.number(),commentId:e.number(),clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:m}),A=e.object({type:e.literal("report-create"),reportHubId:e.number(),report:i,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),T=e.object({type:e.literal("report-update"),reportHubId:e.number(),report:i,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),_=e.object({type:e.literal("report-publish"),reportHubId:e.number(),report:i,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),E=e.object({type:e.literal("report-delete"),reportHubId:e.number(),clientTempId:e.string(),sourceType:m}),F=e.discriminatedUnion("type",[f,x,S,I,A,T,_,E]);export{p as DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS,V as DAILY_REPORT_SSE_CURSOR_PARAM,B as DAILY_REPORT_SSE_HEARTBEAT_MS,v as DAILY_REPORT_SSE_TERMINAL_EVENTS,L as buildDailyReportAttachmentUrl,S as commentAddMessageSchema,I as commentDeleteMessageSchema,f as connectedMessageSchema,i as dailyReportDetailSchema,D as dailyReportExternalCommentSchema,R as dailyReportInterviewerSchema,b as dailyReportLabelDefSchema,l as dailyReportPostedCommentSchema,F as dailyReportSseMessageSchema,s as isDailyReportAttachmentThumbnailVariant,Y as isDailyReportSseStreamId,j as isIdsStreamChunkLine,O as mergeComments,U as normalizeBusinessDateKey,w as parseDailyReportAttachmentQuery,A as reportCreateMessageSchema,E as reportDeleteMessageSchema,_ as reportPublishMessageSchema,T as reportUpdateMessageSchema,x as statusUpdateMessageSchema};
package/dist/server.d.mts CHANGED
@@ -1,9 +1,19 @@
1
- import { f as DailyReportInterviewer, e as DailyReportExternalComment, a as DailyReportItem, b as DailyReportDetail, D as DailyReportAttachmentSummary, h as DailyReportPostedComment } from "./types-CqgYQgbH.mjs";
1
+ import { e as DailyReportInterviewer, d as DailyReportExternalComment, D as DailyReportItem, b as DailyReportDetail, c as DailyReportAttachmentSummary, g as DailyReportPostedComment } from "./types-DkERw8NE.mjs";
2
+ import { TransactionRetryOptions } from "@aiquants/mssql";
2
3
  import * as drizzle_orm_mssql_core from "drizzle-orm/mssql-core";
3
4
  import { AnyMsSqlColumn } from "drizzle-orm/mssql-core";
4
- import { D as DailyReportLogger } from "./logger-D3krZrNK.mjs";
5
- import { TransactionRetryOptions } from "@aiquants/mssql";
6
- import { SQL } from "drizzle-orm";
5
+ interface DailyReportLogger {
6
+ debug(message?: unknown, ...optionalParams: unknown[]): void;
7
+ info(message?: unknown, ...optionalParams: unknown[]): void;
8
+ warn(message?: unknown, ...optionalParams: unknown[]): void;
9
+ error(message?: unknown, ...optionalParams: unknown[]): void;
10
+ }
11
+ declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES: readonly [
12
+ "image/webp",
13
+ "image/jpeg",
14
+ "image/png"
15
+ ];
16
+ declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES: number;
7
17
  type RedisStreamMessage = {
8
18
  id: string;
9
19
  message: Record<string, string>;
@@ -89,7 +99,29 @@ type DailyReportReadAttachment = (filePath: string, options: {
89
99
  maxBytes: number;
90
100
  head: boolean;
91
101
  principal?: string;
102
+ signal: AbortSignal;
92
103
  }) => Promise<DailyReportAttachmentBytes | DailyReportAttachmentError>;
104
+ type DailyReportAttachmentThumbnailSourceFormat = "png" | "jpeg" | "gif" | "webp";
105
+ type DailyReportAttachmentThumbnailFailure = "unsupported" | "failed";
106
+ type DailyReportAttachmentThumbnailOutputMediaType = (typeof DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES)[number];
107
+ type DailyReportAttachmentThumbnail = {
108
+ ok: true;
109
+ bytes: Uint8Array<ArrayBuffer>;
110
+ contentType: DailyReportAttachmentThumbnailOutputMediaType;
111
+ };
112
+ type DailyReportAttachmentThumbnailError = {
113
+ ok: false;
114
+ reason: DailyReportAttachmentThumbnailFailure;
115
+ };
116
+ type DailyReportAttachmentThumbnailRenderer = {
117
+ readonly id: string;
118
+ readonly render: (source: Uint8Array<ArrayBuffer>, options: {
119
+ format: DailyReportAttachmentThumbnailSourceFormat;
120
+ maxWidth: number;
121
+ maxHeight: number;
122
+ signal: AbortSignal;
123
+ }) => Promise<DailyReportAttachmentThumbnail | DailyReportAttachmentThumbnailError>;
124
+ };
93
125
  type SqlResultCacheQueryOptions = {
94
126
  forceRefresh?: boolean;
95
127
  snapshot?: boolean;
@@ -1392,11 +1424,6 @@ declare function defineDailyReportSchema<S extends string>(schemaName: S, opts:
1392
1424
  }>;
1393
1425
  };
1394
1426
  type VisibleSourceTypeSet = ReadonlySet<string> | null;
1395
- declare function normalizeVisibleSourceTypes(raw: readonly string[]): ReadonlySet<string>;
1396
- declare function normalizeVisibleSourceTypes(raw: readonly string[] | null | undefined): VisibleSourceTypeSet;
1397
- declare function isSourceTypeVisible(set: VisibleSourceTypeSet, sourceType: string | null | undefined): boolean;
1398
- declare function deniesEverySourceType(set: VisibleSourceTypeSet): boolean;
1399
- declare function buildVisibleSourceTypeCondition(sourceTypeColumn: AnyMsSqlColumn, set: VisibleSourceTypeSet): SQL | undefined;
1400
1427
  declare class DailyReportViewerScope {
1401
1428
  #private;
1402
1429
  private constructor();
@@ -1405,8 +1432,6 @@ declare class DailyReportViewerScope {
1405
1432
  static restrictTo(input: readonly string[] | DailyReportVisibilityDimensions): DailyReportViewerScope;
1406
1433
  static unrestricted(auditReason: string): DailyReportViewerScope;
1407
1434
  }
1408
- declare function computeViewerScopeDigest(scope: DailyReportViewerScope): string;
1409
- declare function computeSourceTypeDigest(set: VisibleSourceTypeSet): string;
1410
1435
  type DailyReportHubRow = {
1411
1436
  id: number;
1412
1437
  sourceType: string;
@@ -1442,16 +1467,6 @@ type DailyReportUserStatusRow = {
1442
1467
  updatedAt: Date | string;
1443
1468
  updatedBy: string;
1444
1469
  };
1445
- type DailyReportCommentRow = {
1446
- id: number;
1447
- hubId: number;
1448
- userId: number;
1449
- body: string;
1450
- createdAt: Date | string;
1451
- createdBy: string;
1452
- updatedAt: Date | string;
1453
- updatedBy: string;
1454
- };
1455
1470
  type Rows<T> = PromiseLike<T[]>;
1456
1471
  interface SelectChain<T> extends Rows<T> {
1457
1472
  from(t: unknown): SelectChain<T>;
@@ -1504,18 +1519,26 @@ type DailyReportServiceConfig = {
1504
1519
  businessDateTtlMs?: number;
1505
1520
  disableUserIdCache?: boolean;
1506
1521
  attachmentIdCodec?: DailyReportIdCodec;
1522
+ readAttachment?: DailyReportReadAttachment;
1523
+ attachmentThumbnailRenderer?: DailyReportAttachmentThumbnailRenderer;
1524
+ attachmentMaxBytes?: number;
1507
1525
  logger?: DailyReportLogger;
1508
1526
  };
1527
+ type DailyReportAttachmentDelivery = {
1528
+ readonly idCodec: DailyReportIdCodec | undefined;
1529
+ readonly readAttachment: DailyReportReadAttachment | undefined;
1530
+ readonly thumbnailRenderer: DailyReportAttachmentThumbnailRenderer | undefined;
1531
+ readonly maxBytes: number;
1532
+ };
1509
1533
  type DailyReportService = ReturnType<typeof createDailyReportService>;
1510
1534
  type DailyReportIdsSource = {
1511
1535
  readonly items: DailyReportItem[];
1512
1536
  readonly streamAnchor: string | null;
1513
1537
  };
1514
- type DatePattern = "YYYY-MM-DD HH:mm:ss" | "YYYY-MM-DD";
1515
- declare const formatDateValue: (value: Date | string | null | undefined, pattern: DatePattern) => string | null;
1516
1538
  declare function createDailyReportService(config: DailyReportServiceConfig): {
1517
1539
  streamKey: string;
1518
1540
  streamMaxLen: number;
1541
+ attachmentDelivery: DailyReportAttachmentDelivery;
1519
1542
  clearCache: () => Promise<void>;
1520
1543
  invalidateHubReadCaches: (hubIds: readonly number[], businessDates: readonly string[]) => Promise<void>;
1521
1544
  getUserIdByExternalId: (externalId: string) => Promise<number | null>;
@@ -1580,46 +1603,22 @@ declare class DailyReportSseReader {
1580
1603
  private _stopLoop;
1581
1604
  private _emitError;
1582
1605
  }
1583
- type AuthzResourceItem = {
1584
- resourceKey: string;
1585
- name: string;
1586
- description?: string | null;
1587
- };
1588
- type DailyReportSourceTypeInput = {
1589
- key: string;
1590
- name: string;
1591
- description?: string | null;
1592
- includeCommentResource?: boolean;
1593
- };
1594
- declare function defineDailyReportAuthzResources(sources?: DailyReportSourceTypeInput[]): AuthzResourceItem[];
1595
- declare function seedDailyReportAuthzResources(db: unknown, authzTables: {
1596
- TMResource: unknown;
1597
- }, opts: {
1598
- appKey: string;
1599
- actor?: string;
1600
- sources?: DailyReportSourceTypeInput[];
1601
- resources?: AuthzResourceItem[];
1602
- }): Promise<void>;
1603
- declare const generateETag: (data: unknown) => string;
1604
1606
  type LoaderArgs = {
1605
1607
  request: Request;
1606
1608
  params: Record<string, string | undefined>;
1607
1609
  };
1608
1610
  declare const DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS = 60000;
1609
1611
  declare const DAILY_REPORT_SSE_CATCH_UP_BATCH = 1000;
1610
- declare const sanitizeMediaType: (value: string | null | undefined) => string | null;
1611
- declare const encodeRfc8187: (name: string) => string;
1612
- declare const asciiFallbackFileName: (name: string) => string;
1613
1612
  type DailyReportHandlersConfig = {
1614
1613
  authenticate: DailyReportAuthenticate;
1615
1614
  resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
1616
1615
  service: DailyReportService;
1617
1616
  encodeUserId: DailyReportEncodeUserId;
1618
- attachmentIdCodec?: DailyReportIdCodec;
1619
- readAttachment?: DailyReportReadAttachment;
1620
- attachmentMaxBytes?: number;
1621
1617
  attachmentRateLimitPerMinute?: number;
1622
1618
  attachmentConcurrency?: number;
1619
+ attachmentThumbnailRateLimitPerMinute?: number;
1620
+ attachmentThumbnailConcurrency?: number;
1621
+ attachmentThumbnailCacheBytes?: number;
1623
1622
  redis?: DailyReportRedisProvider;
1624
1623
  sseReader: DailyReportSseReader;
1625
1624
  streamKey: string;
@@ -1647,17 +1646,105 @@ declare function createDailyReportHandlers(config: DailyReportHandlersConfig): {
1647
1646
  loader: ({ request, params }: LoaderArgs) => Promise<Response>;
1648
1647
  };
1649
1648
  attachment: {
1650
- loader: ({ request, params }: LoaderArgs) => Promise<Response>;
1649
+ loader: (args: AttachmentLoaderArgs) => Promise<Response>;
1651
1650
  };
1652
1651
  };
1652
+ type AttachmentLoaderArgs = {
1653
+ request: Request;
1654
+ params: Record<string, string | undefined>;
1655
+ };
1656
+ declare const generateETag: (data: unknown) => string;
1653
1657
  declare const jsonResponseWithETag: (request: Request, cookie: string | null, payload: Record<string, unknown>, status?: number, logger?: DailyReportLogger) => Response;
1658
+ type SharpHeaderLike = {
1659
+ width: number;
1660
+ height: number;
1661
+ channels: number;
1662
+ depth: string;
1663
+ };
1664
+ type SharpPipelineLike = {
1665
+ metadata: () => Promise<SharpHeaderLike>;
1666
+ rotate: () => SharpPipelineLike;
1667
+ resize: (options: {
1668
+ width: number;
1669
+ height: number;
1670
+ fit: "inside";
1671
+ withoutEnlargement: boolean;
1672
+ }) => SharpPipelineLike;
1673
+ flatten: (options: {
1674
+ background: string;
1675
+ }) => SharpPipelineLike;
1676
+ webp: (options: {
1677
+ quality: number;
1678
+ effort: number;
1679
+ }) => SharpPipelineLike;
1680
+ toBuffer: () => Promise<Uint8Array>;
1681
+ };
1682
+ type SharpLike = {
1683
+ (input: Uint8Array, options: {
1684
+ limitInputPixels: number;
1685
+ animated: boolean;
1686
+ }): SharpPipelineLike;
1687
+ readonly versions: {
1688
+ readonly sharp: string;
1689
+ readonly vips: string;
1690
+ };
1691
+ cache: (enabled: boolean) => unknown;
1692
+ concurrency: (threads: number) => number;
1693
+ block: (options: {
1694
+ operation: string[];
1695
+ }) => void;
1696
+ unblock: (options: {
1697
+ operation: string[];
1698
+ }) => void;
1699
+ };
1700
+ declare const DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES = 200000000;
1701
+ declare const DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL: Readonly<{
1702
+ fixedBytes: number;
1703
+ pipelineRows: 2048;
1704
+ wholeImageBuffer: Readonly<{
1705
+ "jpeg-single-scan": Readonly<{
1706
+ kind: "none";
1707
+ }>;
1708
+ "jpeg-multi-scan": Readonly<{
1709
+ kind: "jpeg-coefficients";
1710
+ }>;
1711
+ png: Readonly<{
1712
+ kind: "none";
1713
+ }>;
1714
+ "png-interlaced": Readonly<{
1715
+ kind: "decoded-raster";
1716
+ }>;
1717
+ gif: Readonly<{
1718
+ kind: "canvas";
1719
+ bytesPerPixel: 4;
1720
+ }>;
1721
+ "webp-lossy": Readonly<{
1722
+ kind: "none";
1723
+ }>;
1724
+ "webp-lossy-alpha": Readonly<{
1725
+ kind: "canvas";
1726
+ bytesPerPixel: 5;
1727
+ }>;
1728
+ "webp-lossless": Readonly<{
1729
+ kind: "canvas";
1730
+ bytesPerPixel: 4;
1731
+ }>;
1732
+ "webp-animated": Readonly<{
1733
+ kind: "canvas";
1734
+ bytesPerPixel: 9;
1735
+ }>;
1736
+ }>;
1737
+ }>;
1738
+ declare const predictSharpThumbnailWorkingSetBytes: (source: Uint8Array, format: DailyReportAttachmentThumbnailSourceFormat, header: SharpHeaderLike) => number | null;
1739
+ declare const createSharpThumbnailRenderer: (sharp: SharpLike) => DailyReportAttachmentThumbnailRenderer;
1654
1740
  type DailyReportServerConfig = Omit<DailyReportServiceConfig, "cache" | "epochs"> & {
1655
1741
  authenticate: DailyReportAuthenticate;
1656
1742
  resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
1657
- readAttachment?: DailyReportReadAttachment;
1658
- attachmentMaxBytes?: number;
1659
1743
  attachmentRateLimitPerMinute?: number;
1660
1744
  attachmentConcurrency?: number;
1745
+ attachmentThumbnailRateLimitPerMinute?: number;
1746
+ attachmentThumbnailConcurrency?: number;
1747
+ attachmentThumbnailCacheBytes?: number;
1661
1748
  loginRedirectPath?: string;
1662
1749
  enableDevCacheClear?: boolean;
1663
1750
  cacheDefaultTtlMs?: number;
@@ -1695,14 +1782,12 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1695
1782
  }) => Promise<Response>;
1696
1783
  };
1697
1784
  attachment: {
1698
- loader: ({ request, params }: {
1699
- request: Request;
1700
- params: Record<string, string | undefined>;
1701
- }) => Promise<Response>;
1785
+ loader: (args: AttachmentLoaderArgs) => Promise<Response>;
1702
1786
  };
1703
1787
  service: {
1704
1788
  streamKey: string;
1705
1789
  streamMaxLen: number;
1790
+ attachmentDelivery: DailyReportAttachmentDelivery;
1706
1791
  clearCache: () => Promise<void>;
1707
1792
  invalidateHubReadCaches: (hubIds: readonly number[], businessDates: readonly string[]) => Promise<void>;
1708
1793
  getUserIdByExternalId: (externalId: string) => Promise<number | null>;
@@ -1750,4 +1835,4 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1750
1835
  streamKey: string;
1751
1836
  knownSourceTypes: readonly string[];
1752
1837
  };
1753
- export { type AuthzResourceItem, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentBytes, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentTable, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportCommentRow, type DailyReportCommentTable, type DailyReportDb, type DailyReportEncodeUserId, type DailyReportExternalSource, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubRow, type DailyReportHubTable, type DailyReportIdCodec, type DailyReportIdsSource, type DailyReportInternalRow, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportReadAttachment, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type DailyReportResolveUserId, type DailyReportResolveVisibleSourceTypes, type DailyReportServerConfig, type DailyReportService, type DailyReportServiceConfig, type DailyReportSourceTypeInput, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, DailyReportViewerScope, type DailyReportVisibilityDimensions, type DailyReportVisibilityResolveContext, type DailyReportVisibilityResolveReason, type DailyReportVisibleSourceTypes, type EpochStore, type ExternalReportFields, type RedisStreamMessage, SqlResultCache, type SqlResultCacheQueryOptions, type StreamEntry, type VisibleSourceTypeSet, asciiFallbackFileName, buildVisibleSourceTypeCondition, computeSourceTypeDigest, computeViewerScopeDigest, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, defineDailyReportAuthzResources, defineDailyReportSchema, deniesEverySourceType, encodeRfc8187, formatDateValue, generateETag, isSourceTypeVisible, isStreamIdLte, jsonResponseWithETag, normalizeVisibleSourceTypes, sanitizeMediaType, seedDailyReportAuthzResources, transformJsonArray };
1838
+ export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES, DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES, DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentThumbnail, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportDb, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, predictSharpThumbnailWorkingSetBytes, transformJsonArray };