@aiquants/daily-report 0.32.0 → 0.33.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.
@@ -0,0 +1,32 @@
1
+ import { i as DailyReportExternalComment, l as DailyReportPostedComment, D as DailyReportItem } from "./sse-schema-DcOgQr_O.js";
2
+ type UIComment = {
3
+ id: string | number;
4
+ authorName: string;
5
+ content: string;
6
+ createdAt?: string;
7
+ isMine: boolean;
8
+ color?: string;
9
+ isLegacy: boolean;
10
+ };
11
+ declare const mergeComments: (legacyComments: DailyReportExternalComment[], modernComments: DailyReportPostedComment[], currentUserId: string | null | undefined, unknownAuthorName: string) => UIComment[];
12
+ type DailyReportIdsStreamCursor = {
13
+ businessDate: string | null;
14
+ reportHubId: number;
15
+ };
16
+ type DailyReportIdsStreamChunkLine = {
17
+ kind: "chunk";
18
+ items: DailyReportItem[];
19
+ nextCursor: DailyReportIdsStreamCursor | null;
20
+ isLast: boolean;
21
+ total?: number;
22
+ provisional?: boolean;
23
+ snapshot?: string;
24
+ restarted?: boolean;
25
+ streamAnchor?: string | null;
26
+ };
27
+ type DailyReportSseStreamAnchor = {
28
+ readonly lastEventId: string | null;
29
+ readonly revision: number;
30
+ };
31
+ declare const isIdsStreamChunkLine: (line: unknown) => line is DailyReportIdsStreamChunkLine;
32
+ export { type DailyReportSseStreamAnchor as D, type UIComment as U, type DailyReportIdsStreamChunkLine as a, isIdsStreamChunkLine as i, mergeComments as m };
@@ -0,0 +1,32 @@
1
+ import { i as DailyReportExternalComment, l as DailyReportPostedComment, D as DailyReportItem } from "./sse-schema-DcOgQr_O.mjs";
2
+ type UIComment = {
3
+ id: string | number;
4
+ authorName: string;
5
+ content: string;
6
+ createdAt?: string;
7
+ isMine: boolean;
8
+ color?: string;
9
+ isLegacy: boolean;
10
+ };
11
+ declare const mergeComments: (legacyComments: DailyReportExternalComment[], modernComments: DailyReportPostedComment[], currentUserId: string | null | undefined, unknownAuthorName: string) => UIComment[];
12
+ type DailyReportIdsStreamCursor = {
13
+ businessDate: string | null;
14
+ reportHubId: number;
15
+ };
16
+ type DailyReportIdsStreamChunkLine = {
17
+ kind: "chunk";
18
+ items: DailyReportItem[];
19
+ nextCursor: DailyReportIdsStreamCursor | null;
20
+ isLast: boolean;
21
+ total?: number;
22
+ provisional?: boolean;
23
+ snapshot?: string;
24
+ restarted?: boolean;
25
+ streamAnchor?: string | null;
26
+ };
27
+ type DailyReportSseStreamAnchor = {
28
+ readonly lastEventId: string | null;
29
+ readonly revision: number;
30
+ };
31
+ declare const isIdsStreamChunkLine: (line: unknown) => line is DailyReportIdsStreamChunkLine;
32
+ export { type DailyReportSseStreamAnchor as D, type UIComment as U, type DailyReportIdsStreamChunkLine as a, isIdsStreamChunkLine as i, mergeComments as m };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
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";
1
+ export { a as DailyReportIdsStreamChunkLine, D as DailyReportSseStreamAnchor, i as isIdsStreamChunkLine, m as mergeComments } from "./ids-stream-CyK2upgD.mjs";
2
+ export { e as DAILY_REPORT_SSE_CURSOR_PARAM, f as DAILY_REPORT_SSE_HEARTBEAT_MS, g as DAILY_REPORT_SSE_TERMINAL_EVENTS, h as DailyReportAttachmentSummary, d as DailyReportDetail, i as DailyReportExternalComment, j as DailyReportInterviewer, D as DailyReportItem, k as DailyReportLabelDef, l as DailyReportPostedComment, c as DailyReportSseMessage, a as DailyReportUser, m as commentAddMessageSchema, n as commentDeleteMessageSchema, o as connectedMessageSchema, p as dailyReportDetailSchema, q as dailyReportExternalCommentSchema, r as dailyReportInterviewerSchema, s as dailyReportLabelDefSchema, t as dailyReportPostedCommentSchema, u as dailyReportSseMessageSchema, v as isDailyReportSseStreamId, w as reportCreateMessageSchema, x as reportDeleteMessageSchema, y as reportPublishMessageSchema, z as reportUpdateMessageSchema, A as statusUpdateMessageSchema } from "./sse-schema-DcOgQr_O.mjs";
3
3
  import "zod";
