@dbsp/types 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2793,6 +2793,21 @@ interface AdapterCapabilities {
2793
2793
  readonly supportsWindowFunctions: boolean;
2794
2794
  readonly supportsArrayType: boolean;
2795
2795
  }
2796
+ /**
2797
+ * Per-instance connection state for adapters whose compile surface can exist
2798
+ * without a live database connection.
2799
+ *
2800
+ * This is deliberately separate from AdapterCapabilities: a database can
2801
+ * support a feature such as transactions even when this adapter instance has
2802
+ * no connection with which to execute one.
2803
+ */
2804
+ type ConnectionAvailability = {
2805
+ readonly status: 'available';
2806
+ } | {
2807
+ readonly status: 'unavailable';
2808
+ readonly reason: string;
2809
+ readonly fix: string;
2810
+ };
2796
2811
  interface CompiledColumnMetadata {
2797
2812
  readonly table: string;
2798
2813
  readonly column: string;
@@ -3101,6 +3116,14 @@ interface Dump {
3101
3116
  interface BaseAdapter {
3102
3117
  /** Adapter capabilities for feature detection */
3103
3118
  readonly capabilities: AdapterCapabilities;
3119
+ /**
3120
+ * Optional per-instance connection state.
3121
+ *
3122
+ * Adapters that omit this retain the existing capability-only execution
3123
+ * checks. Adapters that declare an unavailable connection let core return
3124
+ * their actionable refusal before any capability preflight.
3125
+ */
3126
+ readonly connectionAvailability?: ConnectionAvailability;
3104
3127
  /**
3105
3128
  * Whether this adapter instance is scoped inside a transaction.
3106
3129
  * Compile-only adapters and adapters without an active transaction report false.
@@ -3392,37 +3415,6 @@ interface DDLGeneratingAdapter extends BaseAdapter {
3392
3415
  */
3393
3416
  generateDDL(schema: ModelIR, options?: Record<string, unknown>): string[];
3394
3417
  }
3395
- /**
3396
- * Compile-only adapter - can compile SQL and generate DDL, but cannot execute
3397
- * queries or stream results. Useful for tooling, CLI, and testing without a
3398
- * live database connection.
3399
- *
3400
- * Includes DDLGeneratingAdapter because DDL generation is purely compile-time
3401
- * (no DB connection required — same rationale as SQL compilation).
3402
- *
3403
- * Explicitly excludes execution interfaces so that type-checking catches
3404
- * misuse (e.g. calling execute() on a compile-only instance) at compile time.
3405
- */
3406
- type CompileOnlyAdapter = CompilingAdapter & DDLGeneratingAdapter & TableDDLGeneratorAdapter & {
3407
- /** Naming convention used by this adapter. */
3408
- readonly dbCasing: DbCasing;
3409
- /**
3410
- * Create a schema-scoped compile-only adapter.
3411
- * Purely a schema-name prefix — no DB interaction required.
3412
- */
3413
- withSchema(schemaName: string): CompileOnlyAdapter;
3414
- readonly execute?: never;
3415
- readonly executeWithMeta?: never;
3416
- readonly executeOne?: never;
3417
- readonly executeOneOrThrow?: never;
3418
- readonly stream?: never;
3419
- readonly streamRaw?: never;
3420
- readonly introspect?: never;
3421
- readonly transaction?: never;
3422
- readonly withPinnedConnection?: never;
3423
- readonly executeRaw?: never;
3424
- readonly executeDDL?: never;
3425
- };
3426
3418
  /**
3427
3419
  * Database adapter interface - full adapter with all capabilities.
3428
3420
  *
@@ -3437,12 +3429,22 @@ interface Adapter<DB = unknown> extends CompilingAdapter, ExecutingAdapter, Stre
3437
3429
  readonly dbCasing: DbCasing;
3438
3430
  /**
3439
3431
  * Execute a DDL statement directly (e.g. TRUNCATE, VACUUM, ALTER TABLE, CREATE INDEX).
3440
- * Optional — compile-only adapters do not implement this.
3432
+ * Optional — adapters that do not provide DDL execution omit this method.
3441
3433
  *
3442
3434
  * @since DDL-TABLE-001
3443
3435
  */
3444
3436
  executeDDL?(sql: string): Promise<void>;
3445
3437
  }
3438
+ /**
3439
+ * @deprecated Existing `CompileOnlyAdapter` annotations remain valid. Use
3440
+ * `Adapter` when direct execution calls are needed.
3441
+ */
3442
+ type CompileOnlyAdapter<DB = unknown> = CompilingAdapter & DDLGeneratingAdapter & TableDDLGeneratorAdapter & {
3443
+ /** Naming convention used by this adapter. */
3444
+ readonly dbCasing: DbCasing;
3445
+ /** Create a schema-scoped compile-only adapter. */
3446
+ withSchema(schemaName: string): CompileOnlyAdapter<DB>;
3447
+ };
3446
3448
  /** Behavior when schema uses features the adapter doesn't support */
3447
3449
  type UnsupportedFeatureBehavior = 'error' | 'warning' | 'ignore';
3448
3450
  /** Aligned with DialectCapabilities supportsDDL* flags (1:1 mapping) */
@@ -3519,4 +3521,4 @@ interface TranslationContext {
3519
3521
  readonly dialectCapabilities: DialectCapabilities;
3520
3522
  }
3521
3523
 
3522
- export { type CustomTraversal as $, type Adapter as A, type BaseAdapter as B, type CompiledQuery as C, type CastExpressionIntent as D, type CheckConstraintIR as E, type CoalesceExpressionIntent as F, type ColumnAliasIntent as G, type ColumnExpressionIntent as H, type ColumnIR as I, type ColumnJsReadType as J, type ColumnListInput as K, type ColumnType as L, type CommonColumnType as M, type NqlBindingRelationType as N, type ComparisonExpressionIntent as O, type PlanReport as P, type ComparisonOperator as Q, type CompileOnlyAdapter as R, type CompileOptions as S, type CompileOptionsBase as T, type CompileResultWithIncludes as U, type CompiledNqlQuery as V, type CompilingAdapter as W, type CreateIndexOptions as X, type CteQueryIntent as Y, type CustomFnExpressionIntent as Z, type CustomOpExpressionIntent as _, type CompiledColumnMetadata as a, type NqlBindingColumnTypeInfo as a$, type DDLFeature as a0, type DDLFeatureElementMap as a1, type DDLFeatureVersionRange as a2, type DDLGeneratingAdapter as a3, type DbCasing as a4, type DecisionType as a5, type DeleteIntent as a6, type DialectCapabilities as a7, type DialectName as a8, type DiffSummary as a9, type InsertIntent as aA, type IntrospectingAdapter as aB, type IntrospectionOptions as aC, type IntrospectionResult as aD, type IsTypeSupported as aE, type JoinDefault as aF, type JoinIntent as aG, type JsonAggOrderByEntry as aH, type JsonContainsIntent as aI, type JsonExistsIntent as aJ, type JsonExtractIntent as aK, type JsonPathExtractIntent as aL, type LiteralExpressionIntent as aM, type LockIntent as aN, type LockStrength as aO, type LockWaitPolicy as aP, type LogicalIdentity as aQ, type LogicalIdentityCarrier as aR, type LogicalOperator as aS, type MSSQLColumnType as aT, type ModelIR as aU, type MutationIntent as aV, type MutationReturningItem as aW, type MySQLColumnType as aX, type NamedArgExpressionIntent as aY, type NestedOutputReadHandling as aZ, type NqlBindingColumnLineage as a_, type DropIndexOptions as aa, type DuckDBColumnType as ab, type Dump as ac, type DumpMeta as ad, type DumpSequenceStep as ae, type EdgeTableTraversal as af, type EmitJoinClause as ag, type EnumIR as ah, type ExecutingAdapter as ai, type ExpressionIntent as aj, type FeatureBehaviorConfig as ak, type FeatureTranslator as al, type FeatureWarning as am, type FieldRef as an, type FilterStrategy as ao, type ForeignKeyIR as ap, type FunctionExpressionIntent as aq, type HierarchyIR as ar, type IncludeIntent as as, type IncludeRecursiveOptions as at, type IncludeStrategy as au, type IndexColumnDef as av, type IndexIR as aw, type IndexInfo as ax, type IndexMethod as ay, type InsertFromIntent as az, type AdapterCapabilities as b, type RequiredEnumLabelIR as b$, type NqlBindingColumnUntypeableReason as b0, type NqlBindingOutputSchema as b1, type NqlBindingRelationFilterMetadata as b2, type NqlBindingVirtualRelation as b3, type NqlBindingVirtualRelationHop as b4, type NqlBindingVirtualRelationRecursive as b5, type NqlProgramSequenceStep as b6, type NqlRuntimeBinding as b7, type NullOperator as b8, type NullsPosition as b9, type QueryIntent as bA, type RangeOperand as bB, type RangeOperator as bC, type RangeValue as bD, type RankingWindowFunction as bE, type RankingWindowIntent as bF, type RawCteIntent as bG, type RawExpressionIntent as bH, type RawSqlAdapter as bI, type RecursiveAdvancedOptions as bJ, type RecursiveDedupe as bK, type RecursiveDirection as bL, type RecursiveEmitOptions as bM, type RecursiveExistsOptions as bN, type RecursiveIntent as bO, type RecursiveMetadata as bP, type RecursiveNodeIdExpr as bQ, type RecursivePlanOptions as bR, type RecursivePlanReport as bS, type RecursiveTrackOptions as bT, type RecursiveTraversal as bU, type RefExpressionIntent as bV, type RelationColumnIntent as bW, type RelationIR as bX, type RelationKind as bY, type RelationOperator as bZ, type RelationType as b_, type OffsetWindowFunction as ba, type OffsetWindowIntent as bb, type OnDeleteAction as bc, type OperationKindRef as bd, type Optionality as be, type OrderByExpressionIntent as bf, type OrderByFieldIntent as bg, type OrderByIntent as bh, type OutputDescriptor as bi, type OutputReadHandling as bj, type OutputSource as bk, type OutputValueShape as bl, type ParamExpressionIntent as bm, type ParamIntent as bn, type PartitionIR as bo, type PinnedConnectionOptions as bp, type PlanDecision as bq, type PlanOptions as br, type PlanWarning as bs, type PlanWarningCode as bt, type PolicyIR as bu, type PostgresColumnType as bv, type PostgresOnlyColumnType as bw, type PseudoColumnExpressionIntent as bx, type PseudoColumnMetadata as by, type PseudoColumnTraversal as bz, type AdapterLogger as c, type WindowOrderBy as c$, type ResolvedIncludeStrategy as c0, type SQLiteColumnType as c1, type SchemaChange as c2, type SchemaDiff as c3, type SelectAggregateIntent as c4, type SelectAllIntent as c5, type SelectFieldsIntent as c6, type SelectIntent as c7, type SelectWithExpressionsIntent as c8, type SemanticArtifactId as c9, type UpsertConflictTarget as cA, type UpsertFromIntent as cB, type UpsertIntent as cC, type VacuumOptions as cD, type WhereAndIntent as cE, type WhereAnyIntent as cF, type WhereComparisonIntent as cG, type WhereExistsIntent as cH, type WhereExpressionIntent as cI, type WhereInIntent as cJ, type WhereInSubqueryIntent as cK, type WhereInValueIntent as cL, type WhereIntent as cM, type WhereJsonContainsIntent as cN, type WhereJsonExistsIntent as cO, type WhereLikeIntent as cP, type WhereNotExistsIntent as cQ, type WhereNotIntent as cR, type WhereNullIntent as cS, type WhereOrIntent as cT, type WhereRangeIntent as cU, type WhereRawExistsIntent as cV, type WhereRawNotExistsIntent as cW, type WhereRelationFilterIntent as cX, type WhereSubqueryIntent as cY, type WindowFunction as cZ, type WindowIntent as c_, type SemanticArtifactRef as ca, type SequenceIR as cb, type SetOperationIntent as cc, type SetOperationType as cd, type SimpleCteIntent as ce, type SortDirection as cf, type StarExpressionIntent as cg, type StreamingAdapter as ch, type StringOperator as ci, type SubqueryExpressionIntent as cj, type SubqueryIncludeInfo as ck, type SubqueryRefIntent as cl, type SupportedColumnTypes as cm, type TableDDLGeneratorAdapter as cn, type TableIR as co, type TransactionBeginOptions as cp, type TransactionOptions as cq, type TransactionalAdapter as cr, type TranslationContext as cs, type TruncateOptions as ct, type TrustRoot as cu, type UnaryExpressionIntent as cv, type UnnestCteIntent as cw, type UnsupportedFeatureBehavior as cx, type UpdateIntent as cy, type UpsertConflictAction as cz, type AdapterStreamOptions as d, getNodeIdAlias as d0, isFieldRef as d1, isParamIntent as d2, resolveOutputReadHandling as d3, toColumnList as d4, type AdjacencyTraversal as e, type AggOrderByArg as f, type AggregateCountIntent as g, type AggregateExpressionIntent as h, type AggregateFieldIntent as i, type AggregateFunction as j, type AggregateIntent as k, type AggregateWindowFunction as l, type AggregateWindowIntent as m, type AliasIncludedColumnsMode as n, type AlterColumnOptions as o, type AmbiguityCheckResult as p, type ArithmeticExpressionIntent as q, type ArrayExpressionIntent as r, type ArrayOperator as s, type AuthorAttestedNativeDefault as t, type AuthorAttester as u, type BatchUpdateIntent as v, type BatchValuesJoinPayload as w, type CTEDefinition as x, type Cardinality as y, type CaseExpressionIntent as z };
3524
+ export { type CustomOpExpressionIntent as $, type Adapter as A, type BaseAdapter as B, type CompiledQuery as C, type CastExpressionIntent as D, type CheckConstraintIR as E, type CoalesceExpressionIntent as F, type ColumnAliasIntent as G, type ColumnExpressionIntent as H, type ColumnIR as I, type ColumnJsReadType as J, type ColumnListInput as K, type ColumnType as L, type CommonColumnType as M, type NqlBindingRelationType as N, type ComparisonExpressionIntent as O, type PlanReport as P, type ComparisonOperator as Q, type CompileOnlyAdapter as R, type CompileOptions as S, type CompileOptionsBase as T, type CompileResultWithIncludes as U, type CompiledNqlQuery as V, type CompilingAdapter as W, type ConnectionAvailability as X, type CreateIndexOptions as Y, type CteQueryIntent as Z, type CustomFnExpressionIntent as _, type CompiledColumnMetadata as a, type NqlBindingColumnLineage as a$, type CustomTraversal as a0, type DDLFeature as a1, type DDLFeatureElementMap as a2, type DDLFeatureVersionRange as a3, type DDLGeneratingAdapter as a4, type DbCasing as a5, type DecisionType as a6, type DeleteIntent as a7, type DialectCapabilities as a8, type DialectName as a9, type InsertFromIntent as aA, type InsertIntent as aB, type IntrospectingAdapter as aC, type IntrospectionOptions as aD, type IntrospectionResult as aE, type IsTypeSupported as aF, type JoinDefault as aG, type JoinIntent as aH, type JsonAggOrderByEntry as aI, type JsonContainsIntent as aJ, type JsonExistsIntent as aK, type JsonExtractIntent as aL, type JsonPathExtractIntent as aM, type LiteralExpressionIntent as aN, type LockIntent as aO, type LockStrength as aP, type LockWaitPolicy as aQ, type LogicalIdentity as aR, type LogicalIdentityCarrier as aS, type LogicalOperator as aT, type MSSQLColumnType as aU, type ModelIR as aV, type MutationIntent as aW, type MutationReturningItem as aX, type MySQLColumnType as aY, type NamedArgExpressionIntent as aZ, type NestedOutputReadHandling as a_, type DiffSummary as aa, type DropIndexOptions as ab, type DuckDBColumnType as ac, type Dump as ad, type DumpMeta as ae, type DumpSequenceStep as af, type EdgeTableTraversal as ag, type EmitJoinClause as ah, type EnumIR as ai, type ExecutingAdapter as aj, type ExpressionIntent as ak, type FeatureBehaviorConfig as al, type FeatureTranslator as am, type FeatureWarning as an, type FieldRef as ao, type FilterStrategy as ap, type ForeignKeyIR as aq, type FunctionExpressionIntent as ar, type HierarchyIR as as, type IncludeIntent as at, type IncludeRecursiveOptions as au, type IncludeStrategy as av, type IndexColumnDef as aw, type IndexIR as ax, type IndexInfo as ay, type IndexMethod as az, type AdapterCapabilities as b, type RelationType as b$, type NqlBindingColumnTypeInfo as b0, type NqlBindingColumnUntypeableReason as b1, type NqlBindingOutputSchema as b2, type NqlBindingRelationFilterMetadata as b3, type NqlBindingVirtualRelation as b4, type NqlBindingVirtualRelationHop as b5, type NqlBindingVirtualRelationRecursive as b6, type NqlProgramSequenceStep as b7, type NqlRuntimeBinding as b8, type NullOperator as b9, type PseudoColumnTraversal as bA, type QueryIntent as bB, type RangeOperand as bC, type RangeOperator as bD, type RangeValue as bE, type RankingWindowFunction as bF, type RankingWindowIntent as bG, type RawCteIntent as bH, type RawExpressionIntent as bI, type RawSqlAdapter as bJ, type RecursiveAdvancedOptions as bK, type RecursiveDedupe as bL, type RecursiveDirection as bM, type RecursiveEmitOptions as bN, type RecursiveExistsOptions as bO, type RecursiveIntent as bP, type RecursiveMetadata as bQ, type RecursiveNodeIdExpr as bR, type RecursivePlanOptions as bS, type RecursivePlanReport as bT, type RecursiveTrackOptions as bU, type RecursiveTraversal as bV, type RefExpressionIntent as bW, type RelationColumnIntent as bX, type RelationIR as bY, type RelationKind as bZ, type RelationOperator as b_, type NullsPosition as ba, type OffsetWindowFunction as bb, type OffsetWindowIntent as bc, type OnDeleteAction as bd, type OperationKindRef as be, type Optionality as bf, type OrderByExpressionIntent as bg, type OrderByFieldIntent as bh, type OrderByIntent as bi, type OutputDescriptor as bj, type OutputReadHandling as bk, type OutputSource as bl, type OutputValueShape as bm, type ParamExpressionIntent as bn, type ParamIntent as bo, type PartitionIR as bp, type PinnedConnectionOptions as bq, type PlanDecision as br, type PlanOptions as bs, type PlanWarning as bt, type PlanWarningCode as bu, type PolicyIR as bv, type PostgresColumnType as bw, type PostgresOnlyColumnType as bx, type PseudoColumnExpressionIntent as by, type PseudoColumnMetadata as bz, type AdapterLogger as c, type WindowIntent as c$, type RequiredEnumLabelIR as c0, type ResolvedIncludeStrategy as c1, type SQLiteColumnType as c2, type SchemaChange as c3, type SchemaDiff as c4, type SelectAggregateIntent as c5, type SelectAllIntent as c6, type SelectFieldsIntent as c7, type SelectIntent as c8, type SelectWithExpressionsIntent as c9, type UpsertConflictAction as cA, type UpsertConflictTarget as cB, type UpsertFromIntent as cC, type UpsertIntent as cD, type VacuumOptions as cE, type WhereAndIntent as cF, type WhereAnyIntent as cG, type WhereComparisonIntent as cH, type WhereExistsIntent as cI, type WhereExpressionIntent as cJ, type WhereInIntent as cK, type WhereInSubqueryIntent as cL, type WhereInValueIntent as cM, type WhereIntent as cN, type WhereJsonContainsIntent as cO, type WhereJsonExistsIntent as cP, type WhereLikeIntent as cQ, type WhereNotExistsIntent as cR, type WhereNotIntent as cS, type WhereNullIntent as cT, type WhereOrIntent as cU, type WhereRangeIntent as cV, type WhereRawExistsIntent as cW, type WhereRawNotExistsIntent as cX, type WhereRelationFilterIntent as cY, type WhereSubqueryIntent as cZ, type WindowFunction as c_, type SemanticArtifactId as ca, type SemanticArtifactRef as cb, type SequenceIR as cc, type SetOperationIntent as cd, type SetOperationType as ce, type SimpleCteIntent as cf, type SortDirection as cg, type StarExpressionIntent as ch, type StreamingAdapter as ci, type StringOperator as cj, type SubqueryExpressionIntent as ck, type SubqueryIncludeInfo as cl, type SubqueryRefIntent as cm, type SupportedColumnTypes as cn, type TableDDLGeneratorAdapter as co, type TableIR as cp, type TransactionBeginOptions as cq, type TransactionOptions as cr, type TransactionalAdapter as cs, type TranslationContext as ct, type TruncateOptions as cu, type TrustRoot as cv, type UnaryExpressionIntent as cw, type UnnestCteIntent as cx, type UnsupportedFeatureBehavior as cy, type UpdateIntent as cz, type AdapterStreamOptions as d, type WindowOrderBy as d0, getNodeIdAlias as d1, isFieldRef as d2, isParamIntent as d3, resolveOutputReadHandling as d4, toColumnList as d5, type AdjacencyTraversal as e, type AggOrderByArg as f, type AggregateCountIntent as g, type AggregateExpressionIntent as h, type AggregateFieldIntent as i, type AggregateFunction as j, type AggregateIntent as k, type AggregateWindowFunction as l, type AggregateWindowIntent as m, type AliasIncludedColumnsMode as n, type AlterColumnOptions as o, type AmbiguityCheckResult as p, type ArithmeticExpressionIntent as q, type ArrayExpressionIntent as r, type ArrayOperator as s, type AuthorAttestedNativeDefault as t, type AuthorAttester as u, type BatchUpdateIntent as v, type BatchValuesJoinPayload as w, type CTEDefinition as x, type Cardinality as y, type CaseExpressionIntent as z };
@@ -1,4 +1,4 @@
1
- import { C as CompiledQuery, a as CompiledColumnMetadata, P as PlanReport } from './adapter-CBhAwQzd.js';
1
+ import { C as CompiledQuery, a as CompiledColumnMetadata, P as PlanReport } from './adapter-CjwnHeg4.js';
2
2
 
3
3
  /**
4
4
  * Stable SPI for implementing the `Adapter` port. Only stable helpers required to construct/validate a
@@ -367,6 +367,9 @@ function buildRelationKeyFields(fk, direction, options = {}) {
367
367
  return { foreignKey };
368
368
  }
369
369
 
370
+ // src/transition/execution-contract.ts
371
+ var EXECUTION_CONTRACT_VERSION = 1;
372
+
370
373
  export {
371
374
  convertBigintJsReadValue,
372
375
  toColumnList,
@@ -424,6 +427,7 @@ export {
424
427
  resolveJsonAggOrderKey,
425
428
  isValidSchema,
426
429
  resolveOutputReadHandling,
427
- buildRelationKeyFields
430
+ buildRelationKeyFields,
431
+ EXECUTION_CONTRACT_VERSION
428
432
  };
429
- //# sourceMappingURL=chunk-4NBXLMCE.js.map
433
+ //# sourceMappingURL=chunk-SEWKTHUK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bigint-js-read.ts","../src/column-list.ts","../src/intent/expression-intent.ts","../src/intent/recursive-intent.ts","../src/intent/select-function-allowlist.ts","../src/intent/type-guards.ts","../src/intent/where-intent.ts","../src/json-agg-order-key.ts","../src/loaded-schema.ts","../src/output-provenance.ts","../src/relation-key-fields.ts","../src/transition/execution-contract.ts"],"sourcesContent":["import type { ColumnJsReadType } from './model-ir.js';\n\nexport interface BigintJsReadConversionContext {\n\treadonly table: string;\n\treadonly column: string;\n\treadonly outputKey: string;\n}\n\nconst MAX_SAFE_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);\nconst MIN_SAFE_BIGINT = BigInt(Number.MIN_SAFE_INTEGER);\nconst INTEGER_STRING_RE = /^[+-]?\\d+$/;\n\nfunction formatValue(value: unknown): string {\n\tif (typeof value === 'string') return `\"${value}\"`;\n\tif (typeof value === 'bigint') return `${value.toString()}n`;\n\tif (typeof value === 'number' || typeof value === 'boolean') {\n\t\treturn String(value);\n\t}\n\tif (value === null) return 'null';\n\tif (value === undefined) return 'undefined';\n\ttry {\n\t\treturn JSON.stringify(value) ?? String(value);\n\t} catch {\n\t\treturn String(value);\n\t}\n}\n\nfunction conversionError(\n\tvalue: unknown,\n\ttarget: Exclude<ColumnJsReadType, 'string'>,\n\tctx: BigintJsReadConversionContext,\n\treason: string,\n): RangeError {\n\treturn new RangeError(\n\t\t`Cannot convert PostgreSQL bigint column \"${ctx.table}.${ctx.column}\" output key \"${ctx.outputKey}\" value ${formatValue(value)} to ${target}: ${reason}.`,\n\t);\n}\n\nfunction toStrictBigInt(\n\tvalue: unknown,\n\ttarget: Exclude<ColumnJsReadType, 'string'>,\n\tctx: BigintJsReadConversionContext,\n): bigint {\n\tif (typeof value === 'bigint') return value;\n\tif (typeof value === 'string') {\n\t\tconst trimmed = value.trim();\n\t\tif (!INTEGER_STRING_RE.test(trimmed)) {\n\t\t\tthrow conversionError(\n\t\t\t\tvalue,\n\t\t\t\ttarget,\n\t\t\t\tctx,\n\t\t\t\t'expected an integer string, bigint, or safe integer number',\n\t\t\t);\n\t\t}\n\t\treturn BigInt(trimmed);\n\t}\n\tif (typeof value === 'number') {\n\t\tif (!Number.isSafeInteger(value)) {\n\t\t\tthrow conversionError(\n\t\t\t\tvalue,\n\t\t\t\ttarget,\n\t\t\t\tctx,\n\t\t\t\t'expected a safe integer number',\n\t\t\t);\n\t\t}\n\t\treturn BigInt(value);\n\t}\n\tthrow conversionError(\n\t\tvalue,\n\t\ttarget,\n\t\tctx,\n\t\t'expected an integer string, bigint, or safe integer number',\n\t);\n}\n\nexport function convertBigintJsReadValue(\n\tvalue: unknown,\n\tjs: ColumnJsReadType,\n\tctx: BigintJsReadConversionContext,\n): unknown {\n\tif (value === null || value === undefined) return value;\n\n\tswitch (js) {\n\t\tcase 'string':\n\t\t\treturn value;\n\t\tcase 'bigint':\n\t\t\treturn toStrictBigInt(value, 'bigint', ctx);\n\t\tcase 'number': {\n\t\t\tconst bigintValue = toStrictBigInt(value, 'number', ctx);\n\t\t\tif (bigintValue > MAX_SAFE_BIGINT || bigintValue < MIN_SAFE_BIGINT) {\n\t\t\t\tthrow conversionError(\n\t\t\t\t\tvalue,\n\t\t\t\t\t'number',\n\t\t\t\t\tctx,\n\t\t\t\t\t\"outside Number.MAX_SAFE_INTEGER; use js:'bigint' or omit js\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn Number(bigintValue);\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid bigint js read type '${String(js)}' for PostgreSQL bigint column \"${ctx.table}.${ctx.column}\".`,\n\t\t\t);\n\t}\n}\n","/**\n * Shared relation-key normalizer.\n *\n * Relation metadata accepts either a single column or a composite column list.\n * Readers should normalize once and keep the full list instead of degrading to\n * the first column.\n */\nexport type ColumnListInput = string | readonly string[] | undefined;\n\nexport function toColumnList(key: ColumnListInput): readonly string[] {\n\tif (key === undefined) return [];\n\treturn typeof key === 'string' ? [key] : key;\n}\n","/**\n * @module intent/expression-intent\n * Expression intent types for computed/derived values in SELECT.\n */\n\nimport type { QueryIntent } from './query-intent.js';\nimport type { AggregateFunction } from './select-intent.js';\nimport type { WhereIntent } from './where-intent.js';\n\n// ============================================================================\n// Expression Intents - Computed/Derived Values\n// ============================================================================\n\n/**\n * COALESCE expression: returns first non-null value from a list of fields\n * @example { kind: 'coalesce', fields: ['name_fr', 'name_en'], as: 'display_name' }\n * → COALESCE(name_fr, name_en) AS display_name\n */\nexport interface CoalesceExpressionIntent {\n\treadonly kind: 'coalesce';\n\t/** Fields to check in order (first non-null wins) */\n\treadonly fields: readonly string[];\n\t/** Required alias for the result column */\n\treadonly as: string;\n}\n\n/**\n * Raw SQL expression (escape hatch for advanced use cases)\n * @example { kind: 'raw', sql: 'NOW()', as: 'current_time' }\n * → NOW() AS current_time\n * @warning Use sparingly - bypasses type safety and SQL injection protection\n */\nexport interface RawExpressionIntent {\n\treadonly kind: 'raw';\n\t/** Raw SQL fragment (must be safe, no user input!) */\n\treadonly sql: string;\n\t/** Required alias for the result column */\n\treadonly as: string;\n}\n\n/**\n * Simple column expression: just a column reference, optionally aliased\n * Used by NQL when a column is selected without modification\n * @example { kind: 'column', column: 'name' }\n * → SELECT \"name\"\n * @example { kind: 'column', column: 'name', as: 'userName' }\n * → SELECT \"name\" AS \"userName\"\n */\nexport interface ColumnExpressionIntent {\n\treadonly kind: 'column';\n\t/** Column name to select */\n\treadonly column: string;\n\t/** Optional alias for the result column */\n\treadonly as?: string;\n}\n\n/**\n * Column alias expression: simple column reference with alias\n * Represents an aliased column as structured intent for dialect compilers\n * @example { kind: 'columnAlias', column: 'name', alias: 'userName' }\n * → SELECT \"name\" AS \"userName\"\n */\nexport interface ColumnAliasIntent {\n\treadonly kind: 'columnAlias';\n\t/** Column name to select */\n\treadonly column: string;\n\t/** Alias for the result column */\n\treadonly alias: string;\n}\n\n/**\n * Relation column expression: select a column from a related table\n * Auto-creates JOIN via include mechanism and selects with custom alias\n * @example { kind: 'relationColumn', relation: 'category', column: 'name', as: 'categoryName' }\n * → SELECT t1.\"name\" AS \"categoryName\" (where t1 is the joined category table)\n * @example { kind: 'relationColumn', relation: 'category.parent', column: 'name', as: 'parentCategoryName' }\n * → Multi-level join: products → category → parent, select parent.name\n */\nexport interface RelationColumnIntent {\n\treadonly kind: 'relationColumn';\n\t/** Relation path to traverse (dot-separated for multi-level) */\n\treadonly relation: string;\n\t/** Column name to select from the target relation */\n\treadonly column: string;\n\t/** Alias for the result column */\n\treadonly as: string;\n}\n\n/**\n * Aggregate expression intent for SELECT expressions\n * @example { kind: 'aggregate', function: 'count', as: 'total' } → COUNT(*) AS total\n * @example { kind: 'aggregate', function: 'sum', field: 'price', as: 'total_price' } → SUM(price) AS total_price\n * @example { kind: 'aggregate', function: 'count', field: 'id', distinct: true, as: 'unique_count' }\n * → COUNT(DISTINCT id) AS unique_count\n */\nexport interface AggregateExpressionIntent {\n\treadonly kind: 'aggregate';\n\t/** Aggregate function */\n\treadonly function: AggregateFunction;\n\t/** Field to aggregate (or '*' for count) */\n\treadonly field: string | '*';\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n\t/** Whether to apply DISTINCT to the aggregate */\n\treadonly distinct?: boolean | undefined;\n\t/** Extra arguments for multi-arg aggregates like string_agg(field, separator) */\n\treadonly extraArgs?: readonly unknown[] | undefined;\n\t/** FILTER (WHERE ...) clause for conditional aggregation */\n\treadonly filter?: WhereIntent | undefined;\n}\n\n/**\n * Pseudo-column traversal keyword for self-referential relations.\n * Used by NQL to traverse hierarchical/tree structures.\n *\n * Default keywords: 'parent', 'child', 'ascendant', 'descendant'.\n * Custom keywords are supported via schema configuration\n * (e.g., 'manager', 'managee' via parentRole/childRole).\n */\nexport type PseudoColumnTraversal = string;\n\n/**\n * Pseudo-column expression intent for self-referential traversal.\n * Enables access to columns on related rows in hierarchical structures.\n *\n * @example { kind: 'pseudoColumn', traversal: 'parent', targetColumn: 'name', as: 'parent.name' }\n * → SELECT parent_row.name AS \"parent.name\" via CTE join\n * @example { kind: 'pseudoColumn', traversal: 'ascendant', targetColumn: 'title', as: 'ancestor_title' }\n * → Recursive CTE to find all ancestors, return their title column\n */\nexport interface PseudoColumnExpressionIntent {\n\treadonly kind: 'pseudoColumn';\n\t/** Traversal type: single-hop (parent/child) or recursive (ascendant/descendant) */\n\treadonly traversal: PseudoColumnTraversal;\n\t/** The column to access on the target row(s) */\n\treadonly targetColumn: string;\n\t/** Alias for result column (required) */\n\treadonly as: string;\n\t/** Optional bounded depth for ascendant[N] / descendant[N] syntax */\n\treadonly depth?: number;\n\t/** Custom role name for multi-FK tables (e.g., 'manager' in manager.ascendant) */\n\treadonly role?: string;\n\t/**\n\t * Chained traversals for multi-hop navigation (e.g., parent.parent.name → ['parent', 'parent']).\n\t * When present, overrides single `traversal` field. Each element generates a successive self-join.\n\t */\n\treadonly traversals?: readonly PseudoColumnTraversal[];\n}\n\n/**\n * Generic function expression (e.g., now(), upper(name), coalesce(a, b)).\n * Used for SQL functions that are not aggregates.\n */\nexport interface FunctionExpressionIntent {\n\treadonly kind: 'function';\n\t/** Function name (e.g., 'upper', 'now', 'coalesce') */\n\treadonly name: string;\n\t/** Function arguments */\n\treadonly args: readonly unknown[];\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n}\n\n/**\n * Scalar subquery in SELECT clause.\n * Produces a single value from a nested query.\n */\nexport interface SubqueryExpressionIntent {\n\treadonly kind: 'subquery';\n\t/** The nested query */\n\treadonly query: QueryIntent;\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n}\n\n/**\n * Arithmetic expression (e.g., price * quantity).\n * Binary operation with left operand, operator, and right operand.\n */\nexport interface ArithmeticExpressionIntent {\n\treadonly kind: 'arithmetic';\n\t/** Left operand (column name or value) */\n\treadonly left: string | number | unknown;\n\t/** Arithmetic operator */\n\treadonly operator: '+' | '-' | '*' | '/' | '%';\n\t/** Right operand (column name or value) */\n\treadonly right: string | number | unknown;\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n}\n\n/**\n * Literal value expression: string, number, boolean, or null.\n * Used in CASE THEN/ELSE clauses for constant values.\n */\nexport interface LiteralExpressionIntent {\n\treadonly kind: 'literal';\n\t/** The literal value */\n\treadonly value: string | number | boolean | null;\n\t/** Optional alias */\n\treadonly as?: string | undefined;\n}\n\n/**\n * Comparison expression: left operator right.\n * Used in CASE WHEN conditions.\n */\nexport interface ComparisonExpressionIntent {\n\treadonly kind: 'comparison';\n\t/** Left side column reference */\n\treadonly column: string;\n\t/** Comparison operator */\n\treadonly operator: '=' | '!=' | '<' | '>' | '<=' | '>=' | 'like';\n\t/** Right side value */\n\treadonly value: unknown;\n}\n\n/**\n * CASE expression: conditional logic in SELECT.\n * CASE WHEN condition THEN result [WHEN ...] [ELSE default] END\n */\nexport interface CaseExpressionIntent {\n\treadonly kind: 'case';\n\t/** Array of WHEN-THEN pairs */\n\treadonly when: ReadonlyArray<{\n\t\treadonly condition: WhereIntent;\n\t\treadonly result: ExpressionIntent;\n\t}>;\n\t/** Optional ELSE clause */\n\treadonly else?: ExpressionIntent | undefined;\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n}\n\n// ============================================================================\n// JSON/JSONB Operators (E13)\n// ============================================================================\n\n/**\n * JSON path extraction: col->'key' or col->>'key' (chained paths supported).\n * Also used for function notation: json_extract(col, 'key'), json_extract_text(col, 'key').\n */\nexport interface JsonExtractIntent {\n\treadonly kind: 'jsonExtract';\n\treadonly field: string;\n\treadonly path: readonly (string | ParamIntent)[];\n\t/** 'json' = returns JSON value (->), 'text' = returns text (->>) */\n\treadonly mode: 'json' | 'text';\n\treadonly as?: string | undefined;\n}\n\n/**\n * JSON containment: col @> value (contains) or col <@ value (contained by).\n */\nexport interface JsonContainsIntent {\n\treadonly kind: 'jsonContains';\n\treadonly field: string;\n\treadonly value: unknown;\n\t/** true = <@ (contained by), false = @> (contains) */\n\treadonly reversed: boolean;\n}\n\n/**\n * JSON key existence: col ? 'key'.\n */\nexport interface JsonExistsIntent {\n\treadonly kind: 'jsonExists';\n\treadonly field: string;\n\treadonly key: string;\n}\n\n/**\n * JSON path extraction with array path: col #> '{a,b}' or col #>> '{a,b}'.\n */\nexport interface JsonPathExtractIntent {\n\treadonly kind: 'jsonPathExtract';\n\treadonly field: string;\n\t/** PostgreSQL JSON path segments. Bound as one text[] parameter by adapters. */\n\treadonly path: readonly (string | ParamIntent)[];\n\t/** 'json' = returns JSON (#>), 'text' = returns text (#>>) */\n\treadonly mode: 'json' | 'text';\n\treadonly as?: string | undefined;\n}\n\n/** Custom binary operator expression (e.g., <=> for pgvector) */\nexport interface CustomOpExpressionIntent {\n\treadonly kind: 'customOp';\n\treadonly operator: string;\n\treadonly left: ExpressionIntent;\n\treadonly right: ExpressionIntent;\n\treadonly as?: string;\n}\n\n/** Custom function call (e.g., paradedb.score) */\n/** Represents a single ORDER BY entry inside an aggregate function. */\nexport interface AggOrderByArg {\n\t/** Discriminator to distinguish from regular expression args. */\n\treadonly __aggOrderBy: true;\n\treadonly field: string;\n\treadonly direction: 'asc' | 'desc';\n}\n\nexport interface CustomFnExpressionIntent {\n\treadonly kind: 'customFn';\n\treadonly name: string;\n\treadonly args: readonly ExpressionIntent[];\n\treadonly as?: string;\n\t/** Apply DISTINCT to the call's arguments (e.g. count(DISTINCT id)) */\n\treadonly distinct?: boolean;\n\t/** FILTER (WHERE ...) clause for conditional aggregation */\n\treadonly filter?: WhereIntent | undefined;\n\t/** ORDER BY clause for ordered aggregates (e.g. array_agg(x ORDER BY y)) */\n\treadonly aggOrderBy?: readonly AggOrderByArg[] | undefined;\n}\n\n/** Column reference in custom expressions */\nexport interface RefExpressionIntent {\n\treadonly kind: 'ref';\n\treadonly column: string;\n}\n\n/**\n * Public bound-parameter node.\n *\n * A value that originated from an NQL named parameter or template binding is\n * represented explicitly in the public IntentAST. The inner value is opaque:\n * consumers must bind it as a value and must not inspect its shape to decide\n * whether it is query structure.\n *\n * @public\n */\nexport interface ParamExpressionIntent {\n\treadonly kind: 'param';\n\treadonly value: unknown;\n\t/** Optional alias when used as a SELECT expression. */\n\treadonly as?: string | undefined;\n}\n\n/** @public */\nexport type ParamIntent = ParamExpressionIntent;\n\n/** Single-level only — never recurse into .value; the inner bound value is opaque user data. @public */\nexport function isParamIntent(value: unknown): value is ParamIntent {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(value as Record<string, unknown>).kind === 'param' &&\n\t\t'value' in (value as Record<string, unknown>)\n\t);\n}\n\n/** Type cast expression */\nexport interface CastExpressionIntent {\n\treadonly kind: 'cast';\n\treadonly expr: ExpressionIntent;\n\treadonly typeName: string;\n}\n\n/** Named argument in a function call: name => value */\nexport interface NamedArgExpressionIntent {\n\treadonly kind: 'namedArg';\n\treadonly name: string;\n\treadonly value: ExpressionIntent;\n}\n\n/** Star/wildcard expression (*) — used in COUNT(*), SELECT *, etc. */\nexport interface StarExpressionIntent {\n\treadonly kind: 'star';\n}\n\n/** PostgreSQL ARRAY constructor: ARRAY[item1, item2, ...] */\nexport interface ArrayExpressionIntent {\n\treadonly kind: 'array';\n\treadonly elements: readonly ExpressionIntent[];\n\treadonly as?: string;\n}\n\n/** Unary operator expression (e.g., NOT, -, ~) */\nexport interface UnaryExpressionIntent {\n\treadonly kind: 'unary';\n\treadonly operator: string;\n\treadonly operand: ExpressionIntent;\n\treadonly as?: string;\n}\n\n/**\n * Expression intent union type - computed/derived values in SELECT\n * Extensible for future expression types\n */\nexport type ExpressionIntent =\n\t| ColumnExpressionIntent\n\t| CoalesceExpressionIntent\n\t| RawExpressionIntent\n\t| ColumnAliasIntent\n\t| RelationColumnIntent\n\t| WindowIntent\n\t| AggregateExpressionIntent\n\t| PseudoColumnExpressionIntent\n\t| FunctionExpressionIntent\n\t| SubqueryExpressionIntent\n\t| ArithmeticExpressionIntent\n\t| LiteralExpressionIntent\n\t| ComparisonExpressionIntent\n\t| CaseExpressionIntent\n\t| JsonExtractIntent\n\t| JsonContainsIntent\n\t| JsonExistsIntent\n\t| JsonPathExtractIntent\n\t| CustomOpExpressionIntent\n\t| CustomFnExpressionIntent\n\t| RefExpressionIntent\n\t| ParamExpressionIntent\n\t| CastExpressionIntent\n\t| UnaryExpressionIntent\n\t| NamedArgExpressionIntent\n\t| StarExpressionIntent\n\t| ArrayExpressionIntent;\n\n// ============================================================================\n// Window Functions (P3-A)\n// ============================================================================\n\n/**\n * Window function types for OVER clause analytics.\n * - Ranking: row_number, rank, dense_rank (no field required)\n * - Aggregate: sum, avg, count, min, max (field required)\n * - Offset: lag, lead (field required, offset/default deferred to P3+)\n */\nexport type WindowFunction =\n\t| 'row_number'\n\t| 'rank'\n\t| 'dense_rank'\n\t| 'sum'\n\t| 'avg'\n\t| 'count'\n\t| 'min'\n\t| 'max'\n\t| 'lag'\n\t| 'lead';\n\n/**\n * Order specification for window OVER clause.\n */\nexport interface WindowOrderBy {\n\treadonly field: string;\n\treadonly direction?: 'asc' | 'desc';\n}\n\n/**\n * Window function intent for analytics over partitions.\n * Produces SQL like: ROW_NUMBER() OVER (PARTITION BY x ORDER BY y) AS alias\n *\n * @example Row numbering\n * {\n * kind: 'window',\n * function: 'row_number',\n * alias: 'rn',\n * over: { orderBy: [{ field: 'created_at', direction: 'desc' }] }\n * }\n *\n * @example Running total\n * {\n * kind: 'window',\n * function: 'sum',\n * field: 'amount',\n * alias: 'running_total',\n * over: { partitionBy: ['account_id'], orderBy: [{ field: 'date' }] }\n * }\n */\n/**\n * Window function intent (ranking branch): ROW_NUMBER / RANK / DENSE_RANK — no field required.\n *\n * @example\n * { kind: 'window', function: 'row_number', alias: 'rn', over: { orderBy: [{ field: 'created_at', direction: 'desc' }] } }\n */\nexport interface RankingWindowIntent {\n\treadonly kind: 'window';\n\treadonly function: RankingWindowFunction;\n\treadonly field?: never;\n\t/** Result column alias (required) */\n\treadonly alias: string;\n\treadonly offset?: never;\n\treadonly defaultValue?: never;\n\t/** OVER clause specification */\n\treadonly over: {\n\t\treadonly partitionBy?: readonly string[] | undefined;\n\t\treadonly orderBy?: readonly WindowOrderBy[] | undefined;\n\t};\n}\n\n/**\n * Window function intent (aggregate branch): SUM / AVG / COUNT / MIN / MAX — field required.\n *\n * @example\n * { kind: 'window', function: 'sum', field: 'amount', alias: 'running_total', over: { partitionBy: ['account_id'] } }\n */\n/**\n * Window function intent (aggregate branch): SUM / AVG / COUNT / MIN / MAX.\n * Field is required for sum/avg/min/max; COUNT omits field to produce COUNT(*) OVER (...).\n *\n * @example SUM with field\n * { kind: 'window', function: 'sum', field: 'amount', alias: 'running_total', over: { partitionBy: ['account_id'] } }\n * @example COUNT(*)\n * { kind: 'window', function: 'count', alias: 'total', over: {} }\n */\nexport interface AggregateWindowIntent {\n\treadonly kind: 'window';\n\treadonly function: AggregateWindowFunction;\n\t/**\n\t * Field to aggregate over.\n\t * Required for sum/avg/min/max. Omit (or undefined) for COUNT(*) OVER (...).\n\t */\n\treadonly field?: string | undefined;\n\t/** Result column alias (required) */\n\treadonly alias: string;\n\treadonly offset?: never;\n\treadonly defaultValue?: never;\n\t/** OVER clause specification */\n\treadonly over: {\n\t\treadonly partitionBy?: readonly string[] | undefined;\n\t\treadonly orderBy?: readonly WindowOrderBy[] | undefined;\n\t};\n}\n\n/**\n * Window function intent (offset branch): LAG / LEAD — field required, offset optional.\n *\n * @example\n * { kind: 'window', function: 'lag', field: 'salary', alias: 'prev_salary', over: { orderBy: [{ field: 'date', direction: 'asc' }] } }\n */\nexport interface OffsetWindowIntent {\n\treadonly kind: 'window';\n\treadonly function: OffsetWindowFunction;\n\t/** Field to access from the offset row (required for lag/lead) */\n\treadonly field: string;\n\t/** Result column alias (required) */\n\treadonly alias: string;\n\t/** Offset for lag/lead (default: 1 in PostgreSQL) */\n\treadonly offset?: number | undefined;\n\t/** Default value for lag/lead when row doesn't exist */\n\treadonly defaultValue?: unknown;\n\t/** OVER clause specification */\n\treadonly over: {\n\t\treadonly partitionBy?: readonly string[] | undefined;\n\t\treadonly orderBy?: readonly WindowOrderBy[] | undefined;\n\t};\n}\n\n/**\n * Window function intent for analytics over partitions.\n * Discriminated by function group:\n * - RankingWindowIntent: row_number / rank / dense_rank (no field)\n * - AggregateWindowIntent: sum / avg / count / min / max (field required)\n * - OffsetWindowIntent: lag / lead (field required, offset optional)\n */\nexport type WindowIntent =\n\t| RankingWindowIntent\n\t| AggregateWindowIntent\n\t| OffsetWindowIntent;\n\n/**\n * Ranking window functions (no field required)\n */\nexport type RankingWindowFunction = 'row_number' | 'rank' | 'dense_rank';\n\n/**\n * Aggregate window functions (field required)\n */\nexport type AggregateWindowFunction = 'sum' | 'avg' | 'count' | 'min' | 'max';\n\n/**\n * Offset window functions (field required, offset/default deferred)\n */\nexport type OffsetWindowFunction = 'lag' | 'lead';\n","/**\n * @module intent/recursive-intent\n * Recursive CTE intent types for hierarchical data traversal (RFC-001).\n */\n\nimport type { OrderByIntent } from './include-intent.js';\nimport type { WhereIntent } from './where-intent.js';\n\n// ============================================================================\n// Recursive CTE Intent - Hierarchical Data Traversal (RFC-001)\n// ============================================================================\n\n/**\n * Node ID expression for recursive CTE anchor.\n * Used to define the join key for recursive traversal.\n */\nexport type RecursiveNodeIdExpr =\n\t| { readonly kind: 'column'; readonly name: string; readonly as?: string }\n\t| {\n\t\t\treadonly kind: 'literal';\n\t\t\treadonly value: unknown;\n\t\t\treadonly as?: string;\n\t }\n\t| {\n\t\t\treadonly kind: 'binary';\n\t\t\treadonly left: RecursiveNodeIdExpr;\n\t\t\treadonly op: string;\n\t\t\treadonly right: RecursiveNodeIdExpr;\n\t\t\treadonly as?: string;\n\t };\n\n/**\n * Get the alias for a node ID expression.\n * Used by both planner and compiler for consistent CTE column naming.\n *\n * @param expr - The node ID expression\n * @returns The alias to use (explicit alias, column name, or 'node_id' fallback)\n */\nexport function getNodeIdAlias(expr: RecursiveNodeIdExpr): string {\n\tif (expr.as) return expr.as;\n\tif (expr.kind === 'column') return expr.name;\n\tif (expr.kind === 'literal') return 'node_id';\n\t// Binary expression needs explicit alias\n\treturn 'node_id';\n}\n\n/**\n * Adjacency-list traversal (self-referential table).\n * Example: roles.parent_id → roles.id\n */\nexport interface AdjacencyTraversal {\n\treadonly kind: 'adjacency';\n\n\t/** Table containing hierarchical data */\n\treadonly nodeTable: string;\n\n\t/** Primary key column (e.g., \"id\") */\n\treadonly nodeId: string;\n\n\t/** Foreign key pointing to parent (e.g., \"parent_id\") */\n\treadonly parentId: string;\n\n\t/** Traversal direction */\n\treadonly direction: 'descendants' | 'ancestors';\n\n\t/** Filter applied to each step (e.g., active = true) */\n\treadonly stepWhere?: WhereIntent;\n}\n\n/**\n * Edge-table traversal (separate join table).\n * Example: role_inheritance(from_role_id, to_role_id)\n */\nexport interface EdgeTableTraversal {\n\treadonly kind: 'edge-table';\n\n\t/** Node table containing hierarchical data */\n\treadonly nodeTable: string;\n\n\t/** Edge table containing relationships */\n\treadonly edgeTable: string;\n\n\t/** Primary key column in node table (e.g., \"id\") */\n\treadonly nodeId: string;\n\n\t/** Source column in edge table (e.g., \"from_role_id\") */\n\treadonly edgeFrom: string;\n\n\t/** Target column in edge table (e.g., \"to_role_id\") */\n\treadonly edgeTo: string;\n\n\t/** Traversal direction */\n\treadonly direction: 'out' | 'in' | 'both';\n\n\t/** Filter on edges (e.g., relationship_type = 'inheritance') */\n\treadonly edgeWhere?: WhereIntent;\n\n\t/** Filter on nodes (e.g., active = true) */\n\treadonly nodeWhere?: WhereIntent;\n\n\t/** Edge attributes to include in result */\n\treadonly edgeSelect?: readonly string[];\n\n\t/**\n\t * Hint for edge storage semantics (only affects `direction: 'both'`).\n\t *\n\t * - 'unknown' (default): Edges may exist in both directions (A→B and B→A).\n\t * Uses UNION (distinct) to avoid duplicates. Safe but slower.\n\t * - 'directed-only': Caller guarantees edges are stored once only.\n\t * Uses UNION ALL for performance. INCORRECT if duplicates exist.\n\t */\n\treadonly edgeStorageHint?: 'unknown' | 'directed-only';\n}\n\n/**\n * Custom traversal for complex cases (P2 escape hatch).\n */\nexport interface CustomTraversal {\n\treadonly kind: 'custom';\n\t/** Explicit step query builder - reserved for P2 */\n\treadonly stepBuilder?: unknown;\n}\n\n/**\n * Recursive traversal type union.\n */\nexport type RecursiveTraversal =\n\t| AdjacencyTraversal\n\t| EdgeTableTraversal\n\t| CustomTraversal;\n\n/**\n * Tracking options for recursive traversal.\n */\nexport interface RecursiveTrackOptions {\n\t/** Depth counter (starts at 0) */\n\treadonly depth?: {\n\t\treadonly as?: string; // Default: \"depth\"\n\t};\n\n\t/** Path tracking for cycle detection + debugging */\n\treadonly path?: {\n\t\t/** Columns to trace in path (default: nodeId only) */\n\t\treadonly by?: 'nodeId' | readonly string[];\n\t\t/** Result column name (default: \"path\") */\n\t\treadonly as?: string;\n\t\t/** Storage strategy (default: 'array' for PostgreSQL, 'string' for others) */\n\t\treadonly strategy?: 'array' | 'string';\n\t\t/** Separator for string strategy (default: '/') */\n\t\treadonly separator?: string;\n\t};\n\n\t/** Cycle detection marker */\n\treadonly isCycle?: {\n\t\treadonly as?: string; // Default: \"is_cycle\"\n\t};\n}\n\n/**\n * Join clause for CTE emit composition.\n * Allows joining the CTE result with additional tables for final projection.\n */\nexport interface EmitJoinClause {\n\t/** Table to join with */\n\treadonly table: string;\n\n\t/** Join type (default: 'inner') */\n\treadonly type?: 'inner' | 'left';\n\n\t/** Alias for this table (auto-generated if not provided) */\n\treadonly as?: string;\n\n\t/** Join condition */\n\treadonly on: {\n\t\t/** Column from CTE or previous joined table */\n\t\treadonly left: string;\n\t\t/** Column from this table */\n\t\treadonly right: string;\n\t};\n\n\t/** Columns to select from this table */\n\treadonly select?: readonly (\n\t\t| string\n\t\t| { readonly column: string; readonly as: string }\n\t)[];\n}\n\n/**\n * Emit options for recursive CTE final projection.\n */\nexport interface RecursiveEmitOptions {\n\t/** Fields to select from CTE */\n\treadonly select?: readonly string[];\n\t/** Filter on generated rows */\n\treadonly where?: WhereIntent;\n\t/** Ordering */\n\treadonly orderBy?: readonly OrderByIntent[];\n\t/** Join CTE result with additional tables for composition */\n\treadonly joinWith?: readonly EmitJoinClause[];\n\t/** Apply DISTINCT to final result */\n\treadonly distinct?: boolean;\n}\n\n/**\n * PostgreSQL-specific options for recursive CTE (capability-gated).\n */\nexport interface RecursiveAdvancedOptions {\n\t/**\n\t * Cycle detection strategy (adapter-specific implementation).\n\t * - 'error': Throw on cycle detection\n\t * - 'stop': Stop traversal at cycle (prune branch)\n\t * - 'mark': Add is_cycle column to results\n\t *\n\t * PostgreSQL 14+ uses native CYCLE clause.\n\t * Other adapters may use application-level detection.\n\t */\n\treadonly cycle?: 'error' | 'stop' | 'mark';\n\n\t/**\n\t * Traversal search order (adapter-specific implementation).\n\t * - 'depth': Depth-first search order\n\t * - 'breadth': Breadth-first search order\n\t *\n\t * PostgreSQL 14+ uses native SEARCH clause.\n\t * Other adapters may use ORDER BY on depth column.\n\t */\n\treadonly search?: 'depth' | 'breadth';\n}\n\n/**\n * Deduplication strategy for recursive CTE.\n *\n * - 'none': No dedup. May return same node multiple times via different paths.\n * Fastest. Use when you need all paths or when graph is known to be a tree.\n *\n * - 'final': One row per nodeId in final output.\n * Implemented via `DISTINCT ON (nodeId)` (PostgreSQL) or\n * `ROW_NUMBER() OVER (PARTITION BY nodeId)` fallback.\n * ⚠️ NOT the same as `query.distinct()` which dedupes on entire row!\n *\n * Note: 'global' (UNION instead of UNION ALL) was considered but not implemented.\n * 'final' provides the same end result with better performance characteristics.\n */\nexport type RecursiveDedupe = 'none' | 'final';\n\n/**\n * Recursive CTE intent for hierarchical data traversal.\n *\n * Key invariant: anchor and step MUST produce identical column shape.\n * The planner validates this and auto-injects nodeIdExpr.\n *\n * @see RFC-001 for detailed specification\n */\nexport interface RecursiveIntent {\n\treadonly type: 'recursive';\n\n\t/** CTE name for the recursive query */\n\treadonly cteName: string;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// START (anchor/seed)\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\treadonly start: {\n\t\t/** Source table for anchor query */\n\t\treadonly from: string;\n\n\t\t/** Filter for seed rows (e.g., where id = $userId) */\n\t\treadonly where?: WhereIntent;\n\n\t\t/**\n\t\t * REQUIRED: Expression for node ID. Auto-injected into select.\n\t\t * This ensures the recursive join always has the key column.\n\t\t */\n\t\treadonly nodeIdExpr: RecursiveNodeIdExpr;\n\n\t\t/** Additional fields to select (beyond nodeId) */\n\t\treadonly select?: readonly string[];\n\t};\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// TRAVERSAL\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Traversal configuration (adjacency-list or edge-table) */\n\treadonly traversal: RecursiveTraversal;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// TRACKING (system columns)\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Tracking options for depth, path, and cycle detection */\n\treadonly track?: RecursiveTrackOptions;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// SAFETY\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Maximum recursion depth (REQUIRED) */\n\treadonly maxDepth: number;\n\n\t/** Maximum rows (optional safety limit) */\n\treadonly maxRows?: number;\n\n\t/** Deduplication strategy */\n\treadonly dedupe?: RecursiveDedupe;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// EMIT (final projection)\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Final projection options */\n\treadonly emit?: RecursiveEmitOptions;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// ADVANCED OPTIONS (capability-gated, adapter-specific implementation)\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Advanced recursive options (cycle detection, search order) */\n\treadonly advancedOptions?: RecursiveAdvancedOptions;\n}\n","/**\n * NQL-origin SELECT function allowlist.\n *\n * This is the shared security gate for function names that originated in NQL\n * SELECT text and later cross the IntentAST-to-SQL adapter boundary. Extend it\n * only after adding compiler and adapter coverage proving the function is\n * intentionally supported for NQL-origin SELECT projections.\n */\nexport const NQL_SELECT_AGGREGATE_FUNCTIONS = [\n\t'count',\n\t'sum',\n\t'avg',\n\t'min',\n\t'max',\n] as const;\n\nexport const NQL_SELECT_JSON_FUNCTIONS = [\n\t'json_extract',\n\t'json_extract_text',\n\t'json_path',\n\t'json_path_text',\n] as const;\n\nexport const NQL_SELECT_VALUE_FUNCTIONS = [\n\t'coalesce',\n\t'lower',\n\t'now',\n\t'round',\n\t'upper',\n] as const;\n\nexport const NQL_SELECT_SCALAR_FUNCTIONS = [\n\t...NQL_SELECT_AGGREGATE_FUNCTIONS,\n\t...NQL_SELECT_JSON_FUNCTIONS,\n\t...NQL_SELECT_VALUE_FUNCTIONS,\n] as const;\n\nexport const NQL_SELECT_WINDOW_ONLY_FUNCTIONS = [\n\t'row_number',\n\t'rank',\n\t'dense_rank',\n\t'lag',\n\t'lead',\n] as const;\n\nexport const NQL_SELECT_WINDOW_FUNCTIONS = [\n\t...NQL_SELECT_WINDOW_ONLY_FUNCTIONS,\n\t'count',\n\t'sum',\n\t'avg',\n\t'min',\n\t'max',\n] as const;\n\nexport const NQL_SELECT_SCALAR_FUNCTION_ALLOWLIST: ReadonlySet<string> =\n\tnew Set(NQL_SELECT_SCALAR_FUNCTIONS);\n\nexport const NQL_SELECT_WINDOW_FUNCTION_ALLOWLIST: ReadonlySet<string> =\n\tnew Set(NQL_SELECT_WINDOW_FUNCTIONS);\n\nexport const NQL_SELECT_FUNCTION_ALLOWLIST: ReadonlySet<string> = new Set([\n\t...NQL_SELECT_SCALAR_FUNCTIONS,\n\t...NQL_SELECT_WINDOW_FUNCTIONS,\n]);\n\ntype NqlSelectScalarFunction = (typeof NQL_SELECT_SCALAR_FUNCTIONS)[number];\ntype NqlSelectWindowFunction = (typeof NQL_SELECT_WINDOW_FUNCTIONS)[number];\n\nexport function isNqlSelectScalarFunctionAllowed(\n\tname: string,\n): name is NqlSelectScalarFunction {\n\treturn NQL_SELECT_SCALAR_FUNCTION_ALLOWLIST.has(name.toLowerCase());\n}\n\nexport function isNqlSelectFunctionAllowed(name: string): boolean {\n\treturn NQL_SELECT_FUNCTION_ALLOWLIST.has(name.toLowerCase());\n}\n\nexport function isNqlSelectWindowFunctionAllowed(\n\tname: string,\n): name is NqlSelectWindowFunction {\n\treturn NQL_SELECT_WINDOW_FUNCTION_ALLOWLIST.has(name.toLowerCase());\n}\n","/**\n * @module intent/type-guards\n * Type guard functions for all intent AST types.\n */\n\nimport type {\n\tAggregateWindowFunction,\n\tCoalesceExpressionIntent,\n\tColumnAliasIntent,\n\tExpressionIntent,\n\tOffsetWindowFunction,\n\tRankingWindowFunction,\n\tRawExpressionIntent,\n\tRelationColumnIntent,\n\tWindowFunction,\n\tWindowIntent,\n} from './expression-intent.js';\nimport type {\n\tDeleteIntent,\n\tInsertIntent,\n\tMutationIntent,\n\tUpdateIntent,\n\tUpsertIntent,\n} from './mutation-intent.js';\nimport type { QueryIntent } from './query-intent.js';\nimport type {\n\tAdjacencyTraversal,\n\tCustomTraversal,\n\tEdgeTableTraversal,\n\tRecursiveIntent,\n\tRecursiveTraversal,\n} from './recursive-intent.js';\nimport type {\n\tSelectAggregateIntent,\n\tSelectAllIntent,\n\tSelectFieldsIntent,\n\tSelectIntent,\n\tSelectWithExpressionsIntent,\n} from './select-intent.js';\nimport type {\n\tSubqueryRefIntent,\n\tWhereAndIntent,\n\tWhereAnyIntent,\n\tWhereComparisonIntent,\n\tWhereExistsIntent,\n\tWhereInIntent,\n\tWhereIntent,\n\tWhereLikeIntent,\n\tWhereNotExistsIntent,\n\tWhereNotIntent,\n\tWhereNullIntent,\n\tWhereOrIntent,\n\tWhereRangeIntent,\n\tWhereRelationFilterIntent,\n\tWhereSubqueryIntent,\n} from './where-intent.js';\n\n// ============================================================================\n// Window Intent Type Guards\n// ============================================================================\n\n/**\n * Check if an intent is a window function intent\n */\nexport function isWindowIntent(intent: unknown): intent is WindowIntent {\n\treturn (\n\t\ttypeof intent === 'object' &&\n\t\tintent !== null &&\n\t\t'kind' in intent &&\n\t\t(intent as Record<string, unknown>).kind === 'window'\n\t);\n}\n\n/**\n * Check if a window function requires a field (aggregate or offset functions)\n */\nexport function isAggregateWindowFunction(\n\tfn: WindowFunction,\n): fn is AggregateWindowFunction | OffsetWindowFunction {\n\treturn ['sum', 'avg', 'count', 'min', 'max', 'lag', 'lead'].includes(fn);\n}\n\n/**\n * Check if a window function is a ranking function (no field required)\n */\nexport function isRankingWindowFunction(\n\tfn: WindowFunction,\n): fn is RankingWindowFunction {\n\treturn ['row_number', 'rank', 'dense_rank'].includes(fn);\n}\n\n// ============================================================================\n// Where Intent Type Guards\n// ============================================================================\n\n/**\n * Check if a where intent is a comparison\n */\nexport function isWhereComparison(\n\twhere: WhereIntent,\n): where is WhereComparisonIntent {\n\treturn where.kind === 'comparison';\n}\n\n/**\n * Check if a where intent is a like filter\n */\nexport function isWhereLike(where: WhereIntent): where is WhereLikeIntent {\n\treturn where.kind === 'like';\n}\n\n/**\n * Check if a where intent is a subquery filter\n */\nexport function isWhereSubquery(\n\twhere: WhereIntent,\n): where is WhereSubqueryIntent {\n\treturn where.kind === 'subquery';\n}\n\n/**\n * Check if a value is a subquery ref (column reference in subquery)\n */\nexport function isSubqueryRef(value: unknown): value is SubqueryRefIntent {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'kind' in value &&\n\t\t(value as Record<string, unknown>).kind === 'ref'\n\t);\n}\n\n/**\n * Check if a where intent is an in filter\n */\nexport function isWhereIn(where: WhereIntent): where is WhereInIntent {\n\treturn where.kind === 'in';\n}\n\n/**\n * Check if a where intent is an any filter (= ANY($N::type[]))\n */\nexport function isWhereAny(where: WhereIntent): where is WhereAnyIntent {\n\treturn where.kind === 'any';\n}\n\n/**\n * Check if a where intent is a null filter\n */\nexport function isWhereNull(where: WhereIntent): where is WhereNullIntent {\n\treturn where.kind === 'null';\n}\n\n/**\n * Check if a where intent is a range filter (PostgreSQL range types)\n */\nexport function isWhereRange(where: WhereIntent): where is WhereRangeIntent {\n\treturn where.kind === 'range';\n}\n\n/**\n * Check if a where intent is a logical AND\n */\nexport function isWhereAnd(where: WhereIntent): where is WhereAndIntent {\n\treturn where.kind === 'and';\n}\n\n/**\n * Check if a where intent is a logical OR\n */\nexport function isWhereOr(where: WhereIntent): where is WhereOrIntent {\n\treturn where.kind === 'or';\n}\n\n/**\n * Check if a where intent is a logical NOT\n */\nexport function isWhereNot(where: WhereIntent): where is WhereNotIntent {\n\treturn where.kind === 'not';\n}\n\n/**\n * Check if a where intent is an exists filter\n */\nexport function isWhereExists(where: WhereIntent): where is WhereExistsIntent {\n\treturn where.kind === 'exists';\n}\n\n/**\n * Check if a where intent is a not exists filter\n */\nexport function isWhereNotExists(\n\twhere: WhereIntent,\n): where is WhereNotExistsIntent {\n\treturn where.kind === 'notExists';\n}\n\n/**\n * Check if a where intent is a relation filter\n */\nexport function isWhereRelationFilter(\n\twhere: WhereIntent,\n): where is WhereRelationFilterIntent {\n\treturn where.kind === 'relationFilter';\n}\n\n/**\n * Check if a where intent is any relation-based filter\n */\nexport function isWhereRelationBased(\n\twhere: WhereIntent,\n): where is\n\t| WhereExistsIntent\n\t| WhereNotExistsIntent\n\t| WhereRelationFilterIntent {\n\treturn (\n\t\twhere.kind === 'exists' ||\n\t\twhere.kind === 'notExists' ||\n\t\twhere.kind === 'relationFilter'\n\t);\n}\n\n/**\n * Check if a where intent is a logical operator (and/or/not)\n */\nexport function isWhereLogical(\n\twhere: WhereIntent,\n): where is WhereAndIntent | WhereOrIntent | WhereNotIntent {\n\treturn where.kind === 'and' || where.kind === 'or' || where.kind === 'not';\n}\n\n// ============================================================================\n// Select Intent Type Guards\n// ============================================================================\n\n/**\n * Check if a select intent selects all columns\n */\nexport function isSelectAll(select: SelectIntent): select is SelectAllIntent {\n\treturn select.type === 'all';\n}\n\n/**\n * Check if a select intent selects specific fields\n */\nexport function isSelectFields(\n\tselect: SelectIntent,\n): select is SelectFieldsIntent {\n\treturn select.type === 'fields';\n}\n\n/**\n * Check if a select intent is an aggregate select\n */\nexport function isSelectAggregate(\n\tselect: SelectIntent,\n): select is SelectAggregateIntent {\n\treturn select.type === 'aggregate';\n}\n\n/**\n * Check if a select intent has expressions\n */\nexport function isSelectWithExpressions(\n\tselect: SelectIntent,\n): select is SelectWithExpressionsIntent {\n\treturn select.type === 'expressions';\n}\n\n// ============================================================================\n// Expression Intent Type Guards\n// ============================================================================\n\n/**\n * Check if an expression is a COALESCE expression\n */\nexport function isCoalesceExpression(\n\texpr: ExpressionIntent,\n): expr is CoalesceExpressionIntent {\n\treturn expr.kind === 'coalesce';\n}\n\n/**\n * Check if an expression is a raw SQL expression\n */\nexport function isRawExpression(\n\texpr: ExpressionIntent,\n): expr is RawExpressionIntent {\n\treturn expr.kind === 'raw';\n}\n\n/**\n * Check if an expression is a column alias expression\n */\nexport function isColumnAliasExpression(\n\texpr: ExpressionIntent,\n): expr is ColumnAliasIntent {\n\treturn expr.kind === 'columnAlias';\n}\n\n/**\n * Check if an expression is a relation column expression\n */\nexport function isRelationColumnExpression(\n\texpr: ExpressionIntent,\n): expr is RelationColumnIntent {\n\treturn expr.kind === 'relationColumn';\n}\n\n// ============================================================================\n// Recursive CTE Type Guards\n// ============================================================================\n\n/**\n * Check if a traversal is adjacency-list based\n */\nexport function isAdjacencyTraversal(\n\ttraversal: RecursiveTraversal,\n): traversal is AdjacencyTraversal {\n\treturn traversal.kind === 'adjacency';\n}\n\n/**\n * Check if a traversal is edge-table based\n */\nexport function isEdgeTableTraversal(\n\ttraversal: RecursiveTraversal,\n): traversal is EdgeTableTraversal {\n\treturn traversal.kind === 'edge-table';\n}\n\n/**\n * Check if a traversal is custom\n */\nexport function isCustomTraversal(\n\ttraversal: RecursiveTraversal,\n): traversal is CustomTraversal {\n\treturn traversal.kind === 'custom';\n}\n\n/**\n * Check if an intent is a recursive CTE intent\n */\nexport function isRecursiveIntent(\n\tintent: QueryIntent | RecursiveIntent,\n): intent is RecursiveIntent {\n\treturn intent.type === 'recursive';\n}\n\n// ============================================================================\n// Mutation Intent Type Guards\n// ============================================================================\n\n/**\n * Check if an intent is an insert intent\n */\nexport function isInsertIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is InsertIntent {\n\treturn intent.type === 'insert';\n}\n\n/**\n * Check if an intent is an update intent\n */\nexport function isUpdateIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is UpdateIntent {\n\treturn intent.type === 'update';\n}\n\n/**\n * Check if an intent is a delete intent\n */\nexport function isDeleteIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is DeleteIntent {\n\treturn intent.type === 'delete';\n}\n\n/**\n * Check if an intent is an upsert intent (DX-026)\n */\nexport function isUpsertIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is UpsertIntent {\n\treturn intent.type === 'upsert';\n}\n\n/**\n * Check if an intent is any mutation intent\n */\nexport function isMutationIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is MutationIntent {\n\treturn (\n\t\tintent.type === 'insert' ||\n\t\tintent.type === 'insert_from' ||\n\t\tintent.type === 'upsert_from' ||\n\t\tintent.type === 'update' ||\n\t\tintent.type === 'batchUpdate' ||\n\t\tintent.type === 'delete' ||\n\t\tintent.type === 'upsert'\n\t);\n}\n","/**\n * @module intent/where-intent\n * Where intent types for filter conditions.\n */\n\nimport type { ColumnListInput } from '../column-list.js';\nimport type { RangeValue } from '../shared/utils.js';\nimport type { ExpressionIntent, ParamIntent } from './expression-intent.js';\nimport type { ComparisonOperator, NullOperator } from './operators.js';\nimport type { QueryIntent } from './query-intent.js';\nimport type { RecursiveExistsOptions } from './recursive-types.js';\n\nexport type { RangeValue };\n\n// ============================================================================\n// Where Intent - Filter Conditions\n// ============================================================================\n\n/**\n * Typed field reference for cross-table column comparisons in relation filters.\n *\n * When using aliased relation filters like `some(orders as o, o.total > minOrder)`,\n * the RHS `minOrder` is a reference to the parent table's column, not a literal value.\n * FieldRef captures this distinction so the adapter can compile it as a column reference\n * instead of a parameterized value.\n *\n * @example\n * // some(rel as r, r.col > bareCol) → value: { kind: 'fieldRef', column: 'bareCol', scope: 'outer' }\n * // some(rel as r, r.col > r.otherCol) → value: { kind: 'fieldRef', column: 'otherCol', scope: 'inner' }\n * // some(a as x, some(b as y, y.f > x.g)) → value: { kind: 'fieldRef', column: 'g', scope: 'outer', alias: 'x' }\n */\nexport interface FieldRef {\n\treadonly kind: 'fieldRef';\n\treadonly column: string;\n\treadonly scope: 'inner' | 'outer';\n\t/** Named alias for outer scope (when referencing a specific outer alias in nested filters) */\n\treadonly alias?: string;\n}\n\n/**\n * Type guard for FieldRef values\n */\nexport function isFieldRef(value: unknown): value is FieldRef {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object' &&\n\t\t(value as Record<string, unknown>).kind === 'fieldRef'\n\t);\n}\n\nexport interface WhereComparisonIntent {\n\treadonly kind: 'comparison';\n\treadonly field: string;\n\treadonly operator: ComparisonOperator;\n\treadonly value: unknown;\n\t/** JSON path extraction before comparison (e.g., data->'key' = 'val') */\n\treadonly jsonPath?: readonly (string | ParamIntent)[];\n\t/** JSON extraction mode: 'json' = ->, 'text' = ->> */\n\treadonly jsonMode?: 'json' | 'text';\n}\n\n/**\n * String filter: field like pattern\n */\nexport interface WhereLikeIntent {\n\treadonly kind: 'like';\n\treadonly field: string;\n\treadonly pattern: string | ParamIntent;\n\t/** Case-insensitive matching */\n\treadonly caseInsensitive?: boolean;\n\t/** Escape character for LIKE pattern (e.g. '\\\\' to escape _ and %) */\n\treadonly escape?: string;\n}\n\n/**\n * Array filter: field in [values]\n */\n/**\n * Array filter (values branch): field IN (v1, v2, ...)\n */\nexport interface WhereInValueIntent {\n\treadonly kind: 'in';\n\treadonly field: string;\n\treadonly values: readonly unknown[];\n\treadonly subquery?: never;\n\treadonly not?: boolean;\n}\n\n/**\n * Array filter (subquery branch): field IN (SELECT ...)\n */\nexport interface WhereInSubqueryIntent {\n\treadonly kind: 'in';\n\treadonly field: string;\n\treadonly subquery: QueryIntent;\n\treadonly values?: never;\n\treadonly not?: boolean;\n}\n\n/**\n * Array filter: field in [values] OR field IN (subquery)\n * XOR: exactly one of `values` or `subquery` must be present.\n */\nexport type WhereInIntent = WhereInValueIntent | WhereInSubqueryIntent;\n\n/**\n * Array membership filter using PostgreSQL ANY() operator.\n * Compiles to: \"col\" = ANY($N::type[])\n */\nexport interface WhereAnyIntent {\n\treadonly kind: 'any';\n\treadonly field: string;\n\treadonly values: readonly unknown[] | ParamIntent;\n}\n\n/**\n * Operand accepted by range WHERE filters.\n * - RangeValue: for range-to-range operators (overlaps, contains, containedBy)\n * - string: ISO date/timestamp literals (e.g. '2025-01-15', '2025-01-15T08:00:00Z')\n * - number: integer/numeric point values (e.g. 50000 for salary_range @> 50000)\n * - boolean: rarely used but valid PostgreSQL range operand\n */\nexport type RangeOperand = RangeValue | string | number | boolean;\n\n/**\n * Range operator for PostgreSQL range types.\n * - overlaps: && (ranges have common points)\n * - contains: @> (range contains value or range)\n * - containedBy: <@ (range is contained by another range)\n */\nexport type RangeOperator = 'overlaps' | 'contains' | 'containedBy' | 'between';\n\n/**\n * Range filter: field overlaps/contains/containedBy range value\n * PostgreSQL range types: daterange, tsrange, tstzrange, int4range, int8range, numrange\n *\n * @example\n * // Check if booking dates overlap a period\n * { kind: 'range', field: 'dates', operator: 'overlaps', value: { lower: '2025-01-15', upper: '2025-01-20' } }\n *\n * // Check if salary range contains a value\n * { kind: 'range', field: 'salary_range', operator: 'contains', value: 50000 }\n */\n/**\n * Range filter: field overlaps/contains/containedBy range value\n * PostgreSQL range types: daterange, tsrange, tstzrange, int4range, int8range, numrange\n *\n * @example\n * // Check if booking dates overlap a period\n * { kind: 'range', field: 'dates', operator: 'overlaps', value: { lower: '2025-01-15', upper: '2025-01-20' } }\n *\n * // Check if salary range contains a value\n * { kind: 'range', field: 'salary_range', operator: 'contains', value: 50000 }\n */\nexport interface WhereRangeIntent {\n\treadonly kind: 'range';\n\treadonly field: string;\n\treadonly operator: RangeOperator;\n\t/** Operand: RangeValue for range-to-range ops, or a scalar (string | number | boolean) for point-in-range ops */\n\treadonly value: RangeOperand;\n}\n\n/**\n * Null filter: field is null / is not null\n */\nexport interface WhereNullIntent {\n\treadonly kind: 'null';\n\treadonly field: string;\n\treadonly operator: NullOperator;\n}\n\n/**\n * Logical AND: all conditions must match\n */\nexport interface WhereAndIntent {\n\treadonly kind: 'and';\n\treadonly conditions: readonly WhereIntent[];\n}\n\n/**\n * Logical OR: at least one condition must match\n */\nexport interface WhereOrIntent {\n\treadonly kind: 'or';\n\treadonly conditions: readonly WhereIntent[];\n}\n\n/**\n * Logical NOT: condition must not match\n */\nexport interface WhereNotIntent {\n\treadonly kind: 'not';\n\treadonly condition: WhereIntent;\n}\n\n/**\n * Relation exists filter: filter by existence of related records\n * Critical for Q1 golden test - enables EXISTS subquery strategy\n *\n * @example\n * // Find users who have at least one published post\n * { kind: 'exists', relation: 'posts', where: { kind: 'comparison', field: 'status', operator: 'eq', value: 'published' } }\n */\nexport interface WhereExistsIntent {\n\treadonly kind: 'exists';\n\t/** Relation name to check existence */\n\treadonly relation: string;\n\t/** Optional filter on related records */\n\treadonly where?: WhereIntent;\n\t/**\n\t * Recursive options for ancestor/descendant existence checks.\n\t * When present, generates a recursive CTE instead of simple EXISTS.\n\t */\n\treadonly recursive?: RecursiveExistsOptions;\n\t/**\n\t * Optional JOIN declarations inside the EXISTS subquery.\n\t * Keys are relation names (used as aliases), values specify join type.\n\t * Enables filtering on joined tables inside the subquery.\n\t *\n\t * @example\n\t * exists('callers', {\n\t * include: { callerFile: { join: 'inner' } },\n\t * where: eq('callerFile.project_id', projectId)\n\t * })\n\t */\n\treadonly include?: Readonly<Record<string, { join?: 'inner' | 'left' }>>;\n}\n\n/**\n * Relation not exists filter: filter by absence of related records\n *\n * @example\n * // Find users who have no posts\n * { kind: 'notExists', relation: 'posts' }\n */\nexport interface WhereNotExistsIntent {\n\treadonly kind: 'notExists';\n\t/** Relation name to check absence */\n\treadonly relation: string;\n\t/** Optional filter on related records */\n\treadonly where?: WhereIntent;\n\t/**\n\t * Recursive options for ancestor/descendant absence checks.\n\t * When present, generates a recursive CTE instead of simple NOT EXISTS.\n\t */\n\treadonly recursive?: RecursiveExistsOptions;\n\t/**\n\t * Optional JOIN declarations inside the NOT EXISTS subquery.\n\t * Keys are relation names (used as aliases), values specify join type.\n\t * Enables filtering on joined tables inside the subquery.\n\t *\n\t * @example\n\t * notExists('callers', {\n\t * include: { callerFile: { join: 'inner' } },\n\t * where: eq('callerFile.project_id', projectId)\n\t * })\n\t */\n\treadonly include?: Readonly<Record<string, { join?: 'inner' | 'left' }>>;\n}\n\n/**\n * Raw EXISTS subquery filter using an arbitrary QueryIntent.\n * Unlike WhereExistsIntent (which uses FK-resolved relation names),\n * this wraps a fully-specified subquery for correlated EXISTS checks.\n *\n * @example\n * // EXISTS (SELECT 1 FROM symbols WHERE symbols.id = calls.symbol_id AND ...)\n * exists(subquery('symbols').where(eq('id', ref('calls.symbol_id'))))\n */\nexport interface WhereRawExistsIntent {\n\treadonly kind: 'rawExists';\n\t/** The subquery producing rows for the EXISTS check */\n\treadonly subquery: QueryIntent;\n}\n\n/**\n * Raw NOT EXISTS subquery filter using an arbitrary QueryIntent.\n *\n * @example\n * // NOT EXISTS (SELECT 1 FROM symbols WHERE ...)\n * notExists(subquery('symbols').where(...))\n */\nexport interface WhereRawNotExistsIntent {\n\treadonly kind: 'rawNotExists';\n\t/** The subquery producing rows for the NOT EXISTS check */\n\treadonly subquery: QueryIntent;\n}\n\n/**\n * Relation filter: filter parent by conditions on related records\n * More flexible than exists - allows filtering by related record attributes\n *\n * @example\n * // Find users whose latest post was created in 2024\n * { kind: 'relationFilter', relation: 'posts', where: {...}, mode: 'some' }\n */\nexport interface WhereRelationFilterIntent {\n\treadonly kind: 'relationFilter';\n\t/**\n\t * Relation path for filtering.\n\t * - Single relation: 'posts' or ['posts']\n\t * - Multi-hop (SPEC-002): ['author', 'company'] for author.company traversal\n\t */\n\treadonly relation: string | readonly string[];\n\t/** Filter conditions on related records */\n\treadonly where: WhereIntent;\n\t/**\n\t * Match mode:\n\t * - 'some': At least one related record matches (default)\n\t * - 'every': All related records match\n\t * - 'none': No related records match\n\t */\n\treadonly mode: 'some' | 'every' | 'none';\n\t/** Optional alias for complex conditions (SPEC-002) */\n\treadonly alias?: string | undefined;\n\t/**\n\t * Optional display/debug metadata for pre-resolved relation filters.\n\t * These fields are not trusted for compilation. Internal compiler paths that\n\t * prove a virtual source maps to a real model relation use a module-private\n\t * proof payload instead.\n\t */\n\treadonly targetTable?: string | undefined;\n\treadonly sourceColumn?: ColumnListInput;\n\treadonly targetColumn?: ColumnListInput;\n}\n\n// ============================================================================\n// Subquery Intent - Scalar Subquery in WHERE\n// ============================================================================\n\n/**\n * Reference to a parent query column in a subquery.\n * Used to create correlated subqueries.\n *\n * The `outer` field is a discriminator set by `outerRef()` in\n * `@dbsp/core` to distinguish a genuine outer-query reference from an\n * inner `ref()` expression (RefExpressionIntent), which has the same\n * structural shape `{ kind: 'ref', column }`. Converters that need to\n * detect correlated subqueries check `outer === true`; an intent built\n * without `outer` (i.e. a plain `{ kind: 'ref', column }`) is treated\n * as a non-correlated inner expression reference.\n *\n * @example\n * // Outer reference produced by outerRef('id'):\n * { kind: 'ref', column: 'id', outer: true }\n *\n * // Inner column reference (not a correlated outer ref):\n * { kind: 'ref', column: 'id' } // outer is absent / undefined\n */\nexport interface SubqueryRefIntent {\n\treadonly kind: 'ref';\n\t/** Column name or aliased column (e.g., 'id' or 't0.id') */\n\treadonly column: string;\n\t/**\n\t * Discriminator that marks this as a genuine outer-query reference\n\t * (set by `outerRef()`). Absent on plain inner expression refs.\n\t * Optional so that existing raw intents built per the type without\n\t * this field remain valid (non-breaking addition).\n\t */\n\treadonly outer?: true;\n}\n\n/**\n * Subquery intent for scalar subquery comparisons.\n * Produces correlated subqueries in SQL.\n *\n * @example\n * // Find products where price equals max price of category\n * {\n * kind: 'subquery',\n * field: 'price',\n * operator: 'eq',\n * subquery: { from: 'products', select: { kind: 'aggregate', fn: 'max', field: 'price' } }\n * }\n */\nexport interface WhereSubqueryIntent {\n\treadonly kind: 'subquery';\n\t/** Field to compare on the parent query */\n\treadonly field: string;\n\t/** Comparison operator */\n\treadonly operator: ComparisonOperator;\n\t/** Subquery producing scalar value */\n\treadonly subquery: QueryIntent;\n}\n\n// ============================================================================\n// JSON/JSONB WHERE Intents (E13)\n// ============================================================================\n\n/**\n * JSON containment filter: col @> value or col <@ value.\n * @example { kind: 'jsonContains', field: 'data', value: '{\"active\":true}', reversed: false }\n * → WHERE \"data\" @> $1\n */\nexport interface WhereJsonContainsIntent {\n\treadonly kind: 'jsonContains';\n\treadonly field: string;\n\treadonly value: unknown;\n\t/** false = @> (field contains value), true = <@ (field contained by value) */\n\treadonly reversed: boolean;\n}\n\n/**\n * JSON key existence filter: col ? 'key'.\n * @example { kind: 'jsonExists', field: 'data', key: 'email' }\n * → WHERE \"data\" ? $1\n */\nexport interface WhereJsonExistsIntent {\n\treadonly kind: 'jsonExists';\n\treadonly field: string;\n\treadonly key: string | ParamIntent;\n}\n\n/** WHERE clause using a custom expression with comparison */\nexport interface WhereExpressionIntent {\n\treadonly kind: 'expression';\n\treadonly expr: ExpressionIntent;\n\treadonly operator: ComparisonOperator;\n\treadonly value: unknown;\n}\n\n/**\n * Where intent - filter conditions union type\n * Discriminated union using 'kind' field\n */\nexport type WhereIntent =\n\t| WhereComparisonIntent\n\t| WhereLikeIntent\n\t| WhereInIntent\n\t| WhereAnyIntent\n\t| WhereNullIntent\n\t| WhereRangeIntent\n\t| WhereAndIntent\n\t| WhereOrIntent\n\t| WhereNotIntent\n\t| WhereExistsIntent\n\t| WhereNotExistsIntent\n\t| WhereRawExistsIntent\n\t| WhereRawNotExistsIntent\n\t| WhereRelationFilterIntent\n\t| WhereSubqueryIntent\n\t| WhereJsonContainsIntent\n\t| WhereJsonExistsIntent\n\t| WhereExpressionIntent;\n","import { toColumnList } from './column-list.js';\nimport type { TableIR } from './model-ir.js';\n\n/**\n * Dialect-neutral json_agg order intent.\n *\n * `fallback` means the table has no declared primary key, so adapters should\n * realize the all-column deterministic fallback in their own dialect.\n */\nexport interface JsonAggOrderKey {\n\treadonly columns: readonly string[];\n\treadonly fallback: boolean;\n}\n\nexport function resolveJsonAggOrderKey(table: TableIR): JsonAggOrderKey {\n\tconst pkColumns = toColumnList(table.primaryKey);\n\treturn pkColumns.length > 0\n\t\t? { columns: pkColumns, fallback: false }\n\t\t: { columns: table.columns.map((col) => col.name), fallback: true };\n}\n","import type { ModelIR } from './model-ir.js';\n\n/**\n * Canonical shape of a `schema()` factory result as produced by\n * `createOrm({schema: ...})` callers and consumed by tooling\n * (cli, gui sidecar, mcp-server).\n *\n * ARCH-005: Schema type from schema() function.\n * Contains the definition, pre-computed ModelIR, and table names.\n */\nexport interface LoadedSchema {\n\treadonly definition: Record<string, unknown>;\n\treadonly model: ModelIR;\n\treadonly tableNames: readonly string[];\n}\n\nfunction isMap(value: unknown): value is Map<unknown, unknown> {\n\tif (typeof value !== 'object' || value === null) return false;\n\ttry {\n\t\tMap.prototype.has.call(value, undefined);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Runtime type guard for a `schema()` result. Checks the shapes, not just the\n * key names: the model's `tables` and `relations` must be real Maps and its\n * methods real functions, `definition` an object, and `tableNames` an array of\n * strings. Callers load these from disk and then call `.get()` / `.entries()`\n * on the model, so an object that merely has the right keys must not pass.\n *\n * It does not validate the schema's contents — only that this is a `schema()`\n * result rather than an arbitrary object.\n */\nexport function isValidSchema(schema: unknown): schema is LoadedSchema {\n\tif (\n\t\ttypeof schema !== 'object' ||\n\t\tschema === null ||\n\t\t!('model' in schema) ||\n\t\t!('definition' in schema) ||\n\t\t!('tableNames' in schema)\n\t) {\n\t\treturn false;\n\t}\n\tconst s = schema as LoadedSchema;\n\tif (typeof s.model !== 'object' || s.model === null) return false;\n\tif (!('tables' in s.model) || !('relations' in s.model)) return false;\n\tif (!isMap(s.model.tables)) return false;\n\tif (!isMap(s.model.relations)) return false;\n\tif (typeof s.definition !== 'object' || s.definition === null) return false;\n\tif (!Array.isArray(s.tableNames)) return false;\n\tif (s.tableNames.some((name) => typeof name !== 'string')) return false;\n\t// Validate required ModelIR methods are present\n\tif (typeof s.model.getTable !== 'function') return false;\n\tif (typeof s.model.getRelation !== 'function') return false;\n\tif (typeof s.model.getRelationsFrom !== 'function') return false;\n\tif (typeof s.model.getRelationsTo !== 'function') return false;\n\tif (typeof s.model.isAmbiguous !== 'function') return false;\n\treturn true;\n}\n","import type { ColumnJsReadType } from './model-ir.js';\n\nexport type OutputValueShape =\n\t| { readonly kind: 'scalar'; readonly cardinality: 'one' }\n\t| {\n\t\t\treadonly kind: 'array';\n\t\t\treadonly cardinality: 'many';\n\t\t\treadonly aggregate?: 'json_agg' | 'array_agg';\n\t }\n\t| {\n\t\t\treadonly kind: 'object';\n\t\t\treadonly cardinality: 'one';\n\t\t\treadonly aggregate?: 'json_agg';\n\t }\n\t| { readonly kind: 'aggregate-scalar'; readonly aggregate: string }\n\t| { readonly kind: 'unknown'; readonly reason: string };\n\nexport type OutputSource =\n\t| {\n\t\t\treadonly kind: 'modelColumn';\n\t\t\treadonly table: string;\n\t\t\treadonly column: string;\n\t\t\treadonly js?: ColumnJsReadType;\n\t }\n\t| { readonly kind: 'expression'; readonly reason: string }\n\t| { readonly kind: 'ambiguous'; readonly reason: string }\n\t| { readonly kind: 'unresolved'; readonly reason: string };\n\nexport type OutputDescriptor = {\n\treadonly outputKey: string;\n\treadonly source: OutputSource;\n\treadonly shape: OutputValueShape;\n};\n\nexport type OutputReadHandling =\n\t| {\n\t\t\treadonly kind: 'scalarConvert';\n\t\t\treadonly table: string;\n\t\t\treadonly column: string;\n\t\t\treadonly js: ColumnJsReadType;\n\t }\n\t| {\n\t\t\treadonly kind: 'nestedTransform';\n\t\t\treadonly table: string;\n\t\t\treadonly column: string;\n\t\t\treadonly js: ColumnJsReadType;\n\t }\n\t| { readonly kind: 'none' };\n\nexport type NestedOutputReadHandling = Extract<\n\tOutputReadHandling,\n\t{ readonly kind: 'nestedTransform' }\n>;\n\nexport function resolveOutputReadHandling(\n\tdescriptor: OutputDescriptor,\n): OutputReadHandling {\n\tconst { source } = descriptor;\n\tif (source.kind !== 'modelColumn' || source.js === undefined) {\n\t\treturn { kind: 'none' };\n\t}\n\n\tswitch (descriptor.shape.kind) {\n\t\tcase 'scalar':\n\t\t\treturn {\n\t\t\t\tkind: 'scalarConvert',\n\t\t\t\ttable: source.table,\n\t\t\t\tcolumn: source.column,\n\t\t\t\tjs: source.js,\n\t\t\t};\n\t\tcase 'array':\n\t\tcase 'object':\n\t\t\treturn {\n\t\t\t\tkind: 'nestedTransform',\n\t\t\t\ttable: source.table,\n\t\t\t\tcolumn: source.column,\n\t\t\t\tjs: source.js,\n\t\t\t};\n\t\tcase 'aggregate-scalar':\n\t\tcase 'unknown':\n\t\t\treturn { kind: 'none' };\n\t}\n}\n","import type { ColumnListInput } from './column-list.js';\nimport { toColumnList } from './column-list.js';\nimport type { ForeignKeyIR, RelationIR } from './model-ir.js';\n\nconst DEFAULT_REFERENCED_COLUMN = 'id';\n\nexport type RelationKeyDirection = 'belongsTo' | 'inverse';\n\nexport type RelationKeyForeignKey = Pick<ForeignKeyIR, 'references'> & {\n\treadonly columns: ColumnListInput;\n};\n\nexport interface RelationKeyBuilderOptions {\n\treadonly defaultReferencedColumn?: string;\n\treadonly foreignKeyShape?: ColumnListInput;\n\treadonly referencedKeyShape?: ColumnListInput;\n}\n\nexport type RelationKeyFields = Pick<RelationIR, 'foreignKey'> &\n\tPartial<Pick<RelationIR, 'sourceKey' | 'targetKey'>>;\n\nfunction columnListValue(\n\tcolumns: readonly string[],\n\tshape?: ColumnListInput,\n): string | readonly string[] {\n\tif (shape !== undefined && typeof shape !== 'string') return columns;\n\t// biome-ignore lint/style/noNonNullAssertion: columns.length === 1 guaranteed by the ternary condition on this line\n\treturn columns.length === 1 ? columns[0]! : columns;\n}\n\n/**\n * Build RelationIR key fields from a foreign key while preserving both sides.\n *\n * The local FK columns and referenced columns are normalized with toColumnList()\n * so composite keys cannot silently degrade to their first column.\n */\nexport function buildRelationKeyFields(\n\tfk: RelationKeyForeignKey,\n\tdirection: RelationKeyDirection,\n\toptions: RelationKeyBuilderOptions = {},\n): RelationKeyFields {\n\tconst foreignKeyColumns = toColumnList(fk.columns);\n\tconst referencedColumns = toColumnList(fk.references.columns);\n\n\tif (foreignKeyColumns.length !== referencedColumns.length) {\n\t\tthrow new Error(\n\t\t\t`Foreign key column count (${foreignKeyColumns.length}) must match referenced column count (${referencedColumns.length})`,\n\t\t);\n\t}\n\n\tconst foreignKey = columnListValue(\n\t\tforeignKeyColumns,\n\t\toptions.foreignKeyShape,\n\t);\n\tconst defaultReferencedColumn =\n\t\toptions.defaultReferencedColumn ?? DEFAULT_REFERENCED_COLUMN;\n\tconst isImplicitDefaultReference =\n\t\toptions.referencedKeyShape === undefined &&\n\t\treferencedColumns.length === 1 &&\n\t\treferencedColumns[0] === defaultReferencedColumn;\n\n\tif (!isImplicitDefaultReference) {\n\t\tconst referencedKey = columnListValue(\n\t\t\treferencedColumns,\n\t\t\toptions.referencedKeyShape,\n\t\t);\n\t\tif (direction === 'belongsTo') {\n\t\t\treturn { foreignKey, targetKey: referencedKey };\n\t\t}\n\t\treturn { foreignKey, sourceKey: referencedKey };\n\t}\n\n\treturn { foreignKey };\n}\n","/**\n * Durable, reviewed conditions for executing a serialized transition plan.\n *\n * This is deliberately a small document format rather than a second copy of\n * ObservationContext. Its requirements are canonicalized before persistence\n * and are covered by the plan digest.\n */\nexport const EXECUTION_CONTRACT_VERSION = 1 as const;\n\nexport type ExecutionRequirementMode =\n\t| 'must-match'\n\t| 'set-and-verify'\n\t| 'must-satisfy'\n\t| 'provenance';\n\nexport interface PostgreSqlNamespaceIdentity {\n\treadonly name: string;\n\treadonly oid: string;\n}\n\nexport interface PostgreSqlPhysicalTargetRequirement {\n\treadonly kind: 'postgresql.physical-target';\n\treadonly mode: 'must-match';\n\treadonly systemIdentifier: string;\n\treadonly databaseOid: string;\n\t/** Canonical lexical set, never a positional list. */\n\treadonly namespaces: readonly PostgreSqlNamespaceIdentity[];\n}\n\nexport interface PostgreSqlEngineRequirement {\n\treadonly kind: 'postgresql.engine-version';\n\treadonly mode: 'must-satisfy';\n\treadonly stepId: string;\n\treadonly minServerVersionNum?: number;\n\treadonly maxServerVersionNum?: number;\n}\n\n/** Authority is a capability over an object, never a role-name comparison. */\nexport interface PostgreSqlAuthorityRequirement {\n\treadonly kind: 'postgresql.authority';\n\treadonly mode: 'must-satisfy';\n\treadonly action: 'schema-usage' | 'table-alter' | 'type-alter';\n\treadonly schema: string;\n\treadonly object?: string;\n}\n\nexport interface PostgreSqlSessionSettingRequirement {\n\treadonly kind: 'postgresql.session-setting';\n\treadonly mode: 'set-and-verify' | 'provenance';\n\treadonly setting:\n\t\t| 'standard_conforming_strings'\n\t\t| 'search_path'\n\t\t| 'client_encoding'\n\t\t| 'TimeZone';\n\treadonly value: string;\n}\n\nexport type ExecutionRequirement =\n\t| PostgreSqlPhysicalTargetRequirement\n\t| PostgreSqlEngineRequirement\n\t| PostgreSqlAuthorityRequirement\n\t| PostgreSqlSessionSettingRequirement;\n\nexport interface ExecutionContract {\n\treadonly version: typeof EXECUTION_CONTRACT_VERSION;\n\t/** A canonically ordered set. Unknown kinds and modes are invalid. */\n\treadonly requirements: readonly ExecutionRequirement[];\n}\n"],"mappings":";AAQA,IAAM,kBAAkB,OAAO,OAAO,gBAAgB;AACtD,IAAM,kBAAkB,OAAO,OAAO,gBAAgB;AACtD,IAAM,oBAAoB;AAE1B,SAAS,YAAY,OAAwB;AAC5C,MAAI,OAAO,UAAU,SAAU,QAAO,IAAI,KAAK;AAC/C,MAAI,OAAO,UAAU,SAAU,QAAO,GAAG,MAAM,SAAS,CAAC;AACzD,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW;AAC5D,WAAO,OAAO,KAAK;AAAA,EACpB;AACA,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI;AACH,WAAO,KAAK,UAAU,KAAK,KAAK,OAAO,KAAK;AAAA,EAC7C,QAAQ;AACP,WAAO,OAAO,KAAK;AAAA,EACpB;AACD;AAEA,SAAS,gBACR,OACA,QACA,KACA,QACa;AACb,SAAO,IAAI;AAAA,IACV,4CAA4C,IAAI,KAAK,IAAI,IAAI,MAAM,iBAAiB,IAAI,SAAS,WAAW,YAAY,KAAK,CAAC,OAAO,MAAM,KAAK,MAAM;AAAA,EACvJ;AACD;AAEA,SAAS,eACR,OACA,QACA,KACS;AACT,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,OAAO,UAAU,UAAU;AAC9B,UAAM,UAAU,MAAM,KAAK;AAC3B,QAAI,CAAC,kBAAkB,KAAK,OAAO,GAAG;AACrC,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AACA,WAAO,OAAO,OAAO;AAAA,EACtB;AACA,MAAI,OAAO,UAAU,UAAU;AAC9B,QAAI,CAAC,OAAO,cAAc,KAAK,GAAG;AACjC,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AACA,WAAO,OAAO,KAAK;AAAA,EAC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UAAU,UAAa,OAAO,UAAU,SAAU,QAAO;AAE7D,SAAO,QAAQ,WAAW,IAAI,QAAQ,CAAC,IAAK;AAC7C;AAQO,SAAS,uBACf,IACA,WACA,UAAqC,CAAC,GAClB;AACpB,QAAM,oBAAoB,aAAa,GAAG,OAAO;AACjD,QAAM,oBAAoB,aAAa,GAAG,WAAW,OAAO;AAE5D,MAAI,kBAAkB,WAAW,kBAAkB,QAAQ;AAC1D,UAAM,IAAI;AAAA,MACT,6BAA6B,kBAAkB,MAAM,yCAAyC,kBAAkB,MAAM;AAAA,IACvH;AAAA,EACD;AAEA,QAAM,aAAa;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,EACT;AACA,QAAM,0BACL,QAAQ,2BAA2B;AACpC,QAAM,6BACL,QAAQ,uBAAuB,UAC/B,kBAAkB,WAAW,KAC7B,kBAAkB,CAAC,MAAM;AAE1B,MAAI,CAAC,4BAA4B;AAChC,UAAM,gBAAgB;AAAA,MACrB;AAAA,MACA,QAAQ;AAAA,IACT;AACA,QAAI,cAAc,aAAa;AAC9B,aAAO,EAAE,YAAY,WAAW,cAAc;AAAA,IAC/C;AACA,WAAO,EAAE,YAAY,WAAW,cAAc;AAAA,EAC/C;AAEA,SAAO,EAAE,WAAW;AACrB;;;AClEO,IAAM,6BAA6B;","names":[]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { bU as RecursiveTraversal, e as AdjacencyTraversal, cZ as WindowFunction, l as AggregateWindowFunction, ba as OffsetWindowFunction, aj as ExpressionIntent, F as CoalesceExpressionIntent, G as ColumnAliasIntent, $ as CustomTraversal, bA as QueryIntent, bO as RecursiveIntent, aV as MutationIntent, a6 as DeleteIntent, af as EdgeTableTraversal, aA as InsertIntent, bE as RankingWindowFunction, bH as RawExpressionIntent, bW as RelationColumnIntent, c7 as SelectIntent, c4 as SelectAggregateIntent, c5 as SelectAllIntent, c6 as SelectFieldsIntent, c8 as SelectWithExpressionsIntent, cl as SubqueryRefIntent, cy as UpdateIntent, cC as UpsertIntent, cM as WhereIntent, cE as WhereAndIntent, cF as WhereAnyIntent, cG as WhereComparisonIntent, cH as WhereExistsIntent, cJ as WhereInIntent, cP as WhereLikeIntent, cT as WhereOrIntent, cR as WhereNotIntent, cQ as WhereNotExistsIntent, cS as WhereNullIntent, cU as WhereRangeIntent, cX as WhereRelationFilterIntent, cY as WhereSubqueryIntent, c_ as WindowIntent, J as ColumnJsReadType, co as TableIR, aU as ModelIR, K as ColumnListInput, bX as RelationIR, ap as ForeignKeyIR, ca as SemanticArtifactRef, cu as TrustRoot, bd as OperationKindRef } from './adapter-CBhAwQzd.js';
2
- export { A as Adapter, b as AdapterCapabilities, c as AdapterLogger, d as AdapterStreamOptions, f as AggOrderByArg, g as AggregateCountIntent, h as AggregateExpressionIntent, i as AggregateFieldIntent, j as AggregateFunction, k as AggregateIntent, m as AggregateWindowIntent, n as AliasIncludedColumnsMode, o as AlterColumnOptions, p as AmbiguityCheckResult, q as ArithmeticExpressionIntent, r as ArrayExpressionIntent, s as ArrayOperator, t as AuthorAttestedNativeDefault, u as AuthorAttester, B as BaseAdapter, v as BatchUpdateIntent, w as BatchValuesJoinPayload, x as CTEDefinition, y as Cardinality, z as CaseExpressionIntent, D as CastExpressionIntent, E as CheckConstraintIR, H as ColumnExpressionIntent, I as ColumnIR, L as ColumnType, M as CommonColumnType, O as ComparisonExpressionIntent, Q as ComparisonOperator, R as CompileOnlyAdapter, S as CompileOptions, T as CompileOptionsBase, U as CompileResultWithIncludes, a as CompiledColumnMetadata, V as CompiledNqlQuery, C as CompiledQuery, W as CompilingAdapter, X as CreateIndexOptions, Y as CteQueryIntent, Z as CustomFnExpressionIntent, _ as CustomOpExpressionIntent, a0 as DDLFeature, a1 as DDLFeatureElementMap, a2 as DDLFeatureVersionRange, a3 as DDLGeneratingAdapter, a4 as DbCasing, a5 as DecisionType, a7 as DialectCapabilities, a8 as DialectName, a9 as DiffSummary, aa as DropIndexOptions, ab as DuckDBColumnType, ac as Dump, ad as DumpMeta, ae as DumpSequenceStep, ag as EmitJoinClause, ah as EnumIR, ai as ExecutingAdapter, ak as FeatureBehaviorConfig, al as FeatureTranslator, am as FeatureWarning, an as FieldRef, ao as FilterStrategy, aq as FunctionExpressionIntent, ar as HierarchyIR, as as IncludeIntent, at as IncludeRecursiveOptions, au as IncludeStrategy, av as IndexColumnDef, aw as IndexIR, ax as IndexInfo, ay as IndexMethod, az as InsertFromIntent, aB as IntrospectingAdapter, aC as IntrospectionOptions, aD as IntrospectionResult, aE as IsTypeSupported, aF as JoinDefault, aG as JoinIntent, aH as JsonAggOrderByEntry, aI as JsonContainsIntent, aJ as JsonExistsIntent, aK as JsonExtractIntent, aL as JsonPathExtractIntent, aM as LiteralExpressionIntent, aN as LockIntent, aO as LockStrength, aP as LockWaitPolicy, aQ as LogicalIdentity, aR as LogicalIdentityCarrier, aS as LogicalOperator, aT as MSSQLColumnType, aW as MutationReturningItem, aX as MySQLColumnType, aY as NamedArgExpressionIntent, aZ as NestedOutputReadHandling, a_ as NqlBindingColumnLineage, a$ as NqlBindingColumnTypeInfo, b0 as NqlBindingColumnUntypeableReason, b1 as NqlBindingOutputSchema, b2 as NqlBindingRelationFilterMetadata, N as NqlBindingRelationType, b3 as NqlBindingVirtualRelation, b4 as NqlBindingVirtualRelationHop, b5 as NqlBindingVirtualRelationRecursive, b6 as NqlProgramSequenceStep, b7 as NqlRuntimeBinding, b8 as NullOperator, b9 as NullsPosition, bb as OffsetWindowIntent, bc as OnDeleteAction, be as Optionality, bf as OrderByExpressionIntent, bg as OrderByFieldIntent, bh as OrderByIntent, bi as OutputDescriptor, bj as OutputReadHandling, bk as OutputSource, bl as OutputValueShape, bm as ParamExpressionIntent, bn as ParamIntent, bo as PartitionIR, bp as PinnedConnectionOptions, bq as PlanDecision, br as PlanOptions, P as PlanReport, bs as PlanWarning, bt as PlanWarningCode, bu as PolicyIR, bv as PostgresColumnType, bw as PostgresOnlyColumnType, bx as PseudoColumnExpressionIntent, by as PseudoColumnMetadata, bz as PseudoColumnTraversal, bB as RangeOperand, bC as RangeOperator, bD as RangeValue, bF as RankingWindowIntent, bG as RawCteIntent, bI as RawSqlAdapter, bJ as RecursiveAdvancedOptions, bK as RecursiveDedupe, bL as RecursiveDirection, bM as RecursiveEmitOptions, bN as RecursiveExistsOptions, bP as RecursiveMetadata, bQ as RecursiveNodeIdExpr, bR as RecursivePlanOptions, bS as RecursivePlanReport, bT as RecursiveTrackOptions, bV as RefExpressionIntent, bY as RelationKind, bZ as RelationOperator, b_ as RelationType, b$ as RequiredEnumLabelIR, c0 as ResolvedIncludeStrategy, c1 as SQLiteColumnType, c2 as SchemaChange, c3 as SchemaDiff, c9 as SemanticArtifactId, cb as SequenceIR, cc as SetOperationIntent, cd as SetOperationType, ce as SimpleCteIntent, cf as SortDirection, cg as StarExpressionIntent, ch as StreamingAdapter, ci as StringOperator, cj as SubqueryExpressionIntent, ck as SubqueryIncludeInfo, cm as SupportedColumnTypes, cn as TableDDLGeneratorAdapter, cp as TransactionBeginOptions, cq as TransactionOptions, cr as TransactionalAdapter, cs as TranslationContext, ct as TruncateOptions, cv as UnaryExpressionIntent, cw as UnnestCteIntent, cx as UnsupportedFeatureBehavior, cz as UpsertConflictAction, cA as UpsertConflictTarget, cB as UpsertFromIntent, cD as VacuumOptions, cI as WhereExpressionIntent, cK as WhereInSubqueryIntent, cL as WhereInValueIntent, cN as WhereJsonContainsIntent, cO as WhereJsonExistsIntent, cV as WhereRawExistsIntent, cW as WhereRawNotExistsIntent, c$ as WindowOrderBy, d0 as getNodeIdAlias, d1 as isFieldRef, d2 as isParamIntent, d3 as resolveOutputReadHandling, d4 as toColumnList } from './adapter-CBhAwQzd.js';
1
+ import { bV as RecursiveTraversal, e as AdjacencyTraversal, c_ as WindowFunction, l as AggregateWindowFunction, bb as OffsetWindowFunction, ak as ExpressionIntent, F as CoalesceExpressionIntent, G as ColumnAliasIntent, a0 as CustomTraversal, bB as QueryIntent, bP as RecursiveIntent, aW as MutationIntent, a7 as DeleteIntent, ag as EdgeTableTraversal, aB as InsertIntent, bF as RankingWindowFunction, bI as RawExpressionIntent, bX as RelationColumnIntent, c8 as SelectIntent, c5 as SelectAggregateIntent, c6 as SelectAllIntent, c7 as SelectFieldsIntent, c9 as SelectWithExpressionsIntent, cm as SubqueryRefIntent, cz as UpdateIntent, cD as UpsertIntent, cN as WhereIntent, cF as WhereAndIntent, cG as WhereAnyIntent, cH as WhereComparisonIntent, cI as WhereExistsIntent, cK as WhereInIntent, cQ as WhereLikeIntent, cU as WhereOrIntent, cS as WhereNotIntent, cR as WhereNotExistsIntent, cT as WhereNullIntent, cV as WhereRangeIntent, cY as WhereRelationFilterIntent, cZ as WhereSubqueryIntent, c$ as WindowIntent, J as ColumnJsReadType, cp as TableIR, aV as ModelIR, K as ColumnListInput, bY as RelationIR, aq as ForeignKeyIR, cb as SemanticArtifactRef, cv as TrustRoot, be as OperationKindRef } from './adapter-CjwnHeg4.js';
2
+ export { A as Adapter, b as AdapterCapabilities, c as AdapterLogger, d as AdapterStreamOptions, f as AggOrderByArg, g as AggregateCountIntent, h as AggregateExpressionIntent, i as AggregateFieldIntent, j as AggregateFunction, k as AggregateIntent, m as AggregateWindowIntent, n as AliasIncludedColumnsMode, o as AlterColumnOptions, p as AmbiguityCheckResult, q as ArithmeticExpressionIntent, r as ArrayExpressionIntent, s as ArrayOperator, t as AuthorAttestedNativeDefault, u as AuthorAttester, B as BaseAdapter, v as BatchUpdateIntent, w as BatchValuesJoinPayload, x as CTEDefinition, y as Cardinality, z as CaseExpressionIntent, D as CastExpressionIntent, E as CheckConstraintIR, H as ColumnExpressionIntent, I as ColumnIR, L as ColumnType, M as CommonColumnType, O as ComparisonExpressionIntent, Q as ComparisonOperator, R as CompileOnlyAdapter, S as CompileOptions, T as CompileOptionsBase, U as CompileResultWithIncludes, a as CompiledColumnMetadata, V as CompiledNqlQuery, C as CompiledQuery, W as CompilingAdapter, X as ConnectionAvailability, Y as CreateIndexOptions, Z as CteQueryIntent, _ as CustomFnExpressionIntent, $ as CustomOpExpressionIntent, a1 as DDLFeature, a2 as DDLFeatureElementMap, a3 as DDLFeatureVersionRange, a4 as DDLGeneratingAdapter, a5 as DbCasing, a6 as DecisionType, a8 as DialectCapabilities, a9 as DialectName, aa as DiffSummary, ab as DropIndexOptions, ac as DuckDBColumnType, ad as Dump, ae as DumpMeta, af as DumpSequenceStep, ah as EmitJoinClause, ai as EnumIR, aj as ExecutingAdapter, al as FeatureBehaviorConfig, am as FeatureTranslator, an as FeatureWarning, ao as FieldRef, ap as FilterStrategy, ar as FunctionExpressionIntent, as as HierarchyIR, at as IncludeIntent, au as IncludeRecursiveOptions, av as IncludeStrategy, aw as IndexColumnDef, ax as IndexIR, ay as IndexInfo, az as IndexMethod, aA as InsertFromIntent, aC as IntrospectingAdapter, aD as IntrospectionOptions, aE as IntrospectionResult, aF as IsTypeSupported, aG as JoinDefault, aH as JoinIntent, aI as JsonAggOrderByEntry, aJ as JsonContainsIntent, aK as JsonExistsIntent, aL as JsonExtractIntent, aM as JsonPathExtractIntent, aN as LiteralExpressionIntent, aO as LockIntent, aP as LockStrength, aQ as LockWaitPolicy, aR as LogicalIdentity, aS as LogicalIdentityCarrier, aT as LogicalOperator, aU as MSSQLColumnType, aX as MutationReturningItem, aY as MySQLColumnType, aZ as NamedArgExpressionIntent, a_ as NestedOutputReadHandling, a$ as NqlBindingColumnLineage, b0 as NqlBindingColumnTypeInfo, b1 as NqlBindingColumnUntypeableReason, b2 as NqlBindingOutputSchema, b3 as NqlBindingRelationFilterMetadata, N as NqlBindingRelationType, b4 as NqlBindingVirtualRelation, b5 as NqlBindingVirtualRelationHop, b6 as NqlBindingVirtualRelationRecursive, b7 as NqlProgramSequenceStep, b8 as NqlRuntimeBinding, b9 as NullOperator, ba as NullsPosition, bc as OffsetWindowIntent, bd as OnDeleteAction, bf as Optionality, bg as OrderByExpressionIntent, bh as OrderByFieldIntent, bi as OrderByIntent, bj as OutputDescriptor, bk as OutputReadHandling, bl as OutputSource, bm as OutputValueShape, bn as ParamExpressionIntent, bo as ParamIntent, bp as PartitionIR, bq as PinnedConnectionOptions, br as PlanDecision, bs as PlanOptions, P as PlanReport, bt as PlanWarning, bu as PlanWarningCode, bv as PolicyIR, bw as PostgresColumnType, bx as PostgresOnlyColumnType, by as PseudoColumnExpressionIntent, bz as PseudoColumnMetadata, bA as PseudoColumnTraversal, bC as RangeOperand, bD as RangeOperator, bE as RangeValue, bG as RankingWindowIntent, bH as RawCteIntent, bJ as RawSqlAdapter, bK as RecursiveAdvancedOptions, bL as RecursiveDedupe, bM as RecursiveDirection, bN as RecursiveEmitOptions, bO as RecursiveExistsOptions, bQ as RecursiveMetadata, bR as RecursiveNodeIdExpr, bS as RecursivePlanOptions, bT as RecursivePlanReport, bU as RecursiveTrackOptions, bW as RefExpressionIntent, bZ as RelationKind, b_ as RelationOperator, b$ as RelationType, c0 as RequiredEnumLabelIR, c1 as ResolvedIncludeStrategy, c2 as SQLiteColumnType, c3 as SchemaChange, c4 as SchemaDiff, ca as SemanticArtifactId, cc as SequenceIR, cd as SetOperationIntent, ce as SetOperationType, cf as SimpleCteIntent, cg as SortDirection, ch as StarExpressionIntent, ci as StreamingAdapter, cj as StringOperator, ck as SubqueryExpressionIntent, cl as SubqueryIncludeInfo, cn as SupportedColumnTypes, co as TableDDLGeneratorAdapter, cq as TransactionBeginOptions, cr as TransactionOptions, cs as TransactionalAdapter, ct as TranslationContext, cu as TruncateOptions, cw as UnaryExpressionIntent, cx as UnnestCteIntent, cy as UnsupportedFeatureBehavior, cA as UpsertConflictAction, cB as UpsertConflictTarget, cC as UpsertFromIntent, cE as VacuumOptions, cJ as WhereExpressionIntent, cL as WhereInSubqueryIntent, cM as WhereInValueIntent, cO as WhereJsonContainsIntent, cP as WhereJsonExistsIntent, cW as WhereRawExistsIntent, cX as WhereRawNotExistsIntent, d0 as WindowOrderBy, d1 as getNodeIdAlias, d2 as isFieldRef, d3 as isParamIntent, d4 as resolveOutputReadHandling, d5 as toColumnList } from './adapter-CjwnHeg4.js';
3
3
 
4
4
  /**
5
5
  * NQL-origin SELECT function allowlist.
@@ -271,6 +271,14 @@ interface ResourceSelector {
271
271
  readonly within?: ResourceAddress;
272
272
  }
273
273
 
274
+ interface PostgreSqlObservationTargetIdentity {
275
+ readonly systemIdentifier: string;
276
+ readonly databaseOid: string;
277
+ readonly namespaces: readonly {
278
+ readonly name: string;
279
+ readonly oid: string;
280
+ }[];
281
+ }
274
282
  type EvidenceId = string & {
275
283
  readonly __brand: 'EvidenceId';
276
284
  };
@@ -302,6 +310,8 @@ interface ObservationContext {
302
310
  readonly collationProvider?: string;
303
311
  readonly collationVersion?: string;
304
312
  readonly transaction?: string;
313
+ /** Read from PostgreSQL catalogs; no name-only fallback is permitted. */
314
+ readonly postgresqlTargetIdentity?: PostgreSqlObservationTargetIdentity;
305
315
  }
