@milaboratories/ptabler-expression-js 1.1.22 → 1.1.24

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.
@@ -1 +1 @@
1
- {"version":3,"file":"expressions.js","sources":["../src/expressions.ts"],"sourcesContent":["/**\n * Base expressionImpl classes and interfaces for PTabler JavaScript implementation\n */\n\nimport type {\n AggregationType,\n BinaryArithmeticExpression,\n BinaryArithmeticOperator,\n BooleanLogicExpression,\n ColumnReferenceExpression,\n ComparisonExpression,\n ComparisonOperator,\n ConstantValueExpression,\n CumsumExpression,\n Expression,\n ExtendedUnaryStringExpression,\n FillNaNExpression,\n FillNullExpression,\n FuzzyFilterDistanceMetric,\n FuzzyStringFilterExpression,\n MinMaxExpression,\n MinMaxOperator,\n NotExpression,\n RankExpression,\n StringContainsExpression,\n StringDistanceExpression,\n StringDistanceMetric,\n StringJoinExpression,\n StringReplaceExpression,\n SubstringExpression,\n UnaryArithmeticExpression,\n UnaryArithmeticOperator,\n WhenThenOtherwiseExpression,\n WindowExpression,\n} from \"./types\";\n\n/**\n * Base abstract class for all expressions\n */\nexport abstract class ExpressionImpl {\n protected _alias?: string;\n\n /**\n * Convert the expressionImpl to JSON format compatible with PTabler schema\n */\n abstract toJSON(): Expression;\n\n /**\n * Get the alias for this expressionImpl (defaults to a generated name)\n */\n abstract getAlias(): string;\n\n /**\n * Set an alias for this expression\n */\n alias(name: string): ExpressionImpl {\n const cloned = this.clone();\n cloned._alias = name;\n return cloned;\n }\n\n /**\n * Clone this expression\n */\n protected abstract clone(): ExpressionImpl;\n\n // Arithmetic operations\n plus(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"plus\", this, coerceToExpression(other));\n }\n\n minus(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"minus\", this, coerceToExpression(other));\n }\n\n multiply(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"multiply\", this, coerceToExpression(other));\n }\n\n truediv(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"truediv\", this, coerceToExpression(other));\n }\n\n floordiv(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"floordiv\", this, coerceToExpression(other));\n }\n\n // Comparison operations\n gt(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"gt\", this, coerceToExpression(other));\n }\n\n ge(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"ge\", this, coerceToExpression(other));\n }\n\n eq(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"eq\", this, coerceToExpression(other));\n }\n\n lt(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"lt\", this, coerceToExpression(other));\n }\n\n le(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"le\", this, coerceToExpression(other));\n }\n\n neq(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"neq\", this, coerceToExpression(other));\n }\n\n // Logical operations\n and(...others: ExpressionImpl[]): LogicalExpressionImpl {\n return new LogicalExpressionImpl(\"and\", [this, ...others]);\n }\n\n or(...others: ExpressionImpl[]): LogicalExpressionImpl {\n return new LogicalExpressionImpl(\"or\", [this, ...others]);\n }\n\n not(): LogicalExpressionImpl {\n return new LogicalExpressionImpl(\"not\", [this]);\n }\n\n // Unary arithmetic operations\n abs(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"abs\", this);\n }\n\n sqrt(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"sqrt\", this);\n }\n\n log(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"log\", this);\n }\n\n log10(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"log10\", this);\n }\n\n log2(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"log2\", this);\n }\n\n floor(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"floor\", this);\n }\n\n ceil(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"ceil\", this);\n }\n\n round(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"round\", this);\n }\n\n negate(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"negate\", this);\n }\n\n // Null checks\n isNull(): NullCheckExpressionImpl {\n return new NullCheckExpressionImpl(\"is_na\", this);\n }\n\n isNotNull(): NullCheckExpressionImpl {\n return new NullCheckExpressionImpl(\"is_not_na\", this);\n }\n\n // Fill null/NaN\n fillNull(value: ExpressionImpl): FillNullExpressionImpl {\n return new FillNullExpressionImpl(this, coerceToExpression(value));\n }\n\n fillNaN(value: ExpressionImpl): FillNaNExpressionImpl {\n return new FillNaNExpressionImpl(this, coerceToExpression(value));\n }\n\n // String operations\n strConcat(...others: (ExpressionImpl | string)[]): StringConcatExpressionImpl {\n return new StringConcatExpressionImpl([this, ...others.map(coerceToExpression)]);\n }\n\n substring(start: number, length?: number): SubstringExpressionImpl {\n return new SubstringExpressionImpl(this, start, length);\n }\n\n strReplace(\n pattern: string,\n value: string,\n options?: Pick<StringReplaceExpression, \"replaceAll\" | \"literal\">,\n ): StringReplaceExpressionImpl {\n return new StringReplaceExpressionImpl(this, pattern, value, options);\n }\n\n strContains(\n pattern: ExpressionImpl | string,\n literal?: boolean,\n strict?: boolean,\n ): StringContainsExpressionImpl {\n return new StringContainsExpressionImpl(this, coerceToExpression(pattern), literal, strict);\n }\n\n strToUpper(): StringCaseExpressionImpl {\n return new StringCaseExpressionImpl(\"to_upper\", this);\n }\n\n strToLower(): StringCaseExpressionImpl {\n return new StringCaseExpressionImpl(\"to_lower\", this);\n }\n\n strStartsWith(pattern: ExpressionImpl | string): StringStartsWithExpressionImpl {\n return new StringStartsWithExpressionImpl(this, coerceToExpression(pattern));\n }\n\n strEndsWith(pattern: ExpressionImpl | string): StringEndsWithExpressionImpl {\n return new StringEndsWithExpressionImpl(this, coerceToExpression(pattern));\n }\n\n // Aggregation operations\n sum(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"sum\", this);\n }\n\n mean(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"mean\", this);\n }\n\n count(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"count\", this);\n }\n\n min(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"min\", this);\n }\n\n max(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"max\", this);\n }\n\n first(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"first\", this);\n }\n\n last(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"last\", this);\n }\n\n cumsum(): CumsumExpressionImpl {\n return new CumsumExpressionImpl(this);\n }\n\n // Fuzzy operations\n stringDistance(\n other: ExpressionImpl | string,\n metric: StringDistanceMetric,\n returnSimilarity?: boolean,\n ): StringDistanceExpressionImpl {\n return new StringDistanceExpressionImpl(\n this,\n coerceToExpression(other),\n metric,\n returnSimilarity,\n );\n }\n\n fuzzyStringFilter(\n pattern: ExpressionImpl | string,\n metric: FuzzyFilterDistanceMetric,\n bound: number,\n ): FuzzyStringFilterExpressionImpl {\n return new FuzzyStringFilterExpressionImpl(this, coerceToExpression(pattern), metric, bound);\n }\n}\n\nexport class ColumnExpressionImpl extends ExpressionImpl {\n constructor(private readonly columnName: string) {\n super();\n }\n\n toJSON(): ColumnReferenceExpression {\n return {\n type: \"col\",\n name: this.columnName,\n };\n }\n\n getAlias(): string {\n return this._alias || this.columnName;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new ColumnExpressionImpl(this.columnName);\n cloned._alias = this._alias;\n return cloned;\n }\n\n /**\n * Get the column name\n */\n getColumnName(): string {\n return this.columnName;\n }\n}\n\n/**\n * Helper function to coerce values to expressions\n */\nexport function coerceToExpression(value: ExpressionImpl | LiteralValue): ExpressionImpl {\n if (value instanceof ExpressionImpl) {\n return value;\n }\n return new LiteralExpressionImpl(value);\n}\n\nexport class MinMaxExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly op: MinMaxOperator,\n private readonly ops: ExpressionImpl[],\n ) {\n super();\n }\n\n toJSON(): MinMaxExpression {\n return {\n type: this.op,\n operands: this.ops.map((o) => o.toJSON()),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.op}_${this.ops.map((o) => o.getAlias()).join(\"_\")}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new MinMaxExpressionImpl(this.op, this.ops);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\n// Forward declarations for concrete expressionImpl classes\n// These will be imported from their respective modules\nexport class ArithmeticExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: BinaryArithmeticOperator,\n private readonly lhs: ExpressionImpl,\n private readonly rhs: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): BinaryArithmeticExpression {\n return {\n type: this.operator,\n lhs: this.lhs.toJSON(),\n rhs: this.rhs.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.lhs.getAlias()}_${this.operator}_${this.rhs.getAlias()}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new ArithmeticExpressionImpl(this.operator, this.lhs, this.rhs);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class ComparisonExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: ComparisonOperator,\n private readonly lhs: ExpressionImpl,\n private readonly rhs: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): ComparisonExpression {\n return {\n type: this.operator,\n lhs: this.lhs.toJSON(),\n rhs: this.rhs.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.lhs.getAlias()}_${this.operator}_${this.rhs.getAlias()}`;\n }\n\n protected clone(): ComparisonExpressionImpl {\n const cloned = new ComparisonExpressionImpl(this.operator, this.lhs, this.rhs);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class LogicalExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: \"and\" | \"or\" | \"not\",\n private readonly operands: ExpressionImpl[],\n ) {\n super();\n }\n\n toJSON(): NotExpression | BooleanLogicExpression {\n if (this.operator === \"not\") {\n return {\n type: \"not\",\n value: this.operands[0].toJSON(),\n };\n }\n return {\n type: this.operator,\n operands: this.operands.map((op) => op.toJSON()),\n };\n }\n\n getAlias(): string {\n if (this._alias) return this._alias;\n if (this.operator === \"not\") {\n return `not_${this.operands[0].getAlias()}`;\n }\n return this.operands.map((op) => op.getAlias()).join(`_${this.operator}_`);\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new LogicalExpressionImpl(this.operator, this.operands);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class UnaryArithmeticExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: UnaryArithmeticOperator,\n private readonly value: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): UnaryArithmeticExpression {\n return {\n type: this.operator,\n value: this.value.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.operator}_${this.value.getAlias()}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new UnaryArithmeticExpressionImpl(this.operator, this.value);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class NullCheckExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: \"is_na\" | \"is_not_na\",\n private readonly value: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): Expression {\n return {\n type: this.operator,\n value: this.value.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.value.getAlias()}_${this.operator}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new NullCheckExpressionImpl(this.operator, this.value);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport type LiteralValue = string | number | boolean | null;\n\nexport class LiteralExpressionImpl extends ExpressionImpl {\n constructor(private readonly value: LiteralValue) {\n super();\n }\n\n toJSON(): ConstantValueExpression {\n return {\n type: \"const\",\n value: this.value,\n };\n }\n\n getAlias(): string {\n return this._alias || this.generateDefaultAlias();\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new LiteralExpressionImpl(this.value);\n cloned._alias = this._alias;\n return cloned;\n }\n\n /**\n * Get the literal value\n */\n getValue(): string | number | boolean | null {\n return this.value;\n }\n\n /**\n * Generate a default alias based on the value\n */\n private generateDefaultAlias(): string {\n if (this.value === null || this.value === undefined) {\n return \"null\";\n }\n if (typeof this.value === \"string\") {\n // For string values, truncate if too long and make safe for column names\n const safe = this.value.replace(/[^a-zA-Z0-9_]/g, \"_\");\n return safe.length > 20 ? safe.substring(0, 17) + \"...\" : safe;\n }\n if (typeof this.value === \"boolean\") {\n return this.value ? \"true\" : \"false\";\n }\n if (typeof this.value === \"number\") {\n return String(this.value);\n }\n if (Array.isArray(this.value)) {\n return \"array\";\n }\n if (typeof this.value === \"object\") {\n return \"object\";\n }\n return \"literal\";\n }\n}\n\nexport class FillNullExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly fillValue: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): FillNullExpression {\n return {\n type: \"fill_null\",\n input: this.expr.toJSON(),\n fillValue: this.fillValue.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_fill_null`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new FillNullExpressionImpl(this.expr, this.fillValue);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class FillNaNExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly fillValue: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): FillNaNExpression {\n return {\n type: \"fill_nan\",\n input: this.expr.toJSON(),\n fillValue: this.fillValue.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_fill_nan`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new FillNaNExpressionImpl(this.expr, this.fillValue);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringConcatExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operands: ExpressionImpl[],\n private readonly delimiter: string = \"\",\n ) {\n super();\n }\n\n toJSON(): StringJoinExpression {\n return {\n type: \"str_join\",\n operands: this.operands.map((o) => o.toJSON()),\n delimiter: this.delimiter,\n };\n }\n\n getAlias(): string {\n return this._alias || this.operands.map((o) => o.getAlias()).join(\"_\");\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringConcatExpressionImpl(this.operands);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class SubstringExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly start: number,\n private readonly length?: number,\n ) {\n super();\n }\n\n toJSON(): SubstringExpression {\n return {\n type: \"substring\",\n value: this.expr.toJSON(),\n start: { type: \"const\", value: this.start },\n length: this.length !== undefined ? { type: \"const\", value: this.length } : undefined,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_substring`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new SubstringExpressionImpl(this.expr, this.start, this.length);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringReplaceExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: string,\n private readonly value: string,\n private readonly options?: Pick<StringReplaceExpression, \"replaceAll\" | \"literal\">,\n ) {\n super();\n }\n\n toJSON(): StringReplaceExpression {\n return {\n type: \"str_replace\",\n value: this.expr.toJSON(),\n pattern: this.pattern,\n replacement: this.value,\n replaceAll: this.options?.replaceAll || false,\n literal: this.options?.literal || false,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_replace`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringReplaceExpressionImpl(\n this.expr,\n this.pattern,\n this.value,\n this.options,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringContainsExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: ExpressionImpl,\n private readonly literal?: boolean,\n private readonly strict?: boolean,\n ) {\n super();\n }\n\n toJSON(): StringContainsExpression {\n return {\n type: \"str_contains\",\n value: this.expr.toJSON(),\n pattern: this.pattern.toJSON(),\n literal: this.literal || false,\n strict: this.strict !== undefined ? this.strict : true,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_contains`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringContainsExpressionImpl(\n this.expr,\n this.pattern,\n this.literal,\n this.strict,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringCaseExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operation: \"to_upper\" | \"to_lower\",\n private readonly expr: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): ExtendedUnaryStringExpression {\n return {\n type: this.operation,\n value: this.expr.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_${this.operation}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringCaseExpressionImpl(this.operation, this.expr);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringStartsWithExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): Expression {\n return {\n type: \"str_starts_with\",\n value: this.expr.toJSON(),\n prefix: this.pattern.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_starts_with`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringStartsWithExpressionImpl(this.expr, this.pattern);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringEndsWithExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): Expression {\n return {\n type: \"str_ends_with\",\n value: this.expr.toJSON(),\n suffix: this.pattern.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_ends_with`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringEndsWithExpressionImpl(this.expr, this.pattern);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class CumsumExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly value: ExpressionImpl,\n private readonly additionalOrderBy: ExpressionImpl[] = [],\n private readonly partitionBy: ExpressionImpl[] = [],\n private readonly descending?: boolean,\n ) {\n super();\n }\n\n toJSON(): CumsumExpression {\n return {\n type: \"cumsum\",\n value: this.value.toJSON(),\n additionalOrderBy: this.additionalOrderBy.map((expr) => expr.toJSON()),\n partitionBy: this.partitionBy.map((expr) => expr.toJSON()),\n descending: this.descending,\n };\n }\n\n getAlias(): string {\n return this._alias || `cumsum_${this.value.getAlias()}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new CumsumExpressionImpl(\n this.value,\n this.additionalOrderBy,\n this.partitionBy,\n this.descending,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class AggregationExpressionImpl extends ExpressionImpl {\n constructor(\n public operation: AggregationType,\n public expr?: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): WindowExpression {\n return {\n type: \"aggregate\",\n aggregation: this.operation,\n value: this.expr?.toJSON() || { type: \"const\", value: 1 },\n partitionBy: [],\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.operation}${this.expr ? \"_\" + this.expr.getAlias() : \"\"}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new AggregationExpressionImpl(this.operation, this.expr);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class WindowExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly aggregation: AggregationType,\n private readonly partitionBy: ExpressionImpl[],\n ) {\n super();\n }\n\n toJSON(): WindowExpression {\n return {\n type: \"aggregate\",\n aggregation: this.aggregation,\n value: this.expr.toJSON(),\n partitionBy: this.partitionBy.map((expr) => expr.toJSON()),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_window`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new WindowExpressionImpl(this.expr, this.aggregation, this.partitionBy);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringDistanceExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly string1: ExpressionImpl,\n private readonly string2: ExpressionImpl,\n private readonly metric: StringDistanceMetric,\n private readonly returnSimilarity?: boolean,\n ) {\n super();\n }\n\n toJSON(): StringDistanceExpression {\n return {\n type: \"string_distance\",\n metric: this.metric,\n string1: this.string1.toJSON(),\n string2: this.string2.toJSON(),\n returnSimilarity: this.returnSimilarity || false,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.string1.getAlias()}_distance_${this.string2.getAlias()}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringDistanceExpressionImpl(\n this.string1,\n this.string2,\n this.metric,\n this.returnSimilarity,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class FuzzyStringFilterExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: ExpressionImpl,\n private readonly metric: FuzzyFilterDistanceMetric,\n private readonly bound: number,\n ) {\n super();\n }\n\n toJSON(): FuzzyStringFilterExpression {\n return {\n type: \"fuzzy_string_filter\",\n metric: this.metric,\n value: this.expr.toJSON(),\n pattern: this.pattern.toJSON(),\n bound: this.bound,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_fuzzy_filter`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new FuzzyStringFilterExpressionImpl(\n this.expr,\n this.pattern,\n this.metric,\n this.bound,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class RankExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly orderBy: ExpressionImpl[],\n private readonly partitionBy: ExpressionImpl[],\n private readonly descending: boolean,\n ) {\n super();\n }\n\n toJSON(): RankExpression {\n return {\n type: \"rank\",\n orderBy: this.orderBy.map((e) => e.toJSON()),\n partitionBy: this.partitionBy.map((e) => e.toJSON()),\n descending: this.descending || undefined,\n };\n }\n\n getAlias(): string {\n const order = this.orderBy.map((e) => e.getAlias()).join(\"_\");\n const part = this.partitionBy.map((e) => e.getAlias()).join(\"_\");\n const dir = this.descending ? \"desc\" : \"asc\";\n return this._alias || `rank_${order}${part ? `_over_${part}` : \"\"}_${dir}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new RankExpressionImpl(this.orderBy, this.partitionBy, this.descending);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class WhenThenOtherwiseExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly conditions: Array<{ when: ExpressionImpl; then: ExpressionImpl }>,\n private readonly otherwiseValue: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): WhenThenOtherwiseExpression {\n return {\n type: \"when_then_otherwise\",\n conditions: this.conditions.map((clause) => ({\n when: clause.when.toJSON(),\n then: clause.then.toJSON(),\n })),\n otherwise: this.otherwiseValue.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || \"conditional\";\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new WhenThenOtherwiseExpressionImpl(this.conditions, this.otherwiseValue);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n"],"names":[],"mappings":"AAAA;;AAEG;AAkCH;;AAEG;MACmB,cAAc,CAAA;AACxB,IAAA,MAAM;AAYhB;;AAEG;AACH,IAAA,KAAK,CAAC,IAAY,EAAA;AAChB,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE;AAC3B,QAAA,MAAM,CAAC,MAAM,GAAG,IAAI;AACpB,QAAA,OAAO,MAAM;IACf;;AAQA,IAAA,I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ACjE,cAA8B,EAAA;AAE/C,QAAA,KAAK,EAAE;QAHU,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,cAAc,GAAd,cAAc;IAGjC;IAEA,MAAM,GAAA;QACJ,OAAO;AACL,YAAA,IAAI,EAAE,qBAAqB;AAC3B,YAAA,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,MAAM;AAC3C,gBAAA,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE;AAC1B,gBAAA,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE;AAC3B,aAAA,CAAC,CAAC;AACH,YAAA,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE;SACxC;IACH;IAEA,QAAQ,GAAA;AACN,QAAA,OAAO,IAAI,CAAC,MAAM,IAAI,aAAa;IACrC;IAEU,KAAK,GAAA;AACb,QAAA,MAAM,MAAM,GAAG,IAAI,+BAA+B,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC;AACxF,QAAA,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM;AAC3B,QAAA,OAAO,MAAM;IACf;AACD;;;;"}
1
+ {"version":3,"file":"expressions.js","names":[],"sources":["../src/expressions.ts"],"sourcesContent":["/**\n * Base expressionImpl classes and interfaces for PTabler JavaScript implementation\n */\n\nimport type {\n AggregationType,\n BinaryArithmeticExpression,\n BinaryArithmeticOperator,\n BooleanLogicExpression,\n ColumnReferenceExpression,\n ComparisonExpression,\n ComparisonOperator,\n ConstantValueExpression,\n CumsumExpression,\n Expression,\n ExtendedUnaryStringExpression,\n FillNaNExpression,\n FillNullExpression,\n FuzzyFilterDistanceMetric,\n FuzzyStringFilterExpression,\n MinMaxExpression,\n MinMaxOperator,\n NotExpression,\n RankExpression,\n StringContainsExpression,\n StringDistanceExpression,\n StringDistanceMetric,\n StringJoinExpression,\n StringReplaceExpression,\n SubstringExpression,\n UnaryArithmeticExpression,\n UnaryArithmeticOperator,\n WhenThenOtherwiseExpression,\n WindowExpression,\n} from \"./types\";\n\n/**\n * Base abstract class for all expressions\n */\nexport abstract class ExpressionImpl {\n protected _alias?: string;\n\n /**\n * Convert the expressionImpl to JSON format compatible with PTabler schema\n */\n abstract toJSON(): Expression;\n\n /**\n * Get the alias for this expressionImpl (defaults to a generated name)\n */\n abstract getAlias(): string;\n\n /**\n * Set an alias for this expression\n */\n alias(name: string): ExpressionImpl {\n const cloned = this.clone();\n cloned._alias = name;\n return cloned;\n }\n\n /**\n * Clone this expression\n */\n protected abstract clone(): ExpressionImpl;\n\n // Arithmetic operations\n plus(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"plus\", this, coerceToExpression(other));\n }\n\n minus(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"minus\", this, coerceToExpression(other));\n }\n\n multiply(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"multiply\", this, coerceToExpression(other));\n }\n\n truediv(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"truediv\", this, coerceToExpression(other));\n }\n\n floordiv(other: ExpressionImpl | number | string): ArithmeticExpressionImpl {\n return new ArithmeticExpressionImpl(\"floordiv\", this, coerceToExpression(other));\n }\n\n // Comparison operations\n gt(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"gt\", this, coerceToExpression(other));\n }\n\n ge(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"ge\", this, coerceToExpression(other));\n }\n\n eq(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"eq\", this, coerceToExpression(other));\n }\n\n lt(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"lt\", this, coerceToExpression(other));\n }\n\n le(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"le\", this, coerceToExpression(other));\n }\n\n neq(other: ExpressionImpl | number | string): ComparisonExpressionImpl {\n return new ComparisonExpressionImpl(\"neq\", this, coerceToExpression(other));\n }\n\n // Logical operations\n and(...others: ExpressionImpl[]): LogicalExpressionImpl {\n return new LogicalExpressionImpl(\"and\", [this, ...others]);\n }\n\n or(...others: ExpressionImpl[]): LogicalExpressionImpl {\n return new LogicalExpressionImpl(\"or\", [this, ...others]);\n }\n\n not(): LogicalExpressionImpl {\n return new LogicalExpressionImpl(\"not\", [this]);\n }\n\n // Unary arithmetic operations\n abs(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"abs\", this);\n }\n\n sqrt(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"sqrt\", this);\n }\n\n log(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"log\", this);\n }\n\n log10(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"log10\", this);\n }\n\n log2(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"log2\", this);\n }\n\n floor(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"floor\", this);\n }\n\n ceil(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"ceil\", this);\n }\n\n round(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"round\", this);\n }\n\n negate(): UnaryArithmeticExpressionImpl {\n return new UnaryArithmeticExpressionImpl(\"negate\", this);\n }\n\n // Null checks\n isNull(): NullCheckExpressionImpl {\n return new NullCheckExpressionImpl(\"is_na\", this);\n }\n\n isNotNull(): NullCheckExpressionImpl {\n return new NullCheckExpressionImpl(\"is_not_na\", this);\n }\n\n // Fill null/NaN\n fillNull(value: ExpressionImpl): FillNullExpressionImpl {\n return new FillNullExpressionImpl(this, coerceToExpression(value));\n }\n\n fillNaN(value: ExpressionImpl): FillNaNExpressionImpl {\n return new FillNaNExpressionImpl(this, coerceToExpression(value));\n }\n\n // String operations\n strConcat(...others: (ExpressionImpl | string)[]): StringConcatExpressionImpl {\n return new StringConcatExpressionImpl([this, ...others.map(coerceToExpression)]);\n }\n\n substring(start: number, length?: number): SubstringExpressionImpl {\n return new SubstringExpressionImpl(this, start, length);\n }\n\n strReplace(\n pattern: string,\n value: string,\n options?: Pick<StringReplaceExpression, \"replaceAll\" | \"literal\">,\n ): StringReplaceExpressionImpl {\n return new StringReplaceExpressionImpl(this, pattern, value, options);\n }\n\n strContains(\n pattern: ExpressionImpl | string,\n literal?: boolean,\n strict?: boolean,\n ): StringContainsExpressionImpl {\n return new StringContainsExpressionImpl(this, coerceToExpression(pattern), literal, strict);\n }\n\n strToUpper(): StringCaseExpressionImpl {\n return new StringCaseExpressionImpl(\"to_upper\", this);\n }\n\n strToLower(): StringCaseExpressionImpl {\n return new StringCaseExpressionImpl(\"to_lower\", this);\n }\n\n strStartsWith(pattern: ExpressionImpl | string): StringStartsWithExpressionImpl {\n return new StringStartsWithExpressionImpl(this, coerceToExpression(pattern));\n }\n\n strEndsWith(pattern: ExpressionImpl | string): StringEndsWithExpressionImpl {\n return new StringEndsWithExpressionImpl(this, coerceToExpression(pattern));\n }\n\n // Aggregation operations\n sum(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"sum\", this);\n }\n\n mean(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"mean\", this);\n }\n\n count(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"count\", this);\n }\n\n min(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"min\", this);\n }\n\n max(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"max\", this);\n }\n\n first(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"first\", this);\n }\n\n last(): AggregationExpressionImpl {\n return new AggregationExpressionImpl(\"last\", this);\n }\n\n cumsum(): CumsumExpressionImpl {\n return new CumsumExpressionImpl(this);\n }\n\n // Fuzzy operations\n stringDistance(\n other: ExpressionImpl | string,\n metric: StringDistanceMetric,\n returnSimilarity?: boolean,\n ): StringDistanceExpressionImpl {\n return new StringDistanceExpressionImpl(\n this,\n coerceToExpression(other),\n metric,\n returnSimilarity,\n );\n }\n\n fuzzyStringFilter(\n pattern: ExpressionImpl | string,\n metric: FuzzyFilterDistanceMetric,\n bound: number,\n ): FuzzyStringFilterExpressionImpl {\n return new FuzzyStringFilterExpressionImpl(this, coerceToExpression(pattern), metric, bound);\n }\n}\n\nexport class ColumnExpressionImpl extends ExpressionImpl {\n constructor(private readonly columnName: string) {\n super();\n }\n\n toJSON(): ColumnReferenceExpression {\n return {\n type: \"col\",\n name: this.columnName,\n };\n }\n\n getAlias(): string {\n return this._alias || this.columnName;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new ColumnExpressionImpl(this.columnName);\n cloned._alias = this._alias;\n return cloned;\n }\n\n /**\n * Get the column name\n */\n getColumnName(): string {\n return this.columnName;\n }\n}\n\n/**\n * Helper function to coerce values to expressions\n */\nexport function coerceToExpression(value: ExpressionImpl | LiteralValue): ExpressionImpl {\n if (value instanceof ExpressionImpl) {\n return value;\n }\n return new LiteralExpressionImpl(value);\n}\n\nexport class MinMaxExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly op: MinMaxOperator,\n private readonly ops: ExpressionImpl[],\n ) {\n super();\n }\n\n toJSON(): MinMaxExpression {\n return {\n type: this.op,\n operands: this.ops.map((o) => o.toJSON()),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.op}_${this.ops.map((o) => o.getAlias()).join(\"_\")}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new MinMaxExpressionImpl(this.op, this.ops);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\n// Forward declarations for concrete expressionImpl classes\n// These will be imported from their respective modules\nexport class ArithmeticExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: BinaryArithmeticOperator,\n private readonly lhs: ExpressionImpl,\n private readonly rhs: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): BinaryArithmeticExpression {\n return {\n type: this.operator,\n lhs: this.lhs.toJSON(),\n rhs: this.rhs.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.lhs.getAlias()}_${this.operator}_${this.rhs.getAlias()}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new ArithmeticExpressionImpl(this.operator, this.lhs, this.rhs);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class ComparisonExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: ComparisonOperator,\n private readonly lhs: ExpressionImpl,\n private readonly rhs: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): ComparisonExpression {\n return {\n type: this.operator,\n lhs: this.lhs.toJSON(),\n rhs: this.rhs.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.lhs.getAlias()}_${this.operator}_${this.rhs.getAlias()}`;\n }\n\n protected clone(): ComparisonExpressionImpl {\n const cloned = new ComparisonExpressionImpl(this.operator, this.lhs, this.rhs);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class LogicalExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: \"and\" | \"or\" | \"not\",\n private readonly operands: ExpressionImpl[],\n ) {\n super();\n }\n\n toJSON(): NotExpression | BooleanLogicExpression {\n if (this.operator === \"not\") {\n return {\n type: \"not\",\n value: this.operands[0].toJSON(),\n };\n }\n return {\n type: this.operator,\n operands: this.operands.map((op) => op.toJSON()),\n };\n }\n\n getAlias(): string {\n if (this._alias) return this._alias;\n if (this.operator === \"not\") {\n return `not_${this.operands[0].getAlias()}`;\n }\n return this.operands.map((op) => op.getAlias()).join(`_${this.operator}_`);\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new LogicalExpressionImpl(this.operator, this.operands);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class UnaryArithmeticExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: UnaryArithmeticOperator,\n private readonly value: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): UnaryArithmeticExpression {\n return {\n type: this.operator,\n value: this.value.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.operator}_${this.value.getAlias()}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new UnaryArithmeticExpressionImpl(this.operator, this.value);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class NullCheckExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operator: \"is_na\" | \"is_not_na\",\n private readonly value: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): Expression {\n return {\n type: this.operator,\n value: this.value.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.value.getAlias()}_${this.operator}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new NullCheckExpressionImpl(this.operator, this.value);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport type LiteralValue = string | number | boolean | null;\n\nexport class LiteralExpressionImpl extends ExpressionImpl {\n constructor(private readonly value: LiteralValue) {\n super();\n }\n\n toJSON(): ConstantValueExpression {\n return {\n type: \"const\",\n value: this.value,\n };\n }\n\n getAlias(): string {\n return this._alias || this.generateDefaultAlias();\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new LiteralExpressionImpl(this.value);\n cloned._alias = this._alias;\n return cloned;\n }\n\n /**\n * Get the literal value\n */\n getValue(): string | number | boolean | null {\n return this.value;\n }\n\n /**\n * Generate a default alias based on the value\n */\n private generateDefaultAlias(): string {\n if (this.value === null || this.value === undefined) {\n return \"null\";\n }\n if (typeof this.value === \"string\") {\n // For string values, truncate if too long and make safe for column names\n const safe = this.value.replace(/[^a-zA-Z0-9_]/g, \"_\");\n return safe.length > 20 ? safe.substring(0, 17) + \"...\" : safe;\n }\n if (typeof this.value === \"boolean\") {\n return this.value ? \"true\" : \"false\";\n }\n if (typeof this.value === \"number\") {\n return String(this.value);\n }\n if (Array.isArray(this.value)) {\n return \"array\";\n }\n if (typeof this.value === \"object\") {\n return \"object\";\n }\n return \"literal\";\n }\n}\n\nexport class FillNullExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly fillValue: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): FillNullExpression {\n return {\n type: \"fill_null\",\n input: this.expr.toJSON(),\n fillValue: this.fillValue.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_fill_null`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new FillNullExpressionImpl(this.expr, this.fillValue);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class FillNaNExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly fillValue: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): FillNaNExpression {\n return {\n type: \"fill_nan\",\n input: this.expr.toJSON(),\n fillValue: this.fillValue.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_fill_nan`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new FillNaNExpressionImpl(this.expr, this.fillValue);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringConcatExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operands: ExpressionImpl[],\n private readonly delimiter: string = \"\",\n ) {\n super();\n }\n\n toJSON(): StringJoinExpression {\n return {\n type: \"str_join\",\n operands: this.operands.map((o) => o.toJSON()),\n delimiter: this.delimiter,\n };\n }\n\n getAlias(): string {\n return this._alias || this.operands.map((o) => o.getAlias()).join(\"_\");\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringConcatExpressionImpl(this.operands);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class SubstringExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly start: number,\n private readonly length?: number,\n ) {\n super();\n }\n\n toJSON(): SubstringExpression {\n return {\n type: \"substring\",\n value: this.expr.toJSON(),\n start: { type: \"const\", value: this.start },\n length: this.length !== undefined ? { type: \"const\", value: this.length } : undefined,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_substring`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new SubstringExpressionImpl(this.expr, this.start, this.length);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringReplaceExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: string,\n private readonly value: string,\n private readonly options?: Pick<StringReplaceExpression, \"replaceAll\" | \"literal\">,\n ) {\n super();\n }\n\n toJSON(): StringReplaceExpression {\n return {\n type: \"str_replace\",\n value: this.expr.toJSON(),\n pattern: this.pattern,\n replacement: this.value,\n replaceAll: this.options?.replaceAll || false,\n literal: this.options?.literal || false,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_replace`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringReplaceExpressionImpl(\n this.expr,\n this.pattern,\n this.value,\n this.options,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringContainsExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: ExpressionImpl,\n private readonly literal?: boolean,\n private readonly strict?: boolean,\n ) {\n super();\n }\n\n toJSON(): StringContainsExpression {\n return {\n type: \"str_contains\",\n value: this.expr.toJSON(),\n pattern: this.pattern.toJSON(),\n literal: this.literal || false,\n strict: this.strict !== undefined ? this.strict : true,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_contains`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringContainsExpressionImpl(\n this.expr,\n this.pattern,\n this.literal,\n this.strict,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringCaseExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly operation: \"to_upper\" | \"to_lower\",\n private readonly expr: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): ExtendedUnaryStringExpression {\n return {\n type: this.operation,\n value: this.expr.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_${this.operation}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringCaseExpressionImpl(this.operation, this.expr);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringStartsWithExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): Expression {\n return {\n type: \"str_starts_with\",\n value: this.expr.toJSON(),\n prefix: this.pattern.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_starts_with`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringStartsWithExpressionImpl(this.expr, this.pattern);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringEndsWithExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): Expression {\n return {\n type: \"str_ends_with\",\n value: this.expr.toJSON(),\n suffix: this.pattern.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_ends_with`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringEndsWithExpressionImpl(this.expr, this.pattern);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class CumsumExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly value: ExpressionImpl,\n private readonly additionalOrderBy: ExpressionImpl[] = [],\n private readonly partitionBy: ExpressionImpl[] = [],\n private readonly descending?: boolean,\n ) {\n super();\n }\n\n toJSON(): CumsumExpression {\n return {\n type: \"cumsum\",\n value: this.value.toJSON(),\n additionalOrderBy: this.additionalOrderBy.map((expr) => expr.toJSON()),\n partitionBy: this.partitionBy.map((expr) => expr.toJSON()),\n descending: this.descending,\n };\n }\n\n getAlias(): string {\n return this._alias || `cumsum_${this.value.getAlias()}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new CumsumExpressionImpl(\n this.value,\n this.additionalOrderBy,\n this.partitionBy,\n this.descending,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class AggregationExpressionImpl extends ExpressionImpl {\n constructor(\n public operation: AggregationType,\n public expr?: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): WindowExpression {\n return {\n type: \"aggregate\",\n aggregation: this.operation,\n value: this.expr?.toJSON() || { type: \"const\", value: 1 },\n partitionBy: [],\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.operation}${this.expr ? \"_\" + this.expr.getAlias() : \"\"}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new AggregationExpressionImpl(this.operation, this.expr);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class WindowExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly aggregation: AggregationType,\n private readonly partitionBy: ExpressionImpl[],\n ) {\n super();\n }\n\n toJSON(): WindowExpression {\n return {\n type: \"aggregate\",\n aggregation: this.aggregation,\n value: this.expr.toJSON(),\n partitionBy: this.partitionBy.map((expr) => expr.toJSON()),\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_window`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new WindowExpressionImpl(this.expr, this.aggregation, this.partitionBy);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class StringDistanceExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly string1: ExpressionImpl,\n private readonly string2: ExpressionImpl,\n private readonly metric: StringDistanceMetric,\n private readonly returnSimilarity?: boolean,\n ) {\n super();\n }\n\n toJSON(): StringDistanceExpression {\n return {\n type: \"string_distance\",\n metric: this.metric,\n string1: this.string1.toJSON(),\n string2: this.string2.toJSON(),\n returnSimilarity: this.returnSimilarity || false,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.string1.getAlias()}_distance_${this.string2.getAlias()}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new StringDistanceExpressionImpl(\n this.string1,\n this.string2,\n this.metric,\n this.returnSimilarity,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class FuzzyStringFilterExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly expr: ExpressionImpl,\n private readonly pattern: ExpressionImpl,\n private readonly metric: FuzzyFilterDistanceMetric,\n private readonly bound: number,\n ) {\n super();\n }\n\n toJSON(): FuzzyStringFilterExpression {\n return {\n type: \"fuzzy_string_filter\",\n metric: this.metric,\n value: this.expr.toJSON(),\n pattern: this.pattern.toJSON(),\n bound: this.bound,\n };\n }\n\n getAlias(): string {\n return this._alias || `${this.expr.getAlias()}_fuzzy_filter`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new FuzzyStringFilterExpressionImpl(\n this.expr,\n this.pattern,\n this.metric,\n this.bound,\n );\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class RankExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly orderBy: ExpressionImpl[],\n private readonly partitionBy: ExpressionImpl[],\n private readonly descending: boolean,\n ) {\n super();\n }\n\n toJSON(): RankExpression {\n return {\n type: \"rank\",\n orderBy: this.orderBy.map((e) => e.toJSON()),\n partitionBy: this.partitionBy.map((e) => e.toJSON()),\n descending: this.descending || undefined,\n };\n }\n\n getAlias(): string {\n const order = this.orderBy.map((e) => e.getAlias()).join(\"_\");\n const part = this.partitionBy.map((e) => e.getAlias()).join(\"_\");\n const dir = this.descending ? \"desc\" : \"asc\";\n return this._alias || `rank_${order}${part ? `_over_${part}` : \"\"}_${dir}`;\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new RankExpressionImpl(this.orderBy, this.partitionBy, this.descending);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n\nexport class WhenThenOtherwiseExpressionImpl extends ExpressionImpl {\n constructor(\n private readonly conditions: Array<{ when: ExpressionImpl; then: ExpressionImpl }>,\n private readonly otherwiseValue: ExpressionImpl,\n ) {\n super();\n }\n\n toJSON(): WhenThenOtherwiseExpression {\n return {\n type: \"when_then_otherwise\",\n conditions: this.conditions.map((clause) => ({\n when: clause.when.toJSON(),\n then: clause.then.toJSON(),\n })),\n otherwise: this.otherwiseValue.toJSON(),\n };\n }\n\n getAlias(): string {\n return this._alias || \"conditional\";\n }\n\n protected clone(): ExpressionImpl {\n const cloned = new WhenThenOtherwiseExpressionImpl(this.conditions, this.otherwiseValue);\n cloned._alias = this._alias;\n return cloned;\n }\n}\n"],"mappings":";;;;AAuCA,IAAsB,iBAAtB,MAAqC;CACnC,AAAU;;;;CAeV,MAAM,MAA8B;EAClC,MAAM,SAAS,KAAK,OAAO;AAC3B,SAAO,SAAS;AAChB,SAAO;;CAST,KAAK,OAAmE;AACtE,SAAO,IAAI,yBAAyB,QAAQ,MAAM,mBAAmB,MAAM,CAAC;;CAG9E,MAAM,OAAmE;AACvE,SAAO,IAAI,yBAAyB,SAAS,MAAM,mBAAmB,MAAM,CAAC;;CAG/E,SAAS,OAAmE;AAC1E,SAAO,IAAI,yBAAyB,YAAY,MAAM,mBAAmB,MAAM,CAAC;;CAGlF,QAAQ,OAAmE;AACzE,SAAO,IAAI,yBAAyB,WAAW,MAAM,mBAAmB,MAAM,CAAC;;CAGjF,SAAS,OAAmE;AAC1E,SAAO,IAAI,yBAAyB,YAAY,MAAM,mBAAmB,MAAM,CAAC;;CAIlF,GAAG,OAAmE;AACpE,SAAO,IAAI,yBAAyB,MAAM,MAAM,mBAAmB,MAAM,CAAC;;CAG5E,GAAG,OAAmE;AACpE,SAAO,IAAI,yBAAyB,MAAM,MAAM,mBAAmB,MAAM,CAAC;;CAG5E,GAAG,OAAmE;AACpE,SAAO,IAAI,yBAAyB,MAAM,MAAM,mBAAmB,MAAM,CAAC;;CAG5E,GAAG,OAAmE;AACpE,SAAO,IAAI,yBAAyB,MAAM,MAAM,mBAAmB,MAAM,C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Aa,wCAAwC,eAAe;CAClE,YACE,AAAiB,YACjB,AAAiB,gBACjB;AACA,SAAO;EAHU;EACA;;CAKnB,SAAsC;AACpC,SAAO;GACL,MAAM;GACN,YAAY,KAAK,WAAW,KAAK,YAAY;IAC3C,MAAM,OAAO,KAAK,QAAQ;IAC1B,MAAM,OAAO,KAAK,QAAQ;IAC3B,EAAE;GACH,WAAW,KAAK,eAAe,QAAQ;GACxC;;CAGH,WAAmB;AACjB,SAAO,KAAK,UAAU;;CAGxB,AAAU,QAAwB;EAChC,MAAM,SAAS,IAAI,gCAAgC,KAAK,YAAY,KAAK,eAAe;AACxF,SAAO,SAAS,KAAK;AACrB,SAAO"}
@@ -1,169 +1,140 @@
1
- 'use strict';
1
+ const require_expressions = require('./expressions.cjs');
2
2
 
