@prisma-next/sql-relational-core 0.3.0-dev.5 → 0.3.0-dev.51

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.
Files changed (173) hide show
  1. package/README.md +18 -2
  2. package/dist/errors-7_V3El9I.mjs +3 -0
  3. package/dist/errors-DVufq9PT.d.mts +2 -0
  4. package/dist/exports/ast.d.mts +192 -0
  5. package/dist/exports/ast.d.mts.map +1 -0
  6. package/dist/exports/ast.mjs +361 -0
  7. package/dist/exports/ast.mjs.map +1 -0
  8. package/dist/exports/errors.d.mts +2 -0
  9. package/dist/exports/errors.mjs +3 -0
  10. package/dist/exports/guards.d.mts +5 -0
  11. package/dist/exports/guards.mjs +3 -0
  12. package/dist/exports/operations-registry.d.mts +5 -0
  13. package/dist/exports/operations-registry.mjs +3 -0
  14. package/dist/exports/param.d.mts +5 -0
  15. package/dist/exports/param.mjs +3 -0
  16. package/dist/exports/plan.d.mts +2 -0
  17. package/dist/exports/plan.mjs +17 -0
  18. package/dist/exports/plan.mjs.map +1 -0
  19. package/dist/exports/query-lane-context.d.mts +2 -0
  20. package/dist/exports/query-lane-context.mjs +1 -0
  21. package/dist/exports/schema.d.mts +5 -0
  22. package/dist/exports/schema.mjs +4 -0
  23. package/dist/exports/types.d.mts +4 -0
  24. package/dist/exports/types.mjs +3 -0
  25. package/dist/exports/utils/guards.d.mts +5 -0
  26. package/dist/exports/utils/guards.mjs +4 -0
  27. package/dist/guards-0ycyntYX.mjs +132 -0
  28. package/dist/guards-0ycyntYX.mjs.map +1 -0
  29. package/dist/guards-DCCpAlOL.d.mts +87 -0
  30. package/dist/guards-DCCpAlOL.d.mts.map +1 -0
  31. package/dist/index.d.mts +12 -0
  32. package/dist/index.mjs +12 -0
  33. package/dist/operations-registry-DPZ5aElH.mjs +152 -0
  34. package/dist/operations-registry-DPZ5aElH.mjs.map +1 -0
  35. package/dist/operations-registry-wVEaiLyt.d.mts +9 -0
  36. package/dist/operations-registry-wVEaiLyt.d.mts.map +1 -0
  37. package/dist/param-C4n0OW59.d.mts +8 -0
  38. package/dist/param-C4n0OW59.d.mts.map +1 -0
  39. package/dist/param-DMU3OWfI.mjs +14 -0
  40. package/dist/param-DMU3OWfI.mjs.map +1 -0
  41. package/dist/plan-BhSWuTfw.d.mts +194 -0
  42. package/dist/plan-BhSWuTfw.d.mts.map +1 -0
  43. package/dist/query-lane-context-CgkPuKaR.d.mts +259 -0
  44. package/dist/query-lane-context-CgkPuKaR.d.mts.map +1 -0
  45. package/dist/schema-Bi5p4aAc.mjs +175 -0
  46. package/dist/schema-Bi5p4aAc.mjs.map +1 -0
  47. package/dist/schema-CgrEMqEd.d.mts +86 -0
  48. package/dist/schema-CgrEMqEd.d.mts.map +1 -0
  49. package/dist/types-CEUzDuDC.d.mts +447 -0
  50. package/dist/types-CEUzDuDC.d.mts.map +1 -0
  51. package/dist/types-Cdi4Whda.mjs +18 -0
  52. package/dist/types-Cdi4Whda.mjs.map +1 -0
  53. package/package.json +39 -56
  54. package/src/ast/codec-types.ts +77 -8
  55. package/src/ast/delete.ts +2 -2
  56. package/src/ast/driver-types.ts +20 -3
  57. package/src/ast/predicate.ts +14 -4
  58. package/src/ast/select.ts +4 -3
  59. package/src/ast/sql-codecs.ts +67 -0
  60. package/src/ast/types.ts +89 -19
  61. package/src/ast/update.ts +2 -2
  62. package/src/exports/ast.ts +1 -0
  63. package/src/exports/guards.ts +5 -0
  64. package/src/exports/utils/guards.ts +1 -0
  65. package/src/operations-registry.ts +112 -73
  66. package/src/query-lane-context.ts +77 -1
  67. package/src/schema.ts +91 -33
  68. package/src/types.ts +327 -75
  69. package/src/utils/guards.ts +88 -18
  70. package/dist/ast/adapter-types.d.ts +0 -28
  71. package/dist/ast/adapter-types.d.ts.map +0 -1
  72. package/dist/ast/codec-types.d.ts +0 -141
  73. package/dist/ast/codec-types.d.ts.map +0 -1
  74. package/dist/ast/common.d.ts +0 -7
  75. package/dist/ast/common.d.ts.map +0 -1
  76. package/dist/ast/delete.d.ts +0 -8
  77. package/dist/ast/delete.d.ts.map +0 -1
  78. package/dist/ast/driver-types.d.ts +0 -20
  79. package/dist/ast/driver-types.d.ts.map +0 -1
  80. package/dist/ast/insert.d.ts +0 -8
  81. package/dist/ast/insert.d.ts.map +0 -1
  82. package/dist/ast/join.d.ts +0 -6
  83. package/dist/ast/join.d.ts.map +0 -1
  84. package/dist/ast/order.d.ts +0 -6
  85. package/dist/ast/order.d.ts.map +0 -1
  86. package/dist/ast/predicate.d.ts +0 -4
  87. package/dist/ast/predicate.d.ts.map +0 -1
  88. package/dist/ast/select.d.ts +0 -18
  89. package/dist/ast/select.d.ts.map +0 -1
  90. package/dist/ast/types.d.ts +0 -118
  91. package/dist/ast/types.d.ts.map +0 -1
  92. package/dist/ast/update.d.ts +0 -9
  93. package/dist/ast/update.d.ts.map +0 -1
  94. package/dist/ast/util.d.ts +0 -2
  95. package/dist/ast/util.d.ts.map +0 -1
  96. package/dist/chunk-2F7DSEOU.js +0 -8
  97. package/dist/chunk-2F7DSEOU.js.map +0 -1
  98. package/dist/chunk-36WJWNHT.js +0 -1
  99. package/dist/chunk-36WJWNHT.js.map +0 -1
  100. package/dist/chunk-5N34PNVZ.js +0 -62
  101. package/dist/chunk-5N34PNVZ.js.map +0 -1
  102. package/dist/chunk-7I3EMQID.js +0 -16
  103. package/dist/chunk-7I3EMQID.js.map +0 -1
  104. package/dist/chunk-CBTYMOX2.js +0 -152
  105. package/dist/chunk-CBTYMOX2.js.map +0 -1
  106. package/dist/chunk-G52ENULI.js +0 -1
  107. package/dist/chunk-G52ENULI.js.map +0 -1
  108. package/dist/chunk-KYSP7L5C.js +0 -16
  109. package/dist/chunk-KYSP7L5C.js.map +0 -1
  110. package/dist/chunk-M23L3JHG.js +0 -159
  111. package/dist/chunk-M23L3JHG.js.map +0 -1
  112. package/dist/chunk-MM74SVJ4.js +0 -13
  113. package/dist/chunk-MM74SVJ4.js.map +0 -1
  114. package/dist/chunk-U7AXAUJA.js +0 -1
  115. package/dist/chunk-U7AXAUJA.js.map +0 -1
  116. package/dist/chunk-WZBPVEZI.js +0 -320
  117. package/dist/chunk-WZBPVEZI.js.map +0 -1
  118. package/dist/errors.d.ts +0 -2
  119. package/dist/errors.d.ts.map +0 -1
  120. package/dist/exports/ast.d.ts +0 -14
  121. package/dist/exports/ast.d.ts.map +0 -1
  122. package/dist/exports/ast.js +0 -46
  123. package/dist/exports/ast.js.map +0 -1
  124. package/dist/exports/errors.d.ts +0 -2
  125. package/dist/exports/errors.d.ts.map +0 -1
  126. package/dist/exports/errors.js +0 -9
  127. package/dist/exports/errors.js.map +0 -1
  128. package/dist/exports/guards.d.ts +0 -2
  129. package/dist/exports/guards.d.ts.map +0 -1
  130. package/dist/exports/guards.js +0 -21
  131. package/dist/exports/guards.js.map +0 -1
  132. package/dist/exports/operations-registry.d.ts +0 -2
  133. package/dist/exports/operations-registry.d.ts.map +0 -1
  134. package/dist/exports/operations-registry.js +0 -9
  135. package/dist/exports/operations-registry.js.map +0 -1
  136. package/dist/exports/param.d.ts +0 -3
  137. package/dist/exports/param.d.ts.map +0 -1
  138. package/dist/exports/param.js +0 -7
  139. package/dist/exports/param.js.map +0 -1
  140. package/dist/exports/plan.d.ts +0 -2
  141. package/dist/exports/plan.d.ts.map +0 -1
  142. package/dist/exports/plan.js +0 -7
  143. package/dist/exports/plan.js.map +0 -1
  144. package/dist/exports/query-lane-context.d.ts +0 -2
  145. package/dist/exports/query-lane-context.d.ts.map +0 -1
  146. package/dist/exports/query-lane-context.js +0 -2
  147. package/dist/exports/query-lane-context.js.map +0 -1
  148. package/dist/exports/schema.d.ts +0 -3
  149. package/dist/exports/schema.d.ts.map +0 -1
  150. package/dist/exports/schema.js +0 -14
  151. package/dist/exports/schema.js.map +0 -1
  152. package/dist/exports/types.d.ts +0 -2
  153. package/dist/exports/types.d.ts.map +0 -1
  154. package/dist/exports/types.js +0 -10
  155. package/dist/exports/types.js.map +0 -1
  156. package/dist/index.d.ts +0 -9
  157. package/dist/index.d.ts.map +0 -1
  158. package/dist/index.js +0 -81
  159. package/dist/index.js.map +0 -1
  160. package/dist/operations-registry.d.ts +0 -5
  161. package/dist/operations-registry.d.ts.map +0 -1
  162. package/dist/param.d.ts +0 -4
  163. package/dist/param.d.ts.map +0 -1
  164. package/dist/plan.d.ts +0 -23
  165. package/dist/plan.d.ts.map +0 -1
  166. package/dist/query-lane-context.d.ts +0 -16
  167. package/dist/query-lane-context.d.ts.map +0 -1
  168. package/dist/schema.d.ts +0 -63
  169. package/dist/schema.d.ts.map +0 -1
  170. package/dist/types.d.ts +0 -332
  171. package/dist/types.d.ts.map +0 -1
  172. package/dist/utils/guards.d.ts +0 -55
  173. package/dist/utils/guards.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.mjs","names":["codec","codecs","codecTypes: Record<string, { readonly input: unknown; readonly output: unknown }>","result: Record<\n string,\n {\n typeId: string;\n scalar: string;\n codec: Codec;\n input: unknown;\n output: unknown;\n jsType: unknown;\n }\n >","out: Record<string, unknown>","arktype"],"sources":["../../src/ast/codec-types.ts","../../src/ast/util.ts","../../src/ast/common.ts","../../src/ast/delete.ts","../../src/ast/insert.ts","../../src/ast/join.ts","../../src/ast/order.ts","../../src/ast/predicate.ts","../../src/ast/select.ts","../../src/ast/sql-codecs.ts","../../src/ast/types.ts","../../src/ast/update.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\nimport type { Type } from 'arktype';\nimport type { O } from 'ts-toolbelt';\n\n/**\n * Descriptor for parameterized codecs that require type parameter validation.\n * Shared between adapter (compile-time) and runtime layers to avoid duplication.\n *\n * @template TParams - The shape of the type parameters (e.g., `{ length: number }`)\n * @template THelper - The type returned by the optional `init` hook\n */\nexport interface CodecParamsDescriptor<TParams = Record<string, unknown>, THelper = unknown> {\n /** The codec ID this descriptor applies to (e.g., 'pg/vector@1') */\n readonly codecId: string;\n\n /**\n * Arktype schema for validating typeParams.\n * Used to validate both storage.types entries and inline column typeParams.\n */\n readonly paramsSchema: Type<TParams>;\n\n /**\n * Optional init hook called during runtime context creation.\n * Receives validated params and returns a helper object to be stored in context.types.\n * If not provided, the validated params are stored directly.\n */\n readonly init?: (params: TParams) => THelper;\n}\n\n/**\n * Codec metadata for database-specific type information.\n * Used for schema introspection and verification.\n */\nexport interface CodecMeta {\n readonly db?: {\n readonly sql?: {\n readonly postgres?: {\n readonly nativeType: string; // e.g. 'integer', 'text', 'vector', 'timestamp with time zone'\n };\n };\n };\n}\n\n/**\n * Codec interface for encoding/decoding values between wire format and JavaScript types.\n *\n * Codecs are pure, synchronous functions with no side effects or IO.\n * They provide deterministic conversion between database wire types and JS values.\n */\nexport interface Codec<\n Id extends string = string,\n TWire = unknown,\n TJs = unknown,\n TParams = Record<string, unknown>,\n THelper = unknown,\n> {\n /**\n * Namespaced codec identifier in format 'namespace/name@version'\n * Examples: 'pg/text@1', 'pg/uuid@1', 'pg/timestamptz@1'\n */\n readonly id: Id;\n\n /**\n * Contract scalar type IDs that this codec can handle.\n * Examples: ['text'], ['int4', 'float8'], ['timestamp', 'timestamptz']\n */\n readonly targetTypes: readonly string[];\n\n /**\n * Optional metadata for database-specific type information.\n * Used for schema introspection and verification.\n */\n readonly meta?: CodecMeta;\n\n /**\n * Optional params schema for parameterized codecs.\n * If provided, typeParams are validated against this schema.\n */\n readonly paramsSchema?: Type<TParams>;\n\n /**\n * Optional init hook for building runtime helper state from validated params.\n *\n * Useful when parameterized types need derived data at runtime, for example:\n * - normalize typeParams into a stable helper shape consumed by lanes/adapters\n * - precompute reusable values once during context creation\n * - avoid repeating typeParams parsing logic during query execution\n *\n * Example:\n * { length: 255 } -> { kind: 'variable', maxLength: 255 }\n *\n * **Convention for JSON/JSONB codecs**: When the helper includes a `validate`\n * property of type `JsonSchemaValidateFn`, the runtime will use it to enforce\n * JSON Schema conformance during encoding and decoding. The property is\n * discovered via duck typing (`helper?.validate`) for flexibility across\n * different codec types.\n */\n readonly init?: (params: TParams) => THelper;\n\n /**\n * Decode a wire value (from database) to JavaScript type.\n * Must be synchronous and pure (no side effects).\n */\n decode(wire: TWire): TJs;\n\n /**\n * Encode a JavaScript value to wire format (for database).\n * Optional - if not provided, values pass through unchanged.\n * Must be synchronous and pure (no side effects).\n */\n encode?(value: TJs): TWire;\n}\n\n/**\n * Registry interface for codecs organized by ID and by contract scalar type.\n *\n * The registry allows looking up codecs by their namespaced ID or by the\n * contract scalar types they handle. Multiple codecs may handle the same\n * scalar type; ordering in byScalar reflects preference (adapter first,\n * then packs, then app overrides).\n */\nexport interface CodecRegistry {\n get(id: string): Codec<string> | undefined;\n has(id: string): boolean;\n getByScalar(scalar: string): readonly Codec<string>[];\n getDefaultCodec(scalar: string): Codec<string> | undefined;\n register(codec: Codec<string>): void;\n [Symbol.iterator](): Iterator<Codec<string>>;\n values(): IterableIterator<Codec<string>>;\n}\n\n/**\n * Implementation of CodecRegistry.\n */\nclass CodecRegistryImpl implements CodecRegistry {\n private readonly _byId = new Map<string, Codec<string>>();\n private readonly _byScalar = new Map<string, Codec<string>[]>();\n\n /**\n * Map-like interface for codec lookup by ID.\n * Example: registry.get('pg/text@1')\n */\n get(id: string): Codec<string> | undefined {\n return this._byId.get(id);\n }\n\n /**\n * Check if a codec with the given ID is registered.\n */\n has(id: string): boolean {\n return this._byId.has(id);\n }\n\n /**\n * Get all codecs that handle a given scalar type.\n * Returns an empty frozen array if no codecs are found.\n * Example: registry.getByScalar('text') → [codec1, codec2, ...]\n */\n getByScalar(scalar: string): readonly Codec<string>[] {\n return this._byScalar.get(scalar) ?? Object.freeze([]);\n }\n\n /**\n * Get the default codec for a scalar type (first registered codec).\n * Returns undefined if no codec handles this scalar type.\n */\n getDefaultCodec(scalar: string): Codec<string> | undefined {\n const _codecs = this._byScalar.get(scalar);\n return _codecs?.[0];\n }\n\n /**\n * Register a codec in the registry.\n * Throws an error if a codec with the same ID is already registered.\n *\n * @param codec - The codec to register\n * @throws Error if a codec with the same ID already exists\n */\n register(codec: Codec<string>): void {\n if (this._byId.has(codec.id)) {\n throw new Error(`Codec with ID '${codec.id}' is already registered`);\n }\n\n this._byId.set(codec.id, codec);\n\n // Update byScalar mapping\n for (const scalarType of codec.targetTypes) {\n const existing = this._byScalar.get(scalarType);\n if (existing) {\n existing.push(codec);\n } else {\n this._byScalar.set(scalarType, [codec]);\n }\n }\n }\n\n /**\n * Returns an iterator over all registered codecs.\n * Useful for iterating through codecs from another registry.\n */\n *[Symbol.iterator](): Iterator<Codec<string>> {\n for (const codec of this._byId.values()) {\n yield codec;\n }\n }\n\n /**\n * Returns an iterable of all registered codecs.\n */\n values(): IterableIterator<Codec<string>> {\n return this._byId.values();\n }\n}\n\n/**\n * Codec factory - creates a codec with typeId and encode/decode functions.\n */\nexport function codec<\n Id extends string,\n TWire,\n TJs,\n TParams = Record<string, unknown>,\n THelper = unknown,\n>(config: {\n typeId: Id;\n targetTypes: readonly string[];\n encode: (value: TJs) => TWire;\n decode: (wire: TWire) => TJs;\n meta?: CodecMeta;\n paramsSchema?: Type<TParams>;\n init?: (params: TParams) => THelper;\n}): Codec<Id, TWire, TJs, TParams, THelper> {\n return {\n id: config.typeId,\n targetTypes: config.targetTypes,\n ...ifDefined('meta', config.meta),\n ...ifDefined('paramsSchema', config.paramsSchema),\n ...ifDefined('init', config.init),\n encode: config.encode,\n decode: config.decode,\n };\n}\n\n/**\n * Type helpers to extract codec types.\n */\nexport type CodecId<T> =\n T extends Codec<infer Id, unknown, unknown>\n ? Id\n : T extends { readonly id: infer Id }\n ? Id\n : never;\nexport type CodecInput<T> = T extends Codec<string, unknown, infer JsT> ? JsT : never;\nexport type CodecOutput<T> = T extends Codec<string, unknown, infer JsT> ? JsT : never;\n\n/**\n * Type helper to extract codec types from builder instance.\n */\nexport type ExtractCodecTypes<\n ScalarNames extends { readonly [K in keyof ScalarNames]: Codec<string> } = Record<never, never>,\n> = {\n readonly [K in keyof ScalarNames as ScalarNames[K] extends Codec<infer Id, unknown, unknown>\n ? Id\n : never]: {\n readonly input: CodecInput<ScalarNames[K]>;\n readonly output: CodecOutput<ScalarNames[K]>;\n };\n};\n\n/**\n * Type helper to extract data type IDs from builder instance.\n * Uses ExtractCodecTypes which preserves literal types as keys.\n * Since ExtractCodecTypes<Record<K, ScalarNames[K]>> has exactly one key (the Id),\n * we extract it by creating a mapped type that uses the Id as both key and value,\n * then extract the value type. This preserves literal types.\n */\nexport type ExtractDataTypes<\n ScalarNames extends { readonly [K in keyof ScalarNames]: Codec<string> },\n> = {\n readonly [K in keyof ScalarNames]: {\n readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;\n }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];\n};\n\n/**\n * Builder interface for declaring codecs.\n */\nexport interface CodecDefBuilder<\n ScalarNames extends { readonly [K in keyof ScalarNames]: Codec<string> } = Record<never, never>,\n> {\n readonly CodecTypes: ExtractCodecTypes<ScalarNames>;\n\n add<ScalarName extends string, CodecImpl extends Codec<string>>(\n scalarName: ScalarName,\n codecImpl: CodecImpl,\n ): CodecDefBuilder<\n O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>\n >;\n\n readonly codecDefinitions: {\n readonly [K in keyof ScalarNames]: {\n readonly typeId: ScalarNames[K] extends Codec<infer Id extends string, unknown, unknown>\n ? Id\n : never;\n readonly scalar: K;\n readonly codec: ScalarNames[K];\n readonly input: CodecInput<ScalarNames[K]>;\n readonly output: CodecOutput<ScalarNames[K]>;\n readonly jsType: CodecOutput<ScalarNames[K]>;\n };\n };\n\n readonly dataTypes: {\n readonly [K in keyof ScalarNames]: {\n readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;\n }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];\n };\n}\n\n/**\n * Implementation of CodecDefBuilder.\n */\nclass CodecDefBuilderImpl<\n ScalarNames extends { readonly [K in keyof ScalarNames]: Codec<string> } = Record<never, never>,\n> implements CodecDefBuilder<ScalarNames>\n{\n private readonly _codecs: ScalarNames;\n\n public readonly CodecTypes: ExtractCodecTypes<ScalarNames>;\n public readonly dataTypes: {\n readonly [K in keyof ScalarNames]: {\n readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;\n }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];\n };\n\n constructor(codecs: ScalarNames) {\n this._codecs = codecs;\n\n // Populate CodecTypes from codecs\n const codecTypes: Record<string, { readonly input: unknown; readonly output: unknown }> = {};\n for (const [, codecImpl] of Object.entries(this._codecs)) {\n const codecImplTyped = codecImpl as Codec<string>;\n codecTypes[codecImplTyped.id] = {\n input: undefined as unknown as CodecInput<typeof codecImplTyped>,\n output: undefined as unknown as CodecOutput<typeof codecImplTyped>,\n };\n }\n this.CodecTypes = codecTypes as ExtractCodecTypes<ScalarNames>;\n\n // Populate dataTypes from codecs - extract id property from each codec\n // Build object preserving keys from ScalarNames\n // Type assertion is safe because we know ScalarNames structure matches the return type\n // biome-ignore lint/suspicious/noExplicitAny: dynamic codec mapping requires any\n const dataTypes = {} as any;\n for (const key in this._codecs) {\n if (Object.hasOwn(this._codecs, key)) {\n const codec = this._codecs[key] as Codec<string>;\n dataTypes[key] = codec.id;\n }\n }\n this.dataTypes = dataTypes as {\n readonly [K in keyof ScalarNames]: {\n readonly [Id in keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>]: Id;\n }[keyof ExtractCodecTypes<Record<K, ScalarNames[K]>>];\n };\n }\n\n add<ScalarName extends string, CodecImpl extends Codec<string>>(\n scalarName: ScalarName,\n codecImpl: CodecImpl,\n ): CodecDefBuilder<\n O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>\n > {\n return new CodecDefBuilderImpl({\n ...this._codecs,\n [scalarName]: codecImpl,\n } as O.Overwrite<ScalarNames, Record<ScalarName, CodecImpl>> & Record<ScalarName, CodecImpl>);\n }\n\n /**\n * Derive codecDefinitions structure.\n */\n get codecDefinitions(): {\n readonly [K in keyof ScalarNames]: {\n readonly typeId: ScalarNames[K] extends Codec<infer Id, unknown, unknown> ? Id : never;\n readonly scalar: K;\n readonly codec: ScalarNames[K];\n readonly input: CodecInput<ScalarNames[K]>;\n readonly output: CodecOutput<ScalarNames[K]>;\n readonly jsType: CodecOutput<ScalarNames[K]>;\n };\n } {\n const result: Record<\n string,\n {\n typeId: string;\n scalar: string;\n codec: Codec;\n input: unknown;\n output: unknown;\n jsType: unknown;\n }\n > = {};\n\n for (const [scalarName, codecImpl] of Object.entries(this._codecs)) {\n const codec = codecImpl as Codec<string>;\n result[scalarName] = {\n typeId: codec.id,\n scalar: scalarName,\n codec: codec,\n input: undefined as unknown as CodecInput<typeof codec>,\n output: undefined as unknown as CodecOutput<typeof codec>,\n jsType: undefined as unknown as CodecOutput<typeof codec>,\n };\n }\n\n return result as {\n readonly [K in keyof ScalarNames]: {\n readonly typeId: ScalarNames[K] extends Codec<infer Id extends string, unknown, unknown>\n ? Id\n : never;\n readonly scalar: K;\n readonly codec: ScalarNames[K];\n readonly input: CodecInput<ScalarNames[K]>;\n readonly output: CodecOutput<ScalarNames[K]>;\n readonly jsType: CodecOutput<ScalarNames[K]>;\n };\n };\n }\n}\n\n/**\n * Create a new codec registry.\n */\nexport function createCodecRegistry(): CodecRegistry {\n return new CodecRegistryImpl();\n}\n\n/**\n * Create a new codec definition builder.\n */\nexport function defineCodecs(): CodecDefBuilder<Record<never, never>> {\n return new CodecDefBuilderImpl({});\n}\n","export function compact<T extends Record<string, unknown>>(o: T): T {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(o)) {\n if (v === undefined || v === null) continue;\n if (Array.isArray(v) && v.length === 0) continue;\n out[k] = v;\n }\n return out as T;\n}\n","import type { ColumnRef, LiteralExpr, OperationExpr, ParamRef, TableRef } from './types';\nimport { compact } from './util';\n\nexport function createTableRef(name: string): TableRef {\n return {\n kind: 'table',\n name,\n };\n}\n\nexport function createColumnRef(table: string, column: string): ColumnRef {\n return {\n kind: 'col',\n table,\n column,\n };\n}\n\nexport function createParamRef(index: number, name?: string): ParamRef {\n return compact({\n kind: 'param',\n index,\n name,\n }) as ParamRef;\n}\n\nexport function createOperationExpr(operation: OperationExpr): OperationExpr {\n return operation;\n}\n\nexport function createLiteralExpr(value: unknown): LiteralExpr {\n return {\n kind: 'literal',\n value,\n };\n}\n","import type { ColumnRef, DeleteAst, TableRef, WhereExpr } from './types';\nimport { compact } from './util';\n\nexport interface CreateDeleteAstOptions {\n readonly table: TableRef;\n readonly where: WhereExpr;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport function createDeleteAst(options: CreateDeleteAstOptions): DeleteAst {\n return compact({\n kind: 'delete',\n table: options.table,\n where: options.where,\n returning: options.returning,\n }) as DeleteAst;\n}\n","import type { ColumnRef, InsertAst, ParamRef, TableRef } from './types';\nimport { compact } from './util';\n\nexport interface CreateInsertAstOptions {\n readonly table: TableRef;\n readonly values: Record<string, ColumnRef | ParamRef>;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport function createInsertAst(options: CreateInsertAstOptions): InsertAst {\n return compact({\n kind: 'insert',\n table: options.table,\n values: options.values,\n returning: options.returning,\n }) as InsertAst;\n}\n","import { planInvalid } from '@prisma-next/plan';\nimport type { AnyColumnBuilder, JoinOnBuilder, JoinOnPredicate } from '../types';\nimport { isColumnBuilder } from '../types';\nimport type { ColumnRef, JoinAst, JoinOnExpr, TableRef } from './types';\n\nexport function createJoin(\n joinType: 'inner' | 'left' | 'right' | 'full',\n table: TableRef,\n on: JoinOnExpr,\n): JoinAst {\n return {\n kind: 'join',\n joinType,\n table,\n on,\n };\n}\n\nexport function createJoinOnExpr(left: ColumnRef, right: ColumnRef): JoinOnExpr {\n return {\n kind: 'eqCol',\n left,\n right,\n };\n}\n\nclass JoinOnBuilderImpl implements JoinOnBuilder {\n eqCol(left: AnyColumnBuilder, right: AnyColumnBuilder): JoinOnPredicate {\n if (!left || !isColumnBuilder(left)) {\n throw planInvalid('Join ON left operand must be a column');\n }\n\n if (!right || !isColumnBuilder(right)) {\n throw planInvalid('Join ON right operand must be a column');\n }\n\n // TypeScript can't narrow ColumnBuilder properly, so we assert\n const leftCol = left as unknown as { table: string; column: string };\n const rightCol = right as unknown as { table: string; column: string };\n if (leftCol.table === rightCol.table) {\n throw planInvalid('Self-joins are not supported in MVP');\n }\n\n return {\n kind: 'join-on',\n left: left as AnyColumnBuilder,\n right: right as AnyColumnBuilder,\n };\n }\n}\n\nexport function createJoinOnBuilder(): JoinOnBuilder {\n return new JoinOnBuilderImpl();\n}\n","import type { ColumnRef, Direction, OperationExpr } from './types';\n\nexport function createOrderByItem(\n expr: ColumnRef | OperationExpr,\n dir: 'asc' | 'desc',\n): { expr: ColumnRef | OperationExpr; dir: Direction } {\n return {\n expr,\n dir,\n };\n}\n","import type {\n BinaryExpr,\n BinaryOp,\n ExistsExpr,\n Expression,\n ListLiteralExpr,\n LiteralExpr,\n NullCheckExpr,\n ParamRef,\n SelectAst,\n} from './types';\n\nexport function createBinaryExpr(\n op: BinaryOp,\n left: Expression,\n right: Expression | ParamRef | LiteralExpr | ListLiteralExpr,\n): BinaryExpr {\n return {\n kind: 'bin',\n op,\n left,\n right,\n };\n}\n\nexport function createExistsExpr(not: boolean, subquery: SelectAst): ExistsExpr {\n return {\n kind: 'exists',\n not,\n subquery,\n };\n}\n\nexport function createNullCheckExpr(expr: Expression, isNull: boolean): NullCheckExpr {\n return {\n kind: 'nullCheck',\n expr,\n isNull,\n };\n}\n","import type {\n ColumnRef,\n Direction,\n IncludeAst,\n IncludeRef,\n JoinAst,\n OperationExpr,\n SelectAst,\n TableRef,\n WhereExpr,\n} from './types';\nimport { compact } from './util';\n\nexport interface CreateSelectAstOptions {\n readonly from: TableRef;\n readonly joins?: ReadonlyArray<JoinAst>;\n readonly includes?: ReadonlyArray<IncludeAst>;\n readonly project: ReadonlyArray<{\n alias: string;\n expr: ColumnRef | IncludeRef | OperationExpr;\n }>;\n readonly where?: WhereExpr;\n readonly orderBy?: ReadonlyArray<{ expr: ColumnRef | OperationExpr; dir: Direction }>;\n readonly limit?: number;\n readonly selectAllIntent?: { table?: string };\n}\n\nexport function createSelectAst(options: CreateSelectAstOptions): SelectAst {\n return compact({\n kind: 'select',\n from: options.from,\n joins: options.joins,\n includes: options.includes,\n project: options.project,\n where: options.where,\n orderBy: options.orderBy,\n limit: options.limit,\n selectAllIntent: options.selectAllIntent,\n }) as SelectAst;\n}\n","import { type as arktype } from 'arktype';\nimport { codec, defineCodecs } from './codec-types';\n\nexport const SQL_CHAR_CODEC_ID = 'sql/char@1' as const;\nexport const SQL_VARCHAR_CODEC_ID = 'sql/varchar@1' as const;\nexport const SQL_INT_CODEC_ID = 'sql/int@1' as const;\nexport const SQL_FLOAT_CODEC_ID = 'sql/float@1' as const;\n\nconst lengthParamsSchema = arktype({\n length: 'number.integer > 0',\n});\n\ntype LengthTypeHelper = {\n readonly kind: 'fixed' | 'variable';\n readonly maxLength: number;\n};\n\nfunction createLengthTypeHelper(\n kind: LengthTypeHelper['kind'],\n): (params: Record<string, unknown>) => LengthTypeHelper {\n return (params) => ({\n kind,\n maxLength: params['length'] as number,\n });\n}\n\nconst sqlCharCodec = codec<typeof SQL_CHAR_CODEC_ID, string, string>({\n typeId: SQL_CHAR_CODEC_ID,\n targetTypes: ['char'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire.trimEnd(),\n paramsSchema: lengthParamsSchema,\n init: createLengthTypeHelper('fixed'),\n});\n\nconst sqlVarcharCodec = codec<typeof SQL_VARCHAR_CODEC_ID, string, string>({\n typeId: SQL_VARCHAR_CODEC_ID,\n targetTypes: ['varchar'],\n encode: (value: string): string => value,\n decode: (wire: string): string => wire,\n paramsSchema: lengthParamsSchema,\n init: createLengthTypeHelper('variable'),\n});\n\nconst sqlIntCodec = codec<typeof SQL_INT_CODEC_ID, number, number>({\n typeId: SQL_INT_CODEC_ID,\n targetTypes: ['int'],\n encode: (value) => value,\n decode: (wire) => wire,\n});\n\nconst sqlFloatCodec = codec<typeof SQL_FLOAT_CODEC_ID, number, number>({\n typeId: SQL_FLOAT_CODEC_ID,\n targetTypes: ['float'],\n encode: (value) => value,\n decode: (wire) => wire,\n});\n\nconst codecs = defineCodecs()\n .add('char', sqlCharCodec)\n .add('varchar', sqlVarcharCodec)\n .add('int', sqlIntCodec)\n .add('float', sqlFloatCodec);\n\nexport const sqlCodecDefinitions = codecs.codecDefinitions;\nexport const sqlDataTypes = codecs.dataTypes;\nexport type SqlCodecTypes = typeof codecs.CodecTypes;\n","import type { ParamDescriptor } from '@prisma-next/contract/types';\nimport type { ReturnSpec } from '@prisma-next/operations';\nimport type { SqlLoweringSpec } from '@prisma-next/sql-operations';\n\n// SQL-specific AST types and supporting types\n// These types are needed by adapters and runtime for SQL query execution\n\nexport type Direction = 'asc' | 'desc';\n\nexport interface TableRef {\n readonly kind: 'table';\n readonly name: string;\n}\n\nexport interface ColumnRef {\n readonly kind: 'col';\n readonly table: string;\n readonly column: string;\n}\n\nexport interface ParamRef {\n readonly kind: 'param';\n readonly index: number;\n readonly name?: string;\n}\n\nexport interface LiteralExpr {\n readonly kind: 'literal';\n readonly value: unknown;\n}\n\nexport interface OperationExpr {\n readonly kind: 'operation';\n readonly method: string;\n readonly forTypeId: string;\n readonly self: Expression;\n readonly args: ReadonlyArray<Expression | ParamRef | LiteralExpr>;\n readonly returns: ReturnSpec;\n readonly lowering: SqlLoweringSpec;\n}\n\n/**\n * Unified expression type - the canonical AST representation for column references\n * and operation expressions. This is what all builders convert to via toExpr().\n */\nexport type Expression = ColumnRef | OperationExpr;\n\n/**\n * Interface for any builder that can produce an Expression.\n * Implemented by ColumnBuilder and ExpressionBuilder.\n */\nexport interface ExpressionSource {\n toExpr(): Expression;\n}\n\nexport function isOperationExpr(expr: Expression): expr is OperationExpr {\n return expr.kind === 'operation';\n}\n\nexport type BinaryOp =\n | 'eq'\n | 'neq'\n | 'gt'\n | 'lt'\n | 'gte'\n | 'lte'\n | 'like'\n | 'ilike'\n | 'in'\n | 'notIn';\n\nexport interface BinaryExpr {\n readonly kind: 'bin';\n readonly op: BinaryOp;\n readonly left: Expression;\n readonly right: Expression | ParamRef | LiteralExpr | ListLiteralExpr;\n}\n\nexport interface ListLiteralExpr {\n readonly kind: 'listLiteral';\n readonly values: ReadonlyArray<ParamRef | LiteralExpr>;\n}\n\nexport interface AndExpr {\n readonly kind: 'and';\n readonly exprs: ReadonlyArray<WhereExpr>;\n}\n\nexport interface OrExpr {\n readonly kind: 'or';\n readonly exprs: ReadonlyArray<WhereExpr>;\n}\n\nexport interface ExistsExpr {\n readonly kind: 'exists';\n readonly not: boolean;\n readonly subquery: SelectAst;\n}\n\n/**\n * Unary expression for IS NULL / IS NOT NULL checks.\n * Used in WHERE clauses to check for null values.\n */\nexport interface NullCheckExpr {\n readonly kind: 'nullCheck';\n readonly expr: Expression;\n readonly isNull: boolean;\n}\n\n/**\n * Union type for WHERE clause expressions.\n */\nexport type WhereExpr = BinaryExpr | ExistsExpr | NullCheckExpr | AndExpr | OrExpr;\n\nexport interface BoundWhereExpr {\n readonly expr: WhereExpr;\n readonly params: readonly unknown[];\n readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;\n}\n\nexport interface ToWhereExpr {\n toWhereExpr(): BoundWhereExpr;\n}\n\nexport type WhereArg = WhereExpr | ToWhereExpr;\n\nexport type JoinOnExpr =\n | {\n readonly kind: 'eqCol';\n readonly left: ColumnRef;\n readonly right: ColumnRef;\n }\n | WhereExpr;\n\nexport interface JoinAst {\n readonly kind: 'join';\n readonly joinType: 'inner' | 'left' | 'right' | 'full';\n readonly table: TableRef;\n readonly on: JoinOnExpr;\n}\n\nexport interface IncludeRef {\n readonly kind: 'includeRef';\n readonly alias: string;\n}\n\nexport interface IncludeAst {\n readonly kind: 'includeMany';\n readonly alias: string;\n readonly child: {\n readonly table: TableRef;\n readonly on: JoinOnExpr;\n readonly where?: WhereExpr;\n readonly orderBy?: ReadonlyArray<{ expr: Expression; dir: Direction }>;\n readonly limit?: number;\n readonly project: ReadonlyArray<{ alias: string; expr: Expression }>;\n };\n}\n\nexport interface SelectAst {\n readonly kind: 'select';\n readonly from: TableRef;\n readonly joins?: ReadonlyArray<JoinAst>;\n readonly includes?: ReadonlyArray<IncludeAst>;\n readonly project: ReadonlyArray<{\n alias: string;\n expr: Expression | IncludeRef | LiteralExpr;\n }>;\n readonly where?: WhereExpr;\n readonly orderBy?: ReadonlyArray<{ expr: Expression; dir: Direction }>;\n readonly limit?: number;\n readonly selectAllIntent?: { table?: string };\n}\n\nexport interface InsertAst {\n readonly kind: 'insert';\n readonly table: TableRef;\n readonly values: Record<string, ColumnRef | ParamRef>;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport interface UpdateAst {\n readonly kind: 'update';\n readonly table: TableRef;\n readonly set: Record<string, ColumnRef | ParamRef>;\n readonly where?: WhereExpr;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport interface DeleteAst {\n readonly kind: 'delete';\n readonly table: TableRef;\n readonly where?: WhereExpr;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport type QueryAst = SelectAst | InsertAst | UpdateAst | DeleteAst;\n\nexport interface LoweredStatement {\n readonly sql: string;\n readonly params: readonly unknown[];\n readonly annotations?: Record<string, unknown>;\n}\n","import type { ColumnRef, ParamRef, TableRef, UpdateAst, WhereExpr } from './types';\nimport { compact } from './util';\n\nexport interface CreateUpdateAstOptions {\n readonly table: TableRef;\n readonly set: Record<string, ColumnRef | ParamRef>;\n readonly where?: WhereExpr;\n readonly returning?: ReadonlyArray<ColumnRef>;\n}\n\nexport function createUpdateAst(options: CreateUpdateAstOptions): UpdateAst {\n return compact({\n kind: 'update',\n table: options.table,\n set: options.set,\n where: options.where,\n returning: options.returning,\n }) as UpdateAst;\n}\n"],"mappings":";;;;;;;;;AAsIA,IAAM,oBAAN,MAAiD;CAC/C,AAAiB,wBAAQ,IAAI,KAA4B;CACzD,AAAiB,4BAAY,IAAI,KAA8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;EACb,OAAO,QAAQ;EACf,WAAW,QAAQ;EACpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { n as planUnsupported, t as planInvalid } from "../errors-DVufq9PT.mjs";
2
+ export { planInvalid, planUnsupported };
@@ -0,0 +1,3 @@
1
+ import { n as planUnsupported, t as planInvalid } from "../errors-7_V3El9I.mjs";
2
+
3
+ export { planInvalid, planUnsupported };
@@ -0,0 +1,5 @@
1
+ import "../query-lane-context-CgkPuKaR.mjs";
2
+ import "../plan-BhSWuTfw.mjs";
3
+ import "../types-CEUzDuDC.mjs";
4
+ import { a as getColumnMeta, c as isExpressionBuilder, d as isParamPlaceholder, f as isValueSource, i as getColumnInfo, l as isExpressionSource, n as expressionFromSource, o as getOperationExpr, p as toExpression, r as extractBaseColumnRef, s as isColumnBuilder, t as collectColumnRefs, u as isOperationExpr } from "../guards-DCCpAlOL.mjs";
5
+ export { collectColumnRefs, expressionFromSource, extractBaseColumnRef, getColumnInfo, getColumnMeta, getOperationExpr, isColumnBuilder, isExpressionBuilder, isExpressionSource, isOperationExpr, isParamPlaceholder, isValueSource, toExpression };
@@ -0,0 +1,3 @@
1
+ import { a as getColumnMeta, c as isExpressionBuilder, d as isParamPlaceholder, f as isValueSource, i as getColumnInfo, l as isExpressionSource, n as expressionFromSource, o as getOperationExpr, p as toExpression, r as extractBaseColumnRef, s as isColumnBuilder, t as collectColumnRefs, u as isOperationExpr } from "../guards-0ycyntYX.mjs";
2
+
3
+ export { collectColumnRefs, expressionFromSource, extractBaseColumnRef, getColumnInfo, getColumnMeta, getOperationExpr, isColumnBuilder, isExpressionBuilder, isExpressionSource, isOperationExpr, isParamPlaceholder, isValueSource, toExpression };
@@ -0,0 +1,5 @@
1
+ import "../query-lane-context-CgkPuKaR.mjs";
2
+ import "../plan-BhSWuTfw.mjs";
3
+ import "../types-CEUzDuDC.mjs";
4
+ import { t as attachOperationsToColumnBuilder } from "../operations-registry-wVEaiLyt.mjs";
5
+ export { attachOperationsToColumnBuilder };
@@ -0,0 +1,3 @@
1
+ import { t as attachOperationsToColumnBuilder } from "../operations-registry-DPZ5aElH.mjs";
2
+
3
+ export { attachOperationsToColumnBuilder };
@@ -0,0 +1,5 @@
1
+ import "../query-lane-context-CgkPuKaR.mjs";
2
+ import "../plan-BhSWuTfw.mjs";
3
+ import "../types-CEUzDuDC.mjs";
4
+ import { n as param, t as Parameter } from "../param-C4n0OW59.mjs";
5
+ export { Parameter, param };
@@ -0,0 +1,3 @@
1
+ import { t as param } from "../param-DMU3OWfI.mjs";
2
+
3
+ export { param };
@@ -0,0 +1,2 @@
1
+ import { n as augmentDescriptorWithColumnMeta, t as SqlQueryPlan } from "../plan-BhSWuTfw.mjs";
2
+ export { SqlQueryPlan, augmentDescriptorWithColumnMeta };
@@ -0,0 +1,17 @@
1
+ //#region src/plan.ts
2
+ /**
3
+ * Augments the last ParamDescriptor in the array with codecId and nativeType from columnMeta.
4
+ * This is used when building WHERE expressions to ensure param descriptors have type information.
5
+ */
6
+ function augmentDescriptorWithColumnMeta(descriptors, columnMeta) {
7
+ const descriptor = descriptors[descriptors.length - 1];
8
+ if (descriptor && columnMeta) descriptors[descriptors.length - 1] = {
9
+ ...descriptor,
10
+ codecId: columnMeta.codecId,
11
+ nativeType: columnMeta.nativeType
12
+ };
13
+ }
14
+
15
+ //#endregion
16
+ export { augmentDescriptorWithColumnMeta };
17
+ //# sourceMappingURL=plan.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.mjs","names":[],"sources":["../../src/plan.ts"],"sourcesContent":["import type { ExecutionPlan, ParamDescriptor } from '@prisma-next/contract/types';\nimport type { StorageColumn } from '@prisma-next/sql-contract/types';\nimport type { QueryAst } from './ast/types';\n\n/**\n * SQL query plan produced by lanes before lowering.\n *\n * Lanes build ASTs and metadata but do not perform SQL lowering.\n * The `sql` field is absent - lowering happens in the runtime executor.\n *\n * Structurally aligns with ExecutionPlan<Row, QueryAst> (without sql field) to maintain\n * compatibility with ExecutionPlan/Plan-based utilities.\n * The generic parameter `_Row` is preserved for type extraction via ResultType.\n */\nexport interface SqlQueryPlan<_Row = unknown>\n extends Pick<ExecutionPlan<_Row, QueryAst>, 'params' | 'meta'> {\n readonly ast: QueryAst;\n // Phantom property to preserve generic parameter for type extraction\n // This allows ResultType to extract _Row for SqlQueryPlan values.\n readonly _Row?: _Row;\n}\n\n/**\n * Augments the last ParamDescriptor in the array with codecId and nativeType from columnMeta.\n * This is used when building WHERE expressions to ensure param descriptors have type information.\n */\nexport function augmentDescriptorWithColumnMeta(\n descriptors: ParamDescriptor[],\n columnMeta: StorageColumn | undefined,\n): void {\n const descriptor = descriptors[descriptors.length - 1];\n if (descriptor && columnMeta) {\n descriptors[descriptors.length - 1] = {\n ...descriptor,\n codecId: columnMeta.codecId,\n nativeType: columnMeta.nativeType,\n };\n }\n}\n"],"mappings":";;;;;AA0BA,SAAgB,gCACd,aACA,YACM;CACN,MAAM,aAAa,YAAY,YAAY,SAAS;AACpD,KAAI,cAAc,WAChB,aAAY,YAAY,SAAS,KAAK;EACpC,GAAG;EACH,SAAS,WAAW;EACpB,YAAY,WAAW;EACxB"}
@@ -0,0 +1,2 @@
1
+ import { a as JsonSchemaValidationResult, c as MutationDefaultsOptions, i as JsonSchemaValidationError, l as TypeHelperRegistry, n as ExecutionContext, o as JsonSchemaValidatorRegistry, r as JsonSchemaValidateFn, s as MutationDefaultsOp, t as AppliedMutationDefault } from "../query-lane-context-CgkPuKaR.mjs";
2
+ export { AppliedMutationDefault, ExecutionContext, JsonSchemaValidateFn, JsonSchemaValidationError, JsonSchemaValidationResult, JsonSchemaValidatorRegistry, MutationDefaultsOp, MutationDefaultsOptions, TypeHelperRegistry };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,5 @@
1
+ import "../query-lane-context-CgkPuKaR.mjs";
2
+ import "../plan-BhSWuTfw.mjs";
3
+ import "../types-CEUzDuDC.mjs";
4
+ import { i as schema, n as SchemaHandle, r as TableBuilderImpl, t as ColumnBuilderImpl } from "../schema-CgrEMqEd.mjs";
5
+ export { ColumnBuilderImpl as Column, ColumnBuilderImpl, SchemaHandle, TableBuilderImpl as Table, TableBuilderImpl, schema };
@@ -0,0 +1,4 @@
1
+ import "../operations-registry-DPZ5aElH.mjs";
2
+ import { n as TableBuilderImpl, r as schema, t as ColumnBuilderImpl } from "../schema-Bi5p4aAc.mjs";
3
+
4
+ export { ColumnBuilderImpl, TableBuilderImpl, schema };
@@ -0,0 +1,4 @@
1
+ import "../query-lane-context-CgkPuKaR.mjs";
2
+ import "../plan-BhSWuTfw.mjs";
3
+ import { A as OperationTypes, B as SqlBuilderOptions, C as Meta, D as NullCheckBuilder, E as NestedProjection, F as RawFunctionOptions, G as TablesOf, H as TableDef, I as RawTemplateFactory, J as createOrderBuilder, K as UnaryBuilder, L as RawTemplateOptions, M as OrderBuilder, N as ParamPlaceholder, O as NullableMethods, P as RawFactory, R as ResultType, S as META, T as ModelMetadata, U as TableKey, V as SqlPlan, W as TableMetadata, Y as isColumnBuilder, _ as InferNestedProjectionRow, a as AnyOrderBuilder, b as JoinOnBuilder, c as BuildOptions, d as ColumnBuilder, f as ColumnsOf, g as HasIncludeManyCapabilities, h as ExpressionBuilder, i as AnyExpressionSource, j as OperationsForTypeId, k as OperationTypeSignature, l as BuildParamsMap, m as Expr, n as AnyColumnBuilder, o as AnyUnaryBuilder, p as ComputeColumnJsType, q as ValueSource, r as AnyColumnBuilderBase, s as BinaryBuilder, t as AnyBinaryBuilder, u as CodecTypes, v as InferProjectionRow, w as ModelDef, x as JoinOnPredicate, y as InferReturningRow, z as RuntimeError } from "../types-CEUzDuDC.mjs";
4
+ export { AnyBinaryBuilder, AnyColumnBuilder, AnyColumnBuilderBase, AnyExpressionSource, AnyOrderBuilder, AnyUnaryBuilder, BinaryBuilder, BuildOptions, BuildParamsMap, CodecTypes, ColumnBuilder, ColumnsOf, ComputeColumnJsType, Expr, ExpressionBuilder, HasIncludeManyCapabilities, InferNestedProjectionRow, InferProjectionRow, InferReturningRow, JoinOnBuilder, JoinOnPredicate, META, Meta, ModelDef, ModelMetadata, NestedProjection, NullCheckBuilder, NullableMethods, OperationTypeSignature, OperationTypes, OperationsForTypeId, OrderBuilder, ParamPlaceholder, RawFactory, RawFunctionOptions, RawTemplateFactory, RawTemplateOptions, ResultType, RuntimeError, SqlBuilderOptions, SqlPlan, TableDef, TableKey, TableMetadata, TablesOf, UnaryBuilder, ValueSource, createOrderBuilder, isColumnBuilder };
@@ -0,0 +1,3 @@
1
+ import { n as isColumnBuilder, t as createOrderBuilder } from "../types-Cdi4Whda.mjs";
2
+
3
+ export { createOrderBuilder, isColumnBuilder };
@@ -0,0 +1,5 @@
1
+ import "../../query-lane-context-CgkPuKaR.mjs";
2
+ import "../../plan-BhSWuTfw.mjs";
3
+ import "../../types-CEUzDuDC.mjs";
4
+ import { a as getColumnMeta, c as isExpressionBuilder, d as isParamPlaceholder, f as isValueSource, i as getColumnInfo, l as isExpressionSource, n as expressionFromSource, o as getOperationExpr, p as toExpression, r as extractBaseColumnRef, s as isColumnBuilder, t as collectColumnRefs, u as isOperationExpr } from "../../guards-DCCpAlOL.mjs";
5
+ export { collectColumnRefs, expressionFromSource, extractBaseColumnRef, getColumnInfo, getColumnMeta, getOperationExpr, isColumnBuilder, isExpressionBuilder, isExpressionSource, isOperationExpr, isParamPlaceholder, isValueSource, toExpression };
@@ -0,0 +1,4 @@
1
+ import { a as getColumnMeta, c as isExpressionBuilder, d as isParamPlaceholder, f as isValueSource, i as getColumnInfo, l as isExpressionSource, n as expressionFromSource, o as getOperationExpr, p as toExpression, r as extractBaseColumnRef, s as isColumnBuilder, t as collectColumnRefs, u as isOperationExpr } from "../../guards-0ycyntYX.mjs";
2
+ import "../guards.mjs";
3
+
4
+ export { collectColumnRefs, expressionFromSource, extractBaseColumnRef, getColumnInfo, getColumnMeta, getOperationExpr, isColumnBuilder, isExpressionBuilder, isExpressionSource, isOperationExpr, isParamPlaceholder, isValueSource, toExpression };
@@ -0,0 +1,132 @@
1
+ //#region src/utils/guards.ts
2
+ /**
3
+ * Helper to extract columnMeta from a ColumnBuilder or ExpressionBuilder.
4
+ * Returns StorageColumn if present, undefined otherwise.
5
+ * Both ColumnBuilder and ExpressionBuilder have columnMeta property.
6
+ */
7
+ function getColumnMeta(expr) {
8
+ if ("columnMeta" in expr) return expr.columnMeta;
9
+ }
10
+ /**
11
+ * Type predicate to check if a value is a ParamPlaceholder.
12
+ */
13
+ function isParamPlaceholder(value) {
14
+ return typeof value === "object" && value !== null && "kind" in value && value.kind === "param-placeholder" && "name" in value && typeof value.name === "string";
15
+ }
16
+ /**
17
+ * Recursively extracts the base ColumnRef from an OperationExpr.
18
+ * If the expression is already a ColumnRef, it is returned directly.
19
+ */
20
+ function extractBaseColumnRef(expr) {
21
+ if (expr.kind === "col") return expr;
22
+ return extractBaseColumnRef(expr.self);
23
+ }
24
+ /**
25
+ * Recursively collects all ColumnRef nodes from an expression tree.
26
+ * Handles nested OperationExpr structures by traversing both self and args.
27
+ */
28
+ function collectColumnRefs(expr) {
29
+ if (expr.kind === "col") return [expr];
30
+ if (expr.kind === "operation") {
31
+ const refs = collectColumnRefs(expr.self);
32
+ for (const arg of expr.args) refs.push(...collectColumnRefs(arg));
33
+ return refs;
34
+ }
35
+ return [];
36
+ }
37
+ /**
38
+ * Type predicate to check if an expression is an OperationExpr.
39
+ */
40
+ function isOperationExpr(expr) {
41
+ return typeof expr === "object" && expr !== null && "kind" in expr && expr.kind === "operation";
42
+ }
43
+ /**
44
+ * Helper to extract table and column from a ColumnBuilder, ExpressionBuilder, or OperationExpr.
45
+ * For ExpressionBuilder or OperationExpr, recursively unwraps to find the base ColumnRef.
46
+ */
47
+ function getColumnInfo(expr) {
48
+ if (isOperationExpr(expr)) {
49
+ const baseCol = extractBaseColumnRef(expr);
50
+ return {
51
+ table: baseCol.table,
52
+ column: baseCol.column
53
+ };
54
+ }
55
+ if (isExpressionBuilder(expr)) {
56
+ const baseCol = extractBaseColumnRef(expr.expr);
57
+ return {
58
+ table: baseCol.table,
59
+ column: baseCol.column
60
+ };
61
+ }
62
+ const colBuilder = expr;
63
+ return {
64
+ table: colBuilder.table,
65
+ column: colBuilder.column
66
+ };
67
+ }
68
+ /**
69
+ * Type predicate to check if a value is a ColumnBuilder.
70
+ */
71
+ function isColumnBuilder(value) {
72
+ return typeof value === "object" && value !== null && "kind" in value && value.kind === "column";
73
+ }
74
+ /**
75
+ * Type predicate to check if a value is an ExpressionBuilder.
76
+ */
77
+ function isExpressionBuilder(value) {
78
+ return typeof value === "object" && value !== null && "kind" in value && value.kind === "expression";
79
+ }
80
+ /**
81
+ * Type predicate to check if a value is an ExpressionSource (has toExpr method).
82
+ */
83
+ function isExpressionSource(value) {
84
+ return typeof value === "object" && value !== null && "toExpr" in value && typeof value.toExpr === "function";
85
+ }
86
+ /**
87
+ * Converts any ExpressionSource to an Expression.
88
+ * This is the canonical way to get an AST Expression from a builder.
89
+ *
90
+ * @param source - A ColumnBuilder or ExpressionBuilder
91
+ * @returns The corresponding Expression (ColumnRef or OperationExpr)
92
+ */
93
+ function toExpression(source) {
94
+ return source.toExpr();
95
+ }
96
+ /**
97
+ * Converts an AnyExpressionSource to an Expression.
98
+ * Handles both ColumnBuilder and ExpressionBuilder.
99
+ *
100
+ * @param source - A ColumnBuilder or ExpressionBuilder
101
+ * @returns The corresponding Expression (ColumnRef or OperationExpr)
102
+ */
103
+ function expressionFromSource(source) {
104
+ return source.toExpr();
105
+ }
106
+ /**
107
+ * Type predicate to check if a value is a ValueSource.
108
+ * ValueSource is either a ParamPlaceholder or an ExpressionSource.
109
+ */
110
+ function isValueSource(value) {
111
+ return isParamPlaceholder(value) || isExpressionSource(value);
112
+ }
113
+ /**
114
+ * Extracts and returns an OperationExpr from a builder.
115
+ * Returns the OperationExpr if the builder is an OperationExpr or has an _operationExpr property,
116
+ * otherwise returns undefined.
117
+ *
118
+ * @deprecated Use isExpressionBuilder() instead. This function exists for backward compatibility
119
+ * with code that uses the hidden _operationExpr property pattern.
120
+ *
121
+ * @design-note: This function accesses the hidden `_operationExpr` property, which is a code smell.
122
+ * The ExpressionBuilder type (introduced in the operation-expr-refactoring) provides a cleaner
123
+ * approach by explicitly representing operation results as a distinct type.
124
+ */
125
+ function getOperationExpr(builder) {
126
+ if (isOperationExpr(builder)) return builder;
127
+ return builder._operationExpr;
128
+ }
129
+
130
+ //#endregion
131
+ export { getColumnMeta as a, isExpressionBuilder as c, isParamPlaceholder as d, isValueSource as f, getColumnInfo as i, isExpressionSource as l, expressionFromSource as n, getOperationExpr as o, toExpression as p, extractBaseColumnRef as r, isColumnBuilder as s, collectColumnRefs as t, isOperationExpr as u };
132
+ //# sourceMappingURL=guards-0ycyntYX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards-0ycyntYX.mjs","names":["refs: ColumnRef[]"],"sources":["../src/utils/guards.ts"],"sourcesContent":["import type { StorageColumn } from '@prisma-next/sql-contract/types';\nimport type {\n ColumnRef,\n Expression,\n ExpressionSource,\n LiteralExpr,\n OperationExpr,\n ParamRef,\n} from '../ast/types';\nimport type {\n AnyColumnBuilder,\n AnyExpressionSource,\n ExpressionBuilder,\n ParamPlaceholder,\n ValueSource,\n} from '../types';\n\n/**\n * Helper to extract columnMeta from a ColumnBuilder or ExpressionBuilder.\n * Returns StorageColumn if present, undefined otherwise.\n * Both ColumnBuilder and ExpressionBuilder have columnMeta property.\n */\nexport function getColumnMeta(expr: AnyExpressionSource): StorageColumn | undefined {\n // Both ColumnBuilder and ExpressionBuilder have columnMeta: StorageColumn\n // TypeScript should narrow the type after the 'in' check\n if ('columnMeta' in expr) {\n return expr.columnMeta;\n }\n return undefined;\n}\n\n/**\n * Type predicate to check if a value is a ParamPlaceholder.\n */\nexport function isParamPlaceholder(value: unknown): value is ParamPlaceholder {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'kind' in value &&\n (value as { kind: unknown }).kind === 'param-placeholder' &&\n 'name' in value &&\n typeof (value as { name: unknown }).name === 'string'\n );\n}\n\n/**\n * Recursively extracts the base ColumnRef from an OperationExpr.\n * If the expression is already a ColumnRef, it is returned directly.\n */\nexport function extractBaseColumnRef(expr: ColumnRef | OperationExpr): ColumnRef {\n if (expr.kind === 'col') {\n return expr;\n }\n return extractBaseColumnRef(expr.self);\n}\n\n/**\n * Recursively collects all ColumnRef nodes from an expression tree.\n * Handles nested OperationExpr structures by traversing both self and args.\n */\nexport function collectColumnRefs(\n expr: ColumnRef | ParamRef | LiteralExpr | OperationExpr,\n): ColumnRef[] {\n if (expr.kind === 'col') {\n return [expr];\n }\n if (expr.kind === 'operation') {\n const refs: ColumnRef[] = collectColumnRefs(expr.self);\n for (const arg of expr.args) {\n refs.push(...collectColumnRefs(arg));\n }\n return refs;\n }\n return [];\n}\n\n/**\n * Type predicate to check if an expression is an OperationExpr.\n */\nexport function isOperationExpr(\n expr: AnyExpressionSource | OperationExpr | Expression,\n): expr is OperationExpr {\n return typeof expr === 'object' && expr !== null && 'kind' in expr && expr.kind === 'operation';\n}\n\n/**\n * Helper to extract table and column from a ColumnBuilder, ExpressionBuilder, or OperationExpr.\n * For ExpressionBuilder or OperationExpr, recursively unwraps to find the base ColumnRef.\n */\nexport function getColumnInfo(expr: AnyExpressionSource | OperationExpr): {\n table: string;\n column: string;\n} {\n if (isOperationExpr(expr)) {\n const baseCol = extractBaseColumnRef(expr);\n return { table: baseCol.table, column: baseCol.column };\n }\n if (isExpressionBuilder(expr)) {\n const baseCol = extractBaseColumnRef(expr.expr);\n return { table: baseCol.table, column: baseCol.column };\n }\n // expr is ColumnBuilder - TypeScript can't narrow properly\n const colBuilder = expr as unknown as { table: string; column: string };\n return { table: colBuilder.table, column: colBuilder.column };\n}\n\n/**\n * Type predicate to check if a value is a ColumnBuilder.\n */\nexport function isColumnBuilder(value: unknown): value is AnyColumnBuilder {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'kind' in value &&\n (value as { kind: unknown }).kind === 'column'\n );\n}\n\n/**\n * Type predicate to check if a value is an ExpressionBuilder.\n */\nexport function isExpressionBuilder(value: unknown): value is ExpressionBuilder {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'kind' in value &&\n (value as { kind: unknown }).kind === 'expression'\n );\n}\n\n/**\n * Type predicate to check if a value is an ExpressionSource (has toExpr method).\n */\nexport function isExpressionSource(value: unknown): value is ExpressionSource {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'toExpr' in value &&\n typeof (value as ExpressionSource).toExpr === 'function'\n );\n}\n\n/**\n * Converts any ExpressionSource to an Expression.\n * This is the canonical way to get an AST Expression from a builder.\n *\n * @param source - A ColumnBuilder or ExpressionBuilder\n * @returns The corresponding Expression (ColumnRef or OperationExpr)\n */\nexport function toExpression(source: ExpressionSource): Expression {\n return source.toExpr();\n}\n\n/**\n * Converts an AnyExpressionSource to an Expression.\n * Handles both ColumnBuilder and ExpressionBuilder.\n *\n * @param source - A ColumnBuilder or ExpressionBuilder\n * @returns The corresponding Expression (ColumnRef or OperationExpr)\n */\nexport function expressionFromSource(source: AnyExpressionSource): Expression {\n return source.toExpr();\n}\n\n/**\n * Type predicate to check if a value is a ValueSource.\n * ValueSource is either a ParamPlaceholder or an ExpressionSource.\n */\nexport function isValueSource(value: unknown): value is ValueSource {\n return isParamPlaceholder(value) || isExpressionSource(value);\n}\n\n/**\n * Extracts and returns an OperationExpr from a builder.\n * Returns the OperationExpr if the builder is an OperationExpr or has an _operationExpr property,\n * otherwise returns undefined.\n *\n * @deprecated Use isExpressionBuilder() instead. This function exists for backward compatibility\n * with code that uses the hidden _operationExpr property pattern.\n *\n * @design-note: This function accesses the hidden `_operationExpr` property, which is a code smell.\n * The ExpressionBuilder type (introduced in the operation-expr-refactoring) provides a cleaner\n * approach by explicitly representing operation results as a distinct type.\n */\nexport function getOperationExpr(\n builder: AnyColumnBuilder | OperationExpr,\n): OperationExpr | undefined {\n if (isOperationExpr(builder)) {\n return builder;\n }\n const builderWithExpr = builder as unknown as { _operationExpr?: OperationExpr };\n return builderWithExpr._operationExpr;\n}\n"],"mappings":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B,SAAS;;;;;AAO1C,SAAgB,mBAAmB,OAA2C;AAC5E,QACE,OAAO,UAAU,YACjB,UAAU,QACV,YAAY,SACZ,OAAQ,MAA2B,WAAW;;;;;;;;;AAWlD,SAAgB,aAAa,QAAsC;AACjE,QAAO,OAAO,QAAQ;;;;;;;;;AAUxB,SAAgB,qBAAqB,QAAyC;AAC5E,QAAO,OAAO,QAAQ;;;;;;AAOxB,SAAgB,cAAc,OAAsC;AAClE,QAAO,mBAAmB,MAAM,IAAI,mBAAmB,MAAM;;;;;;;;;;;;;;AAe/D,SAAgB,iBACd,SAC2B;AAC3B,KAAI,gBAAgB,QAAQ,CAC1B,QAAO;AAGT,QADwB,QACD"}
@@ -0,0 +1,87 @@
1
+ import { S as OperationExpr, d as Expression, f as ExpressionSource, s as ColumnRef, w as ParamRef, y as LiteralExpr } from "./plan-BhSWuTfw.mjs";
2
+ import { N as ParamPlaceholder, h as ExpressionBuilder, i as AnyExpressionSource, n as AnyColumnBuilder, q as ValueSource } from "./types-CEUzDuDC.mjs";
3
+ import { StorageColumn } from "@prisma-next/sql-contract/types";
4
+
5
+ //#region src/utils/guards.d.ts
6
+
7
+ /**
8
+ * Helper to extract columnMeta from a ColumnBuilder or ExpressionBuilder.
9
+ * Returns StorageColumn if present, undefined otherwise.
10
+ * Both ColumnBuilder and ExpressionBuilder have columnMeta property.
11
+ */
12
+ declare function getColumnMeta(expr: AnyExpressionSource): StorageColumn | undefined;
13
+ /**
14
+ * Type predicate to check if a value is a ParamPlaceholder.
15
+ */
16
+ declare function isParamPlaceholder(value: unknown): value is ParamPlaceholder;
17
+ /**
18
+ * Recursively extracts the base ColumnRef from an OperationExpr.
19
+ * If the expression is already a ColumnRef, it is returned directly.
20
+ */
21
+ declare function extractBaseColumnRef(expr: ColumnRef | OperationExpr): ColumnRef;
22
+ /**
23
+ * Recursively collects all ColumnRef nodes from an expression tree.
24
+ * Handles nested OperationExpr structures by traversing both self and args.
25
+ */
26
+ declare function collectColumnRefs(expr: ColumnRef | ParamRef | LiteralExpr | OperationExpr): ColumnRef[];
27
+ /**
28
+ * Type predicate to check if an expression is an OperationExpr.
29
+ */
30
+ declare function isOperationExpr(expr: AnyExpressionSource | OperationExpr | Expression): expr is OperationExpr;
31
+ /**
32
+ * Helper to extract table and column from a ColumnBuilder, ExpressionBuilder, or OperationExpr.
33
+ * For ExpressionBuilder or OperationExpr, recursively unwraps to find the base ColumnRef.
34
+ */
35
+ declare function getColumnInfo(expr: AnyExpressionSource | OperationExpr): {
36
+ table: string;
37
+ column: string;
38
+ };
39
+ /**
40
+ * Type predicate to check if a value is a ColumnBuilder.
41
+ */
42
+ declare function isColumnBuilder(value: unknown): value is AnyColumnBuilder;
43
+ /**
44
+ * Type predicate to check if a value is an ExpressionBuilder.
45
+ */
46
+ declare function isExpressionBuilder(value: unknown): value is ExpressionBuilder;
47
+ /**
48
+ * Type predicate to check if a value is an ExpressionSource (has toExpr method).
49
+ */
50
+ declare function isExpressionSource(value: unknown): value is ExpressionSource;
51
+ /**
52
+ * Converts any ExpressionSource to an Expression.
53
+ * This is the canonical way to get an AST Expression from a builder.
54
+ *
55
+ * @param source - A ColumnBuilder or ExpressionBuilder
56
+ * @returns The corresponding Expression (ColumnRef or OperationExpr)
57
+ */
58
+ declare function toExpression(source: ExpressionSource): Expression;
59
+ /**
60
+ * Converts an AnyExpressionSource to an Expression.
61
+ * Handles both ColumnBuilder and ExpressionBuilder.
62
+ *
63
+ * @param source - A ColumnBuilder or ExpressionBuilder
64
+ * @returns The corresponding Expression (ColumnRef or OperationExpr)
65
+ */
66
+ declare function expressionFromSource(source: AnyExpressionSource): Expression;
67
+ /**
68
+ * Type predicate to check if a value is a ValueSource.
69
+ * ValueSource is either a ParamPlaceholder or an ExpressionSource.
70
+ */
71
+ declare function isValueSource(value: unknown): value is ValueSource;
72
+ /**
73
+ * Extracts and returns an OperationExpr from a builder.
74
+ * Returns the OperationExpr if the builder is an OperationExpr or has an _operationExpr property,
75
+ * otherwise returns undefined.
76
+ *
77
+ * @deprecated Use isExpressionBuilder() instead. This function exists for backward compatibility
78
+ * with code that uses the hidden _operationExpr property pattern.
79
+ *
80
+ * @design-note: This function accesses the hidden `_operationExpr` property, which is a code smell.
81
+ * The ExpressionBuilder type (introduced in the operation-expr-refactoring) provides a cleaner
82
+ * approach by explicitly representing operation results as a distinct type.
83
+ */
84
+ declare function getOperationExpr(builder: AnyColumnBuilder | OperationExpr): OperationExpr | undefined;
85
+ //#endregion
86
+ export { getColumnMeta as a, isExpressionBuilder as c, isParamPlaceholder as d, isValueSource as f, getColumnInfo as i, isExpressionSource as l, expressionFromSource as n, getOperationExpr as o, toExpression as p, extractBaseColumnRef as r, isColumnBuilder as s, collectColumnRefs as t, isOperationExpr as u };
87
+ //# sourceMappingURL=guards-DCCpAlOL.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards-DCCpAlOL.d.mts","names":[],"sources":["../src/utils/guards.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAsBA;AAYA;AAeA;AAA2C,iBA3B3B,aAAA,CA2B2B,IAAA,EA3BP,mBA2BO,CAAA,EA3Be,aA2Bf,GAAA,SAAA;;;;AAW3B,iBA1BA,kBAAA,CA0BiB,KAAA,EAAA,OAAA,CAAA,EAAA,KAAA,IA1B4B,gBA0B5B;;;;;AAE9B,iBAba,oBAAA,CAab,IAAA,EAbwC,SAaxC,GAboD,aAapD,CAAA,EAboE,SAapE;;AAiBH;;;AAC8C,iBApB9B,iBAAA,CAoB8B,IAAA,EAnBtC,SAmBsC,GAnB1B,QAmB0B,GAnBf,WAmBe,GAnBD,aAmBC,CAAA,EAlB3C,SAkB2C,EAAA;;;AAS9C;AAoBgB,iBA9BA,eAAA,CA8B0C,IAAA,EA7BlD,mBA6BkE,GA7B5C,aA6B4C,GA7B5B,UA6B4B,CAAA,EAAA,IAAA,IA5B/D,aA4B+D;AAY1E;AAYA;AAgBA;AAWA;AAQgB,iBA/EA,aAAA,CA+EwC,IAAA,EA/EpB,mBA+E+B,GA/ET,aA+ES,CAAA,EAAA;EAgBnD,KAAA,EAAA,MAAA;EACL,MAAA,EAAA,MAAA;CAAmB;;;;iBA5Ed,eAAA,2BAA0C;;;;iBAY1C,mBAAA,2BAA8C;;;;iBAY9C,kBAAA,2BAA6C;;;;;;;;iBAgB7C,YAAA,SAAqB,mBAAmB;;;;;;;;iBAWxC,oBAAA,SAA6B,sBAAsB;;;;;iBAQnD,aAAA,2BAAwC;;;;;;;;;;;;;iBAgBxC,gBAAA,UACL,mBAAmB,gBAC3B"}
@@ -0,0 +1,12 @@
1
+ import { S as defineCodecs, _ as CodecRegistry, a as JsonSchemaValidationResult, b as codec, c as MutationDefaultsOptions, d as CodecDefBuilder, f as CodecId, g as CodecParamsDescriptor, h as CodecOutput, i as JsonSchemaValidationError, l as TypeHelperRegistry, m as CodecMeta, n as ExecutionContext, o as JsonSchemaValidatorRegistry, p as CodecInput, r as JsonSchemaValidateFn, s as MutationDefaultsOp, t as AppliedMutationDefault, u as Codec, v as ExtractCodecTypes, x as createCodecRegistry, y as ExtractDataTypes } from "./query-lane-context-CgkPuKaR.mjs";
2
+ import { A as WhereArg, C as OrExpr, D as TableRef, E as SelectAst, M as isOperationExpr, O as ToWhereExpr, S as OperationExpr, T as QueryAst, _ as JoinOnExpr, a as BinaryOp, b as LoweredStatement, c as DeleteAst, d as Expression, f as ExpressionSource, g as JoinAst, h as InsertAst, i as BinaryExpr, j as WhereExpr, k as UpdateAst, l as Direction, m as IncludeRef, n as augmentDescriptorWithColumnMeta, o as BoundWhereExpr, p as IncludeAst, r as AndExpr, s as ColumnRef, t as SqlQueryPlan, u as ExistsExpr, v as ListLiteralExpr, w as ParamRef, x as NullCheckExpr, y as LiteralExpr } from "./plan-BhSWuTfw.mjs";
3
+ import { A as OperationTypes, B as SqlBuilderOptions, C as Meta, D as NullCheckBuilder, E as NestedProjection, F as RawFunctionOptions, G as TablesOf, H as TableDef, I as RawTemplateFactory, J as createOrderBuilder, K as UnaryBuilder, L as RawTemplateOptions, M as OrderBuilder, N as ParamPlaceholder, O as NullableMethods, P as RawFactory, R as ResultType, S as META, T as ModelMetadata, U as TableKey, V as SqlPlan, W as TableMetadata, Y as isColumnBuilder, _ as InferNestedProjectionRow, a as AnyOrderBuilder, b as JoinOnBuilder, c as BuildOptions, d as ColumnBuilder, f as ColumnsOf, g as HasIncludeManyCapabilities, h as ExpressionBuilder, i as AnyExpressionSource, j as OperationsForTypeId, k as OperationTypeSignature, l as BuildParamsMap, m as Expr, n as AnyColumnBuilder, o as AnyUnaryBuilder, p as ComputeColumnJsType, q as ValueSource, r as AnyColumnBuilderBase, s as BinaryBuilder, t as AnyBinaryBuilder, u as CodecTypes, v as InferProjectionRow, w as ModelDef, x as JoinOnPredicate, y as InferReturningRow, z as RuntimeError } from "./types-CEUzDuDC.mjs";
4
+ import { Adapter, AdapterProfile, AdapterTarget, CreateDeleteAstOptions, CreateInsertAstOptions, CreateSelectAstOptions, CreateUpdateAstOptions, LoweredPayload, Lowerer, LowererContext, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID, SqlCodecTypes, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlQueryResult, SqlQueryable, SqlTransaction, compact, createBinaryExpr, createColumnRef, createDeleteAst, createExistsExpr, createInsertAst, createJoin, createJoinOnBuilder, createJoinOnExpr, createLiteralExpr, createNullCheckExpr, createOperationExpr, createOrderByItem, createParamRef, createSelectAst, createTableRef, createUpdateAst, sqlCodecDefinitions, sqlDataTypes } from "./exports/ast.mjs";
5
+ import { n as planUnsupported, t as planInvalid } from "./errors-DVufq9PT.mjs";
6
+ import { t as attachOperationsToColumnBuilder } from "./operations-registry-wVEaiLyt.mjs";
7
+ import { n as param, t as Parameter } from "./param-C4n0OW59.mjs";
8
+ import "./exports/plan.mjs";
9
+ import "./exports/query-lane-context.mjs";
10
+ import { i as schema, n as SchemaHandle, r as TableBuilderImpl, t as ColumnBuilderImpl } from "./schema-CgrEMqEd.mjs";
11
+ import "./exports/types.mjs";
12
+ export { Adapter, AdapterProfile, AdapterTarget, AndExpr, AnyBinaryBuilder, AnyColumnBuilder, AnyColumnBuilderBase, AnyExpressionSource, AnyOrderBuilder, AnyUnaryBuilder, AppliedMutationDefault, BinaryBuilder, BinaryExpr, BinaryOp, BoundWhereExpr, BuildOptions, BuildParamsMap, Codec, CodecDefBuilder, CodecId, CodecInput, CodecMeta, CodecOutput, CodecParamsDescriptor, CodecRegistry, CodecTypes, ColumnBuilderImpl as Column, ColumnBuilderImpl, ColumnBuilder, ColumnRef, ColumnsOf, ComputeColumnJsType, CreateDeleteAstOptions, CreateInsertAstOptions, CreateSelectAstOptions, CreateUpdateAstOptions, DeleteAst, Direction, ExecutionContext, ExistsExpr, Expr, Expression, ExpressionBuilder, ExpressionSource, ExtractCodecTypes, ExtractDataTypes, HasIncludeManyCapabilities, IncludeAst, IncludeRef, InferNestedProjectionRow, InferProjectionRow, InferReturningRow, InsertAst, JoinAst, JoinOnBuilder, JoinOnExpr, JoinOnPredicate, JsonSchemaValidateFn, JsonSchemaValidationError, JsonSchemaValidationResult, JsonSchemaValidatorRegistry, ListLiteralExpr, LiteralExpr, LoweredPayload, LoweredStatement, Lowerer, LowererContext, META, Meta, ModelDef, ModelMetadata, MutationDefaultsOp, MutationDefaultsOptions, NestedProjection, NullCheckBuilder, NullCheckExpr, NullableMethods, OperationExpr, OperationTypeSignature, OperationTypes, OperationsForTypeId, OrExpr, OrderBuilder, ParamPlaceholder, ParamRef, Parameter, QueryAst, RawFactory, RawFunctionOptions, RawTemplateFactory, RawTemplateOptions, ResultType, RuntimeError, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID, SchemaHandle, SelectAst, SqlBuilderOptions, SqlCodecTypes, SqlConnection, SqlDriver, SqlDriverState, SqlExecuteRequest, SqlExplainResult, SqlPlan, SqlQueryPlan, SqlQueryResult, SqlQueryable, SqlTransaction, TableBuilderImpl as Table, TableBuilderImpl, TableDef, TableKey, TableMetadata, TableRef, TablesOf, ToWhereExpr, TypeHelperRegistry, UnaryBuilder, UpdateAst, ValueSource, WhereArg, WhereExpr, attachOperationsToColumnBuilder, augmentDescriptorWithColumnMeta, codec, compact, createBinaryExpr, createCodecRegistry, createColumnRef, createDeleteAst, createExistsExpr, createInsertAst, createJoin, createJoinOnBuilder, createJoinOnExpr, createLiteralExpr, createNullCheckExpr, createOperationExpr, createOrderBuilder, createOrderByItem, createParamRef, createSelectAst, createTableRef, createUpdateAst, defineCodecs, isColumnBuilder, isOperationExpr, param, planInvalid, planUnsupported, schema, sqlCodecDefinitions, sqlDataTypes };
package/dist/index.mjs ADDED
@@ -0,0 +1,12 @@
1
+ import { n as isColumnBuilder, t as createOrderBuilder } from "./types-Cdi4Whda.mjs";
2
+ import { SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID, codec, compact, createBinaryExpr, createCodecRegistry, createColumnRef, createDeleteAst, createExistsExpr, createInsertAst, createJoin, createJoinOnBuilder, createJoinOnExpr, createLiteralExpr, createNullCheckExpr, createOperationExpr, createOrderByItem, createParamRef, createSelectAst, createTableRef, createUpdateAst, defineCodecs, isOperationExpr, sqlCodecDefinitions, sqlDataTypes } from "./exports/ast.mjs";
3
+ import { n as planUnsupported, t as planInvalid } from "./errors-7_V3El9I.mjs";
4
+ import { t as attachOperationsToColumnBuilder } from "./operations-registry-DPZ5aElH.mjs";
5
+ import "./exports/operations-registry.mjs";
6
+ import { t as param } from "./param-DMU3OWfI.mjs";
7
+ import { augmentDescriptorWithColumnMeta } from "./exports/plan.mjs";
8
+ import "./exports/query-lane-context.mjs";
9
+ import { n as TableBuilderImpl, r as schema, t as ColumnBuilderImpl } from "./schema-Bi5p4aAc.mjs";
10
+ import "./exports/types.mjs";
11
+
12
+ export { ColumnBuilderImpl, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_VARCHAR_CODEC_ID, TableBuilderImpl, attachOperationsToColumnBuilder, augmentDescriptorWithColumnMeta, codec, compact, createBinaryExpr, createCodecRegistry, createColumnRef, createDeleteAst, createExistsExpr, createInsertAst, createJoin, createJoinOnBuilder, createJoinOnExpr, createLiteralExpr, createNullCheckExpr, createOperationExpr, createOrderBuilder, createOrderByItem, createParamRef, createSelectAst, createTableRef, createUpdateAst, defineCodecs, isColumnBuilder, isOperationExpr, param, planInvalid, planUnsupported, schema, sqlCodecDefinitions, sqlDataTypes };