@prisma/orm-mysql 8.0.0-rc.23-dev.3 → 8.0.0-rc.23-dev.4
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/config.d.mts +2 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +2 -1
- package/dist/config.mjs.map +1 -1
- package/dist/{mysql-static-Cfh99GsI-eGQZPCm5.mjs → mysql-static-CNpyA32F-0x5ux1nm.mjs} +3 -3
- package/dist/{mysql-static-Cfh99GsI-eGQZPCm5.mjs.map → mysql-static-CNpyA32F-0x5ux1nm.mjs.map} +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/runtime.mjs.map +1 -1
- package/dist/static.mjs +1 -1
- package/package.json +8 -8
- package/skills/prisma-8/SKILL.md +1 -1
- package/skills/prisma-8/references/contract.md +2 -2
package/dist/config.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PrismaNextConfig } from "@prisma/orm-framework/config/config-types";
|
|
1
|
+
import { FormatterConfig, PrismaNextConfig } from "@prisma/orm-framework/config/config-types";
|
|
2
2
|
import { ControlExtensionDescriptor } from "@prisma/orm-framework/components/control";
|
|
3
3
|
//#region ../../../3-targets/mysql/9-facade/dist/config.d.mts
|
|
4
4
|
//#region src/config/define-config.d.ts
|
|
@@ -12,6 +12,7 @@ interface MysqlConfigOptions {
|
|
|
12
12
|
readonly migrations?: {
|
|
13
13
|
readonly dir?: string;
|
|
14
14
|
};
|
|
15
|
+
readonly formatter?: FormatterConfig;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* The `prisma.config.ts` of a MySQL project. A `.prisma` contract types an `enum` block of text members as a native MySQL enum, and one of integer members as `int`.
|
package/dist/config.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../../../../3-targets/mysql/9-facade/dist/config.d.mts"],"mappings":";;;;UAGU;WACC;WACA;WACA;aACE;;WAEF,sBAAsB;WACtB;aACE
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../../../3-targets/mysql/9-facade/dist/config.d.mts"],"mappings":";;;;UAGU;WACC;WACA;WACA;aACE;;WAEF,sBAAsB;WACtB;aACE;;WAEF,YAAY;;;;;iBAKN,aAAa,SAAS,qBAAqB"}
|
package/dist/config.mjs
CHANGED
|
@@ -33,7 +33,8 @@ function defineConfig(options) {
|
|
|
33
33
|
extensions: options.extensions ?? [],
|
|
34
34
|
contract,
|
|
35
35
|
...ifDefined("db", options.db),
|
|
36
|
-
...ifDefined("migrations", options.migrations)
|
|
36
|
+
...ifDefined("migrations", options.migrations),
|
|
37
|
+
...ifDefined("formatter", options.formatter)
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
//#endregion
|
package/dist/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../../../../3-targets/mysql/9-facade/dist/config.mjs"],"sourcesContent":["import mysqlAdapter from \"@internal/adapter-mysql/control\";\nimport { defaultContractOutputPath, defineConfig as defineConfig$1 } from \"@internal/config/config-types\";\nimport mysqlDriver from \"@internal/driver-mysql/control\";\nimport sql from \"@internal/family-sql/control\";\nimport { prismaContract } from \"@internal/sql-contract-psl/provider\";\nimport { typescriptContractFromPath } from \"@internal/sql-contract-ts/config-types\";\nimport { MYSQL_ENUM_CODEC_ID, MYSQL_INT_CODEC_ID } from \"@internal/target-mysql/codec-ids\";\nimport mysql from \"@internal/target-mysql/control\";\nimport mysqlPackRef from \"@internal/target-mysql/pack\";\nimport { mysqlCreateNamespace } from \"@internal/target-mysql/types\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { extname, join } from \"pathe\";\n//#region src/config/define-config.ts\n/**\n* The `prisma.config.ts` of a MySQL project. A `.prisma` contract types an `enum` block of text members as a native MySQL enum, and one of integer members as `int`.\n*/\nfunction defineConfig(options) {\n\tconst output = options.output !== void 0 ? join(options.output, \"contract.json\") : defaultContractOutputPath(options.contract);\n\tconst contract = extname(options.contract) === \".ts\" ? typescriptContractFromPath(options.contract, output) : prismaContract(options.contract, {\n\t\toutput,\n\t\ttarget: mysqlPackRef,\n\t\tcreateNamespace: mysqlCreateNamespace,\n\t\tenumInferenceCodecs: {\n\t\t\ttext: MYSQL_ENUM_CODEC_ID,\n\t\t\tint: MYSQL_INT_CODEC_ID\n\t\t}\n\t});\n\treturn defineConfig$1({\n\t\tfamily: sql,\n\t\ttarget: mysql,\n\t\tadapter: mysqlAdapter,\n\t\tdriver: mysqlDriver,\n\t\textensions: options.extensions ?? [],\n\t\tcontract,\n\t\t...ifDefined(\"db\", options.db),\n\t\t...ifDefined(\"migrations\", options.migrations)\n\t});\n}\n//#endregion\nexport { defineConfig };\n\n//# sourceMappingURL=config.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAS,aAAa,SAAS;CAC9B,MAAM,SAAS,QAAQ,WAAW,KAAK,IAAI,KAAK,QAAQ,QAAQ,eAAe,IAAI,0BAA0B,QAAQ,QAAQ;CAC7H,MAAM,WAAW,QAAQ,QAAQ,QAAQ,MAAM,QAAQ,2BAA2B,QAAQ,UAAU,MAAM,IAAI,eAAe,QAAQ,UAAU;EAC9I;EACA,QAAQ;EACR,iBAAiB;EACjB,qBAAqB;GACpB,MAAM;GACN,KAAK;EACN;CACD,CAAC;CACD,OAAO,eAAe;EACrB,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,YAAY,QAAQ,cAAc,CAAC;EACnC;EACA,GAAG,UAAU,MAAM,QAAQ,EAAE;EAC7B,GAAG,UAAU,cAAc,QAAQ,UAAU;
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../../../3-targets/mysql/9-facade/dist/config.mjs"],"sourcesContent":["import mysqlAdapter from \"@internal/adapter-mysql/control\";\nimport { defaultContractOutputPath, defineConfig as defineConfig$1 } from \"@internal/config/config-types\";\nimport mysqlDriver from \"@internal/driver-mysql/control\";\nimport sql from \"@internal/family-sql/control\";\nimport { prismaContract } from \"@internal/sql-contract-psl/provider\";\nimport { typescriptContractFromPath } from \"@internal/sql-contract-ts/config-types\";\nimport { MYSQL_ENUM_CODEC_ID, MYSQL_INT_CODEC_ID } from \"@internal/target-mysql/codec-ids\";\nimport mysql from \"@internal/target-mysql/control\";\nimport mysqlPackRef from \"@internal/target-mysql/pack\";\nimport { mysqlCreateNamespace } from \"@internal/target-mysql/types\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { extname, join } from \"pathe\";\n//#region src/config/define-config.ts\n/**\n* The `prisma.config.ts` of a MySQL project. A `.prisma` contract types an `enum` block of text members as a native MySQL enum, and one of integer members as `int`.\n*/\nfunction defineConfig(options) {\n\tconst output = options.output !== void 0 ? join(options.output, \"contract.json\") : defaultContractOutputPath(options.contract);\n\tconst contract = extname(options.contract) === \".ts\" ? typescriptContractFromPath(options.contract, output) : prismaContract(options.contract, {\n\t\toutput,\n\t\ttarget: mysqlPackRef,\n\t\tcreateNamespace: mysqlCreateNamespace,\n\t\tenumInferenceCodecs: {\n\t\t\ttext: MYSQL_ENUM_CODEC_ID,\n\t\t\tint: MYSQL_INT_CODEC_ID\n\t\t}\n\t});\n\treturn defineConfig$1({\n\t\tfamily: sql,\n\t\ttarget: mysql,\n\t\tadapter: mysqlAdapter,\n\t\tdriver: mysqlDriver,\n\t\textensions: options.extensions ?? [],\n\t\tcontract,\n\t\t...ifDefined(\"db\", options.db),\n\t\t...ifDefined(\"migrations\", options.migrations),\n\t\t...ifDefined(\"formatter\", options.formatter)\n\t});\n}\n//#endregion\nexport { defineConfig };\n\n//# sourceMappingURL=config.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,SAAS,aAAa,SAAS;CAC9B,MAAM,SAAS,QAAQ,WAAW,KAAK,IAAI,KAAK,QAAQ,QAAQ,eAAe,IAAI,0BAA0B,QAAQ,QAAQ;CAC7H,MAAM,WAAW,QAAQ,QAAQ,QAAQ,MAAM,QAAQ,2BAA2B,QAAQ,UAAU,MAAM,IAAI,eAAe,QAAQ,UAAU;EAC9I;EACA,QAAQ;EACR,iBAAiB;EACjB,qBAAqB;GACpB,MAAM;GACN,KAAK;EACN;CACD,CAAC;CACD,OAAO,eAAe;EACrB,QAAQ;EACR,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,YAAY,QAAQ,cAAc,CAAC;EACnC;EACA,GAAG,UAAU,MAAM,QAAQ,EAAE;EAC7B,GAAG,UAAU,cAAc,QAAQ,UAAU;EAC7C,GAAG,UAAU,aAAa,QAAQ,SAAS;CAC5C,CAAC;AACF"}
|
|
@@ -7,8 +7,8 @@ import { assertDefined } from "@prisma/orm-framework/utils/assertions";
|
|
|
7
7
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
8
8
|
import { validateContractOnce } from "@prisma/orm-framework/contract/validate-once";
|
|
9
9
|
import { buildNamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
|
|
10
|
-
//#region ../../../3-targets/mysql/9-facade/dist/mysql-static-
|
|
11
|
-
var version = "8.0.0-rc.23-dev.
|
|
10
|
+
//#region ../../../3-targets/mysql/9-facade/dist/mysql-static-CNpyA32F.mjs
|
|
11
|
+
var version = "8.0.0-rc.23-dev.4";
|
|
12
12
|
const serializer = new MysqlContractSerializer();
|
|
13
13
|
const validator = `${mysqlTarget.targetId}@${version}`;
|
|
14
14
|
/**
|
|
@@ -80,4 +80,4 @@ function mysqlStatic(options) {
|
|
|
80
80
|
//#endregion
|
|
81
81
|
export { validateMysqlContract as i, contractFromJson as n, mysqlStatic as r, buildMysqlStaticContext as t };
|
|
82
82
|
|
|
83
|
-
//# sourceMappingURL=mysql-static-
|
|
83
|
+
//# sourceMappingURL=mysql-static-CNpyA32F-0x5ux1nm.mjs.map
|
package/dist/{mysql-static-Cfh99GsI-eGQZPCm5.mjs.map → mysql-static-CNpyA32F-0x5ux1nm.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mysql-static-
|
|
1
|
+
{"version":3,"file":"mysql-static-CNpyA32F-0x5ux1nm.mjs","names":[],"sources":["../../../../3-targets/mysql/9-facade/dist/mysql-static-CNpyA32F.mjs"],"sourcesContent":["import mysqlAdapter from \"@internal/adapter-mysql/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, createToSql } from \"@internal/sql-runtime\";\nimport mysqlTarget, { MysqlContractSerializer } from \"@internal/target-mysql/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\n//#region package.json\nvar version = \"8.0.0-rc.23-dev.4\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new MysqlContractSerializer();\nconst validator = `${mysqlTarget.targetId}@${version}`;\n/**\n* Validates an emitted MySQL `contract.json` and returns it as the contract type the application\n* names, ready to pass to `mysql({ contract })` and `mysqlStatic({ contract })`. Clients built\n* from the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateMysqlContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/mysql-static.ts\nfunction buildMysqlStaticContext(contract, context, stack) {\n\tconst { rawCodecInferer } = stack.adapter;\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a mysql builder output\");\n\tconst sqlDb = blindCast(sqlNamespace);\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a mysql builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw,\n\t\ttoSql: createToSql(stack, contract)\n\t};\n}\n/**\n* The query surfaces of a MySQL client without a driver: `sql`, `raw`, `enums` and `toSql`. Use\n* it where loading the MySQL driver is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = mysqlStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction mysqlStatic(options) {\n\tconst contract = validateMysqlContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildMysqlStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack);\n}\n//#endregion\nexport { validateMysqlContract as i, mysqlStatic as n, contractFromJson as r, buildMysqlStaticContext as t };\n\n//# sourceMappingURL=mysql-static-CNpyA32F.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,wBAAwB;AAC/C,MAAM,YAAY,GAAG,YAAY,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB7C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,sBAAsB,UAAU;CACxC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,wBAAwB,UAAU,SAAS,OAAO;CAC1D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,+DAA+D;CAC3F,MAAM,QAAQ,UAAU,YAAY;CACpC,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzI,cAAc,OAAO,+DAA+D;CACpF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;AAUA,SAAS,YAAY,SAAS;CAC7B,MAAM,WAAW,sBAAsB,QAAQ,QAAQ;CACvD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,wBAAwB,UAAU,uBAAuB;EAC/D;EACA;CACD,CAAC,GAAG,KAAK;AACV"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as validateMysqlContract, t as buildMysqlStaticContext } from "./mysql-static-
|
|
1
|
+
import { i as validateMysqlContract, t as buildMysqlStaticContext } from "./mysql-static-CNpyA32F-0x5ux1nm.mjs";
|
|
2
2
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
3
3
|
import mysqlAdapter from "@prisma/orm-target-mysql/adapter/runtime";
|
|
4
4
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
package/dist/runtime.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/mysql/9-facade/dist/runtime.mjs"],"sourcesContent":["import { i as validateMysqlContract, t as buildMysqlStaticContext } from \"./mysql-static-Cfh99GsI.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport mysqlAdapter from \"@internal/adapter-mysql/runtime\";\nimport mysqlDriver from \"@internal/driver-mysql/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, delegatingRuntime, toRuntimeOptions, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport mysqlTarget from \"@internal/target-mysql/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { type } from \"arktype\";\n//#region src/errors.ts\nfunction mysqlClientError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction invalidUrl(message, meta) {\n\treturn structuredError(\"RUNTIME.BINDING_INVALID\", message, { meta: {\n\t\textension: \"mysql\",\n\t\t...meta\n\t} });\n}\n/** Checks `url` as the Postgres facade checks its own: a non-empty URL that parses, with the `mysql://` scheme. No part of the URL goes into the error. */\nfunction validateMysqlUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw invalidUrl(\"MySQL URL must be a non-empty string\", { reason: \"empty url\" });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow invalidUrl(\"MySQL URL must be a valid URL\", { reason: \"unparseable url\" });\n\t}\n\tif (parsed.protocol !== \"mysql:\") throw invalidUrl(\"MySQL URL must use mysql://\", {\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t});\n\treturn trimmed;\n}\nfunction resolveMysqlBinding(input) {\n\treturn {\n\t\tkind: \"url\",\n\t\turl: validateMysqlUrl(input.url)\n\t};\n}\nfunction resolveOptionalMysqlBinding(options) {\n\treturn options.url === void 0 ? void 0 : resolveMysqlBinding({ url: options.url });\n}\n//#endregion\n//#region src/runtime/mysql-options.ts\nconst streamOptionSchema = type(\"boolean | undefined\");\n/** Checks `stream` when the factory is called, as the Postgres facade checks `cursor`. */\nfunction validateStreamOption(stream) {\n\tconst result = streamOptionSchema(stream);\n\tif (result instanceof type.errors) throw mysqlClientError(\"RUNTIME.ARGUMENT_INVALID\", \"Invalid stream option\", {\n\t\twhy: result.summary,\n\t\tfix: \"Pass stream: true to stream rows as they arrive, or leave stream unset to read each whole result first.\",\n\t\tmeta: {\n\t\t\textension: \"mysql\",\n\t\t\thelper: \"mysql\",\n\t\t\targument: \"stream\",\n\t\t\treceived: stream\n\t\t}\n\t});\n\treturn result ?? false;\n}\n//#endregion\n//#region src/runtime/mysql-runtime.ts\nvar MysqlRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/mysql.ts\nfunction mysqlOrm(orm) {\n\tconst namespace = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(namespace, \"the unbound namespace always exists on a mysql builder output\");\n\treturn blindCast(Reflect.get(namespace, \"fragment\") === void 0 ? Object.create(namespace, { fragment: { value: Reflect.get(orm, \"fragment\") } }) : namespace);\n}\n/**\n* Builds the members of a MySQL transaction over `txCtx`, so every statement they run goes through the transaction. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.\n*/\nfunction buildMysqlTransactionMembers(options, txCtx) {\n\tconst { context, collections, rawCodecInferer, enums, toSql, prepareRuntime } = options;\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a mysql builder output\");\n\treturn {\n\t\tsql: blindCast(sqlNamespace),\n\t\torm: mysqlOrm(orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t},\n\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t},\n\t\t\tcontext,\n\t\t\t...ifDefined(\"collections\", collections)\n\t\t})),\n\t\traw: createRawLane({\n\t\t\tcontext,\n\t\t\trawCodecInferer\n\t\t}),\n\t\tenums,\n\t\ttoSql,\n\t\tprepare(declaration, callback) {\n\t\t\treturn prepareQuery(prepareRuntime, declaration, callback);\n\t\t}\n\t};\n}\n/**\n* Creates a lazy MySQL client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The database opens on the first query\n* or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-mysql/static';\n* import mysql from '@prisma/orm-mysql/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = mysql({ contract, url: process.env.DATABASE_URL });\n* ```\n*/\nfunction mysql(options) {\n\tconst stream = validateStreamOption(options.stream);\n\tconst contract = validateMysqlContract(options.contract);\n\tlet binding = resolveOptionalMysqlBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\tdriver: mysqlDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: mysqlDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, toSql } = buildMysqlStaticContext(contract, context, stack);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet closePromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst closedError = () => mysqlClientError(\"DRIVER.NOT_CONNECTED\", \"MySQL client is closed\", { meta: { extension: \"mysql\" } });\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"MySQL runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconnectPromise = runtimeDriver.connect(resolvedBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw closedError();\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst adapter = stack.adapter.create(stack);\n\t\tconst driver = stack.driver.create({\n\t\t\tstream,\n\t\t\t...ifDefined(\"poolOptions\", options.poolOptions)\n\t\t});\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new MysqlRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\n\t\t\tdriver,\n\t\t\t...toRuntimeOptions(options),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst workRuntime = delegatingRuntime(getRuntime);\n\tconst orm$1 = mysqlOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: workRuntime\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(workRuntime, declaration, callback);\n\t}\n\treturn {\n\t\tsql,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\ttoSql,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tquery(plan, execOptions) {\n\t\t\treturn workRuntime.query(plan, execOptions);\n\t\t},\n\t\texecute(plan, execOptions) {\n\t\t\treturn workRuntime.execute(plan, execOptions);\n\t\t},\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw closedError();\n\t\t\tif (driverConnected || connectPromise) {\n\t\t\t\tif (bindingInput !== void 0) throw mysqlClientError(\"DRIVER.ALREADY_CONNECTED\", \"MySQL client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\",\n\t\t\t\t\tmeta: { extension: \"mysql\" }\n\t\t\t\t});\n\t\t\t\tconst runtime = getRuntime();\n\t\t\t\tawait connectPromise;\n\t\t\t\tif (closed) throw closedError();\n\t\t\t\treturn runtime;\n\t\t\t}\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveMysqlBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mysqlClientError(\"RUNTIME.BINDING_MISSING\", \"MySQL binding not configured. Pass url to mysql(...) or call db.connect({ url }).\", { meta: { extension: \"mysql\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\tif (closed) throw closedError();\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(workRuntime, (txCtx) => {\n\t\t\t\treturn fn(withTransactionMembers(txCtx, buildMysqlTransactionMembers({\n\t\t\t\t\tcontext,\n\t\t\t\t\tcollections: options.collections,\n\t\t\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\t\t\tenums,\n\t\t\t\t\ttoSql,\n\t\t\t\t\tprepareRuntime: workRuntime\n\t\t\t\t}, txCtx)));\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tif (closePromise) return closePromise;\n\t\t\tclosed = true;\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\t\tawait ownedDispose?.();\n\t\t\t})();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n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"}
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-targets/mysql/9-facade/dist/runtime.mjs"],"sourcesContent":["import { i as validateMysqlContract, t as buildMysqlStaticContext } from \"./mysql-static-CNpyA32F.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport mysqlAdapter from \"@internal/adapter-mysql/runtime\";\nimport mysqlDriver from \"@internal/driver-mysql/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, delegatingRuntime, toRuntimeOptions, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport mysqlTarget from \"@internal/target-mysql/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { type } from \"arktype\";\n//#region src/errors.ts\nfunction mysqlClientError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction invalidUrl(message, meta) {\n\treturn structuredError(\"RUNTIME.BINDING_INVALID\", message, { meta: {\n\t\textension: \"mysql\",\n\t\t...meta\n\t} });\n}\n/** Checks `url` as the Postgres facade checks its own: a non-empty URL that parses, with the `mysql://` scheme. No part of the URL goes into the error. */\nfunction validateMysqlUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw invalidUrl(\"MySQL URL must be a non-empty string\", { reason: \"empty url\" });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow invalidUrl(\"MySQL URL must be a valid URL\", { reason: \"unparseable url\" });\n\t}\n\tif (parsed.protocol !== \"mysql:\") throw invalidUrl(\"MySQL URL must use mysql://\", {\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t});\n\treturn trimmed;\n}\nfunction resolveMysqlBinding(input) {\n\treturn {\n\t\tkind: \"url\",\n\t\turl: validateMysqlUrl(input.url)\n\t};\n}\nfunction resolveOptionalMysqlBinding(options) {\n\treturn options.url === void 0 ? void 0 : resolveMysqlBinding({ url: options.url });\n}\n//#endregion\n//#region src/runtime/mysql-options.ts\nconst streamOptionSchema = type(\"boolean | undefined\");\n/** Checks `stream` when the factory is called, as the Postgres facade checks `cursor`. */\nfunction validateStreamOption(stream) {\n\tconst result = streamOptionSchema(stream);\n\tif (result instanceof type.errors) throw mysqlClientError(\"RUNTIME.ARGUMENT_INVALID\", \"Invalid stream option\", {\n\t\twhy: result.summary,\n\t\tfix: \"Pass stream: true to stream rows as they arrive, or leave stream unset to read each whole result first.\",\n\t\tmeta: {\n\t\t\textension: \"mysql\",\n\t\t\thelper: \"mysql\",\n\t\t\targument: \"stream\",\n\t\t\treceived: stream\n\t\t}\n\t});\n\treturn result ?? false;\n}\n//#endregion\n//#region src/runtime/mysql-runtime.ts\nvar MysqlRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/mysql.ts\nfunction mysqlOrm(orm) {\n\tconst namespace = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(namespace, \"the unbound namespace always exists on a mysql builder output\");\n\treturn blindCast(Reflect.get(namespace, \"fragment\") === void 0 ? Object.create(namespace, { fragment: { value: Reflect.get(orm, \"fragment\") } }) : namespace);\n}\n/**\n* Builds the members of a MySQL transaction over `txCtx`, so every statement they run goes through the transaction. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.\n*/\nfunction buildMysqlTransactionMembers(options, txCtx) {\n\tconst { context, collections, rawCodecInferer, enums, toSql, prepareRuntime } = options;\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a mysql builder output\");\n\treturn {\n\t\tsql: blindCast(sqlNamespace),\n\t\torm: mysqlOrm(orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t},\n\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t},\n\t\t\tcontext,\n\t\t\t...ifDefined(\"collections\", collections)\n\t\t})),\n\t\traw: createRawLane({\n\t\t\tcontext,\n\t\t\trawCodecInferer\n\t\t}),\n\t\tenums,\n\t\ttoSql,\n\t\tprepare(declaration, callback) {\n\t\t\treturn prepareQuery(prepareRuntime, declaration, callback);\n\t\t}\n\t};\n}\n/**\n* Creates a lazy MySQL client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The database opens on the first query\n* or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-mysql/static';\n* import mysql from '@prisma/orm-mysql/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = mysql({ contract, url: process.env.DATABASE_URL });\n* ```\n*/\nfunction mysql(options) {\n\tconst stream = validateStreamOption(options.stream);\n\tconst contract = validateMysqlContract(options.contract);\n\tlet binding = resolveOptionalMysqlBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\tdriver: mysqlDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: mysqlDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, toSql } = buildMysqlStaticContext(contract, context, stack);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet closePromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst closedError = () => mysqlClientError(\"DRIVER.NOT_CONNECTED\", \"MySQL client is closed\", { meta: { extension: \"mysql\" } });\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"MySQL runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconnectPromise = runtimeDriver.connect(resolvedBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw closedError();\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst adapter = stack.adapter.create(stack);\n\t\tconst driver = stack.driver.create({\n\t\t\tstream,\n\t\t\t...ifDefined(\"poolOptions\", options.poolOptions)\n\t\t});\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new MysqlRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\n\t\t\tdriver,\n\t\t\t...toRuntimeOptions(options),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst workRuntime = delegatingRuntime(getRuntime);\n\tconst orm$1 = mysqlOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: workRuntime\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(workRuntime, declaration, callback);\n\t}\n\treturn {\n\t\tsql,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\ttoSql,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tquery(plan, execOptions) {\n\t\t\treturn workRuntime.query(plan, execOptions);\n\t\t},\n\t\texecute(plan, execOptions) {\n\t\t\treturn workRuntime.execute(plan, execOptions);\n\t\t},\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw closedError();\n\t\t\tif (driverConnected || connectPromise) {\n\t\t\t\tif (bindingInput !== void 0) throw mysqlClientError(\"DRIVER.ALREADY_CONNECTED\", \"MySQL client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\",\n\t\t\t\t\tmeta: { extension: \"mysql\" }\n\t\t\t\t});\n\t\t\t\tconst runtime = getRuntime();\n\t\t\t\tawait connectPromise;\n\t\t\t\tif (closed) throw closedError();\n\t\t\t\treturn runtime;\n\t\t\t}\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveMysqlBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mysqlClientError(\"RUNTIME.BINDING_MISSING\", \"MySQL binding not configured. Pass url to mysql(...) or call db.connect({ url }).\", { meta: { extension: \"mysql\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\tif (closed) throw closedError();\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\treturn withTransaction(workRuntime, (txCtx) => {\n\t\t\t\treturn fn(withTransactionMembers(txCtx, buildMysqlTransactionMembers({\n\t\t\t\t\tcontext,\n\t\t\t\t\tcollections: options.collections,\n\t\t\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\t\t\tenums,\n\t\t\t\t\ttoSql,\n\t\t\t\t\tprepareRuntime: workRuntime\n\t\t\t\t}, txCtx)));\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tif (closePromise) return closePromise;\n\t\t\tclosed = true;\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\t\tawait ownedDispose?.();\n\t\t\t})();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { MysqlRuntimeImpl, mysql as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,iBAAiB,MAAM,SAAS,SAAS;CACjD,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;AAGA,SAAS,WAAW,SAAS,MAAM;CAClC,OAAO,gBAAgB,2BAA2B,SAAS,EAAE,MAAM;EAClE,WAAW;EACX,GAAG;CACJ,EAAE,CAAC;AACJ;;AAEA,SAAS,iBAAiB,KAAK;CAC9B,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,WAAW,wCAAwC,EAAE,QAAQ,YAAY,CAAC;CAC1G,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,OAAO;CACzB,QAAQ;EACP,MAAM,WAAW,iCAAiC,EAAE,QAAQ,kBAAkB,CAAC;CAChF;CACA,IAAI,OAAO,aAAa,UAAU,MAAM,WAAW,+BAA+B;EACjF,QAAQ;EACR,UAAU,OAAO;CAClB,CAAC;CACD,OAAO;AACR;AACA,SAAS,oBAAoB,OAAO;CACnC,OAAO;EACN,MAAM;EACN,KAAK,iBAAiB,MAAM,GAAG;CAChC;AACD;AACA,SAAS,4BAA4B,SAAS;CAC7C,OAAO,QAAQ,QAAQ,KAAK,IAAI,KAAK,IAAI,oBAAoB,EAAE,KAAK,QAAQ,IAAI,CAAC;AAClF;AAGA,MAAM,qBAAqB,KAAK,qBAAqB;;AAErD,SAAS,qBAAqB,QAAQ;CACrC,MAAM,SAAS,mBAAmB,MAAM;CACxC,IAAI,kBAAkB,KAAK,QAAQ,MAAM,iBAAiB,4BAA4B,yBAAyB;EAC9G,KAAK,OA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AAgB,YAAY,KAAK,CAAC;IACxC,MAAM,eAAe;GACtB,EAAA,CAAG;GACH,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
|
package/dist/static.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as contractFromJson, r as mysqlStatic } from "./mysql-static-
|
|
1
|
+
import { n as contractFromJson, r as mysqlStatic } from "./mysql-static-CNpyA32F-0x5ux1nm.mjs";
|
|
2
2
|
export { contractFromJson, mysqlStatic as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/orm-mysql",
|
|
3
|
-
"version": "8.0.0-rc.23-dev.
|
|
3
|
+
"version": "8.0.0-rc.23-dev.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
"skills"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@prisma/orm-family-sql": "8.0.0-rc.23-dev.
|
|
14
|
-
"@prisma/orm-framework": "8.0.0-rc.23-dev.
|
|
15
|
-
"@prisma/orm-target-mysql": "8.0.0-rc.23-dev.
|
|
16
|
-
"@prisma/orm-toolchain": "8.0.0-rc.23-dev.
|
|
13
|
+
"@prisma/orm-family-sql": "8.0.0-rc.23-dev.4",
|
|
14
|
+
"@prisma/orm-framework": "8.0.0-rc.23-dev.4",
|
|
15
|
+
"@prisma/orm-target-mysql": "8.0.0-rc.23-dev.4",
|
|
16
|
+
"@prisma/orm-toolchain": "8.0.0-rc.23-dev.4",
|
|
17
17
|
"arktype": "^2.2.2",
|
|
18
18
|
"pathe": "^2.0.3",
|
|
19
19
|
"temporal-spec": "1.0.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@internal/mysql": "8.0.0-rc.23-dev.
|
|
23
|
-
"@repo/tsconfig": "8.0.0-rc.23-dev.
|
|
24
|
-
"@repo/tsdown": "8.0.0-rc.23-dev.
|
|
22
|
+
"@internal/mysql": "8.0.0-rc.23-dev.4",
|
|
23
|
+
"@repo/tsconfig": "8.0.0-rc.23-dev.4",
|
|
24
|
+
"@repo/tsdown": "8.0.0-rc.23-dev.4",
|
|
25
25
|
"tsdown": "0.22.14",
|
|
26
26
|
"typescript": "5.9.3"
|
|
27
27
|
},
|
package/skills/prisma-8/SKILL.md
CHANGED
|
@@ -46,7 +46,7 @@ Both files are **emitted artefacts**. Edit the source; never the JSON or `.d.ts`
|
|
|
46
46
|
- **`contract.prisma` (PSL)** — schema-flavoured DSL. Canonical for typical apps and brownfield Prisma users. Wired by `contract: './<path>/contract.prisma'` — the target config (`ormConfig`, below) detects the `.prisma` extension and routes through the PSL provider. The first line of every `.prisma` file is `// use prisma-8`; `orm init` and `contract infer` write it, and the language server only serves diagnostics, completion, and formatting on files that carry it (it still recognises the header earlier releases wrote and rewrites it on Format).
|
|
47
47
|
- **`contract.ts` (TypeScript builder)** — programmatic authoring with `defineContract({...}, ({ field, model, rel, type }) => ({...}))` from `@internal/postgres/contract-builder` (or `@internal/mongo/contract-builder`). Wired by `contract: './<path>/contract.ts'` — the façade detects the `.ts` extension and routes through the TS provider. Use when you need programmatic composition (per-tenant variants, generated fields) or constructs PSL doesn't yet express (e.g. registering a parameterised extension type — see pgvector's contract).
|
|
48
48
|
- **An existing Prisma schema, during adoption.** A project that still runs an earlier Prisma can point `contract:` at its current `schema.prisma` instead of writing a Prisma 8 contract: `contract: prisma6Schema('prisma/schema.prisma')` from `@internal/mongo/config` reads a Prisma 6 MongoDB schema, and `prisma7Schema` from `@internal/postgres/config` reads a Prisma 7 Postgres schema. The earlier Prisma keeps owning the database; after each change there, run `contract emit` and `db sign`. A construct Prisma 8 cannot express fails `contract emit` with a `PSL.PRISMA6_MONGO_*` or `PSL.PRISMA7_*` diagnostic. See the façade READMEs for the details.
|
|
49
|
-
- **`prisma.config.ts`.** Wires the contract source, the database connection, the migrations directory, and any installed extensions. The file is an *envelope*: the unified CLI's `definePrismaConfig({...})` from `@prisma/cli-engine` wraps an `orm:` section built by the target's `defineConfig` — conventionally imported as `ormConfig` from `@internal/postgres/config` (or `@internal/mongo/config`). There is no flat form; a bare `defineConfig({ contract, ... })` default export fails with `CONFIG.VERSION_MARKER_MISSING`.
|
|
49
|
+
- **`prisma.config.ts`.** Wires the contract source, the database connection, the migrations directory, and any installed extensions. The file is an *envelope*: the unified CLI's `definePrismaConfig({...})` from `@prisma/cli-engine` wraps an `orm:` section built by the target's `defineConfig` — conventionally imported as `ormConfig` from `@internal/postgres/config` (or `@internal/mongo/config`). There is no flat form; a bare `defineConfig({ contract, ... })` default export fails with `CONFIG.VERSION_MARKER_MISSING`. Pass `formatter: { indent, newline }` to `ormConfig` to set how `prisma contract format` and the language server lay out PSL files: `indent` is a whole number of spaces, 1 or more (default 2), or `'tab'`. `newline` is `'LF'` or `'CRLF'`; without it, `contract format` uses the operating system's line ending and the language server uses LF.
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
52
|
// prisma.config.ts — what `prisma orm init` scaffolds
|
|
@@ -62,7 +62,7 @@ Both files are **emitted artefacts**. Edit the source; never the JSON or `.d.ts`
|
|
|
62
62
|
});
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
The fields `ormConfig` accepts: `contract` (path string — `.prisma` or `.ts`), `output` (optional override for where `contract.json` lands), `db` (`{ connection?: string }`), `extensions` (array of control descriptors), `migrations` (`{ dir?: string }`). Without `output`, the path for `contract.json` is derived from `contract` (e.g. `./src/prisma/contract.prisma` → `./src/prisma/contract.json`). Keep `import 'dotenv/config'` when the config reads `process.env`.
|
|
65
|
+
The fields `ormConfig` accepts: `contract` (path string — `.prisma` or `.ts`), `output` (optional override for where `contract.json` lands), `db` (`{ connection?: string }`), `extensions` (array of control descriptors), `migrations` (`{ dir?: string }`), `formatter` (`{ indent?: number | 'tab'; newline?: 'LF' | 'CRLF' }`). Without `output`, the path for `contract.json` is derived from `contract` (e.g. `./src/prisma/contract.prisma` → `./src/prisma/contract.json`). Keep `import 'dotenv/config'` when the config reads `process.env`.
|
|
66
66
|
- **Emit pipeline.** `prisma contract emit --config <path>?` reads `prisma.config.ts`, calls the provider the façade picked, validates the resulting Contract, then atomically writes `contract.json` + `contract.d.ts` colocated with the source.
|
|
67
67
|
- **Extension namespaces.** Extensions contribute namespaced constructors (`pgvector.Vector(length: 1536)`, `postgis.Geometry(...)`) and type aliases. Install them by adding the descriptor to **two** places — both fields are named `extensions`, but the two surfaces consume two different descriptor types and shapes:
|
|
68
68
|
- **In the config (façade and core):** `extensions: [pgvector]` — array of *control* descriptors imported from `@internal/extension-<name>/control`.
|