3
- var expressions = require('./expressions.cjs');
4
-
5
- /**
6
- * Factory functions for creating expressions - mirrors Tengo pt library API
7
- */
8
- // Internal helpers mirroring Tengo behavior
3
+ //#region src/functions.ts
9
4
  function isExpression(v) {
10
- return v instanceof expressions.ExpressionImpl;
5
+ return v instanceof require_expressions.ExpressionImpl;
11
6
  }
12
7
  function asExprFromString(value, interpretation) {
13
- return interpretation === "col" ? col(value) : lit(value);
8
+ return interpretation === "col" ? col(value) : lit(value);
14
9
  }
15
10
  function coerceToExpressionList(items, interpretationForString) {
16
- const arr = Array.isArray(items) ? items : [items];
17
- return arr.map((it) => typeof it === "string" ? asExprFromString(it, interpretationForString) : it);
11
+ return (Array.isArray(items) ? items : [items]).map((it) => typeof it === "string" ? asExprFromString(it, interpretationForString) : it);
18
12
  }
19
13
  /**
20
- * Create a column reference expression
21
- * @param name Column name
22
- */
14
+ * Create a column reference expression
15
+ * @param name Column name
16
+ */
23
17
  function col(name) {
24
- return new expressions.ColumnExpressionImpl(name);
18
+ return new require_expressions.ColumnExpressionImpl(name);
25
19
  }
