@prisma/orm-family-sql 8.0.0-rc.16-dev.1 → 8.0.0-rc.16-dev.3
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/{ast-DFvrXEbF.mjs → ast-B_UPqRyb.mjs} +29 -2
- package/dist/ast-B_UPqRyb.mjs.map +1 -0
- package/dist/{ast-fsQdXFSV.d.mts → ast-Bf6J9_ra.d.mts} +83 -3
- package/dist/ast-Bf6J9_ra.d.mts.map +1 -0
- package/dist/builder.d.mts +1 -1
- package/dist/builder__runtime.d.mts +2 -2
- package/dist/builder__runtime.mjs +17 -16
- package/dist/builder__runtime.mjs.map +1 -1
- package/dist/builder__types.d.mts +1 -1
- package/dist/{control-Bi2JsNep.d.mts → control-DCt08EpW.d.mts} +4 -4
- package/dist/{control-Bi2JsNep.d.mts.map → control-DCt08EpW.d.mts.map} +1 -1
- package/dist/control-adapter-CD_gz6TI.d.mts +1 -0
- package/dist/{control-adapter-CkFfBVei-gLS9b87G.d.mts → control-adapter-CkFfBVei-Ba9JNrCN.d.mts} +2 -2
- package/dist/{control-adapter-CkFfBVei-gLS9b87G.d.mts.map → control-adapter-CkFfBVei-Ba9JNrCN.d.mts.map} +1 -1
- package/dist/{db-CJxU3aL_-CM2IReAK.d.mts → db-D7R5zKiH-SEM04lcK.d.mts} +9 -47
- package/dist/{db-CJxU3aL_-CM2IReAK.d.mts.map → db-D7R5zKiH-SEM04lcK.d.mts.map} +1 -1
- package/dist/{diff-Bg9o9CgK.d.mts → diff-3tfqwWS7.d.mts} +3 -3
- package/dist/{diff-Bg9o9CgK.d.mts.map → diff-3tfqwWS7.d.mts.map} +1 -1
- package/dist/family.d.mts +6 -6
- package/dist/family__control-adapter.d.mts +2 -2
- package/dist/family__control.d.mts +2 -2
- package/dist/family__diff.d.mts +2 -2
- package/dist/family__migration.d.mts +1 -1
- package/dist/{index-Z2FIIMxv.d.mts → index-DYjWQAcJ.d.mts} +3 -3
- package/dist/{index-Z2FIIMxv.d.mts.map → index-DYjWQAcJ.d.mts.map} +1 -1
- package/dist/{migration-o-g1rSb-.d.mts → migration-D6NJlA6-.d.mts} +2 -2
- package/dist/{migration-o-g1rSb-.d.mts.map → migration-D6NJlA6-.d.mts.map} +1 -1
- package/dist/orm-client.d.mts +41 -11
- package/dist/orm-client.d.mts.map +1 -1
- package/dist/orm-client.mjs +101 -6
- package/dist/orm-client.mjs.map +1 -1
- package/dist/{prepared-statement-YtgdlN7e-BU4UQxB5.d.mts → prepared-statement-YtgdlN7e-DBJtJAm7.d.mts} +2 -2
- package/dist/{prepared-statement-YtgdlN7e-BU4UQxB5.d.mts.map → prepared-statement-YtgdlN7e-DBJtJAm7.d.mts.map} +1 -1
- package/dist/relational-core.d.mts +2 -2
- package/dist/relational-core.mjs +2 -2
- package/dist/relational-core__ast.d.mts +2 -2
- package/dist/relational-core__ast.mjs +2 -2
- package/dist/runtime.d.mts +3 -3
- package/dist/runtime__internal__prepared-query.d.mts +1 -1
- package/dist/{types-CvuS68sy-Dip2oI3M.d.mts → types-CvuS68sy-ReNXbgpE.d.mts} +2 -2
- package/dist/{types-CvuS68sy-Dip2oI3M.d.mts.map → types-CvuS68sy-ReNXbgpE.d.mts.map} +1 -1
- package/package.json +18 -18
- package/dist/ast-DFvrXEbF.mjs.map +0 -1
- package/dist/ast-fsQdXFSV.d.mts.map +0 -1
- package/dist/control-adapter-Ciule8Fh.d.mts +0 -1
|
@@ -117,6 +117,33 @@ var JsonDocumentProjection = class JsonDocumentProjection extends JsonValueProje
|
|
|
117
117
|
return new JsonDocumentProjection(this.value.rewrite(rewriter));
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
|
+
/** The `ORM.LOCK_INCOMPATIBLE` error for a lock refused because of `conflict`. */
|
|
121
|
+
function lockIncompatible(conflict, message) {
|
|
122
|
+
return structuredError("ORM.LOCK_INCOMPATIBLE", message, { meta: { conflict } });
|
|
123
|
+
}
|
|
124
|
+
/** The capability each lock strength needs. */
|
|
125
|
+
const lockStrengthCapabilities = {
|
|
126
|
+
forUpdate: { sql: { forUpdate: true } },
|
|
127
|
+
forNoKeyUpdate: { postgres: { forNoKeyUpdate: true } },
|
|
128
|
+
forShare: { sql: { forShare: true } },
|
|
129
|
+
forKeyShare: { postgres: { forKeyShare: true } }
|
|
130
|
+
};
|
|
131
|
+
/** The capability each locking option needs; the wait-policy keys equal the `LockWaitPolicy` values. */
|
|
132
|
+
const lockOptionCapabilities = {
|
|
133
|
+
of: { sql: { lockOf: true } },
|
|
134
|
+
nowait: { sql: { lockNowait: true } },
|
|
135
|
+
skipLocked: { sql: { lockSkipLocked: true } }
|
|
136
|
+
};
|
|
137
|
+
/** The first flag in `requirement` that `capabilities` does not report as `true`, as `group.flag`. */
|
|
138
|
+
function missingCapability(capabilities, requirement) {
|
|
139
|
+
for (const [group, flags] of Object.entries(requirement)) for (const flag of Object.keys(flags)) if (capabilities[group]?.[flag] !== true) return `${group}.${flag}`;
|
|
140
|
+
}
|
|
141
|
+
/** Turns `{ nowait, skipLocked }` into a wait policy, refusing both together with `ORM.ARGUMENT_INVALID`. */
|
|
142
|
+
function lockWaitPolicyOf(methodName, options) {
|
|
143
|
+
if (options?.nowait && options.skipLocked) throw structuredError("ORM.ARGUMENT_INVALID", `${methodName}() takes nowait or skipLocked, not both`, { meta: { method: methodName } });
|
|
144
|
+
if (options?.nowait) return "nowait";
|
|
145
|
+
if (options?.skipLocked) return "skipLocked";
|
|
146
|
+
}
|
|
120
147
|
/**
|
|
121
148
|
* Shared encode/decode/render constants and codec id literals for the five SQL base codecs (`sql/char@1`, `sql/varchar@1`, `sql/int@1`, `sql/float@1`, `sql/text@1`).
|
|
122
149
|
*
|
|
@@ -305,6 +332,6 @@ var SqlVarcharDescriptor = class extends CodecDescriptorTemplateImpl {
|
|
|
305
332
|
const sqlVarcharDescriptor = new SqlVarcharDescriptor();
|
|
306
333
|
const sqlVarcharColumn = (params = {}) => column(sqlVarcharDescriptor.factory(params), sqlVarcharDescriptor.codecId, params);
|
|
307
334
|
//#endregion
|
|
308
|
-
export {
|
|
335
|
+
export { sqlCharRenderOutputType as A, sqlTextDecode as B, lockStrengthCapabilities as C, sqlCharDecode as D, sqlCharColumn as E, sqlIntColumn as F, sqlVarcharDescriptor as G, sqlTextEncode as H, sqlIntDecode as I, sqlVarcharEncode as K, sqlIntDescriptor as L, sqlFloatDecode as M, sqlFloatDescriptor as N, sqlCharDescriptor as O, sqlFloatEncode as P, sqlIntEncode as R, lockOptionCapabilities as S, missingCapability as T, sqlVarcharColumn as U, sqlTextDescriptor as V, sqlVarcharDecode as W, SqlVarcharCodec as _, SQL_FLOAT_CODEC_ID as a, encodeLiteralDefault as b, SQL_VARCHAR_CODEC_ID as c, SqlFloatCodec as d, SqlFloatDescriptor as f, SqlTextDescriptor as g, SqlTextCodec as h, SQL_CHAR_CODEC_ID as i, sqlFloatColumn as j, sqlCharEncode as k, SqlCharCodec as l, SqlIntDescriptor as m, JsonDocumentProjection as n, SQL_INT_CODEC_ID as o, SqlIntCodec as p, sqlVarcharRenderOutputType as q, NativeJsonValueProjection as r, SQL_TEXT_CODEC_ID as s, CodecJsonValueProjection as t, SqlCharDescriptor as u, SqlVarcharDescriptor as v, lockWaitPolicyOf as w, lockIncompatible as x, encodeListLiteralDefault as y, sqlTextColumn as z };
|
|
309
336
|
|
|
310
|
-
//# sourceMappingURL=ast-
|
|
337
|
+
//# sourceMappingURL=ast-B_UPqRyb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-B_UPqRyb.mjs","names":[],"sources":["../../../../2-sql/4-lanes/relational-core/dist/exports/ast.mjs"],"sourcesContent":["import { A as ParamRef, B as aggregateFnNames, C as LiteralExpr, D as OperationExpr, E as NullCheckExpr, F as SelectAst, G as isQueryAst, H as isAggregateFn, I as SubqueryExpr, J as whereExprKinds, K as isWhereExpr, L as TableSource, M as ProjectionItem, N as RawExpr, O as OrExpr, P as RawQueryAst, R as UpdateAst, S as ListExpression, T as NotExpr, U as isOrderByDirection, V as checkLimitOffset, W as isOrderByNulls, Y as frozenCodecRef, _ as InsertAst, a as CastExpr, b as JsonArrayAggExpr, c as DeleteAst, d as DoUpdateSetConflictAction, f as EqColJoinOn, g as IdentifierRef, h as FunctionSource, i as CaseExpr, j as PreparedParamRef, k as OrderByItem, l as DerivedTableSource, m as FunctionCallExpr, n as AndExpr, o as ColumnRef, p as ExistsExpr, q as queryAstKinds, r as BinaryExpr, s as DefaultValueExpr, t as AggregateExpr, u as DoNothingConflictAction, v as InsertOnConflict, w as LockingClause, x as JsonObjectExpr, y as JoinAst, z as WindowFuncExpr } from \"../types-NTQsD2MS.mjs\";\nimport { a as DdlColumn, c as ForeignKeyConstraint, d as PrimaryKeyConstraint, f as UniqueConstraint, i as CheckExpressionConstraint, l as FunctionColumnDefault, n as opaqueSql, o as DdlColumnDefault, p as isDdlNode, r as renderOpaqueSql, s as DdlNode, t as OpaqueSql, u as LiteralColumnDefault } from \"../opaque-sql-BWxbqe5a.mjs\";\nimport { n as compact, r as isAggregateProjection, t as collectOrderedParamRefs } from \"../util-BBgcP3gI.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { CodecDescriptorTemplateImpl, CodecImpl, SAFE_INTEGER_RANGE, codecForRef, column, decodeJsonFloat, decodeJsonInteger, decodeJsonString, encodeJsonFloat } from \"@internal/framework-components/codec\";\nimport { isInternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { withoutTrailing } from \"@internal/utils/text\";\n//#region src/ast/ddl-default.ts\n/**\n* Reads a column's literal default with the column's codec, built with its type parameters, and encodes it for the DDL renderer to inline. `undefined` when no codec descriptor has the column's codec id, so the renderer inlines the value as written.\n*\n* A `Date` is the one authored value JSON has no notation for, so it is encoded as it is. A `null` the codec refuses is SQL NULL, because SQL NULL has no stored form of its own; a codec that reads `null` (a JSON codec) makes it the JSON value null. Any other value the codec refuses is a `CONTRACT.DEFAULT_INVALID` naming the column.\n*/\nasync function encodeLiteralDefault(codecLookup, codecRef, value, where) {\n\tconst codec = codecForRef(codecLookup, codecRef);\n\tif (codec === void 0) return void 0;\n\tif (value instanceof Date) return {\n\t\tkind: \"wire\",\n\t\twire: await codec.encode(value, {})\n\t};\n\treturn encodeWithCodec(codec, value, (cause) => refusedDefault(where, codecRef.codecId, value, void 0, cause));\n}\n/**\n* Reads and encodes each element of a list column's literal default with the column's codec, as {@link encodeLiteralDefault} does a single value, so a `null` element the codec refuses is SQL NULL. `undefined` when no codec descriptor has the column's codec id. An element the codec refuses is a `CONTRACT.DEFAULT_INVALID` naming the column and the element's 1-based position.\n*/\nasync function encodeListLiteralDefault(codecLookup, codecRef, elements, where) {\n\tconst codec = codecForRef(codecLookup, codecRef);\n\tif (codec === void 0) return void 0;\n\treturn Promise.all(elements.map((element, index) => encodeWithCodec(codec, element, (cause) => refusedDefault(where, codecRef.codecId, element, index + 1, cause))));\n}\nasync function encodeWithCodec(codec, value, refused) {\n\tlet decoded;\n\ttry {\n\t\tdecoded = codec.decodeJson(value);\n\t} catch (error) {\n\t\tif (isInternalError(error)) throw error;\n\t\tif (value === null) return { kind: \"sql-null\" };\n\t\tthrow refused(error);\n\t}\n\treturn {\n\t\tkind: \"wire\",\n\t\twire: await codec.encode(decoded, {})\n\t};\n}\nfunction refusedDefault(where, codecId, value, elementPosition, cause) {\n\tconst reason = cause instanceof Error ? cause.message : String(cause);\n\tconst subject = elementPosition === void 0 ? \"default\" : `default (element ${elementPosition})`;\n\treturn structuredError(\"CONTRACT.DEFAULT_INVALID\", `Column \"${where.table}\".\"${where.column}\" has a ${subject} its codec ${codecId} refuses: ${reason}`, {\n\t\twhy: \"A contract.json that an earlier version emitted, or a migration.ts it planned, can hold a default that this version's codec refuses, and so can either file after a hand edit.\",\n\t\tfix: \"If contract.json holds the default, emit the contract again with this version, and correct the default in the contract source if emit refuses it. If a migration.ts sets it, correct it in that file.\",\n\t\tcause,\n\t\tmeta: {\n\t\t\ttable: where.table,\n\t\t\tcolumn: where.column,\n\t\t\tcodecId,\n\t\t\tvalue,\n\t\t\t...ifDefined(\"elementPosition\", elementPosition),\n\t\t\treason: \"codec-refused-default\"\n\t\t}\n\t});\n}\n//#endregion\n//#region src/ast/json-value-projection.ts\nvar JsonValueProjection = class {\n\tvalue;\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n\tfold(folder) {\n\t\treturn this.value.fold(folder);\n\t}\n\tcollectColumnRefs() {\n\t\treturn this.value.collectColumnRefs();\n\t}\n\tcollectParamRefs() {\n\t\treturn this.value.collectParamRefs();\n\t}\n\tfreeze() {\n\t\tObject.freeze(this);\n\t}\n};\nvar CodecJsonValueProjection = class CodecJsonValueProjection extends JsonValueProjection {\n\tkind = \"codec\";\n\tcodec;\n\tconstructor(value, codec) {\n\t\tsuper(value);\n\t\tthis.codec = frozenCodecRef(codec);\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.codec(this);\n\t}\n\trewrite(rewriter) {\n\t\treturn new CodecJsonValueProjection(this.value.rewrite(rewriter), this.codec);\n\t}\n};\nvar NativeJsonValueProjection = class NativeJsonValueProjection extends JsonValueProjection {\n\tkind = \"native\";\n\tconstructor(value) {\n\t\tsuper(value);\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.native(this);\n\t}\n\trewrite(rewriter) {\n\t\treturn new NativeJsonValueProjection(this.value.rewrite(rewriter));\n\t}\n};\nvar JsonDocumentProjection = class JsonDocumentProjection extends JsonValueProjection {\n\tkind = \"document\";\n\tconstructor(value) {\n\t\tsuper(value);\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.document(this);\n\t}\n\trewrite(rewriter) {\n\t\treturn new JsonDocumentProjection(this.value.rewrite(rewriter));\n\t}\n};\n//#endregion\n//#region src/ast/locking.ts\n/** The `ORM.LOCK_INCOMPATIBLE` error for a lock refused because of `conflict`. */\nfunction lockIncompatible(conflict, message) {\n\treturn structuredError(\"ORM.LOCK_INCOMPATIBLE\", message, { meta: { conflict } });\n}\n/** The capability each lock strength needs. */\nconst lockStrengthCapabilities = {\n\tforUpdate: { sql: { forUpdate: true } },\n\tforNoKeyUpdate: { postgres: { forNoKeyUpdate: true } },\n\tforShare: { sql: { forShare: true } },\n\tforKeyShare: { postgres: { forKeyShare: true } }\n};\n/** The capability each locking option needs; the wait-policy keys equal the `LockWaitPolicy` values. */\nconst lockOptionCapabilities = {\n\tof: { sql: { lockOf: true } },\n\tnowait: { sql: { lockNowait: true } },\n\tskipLocked: { sql: { lockSkipLocked: true } }\n};\n/** The first flag in `requirement` that `capabilities` does not report as `true`, as `group.flag`. */\nfunction missingCapability(capabilities, requirement) {\n\tfor (const [group, flags] of Object.entries(requirement)) for (const flag of Object.keys(flags)) if (capabilities[group]?.[flag] !== true) return `${group}.${flag}`;\n}\n/** Turns `{ nowait, skipLocked }` into a wait policy, refusing both together with `ORM.ARGUMENT_INVALID`. */\nfunction lockWaitPolicyOf(methodName, options) {\n\tif (options?.nowait && options.skipLocked) throw structuredError(\"ORM.ARGUMENT_INVALID\", `${methodName}() takes nowait or skipLocked, not both`, { meta: { method: methodName } });\n\tif (options?.nowait) return \"nowait\";\n\tif (options?.skipLocked) return \"skipLocked\";\n}\n//#endregion\n//#region src/ast/sql-codec-helpers.ts\n/**\n* Shared encode/decode/render constants and codec id literals for the five SQL base codecs (`sql/char@1`, `sql/varchar@1`, `sql/int@1`, `sql/float@1`, `sql/text@1`).\n*\n* The codec implementations live in `sql-codecs.ts` (TML-2357). This module retains only the conversion helpers + emit-path renderers the codec methods compose with — keeping a single source of truth for non-trivial conversions while the codec methods provide the framework-required `Promise<…>` boundary.\n*/\nconst SQL_CHAR_CODEC_ID = \"sql/char@1\";\nconst SQL_VARCHAR_CODEC_ID = \"sql/varchar@1\";\nconst SQL_INT_CODEC_ID = \"sql/int@1\";\nconst SQL_FLOAT_CODEC_ID = \"sql/float@1\";\nconst SQL_TEXT_CODEC_ID = \"sql/text@1\";\nconst sqlCharEncode = (value) => value;\n/** A `character` value as the database returns it, without the spaces that pad it to its length. Only spaces pad it, so a trailing tab or newline is part of the value. */\nconst sqlCharDecode = (wire) => withoutTrailing(wire, \" \");\nconst sqlCharRenderOutputType = (typeParams) => {\n\tconst length = typeParams.length;\n\tif (length === void 0) return void 0;\n\tif (typeof length !== \"number\" || !Number.isFinite(length) || !Number.isInteger(length)) throw structuredError(\"RUNTIME.TYPE_PARAMS_INVALID\", `renderOutputType: expected integer \"length\" in typeParams for Char, got ${String(length)}`, { meta: {\n\t\tcodec: SQL_CHAR_CODEC_ID,\n\t\tparam: \"length\",\n\t\treceived: String(length)\n\t} });\n\treturn `Char<${length}>`;\n};\nconst sqlVarcharEncode = (value) => value;\nconst sqlVarcharDecode = (wire) => wire;\nconst sqlVarcharRenderOutputType = (typeParams) => {\n\tconst length = typeParams.length;\n\tif (length === void 0) return void 0;\n\tif (typeof length !== \"number\" || !Number.isFinite(length) || !Number.isInteger(length)) throw structuredError(\"RUNTIME.TYPE_PARAMS_INVALID\", `renderOutputType: expected integer \"length\" in typeParams for Varchar, got ${String(length)}`, { meta: {\n\t\tcodec: SQL_VARCHAR_CODEC_ID,\n\t\tparam: \"length\",\n\t\treceived: String(length)\n\t} });\n\treturn `Varchar<${length}>`;\n};\nconst sqlIntEncode = (value) => value;\nconst sqlIntDecode = (wire) => wire;\nconst sqlFloatEncode = (value) => value;\nconst sqlFloatDecode = (wire) => wire;\nconst sqlTextEncode = (value) => value;\nconst sqlTextDecode = (wire) => wire;\n//#endregion\n//#region src/ast/sql-codecs.ts\nvar SqlTextCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn sqlTextEncode(value);\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn sqlTextDecode(wire);\n\t}\n\tencodeJson(value) {\n\t\treturn value;\n\t}\n\tdecodeJson(json) {\n\t\treturn decodeJsonString(this.id, json);\n\t}\n};\nvar SqlTextDescriptor = class extends CodecDescriptorTemplateImpl {\n\tcodecId = SQL_TEXT_CODEC_ID;\n\ttraits = [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"textual\"\n\t];\n\tparamsSchema = void 0;\n\tfactory() {\n\t\treturn () => new SqlTextCodec(this);\n\t}\n};\nconst sqlTextDescriptor = new SqlTextDescriptor();\nconst sqlTextColumn = () => column(sqlTextDescriptor.factory(), sqlTextDescriptor.codecId, void 0);\nvar SqlIntCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn sqlIntEncode(value);\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn sqlIntDecode(wire);\n\t}\n\tencodeJson(value) {\n\t\treturn value;\n\t}\n\tdecodeJson(json) {\n\t\treturn decodeJsonInteger(this.id, json, SAFE_INTEGER_RANGE);\n\t}\n};\nvar SqlIntDescriptor = class extends CodecDescriptorTemplateImpl {\n\tcodecId = SQL_INT_CODEC_ID;\n\ttraits = [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"numeric\"\n\t];\n\tparamsSchema = void 0;\n\tfactory() {\n\t\treturn () => new SqlIntCodec(this);\n\t}\n};\nconst sqlIntDescriptor = new SqlIntDescriptor();\nconst sqlIntColumn = () => column(sqlIntDescriptor.factory(), sqlIntDescriptor.codecId, void 0);\nvar SqlFloatCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn sqlFloatEncode(value);\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn sqlFloatDecode(wire);\n\t}\n\tencodeJson(value) {\n\t\treturn encodeJsonFloat(value);\n\t}\n\tdecodeJson(json) {\n\t\treturn decodeJsonFloat(this.id, json);\n\t}\n};\nvar SqlFloatDescriptor = class extends CodecDescriptorTemplateImpl {\n\tcodecId = SQL_FLOAT_CODEC_ID;\n\ttraits = [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"numeric\"\n\t];\n\tparamsSchema = void 0;\n\tfactory() {\n\t\treturn () => new SqlFloatCodec(this);\n\t}\n};\nconst sqlFloatDescriptor = new SqlFloatDescriptor();\nconst sqlFloatColumn = () => column(sqlFloatDescriptor.factory(), sqlFloatDescriptor.codecId, void 0);\nvar SqlCharCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn sqlCharEncode(value);\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn sqlCharDecode(wire);\n\t}\n\tencodeJson(value) {\n\t\treturn value;\n\t}\n\tdecodeJson(json) {\n\t\treturn decodeJsonString(this.id, json);\n\t}\n};\nvar SqlCharDescriptor = class extends CodecDescriptorTemplateImpl {\n\tcodecId = SQL_CHAR_CODEC_ID;\n\ttraits = [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"textual\"\n\t];\n\tparamsSchema = void 0;\n\trenderOutputType(params) {\n\t\treturn sqlCharRenderOutputType(params);\n\t}\n\tfactory(_params) {\n\t\treturn () => new SqlCharCodec(this);\n\t}\n};\nconst sqlCharDescriptor = new SqlCharDescriptor();\nconst sqlCharColumn = (params = {}) => column(sqlCharDescriptor.factory(params), sqlCharDescriptor.codecId, params);\nvar SqlVarcharCodec = class extends CodecImpl {\n\tasync encode(value, _ctx) {\n\t\treturn sqlVarcharEncode(value);\n\t}\n\tasync decode(wire, _ctx) {\n\t\treturn sqlVarcharDecode(wire);\n\t}\n\tencodeJson(value) {\n\t\treturn value;\n\t}\n\tdecodeJson(json) {\n\t\treturn decodeJsonString(this.id, json);\n\t}\n};\nvar SqlVarcharDescriptor = class extends CodecDescriptorTemplateImpl {\n\tcodecId = SQL_VARCHAR_CODEC_ID;\n\ttraits = [\n\t\t\"equality\",\n\t\t\"order\",\n\t\t\"textual\"\n\t];\n\tparamsSchema = void 0;\n\trenderOutputType(params) {\n\t\treturn sqlVarcharRenderOutputType(params);\n\t}\n\tfactory(_params) {\n\t\treturn () => new SqlVarcharCodec(this);\n\t}\n};\nconst sqlVarcharDescriptor = new SqlVarcharDescriptor();\nconst sqlVarcharColumn = (params = {}) => column(sqlVarcharDescriptor.factory(params), sqlVarcharDescriptor.codecId, params);\n//#endregion\nexport { AggregateExpr, AndExpr, BinaryExpr, CaseExpr, CastExpr, CheckExpressionConstraint, CodecJsonValueProjection, ColumnRef, DdlColumn, DdlColumnDefault, DdlNode, DefaultValueExpr, DeleteAst, DerivedTableSource, DoNothingConflictAction, DoUpdateSetConflictAction, EqColJoinOn, ExistsExpr, ForeignKeyConstraint, FunctionCallExpr, FunctionColumnDefault, FunctionSource, IdentifierRef, InsertAst, InsertOnConflict, JoinAst, JsonArrayAggExpr, JsonDocumentProjection, JsonObjectExpr, ListExpression, LiteralColumnDefault, LiteralExpr, LockingClause, NativeJsonValueProjection, NotExpr, NullCheckExpr, OpaqueSql, OperationExpr, OrExpr, OrderByItem, ParamRef, PreparedParamRef, PrimaryKeyConstraint, ProjectionItem, RawExpr, RawQueryAst, SQL_CHAR_CODEC_ID, SQL_FLOAT_CODEC_ID, SQL_INT_CODEC_ID, SQL_TEXT_CODEC_ID, SQL_VARCHAR_CODEC_ID, SelectAst, SqlCharCodec, SqlCharDescriptor, SqlFloatCodec, SqlFloatDescriptor, SqlIntCodec, SqlIntDescriptor, SqlTextCodec, SqlTextDescriptor, SqlVarcharCodec, SqlVarcharDescriptor, SubqueryExpr, TableSource, UniqueConstraint, UpdateAst, WindowFuncExpr, aggregateFnNames, checkLimitOffset, collectOrderedParamRefs, compact, encodeListLiteralDefault, encodeLiteralDefault, frozenCodecRef, isAggregateFn, isAggregateProjection, isDdlNode, isOrderByDirection, isOrderByNulls, isQueryAst, isWhereExpr, lockIncompatible, lockOptionCapabilities, lockStrengthCapabilities, lockWaitPolicyOf, missingCapability, opaqueSql, queryAstKinds, renderOpaqueSql, sqlCharColumn, sqlCharDecode, sqlCharDescriptor, sqlCharEncode, sqlCharRenderOutputType, sqlFloatColumn, sqlFloatDecode, sqlFloatDescriptor, sqlFloatEncode, sqlIntColumn, sqlIntDecode, sqlIntDescriptor, sqlIntEncode, sqlTextColumn, sqlTextDecode, sqlTextDescriptor, sqlTextEncode, sqlVarcharColumn, s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LoweredStatement, m as AnyParamRef } from "./types-Sh5HuaZE-C8I29pGQ.mjs";
|
|
1
|
+
import { E as CodecRef$1, Et as ProjectionItem, dt as LockWaitPolicy, h as AnyQueryAst, ht as LoweredStatement, m as AnyParamRef } from "./types-Sh5HuaZE-C8I29pGQ.mjs";
|
|
2
2
|
import { c as SqlQueryable } from "./driver-types-DRsYeq3j-X_D6hNMZ.mjs";
|
|
3
3
|
import "./ddl-types-DtKZjNtN-6TxFf4bH.mjs";
|
|
4
|
+
import { StructuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
4
5
|
import { CodecCallContext, CodecDescriptorTemplateImpl, CodecImpl, CodecInstanceContext, CodecLookupWithDescriptors } from "@prisma/orm-framework/components/codec";
|
|
5
6
|
import { ColumnDefaultLiteralInputValue, ContractMarkerRecord, JsonValue } from "@prisma/orm-framework/contract/types";
|
|
6
7
|
//#region ../../../2-sql/4-lanes/relational-core/dist/exports/ast.d.mts
|
|
@@ -66,6 +67,85 @@ declare function encodeLiteralDefault(codecLookup: Pick<CodecLookupWithDescripto
|
|
|
66
67
|
*/
|
|
67
68
|
declare function encodeListLiteralDefault(codecLookup: Pick<CodecLookupWithDescriptors, 'descriptorFor'>, codecRef: CodecRef$1, elements: readonly JsonValue[], where: LiteralDefaultColumn): Promise<readonly EncodedLiteralDefault[] | undefined>;
|
|
68
69
|
//#endregion
|
|
70
|
+
//#region src/ast/locking.d.ts
|
|
71
|
+
/** What a row lock was combined with when it was refused, as `meta.conflict` of `ORM.LOCK_INCOMPATIBLE`. */
|
|
72
|
+
type LockConflict = 'distinct' | 'distinctOn' | 'groupBy' | 'having' | 'aggregate' | 'subquery' | 'include' | 'includeRefinement' | 'mutation';
|
|
73
|
+
/** The `ORM.LOCK_INCOMPATIBLE` error for a lock refused because of `conflict`. */
|
|
74
|
+
declare function lockIncompatible(conflict: LockConflict, message: string): StructuredError;
|
|
75
|
+
/** A capability requirement: each group's flags that must be reported as `true`. */
|
|
76
|
+
type CapabilityRequirement = {
|
|
77
|
+
readonly [group: string]: {
|
|
78
|
+
readonly [flag: string]: true;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
/** The capability each lock strength needs. */
|
|
82
|
+
declare const lockStrengthCapabilities: {
|
|
83
|
+
readonly forUpdate: {
|
|
84
|
+
readonly sql: {
|
|
85
|
+
readonly forUpdate: true;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
readonly forNoKeyUpdate: {
|
|
89
|
+
readonly postgres: {
|
|
90
|
+
readonly forNoKeyUpdate: true;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
readonly forShare: {
|
|
94
|
+
readonly sql: {
|
|
95
|
+
readonly forShare: true;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
readonly forKeyShare: {
|
|
99
|
+
readonly postgres: {
|
|
100
|
+
readonly forKeyShare: true;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
/** The capability each locking option needs; the wait-policy keys equal the `LockWaitPolicy` values. */
|
|
105
|
+
declare const lockOptionCapabilities: {
|
|
106
|
+
readonly of: {
|
|
107
|
+
readonly sql: {
|
|
108
|
+
readonly lockOf: true;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
readonly nowait: {
|
|
112
|
+
readonly sql: {
|
|
113
|
+
readonly lockNowait: true;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
readonly skipLocked: {
|
|
117
|
+
readonly sql: {
|
|
118
|
+
readonly lockSkipLocked: true;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
type LockStrengthCapabilities = typeof lockStrengthCapabilities;
|
|
123
|
+
type LockOptionCapabilities = typeof lockOptionCapabilities;
|
|
124
|
+
/** The first flag in `requirement` that `capabilities` does not report as `true`, as `group.flag`. */
|
|
125
|
+
declare function missingCapability(capabilities: {
|
|
126
|
+
readonly [group: string]: {
|
|
127
|
+
readonly [flag: string]: unknown;
|
|
128
|
+
} | undefined;
|
|
129
|
+
}, requirement: CapabilityRequirement): string | undefined;
|
|
130
|
+
/** The wait-policy options of a locking method; each key exists only when its capability is reported. */
|
|
131
|
+
type LockWaitOptions<Capabilities> = (Capabilities extends LockOptionCapabilities['nowait'] ? {
|
|
132
|
+
readonly nowait?: true;
|
|
133
|
+
readonly skipLocked?: never;
|
|
134
|
+
} : never) | (Capabilities extends LockOptionCapabilities['skipLocked'] ? {
|
|
135
|
+
readonly skipLocked?: true;
|
|
136
|
+
readonly nowait?: never;
|
|
137
|
+
} : never) | {
|
|
138
|
+
readonly nowait?: never;
|
|
139
|
+
readonly skipLocked?: never;
|
|
140
|
+
};
|
|
141
|
+
/** The wait-policy options as a locking method receives them at run time. */
|
|
142
|
+
interface LockWaitRequest {
|
|
143
|
+
readonly nowait?: true;
|
|
144
|
+
readonly skipLocked?: true;
|
|
145
|
+
}
|
|
146
|
+
/** Turns `{ nowait, skipLocked }` into a wait policy, refusing both together with `ORM.ARGUMENT_INVALID`. */
|
|
147
|
+
declare function lockWaitPolicyOf(methodName: string, options: LockWaitRequest | undefined): LockWaitPolicy | undefined;
|
|
148
|
+
//#endregion
|
|
69
149
|
//#region src/ast/sql-codec-helpers.d.ts
|
|
70
150
|
/**
|
|
71
151
|
* Shared encode/decode/render constants and codec id literals for the five SQL base codecs (`sql/char@1`, `sql/varchar@1`, `sql/int@1`, `sql/float@1`, `sql/text@1`).
|
|
@@ -188,5 +268,5 @@ declare function collectOrderedParamRefs(ast: AnyQueryAst): ReadonlyArray<AnyPar
|
|
|
188
268
|
/** Whether a projection item's top-level expression is an aggregate, `json_agg` or window function. Nested expressions are not inspected. */
|
|
189
269
|
declare function isAggregateProjection(item: ProjectionItem): boolean;
|
|
190
270
|
//#endregion
|
|
191
|
-
export {
|
|
192
|
-
//# sourceMappingURL=ast-
|
|
271
|
+
export { sqlTextColumn as $, collectOrderedParamRefs as A, sqlCharColumn as B, SqlFloatDescriptor as C, SqlTextDescriptor as D, SqlTextCodec as E, lockIncompatible as F, sqlFloatColumn as G, sqlCharDescriptor as H, lockOptionCapabilities as I, sqlFloatEncode as J, sqlFloatDecode as K, lockStrengthCapabilities as L, encodeListLiteralDefault as M, encodeLiteralDefault as N, SqlVarcharCodec as O, isAggregateProjection as P, sqlIntEncode as Q, lockWaitPolicyOf as R, SqlFloatCodec as S, SqlIntDescriptor as T, sqlCharEncode as U, sqlCharDecode as V, sqlCharRenderOutputType as W, sqlIntDecode as X, sqlIntColumn as Y, sqlIntDescriptor as Z, SQL_INT_CODEC_ID as _, EncodedLiteralDefault as a, sqlVarcharDescriptor as at, SqlCharCodec as b, LockOptionCapabilities as c, LockWaitRequest as d, sqlTextDecode as et, Lowerer as f, SQL_FLOAT_CODEC_ID as g, SQL_CHAR_CODEC_ID as h, CapabilityRequirement as i, sqlVarcharDecode as it, compact as j, SqlVarcharDescriptor as k, LockStrengthCapabilities as l, MarkerReadResult as m, AdapterProfile as n, sqlTextEncode as nt, LiteralDefaultColumn as o, sqlVarcharEncode as ot, LowererContext as p, sqlFloatDescriptor as q, AdapterTarget as r, sqlVarcharColumn as rt, LockConflict as s, sqlVarcharRenderOutputType as st, Adapter as t, sqlTextDescriptor as tt, LockWaitOptions as u, SQL_TEXT_CODEC_ID as v, SqlIntCodec as w, SqlCharDescriptor as x, SQL_VARCHAR_CODEC_ID as y, missingCapability as z };
|
|
272
|
+
//# sourceMappingURL=ast-Bf6J9_ra.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-Bf6J9_ra.d.mts","names":[],"sources":["../../../../2-sql/4-lanes/relational-core/dist/exports/ast.d.mts"],"mappings":";;;;;;;;KAOK;;;;;;;KAOA;WACM;WACA,QAAQ;;WAER;;WAEA;;UAED,eAAe,gBAAgB,gBAAgB;WAC9C;WACA,QAAQ;WACR,cAAc;;;;EAIvB,WAAW,WAAW,eAAe,QAAQ;;UAErC,eAAe;WACd,UAAU;WACV;;KAEN,QAAQ,eAAe,qBAAqB,QAA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ScopeField } from "./expression-B-QXMOmY.mjs";
|
|
2
|
-
import { T as WhereFilter, _ as SelectQuery, a as DeleteQuery, c as GatedMethod, f as QueryContext, g as Scope, h as ResolveRow, i as Db, l as GroupedQuery, s as Functions, t as AggregateFunctions, u as InsertQuery, v as Subquery, w as UpdateQuery, x as TableProxy } from "./db-
|
|
2
|
+
import { T as WhereFilter, _ as SelectQuery, a as DeleteQuery, c as GatedMethod, f as QueryContext, g as Scope, h as ResolveRow, i as Db, l as GroupedQuery, s as Functions, t as AggregateFunctions, u as InsertQuery, v as Subquery, w as UpdateQuery, x as TableProxy } from "./db-D7R5zKiH-SEM04lcK.mjs";
|
|
3
3
|
export type { AggregateFunctions, Db, DeleteQuery, Expression, Functions, GatedMethod, GroupedQuery, InsertQuery, QueryContext, ResolveRow, Scope, ScopeField, SelectQuery, Subquery, TableProxy, UpdateQuery, WhereFilter };
|
|
@@ -2,9 +2,9 @@ import { l as SqlStorage } from "./sql-storage-DSnnRQAf-DaHPnley.mjs";
|
|
|
2
2
|
import "./types-DkOYK86-.mjs";
|
|
3
3
|
import { i as SqlOperationEntry } from "./index-qOLTnfYz.mjs";
|
|
4
4
|
import { c as AnyExpression } from "./types-Sh5HuaZE-C8I29pGQ.mjs";
|
|
5
|
-
import "./ast-
|
|
5
|
+
import "./ast-Bf6J9_ra.mjs";
|
|
6
6
|
import { l as RawCodecInferer, o as Expression, x as ScopeField } from "./expression-B-QXMOmY.mjs";
|
|
7
|
-
import { S as TableProxyContract, f as QueryContext, g as Scope, i as Db, o as FieldProxy, p as RawLane, s as Functions, t as AggregateFunctions } from "./db-
|
|
7
|
+
import { S as TableProxyContract, f as QueryContext, g as Scope, i as Db, o as FieldProxy, p as RawLane, s as Functions, t as AggregateFunctions } from "./db-D7R5zKiH-SEM04lcK.mjs";
|
|
8
8
|
import { a as SqlAggregateDescriptorRegistry, n as ExecutionContext } from "./query-lane-context-CJoNBspB-Ylhia3fC.mjs";
|
|
9
9
|
import "./query-lane-context-qK5s2okl.mjs";
|
|
10
10
|
import { Contract } from "@prisma/orm-framework/contract/types";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { A as ParamRef, C as LiteralExpr, E as NullCheckExpr, F as SelectAst, G as isOrderByNulls, I as SubqueryExpr, L as TableSource, M as ProjectionItem, O as OrExpr, R as UpdateAst, S as ListExpression, U as isAggregateFn, W as isOrderByDirection, _ as InsertAst, c as DeleteAst, g as IdentifierRef, k as OrderByItem, l as DerivedTableSource, n as AndExpr, o as ColumnRef, p as ExistsExpr, r as BinaryExpr, t as AggregateExpr, w as LockingClause, y as JoinAst } from "./types-NTQsD2MS-DAP2yVDn.mjs";
|
|
2
2
|
import { r as isAggregateProjection, t as collectOrderedParamRefs } from "./util-BBgcP3gI-XJBkxo1K.mjs";
|
|
3
|
+
import { C as lockStrengthCapabilities, S as lockOptionCapabilities, w as lockWaitPolicyOf, x as lockIncompatible } from "./ast-B_UPqRyb.mjs";
|
|
3
4
|
import { i as isExpression, n as codecOf, o as toExpr, r as createRawSql } from "./expression-JOe6lo4g.mjs";
|
|
4
5
|
import { n as codecRefForStorageColumn } from "./codec-descriptor-registry-DoGFktu5.mjs";
|
|
5
6
|
import { assertAnnotationsApplicable } from "@prisma/orm-framework/components/runtime";
|
|
@@ -413,6 +414,12 @@ function combineWhereExprs(exprs) {
|
|
|
413
414
|
if (exprs.length === 1) return exprs[0];
|
|
414
415
|
return AndExpr.of(exprs);
|
|
415
416
|
}
|
|
417
|
+
const lockConflictKinds = [
|
|
418
|
+
"distinct",
|
|
419
|
+
"distinctOn",
|
|
420
|
+
"groupBy",
|
|
421
|
+
"having"
|
|
422
|
+
];
|
|
416
423
|
function lockConflictOf(state) {
|
|
417
424
|
const conflicts = {
|
|
418
425
|
distinct: state.distinct !== void 0,
|
|
@@ -420,17 +427,17 @@ function lockConflictOf(state) {
|
|
|
420
427
|
groupBy: state.groupBy.length > 0,
|
|
421
428
|
having: state.having !== void 0
|
|
422
429
|
};
|
|
423
|
-
return
|
|
430
|
+
return lockConflictKinds.find((conflict) => conflicts[conflict]);
|
|
424
431
|
}
|
|
425
432
|
function assertLockable(state) {
|
|
426
433
|
if (state.locking === void 0) return;
|
|
427
434
|
const conflict = lockConflictOf(state);
|
|
428
|
-
if (conflict !== void 0) throw
|
|
435
|
+
if (conflict !== void 0) throw lockIncompatible(conflict, `A locking clause cannot be combined with ${conflict}`);
|
|
429
436
|
const item = state.projections.find(isAggregateProjection);
|
|
430
|
-
if (item !== void 0) throw
|
|
437
|
+
if (item !== void 0) throw lockIncompatible("aggregate", `A locking clause cannot be combined with an aggregate or window function in the projection (column "${item.alias}")`);
|
|
431
438
|
}
|
|
432
439
|
function assertNotLocked(state) {
|
|
433
|
-
if (state.locking !== void 0) throw
|
|
440
|
+
if (state.locking !== void 0) throw lockIncompatible("subquery", "A locked select cannot be used as a subquery");
|
|
434
441
|
}
|
|
435
442
|
function buildSelectAst(state) {
|
|
436
443
|
assertLockable(state);
|
|
@@ -722,16 +729,15 @@ var SelectQueryImpl = class SelectQueryImpl extends QueryBase {
|
|
|
722
729
|
const item = resolveOrderBy(arg, options, this.state.scope, this.state.rowFields, this.ctx, false);
|
|
723
730
|
return this.clone(cloneState(this.state, { orderBy: [...this.state.orderBy, item] }));
|
|
724
731
|
}
|
|
725
|
-
forUpdate = this._gate(
|
|
726
|
-
forNoKeyUpdate = this._gate(
|
|
727
|
-
forShare = this._gate(
|
|
728
|
-
forKeyShare = this._gate(
|
|
732
|
+
forUpdate = this._gate(lockStrengthCapabilities.forUpdate, "forUpdate", (options) => this.lock("forUpdate", options));
|
|
733
|
+
forNoKeyUpdate = this._gate(lockStrengthCapabilities.forNoKeyUpdate, "forNoKeyUpdate", (options) => this.lock("forNoKeyUpdate", options));
|
|
734
|
+
forShare = this._gate(lockStrengthCapabilities.forShare, "forShare", (options) => this.lock("forShare", options));
|
|
735
|
+
forKeyShare = this._gate(lockStrengthCapabilities.forKeyShare, "forKeyShare", (options) => this.lock("forKeyShare", options));
|
|
729
736
|
lock(strength, options) {
|
|
730
737
|
const of = options?.of !== void 0 && options.of.length > 0 ? options.of : void 0;
|
|
731
|
-
if (of !== void 0) assertCapability(this.ctx,
|
|
738
|
+
if (of !== void 0) assertCapability(this.ctx, lockOptionCapabilities.of, strength);
|
|
732
739
|
const waitPolicy = lockWaitPolicyOf(strength, options);
|
|
733
|
-
if (waitPolicy
|
|
734
|
-
if (waitPolicy === "skipLocked") assertCapability(this.ctx, { sql: { lockSkipLocked: true } }, strength);
|
|
740
|
+
if (waitPolicy !== void 0) assertCapability(this.ctx, lockOptionCapabilities[waitPolicy], strength);
|
|
735
741
|
const clause = LockingClause.of(strength, {
|
|
736
742
|
...ifDefined("of", of),
|
|
737
743
|
...ifDefined("waitPolicy", waitPolicy)
|
|
@@ -739,11 +745,6 @@ var SelectQueryImpl = class SelectQueryImpl extends QueryBase {
|
|
|
739
745
|
return this.clone(cloneState(this.state, { locking: [...this.state.locking ?? [], clause] }));
|
|
740
746
|
}
|
|
741
747
|
};
|
|
742
|
-
function lockWaitPolicyOf(methodName, options) {
|
|
743
|
-
if (options?.nowait && options.skipLocked) throw structuredError("ORM.ARGUMENT_INVALID", `${methodName}() takes nowait or skipLocked, not both`, { meta: { method: methodName } });
|
|
744
|
-
if (options?.nowait) return "nowait";
|
|
745
|
-
if (options?.skipLocked) return "skipLocked";
|
|
746
|
-
}
|
|
747
748
|
var GroupedQueryImpl = class GroupedQueryImpl extends QueryBase {
|
|
748
749
|
clone(state) {
|
|
749
750
|
return new GroupedQueryImpl(state, this.ctx);
|