@prisma/orm-target-mysql 8.0.0-rc.22-dev.10 → 8.0.0-rc.22-dev.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +3 -1
  2. package/dist/{adapter-_WBomuTw.d.mts → adapter-Dl4Wwz1I.d.mts} +4 -2
  3. package/dist/adapter-Dl4Wwz1I.d.mts.map +1 -0
  4. package/dist/adapter.d.mts +5 -5
  5. package/dist/adapter.mjs +2 -2
  6. package/dist/adapter__adapter.d.mts +1 -1
  7. package/dist/adapter__adapter.mjs +1 -1
  8. package/dist/adapter__codec-types.d.mts +2 -2
  9. package/dist/adapter__control.d.mts +1 -1
  10. package/dist/adapter__control.mjs +1 -1
  11. package/dist/adapter__runtime.d.mts +1 -1
  12. package/dist/adapter__runtime.mjs +89 -14
  13. package/dist/adapter__runtime.mjs.map +1 -1
  14. package/dist/{codec-descriptor-Du6DSz-3-ytBCu_mq.mjs → codec-descriptor-3xp1XvVH-yVLnNzZ8.mjs} +5 -3
  15. package/dist/codec-descriptor-3xp1XvVH-yVLnNzZ8.mjs.map +1 -0
  16. package/dist/codec-ids-CrR9Xi7r-CarpqbNM.mjs +20 -0
  17. package/dist/codec-ids-CrR9Xi7r-CarpqbNM.mjs.map +1 -0
  18. package/dist/codec-ids-Dgh5IpML-76oBMuwK.d.mts +20 -0
  19. package/dist/codec-ids-Dgh5IpML-76oBMuwK.d.mts.map +1 -0
  20. package/dist/codec-types-BH5moCD9.d.mts +1 -0
  21. package/dist/codec-types-Bai_CFkk-Blx2GxCH.d.mts +31 -0
  22. package/dist/codec-types-Bai_CFkk-Blx2GxCH.d.mts.map +1 -0
  23. package/dist/codec-types-zzVcrnbk.d.mts +1 -0
  24. package/dist/codecs-BMidk26M-DsKq6wt5.d.mts +282 -0
  25. package/dist/codecs-BMidk26M-DsKq6wt5.d.mts.map +1 -0
  26. package/dist/codecs-BfiB79-5.mjs +750 -0
  27. package/dist/codecs-BfiB79-5.mjs.map +1 -0
  28. package/dist/codecs-C_twedMx.d.mts +36 -0
  29. package/dist/codecs-C_twedMx.d.mts.map +1 -0
  30. package/dist/{contract-contributions-B9njRJbt-ClEtrK2L.mjs → contract-contributions-ChiX6W0F-CAng98bZ.mjs} +5 -4
  31. package/dist/contract-contributions-ChiX6W0F-CAng98bZ.mjs.map +1 -0
  32. package/dist/{control-6wRZXIJ7.mjs → control-5eVF1TXc.mjs} +2 -2
  33. package/dist/{control-6wRZXIJ7.mjs.map → control-5eVF1TXc.mjs.map} +1 -1
  34. package/dist/{control-WTY7Jpxk.mjs → control-BBhWaGnH.mjs} +24 -13
  35. package/dist/control-BBhWaGnH.mjs.map +1 -0
  36. package/dist/control-BvSM7mGR.d.mts +396 -0
  37. package/dist/control-BvSM7mGR.d.mts.map +1 -0
  38. package/dist/{control-Ez_PtlFI.d.mts → control-MoPFgSaQ.d.mts} +2 -2
  39. package/dist/{control-Ez_PtlFI.d.mts.map → control-MoPFgSaQ.d.mts.map} +1 -1
  40. package/dist/data-type-entries-C7VH2IHc-D1d5I8zF.mjs +59 -0
  41. package/dist/data-type-entries-C7VH2IHc-D1d5I8zF.mjs.map +1 -0
  42. package/dist/{data-types-SXrh0Lou.d.mts → data-types-C-rfxpgB.d.mts} +2 -2
  43. package/dist/data-types-C-rfxpgB.d.mts.map +1 -0
  44. package/dist/data-types-D2HAT-Qf-CRI506c0.d.mts +88 -0
  45. package/dist/data-types-D2HAT-Qf-CRI506c0.d.mts.map +1 -0
  46. package/dist/data-types-DOaaPS93-DBkMJyh1.mjs +289 -0
  47. package/dist/data-types-DOaaPS93-DBkMJyh1.mjs.map +1 -0
  48. package/dist/date-time-now-generators-DY-8Bodc-DcQ3h4Fg.mjs +72 -0
  49. package/dist/date-time-now-generators-DY-8Bodc-DcQ3h4Fg.mjs.map +1 -0
  50. package/dist/{default-normalizer-BDUgHXUn-Xk7HQJuI.mjs → default-normalizer-C8pc7SbL-CKgOEnGl.mjs} +22 -12
  51. package/dist/default-normalizer-C8pc7SbL-CKgOEnGl.mjs.map +1 -0
  52. package/dist/{default-normalizer-BBhGpw7r.d.mts → default-normalizer-CGIwQiKB.d.mts} +4 -4
  53. package/dist/{default-normalizer-BBhGpw7r.d.mts.map → default-normalizer-CGIwQiKB.d.mts.map} +1 -1
  54. package/dist/descriptor-meta-CsMPRsxp-DhK87vlc.mjs +352 -0
  55. package/dist/descriptor-meta-CsMPRsxp-DhK87vlc.mjs.map +1 -0
  56. package/dist/driver.mjs +1 -1
  57. package/dist/driver__control.mjs +1 -1
  58. package/dist/driver__runtime.mjs +275 -126
  59. package/dist/driver__runtime.mjs.map +1 -1
  60. package/dist/errors-Cng94tYg-D02Eud2d.mjs +87 -0
  61. package/dist/errors-Cng94tYg-D02Eud2d.mjs.map +1 -0
  62. package/dist/{errors-BYhjQT7y.d.mts → errors-DfrC_yfG.d.mts} +2 -2
  63. package/dist/{errors-BYhjQT7y.d.mts.map → errors-DfrC_yfG.d.mts.map} +1 -1
  64. package/dist/{marker-lock-CmGvN4hw-Com29AtQ.mjs → marker-lock-Bwew7cAs-CZ20Y_tA.mjs} +3 -3
  65. package/dist/{marker-lock-CmGvN4hw-Com29AtQ.mjs.map → marker-lock-Bwew7cAs-CZ20Y_tA.mjs.map} +1 -1
  66. package/dist/{marker-read-aEaHihYj-Cyg16yn1.mjs → marker-read-Cf80LSbG-CUp3v1e5.mjs} +5 -5
  67. package/dist/{marker-read-aEaHihYj-Cyg16yn1.mjs.map → marker-read-Cf80LSbG-CUp3v1e5.mjs.map} +1 -1
  68. package/dist/mysql-contract-serializer-BnTKRSsN-B2O3EreV.mjs +35 -0
  69. package/dist/mysql-contract-serializer-BnTKRSsN-B2O3EreV.mjs.map +1 -0
  70. package/dist/{mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs → mysql-database-CHl9-oSL-CWZLDXt6.mjs} +39 -40
  71. package/dist/mysql-database-CHl9-oSL-CWZLDXt6.mjs.map +1 -0
  72. package/dist/now-expression-DVD18CUc-00buJUto.mjs +38 -0
  73. package/dist/now-expression-DVD18CUc-00buJUto.mjs.map +1 -0
  74. package/dist/{pack-YVG-iBMQ.d.mts → pack-BXvLVBWP.d.mts} +395 -14
  75. package/dist/{pack-YVG-iBMQ.d.mts.map → pack-BXvLVBWP.d.mts.map} +1 -1
  76. package/dist/require-temporal-DeDQhbTn-Bxc65WbA.mjs +16 -0
  77. package/dist/require-temporal-DeDQhbTn-Bxc65WbA.mjs.map +1 -0
  78. package/dist/{runner-BaBQoXiU-C7ln-4b2.mjs → runner-C39AEe6--BVG3xPYw.mjs} +7 -7
  79. package/dist/{runner-BaBQoXiU-C7ln-4b2.mjs.map → runner-C39AEe6--BVG3xPYw.mjs.map} +1 -1
  80. package/dist/{runtime-CeuRr9nE.d.mts → runtime-ClRDfPiY.d.mts} +2 -2
  81. package/dist/{runtime-CeuRr9nE.d.mts.map → runtime-ClRDfPiY.d.mts.map} +1 -1
  82. package/dist/runtime-CrB5DXx4.d.mts +54 -0
  83. package/dist/runtime-CrB5DXx4.d.mts.map +1 -0
  84. package/dist/{sql-utils-Db0IQO_B-PaULnfrE.mjs → sql-utils-Cmv_TVa8-BetrIUcj.mjs} +3 -3
  85. package/dist/{sql-utils-Db0IQO_B-PaULnfrE.mjs.map → sql-utils-Cmv_TVa8-BetrIUcj.mjs.map} +1 -1
  86. package/dist/{sql-utils-RW0vJvDl.mjs → sql-utils-bD4SfgX0.mjs} +2 -2
  87. package/dist/{sql-utils-RW0vJvDl.mjs.map → sql-utils-bD4SfgX0.mjs.map} +1 -1
  88. package/dist/{statement-kfMRMKIt-D6cAOKys.mjs → statement-DC62oiSx-Buzptbpk.mjs} +21 -15
  89. package/dist/statement-DC62oiSx-Buzptbpk.mjs.map +1 -0
  90. package/dist/target.d.mts +14 -13
  91. package/dist/target.mjs +17 -13
  92. package/dist/target__codec-descriptor.mjs +1 -1
  93. package/dist/target__codec-ids.d.mts +2 -2
  94. package/dist/target__codec-ids.mjs +2 -2
  95. package/dist/target__codec-types.d.mts +2 -2
  96. package/dist/target__codecs.d.mts +3 -3
  97. package/dist/target__codecs.mjs +3 -2
  98. package/dist/target__control.d.mts +2 -2
  99. package/dist/target__control.mjs +38 -32
  100. package/dist/target__control.mjs.map +1 -1
  101. package/dist/target__data-types.d.mts +3 -3
  102. package/dist/target__data-types.mjs +3 -3
  103. package/dist/target__default-normalizer.d.mts +1 -1
  104. package/dist/target__default-normalizer.mjs +1 -1
  105. package/dist/target__errors.d.mts +1 -1
  106. package/dist/target__errors.mjs +1 -1
  107. package/dist/target__marker-lock.mjs +1 -1
  108. package/dist/target__migration.mjs +1 -1
  109. package/dist/target__pack.d.mts +1 -1
  110. package/dist/target__pack.mjs +1 -1
  111. package/dist/target__runtime.d.mts +2 -2
  112. package/dist/target__runtime.mjs +3 -3
  113. package/dist/target__runtime.mjs.map +1 -1
  114. package/dist/target__sql-utils.mjs +2 -2
  115. package/dist/target__types.d.mts +2 -0
  116. package/dist/target__types.mjs +2 -0
  117. package/dist/{control-_4epnrIW.d.mts → types-CgrFHUdk.d.mts} +3 -8
  118. package/dist/types-CgrFHUdk.d.mts.map +1 -0
  119. package/package.json +18 -12
  120. package/dist/adapter-_WBomuTw.d.mts.map +0 -1
  121. package/dist/codec-descriptor-Du6DSz-3-ytBCu_mq.mjs.map +0 -1
  122. package/dist/codec-ids-cjxtOcLM-vFeQhgPm.mjs +0 -10
  123. package/dist/codec-ids-cjxtOcLM-vFeQhgPm.mjs.map +0 -1
  124. package/dist/codec-ids-sMOU8F-B-BQbCq2dr.d.mts +0 -10
  125. package/dist/codec-ids-sMOU8F-B-BQbCq2dr.d.mts.map +0 -1
  126. package/dist/codec-types-Bd7DL1Mr-CZWNfnp9.d.mts +0 -21
  127. package/dist/codec-types-Bd7DL1Mr-CZWNfnp9.d.mts.map +0 -1
  128. package/dist/codec-types-Bo3Jfilx.d.mts +0 -1
  129. package/dist/codec-types-Ja2kLzLS.d.mts +0 -1
  130. package/dist/codecs-C00kjHgh.mjs +0 -282
  131. package/dist/codecs-C00kjHgh.mjs.map +0 -1
  132. package/dist/codecs-CO_VNEYU-CwAnKzRs.d.mts +0 -102
  133. package/dist/codecs-CO_VNEYU-CwAnKzRs.d.mts.map +0 -1
  134. package/dist/codecs-DM61agRr.d.mts +0 -21
  135. package/dist/codecs-DM61agRr.d.mts.map +0 -1
  136. package/dist/contract-contributions-B9njRJbt-ClEtrK2L.mjs.map +0 -1
  137. package/dist/control-WTY7Jpxk.mjs.map +0 -1
  138. package/dist/control-_4epnrIW.d.mts.map +0 -1
  139. package/dist/data-type-entries-B0AoBozh-f9AEUIUQ.mjs +0 -42
  140. package/dist/data-type-entries-B0AoBozh-f9AEUIUQ.mjs.map +0 -1
  141. package/dist/data-types-BpihGKoK-BMW-m4EN.d.mts +0 -52
  142. package/dist/data-types-BpihGKoK-BMW-m4EN.d.mts.map +0 -1
  143. package/dist/data-types-Dv9gwVRV-BZPzCWZk.mjs +0 -181
  144. package/dist/data-types-Dv9gwVRV-BZPzCWZk.mjs.map +0 -1
  145. package/dist/data-types-SXrh0Lou.d.mts.map +0 -1
  146. package/dist/default-normalizer-BDUgHXUn-Xk7HQJuI.mjs.map +0 -1
  147. package/dist/descriptor-meta-BurjcSiU-Cbk2L1jf.mjs +0 -82
  148. package/dist/descriptor-meta-BurjcSiU-Cbk2L1jf.mjs.map +0 -1
  149. package/dist/descriptor-meta-runtime-Bk_00UrX-BLN4Ahpj.mjs +0 -17
  150. package/dist/descriptor-meta-runtime-Bk_00UrX-BLN4Ahpj.mjs.map +0 -1
  151. package/dist/errors-rvH_F2Yj-BQrO_--u.mjs +0 -20
  152. package/dist/errors-rvH_F2Yj-BQrO_--u.mjs.map +0 -1
  153. package/dist/mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs.map +0 -1
  154. package/dist/runtime-Cl0BbTZq.d.mts +0 -22
  155. package/dist/runtime-Cl0BbTZq.d.mts.map +0 -1
  156. package/dist/statement-kfMRMKIt-D6cAOKys.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"driver__runtime.mjs","names":["#streamRows","#runReleasing","#interruptAndEnd","#stopEarly","#onRelease","#released","#count","#idle","#fail","#options","#sessionSettings","#state","#interrupt","#inUse"],"sources":["../../../../3-targets/mysql/3-driver/dist/runtime.mjs"],"sourcesContent":["import { a as connectingCannotSucceed, c as isFatal, d as DEFAULT_CONNECT_TIMEOUT_MILLIS, f as mysqlConnectionOptions, l as normalizeMysqlError, m as acquireClientQueryLock, n as SessionSettingsGuard, p as mysqlPoolOptions, t as statementFor, u as mysqlDriverDescriptorMeta } from \"./statement-kfMRMKIt.mjs\";\nimport { errorRuntime } from \"@internal/errors/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { createConnection, createPool } from \"mariadb\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { EventEmitter } from \"node:events\";\nimport { finished } from \"node:stream/promises\";\n//#region src/core/runtime/mysql-driver.ts\nfunction notConnected(message) {\n\treturn errorRuntime(\"DRIVER.NOT_CONNECTED\", message, { fix: \"Call connect(binding) before running queries, and do not use the driver after close().\" });\n}\n/** Runs `request` on `client` in one round trip and returns its result: its `?N` placeholders written as `?`, and its values handed to the package, which writes them into the statement. Throws the package's error as it is. */\nasync function run(client, request) {\n\tconst { sql, values } = statementFor(client, request.sql, request.params ?? []);\n\treturn client.query(sql, values);\n}\n/** Starts streaming the rows of `request` on `client`, sent as {@link run} sends it. Throws the error to report, after noting in `outcome` whether it left the client unusable. */\nfunction startStream(client, request, outcome) {\n\ttry {\n\t\tconst { sql, values } = statementFor(client, request.sql, request.params ?? []);\n\t\treturn client.queryStream(sql, values);\n\t} catch (error) {\n\t\tthrow settle(error, outcome);\n\t}\n}\nfunction affectedRows(result) {\n\treturn typeof result === \"object\" && result !== null && \"affectedRows\" in result && typeof result.affectedRows === \"number\" ? result.affectedRows : 0;\n}\n/** The error to report for `error`, after noting in `outcome` whether it left the client unusable. */\nfunction settle(error, outcome) {\n\tif (isFatal(error)) outcome.destroy = true;\n\treturn normalizeMysqlError(error);\n}\n/**\n* Whether the package has received the end of the result, so that any rows the caller has not read are already in the stream's buffer. The package pushes the end of the stream when MySQL's last packet arrives; Node records that in `_readableState.ended`, and its public API reports the end only after the caller has read every row.\n*/\nfunction resultReceived(rows) {\n\tconst state = Reflect.get(rows, \"_readableState\");\n\treturn typeof state === \"object\" && state !== null && \"ended\" in state && state.ended === true;\n}\n/** Reads and drops the rest of `rows` and settles once it has ended or failed. A caller that abandoned its loop over the stream leaves the loop's `'readable'` listener behind, which would keep the stream paused, so it is removed. */\nasync function dropRest(rows) {\n\trows.close?.();\n\trows.removeAllListeners(\"readable\");\n\trows.resume();\n\tawait finished(rows);\n}\n/** The package can report an error on a stream after the caller stopped reading it, such as the one for a connection destroyed mid-result; the generator has already settled by then. */\nfunction ignoreAfterStop() {}\n/** Waiting for a statement to end needs only that it settled; its own caller handles how. */\nfunction settledEither() {}\n/** Waits for `work` to settle, but no longer than `ms`. */\nasync function settledWithin(work, ms) {\n\tlet timer;\n\tconst elapsed = new Promise((resolve) => {\n\t\ttimer = setTimeout(resolve, ms);\n\t});\n\ttry {\n\t\tawait Promise.race([work.then(settledEither, settledEither), elapsed]);\n\t} finally {\n\t\tclearTimeout(timer);\n\t}\n}\nfunction noConnection() {}\n/** The server may have run a `KILL` whose reply was lost, so the statement may still end; the caller waits for it either way. */\nfunction killReplyLost() {}\n/**\n* Sends `KILL QUERY` for the statement running on the connection with id `threadId`, over a short-lived connection of its own, because MySQL cannot interrupt a statement from the connection that runs it. That connection waits for the reply no longer than it waits to connect. Resolves `true` once the `KILL` was sent, whatever the reply, and `false` when the connection could not be opened. Never rejects.\n*\n* The package does the same when it destroys a connection with a statement still running, but leaves a failure of its `KILL` unhandled, which ends a Node.js process. So the driver interrupts the statement itself and destroys the connection only once the statement has ended, when the package has nothing left to interrupt.\n*/\nasync function interruptStatement(options, threadId) {\n\tconst connection = await createConnection({\n\t\t...options,\n\t\t...ifDefined(\"socketTimeout\", options.connectTimeout)\n\t}).catch(noConnection);\n\tif (connection === void 0) return false;\n\tawait connection.query(\"KILL QUERY ?\", [threadId]).catch(killReplyLost);\n\tconnection.destroy();\n\treturn true;\n}\nvar MysqlQueryable = class {\n\tstreams;\n\t/** Called with each stream when it starts and with `undefined` when it ends, so a held connection can end a stream its caller abandoned. */\n\tstreamChanged(_rows) {}\n\t/** Called with each buffered statement as it starts, so a held connection can wait for it to end. */\n\tstatementRunning(_running) {}\n\tconstructor(streams) {\n\t\tthis.streams = streams;\n\t}\n\tasync *query(request) {\n\t\tif (this.streams) {\n\t\t\tyield* this.#streamRows(request);\n\t\t\treturn;\n\t\t}\n\t\tconst result = await this.#runReleasing(request);\n\t\tfor (const row of Array.isArray(result) ? result : []) yield blindCast(row);\n\t}\n\tasync execute(request) {\n\t\treturn { affectedRows: affectedRows(await this.#runReleasing(request)) };\n\t}\n\tasync #runReleasing(request) {\n\t\tconst client = await this.acquireClient();\n\t\tconst outcome = { destroy: false };\n\t\ttry {\n\t\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\t\ttry {\n\t\t\t\tconst running = run(client, request);\n\t\t\t\tthis.statementRunning(running);\n\t\t\t\treturn await running;\n\t\t\t} finally {\n\t\t\t\treleaseLock();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow settle(error, outcome);\n\t\t} finally {\n\t\t\tawait this.releaseClient(client, outcome);\n\t\t}\n\t}\n\t/**\n\t* Streams the rows of `request` as they arrive; the package pauses the socket while the caller is busy. A caller that stops reading early is handled by {@link MysqlQueryable.#stopEarly}, or by {@link MysqlQueryable.#interruptAndEnd} for a pooled client whose result is still arriving, which then gives the client back in the background. A fatal error, such as a lost connection, destroys the client.\n\t*/\n\tasync *#streamRows(request) {\n\t\tconst client = await this.acquireClient();\n\t\tconst outcome = { destroy: false };\n\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\tlet ending;\n\t\ttry {\n\t\t\tconst rows = startStream(client, request, outcome);\n\t\t\trows.on(\"error\", ignoreAfterStop);\n\t\t\tthis.streamChanged(rows);\n\t\t\tlet settled = false;\n\t\t\ttry {\n\t\t\t\tfor await (const row of rows.iterator({ destroyOnReturn: false })) yield blindCast(row);\n\t\t\t\tsettled = true;\n\t\t\t} catch (error) {\n\t\t\t\tsettled = true;\n\t\t\t\tthrow settle(error, outcome);\n\t\t\t} finally {\n\t\t\t\tif (!settled && !this.holdsClient && !resultReceived(rows)) {\n\t\t\t\t\toutcome.destroy = true;\n\t\t\t\t\tending = this.#interruptAndEnd(client, rows);\n\t\t\t\t} else if (!settled) await this.#stopEarly(rows, outcome);\n\t\t\t\tif (outcome.destroy && ending === void 0) rows.destroy();\n\t\t\t\tthis.streamChanged(void 0);\n\t\t\t}\n\t\t} finally {\n\t\t\tif (ending === void 0) {\n\t\t\t\treleaseLock();\n\t\t\t\tawait this.releaseClient(client, outcome);\n\t\t\t} else ending.then(() => {\n\t\t\t\treleaseLock();\n\t\t\t\treturn this.releaseClient(client, outcome);\n\t\t\t}).catch(ignoreAfterStop);\n\t\t}\n\t}\n\t/** Ends a stream the caller stopped reading early whose client survives it: a held client, whose session must survive, or a pooled one whose whole result has arrived. The rest is read and dropped. */\n\tasync #stopEarly(rows, outcome) {\n\t\tawait dropRest(rows).catch((error) => {\n\t\t\tif (isFatal(error)) outcome.destroy = true;\n\t\t});\n\t}\n\t/**\n\t* Ends a stream the caller stopped reading early on a pooled client whose result is still arriving. The client is destroyed rather than kept, so a large result is not downloaded only to be thrown away, since MySQL does not say how many rows remain; before that, its statement is interrupted and the rest of the result dropped, so the package finds nothing left to interrupt. Settles once the result has ended or the wait for it is over.\n\t*/\n\tasync #interruptAndEnd(client, rows) {\n\t\tawait this.endStatement(client, dropRest(rows).catch(ignoreAfterStop));\n\t\trows.destroy();\n\t}\n};\n/**\n* A queryable on a connection the caller holds, whose statements all run on the same session, in the order they are sent, under the client's lock. A statement sent while a stream on the connection is open waits for that stream to end; one awaited inside the stream's own loop never finishes, as on Postgres with a cursor.\n*/\nvar MysqlHeldQueryable = class extends MysqlQueryable {\n\tclient;\n\theld;\n\tend;\n\tholdsClient = true;\n\tconstructor(client, held, streams, end) {\n\t\tsuper(streams);\n\t\tthis.client = client;\n\t\tthis.held = held;\n\t\tthis.end = end;\n\t}\n\tendStatement(client, ended) {\n\t\treturn this.end(client, ended);\n\t}\n\tstreamChanged(rows) {\n\t\tthis.held.stream = rows;\n\t}\n\tstatementRunning(running) {\n\t\tconst settled = running.then(settledEither, settledEither);\n\t\tthis.held.statements.add(settled);\n\t\tsettled.then(() => this.held.statements.delete(settled));\n\t}\n\tasync acquireClient() {\n\t\tthis.held.running += 1;\n\t\treturn this.client;\n\t}\n\tasync releaseClient() {\n\t\tthis.held.running -= 1;\n\t}\n\t/** Runs one of the package's transaction calls under the client's lock, taken as a statement takes it, so it keeps its place among the statements sent. */\n\tasync underLock(call) {\n\t\tconst client = await this.acquireClient();\n\t\ttry {\n\t\t\tconst releaseLock = await acquireClientQueryLock(client);\n\t\t\ttry {\n\t\t\t\tawait call();\n\t\t\t} finally {\n\t\t\t\treleaseLock();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow normalizeMysqlError(error);\n\t\t} finally {\n\t\t\tawait this.releaseClient();\n\t\t}\n\t}\n};\nvar MysqlConnectionImpl = class extends MysqlHeldQueryable {\n\t#onRelease;\n\tconstructor(client, streams, end, onRelease) {\n\t\tsuper(client, {\n\t\t\trunning: 0,\n\t\t\tstream: void 0,\n\t\t\tstatements: /* @__PURE__ */ new Set()\n\t\t}, streams, end);\n\t\tthis.#onRelease = onRelease;\n\t}\n\t#released() {\n\t\tconst onRelease = this.#onRelease;\n\t\tthis.#onRelease = void 0;\n\t\tonRelease?.();\n\t}\n\tasync beginTransaction() {\n\t\tawait this.underLock(() => this.client.beginTransaction());\n\t\treturn new MysqlTransactionImpl(this.client, this.held, this.streams, this.end);\n\t}\n\t/**\n\t* Returns the connection to the pool, as the Postgres driver's `release()` does. A connection with a statement still running, such as a stream the caller dropped, is destroyed instead: the package's release sends `ROLLBACK` behind that statement and waits for it, which would never finish, where `pg`'s release does not wait on the server.\n\t*/\n\tasync release() {\n\t\tif (this.held.running > 0) return this.destroy();\n\t\ttry {\n\t\t\tawait this.client.release();\n\t\t} finally {\n\t\t\tthis.#released();\n\t\t}\n\t}\n\t/** Destroys the connection. A statement still running on it, buffered or a stream its caller abandoned, is interrupted first, and the connection destroyed once it has ended; see {@link interruptStatement}. */\n\tasync destroy(_reason) {\n\t\tif (this.held.running > 0) {\n\t\t\tconst stream = this.held.stream;\n\t\t\tconst ended = Promise.all([...stream === void 0 ? [] : [dropRest(stream).catch(ignoreAfterStop)], ...this.held.statements]);\n\t\t\tawait this.endStatement(this.client, ended);\n\t\t}\n\t\tthis.client.destroy();\n\t\tthis.#released();\n\t}\n};\nvar MysqlTransactionImpl = class extends MysqlHeldQueryable {\n\tasync commit() {\n\t\tawait this.underLock(() => this.client.commit());\n\t}\n\tasync rollback() {\n\t\tawait this.underLock(() => this.client.rollback());\n\t}\n};\n/** How many clients the driver has handed out and not had back, a held connection or one lent to a single statement, so `close()` can wait until every one is back. */\nvar ClientsInUse = class {\n\t#count = 0;\n\t#idle = [];\n\tacquired() {\n\t\tthis.#count += 1;\n\t}\n\treleased() {\n\t\tthis.#count -= 1;\n\t\tif (this.#count === 0) for (const resolve of this.#idle.splice(0)) resolve();\n\t}\n\tnone() {\n\t\treturn this.#count === 0 ? Promise.resolve() : new Promise((resolve) => this.#idle.push(resolve));\n\t}\n};\n/** The pool reports a connection it failed to open on its `'error'` event, and again as the cause of a `getConnection` that times out; the driver reports it there. */\nfunction ignoreConnectionFailure() {}\n/**\n* The statements waiting for a connection from the pool. The pool keeps retrying a connection it cannot open, with a growing pause between attempts, and fails a waiting `getConnection` only when `connectionTimeoutMillis` ends; the package reports each failure to its `logger.error` as it happens, together with every failed statement. `pg.Pool` instead rejects a pending connect whose connection fails, at once. So the driver fails the waiting statements at once with a failure no retry can get past. It keeps no failure: a later statement waits for the pool's next attempt.\n*/\nvar WaitingForConnection = class {\n\t#fail = /* @__PURE__ */ new Set();\n\tasync race(getting) {\n\t\tlet fail = () => {};\n\t\tconst failed = new Promise((_, reject) => {\n\t\t\tfail = reject;\n\t\t});\n\t\tthis.#fail.add(fail);\n\t\ttry {\n\t\t\treturn await Promise.race([getting, failed]);\n\t\t} finally {\n\t\t\tthis.#fail.delete(fail);\n\t\t}\n\t}\n\t/** Reacts to an error the package reports: only a failure to connect, which the package marks fatal, that no retry can get past. A statement can fail with the same error number, such as 1524 for a missing authentication plugin, but not fatally. */\n\treported(error) {\n\t\tif (!isFatal(error) || !connectingCannotSucceed(error)) return;\n\t\tfor (const fail of this.#fail) fail(error);\n\t\tthis.#fail.clear();\n\t}\n};\n/** Gives a connection the pool hands over after its statement stopped waiting back to the pool. */\nfunction releaseLate(getting) {\n\tgetting.then((late) => late.release(), ignoreConnectionFailure).catch(ignoreConnectionFailure);\n}\n/**\n* The MySQL runtime driver: a `mariadb` pool. Every statement takes one round trip over the text protocol, the package writing its values into it. A query reads its whole result before the first row unless `stream` is set. The pool runs the session setup once on each physical connection, and the driver then sets the target's session settings on it; a connection goes back to the pool after each statement as it is; a broken connection is destroyed. `close()` waits for every connection and stream it has handed out before it ends the pool.\n*/\nvar MysqlDriver = class extends MysqlQueryable {\n\tfamilyId = \"sql\";\n\ttargetId = \"mysql\";\n\tholdsClient = false;\n\t#state = { kind: \"unbound\" };\n\t/** The options of the short-lived connection that interrupts a statement, and how long to wait for an interrupted statement to end: as long as a connection may take to open, or the default when `connectionTimeoutMillis` is 0, which the package reads as no limit. Set by `connect()` and kept through `close()`, which waits for statements still ending. */\n\t#interrupt;\n\t#inUse = new ClientsInUse();\n\t#options;\n\t#sessionSettings;\n\tconstructor(options = {}) {\n\t\tsuper(options.stream ?? false);\n\t\tthis.#options = options;\n\t\tthis.#sessionSettings = new SessionSettingsGuard(options.sessionSettings ?? {});\n\t}\n\tget state() {\n\t\treturn this.#state.kind;\n\t}\n\tasync connect(binding) {\n\t\tif (this.#state.kind === \"connected\") throw errorRuntime(\"DRIVER.ALREADY_CONNECTED\", \"MySQL driver already connected\", { fix: \"Call close() before connecting again.\" });\n\t\tconst waiting = new WaitingForConnection();\n\t\tconst pool = createPool({\n\t\t\t...mysqlPoolOptions(binding.url, this.#options.poolOptions),\n\t\t\tlogger: { error: (error) => waiting.reported(error) }\n\t\t});\n\t\tif (pool instanceof EventEmitter) pool.on(\"error\", ignoreConnectionFailure);\n\t\tconst connectionTimeout = this.#options.poolOptions?.connectionTimeoutMillis;\n\t\tconst interruptTimeoutMs = connectionTimeout !== void 0 && connectionTimeout > 0 ? connectionTimeout : DEFAULT_CONNECT_TIMEOUT_MILLIS;\n\t\tthis.#interrupt = {\n\t\t\toptions: mysqlConnectionOptions(binding.url, { connectTimeoutMs: interruptTimeoutMs }),\n\t\t\twaitMs: interruptTimeoutMs\n\t\t};\n\t\tthis.#state = {\n\t\t\tkind: \"connected\",\n\t\t\tpool,\n\t\t\twaiting\n\t\t};\n\t}\n\t/** See {@link EndStatement}. When the `KILL` cannot be sent at all, there is no wait: the client is destroyed at once, and the package interrupts the statement itself. */\n\tasync endStatement(client, ended) {\n\t\tconst settled = ended.then(settledEither, settledEither);\n\t\tconst interrupt = this.#interrupt;\n\t\tif (interrupt === void 0 || client.threadId === null) return;\n\t\tif (await interruptStatement(interrupt.options, client.threadId)) await settledWithin(settled, interrupt.waitMs);\n\t}\n\tasync acquireConnection() {\n\t\treturn new MysqlConnectionImpl(await this.acquireClient(), this.streams, (held, ended) => this.endStatement(held, ended), () => this.#inUse.released());\n\t}\n\tasync close() {\n\t\tif (this.#state.kind !== \"connected\") return;\n\t\tconst { pool } = this.#state;\n\t\tthis.#state = { kind: \"closed\" };\n\t\tawait this.#inUse.none();\n\t\tawait pool.end();\n\t}\n\tasync acquireClient() {\n\t\tif (this.#state.kind !== \"connected\") throw notConnected(this.#state.kind === \"closed\" ? \"MySQL driver is closed\" : \"MySQL driver not connected\");\n\t\tconst { pool, waiting } = this.#state;\n\t\tthis.#inUse.acquired();\n\t\tconst getting = pool.getConnection();\n\t\tlet client;\n\t\ttry {\n\t\t\tclient = await waiting.race(getting);\n\t\t} catch (error) {\n\t\t\treleaseLate(getting);\n\t\t\tthis.#inUse.released();\n\t\t\tthrow normalizeMysqlError(error);\n\t\t}\n\t\ttry {\n\t\t\tawait this.#sessionSettings.ensure(client);\n\t\t} catch (error) {\n\t\t\tclient.destroy();\n\t\t\tthis.#inUse.released();\n\t\t\tthrow normalizeMysqlError(error);\n\t\t}\n\t\treturn client;\n\t}\n\tasync releaseClient(client, { destroy }) {\n\t\ttry {\n\t\t\tif (destroy) client.destroy();\n\t\t\telse await client.release();\n\t\t} finally {\n\t\t\tthis.#inUse.released();\n\t\t}\n\t}\n};\n//#endregion\n//#region src/core/runtime/runtime-driver.ts\nconst mysqlRuntimeDriverDescriptor = {\n\t...mysqlDriverDescriptorMeta,\n\tcreate(options, sessionSettings) {\n\t\treturn new MysqlDriver({\n\t\t\t...options,\n\t\t\t...ifDefined(\"sessionSettings\", sessionSettings)\n\t\t});\n\t}\n};\n//#endregion\nexport { mysqlRuntimeDriverDescriptor as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;AAQA,SAAS,aAAa,SAAS;CAC9B,OAAO,aAAa,wBAAwB,SAAS,EAAE,KAAK,yFAAyF,CAAC;AACvJ;;AAEA,eAAe,IAAI,QAAQ,SAAS;CACnC,MAAM,EAAE,KAAK,WAAW,aAAa,QAAQ,QAAQ,KAAK,QAAQ,UAAU,CAAC,CAAC;CAC9E,OAAO,OAAO,MAAM,KAAK,MAAM;AAChC;;AAEA,SAAS,YAAY,QAAQ,SAAS,SAAS;CAC9C,IAAI;EACH,MAAM,EAAE,KAAK,WAAW,aAAa,QAAQ,QAAQ,KAAK,QAAQ,UAAU,CAAC,CAAC;EAC9E,OAAO,OAAO,YAAY,KAAK,MAAM;CACtC,SAAS,OAAO;EACf,MAAM,OAAO,OAAO,OA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,IAAI,oBAAoB,MAAM,KAAK,cAAc,GAAG,KAAK,UAAU,MAAM,UAAU,KAAK,aAAa,MAAM,KAAK,SAAS,KAAKC,OAAO,SAAS,CAAC;CACvJ;CACA,MAAM,QAAQ;EACb,IAAI,KAAKF,OAAO,SAAS,aAAa;EACtC,MAAM,EAAE,SAAS,KAAKA;EACtB,KAAKA,SAAS,EAAE,MAAM,SAAS;EAC/B,MAAM,KAAKE,OAAO,KAAK;EACvB,MAAM,KAAK,IAAI;CAChB;CACA,MAAM,gBAAgB;EACrB,IAAI,KAAKF,OAAO,SAAS,aAAa,MAAM,aAAa,KAAKA,OAAO,SAAS,WAAW,2BAA2B,4BAA4B;EAChJ,MAAM,EAAE,MAAM,YAAY,KAAKA;EAC/B,KAAKE,OAAO,SAAS;EACrB,MAAM,UAAU,KAAK,cAAc;EACnC,IAAI;EACJ,IAAI;GACH,SAAS,MAAM,QAAQ,KAAK,OAAO;EACpC,SAAS,OAAO;GACf,YAAY,OAAO;GACnB,KAAKA,OAAO,SAAS;GACrB,MAAM,oBAAoB,KAAK;EAChC;EACA,IAAI;GACH,MAAM,KAAKH,iBAAiB,OAAO,MAAM;EAC1C,SAAS,OAAO;GACf,OAAO,QAAQ;GACf,KAAKG,OAAO,SAAS;GACrB,MAAM,oBAAoB,KAAK;EAChC;EACA,OAAO;CACR;CACA,MAAM,cAAc,QAAQ,EAAE,WAAW;EACxC,IAAI;GACH,IAAI,SAAS,OAAO,QAAQ;QACvB,MAAM,OAAO,QAAQ;EAC3B,UAAU;GACT,KAAKA,OAAO,SAAS;EACtB;CACD;AACD;AAGA,MAAM,+BAA+B;CACpC,GAAG;CACH,OAAO,SAAS,iBAAiB;EAChC,OAAO,IAAI,YAAY;GACtB,GAAG;GACH,GAAG,UAAU,mBAAmB,eAAe;EAChD,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"driver__runtime.mjs","names":["#url","#idleTimeoutMillis","#closed","#idleTimer","#connection","#open","#setAside","#pending","#pendingOn","#idleLater","#streamRows","#runReleasing","#stopEarly","#refuseIfUnusable","#onRelease","#cancelRunning","#runningSettled","#close","#released","#count","#idle","#fail","#canceller","#options","#sessionSettings","#state","#inUse"],"sources":["../../../../3-targets/mysql/3-driver/dist/runtime.mjs"],"sourcesContent":["import { a as connectingCannotSucceed, c as isFatal, d as mysqlConnectionOptions, f as mysqlPoolIdleTimeoutMillis, l as normalizeMysqlError, m as acquireClientQueryLock, n as SessionSettingsGuard, p as mysqlPoolOptions, t as statementFor, u as mysqlDriverDescriptorMeta } from \"./statement-DC62oiSx.mjs\";\nimport { errorRuntime } from \"@internal/errors/execution\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { createConnection, createPool } from \"mariadb\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { EventEmitter } from \"node:events\";\nimport { finished } from \"node:stream/promises\";\n//#region src/core/runtime/canceller.ts\n/** How long the canceller waits to open its connection, and for MySQL to answer a `KILL QUERY`. */\nconst CANCEL_TIMEOUT_MILLIS = 2e3;\nfunction timeout(millis) {\n\tlet timer;\n\treturn {\n\t\texpired: new Promise((resolve) => {\n\t\t\ttimer = setTimeout(() => resolve(\"expired\"), millis);\n\t\t}),\n\t\tclear: () => clearTimeout(timer)\n\t};\n}\n/**\n* Cancels statements with `KILL QUERY`, which MySQL takes only from another connection. It keeps one connection of its own, outside the pool, so a cancel neither waits for a pooled connection nor normally opens one; it opens it on first need, and ends it once it has been idle for the pool's idle timeout, as the pool ends its own; with a timeout of 0 it keeps it open, as the pool keeps its own. Opening it and each `KILL QUERY` are bounded by two seconds. The connection is never destroyed: the package's `destroy()` sends a `KILL` of its own whose failure it does not handle (`mariadb` 3.5.4). A connection that stops answering is set aside and ended with `end()` once its statement settles.\n*/\nvar Canceller = class {\n\t#url;\n\t#idleTimeoutMillis;\n\t#connection;\n\t#pending = /* @__PURE__ */ new WeakMap();\n\t#closed = false;\n\t#idleTimer;\n\tconstructor(url, idleTimeoutMillis) {\n\t\tthis.#url = url;\n\t\tthis.#idleTimeoutMillis = idleTimeoutMillis;\n\t}\n\t/** Sends `KILL QUERY` for `threadId`. Never rejects. A kept connection that is no longer valid is replaced once. */\n\tasync cancel(threadId, replaced = false) {\n\t\tif (this.#closed || threadId === null) return \"unsent\";\n\t\tclearTimeout(this.#idleTimer);\n\t\tconst opening = this.#connection ?? this.#open();\n\t\tthis.#connection = opening;\n\t\tconst connection = await opening;\n\t\tif (connection === void 0) {\n\t\t\tthis.#setAside(opening);\n\t\t\treturn \"unsent\";\n\t\t}\n\t\tif (!connection.isValid()) {\n\t\t\tthis.#setAside(opening);\n\t\t\treturn replaced ? \"unsent\" : this.cancel(threadId, true);\n\t\t}\n\t\tthis.#pending.set(connection, this.#pendingOn(connection) + 1);\n\t\tconst killing = connection.query(\"KILL QUERY ?\", [threadId]).then(() => \"sent\", (error) => isFatal(error) ? \"unconfirmed\" : \"unsent\");\n\t\tkilling.then(() => {\n\t\t\tthis.#pending.set(connection, this.#pendingOn(connection) - 1);\n\t\t\tthis.#idleLater(opening, connection);\n\t\t});\n\t\tconst limit = timeout(CANCEL_TIMEOUT_MILLIS);\n\t\tconst result = await Promise.race([killing, limit.expired]);\n\t\tlimit.clear();\n\t\tif (result === \"sent\" || result === \"unsent\") return result;\n\t\tthis.#setAside(opening);\n\t\tconnection.end().catch(() => void 0);\n\t\treturn \"unconfirmed\";\n\t}\n\t/** Ends the connection: `end()` sends `QUIT` once any `KILL QUERY` on it settles. Waits for that only when no `KILL QUERY` is pending on it, so a connection that stopped answering cannot hold `close()` up. */\n\tasync close() {\n\t\tthis.#closed = true;\n\t\tclearTimeout(this.#idleTimer);\n\t\tconst connection = await this.#connection;\n\t\tthis.#connection = void 0;\n\t\tif (connection === void 0) return;\n\t\tconst ending = connection.end().catch(() => void 0);\n\t\tif (this.#pendingOn(connection) === 0) await ending;\n\t}\n\t#idleLater(opening, connection) {\n\t\tif (this.#idleTimeoutMillis === 0 || this.#pendingOn(connection) > 0 || this.#connection !== opening) return;\n\t\tclearTimeout(this.#idleTimer);\n\t\tthis.#idleTimer = setTimeout(() => {\n\t\t\tif (this.#pendingOn(connection) > 0 || this.#connection !== opening) return;\n\t\t\tthis.#connection = void 0;\n\t\t\tconnection.end().catch(() => void 0);\n\t\t}, this.#idleTimeoutMillis);\n\t\tthis.#idleTimer.unref();\n\t}\n\t#pendingOn(connection) {\n\t\treturn this.#pending.get(connection) ?? 0;\n\t}\n\t#setAside(opening) {\n\t\tif (this.#connection === opening) this.#connection = void 0;\n\t}\n\tasync #open() {\n\t\ttry {\n\t\t\tconst connection = await createConnection(mysqlConnectionOptions(this.#url, { connectTimeoutMs: CANCEL_TIMEOUT_MILLIS }));\n\t\t\tconnection.on(\"error\", () => void 0);\n\t\t\tif (this.#closed) {\n\t\t\t\tawait connection.end().catch(() => void 0);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\treturn connection;\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t}\n};\n//#endregion\n//#region src/core/runtime/mysql-driver.ts\nfunction notConnected(message) {\n\treturn errorRuntime(\"DRIVER.NOT_CONNECTED\", message, { fix: \"Call connect(binding) before running queries, and do not use the driver after close().\" });\n}\n/** Runs `request` on `client` in one round trip and returns its result: its `?N` placeholders written as `?`, and its values handed to the package, which writes them into the statement. Throws the package's error as it is. */\nasync function run(client, request) {\n\tconst { sql, values } = statementFor(client, request.sql, request.params ?? []);\n\treturn client.query(sql, values);\n}\n/** Starts streaming the rows of `request` on `client`, sent as {@link run} sends it. Throws the error to report, after noting in `outcome` whether it left the client unusable. */\nfunction startStream(client, request, outcome) {\n\ttry {\n\t\tconst { sql, values } = statementFor(client, request.sql, request.params ?? []);\n\t\treturn client.queryStream(sql, values);\n\t} catch (error) {\n\t\tthrow settle(error, outcome);\n\t}\n}\n/** What a statement's result reports: the rows it changed, and, when it changed one row, the value MySQL numbered for it. MySQL reports 0 when it numbered none. */\nfunction statementStats(result) {\n\tif (typeof result !== \"object\" || result === null) return { affectedRows: 0 };\n\tconst affectedRows = \"affectedRows\" in result && typeof result.affectedRows === \"number\" ? result.affectedRows : 0;\n\tconst insertId = \"insertId\" in result ? result.insertId : void 0;\n\treturn affectedRows === 1 && (typeof insertId === \"bigint\" || typeof insertId === \"number\") && insertId > 0 ? {\n\t\taffectedRows,\n\t\tinsertId: String(insertId)\n\t} : { affectedRows };\n}\n/** The error to report for `error`, after noting in `outcome` whether it left the client unusable. */\nfunction settle(error, outcome) {\n\tif (isFatal(error)) outcome.destroy = true;\n\treturn normalizeMysqlError(error);\n}\n/**\n* Whether the package has received the end of the result, so that any rows the caller has not read are already in the stream's buffer. The package pushes the end of the stream when MySQL's last packet arrives; Node records that in `_readableState.ended`, and its public API reports the end only after the caller has read every row.\n*/\nfunction resultReceived(rows) {\n\tconst state = Reflect.get(rows, \"_readableState\");\n\treturn typeof state === \"object\" && state !== null && \"ended\" in state && state.ended === true;\n}\n/**\n* Reads and drops what is left of a stream's result. The package's `close()` stops it keeping new rows; the rows already buffered are read here with `read()`, which works whether or not the caller's iterator is still attached to the stream, so an iterator the caller abandoned cannot hold the drain up.\n*/\nasync function dropRest(rows) {\n\trows.close?.();\n\tconst drain = () => {\n\t\twhile (rows.read() !== null);\n\t};\n\trows.on(\"readable\", drain);\n\ttry {\n\t\tdrain();\n\t\tawait finished(rows);\n\t} finally {\n\t\trows.off(\"readable\", drain);\n\t}\n}\nfunction cancelNotConfirmed() {\n\treturn errorRuntime(\"DRIVER.NOT_CONNECTED\", \"A cancel on this MySQL connection could not be confirmed, so the connection can no longer be used\", {\n\t\twhy: \"The driver cancelled a stream the caller stopped early, and MySQL did not answer the KILL QUERY in time. It may still arrive and would interrupt whatever statement the connection runs then.\",\n\t\tfix: \"Release the connection, which closes it; MySQL rolls back an open transaction on it. Acquire another connection and run the work again.\"\n\t});\n}\nfunction connectionReleased() {\n\treturn errorRuntime(\"DRIVER.NOT_CONNECTED\", \"MySQL connection was released\", { fix: \"Send statements on a connection only until you release it, and await each one before release().\" });\n}\n/** The package can report an error on a stream after the caller stopped reading it, such as MySQL's for a statement the driver cancelled; the generator has already settled by then. */\nfunction ignoreAfterStop() {}\n/** MySQL's error for a statement `KILL QUERY` cancelled (`ER_QUERY_INTERRUPTED`). The package marks it fatal when it arrives in the middle of a result, but the connection stays usable. */\nfunction isQueryInterrupted(error) {\n\treturn error instanceof Error && \"errno\" in error && error.errno === 1317;\n}\nvar MysqlQueryable = class {\n\tstreams;\n\tconstructor(streams) {\n\t\tthis.streams = streams;\n\t}\n\t/** Records a stream that is open, and returns the call that records its end. */\n\tstreamOpened(_rows) {\n\t\treturn () => {};\n\t}\n\t/** Takes the client's lock, which keeps statements on it one at a time in the order sent. */\n\tlockClient(client) {\n\t\treturn acquireClientQueryLock(client);\n\t}\n\t/** Runs one statement that is not a stream, under the client's lock. */\n\trunStatement(work) {\n\t\treturn work();\n\t}\n\t/** Whether the client went back to the pool under this queryable, so it must send nothing more on it. */\n\tget handedBack() {\n\t\treturn false;\n\t}\n\tasync *query(request) {\n\t\tif (this.streams) {\n\t\t\tyield* this.#streamRows(request);\n\t\t\treturn;\n\t\t}\n\t\tconst result = await this.#runReleasing(request);\n\t\tfor (const row of Array.isArray(result) ? result : []) yield blindCast(row);\n\t}\n\tasync execute(request) {\n\t\treturn statementStats(await this.#runReleasing(request));\n\t}\n\tasync #runReleasing(request) {\n\t\tconst client = await this.acquireClient();\n\t\tconst outcome = { destroy: false };\n\t\ttry {\n\t\t\tconst releaseLock = await this.lockClient(client);\n\t\t\ttry {\n\t\t\t\treturn await this.runStatement(() => run(client, request));\n\t\t\t} finally {\n\t\t\t\treleaseLock();\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tthrow settle(error, outcome);\n\t\t} finally {\n\t\t\tawait this.releaseClient(client, outcome);\n\t\t}\n\t}\n\t/**\n\t* Streams the rows of `request` as they arrive; the package pauses the socket while the caller is busy. A caller that stops reading early is handled by {@link MysqlQueryable.#stopEarly}. A fatal error, such as a lost connection, destroys the client.\n\t*/\n\tasync *#streamRows(request) {\n\t\tconst client = await this.acquireClient();\n\t\tconst outcome = { destroy: false };\n\t\tlet releaseLock;\n\t\ttry {\n\t\t\treleaseLock = await this.lockClient(client);\n\t\t} catch (error) {\n\t\t\tawait this.releaseClient(client, outcome);\n\t\t\tthrow error;\n\t\t}\n\t\ttry {\n\t\t\tconst rows = startStream(client, request, outcome);\n\t\t\trows.on(\"error\", ignoreAfterStop);\n\t\t\tconst streamClosed = this.streamOpened(rows);\n\t\t\tlet settled = false;\n\t\t\ttry {\n\t\t\t\tfor await (const row of rows.iterator({ destroyOnReturn: false })) yield blindCast(row);\n\t\t\t\tsettled = true;\n\t\t\t} catch (error) {\n\t\t\t\tsettled = true;\n\t\t\t\tthrow settle(error, outcome);\n\t\t\t} finally {\n\t\t\t\tif (!settled && !this.handedBack) await this.#stopEarly(client, rows, outcome);\n\t\t\t\tif (outcome.destroy) rows.destroy();\n\t\t\t\tstreamClosed();\n\t\t\t}\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t\tawait this.releaseClient(client, outcome);\n\t\t}\n\t}\n\t/**\n\t* Ends a stream the caller stopped reading early, and keeps the client usable. While its result is still arriving, the statement is first cancelled with `KILL QUERY`, so a large result is not downloaded only to be thrown away; MySQL does not say how many rows remain. On a held connection or in a transaction, as on a pooled one: `KILL QUERY` ends only the statement, the session survives, and in a transaction MySQL rolls back only that statement. The rest of the result is then read and dropped, MySQL's error for the cancelled statement among it. The client is never destroyed while its statement runs: the package's `destroy()` would send `KILL` itself, on a connection whose failure it does not handle.\n\t*/\n\tasync #stopEarly(client, rows, outcome) {\n\t\tconst cancel = resultReceived(rows) ? \"unsent\" : await this.cancelStatement(client.threadId);\n\t\tawait dropRest(rows).catch((error) => {\n\t\t\tif (isFatal(error) && !(cancel !== \"unsent\" && isQueryInterrupted(error))) outcome.destroy = true;\n\t\t});\n\t\tif (cancel === \"unconfirmed\") this.cancelUnconfirmed(outcome);\n\t}\n\t/**\n\t* A cancel that went out without an answer may still reach MySQL and interrupt the next statement on the client, so the client must not serve another caller. Once its rest has been read, nothing is receiving on it, so closing it sends no `KILL` of the package's own; a late `KILL QUERY` then finds no thread.\n\t*/\n\tcancelUnconfirmed(outcome) {\n\t\toutcome.destroy = true;\n\t}\n};\nfunction handedBackState() {\n\tlet refuse = () => {};\n\tconst signal = new Promise((_, reject) => {\n\t\trefuse = () => reject(connectionReleased());\n\t});\n\tsignal.catch(() => void 0);\n\tconst state = {\n\t\tdone: false,\n\t\tsignal,\n\t\trefuse: () => {\n\t\t\tstate.done = true;\n\t\t\trefuse();\n\t\t}\n\t};\n\treturn state;\n}\n/**\n* A queryable on a connection the caller holds, whose statements all run on the same session, in the order they are sent, under the client's lock. A statement sent while a stream on the connection is open waits for that stream to end; one awaited inside the stream's own loop never finishes, as on Postgres with a cursor.\n*/\nvar MysqlHeldQueryable = class extends MysqlQueryable {\n\tclient;\n\theld;\n\tholdsClient = true;\n\tget cancelStatement() {\n\t\treturn this.held.cancel;\n\t}\n\tstreamOpened(rows) {\n\t\tthis.held.streams.add(rows);\n\t\treturn () => this.held.streams.delete(rows);\n\t}\n\tget handedBack() {\n\t\treturn this.held.handedBack.done;\n\t}\n\tcancelUnconfirmed() {\n\t\tthis.held.cancelUnconfirmed = true;\n\t}\n\t/** Takes the client's lock, or fails once the connection is handed back, whether the statement was sent after that or was still waiting for the lock. A lock taken after that is given straight back. */\n\tasync lockClient(client) {\n\t\tthis.#refuseIfUnusable();\n\t\tconst locking = acquireClientQueryLock(client);\n\t\ttry {\n\t\t\tconst releaseLock = await Promise.race([locking, this.held.handedBack.signal]);\n\t\t\tif (!this.held.handedBack.done && !this.held.cancelUnconfirmed) return releaseLock;\n\t\t\treleaseLock();\n\t\t} catch {\n\t\t\tlocking.then((releaseLock) => releaseLock());\n\t\t}\n\t\tthis.#refuseIfUnusable();\n\t\tthrow connectionReleased();\n\t}\n\t/** Refuses a statement on a connection that was handed back, or whose cancel went out without an answer: a late `KILL QUERY` would interrupt it. */\n\t#refuseIfUnusable() {\n\t\tif (this.held.handedBack.done) throw connectionReleased();\n\t\tif (this.held.cancelUnconfirmed) throw cancelNotConfirmed();\n\t}\n\trunStatement(work) {\n\t\tconst running = work();\n\t\tthis.held.running.add(running);\n\t\trunning.then(() => this.held.running.delete(running), () => this.held.running.delete(running));\n\t\treturn running;\n\t}\n\tconstructor(client, held, streams) {\n\t\tsuper(streams);\n\t\tthis.client = client;\n\t\tthis.held = held;\n\t}\n\tasync acquireClient() {\n\t\tthis.#refuseIfUnusable();\n\t\treturn this.client;\n\t}\n\tasync releaseClient() {}\n\t/** Runs one of the package's transaction calls under the client's lock, taken as a statement takes it, so it keeps its place among the statements sent. */\n\tasync underLock(call) {\n\t\tconst client = await this.acquireClient();\n\t\tconst releaseLock = await this.lockClient(client);\n\t\ttry {\n\t\t\tawait this.runStatement(call);\n\t\t} catch (error) {\n\t\t\tthrow normalizeMysqlError(error);\n\t\t} finally {\n\t\t\treleaseLock();\n\t\t}\n\t}\n};\nvar MysqlConnectionImpl = class extends MysqlHeldQueryable {\n\t#onRelease;\n\tconstructor(client, streams, cancel, onRelease) {\n\t\tsuper(client, {\n\t\t\tstreams: /* @__PURE__ */ new Set(),\n\t\t\tcancelUnconfirmed: false,\n\t\t\trunning: /* @__PURE__ */ new Set(),\n\t\t\tcancel,\n\t\t\thandedBack: handedBackState()\n\t\t}, streams);\n\t\tthis.#onRelease = onRelease;\n\t}\n\t#released() {\n\t\tconst onRelease = this.#onRelease;\n\t\tthis.#onRelease = void 0;\n\t\tonRelease?.();\n\t}\n\tasync beginTransaction() {\n\t\tawait this.underLock(() => this.client.beginTransaction());\n\t\treturn new MysqlTransactionImpl(this.client, this.held, this.streams);\n\t}\n\t/**\n\t* Returns the connection to the pool, as the Postgres driver's `release()` does. From then on the connection refuses every statement, those still waiting for its lock included, so none runs later in another caller's session. A statement that is not a stream and is already running finishes, as on Postgres. A stream still open, such as one the caller dropped, is cancelled and read to its end by the driver: the package's release sends `ROLLBACK` behind that statement and waits for it, which would otherwise never finish, where `pg`'s release does not wait on the server.\n\t*/\n\tasync release() {\n\t\tif (this.held.handedBack.done) return;\n\t\tthis.held.handedBack.refuse();\n\t\ttry {\n\t\t\tif (this.held.streams.size > 0) await this.#cancelRunning();\n\t\t\tawait this.#runningSettled();\n\t\t\tif (this.held.cancelUnconfirmed) await this.#close();\n\t\t\telse await this.client.release();\n\t\t} finally {\n\t\t\tthis.#released();\n\t\t}\n\t}\n\t/** Closes the connection instead of returning it. It refuses every statement from then on, cancels whatever still runs and waits for it to end, so the package's `destroy()` never sends a `KILL` of its own. */\n\tasync destroy(_reason) {\n\t\tif (this.held.handedBack.done) return;\n\t\tthis.held.handedBack.refuse();\n\t\ttry {\n\t\t\tif (this.held.streams.size > 0 || this.held.running.size > 0) await this.#cancelRunning();\n\t\t\tawait this.#runningSettled();\n\t\t\tawait this.#close();\n\t\t} finally {\n\t\t\tthis.#released();\n\t\t}\n\t}\n\t/** Closes the client once the `ping` queued behind anything left on it has answered, so nothing is receiving and the package's `destroy()` sends no `KILL` of its own. */\n\tasync #close() {\n\t\tawait this.client.ping().catch(() => void 0);\n\t\tthis.client.destroy();\n\t}\n\tasync #cancelRunning() {\n\t\tif (await this.held.cancel(this.client.threadId) === \"unconfirmed\") this.held.cancelUnconfirmed = true;\n\t\tawait Promise.all([...this.held.streams].map((rows) => dropRest(rows).catch(() => void 0)));\n\t}\n\tasync #runningSettled() {\n\t\tawait Promise.allSettled([...this.held.running]);\n\t}\n};\nvar MysqlTransactionImpl = class extends MysqlHeldQueryable {\n\tasync commit() {\n\t\tawait this.underLock(() => this.client.commit());\n\t}\n\tasync rollback() {\n\t\tawait this.underLock(() => this.client.rollback());\n\t}\n};\n/** How many clients the driver has handed out and not had back, a held connection or one lent to a single statement, so `close()` can wait until every one is back. */\nvar ClientsInUse = class {\n\t#count = 0;\n\t#idle = [];\n\tacquired() {\n\t\tthis.#count += 1;\n\t}\n\treleased() {\n\t\tthis.#count -= 1;\n\t\tif (this.#count === 0) for (const resolve of this.#idle.splice(0)) resolve();\n\t}\n\tnone() {\n\t\treturn this.#count === 0 ? Promise.resolve() : new Promise((resolve) => this.#idle.push(resolve));\n\t}\n};\n/** The pool reports a connection it failed to open on its `'error'` event, and again as the cause of a `getConnection` that times out; the driver reports it there. */\nfunction ignoreConnectionFailure() {}\n/**\n* The statements waiting for a connection from the pool. The pool keeps retrying a connection it cannot open, with a growing pause between attempts, and fails a waiting `getConnection` only when `connectionTimeoutMillis` ends; the package reports each failure to its `logger.error` as it happens, together with every failed statement. `pg.Pool` instead rejects a pending connect whose connection fails, at once. So the driver fails the waiting statements at once with a failure no retry can get past. It keeps no failure: a later statement waits for the pool's next attempt.\n*/\nvar WaitingForConnection = class {\n\t#fail = /* @__PURE__ */ new Set();\n\tasync race(getting) {\n\t\tlet fail = () => {};\n\t\tconst failed = new Promise((_, reject) => {\n\t\t\tfail = reject;\n\t\t});\n\t\tthis.#fail.add(fail);\n\t\ttry {\n\t\t\treturn await Promise.race([getting, failed]);\n\t\t} finally {\n\t\t\tthis.#fail.delete(fail);\n\t\t}\n\t}\n\t/** Reacts to an error the package reports: only a failure to connect, which the package marks fatal, that no retry can get past. A statement can fail with the same error number, such as 1524 for a missing authentication plugin, but not fatally. */\n\treported(error) {\n\t\tif (!isFatal(error) || !connectingCannotSucceed(error)) return;\n\t\tfor (const fail of this.#fail) fail(error);\n\t\tthis.#fail.clear();\n\t}\n};\n/** Gives a connection the pool hands over after its statement stopped waiting back to the pool. */\nfunction releaseLate(getting) {\n\tgetting.then((late) => late.release(), ignoreConnectionFailure).catch(ignoreConnectionFailure);\n}\n/**\n* The MySQL runtime driver: a `mariadb` pool. Every statement takes one round trip over the text protocol, the package writing its values into it. A query reads its whole result before the first row unless `stream` is set. The pool runs the session setup once on each physical connection, and the driver then sets the target's session settings on it; a connection goes back to the pool after each statement as it is; a broken connection is destroyed. `close()` waits for every connection and stream it has handed out before it ends the pool.\n*/\nvar MysqlDriver = class extends MysqlQueryable {\n\tfamilyId = \"sql\";\n\ttargetId = \"mysql\";\n\tholdsClient = false;\n\t#state = { kind: \"unbound\" };\n\t#inUse = new ClientsInUse();\n\t#canceller;\n\tcancelStatement = (threadId) => this.#canceller?.cancel(threadId) ?? Promise.resolve(\"unsent\");\n\t#options;\n\t#sessionSettings;\n\tconstructor(options = {}) {\n\t\tsuper(options.stream ?? false);\n\t\tthis.#options = options;\n\t\tthis.#sessionSettings = new SessionSettingsGuard(options.sessionSettings ?? {});\n\t}\n\tget state() {\n\t\treturn this.#state.kind;\n\t}\n\tasync connect(binding) {\n\t\tif (this.#state.kind === \"connected\") throw errorRuntime(\"DRIVER.ALREADY_CONNECTED\", \"MySQL driver already connected\", { fix: \"Call close() before connecting again.\" });\n\t\tconst waiting = new WaitingForConnection();\n\t\tconst pool = createPool({\n\t\t\t...mysqlPoolOptions(binding.url, this.#options.poolOptions),\n\t\t\tlogger: { error: (error) => waiting.reported(error) }\n\t\t});\n\t\tif (pool instanceof EventEmitter) pool.on(\"error\", ignoreConnectionFailure);\n\t\tthis.#state = {\n\t\t\tkind: \"connected\",\n\t\t\tpool,\n\t\t\twaiting\n\t\t};\n\t\tthis.#canceller = new Canceller(binding.url, mysqlPoolIdleTimeoutMillis(this.#options.poolOptions));\n\t}\n\tasync acquireConnection() {\n\t\treturn new MysqlConnectionImpl(await this.acquireClient(), this.streams, this.cancelStatement, () => this.#inUse.released());\n\t}\n\tasync close() {\n\t\tif (this.#state.kind !== \"connected\") return;\n\t\tconst { pool } = this.#state;\n\t\tthis.#state = { kind: \"closed\" };\n\t\tawait this.#inUse.none();\n\t\tawait this.#canceller?.close();\n\t\tthis.#canceller = void 0;\n\t\tawait pool.end();\n\t}\n\tasync acquireClient() {\n\t\tif (this.#state.kind !== \"connected\") throw notConnected(this.#state.kind === \"closed\" ? \"MySQL driver is closed\" : \"MySQL driver not connected\");\n\t\tconst { pool, waiting } = this.#state;\n\t\tthis.#inUse.acquired();\n\t\tconst getting = pool.getConnection();\n\t\tlet client;\n\t\ttry {\n\t\t\tclient = await waiting.race(getting);\n\t\t} catch (error) {\n\t\t\treleaseLate(getting);\n\t\t\tthis.#inUse.released();\n\t\t\tthrow normalizeMysqlError(error);\n\t\t}\n\t\ttry {\n\t\t\tawait this.#sessionSettings.ensure(client);\n\t\t} catch (error) {\n\t\t\tclient.destroy();\n\t\t\tthis.#inUse.released();\n\t\t\tthrow normalizeMysqlError(error);\n\t\t}\n\t\treturn client;\n\t}\n\t/**\n\t* Destroys a client only after an error the package marks fatal, or after a cancel that went out without an answer once the rest of its result was read (`cancelUnconfirmed`). The package marks an error fatal when the connection's socket is gone or can no longer be trusted, and it has then already set the connection closed and failed every command on it (`fatalError` in its `connection.js`), so no command is receiving and its `destroy()` sends no `KILL`. A statement the caller stopped early is cancelled and read to its end instead (`#stopEarly`).\n\t*/\n\tasync releaseClient(client, { destroy }) {\n\t\ttry {\n\t\t\tif (destroy) client.destroy();\n\t\t\telse await client.release();\n\t\t} finally {\n\t\t\tthis.#inUse.released();\n\t\t}\n\t}\n};\n//#endregion\n//#region src/core/runtime/runtime-driver.ts\nconst mysqlRuntimeDriverDescriptor = {\n\t...mysqlDriverDescriptorMeta,\n\tcreate(options, sessionSettings) {\n\t\treturn new MysqlDriver({\n\t\t\t...options,\n\t\t\t...ifDefined(\"sessionSettings\", sessionSettings)\n\t\t});\n\t}\n};\n//#endregion\nexport { mysqlRuntimeDriverDescriptor as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;AASA,MAAM,wBAAwB;AAC9B,SAAS,QAAQ,QAAQ;CACxB,IAAI;CACJ,OAAO;EACN,SAAS,IAAI,SAAS,YAAY;GACjC,QAAQ,iBAAiB,QAAQ,SAAS,GAAG,MAAM;EACpD,CAAC;EACD,aAAa,aAAa,KAAK;CAChC;AACD;;;;AAIA,IAAI,YAAY,MAAM;CACrB;CACA;CACA;CACA,2BAA2B,IAAI,QAAQ;CACvC,UAAU;CACV;CACA,YAAY,KAAK,mBAAmB;EACnC,KAAKA,OAAO;EACZ,KAAKC,q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AAM,EAAE,SAAS,KAAKA;EACtB,KAAKA,SAAS,EAAE,MAAM,SAAS;EAC/B,MAAM,KAAKC,OAAO,KAAK;EACvB,MAAM,KAAKJ,YAAY,MAAM;EAC7B,KAAKA,aAAa,KAAK;EACvB,MAAM,KAAK,IAAI;CAChB;CACA,MAAM,gBAAgB;EACrB,IAAI,KAAKG,OAAO,SAAS,aAAa,MAAM,aAAa,KAAKA,OAAO,SAAS,WAAW,2BAA2B,4BAA4B;EAChJ,MAAM,EAAE,MAAM,YAAY,KAAKA;EAC/B,KAAKC,OAAO,SAAS;EACrB,MAAM,UAAU,KAAK,cAAc;EACnC,IAAI;EACJ,IAAI;GACH,SAAS,MAAM,QAAQ,KAAK,OAAO;EACpC,SAAS,OAAO;GACf,YAAY,OAAO;GACnB,KAAKA,OAAO,SAAS;GACrB,MAAM,oBAAoB,KAAK;EAChC;EACA,IAAI;GACH,MAAM,KAAKF,iBAAiB,OAAO,MAAM;EAC1C,SAAS,OAAO;GACf,OAAO,QAAQ;GACf,KAAKE,OAAO,SAAS;GACrB,MAAM,oBAAoB,KAAK;EAChC;EACA,OAAO;CACR;;;;CAIA,MAAM,cAAc,QAAQ,EAAE,WAAW;EACxC,IAAI;GACH,IAAI,SAAS,OAAO,QAAQ;QACvB,MAAM,OAAO,QAAQ;EAC3B,UAAU;GACT,KAAKA,OAAO,SAAS;EACtB;CACD;AACD;AAGA,MAAM,+BAA+B;CACpC,GAAG;CACH,OAAO,SAAS,iBAAiB;EAChC,OAAO,IAAI,YAAY;GACtB,GAAG;GACH,GAAG,UAAU,mBAAmB,eAAe;EAChD,CAAC;CACF;AACD"}
@@ -0,0 +1,87 @@
1
+ import { structuredError } from "@prisma/orm-framework/utils/structured-error";
2
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
+ //#region ../../../3-targets/mysql/1-target/dist/errors-Cng94tYg.mjs
4
+ function mysqlError(code, message, options) {
5
+ return structuredError(code, message, options);
6
+ }
7
+ /** The refusal of a query a later slice of the MySQL target can render: `what` names the feature, as in `Lowering queries`. */
8
+ function mysqlQueryNotYetSupported(what) {
9
+ return mysqlError("RUNTIME.AST_UNSUPPORTED", `${what} is not yet supported on MySQL.`, {
10
+ why: "The MySQL target renders reads; writes and some query forms are not built yet.",
11
+ fix: "Use a Postgres or SQLite target for this query until the MySQL target supports it.",
12
+ meta: {
13
+ target: "mysql",
14
+ feature: what
15
+ }
16
+ });
17
+ }
18
+ const TEMPORAL_UNAVAILABLE_FIX = "Run on a runtime with Temporal available, install a Temporal polyfill before creating the client, or write the column as a convenience type at its default, which needs no Temporal: `DateTime` reads a JavaScript `Date`, and `Date`, `Time` and `Duration` read ISO 8601 strings.";
19
+ function errorTemporalUnavailable(codecId, operation) {
20
+ return mysqlError("RUNTIME.TEMPORAL_UNAVAILABLE", `Codec '${codecId}' cannot ${operation} a value because this runtime has no global Temporal implementation.`, {
21
+ why: "Temporal-backed codecs read and write their values through the global Temporal API, which this runtime does not provide.",
22
+ fix: TEMPORAL_UNAVAILABLE_FIX,
23
+ meta: {
24
+ codecId,
25
+ operation
26
+ }
27
+ });
28
+ }
29
+ function errorTemporalUnavailableForDefault(generatorId) {
30
+ return mysqlError("RUNTIME.TEMPORAL_UNAVAILABLE", `Mutation default generator '${generatorId}' cannot produce a value because this runtime has no global Temporal implementation.`, {
31
+ why: "The generator answers a Temporal-backed column, so the value it produces is a Temporal value, which this runtime cannot construct.",
32
+ fix: TEMPORAL_UNAVAILABLE_FIX,
33
+ meta: { generatorId }
34
+ });
35
+ }
36
+ function errorTemporalWrongType(codecId, temporalTag, stringType, received) {
37
+ return mysqlError("RUNTIME.ENCODE_FAILED", `Codec '${codecId}' encodes a ${temporalTag}, but received ${received}.`, {
38
+ why: "The codec writes the Temporal value's own ISO 8601 text. A value of another type has no text the column holds.",
39
+ fix: `Pass a ${temporalTag}, or author the column with its ${stringType} type to write ISO 8601 text.`,
40
+ meta: {
41
+ codecId,
42
+ temporalTag,
43
+ stringType,
44
+ received
45
+ }
46
+ });
47
+ }
48
+ function errorTemporalNonIsoCalendar(codecId, calendarId) {
49
+ return mysqlError("RUNTIME.ENCODE_FAILED", `Codec '${codecId}' accepts only the iso8601 calendar, but the value carries '${calendarId}'.`, {
50
+ why: "MySQL stores no calendar alongside a date, so a non-ISO calendar would be discarded on write and the value would read back as a different date than the one authored.",
51
+ fix: "Convert the value with .withCalendar(\"iso8601\") before writing if the ISO projection is what you mean to store.",
52
+ meta: {
53
+ codecId,
54
+ calendarId
55
+ }
56
+ });
57
+ }
58
+ /** A date or time codec read a value from MySQL that is not a value of its type, such as a zero date or a `time` that is no time of day, or that `Temporal` cannot hold. */
59
+ function errorDateTimeUnreadable(options) {
60
+ const { codecId, value, detail } = options;
61
+ return mysqlError("RUNTIME.DECODE_FAILED", `Codec '${codecId}' cannot read the value MySQL returned: ${JSON.stringify(value)}. ${detail}`, {
62
+ why: "MySQL can hold values the column's type does not, such as the zero date 0000-00-00 or a time of 838:59:59, when a row is written outside Prisma.",
63
+ fix: "Rewrite the row with a value the column type holds, or read the column with a type that holds its text, such as String.",
64
+ meta: {
65
+ codecId,
66
+ value: value.slice(0, 100)
67
+ },
68
+ ...ifDefined("cause", options.cause)
69
+ });
70
+ }
71
+ /** A date or time codec was given a value its column does not hold, such as a date before the year 1000 or text with digits below a microsecond. */
72
+ function errorDateTimeUnwritable(options) {
73
+ const { codecId, received, detail } = options;
74
+ return mysqlError("RUNTIME.ENCODE_FAILED", `Codec '${codecId}' cannot write ${received}. ${detail}`, {
75
+ why: "The codec refuses a value its column does not hold before it reaches MySQL.",
76
+ fix: "Write a value the column holds, as the message shows.",
77
+ meta: {
78
+ codecId,
79
+ received: received.slice(0, 100)
80
+ },
81
+ ...ifDefined("cause", options.cause)
82
+ });
83
+ }
84
+ //#endregion
85
+ export { errorTemporalUnavailableForDefault as a, mysqlQueryNotYetSupported as c, errorTemporalUnavailable as i, errorDateTimeUnwritable as n, errorTemporalWrongType as o, errorTemporalNonIsoCalendar as r, mysqlError as s, errorDateTimeUnreadable as t };
86
+
87
+ //# sourceMappingURL=errors-Cng94tYg-D02Eud2d.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-Cng94tYg-D02Eud2d.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/errors-Cng94tYg.mjs"],"sourcesContent":["import { structuredError } from \"@internal/utils/structured-error\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/core/errors.ts\nfunction mysqlError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n/** The refusal of a query a later slice of the MySQL target can render: `what` names the feature, as in `Lowering queries`. */\nfunction mysqlQueryNotYetSupported(what) {\n\treturn mysqlError(\"RUNTIME.AST_UNSUPPORTED\", `${what} is not yet supported on MySQL.`, {\n\t\twhy: \"The MySQL target renders reads; writes and some query forms are not built yet.\",\n\t\tfix: \"Use a Postgres or SQLite target for this query until the MySQL target supports it.\",\n\t\tmeta: {\n\t\t\ttarget: \"mysql\",\n\t\t\tfeature: what\n\t\t}\n\t});\n}\nconst TEMPORAL_UNAVAILABLE_FIX = \"Run on a runtime with Temporal available, install a Temporal polyfill before creating the client, or write the column as a convenience type at its default, which needs no Temporal: `DateTime` reads a JavaScript `Date`, and `Date`, `Time` and `Duration` read ISO 8601 strings.\";\nfunction errorTemporalUnavailable(codecId, operation) {\n\treturn mysqlError(\"RUNTIME.TEMPORAL_UNAVAILABLE\", `Codec '${codecId}' cannot ${operation} a value because this runtime has no global Temporal implementation.`, {\n\t\twhy: \"Temporal-backed codecs read and write their values through the global Temporal API, which this runtime does not provide.\",\n\t\tfix: TEMPORAL_UNAVAILABLE_FIX,\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\toperation\n\t\t}\n\t});\n}\nfunction errorTemporalUnavailableForDefault(generatorId) {\n\treturn mysqlError(\"RUNTIME.TEMPORAL_UNAVAILABLE\", `Mutation default generator '${generatorId}' cannot produce a value because this runtime has no global Temporal implementation.`, {\n\t\twhy: \"The generator answers a Temporal-backed column, so the value it produces is a Temporal value, which this runtime cannot construct.\",\n\t\tfix: TEMPORAL_UNAVAILABLE_FIX,\n\t\tmeta: { generatorId }\n\t});\n}\nfunction errorTemporalWrongType(codecId, temporalTag, stringType, received) {\n\treturn mysqlError(\"RUNTIME.ENCODE_FAILED\", `Codec '${codecId}' encodes a ${temporalTag}, but received ${received}.`, {\n\t\twhy: \"The codec writes the Temporal value's own ISO 8601 text. A value of another type has no text the column holds.\",\n\t\tfix: `Pass a ${temporalTag}, or author the column with its ${stringType} type to write ISO 8601 text.`,\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\ttemporalTag,\n\t\t\tstringType,\n\t\t\treceived\n\t\t}\n\t});\n}\nfunction errorTemporalNonIsoCalendar(codecId, calendarId) {\n\treturn mysqlError(\"RUNTIME.ENCODE_FAILED\", `Codec '${codecId}' accepts only the iso8601 calendar, but the value carries '${calendarId}'.`, {\n\t\twhy: \"MySQL stores no calendar alongside a date, so a non-ISO calendar would be discarded on write and the value would read back as a different date than the one authored.\",\n\t\tfix: \"Convert the value with .withCalendar(\\\"iso8601\\\") before writing if the ISO projection is what you mean to store.\",\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\tcalendarId\n\t\t}\n\t});\n}\n/** A date or time codec read a value from MySQL that is not a value of its type, such as a zero date or a `time` that is no time of day, or that `Temporal` cannot hold. */\nfunction errorDateTimeUnreadable(options) {\n\tconst { codecId, value, detail } = options;\n\treturn mysqlError(\"RUNTIME.DECODE_FAILED\", `Codec '${codecId}' cannot read the value MySQL returned: ${JSON.stringify(value)}. ${detail}`, {\n\t\twhy: \"MySQL can hold values the column's type does not, such as the zero date 0000-00-00 or a time of 838:59:59, when a row is written outside Prisma.\",\n\t\tfix: \"Rewrite the row with a value the column type holds, or read the column with a type that holds its text, such as String.\",\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\tvalue: value.slice(0, 100)\n\t\t},\n\t\t...ifDefined(\"cause\", options.cause)\n\t});\n}\n/** A date or time codec was given a value its column does not hold, such as a date before the year 1000 or text with digits below a microsecond. */\nfunction errorDateTimeUnwritable(options) {\n\tconst { codecId, received, detail } = options;\n\treturn mysqlError(\"RUNTIME.ENCODE_FAILED\", `Codec '${codecId}' cannot write ${received}. ${detail}`, {\n\t\twhy: \"The codec refuses a value its column does not hold before it reaches MySQL.\",\n\t\tfix: \"Write a value the column holds, as the message shows.\",\n\t\tmeta: {\n\t\t\tcodecId,\n\t\t\treceived: received.slice(0, 100)\n\t\t},\n\t\t...ifDefined(\"cause\", options.cause)\n\t});\n}\n//#endregion\nexport { errorTemporalUnavailableForDefault as a, mysqlQueryNotYetSupported as c, errorTemporalUnavailable as i, errorDateTimeUnwritable as n, errorTemporalWrongType as o, errorTemporalNonIsoCalendar as r, mysqlError as s, errorDateTimeUnreadable as t };\n\n//# sourceMappingURL=errors-Cng94tYg.mjs.map"],"mappings":";;;AAGA,SAAS,WAAW,MAAM,SAAS,SAAS;CAC3C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;;AAEA,SAAS,0BAA0B,MAAM;CACxC,OAAO,WAAW,2BAA2B,GAAG,KAAK,kCAAkC;EACtF,KAAK;EACL,KAAK;EACL,MAAM;GACL,QAAQ;GACR,SAAS;EACV;CACD,CAAC;AACF;AACA,MAAM,2BAA2B;AACjC,SAAS,yBAAyB,SAAS,WAAW;CACrD,OAAO,WAAW,gCAAgC,UAAU,QAAQ,WAAW,UAAU,uEAAuE;EAC/J,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA;EACD;CACD,CAAC;AACF;AACA,SAAS,mCAAmC,aAAa;CACxD,OAAO,WAAW,gCAAgC,+BAA+B,YAAY,uFAAuF;EACnL,KAAK;EACL,KAAK;EACL,MAAM,EAAE,YAAY;CACrB,CAAC;AACF;AACA,SAAS,uBAAuB,SAAS,aAAa,YAAY,UAAU;CAC3E,OAAO,WAAW,yBAAyB,UAAU,QAAQ,cAAc,YAAY,iBAAiB,SAAS,IAAI;EACpH,KAAK;EACL,KAAK,UAAU,YAAY,kCAAkC,WAAW;EACxE,MAAM;GACL;GACA;GACA;GACA;EACD;CACD,CAAC;AACF;AACA,SAAS,4BAA4B,SAAS,YAAY;CACzD,OAAO,WAAW,yBAAyB,UAAU,QAAQ,8DAA8D,WAAW,KAAK;EAC1I,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA;EACD;CACD,CAAC;AACF;;AAEA,SAAS,wBAAwB,SAAS;CACzC,MAAM,EAAE,SAAS,OAAO,WAAW;CACnC,OAAO,WAAW,yBAAyB,UAAU,QAAQ,0CAA0C,KAAK,UAAU,KAAK,EAAE,IAAI,UAAU;EAC1I,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA,OAAO,MAAM,MAAM,GAAG,GAAG;EAC1B;EACA,GAAG,UAAU,SAAS,QAAQ,KAAK;CACpC,CAAC;AACF;;AAEA,SAAS,wBAAwB,SAAS;CACzC,MAAM,EAAE,SAAS,UAAU,WAAW;CACtC,OAAO,WAAW,yBAAyB,UAAU,QAAQ,iBAAiB,SAAS,IAAI,UAAU;EACpG,KAAK;EACL,KAAK;EACL,MAAM;GACL;GACA,UAAU,SAAS,MAAM,GAAG,GAAG;EAChC;EACA,GAAG,UAAU,SAAS,QAAQ,KAAK;CACpC,CAAC;AACF"}
@@ -1,10 +1,10 @@
1
1
  import { StructuredError, StructuredErrorOptions } from "@prisma/orm-framework/utils/structured-error";
2
2
  //#region ../../../3-targets/mysql/1-target/dist/errors.d.mts
3
3
  //#region src/core/errors.d.ts
4
- type MysqlTargetErrorCode = 'CONTRACT.ARGUMENT_INVALID' | 'CONTRACT.CONSTRAINT_INVALID' | 'CONTRACT.IDENTIFIER_INVALID' | 'CONTRACT.NAMESPACE_INVALID' | 'CONTRACT.TARGET_MISMATCH' | 'CONTRACT.TYPE_PARAMS_INVALID' | 'MIGRATION.CONTRACT_SPACE_VIOLATION' | 'MIGRATION.MARKER_LOCK_TIMEOUT' | 'MIGRATION.MYSQL_CONTROL_STACK_MISSING' | 'RUNTIME.AST_INVALID' | 'RUNTIME.AST_UNSUPPORTED' | 'RUNTIME.CHARACTER_SET_UNSUPPORTED' | 'RUNTIME.DECODE_FAILED' | 'RUNTIME.ENCODE_FAILED' | 'RUNTIME.SQL_MODE_UNSUPPORTED';
4
+ type MysqlTargetErrorCode = 'CONTRACT.ARGUMENT_INVALID' | 'CONTRACT.CONSTRAINT_INVALID' | 'CONTRACT.IDENTIFIER_INVALID' | 'CONTRACT.NAMESPACE_INVALID' | 'CONTRACT.TARGET_MISMATCH' | 'CONTRACT.TYPE_PARAMS_INVALID' | 'MIGRATION.CONTRACT_SPACE_VIOLATION' | 'MIGRATION.MARKER_LOCK_TIMEOUT' | 'MIGRATION.MYSQL_CONTROL_STACK_MISSING' | 'RUNTIME.AST_INVALID' | 'RUNTIME.AST_UNSUPPORTED' | 'RUNTIME.CHARACTER_SET_UNSUPPORTED' | 'RUNTIME.DECODE_FAILED' | 'RUNTIME.ENCODE_FAILED' | 'RUNTIME.SQL_MODE_UNSUPPORTED' | 'RUNTIME.TEMPORAL_UNAVAILABLE';
5
5
  declare function mysqlError(code: MysqlTargetErrorCode, message: string, options?: StructuredErrorOptions): StructuredError;
6
6
  /** The refusal of a query a later slice of the MySQL target can render: `what` names the feature, as in `Lowering queries`. */
7
7
  declare function mysqlQueryNotYetSupported(what: string): StructuredError;
8
8
  //#endregion
9
9
  export { mysqlQueryNotYetSupported as n, mysqlError as t };
10
- //# sourceMappingURL=errors-BYhjQT7y.d.mts.map
10
+ //# sourceMappingURL=errors-DfrC_yfG.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-BYhjQT7y.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/errors.d.mts"],"mappings":";;;KAEK;iBACY,WAAW,MAAM,sBAAsB,iBAAiB,UAAU,yBAAyB;;iBAE3F,0BAA0B,eAAe"}
1
+ {"version":3,"file":"errors-DfrC_yfG.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/errors.d.mts"],"mappings":";;;KAEK;iBACY,WAAW,MAAM,sBAAsB,iBAAiB,UAAU,yBAAyB;;iBAE3F,0BAA0B,eAAe"}
@@ -1,5 +1,5 @@
1
- import { t as mysqlError } from "./errors-rvH_F2Yj-BQrO_--u.mjs";
2
- //#region ../../../3-targets/mysql/1-target/dist/marker-lock-CmGvN4hw.mjs
1
+ import { s as mysqlError } from "./errors-Cng94tYg-D02Eud2d.mjs";
2
+ //#region ../../../3-targets/mysql/1-target/dist/marker-lock-Bwew7cAs.mjs
3
3
  /** How long a migration runner or `db sign` waits for another one to release the marker lock. */