26
20
  /**
27
- * Create a literal value expression
28
- * @param value Literal value (number, string, boolean, null, etc.)
29
- */
21
+ * Create a literal value expression
22
+ * @param value Literal value (number, string, boolean, null, etc.)
23
+ */
30
24
  function lit(value) {
31
- return new expressions.LiteralExpressionImpl(value);
25
+ return new require_expressions.LiteralExpressionImpl(value);
32
26
  }
33
27
  /**
34
- * Create an AND expression with multiple operands (horizontal AND)
35
- * @param expressions Array of expressions to AND together
36
- */
37
- function allHorizontal(...expressions$1) {
38
- // Interpret string args as column names. We don't flatten nested ANDs to keep implementation simple.
39
- const processed = expressions$1.map((e) => (typeof e === "string" ? col(e) : e));
40
- return new expressions.LogicalExpressionImpl("and", processed);
28
+ * Create an AND expression with multiple operands (horizontal AND)
29
+ * @param expressions Array of expressions to AND together
30
+ */
31
+ function allHorizontal(...expressions) {
32
+ return new require_expressions.LogicalExpressionImpl("and", expressions.map((e) => typeof e === "string" ? col(e) : e));
41
33
  }
42
34
  /**
43
- * Create an OR expression with multiple operands (horizontal OR)
44
- * @param expressions Array of expressions to OR together
45
- */
46
- function anyHorizontal(...expressions$1) {
47
- // Interpret string args as column names. We don't flatten nested ORs to keep implementation simple.
48
- const processed = expressions$1.map((e) => (typeof e === "string" ? col(e) : e));
49
- return new expressions.LogicalExpressionImpl("or", processed);
35
+ * Create an OR expression with multiple operands (horizontal OR)
36
+ * @param expressions Array of expressions to OR together
37
+ */
38
+ function anyHorizontal(...expressions) {
39
+ return new require_expressions.LogicalExpressionImpl("or", expressions.map((e) => typeof e === "string" ? col(e) : e));
50
40
  }
51
41
  /**
52
- * Create an AND expression with multiple operands
53
- * @param expressions Array of expressions to AND together
54
- */
42
+ * Create an AND expression with multiple operands
43
+ * @param expressions Array of expressions to AND together
44
+ */
55
45
  function and(...expressions) {
56
- return allHorizontal(...expressions);
46
+ return allHorizontal(...expressions);
57
47
  }
58
48
  /**
59
- * Create an OR expression with multiple operands
60
- * @param expressions Array of expressions to OR together
61
- */
49
+ * Create an OR expression with multiple operands
50
+ * @param expressions Array of expressions to OR together
51
+ */
62
52
  function or(...expressions) {
63
- return anyHorizontal(...expressions);
53
+ return anyHorizontal(...expressions);
64
54
  }
65
55
  /**
66
- * Concatenate string representations with optional delimiter (Tengo: concatStr)
67
- * String inputs are treated as literals.
68
- */
69
- function concatStr(expressions$1, options) {
70
- if (!Array.isArray(expressions$1) || expressions$1.length === 0) {
71
- throw new Error("concatStr requires a non-empty array of expressions");
72
- }
73
- const ops = coerceToExpressionList(expressions$1, "lit");
74
- const delimiter = options?.delimiter ?? "";
75
- return new expressions.StringConcatExpressionImpl(ops, delimiter);
56
+ * Concatenate string representations with optional delimiter (Tengo: concatStr)
57
+ * String inputs are treated as literals.
58
+ */
59
+ function concatStr(expressions, options) {
60
+ if (!Array.isArray(expressions) || expressions.length === 0) throw new Error("concatStr requires a non-empty array of expressions");
61
+ return new require_expressions.StringConcatExpressionImpl(coerceToExpressionList(expressions, "lit"), options?.delimiter ?? "");
76
62
  }
77
63
  /**
78
- * Element-wise min across expressions (Tengo: minHorizontal). Strings -> columns.
79
- */
80
- function minHorizontal(expressions$1) {
81
- if (!Array.isArray(expressions$1) || expressions$1.length === 0) {
82
- throw new Error("minHorizontal requires a non-empty array of expressions");
83
- }
84
- const ops = coerceToExpressionList(expressions$1, "col");
85
- return new expressions.MinMaxExpressionImpl("min", ops);
64
+ * Element-wise min across expressions (Tengo: minHorizontal). Strings -> columns.
65
+ */
66
+ function minHorizontal(expressions) {
67
+ if (!Array.isArray(expressions) || expressions.length === 0) throw new Error("minHorizontal requires a non-empty array of expressions");
68
+ return new require_expressions.MinMaxExpressionImpl("min", coerceToExpressionList(expressions, "col"));
86
69
  }
87
70
  /**
88
- * Element-wise max across expressions (Tengo: maxHorizontal). Strings -> columns.
89
- */
90
- function maxHorizontal(expressions$1) {
91
- if (!Array.isArray(expressions$1) || expressions$1.length === 0) {
92
- throw new Error("maxHorizontal requires a non-empty array of expressions");
93
- }
94
- const ops = coerceToExpressionList(expressions$1, "col");
95
- return new expressions.MinMaxExpressionImpl("max", ops);
71
+ * Element-wise max across expressions (Tengo: maxHorizontal). Strings -> columns.
72
+ */
73
+ function maxHorizontal(expressions) {
74
+ if (!Array.isArray(expressions) || expressions.length === 0) throw new Error("maxHorizontal requires a non-empty array of expressions");
75
+ return new require_expressions.MinMaxExpressionImpl("max", coerceToExpressionList(expressions, "col"));
96
76
  }
97
77
  /**
98
- * Create a conditional when-then expression builder
99
- * @param condition Boolean expression condition
100
- */
78
+ * Create a conditional when-then expression builder
79
+ * @param condition Boolean expression condition
80
+ */
101
81
  function when(condition) {
102
- return WhenThenBuilder.start(condition);
82
+ return WhenThenBuilder.start(condition);
103
83
  }
104
84
  /**
105
- * Create a rank expression
106
- * @param expression Expression to rank
107
- * @param options Ranking options
108
- */
85
+ * Create a rank expression
86
+ * @param expression Expression to rank
87
+ * @param options Ranking options
88
+ */
109
89
  function rank(orderBy, descending = false) {
110
- const orderByList = coerceToExpressionList(orderBy, "col");
111
- return new RankBuilder(orderByList, descending);
90
+ return new RankBuilder(coerceToExpressionList(orderBy, "col"), descending);
112
91
  }
113
92
  /**
114
- * Builder class for when-then-otherwise conditional expressions
115
- */
116
- class WhenThenBuilder {
117
- clauses;
118
- currentWhen;
119
- constructor(clauses, currentWhen) {
120
- this.clauses = clauses;
121
- this.currentWhen = currentWhen;
122
- }
123
- static start(condition) {
124
- if (!isExpression(condition))
125
- throw new Error("when() expects an Expression");
126
- return new WhenThenBuilder([], condition);
127
- }
128
- when(condition) {
129
- if (this.currentWhen)
130
- throw new Error(".when() must follow a .then()");
131
- if (!isExpression(condition))
132
- throw new Error(".when() expects an Expression");
133
- return new WhenThenBuilder(this.clauses, condition);
134
- }
135
- then(value) {
136
- if (!this.currentWhen)
137
- throw new Error(".then() must follow a .when()");
138
- const expr = isExpression(value) ? value : lit(value);
139
- const nextClauses = this.clauses.slice();
140
- nextClauses.push({ when: this.currentWhen, then: expr });
141
- return new WhenThenBuilder(nextClauses, undefined);
142
- }
143
- otherwise(value) {
144
- if (this.currentWhen)
145
- throw new Error(".otherwise() must follow a .then()");
146
- if (this.clauses.length === 0) {
147
- throw new Error("At least one .when().then() clause is required before .otherwise()");
148
- }
149
- const expr = isExpression(value) ? value : lit(value);
150
- return new expressions.WhenThenOtherwiseExpressionImpl(this.clauses, expr);
151
- }
152
- }
153
- // Rank builder and expression
154
- class RankBuilder {
155
- orderBy;
156
- descending;
157
- constructor(orderBy, descending) {
158
- this.orderBy = orderBy;
159
- this.descending = descending;
160
- }
161
- over(partitionBy) {
162
- const partitionByList = coerceToExpressionList(partitionBy, "col");
163
- return new expressions.RankExpressionImpl(this.orderBy, partitionByList, this.descending);
164
- }
165
- }
93
+ * Builder class for when-then-otherwise conditional expressions
94
+ */
95
+ var WhenThenBuilder = class WhenThenBuilder {
96
+ constructor(clauses, currentWhen) {
97
+ this.clauses = clauses;
98
+ this.currentWhen = currentWhen;
99
+ }
100
+ static start(condition) {
101
+ if (!isExpression(condition)) throw new Error("when() expects an Expression");
102
+ return new WhenThenBuilder([], condition);
103
+ }
104
+ when(condition) {
105
+ if (this.currentWhen) throw new Error(".when() must follow a .then()");
106
+ if (!isExpression(condition)) throw new Error(".when() expects an Expression");
107
+ return new WhenThenBuilder(this.clauses, condition);
108
+ }
109
+ then(value) {
110
+ if (!this.currentWhen) throw new Error(".then() must follow a .when()");
111
+ const expr = isExpression(value) ? value : lit(value);
112
+ const nextClauses = this.clauses.slice();
113
+ nextClauses.push({
114
+ when: this.currentWhen,
115
+ then: expr
116
+ });
117
+ return new WhenThenBuilder(nextClauses, void 0);
118
+ }
119
+ otherwise(value) {
120
+ if (this.currentWhen) throw new Error(".otherwise() must follow a .then()");
121
+ if (this.clauses.length === 0) throw new Error("At least one .when().then() clause is required before .otherwise()");
122
+ const expr = isExpression(value) ? value : lit(value);
123
+ return new require_expressions.WhenThenOtherwiseExpressionImpl(this.clauses, expr);
124
+ }
125
+ };
126
+ var RankBuilder = class {
127
+ constructor(orderBy, descending) {
128
+ this.orderBy = orderBy;
129
+ this.descending = descending;
130
+ }
131
+ over(partitionBy) {
132
+ const partitionByList = coerceToExpressionList(partitionBy, "col");
133
+ return new require_expressions.RankExpressionImpl(this.orderBy, partitionByList, this.descending);
134
+ }
135
+ };
166
136
 
137
+ //#endregion
167
138
  exports.RankBuilder = RankBuilder;
168
139
  exports.WhenThenBuilder = WhenThenBuilder;
169
140
  exports.allHorizontal = allHorizontal;
@@ -177,4 +148,4 @@ exports.minHorizontal = minHorizontal;
177
148
  exports.or = or;
178
149
  exports.rank = rank;
179
150
  exports.when = when;
180
- //# sourceMappingURL=functions.cjs.map
151
+ //# sourceMappingURL=functions.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.cjs","sources":["../src/functions.ts"],"sourcesContent":["/**\n * Factory functions for creating expressions - mirrors Tengo pt library API\n */\n\nimport type { LiteralValue } from \"./expressions\";\nimport {\n ColumnExpressionImpl,\n ExpressionImpl,\n LiteralExpressionImpl,\n LogicalExpressionImpl,\n MinMaxExpressionImpl,\n RankExpressionImpl,\n StringConcatExpressionImpl,\n WhenThenOtherwiseExpressionImpl,\n} from \"./expressions\";\n\n// Internal helpers mirroring Tengo behavior\nfunction isExpression(v: unknown): v is ExpressionImpl {\n return v instanceof ExpressionImpl;\n}\n\nfunction asExprFromString(value: string, interpretation: \"col\" | \"lit\"): ExpressionImpl {\n return interpretation === \"col\" ? col(value) : lit(value);\n}\n\nfunction coerceToExpressionList(\n items: Array<ExpressionImpl | string> | ExpressionImpl | string,\n interpretationForString: \"col\" | \"lit\",\n): ExpressionImpl[] {\n const arr = Array.isArray(items) ? items : [items];\n return arr.map((it) =>\n typeof it === \"string\" ? asExprFromString(it, interpretationForString) : it,\n );\n}\n\n/**\n * Create a column reference expression\n * @param name Column name\n */\nexport function col(name: string): ColumnExpressionImpl {\n return new ColumnExpressionImpl(name);\n}\n\n/**\n * Create a literal value expression\n * @param value Literal value (number, string, boolean, null, etc.)\n */\nexport function lit(value: LiteralValue): LiteralExpressionImpl {\n return new LiteralExpressionImpl(value);\n}\n\n/**\n * Create an AND expression with multiple operands (horizontal AND)\n * @param expressions Array of expressions to AND together\n */\nexport function allHorizontal(\n ...expressions: Array<ExpressionImpl | string>\n): LogicalExpressionImpl {\n // Interpret string args as column names. We don't flatten nested ANDs to keep implementation simple.\n const processed: ExpressionImpl[] = expressions.map((e) => (typeof e === \"string\" ? col(e) : e));\n return new LogicalExpressionImpl(\"and\", processed);\n}\n\n/**\n * Create an OR expression with multiple operands (horizontal OR)\n * @param expressions Array of expressions to OR together\n */\nexport function anyHorizontal(\n ...expressions: Array<ExpressionImpl | string>\n): LogicalExpressionImpl {\n // Interpret string args as column names. We don't flatten nested ORs to keep implementation simple.\n const processed: ExpressionImpl[] = expressions.map((e) => (typeof e === \"string\" ? col(e) : e));\n return new LogicalExpressionImpl(\"or\", processed);\n}\n\n/**\n * Create an AND expression with multiple operands\n * @param expressions Array of expressions to AND together\n */\nexport function and(...expressions: Array<ExpressionImpl | string>): LogicalExpressionImpl {\n return allHorizontal(...expressions);\n}\n\n/**\n * Create an OR expression with multiple operands\n * @param expressions Array of expressions to OR together\n */\nexport function or(...expressions: Array<ExpressionImpl | string>): LogicalExpressionImpl {\n return anyHorizontal(...expressions);\n}\n\n/**\n * Concatenate string representations with optional delimiter (Tengo: concatStr)\n * String inputs are treated as literals.\n */\nexport function concatStr(\n expressions: Array<ExpressionImpl | string>,\n options?: { delimiter?: string },\n): ExpressionImpl {\n if (!Array.isArray(expressions) || expressions.length === 0) {\n throw new Error(\"concatStr requires a non-empty array of expressions\");\n }\n const ops = coerceToExpressionList(expressions, \"lit\");\n const delimiter = options?.delimiter ?? \"\";\n return new StringConcatExpressionImpl(ops, delimiter);\n}\n\n/**\n * Element-wise min across expressions (Tengo: minHorizontal). Strings -> columns.\n */\nexport function minHorizontal(expressions: Array<ExpressionImpl | string>): ExpressionImpl {\n if (!Array.isArray(expressions) || expressions.length === 0) {\n throw new Error(\"minHorizontal requires a non-empty array of expressions\");\n }\n\n const ops = coerceToExpressionList(expressions, \"col\");\n return new MinMaxExpressionImpl(\"min\", ops);\n}\n\n/**\n * Element-wise max across expressions (Tengo: maxHorizontal). Strings -> columns.\n */\nexport function maxHorizontal(expressions: Array<ExpressionImpl | string>): ExpressionImpl {\n if (!Array.isArray(expressions) || expressions.length === 0) {\n throw new Error(\"maxHorizontal requires a non-empty array of expressions\");\n }\n const ops = coerceToExpressionList(expressions, \"col\");\n return new MinMaxExpressionImpl(\"max\", ops);\n}\n\n/**\n * Create a conditional when-then expression builder\n * @param condition Boolean expression condition\n */\nexport function when(condition: ExpressionImpl): WhenThenBuilder {\n return WhenThenBuilder.start(condition);\n}\n\n/**\n * Create a rank expression\n * @param expression Expression to rank\n * @param options Ranking options\n */\nexport function rank(\n orderBy: ExpressionImpl | string | Array<ExpressionImpl | string>,\n descending = false,\n): RankBuilder {\n const orderByList = coerceToExpressionList(orderBy, \"col\");\n return new RankBuilder(orderByList, descending);\n}\n\n/**\n * Builder class for when-then-otherwise conditional expressions\n */\nexport class WhenThenBuilder {\n private constructor(\n private readonly clauses: Array<{ when: ExpressionImpl; then: ExpressionImpl }>,\n private readonly currentWhen?: ExpressionImpl,\n ) {}\n\n static start(condition: ExpressionImpl): WhenThenBuilder {\n if (!isExpression(condition)) throw new Error(\"when() expects an Expression\");\n return new WhenThenBuilder([], condition);\n }\n\n when(condition: ExpressionImpl): WhenThenBuilder {\n if (this.currentWhen) throw new Error(\".when() must follow a .then()\");\n if (!isExpression(condition)) throw new Error(\".when() expects an Expression\");\n return new WhenThenBuilder(this.clauses, condition);\n }\n\n then(value: ExpressionImpl | LiteralValue): WhenThenBuilder {\n if (!this.currentWhen) throw new Error(\".then() must follow a .when()\");\n const expr = isExpression(value) ? value : lit(value);\n const nextClauses = this.clauses.slice();\n nextClauses.push({ when: this.currentWhen, then: expr });\n return new WhenThenBuilder(nextClauses, undefined);\n }\n\n otherwise(value: ExpressionImpl | LiteralValue): WhenThenOtherwiseExpressionImpl {\n if (this.currentWhen) throw new Error(\".otherwise() must follow a .then()\");\n if (this.clauses.length === 0) {\n throw new Error(\"At least one .when().then() clause is required before .otherwise()\");\n }\n const expr = isExpression(value) ? value : lit(value);\n return new WhenThenOtherwiseExpressionImpl(this.clauses, expr);\n }\n}\n\n// Rank builder and expression\nexport class RankBuilder {\n constructor(\n private readonly orderBy: ExpressionImpl[],\n private readonly descending: boolean,\n ) {}\n\n over(partitionBy: ExpressionImpl | string | Array<ExpressionImpl | string>): RankExpressionImpl {\n const partitionByList = coerceToExpressionList(partitionBy, \"col\");\n return new RankExpressionImpl(this.orderBy, partitionByList, this.descending);\n }\n}\n"],"names":["ExpressionImpl","ColumnExpressionImpl","LiteralExpressionImpl","expressions","LogicalExpressionImpl","StringConcatExpressionImpl","MinMaxExpressionImpl","WhenThenOtherwiseExpressionImpl","RankExpressionImpl"],"mappings":";;;;AAAA;;AAEG;AAcH;AACA,SAAS,YAAY,CAAC,CAAU,EAAA;IAC9B,OAAO,CAAC,YAAYA,0BAAc;AACpC;AAEA,SAAS,gBAAgB,CAAC,KAAa,EAAE,cAA6B,EAAA;AACpE,IAAA,OAAO,cAAc,KAAK,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC;AAC3D;AAEA,SAAS,sBAAsB,CAC7B,KAA+D,EAC/D,uBAAsC,EAAA;AAEtC,IAAA,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC;IAClD,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,KAChB,OAAO,EAAE,KAAK,QAAQ,GAAG,gBAAgB,CAAC,EAAE,EAAE,uBAAuB,CAAC,GAAG,EAAE,CAC5E;AACH;AAEA;;;AAGG;AACG,SAAU,GAAG,CAAC,IAAY,EAAA;AAC9B,IAAA,OAAO,IAAIC,gCAAoB,CAAC,IAAI,CAAC;AACvC;AAEA;;;AAGG;AACG,SAAU,GAAG,CAAC,KAAmB,EAAA;AACrC,IAAA,OAAO,IAAIC,iCAAqB,CAAC,KAAK,CAAC;AACzC;AA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AO,IAAIC,2CAA+B,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC;IAChE;AACD;AAED;MACa,WAAW,CAAA;AAEH,IAAA,OAAA;AACA,IAAA,UAAA;IAFnB,WAAA,CACmB,OAAyB,EACzB,UAAmB,EAAA;QADnB,IAAA,CAAA,OAAO,GAAP,OAAO;QACP,IAAA,CAAA,UAAU,GAAV,UAAU;IAC1B;AAEH,IAAA,IAAI,CAAC,WAAqE,EAAA;QACxE,MAAM,eAAe,GAAG,sBAAsB,CAAC,WAAW,EAAE,KAAK,CAAC;AAClE,QAAA,OAAO,IAAIC,8BAAkB,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,CAAC,UAAU,CAAC;IAC/E;AACD;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"functions.cjs","names":["ExpressionImpl","ColumnExpressionImpl","LiteralExpressionImpl","LogicalExpressionImpl","StringConcatExpressionImpl","MinMaxExpressionImpl","WhenThenOtherwiseExpressionImpl","RankExpressionImpl"],"sources":["../src/functions.ts"],"sourcesContent":["/**\n * Factory functions for creating expressions - mirrors Tengo pt library API\n */\n\nimport type { LiteralValue } from \"./expressions\";\nimport {\n ColumnExpressionImpl,\n ExpressionImpl,\n LiteralExpressionImpl,\n LogicalExpressionImpl,\n MinMaxExpressionImpl,\n RankExpressionImpl,\n StringConcatExpressionImpl,\n WhenThenOtherwiseExpressionImpl,\n} from \"./expressions\";\n\n// Internal helpers mirroring Tengo behavior\nfunction isExpression(v: unknown): v is ExpressionImpl {\n return v instanceof ExpressionImpl;\n}\n\nfunction asExprFromString(value: string, interpretation: \"col\" | \"lit\"): ExpressionImpl {\n return interpretation === \"col\" ? col(value) : lit(value);\n}\n\nfunction coerceToExpressionList(\n items: Array<ExpressionImpl | string> | ExpressionImpl | string,\n interpretationForString: \"col\" | \"lit\",\n): ExpressionImpl[] {\n const arr = Array.isArray(items) ? items : [items];\n return arr.map((it) =>\n typeof it === \"string\" ? asExprFromString(it, interpretationForString) : it,\n );\n}\n\n/**\n * Create a column reference expression\n * @param name Column name\n */\nexport function col(name: string): ColumnExpressionImpl {\n return new ColumnExpressionImpl(name);\n}\n\n/**\n * Create a literal value expression\n * @param value Literal value (number, string, boolean, null, etc.)\n */\nexport function lit(value: LiteralValue): LiteralExpressionImpl {\n return new LiteralExpressionImpl(value);\n}\n\n/**\n * Create an AND expression with multiple operands (horizontal AND)\n * @param expressions Array of expressions to AND together\n */\nexport function allHorizontal(\n ...expressions: Array<ExpressionImpl | string>\n): LogicalExpressionImpl {\n // Interpret string args as column names. We don't flatten nested ANDs to keep implementation simple.\n const processed: ExpressionImpl[] = expressions.map((e) => (typeof e === \"string\" ? col(e) : e));\n return new LogicalExpressionImpl(\"and\", processed);\n}\n\n/**\n * Create an OR expression with multiple operands (horizontal OR)\n * @param expressions Array of expressions to OR together\n */\nexport function anyHorizontal(\n ...expressions: Array<ExpressionImpl | string>\n): LogicalExpressionImpl {\n // Interpret string args as column names. We don't flatten nested ORs to keep implementation simple.\n const processed: ExpressionImpl[] = expressions.map((e) => (typeof e === \"string\" ? col(e) : e));\n return new LogicalExpressionImpl(\"or\", processed);\n}\n\n/**\n * Create an AND expression with multiple operands\n * @param expressions Array of expressions to AND together\n */\nexport function and(...expressions: Array<ExpressionImpl | string>): LogicalExpressionImpl {\n return allHorizontal(...expressions);\n}\n\n/**\n * Create an OR expression with multiple operands\n * @param expressions Array of expressions to OR together\n */\nexport function or(...expressions: Array<ExpressionImpl | string>): LogicalExpressionImpl {\n return anyHorizontal(...expressions);\n}\n\n/**\n * Concatenate string representations with optional delimiter (Tengo: concatStr)\n * String inputs are treated as literals.\n */\nexport function concatStr(\n expressions: Array<ExpressionImpl | string>,\n options?: { delimiter?: string },\n): ExpressionImpl {\n if (!Array.isArray(expressions) || expressions.length === 0) {\n throw new Error(\"concatStr requires a non-empty array of expressions\");\n }\n const ops = coerceToExpressionList(expressions, \"lit\");\n const delimiter = options?.delimiter ?? \"\";\n return new StringConcatExpressionImpl(ops, delimiter);\n}\n\n/**\n * Element-wise min across expressions (Tengo: minHorizontal). Strings -> columns.\n */\nexport function minHorizontal(expressions: Array<ExpressionImpl | string>): ExpressionImpl {\n if (!Array.isArray(expressions) || expressions.length === 0) {\n throw new Error(\"minHorizontal requires a non-empty array of expressions\");\n }\n\n const ops = coerceToExpressionList(expressions, \"col\");\n return new MinMaxExpressionImpl(\"min\", ops);\n}\n\n/**\n * Element-wise max across expressions (Tengo: maxHorizontal). Strings -> columns.\n */\nexport function maxHorizontal(expressions: Array<ExpressionImpl | string>): ExpressionImpl {\n if (!Array.isArray(expressions) || expressions.length === 0) {\n throw new Error(\"maxHorizontal requires a non-empty array of expressions\");\n }\n const ops = coerceToExpressionList(expressions, \"col\");\n return new MinMaxExpressionImpl(\"max\", ops);\n}\n\n/**\n * Create a conditional when-then expression builder\n * @param condition Boolean expression condition\n */\nexport function when(condition: ExpressionImpl): WhenThenBuilder {\n return WhenThenBuilder.start(condition);\n}\n\n/**\n * Create a rank expression\n * @param expression Expression to rank\n * @param options Ranking options\n */\nexport function rank(\n orderBy: ExpressionImpl | string | Array<ExpressionImpl | string>,\n descending = false,\n): RankBuilder {\n const orderByList = coerceToExpressionList(orderBy, \"col\");\n return new RankBuilder(orderByList, descending);\n}\n\n/**\n * Builder class for when-then-otherwise conditional expressions\n */\nexport class WhenThenBuilder {\n private constructor(\n private readonly clauses: Array<{ when: ExpressionImpl; then: ExpressionImpl }>,\n private readonly currentWhen?: ExpressionImpl,\n ) {}\n\n static start(condition: ExpressionImpl): WhenThenBuilder {\n if (!isExpression(condition)) throw new Error(\"when() expects an Expression\");\n return new WhenThenBuilder([], condition);\n }\n\n when(condition: ExpressionImpl): WhenThenBuilder {\n if (this.currentWhen) throw new Error(\".when() must follow a .then()\");\n if (!isExpression(condition)) throw new Error(\".when() expects an Expression\");\n return new WhenThenBuilder(this.clauses, condition);\n }\n\n then(value: ExpressionImpl | LiteralValue): WhenThenBuilder {\n if (!this.currentWhen) throw new Error(\".then() must follow a .when()\");\n const expr = isExpression(value) ? value : lit(value);\n const nextClauses = this.clauses.slice();\n nextClauses.push({ when: this.currentWhen, then: expr });\n return new WhenThenBuilder(nextClauses, undefined);\n }\n\n otherwise(value: ExpressionImpl | LiteralValue): WhenThenOtherwiseExpressionImpl {\n if (this.currentWhen) throw new Error(\".otherwise() must follow a .then()\");\n if (this.clauses.length === 0) {\n throw new Error(\"At least one .when().then() clause is required before .otherwise()\");\n }\n const expr = isExpression(value) ? value : lit(value);\n return new WhenThenOtherwiseExpressionImpl(this.clauses, expr);\n }\n}\n\n// Rank builder and expression\nexport class RankBuilder {\n constructor(\n private readonly orderBy: ExpressionImpl[],\n private readonly descending: boolean,\n ) {}\n\n over(partitionBy: ExpressionImpl | string | Array<ExpressionImpl | string>): RankExpressionImpl {\n const partitionByList = coerceToExpressionList(partitionBy, \"col\");\n return new RankExpressionImpl(this.orderBy, partitionByList, this.descending);\n }\n}\n"],"mappings":";;;AAiBA,SAAS,aAAa,GAAiC;AACrD,QAAO,aAAaA;;AAGtB,SAAS,iBAAiB,OAAe,gBAA+C;AACtF,QAAO,mBAAmB,QAAQ,IAAI,MAAM,GAAG,IAAI,MAAM;;AAG3D,SAAS,uBACP,OACA,yBACkB;AAElB,SADY,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM,EACvC,KAAK,OACd,OAAO,OAAO,WAAW,iBAAiB,IAAI,wBAAwB,GAAG,GAC1E;;;;;;AAOH,SAAgB,IAAI,MAAoC;AACtD,QAAO,IAAIC,yCAAqB,KAAK;;;;;;AAOvC,SAAgB,IAAI,OAA4C;AAC9D,QAAO,IAAIC,0CAAsB,MAAM;;;;;;AAOzC,SAAgB,cACd,GAAG,aACoB;AAGvB,QAAO,IAAIC,0CAAsB,OADG,YAAY,KAAK,MAAO,OAAO,MAAM,WAAW,IAAI,EAAE,GAAG,EAAG,CAC9C;;;;;;AAOpD,SAAgB,cACd,GAAG,aACoB;AAGvB,QAAO,IAAIA,0C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