@aiquants/daily-report 0.22.1 → 0.24.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>;
@@ -1567,59 +1590,37 @@ type DailyReportSseReaderConfig = {
1567
1590
  };
1568
1591
  declare class DailyReportSseReader {
1569
1592
  private readonly config;
1570
- private _emitter;
1571
- private _state;
1572
- private _refCount;
1593
+ private _source;
1573
1594
  private _lastId;
1574
- private _client;
1595
+ private _positioning;
1596
+ private _generation;
1575
1597
  private readonly _logger;
1576
1598
  constructor(config: DailyReportSseReaderConfig);
1577
- subscribe(onEntry: (entry: StreamEntry) => void, onError?: (err: Error) => void): () => void;
1599
+ ready(): Promise<void>;
1600
+ subscribe(onEntry: (entry: StreamEntry) => void, onError: (err: Error) => void): () => void;
1578
1601
  destroy(): Promise<void>;
1579
- private _startLoop;
1580
- private _stopLoop;
1581
- private _emitError;
1602
+ private _readTail;
1603
+ private _createSource;
1604
+ private _start;
1605
+ private _readLoop;
1606
+ private _invalidateCaches;
1582
1607
  }
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
1608
  type LoaderArgs = {
1605
1609
  request: Request;
1606
1610
  params: Record<string, string | undefined>;
1607
1611
  };
1608
1612
  declare const DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS = 60000;
1609
1613
  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
1614
  type DailyReportHandlersConfig = {
1614
1615
  authenticate: DailyReportAuthenticate;
1615
1616
  resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
1616
1617
  service: DailyReportService;
1617
1618
  encodeUserId: DailyReportEncodeUserId;
1618
- attachmentIdCodec?: DailyReportIdCodec;
1619
- readAttachment?: DailyReportReadAttachment;
1620
- attachmentMaxBytes?: number;
1621
1619
  attachmentRateLimitPerMinute?: number;
1622
1620
  attachmentConcurrency?: number;
1621
+ attachmentThumbnailRateLimitPerMinute?: number;
1622
+ attachmentThumbnailConcurrency?: number;
1623
+ attachmentThumbnailCacheBytes?: number;
1623
1624
  redis?: DailyReportRedisProvider;
1624
1625
  sseReader: DailyReportSseReader;
1625
1626
  streamKey: string;
@@ -1647,17 +1648,105 @@ declare function createDailyReportHandlers(config: DailyReportHandlersConfig): {
1647
1648
  loader: ({ request, params }: LoaderArgs) => Promise<Response>;
1648
1649
  };
1649
1650
  attachment: {
1650
- loader: ({ request, params }: LoaderArgs) => Promise<Response>;
1651
+ loader: (args: AttachmentLoaderArgs) => Promise<Response>;
1651
1652
  };
1652
1653
  };
1654
+ type AttachmentLoaderArgs = {
1655
+ request: Request;
1656
+ params: Record<string, string | undefined>;
1657
+ };
1658
+ declare const generateETag: (data: unknown) => string;
1653
1659
  declare const jsonResponseWithETag: (request: Request, cookie: string | null, payload: Record<string, unknown>, status?: number, logger?: DailyReportLogger) => Response;