4
4
  const MARKER_LOCK_TIMEOUT_SECONDS = 60;
5
5
  /** `GET_LOCK` names are global to the server, so the name carries a hash of the connection's database: two databases on one server never wait on each other. */
@@ -48,4 +48,4 @@ async function withMarkerLock(driver, work, succeeded = () => true) {
48
48
  //#endregion
49
49
  export { withMarkerLock as i, acquireMarkerLock as n, releaseMarkerLock as r, MARKER_LOCK_TIMEOUT_SECONDS as t };
50
50
 
51
- //# sourceMappingURL=marker-lock-CmGvN4hw-Com29AtQ.mjs.map
51
+ //# sourceMappingURL=marker-lock-Bwew7cAs-CZ20Y_tA.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"marker-lock-CmGvN4hw-Com29AtQ.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/marker-lock-CmGvN4hw.mjs"],"sourcesContent":["import { t as mysqlError } from \"./errors-rvH_F2Yj.mjs\";\n//#region src/core/marker-lock.ts\n/** How long a migration runner or `db sign` waits for another one to release the marker lock. */\nconst MARKER_LOCK_TIMEOUT_SECONDS = 60;\n/** `GET_LOCK` names are global to the server, so the name carries a hash of the connection's database: two databases on one server never wait on each other. */\nconst LOCK_NAME = \"CONCAT('prisma_marker_', LEFT(SHA2(DATABASE(), 256), 50))\";\nfunction lockResult(rows) {\n\tconst value = rows[0]?.[\"acquired\"];\n\treturn value === null || value === void 0 ? void 0 : String(value);\n}\n/**\n* Takes the marker lock on the connection `driver` holds. MySQL holds a `GET_LOCK` lock for the session, not for a transaction, so the caller releases it with {@link releaseMarkerLock} on the same connection when the work it guards ends.\n*/\nasync function acquireMarkerLock(driver, timeoutSeconds = 60) {\n\tconst { rows } = await driver.query(`SELECT GET_LOCK(${LOCK_NAME}, ?) AS acquired`, [timeoutSeconds]);\n\tif (lockResult(rows) !== \"1\") throw mysqlError(\"MIGRATION.MARKER_LOCK_TIMEOUT\", `Another process held the migration marker lock for ${timeoutSeconds} seconds.`, {\n\t\twhy: \"A migration or db sign on this database is still running, and they write the contract markers one at a time.\",\n\t\tfix: \"Wait for the other process to finish, then run the command again.\",\n\t\tmeta: { timeoutSeconds }\n\t});\n}\n/** Releases the marker lock {@link acquireMarkerLock} took on this connection. */\nasync function releaseMarkerLock(driver) {\n\tawait driver.query(`SELECT RELEASE_LOCK(${LOCK_NAME}) AS released`);\n}\n/**\n* Releases the marker lock after work that failed, keeping that failure: a release that fails too is dropped. MySQL frees a session's locks when the session ends, which is the usual reason a release fails.\n*/\nasync function releaseMarkerLockAfterFailure(driver) {\n\tawait releaseMarkerLock(driver).catch(() => void 0);\n}\n/**\n* The one way MySQL holds the marker lock: takes it on the connection `driver` holds, runs `work`, and releases it on the same connection when `work` ends. A failed release is reported only when `work` succeeded; when `work` throws, or `succeeded` says its result is a failure, that outcome is what comes back.\n*/\nasync function withMarkerLock(driver, work, succeeded = () => true) {\n\tawait acquireMarkerLock(driver);\n\tlet result;\n\ttry {\n\t\tresult = await work();\n\t} catch (error) {\n\t\tawait releaseMarkerLockAfterFailure(driver);\n\t\tthrow error;\n\t}\n\tif (succeeded(result)) await releaseMarkerLock(driver);\n\telse await releaseMarkerLockAfterFailure(driver);\n\treturn result;\n}\n//#endregion\nexport { withMarkerLock as i, acquireMarkerLock as n, releaseMarkerLock as r, MARKER_LOCK_TIMEOUT_SECONDS as t };\n\n//# sourceMappingURL=marker-lock-CmGvN4hw.mjs.map"],"mappings":";;;AAGA,MAAM,8BAA8B;;AAEpC,MAAM,YAAY;AAClB,SAAS,WAAW,MAAM;CACzB,MAAM,QAAQ,KAAK,EAAE,GAAG;CACxB,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK;AAClE;;;;AAIA,eAAe,kBAAkB,QAAQ,iBAAiB,IAAI;CAC7D,MAAM,EAAE,SAAS,MAAM,OAAO,MAAM,mBAAmB,UAAU,mBAAmB,CAAC,cAAc,CAAC;CACpG,IAAI,WAAW,IAAI,MAAM,KAAK,MAAM,WAAW,iCAAiC,sDAAsD,eAAe,YAAY;EAChK,KAAK;EACL,KAAK;EACL,MAAM,EAAE,eAAe;CACxB,CAAC;AACF;;AAEA,eAAe,kBAAkB,QAAQ;CACxC,MAAM,OAAO,MAAM,uBAAuB,UAAU,cAAc;AACnE;;;;AAIA,eAAe,8BAA8B,QAAQ;CACpD,MAAM,kBAAkB,MAAM,CAAC,CAAC,YAAY,KAAK,CAAC;AACnD;;;;AAIA,eAAe,eAAe,QAAQ,MAAM,kBAAkB,MAAM;CACnE,MAAM,kBAAkB,MAAM;CAC9B,IAAI;CACJ,IAAI;EACH,SAAS,MAAM,KAAK;CACrB,SAAS,OAAO;EACf,MAAM,8BAA8B,MAAM;EAC1C,MAAM;CACP;CACA,IAAI,UAAU,MAAM,GAAG,MAAM,kBAAkB,MAAM;MAChD,MAAM,8BAA8B,MAAM;CAC/C,OAAO;AACR"}
1
+ {"version":3,"file":"marker-lock-Bwew7cAs-CZ20Y_tA.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/marker-lock-Bwew7cAs.mjs"],"sourcesContent":["import { s as mysqlError } from \"./errors-Cng94tYg.mjs\";\n//#region src/core/marker-lock.ts\n/** How long a migration runner or `db sign` waits for another one to release the marker lock. */\nconst MARKER_LOCK_TIMEOUT_SECONDS = 60;\n/** `GET_LOCK` names are global to the server, so the name carries a hash of the connection's database: two databases on one server never wait on each other. */\nconst LOCK_NAME = \"CONCAT('prisma_marker_', LEFT(SHA2(DATABASE(), 256), 50))\";\nfunction lockResult(rows) {\n\tconst value = rows[0]?.[\"acquired\"];\n\treturn value === null || value === void 0 ? void 0 : String(value);\n}\n/**\n* Takes the marker lock on the connection `driver` holds. MySQL holds a `GET_LOCK` lock for the session, not for a transaction, so the caller releases it with {@link releaseMarkerLock} on the same connection when the work it guards ends.\n*/\nasync function acquireMarkerLock(driver, timeoutSeconds = 60) {\n\tconst { rows } = await driver.query(`SELECT GET_LOCK(${LOCK_NAME}, ?) AS acquired`, [timeoutSeconds]);\n\tif (lockResult(rows) !== \"1\") throw mysqlError(\"MIGRATION.MARKER_LOCK_TIMEOUT\", `Another process held the migration marker lock for ${timeoutSeconds} seconds.`, {\n\t\twhy: \"A migration or db sign on this database is still running, and they write the contract markers one at a time.\",\n\t\tfix: \"Wait for the other process to finish, then run the command again.\",\n\t\tmeta: { timeoutSeconds }\n\t});\n}\n/** Releases the marker lock {@link acquireMarkerLock} took on this connection. */\nasync function releaseMarkerLock(driver) {\n\tawait driver.query(`SELECT RELEASE_LOCK(${LOCK_NAME}) AS released`);\n}\n/**\n* Releases the marker lock after work that failed, keeping that failure: a release that fails too is dropped. MySQL frees a session's locks when the session ends, which is the usual reason a release fails.\n*/\nasync function releaseMarkerLockAfterFailure(driver) {\n\tawait releaseMarkerLock(driver).catch(() => void 0);\n}\n/**\n* The one way MySQL holds the marker lock: takes it on the connection `driver` holds, runs `work`, and releases it on the same connection when `work` ends. A failed release is reported only when `work` succeeded; when `work` throws, or `succeeded` says its result is a failure, that outcome is what comes back.\n*/\nasync function withMarkerLock(driver, work, succeeded = () => true) {\n\tawait acquireMarkerLock(driver);\n\tlet result;\n\ttry {\n\t\tresult = await work();\n\t} catch (error) {\n\t\tawait releaseMarkerLockAfterFailure(driver);\n\t\tthrow error;\n\t}\n\tif (succeeded(result)) await releaseMarkerLock(driver);\n\telse await releaseMarkerLockAfterFailure(driver);\n\treturn result;\n}\n//#endregion\nexport { withMarkerLock as i, acquireMarkerLock as n, releaseMarkerLock as r, MARKER_LOCK_TIMEOUT_SECONDS as t };\n\n//# sourceMappingURL=marker-lock-Bwew7cAs.mjs.map"],"mappings":";;;AAGA,MAAM,8BAA8B;;AAEpC,MAAM,YAAY;AAClB,SAAS,WAAW,MAAM;CACzB,MAAM,QAAQ,KAAK,EAAE,GAAG;CACxB,OAAO,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,OAAO,KAAK;AAClE;;;;AAIA,eAAe,kBAAkB,QAAQ,iBAAiB,IAAI;CAC7D,MAAM,EAAE,SAAS,MAAM,OAAO,MAAM,mBAAmB,UAAU,mBAAmB,CAAC,cAAc,CAAC;CACpG,IAAI,WAAW,IAAI,MAAM,KAAK,MAAM,WAAW,iCAAiC,sDAAsD,eAAe,YAAY;EAChK,KAAK;EACL,KAAK;EACL,MAAM,EAAE,eAAe;CACxB,CAAC;AACF;;AAEA,eAAe,kBAAkB,QAAQ;CACxC,MAAM,OAAO,MAAM,uBAAuB,UAAU,cAAc;AACnE;;;;AAIA,eAAe,8BAA8B,QAAQ;CACpD,MAAM,kBAAkB,MAAM,CAAC,CAAC,YAAY,KAAK,CAAC;AACnD;;;;AAIA,eAAe,eAAe,QAAQ,MAAM,kBAAkB,MAAM;CACnE,MAAM,kBAAkB,MAAM;CAC9B,IAAI;CACJ,IAAI;EACH,SAAS,MAAM,KAAK;CACrB,SAAS,OAAO;EACf,MAAM,8BAA8B,MAAM;EAC1C,MAAM;CACP;CACA,IAAI,UAAU,MAAM,GAAG,MAAM,kBAAkB,MAAM;MAChD,MAAM,8BAA8B,MAAM;CAC/C,OAAO;AACR"}
@@ -1,11 +1,11 @@
1
- import { n as quoteIdentifier } from "./sql-utils-Db0IQO_B-PaULnfrE.mjs";
2
- import { o as mysqlCodecRegistry, r as decodeMysqlDatetime } from "./codecs-C00kjHgh.mjs";
1
+ import { n as quoteIdentifier } from "./sql-utils-Cmv_TVa8-BetrIUcj.mjs";
2
+ import { o as mysqlCodecRegistry, r as decodeMysqlDatetime } from "./codecs-BfiB79-5.mjs";
3
3
  import { r as MARKER_TABLE_NAME } from "./control-tables-CcQ77JE7-CxTQYoQJ.mjs";
