@aiquants/daily-report 0.22.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +222 -0
- package/README.md +791 -113
- package/dist/client.d.mts +35 -149
- package/dist/client.d.ts +35 -149
- package/dist/client.js +4 -6
- package/dist/client.mjs +4 -6
- package/dist/{ids-stream-BnM6L-Sk.d.ts → ids-stream-BR5RSj5u.d.ts} +157 -148
- package/dist/{ids-stream-DCuiaTit.d.mts → ids-stream-DvB2h1dj.d.mts} +157 -148
- package/dist/index.d.mts +29 -9
- package/dist/index.d.ts +29 -9
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/server.d.mts +153 -66
- package/dist/server.d.ts +153 -66
- package/dist/server.js +5 -4
- package/dist/server.mjs +5 -4
- package/dist/styles/daily-report.standalone.css +1 -1
- package/dist/{types-CqgYQgbH.d.mts → types-DkERw8NE.d.mts} +2 -1
- package/dist/{types-CqgYQgbH.d.ts → types-DkERw8NE.d.ts} +2 -1
- package/package.json +31 -14
- package/dist/logger-D3krZrNK.d.mts +0 -15
- package/dist/logger-D3krZrNK.d.ts +0 -15
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as DailyReportInterviewer, d as DailyReportExternalComment, D as DailyReportItem, b as DailyReportDetail, c as DailyReportAttachmentSummary, g as DailyReportPostedComment } from "./types-DkERw8NE.js";
|
|
2
|
+
import { TransactionRetryOptions } from "@aiquants/mssql";
|
|
2
3
|
import * as drizzle_orm_mssql_core from "drizzle-orm/mssql-core";
|
|
3
4
|
import { AnyMsSqlColumn } from "drizzle-orm/mssql-core";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
interface DailyReportLogger {
|
|
6
|
+
debug(message?: unknown, ...optionalParams: unknown[]): void;
|
|
7
|
+
info(message?: unknown, ...optionalParams: unknown[]): void;
|
|
8
|
+
warn(message?: unknown, ...optionalParams: unknown[]): void;
|
|
9
|
+
error(message?: unknown, ...optionalParams: unknown[]): void;
|
|
10
|
+
}
|
|
11
|
+
declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES: readonly [
|
|
12
|
+
"image/webp",
|
|
13
|
+
"image/jpeg",
|
|
14
|
+
"image/png"
|
|
15
|
+
];
|
|
16
|
+
declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES: number;
|
|
7
17
|
type RedisStreamMessage = {
|
|
8
18
|
id: string;
|
|
9
19
|
message: Record<string, string>;
|
|
@@ -89,7 +99,29 @@ type DailyReportReadAttachment = (filePath: string, options: {
|
|
|
89
99
|
maxBytes: number;
|
|
90
100
|
head: boolean;
|
|
91
101
|
principal?: string;
|
|
102
|
+
signal: AbortSignal;
|
|
92
103
|
}) => Promise<DailyReportAttachmentBytes | DailyReportAttachmentError>;
|
|
104
|
+
type DailyReportAttachmentThumbnailSourceFormat = "png" | "jpeg" | "gif" | "webp";
|
|
105
|
+
type DailyReportAttachmentThumbnailFailure = "unsupported" | "failed";
|
|
106
|
+
type DailyReportAttachmentThumbnailOutputMediaType = (typeof DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES)[number];
|
|
107
|
+
type DailyReportAttachmentThumbnail = {
|
|
108
|
+
ok: true;
|
|
109
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
110
|
+
contentType: DailyReportAttachmentThumbnailOutputMediaType;
|
|
111
|
+
};
|
|
112
|
+
type DailyReportAttachmentThumbnailError = {
|
|
113
|
+
ok: false;
|
|
114
|
+
reason: DailyReportAttachmentThumbnailFailure;
|
|
115
|
+
};
|
|
116
|
+
type DailyReportAttachmentThumbnailRenderer = {
|
|
117
|
+
readonly id: string;
|
|
118
|
+
readonly render: (source: Uint8Array<ArrayBuffer>, options: {
|
|
119
|
+
format: DailyReportAttachmentThumbnailSourceFormat;
|
|
120
|
+
maxWidth: number;
|
|
121
|
+
maxHeight: number;
|
|
122
|
+
signal: AbortSignal;
|
|
123
|
+
}) => Promise<DailyReportAttachmentThumbnail | DailyReportAttachmentThumbnailError>;
|
|
124
|
+
};
|
|
93
125
|
type SqlResultCacheQueryOptions = {
|
|
94
126
|
forceRefresh?: boolean;
|
|
95
127
|
snapshot?: boolean;
|
|
@@ -1392,11 +1424,6 @@ declare function defineDailyReportSchema<S extends string>(schemaName: S, opts:
|
|
|
1392
1424
|
}>;
|
|
1393
1425
|
};
|
|
1394
1426
|
type VisibleSourceTypeSet = ReadonlySet<string> | null;
|
|
1395
|
-
declare function normalizeVisibleSourceTypes(raw: readonly string[]): ReadonlySet<string>;
|
|
1396
|
-
declare function normalizeVisibleSourceTypes(raw: readonly string[] | null | undefined): VisibleSourceTypeSet;
|
|
1397
|
-
declare function isSourceTypeVisible(set: VisibleSourceTypeSet, sourceType: string | null | undefined): boolean;
|
|
1398
|
-
declare function deniesEverySourceType(set: VisibleSourceTypeSet): boolean;
|
|
1399
|
-
declare function buildVisibleSourceTypeCondition(sourceTypeColumn: AnyMsSqlColumn, set: VisibleSourceTypeSet): SQL | undefined;
|
|
1400
1427
|
declare class DailyReportViewerScope {
|
|
1401
1428
|
#private;
|
|
1402
1429
|
private constructor();
|
|
@@ -1405,8 +1432,6 @@ declare class DailyReportViewerScope {
|
|
|
1405
1432
|
static restrictTo(input: readonly string[] | DailyReportVisibilityDimensions): DailyReportViewerScope;
|
|
1406
1433
|
static unrestricted(auditReason: string): DailyReportViewerScope;
|
|
1407
1434
|
}
|
|
1408
|
-
declare function computeViewerScopeDigest(scope: DailyReportViewerScope): string;
|
|
1409
|
-
declare function computeSourceTypeDigest(set: VisibleSourceTypeSet): string;
|
|
1410
1435
|
type DailyReportHubRow = {
|
|
1411
1436
|
id: number;
|
|
1412
1437
|
sourceType: string;
|
|
@@ -1442,16 +1467,6 @@ type DailyReportUserStatusRow = {
|
|
|
1442
1467
|
updatedAt: Date | string;
|
|
1443
1468
|
updatedBy: string;
|
|
1444
1469
|
};
|
|
1445
|
-
type DailyReportCommentRow = {
|
|
1446
|
-
id: number;
|
|
1447
|
-
hubId: number;
|
|
1448
|
-
userId: number;
|
|
1449
|
-
body: string;
|
|
1450
|
-
createdAt: Date | string;
|
|
1451
|
-
createdBy: string;
|
|
1452
|
-
updatedAt: Date | string;
|
|
1453
|
-
updatedBy: string;
|
|
1454
|
-
};
|
|
1455
1470
|
type Rows<T> = PromiseLike<T[]>;
|
|
1456
1471
|
interface SelectChain<T> extends Rows<T> {
|
|
1457
1472
|
from(t: unknown): SelectChain<T>;
|
|
@@ -1504,18 +1519,26 @@ type DailyReportServiceConfig = {
|
|
|
1504
1519
|
businessDateTtlMs?: number;
|
|
1505
1520
|
disableUserIdCache?: boolean;
|
|
1506
1521
|
attachmentIdCodec?: DailyReportIdCodec;
|
|
1522
|
+
readAttachment?: DailyReportReadAttachment;
|
|
1523
|
+
attachmentThumbnailRenderer?: DailyReportAttachmentThumbnailRenderer;
|
|
1524
|
+
attachmentMaxBytes?: number;
|
|
1507
1525
|
logger?: DailyReportLogger;
|
|
1508
1526
|
};
|
|
1527
|
+
type DailyReportAttachmentDelivery = {
|
|
1528
|
+
readonly idCodec: DailyReportIdCodec | undefined;
|
|
1529
|
+
readonly readAttachment: DailyReportReadAttachment | undefined;
|
|
1530
|
+
readonly thumbnailRenderer: DailyReportAttachmentThumbnailRenderer | undefined;
|
|
1531
|
+
readonly maxBytes: number;
|
|
1532
|
+
};
|
|
1509
1533
|
type DailyReportService = ReturnType<typeof createDailyReportService>;
|
|
1510
1534
|
type DailyReportIdsSource = {
|
|
1511
1535
|
readonly items: DailyReportItem[];
|
|
1512
1536
|
readonly streamAnchor: string | null;
|
|
1513
1537
|
};
|
|
1514
|
-
type DatePattern = "YYYY-MM-DD HH:mm:ss" | "YYYY-MM-DD";
|
|
1515
|
-
declare const formatDateValue: (value: Date | string | null | undefined, pattern: DatePattern) => string | null;
|
|
1516
1538
|
declare function createDailyReportService(config: DailyReportServiceConfig): {
|
|
1517
1539
|
streamKey: string;
|
|
1518
1540
|
streamMaxLen: number;
|
|
1541
|
+
attachmentDelivery: DailyReportAttachmentDelivery;
|
|
1519
1542
|
clearCache: () => Promise<void>;
|
|
1520
1543
|
invalidateHubReadCaches: (hubIds: readonly number[], businessDates: readonly string[]) => Promise<void>;
|
|
1521
1544
|
getUserIdByExternalId: (externalId: string) => Promise<number | null>;
|
|
@@ -1567,59 +1590,37 @@ type DailyReportSseReaderConfig = {
|
|
|
1567
1590
|
};
|
|
1568
1591
|
declare class DailyReportSseReader {
|
|
1569
1592
|
private readonly config;
|
|
1570
|
-
private
|
|
1571
|
-
private _state;
|
|
1572
|
-
private _refCount;
|
|
1593
|
+
private _source;
|
|
1573
1594
|
private _lastId;
|
|
1574
|
-
private
|
|
1595
|
+
private _positioning;
|
|
1596
|
+
private _generation;
|
|
1575
1597
|
private readonly _logger;
|
|
1576
1598
|
constructor(config: DailyReportSseReaderConfig);
|
|
1577
|
-
|
|
1599
|
+
ready(): Promise<void>;
|
|
1600
|
+
subscribe(onEntry: (entry: StreamEntry) => void, onError: (err: Error) => void): () => void;
|
|
1578
1601
|
destroy(): Promise<void>;
|
|
1579
|
-
private
|
|
1580
|
-
private
|
|
1581
|
-
private
|
|
1602
|
+
private _readTail;
|
|
1603
|
+
private _createSource;
|
|
1604
|
+
private _start;
|
|
1605
|
+
private _readLoop;
|
|
1606
|
+
private _invalidateCaches;
|
|
1582
1607
|
}
|
|
1583
|
-
type AuthzResourceItem = {
|
|
1584
|
-
resourceKey: string;
|
|
1585
|
-
name: string;
|
|
1586
|
-
description?: string | null;
|
|
1587
|
-
};
|
|
1588
|
-
type DailyReportSourceTypeInput = {
|
|
1589
|
-
key: string;
|
|
1590
|
-
name: string;
|
|
1591
|
-
description?: string | null;
|
|
1592
|
-
includeCommentResource?: boolean;
|
|
1593
|
-
};
|
|
1594
|
-
declare function defineDailyReportAuthzResources(sources?: DailyReportSourceTypeInput[]): AuthzResourceItem[];
|
|
1595
|
-
declare function seedDailyReportAuthzResources(db: unknown, authzTables: {
|
|
1596
|
-
TMResource: unknown;
|
|
1597
|
-
}, opts: {
|
|
1598
|
-
appKey: string;
|
|
1599
|
-
actor?: string;
|
|
1600
|
-
sources?: DailyReportSourceTypeInput[];
|
|
1601
|
-
resources?: AuthzResourceItem[];
|
|
1602
|
-
}): Promise<void>;
|
|
1603
|
-
declare const generateETag: (data: unknown) => string;
|
|
1604
1608
|
type LoaderArgs = {
|
|
1605
1609
|
request: Request;
|
|
1606
1610
|
params: Record<string, string | undefined>;
|
|
1607
1611
|
};
|
|
1608
1612
|
declare const DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS = 60000;
|
|
1609
1613
|
declare const DAILY_REPORT_SSE_CATCH_UP_BATCH = 1000;
|
|
1610
|
-
declare const sanitizeMediaType: (value: string | null | undefined) => string | null;
|
|
1611
|
-
declare const encodeRfc8187: (name: string) => string;
|
|
1612
|
-
declare const asciiFallbackFileName: (name: string) => string;
|
|
1613
1614
|
type DailyReportHandlersConfig = {
|
|
1614
1615
|
authenticate: DailyReportAuthenticate;
|
|
1615
1616
|
resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
|
|
1616
1617
|
service: DailyReportService;
|
|
1617
1618
|
encodeUserId: DailyReportEncodeUserId;
|
|
1618
|
-
attachmentIdCodec?: DailyReportIdCodec;
|
|
1619
|
-
readAttachment?: DailyReportReadAttachment;
|
|
1620
|
-
attachmentMaxBytes?: number;
|
|
1621
1619
|
attachmentRateLimitPerMinute?: number;
|
|
1622
1620
|
attachmentConcurrency?: number;
|
|
1621
|
+
attachmentThumbnailRateLimitPerMinute?: number;
|
|
1622
|
+
attachmentThumbnailConcurrency?: number;
|
|
1623
|
+
attachmentThumbnailCacheBytes?: number;
|
|
1623
1624
|
redis?: DailyReportRedisProvider;
|
|
1624
1625
|
sseReader: DailyReportSseReader;
|
|
1625
1626
|
streamKey: string;
|
|
@@ -1647,17 +1648,105 @@ declare function createDailyReportHandlers(config: DailyReportHandlersConfig): {
|
|
|
1647
1648
|
loader: ({ request, params }: LoaderArgs) => Promise<Response>;
|
|
1648
1649
|
};
|
|
1649
1650
|
attachment: {
|
|
1650
|
-
loader: (
|
|
1651
|
+
loader: (args: AttachmentLoaderArgs) => Promise<Response>;
|
|
1651
1652
|
};
|
|
1652
1653
|
};
|
|
1654
|
+
type AttachmentLoaderArgs = {
|
|
1655
|
+
request: Request;
|
|
1656
|
+
params: Record<string, string | undefined>;
|
|
1657
|
+
};
|
|
1658
|
+
declare const generateETag: (data: unknown) => string;
|
|
1653
1659
|
declare const jsonResponseWithETag: (request: Request, cookie: string | null, payload: Record<string, unknown>, status?: number, logger?: DailyReportLogger) => Response;
|
|
1660
|
+
type SharpHeaderLike = {
|
|
1661
|
+
width: number;
|
|
1662
|
+
height: number;
|
|
1663
|
+
channels: number;
|
|
1664
|
+
depth: string;
|
|
1665
|
+
};
|
|
1666
|
+
type SharpPipelineLike = {
|
|
1667
|
+
metadata: () => Promise<SharpHeaderLike>;
|
|
1668
|
+
rotate: () => SharpPipelineLike;
|
|
1669
|
+
resize: (options: {
|
|
1670
|
+
width: number;
|
|
1671
|
+
height: number;
|
|
1672
|
+
fit: "inside";
|
|
1673
|
+
withoutEnlargement: boolean;
|
|
1674
|
+
}) => SharpPipelineLike;
|
|
1675
|
+
flatten: (options: {
|
|
1676
|
+
background: string;
|
|
1677
|
+
}) => SharpPipelineLike;
|
|
1678
|
+
webp: (options: {
|
|
1679
|
+
quality: number;
|
|
1680
|
+
effort: number;
|
|
1681
|
+
}) => SharpPipelineLike;
|
|
1682
|
+
toBuffer: () => Promise<Uint8Array>;
|
|
1683
|
+
};
|
|
1684
|
+
type SharpLike = {
|
|
1685
|
+
(input: Uint8Array, options: {
|
|
1686
|
+
limitInputPixels: number;
|
|
1687
|
+
animated: boolean;
|
|
1688
|
+
}): SharpPipelineLike;
|
|
1689
|
+
readonly versions: {
|
|
1690
|
+
readonly sharp: string;
|
|
1691
|
+
readonly vips: string;
|
|
1692
|
+
};
|
|
1693
|
+
cache: (enabled: boolean) => unknown;
|
|
1694
|
+
concurrency: (threads: number) => number;
|
|
1695
|
+
block: (options: {
|
|
1696
|
+
operation: string[];
|
|
1697
|
+
}) => void;
|
|
1698
|
+
unblock: (options: {
|
|
1699
|
+
operation: string[];
|
|
1700
|
+
}) => void;
|
|
1701
|
+
};
|
|
1702
|
+
declare const DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES = 200000000;
|
|
1703
|
+
declare const DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL: Readonly<{
|
|
1704
|
+
fixedBytes: number;
|
|
1705
|
+
pipelineRows: 2048;
|
|
1706
|
+
wholeImageBuffer: Readonly<{
|
|
1707
|
+
"jpeg-single-scan": Readonly<{
|
|
1708
|
+
kind: "none";
|
|
1709
|
+
}>;
|
|
1710
|
+
"jpeg-multi-scan": Readonly<{
|
|
1711
|
+
kind: "jpeg-coefficients";
|
|
1712
|
+
}>;
|
|
1713
|
+
png: Readonly<{
|
|
1714
|
+
kind: "none";
|
|
1715
|
+
}>;
|
|
1716
|
+
"png-interlaced": Readonly<{
|
|
1717
|
+
kind: "decoded-raster";
|
|
1718
|
+
}>;
|
|
1719
|
+
gif: Readonly<{
|
|
1720
|
+
kind: "canvas";
|
|
1721
|
+
bytesPerPixel: 4;
|
|
1722
|
+
}>;
|
|
1723
|
+
"webp-lossy": Readonly<{
|
|
1724
|
+
kind: "none";
|
|
1725
|
+
}>;
|
|
1726
|
+
"webp-lossy-alpha": Readonly<{
|
|
1727
|
+
kind: "canvas";
|
|
1728
|
+
bytesPerPixel: 5;
|
|
1729
|
+
}>;
|
|
1730
|
+
"webp-lossless": Readonly<{
|
|
1731
|
+
kind: "canvas";
|
|
1732
|
+
bytesPerPixel: 4;
|
|
1733
|
+
}>;
|
|
1734
|
+
"webp-animated": Readonly<{
|
|
1735
|
+
kind: "canvas";
|
|
1736
|
+
bytesPerPixel: 9;
|
|
1737
|
+
}>;
|
|
1738
|
+
}>;
|
|
1739
|
+
}>;
|
|
1740
|
+
declare const predictSharpThumbnailWorkingSetBytes: (source: Uint8Array, format: DailyReportAttachmentThumbnailSourceFormat, header: SharpHeaderLike) => number | null;
|
|
1741
|
+
declare const createSharpThumbnailRenderer: (sharp: SharpLike) => DailyReportAttachmentThumbnailRenderer;
|
|
1654
1742
|
type DailyReportServerConfig = Omit<DailyReportServiceConfig, "cache" | "epochs"> & {
|
|
1655
1743
|
authenticate: DailyReportAuthenticate;
|
|
1656
1744
|
resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
|
|
1657
|
-
readAttachment?: DailyReportReadAttachment;
|
|
1658
|
-
attachmentMaxBytes?: number;
|
|
1659
1745
|
attachmentRateLimitPerMinute?: number;
|
|
1660
1746
|
attachmentConcurrency?: number;
|
|
1747
|
+
attachmentThumbnailRateLimitPerMinute?: number;
|
|
1748
|
+
attachmentThumbnailConcurrency?: number;
|
|
1749
|
+
attachmentThumbnailCacheBytes?: number;
|
|
1661
1750
|
loginRedirectPath?: string;
|
|
1662
1751
|
enableDevCacheClear?: boolean;
|
|
1663
1752
|
cacheDefaultTtlMs?: number;
|
|
@@ -1695,14 +1784,12 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
|
|
|
1695
1784
|
}) => Promise<Response>;
|
|
1696
1785
|
};
|
|
1697
1786
|
attachment: {
|
|
1698
|
-
loader: (
|
|
1699
|
-
request: Request;
|
|
1700
|
-
params: Record<string, string | undefined>;
|
|
1701
|
-
}) => Promise<Response>;
|
|
1787
|
+
loader: (args: AttachmentLoaderArgs) => Promise<Response>;
|
|
1702
1788
|
};
|
|
1703
1789
|
service: {
|
|
1704
1790
|
streamKey: string;
|
|
1705
1791
|
streamMaxLen: number;
|
|
1792
|
+
attachmentDelivery: DailyReportAttachmentDelivery;
|
|
1706
1793
|
clearCache: () => Promise<void>;
|
|
1707
1794
|
invalidateHubReadCaches: (hubIds: readonly number[], businessDates: readonly string[]) => Promise<void>;
|
|
1708
1795
|
getUserIdByExternalId: (externalId: string) => Promise<number | null>;
|
|
@@ -1750,4 +1837,4 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
|
|
|
1750
1837
|
streamKey: string;
|
|
1751
1838
|
knownSourceTypes: readonly string[];
|
|
1752
1839
|
};
|
|
1753
|
-
export {
|
|
1840
|
+
export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES, DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES, DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentThumbnail, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportDb, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, predictSharpThumbnailWorkingSetBytes, transformJsonArray };
|