@prisma-next/sql-relational-core 0.12.0-dev.5 → 0.12.0-dev.50
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/dist/{codec-types-Cezo7k-i.d.mts → codec-types-Ey_MAEly.d.mts} +1 -1
- package/dist/{codec-types-Cezo7k-i.d.mts.map → codec-types-Ey_MAEly.d.mts.map} +1 -1
- package/dist/ddl-types-BV7GsGNt.d.mts +56 -0
- package/dist/ddl-types-BV7GsGNt.d.mts.map +1 -0
- package/dist/ddl-types-wqxUC57D.mjs +71 -0
- package/dist/ddl-types-wqxUC57D.mjs.map +1 -0
- package/dist/{errors-BzXb8Kv9.d.mts → errors-CI1oIVmU.d.mts} +2 -2
- package/dist/{errors-BzXb8Kv9.d.mts.map → errors-CI1oIVmU.d.mts.map} +1 -1
- package/dist/{errors-BF7W5uUd.mjs → errors-HvB_h2on.mjs} +1 -1
- package/dist/{errors-BF7W5uUd.mjs.map → errors-HvB_h2on.mjs.map} +1 -1
- package/dist/exports/ast.d.mts +5 -8
- package/dist/exports/ast.d.mts.map +1 -1
- package/dist/exports/ast.mjs +4 -3
- package/dist/exports/ast.mjs.map +1 -1
- package/dist/exports/codec-descriptor-registry.d.mts +3 -3
- package/dist/exports/codec-descriptor-registry.mjs +6 -9
- package/dist/exports/codec-descriptor-registry.mjs.map +1 -1
- package/dist/exports/contract-free.d.mts +149 -0
- package/dist/exports/contract-free.d.mts.map +1 -0
- package/dist/exports/contract-free.mjs +248 -0
- package/dist/exports/contract-free.mjs.map +1 -0
- package/dist/exports/errors.d.mts +1 -1
- package/dist/exports/errors.mjs +1 -1
- package/dist/exports/expression.d.mts +2 -2
- package/dist/exports/expression.mjs +1 -1
- package/dist/exports/middleware.d.mts +1 -1
- package/dist/exports/middleware.mjs +1 -1
- package/dist/exports/plan.d.mts +2 -2
- package/dist/exports/query-lane-context.d.mts +1 -1
- package/dist/exports/types.d.mts +3 -3
- package/dist/index.d.mts +12 -11
- package/dist/index.mjs +6 -5
- package/dist/{middleware-B0yz0pff.mjs → middleware-CbHPs9WK.mjs} +2 -2
- package/dist/{middleware-B0yz0pff.mjs.map → middleware-CbHPs9WK.mjs.map} +1 -1
- package/dist/{middleware-wAl5AE2L.d.mts → middleware-DkAjjPxq.d.mts} +2 -2
- package/dist/{middleware-wAl5AE2L.d.mts.map → middleware-DkAjjPxq.d.mts.map} +1 -1
- package/dist/{plan-DOddRU_l.d.mts → plan-Ds9oN5QU.d.mts} +3 -3
- package/dist/{plan-DOddRU_l.d.mts.map → plan-Ds9oN5QU.d.mts.map} +1 -1
- package/dist/{query-lane-context-Dw1Tz0kv.d.mts → query-lane-context-BUYT0tOb.d.mts} +3 -3
- package/dist/{query-lane-context-Dw1Tz0kv.d.mts.map → query-lane-context-BUYT0tOb.d.mts.map} +1 -1
- package/dist/{sql-execution-plan-DeBoZUre.d.mts → sql-execution-plan-Dopo3SDj.d.mts} +2 -2
- package/dist/{sql-execution-plan-DeBoZUre.d.mts.map → sql-execution-plan-Dopo3SDj.d.mts.map} +1 -1
- package/dist/{types-BFErW7xt.d.mts → types-CLirmH9F.d.mts} +8 -20
- package/dist/types-CLirmH9F.d.mts.map +1 -0
- package/dist/{types-BS8Mm93x.mjs → types-CMznS9Yh.mjs} +16 -5
- package/dist/{types-BS8Mm93x.mjs.map → types-CMznS9Yh.mjs.map} +1 -1
- package/dist/{types-BKeEhnEl.d.mts → types-CXQF5KS8.d.mts} +13 -6
- package/dist/types-CXQF5KS8.d.mts.map +1 -0
- package/dist/{types-CkfUpAlx.d.mts → types-DRBn98H_.d.mts} +3 -3
- package/dist/{types-CkfUpAlx.d.mts.map → types-DRBn98H_.d.mts.map} +1 -1
- package/dist/{util-DWmhUCEO.mjs → util-DUXs0nZ9.mjs} +1 -1
- package/dist/{util-DWmhUCEO.mjs.map → util-DUXs0nZ9.mjs.map} +1 -1
- package/package.json +12 -11
- package/src/ast/adapter-types.ts +0 -5
- package/src/ast/ddl-types.ts +106 -0
- package/src/ast/types.ts +22 -6
- package/src/codec-ref-for-column.ts +7 -9
- package/src/contract-free/column.ts +21 -0
- package/src/contract-free/dml.ts +17 -0
- package/src/contract-free/table.ts +390 -0
- package/src/exports/ast.ts +1 -0
- package/src/exports/contract-free.ts +18 -0
- package/src/types.ts +3 -23
- package/dist/types-BFErW7xt.d.mts.map +0 -1
- package/dist/types-BKeEhnEl.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-B0yz0pff.mjs","names":[],"sources":["../src/middleware/param-ref-mutator.ts"],"sourcesContent":["import type { ParamRefMutator } from '@prisma-next/framework-components/runtime';\nimport type { AnyParamRef } from '../ast/types';\nimport { collectOrderedParamRefs } from '../ast/util';\nimport type { SqlExecutionPlan } from '../sql-execution-plan';\n\n/**\n * Brand applied to {@link ParamRefHandle} so user-constructed handles\n * are rejected by the type system. The mutator only accepts handles it\n * produced from `entries()`.\n *\n * The brand is a phantom type — there is no runtime token. At runtime\n * the handle is the underlying `ParamRef` instance from the plan's\n * `ast`; the brand only narrows the type-level surface so callers\n * cannot fabricate a handle from a fresh `ParamRef.of(...)`.\n */\ndeclare const paramRefHandleBrand: unique symbol;\n\n/**\n * Opaque token identifying a single `ParamRef` in the plan. Produced by\n * {@link SqlParamRefMutator.entries}; consumed by `replaceValue` /\n * `replaceValues`.\n *\n * The phantom `TCodecId` parameter records the codec id of the\n * referenced `ParamRef` so type-level inference can route replacement\n * values through `TCodecMap` to the codec's declared `TInput`.\n */\nexport interface ParamRefHandle<TCodecId extends string | undefined = string | undefined> {\n readonly [paramRefHandleBrand]: TCodecId;\n}\n\n/**\n * One outbound `ParamRef` slot in the plan exposed to middleware.\n * `value` is the current value (post any prior middleware mutations);\n * `codecId` is the codec id declared on the underlying `ParamRef.codec`.\n */\nexport interface ParamRefEntry<TCodecId extends string | undefined = string | undefined> {\n readonly ref: ParamRefHandle<TCodecId>;\n readonly value: unknown;\n readonly codecId: TCodecId;\n}\n\n/**\n * Discriminated entry union over a codec map. For each `K` in\n * `TCodecMap`, `entries()` may yield a `ParamRefEntry<K>`; ParamRefs\n * with no codec id (or a codec id outside the map) yield a\n * `ParamRefEntry<undefined>`. Pattern-matching on `entry.codecId`\n * narrows `entry.ref` to a `ParamRefHandle<K>`, which routes through\n * the typed `replaceValue` overload.\n */\nexport type ParamRefEntryUnion<TCodecMap extends Record<string, unknown>> =\n | { [K in keyof TCodecMap & string]: ParamRefEntry<K> }[keyof TCodecMap & string]\n | ParamRefEntry<undefined>;\n\n/**\n * SQL-family mutator threaded into `SqlMiddleware.beforeExecute` as\n * `params`. Scope is `ParamRef.value` slots only — middleware cannot\n * insert / remove `ParamRef`s, rewrite SQL, or modify projection. The\n * type-level `ParamRefHandle` brand and the `replaceValue(ref,\n * newValue)` shape enforce this at compile time.\n *\n * `entries()` surfaces both literal call-site `ParamRef` slots and\n * `prepare()`-time `PreparedParamRef` bind slots; the handle and codec\n * id work the same for both.\n *\n * Allocation discipline: the mutator is constructed lazily from the\n * plan. `entries()` walks the plan's existing AST without allocating\n * an intermediate array; the working params buffer is only allocated\n * on the first `replaceValue` / `replaceValues` call. If no middleware\n * mutates, `currentParams()` returns the plan's original `params` by\n * reference identity.\n *\n * The `TCodecMap` parameter is a record keyed by codec id; `replaceValue`\n * infers `newValue` from `TCodecMap[H['codecId']]` for handles whose\n * codec id is statically resolvable. For codec ids the type system\n * cannot resolve, `newValue` falls back to `unknown` and the middleware\n * is on the hook for runtime correctness.\n */\nexport interface SqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends ParamRefMutator {\n /** Iterate every outbound `ParamRef` the plan currently carries, in canonical order. */\n entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>>;\n\n /**\n * Replace one `ParamRef`'s value with the result of bulk processing.\n * `newValue` is constrained to the codec's declared `TInput` for codec\n * ids the type system can resolve via `TCodecMap`; for unresolvable\n * codec ids `newValue` is `unknown` (the second overload).\n */\n replaceValue<TCodecId extends keyof TCodecMap & string>(\n ref: ParamRefHandle<TCodecId>,\n newValue: TCodecMap[TCodecId],\n ): void;\n replaceValue(ref: ParamRefHandle<undefined>, newValue: unknown): void;\n\n /** Replace many at once (typical for bulk-pattern middleware). */\n replaceValues(\n updates: Iterable<{\n readonly ref: ParamRefHandle<(keyof TCodecMap & string) | undefined>;\n readonly newValue: unknown;\n }>,\n ): void;\n}\n\n/**\n * Internal-only view of the mutator that exposes the post-mutation params\n * array to the SQL runtime. The runtime calls `currentParams()` after the\n * `beforeExecute` chain has run; the result is the plan's original\n * `params` by reference identity if no middleware mutated, otherwise a\n * frozen new array carrying the mutations applied in chain order.\n *\n * Family-internal contract — `SqlMiddleware` consumers never see this\n * shape; they receive the public `SqlParamRefMutator` view above.\n */\nexport interface SqlParamRefMutatorInternal<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends SqlParamRefMutator<TCodecMap> {\n currentParams(): readonly unknown[];\n}\n\ntype AnyHandle = ParamRefHandle<string | undefined>;\n\n/**\n * Build a {@link SqlParamRefMutatorInternal} for the given lowered plan.\n *\n * The mutator captures `plan.params` by reference and walks\n * `plan.ast` (via `collectOrderedParamRefs`) on demand to build\n * entries. Mutations write to a lazily-allocated working copy so the\n * fast path (no mutation) preserves bit-for-bit reference identity to\n * the original `plan.params`.\n *\n * Threading: `plan.ast` carries the canonical `ParamRef` ordering used\n * by every consumer (renderer's `$N` index map, encode-side metadata\n * walk, etc.). The mutator's `entries()` yields the same order so\n * middleware that filters by codec id sees ParamRefs in the order the\n * runtime will encode them.\n */\nexport function createSqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n>(plan: SqlExecutionPlan): SqlParamRefMutatorInternal<TCodecMap> {\n const originalParams = plan.params;\n const refs: ReadonlyArray<AnyParamRef> = plan.ast ? collectOrderedParamRefs(plan.ast) : [];\n let workingParams: unknown[] | undefined;\n\n const indexOfRef = (handle: AnyHandle): number => {\n // The handle is the underlying ParamRef instance the mutator yielded\n // from entries(); equality is identity equality on the ParamRef. The\n // brand on ParamRefHandle is unforgeable from outside, so the only\n // legal handles came from this mutator's entries().\n return refs.indexOf(handle as unknown as AnyParamRef);\n };\n\n const ensureWorkingParams = (): unknown[] => {\n if (!workingParams) {\n workingParams = [...originalParams];\n }\n return workingParams;\n };\n\n const writeAt = (index: number, value: unknown): void => {\n const buffer = ensureWorkingParams();\n buffer[index] = value;\n };\n\n function* entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>> {\n const view = workingParams ?? originalParams;\n for (let i = 0; i < refs.length; i++) {\n const ref = refs[i];\n if (!ref) continue;\n const handle = ref as unknown as ParamRefHandle<string | undefined>;\n let value: unknown;\n let codecId: string | undefined;\n if (ref.kind === 'param-ref') {\n value = i < view.length ? view[i] : ref.value;\n codecId = ref.codec?.codecId;\n } else {\n // PreparedParamRef positions carry no AST-side fallback value —\n // the slot value at index `i` is the only source.\n value = i < view.length ? view[i] : undefined;\n codecId = ref.codec.codecId;\n }\n // The runtime erases the discriminated union to a single shape; the\n // public type pins each entry's `ref` to the matching `codecId`\n // arm at compile time.\n const entry: ParamRefEntry<string | undefined> = { ref: handle, value, codecId };\n yield entry as ParamRefEntryUnion<TCodecMap>;\n }\n }\n\n function replaceValue(handle: AnyHandle, newValue: unknown): void {\n const index = indexOfRef(handle);\n if (index < 0) {\n // Handle does not belong to this plan. The type system pins this\n // at the brand level; this runtime check guards against handles\n // smuggled across plans.\n return;\n }\n writeAt(index, newValue);\n }\n\n function replaceValues(\n updates: Iterable<{ readonly ref: AnyHandle; readonly newValue: unknown }>,\n ): void {\n for (const { ref, newValue } of updates) {\n const index = indexOfRef(ref);\n if (index < 0) continue;\n writeAt(index, newValue);\n }\n }\n\n // The public `SqlParamRefMutator` declares overloaded `replaceValue`\n // signatures (typed-by-codec / unresolvable-codec). The implementation\n // is one function with a permissive runtime signature; the cast is the\n // single point at which the runtime function meets the typed overload\n // surface, matching the overload-implementation pattern.\n return {\n entries,\n replaceValue: replaceValue as SqlParamRefMutator<TCodecMap>['replaceValue'],\n replaceValues,\n currentParams(): readonly unknown[] {\n if (!workingParams) {\n return originalParams;\n }\n return Object.freeze([...workingParams]);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAyIA,SAAgB,yBAEd,MAA+D;CAC/D,MAAM,iBAAiB,KAAK;CAC5B,MAAM,OAAmC,KAAK,MAAM,wBAAwB,KAAK,GAAG,IAAI,CAAC;CACzF,IAAI;CAEJ,MAAM,cAAc,WAA8B;EAKhD,OAAO,KAAK,QAAQ,MAAgC;CACtD;CAEA,MAAM,4BAAuC;EAC3C,IAAI,CAAC,eACH,gBAAgB,CAAC,GAAG,cAAc;EAEpC,OAAO;CACT;CAEA,MAAM,WAAW,OAAe,UAAyB;EACvD,MAAM,SAAS,oBAAoB;EACnC,OAAO,SAAS;CAClB;CAEA,UAAU,UAA2D;EACnE,MAAM,OAAO,iBAAiB;EAC9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,MAAM,KAAK;GACjB,IAAI,CAAC,KAAK;GACV,MAAM,SAAS;GACf,IAAI;GACJ,IAAI;GACJ,IAAI,IAAI,SAAS,aAAa;IAC5B,QAAQ,IAAI,KAAK,SAAS,KAAK,KAAK,IAAI;IACxC,UAAU,IAAI,OAAO;GACvB,OAAO;IAGL,QAAQ,IAAI,KAAK,SAAS,KAAK,KAAK,KAAA;IACpC,UAAU,IAAI,MAAM;GACtB;GAKA,MAAM;IAD6C,KAAK;IAAQ;IAAO;GAC7D;EACZ;CACF;CAEA,SAAS,aAAa,QAAmB,UAAyB;EAChE,MAAM,QAAQ,WAAW,MAAM;EAC/B,IAAI,QAAQ,GAIV;EAEF,QAAQ,OAAO,QAAQ;CACzB;CAEA,SAAS,cACP,SACM;EACN,KAAK,MAAM,EAAE,KAAK,cAAc,SAAS;GACvC,MAAM,QAAQ,WAAW,GAAG;GAC5B,IAAI,QAAQ,GAAG;GACf,QAAQ,OAAO,QAAQ;EACzB;CACF;CAOA,OAAO;EACL;EACc;EACd;EACA,gBAAoC;GAClC,IAAI,CAAC,eACH,OAAO;GAET,OAAO,OAAO,OAAO,CAAC,GAAG,aAAa,CAAC;EACzC;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"middleware-CbHPs9WK.mjs","names":[],"sources":["../src/middleware/param-ref-mutator.ts"],"sourcesContent":["import type { ParamRefMutator } from '@prisma-next/framework-components/runtime';\nimport type { AnyParamRef } from '../ast/types';\nimport { collectOrderedParamRefs } from '../ast/util';\nimport type { SqlExecutionPlan } from '../sql-execution-plan';\n\n/**\n * Brand applied to {@link ParamRefHandle} so user-constructed handles\n * are rejected by the type system. The mutator only accepts handles it\n * produced from `entries()`.\n *\n * The brand is a phantom type — there is no runtime token. At runtime\n * the handle is the underlying `ParamRef` instance from the plan's\n * `ast`; the brand only narrows the type-level surface so callers\n * cannot fabricate a handle from a fresh `ParamRef.of(...)`.\n */\ndeclare const paramRefHandleBrand: unique symbol;\n\n/**\n * Opaque token identifying a single `ParamRef` in the plan. Produced by\n * {@link SqlParamRefMutator.entries}; consumed by `replaceValue` /\n * `replaceValues`.\n *\n * The phantom `TCodecId` parameter records the codec id of the\n * referenced `ParamRef` so type-level inference can route replacement\n * values through `TCodecMap` to the codec's declared `TInput`.\n */\nexport interface ParamRefHandle<TCodecId extends string | undefined = string | undefined> {\n readonly [paramRefHandleBrand]: TCodecId;\n}\n\n/**\n * One outbound `ParamRef` slot in the plan exposed to middleware.\n * `value` is the current value (post any prior middleware mutations);\n * `codecId` is the codec id declared on the underlying `ParamRef.codec`.\n */\nexport interface ParamRefEntry<TCodecId extends string | undefined = string | undefined> {\n readonly ref: ParamRefHandle<TCodecId>;\n readonly value: unknown;\n readonly codecId: TCodecId;\n}\n\n/**\n * Discriminated entry union over a codec map. For each `K` in\n * `TCodecMap`, `entries()` may yield a `ParamRefEntry<K>`; ParamRefs\n * with no codec id (or a codec id outside the map) yield a\n * `ParamRefEntry<undefined>`. Pattern-matching on `entry.codecId`\n * narrows `entry.ref` to a `ParamRefHandle<K>`, which routes through\n * the typed `replaceValue` overload.\n */\nexport type ParamRefEntryUnion<TCodecMap extends Record<string, unknown>> =\n | { [K in keyof TCodecMap & string]: ParamRefEntry<K> }[keyof TCodecMap & string]\n | ParamRefEntry<undefined>;\n\n/**\n * SQL-family mutator threaded into `SqlMiddleware.beforeExecute` as\n * `params`. Scope is `ParamRef.value` slots only — middleware cannot\n * insert / remove `ParamRef`s, rewrite SQL, or modify projection. The\n * type-level `ParamRefHandle` brand and the `replaceValue(ref,\n * newValue)` shape enforce this at compile time.\n *\n * `entries()` surfaces both literal call-site `ParamRef` slots and\n * `prepare()`-time `PreparedParamRef` bind slots; the handle and codec\n * id work the same for both.\n *\n * Allocation discipline: the mutator is constructed lazily from the\n * plan. `entries()` walks the plan's existing AST without allocating\n * an intermediate array; the working params buffer is only allocated\n * on the first `replaceValue` / `replaceValues` call. If no middleware\n * mutates, `currentParams()` returns the plan's original `params` by\n * reference identity.\n *\n * The `TCodecMap` parameter is a record keyed by codec id; `replaceValue`\n * infers `newValue` from `TCodecMap[H['codecId']]` for handles whose\n * codec id is statically resolvable. For codec ids the type system\n * cannot resolve, `newValue` falls back to `unknown` and the middleware\n * is on the hook for runtime correctness.\n */\nexport interface SqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends ParamRefMutator {\n /** Iterate every outbound `ParamRef` the plan currently carries, in canonical order. */\n entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>>;\n\n /**\n * Replace one `ParamRef`'s value with the result of bulk processing.\n * `newValue` is constrained to the codec's declared `TInput` for codec\n * ids the type system can resolve via `TCodecMap`; for unresolvable\n * codec ids `newValue` is `unknown` (the second overload).\n */\n replaceValue<TCodecId extends keyof TCodecMap & string>(\n ref: ParamRefHandle<TCodecId>,\n newValue: TCodecMap[TCodecId],\n ): void;\n replaceValue(ref: ParamRefHandle<undefined>, newValue: unknown): void;\n\n /** Replace many at once (typical for bulk-pattern middleware). */\n replaceValues(\n updates: Iterable<{\n readonly ref: ParamRefHandle<(keyof TCodecMap & string) | undefined>;\n readonly newValue: unknown;\n }>,\n ): void;\n}\n\n/**\n * Internal-only view of the mutator that exposes the post-mutation params\n * array to the SQL runtime. The runtime calls `currentParams()` after the\n * `beforeExecute` chain has run; the result is the plan's original\n * `params` by reference identity if no middleware mutated, otherwise a\n * frozen new array carrying the mutations applied in chain order.\n *\n * Family-internal contract — `SqlMiddleware` consumers never see this\n * shape; they receive the public `SqlParamRefMutator` view above.\n */\nexport interface SqlParamRefMutatorInternal<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n> extends SqlParamRefMutator<TCodecMap> {\n currentParams(): readonly unknown[];\n}\n\ntype AnyHandle = ParamRefHandle<string | undefined>;\n\n/**\n * Build a {@link SqlParamRefMutatorInternal} for the given lowered plan.\n *\n * The mutator captures `plan.params` by reference and walks\n * `plan.ast` (via `collectOrderedParamRefs`) on demand to build\n * entries. Mutations write to a lazily-allocated working copy so the\n * fast path (no mutation) preserves bit-for-bit reference identity to\n * the original `plan.params`.\n *\n * Threading: `plan.ast` carries the canonical `ParamRef` ordering used\n * by every consumer (renderer's `$N` index map, encode-side metadata\n * walk, etc.). The mutator's `entries()` yields the same order so\n * middleware that filters by codec id sees ParamRefs in the order the\n * runtime will encode them.\n */\nexport function createSqlParamRefMutator<\n TCodecMap extends Record<string, unknown> = Record<string, unknown>,\n>(plan: SqlExecutionPlan): SqlParamRefMutatorInternal<TCodecMap> {\n const originalParams = plan.params;\n const refs: ReadonlyArray<AnyParamRef> = plan.ast ? collectOrderedParamRefs(plan.ast) : [];\n let workingParams: unknown[] | undefined;\n\n const indexOfRef = (handle: AnyHandle): number => {\n // The handle is the underlying ParamRef instance the mutator yielded\n // from entries(); equality is identity equality on the ParamRef. The\n // brand on ParamRefHandle is unforgeable from outside, so the only\n // legal handles came from this mutator's entries().\n return refs.indexOf(handle as unknown as AnyParamRef);\n };\n\n const ensureWorkingParams = (): unknown[] => {\n if (!workingParams) {\n workingParams = [...originalParams];\n }\n return workingParams;\n };\n\n const writeAt = (index: number, value: unknown): void => {\n const buffer = ensureWorkingParams();\n buffer[index] = value;\n };\n\n function* entries(): IterableIterator<ParamRefEntryUnion<TCodecMap>> {\n const view = workingParams ?? originalParams;\n for (let i = 0; i < refs.length; i++) {\n const ref = refs[i];\n if (!ref) continue;\n const handle = ref as unknown as ParamRefHandle<string | undefined>;\n let value: unknown;\n let codecId: string | undefined;\n if (ref.kind === 'param-ref') {\n value = i < view.length ? view[i] : ref.value;\n codecId = ref.codec?.codecId;\n } else {\n // PreparedParamRef positions carry no AST-side fallback value —\n // the slot value at index `i` is the only source.\n value = i < view.length ? view[i] : undefined;\n codecId = ref.codec.codecId;\n }\n // The runtime erases the discriminated union to a single shape; the\n // public type pins each entry's `ref` to the matching `codecId`\n // arm at compile time.\n const entry: ParamRefEntry<string | undefined> = { ref: handle, value, codecId };\n yield entry as ParamRefEntryUnion<TCodecMap>;\n }\n }\n\n function replaceValue(handle: AnyHandle, newValue: unknown): void {\n const index = indexOfRef(handle);\n if (index < 0) {\n // Handle does not belong to this plan. The type system pins this\n // at the brand level; this runtime check guards against handles\n // smuggled across plans.\n return;\n }\n writeAt(index, newValue);\n }\n\n function replaceValues(\n updates: Iterable<{ readonly ref: AnyHandle; readonly newValue: unknown }>,\n ): void {\n for (const { ref, newValue } of updates) {\n const index = indexOfRef(ref);\n if (index < 0) continue;\n writeAt(index, newValue);\n }\n }\n\n // The public `SqlParamRefMutator` declares overloaded `replaceValue`\n // signatures (typed-by-codec / unresolvable-codec). The implementation\n // is one function with a permissive runtime signature; the cast is the\n // single point at which the runtime function meets the typed overload\n // surface, matching the overload-implementation pattern.\n return {\n entries,\n replaceValue: replaceValue as SqlParamRefMutator<TCodecMap>['replaceValue'],\n replaceValues,\n currentParams(): readonly unknown[] {\n if (!workingParams) {\n return originalParams;\n }\n return Object.freeze([...workingParams]);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SqlExecutionPlan } from "./sql-execution-plan-
|
|
1
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-Dopo3SDj.mjs";
|
|
2
2
|
import { ParamRefMutator } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/middleware/param-ref-mutator.d.ts
|
|
@@ -116,4 +116,4 @@ interface SqlParamRefMutatorInternal<TCodecMap extends Record<string, unknown> =
|
|
|
116
116
|
declare function createSqlParamRefMutator<TCodecMap extends Record<string, unknown> = Record<string, unknown>>(plan: SqlExecutionPlan): SqlParamRefMutatorInternal<TCodecMap>;
|
|
117
117
|
//#endregion
|
|
118
118
|
export { SqlParamRefMutatorInternal as a, SqlParamRefMutator as i, ParamRefEntryUnion as n, createSqlParamRefMutator as o, ParamRefHandle as r, ParamRefEntry as t };
|
|
119
|
-
//# sourceMappingURL=middleware-
|
|
119
|
+
//# sourceMappingURL=middleware-DkAjjPxq.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware-
|
|
1
|
+
{"version":3,"file":"middleware-DkAjjPxq.d.mts","names":[],"sources":["../src/middleware/param-ref-mutator.ts"],"mappings":";;;;;;AAG8D;;;;AAYd;AAWhD;;;cAXc,mBAAA;;;;;AAY4B;AAQ1C;;;;UATiB,cAAA;EAAA,UACL,mBAAmB,GAAG,QAAA;AAAA;;;;;;UAQjB,aAAA;EAAA,SACN,GAAA,EAAK,cAAA,CAAe,QAAA;EAAA,SACpB,KAAA;EAAA,SACA,OAAA,EAAS,QAAA;AAAA;AAWpB;;;;;;;;AAAA,KAAY,kBAAA,mBAAqC,MAAA,mCAC/B,SAAA,YAAqB,aAAA,CAAc,CAAA,UAAW,SAAA,aAC5D,aAAA;;;;;;;;;;AAAa;AA0BjB;;;;;;;;;;;;;;UAAiB,kBAAA,mBACG,MAAA,oBAA0B,MAAA,2BACpC,eAAA;EAmBU;EAjBlB,OAAA,IAAW,gBAAA,CAAiB,kBAAA,CAAmB,SAAA;EAFvC;;;;;;EAUR,YAAA,wBAAoC,SAAA,WAClC,GAAA,EAAK,cAAA,CAAe,QAAA,GACpB,QAAA,EAAU,SAAA,CAAU,QAAA;EAEtB,YAAA,CAAa,GAAA,EAAK,cAAA,aAA2B,QAAA;EAZlC;EAeX,aAAA,CACE,OAAA,EAAS,QAAA;IAAA,SACE,GAAA,EAAK,cAAA,QAAsB,SAAA;IAAA,SAC3B,QAAA;EAAA;AAAA;;;;;;;;;;;UAeE,0BAAA,mBACG,MAAA,oBAA0B,MAAA,2BACpC,kBAAA,CAAmB,SAAA;EAC3B,aAAA;AAAA;;;;;;AAjBI;AAcN;;;;;;;;;iBAuBgB,wBAAA,mBACI,MAAA,oBAA0B,MAAA,kBAAA,CAC5C,IAAA,EAAM,gBAAA,GAAmB,0BAAA,CAA2B,SAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as AnyQueryAst } from "./types-
|
|
1
|
+
import { f as AnyQueryAst } from "./types-CXQF5KS8.mjs";
|
|
2
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
2
3
|
import { QueryPlan } from "@prisma-next/framework-components/runtime";
|
|
3
4
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
|
-
import { Contract } from "@prisma-next/contract/types";
|
|
5
5
|
|
|
6
6
|
//#region src/plan.d.ts
|
|
7
7
|
/**
|
|
@@ -41,4 +41,4 @@ interface SqlQueryPlan<Row = unknown> extends QueryPlan<Row> {
|
|
|
41
41
|
declare function planFromAst<Row = unknown>(ast: AnyQueryAst, contract: Contract<SqlStorage>, laneId?: string): SqlQueryPlan<Row>;
|
|
42
42
|
//#endregion
|
|
43
43
|
export { planFromAst as n, SqlQueryPlan as t };
|
|
44
|
-
//# sourceMappingURL=plan-
|
|
44
|
+
//# sourceMappingURL=plan-Ds9oN5QU.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-
|
|
1
|
+
{"version":3,"file":"plan-Ds9oN5QU.d.mts","names":[],"sources":["../src/plan.ts"],"mappings":";;;;;;;;AAkBA;;;;;;;;;;;UAAiB,YAAA,wBAAoC,SAAA,CAAU,GAAA;EAAA,SACpD,GAAA,EAAK,WAAA;EAAA,SACL,MAAA;AAAA;AAAM;AAoBjB;;;;;;;;;;;;;;;;AApBiB,iBAoBD,WAAA,eAAA,CACd,GAAA,EAAK,WAAA,EACL,QAAA,EAAU,QAAA,CAAS,UAAA,GACnB,MAAA,YACC,YAAA,CAAa,GAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as ContractCodecRegistry } from "./codec-types-
|
|
1
|
+
import { c as ContractCodecRegistry } from "./codec-types-Ey_MAEly.mjs";
|
|
2
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
2
3
|
import { CodecDescriptor, CodecRef } from "@prisma-next/framework-components/codec";
|
|
3
4
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
|
-
import { Contract } from "@prisma-next/contract/types";
|
|
5
5
|
import { SqlOperationRegistry } from "@prisma-next/sql-operations";
|
|
6
6
|
|
|
7
7
|
//#region src/query-lane-context.d.ts
|
|
@@ -80,4 +80,4 @@ interface ExecutionContext<TContract extends Contract<SqlStorage> = Contract<Sql
|
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
82
|
export { MutationDefaultsOptions as a, MutationDefaultsOp as i, CodecDescriptorRegistry as n, TypeHelperRegistry as o, ExecutionContext as r, AppliedMutationDefault as t };
|
|
83
|
-
//# sourceMappingURL=query-lane-context-
|
|
83
|
+
//# sourceMappingURL=query-lane-context-BUYT0tOb.d.mts.map
|
package/dist/{query-lane-context-Dw1Tz0kv.d.mts.map → query-lane-context-BUYT0tOb.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-lane-context-
|
|
1
|
+
{"version":3,"file":"query-lane-context-BUYT0tOb.d.mts","names":[],"sources":["../src/query-lane-context.ts"],"mappings":";;;;;;;;;AASA;UAAiB,uBAAA;;;;EAIf,aAAA,CAAc,OAAA,WAAkB,eAAA;EAgBtB;;;;;;;;;;;EAJV,iBAAA,CAAkB,KAAA,UAAe,MAAA,WAAiB,QAAA;EAIxC;;;EAAV,MAAA,IAAU,gBAAA,CAAiB,eAAA;EAIgB;;AAAe;EAA1D,YAAA,CAAa,UAAA,oBAA8B,eAAA;AAAA;;;AAMN;KAA3B,kBAAA,GAAqB,MAAM;AAAA,KAE3B,kBAAA;AAAA,KAEA,sBAAA;EAAA,SACD,MAAA;EAAA,SACA,KAAK;AAAA;AAAA,KAGJ,uBAAA;EAAA,SACD,EAAA,EAAI,kBAAA;EAAA,SACJ,KAAA;EAAA,SACA,MAAA,EAAQ,MAAA;EAHP;;;;EAAA,SAQD,iBAAA,GAAoB,GAAA;AAAA;;;;;;UAQd,gBAAA,mBAAmC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA;EAAA,SACzE,QAAA,EAAU,SAAA;EATV;;;EAAA,SAaA,cAAA,EAAgB,qBAAA;EALV;;;EAAA,SASN,gBAAA,EAAkB,uBAAA;EAAA,SAClB,eAAA,EAAiB,oBAAA;EAVwD;;;EAAA,SAczE,KAAA,EAAO,kBAAA;EALW;;;EAS3B,qBAAA,CAAsB,OAAA,EAAS,uBAAA,GAA0B,aAAA,CAAc,sBAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as AnyQueryAst } from "./types-
|
|
1
|
+
import { f as AnyQueryAst } from "./types-CXQF5KS8.mjs";
|
|
2
2
|
import { ExecutionPlan } from "@prisma-next/framework-components/runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/sql-execution-plan.d.ts
|
|
@@ -29,4 +29,4 @@ interface SqlExecutionPlan<Row = unknown> extends ExecutionPlan<Row> {
|
|
|
29
29
|
}
|
|
30
30
|
//#endregion
|
|
31
31
|
export { SqlExecutionPlan as t };
|
|
32
|
-
//# sourceMappingURL=sql-execution-plan-
|
|
32
|
+
//# sourceMappingURL=sql-execution-plan-Dopo3SDj.d.mts.map
|
package/dist/{sql-execution-plan-DeBoZUre.d.mts.map → sql-execution-plan-Dopo3SDj.d.mts.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-execution-plan-
|
|
1
|
+
{"version":3,"file":"sql-execution-plan-Dopo3SDj.d.mts","names":[],"sources":["../src/sql-execution-plan.ts"],"mappings":";;;;;;AAuBA;;;;;;;;;;;;;;;;AAG2B;;UAHV,gBAAA,wBAAwC,aAAA,CAAc,GAAA;EAAA,SAC5D,GAAA;EAAA,SACA,MAAA;EAAA,SACA,GAAA,EAAK,WAAA;AAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { J as ParamRef, g as ColumnRef } from "./types-
|
|
2
|
-
import { r as ExecutionContext } from "./query-lane-context-
|
|
3
|
-
import { t as SqlExecutionPlan } from "./sql-execution-plan-
|
|
1
|
+
import { J as ParamRef, g as ColumnRef } from "./types-CXQF5KS8.mjs";
|
|
2
|
+
import { r as ExecutionContext } from "./query-lane-context-BUYT0tOb.mjs";
|
|
3
|
+
import { t as SqlExecutionPlan } from "./sql-execution-plan-Dopo3SDj.mjs";
|
|
4
|
+
import { Contract, ContractModelDefinitions } from "@prisma-next/contract/types";
|
|
4
5
|
import { ExtractFieldOutputTypes, SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
|
|
5
|
-
import { Contract, ContractModelsMap } from "@prisma-next/contract/types";
|
|
6
6
|
import { ParamSpec } from "@prisma-next/operations";
|
|
7
7
|
import { SqlLoweringSpec } from "@prisma-next/sql-operations";
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ type Expr = ColumnRef | ParamRef;
|
|
|
12
12
|
* Extracts the model name for a given table by iterating models to find the one
|
|
13
13
|
* whose `storage.table` matches.
|
|
14
14
|
*/
|
|
15
|
-
type ExtractTableToModel<TContract extends Contract<SqlStorage>, TableName extends string> =
|
|
15
|
+
type ExtractTableToModel<TContract extends Contract<SqlStorage>, TableName extends string> = ContractModelDefinitions<TContract> extends infer Models extends Record<string, unknown> ? { [M in keyof Models & string]: Models[M] extends {
|
|
16
16
|
readonly storage: {
|
|
17
17
|
readonly table: TableName;
|
|
18
18
|
};
|
|
@@ -21,7 +21,7 @@ type ExtractTableToModel<TContract extends Contract<SqlStorage>, TableName exten
|
|
|
21
21
|
* Extracts the field name for a given column by finding the field in
|
|
22
22
|
* `model.storage.fields` whose `column` matches.
|
|
23
23
|
*/
|
|
24
|
-
type ExtractColumnToField<TContract extends Contract<SqlStorage>, TableName extends string, ColumnName extends string> = ExtractTableToModel<TContract, TableName> extends infer ModelName extends string ?
|
|
24
|
+
type ExtractColumnToField<TContract extends Contract<SqlStorage>, TableName extends string, ColumnName extends string> = ExtractTableToModel<TContract, TableName> extends infer ModelName extends string ? ContractModelDefinitions<TContract> extends infer Models extends Record<string, unknown> ? ModelName & keyof Models extends infer MKey extends string ? Models[MKey] extends {
|
|
25
25
|
readonly storage: {
|
|
26
26
|
readonly fields: infer Fields extends Record<string, unknown>;
|
|
27
27
|
};
|
|
@@ -94,18 +94,6 @@ type OperationsForTypeId<TypeId extends string, Operations extends OperationType
|
|
|
94
94
|
type ComputeColumnJsType<TContract extends Contract<SqlStorage>, TableName extends string, ColumnName extends string, ColumnMeta extends StorageColumn, CodecTypes extends Record<string, {
|
|
95
95
|
readonly output: unknown;
|
|
96
96
|
}>> = ExtractTableToModel<TContract, TableName> extends infer ModelName ? [ModelName] extends [never] ? FallbackCodecLookup<ColumnMeta, CodecTypes> : ModelName extends string ? ExtractColumnToField<TContract, TableName, ColumnName> extends infer FieldName ? [FieldName] extends [never] ? FallbackCodecLookup<ColumnMeta, CodecTypes> : FieldName extends string ? ModelName extends keyof ExtractFieldOutputTypes<TContract> ? FieldName extends keyof ExtractFieldOutputTypes<TContract>[ModelName] ? ExtractFieldOutputTypes<TContract>[ModelName][FieldName] : never : never : never : never : never : never;
|
|
97
|
-
/**
|
|
98
|
-
* Utility type to check if a contract has the required capabilities for includeMany.
|
|
99
|
-
* Requires both `lateral` and `jsonAgg` to be `true` in the contract's capabilities for the target.
|
|
100
|
-
* Capabilities are nested by target: `{ [target]: { lateral: true, jsonAgg: true } }`
|
|
101
|
-
*/
|
|
102
|
-
type HasIncludeManyCapabilities<TContract extends Contract<SqlStorage>> = TContract extends {
|
|
103
|
-
capabilities: infer C;
|
|
104
|
-
target: infer T;
|
|
105
|
-
} ? T extends string ? C extends Record<string, Record<string, boolean>> ? C extends { [K in T]: infer TargetCaps } ? TargetCaps extends {
|
|
106
|
-
lateral: true;
|
|
107
|
-
jsonAgg: true;
|
|
108
|
-
} ? true : false : false : false : false : false;
|
|
109
97
|
/**
|
|
110
98
|
* Alias for the SQL-domain executable plan, exposed under the legacy
|
|
111
99
|
* `SqlPlan` name for compatibility with SQL builder/utility call sites.
|
|
@@ -189,5 +177,5 @@ interface SqlBuilderOptions<TContract extends Contract<SqlStorage> = Contract<Sq
|
|
|
189
177
|
readonly context: ExecutionContext<TContract>;
|
|
190
178
|
}
|
|
191
179
|
//#endregion
|
|
192
|
-
export {
|
|
193
|
-
//# sourceMappingURL=types-
|
|
180
|
+
export { TableMetadata as C, TableKey as S, RawTemplateOptions as _, ComputeColumnJsType as a, SqlPlan as b, Meta as c, OperationTypeSignature as d, OperationTypes as f, RawTemplateFactory as g, RawFunctionOptions as h, ColumnsOf as i, ModelDef as l, RawFactory as m, BuildParamsMap as n, Expr as o, OperationsForTypeId as p, CodecTypes as r, META as s, BuildOptions as t, ModelMetadata as u, RuntimeError as v, TablesOf as w, TableDef as x, SqlBuilderOptions as y };
|
|
181
|
+
//# sourceMappingURL=types-CLirmH9F.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-CLirmH9F.d.mts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;KAYY,IAAA,GAAO,SAAA,GAAY,QAAQ;;AAAvC;;;KAMK,mBAAA,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ACV,OAAA,EAAS,oBAAA,KACN,MAAA,yBACA,gBAAgB;AAAA,UAEJ,UAAA,SAAmB,kBAAA;EAAA,CACjC,IAAA,UAAc,OAAA,EAAS,kBAAA,GAAqB,gBAAA;EAC7C,IAAA,CAAK,OAAA,EAAS,kBAAA,GAAqB,kBAAA;AAAA;AAAA,UAGpB,YAAA,SAAqB,KAAK;EAAA,SAChC,IAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA,GAAU,MAAA;EAAA,SACV,KAAA;EAAA,SACA,IAAA;AAAA;AAAA,UAGM,cAAA;EAAA,UACL,IAAY;AAAA;AAAA,UAGP,YAAA;EAAA,SACN,MAAA,GAAS,cAAc;AAAA;AAAA,UAGjB,iBAAA,mBAAoC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA;EAAA,SAC1E,OAAA,EAAS,gBAAA,CAAiB,SAAA;AAAA"}
|
|
@@ -77,6 +77,7 @@ function rewriteInsertValue(value, rewriter) {
|
|
|
77
77
|
case "prepared-param-ref": return rewriter.preparedParamRef ? rewriter.preparedParamRef(value) : value;
|
|
78
78
|
case "column-ref": return rewriter.columnRef ? rewriteColumnRefForInsert(value, rewriter) : value;
|
|
79
79
|
case "default-value": return value;
|
|
80
|
+
case "raw-expr": return value;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
function rewriteParamRefForInsert(value, rewriter) {
|
|
@@ -137,14 +138,23 @@ var TableSource = class TableSource extends FromSource {
|
|
|
137
138
|
kind = "table-source";
|
|
138
139
|
name;
|
|
139
140
|
alias;
|
|
140
|
-
|
|
141
|
+
/**
|
|
142
|
+
* Resolved storage namespace coordinate for this table, stamped when the
|
|
143
|
+
* table proxy constructs the AST. Renderers qualify via the namespace
|
|
144
|
+
* concretion's `qualifyTable()` using this id — never by re-resolving the
|
|
145
|
+
* bare table name at render time.
|
|
146
|
+
*/
|
|
147
|
+
namespaceId;
|
|
148
|
+
constructor(name, alias, namespaceId) {
|
|
141
149
|
super();
|
|
142
150
|
this.name = name;
|
|
143
151
|
this.alias = alias;
|
|
144
|
-
this.
|
|
152
|
+
this.namespaceId = namespaceId;
|
|
145
153
|
}
|
|
146
|
-
static named(name, alias) {
|
|
147
|
-
|
|
154
|
+
static named(name, alias, namespaceId) {
|
|
155
|
+
const source = new TableSource(name, alias, namespaceId);
|
|
156
|
+
source.freeze();
|
|
157
|
+
return source;
|
|
148
158
|
}
|
|
149
159
|
rewrite(rewriter) {
|
|
150
160
|
return rewriter.tableSource ? rewriter.tableSource(this) : this;
|
|
@@ -1083,6 +1093,7 @@ var InsertAst = class InsertAst extends QueryAst {
|
|
|
1083
1093
|
collectParamRefs() {
|
|
1084
1094
|
const refs = [];
|
|
1085
1095
|
for (const row of this.rows) for (const value of Object.values(row)) if (value.kind === "param-ref" || value.kind === "prepared-param-ref") refs.push(value);
|
|
1096
|
+
else if (value.kind === "raw-expr") refs.push(...value.collectParamRefs());
|
|
1086
1097
|
if (this.onConflict?.action.kind === "do-update-set") {
|
|
1087
1098
|
for (const value of Object.values(this.onConflict.action.set)) if (value.kind === "param-ref" || value.kind === "prepared-param-ref") refs.push(value);
|
|
1088
1099
|
}
|
|
@@ -1230,4 +1241,4 @@ function isWhereExpr(value) {
|
|
|
1230
1241
|
//#endregion
|
|
1231
1242
|
export { SelectAst as A, OrExpr as C, ProjectionItem as D, PreparedParamRef as E, isQueryAst as F, isWhereExpr as I, queryAstKinds as L, TableSource as M, UpdateAst as N, RawExpr as O, WindowFuncExpr as P, whereExprKinds as R, OperationExpr as S, ParamRef as T, JsonObjectExpr as _, DefaultValueExpr as a, NotExpr as b, DoNothingConflictAction as c, ExistsExpr as d, IdentifierRef as f, JsonArrayAggExpr as g, JoinAst as h, ColumnRef as i, SubqueryExpr as j, RawSqlExpr as k, DoUpdateSetConflictAction as l, InsertOnConflict as m, AndExpr as n, DeleteAst as o, InsertAst as p, BinaryExpr as r, DerivedTableSource as s, AggregateExpr as t, EqColJoinOn as u, ListExpression as v, OrderByItem as w, NullCheckExpr as x, LiteralExpr as y };
|
|
1232
1243
|
|
|
1233
|
-
//# sourceMappingURL=types-
|
|
1244
|
+
//# sourceMappingURL=types-CMznS9Yh.mjs.map
|