@aiquants/daily-report 0.41.0 → 0.42.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
@@ -55,4 +55,6 @@ declare const parseDailyReportAttachmentQuery: (params: URLSearchParams) => Dail
55
55
  type BusinessDateInput = string | Date | null | undefined;
56
56
  declare const normalizeBusinessDateKey: (value: BusinessDateInput) => string | null;
57
57
  declare const DAILY_REPORT_CLIENT_TEMP_ID_PATTERN: RegExp;
58
- export { DAILY_REPORT_API_ENDPOINTS, DAILY_REPORT_API_QUERY_PARAMS, DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS, DAILY_REPORT_CLIENT_TEMP_ID_PATTERN, type DailyReportAttachmentDeliveryRequest, type DailyReportAttachmentInvalidQuery, type DailyReportAttachmentThumbnailBox, type DailyReportAttachmentThumbnailVariant, type BusinessDateInput as DailyReportBusinessDateInput, buildDailyReportAttachmentUrl, isDailyReportAttachmentThumbnailVariant, normalizeBusinessDateKey, parseDailyReportAttachmentQuery };
58
+ declare const DAILY_REPORT_INTERNAL_SOURCE_TYPE = "Internal";
59
+ declare const foldDailyReportSourceTypeToken: (token: string) => string;
60
+ export { DAILY_REPORT_API_ENDPOINTS, DAILY_REPORT_API_QUERY_PARAMS, DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS, DAILY_REPORT_CLIENT_TEMP_ID_PATTERN, DAILY_REPORT_INTERNAL_SOURCE_TYPE, type DailyReportAttachmentDeliveryRequest, type DailyReportAttachmentInvalidQuery, type DailyReportAttachmentThumbnailBox, type DailyReportAttachmentThumbnailVariant, type BusinessDateInput as DailyReportBusinessDateInput, buildDailyReportAttachmentUrl, foldDailyReportSourceTypeToken, isDailyReportAttachmentThumbnailVariant, normalizeBusinessDateKey, parseDailyReportAttachmentQuery };
package/dist/index.d.ts CHANGED
@@ -55,4 +55,6 @@ declare const parseDailyReportAttachmentQuery: (params: URLSearchParams) => Dail
55
55
  type BusinessDateInput = string | Date | null | undefined;
56
56
  declare const normalizeBusinessDateKey: (value: BusinessDateInput) => string | null;
57
57
  declare const DAILY_REPORT_CLIENT_TEMP_ID_PATTERN: RegExp;
