@aiquants/daily-report 0.34.0 → 0.35.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
@@ -1,7 +1,9 @@
1
- import { c as DailyReportSseMessage, j as DailyReportInterviewer, i as DailyReportExternalComment, D as DailyReportItem, d as DailyReportDetail, h as DailyReportAttachmentSummary, l as DailyReportPostedComment } from "./sse-schema-DVIUaiAG.mjs";
1
+ import { c as DailyReportSseMessage, k as DailyReportInterviewer, j as DailyReportExternalComment, D as DailyReportItem, d as DailyReportDetail, i as DailyReportAttachmentSummary, m as DailyReportPostedComment } from "./sse-schema-getLS62T.mjs";
2
2
  import * as drizzle_orm_mssql_core from "drizzle-orm/mssql-core";
3
3
  import { AnyMsSqlColumn } from "drizzle-orm/mssql-core";
4
+ import { a as DailyReportLogger, b as DailyReportSearchCombine, c as DailyReportSearchHit } from "./logger-BaxnzF-0.mjs";
4
5
  import { TransactionRetryOptions } from "@aiquants/mssql";
6
+ import { SQL } from "drizzle-orm";
5
7
  import "zod";
6
8
  type RedisStreamMessage = {
7
9
  id: string;
@@ -164,12 +166,6 @@ declare class SqlResultCache {
164
166
  invalidatePrefix: (prefix: string) => void;
165
167
  private cleanExpired;
166
168
  }
167
- interface DailyReportLogger {
168
- debug(message?: unknown, ...optionalParams: unknown[]): void;
169
- info(message?: unknown, ...optionalParams: unknown[]): void;
170
- warn(message?: unknown, ...optionalParams: unknown[]): void;
171
- error(message?: unknown, ...optionalParams: unknown[]): void;
172
- }
173
169
  type ExternalReportFields = {
174
170
  content?: string | null;
175
171
  employeeName?: string | null;
@@ -1476,6 +1472,245 @@ declare function defineDailyReportSchema<S extends string>(schemaName: S, opts:
1476
1472
  dialect: "mssql";
1477
1473
  }>;
1478
1474
  };
1475
+ type DailyReportSearchDocumentTable = {
1476
+ hubId: AnyMsSqlColumn;
1477
+ searchText: AnyMsSqlColumn;
1478
+ sourceDigest: AnyMsSqlColumn;
1479
+ normalizerVersion: AnyMsSqlColumn;
1480
+ indexedAt: AnyMsSqlColumn;
1481
+ rowVersion: AnyMsSqlColumn;
1482
+ };
1483
+ type DailyReportSearchCommentTable = {
1484
+ hubId: AnyMsSqlColumn;
1485
+ ordinal: AnyMsSqlColumn;
1486
+ authorUserId: AnyMsSqlColumn;
1487
+ commentText: AnyMsSqlColumn;
1488
+ };
1489
+ type DailyReportSearchTables = {
1490
+ document: DailyReportSearchDocumentTable;
1491
+ comment: DailyReportSearchCommentTable;
1492
+ };
1493
+ declare function defineDailyReportSearchSchema<S extends string>(schemaName: S): {
1494
+ document: drizzle_orm_mssql_core.MsSqlTableWithColumns<{
1495
+ name: "DailyReportSearchDocument";
1496
+ schema: S;
1497
+ columns: {
1498
+ hubId: drizzle_orm_mssql_core.MsSqlColumn<{
1499
+ name: string;
1500
+ tableName: "DailyReportSearchDocument";
1501
+ dataType: "number int53";
1502
+ data: number;
1503
+ driverParam: string;
1504
+ notNull: true;
1505
+ hasDefault: false;
1506
+ isPrimaryKey: false;
1507
+ isAutoincrement: false;
1508
+ hasRuntimeDefault: false;
1509
+ enumValues: undefined;
1510
+ baseColumn: never;
1511
+ identity: undefined;
1512
+ generated: undefined;
1513
+ }, {}>;
1514
+ searchText: drizzle_orm_mssql_core.MsSqlColumn<{
1515
+ name: string;
1516
+ tableName: "DailyReportSearchDocument";
1517
+ dataType: "string";
1518
+ data: string;
1519
+ driverParam: string | number;
1520
+ notNull: true;
1521
+ hasDefault: false;
1522
+ isPrimaryKey: false;
1523
+ isAutoincrement: false;
1524
+ hasRuntimeDefault: false;
1525
+ enumValues: [
1526
+ string,
1527
+ ...string[]
1528
+ ];
1529
+ baseColumn: never;
1530
+ identity: undefined;
1531
+ generated: undefined;
1532
+ }, {}>;
1533
+ sourceDigest: drizzle_orm_mssql_core.MsSqlColumn<{
1534
+ name: string;
1535
+ tableName: "DailyReportSearchDocument";
1536
+ dataType: "object buffer";
1537
+ data: Buffer<ArrayBufferLike>;
1538
+ driverParam: Buffer<ArrayBufferLike>;
1539
+ notNull: true;
1540
+ hasDefault: false;
1541
+ isPrimaryKey: false;
1542
+ isAutoincrement: false;
1543
+ hasRuntimeDefault: false;
1544
+ enumValues: undefined;
1545
+ baseColumn: never;
1546
+ identity: undefined;
1547
+ generated: undefined;
1548
+ }, {}>;
1549
+ normalizerVersion: drizzle_orm_mssql_core.MsSqlColumn<{
1550
+ name: string;
1551
+ tableName: "DailyReportSearchDocument";
1552
+ dataType: "string";
1553
+ data: string;
1554
+ driverParam: string | number;
1555
+ notNull: true;
1556
+ hasDefault: false;
1557
+ isPrimaryKey: false;
1558
+ isAutoincrement: false;
1559
+ hasRuntimeDefault: false;
1560
+ enumValues: [
1561
+ string,
1562
+ ...string[]
1563
+ ];
1564
+ baseColumn: never;
1565
+ identity: undefined;
1566
+ generated: undefined;
1567
+ }, {}>;
1568
+ indexedAt: drizzle_orm_mssql_core.MsSqlColumn<{
1569
+ name: string;
1570
+ tableName: "DailyReportSearchDocument";
1571
+ dataType: "object date";
1572
+ data: Date;
1573
+ driverParam: string | Date;
1574
+ notNull: true;
1575
+ hasDefault: false;
1576
+ isPrimaryKey: false;
1577
+ isAutoincrement: false;
1578
+ hasRuntimeDefault: false;
1579
+ enumValues: undefined;
1580
+ baseColumn: never;
1581
+ identity: undefined;
1582
+ generated: undefined;
1583
+ }, {}>;
1584
+ rowVersion: drizzle_orm_mssql_core.MsSqlColumn<{
1585
+ name: string;
1586
+ tableName: "DailyReportSearchDocument";
1587
+ dataType: "object buffer";
1588
+ data: Buffer<ArrayBufferLike>;
1589
+ driverParam: Buffer<ArrayBufferLike>;
1590
+ notNull: true;
1591
+ hasDefault: false;
1592
+ isPrimaryKey: false;
1593
+ isAutoincrement: false;
1594
+ hasRuntimeDefault: false;
1595
+ enumValues: undefined;
1596
+ baseColumn: never;
1597
+ identity: undefined;
1598
+ generated: undefined;
1599
+ }, {}>;
1600
+ };
1601
+ dialect: "mssql";
1602
+ }>;
1603
+ comment: drizzle_orm_mssql_core.MsSqlTableWithColumns<{
1604
+ name: "DailyReportSearchComment";
1605
+ schema: S;
1606
+ columns: {
1607
+ hubId: drizzle_orm_mssql_core.MsSqlColumn<{
1608
+ name: string;
1609
+ tableName: "DailyReportSearchComment";
1610
+ dataType: "number int53";
1611
+ data: number;
1612
+ driverParam: string;
1613
+ notNull: true;
1614
+ hasDefault: false;
1615
+ isPrimaryKey: false;
1616
+ isAutoincrement: false;
1617
+ hasRuntimeDefault: false;
1618
+ enumValues: undefined;
1619
+ baseColumn: never;
1620
+ identity: undefined;
1621
+ generated: undefined;
1622
+ }, {}>;
1623
+ ordinal: drizzle_orm_mssql_core.MsSqlColumn<{
1624
+ name: string;
1625
+ tableName: "DailyReportSearchComment";
1626
+ dataType: "number int32";
1627
+ data: number;
1628
+ driverParam: number;
1629
+ notNull: true;
1630
+ hasDefault: false;
1631
+ isPrimaryKey: false;
1632
+ isAutoincrement: false;
1633
+ hasRuntimeDefault: false;
1634
+ enumValues: undefined;
1635
+ baseColumn: never;
1636
+ identity: undefined;
1637
+ generated: undefined;
1638
+ }, {}>;
1639
+ authorUserId: drizzle_orm_mssql_core.MsSqlColumn<{
1640
+ name: string;
1641
+ tableName: "DailyReportSearchComment";
1642
+ dataType: "number int53";
1643
+ data: number;
1644
+ driverParam: string;
1645
+ notNull: false;
1646
+ hasDefault: false;
1647
+ isPrimaryKey: false;
1648
+ isAutoincrement: false;
1649
+ hasRuntimeDefault: false;
1650
+ enumValues: undefined;
1651
+ baseColumn: never;
1652
+ identity: undefined;
1653
+ generated: undefined;
1654
+ }, {}>;
1655
+ commentText: drizzle_orm_mssql_core.MsSqlColumn<{
1656
+ name: string;
1657
+ tableName: "DailyReportSearchComment";
1658
+ dataType: "string";
1659
+ data: string;
1660
+ driverParam: string | number;
1661
+ notNull: true;
1662
+ hasDefault: false;
1663
+ isPrimaryKey: false;
1664
+ isAutoincrement: false;
1665
+ hasRuntimeDefault: false;
1666
+ enumValues: [
1667
+ string,
1668
+ ...string[]
1669
+ ];
1670
+ baseColumn: never;
1671
+ identity: undefined;
1672
+ generated: undefined;
1673
+ }, {}>;
1674
+ };
1675
+ dialect: "mssql";
1676
+ }>;
1677
+ };
1678
+ type DailyReportSearchSourceTextReader = (db: DailyReportDb, sourceIdNums: readonly number[]) => Promise<ReadonlyMap<number, readonly string[]>>;
1679
+ type DailyReportSearchConfig = {
1680
+ tables: DailyReportSearchTables;
1681
+ externalSourceTexts?: Readonly<Record<string, DailyReportSearchSourceTextReader>>;
1682
+ concurrency: number;
1683
+ rateLimitPerMinute: number;
1684
+ };
1685
+ type DailyReportSearchSqlExecutor = {
1686
+ execute(query: SQL): Promise<unknown>;
1687
+ };
1688
+ type DailyReportSearchReconcileProgress = {
1689
+ readonly scanned: number;
1690
+ readonly written: number;
1691
+ readonly skipped: number;
1692
+ readonly forcedCuts: number;
1693
+ readonly lastHubId: number | null;
1694
+ };
1695
+ type DailyReportSearchReconcileSummary = DailyReportSearchReconcileProgress & {
1696
+ readonly elapsedMs: number;
1697
+ };
1698
+ type DailyReportSearchReconcileOptions = {
1699
+ readonly batchSize: number;
1700
+ readonly hubIds?: readonly number[];
1701
+ readonly signal?: AbortSignal;
1702
+ readonly onProgress?: (progress: DailyReportSearchReconcileProgress) => void;
1703
+ };
1704
+ type DailyReportSearchWord = {
1705
+ readonly alternatives: readonly string[];
1706
+ };
1707
+ type DailyReportSearchSet = {
1708
+ readonly words: readonly DailyReportSearchWord[];
1709
+ };
1710
+ type DailyReportSearchPlan = {
1711
+ readonly combine: DailyReportSearchCombine;
1712
+ readonly sets: readonly DailyReportSearchSet[];
1713
+ };
1479
1714
  type VisibleSourceTypeSet = ReadonlySet<string> | null;
1480
1715
  declare class DailyReportViewerScope {
1481
1716
  #private;
@@ -1546,7 +1781,7 @@ interface UpdateChain<T> {
1546
1781
  interface DeleteChain {
1547
1782
  where(cond: unknown): PromiseLike<unknown>;
1548
1783
  }
1549
- interface DailyReportDb {
1784
+ interface DailyReportDb extends DailyReportSearchSqlExecutor {
1550
1785
  select<T = Record<string, unknown>>(fields?: unknown): SelectChain<T>;
1551
1786
  insert<T = Record<string, unknown>>(t: unknown): InsertChain<T>;
1552
1787
  update<T = Record<string, unknown>>(t: unknown): UpdateChain<T>;
@@ -1572,6 +1807,7 @@ type DailyReportServiceConfig = {
1572
1807
  businessDateTtlMs?: number;
1573
1808
  disableUserIdCache?: boolean;
1574
1809
  attachments?: DailyReportAttachmentsConfig;
1810
+ search?: DailyReportSearchConfig;
1575
1811
  logger?: DailyReportLogger;
1576
1812
  };
1577
1813
  type DailyReportService = ReturnType<typeof createDailyReportService>;
@@ -1592,6 +1828,10 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1592
1828
  thumbnails: AttachmentThumbnailDelivery | null;
1593
1829
  }> | null;
1594
1830
  titleMaxLength: number;
1831
+ searchLimits: {
1832
+ concurrency: number;
1833
+ rateLimitPerMinute: number;
1834
+ } | null;
1595
1835
  clearCache: () => Promise<void>;
1596
1836
  invalidateHubReadCaches: (hubIds: readonly number[], businessDates: readonly string[]) => Promise<void>;
1597
1837
  getUserIdByExternalId: (externalId: string) => Promise<number | null>;
@@ -1604,7 +1844,10 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1604
1844
  getDailyReportsByBusinessDateByExternalId: (scope: DailyReportViewerScope, businessDate: string, externalId: string, { forceRefresh, snapshot, ttlMsOverride }?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail[]>;
1605
1845
  getDailyReportDetailById: (scope: DailyReportViewerScope, reportHubId: number, userId: number, { forceRefresh, snapshot, ttlMsOverride }?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail | null>;
1606
1846
  getDailyReportDetailByIdByExternalId: (scope: DailyReportViewerScope, reportHubId: number, externalId: string, options?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail | null>;
1847
+ getDailyReportDetailsByIdsByExternalId: (scope: DailyReportViewerScope, reportHubIds: readonly number[], externalId: string) => Promise<DailyReportDetail[]>;
1607
1848
  getDraftLabelId: () => Promise<number | null>;
1849
+ searchDailyReports: (scope: DailyReportViewerScope, userId: number, plan: DailyReportSearchPlan) => Promise<DailyReportSearchHit[]>;
1850
+ reconcileSearchIndex: (options: DailyReportSearchReconcileOptions) => Promise<DailyReportSearchReconcileSummary>;
1608
1851
  getAttachmentsByHubIds: (hubIds: number[]) => Promise<Map<number, DailyReportAttachmentSummary[]>>;
1609
1852
  getAttachmentForUser: (scope: DailyReportViewerScope, attachmentId: number, userId: number) => Promise<{
1610
1853
  fileName: string;
@@ -1808,4 +2051,4 @@ type DailyReportServer = DailyReportHandlers & {
1808
2051
  knownSourceTypes: readonly string[];
1809
2052
  };
1810
2053
  declare function createDailyReportServer(config: DailyReportServerConfig): DailyReportServer;
1811
- export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES, DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_WORK_MODEL, DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentThumbnail, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportClientTempId, type DailyReportDb, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServer, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderPort, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, parseClientTempId, predictSharpThumbnailWorkingSetBytes, readSseStreamEntry as readDailyReportSseStreamEntry, transformJsonArray };
2054
+ 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 DailyReportExternalSource, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubRow, type DailyReportHubTable, type DailyReportIdCodec, type DailyReportIdsSource, type DailyReportInternalRow, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportReadAttachment, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type RedisStreamMessage as DailyReportRedisStreamMessage, type DailyReportResolveUserId, type DailyReportResolveVisibleSourceTypes, type ResourceRouteArgs as DailyReportResourceRouteArgs, type DailyReportSearchCommentTable, type DailyReportSearchConfig, type DailyReportSearchDocumentTable, 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 SharpPipelineLike as DailyReportSharpPipelineLike, type SqlResultCacheQueryOptions as DailyReportSqlResultCacheQueryOptions, type DailyReportSseEntryMessage, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportSseReaderPort, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, DailyReportViewerScope, type DailyReportVisibilityDimensions, type DailyReportVisibilityResolveContext, type DailyReportVisibilityResolveReason, type VisibleSourceTypeSet as DailyReportVisibleSourceTypeSet, type DailyReportVisibleSourceTypes, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, defineDailyReportSearchSchema, generateETag, isStreamIdLte, jsonResponseWithETag, parseClientTempId, predictSharpThumbnailWorkingSetBytes, readSseStreamEntry as readDailyReportSseStreamEntry, transformJsonArray };
package/dist/server.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import { c as DailyReportSseMessage, j as DailyReportInterviewer, i as DailyReportExternalComment, D as DailyReportItem, d as DailyReportDetail, h as DailyReportAttachmentSummary, l as DailyReportPostedComment } from "./sse-schema-DVIUaiAG.js";
1
+ import { c as DailyReportSseMessage, k as DailyReportInterviewer, j as DailyReportExternalComment, D as DailyReportItem, d as DailyReportDetail, i as DailyReportAttachmentSummary, m as DailyReportPostedComment } from "./sse-schema-getLS62T.js";
2
2
  import * as drizzle_orm_mssql_core from "drizzle-orm/mssql-core";
3
3
  import { AnyMsSqlColumn } from "drizzle-orm/mssql-core";
4
+ import { a as DailyReportLogger, b as DailyReportSearchCombine, c as DailyReportSearchHit } from "./logger-BaxnzF-0.js";
4
5
  import { TransactionRetryOptions } from "@aiquants/mssql";
6
+ import { SQL } from "drizzle-orm";
5
7
  import "zod";
6
8
  type RedisStreamMessage = {
7
9
  id: string;
@@ -164,12 +166,6 @@ declare class SqlResultCache {
164
166
  invalidatePrefix: (prefix: string) => void;
165
167
  private cleanExpired;
166
168
  }
167
- interface DailyReportLogger {
168
- debug(message?: unknown, ...optionalParams: unknown[]): void;
169
- info(message?: unknown, ...optionalParams: unknown[]): void;
170
- warn(message?: unknown, ...optionalParams: unknown[]): void;
171
- error(message?: unknown, ...optionalParams: unknown[]): void;
172
- }
173
169
  type ExternalReportFields = {
174
170
  content?: string | null;
175
171
  employeeName?: string | null;
@@ -1476,6 +1472,245 @@ declare function defineDailyReportSchema<S extends string>(schemaName: S, opts:
1476
1472
  dialect: "mssql";
1477
1473
  }>;
1478
1474
  };
1475
+ type DailyReportSearchDocumentTable = {
1476
+ hubId: AnyMsSqlColumn;
1477
+ searchText: AnyMsSqlColumn;
1478
+ sourceDigest: AnyMsSqlColumn;
1479
+ normalizerVersion: AnyMsSqlColumn;
1480
+ indexedAt: AnyMsSqlColumn;
1481
+ rowVersion: AnyMsSqlColumn;
1482
+ };
1483
+ type DailyReportSearchCommentTable = {
1484
+ hubId: AnyMsSqlColumn;
1485
+ ordinal: AnyMsSqlColumn;
1486
+ authorUserId: AnyMsSqlColumn;
1487
+ commentText: AnyMsSqlColumn;
1488
+ };
1489
+ type DailyReportSearchTables = {
1490
+ document: DailyReportSearchDocumentTable;
1491
+ comment: DailyReportSearchCommentTable;
1492
+ };
1493
+ declare function defineDailyReportSearchSchema<S extends string>(schemaName: S): {
1494
+ document: drizzle_orm_mssql_core.MsSqlTableWithColumns<{
1495
+ name: "DailyReportSearchDocument";
1496
+ schema: S;
1497
+ columns: {
1498
+ hubId: drizzle_orm_mssql_core.MsSqlColumn<{
1499
+ name: string;
1500
+ tableName: "DailyReportSearchDocument";
1501
+ dataType: "number int53";
1502
+ data: number;
1503
+ driverParam: string;
1504
+ notNull: true;
1505
+ hasDefault: false;
1506
+ isPrimaryKey: false;
1507
+ isAutoincrement: false;
1508
+ hasRuntimeDefault: false;
1509
+ enumValues: undefined;
1510
+ baseColumn: never;
1511
+ identity: undefined;
1512
+ generated: undefined;
1513
+ }, {}>;
1514
+ searchText: drizzle_orm_mssql_core.MsSqlColumn<{
1515
+ name: string;
1516
+ tableName: "DailyReportSearchDocument";
1517
+ dataType: "string";
1518
+ data: string;
1519
+ driverParam: string | number;
1520
+ notNull: true;
1521
+ hasDefault: false;
1522
+ isPrimaryKey: false;
1523
+ isAutoincrement: false;
1524
+ hasRuntimeDefault: false;
1525
+ enumValues: [
1526
+ string,
1527
+ ...string[]
1528
+ ];
1529
+ baseColumn: never;
1530
+ identity: undefined;
1531
+ generated: undefined;
1532
+ }, {}>;
1533
+ sourceDigest: drizzle_orm_mssql_core.MsSqlColumn<{
1534
+ name: string;
1535
+ tableName: "DailyReportSearchDocument";
1536
+ dataType: "object buffer";
1537
+ data: Buffer<ArrayBufferLike>;
1538
+ driverParam: Buffer<ArrayBufferLike>;
1539
+ notNull: true;
1540
+ hasDefault: false;
1541
+ isPrimaryKey: false;
1542
+ isAutoincrement: false;
1543
+ hasRuntimeDefault: false;
1544
+ enumValues: undefined;
1545
+ baseColumn: never;
1546
+ identity: undefined;
1547
+ generated: undefined;
1548
+ }, {}>;
1549
+ normalizerVersion: drizzle_orm_mssql_core.MsSqlColumn<{
1550
+ name: string;
1551
+ tableName: "DailyReportSearchDocument";
1552
+ dataType: "string";
1553
+ data: string;
1554
+ driverParam: string | number;
1555
+ notNull: true;
1556
+ hasDefault: false;
1557
+ isPrimaryKey: false;
1558
+ isAutoincrement: false;
1559
+ hasRuntimeDefault: false;
1560
+ enumValues: [
1561
+ string,
1562
+ ...string[]
1563
+ ];
1564
+ baseColumn: never;
1565
+ identity: undefined;
1566
+ generated: undefined;
1567
+ }, {}>;
1568
+ indexedAt: drizzle_orm_mssql_core.MsSqlColumn<{
1569
+ name: string;
1570
+ tableName: "DailyReportSearchDocument";
1571
+ dataType: "object date";
1572
+ data: Date;
1573
+ driverParam: string | Date;
1574
+ notNull: true;
1575
+ hasDefault: false;
1576
+ isPrimaryKey: false;
1577
+ isAutoincrement: false;
1578
+ hasRuntimeDefault: false;
1579
+ enumValues: undefined;
1580
+ baseColumn: never;
1581
+ identity: undefined;
1582
+ generated: undefined;
1583
+ }, {}>;
1584
+ rowVersion: drizzle_orm_mssql_core.MsSqlColumn<{
1585
+ name: string;
1586
+ tableName: "DailyReportSearchDocument";
1587
+ dataType: "object buffer";
1588
+ data: Buffer<ArrayBufferLike>;
1589
+ driverParam: Buffer<ArrayBufferLike>;
1590
+ notNull: true;
1591
+ hasDefault: false;
1592
+ isPrimaryKey: false;
1593
+ isAutoincrement: false;
1594
+ hasRuntimeDefault: false;
1595
+ enumValues: undefined;
1596
+ baseColumn: never;
1597
+ identity: undefined;
1598
+ generated: undefined;
1599
+ }, {}>;
1600
+ };
1601
+ dialect: "mssql";
1602
+ }>;
1603
+ comment: drizzle_orm_mssql_core.MsSqlTableWithColumns<{
1604
+ name: "DailyReportSearchComment";
1605
+ schema: S;
1606
+ columns: {
1607
+ hubId: drizzle_orm_mssql_core.MsSqlColumn<{
1608
+ name: string;
1609
+ tableName: "DailyReportSearchComment";
1610
+ dataType: "number int53";
1611
+ data: number;
1612
+ driverParam: string;
1613
+ notNull: true;
1614
+ hasDefault: false;
1615
+ isPrimaryKey: false;
1616
+ isAutoincrement: false;
1617
+ hasRuntimeDefault: false;
1618
+ enumValues: undefined;
1619
+ baseColumn: never;
1620
+ identity: undefined;
1621
+ generated: undefined;
1622
+ }, {}>;
1623
+ ordinal: drizzle_orm_mssql_core.MsSqlColumn<{
1624
+ name: string;
1625
+ tableName: "DailyReportSearchComment";
1626
+ dataType: "number int32";
1627
+ data: number;
1628
+ driverParam: number;
1629
+ notNull: true;
1630
+ hasDefault: false;
1631
+ isPrimaryKey: false;
1632
+ isAutoincrement: false;
1633
+ hasRuntimeDefault: false;
1634
+ enumValues: undefined;
1635
+ baseColumn: never;
1636
+ identity: undefined;
1637
+ generated: undefined;
1638
+ }, {}>;
1639
+ authorUserId: drizzle_orm_mssql_core.MsSqlColumn<{
1640
+ name: string;
1641
+ tableName: "DailyReportSearchComment";
1642
+ dataType: "number int53";
1643
+ data: number;
1644
+ driverParam: string;
1645
+ notNull: false;
1646
+ hasDefault: false;
1647
+ isPrimaryKey: false;
1648
+ isAutoincrement: false;
1649
+ hasRuntimeDefault: false;
1650
+ enumValues: undefined;
1651
+ baseColumn: never;
1652
+ identity: undefined;
1653
+ generated: undefined;
1654
+ }, {}>;
1655
+ commentText: drizzle_orm_mssql_core.MsSqlColumn<{
1656
+ name: string;
1657
+ tableName: "DailyReportSearchComment";
1658
+ dataType: "string";
1659
+ data: string;
1660
+ driverParam: string | number;
1661
+ notNull: true;
1662
+ hasDefault: false;
1663
+ isPrimaryKey: false;
1664
+ isAutoincrement: false;
1665
+ hasRuntimeDefault: false;
1666
+ enumValues: [
1667
+ string,
1668
+ ...string[]
1669
+ ];
1670
+ baseColumn: never;
1671
+ identity: undefined;
1672
+ generated: undefined;
1673
+ }, {}>;
1674
+ };
1675
+ dialect: "mssql";
1676
+ }>;
1677
+ };
1678
+ type DailyReportSearchSourceTextReader = (db: DailyReportDb, sourceIdNums: readonly number[]) => Promise<ReadonlyMap<number, readonly string[]>>;
1679
+ type DailyReportSearchConfig = {
1680
+ tables: DailyReportSearchTables;
1681
+ externalSourceTexts?: Readonly<Record<string, DailyReportSearchSourceTextReader>>;
1682
+ concurrency: number;
1683
+ rateLimitPerMinute: number;
1684
+ };
1685
+ type DailyReportSearchSqlExecutor = {
1686
+ execute(query: SQL): Promise<unknown>;
1687
+ };
1688
+ type DailyReportSearchReconcileProgress = {
1689
+ readonly scanned: number;
1690
+ readonly written: number;
1691
+ readonly skipped: number;
1692
+ readonly forcedCuts: number;
1693
+ readonly lastHubId: number | null;
1694
+ };
1695
+ type DailyReportSearchReconcileSummary = DailyReportSearchReconcileProgress & {
1696
+ readonly elapsedMs: number;
1697
+ };
1698
+ type DailyReportSearchReconcileOptions = {
1699
+ readonly batchSize: number;
1700
+ readonly hubIds?: readonly number[];
1701
+ readonly signal?: AbortSignal;
1702
+ readonly onProgress?: (progress: DailyReportSearchReconcileProgress) => void;
1703
+ };
1704
+ type DailyReportSearchWord = {
1705
+ readonly alternatives: readonly string[];
1706
+ };
1707
+ type DailyReportSearchSet = {
1708
+ readonly words: readonly DailyReportSearchWord[];
1709
+ };
1710
+ type DailyReportSearchPlan = {
1711
+ readonly combine: DailyReportSearchCombine;
1712
+ readonly sets: readonly DailyReportSearchSet[];
1713
+ };
1479
1714
  type VisibleSourceTypeSet = ReadonlySet<string> | null;
1480
1715
  declare class DailyReportViewerScope {
1481
1716
  #private;
@@ -1546,7 +1781,7 @@ interface UpdateChain<T> {
1546
1781
  interface DeleteChain {
1547
1782
  where(cond: unknown): PromiseLike<unknown>;
1548
1783
  }
1549
- interface DailyReportDb {
1784
+ interface DailyReportDb extends DailyReportSearchSqlExecutor {
1550
1785
  select<T = Record<string, unknown>>(fields?: unknown): SelectChain<T>;
1551
1786
  insert<T = Record<string, unknown>>(t: unknown): InsertChain<T>;
1552
1787
  update<T = Record<string, unknown>>(t: unknown): UpdateChain<T>;
@@ -1572,6 +1807,7 @@ type DailyReportServiceConfig = {
1572
1807
  businessDateTtlMs?: number;
1573
1808
  disableUserIdCache?: boolean;
1574
1809
  attachments?: DailyReportAttachmentsConfig;
1810
+ search?: DailyReportSearchConfig;
1575
1811
  logger?: DailyReportLogger;
1576
1812
  };
1577
1813
  type DailyReportService = ReturnType<typeof createDailyReportService>;
@@ -1592,6 +1828,10 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1592
1828
  thumbnails: AttachmentThumbnailDelivery | null;
1593
1829
  }> | null;
1594
1830
  titleMaxLength: number;
1831
+ searchLimits: {
1832
+ concurrency: number;
1833
+ rateLimitPerMinute: number;
1834
+ } | null;
1595
1835
  clearCache: () => Promise<void>;
1596
1836
  invalidateHubReadCaches: (hubIds: readonly number[], businessDates: readonly string[]) => Promise<void>;
1597
1837
  getUserIdByExternalId: (externalId: string) => Promise<number | null>;
@@ -1604,7 +1844,10 @@ declare function createDailyReportService(config: DailyReportServiceConfig): {
1604
1844
  getDailyReportsByBusinessDateByExternalId: (scope: DailyReportViewerScope, businessDate: string, externalId: string, { forceRefresh, snapshot, ttlMsOverride }?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail[]>;
1605
1845
  getDailyReportDetailById: (scope: DailyReportViewerScope, reportHubId: number, userId: number, { forceRefresh, snapshot, ttlMsOverride }?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail | null>;
1606
1846
  getDailyReportDetailByIdByExternalId: (scope: DailyReportViewerScope, reportHubId: number, externalId: string, options?: SqlResultCacheQueryOptions) => Promise<DailyReportDetail | null>;
1847
+ getDailyReportDetailsByIdsByExternalId: (scope: DailyReportViewerScope, reportHubIds: readonly number[], externalId: string) => Promise<DailyReportDetail[]>;
1607
1848
  getDraftLabelId: () => Promise<number | null>;
1849
+ searchDailyReports: (scope: DailyReportViewerScope, userId: number, plan: DailyReportSearchPlan) => Promise<DailyReportSearchHit[]>;
1850
+ reconcileSearchIndex: (options: DailyReportSearchReconcileOptions) => Promise<DailyReportSearchReconcileSummary>;
1608
1851
  getAttachmentsByHubIds: (hubIds: number[]) => Promise<Map<number, DailyReportAttachmentSummary[]>>;
1609
1852
  getAttachmentForUser: (scope: DailyReportViewerScope, attachmentId: number, userId: number) => Promise<{
1610
1853
  fileName: string;
@@ -1808,4 +2051,4 @@ type DailyReportServer = DailyReportHandlers & {
1808
2051
  knownSourceTypes: readonly string[];
1809
2052
  };
1810
2053
  declare function createDailyReportServer(config: DailyReportServerConfig): DailyReportServer;
1811
- export { DAILY_REPORT_ATTACHMENT_THUMBNAIL_MAX_OUTPUT_BYTES, DAILY_REPORT_ATTACHMENT_THUMBNAIL_OUTPUT_MEDIA_TYPES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_BUDGET_BYTES, DAILY_REPORT_SHARP_THUMBNAIL_DECODE_WORK_MODEL, DAILY_REPORT_SHARP_THUMBNAIL_WORKING_SET_MODEL, DAILY_REPORT_SSE_CATCH_UP_BATCH, DAILY_REPORT_SSE_VISIBILITY_REFRESH_MS, type DailyReportAttachmentDelivery, type DailyReportAttachmentError, type DailyReportAttachmentFailure, type DailyReportAttachmentThumbnail, type DailyReportAttachmentThumbnailOutputMediaType, type DailyReportAttachmentThumbnailRenderer, type DailyReportAttachmentThumbnailSourceFormat, type DailyReportAttachmentThumbnailsConfig, type DailyReportAttachmentsConfig, type DailyReportAuthResult, type DailyReportAuthenticate, type DailyReportClientTempId, type DailyReportDb, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportIdCodec, type DailyReportReadAttachment, type DailyReportRedisProvider, type DailyReportServer, type DailyReportServerConfig, type DailyReportServiceConfig, DailyReportSseReader, type DailyReportSseReaderPort, type DailyReportTables, DailyReportViewerScope, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, generateETag, isStreamIdLte, jsonResponseWithETag, parseClientTempId, predictSharpThumbnailWorkingSetBytes, readSseStreamEntry as readDailyReportSseStreamEntry, transformJsonArray };
2054
+ 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 DailyReportExternalSource, type DailyReportHandlers, type DailyReportHandlersConfig, type DailyReportHubLabelTable, type DailyReportHubRow, type DailyReportHubTable, type DailyReportIdCodec, type DailyReportIdsSource, type DailyReportInternalRow, type DailyReportInternalTable, type DailyReportLabelTable, type DailyReportReadAttachment, type DailyReportRedisBlockingClient, type DailyReportRedisClient, type DailyReportRedisProvider, type RedisStreamMessage as DailyReportRedisStreamMessage, type DailyReportResolveUserId, type DailyReportResolveVisibleSourceTypes, type ResourceRouteArgs as DailyReportResourceRouteArgs, type DailyReportSearchCommentTable, type DailyReportSearchConfig, type DailyReportSearchDocumentTable, 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 SharpPipelineLike as DailyReportSharpPipelineLike, type SqlResultCacheQueryOptions as DailyReportSqlResultCacheQueryOptions, type DailyReportSseEntryMessage, DailyReportSseReader, type DailyReportSseReaderConfig, type DailyReportSseReaderPort, type DailyReportTables, type DailyReportUserStatusRow, type DailyReportUserStatusTable, type DailyReportUserTable, DailyReportViewerScope, type DailyReportVisibilityDimensions, type DailyReportVisibilityResolveContext, type DailyReportVisibilityResolveReason, type VisibleSourceTypeSet as DailyReportVisibleSourceTypeSet, type DailyReportVisibleSourceTypes, type ExternalReportFields, type SharpLike, SqlResultCache, type StreamEntry, createDailyReportHandlers, createDailyReportServer, createDailyReportService, createEpochStore, createSharpThumbnailRenderer, defineDailyReportSchema, defineDailyReportSearchSchema, generateETag, isStreamIdLte, jsonResponseWithETag, parseClientTempId, predictSharpThumbnailWorkingSetBytes, readSseStreamEntry as readDailyReportSseStreamEntry, transformJsonArray };