data-finder-ts 0.1.0 → 0.1.4
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/README.md +17 -55
- package/dist/chunk-4JVW4TAB.js +180 -0
- package/dist/chunk-4JVW4TAB.js.map +1 -0
- package/dist/chunk-4LNZV6EN.js +500 -0
- package/dist/chunk-4LNZV6EN.js.map +1 -0
- package/dist/chunk-FJYA2ASS.js +136 -0
- package/dist/chunk-FJYA2ASS.js.map +1 -0
- package/dist/chunk-FLEIUDZZ.js +14 -0
- package/dist/chunk-FLEIUDZZ.js.map +1 -0
- package/dist/chunk-MH4XMYVB.js +696 -0
- package/dist/chunk-MH4XMYVB.js.map +1 -0
- package/dist/chunk-PMPLCEWQ.js +90 -0
- package/dist/chunk-PMPLCEWQ.js.map +1 -0
- package/dist/chunk-UYMOE6YU.js +509 -0
- package/dist/chunk-UYMOE6YU.js.map +1 -0
- package/dist/datafinder/attribute.cjs +320 -0
- package/dist/datafinder/attribute.cjs.map +1 -0
- package/dist/datafinder/attribute.d.cts +86 -0
- package/dist/datafinder/attribute.d.ts +86 -0
- package/dist/datafinder/attribute.js +8 -0
- package/dist/datafinder/attribute.js.map +1 -0
- package/dist/datafinder/finder-registry.cjs +39 -0
- package/dist/datafinder/finder-registry.cjs.map +1 -0
- package/dist/datafinder/finder-registry.d.cts +4 -0
- package/dist/datafinder/finder-registry.d.ts +4 -0
- package/dist/datafinder/finder-registry.js +9 -0
- package/dist/datafinder/finder-registry.js.map +1 -0
- package/dist/datafinder/runner.cjs +1595 -0
- package/dist/datafinder/runner.cjs.map +1 -0
- package/dist/datafinder/runner.d.cts +44 -0
- package/dist/datafinder/runner.d.ts +44 -0
- package/dist/datafinder/runner.js +26 -0
- package/dist/datafinder/runner.js.map +1 -0
- package/dist/datafinder/sql-generator.cjs +1467 -0
- package/dist/datafinder/sql-generator.cjs.map +1 -0
- package/dist/datafinder/sql-generator.d.cts +8 -0
- package/dist/datafinder/sql-generator.d.ts +8 -0
- package/dist/datafinder/sql-generator.js +15 -0
- package/dist/datafinder/sql-generator.js.map +1 -0
- package/dist/datafinder/typed-attributes.cjs +909 -0
- package/dist/datafinder/typed-attributes.cjs.map +1 -0
- package/dist/datafinder/typed-attributes.d.cts +242 -0
- package/dist/datafinder/typed-attributes.d.ts +242 -0
- package/dist/datafinder/typed-attributes.js +25 -0
- package/dist/datafinder/typed-attributes.js.map +1 -0
- package/dist/index.cjs +2153 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +199 -0
- package/dist/index.js.map +1 -0
- package/dist/model/milestoning.cjs +145 -0
- package/dist/model/milestoning.cjs.map +1 -0
- package/dist/model/milestoning.d.cts +40 -0
- package/dist/model/milestoning.d.ts +40 -0
- package/dist/model/milestoning.js +18 -0
- package/dist/model/milestoning.js.map +1 -0
- package/dist/model/relational.cjs +579 -0
- package/dist/model/relational.cjs.map +1 -0
- package/dist/model/relational.d.cts +291 -0
- package/dist/model/relational.d.ts +291 -0
- package/dist/model/relational.js +99 -0
- package/dist/model/relational.js.map +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/datafinder/runner.ts","../../src/model/relational.ts","../../src/datafinder/attribute.ts","../../src/model/milestoning.ts","../../src/datafinder/typed-attributes.ts","../../src/datafinder/sql-generator.ts"],"sourcesContent":["import { Attribute } from './attribute';\nimport { toSql } from './sql-generator';\nimport {\n Table,\n Operation,\n SortOperation,\n NoOperation,\n RelationalOperationElement,\n} from '../model/relational';\n\nexport type Row = unknown[];\n\nexport const DEFAULT_TIMEOUT_MS = 60_000;\n\n/** Thrown by a QueryRunner when a query runs longer than the timeout set on its FinderResult. */\nexport class QueryTimeoutError extends Error {\n constructor(readonly timeoutMs: number) {\n super(`Query exceeded ${timeoutMs}ms timeout`);\n this.name = 'QueryTimeoutError';\n }\n}\n\n/** Minimum interface satisfied by both Table (SQL) and GraphQLQuery (GraphQL). */\nexport interface QueryTarget {\n readonly name: string;\n}\n\nexport interface QueryRunner {\n select(\n businessDate: Date | null,\n processingDatetime: Date | null,\n columns: (Attribute | RelationalOperationElement)[],\n table: QueryTarget,\n op: RelationalOperationElement,\n orderBy?: SortOperation[],\n groupBy?: Attribute[],\n limit?: number,\n timeoutMs?: number,\n businessDateTo?: Date | null,\n ): Promise<Row[]>;\n}\n\nlet _runner: QueryRunner | null = null;\n\nexport function registerRunner(runner: QueryRunner): void { _runner = runner; }\nexport function clearRunner(): void { _runner = null; }\nexport function getRunner(): QueryRunner {\n if (!_runner) throw new Error('No query runner registered. Call registerRunner() first.');\n return _runner;\n}\n\nexport class FinderResult {\n private _orderBy: SortOperation[] = [];\n private _groupBy: Attribute[] = [];\n private _limit?: number;\n private _timeoutMs: number = DEFAULT_TIMEOUT_MS;\n\n constructor(\n private readonly _businessDate: Date | null,\n private readonly _processingDatetime: Date | null,\n private readonly _columns: (Attribute | RelationalOperationElement)[],\n private readonly _table: QueryTarget,\n private readonly _op: RelationalOperationElement,\n private readonly _businessDateTo: Date | null = null,\n ) {}\n\n orderByOp(...sorts: SortOperation[]): this {\n this._orderBy = sorts;\n return this;\n }\n\n groupByOp(...attrs: Attribute[]): this {\n this._groupBy = attrs;\n return this;\n }\n\n limit(n: number): this {\n this._limit = n;\n return this;\n }\n\n /** Abort the query and throw QueryTimeoutError if it runs longer than `milliseconds` (default 60000). */\n timeout(milliseconds: number): this {\n this._timeoutMs = milliseconds;\n return this;\n }\n\n toSql(): string {\n return toSql(\n this._businessDate,\n this._processingDatetime,\n this._columns,\n this._table as Table,\n this._op,\n this._orderBy,\n this._groupBy,\n this._limit,\n this._businessDateTo,\n );\n }\n\n async toRows(): Promise<Row[]> {\n return getRunner().select(\n this._businessDate,\n this._processingDatetime,\n this._columns,\n this._table,\n this._op,\n this._orderBy,\n this._groupBy,\n this._limit,\n this._timeoutMs,\n this._businessDateTo,\n );\n }\n}\n\nfunction convertDate(value: Date | string | null): Date | null {\n if (value === null) return null;\n if (value instanceof Date) return value;\n // Zone-less strings (YYYY-MM-DD, or YYYY-MM-DD HH:MM[:SS]) are read as UTC, matching how\n // dates are formatted into SQL, so the value doesn't shift with the machine's timezone.\n let normalized = value;\n if (/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) normalized = value + 'T00:00:00Z';\n else if (/^\\d{4}-\\d{2}-\\d{2}[ T]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?$/.test(value)) normalized = value.replace(' ', 'T') + 'Z';\n const d = new Date(normalized);\n if (isNaN(d.getTime())) throw new Error(`Cannot parse date: ${value}`);\n return d;\n}\n\nexport function convertInputsAndSelect(\n businessDate: Date | string | null,\n processingDatetime: Date | string | null,\n columns: (Attribute | RelationalOperationElement)[],\n table: QueryTarget,\n op: RelationalOperationElement = new NoOperation(),\n): FinderResult {\n return new FinderResult(\n convertDate(businessDate),\n convertDate(processingDatetime),\n columns,\n table,\n op,\n );\n}\n\nexport function convertInputsAndSelectForDateRange(\n businessDateFrom: Date | string,\n businessDateTo: Date | string,\n processingDatetime: Date | string,\n columns: (Attribute | RelationalOperationElement)[],\n table: QueryTarget,\n op: RelationalOperationElement = new NoOperation(),\n): FinderResult {\n if (businessDateFrom == null) throw new Error('businessDateFrom is required for findForDateRange');\n if (businessDateTo == null) throw new Error('businessDateTo is required for findForDateRange');\n if (processingDatetime == null) throw new Error('processingValidAt is required for findForDateRange');\n return new FinderResult(\n convertDate(businessDateFrom),\n convertDate(processingDatetime),\n columns,\n table,\n op,\n convertDate(businessDateTo),\n );\n}\n","export enum ComparisonOperator {\n EQUAL = 'EQUAL',\n NOT_EQUAL = 'NOT_EQUAL',\n LESS_THAN = 'LESS_THAN',\n GREATER_THAN = 'GREATER_THAN',\n LESS_THAN_OR_EQUAL_TO = 'LESS_THAN_OR_EQUAL_TO',\n GREATER_THAN_OR_EQUAL_TO = 'GREATER_THAN_OR_EQUAL_TO',\n LIKE = 'LIKE',\n NOT_LIKE = 'NOT_LIKE',\n}\n\nexport enum LogicalOperator {\n AND = 'AND',\n OR = 'OR',\n}\n\nexport enum AggregateOperator {\n COUNT = 'COUNT',\n SUM = 'SUM',\n MIN = 'MIN',\n MAX = 'MAX',\n AVERAGE = 'AVERAGE',\n}\n\nexport enum ScalarFunction {\n ABS = 'ABS',\n CEILING = 'CEILING',\n FLOOR = 'FLOOR',\n MOD = 'MOD',\n POWER = 'POWER',\n SQRT = 'SQRT',\n ROUND = 'ROUND',\n UPPER = 'UPPER',\n LOWER = 'LOWER',\n TRIM = 'TRIM',\n LTRIM = 'LTRIM',\n RTRIM = 'RTRIM',\n LENGTH = 'LENGTH',\n REVERSE = 'REVERSE',\n LEFT = 'LEFT',\n RIGHT = 'RIGHT',\n REPEAT = 'REPEAT',\n REPLACE = 'REPLACE',\n SUBSTRING = 'SUBSTRING',\n}\n\nexport enum DatePart {\n YEAR = 'YEAR',\n MONTH = 'MONTH',\n DAY = 'DAY',\n HOUR = 'HOUR',\n MINUTE = 'MINUTE',\n SECOND = 'SECOND',\n QUARTER = 'QUARTER',\n WEEK = 'WEEK',\n DOW = 'DOW',\n}\n\nexport enum SortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport abstract class RelationalOperationElement {}\n\nexport abstract class Operation extends RelationalOperationElement {\n andOp(other: RelationalOperationElement): Operation {\n return new LogicalOperation(this, LogicalOperator.AND, other);\n }\n}\n\nexport class NoOperation extends Operation {\n andOp(other: RelationalOperationElement): Operation {\n return other as Operation;\n }\n}\n\nexport abstract class ConstantOperation extends RelationalOperationElement {}\n\nexport class IntegerConstantOperation extends ConstantOperation {\n constructor(readonly value: number) { super(); }\n}\n\nexport class FloatConstantOperation extends ConstantOperation {\n constructor(readonly value: number) { super(); }\n}\n\nexport class StringConstantOperation extends ConstantOperation {\n constructor(readonly value: string) { super(); }\n}\n\nexport class DateConstantOperation extends ConstantOperation {\n constructor(readonly value: Date) { super(); }\n}\n\nexport class DateTimeConstantOperation extends ConstantOperation {\n constructor(readonly value: Date) { super(); }\n}\n\nexport class DecimalConstantOperation extends ConstantOperation {\n constructor(readonly value: number) { super(); }\n}\n\nexport class BooleanConstantOperation extends ConstantOperation {\n constructor(readonly value: boolean) { super(); }\n}\n\nexport abstract class UnaryOperation extends Operation {\n constructor(readonly element: RelationalOperationElement) { super(); }\n}\n\nexport abstract class BinaryOperation extends Operation {\n constructor(\n readonly left: RelationalOperationElement,\n readonly right: RelationalOperationElement,\n ) { super(); }\n}\n\nexport class IsNullOperation extends UnaryOperation {}\n\nexport class IsNotNullOperation extends UnaryOperation {}\n\nexport class ComparisonOperation extends BinaryOperation {\n constructor(\n left: RelationalOperationElement,\n readonly operator: ComparisonOperator,\n right: RelationalOperationElement,\n ) { super(left, right); }\n}\n\nexport class LogicalOperation extends BinaryOperation {\n constructor(\n left: RelationalOperationElement,\n readonly operator: LogicalOperator,\n right: RelationalOperationElement,\n ) { super(left, right); }\n}\n\nexport class WindowSpecification {\n constructor(\n readonly partitionBy: RelationalOperationElement[] = [],\n readonly orderBy: SortOperation[] = [],\n ) {}\n}\n\nexport class AggregateOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly operator: AggregateOperator,\n readonly displayName?: string,\n readonly window?: WindowSpecification,\n ) { super(element); }\n\n over(partitionBy?: RelationalOperationElement[], orderBy?: SortOperation[]): AggregateOperation {\n return new AggregateOperation(this.element, this.operator, this.displayName,\n new WindowSpecification(partitionBy ?? [], orderBy ?? []));\n }\n}\n\nexport enum WindowFunction {\n ROW_NUMBER = 'ROW_NUMBER',\n RANK = 'RANK',\n DENSE_RANK = 'DENSE_RANK',\n NTILE = 'NTILE',\n LAG = 'LAG',\n LEAD = 'LEAD',\n FIRST_VALUE = 'FIRST_VALUE',\n LAST_VALUE = 'LAST_VALUE',\n CUME_DIST = 'CUME_DIST',\n PERCENT_RANK = 'PERCENT_RANK',\n}\n\nexport class WindowFunctionOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement | null,\n readonly func: WindowFunction,\n readonly displayName?: string,\n readonly secondArg?: number,\n readonly extraArgs: (string | number)[] = [],\n readonly window?: WindowSpecification,\n ) { super(element as RelationalOperationElement); }\n\n over(partitionBy?: RelationalOperationElement[], orderBy?: SortOperation[]): WindowFunctionOperation {\n return new WindowFunctionOperation(this.element, this.func, this.displayName, this.secondArg,\n [...this.extraArgs], new WindowSpecification(partitionBy ?? [], orderBy ?? []));\n }\n}\n\nexport class ScalarFunctionOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly func: ScalarFunction,\n readonly displayName?: string,\n readonly secondArg?: number,\n readonly extraArgs: (string | number)[] = [],\n ) { super(element); }\n}\n\nexport class DateExtractOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly part: DatePart,\n readonly displayName?: string,\n ) { super(element); }\n}\n\nexport class DateArithmeticOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly n: number,\n readonly unit: DatePart,\n readonly isAdd: boolean = true,\n readonly displayName?: string,\n ) { super(element); }\n}\n\nexport class DateDiffOperation extends UnaryOperation {\n constructor(\n element: RelationalOperationElement,\n readonly other: Date,\n readonly unit: DatePart,\n readonly displayName?: string,\n ) { super(element); }\n}\n\nexport class Column extends RelationalOperationElement {\n table?: Table;\n\n constructor(\n readonly name: string,\n readonly type: string,\n readonly owner?: string,\n readonly primaryKey: boolean = false,\n ) { super(); }\n}\n\nexport class ForeignKey {\n constructor(readonly column: Column, readonly references: Column) {}\n}\n\nexport abstract class DataStore {\n readonly schemas: Schema[] = [];\n\n constructor(readonly name: string) {}\n\n abstract namespace(schemaName: string): string;\n}\n\nexport class Database extends DataStore {\n constructor(name: string, readonly location?: string) { super(name); }\n\n namespace(schemaName: string): string { return schemaName; }\n}\n\nexport class DataCatalog extends DataStore {\n constructor(name: string) { super(name); }\n\n namespace(schemaName: string): string { return `${this.name}.${schemaName}`; }\n}\n\nexport class Schema {\n readonly tables: Table[] = [];\n\n constructor(readonly name: string, readonly datastore?: DataStore) {\n datastore?.schemas.push(this);\n }\n}\n\nexport class Table {\n private readonly _columnsByName: Map<string, Column> = new Map();\n readonly foreignKeys: ForeignKey[] = [];\n\n constructor(readonly name: string, columns: Column[], readonly schema?: Schema) {\n for (const col of columns) {\n if (this._columnsByName.has(col.name)) {\n throw new Error(`Duplicate column name '${col.name}' in table '${name}'`);\n }\n this._columnsByName.set(col.name, col);\n col.table = this;\n }\n schema?.tables.push(this);\n }\n\n get columns(): Column[] {\n return Array.from(this._columnsByName.values());\n }\n\n get qualifiedName(): string {\n if (!this.schema) return this.name;\n if (!this.schema.datastore) return `${this.schema.name}.${this.name}`;\n return `${this.schema.datastore.namespace(this.schema.name)}.${this.name}`;\n }\n}\n\nexport class JoinOperation {\n filter?: RelationalOperationElement;\n /** Property-equality filters on the join target (property id -> value), set by a related finder given a filter. */\n filterKwargs: Record<string, unknown> = {};\n /** Maps property ids to [column, type, table] for `filterKwargs`. */\n filterColumnMap: Record<string, [string, string, string]> = {};\n\n constructor(\n readonly name: string,\n readonly target: Table,\n readonly left: Column,\n readonly right: Column,\n filter?: RelationalOperationElement,\n ) {\n this.filter = filter;\n }\n}\n\nexport class JoinTreeNodeOperation {\n constructor(\n readonly join: JoinOperation,\n readonly parent?: JoinTreeNodeOperation,\n ) {}\n}\n\nexport class ColumnWithJoin extends RelationalOperationElement {\n /**\n * `embedded` is an alternate reference to a flat (denormalized) column on the owning table that\n * holds the same value without the join; the SQL generator uses it when the join can be elided.\n */\n constructor(\n readonly column: Column,\n readonly parent?: JoinTreeNodeOperation,\n readonly embedded?: ColumnWithJoin,\n ) { super(); }\n}\n\nexport class SortOperation {\n constructor(\n readonly column: ColumnWithJoin,\n readonly direction: SortDirection,\n ) {}\n}\n\nexport class CountAllOperation extends RelationalOperationElement {\n constructor(readonly table: string) { super(); }\n}\n\nexport class Alias extends RelationalOperationElement {\n constructor(readonly element: RelationalOperationElement, readonly name: string) { super(); }\n}\n\n/** Returned by `RelatedFinder.exists()`. A backend translates it to a join-presence check. */\nexport class ExistsOperation extends RelationalOperationElement {\n constructor(readonly node: JoinTreeNodeOperation) { super(); }\n\n andOp(other: RelationalOperationElement): LogicalOperation {\n return new LogicalOperation(this, LogicalOperator.AND, other);\n }\n}\n\n/** Returned by `RelatedFinder.notExists()`. A backend translates it to a join-absence check. */\nexport class NotExistsOperation extends RelationalOperationElement {\n constructor(readonly node: JoinTreeNodeOperation) { super(); }\n\n andOp(other: RelationalOperationElement): LogicalOperation {\n return new LogicalOperation(this, LogicalOperator.AND, other);\n }\n}\n\nexport class SelectOperation {\n constructor(\n readonly display: RelationalOperationElement[],\n readonly filter: RelationalOperationElement,\n readonly orderBy: SortOperation[] = [],\n readonly groupBy: RelationalOperationElement[] = [],\n readonly limit?: number,\n readonly table?: Table,\n /**\n * Extra ON conditions for this query's joins (milestoning and property filters), keyed by join node.\n * Held here rather than on the shared JoinOperation, so queries that use the same node can't affect each other.\n */\n readonly joinFilters: ReadonlyMap<JoinTreeNodeOperation, Operation> = new Map(),\n ) {}\n}\n","import {\n Column,\n AggregateOperation,\n AggregateOperator,\n ColumnWithJoin,\n SortOperation,\n SortDirection,\n IsNullOperation,\n IsNotNullOperation,\n JoinTreeNodeOperation,\n WindowFunction,\n WindowFunctionOperation,\n WindowSpecification,\n} from '../model/relational';\n\nexport abstract class Attribute {\n private readonly _displayName: string;\n private readonly _column: Column;\n private readonly _owner: string;\n private readonly _parent?: JoinTreeNodeOperation;\n private readonly _embedded?: Attribute;\n\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) {\n this._displayName = displayName;\n this._column = new Column(columnName, columnDbType, owner);\n this._owner = owner;\n this._parent = parent;\n this._embedded = embedded;\n }\n\n column(): Column { return this._column; }\n owner(): string { return this._owner; }\n parent(): JoinTreeNodeOperation | undefined { return this._parent; }\n displayName(): string { return this._displayName; }\n\n /** Alternate attribute on a flat column of the owning table, used in place of this one when its join is elided. */\n embedded(): Attribute | undefined { return this._embedded; }\n\n cwj(): ColumnWithJoin {\n return new ColumnWithJoin(this._column, this._parent, this._embedded?.cwj());\n }\n\n /** Count the number of non-null values. Use in a projection with `groupByOp` to aggregate per group. */\n count(): AggregateOperation {\n return new AggregateOperation(\n this.cwj(),\n AggregateOperator.COUNT,\n this._displayName + ' Count',\n );\n }\n\n /** Sort this attribute in ascending order. Pass to `orderByOp` or a window function's `orderBy`. */\n ascending(): SortOperation {\n return new SortOperation(this.cwj(), SortDirection.ASC);\n }\n\n /** Sort this attribute in descending order. Pass to `orderByOp` or a window function's `orderBy`. */\n descending(): SortOperation {\n return new SortOperation(this.cwj(), SortDirection.DESC);\n }\n\n /** Filter to rows where this attribute has no value. */\n isNull(): IsNullOperation {\n return new IsNullOperation(this.cwj());\n }\n\n /** Filter to rows where this attribute has a value. */\n isNotNull(): IsNotNullOperation {\n return new IsNotNullOperation(this.cwj());\n }\n\n private _windowSpec(\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[],\n orderBy?: SortOperation | SortOperation[],\n ): WindowSpecification {\n const pbArr = partitionBy === undefined ? [] : Array.isArray(partitionBy) ? partitionBy : [partitionBy];\n const pb = pbArr.map(x => x instanceof Attribute ? x.cwj() : x);\n const ob = orderBy === undefined ? [] : Array.isArray(orderBy) ? orderBy : [orderBy];\n return new WindowSpecification(pb, ob);\n }\n\n /**\n * Assign a rank to each row within the ordered window, following pandas `Series.rank` conventions.\n *\n * `method` controls tie-breaking (default `'min'`):\n * - `'min'` — tied rows share the lowest rank; the next rank skips.\n * - `'dense'` — like `'min'` but ranks are contiguous (no gaps).\n * - `'first'` — each row gets a unique sequential integer (no ties).\n * - `'max'` — only meaningful with `pct: true` (see below).\n *\n * When `pct: true` the result is a relative rank between 0 and 1:\n * - `method: 'min'` (default) → fraction of values strictly below this row (PERCENT_RANK).\n * - `method: 'max'` → fraction of values at or below this row (cumulative distribution).\n *\n * `partitionBy` restarts the ranking within each group of distinct values.\n */\n rank(opts: {\n method?: 'min' | 'dense' | 'first' | 'max';\n pct?: boolean;\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n const { method = 'min', pct = false, partitionBy, orderBy } = opts;\n let func: WindowFunction;\n let name: string;\n if (pct) {\n if (method === 'max') { func = WindowFunction.CUME_DIST; name = 'Cume Dist'; }\n else { func = WindowFunction.PERCENT_RANK; name = 'Percent Rank'; }\n } else if (method === 'first') { func = WindowFunction.ROW_NUMBER; name = 'Row Number'; }\n else if (method === 'dense') { func = WindowFunction.DENSE_RANK; name = 'Dense Rank'; }\n else { func = WindowFunction.RANK; name = 'Rank'; }\n return new WindowFunctionOperation(null, func, name, undefined, [], this._windowSpec(partitionBy, orderBy));\n }\n\n /**\n * Split rows into `buckets` equal-sized quantile bins ordered by `orderBy`.\n * Each row receives a bucket number from 1 (lowest) to `buckets` (highest).\n * Named after `pandas.qcut`.\n */\n qcut(buckets: number, opts: {\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n return new WindowFunctionOperation(null, WindowFunction.NTILE, 'Quantile', buckets, [],\n this._windowSpec(opts.partitionBy, opts.orderBy));\n }\n\n /**\n * Return the value of this attribute from `periods` rows earlier (positive) or later (negative)\n * within the ordered window, following `pandas.Series.shift`.\n * Rows with no neighbour at the given offset return `null` (or `fillValue` if provided).\n */\n shift(periods = 1, opts: {\n fillValue?: string | number;\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n const extraArgs: (string | number)[] = opts.fillValue !== undefined ? [opts.fillValue] : [];\n const func = periods >= 0 ? WindowFunction.LAG : WindowFunction.LEAD;\n const label = periods >= 0 ? 'Lag' : 'Lead';\n return new WindowFunctionOperation(\n this.cwj(),\n func,\n label + ' ' + this._displayName,\n Math.abs(periods),\n extraArgs,\n this._windowSpec(opts.partitionBy, opts.orderBy),\n );\n }\n\n /**\n * Return the first value of this attribute in the window frame.\n * Use `partitionBy` to restart the frame for each group.\n */\n first(opts: {\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n return new WindowFunctionOperation(\n this.cwj(),\n WindowFunction.FIRST_VALUE,\n 'First ' + this._displayName,\n undefined, [],\n this._windowSpec(opts.partitionBy, opts.orderBy),\n );\n }\n\n /**\n * Return the last value of this attribute in the window frame.\n * Use `partitionBy` to restart the frame for each group.\n */\n last(opts: {\n partitionBy?: Attribute | ColumnWithJoin | (Attribute | ColumnWithJoin)[];\n orderBy?: SortOperation | SortOperation[];\n } = {}): WindowFunctionOperation {\n return new WindowFunctionOperation(\n this.cwj(),\n WindowFunction.LAST_VALUE,\n 'Last ' + this._displayName,\n undefined, [],\n this._windowSpec(opts.partitionBy, opts.orderBy),\n );\n }\n}\n","import { Column, Table, Schema } from './relational';\n\nexport abstract class MilestoningColumns {\n abstract columns(): Column[];\n}\n\nexport class ProcessingTemporalColumns extends MilestoningColumns {\n constructor(\n readonly startAtColumn: Column,\n readonly endAtColumn: Column,\n readonly infiniteDatetime?: string,\n ) { super(); }\n\n columns(): Column[] { return [this.startAtColumn, this.endAtColumn]; }\n}\n\nexport class SingleBusinessDateColumn extends MilestoningColumns {\n constructor(readonly businessDateColumn: Column) { super(); }\n\n columns(): Column[] { return [this.businessDateColumn]; }\n}\n\nexport class BusinessDateAndProcessingTemporalColumns extends MilestoningColumns {\n constructor(\n readonly businessDateColumn: Column,\n readonly startAtColumn: Column,\n readonly endAtColumn: Column,\n readonly infiniteDatetime?: string,\n ) { super(); }\n\n columns(): Column[] {\n return [this.businessDateColumn, this.startAtColumn, this.endAtColumn];\n }\n}\n\nexport class BiTemporalColumns extends MilestoningColumns {\n constructor(\n readonly businessDateFromColumn: Column,\n readonly businessDateToColumn: Column,\n readonly startAtColumn: Column,\n readonly endAtColumn: Column,\n readonly infiniteDatetime?: string,\n ) { super(); }\n\n columns(): Column[] {\n return [\n this.businessDateFromColumn,\n this.businessDateToColumn,\n this.startAtColumn,\n this.endAtColumn,\n ];\n }\n}\n\nexport class MilestonedTable extends Table {\n constructor(\n name: string,\n columns: Column[],\n readonly milestoningColumns: MilestoningColumns,\n schema?: Schema,\n ) {\n super(name, columns, schema);\n for (const col of milestoningColumns.columns()) {\n col.table = this;\n }\n }\n}\n","import { Attribute } from './attribute';\nimport {\n ComparisonOperation,\n ComparisonOperator,\n Operation,\n StringConstantOperation,\n FloatConstantOperation,\n IntegerConstantOperation,\n DateConstantOperation,\n DateTimeConstantOperation,\n BooleanConstantOperation,\n DecimalConstantOperation,\n AggregateOperation,\n AggregateOperator,\n ScalarFunction,\n ScalarFunctionOperation,\n DatePart,\n DateExtractOperation,\n DateArithmeticOperation,\n DateDiffOperation,\n JoinTreeNodeOperation,\n} from '../model/relational';\n\nexport class StringAttribute extends Attribute {\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) { super(displayName, columnName, columnDbType, owner, parent, embedded); }\n\n /** Convert every character to uppercase. */\n toUpperCase(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.UPPER, 'Upper ' + this.displayName());\n }\n /** Convert every character to lowercase. */\n toLowerCase(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.LOWER, 'Lower ' + this.displayName());\n }\n /** Remove leading and trailing whitespace. */\n trim(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.TRIM, 'Trim ' + this.displayName());\n }\n /** Remove leading whitespace. */\n trimStart(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.LTRIM, 'Trim Start ' + this.displayName());\n }\n /** Remove trailing whitespace. */\n trimEnd(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.RTRIM, 'Trim End ' + this.displayName());\n }\n /** Return the number of characters in the string. */\n length(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.LENGTH, 'Length ' + this.displayName());\n }\n /** Return the string with characters in reverse order. */\n reverse(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.REVERSE, 'Reverse ' + this.displayName());\n }\n /** Return the first `n` characters. */\n left(n: number): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.LEFT, 'Left ' + this.displayName(), n);\n }\n /** Return the last `n` characters. */\n right(n: number): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.RIGHT, 'Right ' + this.displayName(), n);\n }\n /** Return the string repeated `n` times. */\n repeat(n: number): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.REPEAT, 'Repeat ' + this.displayName(), n);\n }\n /** Replace all occurrences of `fromStr` with `toStr`. */\n replace(fromStr: string, toStr: string): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.REPLACE, 'Replace ' + this.displayName(), undefined, [fromStr, toStr]);\n }\n /**\n * Extract a portion of the string.\n * `start` is zero-based (following Python convention); `length` is optional.\n */\n substring(start: number, length?: number): ScalarFunctionOperation {\n // Python convention: 0-based start; SQL SUBSTRING is 1-based, so add 1\n const args: (number)[] = length !== undefined ? [start + 1, length] : [start + 1];\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.SUBSTRING, 'Substring ' + this.displayName(), undefined, args);\n }\n\n /** Filter to rows where this attribute equals `value`. */\n eq(value: string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.EQUAL, new StringConstantOperation(value));\n }\n /** Filter to rows where this attribute does not equal `value`. */\n ne(value: string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.NOT_EQUAL, new StringConstantOperation(value));\n }\n /** Filter to rows where this attribute contains `value` as a substring. */\n contains(value: string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LIKE, new StringConstantOperation(`%${value}%`));\n }\n /** Filter to rows where this attribute begins with `prefix`. */\n startsWith(prefix: string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LIKE, new StringConstantOperation(`${prefix}%`));\n }\n /** Filter to rows where this attribute ends with `suffix`. */\n endsWith(suffix: string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LIKE, new StringConstantOperation(`%${suffix}`));\n }\n /** Filter to rows where this attribute does not contain `value` as a substring. */\n notContains(value: string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.NOT_LIKE, new StringConstantOperation(`%${value}%`));\n }\n}\n\nexport abstract class NumericAttribute extends Attribute {\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) { super(displayName, columnName, columnDbType, owner, parent, embedded); }\n\n /** Sum of all values in the group. */\n sum(): AggregateOperation {\n return new AggregateOperation(this.cwj(), AggregateOperator.SUM, 'Sum ' + this.displayName());\n }\n /** Smallest value in the group. */\n min(): AggregateOperation {\n return new AggregateOperation(this.cwj(), AggregateOperator.MIN, 'Min ' + this.displayName());\n }\n /** Largest value in the group. */\n max(): AggregateOperation {\n return new AggregateOperation(this.cwj(), AggregateOperator.MAX, 'Max ' + this.displayName());\n }\n /** Arithmetic mean of all values in the group. */\n average(): AggregateOperation {\n return new AggregateOperation(this.cwj(), AggregateOperator.AVERAGE, 'Average ' + this.displayName());\n }\n /** Absolute value (distance from zero, always non-negative). */\n abs(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.ABS, 'Abs ' + this.displayName());\n }\n /** Round up to the nearest integer. */\n ceil(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.CEILING, 'Ceil ' + this.displayName());\n }\n /** Round down to the nearest integer. */\n floor(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.FLOOR, 'Floor ' + this.displayName());\n }\n /** Square root. */\n sqrt(): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.SQRT, 'Sqrt ' + this.displayName());\n }\n /** Remainder after dividing by `n`. */\n mod(n: number): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.MOD, 'Mod ' + this.displayName(), n);\n }\n /** Raise to the power of `n`. */\n power(n: number): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.POWER, 'Power ' + this.displayName(), n);\n }\n /** Round to `d` decimal places, or to the nearest integer when `d` is omitted. */\n round(d?: number): ScalarFunctionOperation {\n return new ScalarFunctionOperation(this.cwj(), ScalarFunction.ROUND, 'Round ' + this.displayName(), d);\n }\n}\n\nexport class DoubleAttribute extends NumericAttribute {\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) { super(displayName, columnName, columnDbType, owner, parent, embedded); }\n\n /** Filter to rows where this attribute equals `value`. */\n eq(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.EQUAL, new FloatConstantOperation(value));\n }\n /** Filter to rows where this attribute does not equal `value`. */\n ne(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.NOT_EQUAL, new FloatConstantOperation(value));\n }\n /** Filter to rows where this attribute is greater than `value`. */\n gt(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN, new FloatConstantOperation(value));\n }\n /** Filter to rows where this attribute is less than `value`. */\n lt(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN, new FloatConstantOperation(value));\n }\n /** Filter to rows where this attribute is greater than or equal to `value`. */\n gte(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN_OR_EQUAL_TO, new FloatConstantOperation(value));\n }\n /** Filter to rows where this attribute is less than or equal to `value`. */\n lte(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN_OR_EQUAL_TO, new FloatConstantOperation(value));\n }\n}\n\nexport const FloatAttribute = DoubleAttribute;\nexport type FloatAttribute = DoubleAttribute;\n\nexport class DecimalAttribute extends NumericAttribute {\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) { super(displayName, columnName, columnDbType, owner, parent, embedded); }\n\n /** Filter to rows where this attribute equals `value`. */\n eq(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.EQUAL, new DecimalConstantOperation(value));\n }\n /** Filter to rows where this attribute does not equal `value`. */\n ne(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.NOT_EQUAL, new DecimalConstantOperation(value));\n }\n /** Filter to rows where this attribute is greater than `value`. */\n gt(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN, new DecimalConstantOperation(value));\n }\n /** Filter to rows where this attribute is less than `value`. */\n lt(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN, new DecimalConstantOperation(value));\n }\n /** Filter to rows where this attribute is greater than or equal to `value`. */\n gte(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN_OR_EQUAL_TO, new DecimalConstantOperation(value));\n }\n /** Filter to rows where this attribute is less than or equal to `value`. */\n lte(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN_OR_EQUAL_TO, new DecimalConstantOperation(value));\n }\n}\n\nexport class IntegerAttribute extends NumericAttribute {\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) { super(displayName, columnName, columnDbType, owner, parent, embedded); }\n\n /** Filter to rows where this attribute equals `value`. */\n eq(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.EQUAL, new IntegerConstantOperation(value));\n }\n /** Filter to rows where this attribute does not equal `value`. */\n ne(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.NOT_EQUAL, new IntegerConstantOperation(value));\n }\n /** Filter to rows where this attribute is greater than `value`. */\n gt(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN, new IntegerConstantOperation(value));\n }\n /** Filter to rows where this attribute is less than `value`. */\n lt(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN, new IntegerConstantOperation(value));\n }\n /** Filter to rows where this attribute is greater than or equal to `value`. */\n gte(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN_OR_EQUAL_TO, new IntegerConstantOperation(value));\n }\n /** Filter to rows where this attribute is less than or equal to `value`. */\n lte(value: number): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN_OR_EQUAL_TO, new IntegerConstantOperation(value));\n }\n}\n\nexport class BooleanAttribute extends Attribute {\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) { super(displayName, columnName, columnDbType, owner, parent, embedded); }\n\n /** Filter to rows where this attribute equals `value`. */\n eq(value: boolean): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.EQUAL, new BooleanConstantOperation(value));\n }\n /** Filter to rows where this attribute is true. */\n isTrue(): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.EQUAL, new BooleanConstantOperation(true));\n }\n /** Filter to rows where this attribute is false. */\n isFalse(): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.EQUAL, new BooleanConstantOperation(false));\n }\n}\n\nfunction parseDate(value: Date | string): Date {\n if (value instanceof Date) return value;\n const d = new Date(value);\n if (isNaN(d.getTime())) throw new Error(`Cannot parse date: ${value}`);\n return d;\n}\n\nexport class DateAttribute extends Attribute {\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) { super(displayName, columnName, columnDbType, owner, parent, embedded); }\n\n /** Filter to rows where this date equals `value`. */\n eq(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.EQUAL, new DateConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this date does not equal `value`. */\n ne(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.NOT_EQUAL, new DateConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this date is after `value`. */\n gt(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN, new DateConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this date is before `value`. */\n lt(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN, new DateConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this date is on or after `value`. */\n gte(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN_OR_EQUAL_TO, new DateConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this date is on or before `value`. */\n lte(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN_OR_EQUAL_TO, new DateConstantOperation(parseDate(value)));\n }\n\n /** Extract the four-digit calendar year. */\n year(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.YEAR, 'Year ' + this.displayName()); }\n /** Extract the month number (1–12). */\n month(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.MONTH, 'Month ' + this.displayName()); }\n /** Extract the day of the month (1–31). */\n day(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.DAY, 'Day ' + this.displayName()); }\n /** Extract the quarter (1–4). */\n quarter(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.QUARTER, 'Quarter ' + this.displayName()); }\n /** Extract the ISO week number (1–53). */\n week(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.WEEK, 'Week ' + this.displayName()); }\n /** Extract the day of the week (0 = Sunday through 6 = Saturday). */\n dayOfWeek(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.DOW, 'Day Of Week ' + this.displayName()); }\n\n /** Add `n` days to this date. */\n addDays(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.DAY, true, 'Add Days ' + this.displayName()); }\n /** Add `n` months to this date. */\n addMonths(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.MONTH, true, 'Add Months ' + this.displayName()); }\n /** Add `n` years to this date. */\n addYears(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.YEAR, true, 'Add Years ' + this.displayName()); }\n /** Subtract `n` days from this date. */\n subtractDays(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.DAY, false, 'Subtract Days ' + this.displayName()); }\n /** Subtract `n` months from this date. */\n subtractMonths(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.MONTH, false, 'Subtract Months ' + this.displayName()); }\n /** Subtract `n` years from this date. */\n subtractYears(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.YEAR, false, 'Subtract Years ' + this.displayName()); }\n\n /** Number of whole days between this date and `other`. */\n diffDays(other: Date): DateDiffOperation { return new DateDiffOperation(this.cwj(), other, DatePart.DAY, 'Diff Days ' + this.displayName()); }\n /** Number of whole months between this date and `other`. */\n diffMonths(other: Date): DateDiffOperation { return new DateDiffOperation(this.cwj(), other, DatePart.MONTH, 'Diff Months ' + this.displayName()); }\n /** Number of whole years between this date and `other`. */\n diffYears(other: Date): DateDiffOperation { return new DateDiffOperation(this.cwj(), other, DatePart.YEAR, 'Diff Years ' + this.displayName()); }\n}\n\nexport class DateTimeAttribute extends Attribute {\n constructor(\n displayName: string,\n columnName: string,\n columnDbType: string,\n owner: string,\n parent?: JoinTreeNodeOperation,\n embedded?: Attribute,\n ) { super(displayName, columnName, columnDbType, owner, parent, embedded); }\n\n /** Filter to rows where this timestamp equals `value`. */\n eq(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.EQUAL, new DateTimeConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this timestamp does not equal `value`. */\n ne(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.NOT_EQUAL, new DateTimeConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this timestamp is after `value`. */\n gt(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN, new DateTimeConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this timestamp is before `value`. */\n lt(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN, new DateTimeConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this timestamp is on or after `value`. */\n gte(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.GREATER_THAN_OR_EQUAL_TO, new DateTimeConstantOperation(parseDate(value)));\n }\n /** Filter to rows where this timestamp is on or before `value`. */\n lte(value: Date | string): Operation {\n return new ComparisonOperation(this.cwj(), ComparisonOperator.LESS_THAN_OR_EQUAL_TO, new DateTimeConstantOperation(parseDate(value)));\n }\n\n /** Extract the four-digit calendar year. */\n year(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.YEAR, 'Year ' + this.displayName()); }\n /** Extract the month number (1–12). */\n month(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.MONTH, 'Month ' + this.displayName()); }\n /** Extract the day of the month (1–31). */\n day(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.DAY, 'Day ' + this.displayName()); }\n /** Extract the hour (0–23). */\n hour(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.HOUR, 'Hour ' + this.displayName()); }\n /** Extract the minute (0–59). */\n minute(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.MINUTE, 'Minute ' + this.displayName()); }\n /** Extract the second (0–59). */\n second(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.SECOND, 'Second ' + this.displayName()); }\n /** Extract the quarter (1–4). */\n quarter(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.QUARTER, 'Quarter ' + this.displayName()); }\n /** Extract the ISO week number (1–53). */\n week(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.WEEK, 'Week ' + this.displayName()); }\n /** Extract the day of the week (0 = Sunday through 6 = Saturday). */\n dayOfWeek(): DateExtractOperation { return new DateExtractOperation(this.cwj(), DatePart.DOW, 'Day Of Week ' + this.displayName()); }\n\n /** Add `n` days to this timestamp. */\n addDays(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.DAY, true, 'Add Days ' + this.displayName()); }\n /** Add `n` months to this timestamp. */\n addMonths(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.MONTH, true, 'Add Months ' + this.displayName()); }\n /** Add `n` years to this timestamp. */\n addYears(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.YEAR, true, 'Add Years ' + this.displayName()); }\n /** Add `n` hours to this timestamp. */\n addHours(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.HOUR, true, 'Add Hours ' + this.displayName()); }\n /** Add `n` minutes to this timestamp. */\n addMinutes(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.MINUTE, true, 'Add Minutes ' + this.displayName()); }\n /** Add `n` seconds to this timestamp. */\n addSeconds(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.SECOND, true, 'Add Seconds ' + this.displayName()); }\n /** Subtract `n` days from this timestamp. */\n subtractDays(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.DAY, false, 'Subtract Days ' + this.displayName()); }\n /** Subtract `n` months from this timestamp. */\n subtractMonths(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.MONTH, false, 'Subtract Months ' + this.displayName()); }\n /** Subtract `n` years from this timestamp. */\n subtractYears(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.YEAR, false, 'Subtract Years ' + this.displayName()); }\n /** Subtract `n` hours from this timestamp. */\n subtractHours(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.HOUR, false, 'Subtract Hours ' + this.displayName()); }\n /** Subtract `n` minutes from this timestamp. */\n subtractMinutes(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.MINUTE, false, 'Subtract Minutes ' + this.displayName()); }\n /** Subtract `n` seconds from this timestamp. */\n subtractSeconds(n: number): DateArithmeticOperation { return new DateArithmeticOperation(this.cwj(), n, DatePart.SECOND, false, 'Subtract Seconds ' + this.displayName()); }\n\n /** Number of whole days between this timestamp and `other`. */\n diffDays(other: Date): DateDiffOperation { return new DateDiffOperation(this.cwj(), other, DatePart.DAY, 'Diff Days ' + this.displayName()); }\n /** Number of whole months between this timestamp and `other`. */\n diffMonths(other: Date): DateDiffOperation { return new DateDiffOperation(this.cwj(), other, DatePart.MONTH, 'Diff Months ' + this.displayName()); }\n /** Number of whole years between this timestamp and `other`. */\n diffYears(other: Date): DateDiffOperation { return new DateDiffOperation(this.cwj(), other, DatePart.YEAR, 'Diff Years ' + this.displayName()); }\n /** Number of whole hours between this timestamp and `other`. */\n diffHours(other: Date): DateDiffOperation { return new DateDiffOperation(this.cwj(), other, DatePart.HOUR, 'Diff Hours ' + this.displayName()); }\n /** Number of whole minutes between this timestamp and `other`. */\n diffMinutes(other: Date): DateDiffOperation { return new DateDiffOperation(this.cwj(), other, DatePart.MINUTE, 'Diff Minutes ' + this.displayName()); }\n /** Number of whole seconds between this timestamp and `other`. */\n diffSeconds(other: Date): DateDiffOperation { return new DateDiffOperation(this.cwj(), other, DatePart.SECOND, 'Diff Seconds ' + this.displayName()); }\n}\n","import { Attribute } from './attribute';\nimport {\n RelationalOperationElement,\n Operation,\n NoOperation,\n ConstantOperation,\n StringConstantOperation,\n IntegerConstantOperation,\n FloatConstantOperation,\n DateConstantOperation,\n DateTimeConstantOperation,\n BooleanConstantOperation,\n DecimalConstantOperation,\n LogicalOperation,\n LogicalOperator,\n ComparisonOperation,\n ComparisonOperator,\n IsNullOperation,\n IsNotNullOperation,\n AggregateOperation,\n AggregateOperator,\n ScalarFunctionOperation,\n ScalarFunction,\n DateExtractOperation,\n DateArithmeticOperation,\n DateDiffOperation,\n WindowFunction,\n WindowFunctionOperation,\n WindowSpecification,\n Column,\n ColumnWithJoin,\n Table,\n JoinOperation,\n JoinTreeNodeOperation,\n SortOperation,\n SortDirection,\n CountAllOperation,\n UnaryOperation,\n Alias,\n ExistsOperation,\n NotExistsOperation,\n SelectOperation,\n} from '../model/relational';\nimport {\n MilestonedTable,\n BiTemporalColumns,\n BusinessDateAndProcessingTemporalColumns,\n ProcessingTemporalColumns,\n SingleBusinessDateColumn,\n} from '../model/milestoning';\nimport { DateAttribute, DateTimeAttribute } from './typed-attributes';\n\nclass TableAlias {\n constructor(readonly table: string, readonly alias: string) {}\n}\n\nclass TableAliasColumn extends RelationalOperationElement {\n constructor(readonly column: Column, readonly tableAlias: TableAlias) { super(); }\n}\n\nclass Join {\n constructor(\n readonly source: TableAliasColumn,\n readonly target: TableAliasColumn,\n readonly filterOp?: RelationalOperationElement,\n ) {}\n}\n\nfunction sqlFormatDatetime(value: Date): string {\n const pad = (n: number, w = 2) => String(n).padStart(w, '0');\n return `'${value.getUTCFullYear()}-${pad(value.getUTCMonth() + 1)}-${pad(value.getUTCDate())} ${pad(value.getUTCHours())}:${pad(value.getUTCMinutes())}:${pad(value.getUTCSeconds())}'`;\n}\n\nfunction sqlFormatDate(value: Date): string {\n const pad = (n: number) => String(n).padStart(2, '0');\n return `'${value.getUTCFullYear()}-${pad(value.getUTCMonth() + 1)}-${pad(value.getUTCDate())}'`;\n}\n\nconst LOGICAL_OPERATOR_STR: Record<LogicalOperator, string> = {\n [LogicalOperator.AND]: ' AND ',\n [LogicalOperator.OR]: ' OR ',\n};\n\nconst COMPARISON_OPERATOR_STR: Record<ComparisonOperator, string> = {\n [ComparisonOperator.EQUAL]: ' = ',\n [ComparisonOperator.NOT_EQUAL]: ' <> ',\n [ComparisonOperator.LESS_THAN]: ' < ',\n [ComparisonOperator.GREATER_THAN]: ' > ',\n [ComparisonOperator.LESS_THAN_OR_EQUAL_TO]: ' <= ',\n [ComparisonOperator.GREATER_THAN_OR_EQUAL_TO]: ' >= ',\n [ComparisonOperator.LIKE]: ' LIKE ',\n [ComparisonOperator.NOT_LIKE]: ' NOT LIKE ',\n};\n\nconst AGGREGATE_SQL_NAMES: Partial<Record<AggregateOperator, string>> = {\n [AggregateOperator.AVERAGE]: 'AVG',\n};\n\nconst WINDOW_SQL_NAMES: Record<WindowFunction, string> = {\n [WindowFunction.ROW_NUMBER]: 'ROW_NUMBER',\n [WindowFunction.RANK]: 'RANK',\n [WindowFunction.DENSE_RANK]: 'DENSE_RANK',\n [WindowFunction.NTILE]: 'NTILE',\n [WindowFunction.LAG]: 'LAG',\n [WindowFunction.LEAD]: 'LEAD',\n [WindowFunction.FIRST_VALUE]: 'FIRST_VALUE',\n [WindowFunction.LAST_VALUE]: 'LAST_VALUE',\n [WindowFunction.CUME_DIST]: 'CUME_DIST',\n [WindowFunction.PERCENT_RANK]: 'PERCENT_RANK',\n};\n\nconst SCALAR_SQL_NAMES: Record<ScalarFunction, string> = {\n [ScalarFunction.ABS]: 'ABS',\n [ScalarFunction.CEILING]: 'CEILING',\n [ScalarFunction.FLOOR]: 'FLOOR',\n [ScalarFunction.MOD]: 'MOD',\n [ScalarFunction.POWER]: 'POWER',\n [ScalarFunction.SQRT]: 'SQRT',\n [ScalarFunction.ROUND]: 'ROUND',\n [ScalarFunction.UPPER]: 'UPPER',\n [ScalarFunction.LOWER]: 'LOWER',\n [ScalarFunction.TRIM]: 'TRIM',\n [ScalarFunction.LTRIM]: 'LTRIM',\n [ScalarFunction.RTRIM]: 'RTRIM',\n [ScalarFunction.LENGTH]: 'LENGTH',\n [ScalarFunction.REVERSE]: 'REVERSE',\n [ScalarFunction.LEFT]: 'LEFT',\n [ScalarFunction.RIGHT]: 'RIGHT',\n [ScalarFunction.REPEAT]: 'REPEAT',\n [ScalarFunction.REPLACE]: 'REPLACE',\n [ScalarFunction.SUBSTRING]: 'SUBSTRING',\n};\n\nfunction constantValueString(op: ConstantOperation): string {\n if (op instanceof StringConstantOperation) return \"'\" + op.value + \"'\";\n if (op instanceof DateConstantOperation) return sqlFormatDate(op.value);\n if (op instanceof DateTimeConstantOperation) return sqlFormatDatetime(op.value);\n if (op instanceof IntegerConstantOperation) return String(op.value);\n if (op instanceof FloatConstantOperation) return String(op.value);\n if (op instanceof BooleanConstantOperation) return op.value ? 'TRUE' : 'FALSE';\n if (op instanceof DecimalConstantOperation) return String(op.value);\n throw new Error('Unknown constant operation');\n}\n\nfunction windowSpecToString(window: WindowSpecification): string {\n const parts: string[] = [];\n if (window.partitionBy.length > 0) {\n parts.push('PARTITION BY ' + window.partitionBy.map(p => sqlOperationToString(p)).join(', '));\n }\n if (window.orderBy.length > 0) {\n parts.push('ORDER BY ' + window.orderBy.map(s =>\n sqlOperationToString(s.column) + (s.direction === SortDirection.ASC ? ' ASC' : ' DESC'),\n ).join(', '));\n }\n return 'OVER (' + parts.join(' ') + ')';\n}\n\nfunction sqlOperationToString(operation: RelationalOperationElement): string {\n if (operation instanceof TableAliasColumn) {\n return operation.tableAlias.alias + '.' + operation.column.name;\n }\n if (operation instanceof WindowFunctionOperation) {\n const fn = WINDOW_SQL_NAMES[operation.func];\n const parts: string[] = [];\n if (operation.element !== null && operation.element !== undefined) {\n parts.push(sqlOperationToString(operation.element));\n }\n if (operation.secondArg !== undefined) parts.push(String(operation.secondArg));\n for (const arg of operation.extraArgs) {\n parts.push(typeof arg === 'string' ? \"'\" + arg + \"'\" : String(arg));\n }\n const sql = fn + '(' + parts.join(', ') + ')';\n return sql + (operation.window !== undefined ? ' ' + windowSpecToString(operation.window) : ' OVER ()');\n }\n if (operation instanceof AggregateOperation) {\n const fn = AGGREGATE_SQL_NAMES[operation.operator] ?? operation.operator;\n let sql = fn + '(' + sqlOperationToString(operation.element) + ')';\n if (operation.window !== undefined) {\n sql += ' ' + windowSpecToString(operation.window);\n }\n return sql;\n }\n if (operation instanceof ScalarFunctionOperation) {\n const fn = SCALAR_SQL_NAMES[operation.func];\n const parts: string[] = [sqlOperationToString(operation.element)];\n if (operation.secondArg !== undefined) parts.push(String(operation.secondArg));\n for (const arg of operation.extraArgs) {\n parts.push(typeof arg === 'string' ? \"'\" + arg + \"'\" : String(arg));\n }\n return fn + '(' + parts.join(', ') + ')';\n }\n if (operation instanceof DateExtractOperation) {\n return 'EXTRACT(' + operation.part + ' FROM ' + sqlOperationToString(operation.element) + ')';\n }\n if (operation instanceof DateArithmeticOperation) {\n const op = operation.isAdd ? '+' : '-';\n return sqlOperationToString(operation.element) + ' ' + op + ' INTERVAL ' + operation.n + ' ' + operation.unit;\n }\n if (operation instanceof DateDiffOperation) {\n const otherSql = sqlFormatDatetime(operation.other);\n return \"DATE_DIFF('\" + operation.unit.toLowerCase() + \"', \" + sqlOperationToString(operation.element) + ', ' + otherSql + ')';\n }\n if (operation instanceof CountAllOperation) return 'COUNT(*)';\n if (operation instanceof Alias) {\n return sqlOperationToString(operation.element) + ' AS \"' + operation.name + '\"';\n }\n throw new TypeError('Unknown operation in sqlOperationToString: ' + operation.constructor.name);\n}\n\nfunction embeddedOf(ref: Attribute | ColumnWithJoin): Attribute | ColumnWithJoin | undefined {\n return ref instanceof Attribute ? ref.embedded() : ref.embedded;\n}\n\nfunction findColumn(operation: RelationalOperationElement): ColumnWithJoin {\n if (operation instanceof UnaryOperation) return findColumn(operation.element);\n if (operation instanceof ColumnWithJoin) return operation;\n throw new TypeError('Cannot find ColumnWithJoin in: ' + operation.constructor.name);\n}\n\nfunction openEndClause(\n endAttr: DateTimeAttribute | DateAttribute,\n value: Date,\n infiniteDatetime?: string,\n): Operation {\n const gtOp = endAttr instanceof DateTimeAttribute ? endAttr.gt(value) : endAttr.gt(value);\n if (infiniteDatetime === undefined) {\n const colRef = new ColumnWithJoin(endAttr.column(), endAttr.parent());\n return new LogicalOperation(gtOp, LogicalOperator.OR, new IsNullOperation(colRef));\n }\n return gtOp;\n}\n\nfunction buildMilestoningFilterOperation(\n businessDate: Date | null,\n processingDatetime: Date | null,\n table: MilestonedTable,\n joinNode?: JoinTreeNodeOperation,\n): Operation | null {\n const mc = table.milestoningColumns;\n const ops: Operation[] = [];\n\n if (mc instanceof BiTemporalColumns) {\n if (businessDate !== null) {\n const dateFrom = new DateAttribute('business_date_from', mc.businessDateFromColumn.name, mc.businessDateFromColumn.type, mc.businessDateFromColumn.table!.qualifiedName, joinNode);\n const dateTo = new DateAttribute('business_date_to', mc.businessDateToColumn.name, mc.businessDateToColumn.type, mc.businessDateToColumn.table!.qualifiedName, joinNode);\n ops.push(new LogicalOperation(dateFrom.lte(businessDate), LogicalOperator.AND, openEndClause(dateTo, businessDate, mc.infiniteDatetime)));\n }\n if (processingDatetime !== null) {\n const startAt = new DateTimeAttribute('start_at', mc.startAtColumn.name, mc.startAtColumn.type, mc.startAtColumn.table!.qualifiedName, joinNode);\n const endAt = new DateTimeAttribute('end_at', mc.endAtColumn.name, mc.endAtColumn.type, mc.endAtColumn.table!.qualifiedName, joinNode);\n ops.push(new LogicalOperation(startAt.lte(processingDatetime), LogicalOperator.AND, openEndClause(endAt, processingDatetime, mc.infiniteDatetime)));\n }\n } else if (mc instanceof BusinessDateAndProcessingTemporalColumns) {\n if (businessDate !== null) {\n const businessAtt = new DateAttribute('business_date', mc.businessDateColumn.name, mc.businessDateColumn.type, mc.businessDateColumn.table!.qualifiedName, joinNode);\n ops.push(businessAtt.eq(businessDate));\n }\n if (processingDatetime !== null) {\n const startAt = new DateTimeAttribute('start_at', mc.startAtColumn.name, mc.startAtColumn.type, mc.startAtColumn.table!.qualifiedName, joinNode);\n const endAt = new DateTimeAttribute('end_at', mc.endAtColumn.name, mc.endAtColumn.type, mc.endAtColumn.table!.qualifiedName, joinNode);\n ops.push(new LogicalOperation(startAt.lte(processingDatetime), LogicalOperator.AND, openEndClause(endAt, processingDatetime, mc.infiniteDatetime)));\n }\n } else if (mc instanceof ProcessingTemporalColumns && processingDatetime !== null) {\n const startAt = new DateTimeAttribute('start_at', mc.startAtColumn.name, mc.startAtColumn.type, mc.startAtColumn.table!.qualifiedName, joinNode);\n const endAt = new DateTimeAttribute('end_at', mc.endAtColumn.name, mc.endAtColumn.type, mc.endAtColumn.table!.qualifiedName, joinNode);\n ops.push(new LogicalOperation(startAt.lte(processingDatetime), LogicalOperator.AND, openEndClause(endAt, processingDatetime, mc.infiniteDatetime)));\n } else if (mc instanceof SingleBusinessDateColumn && businessDate !== null) {\n const businessAtt = new DateAttribute('business_date', mc.businessDateColumn.name, mc.businessDateColumn.type, mc.businessDateColumn.table!.qualifiedName, joinNode);\n ops.push(businessAtt.eq(businessDate));\n }\n\n if (ops.length === 0) return null;\n if (ops.length === 1) return ops[0];\n return new LogicalOperation(ops[0], LogicalOperator.AND, ops[1]);\n}\n\n/**\n * Like buildMilestoningFilterOperation but applies a business-date range filter.\n *\n * Bitemporal tables use interval overlap:\n * business_date_from_col <= businessDateTo AND business_date_to_col > businessDateFrom\n * Single-date tables:\n * business_date >= businessDateFrom AND business_date <= businessDateTo\n * Processing-date filtering is point-in-time, as in the normal path.\n */\nfunction buildMilestoningFilterOperationForDateRange(\n businessDateFrom: Date | null,\n businessDateTo: Date | null,\n processingDatetime: Date | null,\n table: MilestonedTable,\n joinNode?: JoinTreeNodeOperation,\n): Operation | null {\n const mc = table.milestoningColumns;\n const ops: Operation[] = [];\n const hasRange = businessDateFrom !== null && businessDateTo !== null;\n\n const processingOp = (m: BiTemporalColumns | BusinessDateAndProcessingTemporalColumns | ProcessingTemporalColumns): Operation => {\n const startAt = new DateTimeAttribute('start_at', m.startAtColumn.name, m.startAtColumn.type, m.startAtColumn.table!.qualifiedName, joinNode);\n const endAt = new DateTimeAttribute('end_at', m.endAtColumn.name, m.endAtColumn.type, m.endAtColumn.table!.qualifiedName, joinNode);\n return new LogicalOperation(startAt.lte(processingDatetime!), LogicalOperator.AND, openEndClause(endAt, processingDatetime!, m.infiniteDatetime));\n };\n\n if (mc instanceof BiTemporalColumns) {\n if (hasRange) {\n const dateFrom = new DateAttribute('business_date_from', mc.businessDateFromColumn.name, mc.businessDateFromColumn.type, mc.businessDateFromColumn.table!.qualifiedName, joinNode);\n const dateTo = new DateAttribute('business_date_to', mc.businessDateToColumn.name, mc.businessDateToColumn.type, mc.businessDateToColumn.table!.qualifiedName, joinNode);\n ops.push(new LogicalOperation(dateFrom.lte(businessDateTo!), LogicalOperator.AND, openEndClause(dateTo, businessDateFrom!, mc.infiniteDatetime)));\n }\n if (processingDatetime !== null) ops.push(processingOp(mc));\n } else if (mc instanceof BusinessDateAndProcessingTemporalColumns) {\n if (hasRange) {\n const businessAtt = new DateAttribute('business_date', mc.businessDateColumn.name, mc.businessDateColumn.type, mc.businessDateColumn.table!.qualifiedName, joinNode);\n ops.push(new LogicalOperation(businessAtt.gte(businessDateFrom!), LogicalOperator.AND, businessAtt.lte(businessDateTo!)));\n }\n if (processingDatetime !== null) ops.push(processingOp(mc));\n } else if (mc instanceof ProcessingTemporalColumns) {\n if (processingDatetime !== null) ops.push(processingOp(mc));\n } else if (mc instanceof SingleBusinessDateColumn && hasRange) {\n const businessAtt = new DateAttribute('business_date', mc.businessDateColumn.name, mc.businessDateColumn.type, mc.businessDateColumn.table!.qualifiedName, joinNode);\n ops.push(new LogicalOperation(businessAtt.gte(businessDateFrom!), LogicalOperator.AND, businessAtt.lte(businessDateTo!)));\n }\n\n if (ops.length === 0) return null;\n if (ops.length === 1) return ops[0];\n return new LogicalOperation(ops[0], LogicalOperator.AND, ops[1]);\n}\n\ntype RefVisitor = (ref: Attribute | ColumnWithJoin) => void;\n\ntype NodeVisitor = (node: JoinTreeNodeOperation) => void;\n\n/**\n * Call `visit` for every Attribute/ColumnWithJoin referenced anywhere in `op`, and `visitExists` for the\n * join node of every exists()/notExists(). The latter are not attribute references, so they don't count\n * against whether other references to the same node can be satisfied by an embedded alternate.\n */\nfunction walkRefs(\n op: RelationalOperationElement | null | undefined,\n visit: RefVisitor,\n visitExists?: NodeVisitor,\n): void {\n if (op === null || op === undefined) return;\n if (op instanceof Attribute || op instanceof ColumnWithJoin) {\n visit(op);\n } else if (op instanceof ExistsOperation || op instanceof NotExistsOperation) {\n visitExists?.(op.node);\n } else if (op instanceof AggregateOperation) {\n walkRefs(op.element, visit, visitExists);\n if (op.window) walkWindowSpec(op.window, visit, visitExists);\n } else if (op instanceof WindowFunctionOperation) {\n if (op.element) walkRefs(op.element, visit, visitExists);\n if (op.window) walkWindowSpec(op.window, visit, visitExists);\n } else if (op instanceof ScalarFunctionOperation || op instanceof DateExtractOperation ||\n op instanceof DateArithmeticOperation || op instanceof DateDiffOperation ||\n op instanceof IsNullOperation || op instanceof IsNotNullOperation) {\n walkRefs((op as UnaryOperation).element, visit, visitExists);\n } else if (op instanceof SortOperation) {\n walkRefs(op.column, visit, visitExists);\n } else if (op instanceof LogicalOperation || op instanceof ComparisonOperation) {\n walkRefs((op as any).left, visit, visitExists);\n walkRefs((op as any).right, visit, visitExists);\n }\n}\n\nfunction walkWindowSpec(window: WindowSpecification, visit: RefVisitor, visitExists?: NodeVisitor): void {\n for (const p of window.partitionBy) walkRefs(p, visit, visitExists);\n for (const s of window.orderBy) walkRefs(s.column, visit, visitExists);\n}\n\n/**\n * Translate property-equality filters given to a related finder (e.g. `ef.projects({ code: 'ALPHA' })`)\n * into a relational filter on the join node. `columnMap` maps property ids to [column, type, table].\n */\nfunction buildJoinFilterFromProperties(\n node: JoinTreeNodeOperation,\n filter: Record<string, unknown>,\n columnMap: Record<string, [string, string, string]>,\n): Operation {\n const ops: Operation[] = [];\n for (const [key, value] of Object.entries(filter)) {\n const entry = columnMap[key];\n if (entry === undefined) {\n throw new Error(`Unknown property '${key}' — valid properties are: ${Object.keys(columnMap).sort().join(', ')}`);\n }\n const [name, type, table] = entry;\n const col = new ColumnWithJoin(new Column(name, type, table), node);\n let constant: ConstantOperation;\n if (typeof value === 'boolean') constant = new BooleanConstantOperation(value);\n else if (typeof value === 'number') constant = Number.isInteger(value) ? new IntegerConstantOperation(value) : new FloatConstantOperation(value);\n else if (value instanceof Date) constant = type.toUpperCase() === 'DATE' ? new DateConstantOperation(value) : new DateTimeConstantOperation(value);\n else constant = new StringConstantOperation(String(value));\n ops.push(new ComparisonOperation(col, ComparisonOperator.EQUAL, constant));\n }\n return ops.reduce((acc, op) => new LogicalOperation(acc, LogicalOperator.AND, op));\n}\n\n/**\n * The nodes plus every ancestor, each once, ancestors first. The SQL generator joins a node's\n * ancestors whenever it joins the node, so each of them needs its join filter set too, not only the\n * nodes an expression refers to directly.\n */\nfunction withAncestors(nodes: Iterable<JoinTreeNodeOperation>): JoinTreeNodeOperation[] {\n const ordered = new Set<JoinTreeNodeOperation>();\n const add = (node: JoinTreeNodeOperation): void => {\n if (ordered.has(node)) return;\n if (node.parent !== undefined) add(node.parent);\n ordered.add(node);\n };\n for (const node of nodes) add(node);\n return [...ordered];\n}\n\nfunction buildQueryOperation(\n businessDate: Date | null,\n processingDatetime: Date | null,\n columns: (Attribute | RelationalOperationElement)[],\n table: Table,\n op: RelationalOperationElement,\n orderBy: SortOperation[] = [],\n groupBy: Attribute[] = [],\n limit?: number,\n businessDateTo: Date | null = null,\n): SelectOperation {\n let filter = op;\n const milestoningFor = (t: MilestonedTable, node?: JoinTreeNodeOperation) =>\n businessDateTo !== null\n ? buildMilestoningFilterOperationForDateRange(businessDate, businessDateTo, processingDatetime, t, node)\n : buildMilestoningFilterOperation(businessDate, processingDatetime, t, node);\n\n if (table instanceof MilestonedTable) {\n const milestonedOp = milestoningFor(table);\n if (milestonedOp !== null) {\n filter = filter instanceof NoOperation\n ? milestonedOp\n : new LogicalOperation(filter, LogicalOperator.AND, milestonedOp);\n }\n }\n\n const requiredJoins = new Set<JoinTreeNodeOperation>();\n const collect: RefVisitor = ref => {\n const parent = ref instanceof Attribute ? ref.parent() : ref.parent;\n if (parent !== undefined) requiredJoins.add(parent);\n };\n const collectNode: NodeVisitor = node => requiredJoins.add(node);\n for (const col of columns) walkRefs(col, collect, collectNode);\n for (const expr of groupBy) walkRefs(expr, collect, collectNode);\n for (const sort of orderBy) walkRefs(sort, collect, collectNode);\n walkRefs(op, collect, collectNode);\n\n const joinFilters = new Map<JoinTreeNodeOperation, Operation>();\n for (const node of withAncestors(requiredJoins)) {\n let combined: Operation | undefined;\n if (Object.keys(node.join.filterKwargs).length > 0) {\n combined = buildJoinFilterFromProperties(node, node.join.filterKwargs, node.join.filterColumnMap);\n }\n if (node.join.target instanceof MilestonedTable) {\n const milestonedOp = milestoningFor(node.join.target, node);\n if (milestonedOp !== null) {\n combined = combined === undefined ? milestonedOp : new LogicalOperation(combined, LogicalOperator.AND, milestonedOp);\n }\n }\n if (combined !== undefined) joinFilters.set(node, combined);\n }\n\n return new SelectOperation(columns, filter, orderBy, groupBy, limit, table, joinFilters);\n}\n\nclass SQLQueryGenerator {\n private _select: Alias[] = [];\n private _from: Set<TableAlias> = new Set();\n private _join: Join[] = [];\n private _groupByParts: string[] = [];\n private _orderByParts: string[] = [];\n private _where = '';\n private _limit?: number;\n private _tableAliasIncr = 0;\n private _tableAliasesByTable = new Map<unknown, TableAlias>();\n private _addedJoinIds = new Set<JoinTreeNodeOperation>();\n private _rootTable?: Table;\n private _elidableNodes = new Set<JoinTreeNodeOperation>();\n private _joinFilters: ReadonlyMap<JoinTreeNodeOperation, Operation> = new Map();\n\n generate(select: SelectOperation): void {\n this._rootTable = select.table;\n this._elidableNodes = this._computeElidableNodes(select);\n this._joinFilters = select.joinFilters;\n if (this._rootTable !== undefined) {\n this._from.add(this._tableAliasForTable(this._rootTable.qualifiedName, this._rootTable.qualifiedName));\n }\n this.processSelect(select.display);\n this._where = this.buildFilter(select.filter);\n const groupByJoins = new Map<JoinTreeNodeOperation, JoinTreeNodeOperation>();\n for (const expr of select.groupBy) {\n this._collectRequiredJoins(expr, groupByJoins);\n }\n for (const node of groupByJoins.values()) {\n this._addJoin(node);\n }\n this._groupByParts = select.groupBy.map(a => this._attrToColString(a as Attribute));\n this._orderByParts = select.orderBy.map(s =>\n this.buildFilter(s.column) + (s.direction === SortDirection.ASC ? ' ASC' : ' DESC'),\n );\n this._limit = select.limit;\n }\n\n private _attrToColString(attr: Attribute): string {\n const { column, parent } = this._resolve(attr);\n const ta = this._tableAliasForTable(column.owner!, parent ?? column.owner!);\n return ta.alias + '.' + column.name;\n }\n\n private _collectRequiredJoins(op: RelationalOperationElement | null | undefined, out: Map<JoinTreeNodeOperation, JoinTreeNodeOperation>): void {\n walkRefs(op, ref => {\n const { parent } = this._resolve(ref);\n if (parent !== undefined) out.set(parent, parent);\n });\n }\n\n /**\n * Determine upfront which join nodes can be satisfied entirely by embedded (join-less) alternates:\n * a node is elidable when every reference to it has an embedded alternate. A reference without one\n * (e.g. a milestoning column) keeps the join for every reference to that node.\n */\n private _computeElidableNodes(select: SelectOperation): Set<JoinTreeNodeOperation> {\n const refsByNode = new Map<JoinTreeNodeOperation, (Attribute | ColumnWithJoin)[]>();\n const record = (ref: Attribute | ColumnWithJoin) => {\n const parent = ref instanceof Attribute ? ref.parent() : ref.parent;\n if (parent === undefined) return;\n const refs = refsByNode.get(parent);\n if (refs) refs.push(ref); else refsByNode.set(parent, [ref]);\n };\n for (const col of select.display) walkRefs(col, record);\n for (const expr of select.groupBy) walkRefs(expr, record);\n for (const sort of select.orderBy) walkRefs(sort, record);\n walkRefs(select.filter, record);\n\n const elidable = new Set<JoinTreeNodeOperation>();\n for (const [node, refs] of refsByNode) {\n if (refs.every(ref => embeddedOf(ref) !== undefined)) elidable.add(node);\n }\n return elidable;\n }\n\n /** The (column, parent) a reference should resolve to, substituting its embedded alternate when its join is elided. */\n private _resolve(ref: Attribute | ColumnWithJoin): { column: Column; parent?: JoinTreeNodeOperation } {\n const column = ref instanceof Attribute ? ref.column() : ref.column;\n const parent = ref instanceof Attribute ? ref.parent() : ref.parent;\n if (parent !== undefined && this._elidableNodes.has(parent)) {\n const embedded = embeddedOf(ref);\n if (embedded !== undefined) return this._resolve(embedded);\n }\n return { column, parent };\n }\n\n private _rewriteWindowSpec(window: WindowSpecification): WindowSpecification {\n const partitionBy = window.partitionBy.map(p => this._rewriteOperation(p));\n const orderBy = window.orderBy.map(s => new SortOperation(this._rewriteOperation(s.column) as ColumnWithJoin, s.direction));\n return new WindowSpecification(partitionBy, orderBy);\n }\n\n private _rewriteOperation(op: RelationalOperationElement): RelationalOperationElement {\n if (op instanceof Attribute || op instanceof ColumnWithJoin) {\n const { column, parent } = this._resolve(op);\n return new TableAliasColumn(column, this._tableAliasForTable(column.owner!, parent ?? column.owner!));\n }\n if (op instanceof Column) {\n const ta = this._tableAliasForTable(op.owner!, op.owner!);\n return new TableAliasColumn(op, ta);\n }\n if (op instanceof AggregateOperation) {\n return new AggregateOperation(\n this._rewriteOperation(op.element), op.operator, op.displayName,\n op.window ? this._rewriteWindowSpec(op.window) : undefined,\n );\n }\n if (op instanceof WindowFunctionOperation) {\n const el = op.element ? this._rewriteOperation(op.element) : null;\n return new WindowFunctionOperation(el, op.func, op.displayName, op.secondArg, [...op.extraArgs],\n op.window ? this._rewriteWindowSpec(op.window) : undefined);\n }\n if (op instanceof ScalarFunctionOperation) {\n return new ScalarFunctionOperation(this._rewriteOperation(op.element), op.func, op.displayName, op.secondArg, op.extraArgs);\n }\n if (op instanceof DateExtractOperation) {\n return new DateExtractOperation(this._rewriteOperation(op.element), op.part, op.displayName);\n }\n if (op instanceof DateArithmeticOperation) {\n return new DateArithmeticOperation(this._rewriteOperation(op.element), op.n, op.unit, op.isAdd, op.displayName);\n }\n if (op instanceof DateDiffOperation) {\n return new DateDiffOperation(this._rewriteOperation(op.element), (op as DateDiffOperation).other, (op as DateDiffOperation).unit, op.displayName);\n }\n return op;\n }\n\n private processSelect(cols: (Attribute | RelationalOperationElement)[]): void {\n const requiredJoins = new Map<JoinTreeNodeOperation, JoinTreeNodeOperation>();\n\n for (const col of cols) {\n this._collectRequiredJoins(col, requiredJoins);\n }\n for (const node of requiredJoins.values()) {\n this._addJoin(node);\n }\n\n for (const col of cols) {\n if (col instanceof Attribute) {\n const { column, parent: node } = this._resolve(col);\n let ta: TableAlias;\n if (node !== undefined) {\n ta = this._tableAliasForTable(column.owner!, node);\n } else {\n ta = this._tableAliasForTable(column.owner!, column.owner!);\n this._from.add(ta);\n }\n this._select.push(new Alias(new TableAliasColumn(column, ta), col.displayName()));\n } else if (col instanceof WindowFunctionOperation) {\n const rewritten = this._rewriteOperation(col) as WindowFunctionOperation;\n let alias: string;\n if (col.displayName) {\n alias = col.displayName;\n } else if ([WindowFunction.ROW_NUMBER, WindowFunction.RANK, WindowFunction.DENSE_RANK].includes(col.func)) {\n alias = col.func.replace(/_/g, ' ').replace(/\\b\\w/g, c => c.toUpperCase());\n } else if (col.element) {\n alias = col.func + ' ' + findColumn(col).column.name;\n } else {\n alias = col.func;\n }\n this._select.push(new Alias(rewritten, alias));\n } else if (col instanceof AggregateOperation) {\n const colNested = this._resolve(findColumn(col));\n const node = colNested.parent;\n let ta: TableAlias;\n if (node !== undefined) {\n ta = this._tableAliasForTable(colNested.column.owner!, node);\n } else {\n ta = this._tableAliasForTable(colNested.column.owner!, colNested.column.owner!);\n this._from.add(ta);\n }\n const alias = col.displayName ?? col.operator + ' ' + findColumn(col).column.name;\n const rewrittenAgg = new AggregateOperation(\n new TableAliasColumn(colNested.column, ta), col.operator, undefined,\n col.window ? this._rewriteWindowSpec(col.window) : undefined,\n );\n this._select.push(new Alias(rewrittenAgg, alias));\n } else if (col instanceof ScalarFunctionOperation) {\n const colNested = this._resolve(findColumn(col));\n const node = colNested.parent;\n let ta: TableAlias;\n if (node !== undefined) {\n ta = this._tableAliasForTable(colNested.column.owner!, node);\n } else {\n ta = this._tableAliasForTable(colNested.column.owner!, colNested.column.owner!);\n this._from.add(ta);\n }\n const alias = col.displayName ?? col.func + ' ' + findColumn(col).column.name;\n this._select.push(new Alias(\n new ScalarFunctionOperation(new TableAliasColumn(colNested.column, ta), col.func, undefined, col.secondArg, col.extraArgs),\n alias,\n ));\n } else if (col instanceof DateExtractOperation || col instanceof DateArithmeticOperation || col instanceof DateDiffOperation) {\n const colNested = this._resolve(findColumn(col as RelationalOperationElement));\n const node = colNested.parent;\n let ta: TableAlias;\n if (node !== undefined) {\n ta = this._tableAliasForTable(colNested.column.owner!, node);\n } else {\n ta = this._tableAliasForTable(colNested.column.owner!, colNested.column.owner!);\n this._from.add(ta);\n }\n const alias = (col as DateExtractOperation).displayName ?? findColumn(col as RelationalOperationElement).column.name;\n let aliasedOp: RelationalOperationElement;\n if (col instanceof DateExtractOperation) {\n aliasedOp = new DateExtractOperation(new TableAliasColumn(colNested.column, ta), col.part);\n } else if (col instanceof DateArithmeticOperation) {\n aliasedOp = new DateArithmeticOperation(new TableAliasColumn(colNested.column, ta), col.n, col.unit, col.isAdd);\n } else {\n aliasedOp = new DateDiffOperation(new TableAliasColumn(colNested.column, ta), (col as DateDiffOperation).other, (col as DateDiffOperation).unit);\n }\n this._select.push(new Alias(aliasedOp, alias));\n } else if (col instanceof CountAllOperation) {\n const ta = this._tableAliasForTable(col.table, col.table);\n this._from.add(ta);\n this._select.push(new Alias(col, 'Count'));\n }\n }\n }\n\n private _addJoin(node: JoinTreeNodeOperation): void {\n if (this._addedJoinIds.has(node)) return;\n if (node.parent !== undefined) this._addJoin(node.parent);\n this._addedJoinIds.add(node);\n\n const join = node.join;\n const left = join.left;\n const srcTa = this._tableAliasForTable(left.owner!, node.parent ?? left.owner!);\n if (node.parent === undefined) this._from.add(srcTa);\n const sc = new TableAliasColumn(left, srcTa);\n const right = join.right;\n const tc = new TableAliasColumn(right, this._tableAliasForTable(right.owner!, node));\n const queryFilter = this._joinFilters.get(node);\n const filterOp = join.filter !== undefined && queryFilter !== undefined\n ? new LogicalOperation(join.filter as Operation, LogicalOperator.AND, queryFilter)\n : join.filter ?? queryFilter;\n this._join.push(new Join(sc, tc, filterOp));\n }\n\n buildFilter(op: RelationalOperationElement): string {\n if (op instanceof NoOperation) return '';\n if (op instanceof ExistsOperation) {\n const col = op.node.join.right;\n return this.buildFilter(new ColumnWithJoin(col, op.node)) + ' IS NOT NULL';\n }\n if (op instanceof NotExistsOperation) {\n const col = op.node.join.right;\n return this.buildFilter(new ColumnWithJoin(col, op.node)) + ' IS NULL';\n }\n if (op instanceof IsNotNullOperation) return this.buildFilter(op.element) + ' IS NOT NULL';\n if (op instanceof IsNullOperation) return this.buildFilter(op.element) + ' IS NULL';\n if (op instanceof LogicalOperation) {\n let left = this.buildFilter(op.left);\n let right = this.buildFilter(op.right);\n if (op.left instanceof LogicalOperation) left = '(' + left + ')';\n if (op.right instanceof LogicalOperation) right = '(' + right + ')';\n return left + LOGICAL_OPERATOR_STR[op.operator] + right;\n }\n if (op instanceof ComparisonOperation) {\n return this.buildFilter(op.left) + COMPARISON_OPERATOR_STR[op.operator] + this.buildFilter(op.right);\n }\n if (op instanceof ConstantOperation) return constantValueString(op);\n if (op instanceof ColumnWithJoin) {\n const { column, parent: node } = this._resolve(op);\n let ta: TableAlias;\n if (node !== undefined) {\n ta = this._tableAliasForTable(column.owner!, node);\n this._addJoin(node);\n } else {\n ta = this._tableAliasForTable(column.owner!, column.owner!);\n }\n return ta.alias + '.' + column.name;\n }\n if (op instanceof Column) {\n const ta = this._tableAliasForTable(op.owner!, op.owner!);\n return ta.alias + '.' + op.name;\n }\n throw new Error('Unknown operation in buildFilter: ' + op.constructor.name);\n }\n\n private _tableAliasForTable(table: string, key: unknown): TableAlias {\n if (this._tableAliasesByTable.has(key)) {\n return this._tableAliasesByTable.get(key)!;\n }\n const ta = new TableAlias(table, 't' + this._tableAliasIncr++);\n this._tableAliasesByTable.set(key, ta);\n return ta;\n }\n\n buildQueryString(): string {\n const joins = this._join.map(j =>\n ' LEFT OUTER JOIN ' + j.target.tableAlias.table + ' AS ' + j.target.tableAlias.alias +\n ' ON ' + j.source.tableAlias.alias + '.' + j.source.column.name +\n ' = ' + j.target.tableAlias.alias + '.' + j.target.column.name +\n (j.filterOp ? ' AND ' + this.buildFilter(j.filterOp) : ''),\n );\n\n return 'SELECT ' + this._select.map(ca => sqlOperationToString(ca)).join(',') +\n ' FROM ' + Array.from(this._from).map(ta => ta.table + ' AS ' + ta.alias).join(',') +\n joins.join('') +\n this._buildWhere() +\n this._buildGroupBy() +\n this._buildOrderBy() +\n this._buildLimit();\n }\n\n private _buildWhere(): string {\n return this._where.length > 0 ? ' WHERE ' + this._where : '';\n }\n private _buildGroupBy(): string {\n return this._groupByParts.length > 0 ? ' GROUP BY ' + this._groupByParts.join(', ') : '';\n }\n private _buildOrderBy(): string {\n return this._orderByParts.length > 0 ? ' ORDER BY ' + this._orderByParts.join(', ') : '';\n }\n private _buildLimit(): string {\n return this._limit !== undefined ? ' LIMIT ' + this._limit : '';\n }\n}\n\nexport function selectSqlToString(selectOperation: SelectOperation): string {\n const qg = new SQLQueryGenerator();\n qg.generate(selectOperation);\n return qg.buildQueryString();\n}\n\nexport function toSql(\n businessDate: Date | null,\n processingDatetime: Date | null,\n columns: (Attribute | RelationalOperationElement)[],\n table: Table,\n op: RelationalOperationElement,\n orderBy: SortOperation[] = [],\n groupBy: Attribute[] = [],\n limit?: number,\n businessDateTo: Date | null = null,\n): string {\n const selectOp = buildQueryOperation(businessDate, processingDatetime, columns, table, op, orderBy, groupBy, limit, businessDateTo);\n return selectSqlToString(selectOp);\n}\n\nexport { buildQueryOperation };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;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AAI,MAAM,oDAAoD;AACpG,SAAO,IAAI;AAAA,IACT,YAAY,gBAAgB;AAAA,IAC5B,YAAY,kBAAkB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,cAAc;AAAA,EAC5B;AACF;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Attribute } from './attribute.cjs';
|
|
2
|
+
import { RelationalOperationElement, SortOperation } from '../model/relational.cjs';
|
|
3
|
+
|
|
4
|
+
type Row = unknown[];
|
|
5
|
+
declare const DEFAULT_TIMEOUT_MS = 60000;
|
|
6
|
+
/** Thrown by a QueryRunner when a query runs longer than the timeout set on its FinderResult. */
|
|
7
|
+
declare class QueryTimeoutError extends Error {
|
|
8
|
+
readonly timeoutMs: number;
|
|
9
|
+
constructor(timeoutMs: number);
|
|
10
|
+
}
|
|
11
|
+
/** Minimum interface satisfied by both Table (SQL) and GraphQLQuery (GraphQL). */
|
|
12
|
+
interface QueryTarget {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
}
|
|
15
|
+
interface QueryRunner {
|
|
16
|
+
select(businessDate: Date | null, processingDatetime: Date | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op: RelationalOperationElement, orderBy?: SortOperation[], groupBy?: Attribute[], limit?: number, timeoutMs?: number, businessDateTo?: Date | null): Promise<Row[]>;
|
|
17
|
+
}
|
|
18
|
+
declare function registerRunner(runner: QueryRunner): void;
|
|
19
|
+
declare function clearRunner(): void;
|
|
20
|
+
declare function getRunner(): QueryRunner;
|
|
21
|
+
declare class FinderResult {
|
|
22
|
+
private readonly _businessDate;
|
|
23
|
+
private readonly _processingDatetime;
|
|
24
|
+
private readonly _columns;
|
|
25
|
+
private readonly _table;
|
|
26
|
+
private readonly _op;
|
|
27
|
+
private readonly _businessDateTo;
|
|
28
|
+
private _orderBy;
|
|
29
|
+
private _groupBy;
|
|
30
|
+
private _limit?;
|
|
31
|
+
private _timeoutMs;
|
|
32
|
+
constructor(_businessDate: Date | null, _processingDatetime: Date | null, _columns: (Attribute | RelationalOperationElement)[], _table: QueryTarget, _op: RelationalOperationElement, _businessDateTo?: Date | null);
|
|
33
|
+
orderByOp(...sorts: SortOperation[]): this;
|
|
34
|
+
groupByOp(...attrs: Attribute[]): this;
|
|
35
|
+
limit(n: number): this;
|
|
36
|
+
/** Abort the query and throw QueryTimeoutError if it runs longer than `milliseconds` (default 60000). */
|
|
37
|
+
timeout(milliseconds: number): this;
|
|
38
|
+
toSql(): string;
|
|
39
|
+
toRows(): Promise<Row[]>;
|
|
40
|
+
}
|
|
41
|
+
declare function convertInputsAndSelect(businessDate: Date | string | null, processingDatetime: Date | string | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op?: RelationalOperationElement): FinderResult;
|
|
42
|
+
declare function convertInputsAndSelectForDateRange(businessDateFrom: Date | string, businessDateTo: Date | string, processingDatetime: Date | string, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op?: RelationalOperationElement): FinderResult;
|
|
43
|
+
|
|
44
|
+
export { DEFAULT_TIMEOUT_MS, FinderResult, type QueryRunner, type QueryTarget, QueryTimeoutError, type Row, clearRunner, convertInputsAndSelect, convertInputsAndSelectForDateRange, getRunner, registerRunner };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Attribute } from './attribute.js';
|
|
2
|
+
import { RelationalOperationElement, SortOperation } from '../model/relational.js';
|
|
3
|
+
|
|
4
|
+
type Row = unknown[];
|
|
5
|
+
declare const DEFAULT_TIMEOUT_MS = 60000;
|
|
6
|
+
/** Thrown by a QueryRunner when a query runs longer than the timeout set on its FinderResult. */
|
|
7
|
+
declare class QueryTimeoutError extends Error {
|
|
8
|
+
readonly timeoutMs: number;
|
|
9
|
+
constructor(timeoutMs: number);
|
|
10
|
+
}
|
|
11
|
+
/** Minimum interface satisfied by both Table (SQL) and GraphQLQuery (GraphQL). */
|
|
12
|
+
interface QueryTarget {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
}
|
|
15
|
+
interface QueryRunner {
|
|
16
|
+
select(businessDate: Date | null, processingDatetime: Date | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op: RelationalOperationElement, orderBy?: SortOperation[], groupBy?: Attribute[], limit?: number, timeoutMs?: number, businessDateTo?: Date | null): Promise<Row[]>;
|
|
17
|
+
}
|
|
18
|
+
declare function registerRunner(runner: QueryRunner): void;
|
|
19
|
+
declare function clearRunner(): void;
|
|
20
|
+
declare function getRunner(): QueryRunner;
|
|
21
|
+
declare class FinderResult {
|
|
22
|
+
private readonly _businessDate;
|
|
23
|
+
private readonly _processingDatetime;
|
|
24
|
+
private readonly _columns;
|
|
25
|
+
private readonly _table;
|
|
26
|
+
private readonly _op;
|
|
27
|
+
private readonly _businessDateTo;
|
|
28
|
+
private _orderBy;
|
|
29
|
+
private _groupBy;
|
|
30
|
+
private _limit?;
|
|
31
|
+
private _timeoutMs;
|
|
32
|
+
constructor(_businessDate: Date | null, _processingDatetime: Date | null, _columns: (Attribute | RelationalOperationElement)[], _table: QueryTarget, _op: RelationalOperationElement, _businessDateTo?: Date | null);
|
|
33
|
+
orderByOp(...sorts: SortOperation[]): this;
|
|
34
|
+
groupByOp(...attrs: Attribute[]): this;
|
|
35
|
+
limit(n: number): this;
|
|
36
|
+
/** Abort the query and throw QueryTimeoutError if it runs longer than `milliseconds` (default 60000). */
|
|
37
|
+
timeout(milliseconds: number): this;
|
|
38
|
+
toSql(): string;
|
|
39
|
+
toRows(): Promise<Row[]>;
|
|
40
|
+
}
|
|
41
|
+
declare function convertInputsAndSelect(businessDate: Date | string | null, processingDatetime: Date | string | null, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op?: RelationalOperationElement): FinderResult;
|
|
42
|
+
declare function convertInputsAndSelectForDateRange(businessDateFrom: Date | string, businessDateTo: Date | string, processingDatetime: Date | string, columns: (Attribute | RelationalOperationElement)[], table: QueryTarget, op?: RelationalOperationElement): FinderResult;
|
|
43
|
+
|
|
44
|
+
export { DEFAULT_TIMEOUT_MS, FinderResult, type QueryRunner, type QueryTarget, QueryTimeoutError, type Row, clearRunner, convertInputsAndSelect, convertInputsAndSelectForDateRange, getRunner, registerRunner };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_TIMEOUT_MS,
|
|
3
|
+
FinderResult,
|
|
4
|
+
QueryTimeoutError,
|
|
5
|
+
clearRunner,
|
|
6
|
+
convertInputsAndSelect,
|
|
7
|
+
convertInputsAndSelectForDateRange,
|
|
8
|
+
getRunner,
|
|
9
|
+
registerRunner
|
|
10
|
+
} from "../chunk-FJYA2ASS.js";
|
|
11
|
+
import "../chunk-MH4XMYVB.js";
|
|
12
|
+
import "../chunk-PMPLCEWQ.js";
|
|
13
|
+
import "../chunk-4LNZV6EN.js";
|
|
14
|
+
import "../chunk-4JVW4TAB.js";
|
|
15
|
+
import "../chunk-UYMOE6YU.js";
|
|
16
|
+
export {
|
|
17
|
+
DEFAULT_TIMEOUT_MS,
|
|
18
|
+
FinderResult,
|
|
19
|
+
QueryTimeoutError,
|
|
20
|
+
clearRunner,
|
|
21
|
+
convertInputsAndSelect,
|
|
22
|
+
convertInputsAndSelectForDateRange,
|
|
23
|
+
getRunner,
|
|
24
|
+
registerRunner
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|