58
- export { DAILY_REPORT_API_ENDPOINTS, DAILY_REPORT_API_QUERY_PARAMS, DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS, DAILY_REPORT_CLIENT_TEMP_ID_PATTERN, type DailyReportAttachmentDeliveryRequest, type DailyReportAttachmentInvalidQuery, type DailyReportAttachmentThumbnailBox, type DailyReportAttachmentThumbnailVariant, type BusinessDateInput as DailyReportBusinessDateInput, buildDailyReportAttachmentUrl, isDailyReportAttachmentThumbnailVariant, normalizeBusinessDateKey, parseDailyReportAttachmentQuery };
58
+ declare const DAILY_REPORT_INTERNAL_SOURCE_TYPE = "Internal";
59
+ declare const foldDailyReportSourceTypeToken: (token: string) => string;
60
+ export { DAILY_REPORT_API_ENDPOINTS, DAILY_REPORT_API_QUERY_PARAMS, DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS, DAILY_REPORT_CLIENT_TEMP_ID_PATTERN, DAILY_REPORT_INTERNAL_SOURCE_TYPE, type DailyReportAttachmentDeliveryRequest, type DailyReportAttachmentInvalidQuery, type DailyReportAttachmentThumbnailBox, type DailyReportAttachmentThumbnailVariant, type BusinessDateInput as DailyReportBusinessDateInput, buildDailyReportAttachmentUrl, foldDailyReportSourceTypeToken, isDailyReportAttachmentThumbnailVariant, normalizeBusinessDateKey, parseDailyReportAttachmentQuery };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var U=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var Ve=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},qe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of $e(t))!Ke.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=Fe(t,o))||n.enumerable});return e};var Ge=e=>qe(U({},"__esModule",{value:!0}),e);var Yt={};Ve(Yt,{DAILY_REPORT_ACTION_FIELDS:()=>y,DAILY_REPORT_ACTION_INTENTS:()=>be,DAILY_REPORT_API_ENDPOINTS:()=>Ee,DAILY_REPORT_API_QUERY_PARAMS:()=>Ce,DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS:()=>$,DAILY_REPORT_CLIENT_TEMP_ID_PATTERN:()=>_,DAILY_REPORT_SEARCH_BATCHES_IN_FLIGHT:()=>Ye,DAILY_REPORT_SEARCH_COMBINES:()=>je,DAILY_REPORT_SSE_CURSOR_PARAM:()=>ye,DAILY_REPORT_SSE_HEARTBEAT_MS:()=>me,DAILY_REPORT_SSE_TERMINAL_EVENTS:()=>ce,buildDailyReportAttachmentUrl:()=>Me,dailyReportDetailSchema:()=>I,dailyReportSseMessageSchema:()=>fe,encodeDailyReportActionCommand:()=>De,forEachIdsStreamRow:()=>_e,isDailyReportAttachmentThumbnailVariant:()=>j,normalizeBusinessDateKey:()=>Ae,parseDailyReportActionResult:()=>Ie,parseDailyReportAttachmentQuery:()=>Oe,readDailyReportSearchMarksAnswer:()=>Be,readIdsStreamChunkLine:()=>xe});module.exports=Ge(Yt);var p=require("zod/v3");var _=/^(?:[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 Q=require("zod/v3"),f=e=>Number.isSafeInteger(e)&&e>0,c=Q.z.number().int().positive().max(Number.MAX_SAFE_INTEGER);var d=require("zod/v3");var S=Symbol("daily-report wire mismatch"),h=(e,t,r)=>(e.issues.push({...r,path:t===null?[...e.path]:[...e.path,t]}),S),ee=e=>e===null?"null":Array.isArray(e)?"array":Number.isNaN(e)?"nan":typeof e,A=(e,t)=>({code:"invalid_type",expected:e,received:ee(t)}),Qe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ze=e=>{let t=0;for(let r in e)t+=1;return t},Z=(e,t,r)=>{let n={};for(let o=0;o<r;o+=1){let a=t[o];a in e&&(n[a]=e[a])}return n},E=e=>{let t=Object.keys(e),r=Object.values(e);return(n,o)=>{if(!Qe(n))return h(o,null,A("object",n));let a=null,l=!1,s=0;for(let i=0;i<t.length;i+=1){let m=t[i],R=n[m];R!==void 0&&(s+=1);let b=r[i](R,o,m);if(b===S){l=!0;continue}a===null&&b!==R&&(a=Z(n,t,i)),a!==null&&(b!==void 0||m in n)&&(a[m]=b)}return l?S:a!==null?a:Ze(n)===s?n:Z(n,t,t.length)}},C=e=>(t,r,n)=>{r.path.push(n);let o=e(t,r);return r.path.pop(),o},k=e=>(t,r,n)=>{if(!Array.isArray(t))return h(r,n,A("array",t));r.path.push(n);let o=t,a=!1;for(let l=0;l<t.length;l+=1){let s=t[l],i=e(s,r,l);i===S?a=!0:i!==s&&(o===t&&(o=t.slice()),o[l]=i)}return r.path.pop(),a?S:o},u=(e,t,r)=>e==null||typeof e=="string"?e:h(t,r,A("string",e)),X=(e,t,r)=>e===null||typeof e=="string"?e:h(t,r,A("string",e)),J=(e,t,r)=>typeof e=="string"?e:h(t,r,A("string",e)),Xe=(e,t,r)=>e===null||typeof e=="number"&&!Number.isNaN(e)?e:h(t,r,A("number",e)),w=(e,t,r)=>typeof e=="boolean"?e:h(t,r,A("boolean",e)),W=(e,t,r)=>{if(typeof e=="number"&&f(e))return e;for(let{message:n,path:o,...a}of c.safeParse(e).error.issues)h(t,r,a);return S},te={present:!0,absent:!0,unknown:!0},re=Object.keys(te),Je=re.map(e=>`'${e}'`).join(" | "),et=(e,t,r)=>typeof e!="string"?h(t,r,{code:"invalid_type",expected:Je,received:ee(e)}):Object.hasOwn(te,e)?e:h(t,r,{code:"invalid_enum_value",received:e,options:[...re]}),ne=E({name:u,affiliation:u}),oe=E({name:u,text:u,color:u}),ae=E({id:W,name:u,color:u}),se=E({id:W,userId:u,userName:u,content:u,createdAt:u,isMine:w}),tt=E({id:J,fileName:J,fileType:X,fileSize:Xe,createdAt:X,state:et,hasThumbnail:w}),rt=E({reportHubId:W,date:u,createdAt:u,author:u,userId:u,sourceType:u,employeeName:u,updatedBy:u,updatedAt:u,category:u,creationCategory:u,visitTimeFrom:u,visitTimeTo:u,customerName:u,interviewers:k(C(ne)),subject:u,content:u,externalComments:k(C(oe)),isRead:w,isStarred:w,isDraft:w,labels:k(C(ae)),postedComments:k(C(se)),attachments:k(C(tt))}),N=(e,t)=>{let r={path:[],issues:[]},n=e(t,r);return n===S?{ok:!1,issues:r.issues}:{ok:!0,value:n}},ie=e=>N(rt,e),le=e=>N(ne,e),ue=e=>N(oe,e),pe=e=>N(ae,e),de=e=>N(se,e);var ce=["auth-required","forbidden","resync-required"],me=15e3,ye="lastEventId",nt=/^\d{1,15}-\d{1,15}$/,Re=e=>nt.test(e),M=e=>d.z.unknown().transform((t,r)=>{let n=e(t);if(n.ok)return n.value;for(let o of n.issues)r.addIssue({...o,fatal:!0});return d.z.NEVER}),Vt=M(le),qt=M(ue),Gt=M(pe),B=M(de),I=M(ie),T=d.z.string().regex(_),ot=d.z.object({type:d.z.literal("connected")}),at=d.z.object({type:d.z.literal("status-update"),reportHubId:c,statusType:d.z.enum(["star","read"]),value:d.z.boolean(),clientTempId:T,recipientRawUserId:c.optional()}),v=d.z.string(),st=d.z.object({type:d.z.literal("comment-add"),reportHubId:c,comment:B,clientTempId:T,recipientRawUserId:c.optional(),sourceType:v}),it=d.z.object({type:d.z.literal("comment-delete"),reportHubId:c,commentId:c,clientTempId:T,recipientRawUserId:c.optional(),sourceType:v}),lt=d.z.object({type:d.z.literal("report-create"),reportHubId:c,report:I,clientTempId:T,recipientRawUserId:c.optional()}),ut=d.z.object({type:d.z.literal("report-update"),reportHubId:c,report:I,clientTempId:T,recipientRawUserId:c.optional()}),pt=d.z.object({type:d.z.literal("report-publish"),reportHubId:c,report:I,clientTempId:T,recipientRawUserId:c.optional()}),dt=d.z.object({type:d.z.literal("report-delete"),reportHubId:c,clientTempId:T,sourceType:v}),fe=d.z.discriminatedUnion("type",[ot,at,st,it,lt,ut,pt,dt]);var he=e=>e.issues.map(t=>`${t.path.length===0?"(root)":t.path.join(".")}: ${t.code}`).join("; ");var be=Object.freeze(["create","update","publish","delete","toggleStar","toggleRead","addComment","deleteComment","clearCache"]);var y=Object.freeze({intent:"intent",clientTempId:"clientTempId",businessDate:"businessDate",operationTimestamp:"operationTimestamp",reportHubId:"reportHubId",title:"title",content:"content",isStarred:"isStarred",isRead:"isRead",commentId:"commentId"}),De=e=>{let t=new FormData;if(t.append(y.intent,e.intent),e.intent==="clearCache"||(t.append(y.clientTempId,e.clientTempId),e.businessDate!==null&&t.append(y.businessDate,e.businessDate),e.operationTimestamp!==null&&t.append(y.operationTimestamp,String(e.operationTimestamp)),e.intent==="create"))return t;switch(t.append(y.reportHubId,String(e.reportHubId)),e.intent){case"update":return e.changes.title!==void 0&&t.append(y.title,e.changes.title),e.changes.content!==void 0&&t.append(y.content,e.changes.content),t;case"publish":case"delete":return t;case"toggleStar":return t.append(y.isStarred,String(e.value)),t;case"toggleRead":return t.append(y.isRead,String(e.value)),t;case"addComment":return t.append(y.content,e.content),t;case"deleteComment":return t.append(y.commentId,String(e.commentId)),t}},ct=()=>{let e=c,t=p.z.string().regex(_),r=p.z.literal("OK"),n=p.z.object({isStarred:p.z.boolean(),isRead:p.z.boolean()}),o=p.z.number().int().nonnegative().nullable();return{create:p.z.object({status:r,intent:p.z.literal("create"),reportHubId:e,clientTempId:t,report:I}),update:p.z.object({status:r,intent:p.z.literal("update"),reportHubId:e,clientTempId:t}),publish:p.z.object({status:r,intent:p.z.literal("publish"),reportHubId:e,clientTempId:t,report:I.nullable()}),delete:p.z.object({status:r,intent:p.z.literal("delete"),reportHubId:e,clientTempId:t}),toggleStar:p.z.object({status:r,intent:p.z.literal("toggleStar"),reportHubId:e,clientTempId:t,updatedStatus:n,operationTimestamp:o}),toggleRead:p.z.object({status:r,intent:p.z.literal("toggleRead"),reportHubId:e,clientTempId:t,updatedStatus:n,operationTimestamp:o}),addComment:p.z.object({status:r,intent:p.z.literal("addComment"),reportHubId:e,clientTempId:t,newComment:B}),deleteComment:p.z.object({status:r,intent:p.z.literal("deleteComment"),reportHubId:e,clientTempId:t,deletedCommentId:c}),clearCache:p.z.object({status:r,intent:p.z.literal("clearCache")})}},z=null,mt=()=>(z===null&&(z=ct()),z),Ie=(e,t)=>{let r=mt()[e].safeParse(t);return r.success?{result:r.data}:{mismatch:he(r.error)}};var yt=/^(\d{4})([-/])(\d{2})\2(\d{2})$/;var ge=e=>e<10?`0${e}`:`${e}`,Rt=e=>{if(Number.isNaN(e.getTime()))return null;let t=e.getFullYear(),r=ge(e.getMonth()+1),n=ge(e.getDate());return`${t}-${r}-${n}`},Se=e=>{let t=yt.exec(e);if(t===null)return null;let[,r,,n,o]=t,a=Number(r),l=Number(n),s=Number(o);if(a<1)return null;let i=new Date(0);return i.setUTCFullYear(a,l-1,s),i.getUTCFullYear()!==a||i.getUTCMonth()!==l-1||i.getUTCDate()!==s?null:`${r}-${n}-${o}`},F=e=>Se(e)===e;var Ae=e=>e==null?null:e instanceof Date?Rt(e):Se(e);var Te="ids-columns",ft=e=>{if(typeof e!="object"||e===null)return"unknown";let{kind:t}=e;return t==="chunk"?"chunk":t==="error"?"error":"unknown"},ht=e=>typeof e=="number"&&f(e),bt=e=>{if(typeof e!="object"||e===null)return!1;let{businessDate:t,reportHubId:r}=e;return(t===null||typeof t=="string")&&typeof r=="number"},Dt=4,It=e=>{let t=Dt;for(;2**t<e*2;)t+=1;let r=new Float64Array(2**t),n=r.length-1,o=32-t;return a=>{let l=Math.imul(a|0,2654435761)>>>o;for(;;){let s=r[l];if(s===0)return r[l]=a,!0;if(s===a)return!1;l=l+1&n}}},gt=/^[0-9a-f]{1,16}$/,St=e=>f(e.reportHubId)&&(e.businessDate===null||F(e.businessDate)),At=e=>typeof e=="string"&&gt.test(e),Tt=Object.freeze({kind:"absent"}),xt=Object.freeze({kind:"value",value:null}),_t=e=>e===void 0?Tt:e===null?xt:typeof e=="string"&&Re(e)?{kind:"value",value:e}:{kind:"malformed",received:e},xe=e=>{if(ft(e)!=="chunk")return null;let{ids:t,dates:r,counts:n,sourceTypes:o,sources:a,isLast:l,nextCursor:s,total:i,snapshot:m,provisional:R,restarted:b,streamAnchor:ve}=e;if(typeof l!="boolean"||!(s===null||bt(s))||!(Array.isArray(t)&&Array.isArray(r)&&Array.isArray(n)&&Array.isArray(o)&&Array.isArray(a))||r.length!==n.length||a.length!==t.length)return null;for(let D of o)if(!(D===null||typeof D=="string"))return null;let ze=It(t.length),g=0,V=null,q=0;for(let D=0;D<r.length;D++){let x=r[D],P=n[D];if(!(x===null||typeof x=="string"&&F(x))||D>0&&x===r[D-1]||typeof P!="number"||!Number.isSafeInteger(P)||P<1)return null;let G=g+P;if(G>t.length)return null;for(;g<G;g++){let L=t[g],H=a[g];if(!(ht(L)&&ze(L))||typeof H!="number"||!Number.isSafeInteger(H)||H<0||H>=o.length||g>0&&!Ct(V,q,x,L))return null;V=x,q=L}}return g!==t.length?null:{rows:e,isLast:l,resumeCursor:s!==null&&St(s)?s:null,total:typeof i=="number"&&Number.isSafeInteger(i)&&i>=0?i:null,snapshot:At(m)?m:null,provisional:R===!0,restarted:b===!0,streamAnchor:_t(ve)}},_e=(e,t)=>{let{ids:r,dates:n,counts:o,sourceTypes:a,sources:l}=e,s=0;for(let i=0;i<n.length;i++){let m=n[i];for(let R=s+o[i];s<R;s++){let b=a[l[s]];t(r[s],m,b===null?void 0:b)}}};var Et=(e,t,r,n)=>e!==r?e===null?1:r===null||e>r?-1:1:n-t,Ct=(e,t,r,n)=>Et(e,t,r,n)<0;var Ee=Object.freeze({businessDate:"business-date",idsStream:Te,report:"report",search:"search",reports:"reports",searchMarks:"search-marks",searchFacets:"search-facets",action:"action"}),Ce=Object.freeze({businessDate:"businessDate",reportHubId:"reportHubId",searchQuery:"q",searchCombine:"combine",searchAuthor:"author",searchSourceType:"sourceType",searchCustomer:"customer",reportIds:"ids",forceRefresh:"forceRefresh",cursorReportHubId:"cursor_report_hub_id",cursorBusinessDate:"cursor_business_date",cursorSnapshot:"cursor_snapshot"});var $=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),j=e=>Object.hasOwn($,e);var ke="download",we="thumbnail",Ne="1",Me=(e,t,r)=>{let n=`${e}/attachment/${encodeURIComponent(t)}`;switch(r.kind){case"inline":return n;case"download":return`${n}?${new URLSearchParams({[ke]:Ne})}`;case"thumbnail":return`${n}?${new URLSearchParams({[we]:r.variant})}`}},Oe=e=>{let t=e.getAll(we),r=e.getAll(ke);if(t.length>0&&r.length>0)return{kind:"invalid",reason:"conflict"};if(t.length>0){let[n]=t;return t.length===1&&j(n)?{kind:"thumbnail",variant:n}:{kind:"invalid",reason:"thumbnail_variant"}}return r.length>0?r.length===1&&r[0]===Ne?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var K="legacy-";var kt=/^[1-9][0-9]*$/,wt=/^(?:0|[1-9][0-9]*)$/,Pe=e=>{if(e===null||!kt.test(e))return null;let t=Number(e);return f(t)?t:null},Y=e=>{if(e===null||!wt.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)?t:null};var Nt=Object.freeze(["subject","content","author","employeeName","updatedBy","category","creationCategory","customerName"]),br=Object.freeze({field:e=>e,interviewer:(e,t)=>`interviewer:${e}:${t}`,attachment:e=>`attachment:${e}`,comment:(e,t)=>`comment:${e}:${t}`}),Mt=e=>e.startsWith(K)?Y(e.slice(K.length))!==null:Pe(e)!==null,Le=e=>{if(Nt.includes(e))return!0;let t=e.split(":");switch(t[0]){case"interviewer":return t.length===3&&Y(t[1])!==null&&(t[2]==="name"||t[2]==="affiliation");case"attachment":return t.length===2&&Y(t[1])!==null;case"comment":return t.length===3&&Mt(t[1])&&(t[2]==="author"||t[2]==="content");default:return!1}};var Dr=String.fromCodePoint(3),Ir=String.fromCodePoint(2),gr=String.fromCodePoint(1);var je=["intersection","union"];var Ar=Object.freeze({maxQueryLength:500,maxSets:16,maxWordsPerSet:16,maxWords:32,maxWordLength:100,maxDetailIds:100}),Ot=2,Ye=2,He=Object.freeze({word:0,reading:1}),Ue=e=>e===He.word||e===He.reading;var O=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Tr=2*(1+Ot);var Pt=4294967295,We=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=Pt,Lt=e=>{if(!Array.isArray(e)||e.length%3!==0)return null;let t=[];for(let r=0;r<e.length;r+=3){let n=e[r],o=e[r+1],a=e[r+2];if(!(typeof n=="number"&&Number.isSafeInteger(n)&&n>=0&&typeof o=="number"&&Number.isSafeInteger(o)&&n<o)||!Ue(a))return null;if(r>0){let l=t[r-2];if(l>n||l===n&&t[r-1]===a)return null}t.push(n,o,a)}return t},Ht=e=>{if(!(O(e)&&We(e.fingerprint)))return null;if(Object.hasOwn(e,"dense"))return e.dense===!0&&!Object.hasOwn(e,"ranges")?{fingerprint:e.fingerprint,dense:!0}:null;let t=Lt(e.ranges);return t===null?null:{fingerprint:e.fingerprint,ranges:t}},jt=e=>{if(!O(e))return null;let t={};for(let[r,n]of Object.entries(e)){if(!Le(r))return null;let o=Ht(n);if(o===null)return null;t[r]=o}return t},Be=(e,t)=>{if(!(O(e)&&We(e.wordsDigest)&&Array.isArray(e.reports)&&Array.isArray(e.deferred)))return null;let r=new Set(t.requestedIds),n=new Set,o=2**t.setCount-1,a=[];for(let s of e.reports){if(!O(s))return null;let{reportHubId:i,matchedSets:m}=s;if(!(typeof i=="number"&&f(i)&&r.has(i))||n.has(i)||(n.add(i),t.expectsMatchedSets?!(typeof m=="number"&&Number.isInteger(m)&&m>=0&&m<=o):m!==null))return null;let R=jt(s.fields);if(R===null)return null;a.push({reportHubId:i,matchedSets:m,fields:R})}if(a.length===0&&e.deferred.length>0)return null;let l=[];for(let s of e.deferred){if(!(typeof s=="number"&&f(s)&&r.has(s))||n.has(s))return null;n.add(s),l.push(s)}return{wordsDigest:e.wordsDigest,reports:a,deferred:l}};0&&(module.exports={DAILY_REPORT_ACTION_FIELDS,DAILY_REPORT_ACTION_INTENTS,DAILY_REPORT_API_ENDPOINTS,DAILY_REPORT_API_QUERY_PARAMS,DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS,DAILY_REPORT_CLIENT_TEMP_ID_PATTERN,DAILY_REPORT_SEARCH_BATCHES_IN_FLIGHT,DAILY_REPORT_SEARCH_COMBINES,DAILY_REPORT_SSE_CURSOR_PARAM,DAILY_REPORT_SSE_HEARTBEAT_MS,DAILY_REPORT_SSE_TERMINAL_EVENTS,buildDailyReportAttachmentUrl,dailyReportDetailSchema,dailyReportSseMessageSchema,encodeDailyReportActionCommand,forEachIdsStreamRow,isDailyReportAttachmentThumbnailVariant,normalizeBusinessDateKey,parseDailyReportActionResult,parseDailyReportAttachmentQuery,readDailyReportSearchMarksAnswer,readIdsStreamChunkLine});
1
+ "use strict";var U=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var Ge=(e,t)=>{for(var r in t)U(e,r,{get:t[r],enumerable:!0})},Qe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ve(t))!qe.call(e,o)&&o!==r&&U(e,o,{get:()=>t[o],enumerable:!(n=Ke(t,o))||n.enumerable});return e};var Ze=e=>Qe(U({},"__esModule",{value:!0}),e);var Wt={};Ge(Wt,{DAILY_REPORT_ACTION_FIELDS:()=>y,DAILY_REPORT_ACTION_INTENTS:()=>be,DAILY_REPORT_API_ENDPOINTS:()=>Ee,DAILY_REPORT_API_QUERY_PARAMS:()=>Ce,DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS:()=>$,DAILY_REPORT_CLIENT_TEMP_ID_PATTERN:()=>_,DAILY_REPORT_INTERNAL_SOURCE_TYPE:()=>ve,DAILY_REPORT_SEARCH_BATCHES_IN_FLIGHT:()=>Ye,DAILY_REPORT_SEARCH_COMBINES:()=>je,DAILY_REPORT_SSE_CURSOR_PARAM:()=>ye,DAILY_REPORT_SSE_HEARTBEAT_MS:()=>me,DAILY_REPORT_SSE_TERMINAL_EVENTS:()=>ce,buildDailyReportAttachmentUrl:()=>Me,dailyReportDetailSchema:()=>I,dailyReportSseMessageSchema:()=>fe,encodeDailyReportActionCommand:()=>De,foldDailyReportSourceTypeToken:()=>ze,forEachIdsStreamRow:()=>_e,isDailyReportAttachmentThumbnailVariant:()=>j,normalizeBusinessDateKey:()=>Ae,parseDailyReportActionResult:()=>Ie,parseDailyReportAttachmentQuery:()=>Oe,readDailyReportSearchMarksAnswer:()=>Be,readIdsStreamChunkLine:()=>xe});module.exports=Ze(Wt);var p=require("zod/v3");var _=/^(?:[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 Q=require("zod/v3"),f=e=>Number.isSafeInteger(e)&&e>0,c=Q.z.number().int().positive().max(Number.MAX_SAFE_INTEGER);var d=require("zod/v3");var S=Symbol("daily-report wire mismatch"),h=(e,t,r)=>(e.issues.push({...r,path:t===null?[...e.path]:[...e.path,t]}),S),ee=e=>e===null?"null":Array.isArray(e)?"array":Number.isNaN(e)?"nan":typeof e,A=(e,t)=>({code:"invalid_type",expected:e,received:ee(t)}),Xe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Je=e=>{let t=0;for(let r in e)t+=1;return t},Z=(e,t,r)=>{let n={};for(let o=0;o<r;o+=1){let a=t[o];a in e&&(n[a]=e[a])}return n},E=e=>{let t=Object.keys(e),r=Object.values(e);return(n,o)=>{if(!Xe(n))return h(o,null,A("object",n));let a=null,l=!1,s=0;for(let i=0;i<t.length;i+=1){let m=t[i],R=n[m];R!==void 0&&(s+=1);let b=r[i](R,o,m);if(b===S){l=!0;continue}a===null&&b!==R&&(a=Z(n,t,i)),a!==null&&(b!==void 0||m in n)&&(a[m]=b)}return l?S:a!==null?a:Je(n)===s?n:Z(n,t,t.length)}},C=e=>(t,r,n)=>{r.path.push(n);let o=e(t,r);return r.path.pop(),o},k=e=>(t,r,n)=>{if(!Array.isArray(t))return h(r,n,A("array",t));r.path.push(n);let o=t,a=!1;for(let l=0;l<t.length;l+=1){let s=t[l],i=e(s,r,l);i===S?a=!0:i!==s&&(o===t&&(o=t.slice()),o[l]=i)}return r.path.pop(),a?S:o},u=(e,t,r)=>e==null||typeof e=="string"?e:h(t,r,A("string",e)),X=(e,t,r)=>e===null||typeof e=="string"?e:h(t,r,A("string",e)),J=(e,t,r)=>typeof e=="string"?e:h(t,r,A("string",e)),et=(e,t,r)=>e===null||typeof e=="number"&&!Number.isNaN(e)?e:h(t,r,A("number",e)),w=(e,t,r)=>typeof e=="boolean"?e:h(t,r,A("boolean",e)),W=(e,t,r)=>{if(typeof e=="number"&&f(e))return e;for(let{message:n,path:o,...a}of c.safeParse(e).error.issues)h(t,r,a);return S},te={present:!0,absent:!0,unknown:!0},re=Object.keys(te),tt=re.map(e=>`'${e}'`).join(" | "),rt=(e,t,r)=>typeof e!="string"?h(t,r,{code:"invalid_type",expected:tt,received:ee(e)}):Object.hasOwn(te,e)?e:h(t,r,{code:"invalid_enum_value",received:e,options:[...re]}),ne=E({name:u,affiliation:u}),oe=E({name:u,text:u,color:u}),ae=E({id:W,name:u,color:u}),se=E({id:W,userId:u,userName:u,content:u,createdAt:u,isMine:w}),nt=E({id:J,fileName:J,fileType:X,fileSize:et,createdAt:X,state:rt,hasThumbnail:w}),ot=E({reportHubId:W,date:u,createdAt:u,author:u,userId:u,sourceType:u,employeeName:u,updatedBy:u,updatedAt:u,category:u,creationCategory:u,visitTimeFrom:u,visitTimeTo:u,customerName:u,interviewers:k(C(ne)),subject:u,content:u,externalComments:k(C(oe)),isRead:w,isStarred:w,isDraft:w,labels:k(C(ae)),postedComments:k(C(se)),attachments:k(C(nt))}),N=(e,t)=>{let r={path:[],issues:[]},n=e(t,r);return n===S?{ok:!1,issues:r.issues}:{ok:!0,value:n}},ie=e=>N(ot,e),le=e=>N(ne,e),ue=e=>N(oe,e),pe=e=>N(ae,e),de=e=>N(se,e);var ce=["auth-required","forbidden","resync-required"],me=15e3,ye="lastEventId",at=/^\d{1,15}-\d{1,15}$/,Re=e=>at.test(e),M=e=>d.z.unknown().transform((t,r)=>{let n=e(t);if(n.ok)return n.value;for(let o of n.issues)r.addIssue({...o,fatal:!0});return d.z.NEVER}),Gt=M(le),Qt=M(ue),Zt=M(pe),B=M(de),I=M(ie),T=d.z.string().regex(_),st=d.z.object({type:d.z.literal("connected")}),it=d.z.object({type:d.z.literal("status-update"),reportHubId:c,statusType:d.z.enum(["star","read"]),value:d.z.boolean(),clientTempId:T,recipientRawUserId:c.optional()}),v=d.z.string(),lt=d.z.object({type:d.z.literal("comment-add"),reportHubId:c,comment:B,clientTempId:T,recipientRawUserId:c.optional(),sourceType:v}),ut=d.z.object({type:d.z.literal("comment-delete"),reportHubId:c,commentId:c,clientTempId:T,recipientRawUserId:c.optional(),sourceType:v}),pt=d.z.object({type:d.z.literal("report-create"),reportHubId:c,report:I,clientTempId:T,recipientRawUserId:c.optional()}),dt=d.z.object({type:d.z.literal("report-update"),reportHubId:c,report:I,clientTempId:T,recipientRawUserId:c.optional()}),ct=d.z.object({type:d.z.literal("report-publish"),reportHubId:c,report:I,clientTempId:T,recipientRawUserId:c.optional()}),mt=d.z.object({type:d.z.literal("report-delete"),reportHubId:c,clientTempId:T,sourceType:v}),fe=d.z.discriminatedUnion("type",[st,it,lt,ut,pt,dt,ct,mt]);var he=e=>e.issues.map(t=>`${t.path.length===0?"(root)":t.path.join(".")}: ${t.code}`).join("; ");var be=Object.freeze(["create","update","publish","delete","toggleStar","toggleRead","addComment","deleteComment","clearCache"]);var y=Object.freeze({intent:"intent",clientTempId:"clientTempId",businessDate:"businessDate",operationTimestamp:"operationTimestamp",reportHubId:"reportHubId",title:"title",content:"content",isStarred:"isStarred",isRead:"isRead",commentId:"commentId"}),De=e=>{let t=new FormData;if(t.append(y.intent,e.intent),e.intent==="clearCache"||(t.append(y.clientTempId,e.clientTempId),e.businessDate!==null&&t.append(y.businessDate,e.businessDate),e.operationTimestamp!==null&&t.append(y.operationTimestamp,String(e.operationTimestamp)),e.intent==="create"))return t;switch(t.append(y.reportHubId,String(e.reportHubId)),e.intent){case"update":return e.changes.title!==void 0&&t.append(y.title,e.changes.title),e.changes.content!==void 0&&t.append(y.content,e.changes.content),t;case"publish":case"delete":return t;case"toggleStar":return t.append(y.isStarred,String(e.value)),t;case"toggleRead":return t.append(y.isRead,String(e.value)),t;case"addComment":return t.append(y.content,e.content),t;case"deleteComment":return t.append(y.commentId,String(e.commentId)),t}},yt=()=>{let e=c,t=p.z.string().regex(_),r=p.z.literal("OK"),n=p.z.object({isStarred:p.z.boolean(),isRead:p.z.boolean()}),o=p.z.number().int().nonnegative().nullable();return{create:p.z.object({status:r,intent:p.z.literal("create"),reportHubId:e,clientTempId:t,report:I}),update:p.z.object({status:r,intent:p.z.literal("update"),reportHubId:e,clientTempId:t}),publish:p.z.object({status:r,intent:p.z.literal("publish"),reportHubId:e,clientTempId:t,report:I.nullable()}),delete:p.z.object({status:r,intent:p.z.literal("delete"),reportHubId:e,clientTempId:t}),toggleStar:p.z.object({status:r,intent:p.z.literal("toggleStar"),reportHubId:e,clientTempId:t,updatedStatus:n,operationTimestamp:o}),toggleRead:p.z.object({status:r,intent:p.z.literal("toggleRead"),reportHubId:e,clientTempId:t,updatedStatus:n,operationTimestamp:o}),addComment:p.z.object({status:r,intent:p.z.literal("addComment"),reportHubId:e,clientTempId:t,newComment:B}),deleteComment:p.z.object({status:r,intent:p.z.literal("deleteComment"),reportHubId:e,clientTempId:t,deletedCommentId:c}),clearCache:p.z.object({status:r,intent:p.z.literal("clearCache")})}},z=null,Rt=()=>(z===null&&(z=yt()),z),Ie=(e,t)=>{let r=Rt()[e].safeParse(t);return r.success?{result:r.data}:{mismatch:he(r.error)}};var ft=/^(\d{4})([-/])(\d{2})\2(\d{2})$/;var ge=e=>e<10?`0${e}`:`${e}`,ht=e=>{if(Number.isNaN(e.getTime()))return null;let t=e.getFullYear(),r=ge(e.getMonth()+1),n=ge(e.getDate());return`${t}-${r}-${n}`},Se=e=>{let t=ft.exec(e);if(t===null)return null;let[,r,,n,o]=t,a=Number(r),l=Number(n),s=Number(o);if(a<1)return null;let i=new Date(0);return i.setUTCFullYear(a,l-1,s),i.getUTCFullYear()!==a||i.getUTCMonth()!==l-1||i.getUTCDate()!==s?null:`${r}-${n}-${o}`},F=e=>Se(e)===e;var Ae=e=>e==null?null:e instanceof Date?ht(e):Se(e);var Te="ids-columns",bt=e=>{if(typeof e!="object"||e===null)return"unknown";let{kind:t}=e;return t==="chunk"?"chunk":t==="error"?"error":"unknown"},Dt=e=>typeof e=="number"&&f(e),It=e=>{if(typeof e!="object"||e===null)return!1;let{businessDate:t,reportHubId:r}=e;return(t===null||typeof t=="string")&&typeof r=="number"},gt=4,St=e=>{let t=gt;for(;2**t<e*2;)t+=1;let r=new Float64Array(2**t),n=r.length-1,o=32-t;return a=>{let l=Math.imul(a|0,2654435761)>>>o;for(;;){let s=r[l];if(s===0)return r[l]=a,!0;if(s===a)return!1;l=l+1&n}}},At=/^[0-9a-f]{1,16}$/,Tt=e=>f(e.reportHubId)&&(e.businessDate===null||F(e.businessDate)),xt=e=>typeof e=="string"&&At.test(e),_t=Object.freeze({kind:"absent"}),Et=Object.freeze({kind:"value",value:null}),Ct=e=>e===void 0?_t:e===null?Et:typeof e=="string"&&Re(e)?{kind:"value",value:e}:{kind:"malformed",received:e},xe=e=>{if(bt(e)!=="chunk")return null;let{ids:t,dates:r,counts:n,sourceTypes:o,sources:a,isLast:l,nextCursor:s,total:i,snapshot:m,provisional:R,restarted:b,streamAnchor:Fe}=e;if(typeof l!="boolean"||!(s===null||It(s))||!(Array.isArray(t)&&Array.isArray(r)&&Array.isArray(n)&&Array.isArray(o)&&Array.isArray(a))||r.length!==n.length||a.length!==t.length)return null;for(let D of o)if(!(D===null||typeof D=="string"))return null;let $e=St(t.length),g=0,V=null,q=0;for(let D=0;D<r.length;D++){let x=r[D],P=n[D];if(!(x===null||typeof x=="string"&&F(x))||D>0&&x===r[D-1]||typeof P!="number"||!Number.isSafeInteger(P)||P<1)return null;let G=g+P;if(G>t.length)return null;for(;g<G;g++){let L=t[g],H=a[g];if(!(Dt(L)&&$e(L))||typeof H!="number"||!Number.isSafeInteger(H)||H<0||H>=o.length||g>0&&!wt(V,q,x,L))return null;V=x,q=L}}return g!==t.length?null:{rows:e,isLast:l,resumeCursor:s!==null&&Tt(s)?s:null,total:typeof i=="number"&&Number.isSafeInteger(i)&&i>=0?i:null,snapshot:xt(m)?m:null,provisional:R===!0,restarted:b===!0,streamAnchor:Ct(Fe)}},_e=(e,t)=>{let{ids:r,dates:n,counts:o,sourceTypes:a,sources:l}=e,s=0;for(let i=0;i<n.length;i++){let m=n[i];for(let R=s+o[i];s<R;s++){let b=a[l[s]];t(r[s],m,b===null?void 0:b)}}};var kt=(e,t,r,n)=>e!==r?e===null?1:r===null||e>r?-1:1:n-t,wt=(e,t,r,n)=>kt(e,t,r,n)<0;var Ee=Object.freeze({businessDate:"business-date",idsStream:Te,report:"report",search:"search",reports:"reports",searchMarks:"search-marks",searchFacets:"search-facets",action:"action"}),Ce=Object.freeze({businessDate:"businessDate",reportHubId:"reportHubId",searchQuery:"q",searchCombine:"combine",searchAuthor:"author",searchSourceType:"sourceType",searchCustomer:"customer",reportIds:"ids",forceRefresh:"forceRefresh",cursorReportHubId:"cursor_report_hub_id",cursorBusinessDate:"cursor_business_date",cursorSnapshot:"cursor_snapshot"});var $=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),j=e=>Object.hasOwn($,e);var ke="download",we="thumbnail",Ne="1",Me=(e,t,r)=>{let n=`${e}/attachment/${encodeURIComponent(t)}`;switch(r.kind){case"inline":return n;case"download":return`${n}?${new URLSearchParams({[ke]:Ne})}`;case"thumbnail":return`${n}?${new URLSearchParams({[we]:r.variant})}`}},Oe=e=>{let t=e.getAll(we),r=e.getAll(ke);if(t.length>0&&r.length>0)return{kind:"invalid",reason:"conflict"};if(t.length>0){let[n]=t;return t.length===1&&j(n)?{kind:"thumbnail",variant:n}:{kind:"invalid",reason:"thumbnail_variant"}}return r.length>0?r.length===1&&r[0]===Ne?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var K="legacy-";var Nt=/^[1-9][0-9]*$/,Mt=/^(?:0|[1-9][0-9]*)$/,Pe=e=>{if(e===null||!Nt.test(e))return null;let t=Number(e);return f(t)?t:null},Y=e=>{if(e===null||!Mt.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)?t:null};var Ot=Object.freeze(["subject","content","author","employeeName","updatedBy","category","creationCategory","customerName"]),Ir=Object.freeze({field:e=>e,interviewer:(e,t)=>`interviewer:${e}:${t}`,attachment:e=>`attachment:${e}`,comment:(e,t)=>`comment:${e}:${t}`}),Pt=e=>e.startsWith(K)?Y(e.slice(K.length))!==null:Pe(e)!==null,Le=e=>{if(Ot.includes(e))return!0;let t=e.split(":");switch(t[0]){case"interviewer":return t.length===3&&Y(t[1])!==null&&(t[2]==="name"||t[2]==="affiliation");case"attachment":return t.length===2&&Y(t[1])!==null;case"comment":return t.length===3&&Pt(t[1])&&(t[2]==="author"||t[2]==="content");default:return!1}};var gr=String.fromCodePoint(3),Sr=String.fromCodePoint(2),Ar=String.fromCodePoint(1);var je=["intersection","union"];var xr=Object.freeze({maxQueryLength:500,maxSets:16,maxWordsPerSet:16,maxWords:32,maxWordLength:100,maxDetailIds:100}),Lt=2,Ye=2,He=Object.freeze({word:0,reading:1}),Ue=e=>e===He.word||e===He.reading;var O=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},_r=2*(1+Lt);var Ht=4294967295,We=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=Ht,jt=e=>{if(!Array.isArray(e)||e.length%3!==0)return null;let t=[];for(let r=0;r<e.length;r+=3){let n=e[r],o=e[r+1],a=e[r+2];if(!(typeof n=="number"&&Number.isSafeInteger(n)&&n>=0&&typeof o=="number"&&Number.isSafeInteger(o)&&n<o)||!Ue(a))return null;if(r>0){let l=t[r-2];if(l>n||l===n&&t[r-1]===a)return null}t.push(n,o,a)}return t},Yt=e=>{if(!(O(e)&&We(e.fingerprint)))return null;if(Object.hasOwn(e,"dense"))return e.dense===!0&&!Object.hasOwn(e,"ranges")?{fingerprint:e.fingerprint,dense:!0}:null;let t=jt(e.ranges);return t===null?null:{fingerprint:e.fingerprint,ranges:t}},Ut=e=>{if(!O(e))return null;let t={};for(let[r,n]of Object.entries(e)){if(!Le(r))return null;let o=Yt(n);if(o===null)return null;t[r]=o}return t},Be=(e,t)=>{if(!(O(e)&&We(e.wordsDigest)&&Array.isArray(e.reports)&&Array.isArray(e.deferred)))return null;let r=new Set(t.requestedIds),n=new Set,o=2**t.setCount-1,a=[];for(let s of e.reports){if(!O(s))return null;let{reportHubId:i,matchedSets:m}=s;if(!(typeof i=="number"&&f(i)&&r.has(i))||n.has(i)||(n.add(i),t.expectsMatchedSets?!(typeof m=="number"&&Number.isInteger(m)&&m>=0&&m<=o):m!==null))return null;let R=Ut(s.fields);if(R===null)return null;a.push({reportHubId:i,matchedSets:m,fields:R})}if(a.length===0&&e.deferred.length>0)return null;let l=[];for(let s of e.deferred){if(!(typeof s=="number"&&f(s)&&r.has(s))||n.has(s))return null;n.add(s),l.push(s)}return{wordsDigest:e.wordsDigest,reports:a,deferred:l}};var ve="Internal",ze=e=>e.trim().toLowerCase();0&&(module.exports={DAILY_REPORT_ACTION_FIELDS,DAILY_REPORT_ACTION_INTENTS,DAILY_REPORT_API_ENDPOINTS,DAILY_REPORT_API_QUERY_PARAMS,DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS,DAILY_REPORT_CLIENT_TEMP_ID_PATTERN,DAILY_REPORT_INTERNAL_SOURCE_TYPE,DAILY_REPORT_SEARCH_BATCHES_IN_FLIGHT,DAILY_REPORT_SEARCH_COMBINES,DAILY_REPORT_SSE_CURSOR_PARAM,DAILY_REPORT_SSE_HEARTBEAT_MS,DAILY_REPORT_SSE_TERMINAL_EVENTS,buildDailyReportAttachmentUrl,dailyReportDetailSchema,dailyReportSseMessageSchema,encodeDailyReportActionCommand,foldDailyReportSourceTypeToken,forEachIdsStreamRow,isDailyReportAttachmentThumbnailVariant,normalizeBusinessDateKey,parseDailyReportActionResult,parseDailyReportAttachmentQuery,readDailyReportSearchMarksAnswer,readIdsStreamChunkLine});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{z as p}from"zod/v3";var E=/^(?:[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})$/;import{z as xe}from"zod/v3";var f=e=>Number.isSafeInteger(e)&&e>0,c=xe.number().int().positive().max(Number.MAX_SAFE_INTEGER);import{z as d}from"zod/v3";var g=Symbol("daily-report wire mismatch"),h=(e,t,r)=>(e.issues.push({...r,path:t===null?[...e.path]:[...e.path,t]}),g),Z=e=>e===null?"null":Array.isArray(e)?"array":Number.isNaN(e)?"nan":typeof e,S=(e,t)=>({code:"invalid_type",expected:e,received:Z(t)}),_e=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ee=e=>{let t=0;for(let r in e)t+=1;return t},q=(e,t,r)=>{let n={};for(let o=0;o<r;o+=1){let a=t[o];a in e&&(n[a]=e[a])}return n},_=e=>{let t=Object.keys(e),r=Object.values(e);return(n,o)=>{if(!_e(n))return h(o,null,S("object",n));let a=null,l=!1,s=0;for(let i=0;i<t.length;i+=1){let m=t[i],R=n[m];R!==void 0&&(s+=1);let b=r[i](R,o,m);if(b===g){l=!0;continue}a===null&&b!==R&&(a=q(n,t,i)),a!==null&&(b!==void 0||m in n)&&(a[m]=b)}return l?g:a!==null?a:Ee(n)===s?n:q(n,t,t.length)}},C=e=>(t,r,n)=>{r.path.push(n);let o=e(t,r);return r.path.pop(),o},k=e=>(t,r,n)=>{if(!Array.isArray(t))return h(r,n,S("array",t));r.path.push(n);let o=t,a=!1;for(let l=0;l<t.length;l+=1){let s=t[l],i=e(s,r,l);i===g?a=!0:i!==s&&(o===t&&(o=t.slice()),o[l]=i)}return r.path.pop(),a?g:o},u=(e,t,r)=>e==null||typeof e=="string"?e:h(t,r,S("string",e)),G=(e,t,r)=>e===null||typeof e=="string"?e:h(t,r,S("string",e)),Q=(e,t,r)=>typeof e=="string"?e:h(t,r,S("string",e)),Ce=(e,t,r)=>e===null||typeof e=="number"&&!Number.isNaN(e)?e:h(t,r,S("number",e)),w=(e,t,r)=>typeof e=="boolean"?e:h(t,r,S("boolean",e)),Y=(e,t,r)=>{if(typeof e=="number"&&f(e))return e;for(let{message:n,path:o,...a}of c.safeParse(e).error.issues)h(t,r,a);return g},X={present:!0,absent:!0,unknown:!0},J=Object.keys(X),ke=J.map(e=>`'${e}'`).join(" | "),we=(e,t,r)=>typeof e!="string"?h(t,r,{code:"invalid_type",expected:ke,received:Z(e)}):Object.hasOwn(X,e)?e:h(t,r,{code:"invalid_enum_value",received:e,options:[...J]}),ee=_({name:u,affiliation:u}),te=_({name:u,text:u,color:u}),re=_({id:Y,name:u,color:u}),ne=_({id:Y,userId:u,userName:u,content:u,createdAt:u,isMine:w}),Ne=_({id:Q,fileName:Q,fileType:G,fileSize:Ce,createdAt:G,state:we,hasThumbnail:w}),Me=_({reportHubId:Y,date:u,createdAt:u,author:u,userId:u,sourceType:u,employeeName:u,updatedBy:u,updatedAt:u,category:u,creationCategory:u,visitTimeFrom:u,visitTimeTo:u,customerName:u,interviewers:k(C(ee)),subject:u,content:u,externalComments:k(C(te)),isRead:w,isStarred:w,isDraft:w,labels:k(C(re)),postedComments:k(C(ne)),attachments:k(C(Ne))}),N=(e,t)=>{let r={path:[],issues:[]},n=e(t,r);return n===g?{ok:!1,issues:r.issues}:{ok:!0,value:n}},oe=e=>N(Me,e),ae=e=>N(ee,e),se=e=>N(te,e),ie=e=>N(re,e),le=e=>N(ne,e);var Oe=["auth-required","forbidden","resync-required"],Pe=15e3,Le="lastEventId",He=/^\d{1,15}-\d{1,15}$/,ue=e=>He.test(e),M=e=>d.unknown().transform((t,r)=>{let n=e(t);if(n.ok)return n.value;for(let o of n.issues)r.addIssue({...o,fatal:!0});return d.NEVER}),Wt=M(ae),Bt=M(se),vt=M(ie),U=M(le),A=M(oe),T=d.string().regex(E),je=d.object({type:d.literal("connected")}),Ye=d.object({type:d.literal("status-update"),reportHubId:c,statusType:d.enum(["star","read"]),value:d.boolean(),clientTempId:T,recipientRawUserId:c.optional()}),W=d.string(),Ue=d.object({type:d.literal("comment-add"),reportHubId:c,comment:U,clientTempId:T,recipientRawUserId:c.optional(),sourceType:W}),We=d.object({type:d.literal("comment-delete"),reportHubId:c,commentId:c,clientTempId:T,recipientRawUserId:c.optional(),sourceType:W}),Be=d.object({type:d.literal("report-create"),reportHubId:c,report:A,clientTempId:T,recipientRawUserId:c.optional()}),ve=d.object({type:d.literal("report-update"),reportHubId:c,report:A,clientTempId:T,recipientRawUserId:c.optional()}),ze=d.object({type:d.literal("report-publish"),reportHubId:c,report:A,clientTempId:T,recipientRawUserId:c.optional()}),Fe=d.object({type:d.literal("report-delete"),reportHubId:c,clientTempId:T,sourceType:W}),$e=d.discriminatedUnion("type",[je,Ye,Ue,We,Be,ve,ze,Fe]);var pe=e=>e.issues.map(t=>`${t.path.length===0?"(root)":t.path.join(".")}: ${t.code}`).join("; ");var Ke=Object.freeze(["create","update","publish","delete","toggleStar","toggleRead","addComment","deleteComment","clearCache"]);var y=Object.freeze({intent:"intent",clientTempId:"clientTempId",businessDate:"businessDate",operationTimestamp:"operationTimestamp",reportHubId:"reportHubId",title:"title",content:"content",isStarred:"isStarred",isRead:"isRead",commentId:"commentId"}),Ve=e=>{let t=new FormData;if(t.append(y.intent,e.intent),e.intent==="clearCache"||(t.append(y.clientTempId,e.clientTempId),e.businessDate!==null&&t.append(y.businessDate,e.businessDate),e.operationTimestamp!==null&&t.append(y.operationTimestamp,String(e.operationTimestamp)),e.intent==="create"))return t;switch(t.append(y.reportHubId,String(e.reportHubId)),e.intent){case"update":return e.changes.title!==void 0&&t.append(y.title,e.changes.title),e.changes.content!==void 0&&t.append(y.content,e.changes.content),t;case"publish":case"delete":return t;case"toggleStar":return t.append(y.isStarred,String(e.value)),t;case"toggleRead":return t.append(y.isRead,String(e.value)),t;case"addComment":return t.append(y.content,e.content),t;case"deleteComment":return t.append(y.commentId,String(e.commentId)),t}},qe=()=>{let e=c,t=p.string().regex(E),r=p.literal("OK"),n=p.object({isStarred:p.boolean(),isRead:p.boolean()}),o=p.number().int().nonnegative().nullable();return{create:p.object({status:r,intent:p.literal("create"),reportHubId:e,clientTempId:t,report:A}),update:p.object({status:r,intent:p.literal("update"),reportHubId:e,clientTempId:t}),publish:p.object({status:r,intent:p.literal("publish"),reportHubId:e,clientTempId:t,report:A.nullable()}),delete:p.object({status:r,intent:p.literal("delete"),reportHubId:e,clientTempId:t}),toggleStar:p.object({status:r,intent:p.literal("toggleStar"),reportHubId:e,clientTempId:t,updatedStatus:n,operationTimestamp:o}),toggleRead:p.object({status:r,intent:p.literal("toggleRead"),reportHubId:e,clientTempId:t,updatedStatus:n,operationTimestamp:o}),addComment:p.object({status:r,intent:p.literal("addComment"),reportHubId:e,clientTempId:t,newComment:U}),deleteComment:p.object({status:r,intent:p.literal("deleteComment"),reportHubId:e,clientTempId:t,deletedCommentId:c}),clearCache:p.object({status:r,intent:p.literal("clearCache")})}},B=null,Ge=()=>(B===null&&(B=qe()),B),Qe=(e,t)=>{let r=Ge()[e].safeParse(t);return r.success?{result:r.data}:{mismatch:pe(r.error)}};var Ze=/^(\d{4})([-/])(\d{2})\2(\d{2})$/;var de=e=>e<10?`0${e}`:`${e}`,Xe=e=>{if(Number.isNaN(e.getTime()))return null;let t=e.getFullYear(),r=de(e.getMonth()+1),n=de(e.getDate());return`${t}-${r}-${n}`},ce=e=>{let t=Ze.exec(e);if(t===null)return null;let[,r,,n,o]=t,a=Number(r),l=Number(n),s=Number(o);if(a<1)return null;let i=new Date(0);return i.setUTCFullYear(a,l-1,s),i.getUTCFullYear()!==a||i.getUTCMonth()!==l-1||i.getUTCDate()!==s?null:`${r}-${n}-${o}`},v=e=>ce(e)===e;var Je=e=>e==null?null:e instanceof Date?Xe(e):ce(e);var me="ids-columns",et=e=>{if(typeof e!="object"||e===null)return"unknown";let{kind:t}=e;return t==="chunk"?"chunk":t==="error"?"error":"unknown"},tt=e=>typeof e=="number"&&f(e),rt=e=>{if(typeof e!="object"||e===null)return!1;let{businessDate:t,reportHubId:r}=e;return(t===null||typeof t=="string")&&typeof r=="number"},nt=4,ot=e=>{let t=nt;for(;2**t<e*2;)t+=1;let r=new Float64Array(2**t),n=r.length-1,o=32-t;return a=>{let l=Math.imul(a|0,2654435761)>>>o;for(;;){let s=r[l];if(s===0)return r[l]=a,!0;if(s===a)return!1;l=l+1&n}}},at=/^[0-9a-f]{1,16}$/,st=e=>f(e.reportHubId)&&(e.businessDate===null||v(e.businessDate)),it=e=>typeof e=="string"&&at.test(e),lt=Object.freeze({kind:"absent"}),ut=Object.freeze({kind:"value",value:null}),pt=e=>e===void 0?lt:e===null?ut:typeof e=="string"&&ue(e)?{kind:"value",value:e}:{kind:"malformed",received:e},dt=e=>{if(et(e)!=="chunk")return null;let{ids:t,dates:r,counts:n,sourceTypes:o,sources:a,isLast:l,nextCursor:s,total:i,snapshot:m,provisional:R,restarted:b,streamAnchor:Ae}=e;if(typeof l!="boolean"||!(s===null||rt(s))||!(Array.isArray(t)&&Array.isArray(r)&&Array.isArray(n)&&Array.isArray(o)&&Array.isArray(a))||r.length!==n.length||a.length!==t.length)return null;for(let D of o)if(!(D===null||typeof D=="string"))return null;let Te=ot(t.length),I=0,$=null,K=0;for(let D=0;D<r.length;D++){let x=r[D],P=n[D];if(!(x===null||typeof x=="string"&&v(x))||D>0&&x===r[D-1]||typeof P!="number"||!Number.isSafeInteger(P)||P<1)return null;let V=I+P;if(V>t.length)return null;for(;I<V;I++){let L=t[I],H=a[I];if(!(tt(L)&&Te(L))||typeof H!="number"||!Number.isSafeInteger(H)||H<0||H>=o.length||I>0&&!yt($,K,x,L))return null;$=x,K=L}}return I!==t.length?null:{rows:e,isLast:l,resumeCursor:s!==null&&st(s)?s:null,total:typeof i=="number"&&Number.isSafeInteger(i)&&i>=0?i:null,snapshot:it(m)?m:null,provisional:R===!0,restarted:b===!0,streamAnchor:pt(Ae)}},ct=(e,t)=>{let{ids:r,dates:n,counts:o,sourceTypes:a,sources:l}=e,s=0;for(let i=0;i<n.length;i++){let m=n[i];for(let R=s+o[i];s<R;s++){let b=a[l[s]];t(r[s],m,b===null?void 0:b)}}};var mt=(e,t,r,n)=>e!==r?e===null?1:r===null||e>r?-1:1:n-t,yt=(e,t,r,n)=>mt(e,t,r,n)<0;var Rt=Object.freeze({businessDate:"business-date",idsStream:me,report:"report",search:"search",reports:"reports",searchMarks:"search-marks",searchFacets:"search-facets",action:"action"}),ft=Object.freeze({businessDate:"businessDate",reportHubId:"reportHubId",searchQuery:"q",searchCombine:"combine",searchAuthor:"author",searchSourceType:"sourceType",searchCustomer:"customer",reportIds:"ids",forceRefresh:"forceRefresh",cursorReportHubId:"cursor_report_hub_id",cursorBusinessDate:"cursor_business_date",cursorSnapshot:"cursor_snapshot"});var ye=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),z=e=>Object.hasOwn(ye,e);var Re="download",fe="thumbnail",he="1",ht=(e,t,r)=>{let n=`${e}/attachment/${encodeURIComponent(t)}`;switch(r.kind){case"inline":return n;case"download":return`${n}?${new URLSearchParams({[Re]:he})}`;case"thumbnail":return`${n}?${new URLSearchParams({[fe]:r.variant})}`}},bt=e=>{let t=e.getAll(fe),r=e.getAll(Re);if(t.length>0&&r.length>0)return{kind:"invalid",reason:"conflict"};if(t.length>0){let[n]=t;return t.length===1&&z(n)?{kind:"thumbnail",variant:n}:{kind:"invalid",reason:"thumbnail_variant"}}return r.length>0?r.length===1&&r[0]===he?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var F="legacy-";var Dt=/^[1-9][0-9]*$/,It=/^(?:0|[1-9][0-9]*)$/,be=e=>{if(e===null||!Dt.test(e))return null;let t=Number(e);return f(t)?t:null},j=e=>{if(e===null||!It.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)?t:null};var gt=Object.freeze(["subject","content","author","employeeName","updatedBy","category","creationCategory","customerName"]),cr=Object.freeze({field:e=>e,interviewer:(e,t)=>`interviewer:${e}:${t}`,attachment:e=>`attachment:${e}`,comment:(e,t)=>`comment:${e}:${t}`}),St=e=>e.startsWith(F)?j(e.slice(F.length))!==null:be(e)!==null,De=e=>{if(gt.includes(e))return!0;let t=e.split(":");switch(t[0]){case"interviewer":return t.length===3&&j(t[1])!==null&&(t[2]==="name"||t[2]==="affiliation");case"attachment":return t.length===2&&j(t[1])!==null;case"comment":return t.length===3&&St(t[1])&&(t[2]==="author"||t[2]==="content");default:return!1}};var mr=String.fromCodePoint(3),yr=String.fromCodePoint(2),Rr=String.fromCodePoint(1);var At=["intersection","union"];var hr=Object.freeze({maxQueryLength:500,maxSets:16,maxWordsPerSet:16,maxWords:32,maxWordLength:100,maxDetailIds:100}),Tt=2,xt=2,Ie=Object.freeze({word:0,reading:1}),ge=e=>e===Ie.word||e===Ie.reading;var O=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},br=2*(1+Tt);var _t=4294967295,Se=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=_t,Et=e=>{if(!Array.isArray(e)||e.length%3!==0)return null;let t=[];for(let r=0;r<e.length;r+=3){let n=e[r],o=e[r+1],a=e[r+2];if(!(typeof n=="number"&&Number.isSafeInteger(n)&&n>=0&&typeof o=="number"&&Number.isSafeInteger(o)&&n<o)||!ge(a))return null;if(r>0){let l=t[r-2];if(l>n||l===n&&t[r-1]===a)return null}t.push(n,o,a)}return t},Ct=e=>{if(!(O(e)&&Se(e.fingerprint)))return null;if(Object.hasOwn(e,"dense"))return e.dense===!0&&!Object.hasOwn(e,"ranges")?{fingerprint:e.fingerprint,dense:!0}:null;let t=Et(e.ranges);return t===null?null:{fingerprint:e.fingerprint,ranges:t}},kt=e=>{if(!O(e))return null;let t={};for(let[r,n]of Object.entries(e)){if(!De(r))return null;let o=Ct(n);if(o===null)return null;t[r]=o}return t},wt=(e,t)=>{if(!(O(e)&&Se(e.wordsDigest)&&Array.isArray(e.reports)&&Array.isArray(e.deferred)))return null;let r=new Set(t.requestedIds),n=new Set,o=2**t.setCount-1,a=[];for(let s of e.reports){if(!O(s))return null;let{reportHubId:i,matchedSets:m}=s;if(!(typeof i=="number"&&f(i)&&r.has(i))||n.has(i)||(n.add(i),t.expectsMatchedSets?!(typeof m=="number"&&Number.isInteger(m)&&m>=0&&m<=o):m!==null))return null;let R=kt(s.fields);if(R===null)return null;a.push({reportHubId:i,matchedSets:m,fields:R})}if(a.length===0&&e.deferred.length>0)return null;let l=[];for(let s of e.deferred){if(!(typeof s=="number"&&f(s)&&r.has(s))||n.has(s))return null;n.add(s),l.push(s)}return{wordsDigest:e.wordsDigest,reports:a,deferred:l}};export{y as DAILY_REPORT_ACTION_FIELDS,Ke as DAILY_REPORT_ACTION_INTENTS,Rt as DAILY_REPORT_API_ENDPOINTS,ft as DAILY_REPORT_API_QUERY_PARAMS,ye as DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS,E as DAILY_REPORT_CLIENT_TEMP_ID_PATTERN,xt as DAILY_REPORT_SEARCH_BATCHES_IN_FLIGHT,At as DAILY_REPORT_SEARCH_COMBINES,Le as DAILY_REPORT_SSE_CURSOR_PARAM,Pe as DAILY_REPORT_SSE_HEARTBEAT_MS,Oe as DAILY_REPORT_SSE_TERMINAL_EVENTS,ht as buildDailyReportAttachmentUrl,A as dailyReportDetailSchema,$e as dailyReportSseMessageSchema,Ve as encodeDailyReportActionCommand,ct as forEachIdsStreamRow,z as isDailyReportAttachmentThumbnailVariant,Je as normalizeBusinessDateKey,Qe as parseDailyReportActionResult,bt as parseDailyReportAttachmentQuery,wt as readDailyReportSearchMarksAnswer,dt as readIdsStreamChunkLine};
1
+ import{z as p}from"zod/v3";var E=/^(?:[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})$/;import{z as xe}from"zod/v3";var f=e=>Number.isSafeInteger(e)&&e>0,c=xe.number().int().positive().max(Number.MAX_SAFE_INTEGER);import{z as d}from"zod/v3";var g=Symbol("daily-report wire mismatch"),h=(e,t,r)=>(e.issues.push({...r,path:t===null?[...e.path]:[...e.path,t]}),g),Z=e=>e===null?"null":Array.isArray(e)?"array":Number.isNaN(e)?"nan":typeof e,S=(e,t)=>({code:"invalid_type",expected:e,received:Z(t)}),_e=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ee=e=>{let t=0;for(let r in e)t+=1;return t},q=(e,t,r)=>{let n={};for(let o=0;o<r;o+=1){let a=t[o];a in e&&(n[a]=e[a])}return n},_=e=>{let t=Object.keys(e),r=Object.values(e);return(n,o)=>{if(!_e(n))return h(o,null,S("object",n));let a=null,l=!1,s=0;for(let i=0;i<t.length;i+=1){let m=t[i],R=n[m];R!==void 0&&(s+=1);let b=r[i](R,o,m);if(b===g){l=!0;continue}a===null&&b!==R&&(a=q(n,t,i)),a!==null&&(b!==void 0||m in n)&&(a[m]=b)}return l?g:a!==null?a:Ee(n)===s?n:q(n,t,t.length)}},C=e=>(t,r,n)=>{r.path.push(n);let o=e(t,r);return r.path.pop(),o},k=e=>(t,r,n)=>{if(!Array.isArray(t))return h(r,n,S("array",t));r.path.push(n);let o=t,a=!1;for(let l=0;l<t.length;l+=1){let s=t[l],i=e(s,r,l);i===g?a=!0:i!==s&&(o===t&&(o=t.slice()),o[l]=i)}return r.path.pop(),a?g:o},u=(e,t,r)=>e==null||typeof e=="string"?e:h(t,r,S("string",e)),G=(e,t,r)=>e===null||typeof e=="string"?e:h(t,r,S("string",e)),Q=(e,t,r)=>typeof e=="string"?e:h(t,r,S("string",e)),Ce=(e,t,r)=>e===null||typeof e=="number"&&!Number.isNaN(e)?e:h(t,r,S("number",e)),w=(e,t,r)=>typeof e=="boolean"?e:h(t,r,S("boolean",e)),Y=(e,t,r)=>{if(typeof e=="number"&&f(e))return e;for(let{message:n,path:o,...a}of c.safeParse(e).error.issues)h(t,r,a);return g},X={present:!0,absent:!0,unknown:!0},J=Object.keys(X),ke=J.map(e=>`'${e}'`).join(" | "),we=(e,t,r)=>typeof e!="string"?h(t,r,{code:"invalid_type",expected:ke,received:Z(e)}):Object.hasOwn(X,e)?e:h(t,r,{code:"invalid_enum_value",received:e,options:[...J]}),ee=_({name:u,affiliation:u}),te=_({name:u,text:u,color:u}),re=_({id:Y,name:u,color:u}),ne=_({id:Y,userId:u,userName:u,content:u,createdAt:u,isMine:w}),Ne=_({id:Q,fileName:Q,fileType:G,fileSize:Ce,createdAt:G,state:we,hasThumbnail:w}),Me=_({reportHubId:Y,date:u,createdAt:u,author:u,userId:u,sourceType:u,employeeName:u,updatedBy:u,updatedAt:u,category:u,creationCategory:u,visitTimeFrom:u,visitTimeTo:u,customerName:u,interviewers:k(C(ee)),subject:u,content:u,externalComments:k(C(te)),isRead:w,isStarred:w,isDraft:w,labels:k(C(re)),postedComments:k(C(ne)),attachments:k(C(Ne))}),N=(e,t)=>{let r={path:[],issues:[]},n=e(t,r);return n===g?{ok:!1,issues:r.issues}:{ok:!0,value:n}},oe=e=>N(Me,e),ae=e=>N(ee,e),se=e=>N(te,e),ie=e=>N(re,e),le=e=>N(ne,e);var Oe=["auth-required","forbidden","resync-required"],Pe=15e3,Le="lastEventId",He=/^\d{1,15}-\d{1,15}$/,ue=e=>He.test(e),M=e=>d.unknown().transform((t,r)=>{let n=e(t);if(n.ok)return n.value;for(let o of n.issues)r.addIssue({...o,fatal:!0});return d.NEVER}),vt=M(ae),zt=M(se),Ft=M(ie),U=M(le),A=M(oe),T=d.string().regex(E),je=d.object({type:d.literal("connected")}),Ye=d.object({type:d.literal("status-update"),reportHubId:c,statusType:d.enum(["star","read"]),value:d.boolean(),clientTempId:T,recipientRawUserId:c.optional()}),W=d.string(),Ue=d.object({type:d.literal("comment-add"),reportHubId:c,comment:U,clientTempId:T,recipientRawUserId:c.optional(),sourceType:W}),We=d.object({type:d.literal("comment-delete"),reportHubId:c,commentId:c,clientTempId:T,recipientRawUserId:c.optional(),sourceType:W}),Be=d.object({type:d.literal("report-create"),reportHubId:c,report:A,clientTempId:T,recipientRawUserId:c.optional()}),ve=d.object({type:d.literal("report-update"),reportHubId:c,report:A,clientTempId:T,recipientRawUserId:c.optional()}),ze=d.object({type:d.literal("report-publish"),reportHubId:c,report:A,clientTempId:T,recipientRawUserId:c.optional()}),Fe=d.object({type:d.literal("report-delete"),reportHubId:c,clientTempId:T,sourceType:W}),$e=d.discriminatedUnion("type",[je,Ye,Ue,We,Be,ve,ze,Fe]);var pe=e=>e.issues.map(t=>`${t.path.length===0?"(root)":t.path.join(".")}: ${t.code}`).join("; ");var Ke=Object.freeze(["create","update","publish","delete","toggleStar","toggleRead","addComment","deleteComment","clearCache"]);var y=Object.freeze({intent:"intent",clientTempId:"clientTempId",businessDate:"businessDate",operationTimestamp:"operationTimestamp",reportHubId:"reportHubId",title:"title",content:"content",isStarred:"isStarred",isRead:"isRead",commentId:"commentId"}),Ve=e=>{let t=new FormData;if(t.append(y.intent,e.intent),e.intent==="clearCache"||(t.append(y.clientTempId,e.clientTempId),e.businessDate!==null&&t.append(y.businessDate,e.businessDate),e.operationTimestamp!==null&&t.append(y.operationTimestamp,String(e.operationTimestamp)),e.intent==="create"))return t;switch(t.append(y.reportHubId,String(e.reportHubId)),e.intent){case"update":return e.changes.title!==void 0&&t.append(y.title,e.changes.title),e.changes.content!==void 0&&t.append(y.content,e.changes.content),t;case"publish":case"delete":return t;case"toggleStar":return t.append(y.isStarred,String(e.value)),t;case"toggleRead":return t.append(y.isRead,String(e.value)),t;case"addComment":return t.append(y.content,e.content),t;case"deleteComment":return t.append(y.commentId,String(e.commentId)),t}},qe=()=>{let e=c,t=p.string().regex(E),r=p.literal("OK"),n=p.object({isStarred:p.boolean(),isRead:p.boolean()}),o=p.number().int().nonnegative().nullable();return{create:p.object({status:r,intent:p.literal("create"),reportHubId:e,clientTempId:t,report:A}),update:p.object({status:r,intent:p.literal("update"),reportHubId:e,clientTempId:t}),publish:p.object({status:r,intent:p.literal("publish"),reportHubId:e,clientTempId:t,report:A.nullable()}),delete:p.object({status:r,intent:p.literal("delete"),reportHubId:e,clientTempId:t}),toggleStar:p.object({status:r,intent:p.literal("toggleStar"),reportHubId:e,clientTempId:t,updatedStatus:n,operationTimestamp:o}),toggleRead:p.object({status:r,intent:p.literal("toggleRead"),reportHubId:e,clientTempId:t,updatedStatus:n,operationTimestamp:o}),addComment:p.object({status:r,intent:p.literal("addComment"),reportHubId:e,clientTempId:t,newComment:U}),deleteComment:p.object({status:r,intent:p.literal("deleteComment"),reportHubId:e,clientTempId:t,deletedCommentId:c}),clearCache:p.object({status:r,intent:p.literal("clearCache")})}},B=null,Ge=()=>(B===null&&(B=qe()),B),Qe=(e,t)=>{let r=Ge()[e].safeParse(t);return r.success?{result:r.data}:{mismatch:pe(r.error)}};var Ze=/^(\d{4})([-/])(\d{2})\2(\d{2})$/;var de=e=>e<10?`0${e}`:`${e}`,Xe=e=>{if(Number.isNaN(e.getTime()))return null;let t=e.getFullYear(),r=de(e.getMonth()+1),n=de(e.getDate());return`${t}-${r}-${n}`},ce=e=>{let t=Ze.exec(e);if(t===null)return null;let[,r,,n,o]=t,a=Number(r),l=Number(n),s=Number(o);if(a<1)return null;let i=new Date(0);return i.setUTCFullYear(a,l-1,s),i.getUTCFullYear()!==a||i.getUTCMonth()!==l-1||i.getUTCDate()!==s?null:`${r}-${n}-${o}`},v=e=>ce(e)===e;var Je=e=>e==null?null:e instanceof Date?Xe(e):ce(e);var me="ids-columns",et=e=>{if(typeof e!="object"||e===null)return"unknown";let{kind:t}=e;return t==="chunk"?"chunk":t==="error"?"error":"unknown"},tt=e=>typeof e=="number"&&f(e),rt=e=>{if(typeof e!="object"||e===null)return!1;let{businessDate:t,reportHubId:r}=e;return(t===null||typeof t=="string")&&typeof r=="number"},nt=4,ot=e=>{let t=nt;for(;2**t<e*2;)t+=1;let r=new Float64Array(2**t),n=r.length-1,o=32-t;return a=>{let l=Math.imul(a|0,2654435761)>>>o;for(;;){let s=r[l];if(s===0)return r[l]=a,!0;if(s===a)return!1;l=l+1&n}}},at=/^[0-9a-f]{1,16}$/,st=e=>f(e.reportHubId)&&(e.businessDate===null||v(e.businessDate)),it=e=>typeof e=="string"&&at.test(e),lt=Object.freeze({kind:"absent"}),ut=Object.freeze({kind:"value",value:null}),pt=e=>e===void 0?lt:e===null?ut:typeof e=="string"&&ue(e)?{kind:"value",value:e}:{kind:"malformed",received:e},dt=e=>{if(et(e)!=="chunk")return null;let{ids:t,dates:r,counts:n,sourceTypes:o,sources:a,isLast:l,nextCursor:s,total:i,snapshot:m,provisional:R,restarted:b,streamAnchor:Ae}=e;if(typeof l!="boolean"||!(s===null||rt(s))||!(Array.isArray(t)&&Array.isArray(r)&&Array.isArray(n)&&Array.isArray(o)&&Array.isArray(a))||r.length!==n.length||a.length!==t.length)return null;for(let D of o)if(!(D===null||typeof D=="string"))return null;let Te=ot(t.length),I=0,$=null,K=0;for(let D=0;D<r.length;D++){let x=r[D],P=n[D];if(!(x===null||typeof x=="string"&&v(x))||D>0&&x===r[D-1]||typeof P!="number"||!Number.isSafeInteger(P)||P<1)return null;let V=I+P;if(V>t.length)return null;for(;I<V;I++){let L=t[I],H=a[I];if(!(tt(L)&&Te(L))||typeof H!="number"||!Number.isSafeInteger(H)||H<0||H>=o.length||I>0&&!yt($,K,x,L))return null;$=x,K=L}}return I!==t.length?null:{rows:e,isLast:l,resumeCursor:s!==null&&st(s)?s:null,total:typeof i=="number"&&Number.isSafeInteger(i)&&i>=0?i:null,snapshot:it(m)?m:null,provisional:R===!0,restarted:b===!0,streamAnchor:pt(Ae)}},ct=(e,t)=>{let{ids:r,dates:n,counts:o,sourceTypes:a,sources:l}=e,s=0;for(let i=0;i<n.length;i++){let m=n[i];for(let R=s+o[i];s<R;s++){let b=a[l[s]];t(r[s],m,b===null?void 0:b)}}};var mt=(e,t,r,n)=>e!==r?e===null?1:r===null||e>r?-1:1:n-t,yt=(e,t,r,n)=>mt(e,t,r,n)<0;var Rt=Object.freeze({businessDate:"business-date",idsStream:me,report:"report",search:"search",reports:"reports",searchMarks:"search-marks",searchFacets:"search-facets",action:"action"}),ft=Object.freeze({businessDate:"businessDate",reportHubId:"reportHubId",searchQuery:"q",searchCombine:"combine",searchAuthor:"author",searchSourceType:"sourceType",searchCustomer:"customer",reportIds:"ids",forceRefresh:"forceRefresh",cursorReportHubId:"cursor_report_hub_id",cursorBusinessDate:"cursor_business_date",cursorSnapshot:"cursor_snapshot"});var ye=Object.freeze({tile:Object.freeze({maxWidth:480,maxHeight:320})}),z=e=>Object.hasOwn(ye,e);var Re="download",fe="thumbnail",he="1",ht=(e,t,r)=>{let n=`${e}/attachment/${encodeURIComponent(t)}`;switch(r.kind){case"inline":return n;case"download":return`${n}?${new URLSearchParams({[Re]:he})}`;case"thumbnail":return`${n}?${new URLSearchParams({[fe]:r.variant})}`}},bt=e=>{let t=e.getAll(fe),r=e.getAll(Re);if(t.length>0&&r.length>0)return{kind:"invalid",reason:"conflict"};if(t.length>0){let[n]=t;return t.length===1&&z(n)?{kind:"thumbnail",variant:n}:{kind:"invalid",reason:"thumbnail_variant"}}return r.length>0?r.length===1&&r[0]===he?{kind:"download"}:{kind:"invalid",reason:"download_value"}:{kind:"inline"}};var F="legacy-";var Dt=/^[1-9][0-9]*$/,It=/^(?:0|[1-9][0-9]*)$/,be=e=>{if(e===null||!Dt.test(e))return null;let t=Number(e);return f(t)?t:null},j=e=>{if(e===null||!It.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)?t:null};var gt=Object.freeze(["subject","content","author","employeeName","updatedBy","category","creationCategory","customerName"]),yr=Object.freeze({field:e=>e,interviewer:(e,t)=>`interviewer:${e}:${t}`,attachment:e=>`attachment:${e}`,comment:(e,t)=>`comment:${e}:${t}`}),St=e=>e.startsWith(F)?j(e.slice(F.length))!==null:be(e)!==null,De=e=>{if(gt.includes(e))return!0;let t=e.split(":");switch(t[0]){case"interviewer":return t.length===3&&j(t[1])!==null&&(t[2]==="name"||t[2]==="affiliation");case"attachment":return t.length===2&&j(t[1])!==null;case"comment":return t.length===3&&St(t[1])&&(t[2]==="author"||t[2]==="content");default:return!1}};var Rr=String.fromCodePoint(3),fr=String.fromCodePoint(2),hr=String.fromCodePoint(1);var At=["intersection","union"];var Dr=Object.freeze({maxQueryLength:500,maxSets:16,maxWordsPerSet:16,maxWords:32,maxWordLength:100,maxDetailIds:100}),Tt=2,xt=2,Ie=Object.freeze({word:0,reading:1}),ge=e=>e===Ie.word||e===Ie.reading;var O=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Ir=2*(1+Tt);var _t=4294967295,Se=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=_t,Et=e=>{if(!Array.isArray(e)||e.length%3!==0)return null;let t=[];for(let r=0;r<e.length;r+=3){let n=e[r],o=e[r+1],a=e[r+2];if(!(typeof n=="number"&&Number.isSafeInteger(n)&&n>=0&&typeof o=="number"&&Number.isSafeInteger(o)&&n<o)||!ge(a))return null;if(r>0){let l=t[r-2];if(l>n||l===n&&t[r-1]===a)return null}t.push(n,o,a)}return t},Ct=e=>{if(!(O(e)&&Se(e.fingerprint)))return null;if(Object.hasOwn(e,"dense"))return e.dense===!0&&!Object.hasOwn(e,"ranges")?{fingerprint:e.fingerprint,dense:!0}:null;let t=Et(e.ranges);return t===null?null:{fingerprint:e.fingerprint,ranges:t}},kt=e=>{if(!O(e))return null;let t={};for(let[r,n]of Object.entries(e)){if(!De(r))return null;let o=Ct(n);if(o===null)return null;t[r]=o}return t},wt=(e,t)=>{if(!(O(e)&&Se(e.wordsDigest)&&Array.isArray(e.reports)&&Array.isArray(e.deferred)))return null;let r=new Set(t.requestedIds),n=new Set,o=2**t.setCount-1,a=[];for(let s of e.reports){if(!O(s))return null;let{reportHubId:i,matchedSets:m}=s;if(!(typeof i=="number"&&f(i)&&r.has(i))||n.has(i)||(n.add(i),t.expectsMatchedSets?!(typeof m=="number"&&Number.isInteger(m)&&m>=0&&m<=o):m!==null))return null;let R=kt(s.fields);if(R===null)return null;a.push({reportHubId:i,matchedSets:m,fields:R})}if(a.length===0&&e.deferred.length>0)return null;let l=[];for(let s of e.deferred){if(!(typeof s=="number"&&f(s)&&r.has(s))||n.has(s))return null;n.add(s),l.push(s)}return{wordsDigest:e.wordsDigest,reports:a,deferred:l}};var Nt="Internal",Mt=e=>e.trim().toLowerCase();export{y as DAILY_REPORT_ACTION_FIELDS,Ke as DAILY_REPORT_ACTION_INTENTS,Rt as DAILY_REPORT_API_ENDPOINTS,ft as DAILY_REPORT_API_QUERY_PARAMS,ye as DAILY_REPORT_ATTACHMENT_THUMBNAIL_VARIANTS,E as DAILY_REPORT_CLIENT_TEMP_ID_PATTERN,Nt as DAILY_REPORT_INTERNAL_SOURCE_TYPE,xt as DAILY_REPORT_SEARCH_BATCHES_IN_FLIGHT,At as DAILY_REPORT_SEARCH_COMBINES,Le as DAILY_REPORT_SSE_CURSOR_PARAM,Pe as DAILY_REPORT_SSE_HEARTBEAT_MS,Oe as DAILY_REPORT_SSE_TERMINAL_EVENTS,ht as buildDailyReportAttachmentUrl,A as dailyReportDetailSchema,$e as dailyReportSseMessageSchema,Ve as encodeDailyReportActionCommand,Mt as foldDailyReportSourceTypeToken,ct as forEachIdsStreamRow,z as isDailyReportAttachmentThumbnailVariant,Je as normalizeBusinessDateKey,Qe as parseDailyReportActionResult,bt as parseDailyReportAttachmentQuery,wt as readDailyReportSearchMarksAnswer,dt as readIdsStreamChunkLine};
package/dist/server.d.mts CHANGED
@@ -78,7 +78,10 @@ type DailyReportVisibilityDimensions = {
78
78
  read: readonly string[];
79
79
  comment?: readonly string[];
80
80
  };
