@aiquants/daily-report 0.22.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +190 -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 +143 -58
- package/dist/server.d.ts +143 -58
- 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>;
|
|
@@ -1580,46 +1603,22 @@ declare class DailyReportSseReader {
|
|
|
1580
1603
|
private _stopLoop;
|
|
1581
1604
|
private _emitError;
|
|
1582
1605
|
}
|
|
1583
|
-
type AuthzResourceItem = {
|
|
1584
|
-
resourceKey: string;
|
|
1585
|
-
name: string;
|
|
1586
|
-
description?: string | null;
|
|
1587
|
-
};
|
|
1588
|
-
type DailyReportSourceTypeInput = {
|
|
1589
|
-
key: string;
|
|
1590
|
-
name: string;
|
|
1591
|
-
description?: string | null;
|
|
1592
|
-
includeCommentResource?: boolean;
|
|
1593
|
-
};
|
|
1594
|
-
declare function defineDailyReportAuthzResources(sources?: DailyReportSourceTypeInput[]): AuthzResourceItem[];
|
|
1595
|
-
declare function seedDailyReportAuthzResources(db: unknown, authzTables: {
|
|
1596
|
-
TMResource: unknown;
|
|
1597
|
-
}, opts: {
|
|
1598
|
-
appKey: string;
|
|
1599
|
-
actor?: string;
|
|
1600
|
-
sources?: DailyReportSourceTypeInput[];
|
|
1601
|
-
resources?: AuthzResourceItem[];
|
|
1602
|
-
}): Promise<void>;
|
|
1603
|
-
declare const generateETag: (data: unknown) => string;
|
|
1604
1606
|
type LoaderArgs = {
|
|
1605
1607
|
request: Request;
|
|
1606
1608
|
params: Record<string, string | undefined>;
|
|
1607
1609
|
};
|
|
1608
1610
|
declare const DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS = 60000;
|
|
1609
1611
|
declare const DAILY_REPORT_SSE_CATCH_UP_BATCH = 1000;
|
|
1610
|
-
declare const sanitizeMediaType: (value: string | null | undefined) => string | null;
|
|
1611
|
-
declare const encodeRfc8187: (name: string) => string;
|
|
1612
|
-
declare const asciiFallbackFileName: (name: string) => string;
|
|
1613
1612
|
type DailyReportHandlersConfig = {
|
|
1614
1613
|
authenticate: DailyReportAuthenticate;
|
|
1615
1614
|
resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
|
|
1616
1615
|
service: DailyReportService;
|
|
1617
1616
|
encodeUserId: DailyReportEncodeUserId;
|
|
1618
|
-
attachmentIdCodec?: DailyReportIdCodec;
|
|
1619
|
-
readAttachment?: DailyReportReadAttachment;
|
|
1620
|
-
attachmentMaxBytes?: number;
|
|
1621
1617
|
attachmentRateLimitPerMinute?: number;
|
|
1622
1618
|
attachmentConcurrency?: number;
|
|
1619
|
+
attachmentThumbnailRateLimitPerMinute?: number;
|
|
1620
|
+
attachmentThumbnailConcurrency?: number;
|
|
1621
|
+
attachmentThumbnailCacheBytes?: number;
|
|
1623
1622
|
redis?: DailyReportRedisProvider;
|
|
1624
1623
|
sseReader: DailyReportSseReader;
|
|
1625
1624
|
streamKey: string;
|
|
@@ -1647,17 +1646,105 @@ declare function createDailyReportHandlers(config: DailyReportHandlersConfig): {
|
|
|
1647
1646
|
loader: ({ request, params }: LoaderArgs) => Promise<Response>;
|
|
1648
1647
|
};
|
|
1649
1648
|
attachment: {
|
|
1650
|
-
loader: (
|
|
1649
|
+
loader: (args: AttachmentLoaderArgs) => Promise<Response>;
|
|
1651
1650
|
};
|
|
1652
1651
|
};
|
|
1652
|
+
type AttachmentLoaderArgs = {
|
|
1653
|
+
request: Request;
|
|
1654
|
+
params: Record<string, string | undefined>;
|
|
1655
|
+
};
|
|
1656
|
+
declare const generateETag: (data: unknown) => string;
|
|
1653
1657
|
declare const jsonResponseWithETag: (request: Request, cookie: string | null, payload: Record<string, unknown>, status?: number, logger?: DailyReportLogger) => Response;
|
|
1658
|
+
type SharpHeaderLike = {
|
|
1659
|
+
width: number;
|
|
1660
|
+
height: number;
|
|
1661
|
+
channels: number;
|
|
1662
|
+
depth: string;
|
|
1663
|
+
};
|
|
1664
|
+
type SharpPipelineLike = {
|
|
1665
|
+
metadata: () => Promise<SharpHeaderLike>;
|
|
1666
|
+
rotate: () => SharpPipelineLike;
|
|
1667
|
+
resize: (options: {
|
|
1668
|
+
width: number;
|
|
1669
|
+
height: number;
|
|
1670
|
+
fit: "inside";
|
|
1671
|
+
withoutEnlargement: boolean;
|
|
1672
|
+
}) => SharpPipelineLike;
|
|
1673
|
+
flatten: (options: {
|
|
1674
|
+
background: string;
|
|
1675
|
+
}) => SharpPipelineLike;
|
|
1676
|
+
webp: (options: {
|
|
1677
|
+
quality: number;
|
|
1678
|
+
effort: number;
|
|
1679
|
+
}) => SharpPipelineLike;
|
|
1680
|
+
toBuffer: () => Promise<Uint8Array>;
|
|
1681
|
+
};
|
|
1682
|
+
type SharpLike = {
|
|
1683
|
+
(input: Uint8Array, options: {
|
|
1684
|
+
limitInputPixels: number;
|
|
1685
|
+
animated: boolean;
|
|
1686
|
+
}): SharpPipelineLike;
|
|
1687
|
+
readonly versions: {
|
|
1688
|
+
readonly sharp: string;
|
|
1689
|
+
readonly vips: string;
|
|
1690
|
+
};
|
|
1691
|
+
cache: (enabled: boolean) => unknown;
|
|
1692
|
+
concurrency: (threads: number) => number;
|
|
1693
|
+
block: (options: {
|
|
1694
|
+
operation: string[];
|
|
1695
|
+
}) => void;
|
|
1696
|
+
unblock: (options: {
|
|
1697
|
+
operation: string[];
|
|
1698
|
+
}) => void;
|
|
1699
|
+
};
|
|
1700
|
+
declare const DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES = 200000000;
|
|
1701
|
+
declare const DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL: Readonly<{
|
|
1702
|
+
fixedBytes: number;
|
|
1703
|
+
pipelineRows: 2048;
|
|
1704
|
+
wholeImageBuffer: Readonly<{
|
|
1705
|
+
"jpeg-single-scan": Readonly<{
|
|
1706
|
+
kind: "none";
|
|
1707
|
+
}>;
|
|
1708
|
+
"jpeg-multi-scan": Readonly<{
|
|
1709
|
+
kind: "jpeg-coefficients";
|
|
1710
|
+
}>;
|
|
1711
|
+
png: Readonly<{
|
|
1712
|
+
kind: "none";
|
|
1713
|
+
}>;
|
|
1714
|
+
"png-interlaced": Readonly<{
|
|
1715
|
+
kind: "decoded-raster";
|
|
1716
|
+
}>;
|
|
1717
|
+
gif: Readonly<{
|
|
1718
|
+
kind: "canvas";
|
|
1719
|
+
bytesPerPixel: 4;
|
|
1720
|
+
}>;
|
|
1721
|
+
"webp-lossy": Readonly<{
|
|
1722
|
+
kind: "none";
|
|
1723
|
+
}>;
|
|
1724
|
+
"webp-lossy-alpha": Readonly<{
|
|
1725
|
+
kind: "canvas";
|
|
1726
|
+
bytesPerPixel: 5;
|
|
1727
|
+
}>;
|
|
1728
|
+
"webp-lossless": Readonly<{
|
|
1729
|
+
kind: "canvas";
|
|
1730
|
+
bytesPerPixel: 4;
|
|
1731
|
+
}>;
|
|
1732
|
+
"webp-animated": Readonly<{
|
|
1733
|
+
kind: "canvas";
|
|
1734
|
+
bytesPerPixel: 9;
|
|
1735
|
+
}>;
|
|
1736
|
+
}>;
|
|
1737
|
+
}>;
|
|
1738
|
+
declare const predictSharpThumbnailWorkingSetBytes: (source: Uint8Array, format: DailyReportAttachmentThumbnailSourceFormat, header: SharpHeaderLike) => number | null;
|
|
1739
|
+
declare const createSharpThumbnailRenderer: (sharp: SharpLike) => DailyReportAttachmentThumbnailRenderer;
|
|
1654
1740
|
type DailyReportServerConfig = Omit<DailyReportServiceConfig, "cache" | "epochs"> & {
|
|
1655
1741
|
authenticate: DailyReportAuthenticate;
|
|
1656
1742
|
resolveVisibleSourceTypes?: DailyReportResolveVisibleSourceTypes;
|
|
1657
|
-
readAttachment?: DailyReportReadAttachment;
|
|
1658
|
-
attachmentMaxBytes?: number;
|
|
1659
1743
|
attachmentRateLimitPerMinute?: number;
|
|
1660
1744
|
attachmentConcurrency?: number;
|
|
1745
|
+
attachmentThumbnailRateLimitPerMinute?: number;
|
|
1746
|
+
attachmentThumbnailConcurrency?: number;
|
|
1747
|
+
attachmentThumbnailCacheBytes?: number;
|
|
1661
1748
|
loginRedirectPath?: string;
|
|
1662
1749
|
enableDevCacheClear?: boolean;
|
|
1663
1750
|
cacheDefaultTtlMs?: number;
|
|
@@ -1695,14 +1782,12 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
|
|
|
1695
1782
|
}) => Promise<Response>;
|
|
1696
1783
|
};
|
|
1697
1784
|
attachment: {
|
|
1698
|
-
loader: (
|
|
1699
|
-
request: Request;
|
|
1700
|
-
params: Record<string, string | undefined>;
|
|
1701
|
-
}) => Promise<Response>;
|
|
1785
|
+
loader: (args: AttachmentLoaderArgs) => Promise<Response>;
|
|
1702
1786
|
};
|
|
1703
1787
|
service: {
|
|
1704
1788
|
streamKey: string;
|
|
1705
1789
|
streamMaxLen: number;
|
|
1790
|
+
attachmentDelivery: DailyReportAttachmentDelivery;
|
|
1706
1791
|
clearCache: () => Promise<void>;
|
|
1707
1792
|
invalidateHubReadCaches: (hubIds: readonly number[], businessDates: readonly string[]) => Promise<void>;
|
|
1708
1793
|
getUserIdByExternalId: (externalId: string) => Promise<number | null>;
|
|
@@ -1750,4 +1835,4 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
|
|
|
1750
1835
|
streamKey: string;
|
|
1751
1836
|
knownSourceTypes: readonly string[];
|
|
1752
1837
|
};
|
|
1753
|
-
export {
|
|
1838
|
+
export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES, DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES, DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentThumbnail, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportDb, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, predictSharpThumbnailWorkingSetBytes, transformJsonArray };
|