1660
+ type SharpHeaderLike = {
1661
+ width: number;
1662
+ height: number;
1663
+ channels: number;
1664
+ depth: string;
1665
+ };
1666
+ type SharpPipelineLike = {
1667
+ metadata: () => Promise<SharpHeaderLike>;
1668
+ rotate: () => SharpPipelineLike;
1669
+ resize: (options: {
1670
+ width: number;
1671
+ height: number;
1672
+ fit: "inside";
1673
+ withoutEnlargement: boolean;
1674
+ }) => SharpPipelineLike;
1675
+ flatten: (options: {
1676
+ background: string;
1677
+ }) => SharpPipelineLike;
1678
+ webp: (options: {
1679
+ quality: number;
1680
+ effort: number;
1681
+ }) => SharpPipelineLike;
1682
+ toBuffer: () => Promise<Uint8Array>;
1683
+ };
1684
+ type SharpLike = {
1685
+ (input: Uint8Array, options: {
1686
+ limitInputPixels: number;
1687
+ animated: boolean;
1688
+ }): SharpPipelineLike;
1689
+ readonly versions: {
1690
+ readonly sharp: string;
1691
+ readonly vips: string;
1692
+ };
1693
+ cache: (enabled: boolean) => unknown;
1694
+ concurrency: (threads: number) => number;
1695
+ block: (options: {
1696
+ operation: string[];
1697
+ }) => void;
1698
+ unblock: (options: {
1699
+ operation: string[];
1700
+ }) => void;
1701
+ };
1702
+ declare const DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES = 200000000;
1703
+ declare const DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL: Readonly<{
1704
+ fixedBytes: number;
1705
+ pipelineRows: 2048;
1706
+ wholeImageBuffer: Readonly<{
1707
+ "jpeg-single-scan": Readonly<{
1708
+ kind: "none";
1709
+ }>;
1710
+ "jpeg-multi-scan": Readonly<{
1711
+ kind: "jpeg-coefficients";
1712
+ }>;
1713
+ png: Readonly<{
1714
+ kind: "none";
1715
+ }>;
1716
+ "png-interlaced": Readonly<{
1717
+ kind: "decoded-raster";
1718
+ }>;
1719
+ gif: Readonly<{
1720
+ kind: "canvas";
1721
+ bytesPerPixel: 4;
1722
+ }>;
1723
+ "webp-lossy": Readonly<{
1724
+ kind: "none";
1725
+ }>;
1726
+ "webp-lossy-alpha": Readonly<{
1727
+ kind: "canvas";
1728
+ bytesPerPixel: 5;
1729
+ }>;
1730
+ "webp-lossless": Readonly<{
1731
+ kind: "canvas";
1732
+ bytesPerPixel: 4;
1733
+ }>;
1734
+ "webp-animated": Readonly<{
1735
+ kind: "canvas";
1736
+ bytesPerPixel: 9;
1737
+ }>;
1738
+ }>;
1739
+ }>;
1740
+ declare const predictSharpThumbnailWorkingSetBytes: (source: Uint8Array, format: DailyReportAttachmentThumbnailSourceFormat, header: SharpHeaderLike) => number | null;
1741
+ declare const createSharpThumbnailRenderer: (sharp: SharpLike) => DailyReportAttachmentThumbnailRenderer;
1654
1742
  type DailyReportServerConfig = Omit<DailyReportServiceConfig, "cache" | "epochs"> & {
1655
1743
  authenticate: DailyReportAuthenticate;
1656
1744
  resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
1657
- readAttachment?: DailyReportReadAttachment;
1658
- attachmentMaxBytes?: number;
1659
1745
  attachmentRateLimitPerMinute?: number;
1660
1746
  attachmentConcurrency?: number;
1747
+ attachmentThumbnailRateLimitPerMinute?: number;
1748
+ attachmentThumbnailConcurrency?: number;
1749
+ attachmentThumbnailCacheBytes?: number;
1661
1750
  loginRedirectPath?: string;
1662
1751
  enableDevCacheClear?: boolean;
1663
1752
  cacheDefaultTtlMs?: number;
@@ -1695,14 +1784,12 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1695
1784
  }) => Promise<Response>;
1696
1785
  };
1697
1786
  attachment: {
1698
- loader: ({ request, params }: {
1699
- request: Request;
1700
- params: Record<string, string | undefined>;
1701
- }) => Promise<Response>;
1787
+ loader: (args: AttachmentLoaderArgs) => Promise<Response>;
1702
1788
  };
1703
1789
  service: {
1704
1790
  streamKey: string;
1705
1791
  streamMaxLen: number;
1792
+ attachmentDelivery: DailyReportAttachmentDelivery;
1706
1793
  clearCache: () => Promise<void>;
1707
1794
  invalidateHubReadCaches: (hubIds: readonly number[], businessDates: readonly string[]) => Promise<void>;
1708
1795
  getUserIdByExternalId: (externalId: string) => Promise<number | null>;
@@ -1750,4 +1837,4 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1750
1837
  streamKey: string;
1751
1838
  knownSourceTypes: readonly string[];
1752
1839
  };
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 };
1840
+ 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 };