81
- type DailyReportVisibleSourceTypes = readonly string[] | DailyReportVisibilityDimensions | null | undefined;
81
+ type DailyReportVisibilityOptOut = {
82
+ readonly unrestricted: string;
83
+ };
84
+ type DailyReportVisibleSourceTypes = readonly string[] | DailyReportVisibilityDimensions | DailyReportVisibilityOptOut;
82
85
  type DailyReportVisibilityResolveReason = "initial" | "refresh";
83
86
  type DailyReportVisibilityResolveContext = {
84
87
  reason: DailyReportVisibilityResolveReason;
@@ -1888,7 +1891,6 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1888
1891
  }) => Promise<DailyReportIdsSource>;
1889
1892
  getDailyReportIdsFirstPageByExternalId: (scope: DailyReportViewerScope, externalId: string, limit: number) => Promise<DailyReportItem[]>;
1890
1893
  readSseStreamAnchor: () => Promise<string | null>;
1891
- getDailyReportsByBusinessDate: (scope: DailyReportViewerScope, businessDate: string, { forceRefresh, snapshot, ttlMsOverride }?: Omit<SqlResultCacheQueryOptions, "admission">) => Promise<DailyReportDetail[]>;
1892
1894
  getDailyReportsByBusinessDateByExternalId: (scope: DailyReportViewerScope, businessDate: string, externalId: string, { forceRefresh, snapshot, ttlMsOverride, admission }?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail[]>;
1893
1895
  getDailyReportDetailById: (scope: DailyReportViewerScope, reportHubId: number, userId: number, { forceRefresh, snapshot, ttlMsOverride, admission }?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail | null>;
1894
1896
  getDailyReportDetailByIdByExternalId: (scope: DailyReportViewerScope, reportHubId: number, externalId: string, options?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail | null>;
@@ -1913,23 +1915,23 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1913
1915
  setReadStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isRead: boolean, clientTempId: DailyReportClientTempId) => Promise<DailyReportUserStatusRow>;
1914
1916
  addComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, content: string, businessDate: string | null, clientTempId: DailyReportClientTempId) => Promise<DailyReportPostedComment>;
1915
1917
  deleteComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, commentId: number, businessDate: string | null, clientTempId: DailyReportClientTempId) => Promise<void>;
