@aiquants/daily-report 0.26.0 → 0.28.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/server.d.mts CHANGED
@@ -8,12 +8,6 @@ interface DailyReportLogger {
8
8
  warn(message?: unknown, ...optionalParams: unknown[]): void;
9
9
  error(message?: unknown, ...optionalParams: unknown[]): void;
10
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;
17
11
  type RedisStreamMessage = {
18
12
  id: string;
19
13
  message: Record<string, string>;
@@ -48,6 +42,14 @@ type DailyReportRedisProvider = {
48
42
  getClient(): Promise<DailyReportRedisClient | undefined>;
49
43
  createClient(): Promise<DailyReportRedisBlockingClient | undefined>;
50
44
  };
45
+ type StreamEntry = {
46
+ id: string;
47
+ message: Record<string, string>;
48
+ };
49
+ type DailyReportSseReaderPort = {
50
+ ready(): Promise<void>;
51
+ subscribe(onEntry: (entry: StreamEntry) => void, onError: (err: Error) => void): () => void;
52
+ };
51
53
  type DailyReportAuthResult = {
52
54
  user?: {
53
55
  id: string;
@@ -103,6 +105,12 @@ type DailyReportReadAttachment = (filePath: string, options: {
103
105
  }) => Promise<DailyReportAttachmentBytes | DailyReportAttachmentError>;
104
106
  type DailyReportAttachmentThumbnailSourceFormat = "png" | "jpeg" | "gif" | "webp";
105
107
  type DailyReportAttachmentThumbnailFailure = "unsupported" | "failed";
108
+ declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES: readonly [
109
+ "image/webp",
110
+ "image/jpeg",
111
+ "image/png"
112
+ ];
113
+ declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES: number;
106
114
  type DailyReportAttachmentThumbnailOutputMediaType = (typeof DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES)[number];
107
115
  type DailyReportAttachmentThumbnail = {
108
116
  ok: true;
@@ -1576,17 +1584,13 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1576
1584
  deleteDailyReportLabel: (tx: DailyReportDb, hubId: number, labelId: number) => Promise<void>;
1577
1585
  };
1578
1586
  declare const isStreamIdLte: (a: string, b: string) => boolean;
1579
- type StreamEntry = {
1580
- id: string;
1581
- message: Record<string, string>;
1582
- };
1583
1587
  type DailyReportSseReaderConfig = {
1584
1588
  redis?: DailyReportRedisProvider;
1585
1589
  streamKey: string;
1586
1590
  cache: SqlResultCache;
1587
1591
  logger?: DailyReportLogger;
1588
1592
  };
1589
- declare class DailyReportSseReader {
1593
+ declare class DailyReportSseReader implements DailyReportSseReaderPort {
1590
1594
  private readonly config;
1591
1595
  private _source;
1592
1596
  private _lastId;
@@ -1604,6 +1608,7 @@ declare class DailyReportSseReader {
1604
1608
  private _readLoop;
1605
1609
  private _invalidateCaches;
1606
1610
  }
1611
+ declare const generateETag: (data: unknown) => string;
1607
1612
  type LoaderArgs = {
1608
1613
  request: Request;
1609
1614
  params: Record<string, string | undefined>;
@@ -1621,7 +1626,7 @@ type DailyReportHandlersConfig = {
1621
1626
  attachmentThumbnailConcurrency?: number;
1622
1627
  attachmentThumbnailCacheBytes?: number;
1623
1628
  redis?: DailyReportRedisProvider;
1624
- sseReader: DailyReportSseReader;
1629
+ sseReader: DailyReportSseReaderPort;
1625
1630
  streamKey: string;
1626
1631
  loginRedirectPath?: string;
1627
1632
  enableDevCacheClear?: boolean;
@@ -1640,21 +1645,16 @@ declare function createDailyReportHandlers(config: DailyReportHandlersConfig): {
1640
1645
  }>;
1641
1646
  };
1642
1647
  api: {
1643
- loader: ({ request, params }: LoaderArgs) => Promise<Response>;
1644
- action: ({ request, params }: LoaderArgs) => Promise<Response>;
1648
+ loader: (args: LoaderArgs) => Promise<Response>;
1649
+ action: (args: LoaderArgs) => Promise<Response>;
1645
1650
  };
1646
1651
  sse: {
1647
- loader: ({ request, params }: LoaderArgs) => Promise<Response>;
1652
+ loader: (args: LoaderArgs) => Promise<Response>;
1648
1653
  };
1649
1654
  attachment: {
1650
- loader: (args: AttachmentLoaderArgs) => Promise<Response>;
1655
+ loader: (args: LoaderArgs) => Promise<Response>;
1651
1656
  };
1652
1657
  };
1653
- type AttachmentLoaderArgs = {
1654
- request: Request;
1655
- params: Record<string, string | undefined>;
1656
- };
1657
- declare const generateETag: (data: unknown) => string;
1658
1658
  declare const jsonResponseWithETag: (request: Request, cookie: string | null, payload: Record<string, unknown>, status?: number, logger?: DailyReportLogger) => Response;
1659
1659
  type SharpHeaderLike = {
1660
1660
  width: number;
@@ -1777,23 +1777,26 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1777
1777
  }>;
1778
1778
  };
1779
1779
  api: {
1780
- loader: ({ request, params }: {
1780
+ loader: (args: {
1781
1781
  request: Request;
1782
1782
  params: Record<string, string | undefined>;
1783
1783
  }) => Promise<Response>;
1784
- action: ({ request, params }: {
1784
+ action: (args: {
1785
1785
  request: Request;
1786
1786
  params: Record<string, string | undefined>;
1787
1787
  }) => Promise<Response>;
1788
1788
  };
1789
1789
  sse: {
1790
- loader: ({ request, params }: {
1790
+ loader: (args: {
1791
1791
  request: Request;
1792
1792
  params: Record<string, string | undefined>;
1793
1793
  }) => Promise<Response>;
1794
1794
  };
1795
1795
  attachment: {
1796
- loader: (args: AttachmentLoaderArgs) => Promise<Response>;
1796
+ loader: (args: {
1797
+ request: Request;
1798
+ params: Record<string, string | undefined>;
1799
+ }) => Promise<Response>;
1797
1800
  };
1798
1801
  service: {
1799
1802
  streamKey: string;
@@ -1846,4 +1849,4 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1846
1849
  streamKey: string;
1847
1850
  knownSourceTypes: readonly string[];
1848
1851
  };
1849
- export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES, DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_WORK_MODEL, DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentThumbnail, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type 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 };
1852
+ export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES, DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_WORK_MODEL, DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentThumbnail, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportDb, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderPort, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, predictSharpThumbnailWorkingSetBytes, transformJsonArray };
package/dist/server.d.ts CHANGED
@@ -8,12 +8,6 @@ interface DailyReportLogger {
8
8
  warn(message?: unknown, ...optionalParams: unknown[]): void;
9
9
  error(message?: unknown, ...optionalParams: unknown[]): void;
10
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;
17
11
  type RedisStreamMessage = {
18
12
  id: string;
19
13
  message: Record<string, string>;
@@ -48,6 +42,14 @@ type DailyReportRedisProvider = {
48
42
  getClient(): Promise<DailyReportRedisClient | undefined>;
49
43
  createClient(): Promise<DailyReportRedisBlockingClient | undefined>;
50
44
  };
45
+ type StreamEntry = {
46
+ id: string;
47
+ message: Record<string, string>;
48
+ };
49
+ type DailyReportSseReaderPort = {
50
+ ready(): Promise<void>;
51
+ subscribe(onEntry: (entry: StreamEntry) => void, onError: (err: Error) => void): () => void;
52
+ };
51
53
  type DailyReportAuthResult = {
52
54
  user?: {
53
55
  id: string;
@@ -103,6 +105,12 @@ type DailyReportReadAttachment = (filePath: string, options: {
103
105
  }) => Promise<DailyReportAttachmentBytes | DailyReportAttachmentError>;
104
106
  type DailyReportAttachmentThumbnailSourceFormat = "png" | "jpeg" | "gif" | "webp";
105
107
  type DailyReportAttachmentThumbnailFailure = "unsupported" | "failed";
108
+ declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES: readonly [
109
+ "image/webp",
110
+ "image/jpeg",
111
+ "image/png"
112
+ ];
113
+ declare const DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES: number;
106
114
  type DailyReportAttachmentThumbnailOutputMediaType = (typeof DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES)[number];
107
115
  type DailyReportAttachmentThumbnail = {
108
116
  ok: true;
@@ -1576,17 +1584,13 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1576
1584
  deleteDailyReportLabel: (tx: DailyReportDb, hubId: number, labelId: number) => Promise<void>;
1577
1585
  };
1578
1586
  declare const isStreamIdLte: (a: string, b: string) => boolean;
1579
- type StreamEntry = {
1580
- id: string;
1581
- message: Record<string, string>;
1582
- };
1583
1587
  type DailyReportSseReaderConfig = {
1584
1588
  redis?: DailyReportRedisProvider;
1585
1589
  streamKey: string;
1586
1590
  cache: SqlResultCache;
1587
1591
  logger?: DailyReportLogger;
1588
1592
  };
1589
- declare class DailyReportSseReader {
1593
+ declare class DailyReportSseReader implements DailyReportSseReaderPort {
1590
1594
  private readonly config;
1591
1595
  private _source;
1592
1596
  private _lastId;
@@ -1604,6 +1608,7 @@ declare class DailyReportSseReader {
1604
1608
  private _readLoop;
1605
1609
  private _invalidateCaches;
1606
1610
  }
1611
+ declare const generateETag: (data: unknown) => string;
1607
1612
  type LoaderArgs = {
1608
1613
  request: Request;
1609
1614
  params: Record<string, string | undefined>;
@@ -1621,7 +1626,7 @@ type DailyReportHandlersConfig = {
1621
1626
  attachmentThumbnailConcurrency?: number;
1622
1627
  attachmentThumbnailCacheBytes?: number;
1623
1628
  redis?: DailyReportRedisProvider;
1624
- sseReader: DailyReportSseReader;
1629
+ sseReader: DailyReportSseReaderPort;
1625
1630
  streamKey: string;
1626
1631
  loginRedirectPath?: string;
1627
1632
  enableDevCacheClear?: boolean;
@@ -1640,21 +1645,16 @@ declare function createDailyReportHandlers(config: DailyReportHandlersConfig): {
1640
1645
  }>;
1641
1646
  };
1642
1647
  api: {
1643
- loader: ({ request, params }: LoaderArgs) => Promise<Response>;
1644
- action: ({ request, params }: LoaderArgs) => Promise<Response>;
1648
+ loader: (args: LoaderArgs) => Promise<Response>;
1649
+ action: (args: LoaderArgs) => Promise<Response>;
1645
1650
  };
1646
1651
  sse: {
1647
- loader: ({ request, params }: LoaderArgs) => Promise<Response>;
1652
+ loader: (args: LoaderArgs) => Promise<Response>;
1648
1653
  };
1649
1654
  attachment: {
1650
- loader: (args: AttachmentLoaderArgs) => Promise<Response>;
1655
+ loader: (args: LoaderArgs) => Promise<Response>;
1651
1656
  };
1652
1657
  };
1653
- type AttachmentLoaderArgs = {
1654
- request: Request;
1655
- params: Record<string, string | undefined>;
1656
- };
1657
- declare const generateETag: (data: unknown) => string;
1658
1658
  declare const jsonResponseWithETag: (request: Request, cookie: string | null, payload: Record<string, unknown>, status?: number, logger?: DailyReportLogger) => Response;
1659
1659
  type SharpHeaderLike = {
1660
1660
  width: number;
@@ -1777,23 +1777,26 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1777
1777
  }>;
1778
1778
  };
1779
1779
  api: {
1780
- loader: ({ request, params }: {
1780
+ loader: (args: {
1781
1781
  request: Request;
1782
1782
  params: Record<string, string | undefined>;
1783
1783
  }) => Promise<Response>;
1784
- action: ({ request, params }: {
1784
+ action: (args: {
1785
1785
  request: Request;
1786
1786
  params: Record<string, string | undefined>;
1787
1787
  }) => Promise<Response>;
1788
1788
  };
1789
1789
  sse: {
1790
- loader: ({ request, params }: {
1790
+ loader: (args: {
1791
1791
  request: Request;
1792
1792
  params: Record<string, string | undefined>;
1793
1793
  }) => Promise<Response>;
1794
1794
  };
1795
1795
  attachment: {
1796
- loader: (args: AttachmentLoaderArgs) => Promise<Response>;
1796
+ loader: (args: {
1797
+ request: Request;
1798
+ params: Record<string, string | undefined>;
1799
+ }) => Promise<Response>;
1797
1800
  };
1798
1801
  service: {
1799
1802
  streamKey: string;
@@ -1846,4 +1849,4 @@ declare function createDailyReportServer(config: DailyReportServerConfig): {
1846
1849
  streamKey: string;
1847
1850
  knownSourceTypes: readonly string[];
1848
1851
  };
1849
- export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES, DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_WORK_MODEL, DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentThumbnail, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type 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 };
1852
+ export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES, DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_WORK_MODEL, DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentThumbnail, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportDb, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderPort, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, predictSharpThumbnailWorkingSetBytes, transformJsonArray };