306
316
  type ObservationPrivilegeMergeResult = {
307
317
  readonly merged: readonly string[];
@@ -561,7 +571,7 @@ interface TransitionFragment {
561
571
  readonly selectionRationale: RuleSelectionRationale;
562
572
  }
563
573
 
564
- type OutcomeReasonCode = 'proven-applicable' | 'proven-inapplicable' | 'context-mismatch' | 'insufficient-evidence' | 'unsupported-transition' | 'ambiguous-rule' | 'uncomposable' | 'ambiguous-intent' | 'guard-failed' | 'guard-timeout' | 'operation-failed-not-applied' | 'partially-applied' | 'unknown-step-result' | 'resume-required';
574
+ type OutcomeReasonCode = 'proven-applicable' | 'proven-inapplicable' | 'context-mismatch' | 'persistence-failed' | 'insufficient-evidence' | 'unsupported-transition' | 'ambiguous-rule' | 'uncomposable' | 'ambiguous-intent' | 'guard-failed' | 'guard-timeout' | 'operation-failed-not-applied' | 'partially-applied' | 'unknown-step-result' | 'resume-required';
565
575
  interface OutcomeReasonBase {
566
576
  readonly detail?: string;
567
577
  readonly scope: readonly ResourceAddress[];
@@ -576,6 +586,10 @@ type OutcomeReason = (OutcomeReasonBase & {
576
586
  readonly code: 'context-mismatch';
577
587
  readonly artifact: SemanticArtifactRef;
578
588
  readonly fact: ContextFact;
589
+ }) | (OutcomeReasonBase & {
590
+ readonly code: 'persistence-failed';
591
+ readonly artifact: SemanticArtifactRef;
592
+ readonly fact: ContextFact;
579
593
  }) | (OutcomeReasonBase & {
580
594
  readonly code: 'insufficient-evidence';
581
595
  readonly obligation: ProofObligation;
@@ -641,6 +655,55 @@ type InapplicableAssessment = PlanAssessment & {
641
655
  readonly decision: 'inapplicable';
642
656
  };
643
657
 
658
+ /**
659
+ * Durable, reviewed conditions for executing a serialized transition plan.
660
+ *
661
+ * This is deliberately a small document format rather than a second copy of
662
+ * ObservationContext. Its requirements are canonicalized before persistence
663
+ * and are covered by the plan digest.
664
+ */
665
+ declare const EXECUTION_CONTRACT_VERSION: 1;
666
+ type ExecutionRequirementMode = 'must-match' | 'set-and-verify' | 'must-satisfy' | 'provenance';
667
+ interface PostgreSqlNamespaceIdentity {
668
+ readonly name: string;
669
+ readonly oid: string;
670
+ }
671
+ interface PostgreSqlPhysicalTargetRequirement {
672
+ readonly kind: 'postgresql.physical-target';
673
+ readonly mode: 'must-match';
674
+ readonly systemIdentifier: string;
675
+ readonly databaseOid: string;
676
+ /** Canonical lexical set, never a positional list. */
677
+ readonly namespaces: readonly PostgreSqlNamespaceIdentity[];
678
+ }
679
+ interface PostgreSqlEngineRequirement {
680
+ readonly kind: 'postgresql.engine-version';
681
+ readonly mode: 'must-satisfy';
682
+ readonly stepId: string;
683
+ readonly minServerVersionNum?: number;
684
+ readonly maxServerVersionNum?: number;
685
+ }
686
+ /** Authority is a capability over an object, never a role-name comparison. */
687
+ interface PostgreSqlAuthorityRequirement {
688
+ readonly kind: 'postgresql.authority';
689
+ readonly mode: 'must-satisfy';
690
+ readonly action: 'schema-usage' | 'table-alter' | 'type-alter';
691
+ readonly schema: string;
692
+ readonly object?: string;
693
+ }
694
+ interface PostgreSqlSessionSettingRequirement {
695
+ readonly kind: 'postgresql.session-setting';
696
+ readonly mode: 'set-and-verify' | 'provenance';
697
+ readonly setting: 'standard_conforming_strings' | 'search_path' | 'client_encoding' | 'TimeZone';
698
+ readonly value: string;
699
+ }
700
+ type ExecutionRequirement = PostgreSqlPhysicalTargetRequirement | PostgreSqlEngineRequirement | PostgreSqlAuthorityRequirement | PostgreSqlSessionSettingRequirement;
701
+ interface ExecutionContract {
702
+ readonly version: typeof EXECUTION_CONTRACT_VERSION;
703
+ /** A canonically ordered set. Unknown kinds and modes are invalid. */
704
+ readonly requirements: readonly ExecutionRequirement[];
705
+ }
706
+
644
707
  /**
645
708
  * ProvenPlanShape is the serializable audit/dump shape of a plan the prover can
646
709
  * derive. It is not an apply credential: runtime safety comes from @dbsp/core
@@ -759,6 +822,8 @@ interface GuardedPlan {
759
822
  readonly segments: readonly GuardedPlanSegment[];
760
823
  readonly steps: readonly GuardedPlanStep[];
761
824
  readonly postconditions: readonly ExecutableAssertion[];
825
+ /** Present on plans emitted by current `dbsp plan` and covered by its digest. */
826
+ readonly executionContract?: ExecutionContract;
762
827
  }
763
828
  type ProvenGuardProtocol = Exclude<GuardProtocol, {
764
829
  readonly kind: 'impossible';
@@ -1058,4 +1123,4 @@ interface ApplyPolicy {
1058
1123
  readonly accepts: readonly AssumptionAcceptance[];
1059
1124
  }
1060
1125
 
1061
- export { AdjacencyTraversal, type AdvisoryObservation, type AdvisoryObservationId, AggregateWindowFunction, type ApplicableAssessment, type ApplicableEvaluation, type ApplyGuard, type ApplyPolicy, type ApplyResult, type Assumption, type AssumptionAcceptance, type AssumptionId, type BigintJsReadConversionContext, type BoundBinding, type CapabilityAvailabilityPredicate, type CapabilityDescriptor, type ClaimConclusion, type ClaimDerivation, type ClaimId, type ClaimSelector, CoalesceExpressionIntent, type CollationRef, ColumnAliasIntent, ColumnJsReadType, ColumnListInput, type Comparator, type CompareOutcome, type CompositionFactSatisfactionOwner, type ContextFact, type ContextMutation, CustomTraversal, DeleteIntent, type DurableIntentRecord, EdgeTableTraversal, type EquivalenceCapability, type EquivalenceContext, type EquivalenceResult, type EvidenceClaimConclusion, type EvidenceClaimResult, type EvidenceId, type EvidenceObservation, type EvidenceObservationFilters, type EvidenceView, type ExecutableAssertion, type ExpressionEquivalenceCategory, ExpressionIntent, type ExpressionValue, type ExternalEffectCoverage, type FingerprintManifest, ForeignKeyIR, type GuardPredicate, type GuardProtocol, type GuardProtocolKind, type GuardedPlan, type GuardedPlanSegment, type GuardedPlanStep, type InapplicableAssessment, InsertIntent, type IssuedObservation, type JsonAggOrderKey, type JsonValue, type LoadedSchema, type LockRequirement, ModelIR, MutationIntent, NQL_SELECT_AGGREGATE_FUNCTIONS, NQL_SELECT_FUNCTION_ALLOWLIST, NQL_SELECT_JSON_FUNCTIONS, NQL_SELECT_SCALAR_FUNCTIONS, NQL_SELECT_SCALAR_FUNCTION_ALLOWLIST, NQL_SELECT_VALUE_FUNCTIONS, NQL_SELECT_WINDOW_FUNCTIONS, NQL_SELECT_WINDOW_FUNCTION_ALLOWLIST, NQL_SELECT_WINDOW_ONLY_FUNCTIONS, type ObservationBooleanClaim, type ObservationContext, type ObservationIssuer, type ObservationPrivilegeMergeResult, type ObservationRequest, type ObservationResult, type ObservationStability, type ObservedOutcomeRecord, OffsetWindowFunction, type OperationEffectAssessment, type OperationEffects, type OperationExecutionOutcome, type OperationExecutionSemantics, OperationKindRef, type OperationRecoverySemantics, type OperationSemantics, type OutcomeReason, type OutcomeReasonCode, type PhysicalOperation, type PlanAssessment, type PortableExpression, type ProofClaim, type ProofClaimDraft, type ProofEvidenceAccess, type ProofObligation, type Proposition, type ProvenApplyGuard, type ProvenGuardProtocol, type ProvenPlanShape, type ProvenPlanStep, QueryIntent, RankingWindowFunction, RawExpressionIntent, type RecognitionContext, type RecognitionResult, type RecoveryArtefact, RecursiveIntent, RecursiveTraversal, RelationColumnIntent, RelationIR, type RelationKeyBuilderOptions, type RelationKeyDirection, type RelationKeyFields, type RelationKeyForeignKey, type ResourceAddress, type ResourceSelector, type RuleEvaluation, type RulePrecedenceFact, type RuleRef, type RuleSelectionRationale, type RuleSupport, SelectAggregateIntent, SelectAllIntent, SelectFieldsIntent, SelectIntent, SelectWithExpressionsIntent, SemanticArtifactRef, type SerializedProvenPlan, type StepJournal, type StepOutcome, SubqueryRefIntent, TableIR, type TargetBinding, type TransactionalCompletionRecord, type TransitionCandidate, type TransitionCompositionFact, type TransitionFragment, type TransitionFragmentComposition, type TransitionJournalEvent, type TransitionJournalEventName, type TransitionJournalEventRecord, type TransitionLessor, type TransitionQueryClient, type TransitionQueryResult, type TransitionRule, type TransitionRunJournal, type TransitionRunMetadata, type TransitionSessionClient, TrustRoot, type TypeRef, type UnknownCoverage, type UnknownTransitionRecognition, type UnresolvableExpression, type UnsafeNativeFragment, UpdateIntent, UpsertIntent, type VendorValidatedExpression, WhereAndIntent, WhereAnyIntent, WhereComparisonIntent, WhereExistsIntent, WhereInIntent, WhereIntent, WhereLikeIntent, WhereNotExistsIntent, WhereNotIntent, WhereNullIntent, WhereOrIntent, WhereRangeIntent, WhereRelationFilterIntent, WhereSubqueryIntent, WindowFunction, WindowIntent, buildRelationKeyFields, convertBigintJsReadValue, isAdjacencyTraversal, isAggregateWindowFunction, isCoalesceExpression, isColumnAliasExpression, isCustomTraversal, isDeleteIntent, isEdgeTableTraversal, isInsertIntent, isMutationIntent, isNqlSelectFunctionAllowed, isNqlSelectScalarFunctionAllowed, isNqlSelectWindowFunctionAllowed, isRankingWindowFunction, isRawExpression, isRecursiveIntent, isRelationColumnExpression, isSelectAggregate, isSelectAll, isSelectFields, isSelectWithExpressions, isSubqueryRef, isUpdateIntent, isUpsertIntent, isValidSchema, isWhereAnd, isWhereAny, isWhereComparison, isWhereExists, isWhereIn, isWhereLike, isWhereLogical, isWhereNot, isWhereNotExists, isWhereNull, isWhereOr, isWhereRange, isWhereRelationBased, isWhereRelationFilter, isWhereSubquery, isWindowIntent, resolveJsonAggOrderKey };
1126
+ export { AdjacencyTraversal, type AdvisoryObservation, type AdvisoryObservationId, AggregateWindowFunction, type ApplicableAssessment, type ApplicableEvaluation, type ApplyGuard, type ApplyPolicy, type ApplyResult, type Assumption, type AssumptionAcceptance, type AssumptionId, type BigintJsReadConversionContext, type BoundBinding, type CapabilityAvailabilityPredicate, type CapabilityDescriptor, type ClaimConclusion, type ClaimDerivation, type ClaimId, type ClaimSelector, CoalesceExpressionIntent, type CollationRef, ColumnAliasIntent, ColumnJsReadType, ColumnListInput, type Comparator, type CompareOutcome, type CompositionFactSatisfactionOwner, type ContextFact, type ContextMutation, CustomTraversal, DeleteIntent, type DurableIntentRecord, EXECUTION_CONTRACT_VERSION, EdgeTableTraversal, type EquivalenceCapability, type EquivalenceContext, type EquivalenceResult, type EvidenceClaimConclusion, type EvidenceClaimResult, type EvidenceId, type EvidenceObservation, type EvidenceObservationFilters, type EvidenceView, type ExecutableAssertion, type ExecutionContract, type ExecutionRequirement, type ExecutionRequirementMode, type ExpressionEquivalenceCategory, ExpressionIntent, type ExpressionValue, type ExternalEffectCoverage, type FingerprintManifest, ForeignKeyIR, type GuardPredicate, type GuardProtocol, type GuardProtocolKind, type GuardedPlan, type GuardedPlanSegment, type GuardedPlanStep, type InapplicableAssessment, InsertIntent, type IssuedObservation, type JsonAggOrderKey, type JsonValue, type LoadedSchema, type LockRequirement, ModelIR, MutationIntent, NQL_SELECT_AGGREGATE_FUNCTIONS, NQL_SELECT_FUNCTION_ALLOWLIST, NQL_SELECT_JSON_FUNCTIONS, NQL_SELECT_SCALAR_FUNCTIONS, NQL_SELECT_SCALAR_FUNCTION_ALLOWLIST, NQL_SELECT_VALUE_FUNCTIONS, NQL_SELECT_WINDOW_FUNCTIONS, NQL_SELECT_WINDOW_FUNCTION_ALLOWLIST, NQL_SELECT_WINDOW_ONLY_FUNCTIONS, type ObservationBooleanClaim, type ObservationContext, type ObservationIssuer, type ObservationPrivilegeMergeResult, type ObservationRequest, type ObservationResult, type ObservationStability, type ObservedOutcomeRecord, OffsetWindowFunction, type OperationEffectAssessment, type OperationEffects, type OperationExecutionOutcome, type OperationExecutionSemantics, OperationKindRef, type OperationRecoverySemantics, type OperationSemantics, type OutcomeReason, type OutcomeReasonCode, type PhysicalOperation, type PlanAssessment, type PortableExpression, type PostgreSqlAuthorityRequirement, type PostgreSqlEngineRequirement, type PostgreSqlNamespaceIdentity, type PostgreSqlObservationTargetIdentity, type PostgreSqlPhysicalTargetRequirement, type PostgreSqlSessionSettingRequirement, type ProofClaim, type ProofClaimDraft, type ProofEvidenceAccess, type ProofObligation, type Proposition, type ProvenApplyGuard, type ProvenGuardProtocol, type ProvenPlanShape, type ProvenPlanStep, QueryIntent, RankingWindowFunction, RawExpressionIntent, type RecognitionContext, type RecognitionResult, type RecoveryArtefact, RecursiveIntent, RecursiveTraversal, RelationColumnIntent, RelationIR, type RelationKeyBuilderOptions, type RelationKeyDirection, type RelationKeyFields, type RelationKeyForeignKey, type ResourceAddress, type ResourceSelector, type RuleEvaluation, type RulePrecedenceFact, type RuleRef, type RuleSelectionRationale, type RuleSupport, SelectAggregateIntent, SelectAllIntent, SelectFieldsIntent, SelectIntent, SelectWithExpressionsIntent, SemanticArtifactRef, type SerializedProvenPlan, type StepJournal, type StepOutcome, SubqueryRefIntent, TableIR, type TargetBinding, type TransactionalCompletionRecord, type TransitionCandidate, type TransitionCompositionFact, type TransitionFragment, type TransitionFragmentComposition, type TransitionJournalEvent, type TransitionJournalEventName, type TransitionJournalEventRecord, type TransitionLessor, type TransitionQueryClient, type TransitionQueryResult, type TransitionRule, type TransitionRunJournal, type TransitionRunMetadata, type TransitionSessionClient, TrustRoot, type TypeRef, type UnknownCoverage, type UnknownTransitionRecognition, type UnresolvableExpression, type UnsafeNativeFragment, UpdateIntent, UpsertIntent, type VendorValidatedExpression, WhereAndIntent, WhereAnyIntent, WhereComparisonIntent, WhereExistsIntent, WhereInIntent, WhereIntent, WhereLikeIntent, WhereNotExistsIntent, WhereNotIntent, WhereNullIntent, WhereOrIntent, WhereRangeIntent, WhereRelationFilterIntent, WhereSubqueryIntent, WindowFunction, WindowIntent, buildRelationKeyFields, convertBigintJsReadValue, isAdjacencyTraversal, isAggregateWindowFunction, isCoalesceExpression, isColumnAliasExpression, isCustomTraversal, isDeleteIntent, isEdgeTableTraversal, isInsertIntent, isMutationIntent, isNqlSelectFunctionAllowed, isNqlSelectScalarFunctionAllowed, isNqlSelectWindowFunctionAllowed, isRankingWindowFunction, isRawExpression, isRecursiveIntent, isRelationColumnExpression, isSelectAggregate, isSelectAll, isSelectFields, isSelectWithExpressions, isSubqueryRef, isUpdateIntent, isUpsertIntent, isValidSchema, isWhereAnd, isWhereAny, isWhereComparison, isWhereExists, isWhereIn, isWhereLike, isWhereLogical, isWhereNot, isWhereNotExists, isWhereNull, isWhereOr, isWhereRange, isWhereRelationBased, isWhereRelationFilter, isWhereSubquery, isWindowIntent, resolveJsonAggOrderKey };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ EXECUTION_CONTRACT_VERSION,
2
3
  NQL_SELECT_AGGREGATE_FUNCTIONS,
3
4
  NQL_SELECT_FUNCTION_ALLOWLIST,
4
5
  NQL_SELECT_JSON_FUNCTIONS,
@@ -56,8 +57,9 @@ import {
56
57
  resolveJsonAggOrderKey,
57
58
  resolveOutputReadHandling,
58
59
  toColumnList
59
- } from "./chunk-4NBXLMCE.js";
60
+ } from "./chunk-SEWKTHUK.js";
60
61
  export {
62
+ EXECUTION_CONTRACT_VERSION,
61
63
  NQL_SELECT_AGGREGATE_FUNCTIONS,
62
64
  NQL_SELECT_FUNCTION_ALLOWLIST,
63
65
  NQL_SELECT_JSON_FUNCTIONS,
@@ -1,6 +1,6 @@
1
- import { N as NqlBindingRelationType } from './adapter-CBhAwQzd.js';
2
- export { A as Adapter, b as AdapterCapabilities, c as AdapterLogger, d as AdapterStreamOptions, e as AdjacencyTraversal, f as AggOrderByArg, g as AggregateCountIntent, h as AggregateExpressionIntent, i as AggregateFieldIntent, j as AggregateFunction, k as AggregateIntent, l as AggregateWindowFunction, m as AggregateWindowIntent, n as AliasIncludedColumnsMode, o as AlterColumnOptions, p as AmbiguityCheckResult, q as ArithmeticExpressionIntent, r as ArrayExpressionIntent, s as ArrayOperator, t as AuthorAttestedNativeDefault, u as AuthorAttester, B as BaseAdapter, v as BatchUpdateIntent, w as BatchValuesJoinPayload, x as CTEDefinition, y as Cardinality, z as CaseExpressionIntent, D as CastExpressionIntent, E as CheckConstraintIR, F as CoalesceExpressionIntent, G as ColumnAliasIntent, H as ColumnExpressionIntent, I as ColumnIR, J as ColumnJsReadType, K as ColumnListInput, L as ColumnType, M as CommonColumnType, O as ComparisonExpressionIntent, Q as ComparisonOperator, R as CompileOnlyAdapter, S as CompileOptions, T as CompileOptionsBase, U as CompileResultWithIncludes, a as CompiledColumnMetadata, V as CompiledNqlQuery, C as CompiledQuery, W as CompilingAdapter, X as CreateIndexOptions, Y as CteQueryIntent, Z as CustomFnExpressionIntent, _ as CustomOpExpressionIntent, $ as CustomTraversal, a0 as DDLFeature, a1 as DDLFeatureElementMap, a2 as DDLFeatureVersionRange, a3 as DDLGeneratingAdapter, a4 as DbCasing, a5 as DecisionType, a6 as DeleteIntent, a7 as DialectCapabilities, a8 as DialectName, a9 as DiffSummary, aa as DropIndexOptions, ab as DuckDBColumnType, ac as Dump, ad as DumpMeta, ae as DumpSequenceStep, af as EdgeTableTraversal, ag as EmitJoinClause, ah as EnumIR, ai as ExecutingAdapter, aj as ExpressionIntent, ak as FeatureBehaviorConfig, al as FeatureTranslator, am as FeatureWarning, an as FieldRef, ao as FilterStrategy, ap as ForeignKeyIR, aq as FunctionExpressionIntent, ar as HierarchyIR, as as IncludeIntent, at as IncludeRecursiveOptions, au as IncludeStrategy, av as IndexColumnDef, aw as IndexIR, ax as IndexInfo, ay as IndexMethod, az as InsertFromIntent, aA as InsertIntent, aB as IntrospectingAdapter, aC as IntrospectionOptions, aD as IntrospectionResult, aE as IsTypeSupported, aF as JoinDefault, aG as JoinIntent, aH as JsonAggOrderByEntry, aI as JsonContainsIntent, aJ as JsonExistsIntent, aK as JsonExtractIntent, aL as JsonPathExtractIntent, aM as LiteralExpressionIntent, aN as LockIntent, aO as LockStrength, aP as LockWaitPolicy, aQ as LogicalIdentity, aR as LogicalIdentityCarrier, aS as LogicalOperator, aT as MSSQLColumnType, aU as ModelIR, aV as MutationIntent, aW as MutationReturningItem, aX as MySQLColumnType, aY as NamedArgExpressionIntent, aZ as NestedOutputReadHandling, a_ as NqlBindingColumnLineage, a$ as NqlBindingColumnTypeInfo, b0 as NqlBindingColumnUntypeableReason, b1 as NqlBindingOutputSchema, b2 as NqlBindingRelationFilterMetadata, b3 as NqlBindingVirtualRelation, b4 as NqlBindingVirtualRelationHop, b5 as NqlBindingVirtualRelationRecursive, b6 as NqlProgramSequenceStep, b7 as NqlRuntimeBinding, b8 as NullOperator, b9 as NullsPosition, ba as OffsetWindowFunction, bb as OffsetWindowIntent, bc as OnDeleteAction, bd as OperationKindRef, be as Optionality, bf as OrderByExpressionIntent, bg as OrderByFieldIntent, bh as OrderByIntent, bi as OutputDescriptor, bj as OutputReadHandling, bk as OutputSource, bl as OutputValueShape, bm as ParamExpressionIntent, bn as ParamIntent, bo as PartitionIR, bp as PinnedConnectionOptions, bq as PlanDecision, br as PlanOptions, P as PlanReport, bs as PlanWarning, bt as PlanWarningCode, bu as PolicyIR, bv as PostgresColumnType, bw as PostgresOnlyColumnType, bx as PseudoColumnExpressionIntent, by as PseudoColumnMetadata, bz as PseudoColumnTraversal, bA as QueryIntent, bB as RangeOperand, bC as RangeOperator, bD as RangeValue, bE as RankingWindowFunction, bF as RankingWindowIntent, bG as RawCteIntent, bH as RawExpressionIntent, bI as RawSqlAdapter, bJ as RecursiveAdvancedOptions, bK as RecursiveDedupe, bL as RecursiveDirection, bM as RecursiveEmitOptions, bN as RecursiveExistsOptions, bO as RecursiveIntent, bP as RecursiveMetadata, bQ as RecursiveNodeIdExpr, bR as RecursivePlanOptions, bS as RecursivePlanReport, bT as RecursiveTrackOptions, bU as RecursiveTraversal, bV as RefExpressionIntent, bW as RelationColumnIntent, bX as RelationIR, bY as RelationKind, bZ as RelationOperator, b_ as RelationType, b$ as RequiredEnumLabelIR, c0 as ResolvedIncludeStrategy, c1 as SQLiteColumnType, c2 as SchemaChange, c3 as SchemaDiff, c4 as SelectAggregateIntent, c5 as SelectAllIntent, c6 as SelectFieldsIntent, c7 as SelectIntent, c8 as SelectWithExpressionsIntent, c9 as SemanticArtifactId, ca as SemanticArtifactRef, cb as SequenceIR, cc as SetOperationIntent, cd as SetOperationType, ce as SimpleCteIntent, cf as SortDirection, cg as StarExpressionIntent, ch as StreamingAdapter, ci as StringOperator, cj as SubqueryExpressionIntent, ck as SubqueryIncludeInfo, cl as SubqueryRefIntent, cm as SupportedColumnTypes, cn as TableDDLGeneratorAdapter, co as TableIR, cp as TransactionBeginOptions, cq as TransactionOptions, cr as TransactionalAdapter, cs as TranslationContext, ct as TruncateOptions, cu as TrustRoot, cv as UnaryExpressionIntent, cw as UnnestCteIntent, cx as UnsupportedFeatureBehavior, cy as UpdateIntent, cz as UpsertConflictAction, cA as UpsertConflictTarget, cB as UpsertFromIntent, cC as UpsertIntent, cD as VacuumOptions, cE as WhereAndIntent, cF as WhereAnyIntent, cG as WhereComparisonIntent, cH as WhereExistsIntent, cI as WhereExpressionIntent, cJ as WhereInIntent, cK as WhereInSubqueryIntent, cL as WhereInValueIntent, cM as WhereIntent, cN as WhereJsonContainsIntent, cO as WhereJsonExistsIntent, cP as WhereLikeIntent, cQ as WhereNotExistsIntent, cR as WhereNotIntent, cS as WhereNullIntent, cT as WhereOrIntent, cU as WhereRangeIntent, cV as WhereRawExistsIntent, cW as WhereRawNotExistsIntent, cX as WhereRelationFilterIntent, cY as WhereSubqueryIntent, cZ as WindowFunction, c_ as WindowIntent, c$ as WindowOrderBy, d0 as getNodeIdAlias, d1 as isFieldRef, d2 as isParamIntent, d3 as resolveOutputReadHandling, d4 as toColumnList } from './adapter-CBhAwQzd.js';
3
- export { AdvisoryObservation, AdvisoryObservationId, ApplicableAssessment, ApplicableEvaluation, ApplyGuard, ApplyPolicy, ApplyResult, Assumption, AssumptionAcceptance, AssumptionId, BigintJsReadConversionContext, BoundBinding, CapabilityAvailabilityPredicate, CapabilityDescriptor, ClaimConclusion, ClaimDerivation, ClaimId, ClaimSelector, CollationRef, Comparator, CompareOutcome, CompositionFactSatisfactionOwner, ContextFact, ContextMutation, DurableIntentRecord, EquivalenceCapability, EquivalenceContext, EquivalenceResult, EvidenceClaimConclusion, EvidenceClaimResult, EvidenceId, EvidenceObservation, EvidenceObservationFilters, EvidenceView, ExecutableAssertion, ExpressionEquivalenceCategory, ExpressionValue, ExternalEffectCoverage, FingerprintManifest, GuardPredicate, GuardProtocol, GuardProtocolKind, GuardedPlan, GuardedPlanSegment, GuardedPlanStep, InapplicableAssessment, IssuedObservation, JsonAggOrderKey, JsonValue, LoadedSchema, LockRequirement, NQL_SELECT_AGGREGATE_FUNCTIONS, NQL_SELECT_FUNCTION_ALLOWLIST, NQL_SELECT_JSON_FUNCTIONS, NQL_SELECT_SCALAR_FUNCTIONS, NQL_SELECT_SCALAR_FUNCTION_ALLOWLIST, NQL_SELECT_VALUE_FUNCTIONS, NQL_SELECT_WINDOW_FUNCTIONS, NQL_SELECT_WINDOW_FUNCTION_ALLOWLIST, NQL_SELECT_WINDOW_ONLY_FUNCTIONS, ObservationBooleanClaim, ObservationContext, ObservationIssuer, ObservationPrivilegeMergeResult, ObservationRequest, ObservationResult, ObservationStability, ObservedOutcomeRecord, OperationEffectAssessment, OperationEffects, OperationExecutionOutcome, OperationExecutionSemantics, OperationRecoverySemantics, OperationSemantics, OutcomeReason, OutcomeReasonCode, PhysicalOperation, PlanAssessment, PortableExpression, ProofClaim, ProofClaimDraft, ProofEvidenceAccess, ProofObligation, Proposition, ProvenApplyGuard, ProvenGuardProtocol, ProvenPlanShape, ProvenPlanStep, RecognitionContext, RecognitionResult, RecoveryArtefact, RelationKeyBuilderOptions, RelationKeyDirection, RelationKeyFields, RelationKeyForeignKey, ResourceAddress, ResourceSelector, RuleEvaluation, RulePrecedenceFact, RuleRef, RuleSelectionRationale, RuleSupport, SerializedProvenPlan, StepJournal, StepOutcome, TargetBinding, TransactionalCompletionRecord, TransitionCandidate, TransitionCompositionFact, TransitionFragment, TransitionFragmentComposition, TransitionJournalEvent, TransitionJournalEventName, TransitionJournalEventRecord, TransitionLessor, TransitionQueryClient, TransitionQueryResult, TransitionRule, TransitionRunJournal, TransitionRunMetadata, TransitionSessionClient, TypeRef, UnknownCoverage, UnknownTransitionRecognition, UnresolvableExpression, UnsafeNativeFragment, VendorValidatedExpression, buildRelationKeyFields, convertBigintJsReadValue, isAdjacencyTraversal, isAggregateWindowFunction, isCoalesceExpression, isColumnAliasExpression, isCustomTraversal, isDeleteIntent, isEdgeTableTraversal, isInsertIntent, isMutationIntent, isNqlSelectFunctionAllowed, isNqlSelectScalarFunctionAllowed, isNqlSelectWindowFunctionAllowed, isRankingWindowFunction, isRawExpression, isRecursiveIntent, isRelationColumnExpression, isSelectAggregate, isSelectAll, isSelectFields, isSelectWithExpressions, isSubqueryRef, isUpdateIntent, isUpsertIntent, isValidSchema, isWhereAnd, isWhereAny, isWhereComparison, isWhereExists, isWhereIn, isWhereLike, isWhereLogical, isWhereNot, isWhereNotExists, isWhereNull, isWhereOr, isWhereRange, isWhereRelationBased, isWhereRelationFilter, isWhereSubquery, isWindowIntent, resolveJsonAggOrderKey } from './index.js';
1
+ import { N as NqlBindingRelationType } from './adapter-CjwnHeg4.js';
2
+ export { A as Adapter, b as AdapterCapabilities, c as AdapterLogger, d as AdapterStreamOptions, e as AdjacencyTraversal, f as AggOrderByArg, g as AggregateCountIntent, h as AggregateExpressionIntent, i as AggregateFieldIntent, j as AggregateFunction, k as AggregateIntent, l as AggregateWindowFunction, m as AggregateWindowIntent, n as AliasIncludedColumnsMode, o as AlterColumnOptions, p as AmbiguityCheckResult, q as ArithmeticExpressionIntent, r as ArrayExpressionIntent, s as ArrayOperator, t as AuthorAttestedNativeDefault, u as AuthorAttester, B as BaseAdapter, v as BatchUpdateIntent, w as BatchValuesJoinPayload, x as CTEDefinition, y as Cardinality, z as CaseExpressionIntent, D as CastExpressionIntent, E as CheckConstraintIR, F as CoalesceExpressionIntent, G as ColumnAliasIntent, H as ColumnExpressionIntent, I as ColumnIR, J as ColumnJsReadType, K as ColumnListInput, L as ColumnType, M as CommonColumnType, O as ComparisonExpressionIntent, Q as ComparisonOperator, R as CompileOnlyAdapter, S as CompileOptions, T as CompileOptionsBase, U as CompileResultWithIncludes, a as CompiledColumnMetadata, V as CompiledNqlQuery, C as CompiledQuery, W as CompilingAdapter, X as ConnectionAvailability, Y as CreateIndexOptions, Z as CteQueryIntent, _ as CustomFnExpressionIntent, $ as CustomOpExpressionIntent, a0 as CustomTraversal, a1 as DDLFeature, a2 as DDLFeatureElementMap, a3 as DDLFeatureVersionRange, a4 as DDLGeneratingAdapter, a5 as DbCasing, a6 as DecisionType, a7 as DeleteIntent, a8 as DialectCapabilities, a9 as DialectName, aa as DiffSummary, ab as DropIndexOptions, ac as DuckDBColumnType, ad as Dump, ae as DumpMeta, af as DumpSequenceStep, ag as EdgeTableTraversal, ah as EmitJoinClause, ai as EnumIR, aj as ExecutingAdapter, ak as ExpressionIntent, al as FeatureBehaviorConfig, am as FeatureTranslator, an as FeatureWarning, ao as FieldRef, ap as FilterStrategy, aq as ForeignKeyIR, ar as FunctionExpressionIntent, as as HierarchyIR, at as IncludeIntent, au as IncludeRecursiveOptions, av as IncludeStrategy, aw as IndexColumnDef, ax as IndexIR, ay as IndexInfo, az as IndexMethod, aA as InsertFromIntent, aB as InsertIntent, aC as IntrospectingAdapter, aD as IntrospectionOptions, aE as IntrospectionResult, aF as IsTypeSupported, aG as JoinDefault, aH as JoinIntent, aI as JsonAggOrderByEntry, aJ as JsonContainsIntent, aK as JsonExistsIntent, aL as JsonExtractIntent, aM as JsonPathExtractIntent, aN as LiteralExpressionIntent, aO as LockIntent, aP as LockStrength, aQ as LockWaitPolicy, aR as LogicalIdentity, aS as LogicalIdentityCarrier, aT as LogicalOperator, aU as MSSQLColumnType, aV as ModelIR, aW as MutationIntent, aX as MutationReturningItem, aY as MySQLColumnType, aZ as NamedArgExpressionIntent, a_ as NestedOutputReadHandling, a$ as NqlBindingColumnLineage, b0 as NqlBindingColumnTypeInfo, b1 as NqlBindingColumnUntypeableReason, b2 as NqlBindingOutputSchema, b3 as NqlBindingRelationFilterMetadata, b4 as NqlBindingVirtualRelation, b5 as NqlBindingVirtualRelationHop, b6 as NqlBindingVirtualRelationRecursive, b7 as NqlProgramSequenceStep, b8 as NqlRuntimeBinding, b9 as NullOperator, ba as NullsPosition, bb as OffsetWindowFunction, bc as OffsetWindowIntent, bd as OnDeleteAction, be as OperationKindRef, bf as Optionality, bg as OrderByExpressionIntent, bh as OrderByFieldIntent, bi as OrderByIntent, bj as OutputDescriptor, bk as OutputReadHandling, bl as OutputSource, bm as OutputValueShape, bn as ParamExpressionIntent, bo as ParamIntent, bp as PartitionIR, bq as PinnedConnectionOptions, br as PlanDecision, bs as PlanOptions, P as PlanReport, bt as PlanWarning, bu as PlanWarningCode, bv as PolicyIR, bw as PostgresColumnType, bx as PostgresOnlyColumnType, by as PseudoColumnExpressionIntent, bz as PseudoColumnMetadata, bA as PseudoColumnTraversal, bB as QueryIntent, bC as RangeOperand, bD as RangeOperator, bE as RangeValue, bF as RankingWindowFunction, bG as RankingWindowIntent, bH as RawCteIntent, bI as RawExpressionIntent, bJ as RawSqlAdapter, bK as RecursiveAdvancedOptions, bL as RecursiveDedupe, bM as RecursiveDirection, bN as RecursiveEmitOptions, bO as RecursiveExistsOptions, bP as RecursiveIntent, bQ as RecursiveMetadata, bR as RecursiveNodeIdExpr, bS as RecursivePlanOptions, bT as RecursivePlanReport, bU as RecursiveTrackOptions, bV as RecursiveTraversal, bW as RefExpressionIntent, bX as RelationColumnIntent, bY as RelationIR, bZ as RelationKind, b_ as RelationOperator, b$ as RelationType, c0 as RequiredEnumLabelIR, c1 as ResolvedIncludeStrategy, c2 as SQLiteColumnType, c3 as SchemaChange, c4 as SchemaDiff, c5 as SelectAggregateIntent, c6 as SelectAllIntent, c7 as SelectFieldsIntent, c8 as SelectIntent, c9 as SelectWithExpressionsIntent, ca as SemanticArtifactId, cb as SemanticArtifactRef, cc as SequenceIR, cd as SetOperationIntent, ce as SetOperationType, cf as SimpleCteIntent, cg as SortDirection, ch as StarExpressionIntent, ci as StreamingAdapter, cj as StringOperator, ck as SubqueryExpressionIntent, cl as SubqueryIncludeInfo, cm as SubqueryRefIntent, cn as SupportedColumnTypes, co as TableDDLGeneratorAdapter, cp as TableIR, cq as TransactionBeginOptions, cr as TransactionOptions, cs as TransactionalAdapter, ct as TranslationContext, cu as TruncateOptions, cv as TrustRoot, cw as UnaryExpressionIntent, cx as UnnestCteIntent, cy as UnsupportedFeatureBehavior, cz as UpdateIntent, cA as UpsertConflictAction, cB as UpsertConflictTarget, cC as UpsertFromIntent, cD as UpsertIntent, cE as VacuumOptions, cF as WhereAndIntent, cG as WhereAnyIntent, cH as WhereComparisonIntent, cI as WhereExistsIntent, cJ as WhereExpressionIntent, cK as WhereInIntent, cL as WhereInSubqueryIntent, cM as WhereInValueIntent, cN as WhereIntent, cO as WhereJsonContainsIntent, cP as WhereJsonExistsIntent, cQ as WhereLikeIntent, cR as WhereNotExistsIntent, cS as WhereNotIntent, cT as WhereNullIntent, cU as WhereOrIntent, cV as WhereRangeIntent, cW as WhereRawExistsIntent, cX as WhereRawNotExistsIntent, cY as WhereRelationFilterIntent, cZ as WhereSubqueryIntent, c_ as WindowFunction, c$ as WindowIntent, d0 as WindowOrderBy, d1 as getNodeIdAlias, d2 as isFieldRef, d3 as isParamIntent, d4 as resolveOutputReadHandling, d5 as toColumnList } from './adapter-CjwnHeg4.js';
3
+ export { AdvisoryObservation, AdvisoryObservationId, ApplicableAssessment, ApplicableEvaluation, ApplyGuard, ApplyPolicy, ApplyResult, Assumption, AssumptionAcceptance, AssumptionId, BigintJsReadConversionContext, BoundBinding, CapabilityAvailabilityPredicate, CapabilityDescriptor, ClaimConclusion, ClaimDerivation, ClaimId, ClaimSelector, CollationRef, Comparator, CompareOutcome, CompositionFactSatisfactionOwner, ContextFact, ContextMutation, DurableIntentRecord, EXECUTION_CONTRACT_VERSION, EquivalenceCapability, EquivalenceContext, EquivalenceResult, EvidenceClaimConclusion, EvidenceClaimResult, EvidenceId, EvidenceObservation, EvidenceObservationFilters, EvidenceView, ExecutableAssertion, ExecutionContract, ExecutionRequirement, ExecutionRequirementMode, ExpressionEquivalenceCategory, ExpressionValue, ExternalEffectCoverage, FingerprintManifest, GuardPredicate, GuardProtocol, GuardProtocolKind, GuardedPlan, GuardedPlanSegment, GuardedPlanStep, InapplicableAssessment, IssuedObservation, JsonAggOrderKey, JsonValue, LoadedSchema, LockRequirement, NQL_SELECT_AGGREGATE_FUNCTIONS, NQL_SELECT_FUNCTION_ALLOWLIST, NQL_SELECT_JSON_FUNCTIONS, NQL_SELECT_SCALAR_FUNCTIONS, NQL_SELECT_SCALAR_FUNCTION_ALLOWLIST, NQL_SELECT_VALUE_FUNCTIONS, NQL_SELECT_WINDOW_FUNCTIONS, NQL_SELECT_WINDOW_FUNCTION_ALLOWLIST, NQL_SELECT_WINDOW_ONLY_FUNCTIONS, ObservationBooleanClaim, ObservationContext, ObservationIssuer, ObservationPrivilegeMergeResult, ObservationRequest, ObservationResult, ObservationStability, ObservedOutcomeRecord, OperationEffectAssessment, OperationEffects, OperationExecutionOutcome, OperationExecutionSemantics, OperationRecoverySemantics, OperationSemantics, OutcomeReason, OutcomeReasonCode, PhysicalOperation, PlanAssessment, PortableExpression, PostgreSqlAuthorityRequirement, PostgreSqlEngineRequirement, PostgreSqlNamespaceIdentity, PostgreSqlObservationTargetIdentity, PostgreSqlPhysicalTargetRequirement, PostgreSqlSessionSettingRequirement, ProofClaim, ProofClaimDraft, ProofEvidenceAccess, ProofObligation, Proposition, ProvenApplyGuard, ProvenGuardProtocol, ProvenPlanShape, ProvenPlanStep, RecognitionContext, RecognitionResult, RecoveryArtefact, RelationKeyBuilderOptions, RelationKeyDirection, RelationKeyFields, RelationKeyForeignKey, ResourceAddress, ResourceSelector, RuleEvaluation, RulePrecedenceFact, RuleRef, RuleSelectionRationale, RuleSupport, SerializedProvenPlan, StepJournal, StepOutcome, TargetBinding, TransactionalCompletionRecord, TransitionCandidate, TransitionCompositionFact, TransitionFragment, TransitionFragmentComposition, TransitionJournalEvent, TransitionJournalEventName, TransitionJournalEventRecord, TransitionLessor, TransitionQueryClient, TransitionQueryResult, TransitionRule, TransitionRunJournal, TransitionRunMetadata, TransitionSessionClient, TypeRef, UnknownCoverage, UnknownTransitionRecognition, UnresolvableExpression, UnsafeNativeFragment, VendorValidatedExpression, buildRelationKeyFields, convertBigintJsReadValue, isAdjacencyTraversal, isAggregateWindowFunction, isCoalesceExpression, isColumnAliasExpression, isCustomTraversal, isDeleteIntent, isEdgeTableTraversal, isInsertIntent, isMutationIntent, isNqlSelectFunctionAllowed, isNqlSelectScalarFunctionAllowed, isNqlSelectWindowFunctionAllowed, isRankingWindowFunction, isRawExpression, isRecursiveIntent, isRelationColumnExpression, isSelectAggregate, isSelectAll, isSelectFields, isSelectWithExpressions, isSubqueryRef, isUpdateIntent, isUpsertIntent, isValidSchema, isWhereAnd, isWhereAny, isWhereComparison, isWhereExists, isWhereIn, isWhereLike, isWhereLogical, isWhereNot, isWhereNotExists, isWhereNull, isWhereOr, isWhereRange, isWhereRelationBased, isWhereRelationFilter, isWhereSubquery, isWindowIntent, resolveJsonAggOrderKey } from './index.js';
4
4
 
5
5
  /**
6
6
  * @module builders
package/dist/internal.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ EXECUTION_CONTRACT_VERSION,
2
3
  NQL_SELECT_AGGREGATE_FUNCTIONS,
3
4
  NQL_SELECT_FUNCTION_ALLOWLIST,
4
5
  NQL_SELECT_JSON_FUNCTIONS,
@@ -56,7 +57,7 @@ import {
56
57
  resolveJsonAggOrderKey,
57
58
  resolveOutputReadHandling,
58
59
  toColumnList
59
- } from "./chunk-4NBXLMCE.js";
60
+ } from "./chunk-SEWKTHUK.js";
60
61
 
61
62
  // src/internal.ts
62
63
  function explainUnsupportedNqlBindingIncludeHop(relationName, relation, include) {
@@ -224,6 +225,7 @@ function getTrustedNqlRelationFilterFields(value) {
224
225
  return isTrustedRelationFilterPayload(payload) ? payload : void 0;
225
226
  }
226
227
  export {
228
+ EXECUTION_CONTRACT_VERSION,
227
229
  NQL_INTERNAL_COMPILER_OPTIONS,
228
230
  NQL_SELECT_AGGREGATE_FUNCTIONS,
229
231
  NQL_SELECT_FUNCTION_ALLOWLIST,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal.ts"],"sourcesContent":["/**\n * @dbsp/types/internal - Internal type definitions\n *\n * These types are for internal use by @dbsp package implementations.\n * They are NOT part of the public API and may change without notice.\n *\n * @module @dbsp/types/internal\n * @internal\n */\n\nimport { toColumnList } from './column-list.js';\nimport type { NqlBindingRelationType } from './model-ir.js';\n\n// Internal-only build utilities (NOT part of public API)\nexport type { IntentBuilder, Mutable } from './builders.js';\n\n/** @internal Minimal relation shape needed to validate NQL binding include hops. */\nexport interface NqlBindingIncludeRelationShape {\n\treadonly type?: NqlBindingRelationType | undefined;\n\treadonly foreignKey?: string | readonly string[] | undefined;\n\treadonly source?: string | undefined;\n\treadonly target?: string | undefined;\n\treadonly through?: unknown;\n\treadonly otherKey?: unknown;\n\treadonly throughSourceKey?: unknown;\n\treadonly throughTargetKey?: unknown;\n\treadonly recursive?: unknown;\n}\n\n/** @internal Minimal include-node shape needed to validate NQL binding include hops. */\nexport interface NqlBindingIncludeNodeShape {\n\treadonly relation?: unknown;\n\treadonly include?: readonly NqlBindingIncludeNodeShape[] | undefined;\n\treadonly [key: string]: unknown;\n}\n\n/** @internal */\nexport function explainUnsupportedNqlBindingIncludeHop(\n\trelationName: string,\n\trelation: NqlBindingIncludeRelationShape,\n\tinclude?: NqlBindingIncludeNodeShape,\n): string | undefined {\n\tconst includeReason = include\n\t\t? explainUnsupportedNqlBindingIncludeNode(relationName, include)\n\t\t: undefined;\n\tif (includeReason) return includeReason;\n\tif (\n\t\trelation.type === 'belongsToMany' ||\n\t\trelation.type === 'manyToMany' ||\n\t\trelation.through !== undefined ||\n\t\trelation.otherKey !== undefined ||\n\t\trelation.throughSourceKey !== undefined ||\n\t\trelation.throughTargetKey !== undefined\n\t) {\n\t\treturn `relation '${relationName}' is '${relation.type ?? 'through'}' and needs junction traversal; binding includes for many-to-many/through relations are not supported (ref-#192)`;\n\t}\n\tif (\n\t\trelation.type !== 'belongsTo' &&\n\t\trelation.type !== 'hasOne' &&\n\t\trelation.type !== 'hasMany'\n\t) {\n\t\treturn `relation '${relationName}' is '${relation.type ?? 'unknown'}'; binding includes require a belongsTo/hasOne/hasMany relation (ref-#192)`;\n\t}\n\tconst fkColumns = toColumnList(relation.foreignKey);\n\tif (fkColumns.length === 0 || fkColumns.some((col) => col.length === 0)) {\n\t\treturn `relation '${relationName}' must have at least one non-empty FK column for binding includes (ref-#179)`;\n\t}\n\tif (\n\t\trelation.recursive !== undefined ||\n\t\t(relation.source !== undefined &&\n\t\t\trelation.target !== undefined &&\n\t\t\trelation.source === relation.target)\n\t) {\n\t\treturn `relation '${relationName}' is recursive/self-referential; binding includes for recursive relations require recursive CTE handling and are not supported (ref-#193)`;\n\t}\n\treturn undefined;\n}\n\nconst NQL_BINDING_INCLUDE_NODE_KEYS: ReadonlySet<string> = new Set([\n\t'relation',\n\t'include',\n]);\n\nfunction explainUnsupportedNqlBindingIncludeNode(\n\trelationName: string,\n\tinclude: NqlBindingIncludeNodeShape,\n): string | undefined {\n\tconst keys = Object.keys(include);\n\tconst unsupportedKeys = keys.filter(\n\t\t(key) => !NQL_BINDING_INCLUDE_NODE_KEYS.has(key),\n\t);\n\tif (unsupportedKeys.length > 0) {\n\t\tconst options = unsupportedKeys.map((key) => `'${key}'`).join(', ');\n\t\treturn `relation '${relationName}' include node carries unsupported option${unsupportedKeys.length === 1 ? '' : 's'} ${options}; binding includes only allow 'relation' and nested 'include' (ref-#192)`;\n\t}\n\tif (typeof include.relation !== 'string' || include.relation.length === 0) {\n\t\treturn `relation '${relationName}' include node must name a relation (ref-#192)`;\n\t}\n\tif (include.include !== undefined && !Array.isArray(include.include)) {\n\t\treturn `relation '${relationName}' nested include must be an array (ref-#192)`;\n\t}\n\treturn undefined;\n}\n\n/**\n * @internal Shared compiler-options marker for trusted NQL package internals.\n *\n * Deliberately uses Symbol(), not Symbol.for(), so knowing the description does\n * not let callers forge the marker through the global symbol registry.\n */\nexport const NQL_INTERNAL_COMPILER_OPTIONS: unique symbol = Symbol(\n\t'@dbsp/nql/internalCompilerOptions',\n);\n\nconst NQL_BINDING_REF = Symbol('@dbsp/nql/bindingRef');\nconst NQL_TRUSTED_RELATION_FILTER = Symbol('@dbsp/nql/trustedRelationFilter');\n\n/**\n * @internal Opaque marker for NQL compiler-created binding references.\n *\n * The brand is a module-private Symbol(), so JSON/plain object inputs cannot\n * forge it by shape.\n */\nexport interface NqlBindingRef {\n\treadonly name: string;\n\treadonly [NQL_BINDING_REF]: true;\n}\n\n/** @internal */\nexport function createNqlBindingRef(name: string): NqlBindingRef {\n\tconst ref = { name } as { name: string; [NQL_BINDING_REF]?: true };\n\tObject.defineProperty(ref, NQL_BINDING_REF, {\n\t\tvalue: true,\n\t\tenumerable: false,\n\t});\n\treturn ref as NqlBindingRef;\n}\n\n/** @internal */\nexport function isNqlBindingRef(value: unknown): value is NqlBindingRef {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly name?: unknown;\n\t\treadonly [NQL_BINDING_REF]?: unknown;\n\t};\n\treturn (\n\t\tObject.hasOwn(record, NQL_BINDING_REF) &&\n\t\trecord[NQL_BINDING_REF] === true &&\n\t\ttypeof record.name === 'string'\n\t);\n}\n\n/** @internal */\nexport function getNqlBindingRefName(ref: NqlBindingRef): string {\n\treturn ref.name;\n}\n\n/** @internal */\nexport type NqlTrustedRelationFilterRelation = string | readonly string[];\n\n/** @internal */\nexport interface NqlTrustedRelationFilterHop {\n\treadonly target: string;\n\treadonly fkColumn: readonly string[];\n\treadonly joinColumn: readonly string[];\n}\n\n/** @internal */\nexport interface NqlTrustedRelationFilterRecursive {\n\treadonly direction: 'up' | 'down';\n\treadonly maxDepth: number;\n\treadonly selfRefColumn: string;\n\treadonly targetKeyColumn: string;\n}\n\n/** @internal */\nexport interface NqlTrustedRelationFilterFields {\n\treadonly relation: NqlTrustedRelationFilterRelation;\n\treadonly targetTable: string;\n\treadonly sourceColumn: readonly string[];\n\treadonly targetColumn: readonly string[];\n\treadonly hops: readonly NqlTrustedRelationFilterHop[];\n\treadonly through?: string;\n\treadonly throughSourceColumn?: string;\n\treadonly throughTargetColumn?: string;\n\treadonly selectedColumn?: string;\n\treadonly cardinality?: 'one' | 'many';\n\treadonly relationType?: NqlBindingRelationType;\n\treadonly recursive?: NqlTrustedRelationFilterRecursive;\n}\n\n/**\n * @internal Opaque proof for NQL compiler-proven relation filter metadata.\n *\n * The module-private Symbol stores the frozen proven payload. Public\n * targetTable/sourceColumn/targetColumn/relation fields are display metadata only;\n * consumers must read the payload through getTrustedNqlRelationFilterFields().\n */\nexport interface NqlTrustedRelationFilterProof {\n\treadonly [NQL_TRUSTED_RELATION_FILTER]: NqlTrustedRelationFilterFields;\n}\n\nfunction isStringArray(value: unknown): value is readonly string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length > 0 &&\n\t\tvalue.every((item) => typeof item === 'string' && item.length > 0)\n\t);\n}\n\nfunction isRelationType(value: unknown): value is NqlBindingRelationType {\n\treturn (\n\t\tvalue === 'hasOne' ||\n\t\tvalue === 'hasMany' ||\n\t\tvalue === 'belongsTo' ||\n\t\tvalue === 'belongsToMany' ||\n\t\tvalue === 'manyToMany'\n\t);\n}\n\nfunction isTrustedRelationFilterHop(\n\tvalue: unknown,\n): value is NqlTrustedRelationFilterHop {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly target?: unknown;\n\t\treadonly fkColumn?: unknown;\n\t\treadonly joinColumn?: unknown;\n\t};\n\treturn (\n\t\ttypeof record.target === 'string' &&\n\t\trecord.target.length > 0 &&\n\t\tisStringArray(record.fkColumn) &&\n\t\tisStringArray(record.joinColumn) &&\n\t\trecord.fkColumn.length === record.joinColumn.length\n\t);\n}\n\nfunction isTrustedRelationFilterRecursive(\n\tvalue: unknown,\n): value is NqlTrustedRelationFilterRecursive {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly direction?: unknown;\n\t\treadonly maxDepth?: unknown;\n\t\treadonly selfRefColumn?: unknown;\n\t\treadonly targetKeyColumn?: unknown;\n\t};\n\treturn (\n\t\t(record.direction === 'up' || record.direction === 'down') &&\n\t\ttypeof record.maxDepth === 'number' &&\n\t\tNumber.isSafeInteger(record.maxDepth) &&\n\t\trecord.maxDepth > 0 &&\n\t\ttypeof record.selfRefColumn === 'string' &&\n\t\trecord.selfRefColumn.length > 0 &&\n\t\ttypeof record.targetKeyColumn === 'string' &&\n\t\trecord.targetKeyColumn.length > 0\n\t);\n}\n\nfunction relationHasMultipleHops(\n\trelation: NqlTrustedRelationFilterRelation,\n): boolean {\n\tif (typeof relation !== 'string') return relation.length > 1;\n\treturn relation.split('.').length > 1;\n}\n\nfunction isTrustedRelationFilterPayload(\n\tvalue: unknown,\n): value is NqlTrustedRelationFilterFields {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly relation?: unknown;\n\t\treadonly targetTable?: unknown;\n\t\treadonly sourceColumn?: unknown;\n\t\treadonly targetColumn?: unknown;\n\t\treadonly hops?: unknown;\n\t\treadonly through?: unknown;\n\t\treadonly throughSourceColumn?: unknown;\n\t\treadonly throughTargetColumn?: unknown;\n\t\treadonly selectedColumn?: unknown;\n\t\treadonly cardinality?: unknown;\n\t\treadonly relationType?: unknown;\n\t\treadonly recursive?: unknown;\n\t};\n\treturn (\n\t\t(typeof record.relation === 'string' || isStringArray(record.relation)) &&\n\t\ttypeof record.targetTable === 'string' &&\n\t\tisStringArray(record.sourceColumn) &&\n\t\tisStringArray(record.targetColumn) &&\n\t\trecord.sourceColumn.length === record.targetColumn.length &&\n\t\tArray.isArray(record.hops) &&\n\t\trecord.hops.every(isTrustedRelationFilterHop) &&\n\t\t(record.through === undefined ||\n\t\t\t(typeof record.through === 'string' && record.through.length > 0)) &&\n\t\t(record.throughSourceColumn === undefined ||\n\t\t\t(typeof record.throughSourceColumn === 'string' &&\n\t\t\t\trecord.throughSourceColumn.length > 0)) &&\n\t\t(record.throughTargetColumn === undefined ||\n\t\t\t(typeof record.throughTargetColumn === 'string' &&\n\t\t\t\trecord.throughTargetColumn.length > 0)) &&\n\t\t(record.selectedColumn === undefined ||\n\t\t\ttypeof record.selectedColumn === 'string') &&\n\t\t(record.cardinality === undefined ||\n\t\t\trecord.cardinality === 'one' ||\n\t\t\trecord.cardinality === 'many') &&\n\t\t(record.relationType === undefined ||\n\t\t\tisRelationType(record.relationType)) &&\n\t\t(record.recursive === undefined ||\n\t\t\tisTrustedRelationFilterRecursive(record.recursive)) &&\n\t\t!(\n\t\t\trecord.selectedColumn !== undefined &&\n\t\t\trecord.cardinality === 'one' &&\n\t\t\trelationHasMultipleHops(record.relation) &&\n\t\t\trecord.hops.length === 0\n\t\t)\n\t);\n}\n\nfunction freezeTrustedRelationFilterPayload(\n\tfields: NqlTrustedRelationFilterFields,\n): NqlTrustedRelationFilterFields {\n\tconst relation = Array.isArray(fields.relation)\n\t\t? Object.freeze([...fields.relation])\n\t\t: fields.relation;\n\tconst through = fields.through;\n\tconst throughSourceColumn = fields.throughSourceColumn;\n\tconst throughTargetColumn = fields.throughTargetColumn;\n\tconst recursive =\n\t\tfields.recursive === undefined\n\t\t\t? undefined\n\t\t\t: Object.freeze({\n\t\t\t\t\tdirection: fields.recursive.direction,\n\t\t\t\t\tmaxDepth: fields.recursive.maxDepth,\n\t\t\t\t\tselfRefColumn: fields.recursive.selfRefColumn,\n\t\t\t\t\ttargetKeyColumn: fields.recursive.targetKeyColumn,\n\t\t\t\t});\n\tconst hops = Object.freeze(\n\t\tfields.hops.map((hop) =>\n\t\t\tObject.freeze({\n\t\t\t\ttarget: hop.target,\n\t\t\t\tfkColumn: Object.freeze([...hop.fkColumn]),\n\t\t\t\tjoinColumn: Object.freeze([...hop.joinColumn]),\n\t\t\t}),\n\t\t),\n\t);\n\treturn Object.freeze({\n\t\trelation,\n\t\ttargetTable: fields.targetTable,\n\t\tsourceColumn: Object.freeze([...fields.sourceColumn]),\n\t\ttargetColumn: Object.freeze([...fields.targetColumn]),\n\t\thops,\n\t\t...(through !== undefined && {\n\t\t\tthrough,\n\t\t}),\n\t\t...(throughSourceColumn !== undefined && {\n\t\t\tthroughSourceColumn,\n\t\t}),\n\t\t...(throughTargetColumn !== undefined && {\n\t\t\tthroughTargetColumn,\n\t\t}),\n\t\t...(fields.selectedColumn !== undefined && {\n\t\t\tselectedColumn: fields.selectedColumn,\n\t\t}),\n\t\t...(fields.cardinality !== undefined && {\n\t\t\tcardinality: fields.cardinality,\n\t\t}),\n\t\t...(fields.relationType !== undefined && {\n\t\t\trelationType: fields.relationType,\n\t\t}),\n\t\t...(recursive !== undefined && {\n\t\t\trecursive,\n\t\t}),\n\t});\n}\n\n/** @internal */\nexport function markNqlTrustedRelationFilter<T extends object>(\n\tvalue: T,\n\tfields: NqlTrustedRelationFilterFields,\n): T & NqlTrustedRelationFilterProof {\n\tObject.defineProperty(value, NQL_TRUSTED_RELATION_FILTER, {\n\t\tvalue: freezeTrustedRelationFilterPayload(fields),\n\t\tenumerable: false,\n\t});\n\treturn value as T & NqlTrustedRelationFilterProof;\n}\n\n/** @internal */\nexport function hasNqlTrustedRelationFilterProof(\n\tvalue: unknown,\n): value is NqlTrustedRelationFilterProof {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly [NQL_TRUSTED_RELATION_FILTER]?: unknown;\n\t};\n\treturn (\n\t\tObject.hasOwn(record, NQL_TRUSTED_RELATION_FILTER) &&\n\t\tisTrustedRelationFilterPayload(record[NQL_TRUSTED_RELATION_FILTER])\n\t);\n}\n\n/** @internal */\nexport function getTrustedNqlRelationFilterFields(\n\tvalue: unknown,\n): NqlTrustedRelationFilterFields | undefined {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn undefined;\n\t}\n\tconst record = value as {\n\t\treadonly [NQL_TRUSTED_RELATION_FILTER]?: unknown;\n\t};\n\tconst payload = record[NQL_TRUSTED_RELATION_FILTER];\n\treturn isTrustedRelationFilterPayload(payload) ? payload : undefined;\n}\n\n// Re-export all public types for convenience\nexport * from './index.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,SAAS,uCACf,cACA,UACA,SACqB;AACrB,QAAM,gBAAgB,UACnB,wCAAwC,cAAc,OAAO,IAC7D;AACH,MAAI,cAAe,QAAO;AAC1B,MACC,SAAS,SAAS,mBAClB,SAAS,SAAS,gBAClB,SAAS,YAAY,UACrB,SAAS,aAAa,UACtB,SAAS,qBAAqB,UAC9B,SAAS,qBAAqB,QAC7B;AACD,WAAO,aAAa,YAAY,SAAS,SAAS,QAAQ,SAAS;AAAA,EACpE;AACA,MACC,SAAS,SAAS,eAClB,SAAS,SAAS,YAClB,SAAS,SAAS,WACjB;AACD,WAAO,aAAa,YAAY,SAAS,SAAS,QAAQ,SAAS;AAAA,EACpE;AACA,QAAM,YAAY,aAAa,SAAS,UAAU;AAClD,MAAI,UAAU,WAAW,KAAK,UAAU,KAAK,CAAC,QAAQ,IAAI,WAAW,CAAC,GAAG;AACxE,WAAO,aAAa,YAAY;AAAA,EACjC;AACA,MACC,SAAS,cAAc,UACtB,SAAS,WAAW,UACpB,SAAS,WAAW,UACpB,SAAS,WAAW,SAAS,QAC7B;AACD,WAAO,aAAa,YAAY;AAAA,EAC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AO;AAAA,IACpB;AAAA,IACA,aAAa,OAAO;AAAA,IACpB,cAAc,OAAO,OAAO,CAAC,GAAG,OAAO,YAAY,CAAC;AAAA,IACpD,cAAc,OAAO,OAAO,CAAC,GAAG,OAAO,YAAY,CAAC;AAAA,IACpD;AAAA,IACA,GAAI,YAAY,UAAa;AAAA,MAC5B;AAAA,IACD;AAAA,IACA,GAAI,wBAAwB,UAAa;AAAA,MACxC;AAAA,IACD;AAAA,IACA,GAAI,wBAAwB,UAAa;AAAA,MACxC;AAAA,IACD;AAAA,IACA,GAAI,OAAO,mBAAmB,UAAa;AAAA,MAC1C,gBAAgB,OAAO;AAAA,IACxB;AAAA,IACA,GAAI,OAAO,gBAAgB,UAAa;AAAA,MACvC,aAAa,OAAO;AAAA,IACrB;AAAA,IACA,GAAI,OAAO,iBAAiB,UAAa;AAAA,MACxC,cAAc,OAAO;AAAA,IACtB;AAAA,IACA,GAAI,cAAc,UAAa;AAAA,MAC9B;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAGO,SAAS,6BACf,OACA,QACoC;AACpC,SAAO,eAAe,OAAO,6BAA6B;AAAA,IACzD,OAAO,mCAAmC,MAAM;AAAA,IAChD,YAAY;AAAA,EACb,CAAC;AACD,SAAO;AACR;AAGO,SAAS,iCACf,OACyC;AACzC,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAChD,WAAO;AAAA,EACR;AACA,QAAM,SAAS;AAGf,SACC,OAAO,OAAO,QAAQ,2BAA2B,KACjD,+BAA+B,OAAO,2BAA2B,CAAC;AAEpE;AAGO,SAAS,kCACf,OAC6C;AAC7C,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAChD,WAAO;AAAA,EACR;AACA,QAAM,SAAS;AAGf,QAAM,UAAU,OAAO,2BAA2B;AAClD,SAAO,+BAA+B,OAAO,IAAI,UAAU;AAC5D;","names":[]}
1
+ {"version":3,"sources":["../src/internal.ts"],"sourcesContent":["/**\n * @dbsp/types/internal - Internal type definitions\n *\n * These types are for internal use by @dbsp package implementations.\n * They are NOT part of the public API and may change without notice.\n *\n * @module @dbsp/types/internal\n * @internal\n */\n\nimport { toColumnList } from './column-list.js';\nimport type { NqlBindingRelationType } from './model-ir.js';\n\n// Internal-only build utilities (NOT part of public API)\nexport type { IntentBuilder, Mutable } from './builders.js';\n\n/** @internal Minimal relation shape needed to validate NQL binding include hops. */\nexport interface NqlBindingIncludeRelationShape {\n\treadonly type?: NqlBindingRelationType | undefined;\n\treadonly foreignKey?: string | readonly string[] | undefined;\n\treadonly source?: string | undefined;\n\treadonly target?: string | undefined;\n\treadonly through?: unknown;\n\treadonly otherKey?: unknown;\n\treadonly throughSourceKey?: unknown;\n\treadonly throughTargetKey?: unknown;\n\treadonly recursive?: unknown;\n}\n\n/** @internal Minimal include-node shape needed to validate NQL binding include hops. */\nexport interface NqlBindingIncludeNodeShape {\n\treadonly relation?: unknown;\n\treadonly include?: readonly NqlBindingIncludeNodeShape[] | undefined;\n\treadonly [key: string]: unknown;\n}\n\n/** @internal */\nexport function explainUnsupportedNqlBindingIncludeHop(\n\trelationName: string,\n\trelation: NqlBindingIncludeRelationShape,\n\tinclude?: NqlBindingIncludeNodeShape,\n): string | undefined {\n\tconst includeReason = include\n\t\t? explainUnsupportedNqlBindingIncludeNode(relationName, include)\n\t\t: undefined;\n\tif (includeReason) return includeReason;\n\tif (\n\t\trelation.type === 'belongsToMany' ||\n\t\trelation.type === 'manyToMany' ||\n\t\trelation.through !== undefined ||\n\t\trelation.otherKey !== undefined ||\n\t\trelation.throughSourceKey !== undefined ||\n\t\trelation.throughTargetKey !== undefined\n\t) {\n\t\treturn `relation '${relationName}' is '${relation.type ?? 'through'}' and needs junction traversal; binding includes for many-to-many/through relations are not supported (ref-#192)`;\n\t}\n\tif (\n\t\trelation.type !== 'belongsTo' &&\n\t\trelation.type !== 'hasOne' &&\n\t\trelation.type !== 'hasMany'\n\t) {\n\t\treturn `relation '${relationName}' is '${relation.type ?? 'unknown'}'; binding includes require a belongsTo/hasOne/hasMany relation (ref-#192)`;\n\t}\n\tconst fkColumns = toColumnList(relation.foreignKey);\n\tif (fkColumns.length === 0 || fkColumns.some((col) => col.length === 0)) {\n\t\treturn `relation '${relationName}' must have at least one non-empty FK column for binding includes (ref-#179)`;\n\t}\n\tif (\n\t\trelation.recursive !== undefined ||\n\t\t(relation.source !== undefined &&\n\t\t\trelation.target !== undefined &&\n\t\t\trelation.source === relation.target)\n\t) {\n\t\treturn `relation '${relationName}' is recursive/self-referential; binding includes for recursive relations require recursive CTE handling and are not supported (ref-#193)`;\n\t}\n\treturn undefined;\n}\n\nconst NQL_BINDING_INCLUDE_NODE_KEYS: ReadonlySet<string> = new Set([\n\t'relation',\n\t'include',\n]);\n\nfunction explainUnsupportedNqlBindingIncludeNode(\n\trelationName: string,\n\tinclude: NqlBindingIncludeNodeShape,\n): string | undefined {\n\tconst keys = Object.keys(include);\n\tconst unsupportedKeys = keys.filter(\n\t\t(key) => !NQL_BINDING_INCLUDE_NODE_KEYS.has(key),\n\t);\n\tif (unsupportedKeys.length > 0) {\n\t\tconst options = unsupportedKeys.map((key) => `'${key}'`).join(', ');\n\t\treturn `relation '${relationName}' include node carries unsupported option${unsupportedKeys.length === 1 ? '' : 's'} ${options}; binding includes only allow 'relation' and nested 'include' (ref-#192)`;\n\t}\n\tif (typeof include.relation !== 'string' || include.relation.length === 0) {\n\t\treturn `relation '${relationName}' include node must name a relation (ref-#192)`;\n\t}\n\tif (include.include !== undefined && !Array.isArray(include.include)) {\n\t\treturn `relation '${relationName}' nested include must be an array (ref-#192)`;\n\t}\n\treturn undefined;\n}\n\n/**\n * @internal Shared compiler-options marker for trusted NQL package internals.\n *\n * Deliberately uses Symbol(), not Symbol.for(), so knowing the description does\n * not let callers forge the marker through the global symbol registry.\n */\nexport const NQL_INTERNAL_COMPILER_OPTIONS: unique symbol = Symbol(\n\t'@dbsp/nql/internalCompilerOptions',\n);\n\nconst NQL_BINDING_REF = Symbol('@dbsp/nql/bindingRef');\nconst NQL_TRUSTED_RELATION_FILTER = Symbol('@dbsp/nql/trustedRelationFilter');\n\n/**\n * @internal Opaque marker for NQL compiler-created binding references.\n *\n * The brand is a module-private Symbol(), so JSON/plain object inputs cannot\n * forge it by shape.\n */\nexport interface NqlBindingRef {\n\treadonly name: string;\n\treadonly [NQL_BINDING_REF]: true;\n}\n\n/** @internal */\nexport function createNqlBindingRef(name: string): NqlBindingRef {\n\tconst ref = { name } as { name: string; [NQL_BINDING_REF]?: true };\n\tObject.defineProperty(ref, NQL_BINDING_REF, {\n\t\tvalue: true,\n\t\tenumerable: false,\n\t});\n\treturn ref as NqlBindingRef;\n}\n\n/** @internal */\nexport function isNqlBindingRef(value: unknown): value is NqlBindingRef {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly name?: unknown;\n\t\treadonly [NQL_BINDING_REF]?: unknown;\n\t};\n\treturn (\n\t\tObject.hasOwn(record, NQL_BINDING_REF) &&\n\t\trecord[NQL_BINDING_REF] === true &&\n\t\ttypeof record.name === 'string'\n\t);\n}\n\n/** @internal */\nexport function getNqlBindingRefName(ref: NqlBindingRef): string {\n\treturn ref.name;\n}\n\n/** @internal */\nexport type NqlTrustedRelationFilterRelation = string | readonly string[];\n\n/** @internal */\nexport interface NqlTrustedRelationFilterHop {\n\treadonly target: string;\n\treadonly fkColumn: readonly string[];\n\treadonly joinColumn: readonly string[];\n}\n\n/** @internal */\nexport interface NqlTrustedRelationFilterRecursive {\n\treadonly direction: 'up' | 'down';\n\treadonly maxDepth: number;\n\treadonly selfRefColumn: string;\n\treadonly targetKeyColumn: string;\n}\n\n/** @internal */\nexport interface NqlTrustedRelationFilterFields {\n\treadonly relation: NqlTrustedRelationFilterRelation;\n\treadonly targetTable: string;\n\treadonly sourceColumn: readonly string[];\n\treadonly targetColumn: readonly string[];\n\treadonly hops: readonly NqlTrustedRelationFilterHop[];\n\treadonly through?: string;\n\treadonly throughSourceColumn?: string;\n\treadonly throughTargetColumn?: string;\n\treadonly selectedColumn?: string;\n\treadonly cardinality?: 'one' | 'many';\n\treadonly relationType?: NqlBindingRelationType;\n\treadonly recursive?: NqlTrustedRelationFilterRecursive;\n}\n\n/**\n * @internal Opaque proof for NQL compiler-proven relation filter metadata.\n *\n * The module-private Symbol stores the frozen proven payload. Public\n * targetTable/sourceColumn/targetColumn/relation fields are display metadata only;\n * consumers must read the payload through getTrustedNqlRelationFilterFields().\n */\nexport interface NqlTrustedRelationFilterProof {\n\treadonly [NQL_TRUSTED_RELATION_FILTER]: NqlTrustedRelationFilterFields;\n}\n\nfunction isStringArray(value: unknown): value is readonly string[] {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length > 0 &&\n\t\tvalue.every((item) => typeof item === 'string' && item.length > 0)\n\t);\n}\n\nfunction isRelationType(value: unknown): value is NqlBindingRelationType {\n\treturn (\n\t\tvalue === 'hasOne' ||\n\t\tvalue === 'hasMany' ||\n\t\tvalue === 'belongsTo' ||\n\t\tvalue === 'belongsToMany' ||\n\t\tvalue === 'manyToMany'\n\t);\n}\n\nfunction isTrustedRelationFilterHop(\n\tvalue: unknown,\n): value is NqlTrustedRelationFilterHop {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly target?: unknown;\n\t\treadonly fkColumn?: unknown;\n\t\treadonly joinColumn?: unknown;\n\t};\n\treturn (\n\t\ttypeof record.target === 'string' &&\n\t\trecord.target.length > 0 &&\n\t\tisStringArray(record.fkColumn) &&\n\t\tisStringArray(record.joinColumn) &&\n\t\trecord.fkColumn.length === record.joinColumn.length\n\t);\n}\n\nfunction isTrustedRelationFilterRecursive(\n\tvalue: unknown,\n): value is NqlTrustedRelationFilterRecursive {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly direction?: unknown;\n\t\treadonly maxDepth?: unknown;\n\t\treadonly selfRefColumn?: unknown;\n\t\treadonly targetKeyColumn?: unknown;\n\t};\n\treturn (\n\t\t(record.direction === 'up' || record.direction === 'down') &&\n\t\ttypeof record.maxDepth === 'number' &&\n\t\tNumber.isSafeInteger(record.maxDepth) &&\n\t\trecord.maxDepth > 0 &&\n\t\ttypeof record.selfRefColumn === 'string' &&\n\t\trecord.selfRefColumn.length > 0 &&\n\t\ttypeof record.targetKeyColumn === 'string' &&\n\t\trecord.targetKeyColumn.length > 0\n\t);\n}\n\nfunction relationHasMultipleHops(\n\trelation: NqlTrustedRelationFilterRelation,\n): boolean {\n\tif (typeof relation !== 'string') return relation.length > 1;\n\treturn relation.split('.').length > 1;\n}\n\nfunction isTrustedRelationFilterPayload(\n\tvalue: unknown,\n): value is NqlTrustedRelationFilterFields {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly relation?: unknown;\n\t\treadonly targetTable?: unknown;\n\t\treadonly sourceColumn?: unknown;\n\t\treadonly targetColumn?: unknown;\n\t\treadonly hops?: unknown;\n\t\treadonly through?: unknown;\n\t\treadonly throughSourceColumn?: unknown;\n\t\treadonly throughTargetColumn?: unknown;\n\t\treadonly selectedColumn?: unknown;\n\t\treadonly cardinality?: unknown;\n\t\treadonly relationType?: unknown;\n\t\treadonly recursive?: unknown;\n\t};\n\treturn (\n\t\t(typeof record.relation === 'string' || isStringArray(record.relation)) &&\n\t\ttypeof record.targetTable === 'string' &&\n\t\tisStringArray(record.sourceColumn) &&\n\t\tisStringArray(record.targetColumn) &&\n\t\trecord.sourceColumn.length === record.targetColumn.length &&\n\t\tArray.isArray(record.hops) &&\n\t\trecord.hops.every(isTrustedRelationFilterHop) &&\n\t\t(record.through === undefined ||\n\t\t\t(typeof record.through === 'string' && record.through.length > 0)) &&\n\t\t(record.throughSourceColumn === undefined ||\n\t\t\t(typeof record.throughSourceColumn === 'string' &&\n\t\t\t\trecord.throughSourceColumn.length > 0)) &&\n\t\t(record.throughTargetColumn === undefined ||\n\t\t\t(typeof record.throughTargetColumn === 'string' &&\n\t\t\t\trecord.throughTargetColumn.length > 0)) &&\n\t\t(record.selectedColumn === undefined ||\n\t\t\ttypeof record.selectedColumn === 'string') &&\n\t\t(record.cardinality === undefined ||\n\t\t\trecord.cardinality === 'one' ||\n\t\t\trecord.cardinality === 'many') &&\n\t\t(record.relationType === undefined ||\n\t\t\tisRelationType(record.relationType)) &&\n\t\t(record.recursive === undefined ||\n\t\t\tisTrustedRelationFilterRecursive(record.recursive)) &&\n\t\t!(\n\t\t\trecord.selectedColumn !== undefined &&\n\t\t\trecord.cardinality === 'one' &&\n\t\t\trelationHasMultipleHops(record.relation) &&\n\t\t\trecord.hops.length === 0\n\t\t)\n\t);\n}\n\nfunction freezeTrustedRelationFilterPayload(\n\tfields: NqlTrustedRelationFilterFields,\n): NqlTrustedRelationFilterFields {\n\tconst relation = Array.isArray(fields.relation)\n\t\t? Object.freeze([...fields.relation])\n\t\t: fields.relation;\n\tconst through = fields.through;\n\tconst throughSourceColumn = fields.throughSourceColumn;\n\tconst throughTargetColumn = fields.throughTargetColumn;\n\tconst recursive =\n\t\tfields.recursive === undefined\n\t\t\t? undefined\n\t\t\t: Object.freeze({\n\t\t\t\t\tdirection: fields.recursive.direction,\n\t\t\t\t\tmaxDepth: fields.recursive.maxDepth,\n\t\t\t\t\tselfRefColumn: fields.recursive.selfRefColumn,\n\t\t\t\t\ttargetKeyColumn: fields.recursive.targetKeyColumn,\n\t\t\t\t});\n\tconst hops = Object.freeze(\n\t\tfields.hops.map((hop) =>\n\t\t\tObject.freeze({\n\t\t\t\ttarget: hop.target,\n\t\t\t\tfkColumn: Object.freeze([...hop.fkColumn]),\n\t\t\t\tjoinColumn: Object.freeze([...hop.joinColumn]),\n\t\t\t}),\n\t\t),\n\t);\n\treturn Object.freeze({\n\t\trelation,\n\t\ttargetTable: fields.targetTable,\n\t\tsourceColumn: Object.freeze([...fields.sourceColumn]),\n\t\ttargetColumn: Object.freeze([...fields.targetColumn]),\n\t\thops,\n\t\t...(through !== undefined && {\n\t\t\tthrough,\n\t\t}),\n\t\t...(throughSourceColumn !== undefined && {\n\t\t\tthroughSourceColumn,\n\t\t}),\n\t\t...(throughTargetColumn !== undefined && {\n\t\t\tthroughTargetColumn,\n\t\t}),\n\t\t...(fields.selectedColumn !== undefined && {\n\t\t\tselectedColumn: fields.selectedColumn,\n\t\t}),\n\t\t...(fields.cardinality !== undefined && {\n\t\t\tcardinality: fields.cardinality,\n\t\t}),\n\t\t...(fields.relationType !== undefined && {\n\t\t\trelationType: fields.relationType,\n\t\t}),\n\t\t...(recursive !== undefined && {\n\t\t\trecursive,\n\t\t}),\n\t});\n}\n\n/** @internal */\nexport function markNqlTrustedRelationFilter<T extends object>(\n\tvalue: T,\n\tfields: NqlTrustedRelationFilterFields,\n): T & NqlTrustedRelationFilterProof {\n\tObject.defineProperty(value, NQL_TRUSTED_RELATION_FILTER, {\n\t\tvalue: freezeTrustedRelationFilterPayload(fields),\n\t\tenumerable: false,\n\t});\n\treturn value as T & NqlTrustedRelationFilterProof;\n}\n\n/** @internal */\nexport function hasNqlTrustedRelationFilterProof(\n\tvalue: unknown,\n): value is NqlTrustedRelationFilterProof {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn false;\n\t}\n\tconst record = value as {\n\t\treadonly [NQL_TRUSTED_RELATION_FILTER]?: unknown;\n\t};\n\treturn (\n\t\tObject.hasOwn(record, NQL_TRUSTED_RELATION_FILTER) &&\n\t\tisTrustedRelationFilterPayload(record[NQL_TRUSTED_RELATION_FILTER])\n\t);\n}\n\n/** @internal */\nexport function getTrustedNqlRelationFilterFields(\n\tvalue: unknown,\n): NqlTrustedRelationFilterFields | undefined {\n\tif (value === null || typeof value !== 'object') {\n\t\treturn undefined;\n\t}\n\tconst record = value as {\n\t\treadonly [NQL_TRUSTED_RELATION_FILTER]?: unknown;\n\t};\n\tconst payload = record[NQL_TRUSTED_RELATION_FILTER];\n\treturn isTrustedRelationFilterPayload(payload) ? payload : undefined;\n}\n\n// Re-export all public types for convenience\nexport *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Aa;AAAA,MACvC,aAAa,OAAO;AAAA,IACrB;AAAA,IACA,GAAI,OAAO,iBAAiB,UAAa;AAAA,MACxC,cAAc,OAAO;AAAA,IACtB;AAAA,IACA,GAAI,cAAc,UAAa;AAAA,MAC9B;AAAA,IACD;AAAA,EACD,CAAC;AACF;AAGO,SAAS,6BACf,OACA,QACoC;AACpC,SAAO,eAAe,OAAO,6BAA6B;AAAA,IACzD,OAAO,mCAAmC,MAAM;AAAA,IAChD,YAAY;AAAA,EACb,CAAC;AACD,SAAO;AACR;AAGO,SAAS,iCACf,OACyC;AACzC,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAChD,WAAO;AAAA,EACR;AACA,QAAM,SAAS;AAGf,SACC,OAAO,OAAO,QAAQ,2BAA2B,KACjD,+BAA+B,OAAO,2BAA2B,CAAC;AAEpE;AAGO,SAAS,kCACf,OAC6C;AAC7C,MAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAChD,WAAO;AAAA,EACR;AACA,QAAM,SAAS;AAGf,QAAM,UAAU,OAAO,2BAA2B;AAClD,SAAO,+BAA+B,OAAO,IAAI,UAAU;AAC5D;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbsp/types",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "Shared type definitions for the db-semantic-planner ecosystem",
5
5
  "author": "Olivier Orabona <oorabona@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/bigint-js-read.ts","../src/column-list.ts","../src/intent/expression-intent.ts","../src/intent/recursive-intent.ts","../src/intent/select-function-allowlist.ts","../src/intent/type-guards.ts","../src/intent/where-intent.ts","../src/json-agg-order-key.ts","../src/loaded-schema.ts","../src/output-provenance.ts","../src/relation-key-fields.ts"],"sourcesContent":["import type { ColumnJsReadType } from './model-ir.js';\n\nexport interface BigintJsReadConversionContext {\n\treadonly table: string;\n\treadonly column: string;\n\treadonly outputKey: string;\n}\n\nconst MAX_SAFE_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);\nconst MIN_SAFE_BIGINT = BigInt(Number.MIN_SAFE_INTEGER);\nconst INTEGER_STRING_RE = /^[+-]?\\d+$/;\n\nfunction formatValue(value: unknown): string {\n\tif (typeof value === 'string') return `\"${value}\"`;\n\tif (typeof value === 'bigint') return `${value.toString()}n`;\n\tif (typeof value === 'number' || typeof value === 'boolean') {\n\t\treturn String(value);\n\t}\n\tif (value === null) return 'null';\n\tif (value === undefined) return 'undefined';\n\ttry {\n\t\treturn JSON.stringify(value) ?? String(value);\n\t} catch {\n\t\treturn String(value);\n\t}\n}\n\nfunction conversionError(\n\tvalue: unknown,\n\ttarget: Exclude<ColumnJsReadType, 'string'>,\n\tctx: BigintJsReadConversionContext,\n\treason: string,\n): RangeError {\n\treturn new RangeError(\n\t\t`Cannot convert PostgreSQL bigint column \"${ctx.table}.${ctx.column}\" output key \"${ctx.outputKey}\" value ${formatValue(value)} to ${target}: ${reason}.`,\n\t);\n}\n\nfunction toStrictBigInt(\n\tvalue: unknown,\n\ttarget: Exclude<ColumnJsReadType, 'string'>,\n\tctx: BigintJsReadConversionContext,\n): bigint {\n\tif (typeof value === 'bigint') return value;\n\tif (typeof value === 'string') {\n\t\tconst trimmed = value.trim();\n\t\tif (!INTEGER_STRING_RE.test(trimmed)) {\n\t\t\tthrow conversionError(\n\t\t\t\tvalue,\n\t\t\t\ttarget,\n\t\t\t\tctx,\n\t\t\t\t'expected an integer string, bigint, or safe integer number',\n\t\t\t);\n\t\t}\n\t\treturn BigInt(trimmed);\n\t}\n\tif (typeof value === 'number') {\n\t\tif (!Number.isSafeInteger(value)) {\n\t\t\tthrow conversionError(\n\t\t\t\tvalue,\n\t\t\t\ttarget,\n\t\t\t\tctx,\n\t\t\t\t'expected a safe integer number',\n\t\t\t);\n\t\t}\n\t\treturn BigInt(value);\n\t}\n\tthrow conversionError(\n\t\tvalue,\n\t\ttarget,\n\t\tctx,\n\t\t'expected an integer string, bigint, or safe integer number',\n\t);\n}\n\nexport function convertBigintJsReadValue(\n\tvalue: unknown,\n\tjs: ColumnJsReadType,\n\tctx: BigintJsReadConversionContext,\n): unknown {\n\tif (value === null || value === undefined) return value;\n\n\tswitch (js) {\n\t\tcase 'string':\n\t\t\treturn value;\n\t\tcase 'bigint':\n\t\t\treturn toStrictBigInt(value, 'bigint', ctx);\n\t\tcase 'number': {\n\t\t\tconst bigintValue = toStrictBigInt(value, 'number', ctx);\n\t\t\tif (bigintValue > MAX_SAFE_BIGINT || bigintValue < MIN_SAFE_BIGINT) {\n\t\t\t\tthrow conversionError(\n\t\t\t\t\tvalue,\n\t\t\t\t\t'number',\n\t\t\t\t\tctx,\n\t\t\t\t\t\"outside Number.MAX_SAFE_INTEGER; use js:'bigint' or omit js\",\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn Number(bigintValue);\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid bigint js read type '${String(js)}' for PostgreSQL bigint column \"${ctx.table}.${ctx.column}\".`,\n\t\t\t);\n\t}\n}\n","/**\n * Shared relation-key normalizer.\n *\n * Relation metadata accepts either a single column or a composite column list.\n * Readers should normalize once and keep the full list instead of degrading to\n * the first column.\n */\nexport type ColumnListInput = string | readonly string[] | undefined;\n\nexport function toColumnList(key: ColumnListInput): readonly string[] {\n\tif (key === undefined) return [];\n\treturn typeof key === 'string' ? [key] : key;\n}\n","/**\n * @module intent/expression-intent\n * Expression intent types for computed/derived values in SELECT.\n */\n\nimport type { QueryIntent } from './query-intent.js';\nimport type { AggregateFunction } from './select-intent.js';\nimport type { WhereIntent } from './where-intent.js';\n\n// ============================================================================\n// Expression Intents - Computed/Derived Values\n// ============================================================================\n\n/**\n * COALESCE expression: returns first non-null value from a list of fields\n * @example { kind: 'coalesce', fields: ['name_fr', 'name_en'], as: 'display_name' }\n * → COALESCE(name_fr, name_en) AS display_name\n */\nexport interface CoalesceExpressionIntent {\n\treadonly kind: 'coalesce';\n\t/** Fields to check in order (first non-null wins) */\n\treadonly fields: readonly string[];\n\t/** Required alias for the result column */\n\treadonly as: string;\n}\n\n/**\n * Raw SQL expression (escape hatch for advanced use cases)\n * @example { kind: 'raw', sql: 'NOW()', as: 'current_time' }\n * → NOW() AS current_time\n * @warning Use sparingly - bypasses type safety and SQL injection protection\n */\nexport interface RawExpressionIntent {\n\treadonly kind: 'raw';\n\t/** Raw SQL fragment (must be safe, no user input!) */\n\treadonly sql: string;\n\t/** Required alias for the result column */\n\treadonly as: string;\n}\n\n/**\n * Simple column expression: just a column reference, optionally aliased\n * Used by NQL when a column is selected without modification\n * @example { kind: 'column', column: 'name' }\n * → SELECT \"name\"\n * @example { kind: 'column', column: 'name', as: 'userName' }\n * → SELECT \"name\" AS \"userName\"\n */\nexport interface ColumnExpressionIntent {\n\treadonly kind: 'column';\n\t/** Column name to select */\n\treadonly column: string;\n\t/** Optional alias for the result column */\n\treadonly as?: string;\n}\n\n/**\n * Column alias expression: simple column reference with alias\n * Represents an aliased column as structured intent for dialect compilers\n * @example { kind: 'columnAlias', column: 'name', alias: 'userName' }\n * → SELECT \"name\" AS \"userName\"\n */\nexport interface ColumnAliasIntent {\n\treadonly kind: 'columnAlias';\n\t/** Column name to select */\n\treadonly column: string;\n\t/** Alias for the result column */\n\treadonly alias: string;\n}\n\n/**\n * Relation column expression: select a column from a related table\n * Auto-creates JOIN via include mechanism and selects with custom alias\n * @example { kind: 'relationColumn', relation: 'category', column: 'name', as: 'categoryName' }\n * → SELECT t1.\"name\" AS \"categoryName\" (where t1 is the joined category table)\n * @example { kind: 'relationColumn', relation: 'category.parent', column: 'name', as: 'parentCategoryName' }\n * → Multi-level join: products → category → parent, select parent.name\n */\nexport interface RelationColumnIntent {\n\treadonly kind: 'relationColumn';\n\t/** Relation path to traverse (dot-separated for multi-level) */\n\treadonly relation: string;\n\t/** Column name to select from the target relation */\n\treadonly column: string;\n\t/** Alias for the result column */\n\treadonly as: string;\n}\n\n/**\n * Aggregate expression intent for SELECT expressions\n * @example { kind: 'aggregate', function: 'count', as: 'total' } → COUNT(*) AS total\n * @example { kind: 'aggregate', function: 'sum', field: 'price', as: 'total_price' } → SUM(price) AS total_price\n * @example { kind: 'aggregate', function: 'count', field: 'id', distinct: true, as: 'unique_count' }\n * → COUNT(DISTINCT id) AS unique_count\n */\nexport interface AggregateExpressionIntent {\n\treadonly kind: 'aggregate';\n\t/** Aggregate function */\n\treadonly function: AggregateFunction;\n\t/** Field to aggregate (or '*' for count) */\n\treadonly field: string | '*';\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n\t/** Whether to apply DISTINCT to the aggregate */\n\treadonly distinct?: boolean | undefined;\n\t/** Extra arguments for multi-arg aggregates like string_agg(field, separator) */\n\treadonly extraArgs?: readonly unknown[] | undefined;\n\t/** FILTER (WHERE ...) clause for conditional aggregation */\n\treadonly filter?: WhereIntent | undefined;\n}\n\n/**\n * Pseudo-column traversal keyword for self-referential relations.\n * Used by NQL to traverse hierarchical/tree structures.\n *\n * Default keywords: 'parent', 'child', 'ascendant', 'descendant'.\n * Custom keywords are supported via schema configuration\n * (e.g., 'manager', 'managee' via parentRole/childRole).\n */\nexport type PseudoColumnTraversal = string;\n\n/**\n * Pseudo-column expression intent for self-referential traversal.\n * Enables access to columns on related rows in hierarchical structures.\n *\n * @example { kind: 'pseudoColumn', traversal: 'parent', targetColumn: 'name', as: 'parent.name' }\n * → SELECT parent_row.name AS \"parent.name\" via CTE join\n * @example { kind: 'pseudoColumn', traversal: 'ascendant', targetColumn: 'title', as: 'ancestor_title' }\n * → Recursive CTE to find all ancestors, return their title column\n */\nexport interface PseudoColumnExpressionIntent {\n\treadonly kind: 'pseudoColumn';\n\t/** Traversal type: single-hop (parent/child) or recursive (ascendant/descendant) */\n\treadonly traversal: PseudoColumnTraversal;\n\t/** The column to access on the target row(s) */\n\treadonly targetColumn: string;\n\t/** Alias for result column (required) */\n\treadonly as: string;\n\t/** Optional bounded depth for ascendant[N] / descendant[N] syntax */\n\treadonly depth?: number;\n\t/** Custom role name for multi-FK tables (e.g., 'manager' in manager.ascendant) */\n\treadonly role?: string;\n\t/**\n\t * Chained traversals for multi-hop navigation (e.g., parent.parent.name → ['parent', 'parent']).\n\t * When present, overrides single `traversal` field. Each element generates a successive self-join.\n\t */\n\treadonly traversals?: readonly PseudoColumnTraversal[];\n}\n\n/**\n * Generic function expression (e.g., now(), upper(name), coalesce(a, b)).\n * Used for SQL functions that are not aggregates.\n */\nexport interface FunctionExpressionIntent {\n\treadonly kind: 'function';\n\t/** Function name (e.g., 'upper', 'now', 'coalesce') */\n\treadonly name: string;\n\t/** Function arguments */\n\treadonly args: readonly unknown[];\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n}\n\n/**\n * Scalar subquery in SELECT clause.\n * Produces a single value from a nested query.\n */\nexport interface SubqueryExpressionIntent {\n\treadonly kind: 'subquery';\n\t/** The nested query */\n\treadonly query: QueryIntent;\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n}\n\n/**\n * Arithmetic expression (e.g., price * quantity).\n * Binary operation with left operand, operator, and right operand.\n */\nexport interface ArithmeticExpressionIntent {\n\treadonly kind: 'arithmetic';\n\t/** Left operand (column name or value) */\n\treadonly left: string | number | unknown;\n\t/** Arithmetic operator */\n\treadonly operator: '+' | '-' | '*' | '/' | '%';\n\t/** Right operand (column name or value) */\n\treadonly right: string | number | unknown;\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n}\n\n/**\n * Literal value expression: string, number, boolean, or null.\n * Used in CASE THEN/ELSE clauses for constant values.\n */\nexport interface LiteralExpressionIntent {\n\treadonly kind: 'literal';\n\t/** The literal value */\n\treadonly value: string | number | boolean | null;\n\t/** Optional alias */\n\treadonly as?: string | undefined;\n}\n\n/**\n * Comparison expression: left operator right.\n * Used in CASE WHEN conditions.\n */\nexport interface ComparisonExpressionIntent {\n\treadonly kind: 'comparison';\n\t/** Left side column reference */\n\treadonly column: string;\n\t/** Comparison operator */\n\treadonly operator: '=' | '!=' | '<' | '>' | '<=' | '>=' | 'like';\n\t/** Right side value */\n\treadonly value: unknown;\n}\n\n/**\n * CASE expression: conditional logic in SELECT.\n * CASE WHEN condition THEN result [WHEN ...] [ELSE default] END\n */\nexport interface CaseExpressionIntent {\n\treadonly kind: 'case';\n\t/** Array of WHEN-THEN pairs */\n\treadonly when: ReadonlyArray<{\n\t\treadonly condition: WhereIntent;\n\t\treadonly result: ExpressionIntent;\n\t}>;\n\t/** Optional ELSE clause */\n\treadonly else?: ExpressionIntent | undefined;\n\t/** Alias for result column */\n\treadonly as?: string | undefined;\n}\n\n// ============================================================================\n// JSON/JSONB Operators (E13)\n// ============================================================================\n\n/**\n * JSON path extraction: col->'key' or col->>'key' (chained paths supported).\n * Also used for function notation: json_extract(col, 'key'), json_extract_text(col, 'key').\n */\nexport interface JsonExtractIntent {\n\treadonly kind: 'jsonExtract';\n\treadonly field: string;\n\treadonly path: readonly (string | ParamIntent)[];\n\t/** 'json' = returns JSON value (->), 'text' = returns text (->>) */\n\treadonly mode: 'json' | 'text';\n\treadonly as?: string | undefined;\n}\n\n/**\n * JSON containment: col @> value (contains) or col <@ value (contained by).\n */\nexport interface JsonContainsIntent {\n\treadonly kind: 'jsonContains';\n\treadonly field: string;\n\treadonly value: unknown;\n\t/** true = <@ (contained by), false = @> (contains) */\n\treadonly reversed: boolean;\n}\n\n/**\n * JSON key existence: col ? 'key'.\n */\nexport interface JsonExistsIntent {\n\treadonly kind: 'jsonExists';\n\treadonly field: string;\n\treadonly key: string;\n}\n\n/**\n * JSON path extraction with array path: col #> '{a,b}' or col #>> '{a,b}'.\n */\nexport interface JsonPathExtractIntent {\n\treadonly kind: 'jsonPathExtract';\n\treadonly field: string;\n\t/** PostgreSQL JSON path segments. Bound as one text[] parameter by adapters. */\n\treadonly path: readonly (string | ParamIntent)[];\n\t/** 'json' = returns JSON (#>), 'text' = returns text (#>>) */\n\treadonly mode: 'json' | 'text';\n\treadonly as?: string | undefined;\n}\n\n/** Custom binary operator expression (e.g., <=> for pgvector) */\nexport interface CustomOpExpressionIntent {\n\treadonly kind: 'customOp';\n\treadonly operator: string;\n\treadonly left: ExpressionIntent;\n\treadonly right: ExpressionIntent;\n\treadonly as?: string;\n}\n\n/** Custom function call (e.g., paradedb.score) */\n/** Represents a single ORDER BY entry inside an aggregate function. */\nexport interface AggOrderByArg {\n\t/** Discriminator to distinguish from regular expression args. */\n\treadonly __aggOrderBy: true;\n\treadonly field: string;\n\treadonly direction: 'asc' | 'desc';\n}\n\nexport interface CustomFnExpressionIntent {\n\treadonly kind: 'customFn';\n\treadonly name: string;\n\treadonly args: readonly ExpressionIntent[];\n\treadonly as?: string;\n\t/** Apply DISTINCT to the call's arguments (e.g. count(DISTINCT id)) */\n\treadonly distinct?: boolean;\n\t/** FILTER (WHERE ...) clause for conditional aggregation */\n\treadonly filter?: WhereIntent | undefined;\n\t/** ORDER BY clause for ordered aggregates (e.g. array_agg(x ORDER BY y)) */\n\treadonly aggOrderBy?: readonly AggOrderByArg[] | undefined;\n}\n\n/** Column reference in custom expressions */\nexport interface RefExpressionIntent {\n\treadonly kind: 'ref';\n\treadonly column: string;\n}\n\n/**\n * Public bound-parameter node.\n *\n * A value that originated from an NQL named parameter or template binding is\n * represented explicitly in the public IntentAST. The inner value is opaque:\n * consumers must bind it as a value and must not inspect its shape to decide\n * whether it is query structure.\n *\n * @public\n */\nexport interface ParamExpressionIntent {\n\treadonly kind: 'param';\n\treadonly value: unknown;\n\t/** Optional alias when used as a SELECT expression. */\n\treadonly as?: string | undefined;\n}\n\n/** @public */\nexport type ParamIntent = ParamExpressionIntent;\n\n/** Single-level only — never recurse into .value; the inner bound value is opaque user data. @public */\nexport function isParamIntent(value: unknown): value is ParamIntent {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(value as Record<string, unknown>).kind === 'param' &&\n\t\t'value' in (value as Record<string, unknown>)\n\t);\n}\n\n/** Type cast expression */\nexport interface CastExpressionIntent {\n\treadonly kind: 'cast';\n\treadonly expr: ExpressionIntent;\n\treadonly typeName: string;\n}\n\n/** Named argument in a function call: name => value */\nexport interface NamedArgExpressionIntent {\n\treadonly kind: 'namedArg';\n\treadonly name: string;\n\treadonly value: ExpressionIntent;\n}\n\n/** Star/wildcard expression (*) — used in COUNT(*), SELECT *, etc. */\nexport interface StarExpressionIntent {\n\treadonly kind: 'star';\n}\n\n/** PostgreSQL ARRAY constructor: ARRAY[item1, item2, ...] */\nexport interface ArrayExpressionIntent {\n\treadonly kind: 'array';\n\treadonly elements: readonly ExpressionIntent[];\n\treadonly as?: string;\n}\n\n/** Unary operator expression (e.g., NOT, -, ~) */\nexport interface UnaryExpressionIntent {\n\treadonly kind: 'unary';\n\treadonly operator: string;\n\treadonly operand: ExpressionIntent;\n\treadonly as?: string;\n}\n\n/**\n * Expression intent union type - computed/derived values in SELECT\n * Extensible for future expression types\n */\nexport type ExpressionIntent =\n\t| ColumnExpressionIntent\n\t| CoalesceExpressionIntent\n\t| RawExpressionIntent\n\t| ColumnAliasIntent\n\t| RelationColumnIntent\n\t| WindowIntent\n\t| AggregateExpressionIntent\n\t| PseudoColumnExpressionIntent\n\t| FunctionExpressionIntent\n\t| SubqueryExpressionIntent\n\t| ArithmeticExpressionIntent\n\t| LiteralExpressionIntent\n\t| ComparisonExpressionIntent\n\t| CaseExpressionIntent\n\t| JsonExtractIntent\n\t| JsonContainsIntent\n\t| JsonExistsIntent\n\t| JsonPathExtractIntent\n\t| CustomOpExpressionIntent\n\t| CustomFnExpressionIntent\n\t| RefExpressionIntent\n\t| ParamExpressionIntent\n\t| CastExpressionIntent\n\t| UnaryExpressionIntent\n\t| NamedArgExpressionIntent\n\t| StarExpressionIntent\n\t| ArrayExpressionIntent;\n\n// ============================================================================\n// Window Functions (P3-A)\n// ============================================================================\n\n/**\n * Window function types for OVER clause analytics.\n * - Ranking: row_number, rank, dense_rank (no field required)\n * - Aggregate: sum, avg, count, min, max (field required)\n * - Offset: lag, lead (field required, offset/default deferred to P3+)\n */\nexport type WindowFunction =\n\t| 'row_number'\n\t| 'rank'\n\t| 'dense_rank'\n\t| 'sum'\n\t| 'avg'\n\t| 'count'\n\t| 'min'\n\t| 'max'\n\t| 'lag'\n\t| 'lead';\n\n/**\n * Order specification for window OVER clause.\n */\nexport interface WindowOrderBy {\n\treadonly field: string;\n\treadonly direction?: 'asc' | 'desc';\n}\n\n/**\n * Window function intent for analytics over partitions.\n * Produces SQL like: ROW_NUMBER() OVER (PARTITION BY x ORDER BY y) AS alias\n *\n * @example Row numbering\n * {\n * kind: 'window',\n * function: 'row_number',\n * alias: 'rn',\n * over: { orderBy: [{ field: 'created_at', direction: 'desc' }] }\n * }\n *\n * @example Running total\n * {\n * kind: 'window',\n * function: 'sum',\n * field: 'amount',\n * alias: 'running_total',\n * over: { partitionBy: ['account_id'], orderBy: [{ field: 'date' }] }\n * }\n */\n/**\n * Window function intent (ranking branch): ROW_NUMBER / RANK / DENSE_RANK — no field required.\n *\n * @example\n * { kind: 'window', function: 'row_number', alias: 'rn', over: { orderBy: [{ field: 'created_at', direction: 'desc' }] } }\n */\nexport interface RankingWindowIntent {\n\treadonly kind: 'window';\n\treadonly function: RankingWindowFunction;\n\treadonly field?: never;\n\t/** Result column alias (required) */\n\treadonly alias: string;\n\treadonly offset?: never;\n\treadonly defaultValue?: never;\n\t/** OVER clause specification */\n\treadonly over: {\n\t\treadonly partitionBy?: readonly string[] | undefined;\n\t\treadonly orderBy?: readonly WindowOrderBy[] | undefined;\n\t};\n}\n\n/**\n * Window function intent (aggregate branch): SUM / AVG / COUNT / MIN / MAX — field required.\n *\n * @example\n * { kind: 'window', function: 'sum', field: 'amount', alias: 'running_total', over: { partitionBy: ['account_id'] } }\n */\n/**\n * Window function intent (aggregate branch): SUM / AVG / COUNT / MIN / MAX.\n * Field is required for sum/avg/min/max; COUNT omits field to produce COUNT(*) OVER (...).\n *\n * @example SUM with field\n * { kind: 'window', function: 'sum', field: 'amount', alias: 'running_total', over: { partitionBy: ['account_id'] } }\n * @example COUNT(*)\n * { kind: 'window', function: 'count', alias: 'total', over: {} }\n */\nexport interface AggregateWindowIntent {\n\treadonly kind: 'window';\n\treadonly function: AggregateWindowFunction;\n\t/**\n\t * Field to aggregate over.\n\t * Required for sum/avg/min/max. Omit (or undefined) for COUNT(*) OVER (...).\n\t */\n\treadonly field?: string | undefined;\n\t/** Result column alias (required) */\n\treadonly alias: string;\n\treadonly offset?: never;\n\treadonly defaultValue?: never;\n\t/** OVER clause specification */\n\treadonly over: {\n\t\treadonly partitionBy?: readonly string[] | undefined;\n\t\treadonly orderBy?: readonly WindowOrderBy[] | undefined;\n\t};\n}\n\n/**\n * Window function intent (offset branch): LAG / LEAD — field required, offset optional.\n *\n * @example\n * { kind: 'window', function: 'lag', field: 'salary', alias: 'prev_salary', over: { orderBy: [{ field: 'date', direction: 'asc' }] } }\n */\nexport interface OffsetWindowIntent {\n\treadonly kind: 'window';\n\treadonly function: OffsetWindowFunction;\n\t/** Field to access from the offset row (required for lag/lead) */\n\treadonly field: string;\n\t/** Result column alias (required) */\n\treadonly alias: string;\n\t/** Offset for lag/lead (default: 1 in PostgreSQL) */\n\treadonly offset?: number | undefined;\n\t/** Default value for lag/lead when row doesn't exist */\n\treadonly defaultValue?: unknown;\n\t/** OVER clause specification */\n\treadonly over: {\n\t\treadonly partitionBy?: readonly string[] | undefined;\n\t\treadonly orderBy?: readonly WindowOrderBy[] | undefined;\n\t};\n}\n\n/**\n * Window function intent for analytics over partitions.\n * Discriminated by function group:\n * - RankingWindowIntent: row_number / rank / dense_rank (no field)\n * - AggregateWindowIntent: sum / avg / count / min / max (field required)\n * - OffsetWindowIntent: lag / lead (field required, offset optional)\n */\nexport type WindowIntent =\n\t| RankingWindowIntent\n\t| AggregateWindowIntent\n\t| OffsetWindowIntent;\n\n/**\n * Ranking window functions (no field required)\n */\nexport type RankingWindowFunction = 'row_number' | 'rank' | 'dense_rank';\n\n/**\n * Aggregate window functions (field required)\n */\nexport type AggregateWindowFunction = 'sum' | 'avg' | 'count' | 'min' | 'max';\n\n/**\n * Offset window functions (field required, offset/default deferred)\n */\nexport type OffsetWindowFunction = 'lag' | 'lead';\n","/**\n * @module intent/recursive-intent\n * Recursive CTE intent types for hierarchical data traversal (RFC-001).\n */\n\nimport type { OrderByIntent } from './include-intent.js';\nimport type { WhereIntent } from './where-intent.js';\n\n// ============================================================================\n// Recursive CTE Intent - Hierarchical Data Traversal (RFC-001)\n// ============================================================================\n\n/**\n * Node ID expression for recursive CTE anchor.\n * Used to define the join key for recursive traversal.\n */\nexport type RecursiveNodeIdExpr =\n\t| { readonly kind: 'column'; readonly name: string; readonly as?: string }\n\t| {\n\t\t\treadonly kind: 'literal';\n\t\t\treadonly value: unknown;\n\t\t\treadonly as?: string;\n\t }\n\t| {\n\t\t\treadonly kind: 'binary';\n\t\t\treadonly left: RecursiveNodeIdExpr;\n\t\t\treadonly op: string;\n\t\t\treadonly right: RecursiveNodeIdExpr;\n\t\t\treadonly as?: string;\n\t };\n\n/**\n * Get the alias for a node ID expression.\n * Used by both planner and compiler for consistent CTE column naming.\n *\n * @param expr - The node ID expression\n * @returns The alias to use (explicit alias, column name, or 'node_id' fallback)\n */\nexport function getNodeIdAlias(expr: RecursiveNodeIdExpr): string {\n\tif (expr.as) return expr.as;\n\tif (expr.kind === 'column') return expr.name;\n\tif (expr.kind === 'literal') return 'node_id';\n\t// Binary expression needs explicit alias\n\treturn 'node_id';\n}\n\n/**\n * Adjacency-list traversal (self-referential table).\n * Example: roles.parent_id → roles.id\n */\nexport interface AdjacencyTraversal {\n\treadonly kind: 'adjacency';\n\n\t/** Table containing hierarchical data */\n\treadonly nodeTable: string;\n\n\t/** Primary key column (e.g., \"id\") */\n\treadonly nodeId: string;\n\n\t/** Foreign key pointing to parent (e.g., \"parent_id\") */\n\treadonly parentId: string;\n\n\t/** Traversal direction */\n\treadonly direction: 'descendants' | 'ancestors';\n\n\t/** Filter applied to each step (e.g., active = true) */\n\treadonly stepWhere?: WhereIntent;\n}\n\n/**\n * Edge-table traversal (separate join table).\n * Example: role_inheritance(from_role_id, to_role_id)\n */\nexport interface EdgeTableTraversal {\n\treadonly kind: 'edge-table';\n\n\t/** Node table containing hierarchical data */\n\treadonly nodeTable: string;\n\n\t/** Edge table containing relationships */\n\treadonly edgeTable: string;\n\n\t/** Primary key column in node table (e.g., \"id\") */\n\treadonly nodeId: string;\n\n\t/** Source column in edge table (e.g., \"from_role_id\") */\n\treadonly edgeFrom: string;\n\n\t/** Target column in edge table (e.g., \"to_role_id\") */\n\treadonly edgeTo: string;\n\n\t/** Traversal direction */\n\treadonly direction: 'out' | 'in' | 'both';\n\n\t/** Filter on edges (e.g., relationship_type = 'inheritance') */\n\treadonly edgeWhere?: WhereIntent;\n\n\t/** Filter on nodes (e.g., active = true) */\n\treadonly nodeWhere?: WhereIntent;\n\n\t/** Edge attributes to include in result */\n\treadonly edgeSelect?: readonly string[];\n\n\t/**\n\t * Hint for edge storage semantics (only affects `direction: 'both'`).\n\t *\n\t * - 'unknown' (default): Edges may exist in both directions (A→B and B→A).\n\t * Uses UNION (distinct) to avoid duplicates. Safe but slower.\n\t * - 'directed-only': Caller guarantees edges are stored once only.\n\t * Uses UNION ALL for performance. INCORRECT if duplicates exist.\n\t */\n\treadonly edgeStorageHint?: 'unknown' | 'directed-only';\n}\n\n/**\n * Custom traversal for complex cases (P2 escape hatch).\n */\nexport interface CustomTraversal {\n\treadonly kind: 'custom';\n\t/** Explicit step query builder - reserved for P2 */\n\treadonly stepBuilder?: unknown;\n}\n\n/**\n * Recursive traversal type union.\n */\nexport type RecursiveTraversal =\n\t| AdjacencyTraversal\n\t| EdgeTableTraversal\n\t| CustomTraversal;\n\n/**\n * Tracking options for recursive traversal.\n */\nexport interface RecursiveTrackOptions {\n\t/** Depth counter (starts at 0) */\n\treadonly depth?: {\n\t\treadonly as?: string; // Default: \"depth\"\n\t};\n\n\t/** Path tracking for cycle detection + debugging */\n\treadonly path?: {\n\t\t/** Columns to trace in path (default: nodeId only) */\n\t\treadonly by?: 'nodeId' | readonly string[];\n\t\t/** Result column name (default: \"path\") */\n\t\treadonly as?: string;\n\t\t/** Storage strategy (default: 'array' for PostgreSQL, 'string' for others) */\n\t\treadonly strategy?: 'array' | 'string';\n\t\t/** Separator for string strategy (default: '/') */\n\t\treadonly separator?: string;\n\t};\n\n\t/** Cycle detection marker */\n\treadonly isCycle?: {\n\t\treadonly as?: string; // Default: \"is_cycle\"\n\t};\n}\n\n/**\n * Join clause for CTE emit composition.\n * Allows joining the CTE result with additional tables for final projection.\n */\nexport interface EmitJoinClause {\n\t/** Table to join with */\n\treadonly table: string;\n\n\t/** Join type (default: 'inner') */\n\treadonly type?: 'inner' | 'left';\n\n\t/** Alias for this table (auto-generated if not provided) */\n\treadonly as?: string;\n\n\t/** Join condition */\n\treadonly on: {\n\t\t/** Column from CTE or previous joined table */\n\t\treadonly left: string;\n\t\t/** Column from this table */\n\t\treadonly right: string;\n\t};\n\n\t/** Columns to select from this table */\n\treadonly select?: readonly (\n\t\t| string\n\t\t| { readonly column: string; readonly as: string }\n\t)[];\n}\n\n/**\n * Emit options for recursive CTE final projection.\n */\nexport interface RecursiveEmitOptions {\n\t/** Fields to select from CTE */\n\treadonly select?: readonly string[];\n\t/** Filter on generated rows */\n\treadonly where?: WhereIntent;\n\t/** Ordering */\n\treadonly orderBy?: readonly OrderByIntent[];\n\t/** Join CTE result with additional tables for composition */\n\treadonly joinWith?: readonly EmitJoinClause[];\n\t/** Apply DISTINCT to final result */\n\treadonly distinct?: boolean;\n}\n\n/**\n * PostgreSQL-specific options for recursive CTE (capability-gated).\n */\nexport interface RecursiveAdvancedOptions {\n\t/**\n\t * Cycle detection strategy (adapter-specific implementation).\n\t * - 'error': Throw on cycle detection\n\t * - 'stop': Stop traversal at cycle (prune branch)\n\t * - 'mark': Add is_cycle column to results\n\t *\n\t * PostgreSQL 14+ uses native CYCLE clause.\n\t * Other adapters may use application-level detection.\n\t */\n\treadonly cycle?: 'error' | 'stop' | 'mark';\n\n\t/**\n\t * Traversal search order (adapter-specific implementation).\n\t * - 'depth': Depth-first search order\n\t * - 'breadth': Breadth-first search order\n\t *\n\t * PostgreSQL 14+ uses native SEARCH clause.\n\t * Other adapters may use ORDER BY on depth column.\n\t */\n\treadonly search?: 'depth' | 'breadth';\n}\n\n/**\n * Deduplication strategy for recursive CTE.\n *\n * - 'none': No dedup. May return same node multiple times via different paths.\n * Fastest. Use when you need all paths or when graph is known to be a tree.\n *\n * - 'final': One row per nodeId in final output.\n * Implemented via `DISTINCT ON (nodeId)` (PostgreSQL) or\n * `ROW_NUMBER() OVER (PARTITION BY nodeId)` fallback.\n * ⚠️ NOT the same as `query.distinct()` which dedupes on entire row!\n *\n * Note: 'global' (UNION instead of UNION ALL) was considered but not implemented.\n * 'final' provides the same end result with better performance characteristics.\n */\nexport type RecursiveDedupe = 'none' | 'final';\n\n/**\n * Recursive CTE intent for hierarchical data traversal.\n *\n * Key invariant: anchor and step MUST produce identical column shape.\n * The planner validates this and auto-injects nodeIdExpr.\n *\n * @see RFC-001 for detailed specification\n */\nexport interface RecursiveIntent {\n\treadonly type: 'recursive';\n\n\t/** CTE name for the recursive query */\n\treadonly cteName: string;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// START (anchor/seed)\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\treadonly start: {\n\t\t/** Source table for anchor query */\n\t\treadonly from: string;\n\n\t\t/** Filter for seed rows (e.g., where id = $userId) */\n\t\treadonly where?: WhereIntent;\n\n\t\t/**\n\t\t * REQUIRED: Expression for node ID. Auto-injected into select.\n\t\t * This ensures the recursive join always has the key column.\n\t\t */\n\t\treadonly nodeIdExpr: RecursiveNodeIdExpr;\n\n\t\t/** Additional fields to select (beyond nodeId) */\n\t\treadonly select?: readonly string[];\n\t};\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// TRAVERSAL\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Traversal configuration (adjacency-list or edge-table) */\n\treadonly traversal: RecursiveTraversal;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// TRACKING (system columns)\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Tracking options for depth, path, and cycle detection */\n\treadonly track?: RecursiveTrackOptions;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// SAFETY\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Maximum recursion depth (REQUIRED) */\n\treadonly maxDepth: number;\n\n\t/** Maximum rows (optional safety limit) */\n\treadonly maxRows?: number;\n\n\t/** Deduplication strategy */\n\treadonly dedupe?: RecursiveDedupe;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// EMIT (final projection)\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Final projection options */\n\treadonly emit?: RecursiveEmitOptions;\n\n\t// ─────────────────────────────────────────────────────────────────────────\n\t// ADVANCED OPTIONS (capability-gated, adapter-specific implementation)\n\t// ─────────────────────────────────────────────────────────────────────────\n\n\t/** Advanced recursive options (cycle detection, search order) */\n\treadonly advancedOptions?: RecursiveAdvancedOptions;\n}\n","/**\n * NQL-origin SELECT function allowlist.\n *\n * This is the shared security gate for function names that originated in NQL\n * SELECT text and later cross the IntentAST-to-SQL adapter boundary. Extend it\n * only after adding compiler and adapter coverage proving the function is\n * intentionally supported for NQL-origin SELECT projections.\n */\nexport const NQL_SELECT_AGGREGATE_FUNCTIONS = [\n\t'count',\n\t'sum',\n\t'avg',\n\t'min',\n\t'max',\n] as const;\n\nexport const NQL_SELECT_JSON_FUNCTIONS = [\n\t'json_extract',\n\t'json_extract_text',\n\t'json_path',\n\t'json_path_text',\n] as const;\n\nexport const NQL_SELECT_VALUE_FUNCTIONS = [\n\t'coalesce',\n\t'lower',\n\t'now',\n\t'round',\n\t'upper',\n] as const;\n\nexport const NQL_SELECT_SCALAR_FUNCTIONS = [\n\t...NQL_SELECT_AGGREGATE_FUNCTIONS,\n\t...NQL_SELECT_JSON_FUNCTIONS,\n\t...NQL_SELECT_VALUE_FUNCTIONS,\n] as const;\n\nexport const NQL_SELECT_WINDOW_ONLY_FUNCTIONS = [\n\t'row_number',\n\t'rank',\n\t'dense_rank',\n\t'lag',\n\t'lead',\n] as const;\n\nexport const NQL_SELECT_WINDOW_FUNCTIONS = [\n\t...NQL_SELECT_WINDOW_ONLY_FUNCTIONS,\n\t'count',\n\t'sum',\n\t'avg',\n\t'min',\n\t'max',\n] as const;\n\nexport const NQL_SELECT_SCALAR_FUNCTION_ALLOWLIST: ReadonlySet<string> =\n\tnew Set(NQL_SELECT_SCALAR_FUNCTIONS);\n\nexport const NQL_SELECT_WINDOW_FUNCTION_ALLOWLIST: ReadonlySet<string> =\n\tnew Set(NQL_SELECT_WINDOW_FUNCTIONS);\n\nexport const NQL_SELECT_FUNCTION_ALLOWLIST: ReadonlySet<string> = new Set([\n\t...NQL_SELECT_SCALAR_FUNCTIONS,\n\t...NQL_SELECT_WINDOW_FUNCTIONS,\n]);\n\ntype NqlSelectScalarFunction = (typeof NQL_SELECT_SCALAR_FUNCTIONS)[number];\ntype NqlSelectWindowFunction = (typeof NQL_SELECT_WINDOW_FUNCTIONS)[number];\n\nexport function isNqlSelectScalarFunctionAllowed(\n\tname: string,\n): name is NqlSelectScalarFunction {\n\treturn NQL_SELECT_SCALAR_FUNCTION_ALLOWLIST.has(name.toLowerCase());\n}\n\nexport function isNqlSelectFunctionAllowed(name: string): boolean {\n\treturn NQL_SELECT_FUNCTION_ALLOWLIST.has(name.toLowerCase());\n}\n\nexport function isNqlSelectWindowFunctionAllowed(\n\tname: string,\n): name is NqlSelectWindowFunction {\n\treturn NQL_SELECT_WINDOW_FUNCTION_ALLOWLIST.has(name.toLowerCase());\n}\n","/**\n * @module intent/type-guards\n * Type guard functions for all intent AST types.\n */\n\nimport type {\n\tAggregateWindowFunction,\n\tCoalesceExpressionIntent,\n\tColumnAliasIntent,\n\tExpressionIntent,\n\tOffsetWindowFunction,\n\tRankingWindowFunction,\n\tRawExpressionIntent,\n\tRelationColumnIntent,\n\tWindowFunction,\n\tWindowIntent,\n} from './expression-intent.js';\nimport type {\n\tDeleteIntent,\n\tInsertIntent,\n\tMutationIntent,\n\tUpdateIntent,\n\tUpsertIntent,\n} from './mutation-intent.js';\nimport type { QueryIntent } from './query-intent.js';\nimport type {\n\tAdjacencyTraversal,\n\tCustomTraversal,\n\tEdgeTableTraversal,\n\tRecursiveIntent,\n\tRecursiveTraversal,\n} from './recursive-intent.js';\nimport type {\n\tSelectAggregateIntent,\n\tSelectAllIntent,\n\tSelectFieldsIntent,\n\tSelectIntent,\n\tSelectWithExpressionsIntent,\n} from './select-intent.js';\nimport type {\n\tSubqueryRefIntent,\n\tWhereAndIntent,\n\tWhereAnyIntent,\n\tWhereComparisonIntent,\n\tWhereExistsIntent,\n\tWhereInIntent,\n\tWhereIntent,\n\tWhereLikeIntent,\n\tWhereNotExistsIntent,\n\tWhereNotIntent,\n\tWhereNullIntent,\n\tWhereOrIntent,\n\tWhereRangeIntent,\n\tWhereRelationFilterIntent,\n\tWhereSubqueryIntent,\n} from './where-intent.js';\n\n// ============================================================================\n// Window Intent Type Guards\n// ============================================================================\n\n/**\n * Check if an intent is a window function intent\n */\nexport function isWindowIntent(intent: unknown): intent is WindowIntent {\n\treturn (\n\t\ttypeof intent === 'object' &&\n\t\tintent !== null &&\n\t\t'kind' in intent &&\n\t\t(intent as Record<string, unknown>).kind === 'window'\n\t);\n}\n\n/**\n * Check if a window function requires a field (aggregate or offset functions)\n */\nexport function isAggregateWindowFunction(\n\tfn: WindowFunction,\n): fn is AggregateWindowFunction | OffsetWindowFunction {\n\treturn ['sum', 'avg', 'count', 'min', 'max', 'lag', 'lead'].includes(fn);\n}\n\n/**\n * Check if a window function is a ranking function (no field required)\n */\nexport function isRankingWindowFunction(\n\tfn: WindowFunction,\n): fn is RankingWindowFunction {\n\treturn ['row_number', 'rank', 'dense_rank'].includes(fn);\n}\n\n// ============================================================================\n// Where Intent Type Guards\n// ============================================================================\n\n/**\n * Check if a where intent is a comparison\n */\nexport function isWhereComparison(\n\twhere: WhereIntent,\n): where is WhereComparisonIntent {\n\treturn where.kind === 'comparison';\n}\n\n/**\n * Check if a where intent is a like filter\n */\nexport function isWhereLike(where: WhereIntent): where is WhereLikeIntent {\n\treturn where.kind === 'like';\n}\n\n/**\n * Check if a where intent is a subquery filter\n */\nexport function isWhereSubquery(\n\twhere: WhereIntent,\n): where is WhereSubqueryIntent {\n\treturn where.kind === 'subquery';\n}\n\n/**\n * Check if a value is a subquery ref (column reference in subquery)\n */\nexport function isSubqueryRef(value: unknown): value is SubqueryRefIntent {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'kind' in value &&\n\t\t(value as Record<string, unknown>).kind === 'ref'\n\t);\n}\n\n/**\n * Check if a where intent is an in filter\n */\nexport function isWhereIn(where: WhereIntent): where is WhereInIntent {\n\treturn where.kind === 'in';\n}\n\n/**\n * Check if a where intent is an any filter (= ANY($N::type[]))\n */\nexport function isWhereAny(where: WhereIntent): where is WhereAnyIntent {\n\treturn where.kind === 'any';\n}\n\n/**\n * Check if a where intent is a null filter\n */\nexport function isWhereNull(where: WhereIntent): where is WhereNullIntent {\n\treturn where.kind === 'null';\n}\n\n/**\n * Check if a where intent is a range filter (PostgreSQL range types)\n */\nexport function isWhereRange(where: WhereIntent): where is WhereRangeIntent {\n\treturn where.kind === 'range';\n}\n\n/**\n * Check if a where intent is a logical AND\n */\nexport function isWhereAnd(where: WhereIntent): where is WhereAndIntent {\n\treturn where.kind === 'and';\n}\n\n/**\n * Check if a where intent is a logical OR\n */\nexport function isWhereOr(where: WhereIntent): where is WhereOrIntent {\n\treturn where.kind === 'or';\n}\n\n/**\n * Check if a where intent is a logical NOT\n */\nexport function isWhereNot(where: WhereIntent): where is WhereNotIntent {\n\treturn where.kind === 'not';\n}\n\n/**\n * Check if a where intent is an exists filter\n */\nexport function isWhereExists(where: WhereIntent): where is WhereExistsIntent {\n\treturn where.kind === 'exists';\n}\n\n/**\n * Check if a where intent is a not exists filter\n */\nexport function isWhereNotExists(\n\twhere: WhereIntent,\n): where is WhereNotExistsIntent {\n\treturn where.kind === 'notExists';\n}\n\n/**\n * Check if a where intent is a relation filter\n */\nexport function isWhereRelationFilter(\n\twhere: WhereIntent,\n): where is WhereRelationFilterIntent {\n\treturn where.kind === 'relationFilter';\n}\n\n/**\n * Check if a where intent is any relation-based filter\n */\nexport function isWhereRelationBased(\n\twhere: WhereIntent,\n): where is\n\t| WhereExistsIntent\n\t| WhereNotExistsIntent\n\t| WhereRelationFilterIntent {\n\treturn (\n\t\twhere.kind === 'exists' ||\n\t\twhere.kind === 'notExists' ||\n\t\twhere.kind === 'relationFilter'\n\t);\n}\n\n/**\n * Check if a where intent is a logical operator (and/or/not)\n */\nexport function isWhereLogical(\n\twhere: WhereIntent,\n): where is WhereAndIntent | WhereOrIntent | WhereNotIntent {\n\treturn where.kind === 'and' || where.kind === 'or' || where.kind === 'not';\n}\n\n// ============================================================================\n// Select Intent Type Guards\n// ============================================================================\n\n/**\n * Check if a select intent selects all columns\n */\nexport function isSelectAll(select: SelectIntent): select is SelectAllIntent {\n\treturn select.type === 'all';\n}\n\n/**\n * Check if a select intent selects specific fields\n */\nexport function isSelectFields(\n\tselect: SelectIntent,\n): select is SelectFieldsIntent {\n\treturn select.type === 'fields';\n}\n\n/**\n * Check if a select intent is an aggregate select\n */\nexport function isSelectAggregate(\n\tselect: SelectIntent,\n): select is SelectAggregateIntent {\n\treturn select.type === 'aggregate';\n}\n\n/**\n * Check if a select intent has expressions\n */\nexport function isSelectWithExpressions(\n\tselect: SelectIntent,\n): select is SelectWithExpressionsIntent {\n\treturn select.type === 'expressions';\n}\n\n// ============================================================================\n// Expression Intent Type Guards\n// ============================================================================\n\n/**\n * Check if an expression is a COALESCE expression\n */\nexport function isCoalesceExpression(\n\texpr: ExpressionIntent,\n): expr is CoalesceExpressionIntent {\n\treturn expr.kind === 'coalesce';\n}\n\n/**\n * Check if an expression is a raw SQL expression\n */\nexport function isRawExpression(\n\texpr: ExpressionIntent,\n): expr is RawExpressionIntent {\n\treturn expr.kind === 'raw';\n}\n\n/**\n * Check if an expression is a column alias expression\n */\nexport function isColumnAliasExpression(\n\texpr: ExpressionIntent,\n): expr is ColumnAliasIntent {\n\treturn expr.kind === 'columnAlias';\n}\n\n/**\n * Check if an expression is a relation column expression\n */\nexport function isRelationColumnExpression(\n\texpr: ExpressionIntent,\n): expr is RelationColumnIntent {\n\treturn expr.kind === 'relationColumn';\n}\n\n// ============================================================================\n// Recursive CTE Type Guards\n// ============================================================================\n\n/**\n * Check if a traversal is adjacency-list based\n */\nexport function isAdjacencyTraversal(\n\ttraversal: RecursiveTraversal,\n): traversal is AdjacencyTraversal {\n\treturn traversal.kind === 'adjacency';\n}\n\n/**\n * Check if a traversal is edge-table based\n */\nexport function isEdgeTableTraversal(\n\ttraversal: RecursiveTraversal,\n): traversal is EdgeTableTraversal {\n\treturn traversal.kind === 'edge-table';\n}\n\n/**\n * Check if a traversal is custom\n */\nexport function isCustomTraversal(\n\ttraversal: RecursiveTraversal,\n): traversal is CustomTraversal {\n\treturn traversal.kind === 'custom';\n}\n\n/**\n * Check if an intent is a recursive CTE intent\n */\nexport function isRecursiveIntent(\n\tintent: QueryIntent | RecursiveIntent,\n): intent is RecursiveIntent {\n\treturn intent.type === 'recursive';\n}\n\n// ============================================================================\n// Mutation Intent Type Guards\n// ============================================================================\n\n/**\n * Check if an intent is an insert intent\n */\nexport function isInsertIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is InsertIntent {\n\treturn intent.type === 'insert';\n}\n\n/**\n * Check if an intent is an update intent\n */\nexport function isUpdateIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is UpdateIntent {\n\treturn intent.type === 'update';\n}\n\n/**\n * Check if an intent is a delete intent\n */\nexport function isDeleteIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is DeleteIntent {\n\treturn intent.type === 'delete';\n}\n\n/**\n * Check if an intent is an upsert intent (DX-026)\n */\nexport function isUpsertIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is UpsertIntent {\n\treturn intent.type === 'upsert';\n}\n\n/**\n * Check if an intent is any mutation intent\n */\nexport function isMutationIntent(\n\tintent: QueryIntent | RecursiveIntent | MutationIntent,\n): intent is MutationIntent {\n\treturn (\n\t\tintent.type === 'insert' ||\n\t\tintent.type === 'insert_from' ||\n\t\tintent.type === 'upsert_from' ||\n\t\tintent.type === 'update' ||\n\t\tintent.type === 'batchUpdate' ||\n\t\tintent.type === 'delete' ||\n\t\tintent.type === 'upsert'\n\t);\n}\n","/**\n * @module intent/where-intent\n * Where intent types for filter conditions.\n */\n\nimport type { ColumnListInput } from '../column-list.js';\nimport type { RangeValue } from '../shared/utils.js';\nimport type { ExpressionIntent, ParamIntent } from './expression-intent.js';\nimport type { ComparisonOperator, NullOperator } from './operators.js';\nimport type { QueryIntent } from './query-intent.js';\nimport type { RecursiveExistsOptions } from './recursive-types.js';\n\nexport type { RangeValue };\n\n// ============================================================================\n// Where Intent - Filter Conditions\n// ============================================================================\n\n/**\n * Typed field reference for cross-table column comparisons in relation filters.\n *\n * When using aliased relation filters like `some(orders as o, o.total > minOrder)`,\n * the RHS `minOrder` is a reference to the parent table's column, not a literal value.\n * FieldRef captures this distinction so the adapter can compile it as a column reference\n * instead of a parameterized value.\n *\n * @example\n * // some(rel as r, r.col > bareCol) → value: { kind: 'fieldRef', column: 'bareCol', scope: 'outer' }\n * // some(rel as r, r.col > r.otherCol) → value: { kind: 'fieldRef', column: 'otherCol', scope: 'inner' }\n * // some(a as x, some(b as y, y.f > x.g)) → value: { kind: 'fieldRef', column: 'g', scope: 'outer', alias: 'x' }\n */\nexport interface FieldRef {\n\treadonly kind: 'fieldRef';\n\treadonly column: string;\n\treadonly scope: 'inner' | 'outer';\n\t/** Named alias for outer scope (when referencing a specific outer alias in nested filters) */\n\treadonly alias?: string;\n}\n\n/**\n * Type guard for FieldRef values\n */\nexport function isFieldRef(value: unknown): value is FieldRef {\n\treturn (\n\t\tvalue !== null &&\n\t\ttypeof value === 'object' &&\n\t\t(value as Record<string, unknown>).kind === 'fieldRef'\n\t);\n}\n\nexport interface WhereComparisonIntent {\n\treadonly kind: 'comparison';\n\treadonly field: string;\n\treadonly operator: ComparisonOperator;\n\treadonly value: unknown;\n\t/** JSON path extraction before comparison (e.g., data->'key' = 'val') */\n\treadonly jsonPath?: readonly (string | ParamIntent)[];\n\t/** JSON extraction mode: 'json' = ->, 'text' = ->> */\n\treadonly jsonMode?: 'json' | 'text';\n}\n\n/**\n * String filter: field like pattern\n */\nexport interface WhereLikeIntent {\n\treadonly kind: 'like';\n\treadonly field: string;\n\treadonly pattern: string | ParamIntent;\n\t/** Case-insensitive matching */\n\treadonly caseInsensitive?: boolean;\n\t/** Escape character for LIKE pattern (e.g. '\\\\' to escape _ and %) */\n\treadonly escape?: string;\n}\n\n/**\n * Array filter: field in [values]\n */\n/**\n * Array filter (values branch): field IN (v1, v2, ...)\n */\nexport interface WhereInValueIntent {\n\treadonly kind: 'in';\n\treadonly field: string;\n\treadonly values: readonly unknown[];\n\treadonly subquery?: never;\n\treadonly not?: boolean;\n}\n\n/**\n * Array filter (subquery branch): field IN (SELECT ...)\n */\nexport interface WhereInSubqueryIntent {\n\treadonly kind: 'in';\n\treadonly field: string;\n\treadonly subquery: QueryIntent;\n\treadonly values?: never;\n\treadonly not?: boolean;\n}\n\n/**\n * Array filter: field in [values] OR field IN (subquery)\n * XOR: exactly one of `values` or `subquery` must be present.\n */\nexport type WhereInIntent = WhereInValueIntent | WhereInSubqueryIntent;\n\n/**\n * Array membership filter using PostgreSQL ANY() operator.\n * Compiles to: \"col\" = ANY($N::type[])\n */\nexport interface WhereAnyIntent {\n\treadonly kind: 'any';\n\treadonly field: string;\n\treadonly values: readonly unknown[] | ParamIntent;\n}\n\n/**\n * Operand accepted by range WHERE filters.\n * - RangeValue: for range-to-range operators (overlaps, contains, containedBy)\n * - string: ISO date/timestamp literals (e.g. '2025-01-15', '2025-01-15T08:00:00Z')\n * - number: integer/numeric point values (e.g. 50000 for salary_range @> 50000)\n * - boolean: rarely used but valid PostgreSQL range operand\n */\nexport type RangeOperand = RangeValue | string | number | boolean;\n\n/**\n * Range operator for PostgreSQL range types.\n * - overlaps: && (ranges have common points)\n * - contains: @> (range contains value or range)\n * - containedBy: <@ (range is contained by another range)\n */\nexport type RangeOperator = 'overlaps' | 'contains' | 'containedBy' | 'between';\n\n/**\n * Range filter: field overlaps/contains/containedBy range value\n * PostgreSQL range types: daterange, tsrange, tstzrange, int4range, int8range, numrange\n *\n * @example\n * // Check if booking dates overlap a period\n * { kind: 'range', field: 'dates', operator: 'overlaps', value: { lower: '2025-01-15', upper: '2025-01-20' } }\n *\n * // Check if salary range contains a value\n * { kind: 'range', field: 'salary_range', operator: 'contains', value: 50000 }\n */\n/**\n * Range filter: field overlaps/contains/containedBy range value\n * PostgreSQL range types: daterange, tsrange, tstzrange, int4range, int8range, numrange\n *\n * @example\n * // Check if booking dates overlap a period\n * { kind: 'range', field: 'dates', operator: 'overlaps', value: { lower: '2025-01-15', upper: '2025-01-20' } }\n *\n * // Check if salary range contains a value\n * { kind: 'range', field: 'salary_range', operator: 'contains', value: 50000 }\n */\nexport interface WhereRangeIntent {\n\treadonly kind: 'range';\n\treadonly field: string;\n\treadonly operator: RangeOperator;\n\t/** Operand: RangeValue for range-to-range ops, or a scalar (string | number | boolean) for point-in-range ops */\n\treadonly value: RangeOperand;\n}\n\n/**\n * Null filter: field is null / is not null\n */\nexport interface WhereNullIntent {\n\treadonly kind: 'null';\n\treadonly field: string;\n\treadonly operator: NullOperator;\n}\n\n/**\n * Logical AND: all conditions must match\n */\nexport interface WhereAndIntent {\n\treadonly kind: 'and';\n\treadonly conditions: readonly WhereIntent[];\n}\n\n/**\n * Logical OR: at least one condition must match\n */\nexport interface WhereOrIntent {\n\treadonly kind: 'or';\n\treadonly conditions: readonly WhereIntent[];\n}\n\n/**\n * Logical NOT: condition must not match\n */\nexport interface WhereNotIntent {\n\treadonly kind: 'not';\n\treadonly condition: WhereIntent;\n}\n\n/**\n * Relation exists filter: filter by existence of related records\n * Critical for Q1 golden test - enables EXISTS subquery strategy\n *\n * @example\n * // Find users who have at least one published post\n * { kind: 'exists', relation: 'posts', where: { kind: 'comparison', field: 'status', operator: 'eq', value: 'published' } }\n */\nexport interface WhereExistsIntent {\n\treadonly kind: 'exists';\n\t/** Relation name to check existence */\n\treadonly relation: string;\n\t/** Optional filter on related records */\n\treadonly where?: WhereIntent;\n\t/**\n\t * Recursive options for ancestor/descendant existence checks.\n\t * When present, generates a recursive CTE instead of simple EXISTS.\n\t */\n\treadonly recursive?: RecursiveExistsOptions;\n\t/**\n\t * Optional JOIN declarations inside the EXISTS subquery.\n\t * Keys are relation names (used as aliases), values specify join type.\n\t * Enables filtering on joined tables inside the subquery.\n\t *\n\t * @example\n\t * exists('callers', {\n\t * include: { callerFile: { join: 'inner' } },\n\t * where: eq('callerFile.project_id', projectId)\n\t * })\n\t */\n\treadonly include?: Readonly<Record<string, { join?: 'inner' | 'left' }>>;\n}\n\n/**\n * Relation not exists filter: filter by absence of related records\n *\n * @example\n * // Find users who have no posts\n * { kind: 'notExists', relation: 'posts' }\n */\nexport interface WhereNotExistsIntent {\n\treadonly kind: 'notExists';\n\t/** Relation name to check absence */\n\treadonly relation: string;\n\t/** Optional filter on related records */\n\treadonly where?: WhereIntent;\n\t/**\n\t * Recursive options for ancestor/descendant absence checks.\n\t * When present, generates a recursive CTE instead of simple NOT EXISTS.\n\t */\n\treadonly recursive?: RecursiveExistsOptions;\n\t/**\n\t * Optional JOIN declarations inside the NOT EXISTS subquery.\n\t * Keys are relation names (used as aliases), values specify join type.\n\t * Enables filtering on joined tables inside the subquery.\n\t *\n\t * @example\n\t * notExists('callers', {\n\t * include: { callerFile: { join: 'inner' } },\n\t * where: eq('callerFile.project_id', projectId)\n\t * })\n\t */\n\treadonly include?: Readonly<Record<string, { join?: 'inner' | 'left' }>>;\n}\n\n/**\n * Raw EXISTS subquery filter using an arbitrary QueryIntent.\n * Unlike WhereExistsIntent (which uses FK-resolved relation names),\n * this wraps a fully-specified subquery for correlated EXISTS checks.\n *\n * @example\n * // EXISTS (SELECT 1 FROM symbols WHERE symbols.id = calls.symbol_id AND ...)\n * exists(subquery('symbols').where(eq('id', ref('calls.symbol_id'))))\n */\nexport interface WhereRawExistsIntent {\n\treadonly kind: 'rawExists';\n\t/** The subquery producing rows for the EXISTS check */\n\treadonly subquery: QueryIntent;\n}\n\n/**\n * Raw NOT EXISTS subquery filter using an arbitrary QueryIntent.\n *\n * @example\n * // NOT EXISTS (SELECT 1 FROM symbols WHERE ...)\n * notExists(subquery('symbols').where(...))\n */\nexport interface WhereRawNotExistsIntent {\n\treadonly kind: 'rawNotExists';\n\t/** The subquery producing rows for the NOT EXISTS check */\n\treadonly subquery: QueryIntent;\n}\n\n/**\n * Relation filter: filter parent by conditions on related records\n * More flexible than exists - allows filtering by related record attributes\n *\n * @example\n * // Find users whose latest post was created in 2024\n * { kind: 'relationFilter', relation: 'posts', where: {...}, mode: 'some' }\n */\nexport interface WhereRelationFilterIntent {\n\treadonly kind: 'relationFilter';\n\t/**\n\t * Relation path for filtering.\n\t * - Single relation: 'posts' or ['posts']\n\t * - Multi-hop (SPEC-002): ['author', 'company'] for author.company traversal\n\t */\n\treadonly relation: string | readonly string[];\n\t/** Filter conditions on related records */\n\treadonly where: WhereIntent;\n\t/**\n\t * Match mode:\n\t * - 'some': At least one related record matches (default)\n\t * - 'every': All related records match\n\t * - 'none': No related records match\n\t */\n\treadonly mode: 'some' | 'every' | 'none';\n\t/** Optional alias for complex conditions (SPEC-002) */\n\treadonly alias?: string | undefined;\n\t/**\n\t * Optional display/debug metadata for pre-resolved relation filters.\n\t * These fields are not trusted for compilation. Internal compiler paths that\n\t * prove a virtual source maps to a real model relation use a module-private\n\t * proof payload instead.\n\t */\n\treadonly targetTable?: string | undefined;\n\treadonly sourceColumn?: ColumnListInput;\n\treadonly targetColumn?: ColumnListInput;\n}\n\n// ============================================================================\n// Subquery Intent - Scalar Subquery in WHERE\n// ============================================================================\n\n/**\n * Reference to a parent query column in a subquery.\n * Used to create correlated subqueries.\n *\n * The `outer` field is a discriminator set by `outerRef()` in\n * `@dbsp/core` to distinguish a genuine outer-query reference from an\n * inner `ref()` expression (RefExpressionIntent), which has the same\n * structural shape `{ kind: 'ref', column }`. Converters that need to\n * detect correlated subqueries check `outer === true`; an intent built\n * without `outer` (i.e. a plain `{ kind: 'ref', column }`) is treated\n * as a non-correlated inner expression reference.\n *\n * @example\n * // Outer reference produced by outerRef('id'):\n * { kind: 'ref', column: 'id', outer: true }\n *\n * // Inner column reference (not a correlated outer ref):\n * { kind: 'ref', column: 'id' } // outer is absent / undefined\n */\nexport interface SubqueryRefIntent {\n\treadonly kind: 'ref';\n\t/** Column name or aliased column (e.g., 'id' or 't0.id') */\n\treadonly column: string;\n\t/**\n\t * Discriminator that marks this as a genuine outer-query reference\n\t * (set by `outerRef()`). Absent on plain inner expression refs.\n\t * Optional so that existing raw intents built per the type without\n\t * this field remain valid (non-breaking addition).\n\t */\n\treadonly outer?: true;\n}\n\n/**\n * Subquery intent for scalar subquery comparisons.\n * Produces correlated subqueries in SQL.\n *\n * @example\n * // Find products where price equals max price of category\n * {\n * kind: 'subquery',\n * field: 'price',\n * operator: 'eq',\n * subquery: { from: 'products', select: { kind: 'aggregate', fn: 'max', field: 'price' } }\n * }\n */\nexport interface WhereSubqueryIntent {\n\treadonly kind: 'subquery';\n\t/** Field to compare on the parent query */\n\treadonly field: string;\n\t/** Comparison operator */\n\treadonly operator: ComparisonOperator;\n\t/** Subquery producing scalar value */\n\treadonly subquery: QueryIntent;\n}\n\n// ============================================================================\n// JSON/JSONB WHERE Intents (E13)\n// ============================================================================\n\n/**\n * JSON containment filter: col @> value or col <@ value.\n * @example { kind: 'jsonContains', field: 'data', value: '{\"active\":true}', reversed: false }\n * → WHERE \"data\" @> $1\n */\nexport interface WhereJsonContainsIntent {\n\treadonly kind: 'jsonContains';\n\treadonly field: string;\n\treadonly value: unknown;\n\t/** false = @> (field contains value), true = <@ (field contained by value) */\n\treadonly reversed: boolean;\n}\n\n/**\n * JSON key existence filter: col ? 'key'.\n * @example { kind: 'jsonExists', field: 'data', key: 'email' }\n * → WHERE \"data\" ? $1\n */\nexport interface WhereJsonExistsIntent {\n\treadonly kind: 'jsonExists';\n\treadonly field: string;\n\treadonly key: string | ParamIntent;\n}\n\n/** WHERE clause using a custom expression with comparison */\nexport interface WhereExpressionIntent {\n\treadonly kind: 'expression';\n\treadonly expr: ExpressionIntent;\n\treadonly operator: ComparisonOperator;\n\treadonly value: unknown;\n}\n\n/**\n * Where intent - filter conditions union type\n * Discriminated union using 'kind' field\n */\nexport type WhereIntent =\n\t| WhereComparisonIntent\n\t| WhereLikeIntent\n\t| WhereInIntent\n\t| WhereAnyIntent\n\t| WhereNullIntent\n\t| WhereRangeIntent\n\t| WhereAndIntent\n\t| WhereOrIntent\n\t| WhereNotIntent\n\t| WhereExistsIntent\n\t| WhereNotExistsIntent\n\t| WhereRawExistsIntent\n\t| WhereRawNotExistsIntent\n\t| WhereRelationFilterIntent\n\t| WhereSubqueryIntent\n\t| WhereJsonContainsIntent\n\t| WhereJsonExistsIntent\n\t| WhereExpressionIntent;\n","import { toColumnList } from './column-list.js';\nimport type { TableIR } from './model-ir.js';\n\n/**\n * Dialect-neutral json_agg order intent.\n *\n * `fallback` means the table has no declared primary key, so adapters should\n * realize the all-column deterministic fallback in their own dialect.\n */\nexport interface JsonAggOrderKey {\n\treadonly columns: readonly string[];\n\treadonly fallback: boolean;\n}\n\nexport function resolveJsonAggOrderKey(table: TableIR): JsonAggOrderKey {\n\tconst pkColumns = toColumnList(table.primaryKey);\n\treturn pkColumns.length > 0\n\t\t? { columns: pkColumns, fallback: false }\n\t\t: { columns: table.columns.map((col) => col.name), fallback: true };\n}\n","import type { ModelIR } from './model-ir.js';\n\n/**\n * Canonical shape of a `schema()` factory result as produced by\n * `createOrm({schema: ...})` callers and consumed by tooling\n * (cli, gui sidecar, mcp-server).\n *\n * ARCH-005: Schema type from schema() function.\n * Contains the definition, pre-computed ModelIR, and table names.\n */\nexport interface LoadedSchema {\n\treadonly definition: Record<string, unknown>;\n\treadonly model: ModelIR;\n\treadonly tableNames: readonly string[];\n}\n\nfunction isMap(value: unknown): value is Map<unknown, unknown> {\n\tif (typeof value !== 'object' || value === null) return false;\n\ttry {\n\t\tMap.prototype.has.call(value, undefined);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Runtime type guard for a `schema()` result. Checks the shapes, not just the\n * key names: the model's `tables` and `relations` must be real Maps and its\n * methods real functions, `definition` an object, and `tableNames` an array of\n * strings. Callers load these from disk and then call `.get()` / `.entries()`\n * on the model, so an object that merely has the right keys must not pass.\n *\n * It does not validate the schema's contents — only that this is a `schema()`\n * result rather than an arbitrary object.\n */\nexport function isValidSchema(schema: unknown): schema is LoadedSchema {\n\tif (\n\t\ttypeof schema !== 'object' ||\n\t\tschema === null ||\n\t\t!('model' in schema) ||\n\t\t!('definition' in schema) ||\n\t\t!('tableNames' in schema)\n\t) {\n\t\treturn false;\n\t}\n\tconst s = schema as LoadedSchema;\n\tif (typeof s.model !== 'object' || s.model === null) return false;\n\tif (!('tables' in s.model) || !('relations' in s.model)) return false;\n\tif (!isMap(s.model.tables)) return false;\n\tif (!isMap(s.model.relations)) return false;\n\tif (typeof s.definition !== 'object' || s.definition === null) return false;\n\tif (!Array.isArray(s.tableNames)) return false;\n\tif (s.tableNames.some((name) => typeof name !== 'string')) return false;\n\t// Validate required ModelIR methods are present\n\tif (typeof s.model.getTable !== 'function') return false;\n\tif (typeof s.model.getRelation !== 'function') return false;\n\tif (typeof s.model.getRelationsFrom !== 'function') return false;\n\tif (typeof s.model.getRelationsTo !== 'function') return false;\n\tif (typeof s.model.isAmbiguous !== 'function') return false;\n\treturn true;\n}\n","import type { ColumnJsReadType } from './model-ir.js';\n\nexport type OutputValueShape =\n\t| { readonly kind: 'scalar'; readonly cardinality: 'one' }\n\t| {\n\t\t\treadonly kind: 'array';\n\t\t\treadonly cardinality: 'many';\n\t\t\treadonly aggregate?: 'json_agg' | 'array_agg';\n\t }\n\t| {\n\t\t\treadonly kind: 'object';\n\t\t\treadonly cardinality: 'one';\n\t\t\treadonly aggregate?: 'json_agg';\n\t }\n\t| { readonly kind: 'aggregate-scalar'; readonly aggregate: string }\n\t| { readonly kind: 'unknown'; readonly reason: string };\n\nexport type OutputSource =\n\t| {\n\t\t\treadonly kind: 'modelColumn';\n\t\t\treadonly table: string;\n\t\t\treadonly column: string;\n\t\t\treadonly js?: ColumnJsReadType;\n\t }\n\t| { readonly kind: 'expression'; readonly reason: string }\n\t| { readonly kind: 'ambiguous'; readonly reason: string }\n\t| { readonly kind: 'unresolved'; readonly reason: string };\n\nexport type OutputDescriptor = {\n\treadonly outputKey: string;\n\treadonly source: OutputSource;\n\treadonly shape: OutputValueShape;\n};\n\nexport type OutputReadHandling =\n\t| {\n\t\t\treadonly kind: 'scalarConvert';\n\t\t\treadonly table: string;\n\t\t\treadonly column: string;\n\t\t\treadonly js: ColumnJsReadType;\n\t }\n\t| {\n\t\t\treadonly kind: 'nestedTransform';\n\t\t\treadonly table: string;\n\t\t\treadonly column: string;\n\t\t\treadonly js: ColumnJsReadType;\n\t }\n\t| { readonly kind: 'none' };\n\nexport type NestedOutputReadHandling = Extract<\n\tOutputReadHandling,\n\t{ readonly kind: 'nestedTransform' }\n>;\n\nexport function resolveOutputReadHandling(\n\tdescriptor: OutputDescriptor,\n): OutputReadHandling {\n\tconst { source } = descriptor;\n\tif (source.kind !== 'modelColumn' || source.js === undefined) {\n\t\treturn { kind: 'none' };\n\t}\n\n\tswitch (descriptor.shape.kind) {\n\t\tcase 'scalar':\n\t\t\treturn {\n\t\t\t\tkind: 'scalarConvert',\n\t\t\t\ttable: source.table,\n\t\t\t\tcolumn: source.column,\n\t\t\t\tjs: source.js,\n\t\t\t};\n\t\tcase 'array':\n\t\tcase 'object':\n\t\t\treturn {\n\t\t\t\tkind: 'nestedTransform',\n\t\t\t\ttable: source.table,\n\t\t\t\tcolumn: source.column,\n\t\t\t\tjs: source.js,\n\t\t\t};\n\t\tcase 'aggregate-scalar':\n\t\tcase 'unknown':\n\t\t\treturn { kind: 'none' };\n\t}\n}\n","import type { ColumnListInput } from './column-list.js';\nimport { toColumnList } from './column-list.js';\nimport type { ForeignKeyIR, RelationIR } from './model-ir.js';\n\nconst DEFAULT_REFERENCED_COLUMN = 'id';\n\nexport type RelationKeyDirection = 'belongsTo' | 'inverse';\n\nexport type RelationKeyForeignKey = Pick<ForeignKeyIR, 'references'> & {\n\treadonly columns: ColumnListInput;\n};\n\nexport interface RelationKeyBuilderOptions {\n\treadonly defaultReferencedColumn?: string;\n\treadonly foreignKeyShape?: ColumnListInput;\n\treadonly referencedKeyShape?: ColumnListInput;\n}\n\nexport type RelationKeyFields = Pick<RelationIR, 'foreignKey'> &\n\tPartial<Pick<RelationIR, 'sourceKey' | 'targetKey'>>;\n\nfunction columnListValue(\n\tcolumns: readonly string[],\n\tshape?: ColumnListInput,\n): string | readonly string[] {\n\tif (shape !== undefined && typeof shape !== 'string') return columns;\n\t// biome-ignore lint/style/noNonNullAssertion: columns.length === 1 guaranteed by the ternary condition on this line\n\treturn columns.length === 1 ? columns[0]! : columns;\n}\n\n/**\n * Build RelationIR key fields from a foreign key while preserving both sides.\n *\n * The local FK columns and referenced columns are normalized with toColumnList()\n * so composite keys cannot silently degrade to their first column.\n */\nexport function buildRelationKeyFields(\n\tfk: RelationKeyForeignKey,\n\tdirection: RelationKeyDirection,\n\toptions: RelationKeyBuilderOptions = {},\n): RelationKeyFields {\n\tconst foreignKeyColumns = toColumnList(fk.columns);\n\tconst referencedColumns = toColumnList(fk.references.columns);\n\n\tif (foreignKeyColumns.length !== referencedColumns.length) {\n\t\tthrow new Error(\n\t\t\t`Foreign key column count (${foreignKeyColumns.length}) must match referenced column count (${referencedColumns.length})`,\n\t\t);\n\t}\n\n\tconst foreignKey = columnListValue(\n\t\tforeignKeyColumns,\n\t\toptions.foreignKeyShape,\n\t);\n\tconst defaultReferencedColumn =\n\t\toptions.defaultReferencedColumn ?? DEFAULT_REFERENCED_COLUMN;\n\tconst isImplicitDefaultReference =\n\t\toptions.referencedKeyShape === undefined &&\n\t\treferencedColumns.length === 1 &&\n\t\treferencedColumns[0] === defaultReferencedColumn;\n\n\tif (!isImplicitDefaultReference) {\n\t\tconst referencedKey = columnListValue(\n\t\t\treferencedColumns,\n\t\t\toptions.referencedKeyShape,\n\t\t);\n\t\tif (direction === 'belongsTo') {\n\t\t\treturn { foreignKey, targetKey: referencedKey };\n\t\t}\n\t\treturn { foreignKey, sourceKey: referencedKey };\n\t}\n\n\treturn { foreignKey };\n}\n"],"mappings":";AAQA,IAAM,kBAAkB,OAAO,OAAO,gBAAgB;AACtD,IAAM,kBAAkB,OAAO,OAAO,gBAAgB;AACtD,IAAM,oBAAoB;AAE1B,SAAS,YAAY,OAAwB;AAC5C,MAAI,OAAO,UAAU,SAAU,QAAO,IAAI,KAAK;AAC/C,MAAI,OAAO,UAAU,SAAU,QAAO,GAAG,MAAM,SAAS,CAAC;AACzD,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW;AAC5D,WAAO,OAAO,KAAK;AAAA,EACpB;AACA,MAAI,UAAU,KAAM,QAAO;AAC3B,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI;AACH,WAAO,KAAK,UAAU,KAAK,KAAK,OAAO,KAAK;AAAA,EAC7C,QAAQ;AACP,WAAO,OAAO,KAAK;AAAA,EACpB;AACD;AAEA,SAAS,gBACR,OACA,QACA,KACA,QACa;AACb,SAAO,IAAI;AAAA,IACV,4CAA4C,IAAI,KAAK,IAAI,IAAI,MAAM,iBAAiB,IAAI,SAAS,WAAW,YAAY,KAAK,CAAC,OAAO,MAAM,KAAK,MAAM;AAAA,EACvJ;AACD;AAEA,SAAS,eACR,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