1916
- createDailyReport: (userId: number, businessDate: string, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail>;
1917
- updateDailyReport: (reportHubId: number, userId: number, data: {
1918
+ createDailyReport: (scope: DailyReportViewerScope, userId: number, businessDate: string, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail>;
1919
+ updateDailyReport: (scope: DailyReportViewerScope, reportHubId: number, userId: number, data: {
1918
1920
  title?: string;
1919
1921
  content?: string;
1920
1922
  }, clientTempId: DailyReportClientTempId) => Promise<void>;
1921
- publishDailyReport: (reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail | null>;
1922
- deleteDailyReport: (reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<void>;
1923
+ publishDailyReport: (scope: DailyReportViewerScope, reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail | null>;
1924
+ deleteDailyReport: (scope: DailyReportViewerScope, reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<void>;
1923
1925
  };
1924
1926
  type DailyReportHandlersConfig = {
1925
1927
  authenticate: DailyReportAuthenticate;
1926
- resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
1928
+ resolveVisibleSourceTypes: DailyReportResolveVisibleSourceTypes;
1927
1929
  service: DailyReportService;
1928
1930
  encodeUserId: DailyReportEncodeUserId;
1929
1931
  redis?: DailyReportRedisProvider;
1930
1932
  sseReader: DailyReportSseReaderPort;
1931
1933
  streamKey: string;
1932
- loginRedirectPath?: string;
1934
+ loginRedirectPath: string;
1933
1935
  enableDevCacheClear?: boolean;
1934
1936
  logger?: DailyReportLogger;
1935
1937
  };
@@ -2080,10 +2082,17 @@ declare const readSseStreamEntry: (raw: RedisStreamMessage, logger: DailyReportL
2080
2082
  readonly entry: StreamEntry;
2081
2083
  readonly json: unknown;
2082
2084
  };
2085
+ declare const DAILY_REPORT_VISIBILITY_MAX_CACHE_TTL_MS = 60000;
2086
+ type DailyReportVisibilityCacheConfig = {
2087
+ readonly ttlMs: number;
2088
+ readonly readViewerKey: (request: Request, context: DailyReportVisibilityResolveContext) => Promise<string | null>;
2089
+ readonly resolve: DailyReportResolveVisibleSourceTypes;
2090
+ };
2091
+ declare const createDailyReportVisibilityCache: (config: DailyReportVisibilityCacheConfig) => DailyReportResolveVisibleSourceTypes;
2083
2092
  type DailyReportServerConfig = Omit<DailyReportServiceConfig, "cache" | "epochs"> & {
2084
2093
  authenticate: DailyReportAuthenticate;
2085
- resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
2086
- loginRedirectPath?: string;
2094
+ resolveVisibleSourceTypes: DailyReportResolveVisibleSourceTypes;
2095
+ loginRedirectPath: string;
2087
2096
  enableDevCacheClear?: boolean;
2088
2097
  cacheDefaultTtlMs?: number;
2089
2098
  cacheMaxBuckets?: number;
@@ -2099,4 +2108,4 @@ type DailyReportServer = DailyReportHandlers & {
2099
2108
  knownSourceTypes: readonly string[];
2100
2109
  };
2101
2110
  declare function createDailyReportServer(config: DailyReportServerConfig): DailyReportServer;
2102
- 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 DailyReportAttachmentBytes, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentTable, type DailyReportAttachmentThumbnail, type AttachmentThumbnailDelivery as DailyReportAttachmentThumbnailDelivery, type DailyReportAttachmentThumbnailError, type DailyReportAttachmentThumbnailFailure, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportClientTempId, type DailyReportCommentTable, type DailyReportDb, type DeleteChain as DailyReportDbDeleteChain, type InsertChain as DailyReportDbInsertChain, type Rows as DailyReportDbRows, type SelectChain as DailyReportDbSelectChain, type UpdateChain as DailyReportDbUpdateChain, type DailyReportEncodeUserId, type EpochStore as DailyReportEpochStore, type ExternalReportFields as DailyReportExternalReportFields, type DailyReportExternalSource, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubTable, type DailyReportIdCodec, type DailyReportIdsSource, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportReadAttachment, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type RedisStreamMessage as DailyReportRedisStreamMessage, type DailyReportResolveUserId, type DailyReportResolveVisibleSourceTypes, type ResourceRouteArgs as DailyReportResourceRouteArgs, DailyReportSearchAlternative, type DailyReportSearchCommentTable, type DailyReportSearchConfig, type DailyReportSearchCriteria, type DailyReportSearchDocumentTable, DailyReportSearchFacets, type DailyReportSearchFilters, type DailyReportSearchNameFilter, type DailyReportSearchPlan, type DailyReportSearchReconcileOptions, type DailyReportSearchReconcileProgress, type DailyReportSearchReconcileSummary, type DailyReportSearchSet, type DailyReportSearchSourceTextReader, type DailyReportSearchSqlExecutor, type DailyReportSearchTables, type DailyReportSearchWord, type DailyReportServer, type DailyReportServerConfig, type DailyReportService, type DailyReportServiceConfig, type SharpHeaderLike as DailyReportSharpHeaderLike, type SharpLike as DailyReportSharpLike, type SharpPipelineLike as DailyReportSharpPipelineLike, type SqlResultCacheMissAdmission as DailyReportSqlResultCacheMissAdmission, type SqlResultCacheQueryOptions as DailyReportSqlResultCacheQueryOptions, type DailyReportSseEntryMessage, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportSseReaderPort, type StreamEntry as DailyReportSseStreamEntry, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, DailyReportViewerScope, type DailyReportVisibilityDimensions, type DailyReportVisibilityResolveContext, type DailyReportVisibilityResolveReason, type VisibleSourceTypeSet as DailyReportVisibleSourceTypeSet, type DailyReportVisibleSourceTypes, SqlResultCache, buildDailyReportSseStreamKey, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, defineDailyReportSearchSchema, isStreamIdLte, parseClientTempId, predictSharpThumbnailWorkingSetBytes, readSseStreamEntry as readDailyReportSseStreamEntry, transformJsonArray };
2111
+ 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, DAILY_REPORT_VISIBILITY_MAX_CACHE_TTL_MS, type DailyReportAttachmentBytes, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentTable, type DailyReportAttachmentThumbnail, type AttachmentThumbnailDelivery as DailyReportAttachmentThumbnailDelivery, type DailyReportAttachmentThumbnailError, type DailyReportAttachmentThumbnailFailure, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportClientTempId, type DailyReportCommentTable, type DailyReportDb, type DeleteChain as DailyReportDbDeleteChain, type InsertChain as DailyReportDbInsertChain, type Rows as DailyReportDbRows, type SelectChain as DailyReportDbSelectChain, type UpdateChain as DailyReportDbUpdateChain, type DailyReportEncodeUserId, type EpochStore as DailyReportEpochStore, type ExternalReportFields as DailyReportExternalReportFields, type DailyReportExternalSource, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubTable, type DailyReportIdCodec, type DailyReportIdsSource, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportReadAttachment, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type RedisStreamMessage as DailyReportRedisStreamMessage, type DailyReportResolveUserId, type DailyReportResolveVisibleSourceTypes, type ResourceRouteArgs as DailyReportResourceRouteArgs, DailyReportSearchAlternative, type DailyReportSearchCommentTable, type DailyReportSearchConfig, type DailyReportSearchCriteria, type DailyReportSearchDocumentTable, DailyReportSearchFacets, type DailyReportSearchFilters, type DailyReportSearchNameFilter, type DailyReportSearchPlan, type DailyReportSearchReconcileOptions, type DailyReportSearchReconcileProgress, type DailyReportSearchReconcileSummary, type DailyReportSearchSet, type DailyReportSearchSourceTextReader, type DailyReportSearchSqlExecutor, type DailyReportSearchTables, type DailyReportSearchWord, type DailyReportServer, type DailyReportServerConfig, type DailyReportService, type DailyReportServiceConfig, type SharpHeaderLike as DailyReportSharpHeaderLike, type SharpLike as DailyReportSharpLike, type SharpPipelineLike as DailyReportSharpPipelineLike, type SqlResultCacheMissAdmission as DailyReportSqlResultCacheMissAdmission, type SqlResultCacheQueryOptions as DailyReportSqlResultCacheQueryOptions, type DailyReportSseEntryMessage, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportSseReaderPort, type StreamEntry as DailyReportSseStreamEntry, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, DailyReportViewerScope, type DailyReportVisibilityCacheConfig, type DailyReportVisibilityDimensions, type DailyReportVisibilityOptOut, type DailyReportVisibilityResolveContext, type DailyReportVisibilityResolveReason, type VisibleSourceTypeSet as DailyReportVisibleSourceTypeSet, type DailyReportVisibleSourceTypes, SqlResultCache, buildDailyReportSseStreamKey, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createDailyReportVisibilityCache, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, defineDailyReportSearchSchema, isStreamIdLte, parseClientTempId, predictSharpThumbnailWorkingSetBytes, readSseStreamEntry as readDailyReportSseStreamEntry, transformJsonArray };
package/dist/server.d.ts CHANGED
@@ -78,7 +78,10 @@ type DailyReportVisibilityDimensions = {
78
78
  read: readonly string[];
79
79
  comment?: readonly string[];
80
80
  };
81
- type DailyReportVisibleSourceTypes = readonly string[] | DailyReportVisibilityDimensions | null | undefined;
81
+ type DailyReportVisibilityOptOut = {
82
+ readonly unrestricted: string;
83
+ };
84
+ type DailyReportVisibleSourceTypes = readonly string[] | DailyReportVisibilityDimensions | DailyReportVisibilityOptOut;
82
85
  type DailyReportVisibilityResolveReason = "initial" | "refresh";
83
86
  type DailyReportVisibilityResolveContext = {
84
87
  reason: DailyReportVisibilityResolveReason;
@@ -1888,7 +1891,6 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1888
1891
  }) => Promise<DailyReportIdsSource>;
1889
1892
  getDailyReportIdsFirstPageByExternalId: (scope: DailyReportViewerScope, externalId: string, limit: number) => Promise<DailyReportItem[]>;
1890
1893
  readSseStreamAnchor: () => Promise<string | null>;
1891
- getDailyReportsByBusinessDate: (scope: DailyReportViewerScope, businessDate: string, { forceRefresh, snapshot, ttlMsOverride }?: Omit<SqlResultCacheQueryOptions, "admission">) => Promise<DailyReportDetail[]>;
1892
1894
  getDailyReportsByBusinessDateByExternalId: (scope: DailyReportViewerScope, businessDate: string, externalId: string, { forceRefresh, snapshot, ttlMsOverride, admission }?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail[]>;
1893
1895
  getDailyReportDetailById: (scope: DailyReportViewerScope, reportHubId: number, userId: number, { forceRefresh, snapshot, ttlMsOverride, admission }?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail | null>;
1894
1896
  getDailyReportDetailByIdByExternalId: (scope: DailyReportViewerScope, reportHubId: number, externalId: string, options?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail | null>;
@@ -1913,23 +1915,23 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1913
1915
  setReadStatus: (scope: DailyReportViewerScope, userId: number, reportHubId: number, businessDate: string | null, isRead: boolean, clientTempId: DailyReportClientTempId) => Promise<DailyReportUserStatusRow>;
1914
1916
  addComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, content: string, businessDate: string | null, clientTempId: DailyReportClientTempId) => Promise<DailyReportPostedComment>;
1915
1917
  deleteComment: (scope: DailyReportViewerScope, userId: number, reportHubId: number, commentId: number, businessDate: string | null, clientTempId: DailyReportClientTempId) => Promise<void>;
1916
- createDailyReport: (userId: number, businessDate: string, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail>;
1917
- updateDailyReport: (reportHubId: number, userId: number, data: {
1918
+ createDailyReport: (scope: DailyReportViewerScope, userId: number, businessDate: string, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail>;
1919
+ updateDailyReport: (scope: DailyReportViewerScope, reportHubId: number, userId: number, data: {
1918
1920
  title?: string;
1919
1921
  content?: string;
1920
1922
  }, clientTempId: DailyReportClientTempId) => Promise<void>;
1921
- publishDailyReport: (reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail | null>;
1922
- deleteDailyReport: (reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<void>;
1923
+ publishDailyReport: (scope: DailyReportViewerScope, reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<DailyReportDetail | null>;
1924
+ deleteDailyReport: (scope: DailyReportViewerScope, reportHubId: number, userId: number, clientTempId: DailyReportClientTempId) => Promise<void>;
1923
1925
  };
1924
1926
  type DailyReportHandlersConfig = {
1925
1927
  authenticate: DailyReportAuthenticate;
1926
- resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
1928
+ resolveVisibleSourceTypes: DailyReportResolveVisibleSourceTypes;
1927
1929
  service: DailyReportService;
1928
1930
  encodeUserId: DailyReportEncodeUserId;
1929
1931
  redis?: DailyReportRedisProvider;
1930
1932
  sseReader: DailyReportSseReaderPort;
1931
1933
  streamKey: string;
1932
- loginRedirectPath?: string;
1934
+ loginRedirectPath: string;
1933
1935
  enableDevCacheClear?: boolean;
1934
1936
  logger?: DailyReportLogger;
1935
1937
  };
@@ -2080,10 +2082,17 @@ declare const readSseStreamEntry: (raw: RedisStreamMessage, logger: DailyReportL
2080
2082
  readonly entry: StreamEntry;
2081
2083
  readonly json: unknown;
2082
2084
  };
2085
+ declare const DAILY_REPORT_VISIBILITY_MAX_CACHE_TTL_MS = 60000;
2086
+ type DailyReportVisibilityCacheConfig = {
2087
+ readonly ttlMs: number;
2088
+ readonly readViewerKey: (request: Request, context: DailyReportVisibilityResolveContext) => Promise<string | null>;
2089
+ readonly resolve: DailyReportResolveVisibleSourceTypes;
2090
+ };
2091
+ declare const createDailyReportVisibilityCache: (config: DailyReportVisibilityCacheConfig) => DailyReportResolveVisibleSourceTypes;
2083
2092
  type DailyReportServerConfig = Omit<DailyReportServiceConfig, "cache" | "epochs"> & {
2084
2093
  authenticate: DailyReportAuthenticate;
2085
- resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
2086
- loginRedirectPath?: string;
2094
+ resolveVisibleSourceTypes: DailyReportResolveVisibleSourceTypes;
2095
+ loginRedirectPath: string;
2087
2096
  enableDevCacheClear?: boolean;
2088
2097
  cacheDefaultTtlMs?: number;
2089
2098
  cacheMaxBuckets?: number;
@@ -2099,4 +2108,4 @@ type DailyReportServer = DailyReportHandlers & {
2099
2108
  knownSourceTypes: readonly string[];
2100
2109
  };
2101
2110
  declare function createDailyReportServer(config: DailyReportServerConfig): DailyReportServer;
2102
- 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 DailyReportAttachmentBytes, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentTable, type DailyReportAttachmentThumbnail, type AttachmentThumbnailDelivery as DailyReportAttachmentThumbnailDelivery, type DailyReportAttachmentThumbnailError, type DailyReportAttachmentThumbnailFailure, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportClientTempId, type DailyReportCommentTable, type DailyReportDb, type DeleteChain as DailyReportDbDeleteChain, type InsertChain as DailyReportDbInsertChain, type Rows as DailyReportDbRows, type SelectChain as DailyReportDbSelectChain, type UpdateChain as DailyReportDbUpdateChain, type DailyReportEncodeUserId, type EpochStore as DailyReportEpochStore, type ExternalReportFields as DailyReportExternalReportFields, type DailyReportExternalSource, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubTable, type DailyReportIdCodec, type DailyReportIdsSource, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportReadAttachment, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type RedisStreamMessage as DailyReportRedisStreamMessage, type DailyReportResolveUserId, type DailyReportResolveVisibleSourceTypes, type ResourceRouteArgs as DailyReportResourceRouteArgs, DailyReportSearchAlternative, type DailyReportSearchCommentTable, type DailyReportSearchConfig, type DailyReportSearchCriteria, type DailyReportSearchDocumentTable, DailyReportSearchFacets, type DailyReportSearchFilters, type DailyReportSearchNameFilter, type DailyReportSearchPlan, type DailyReportSearchReconcileOptions, type DailyReportSearchReconcileProgress, type DailyReportSearchReconcileSummary, type DailyReportSearchSet, type DailyReportSearchSourceTextReader, type DailyReportSearchSqlExecutor, type DailyReportSearchTables, type DailyReportSearchWord, type DailyReportServer, type DailyReportServerConfig, type DailyReportService, type DailyReportServiceConfig, type SharpHeaderLike as DailyReportSharpHeaderLike, type SharpLike as DailyReportSharpLike, type SharpPipelineLike as DailyReportSharpPipelineLike, type SqlResultCacheMissAdmission as DailyReportSqlResultCacheMissAdmission, type SqlResultCacheQueryOptions as DailyReportSqlResultCacheQueryOptions, type DailyReportSseEntryMessage, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportSseReaderPort, type StreamEntry as DailyReportSseStreamEntry, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, DailyReportViewerScope, type DailyReportVisibilityDimensions, type DailyReportVisibilityResolveContext, type DailyReportVisibilityResolveReason, type VisibleSourceTypeSet as DailyReportVisibleSourceTypeSet, type DailyReportVisibleSourceTypes, SqlResultCache, buildDailyReportSseStreamKey, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, defineDailyReportSearchSchema, isStreamIdLte, parseClientTempId, predictSharpThumbnailWorkingSetBytes, readSseStreamEntry as readDailyReportSseStreamEntry, transformJsonArray };
2111
+ 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, DAILY_REPORT_VISIBILITY_MAX_CACHE_TTL_MS, type DailyReportAttachmentBytes, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentTable, type DailyReportAttachmentThumbnail, type AttachmentThumbnailDelivery as DailyReportAttachmentThumbnailDelivery, type DailyReportAttachmentThumbnailError, type DailyReportAttachmentThumbnailFailure, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportClientTempId, type DailyReportCommentTable, type DailyReportDb, type DeleteChain as DailyReportDbDeleteChain, type InsertChain as DailyReportDbInsertChain, type Rows as DailyReportDbRows, type SelectChain as DailyReportDbSelectChain, type UpdateChain as DailyReportDbUpdateChain, type DailyReportEncodeUserId, type EpochStore as DailyReportEpochStore, type ExternalReportFields as DailyReportExternalReportFields, type DailyReportExternalSource, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubTable, type DailyReportIdCodec, type DailyReportIdsSource, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportReadAttachment, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type RedisStreamMessage as DailyReportRedisStreamMessage, type DailyReportResolveUserId, type DailyReportResolveVisibleSourceTypes, type ResourceRouteArgs as DailyReportResourceRouteArgs, DailyReportSearchAlternative, type DailyReportSearchCommentTable, type DailyReportSearchConfig, type DailyReportSearchCriteria, type DailyReportSearchDocumentTable, DailyReportSearchFacets, type DailyReportSearchFilters, type DailyReportSearchNameFilter, type DailyReportSearchPlan, type DailyReportSearchReconcileOptions, type DailyReportSearchReconcileProgress, type DailyReportSearchReconcileSummary, type DailyReportSearchSet, type DailyReportSearchSourceTextReader, type DailyReportSearchSqlExecutor, type DailyReportSearchTables, type DailyReportSearchWord, type DailyReportServer, type DailyReportServerConfig, type DailyReportService, type DailyReportServiceConfig, type SharpHeaderLike as DailyReportSharpHeaderLike, type SharpLike as DailyReportSharpLike, type SharpPipelineLike as DailyReportSharpPipelineLike, type SqlResultCacheMissAdmission as DailyReportSqlResultCacheMissAdmission, type SqlResultCacheQueryOptions as DailyReportSqlResultCacheQueryOptions, type DailyReportSseEntryMessage, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportSseReaderPort, type StreamEntry as DailyReportSseStreamEntry, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, DailyReportViewerScope, type DailyReportVisibilityCacheConfig, type DailyReportVisibilityDimensions, type DailyReportVisibilityOptOut, type DailyReportVisibilityResolveContext, type DailyReportVisibilityResolveReason, type VisibleSourceTypeSet as DailyReportVisibleSourceTypeSet, type DailyReportVisibleSourceTypes, SqlResultCache, buildDailyReportSseStreamKey, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createDailyReportVisibilityCache, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, defineDailyReportSearchSchema, isStreamIdLte, parseClientTempId, predictSharpThumbnailWorkingSetBytes, readSseStreamEntry as readDailyReportSseStreamEntry, transformJsonArray };