@prisma-next/sql-relational-core 0.3.0-dev.6 → 0.3.0-dev.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +18 -2
- package/dist/errors-7_V3El9I.mjs +3 -0
- package/dist/errors-DVufq9PT.d.mts +2 -0
- package/dist/exports/ast.d.mts +192 -0
- package/dist/exports/ast.d.mts.map +1 -0
- package/dist/exports/ast.mjs +361 -0
- package/dist/exports/ast.mjs.map +1 -0
- package/dist/exports/errors.d.mts +2 -0
- package/dist/exports/errors.mjs +3 -0
- package/dist/exports/guards.d.mts +5 -0
- package/dist/exports/guards.mjs +3 -0
- package/dist/exports/operations-registry.d.mts +5 -0
- package/dist/exports/operations-registry.mjs +3 -0
- package/dist/exports/param.d.mts +5 -0
- package/dist/exports/param.mjs +3 -0
- package/dist/exports/plan.d.mts +2 -0
- package/dist/exports/plan.mjs +17 -0
- package/dist/exports/plan.mjs.map +1 -0
- package/dist/exports/query-lane-context.d.mts +2 -0
- package/dist/exports/query-lane-context.mjs +1 -0
- package/dist/exports/schema.d.mts +5 -0
- package/dist/exports/schema.mjs +4 -0
- package/dist/exports/types.d.mts +4 -0
- package/dist/exports/types.mjs +3 -0
- package/dist/exports/utils/guards.d.mts +5 -0
- package/dist/exports/utils/guards.mjs +4 -0
- package/dist/guards-0ycyntYX.mjs +132 -0
- package/dist/guards-0ycyntYX.mjs.map +1 -0
- package/dist/guards-DCCpAlOL.d.mts +87 -0
- package/dist/guards-DCCpAlOL.d.mts.map +1 -0
- package/dist/index.d.mts +12 -0
- package/dist/index.mjs +12 -0
- package/dist/operations-registry-DPZ5aElH.mjs +152 -0
- package/dist/operations-registry-DPZ5aElH.mjs.map +1 -0
- package/dist/operations-registry-wVEaiLyt.d.mts +9 -0
- package/dist/operations-registry-wVEaiLyt.d.mts.map +1 -0
- package/dist/param-C4n0OW59.d.mts +8 -0
- package/dist/param-C4n0OW59.d.mts.map +1 -0
- package/dist/param-DMU3OWfI.mjs +14 -0
- package/dist/param-DMU3OWfI.mjs.map +1 -0
- package/dist/plan-BhSWuTfw.d.mts +194 -0
- package/dist/plan-BhSWuTfw.d.mts.map +1 -0
- package/dist/query-lane-context-CgkPuKaR.d.mts +259 -0
- package/dist/query-lane-context-CgkPuKaR.d.mts.map +1 -0
- package/dist/schema-Bi5p4aAc.mjs +175 -0
- package/dist/schema-Bi5p4aAc.mjs.map +1 -0
- package/dist/schema-CgrEMqEd.d.mts +86 -0
- package/dist/schema-CgrEMqEd.d.mts.map +1 -0
- package/dist/types-CEUzDuDC.d.mts +447 -0
- package/dist/types-CEUzDuDC.d.mts.map +1 -0
- package/dist/types-Cdi4Whda.mjs +18 -0
- package/dist/types-Cdi4Whda.mjs.map +1 -0
- package/package.json +38 -55
- package/src/ast/codec-types.ts +77 -8
- package/src/ast/delete.ts +2 -2
- package/src/ast/driver-types.ts +20 -3
- package/src/ast/predicate.ts +14 -4
- package/src/ast/select.ts +4 -3
- package/src/ast/sql-codecs.ts +67 -0
- package/src/ast/types.ts +89 -19
- package/src/ast/update.ts +2 -2
- package/src/exports/ast.ts +1 -0
- package/src/exports/guards.ts +5 -0
- package/src/exports/utils/guards.ts +1 -0
- package/src/operations-registry.ts +112 -73
- package/src/query-lane-context.ts +77 -1
- package/src/schema.ts +91 -33
- package/src/types.ts +327 -75
- package/src/utils/guards.ts +88 -18
- package/dist/ast/adapter-types.d.ts +0 -28
- package/dist/ast/adapter-types.d.ts.map +0 -1
- package/dist/ast/codec-types.d.ts +0 -141
- package/dist/ast/codec-types.d.ts.map +0 -1
- package/dist/ast/common.d.ts +0 -7
- package/dist/ast/common.d.ts.map +0 -1
- package/dist/ast/delete.d.ts +0 -8
- package/dist/ast/delete.d.ts.map +0 -1
- package/dist/ast/driver-types.d.ts +0 -20
- package/dist/ast/driver-types.d.ts.map +0 -1
- package/dist/ast/insert.d.ts +0 -8
- package/dist/ast/insert.d.ts.map +0 -1
- package/dist/ast/join.d.ts +0 -6
- package/dist/ast/join.d.ts.map +0 -1
- package/dist/ast/order.d.ts +0 -6
- package/dist/ast/order.d.ts.map +0 -1
- package/dist/ast/predicate.d.ts +0 -4
- package/dist/ast/predicate.d.ts.map +0 -1
- package/dist/ast/select.d.ts +0 -18
- package/dist/ast/select.d.ts.map +0 -1
- package/dist/ast/types.d.ts +0 -118
- package/dist/ast/types.d.ts.map +0 -1
- package/dist/ast/update.d.ts +0 -9
- package/dist/ast/update.d.ts.map +0 -1
- package/dist/ast/util.d.ts +0 -2
- package/dist/ast/util.d.ts.map +0 -1
- package/dist/chunk-2F7DSEOU.js +0 -8
- package/dist/chunk-2F7DSEOU.js.map +0 -1
- package/dist/chunk-36WJWNHT.js +0 -1
- package/dist/chunk-36WJWNHT.js.map +0 -1
- package/dist/chunk-5N34PNVZ.js +0 -62
- package/dist/chunk-5N34PNVZ.js.map +0 -1
- package/dist/chunk-7I3EMQID.js +0 -16
- package/dist/chunk-7I3EMQID.js.map +0 -1
- package/dist/chunk-CBTYMOX2.js +0 -152
- package/dist/chunk-CBTYMOX2.js.map +0 -1
- package/dist/chunk-G52ENULI.js +0 -1
- package/dist/chunk-G52ENULI.js.map +0 -1
- package/dist/chunk-KYSP7L5C.js +0 -16
- package/dist/chunk-KYSP7L5C.js.map +0 -1
- package/dist/chunk-M23L3JHG.js +0 -159
- package/dist/chunk-M23L3JHG.js.map +0 -1
- package/dist/chunk-MM74SVJ4.js +0 -13
- package/dist/chunk-MM74SVJ4.js.map +0 -1
- package/dist/chunk-U7AXAUJA.js +0 -1
- package/dist/chunk-U7AXAUJA.js.map +0 -1
- package/dist/chunk-WZBPVEZI.js +0 -320
- package/dist/chunk-WZBPVEZI.js.map +0 -1
- package/dist/errors.d.ts +0 -2
- package/dist/errors.d.ts.map +0 -1
- package/dist/exports/ast.d.ts +0 -14
- package/dist/exports/ast.d.ts.map +0 -1
- package/dist/exports/ast.js +0 -46
- package/dist/exports/ast.js.map +0 -1
- package/dist/exports/errors.d.ts +0 -2
- package/dist/exports/errors.d.ts.map +0 -1
- package/dist/exports/errors.js +0 -9
- package/dist/exports/errors.js.map +0 -1
- package/dist/exports/guards.d.ts +0 -2
- package/dist/exports/guards.d.ts.map +0 -1
- package/dist/exports/guards.js +0 -21
- package/dist/exports/guards.js.map +0 -1
- package/dist/exports/operations-registry.d.ts +0 -2
- package/dist/exports/operations-registry.d.ts.map +0 -1
- package/dist/exports/operations-registry.js +0 -9
- package/dist/exports/operations-registry.js.map +0 -1
- package/dist/exports/param.d.ts +0 -3
- package/dist/exports/param.d.ts.map +0 -1
- package/dist/exports/param.js +0 -7
- package/dist/exports/param.js.map +0 -1
- package/dist/exports/plan.d.ts +0 -2
- package/dist/exports/plan.d.ts.map +0 -1
- package/dist/exports/plan.js +0 -7
- package/dist/exports/plan.js.map +0 -1
- package/dist/exports/query-lane-context.d.ts +0 -2
- package/dist/exports/query-lane-context.d.ts.map +0 -1
- package/dist/exports/query-lane-context.js +0 -2
- package/dist/exports/query-lane-context.js.map +0 -1
- package/dist/exports/schema.d.ts +0 -3
- package/dist/exports/schema.d.ts.map +0 -1
- package/dist/exports/schema.js +0 -14
- package/dist/exports/schema.js.map +0 -1
- package/dist/exports/types.d.ts +0 -2
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -10
- package/dist/exports/types.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -81
- package/dist/index.js.map +0 -1
- package/dist/operations-registry.d.ts +0 -5
- package/dist/operations-registry.d.ts.map +0 -1
- package/dist/param.d.ts +0 -4
- package/dist/param.d.ts.map +0 -1
- package/dist/plan.d.ts +0 -23
- package/dist/plan.d.ts.map +0 -1
- package/dist/query-lane-context.d.ts +0 -16
- package/dist/query-lane-context.d.ts.map +0 -1
- package/dist/schema.d.ts +0 -63
- package/dist/schema.d.ts.map +0 -1
- package/dist/types.d.ts +0 -332
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/guards.d.ts +0 -55
- package/dist/utils/guards.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-Bi5p4aAc.mjs","names":["table: string","column: ColumnName","storageColumn: ColumnMeta"],"sources":["../src/schema.ts"],"sourcesContent":["import type { OperationRegistry } from '@prisma-next/operations';\nimport { planInvalid } from '@prisma-next/plan';\nimport type {\n ExtractCodecTypes,\n ExtractOperationTypes,\n SqlContract,\n SqlStorage,\n StorageColumn,\n} from '@prisma-next/sql-contract/types';\nimport type { BinaryOp, ColumnRef, ExpressionSource, TableRef } from './ast/types';\nimport { attachOperationsToColumnBuilder } from './operations-registry';\nimport type { ExecutionContext } from './query-lane-context';\nimport type {\n BinaryBuilder,\n CodecTypes as CodecTypesType,\n ColumnBuilder,\n ComputeColumnJsType,\n NullCheckBuilder,\n OperationTypeSignature,\n OperationTypes,\n OrderBuilder,\n ParamPlaceholder,\n} from './types';\n\ntype TableColumns<Table extends { columns: Record<string, StorageColumn> }> = Table['columns'];\n\ntype ColumnBuilders<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n Columns extends Record<string, StorageColumn>,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n> = {\n readonly [K in keyof Columns]: ColumnBuilder<\n K & string,\n Columns[K],\n ComputeColumnJsType<Contract, TableName, K & string, Columns[K], CodecTypes>,\n Operations\n >;\n};\n\nexport class ColumnBuilderImpl<\n ColumnName extends string,\n ColumnMeta extends StorageColumn,\n JsType = unknown,\n> implements ExpressionSource\n{\n readonly kind = 'column' as const;\n\n constructor(\n readonly table: string,\n readonly column: ColumnName,\n private readonly storageColumn: ColumnMeta,\n ) {}\n\n get columnMeta(): ColumnMeta {\n return this.storageColumn;\n }\n\n // Type-level helper property (not used at runtime)\n get __jsType(): JsType {\n return undefined as unknown as JsType;\n }\n\n /**\n * Converts this column builder to a ColumnRef expression.\n * This is the canonical way to get an AST node from a builder.\n */\n toExpr(): ColumnRef {\n return Object.freeze({\n kind: 'col' as const,\n table: this.table,\n column: this.column,\n });\n }\n\n private createBinaryBuilder(\n op: BinaryOp,\n value: ParamPlaceholder | ExpressionSource,\n ): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n if (value == null) {\n throw planInvalid(\n 'Parameter placeholder or expression source required for column comparison',\n );\n }\n // Check for ExpressionSource first (has toExpr method)\n if ('toExpr' in value && typeof value.toExpr === 'function') {\n return Object.freeze({\n kind: 'binary' as const,\n op,\n left: this.toExpr(),\n right: value,\n }) as BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n }\n // Must be a ParamPlaceholder\n if ('kind' in value && value.kind === 'param-placeholder') {\n return Object.freeze({\n kind: 'binary' as const,\n op,\n left: this.toExpr(),\n right: value,\n }) as BinaryBuilder<ColumnName, ColumnMeta, JsType>;\n }\n throw planInvalid('Parameter placeholder or expression source required for column comparison');\n }\n\n eq(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('eq', value);\n }\n\n neq(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('neq', value);\n }\n\n gt(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('gt', value);\n }\n\n lt(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('lt', value);\n }\n\n gte(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('gte', value);\n }\n\n lte(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType> {\n return this.createBinaryBuilder('lte', value);\n }\n\n asc(): OrderBuilder<ColumnName, ColumnMeta, JsType> {\n return Object.freeze({\n kind: 'order' as const,\n expr: this.toExpr(),\n dir: 'asc' as const,\n }) as OrderBuilder<ColumnName, ColumnMeta, JsType>;\n }\n\n desc(): OrderBuilder<ColumnName, ColumnMeta, JsType> {\n return Object.freeze({\n kind: 'order' as const,\n expr: this.toExpr(),\n dir: 'desc' as const,\n }) as OrderBuilder<ColumnName, ColumnMeta, JsType>;\n }\n\n /**\n * Creates an IS NULL check for this column.\n * Available on all columns at runtime, but typed to only be visible on nullable columns.\n */\n isNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType> {\n return Object.freeze({\n kind: 'nullCheck' as const,\n expr: this.toExpr(),\n isNull: true,\n }) as NullCheckBuilder<ColumnName, ColumnMeta, JsType>;\n }\n\n /**\n * Creates an IS NOT NULL check for this column.\n * Available on all columns at runtime, but typed to only be visible on nullable columns.\n */\n isNotNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType> {\n return Object.freeze({\n kind: 'nullCheck' as const,\n expr: this.toExpr(),\n isNull: false,\n }) as NullCheckBuilder<ColumnName, ColumnMeta, JsType>;\n }\n}\n\nexport class TableBuilderImpl<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n Columns extends Record<string, StorageColumn>,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n> implements TableRef\n{\n readonly kind = 'table' as const;\n readonly columns: ColumnBuilders<Contract, TableName, Columns, CodecTypes, Operations>;\n private readonly _name: TableName;\n\n constructor(\n name: TableName,\n columns: ColumnBuilders<Contract, TableName, Columns, CodecTypes, Operations>,\n ) {\n this._name = name;\n this.columns = columns;\n }\n\n get name(): string {\n return this._name;\n }\n}\n\nfunction buildColumns<\n Contract extends SqlContract<SqlStorage>,\n TableName extends keyof Contract['storage']['tables'] & string,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n>(\n tableName: TableName,\n storage: SqlStorage,\n _contract: Contract,\n operationRegistry?: OperationRegistry,\n contractCapabilities?: Record<string, Record<string, boolean>>,\n): ColumnBuilders<\n Contract,\n TableName,\n Contract['storage']['tables'][TableName]['columns'],\n CodecTypes,\n Operations\n> {\n const table = storage.tables[tableName];\n\n if (!table) {\n throw planInvalid(`Unknown table ${tableName}`);\n }\n\n type Columns = Contract['storage']['tables'][TableName]['columns'];\n const tableColumns = table.columns as Columns;\n\n const result = {} as {\n [K in keyof Columns]: ColumnBuilder<\n K & string,\n Columns[K],\n ComputeColumnJsType<Contract, TableName, K & string, Columns[K], CodecTypes>,\n Operations\n >;\n };\n\n const assignColumn = <ColumnKey extends keyof Columns & string>(\n columnName: ColumnKey,\n columnDef: Columns[ColumnKey],\n ) => {\n type JsType = ComputeColumnJsType<\n Contract,\n TableName,\n ColumnKey,\n Columns[ColumnKey],\n CodecTypes\n >;\n\n const columnBuilder = new ColumnBuilderImpl<ColumnKey, Columns[ColumnKey], JsType>(\n tableName,\n columnName,\n columnDef,\n );\n\n const builderWithOps = attachOperationsToColumnBuilder<\n ColumnKey,\n Columns[ColumnKey],\n JsType,\n Operations\n >(\n columnBuilder as unknown as ColumnBuilder<\n ColumnKey,\n Columns[ColumnKey],\n JsType,\n Record<string, never>\n >,\n columnDef,\n operationRegistry,\n contractCapabilities,\n );\n\n (result as Record<string, unknown>)[columnName] = builderWithOps;\n };\n\n for (const columnName of Object.keys(tableColumns) as Array<keyof Columns & string>) {\n const columnDef = tableColumns[columnName];\n if (!columnDef) continue;\n assignColumn(columnName, columnDef);\n }\n\n return result as ColumnBuilders<Contract, TableName, Columns, CodecTypes, Operations>;\n}\n\n/**\n * Creates a Proxy that enables accessing table columns directly on the table object,\n * in addition to the standard `table.columns.columnName` syntax.\n *\n * This allows both access patterns:\n * - `tables.user.columns.id` (standard access)\n * - `tables.user.id` (convenience access via proxy)\n *\n * The proxy intercepts property access and routes column name lookups to\n * `table.columns[prop]`, while preserving direct access to table properties\n * like `name`, `kind`, and `columns`.\n */\nfunction createTableProxy<\n Contract extends SqlContract<SqlStorage>,\n TableName extends string,\n Columns extends Record<string, StorageColumn>,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n>(\n table: TableBuilderImpl<Contract, TableName, Columns, CodecTypes, Operations>,\n): TableBuilderImpl<Contract, TableName, Columns, CodecTypes, Operations> {\n return new Proxy(table, {\n get(target, prop) {\n if (prop === 'name' || prop === 'kind' || prop === 'columns') {\n return Reflect.get(target, prop);\n }\n if (typeof prop === 'string' && prop in target.columns) {\n return target.columns[prop as keyof typeof target.columns];\n }\n return undefined;\n },\n });\n}\n\ntype ExtractSchemaTables<\n Contract extends SqlContract<SqlStorage>,\n CodecTypes extends CodecTypesType,\n Operations extends OperationTypes,\n> = {\n readonly [TableName in keyof Contract['storage']['tables']]: TableBuilderImpl<\n Contract,\n TableName & string,\n TableColumns<Contract['storage']['tables'][TableName]>,\n CodecTypes,\n Operations\n > &\n TableRef;\n};\n\n/**\n * Extracts the types registry shape from a contract.\n * Each key is a type name from storage.types, and the value preserves the\n * literal type from the contract (including codecId, nativeType, and typeParams).\n * Returns an empty object type {} when storage.types is undefined.\n */\ntype ExtractSchemaTypes<Contract extends SqlContract<SqlStorage>> =\n Contract['storage']['types'] extends infer Types\n ? Types extends Record<string, unknown>\n ? { readonly [TypeName in keyof Types]: Types[TypeName] }\n : Record<string, never>\n : Record<string, never>;\n\nexport type SchemaHandle<\n Contract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>,\n CodecTypes extends CodecTypesType = CodecTypesType,\n Operations extends OperationTypes = Record<string, never>,\n> = {\n readonly tables: ExtractSchemaTables<Contract, CodecTypes, Operations>;\n /**\n * Initialized type helpers from storage.types.\n * Each entry corresponds to a named type instance in the contract's storage.types.\n */\n readonly types: ExtractSchemaTypes<Contract>;\n};\n\ntype SchemaReturnType<Contract extends SqlContract<SqlStorage>> = SchemaHandle<\n Contract,\n ExtractCodecTypes<Contract>,\n ToOperationTypes<ExtractOperationTypes<Contract>>\n>;\n\ntype NormalizeOperationTypes<T> = {\n [TypeId in keyof T]: {\n [Method in keyof T[TypeId]]: T[TypeId][Method] extends OperationTypeSignature\n ? T[TypeId][Method]\n : OperationTypeSignature;\n };\n};\n\ntype ToOperationTypes<T> = T extends OperationTypes ? T : NormalizeOperationTypes<T>;\n\n/**\n * Creates a schema handle for building SQL queries.\n *\n * @param context - Query lane context containing contract, codec and operation registries\n * @returns A schema handle with typed table builders and type helpers\n *\n * @example\n * ```typescript\n * const schemaHandle = schema<Contract>(context);\n * const userTable = schemaHandle.tables.user;\n * const vectorType = schemaHandle.types.Vector1536;\n * ```\n */\nexport function schema<Contract extends SqlContract<SqlStorage>>(\n context: ExecutionContext<Contract>,\n): SchemaReturnType<Contract> {\n const contract = context.contract;\n const storage = contract.storage;\n type CodecTypes = ExtractCodecTypes<Contract>;\n type Operations = ToOperationTypes<ExtractOperationTypes<Contract>>;\n const tables = {} as ExtractSchemaTables<Contract, CodecTypes, Operations>;\n const contractCapabilities = contract.capabilities;\n\n const operationRegistry = context.operations;\n\n for (const tableName of Object.keys(storage.tables) as Array<\n keyof Contract['storage']['tables'] & string\n >) {\n const columns = buildColumns<Contract, typeof tableName, CodecTypes, Operations>(\n tableName,\n storage,\n contract,\n operationRegistry,\n contractCapabilities,\n );\n const table = new TableBuilderImpl<\n Contract,\n typeof tableName & string,\n Contract['storage']['tables'][typeof tableName]['columns'],\n CodecTypes,\n Operations\n >(tableName, columns);\n const proxiedTable = createTableProxy<\n Contract,\n typeof tableName & string,\n Contract['storage']['tables'][typeof tableName]['columns'],\n CodecTypes,\n Operations\n >(table);\n (tables as Record<string, unknown>)[tableName] = Object.freeze(\n proxiedTable,\n ) as ExtractSchemaTables<Contract, CodecTypes, Operations>[typeof tableName];\n }\n\n // Get type helpers from context (populated by runtime context creation)\n const types = context.types as ExtractSchemaTypes<Contract>;\n\n return Object.freeze({ tables, types }) as SchemaReturnType<Contract>;\n}\n\nexport type { ColumnBuilderImpl as Column, TableBuilderImpl as Table };\n"],"mappings":";;;;AAyCA,IAAa,oBAAb,MAKA;CACE,AAAS,OAAO;CAEhB,YACE,AAASA,OACT,AAASC,QACT,AAAiBC,eACjB;EAHS;EACA;EACQ;;CAGnB,IAAI,aAAyB;AAC3B,SAAO,KAA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OAAO,OACtD,aACD;;CAIH,MAAM,QAAQ,QAAQ;AAEtB,QAAO,OAAO,OAAO;EAAE;EAAQ;EAAO,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { n as ExecutionContext } from "./query-lane-context-CgkPuKaR.mjs";
|
|
2
|
+
import { D as TableRef, f as ExpressionSource, s as ColumnRef } from "./plan-BhSWuTfw.mjs";
|
|
3
|
+
import { A as OperationTypes, D as NullCheckBuilder, M as OrderBuilder, N as ParamPlaceholder, d as ColumnBuilder, k as OperationTypeSignature, p as ComputeColumnJsType, s as BinaryBuilder, u as CodecTypes } from "./types-CEUzDuDC.mjs";
|
|
4
|
+
import { ExtractCodecTypes, ExtractOperationTypes, SqlContract, SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
|
|
5
|
+
|
|
6
|
+
//#region src/schema.d.ts
|
|
7
|
+
type TableColumns<Table extends {
|
|
8
|
+
columns: Record<string, StorageColumn>;
|
|
9
|
+
}> = Table['columns'];
|
|
10
|
+
type ColumnBuilders<Contract extends SqlContract<SqlStorage>, TableName$1 extends string, Columns extends Record<string, StorageColumn>, CodecTypes$1 extends CodecTypes, Operations extends OperationTypes> = { readonly [K in keyof Columns]: ColumnBuilder<K & string, Columns[K], ComputeColumnJsType<Contract, TableName$1, K & string, Columns[K], CodecTypes$1>, Operations> };
|
|
11
|
+
declare class ColumnBuilderImpl<ColumnName extends string, ColumnMeta extends StorageColumn, JsType = unknown> implements ExpressionSource {
|
|
12
|
+
readonly table: string;
|
|
13
|
+
readonly column: ColumnName;
|
|
14
|
+
private readonly storageColumn;
|
|
15
|
+
readonly kind: "column";
|
|
16
|
+
constructor(table: string, column: ColumnName, storageColumn: ColumnMeta);
|
|
17
|
+
get columnMeta(): ColumnMeta;
|
|
18
|
+
get __jsType(): JsType;
|
|
19
|
+
/**
|
|
20
|
+
* Converts this column builder to a ColumnRef expression.
|
|
21
|
+
* This is the canonical way to get an AST node from a builder.
|
|
22
|
+
*/
|
|
23
|
+
toExpr(): ColumnRef;
|
|
24
|
+
private createBinaryBuilder;
|
|
25
|
+
eq(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
|
|
26
|
+
neq(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
|
|
27
|
+
gt(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
|
|
28
|
+
lt(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
|
|
29
|
+
gte(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
|
|
30
|
+
lte(value: ParamPlaceholder | ExpressionSource): BinaryBuilder<ColumnName, ColumnMeta, JsType>;
|
|
31
|
+
asc(): OrderBuilder<ColumnName, ColumnMeta, JsType>;
|
|
32
|
+
desc(): OrderBuilder<ColumnName, ColumnMeta, JsType>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates an IS NULL check for this column.
|
|
35
|
+
* Available on all columns at runtime, but typed to only be visible on nullable columns.
|
|
36
|
+
*/
|
|
37
|
+
isNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates an IS NOT NULL check for this column.
|
|
40
|
+
* Available on all columns at runtime, but typed to only be visible on nullable columns.
|
|
41
|
+
*/
|
|
42
|
+
isNotNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType>;
|
|
43
|
+
}
|
|
44
|
+
declare class TableBuilderImpl<Contract extends SqlContract<SqlStorage>, TableName$1 extends string, Columns extends Record<string, StorageColumn>, CodecTypes$1 extends CodecTypes, Operations extends OperationTypes> implements TableRef {
|
|
45
|
+
readonly kind: "table";
|
|
46
|
+
readonly columns: ColumnBuilders<Contract, TableName$1, Columns, CodecTypes$1, Operations>;
|
|
47
|
+
private readonly _name;
|
|
48
|
+
constructor(name: TableName$1, columns: ColumnBuilders<Contract, TableName$1, Columns, CodecTypes$1, Operations>);
|
|
49
|
+
get name(): string;
|
|
50
|
+
}
|
|
51
|
+
type ExtractSchemaTables<Contract extends SqlContract<SqlStorage>, CodecTypes$1 extends CodecTypes, Operations extends OperationTypes> = { readonly [TableName in keyof Contract['storage']['tables']]: TableBuilderImpl<Contract, TableName & string, TableColumns<Contract['storage']['tables'][TableName]>, CodecTypes$1, Operations> & TableRef };
|
|
52
|
+
/**
|
|
53
|
+
* Extracts the types registry shape from a contract.
|
|
54
|
+
* Each key is a type name from storage.types, and the value preserves the
|
|
55
|
+
* literal type from the contract (including codecId, nativeType, and typeParams).
|
|
56
|
+
* Returns an empty object type {} when storage.types is undefined.
|
|
57
|
+
*/
|
|
58
|
+
type ExtractSchemaTypes<Contract extends SqlContract<SqlStorage>> = Contract['storage']['types'] extends infer Types ? Types extends Record<string, unknown> ? { readonly [TypeName in keyof Types]: Types[TypeName] } : Record<string, never> : Record<string, never>;
|
|
59
|
+
type SchemaHandle<Contract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>, CodecTypes$1 extends CodecTypes = CodecTypes, Operations extends OperationTypes = Record<string, never>> = {
|
|
60
|
+
readonly tables: ExtractSchemaTables<Contract, CodecTypes$1, Operations>;
|
|
61
|
+
/**
|
|
62
|
+
* Initialized type helpers from storage.types.
|
|
63
|
+
* Each entry corresponds to a named type instance in the contract's storage.types.
|
|
64
|
+
*/
|
|
65
|
+
readonly types: ExtractSchemaTypes<Contract>;
|
|
66
|
+
};
|
|
67
|
+
type SchemaReturnType<Contract extends SqlContract<SqlStorage>> = SchemaHandle<Contract, ExtractCodecTypes<Contract>, ToOperationTypes<ExtractOperationTypes<Contract>>>;
|
|
68
|
+
type NormalizeOperationTypes<T> = { [TypeId in keyof T]: { [Method in keyof T[TypeId]]: T[TypeId][Method] extends OperationTypeSignature ? T[TypeId][Method] : OperationTypeSignature } };
|
|
69
|
+
type ToOperationTypes<T> = T extends OperationTypes ? T : NormalizeOperationTypes<T>;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a schema handle for building SQL queries.
|
|
72
|
+
*
|
|
73
|
+
* @param context - Query lane context containing contract, codec and operation registries
|
|
74
|
+
* @returns A schema handle with typed table builders and type helpers
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const schemaHandle = schema<Contract>(context);
|
|
79
|
+
* const userTable = schemaHandle.tables.user;
|
|
80
|
+
* const vectorType = schemaHandle.types.Vector1536;
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
declare function schema<Contract extends SqlContract<SqlStorage>>(context: ExecutionContext<Contract>): SchemaReturnType<Contract>;
|
|
84
|
+
//#endregion
|
|
85
|
+
export { schema as i, SchemaHandle as n, TableBuilderImpl as r, ColumnBuilderImpl as t };
|
|
86
|
+
//# sourceMappingURL=schema-CgrEMqEd.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-CgrEMqEd.d.mts","names":[],"sources":["../src/schema.ts"],"sourcesContent":[],"mappings":";;;;;;KAwBK;WAAsC,eAAe;AAFzC,CAAA,CAAA,GAE6D,KAAzE,CAAA,SAAY,CAAA;KAEZ,cAFqD,CAAA,iBAGvC,WAHuC,CAG3B,UAH2B,CAAA,EAAA,oBAAA,MAAA,EAAA,gBAKxC,MALwC,CAAA,MAAA,EAKzB,aALyB,CAAA,EAAA,qBAMrC,UANqC,EAAA,mBAOrC,cAPqC,CAAA,GAAA,iBAAf,MASpB,OAToB,GASV,aATU,CAUvC,CAVuC,GAAA,MAAA,EAWvC,OAXuC,CAW/B,CAX+B,CAAA,EAYvC,mBAZuC,CAYnB,QAZmB,EAYT,WAZS,EAYE,CAZF,GAAA,MAAA,EAYc,OAZd,CAYsB,CAZtB,CAAA,EAY0B,YAZ1B,CAAA,EAavC,UAbuC,CAAA,EAAmC;AAAK,cAiBtE,iBAjBsE,CAAA,mBAAA,MAAA,EAAA,mBAmB9D,aAnB8D,EAAA,SAAA,OAAA,CA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4C,CA4O1C,MA5O0C,CAAA,CA4OlC,MA5OkC,CAAA,SA4OlB,sBA5OkB,GA6OrE,CA7OqE,CA6OnE,MA7OmE,CAAA,CA6O3D,MA7O2D,CAAA,GA8OrE,sBA9OqE,EAAY,EAAtC;KAkP9C,gBA9OiB,CAAA,CAAA,CAAA,GA8OK,CA9OL,SA8Oe,cA9Of,GA8OgC,CA9OhC,GA8OoC,uBA9OpC,CA8O4D,CA9O5D,CAAA;;;;;;;;;;;;;;AAgCkC,iBA6NxC,MA7NwC,CAAA,iBA6NhB,WA7NgB,CA6NJ,UA7NI,CAAA,CAAA,CAAA,OAAA,EA8N7C,gBA9N6C,CA8N5B,QA9N4B,CAAA,CAAA,EA+NrD,gBA/NqD,CA+NpC,QA/NoC,CAAA"}
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { n as ExecutionContext } from "./query-lane-context-CgkPuKaR.mjs";
|
|
2
|
+
import { S as OperationExpr, T as QueryAst, a as BinaryOp, d as Expression, f as ExpressionSource, l as Direction, s as ColumnRef, t as SqlQueryPlan, w as ParamRef } from "./plan-BhSWuTfw.mjs";
|
|
3
|
+
import { RuntimeError } from "@prisma-next/plan";
|
|
4
|
+
import { ArgSpec, ReturnSpec } from "@prisma-next/operations";
|
|
5
|
+
import { ExecutionPlan, PlanRefs, ResultType } from "@prisma-next/contract/types";
|
|
6
|
+
import { SqlLoweringSpec } from "@prisma-next/sql-operations";
|
|
7
|
+
import { SqlContract, SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
|
|
8
|
+
|
|
9
|
+
//#region src/types.d.ts
|
|
10
|
+
interface ParamPlaceholder {
|
|
11
|
+
readonly kind: 'param-placeholder';
|
|
12
|
+
readonly name: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* ValueSource represents any value that can appear in a comparison or as an argument.
|
|
16
|
+
* This includes:
|
|
17
|
+
* - ParamPlaceholder: A parameter placeholder (e.g., `param('userId')`)
|
|
18
|
+
* - ExpressionSource: Something that can be converted to an Expression (ColumnBuilder, ExpressionBuilder)
|
|
19
|
+
*/
|
|
20
|
+
type ValueSource = ParamPlaceholder | ExpressionSource;
|
|
21
|
+
interface OrderBuilder<_ColumnName extends string = string, _ColumnMeta extends StorageColumn = StorageColumn, _JsType = unknown> {
|
|
22
|
+
readonly kind: 'order';
|
|
23
|
+
readonly expr: Expression;
|
|
24
|
+
readonly dir: Direction;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates an OrderBuilder for use in orderBy clauses.
|
|
28
|
+
*/
|
|
29
|
+
declare function createOrderBuilder(expr: AnyColumnBuilder | OperationExpr, dir: Direction): AnyOrderBuilder;
|
|
30
|
+
/**
|
|
31
|
+
* ColumnBuilder with optional operation methods based on the column's typeId.
|
|
32
|
+
* When Operations is provided and the column's typeId matches, operation methods are included.
|
|
33
|
+
* Implements ExpressionSource to provide type-safe conversion to ColumnRef.
|
|
34
|
+
*
|
|
35
|
+
* For nullable columns (ColumnMeta['nullable'] extends true), includes isNull() and isNotNull() methods.
|
|
36
|
+
*/
|
|
37
|
+
type ColumnBuilder<ColumnName extends string = string, ColumnMeta extends StorageColumn = StorageColumn, JsType$1 = unknown, Operations extends OperationTypes = Record<string, never>> = {
|
|
38
|
+
readonly kind: 'column';
|
|
39
|
+
readonly table: string;
|
|
40
|
+
readonly column: ColumnName;
|
|
41
|
+
readonly columnMeta: ColumnMeta;
|
|
42
|
+
eq(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
43
|
+
neq(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
44
|
+
gt(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
45
|
+
lt(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
46
|
+
gte(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
47
|
+
lte(value: ValueSource): BinaryBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
48
|
+
asc(): OrderBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
49
|
+
desc(): OrderBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
50
|
+
/** Converts this column builder to a ColumnRef expression */
|
|
51
|
+
toExpr(): ColumnRef;
|
|
52
|
+
readonly __jsType: JsType$1;
|
|
53
|
+
} & (ColumnMeta['codecId'] extends string ? ColumnMeta['codecId'] extends keyof Operations ? OperationMethods<OperationsForTypeId<ColumnMeta['codecId'] & string, Operations>, ColumnName, StorageColumn, JsType$1> : Record<string, never> : Record<string, never>) & (ColumnMeta['nullable'] extends true ? NullableMethods<ColumnName, ColumnMeta, JsType$1> : Record<string, never>);
|
|
54
|
+
interface BinaryBuilder<_ColumnName extends string = string, _ColumnMeta extends StorageColumn = StorageColumn, _JsType = unknown> {
|
|
55
|
+
readonly kind: 'binary';
|
|
56
|
+
readonly op: BinaryOp;
|
|
57
|
+
readonly left: Expression;
|
|
58
|
+
readonly right: ValueSource;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Builder for IS NULL / IS NOT NULL checks.
|
|
62
|
+
* Used to build unary null check expressions in WHERE clauses.
|
|
63
|
+
*/
|
|
64
|
+
interface NullCheckBuilder<_ColumnName extends string = string, _ColumnMeta extends StorageColumn = StorageColumn, _JsType = unknown> {
|
|
65
|
+
readonly kind: 'nullCheck';
|
|
66
|
+
readonly expr: Expression;
|
|
67
|
+
readonly isNull: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Union type for unary builders (currently just NullCheckBuilder).
|
|
71
|
+
* Extensible for future unary operators.
|
|
72
|
+
*/
|
|
73
|
+
type UnaryBuilder = NullCheckBuilder;
|
|
74
|
+
type AnyBinaryBuilder = BinaryBuilder;
|
|
75
|
+
type AnyOrderBuilder = OrderBuilder;
|
|
76
|
+
type AnyUnaryBuilder = UnaryBuilder;
|
|
77
|
+
/**
|
|
78
|
+
* Methods available only on nullable columns.
|
|
79
|
+
* These are conditionally added to ColumnBuilder when ColumnMeta['nullable'] is true.
|
|
80
|
+
* Note: Index signature is required for compatibility with AnyColumnBuilderBase's index signature.
|
|
81
|
+
*/
|
|
82
|
+
interface NullableMethods<ColumnName extends string = string, ColumnMeta extends StorageColumn = StorageColumn, JsType$1 = unknown> {
|
|
83
|
+
/** Creates an IS NULL check for this column */
|
|
84
|
+
isNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
85
|
+
/** Creates an IS NOT NULL check for this column */
|
|
86
|
+
isNotNull(): NullCheckBuilder<ColumnName, ColumnMeta, JsType$1>;
|
|
87
|
+
/** Index signature for compatibility with AnyColumnBuilderBase */
|
|
88
|
+
readonly [key: string]: unknown;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* ExpressionBuilder represents the result of an operation (e.g., col.distance(...)).
|
|
92
|
+
* Unlike ColumnBuilder (which represents a column), ExpressionBuilder represents
|
|
93
|
+
* an operation expression and provides the same DSL methods for chaining.
|
|
94
|
+
*
|
|
95
|
+
* Implements ExpressionSource to provide type-safe conversion to OperationExpr.
|
|
96
|
+
*/
|
|
97
|
+
interface ExpressionBuilder<JsType$1 = unknown> extends ExpressionSource {
|
|
98
|
+
readonly kind: 'expression';
|
|
99
|
+
readonly expr: OperationExpr;
|
|
100
|
+
readonly columnMeta: StorageColumn;
|
|
101
|
+
eq(value: ValueSource): AnyBinaryBuilder;
|
|
102
|
+
neq(value: ValueSource): AnyBinaryBuilder;
|
|
103
|
+
gt(value: ValueSource): AnyBinaryBuilder;
|
|
104
|
+
lt(value: ValueSource): AnyBinaryBuilder;
|
|
105
|
+
gte(value: ValueSource): AnyBinaryBuilder;
|
|
106
|
+
lte(value: ValueSource): AnyBinaryBuilder;
|
|
107
|
+
asc(): AnyOrderBuilder;
|
|
108
|
+
desc(): AnyOrderBuilder;
|
|
109
|
+
/** Converts this expression builder to the underlying OperationExpr */
|
|
110
|
+
toExpr(): OperationExpr;
|
|
111
|
+
readonly __jsType: JsType$1;
|
|
112
|
+
}
|
|
113
|
+
type AnyColumnBuilderBase = {
|
|
114
|
+
readonly kind: 'column';
|
|
115
|
+
readonly table: string;
|
|
116
|
+
readonly column: string;
|
|
117
|
+
readonly columnMeta: StorageColumn;
|
|
118
|
+
eq(value: ValueSource): AnyBinaryBuilder;
|
|
119
|
+
neq(value: ValueSource): AnyBinaryBuilder;
|
|
120
|
+
gt(value: ValueSource): AnyBinaryBuilder;
|
|
121
|
+
lt(value: ValueSource): AnyBinaryBuilder;
|
|
122
|
+
gte(value: ValueSource): AnyBinaryBuilder;
|
|
123
|
+
lte(value: ValueSource): AnyBinaryBuilder;
|
|
124
|
+
asc(): AnyOrderBuilder;
|
|
125
|
+
desc(): AnyOrderBuilder;
|
|
126
|
+
toExpr(): ColumnRef;
|
|
127
|
+
readonly __jsType: unknown;
|
|
128
|
+
isNull?(): AnyUnaryBuilder;
|
|
129
|
+
isNotNull?(): AnyUnaryBuilder;
|
|
130
|
+
readonly [key: string]: unknown;
|
|
131
|
+
};
|
|
132
|
+
type AnyColumnBuilder = ColumnBuilder<string, StorageColumn, unknown, any> | AnyColumnBuilderBase;
|
|
133
|
+
/**
|
|
134
|
+
* Union type for any builder that can produce an Expression.
|
|
135
|
+
* Used in DSL method signatures where either a column or operation result can be passed.
|
|
136
|
+
*/
|
|
137
|
+
type AnyExpressionSource = AnyColumnBuilder | ExpressionBuilder;
|
|
138
|
+
declare function isColumnBuilder(value: unknown): value is AnyColumnBuilder;
|
|
139
|
+
interface JoinOnBuilder {
|
|
140
|
+
eqCol(left: AnyColumnBuilder, right: AnyColumnBuilder): JoinOnPredicate;
|
|
141
|
+
}
|
|
142
|
+
interface JoinOnPredicate {
|
|
143
|
+
readonly kind: 'join-on';
|
|
144
|
+
readonly left: AnyColumnBuilder;
|
|
145
|
+
readonly right: AnyColumnBuilder;
|
|
146
|
+
}
|
|
147
|
+
type Expr = ColumnRef | ParamRef;
|
|
148
|
+
/**
|
|
149
|
+
* Helper type to extract codec output type from CodecTypes.
|
|
150
|
+
* Returns never if the codecId is not found in CodecTypes.
|
|
151
|
+
*/
|
|
152
|
+
type ExtractCodecOutputType<CodecId extends string, CodecTypes$1 extends Record<string, {
|
|
153
|
+
readonly output: unknown;
|
|
154
|
+
}>> = CodecId extends keyof CodecTypes$1 ? CodecTypes$1[CodecId] extends {
|
|
155
|
+
readonly output: infer Output;
|
|
156
|
+
} ? Output : never : never;
|
|
157
|
+
/**
|
|
158
|
+
* Extracts the model name for a given table from the contract mappings.
|
|
159
|
+
*/
|
|
160
|
+
type ExtractTableToModel<Contract extends SqlContract<SqlStorage>, TableName extends string> = Contract['mappings'] extends {
|
|
161
|
+
readonly tableToModel: infer TableToModel;
|
|
162
|
+
} ? TableToModel extends Record<string, string> ? TableName extends keyof TableToModel ? TableToModel[TableName] : never : never : never;
|
|
163
|
+
/**
|
|
164
|
+
* Extracts the field name for a given table column from the contract mappings.
|
|
165
|
+
*/
|
|
166
|
+
type ExtractColumnToField<Contract extends SqlContract<SqlStorage>, TableName extends string, ColumnName extends string> = Contract['mappings'] extends {
|
|
167
|
+
readonly columnToField: infer ColumnToField;
|
|
168
|
+
} ? ColumnToField extends Record<string, Record<string, string>> ? TableName extends keyof ColumnToField ? ColumnName extends keyof ColumnToField[TableName] ? ColumnToField[TableName][ColumnName] : never : never : never : never;
|
|
169
|
+
/**
|
|
170
|
+
* Extracts the field value type from a model's fields.
|
|
171
|
+
*/
|
|
172
|
+
type ExtractFieldValue<Contract extends SqlContract<SqlStorage>, ModelName$1 extends string, FieldName$1 extends string> = Contract['models'] extends infer Models ? Models extends Record<string, unknown> ? ModelName$1 extends keyof Models ? Models[ModelName$1] extends {
|
|
173
|
+
readonly fields: infer Fields;
|
|
174
|
+
} ? Fields extends Record<string, unknown> ? FieldName$1 extends keyof Fields ? Fields[FieldName$1] : never : never : never : never : never : never;
|
|
175
|
+
/**
|
|
176
|
+
* Extracts the JavaScript type for a column from model mappings if available.
|
|
177
|
+
* Returns `never` if the column maps to a ModelField object (which indicates
|
|
178
|
+
* a relation that should fall through to codec-based type resolution).
|
|
179
|
+
*
|
|
180
|
+
* The check for ModelField uses `Exclude<keyof FieldValue, 'column'> extends never`
|
|
181
|
+
* to ensure we only skip pure `{ column: string }` marker objects, not richer
|
|
182
|
+
* object types that happen to include a `column` property.
|
|
183
|
+
*/
|
|
184
|
+
type ExtractColumnJsTypeFromModels<Contract extends SqlContract<SqlStorage>, TableName extends string, ColumnName extends string> = ExtractTableToModel<Contract, TableName> extends infer ModelName ? ModelName extends string ? ExtractColumnToField<Contract, TableName, ColumnName> extends infer FieldName ? FieldName extends string ? ExtractFieldValue<Contract, ModelName, FieldName> extends infer FieldValue ? FieldValue extends {
|
|
185
|
+
readonly column: string;
|
|
186
|
+
} ? Exclude<keyof FieldValue, 'column'> extends never ? never : FieldValue : FieldValue : never : never : never : never : never;
|
|
187
|
+
/**
|
|
188
|
+
* Resolves type params for a column from either:
|
|
189
|
+
* - inline `columnMeta.typeParams`, or
|
|
190
|
+
* - `columnMeta.typeRef` (resolving into `contract.storage.types[typeRef].typeParams`).
|
|
191
|
+
*/
|
|
192
|
+
type ResolveColumnTypeParams<Contract extends SqlContract<SqlStorage>, ColumnMeta extends StorageColumn> = ColumnMeta extends {
|
|
193
|
+
typeParams: infer Params;
|
|
194
|
+
} ? Params extends object ? Params : undefined : ColumnMeta extends {
|
|
195
|
+
typeRef: infer TypeRef extends string;
|
|
196
|
+
} ? Contract['storage'] extends {
|
|
197
|
+
types: infer Types;
|
|
198
|
+
} ? Types extends Record<string, unknown> ? TypeRef extends keyof Types ? Types[TypeRef] extends {
|
|
199
|
+
typeParams: infer Params;
|
|
200
|
+
} ? Params extends object ? Params : undefined : undefined : undefined : undefined : undefined : undefined;
|
|
201
|
+
/**
|
|
202
|
+
* If a codec entry exposes a type-level parameterized output surface, compute the output type
|
|
203
|
+
* for a specific params object. Falls back to `never` if not supported.
|
|
204
|
+
*
|
|
205
|
+
* This enables lane typing to incorporate `columnMeta.typeParams` without branching on codec IDs
|
|
206
|
+
* in core lane code.
|
|
207
|
+
*/
|
|
208
|
+
type ExtractParameterizedCodecOutputType<CodecId extends string, Params$1, CodecTypes$1 extends Record<string, {
|
|
209
|
+
readonly output: unknown;
|
|
210
|
+
}>> = CodecId extends keyof CodecTypes$1 ? CodecTypes$1[CodecId] extends {
|
|
211
|
+
readonly parameterizedOutput: infer Fn;
|
|
212
|
+
} ? Fn extends ((params: Params$1) => infer Out) ? Out : never : never : never;
|
|
213
|
+
/**
|
|
214
|
+
* Type-level operation signature.
|
|
215
|
+
* Represents an operation at the type level, similar to OperationSignature at runtime.
|
|
216
|
+
*/
|
|
217
|
+
type OperationTypeSignature = {
|
|
218
|
+
readonly args: ReadonlyArray<ArgSpec>;
|
|
219
|
+
readonly returns: ReturnSpec;
|
|
220
|
+
readonly lowering: SqlLoweringSpec;
|
|
221
|
+
readonly capabilities?: ReadonlyArray<string>;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Type-level operation registry.
|
|
225
|
+
* Maps typeId → operations, where operations is a record of method name → operation signature.
|
|
226
|
+
*
|
|
227
|
+
* Example:
|
|
228
|
+
* ```typescript
|
|
229
|
+
* type MyOperations: OperationTypes = {
|
|
230
|
+
* 'pg/vector@1': {
|
|
231
|
+
* cosineDistance: {
|
|
232
|
+
* args: [{ kind: 'typeId'; type: 'pg/vector@1' }];
|
|
233
|
+
* returns: { kind: 'builtin'; type: 'number' };
|
|
234
|
+
* lowering: { targetFamily: 'sql'; strategy: 'function'; template: '...' };
|
|
235
|
+
* };
|
|
236
|
+
* };
|
|
237
|
+
* };
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
type OperationTypes = Record<string, Record<string, OperationTypeSignature>>;
|
|
241
|
+
/**
|
|
242
|
+
* CodecTypes represents a map of typeId to codec definitions.
|
|
243
|
+
* Each codec definition must have an `output` property indicating the JavaScript type.
|
|
244
|
+
*
|
|
245
|
+
* Example:
|
|
246
|
+
* ```typescript
|
|
247
|
+
* type MyCodecTypes: CodecTypes = {
|
|
248
|
+
* 'pg/int4@1': { output: number };
|
|
249
|
+
* 'pg/text@1': { output: string };
|
|
250
|
+
* };
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
type CodecTypes = Record<string, {
|
|
254
|
+
readonly output: unknown;
|
|
255
|
+
}>;
|
|
256
|
+
/**
|
|
257
|
+
* Extracts operations for a given typeId from the operation registry.
|
|
258
|
+
* Returns an empty record if the typeId is not found.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```typescript
|
|
262
|
+
* type Ops = OperationsForTypeId<'pg/vector@1', MyOperations>;
|
|
263
|
+
* // Ops = { cosineDistance: { ... }, l2Distance: { ... } }
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
type OperationsForTypeId<TypeId$1 extends string, Operations extends OperationTypes> = Operations extends Record<string, never> ? Record<string, never> : TypeId$1 extends keyof Operations ? Operations[TypeId$1] : Record<string, never>;
|
|
267
|
+
/**
|
|
268
|
+
* Maps operation signatures to method signatures on ColumnBuilder.
|
|
269
|
+
* Each operation becomes a method that returns a ColumnBuilder or BinaryBuilder
|
|
270
|
+
* based on the return type.
|
|
271
|
+
*/
|
|
272
|
+
type OperationMethods<Ops extends Record<string, OperationTypeSignature>, ColumnName extends string, ColumnMeta extends StorageColumn, JsType$1> = { [K in keyof Ops]: Ops[K] extends OperationTypeSignature ? (...args: OperationArgs<Ops[K]['args']>) => OperationReturn<Ops[K]['returns'], ColumnName, ColumnMeta, JsType$1> : never };
|
|
273
|
+
/**
|
|
274
|
+
* Maps operation argument specs to TypeScript argument types.
|
|
275
|
+
* - typeId args: ColumnBuilder (accepts base columns or operation results)
|
|
276
|
+
* - param args: ParamPlaceholder
|
|
277
|
+
* - literal args: unknown (could be more specific in future)
|
|
278
|
+
*/
|
|
279
|
+
type OperationArgs<Args extends ReadonlyArray<ArgSpec>> = Args extends readonly [infer First, ...infer Rest] ? First extends ArgSpec ? [ArgToType<First>, ...(Rest extends ReadonlyArray<ArgSpec> ? OperationArgs<Rest> : [])] : [] : [];
|
|
280
|
+
type ArgToType<Arg extends ArgSpec> = Arg extends {
|
|
281
|
+
kind: 'typeId';
|
|
282
|
+
} ? AnyExpressionSource : Arg extends {
|
|
283
|
+
kind: 'param';
|
|
284
|
+
} ? ParamPlaceholder : Arg extends {
|
|
285
|
+
kind: 'literal';
|
|
286
|
+
} ? unknown : never;
|
|
287
|
+
/**
|
|
288
|
+
* Maps operation return spec to return type.
|
|
289
|
+
* Operations return ExpressionBuilder, not ColumnBuilder, because the result
|
|
290
|
+
* represents an expression (OperationExpr) rather than a column reference.
|
|
291
|
+
*/
|
|
292
|
+
type OperationReturn<Returns extends ReturnSpec, _ColumnName extends string, _ColumnMeta extends StorageColumn, _JsType> = Returns extends {
|
|
293
|
+
kind: 'builtin';
|
|
294
|
+
type: infer T;
|
|
295
|
+
} ? T extends 'number' ? ExpressionBuilder<number> : T extends 'boolean' ? ExpressionBuilder<boolean> : T extends 'string' ? ExpressionBuilder<string> : ExpressionBuilder<unknown> : Returns extends {
|
|
296
|
+
kind: 'typeId';
|
|
297
|
+
} ? ExpressionBuilder<unknown> : ExpressionBuilder<unknown>;
|
|
298
|
+
/**
|
|
299
|
+
* Computes JavaScript type for a column at column creation time.
|
|
300
|
+
*
|
|
301
|
+
* Type inference:
|
|
302
|
+
* - Read columnMeta.codecId as typeId string literal
|
|
303
|
+
* - Look up CodecTypes[typeId].output
|
|
304
|
+
* - Apply nullability: nullable ? Output | null : Output
|
|
305
|
+
*/
|
|
306
|
+
type ColumnMetaTypeId<ColumnMeta> = ColumnMeta extends {
|
|
307
|
+
codecId: infer CodecId extends string;
|
|
308
|
+
} ? CodecId : ColumnMeta extends {
|
|
309
|
+
type: infer TypeId extends string;
|
|
310
|
+
} ? TypeId : never;
|
|
311
|
+
type ComputeColumnJsType<Contract extends SqlContract<SqlStorage>, TableName extends string, ColumnName extends string, ColumnMeta extends StorageColumn, CodecTypes$1 extends Record<string, {
|
|
312
|
+
readonly output: unknown;
|
|
313
|
+
}>> = ExtractColumnJsTypeFromModels<Contract, TableName, ColumnName> extends infer FromModels ? [FromModels] extends [never] ? ColumnMeta extends {
|
|
314
|
+
nullable: infer Nullable;
|
|
315
|
+
} ? ColumnMetaTypeId<ColumnMeta> extends infer TypeId ? TypeId extends string ? ResolveColumnTypeParams<Contract, ColumnMeta> extends infer Params ? Params extends object ? ExtractParameterizedCodecOutputType<TypeId, Params, CodecTypes$1> extends infer ParamOutput ? [ParamOutput] extends [never] ? ExtractCodecOutputType<TypeId, CodecTypes$1> extends infer CodecOutput ? [CodecOutput] extends [never] ? unknown : Nullable extends true ? CodecOutput | null : CodecOutput : unknown : Nullable extends true ? ParamOutput | null : ParamOutput : unknown : ExtractCodecOutputType<TypeId, CodecTypes$1> extends infer CodecOutput ? [CodecOutput] extends [never] ? unknown : Nullable extends true ? CodecOutput | null : CodecOutput : unknown : unknown : unknown : unknown : unknown : FromModels : unknown;
|
|
316
|
+
/**
|
|
317
|
+
* Infers Row type from a projection object.
|
|
318
|
+
* Maps Record<string, ColumnBuilder> to Record<string, JSType>
|
|
319
|
+
*
|
|
320
|
+
* Extracts the pre-computed JsType from each ColumnBuilder in the projection.
|
|
321
|
+
*/
|
|
322
|
+
/**
|
|
323
|
+
* Extracts the inferred JsType carried by a ColumnBuilder.
|
|
324
|
+
*/
|
|
325
|
+
type ExtractJsTypeFromColumnBuilder<CB extends AnyColumnBuilder> = CB extends ColumnBuilder<infer _ColumnName extends string, infer _ColumnMeta extends StorageColumn, infer JsType, infer _Ops> ? JsType : never;
|
|
326
|
+
type InferProjectionRow<P extends Record<string, AnyColumnBuilder>> = { [K in keyof P]: ExtractJsTypeFromColumnBuilder<P[K]> };
|
|
327
|
+
/**
|
|
328
|
+
* Nested projection type - allows recursive nesting of ColumnBuilder, ExpressionBuilder, or nested objects.
|
|
329
|
+
*/
|
|
330
|
+
type NestedProjection = Record<string, AnyExpressionSource | Record<string, AnyExpressionSource | Record<string, AnyExpressionSource | Record<string, AnyExpressionSource | Record<string, AnyExpressionSource>>>>>;
|
|
331
|
+
/**
|
|
332
|
+
* Helper type to extract include type from Includes map.
|
|
333
|
+
* Returns the value type if K is a key of Includes, otherwise returns unknown.
|
|
334
|
+
*/
|
|
335
|
+
type ExtractIncludeType<K$1 extends string, Includes extends Record<string, unknown>> = K$1 extends keyof Includes ? Includes[K$1] : unknown;
|
|
336
|
+
/**
|
|
337
|
+
* Infers Row type from a nested projection object.
|
|
338
|
+
* Recursively maps Record<string, ColumnBuilder | boolean | NestedProjection> to nested object types.
|
|
339
|
+
*
|
|
340
|
+
* Extracts the pre-computed JsType from each ColumnBuilder at leaves.
|
|
341
|
+
* When a value is `true`, it represents an include reference and infers `Array<ChildShape>`
|
|
342
|
+
* by looking up the include alias in the Includes type map.
|
|
343
|
+
*/
|
|
344
|
+
type InferNestedProjectionRow<P extends Record<string, AnyExpressionSource | boolean | NestedProjection>, CodecTypes$1 extends Record<string, {
|
|
345
|
+
readonly output: unknown;
|
|
346
|
+
}> = Record<string, never>, Includes extends Record<string, unknown> = Record<string, never>> = { [K in keyof P]: P[K] extends ExpressionBuilder<infer JsType> ? JsType : P[K] extends AnyColumnBuilder ? ExtractJsTypeFromColumnBuilder<P[K]> : P[K] extends true ? Array<ExtractIncludeType<K & string, Includes>> : P[K] extends NestedProjection ? InferNestedProjectionRow<P[K], CodecTypes$1, Includes> : never };
|
|
347
|
+
/**
|
|
348
|
+
* Infers Row type from a tuple of ColumnBuilders used in returning() clause.
|
|
349
|
+
* Extracts column name and JsType from each ColumnBuilder and creates a Record.
|
|
350
|
+
*/
|
|
351
|
+
type InferReturningRow<Columns extends readonly AnyColumnBuilder[]> = Columns extends readonly [infer First, ...infer Rest] ? First extends ColumnBuilder<infer Name, infer _Meta, infer JsType, infer _Ops extends OperationTypes> ? Name extends string ? Rest extends readonly AnyColumnBuilder[] ? { [K in Name]: JsType } & InferReturningRow<Rest> : { [K in Name]: JsType } : never : never : Record<string, never>;
|
|
352
|
+
/**
|
|
353
|
+
* Utility type to check if a contract has the required capabilities for includeMany.
|
|
354
|
+
* Requires both `lateral` and `jsonAgg` to be `true` in the contract's capabilities for the target.
|
|
355
|
+
* Capabilities are nested by target: `{ [target]: { lateral: true, jsonAgg: true } }`
|
|
356
|
+
*/
|
|
357
|
+
type HasIncludeManyCapabilities<TContract extends SqlContract<SqlStorage>> = TContract extends {
|
|
358
|
+
capabilities: infer C;
|
|
359
|
+
target: infer T;
|
|
360
|
+
} ? T extends string ? C extends Record<string, Record<string, boolean>> ? C extends { [K in T]: infer TargetCaps } ? TargetCaps extends {
|
|
361
|
+
lateral: true;
|
|
362
|
+
jsonAgg: true;
|
|
363
|
+
} ? true : false : false : false : false : false;
|
|
364
|
+
/**
|
|
365
|
+
* SQL-specific Plan type that refines the ast field to use QueryAst.
|
|
366
|
+
* This is the type used by SQL query builders.
|
|
367
|
+
*/
|
|
368
|
+
type SqlPlan<Row = unknown> = ExecutionPlan<Row, QueryAst>;
|
|
369
|
+
/**
|
|
370
|
+
* Helper types for extracting contract structure.
|
|
371
|
+
*/
|
|
372
|
+
type TablesOf<TContract> = TContract extends {
|
|
373
|
+
storage: {
|
|
374
|
+
tables: infer U;
|
|
375
|
+
};
|
|
376
|
+
} ? U : never;
|
|
377
|
+
type TableKey<TContract> = Extract<keyof TablesOf<TContract>, string>;
|
|
378
|
+
/**
|
|
379
|
+
* Unique symbol for metadata property to avoid collisions with user-defined properties
|
|
380
|
+
*/
|
|
381
|
+
declare const META: unique symbol;
|
|
382
|
+
/**
|
|
383
|
+
* Extracts metadata from a type that has a META property
|
|
384
|
+
*/
|
|
385
|
+
type Meta<T$1 extends {
|
|
386
|
+
[META]: unknown;
|
|
387
|
+
}> = T$1[typeof META];
|
|
388
|
+
/**
|
|
389
|
+
* Metadata interface for table definitions
|
|
390
|
+
*/
|
|
391
|
+
interface TableMetadata<Name$1 extends string> {
|
|
392
|
+
name: Name$1;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Metadata interface for model definitions
|
|
396
|
+
*/
|
|
397
|
+
interface ModelMetadata<Name$1 extends string> {
|
|
398
|
+
name: Name$1;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Base interface for table definitions with metadata
|
|
402
|
+
* Used in contract.d.ts to define storage-level table types
|
|
403
|
+
*/
|
|
404
|
+
interface TableDef<Name$1 extends string> {
|
|
405
|
+
readonly [META]: TableMetadata<Name$1>;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Base interface for model definitions with metadata
|
|
409
|
+
* Used in contract.d.ts to define application-level model types
|
|
410
|
+
*/
|
|
411
|
+
interface ModelDef<Name$1 extends string> {
|
|
412
|
+
readonly [META]: ModelMetadata<Name$1>;
|
|
413
|
+
}
|
|
414
|
+
type ColumnsOf<TContract, K$1 extends TableKey<TContract>> = K$1 extends keyof TablesOf<TContract> ? TablesOf<TContract>[K$1] extends {
|
|
415
|
+
columns: infer C;
|
|
416
|
+
} ? C : never : never;
|
|
417
|
+
interface RawTemplateOptions {
|
|
418
|
+
readonly refs?: PlanRefs;
|
|
419
|
+
readonly annotations?: Record<string, unknown>;
|
|
420
|
+
readonly projection?: ReadonlyArray<string>;
|
|
421
|
+
}
|
|
422
|
+
interface RawFunctionOptions extends RawTemplateOptions {
|
|
423
|
+
readonly params: ReadonlyArray<unknown>;
|
|
424
|
+
}
|
|
425
|
+
type RawTemplateFactory = (strings: TemplateStringsArray, ...values: readonly unknown[]) => ExecutionPlan;
|
|
426
|
+
interface RawFactory extends RawTemplateFactory {
|
|
427
|
+
(text: string, options: RawFunctionOptions): ExecutionPlan;
|
|
428
|
+
with(options: RawTemplateOptions): RawTemplateFactory;
|
|
429
|
+
}
|
|
430
|
+
interface BuildParamsMap {
|
|
431
|
+
readonly [name: string]: unknown;
|
|
432
|
+
}
|
|
433
|
+
interface BuildOptions {
|
|
434
|
+
readonly params?: BuildParamsMap;
|
|
435
|
+
}
|
|
436
|
+
interface SqlBuilderOptions<TContract extends SqlContract<SqlStorage> = SqlContract<SqlStorage>> {
|
|
437
|
+
readonly context: ExecutionContext<TContract>;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* SQL-specific ResultType that works with both Plan and SqlQueryPlan.
|
|
441
|
+
* This extends the core ResultType to also handle SqlQueryPlan.
|
|
442
|
+
* Example: `type Row = ResultType<typeof plan>`
|
|
443
|
+
*/
|
|
444
|
+
type ResultType$1<P> = P extends SqlQueryPlan<infer R> ? R : ResultType<P>;
|
|
445
|
+
//#endregion
|
|
446
|
+
export { OperationTypes as A, SqlBuilderOptions as B, Meta as C, NullCheckBuilder as D, NestedProjection as E, RawFunctionOptions as F, TablesOf as G, TableDef as H, RawTemplateFactory as I, createOrderBuilder as J, UnaryBuilder as K, RawTemplateOptions as L, OrderBuilder as M, ParamPlaceholder as N, NullableMethods as O, RawFactory as P, ResultType$1 as R, META as S, ModelMetadata as T, TableKey as U, SqlPlan as V, TableMetadata as W, isColumnBuilder as Y, InferNestedProjectionRow as _, AnyOrderBuilder as a, JoinOnBuilder as b, BuildOptions as c, ColumnBuilder as d, ColumnsOf as f, HasIncludeManyCapabilities as g, ExpressionBuilder as h, AnyExpressionSource as i, OperationsForTypeId as j, OperationTypeSignature as k, BuildParamsMap as l, Expr as m, AnyColumnBuilder as n, AnyUnaryBuilder as o, ComputeColumnJsType as p, ValueSource as q, AnyColumnBuilderBase as r, BinaryBuilder as s, AnyBinaryBuilder as t, CodecTypes as u, InferProjectionRow as v, ModelDef as w, JoinOnPredicate as x, InferReturningRow as y, RuntimeError as z };
|
|
447
|
+
//# sourceMappingURL=types-CEUzDuDC.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CEUzDuDC.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;UAqBiB,gBAAA;;EAAA,SAAA,IAAA,EAAA,MAAgB;AAWjC;AAEA;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kB,YArGK,CAAA,KAAA,EAAA,CAAA,GAAA,CAAA,GAqGuB,UArGvB,CAqGsC,CArGtC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates an OrderBuilder for use in orderBy clauses.
|
|
4
|
+
*/
|
|
5
|
+
function createOrderBuilder(expr, dir) {
|
|
6
|
+
return {
|
|
7
|
+
kind: "order",
|
|
8
|
+
expr,
|
|
9
|
+
dir
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function isColumnBuilder(value) {
|
|
13
|
+
return typeof value === "object" && value !== null && "kind" in value && value.kind === "column";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
//#endregion
|
|
17
|
+
export { isColumnBuilder as n, createOrderBuilder as t };
|
|
18
|
+
//# sourceMappingURL=types-Cdi4Whda.mjs.map
|