4
- import { n as mysqlAdapterContractContributions } from "./contract-contributions-B9njRJbt-ClEtrK2L.mjs";
4
+ import { n as mysqlAdapterContractContributions } from "./contract-contributions-ChiX6W0F-CAng98bZ.mjs";
5
5
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
6
6
  import { withMarkerReadErrorHandling } from "@prisma/orm-framework/errors/execution";
7
7
  import { parseContractMarkerRow } from "@prisma/orm-family-sql/family/verify";
8
- //#region ../../../3-targets/mysql/2-adapter/dist/marker-read-aEaHihYj.mjs
8
+ //#region ../../../3-targets/mysql/2-adapter/dist/marker-read-Cf80LSbG.mjs
9
9
  const mysqlAdapterDescriptorMeta = {
10
10
  kind: "adapter",
11
11
  familyId: "sql",
@@ -75,4 +75,4 @@ async function readMarkerResult(driver, space) {
75
75
  //#endregion
76
76
  export { readMarkerRows as a, readMarkerResult as i, mysqlAdapterDescriptorMeta as n, tableExists as o, parseJsonColumn as r, decodeMysqlMarkerRow as t };
77
77
 
78
- //# sourceMappingURL=marker-read-aEaHihYj-Cyg16yn1.mjs.map
78
+ //# sourceMappingURL=marker-read-Cf80LSbG-CUp3v1e5.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"marker-read-aEaHihYj-Cyg16yn1.mjs","names":[],"sources":["../../../../3-targets/mysql/2-adapter/dist/marker-read-aEaHihYj.mjs"],"sourcesContent":["import { t as mysqlAdapterContractContributions } from \"./contract-contributions-B9njRJbt.mjs\";\nimport { decodeMysqlDatetime, mysqlCodecRegistry } from \"@internal/target-mysql/codecs\";\nimport { withMarkerReadErrorHandling } from \"@internal/errors/execution\";\nimport { MARKER_TABLE_NAME } from \"@internal/target-mysql/control-tables\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { parseContractMarkerRow } from \"@internal/family-sql/verify\";\nimport { quoteIdentifier } from \"@internal/target-mysql/sql-utils\";\n//#region src/core/descriptor-meta.ts\nconst mysqlAdapterDescriptorMeta = {\n\tkind: \"adapter\",\n\tfamilyId: \"sql\",\n\ttargetId: \"mysql\",\n\tid: \"mysql\",\n\tversion: \"0.0.1\",\n\tcapabilities: mysqlAdapterContractContributions.capabilities,\n\ttypes: { codecTypes: {\n\t\tcodecDescriptors: Array.from(mysqlCodecRegistry.values()),\n\t\timport: {\n\t\t\tpackage: \"@internal/adapter-mysql/codec-types\",\n\t\t\tnamed: \"CodecTypes\",\n\t\t\talias: \"MysqlTypes\"\n\t\t}\n\t} }\n};\n//#endregion\n//#region src/core/marker-read.ts\nconst MARKER_COLUMNS = \"space, core_hash, profile_hash, contract_json, canonical_version, updated_at, app_tag, meta, invariants\";\n/** Whether the connection's database has the table `name`. */\nasync function tableExists(driver, name) {\n\tconst { rows } = await driver.query(\"SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?\", [name]);\n\treturn rows.length > 0;\n}\nfunction parseJsonColumn(column, text) {\n\tif (typeof text !== \"string\") return text;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch (error) {\n\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\tthrow structuredError(\"CONTRACT.MARKER_ROW_CORRUPT\", `Invalid contract marker row: ${column} is not valid JSON: ${detail}`, {\n\t\t\tmeta: { detail },\n\t\t\tcause: error\n\t\t});\n\t}\n}\n/** A marker row as MySQL's text arrives, in the shape the family's marker parser reads. */\nfunction decodeMysqlMarkerRow(row) {\n\tconst canonicalVersion = row[\"canonical_version\"];\n\tconst updatedAt = row[\"updated_at\"];\n\treturn parseContractMarkerRow({\n\t\t...row,\n\t\tcanonical_version: typeof canonicalVersion === \"string\" ? Number(canonicalVersion) : canonicalVersion,\n\t\tupdated_at: typeof updatedAt === \"string\" ? decodeMysqlDatetime(updatedAt) : updatedAt,\n\t\tinvariants: parseJsonColumn(\"invariants\", row[\"invariants\"])\n\t});\n}\nasync function readMarkerRows(driver, space) {\n\tif (!await tableExists(driver, MARKER_TABLE_NAME)) return void 0;\n\tconst select = `SELECT ${MARKER_COLUMNS} FROM ${quoteIdentifier(MARKER_TABLE_NAME)}`;\n\tconst { rows } = space === void 0 ? await driver.query(select) : await driver.query(`${select} WHERE space = ?`, [space]);\n\treturn rows;\n}\n/** The marker of `space`, or whether the marker table or the space's row is missing. */\nasync function readMarkerResult(driver, space) {\n\treturn withMarkerReadErrorHandling(async () => {\n\t\tconst rows = await readMarkerRows(driver, space);\n\t\tif (rows === void 0) return { kind: \"no-table\" };\n\t\tconst [row] = rows;\n\t\treturn row === void 0 ? { kind: \"absent\" } : {\n\t\t\tkind: \"present\",\n\t\t\trecord: decodeMysqlMarkerRow(row)\n\t\t};\n\t}, {\n\t\tspace,\n\t\tmarkerLocation: MARKER_TABLE_NAME\n\t});\n}\n//#endregion\nexport { tableExists as a, readMarkerRows as i, parseJsonColumn as n, mysqlAdapterDescriptorMeta as o, readMarkerResult as r, decodeMysqlMarkerRow as t };\n\n//# sourceMappingURL=marker-read-aEaHihYj.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,6BAA6B;CAClC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,kCAAkC;CAChD,OAAO,EAAE,YAAY;EACpB,kBAAkB,MAAM,KAAK,mBAAmB,OAAO,CAAC;EACxD,QAAQ;GACP,SAAS;GACT,OAAO;GACP,OAAO;EACR;CACD,EAAE;AACH;AAGA,MAAM,iBAAiB;;AAEvB,eAAe,YAAY,QAAQ,MAAM;CACxC,MAAM,EAAE,SAAS,MAAM,OAAO,MAAM,uGAAuG,CAAC,IAAI,CAAC;CACjJ,OAAO,KAAK,SAAS;AACtB;AACA,SAAS,gBAAgB,QAAQ,MAAM;CACtC,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI;EACH,OAAO,KAAK,MAAM,IAAI;CACvB,SAAS,OAAO;EACf,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACpE,MAAM,gBAAgB,+BAA+B,gCAAgC,OAAO,sBAAsB,UAAU;GAC3H,MAAM,EAAE,OAAO;GACf,OAAO;EACR,CAAC;CACF;AACD;;AAEA,SAAS,qBAAqB,KAAK;CAClC,MAAM,mBAAmB,IAAI;CAC7B,MAAM,YAAY,IAAI;CACtB,OAAO,uBAAuB;EAC7B,GAAG;EACH,mBAAmB,OAAO,qBAAqB,WAAW,OAAO,gBAAgB,IAAI;EACrF,YAAY,OAAO,cAAc,WAAW,oBAAoB,SAAS,IAAI;EAC7E,YAAY,gBAAgB,cAAc,IAAI,aAAa;CAC5D,CAAC;AACF;AACA,eAAe,eAAe,QAAQ,OAAO;CAC5C,IAAI,CAAC,MAAM,YAAY,QAAA,gBAAyB,GAAG,OAAO,KAAK;CAC/D,MAAM,SAAS,UAAU,eAAe,QAAQ,gBAAgB,iBAAiB;CACjF,MAAM,EAAE,SAAS,UAAU,KAAK,IAAI,MAAM,OAAO,MAAM,MAAM,IAAI,MAAM,OAAO,MAAM,GAAG,OAAO,mBAAmB,CAAC,KAAK,CAAC;CACxH,OAAO;AACR;;AAEA,eAAe,iBAAiB,QAAQ,OAAO;CAC9C,OAAO,4BAA4B,YAAY;EAC9C,MAAM,OAAO,MAAM,eAAe,QAAQ,KAAK;EAC/C,IAAI,SAAS,KAAK,GAAG,OAAO,EAAE,MAAM,WAAW;EAC/C,MAAM,CAAC,OAAO;EACd,OAAO,QAAQ,KAAK,IAAI,EAAE,MAAM,SAAS,IAAI;GAC5C,MAAM;GACN,QAAQ,qBAAqB,GAAG;EACjC;CACD,GAAG;EACF;EACA,gBAAgB;CACjB,CAAC;AACF"}
1
+ {"version":3,"file":"marker-read-Cf80LSbG-CUp3v1e5.mjs","names":[],"sources":["../../../../3-targets/mysql/2-adapter/dist/marker-read-Cf80LSbG.mjs"],"sourcesContent":["import { t as mysqlAdapterContractContributions } from \"./contract-contributions-ChiX6W0F.mjs\";\nimport { decodeMysqlDatetime, mysqlCodecRegistry } from \"@internal/target-mysql/codecs\";\nimport { withMarkerReadErrorHandling } from \"@internal/errors/execution\";\nimport { MARKER_TABLE_NAME } from \"@internal/target-mysql/control-tables\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { parseContractMarkerRow } from \"@internal/family-sql/verify\";\nimport { quoteIdentifier } from \"@internal/target-mysql/sql-utils\";\n//#region src/core/descriptor-meta.ts\nconst mysqlAdapterDescriptorMeta = {\n\tkind: \"adapter\",\n\tfamilyId: \"sql\",\n\ttargetId: \"mysql\",\n\tid: \"mysql\",\n\tversion: \"0.0.1\",\n\tcapabilities: mysqlAdapterContractContributions.capabilities,\n\ttypes: { codecTypes: {\n\t\tcodecDescriptors: Array.from(mysqlCodecRegistry.values()),\n\t\timport: {\n\t\t\tpackage: \"@internal/adapter-mysql/codec-types\",\n\t\t\tnamed: \"CodecTypes\",\n\t\t\talias: \"MysqlTypes\"\n\t\t}\n\t} }\n};\n//#endregion\n//#region src/core/marker-read.ts\nconst MARKER_COLUMNS = \"space, core_hash, profile_hash, contract_json, canonical_version, updated_at, app_tag, meta, invariants\";\n/** Whether the connection's database has the table `name`. */\nasync function tableExists(driver, name) {\n\tconst { rows } = await driver.query(\"SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ?\", [name]);\n\treturn rows.length > 0;\n}\nfunction parseJsonColumn(column, text) {\n\tif (typeof text !== \"string\") return text;\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch (error) {\n\t\tconst detail = error instanceof Error ? error.message : String(error);\n\t\tthrow structuredError(\"CONTRACT.MARKER_ROW_CORRUPT\", `Invalid contract marker row: ${column} is not valid JSON: ${detail}`, {\n\t\t\tmeta: { detail },\n\t\t\tcause: error\n\t\t});\n\t}\n}\n/** A marker row as MySQL's text arrives, in the shape the family's marker parser reads. */\nfunction decodeMysqlMarkerRow(row) {\n\tconst canonicalVersion = row[\"canonical_version\"];\n\tconst updatedAt = row[\"updated_at\"];\n\treturn parseContractMarkerRow({\n\t\t...row,\n\t\tcanonical_version: typeof canonicalVersion === \"string\" ? Number(canonicalVersion) : canonicalVersion,\n\t\tupdated_at: typeof updatedAt === \"string\" ? decodeMysqlDatetime(updatedAt) : updatedAt,\n\t\tinvariants: parseJsonColumn(\"invariants\", row[\"invariants\"])\n\t});\n}\nasync function readMarkerRows(driver, space) {\n\tif (!await tableExists(driver, MARKER_TABLE_NAME)) return void 0;\n\tconst select = `SELECT ${MARKER_COLUMNS} FROM ${quoteIdentifier(MARKER_TABLE_NAME)}`;\n\tconst { rows } = space === void 0 ? await driver.query(select) : await driver.query(`${select} WHERE space = ?`, [space]);\n\treturn rows;\n}\n/** The marker of `space`, or whether the marker table or the space's row is missing. */\nasync function readMarkerResult(driver, space) {\n\treturn withMarkerReadErrorHandling(async () => {\n\t\tconst rows = await readMarkerRows(driver, space);\n\t\tif (rows === void 0) return { kind: \"no-table\" };\n\t\tconst [row] = rows;\n\t\treturn row === void 0 ? { kind: \"absent\" } : {\n\t\t\tkind: \"present\",\n\t\t\trecord: decodeMysqlMarkerRow(row)\n\t\t};\n\t}, {\n\t\tspace,\n\t\tmarkerLocation: MARKER_TABLE_NAME\n\t});\n}\n//#endregion\nexport { tableExists as a, readMarkerRows as i, parseJsonColumn as n, mysqlAdapterDescriptorMeta as o, readMarkerResult as r, decodeMysqlMarkerRow as t };\n\n//# sourceMappingURL=marker-read-Cf80LSbG.mjs.map"],"mappings":";;;;;;;;AAQA,MAAM,6BAA6B;CAClC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,kCAAkC;CAChD,OAAO,EAAE,YAAY;EACpB,kBAAkB,MAAM,KAAK,mBAAmB,OAAO,CAAC;EACxD,QAAQ;GACP,SAAS;GACT,OAAO;GACP,OAAO;EACR;CACD,EAAE;AACH;AAGA,MAAM,iBAAiB;;AAEvB,eAAe,YAAY,QAAQ,MAAM;CACxC,MAAM,EAAE,SAAS,MAAM,OAAO,MAAM,uGAAuG,CAAC,IAAI,CAA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ACF"}
@@ -0,0 +1,35 @@
1
+ import { o as mysqlDataTypes } from "./data-types-DOaaPS93-DBkMJyh1.mjs";
2
+ import { n as mysqlCreateNamespace } from "./mysql-database-CHl9-oSL-CWZLDXt6.mjs";
3
+ import { createDataTypeLookup } from "@prisma/orm-framework/components/codec";
4
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
5
+ import { SqlContractSerializerBase } from "@prisma/orm-family-sql/family/ir";
6
+ //#region ../../../3-targets/mysql/1-target/dist/mysql-contract-serializer-BnTKRSsN.mjs
7
+ /** The MySQL target's contract serializer: the SQL family's, with each namespace built as a `MysqlDatabase`. */
8
+ var MysqlContractSerializer = class extends SqlContractSerializerBase {
9
+ constructor() {
10
+ super(/* @__PURE__ */ new Map(), [], createDataTypeLookup(mysqlDataTypes));
11
+ }
12
+ hydrateSqlNamespaceEntry(nsId, raw) {
13
+ return mysqlCreateNamespace(blindCast(super.hydrateSqlNamespaceEntry(nsId, raw)));
14
+ }
15
+ serializeContract(contract) {
16
+ const { storage, ...rest } = contract;
17
+ const namespacesJson = {};
18
+ for (const [nsId, ns] of Object.entries(storage.namespaces)) namespacesJson[nsId] = {
19
+ id: ns.id,
20
+ entries: this.serializeNamespaceEntries(ns.entries)
21
+ };
22
+ return blindCast({
23
+ ...rest,
24
+ storage: {
25
+ storageHash: String(storage.storageHash),
26
+ namespaces: namespacesJson,
27
+ ...storage.types !== void 0 ? { types: this.serializeJsonObject(storage.types) } : {}
28
+ }
29
+ });
30
+ }
31
+ };
32
+ //#endregion
33
+ export { MysqlContractSerializer as t };
34
+
35
+ //# sourceMappingURL=mysql-contract-serializer-BnTKRSsN-B2O3EreV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql-contract-serializer-BnTKRSsN-B2O3EreV.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/mysql-contract-serializer-BnTKRSsN.mjs"],"sourcesContent":["import { o as mysqlDataTypes } from \"./data-types-DOaaPS93.mjs\";\nimport { n as mysqlCreateNamespace } from \"./mysql-database-CHl9-oSL.mjs\";\nimport { createDataTypeLookup } from \"@internal/framework-components/codec\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { SqlContractSerializerBase } from \"@internal/family-sql/ir\";\n//#region src/core/mysql-contract-serializer.ts\n/** The MySQL target's contract serializer: the SQL family's, with each namespace built as a `MysqlDatabase`. */\nvar MysqlContractSerializer = class extends SqlContractSerializerBase {\n\tconstructor() {\n\t\tsuper(/* @__PURE__ */ new Map(), [], createDataTypeLookup(mysqlDataTypes));\n\t}\n\thydrateSqlNamespaceEntry(nsId, raw) {\n\t\treturn mysqlCreateNamespace(blindCast(super.hydrateSqlNamespaceEntry(nsId, raw)));\n\t}\n\tserializeContract(contract) {\n\t\tconst { storage, ...rest } = contract;\n\t\tconst namespacesJson = {};\n\t\tfor (const [nsId, ns] of Object.entries(storage.namespaces)) namespacesJson[nsId] = {\n\t\t\tid: ns.id,\n\t\t\tentries: this.serializeNamespaceEntries(ns.entries)\n\t\t};\n\t\treturn blindCast({\n\t\t\t...rest,\n\t\t\tstorage: {\n\t\t\t\tstorageHash: String(storage.storageHash),\n\t\t\t\tnamespaces: namespacesJson,\n\t\t\t\t...storage.types !== void 0 ? { types: this.serializeJsonObject(storage.types) } : {}\n\t\t\t}\n\t\t});\n\t}\n};\n//#endregion\nexport { MysqlContractSerializer as t };\n\n//# sourceMappingURL=mysql-contract-serializer-BnTKRSsN.mjs.map"],"mappings":";;;;;;;AAOA,IAAI,0BAA0B,cAAc,0BAA0B;CACrE,cAAc;EACb,sBAAsB,IAAI,IAAI,GAAG,CAAC,GAAG,qBAAqB,cAAc,CAAC;CAC1E;CACA,yBAAyB,MAAM,KAAK;EACnC,OAAO,qBAAqB,UAAU,MAAM,yBAAyB,MAAM,GAAG,CAAC,CAAC;CACjF;CACA,kBAAkB,UAAU;EAC3B,MAAM,EAAE,SAAS,GAAG,SAAS;EAC7B,MAAM,iBAAiB,CAAC;EACxB,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,QAAQ,UAAU,GAAG,eAAe,QAAQ;GACnF,IAAI,GAAG;GACP,SAAS,KAAK,0BAA0B,GAAG,OAAO;EACnD;EACA,OAAO,UAAU;GAChB,GAAG;GACH,SAAS;IACR,aAAa,OAAO,QAAQ,WAAW;IACvC,YAAY;IACZ,GAAG,QAAQ,UAAU,KAAK,IAAI,EAAE,OAAO,KAAK,oBAAoB,QAAQ,KAAK,EAAE,IAAI,CAAC;GACrF;EACD,CAAC;CACF;AACD"}
@@ -1,13 +1,11 @@
1
- import { t as mysqlError } from "./errors-rvH_F2Yj-BQrO_--u.mjs";
2
- import { n as quoteIdentifier } from "./sql-utils-Db0IQO_B-PaULnfrE.mjs";
3
- import { i as mysqlDataTypes } from "./data-types-Dv9gwVRV-BZPzCWZk.mjs";
4
- import { createDataTypeLookup } from "@prisma/orm-framework/components/codec";
1
+ import { s as mysqlError } from "./errors-Cng94tYg-D02Eud2d.mjs";
2
+ import { n as quoteIdentifier } from "./sql-utils-Cmv_TVa8-BetrIUcj.mjs";
3
+ import { S as mysqlTimestamp, b as mysqlTime, l as mysqlDatetime } from "./data-types-DOaaPS93-DBkMJyh1.mjs";
5
4
  import { blindCast } from "@prisma/orm-framework/utils/casts";
6
5
  import { UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from "@prisma/orm-framework/components/ir";
7
6
  import { SqlNamespaceBase } from "@prisma/orm-family-sql/contract/types";
8
- import { SqlContractSerializerBase } from "@prisma/orm-family-sql/family/ir";
9
7
  import { tableEntityKind } from "@prisma/orm-family-sql/contract/entity-kinds";
10
- //#region ../../../3-targets/mysql/1-target/dist/mysql-contract-serializer-DLv0uW_f.mjs
8
+ //#region ../../../3-targets/mysql/1-target/dist/mysql-database-CHl9-oSL.mjs
11
9
  const MYSQL_NAMESPACE_KIND = "mysql-namespace";
12
10
  /**
13
11
  * The MySQL database a connection uses, as the contract's one namespace. Tables are addressed unqualified, so the contract runs against whichever database the connection names.
@@ -85,27 +83,53 @@ function enumColumnWithMembers(namespace, tableName, columnName, column) {
85
83
  }
86
84
  };
87
85
  }
88
- function withEnumMembers(namespace, tableName, table) {
86
+ /** The data types whose bare column type holds whole seconds. */
87
+ const PRECISION_DATA_TYPES = /* @__PURE__ */ new Set([
88
+ mysqlDatetime.id,
89
+ mysqlTimestamp.id,
90
+ mysqlTime.id
91
+ ]);
92
+ function isUnwrittenPrecisionColumn(column) {
93
+ if (!isLoose(column) || !PRECISION_DATA_TYPES.has(column["dataType"])) return false;
94
+ const typeParams = column["typeParams"];
95
+ return !isLoose(typeParams) || typeParams["precision"] === void 0;
96
+ }
97
+ /** A `datetime`, `timestamp` or `time` column with no precision written records 0, the fraction digits MySQL gives the bare type, so its codec writes a value MySQL does not round; a codec reference with no precision is a raw parameter's, which is written whole. */
98
+ function withZeroPrecision(column) {
99
+ const typeParams = isLoose(column["typeParams"]) ? column["typeParams"] : {};
100
+ return {
101
+ ...column,
102
+ typeParams: {
103
+ ...typeParams,
104
+ precision: 0
105
+ }
106
+ };
107
+ }
108
+ function withFilledTypeParams(namespace, tableName, table) {
89
109
  if (!isLoose(table)) return table;
90
110
  const columns = table["columns"];
91
- if (!isLoose(columns) || !Object.values(columns).some(isEnumColumn)) return table;
92
- const filled = Object.fromEntries(Object.entries(columns).map(([columnName, column]) => [columnName, isEnumColumn(column) ? enumColumnWithMembers(namespace, tableName, columnName, column) : column]));
111
+ if (!isLoose(columns) || !Object.values(columns).some((column) => isEnumColumn(column) || isUnwrittenPrecisionColumn(column))) return table;
112
+ const filled = Object.fromEntries(Object.entries(columns).map(([columnName, column]) => {
113
+ if (isEnumColumn(column)) return [columnName, enumColumnWithMembers(namespace, tableName, columnName, column)];
114
+ if (isUnwrittenPrecisionColumn(column)) return [columnName, withZeroPrecision(column)];
115
+ return [columnName, column];
116
+ }));
93
117
  return {
94
118
  ...table,
95
119
  columns: filled
96
120
  };
97
121
  }
98
122
  /**
99
- * Writes each MySQL enum column's members, from the value set the column names, into its type parameters, in the order the enum declares them, and refuses a column whose own members differ from them. The column's type is then `enum('A','B')`, so the database enforces the members and `db verify` sees a change to them as a change of the column's type.
123
+ * Writes the type parameters MySQL gives a column that the authored schema leaves out. Each MySQL enum column's members, from the value set the column names, go into its type parameters in the order the enum declares them, and a column whose own members differ from them is refused; the column's type is then `enum('A','B')`, so the database enforces the members and `db verify` sees a change to them as a change of the column's type. A `datetime`, `timestamp` or `time` column with no precision records precision 0.
100
124
  */
101
- function fillEnumMembers(input) {
125
+ function fillTypeParams(input) {
102
126
  const tables = input.entries["table"];
103
127
  if (tables === void 0) return input;
104
128
  return {
105
129
  ...input,
106
130
  entries: {
107
131
  ...input.entries,
108
- table: Object.fromEntries(Object.entries(tables).map(([tableName, table]) => [tableName, withEnumMembers(input, tableName, table)]))
132
+ table: Object.fromEntries(Object.entries(tables).map(([tableName, table]) => [tableName, withFilledTypeParams(input, tableName, table)]))
109
133
  }
110
134
  };
111
135
  }
@@ -127,34 +151,9 @@ function rejectSqlBodyIndexes(input) {
127
151
  function mysqlCreateNamespace(input) {
128
152
  if (input.id !== UNBOUND_NAMESPACE_ID) throw mysqlError("CONTRACT.NAMESPACE_INVALID", `The MySQL target has one namespace, "${UNBOUND_NAMESPACE_ID}"; it received "${input.id}".`, { meta: { received: input.id } });
129
153
  rejectSqlBodyIndexes(input);
130
- return new MysqlDatabase(fillEnumMembers(input));
154
+ return new MysqlDatabase(fillTypeParams(input));
131
155
  }
132
- /** The MySQL target's contract serializer: the SQL family's, with each namespace built as a `MysqlDatabase`. */
133
- var MysqlContractSerializer = class extends SqlContractSerializerBase {
134
- constructor() {
135
- super(/* @__PURE__ */ new Map(), [], createDataTypeLookup(mysqlDataTypes));
136
- }
137
- hydrateSqlNamespaceEntry(nsId, raw) {
138
- return mysqlCreateNamespace(blindCast(super.hydrateSqlNamespaceEntry(nsId, raw)));
139
- }
140
- serializeContract(contract) {
141
- const { storage, ...rest } = contract;
142
- const namespacesJson = {};
143
- for (const [nsId, ns] of Object.entries(storage.namespaces)) namespacesJson[nsId] = {
144
- id: ns.id,
145
- entries: this.serializeNamespaceEntries(ns.entries)
146
- };
147
- return blindCast({
148
- ...rest,
149
- storage: {
150
- storageHash: String(storage.storageHash),
151
- namespaces: namespacesJson,
152
- ...storage.types !== void 0 ? { types: this.serializeJsonObject(storage.types) } : {}
153
- }
154
- });
155
- }
156
- };
157
156
  //#endregion
158
- export { MysqlDatabase as n, mysqlCreateNamespace as r, MysqlContractSerializer as t };
157
+ export { mysqlCreateNamespace as n, MysqlDatabase as t };
159
158
 
160
- //# sourceMappingURL=mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs.map
159
+ //# sourceMappingURL=mysql-database-CHl9-oSL-CWZLDXt6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mysql-database-CHl9-oSL-CWZLDXt6.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/mysql-database-CHl9-oSL.mjs"],"sourcesContent":["import \"./codec-ids-CrR9Xi7r.mjs\";\nimport { s as mysqlError } from \"./errors-Cng94tYg.mjs\";\nimport { n as quoteIdentifier } from \"./sql-utils-Cmv_TVa8.mjs\";\nimport { S as mysqlTimestamp, b as mysqlTime, l as mysqlDatetime } from \"./data-types-DOaaPS93.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { SqlNamespaceBase } from \"@internal/sql-contract/types\";\nimport { UNBOUND_NAMESPACE_ID, freezeNode, hydrateNamespaceEntities } from \"@internal/framework-components/ir\";\nimport { tableEntityKind } from \"@internal/sql-contract/entity-kinds\";\n//#region src/core/mysql-database.ts\nconst MYSQL_NAMESPACE_KIND = \"mysql-namespace\";\n/**\n* The MySQL database a connection uses, as the contract's one namespace. Tables are addressed unqualified, so the contract runs against whichever database the connection names.\n*/\nvar MysqlDatabase = class extends SqlNamespaceBase {\n\tid;\n\tentries;\n\tconstructor(input) {\n\t\tsuper();\n\t\tthis.id = input.id;\n\t\tconst dispatched = hydrateNamespaceEntities(input.entries, /* @__PURE__ */ new Map([[\"table\", tableEntityKind]]), \"carry\");\n\t\tthis.entries = Object.freeze(blindCast(dispatched));\n\t\tObject.defineProperty(this, \"kind\", {\n\t\t\tvalue: MYSQL_NAMESPACE_KIND,\n\t\t\twritable: false,\n\t\t\tenumerable: false,\n\t\t\tconfigurable: true\n\t\t});\n\t\tfreezeNode(this);\n\t}\n\tget table() {\n\t\treturn this.entries.table ?? Object.freeze({});\n\t}\n\tqualifier() {\n\t\treturn \"\";\n\t}\n\tqualifyTable(tableName) {\n\t\treturn quoteIdentifier(tableName);\n\t}\n};\nfunction isLoose(value) {\n\treturn typeof value === \"object\" && value !== null;\n}\nfunction enumMembersOf(namespace, tableName, columnName, column) {\n\tconst subject = `Column \"${tableName}\".\"${columnName}\"`;\n\tconst ref = column[\"valueSet\"];\n\tconst valueSetName = isLoose(ref) && ref[\"namespaceId\"] === namespace.id ? ref[\"entityName\"] : void 0;\n\tconst valueSet = typeof valueSetName === \"string\" ? namespace.entries[\"valueSet\"]?.[valueSetName] : void 0;\n\tconst values = isLoose(valueSet) ? valueSet[\"values\"] : void 0;\n\tif (!Array.isArray(values) || !values.every((value) => typeof value === \"string\")) throw mysqlError(\"CONTRACT.TYPE_PARAMS_INVALID\", `${subject} is a MySQL enum but has no enum whose text members it can list.`, {\n\t\twhy: \"A native MySQL enum column is written with its members, which come from the enum that types the column.\",\n\t\tfix: \"Type the column with a PSL enum or an enumType() whose members are text.\",\n\t\tmeta: {\n\t\t\ttable: tableName,\n\t\t\tcolumn: columnName\n\t\t}\n\t});\n\treturn values;\n}\nfunction isEnumColumn(column) {\n\treturn isLoose(column) && column[\"codecId\"] === \"mysql/enum@1\";\n}\nfunction sameMembers(left, right) {\n\treturn left.length === right.length && left.every((value, index) => value === right[index]);\n}\nfunction enumColumnWithMembers(namespace, tableName, columnName, column) {\n\tconst typeParams = isLoose(column[\"typeParams\"]) ? column[\"typeParams\"] : {};\n\tconst values = enumMembersOf(namespace, tableName, columnName, column);\n\tconst listed = typeParams[\"values\"];\n\tif (listed !== void 0 && !(Array.isArray(listed) && sameMembers(listed, values))) throw mysqlError(\"CONTRACT.TYPE_PARAMS_INVALID\", `Column \"${tableName}\".\"${columnName}\" lists enum members that differ from the members of the enum that types it.`, {\n\t\twhy: \"A MySQL enum column takes its members from its enum, in the order the enum declares them, so the database and the contract enforce the same members.\",\n\t\tfix: \"Remove the column’s own members, or make them equal the enum’s members in the same order.\",\n\t\tmeta: {\n\t\t\ttable: tableName,\n\t\t\tcolumn: columnName,\n\t\t\tcolumnValues: listed,\n\t\t\tvalueSetValues: values\n\t\t}\n\t});\n\treturn {\n\t\t...column,\n\t\ttypeParams: {\n\t\t\t...typeParams,\n\t\t\tvalues\n\t\t}\n\t};\n}\n/** The data types whose bare column type holds whole seconds. */\nconst PRECISION_DATA_TYPES = /* @__PURE__ */ new Set([\n\tmysqlDatetime.id,\n\tmysqlTimestamp.id,\n\tmysqlTime.id\n]);\nfunction isUnwrittenPrecisionColumn(column) {\n\tif (!isLoose(column) || !PRECISION_DATA_TYPES.has(column[\"dataType\"])) return false;\n\tconst typeParams = column[\"typeParams\"];\n\treturn !isLoose(typeParams) || typeParams[\"precision\"] === void 0;\n}\n/** A `datetime`, `timestamp` or `time` column with no precision written records 0, the fraction digits MySQL gives the bare type, so its codec writes a value MySQL does not round; a codec reference with no precision is a raw parameter's, which is written whole. */\nfunction withZeroPrecision(column) {\n\tconst typeParams = isLoose(column[\"typeParams\"]) ? column[\"typeParams\"] : {};\n\treturn {\n\t\t...column,\n\t\ttypeParams: {\n\t\t\t...typeParams,\n\t\t\tprecision: 0\n\t\t}\n\t};\n}\nfunction withFilledTypeParams(namespace, tableName, table) {\n\tif (!isLoose(table)) return table;\n\tconst columns = table[\"columns\"];\n\tif (!isLoose(columns) || !Object.values(columns).some((column) => isEnumColumn(column) || isUnwrittenPrecisionColumn(column))) return table;\n\tconst filled = Object.fromEntries(Object.entries(columns).map(([columnName, column]) => {\n\t\tif (isEnumColumn(column)) return [columnName, enumColumnWithMembers(namespace, tableName, columnName, column)];\n\t\tif (isUnwrittenPrecisionColumn(column)) return [columnName, withZeroPrecision(column)];\n\t\treturn [columnName, column];\n\t}));\n\treturn {\n\t\t...table,\n\t\tcolumns: filled\n\t};\n}\n/**\n* Writes the type parameters MySQL gives a column that the authored schema leaves out. Each MySQL enum column's members, from the value set the column names, go into its type parameters in the order the enum declares them, and a column whose own members differ from them is refused; the column's type is then `enum('A','B')`, so the database enforces the members and `db verify` sees a change to them as a change of the column's type. A `datetime`, `timestamp` or `time` column with no precision records precision 0.\n*/\nfunction fillTypeParams(input) {\n\tconst tables = input.entries[\"table\"];\n\tif (tables === void 0) return input;\n\treturn {\n\t\t...input,\n\t\tentries: {\n\t\t\t...input.entries,\n\t\t\ttable: Object.fromEntries(Object.entries(tables).map(([tableName, table]) => [tableName, withFilledTypeParams(input, tableName, table)]))\n\t\t}\n\t};\n}\n/**\n* The MySQL target's refusal of expression and partial indexes, which it neither writes nor introspects yet.\n*/\nfunction rejectSqlBodyIndexes(input) {\n\tfor (const [tableName, table] of Object.entries(input.entries[\"table\"] ?? {})) {\n\t\tconst indexes = isLoose(table) ? table[\"indexes\"] : void 0;\n\t\tfor (const index of Array.isArray(indexes) ? indexes : []) {\n\t\t\tif (!isLoose(index)) continue;\n\t\t\tif (index[\"expression\"] !== void 0 || index[\"where\"] !== void 0) throw mysqlError(\"CONTRACT.ARGUMENT_INVALID\", `MySQL does not support expression or partial indexes yet: index \"${String(index[\"name\"] ?? \"<unnamed>\")}\" on table \"${tableName}\" declares ${index[\"expression\"] !== void 0 ? \"an expression\" : \"a where predicate\"}. Use a fields-only index.`, { meta: { table: tableName } });\n\t\t}\n\t}\n}\n/**\n* The namespace factory the MySQL target hands `defineContract` and the PSL interpreter. MySQL has one namespace per connection, the framework's unbound slot.\n*/\nfunction mysqlCreateNamespace(input) {\n\tif (input.id !== UNBOUND_NAMESPACE_ID) throw mysqlError(\"CONTRACT.NAMESPACE_INVALID\", `The MySQL target has one namespace, \"${UNBOUND_NAMESPACE_ID}\"; it received \"${input.id}\".`, { meta: { received: input.id } });\n\trejectSqlBodyIndexes(input);\n\treturn new MysqlDatabase(fillTypeParams(input));\n}\n//#endregion\nexport { mysqlCreateNamespace as n, MysqlDatabase as t };\n\n//# sourceMappingURL=mysql-database-CHl9-oSL.mjs.map"],"mappings":";;;;;;;;AASA,MAAM,uBAAuB;;;;AAI7B,IAAI,gBAAgB,cAAc,iBAAiB;CAClD;CACA;CACA,YAAY,OAAO;EAClB,MAAM;EACN,KAAK,KAAK,MAAM;EAChB,MAAM,aAAa,yBAAyB,MAAM,yBAAyB,IAAI,IAAI,CAAC,CAAC,SAAS,eAAe,CAAC,CAAC,GAAG,OAAO;EACzH,KAAK,UAAU,OAAO,OAAO,UAAU,UAAU,CAAC;EAClD,OAAO,eAAe,MAAM,QAAQ;GACnC,OAAO;GACP,UAAU;GACV,YAAY;GACZ,cAAc;EACf,CAAC;EACD,WAAW,IAAI;CAChB;CACA,IAAI,QAAQ;EACX,OAAO,KAAK,QAAQ,SAAS,OAAO,OAAO,CAAC,CAAC;CAC9C;CACA,YAAY;EACX,OAAO;CACR;CACA,aAAa,WAAW;EACvB,OAAO,gBAAgB,SAAS;CACjC;AACD;AACA,SAAS,QAAQ,OAAO;CACvB,OAAO,OAAO,UAAU,YAAY,UAAU;AAC/C;AACA,SAAS,cAAc,WAAW,WAAW,YAAY,QAAQ;CAChE,MAAM,UAAU,WAAW,UAAU,KAAK,WAAW;CACrD,MAAM,MAAM,OAAO;CACnB,MAAM,eAAe,QAAQ,GAAG,KAAK,IAAI,mBAAmB,UAAU,KAAK,IAAI,gBAAgB,KAAK;CACpG,MAAM,WAAW,OAAO,iBAAiB,WAAW,UAAU,QAAQ,WAAW,GAAG,gBAAgB,KAAK;CACzG,MAAM,SAAS,QAAQ,QAAQ,IAAI,SAAS,YAAY,KAAK;CAC7D,IAAI,CAAC,MAAM,QAAQ,MAAM,KAAK,CAAC,OAAO,OAAO,UAAU,OAAO,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,aAAa,KAAK,GAAG,MAAM,WAAW,6BAA6B,oEAAoE,OAAO,MAAM,WAAW,WAAW,EAAE,cAAc,UAAU,aAAa,MAAM,kBAAkB,KAAK,IAAI,kBAAkB,oBAAoB,6BAA6B,EAAE,MAAM,EAAE,OAAO,UAAU,EAAE,CAAC;EAChY;CACD;AACD;;;;AAIA,SAAS,qBAAqB,OAAO;CACpC,IAAI,MAAM,OAAO,sBAAsB,MAAM,WAAW,8BAA8B,wCAAwC,qBAAqB,kBAAkB,MAAM,GAAG,KAAK,EAAE,MAAM,EAAE,UAAU,MAAM,GAAG,EAAE,CAAC;CACnN,qBAAqB,KAAK;CAC1B,OAAO,IAAI,cAAc,eAAe,KAAK,CAAC;AAC/C"}
@@ -0,0 +1,38 @@
1
+ import { S as mysqlTimestamp, b as mysqlTime, i as mysqlChar, l as mysqlDatetime, s as mysqlDate, v as mysqlText, w as mysqlVarchar } from "./data-types-DOaaPS93-DBkMJyh1.mjs";
2
+ import { sqlRawDataType } from "@prisma/orm-family-sql/contract/data-type";
3
+ //#region ../../../3-targets/mysql/1-target/dist/now-expression-DVD18CUc.mjs
4
+ /** The name of the current instant, as a contract writes it. */
5
+ const MYSQL_INSTANT_NOW = "now()";
6
+ /** The name a `now()` default on a `date` column reads back as: MySQL reports `curdate()`, which writes a date, not an instant. */
7
+ const MYSQL_DATE_NOW = "CURRENT_DATE";
8
+ /** The name a `now()` default on a `time` column reads back as: MySQL reports `curtime(p)`, which writes a time of day. */
9
+ const MYSQL_TIME_NOW = "CURRENT_TIME";
10
+ const CURRENT_VALUE_BY_DATA_TYPE = /* @__PURE__ */ new Map([
11
+ [mysqlDatetime.id, MYSQL_INSTANT_NOW],
12
+ [mysqlTimestamp.id, MYSQL_INSTANT_NOW],
13
+ [mysqlDate.id, MYSQL_DATE_NOW],
14
+ [mysqlTime.id, MYSQL_TIME_NOW],
15
+ [mysqlText.id, MYSQL_INSTANT_NOW],
16
+ [mysqlVarchar.id, MYSQL_INSTANT_NOW],
17
+ [mysqlChar.id, MYSQL_INSTANT_NOW],
18
+ [sqlRawDataType.id, MYSQL_INSTANT_NOW]
19
+ ]);
20
+ /**
21
+ * The current value a `now()` default writes on a column of `dataTypeId`: the current date on `mysql/date`, the current time of day on `mysql/time`, and the current instant on `datetime`, `timestamp`, text, a raw column, whose values Prisma does not read, and a column of no known data type. `undefined` on a data type that stores no date or time, such as `mysql/int` or `mysql/duration`, as PostgreSQL refuses `now()` on an `integer` or an `interval` column.
22
+ */
23
+ function mysqlCurrentValueFor(dataTypeId) {
24
+ return dataTypeId === void 0 ? MYSQL_INSTANT_NOW : CURRENT_VALUE_BY_DATA_TYPE.get(dataTypeId);
25
+ }
26
+ /** The MySQL expression for a current value, with the column's fraction digits, which MySQL requires to match the column's. */
27
+ function mysqlNowExpression(current, precision) {
28
+ const digits = precision === void 0 || precision === 0 ? "" : `(${precision})`;
29
+ switch (current) {
30
+ case MYSQL_INSTANT_NOW: return `CURRENT_TIMESTAMP${digits}`;
31
+ case MYSQL_DATE_NOW: return "CURRENT_DATE";
32
+ case MYSQL_TIME_NOW: return `CURRENT_TIME${digits}`;
33
+ }
34
+ }
35
+ //#endregion
36
+ export { mysqlNowExpression as a, mysqlCurrentValueFor as i, MYSQL_INSTANT_NOW as n, MYSQL_TIME_NOW as r, MYSQL_DATE_NOW as t };
37
+
38
+ //# sourceMappingURL=now-expression-DVD18CUc-00buJUto.mjs.map