4
4
  type DailyReportAttachmentThumbnailBox = {
5
5
  readonly maxWidth: number;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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";
1
+ export { a as DailyReportIdsStreamChunkLine, D as DailyReportSseStreamAnchor, i as isIdsStreamChunkLine, m as mergeComments } from "./ids-stream-CtlszCHr.js";
2
+ export { e as DAILY_REPORT_SSE_CURSOR_PARAM, f as DAILY_REPORT_SSE_HEARTBEAT_MS, g as DAILY_REPORT_SSE_TERMINAL_EVENTS, h as DailyReportAttachmentSummary, d as DailyReportDetail, i as DailyReportExternalComment, j as DailyReportInterviewer, D as DailyReportItem, k as DailyReportLabelDef, l as DailyReportPostedComment, c as DailyReportSseMessage, a as DailyReportUser, m as commentAddMessageSchema, n as commentDeleteMessageSchema, o as connectedMessageSchema, p as dailyReportDetailSchema, q as dailyReportExternalCommentSchema, r as dailyReportInterviewerSchema, s as dailyReportLabelDefSchema, t as dailyReportPostedCommentSchema, u as dailyReportSseMessageSchema, v as isDailyReportSseStreamId, w as reportCreateMessageSchema, x as reportDeleteMessageSchema, y as reportPublishMessageSchema, z as reportUpdateMessageSchema, A as statusUpdateMessageSchema } from "./sse-schema-DcOgQr_O.js";
3
3
  import "zod";
4
4
  type DailyReportAttachmentThumbnailBox = {
5
5
  readonly maxWidth: number;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var d=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var F=(t,r)=>{for(var n in r)d(t,n,{get:r[n],enumerable:!0})},K=(t,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of Y(r))!z.call(t,i)&&i!==n&&d(t,i,{get:()=>r[i],enumerable:!(o=V(r,i))||o.enumerable});return t};var q=t=>K(d({},"__esModule",{value:!0}),t);var te={};F(te,{DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS:()=>y,DAILY_REPORT_SSE_CURSOR_PARAM:()=>H,DAILY_REPORT_SSE_HEARTBEAT_MS:()=>B,DAILY_REPORT_SSE_TERMINAL_EVENTS:()=>$,buildDailyReportAttachmentUrl:()=>k,commentAddMessageSchema:()=>f,commentDeleteMessageSchema:()=>S,connectedMessageSchema:()=>D,dailyReportDetailSchema:()=>l,dailyReportExternalCommentSchema:()=>g,dailyReportInterviewerSchema:()=>h,dailyReportLabelDefSchema:()=>R,dailyReportPostedCommentSchema:()=>c,dailyReportSseMessageSchema:()=>v,isDailyReportAttachmentThumbnailVariant:()=>p,isDailyReportSseStreamId:()=>j,isIdsStreamChunkLine:()=>O,mergeComments:()=>P,normalizeBusinessDateKey:()=>w,parseDailyReportAttachmentQuery:()=>N,reportCreateMessageSchema:()=>I,reportDeleteMessageSchema:()=>_,reportPublishMessageSchema:()=>T,reportUpdateMessageSchema:()=>A,statusUpdateMessageSchema:()=>b});module.exports=q(te);var y=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),p=t=>Object.hasOwn(y,t);var E="download",C="thumbnail",M="1",k=(t,r,n)=>{let o=`${t}/attachment/${encodeURIComponent(r)}`;switch(n.kind){case"inline":return o;case"download":return`${o}?${new URLSearchParams({[E]:M})}`;case"thumbnail":return`${o}?${new URLSearchParams({[C]:n.variant})}`}},N=t=>{let r=t.getAll(C),n=t.getAll(E);if(r.length>0&&n.length>0)return{kind:"invalid",reason:"conflict"};if(r.length>0){let[o]=r;return r.length===1&&p(o)?{kind:"thumbnail",variant:o}:{kind:"invalid",reason:"thumbnail_variant"}}return n.length>0?n.length===1&&n[0]===M?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var Q=/^(\d{4})([-/])(\d{2})\2(\d{2})$/;var L=t=>t<10?`0${t}`:`${t}`,W=t=>{if(Number.isNaN(t.getTime()))return null;let r=t.getFullYear(),n=L(t.getMonth()+1),o=L(t.getDate());return`${r}-${n}-${o}`},J=t=>{let r=Q.exec(t);if(r===null)return null;let[,n,,o,i]=r,s=Number(n),a=Number(o),m=Number(i);if(s<1)return null;let u=new Date(0);return u.setUTCFullYear(s,a-1,m),u.getUTCFullYear()!==s||u.getUTCMonth()!==a-1||u.getUTCDate()!==m?null:`${n}-${o}-${i}`};var w=t=>t==null?null:t instanceof Date?W(t):J(t);var G=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,U=(t,r,n)=>new RangeError(`[daily-report] ${t} must be ${r}; got ${G(n)}`);var P=(t,r,n,o)=>{if(typeof o!="string"||o.trim()==="")throw U("mergeComments: unknownAuthorName","a non-blank string",o);let i=t.map((a,m)=>({id:`legacy-${m}`,authorName:a.name||o,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),s=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,...s]};var X=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"},O=t=>X(t)==="chunk";var e=require("zod"),$=["auth-required","forbidden","resync-required"],B=15e3,H="lastEventId",Z=/^\d{1,15}-\d{1,15}$/,j=t=>Z.test(t),h=e.z.object({name:e.z.string().nullish(),affiliation:e.z.string().nullish()}),g=e.z.object({name:e.z.string().nullish(),text:e.z.string().nullish(),color:e.z.string().nullish()}),R=e.z.object({id:e.z.number(),name:e.z.string().nullish(),color:e.z.string().nullish()}),c=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()}),ee=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)}),l=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(h),subject:e.z.string().nullish(),content:e.z.string().nullish(),externalComments:e.z.array(g),isRead:e.z.boolean(),isStarred:e.z.boolean(),labels:e.z.array(R),postedComments:e.z.array(c),attachments:e.z.array(ee).default([])}),D=e.z.object({type:e.z.literal("connected")}),b=e.z.object({type:e.z.literal("status-update"),reportHubId:e.z.number(),statusType:e.z.enum(["star","read"]),value:e.z.boolean(),clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),x=e.z.string().optional(),f=e.z.object({type:e.z.literal("comment-add"),reportHubId:e.z.number(),comment:c,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional(),sourceType:x}),S=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:x}),I=e.z.object({type:e.z.literal("report-create"),reportHubId:e.z.number(),report:l,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),A=e.z.object({type:e.z.literal("report-update"),reportHubId:e.z.number(),report:l,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),T=e.z.object({type:e.z.literal("report-publish"),reportHubId:e.z.number(),report:l,clientTempId:e.z.string(),recipientRawUserId:e.z.number().optional()}),_=e.z.object({type:e.z.literal("report-delete"),reportHubId:e.z.number(),clientTempId:e.z.string(),sourceType:x}),v=e.z.discriminatedUnion("type",[D,b,f,S,I,A,T,_]);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});
1
+ "use strict";var y=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var q=(t,r)=>{for(var n in r)y(t,n,{get:r[n],enumerable:!0})},Q=(t,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of F(r))!K.call(t,i)&&i!==n&&y(t,i,{get:()=>r[i],enumerable:!(o=z(r,i))||o.enumerable});return t};var W=t=>Q(y({},"__esModule",{value:!0}),t);var ne={};q(ne,{DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS:()=>h,DAILY_REPORT_SSE_CURSOR_PARAM:()=>Y,DAILY_REPORT_SSE_HEARTBEAT_MS:()=>j,DAILY_REPORT_SSE_TERMINAL_EVENTS:()=>H,buildDailyReportAttachmentUrl:()=>N,commentAddMessageSchema:()=>S,commentDeleteMessageSchema:()=>I,connectedMessageSchema:()=>f,dailyReportDetailSchema:()=>m,dailyReportExternalCommentSchema:()=>R,dailyReportInterviewerSchema:()=>g,dailyReportLabelDefSchema:()=>D,dailyReportPostedCommentSchema:()=>d,dailyReportSseMessageSchema:()=>V,isDailyReportAttachmentThumbnailVariant:()=>c,isDailyReportSseStreamId:()=>v,isIdsStreamChunkLine:()=>$,mergeComments:()=>O,normalizeBusinessDateKey:()=>P,parseDailyReportAttachmentQuery:()=>L,reportCreateMessageSchema:()=>T,reportDeleteMessageSchema:()=>E,reportPublishMessageSchema:()=>_,reportUpdateMessageSchema:()=>A,statusUpdateMessageSchema:()=>b});module.exports=W(ne);var h=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),c=t=>Object.hasOwn(h,t);var C="download",M="thumbnail",k="1",N=(t,r,n)=>{let o=`${t}/attachment/${encodeURIComponent(r)}`;switch(n.kind){case"inline":return o;case"download":return`${o}?${new URLSearchParams({[C]:k})}`;case"thumbnail":return`${o}?${new URLSearchParams({[M]:n.variant})}`}},L=t=>{let r=t.getAll(M),n=t.getAll(C);if(r.length>0&&n.length>0)return{kind:"invalid",reason:"conflict"};if(r.length>0){let[o]=r;return r.length===1&&c(o)?{kind:"thumbnail",variant:o}:{kind:"invalid",reason:"thumbnail_variant"}}return n.length>0?n.length===1&&n[0]===k?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var J=/^(\d{4})([-/])(\d{2})\2(\d{2})$/;var w=t=>t<10?`0${t}`:`${t}`,G=t=>{if(Number.isNaN(t.getTime()))return null;let r=t.getFullYear(),n=w(t.getMonth()+1),o=w(t.getDate());return`${r}-${n}-${o}`},X=t=>{let r=J.exec(t);if(r===null)return null;let[,n,,o,i]=r,l=Number(n),a=Number(o),u=Number(i);if(l<1)return null;let p=new Date(0);return p.setUTCFullYear(l,a-1,u),p.getUTCFullYear()!==l||p.getUTCMonth()!==a-1||p.getUTCDate()!==u?null:`${n}-${o}-${i}`};var P=t=>t==null?null:t instanceof Date?G(t):X(t);var Z=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,U=(t,r,n)=>new RangeError(`[daily-report] ${t} must be ${r}; got ${Z(n)}`);var O=(t,r,n,o)=>{if(typeof o!="string"||o.trim()==="")throw U("mergeComments: unknownAuthorName","a non-blank string",o);let i=t.map((a,u)=>({id:`legacy-${u}`,authorName:a.name||o,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),l=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,...l]};var ee=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"},$=t=>ee(t)==="chunk";var e=require("zod");var B=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|-[1-9][0-9]{0,15})$/;var H=["auth-required","forbidden","resync-required"],j=15e3,Y="lastEventId",te=/^\d{1,15}-\d{1,15}$/,v=t=>te.test(t),g=e.z.object({name:e.z.string().nullish(),affiliation:e.z.string().nullish()}),R=e.z.object({name:e.z.string().nullish(),text:e.z.string().nullish(),color:e.z.string().nullish()}),D=e.z.object({id:e.z.number(),name:e.z.string().nullish(),color:e.z.string().nullish()}),d=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()}),re=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)}),m=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(g),subject:e.z.string().nullish(),content:e.z.string().nullish(),externalComments:e.z.array(R),isRead:e.z.boolean(),isStarred:e.z.boolean(),labels:e.z.array(D),postedComments:e.z.array(d),attachments:e.z.array(re).default([])}),s=e.z.string().regex(B),f=e.z.object({type:e.z.literal("connected")}),b=e.z.object({type:e.z.literal("status-update"),reportHubId:e.z.number(),statusType:e.z.enum(["star","read"]),value:e.z.boolean(),clientTempId:s,recipientRawUserId:e.z.number().optional()}),x=e.z.string().optional(),S=e.z.object({type:e.z.literal("comment-add"),reportHubId:e.z.number(),comment:d,clientTempId:s,recipientRawUserId:e.z.number().optional(),sourceType:x}),I=e.z.object({type:e.z.literal("comment-delete"),reportHubId:e.z.number(),commentId:e.z.number(),clientTempId:s,recipientRawUserId:e.z.number().optional(),sourceType:x}),T=e.z.object({type:e.z.literal("report-create"),reportHubId:e.z.number(),report:m,clientTempId:s,recipientRawUserId:e.z.number().optional()}),A=e.z.object({type:e.z.literal("report-update"),reportHubId:e.z.number(),report:m,clientTempId:s,recipientRawUserId:e.z.number().optional()}),_=e.z.object({type:e.z.literal("report-publish"),reportHubId:e.z.number(),report:m,clientTempId:s,recipientRawUserId:e.z.number().optional()}),E=e.z.object({type:e.z.literal("report-delete"),reportHubId:e.z.number(),clientTempId:s,sourceType:x}),V=e.z.discriminatedUnion("type",[f,b,S,I,T,A,_,E]);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 y=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),p=t=>Object.hasOwn(y,t);var h="download",g="thumbnail",R="1",N=(t,r,n)=>{let o=`${t}/attachment/${encodeURIComponent(r)}`;switch(n.kind){case"inline":return o;case"download":return`${o}?${new URLSearchParams({[h]:R})}`;case"thumbnail":return`${o}?${new URLSearchParams({[g]:n.variant})}`}},L=t=>{let r=t.getAll(g),n=t.getAll(h);if(r.length>0&&n.length>0)return{kind:"invalid",reason:"conflict"};if(r.length>0){let[o]=r;return r.length===1&&p(o)?{kind:"thumbnail",variant:o}:{kind:"invalid",reason:"thumbnail_variant"}}return n.length>0?n.length===1&&n[0]===R?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var w=/^(\d{4})([-/])(\d{2})\2(\d{2})$/;var D=t=>t<10?`0${t}`:`${t}`,U=t=>{if(Number.isNaN(t.getTime()))return null;let r=t.getFullYear(),n=D(t.getMonth()+1),o=D(t.getDate());return`${r}-${n}-${o}`},P=t=>{let r=w.exec(t);if(r===null)return null;let[,n,,o,s]=r,i=Number(n),a=Number(o),l=Number(s);if(i<1)return null;let m=new Date(0);return m.setUTCFullYear(i,a-1,l),m.getUTCFullYear()!==i||m.getUTCMonth()!==a-1||m.getUTCDate()!==l?null:`${n}-${o}-${s}`};var O=t=>t==null?null:t instanceof Date?U(t):P(t);var $=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,b=(t,r,n)=>new RangeError(`[daily-report] ${t} must be ${r}; got ${$(n)}`);var B=(t,r,n,o)=>{if(typeof o!="string"||o.trim()==="")throw b("mergeComments: unknownAuthorName","a non-blank string",o);let s=t.map((a,l)=>({id:`legacy-${l}`,authorName:a.name||o,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),i=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[...s,...i]};var H=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=>H(t)==="chunk";import{z as e}from"zod";var v=["auth-required","forbidden","resync-required"],V=15e3,Y="lastEventId",z=/^\d{1,15}-\d{1,15}$/,F=t=>z.test(t),x=e.object({name:e.string().nullish(),affiliation:e.string().nullish()}),f=e.object({name:e.string().nullish(),text:e.string().nullish(),color:e.string().nullish()}),S=e.object({id:e.number(),name:e.string().nullish(),color:e.string().nullish()}),c=e.object({id:e.number(),userId:e.string().nullish(),userName:e.string().nullish(),content:e.string().nullish(),createdAt:e.string().nullish(),isMine:e.boolean()}),K=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)}),u=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(x),subject:e.string().nullish(),content:e.string().nullish(),externalComments:e.array(f),isRead:e.boolean(),isStarred:e.boolean(),labels:e.array(S),postedComments:e.array(c),attachments:e.array(K).default([])}),I=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(),T=e.object({type:e.literal("comment-add"),reportHubId:e.number(),comment:c,clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:d}),_=e.object({type:e.literal("comment-delete"),reportHubId:e.number(),commentId:e.number(),clientTempId:e.string(),recipientRawUserId:e.number().optional(),sourceType:d}),E=e.object({type:e.literal("report-create"),reportHubId:e.number(),report:u,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),C=e.object({type:e.literal("report-update"),reportHubId:e.number(),report:u,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),M=e.object({type:e.literal("report-publish"),reportHubId:e.number(),report:u,clientTempId:e.string(),recipientRawUserId:e.number().optional()}),k=e.object({type:e.literal("report-delete"),reportHubId:e.number(),clientTempId:e.string(),sourceType:d}),q=e.discriminatedUnion("type",[I,A,T,_,E,C,M,k]);export{y as DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS,Y as DAILY_REPORT_SSE_CURSOR_PARAM,V as DAILY_REPORT_SSE_HEARTBEAT_MS,v as DAILY_REPORT_SSE_TERMINAL_EVENTS,N as buildDailyReportAttachmentUrl,T as commentAddMessageSchema,_ as commentDeleteMessageSchema,I as connectedMessageSchema,u as dailyReportDetailSchema,f as dailyReportExternalCommentSchema,x as dailyReportInterviewerSchema,S as dailyReportLabelDefSchema,c as dailyReportPostedCommentSchema,q as dailyReportSseMessageSchema,p as isDailyReportAttachmentThumbnailVariant,F as isDailyReportSseStreamId,j as isIdsStreamChunkLine,B as mergeComments,O as normalizeBusinessDateKey,L as parseDailyReportAttachmentQuery,E as reportCreateMessageSchema,k as reportDeleteMessageSchema,M as reportPublishMessageSchema,C as reportUpdateMessageSchema,A as statusUpdateMessageSchema};
1
+ var h=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),c=t=>Object.hasOwn(h,t);var g="download",R="thumbnail",D="1",w=(t,r,n)=>{let o=`${t}/attachment/${encodeURIComponent(r)}`;switch(n.kind){case"inline":return o;case"download":return`${o}?${new URLSearchParams({[g]:D})}`;case"thumbnail":return`${o}?${new URLSearchParams({[R]:n.variant})}`}},P=t=>{let r=t.getAll(R),n=t.getAll(g);if(r.length>0&&n.length>0)return{kind:"invalid",reason:"conflict"};if(r.length>0){let[o]=r;return r.length===1&&c(o)?{kind:"thumbnail",variant:o}:{kind:"invalid",reason:"thumbnail_variant"}}return n.length>0?n.length===1&&n[0]===D?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var U=/^(\d{4})([-/])(\d{2})\2(\d{2})$/;var f=t=>t<10?`0${t}`:`${t}`,O=t=>{if(Number.isNaN(t.getTime()))return null;let r=t.getFullYear(),n=f(t.getMonth()+1),o=f(t.getDate());return`${r}-${n}-${o}`},$=t=>{let r=U.exec(t);if(r===null)return null;let[,n,,o,l]=r,s=Number(n),a=Number(o),m=Number(l);if(s<1)return null;let u=new Date(0);return u.setUTCFullYear(s,a-1,m),u.getUTCFullYear()!==s||u.getUTCMonth()!==a-1||u.getUTCDate()!==m?null:`${n}-${o}-${l}`};var B=t=>t==null?null:t instanceof Date?O(t):$(t);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,b=(t,r,n)=>new RangeError(`[daily-report] ${t} must be ${r}; got ${H(n)}`);var j=(t,r,n,o)=>{if(typeof o!="string"||o.trim()==="")throw b("mergeComments: unknownAuthorName","a non-blank string",o);let l=t.map((a,m)=>({id:`legacy-${m}`,authorName:a.name||o,content:a.text||"",isMine:!1,color:a.color||void 0,isLegacy:!0})),s=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[...l,...s]};var Y=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"},v=t=>Y(t)==="chunk";import{z as e}from"zod";var x=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|-[1-9][0-9]{0,15})$/;var V=["auth-required","forbidden","resync-required"],z=15e3,F="lastEventId",K=/^\d{1,15}-\d{1,15}$/,q=t=>K.test(t),S=e.object({name:e.string().nullish(),affiliation:e.string().nullish()}),I=e.object({name:e.string().nullish(),text:e.string().nullish(),color:e.string().nullish()}),T=e.object({id:e.number(),name:e.string().nullish(),color:e.string().nullish()}),d=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)}),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(S),subject:e.string().nullish(),content:e.string().nullish(),externalComments:e.array(I),isRead:e.boolean(),isStarred:e.boolean(),labels:e.array(T),postedComments:e.array(d),attachments:e.array(Q).default([])}),i=e.string().regex(x),A=e.object({type:e.literal("connected")}),_=e.object({type:e.literal("status-update"),reportHubId:e.number(),statusType:e.enum(["star","read"]),value:e.boolean(),clientTempId:i,recipientRawUserId:e.number().optional()}),y=e.string().optional(),E=e.object({type:e.literal("comment-add"),reportHubId:e.number(),comment:d,clientTempId:i,recipientRawUserId:e.number().optional(),sourceType:y}),C=e.object({type:e.literal("comment-delete"),reportHubId:e.number(),commentId:e.number(),clientTempId:i,recipientRawUserId:e.number().optional(),sourceType:y}),M=e.object({type:e.literal("report-create"),reportHubId:e.number(),report:p,clientTempId:i,recipientRawUserId:e.number().optional()}),k=e.object({type:e.literal("report-update"),reportHubId:e.number(),report:p,clientTempId:i,recipientRawUserId:e.number().optional()}),N=e.object({type:e.literal("report-publish"),reportHubId:e.number(),report:p,clientTempId:i,recipientRawUserId:e.number().optional()}),L=e.object({type:e.literal("report-delete"),reportHubId:e.number(),clientTempId:i,sourceType:y}),W=e.discriminatedUnion("type",[A,_,E,C,M,k,N,L]);export{h as DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS,F as DAILY_REPORT_SSE_CURSOR_PARAM,z as DAILY_REPORT_SSE_HEARTBEAT_MS,V as DAILY_REPORT_SSE_TERMINAL_EVENTS,w as buildDailyReportAttachmentUrl,E as commentAddMessageSchema,C as commentDeleteMessageSchema,A as connectedMessageSchema,p as dailyReportDetailSchema,I as dailyReportExternalCommentSchema,S as dailyReportInterviewerSchema,T as dailyReportLabelDefSchema,d as dailyReportPostedCommentSchema,W as dailyReportSseMessageSchema,c as isDailyReportAttachmentThumbnailVariant,q as isDailyReportSseStreamId,v as isIdsStreamChunkLine,j as mergeComments,B as normalizeBusinessDateKey,P as parseDailyReportAttachmentQuery,M as reportCreateMessageSchema,L as reportDeleteMessageSchema,N as reportPublishMessageSchema,k as reportUpdateMessageSchema,_ as statusUpdateMessageSchema};
package/dist/server.d.mts CHANGED
@@ -1,7 +1,8 @@
1
+ import { c as DailyReportSseMessage, j as DailyReportInterviewer, i as DailyReportExternalComment, D as DailyReportItem, d as DailyReportDetail, h as DailyReportAttachmentSummary, l as DailyReportPostedComment } from "./sse-schema-DcOgQr_O.mjs";
1
2
  import * as drizzle_orm_mssql_core from "drizzle-orm/mssql-core";
2
3
  import { AnyMsSqlColumn } from "drizzle-orm/mssql-core";
3
- import { e as DailyReportInterviewer, d as DailyReportExternalComment, D as DailyReportItem, b as DailyReportDetail, c as DailyReportAttachmentSummary, g as DailyReportPostedComment } from "./types-DkERw8NE.mjs";
4
4
  import { TransactionRetryOptions } from "@aiquants/mssql";
5
+ import "zod";
5
6
  type RedisStreamMessage = {
6
7
  id: string;
7
8
  message: Record<string, string>;
@@ -36,9 +37,14 @@ type DailyReportRedisProvider = {
36
37
  getClient(): Promise<DailyReportRedisClient | undefined>;
37
38
  createClient(): Promise<DailyReportRedisBlockingClient | undefined>;
38
39
  };
40
+ type DailyReportSseEntryMessage = {
41
+ readonly parsed: DailyReportSseMessage;
42
+ readonly published: Readonly<Record<string, unknown>>;
43
+ readonly text: string;
44
+ };
39
45
  type StreamEntry = {
40
- id: string;
41
- message: Record<string, string>;
46
+ readonly id: string;
47
+ readonly message: DailyReportSseEntryMessage | null;
42
48
  };
43
49
  type DailyReportSseReaderPort = {
44
50
  ready(): Promise<void>;
@@ -1470,6 +1476,11 @@ declare class DailyReportViewerScope {
1470
1476
  static restrictTo(input: readonly string[] | DailyReportVisibilityDimensions): DailyReportViewerScope;
1471
1477
  static unrestricted(auditReason: string): DailyReportViewerScope;
1472
1478
  }
1479
+ declare const CLIENT_TEMP_ID_BRAND: unique symbol;
1480
+ type DailyReportClientTempId = string & {
1481
+ readonly [CLIENT_TEMP_ID_BRAND]: true;
1482
+ };
1483
+ declare const parseClientTempId: (raw: string | null) => DailyReportClientTempId | null;
1473
1484
  type DailyReportHubRow = {
1474
1485
  id: number;
1475
1486
  sourceType: string;
@@ -1599,17 +1610,17 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1599
1610
  } | null>;
1600
1611
  markAttachmentMissing: (attachmentId: number) => Promise<void>;
1601
1612
  markAttachmentPresent: (attachmentId: number) => Promise<void>;
1602
- setStarStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isStarred: boolean, clientTempId: string) => Promise<DailyReportUserStatusRow>;
1603
- setReadStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isRead: boolean, clientTempId: string) => Promise<DailyReportUserStatusRow>;
1604
- addComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, content: string, businessDate: string | null, clientTempId: string) => Promise<DailyReportPostedComment>;
1605
- deleteComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, commentId: number, businessDate: string | null, clientTempId: string) => Promise<void>;
1606
- createDailyReport: (userId: number, businessDate: string, clientTempId: string) => Promise<DailyReportDetail>;
1613
+ setStarStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isStarred: boolean, clientTempId: DailyReportClientTempId) => Promise<DailyReportUserStatusRow>;
1614
+ setReadStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isRead: boolean, clientTempId: DailyReportClientTempId) => Promise<DailyReportUserStatusRow>;
1615
+ addComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, content: string, businessDate: string | null, clientTempId: DailyReportClientTempId) => Promise<DailyReportPostedComment>;
1616
+ deleteComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, commentId: number, businessDate: string | null, clientTempId: DailyReportClientTempId) => Promise<void>;
1617
+ createDailyReport: (userId: number, businessDate: string, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail>;
1607
1618
  updateDailyReport: (reportHubId: number, userId: number, data: {
1608
1619
  title?: string;
1609
1620
  content?: string;
1610
- }, clientTempId: string) => Promise<void>;
1611
- publishDailyReport: (reportHubId: number, userId: number, clientTempId: string) => Promise<DailyReportDetail | null>;
1612
- deleteDailyReport: (reportHubId: number, userId: number, clientTempId: string) => Promise<void>;
1621
+ }, clientTempId: DailyReportClientTempId) => Promise<void>;
1622
+ publishDailyReport: (reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail | null>;
1623
+ deleteDailyReport: (reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<void>;
1613
1624
  findDailyReportHubById: (tx: DailyReportDb, reportHubId: number) => Promise<DailyReportHubRow[]>;
1614
1625
  updateDailyReportHub: (tx: DailyReportDb, reportHubId: number, data: Partial<DailyReportHubRow>) => Promise<void>;
1615
1626
  updateDailyReportInternal: (tx: DailyReportDb, hubId: number, data: Partial<DailyReportInternalRow>) => Promise<void>;
@@ -1771,7 +1782,7 @@ declare const DAILY_REPORT_SHARP_THUMBNAIL_DECODE_WORK_MODEL: Readonly<{
1771
1782
  declare const predictSharpThumbnailWorkingSetBytes: (source: Uint8Array, format: DailyReportAttachmentThumbnailSourceFormat, header: SharpHeaderLike) => number | null;
1772
1783
  declare const createSharpThumbnailRenderer: (sharp: SharpLike) => DailyReportAttachmentThumbnailRenderer;
1773
1784
  declare const DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS = 60000;
1774
- declare const DAILY_REPORT_SSE_CATCH_UP_BATCH = 1000;
1785
+ declare const DAILY_REPORT_SSE_CATCH_UP_BATCH: number;
1775
1786
  type DailyReportServerConfig = Omit<DailyReportServiceConfig, "cache" | "epochs"> & {
1776
1787
  authenticate: DailyReportAuthenticate;
1777
1788
  resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
@@ -1789,4 +1800,4 @@ type DailyReportServer = DailyReportHandlers & {
1789
1800
  knownSourceTypes: readonly string[];
1790
1801
  };
1791
1802
  declare function createDailyReportServer(config: DailyReportServerConfig): DailyReportServer;
1792
- 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_DECODE_WORK_MODEL, 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 DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportDb, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServer, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderPort, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, predictSharpThumbnailWorkingSetBytes, transformJsonArray };
1803
+ 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_DECODE_WORK_MODEL, 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 DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportClientTempId, type DailyReportDb, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServer, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderPort, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, parseClientTempId, predictSharpThumbnailWorkingSetBytes, transformJsonArray };
package/dist/server.d.ts CHANGED
@@ -1,7 +1,8 @@
1
+ import { c as DailyReportSseMessage, j as DailyReportInterviewer, i as DailyReportExternalComment, D as DailyReportItem, d as DailyReportDetail, h as DailyReportAttachmentSummary, l as DailyReportPostedComment } from "./sse-schema-DcOgQr_O.js";
1
2
  import * as drizzle_orm_mssql_core from "drizzle-orm/mssql-core";
2
3
  import { AnyMsSqlColumn } from "drizzle-orm/mssql-core";
3
- import { e as DailyReportInterviewer, d as DailyReportExternalComment, D as DailyReportItem, b as DailyReportDetail, c as DailyReportAttachmentSummary, g as DailyReportPostedComment } from "./types-DkERw8NE.js";
4
4
  import { TransactionRetryOptions } from "@aiquants/mssql";
5
+ import "zod";
5
6
  type RedisStreamMessage = {
6
7
  id: string;
7
8
  message: Record<string, string>;
@@ -36,9 +37,14 @@ type DailyReportRedisProvider = {
36
37
  getClient(): Promise<DailyReportRedisClient | undefined>;
37
38
  createClient(): Promise<DailyReportRedisBlockingClient | undefined>;
38
39
  };
40
+ type DailyReportSseEntryMessage = {
41
+ readonly parsed: DailyReportSseMessage;
42
+ readonly published: Readonly<Record<string, unknown>>;
43
+ readonly text: string;
44
+ };
39
45
  type StreamEntry = {
40
- id: string;
41
- message: Record<string, string>;
46
+ readonly id: string;
47
+ readonly message: DailyReportSseEntryMessage | null;
42
48
  };
43
49
  type DailyReportSseReaderPort = {
44
50
  ready(): Promise<void>;
@@ -1470,6 +1476,11 @@ declare class DailyReportViewerScope {
1470
1476
  static restrictTo(input: readonly string[] | DailyReportVisibilityDimensions): DailyReportViewerScope;
1471
1477
  static unrestricted(auditReason: string): DailyReportViewerScope;
1472
1478
  }
1479
+ declare const CLIENT_TEMP_ID_BRAND: unique symbol;
1480
+ type DailyReportClientTempId = string & {
1481
+ readonly [CLIENT_TEMP_ID_BRAND]: true;
1482
+ };
1483
+ declare const parseClientTempId: (raw: string | null) => DailyReportClientTempId | null;
1473
1484
  type DailyReportHubRow = {
1474
1485
  id: number;
1475
1486
  sourceType: string;
@@ -1599,17 +1610,17 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1599
1610
  } | null>;
1600
1611
  markAttachmentMissing: (attachmentId: number) => Promise<void>;
1601
1612
  markAttachmentPresent: (attachmentId: number) => Promise<void>;
1602
- setStarStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isStarred: boolean, clientTempId: string) => Promise<DailyReportUserStatusRow>;
1603
- setReadStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isRead: boolean, clientTempId: string) => Promise<DailyReportUserStatusRow>;
1604
- addComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, content: string, businessDate: string | null, clientTempId: string) => Promise<DailyReportPostedComment>;
1605
- deleteComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, commentId: number, businessDate: string | null, clientTempId: string) => Promise<void>;
1606
- createDailyReport: (userId: number, businessDate: string, clientTempId: string) => Promise<DailyReportDetail>;
1613
+ setStarStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isStarred: boolean, clientTempId: DailyReportClientTempId) => Promise<DailyReportUserStatusRow>;
1614
+ setReadStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isRead: boolean, clientTempId: DailyReportClientTempId) => Promise<DailyReportUserStatusRow>;
1615
+ addComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, content: string, businessDate: string | null, clientTempId: DailyReportClientTempId) => Promise<DailyReportPostedComment>;
1616
+ deleteComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, commentId: number, businessDate: string | null, clientTempId: DailyReportClientTempId) => Promise<void>;
1617
+ createDailyReport: (userId: number, businessDate: string, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail>;
1607
1618
  updateDailyReport: (reportHubId: number, userId: number, data: {
1608
1619
  title?: string;
1609
1620
  content?: string;
1610
- }, clientTempId: string) => Promise<void>;
1611
- publishDailyReport: (reportHubId: number, userId: number, clientTempId: string) => Promise<DailyReportDetail | null>;
1612
- deleteDailyReport: (reportHubId: number, userId: number, clientTempId: string) => Promise<void>;
1621
+ }, clientTempId: DailyReportClientTempId) => Promise<void>;
1622
+ publishDailyReport: (reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail | null>;
1623
+ deleteDailyReport: (reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<void>;
1613
1624
  findDailyReportHubById: (tx: DailyReportDb, reportHubId: number) => Promise<DailyReportHubRow[]>;
1614
1625
  updateDailyReportHub: (tx: DailyReportDb, reportHubId: number, data: Partial<DailyReportHubRow>) => Promise<void>;
1615
1626
  updateDailyReportInternal: (tx: DailyReportDb, hubId: number, data: Partial<DailyReportInternalRow>) => Promise<void>;
@@ -1771,7 +1782,7 @@ declare const DAILY_REPORT_SHARP_THUMBNAIL_DECODE_WORK_MODEL: Readonly<{
1771
1782
  declare const predictSharpThumbnailWorkingSetBytes: (source: Uint8Array, format: DailyReportAttachmentThumbnailSourceFormat, header: SharpHeaderLike) => number | null;
1772
1783
  declare const createSharpThumbnailRenderer: (sharp: SharpLike) => DailyReportAttachmentThumbnailRenderer;
1773
1784
  declare const DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS = 60000;
1774
- declare const DAILY_REPORT_SSE_CATCH_UP_BATCH = 1000;
1785
+ declare const DAILY_REPORT_SSE_CATCH_UP_BATCH: number;
1775
1786
  type DailyReportServerConfig = Omit<DailyReportServiceConfig, "cache" | "epochs"> & {
1776
1787
  authenticate: DailyReportAuthenticate;
1777
1788
  resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
@@ -1789,4 +1800,4 @@ type DailyReportServer = DailyReportHandlers & {
1789
1800
  knownSourceTypes: readonly string[];
1790
1801
  };
1791
1802
  declare function createDailyReportServer(config: DailyReportServerConfig): DailyReportServer;
1792
- 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_DECODE_WORK_MODEL, 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 DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportDb, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServer, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderPort, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, predictSharpThumbnailWorkingSetBytes, transformJsonArray };
1803
+ 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_DECODE_WORK_MODEL, 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 DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportClientTempId, type DailyReportDb, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServer, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderPort, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, parseClientTempId, predictSharpThumbnailWorkingSetBytes, transformJsonArray };