@prisma/orm-target-mysql 8.0.0-rc.22-dev.11 → 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 (146) hide show
  1. package/README.md +2 -0
  2. package/dist/adapter.d.mts +4 -4
  3. package/dist/adapter.mjs +1 -1
  4. package/dist/adapter__codec-types.d.mts +2 -2
  5. package/dist/adapter__control.d.mts +1 -1
  6. package/dist/adapter__control.mjs +1 -1
  7. package/dist/adapter__runtime.d.mts +1 -1
  8. package/dist/adapter__runtime.mjs +17 -6
  9. package/dist/adapter__runtime.mjs.map +1 -1
  10. package/dist/{codec-descriptor-Du6DSz-3-ytBCu_mq.mjs → codec-descriptor-3xp1XvVH-yVLnNzZ8.mjs} +5 -3
  11. package/dist/codec-descriptor-3xp1XvVH-yVLnNzZ8.mjs.map +1 -0
  12. package/dist/codec-ids-CrR9Xi7r-CarpqbNM.mjs +20 -0
  13. package/dist/codec-ids-CrR9Xi7r-CarpqbNM.mjs.map +1 -0
  14. package/dist/codec-ids-Dgh5IpML-76oBMuwK.d.mts +20 -0
  15. package/dist/codec-ids-Dgh5IpML-76oBMuwK.d.mts.map +1 -0
  16. package/dist/codec-types-BH5moCD9.d.mts +1 -0
  17. package/dist/codec-types-Bai_CFkk-Blx2GxCH.d.mts +31 -0
  18. package/dist/codec-types-Bai_CFkk-Blx2GxCH.d.mts.map +1 -0
  19. package/dist/codec-types-zzVcrnbk.d.mts +1 -0
  20. package/dist/codecs-BMidk26M-DsKq6wt5.d.mts +282 -0
  21. package/dist/codecs-BMidk26M-DsKq6wt5.d.mts.map +1 -0
  22. package/dist/codecs-BfiB79-5.mjs +750 -0
  23. package/dist/codecs-BfiB79-5.mjs.map +1 -0
  24. package/dist/codecs-C_twedMx.d.mts +36 -0
  25. package/dist/codecs-C_twedMx.d.mts.map +1 -0
  26. package/dist/{control-CgeXsxCR.mjs → control-5eVF1TXc.mjs} +2 -2
  27. package/dist/{control-CgeXsxCR.mjs.map → control-5eVF1TXc.mjs.map} +1 -1
  28. package/dist/{control-H2sjKXXS.mjs → control-BBhWaGnH.mjs} +24 -13
  29. package/dist/control-BBhWaGnH.mjs.map +1 -0
  30. package/dist/control-BvSM7mGR.d.mts +396 -0
  31. package/dist/control-BvSM7mGR.d.mts.map +1 -0
  32. package/dist/{control-Ez_PtlFI.d.mts → control-MoPFgSaQ.d.mts} +2 -2
  33. package/dist/{control-Ez_PtlFI.d.mts.map → control-MoPFgSaQ.d.mts.map} +1 -1
  34. package/dist/data-type-entries-C7VH2IHc-D1d5I8zF.mjs +59 -0
  35. package/dist/data-type-entries-C7VH2IHc-D1d5I8zF.mjs.map +1 -0
  36. package/dist/{data-types-SXrh0Lou.d.mts → data-types-C-rfxpgB.d.mts} +2 -2
  37. package/dist/data-types-C-rfxpgB.d.mts.map +1 -0
  38. package/dist/data-types-D2HAT-Qf-CRI506c0.d.mts +88 -0
  39. package/dist/data-types-D2HAT-Qf-CRI506c0.d.mts.map +1 -0
  40. package/dist/data-types-DOaaPS93-DBkMJyh1.mjs +289 -0
  41. package/dist/data-types-DOaaPS93-DBkMJyh1.mjs.map +1 -0
  42. package/dist/date-time-now-generators-DY-8Bodc-DcQ3h4Fg.mjs +72 -0
  43. package/dist/date-time-now-generators-DY-8Bodc-DcQ3h4Fg.mjs.map +1 -0
  44. package/dist/{default-normalizer-BDUgHXUn-Xk7HQJuI.mjs → default-normalizer-C8pc7SbL-CKgOEnGl.mjs} +22 -12
  45. package/dist/default-normalizer-C8pc7SbL-CKgOEnGl.mjs.map +1 -0
  46. package/dist/{default-normalizer-BBhGpw7r.d.mts → default-normalizer-CGIwQiKB.d.mts} +4 -4
  47. package/dist/{default-normalizer-BBhGpw7r.d.mts.map → default-normalizer-CGIwQiKB.d.mts.map} +1 -1
  48. package/dist/descriptor-meta-CsMPRsxp-DhK87vlc.mjs +352 -0
  49. package/dist/descriptor-meta-CsMPRsxp-DhK87vlc.mjs.map +1 -0
  50. package/dist/driver.mjs +1 -1
  51. package/dist/driver__control.mjs +1 -1
  52. package/dist/driver__runtime.mjs +1 -1
  53. package/dist/errors-Cng94tYg-D02Eud2d.mjs +87 -0
  54. package/dist/errors-Cng94tYg-D02Eud2d.mjs.map +1 -0
  55. package/dist/{errors-BYhjQT7y.d.mts → errors-DfrC_yfG.d.mts} +2 -2
  56. package/dist/{errors-BYhjQT7y.d.mts.map → errors-DfrC_yfG.d.mts.map} +1 -1
  57. package/dist/{marker-lock-CmGvN4hw-Com29AtQ.mjs → marker-lock-Bwew7cAs-CZ20Y_tA.mjs} +3 -3
  58. package/dist/{marker-lock-CmGvN4hw-Com29AtQ.mjs.map → marker-lock-Bwew7cAs-CZ20Y_tA.mjs.map} +1 -1
  59. package/dist/{marker-read-Cf80LSbG-BZaJ8Ll6.mjs → marker-read-Cf80LSbG-CUp3v1e5.mjs} +3 -3
  60. package/dist/{marker-read-Cf80LSbG-BZaJ8Ll6.mjs.map → marker-read-Cf80LSbG-CUp3v1e5.mjs.map} +1 -1
  61. package/dist/mysql-contract-serializer-BnTKRSsN-B2O3EreV.mjs +35 -0
  62. package/dist/mysql-contract-serializer-BnTKRSsN-B2O3EreV.mjs.map +1 -0
  63. package/dist/{mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs → mysql-database-CHl9-oSL-CWZLDXt6.mjs} +39 -40
  64. package/dist/mysql-database-CHl9-oSL-CWZLDXt6.mjs.map +1 -0
  65. package/dist/now-expression-DVD18CUc-00buJUto.mjs +38 -0
  66. package/dist/now-expression-DVD18CUc-00buJUto.mjs.map +1 -0
  67. package/dist/{pack-DXsOvRJn.d.mts → pack-BXvLVBWP.d.mts} +394 -14
  68. package/dist/{pack-DXsOvRJn.d.mts.map → pack-BXvLVBWP.d.mts.map} +1 -1
  69. package/dist/require-temporal-DeDQhbTn-Bxc65WbA.mjs +16 -0
  70. package/dist/require-temporal-DeDQhbTn-Bxc65WbA.mjs.map +1 -0
  71. package/dist/{runner-BaBQoXiU-C7ln-4b2.mjs → runner-C39AEe6--BVG3xPYw.mjs} +7 -7
  72. package/dist/{runner-BaBQoXiU-C7ln-4b2.mjs.map → runner-C39AEe6--BVG3xPYw.mjs.map} +1 -1
  73. package/dist/{runtime-CeuRr9nE.d.mts → runtime-ClRDfPiY.d.mts} +2 -2
  74. package/dist/{runtime-CeuRr9nE.d.mts.map → runtime-ClRDfPiY.d.mts.map} +1 -1
  75. package/dist/runtime-CrB5DXx4.d.mts +54 -0
  76. package/dist/runtime-CrB5DXx4.d.mts.map +1 -0
  77. package/dist/{sql-utils-Db0IQO_B-PaULnfrE.mjs → sql-utils-Cmv_TVa8-BetrIUcj.mjs} +3 -3
  78. package/dist/{sql-utils-Db0IQO_B-PaULnfrE.mjs.map → sql-utils-Cmv_TVa8-BetrIUcj.mjs.map} +1 -1
  79. package/dist/{sql-utils-RW0vJvDl.mjs → sql-utils-bD4SfgX0.mjs} +2 -2
  80. package/dist/{sql-utils-RW0vJvDl.mjs.map → sql-utils-bD4SfgX0.mjs.map} +1 -1
  81. package/dist/{statement-DC62oiSx-DTx1JaP7.mjs → statement-DC62oiSx-Buzptbpk.mjs} +5 -5
  82. package/dist/{statement-DC62oiSx-DTx1JaP7.mjs.map → statement-DC62oiSx-Buzptbpk.mjs.map} +1 -1
  83. package/dist/target.d.mts +14 -13
  84. package/dist/target.mjs +17 -13
  85. package/dist/target__codec-descriptor.mjs +1 -1
  86. package/dist/target__codec-ids.d.mts +2 -2
  87. package/dist/target__codec-ids.mjs +2 -2
  88. package/dist/target__codec-types.d.mts +2 -2
  89. package/dist/target__codecs.d.mts +3 -3
  90. package/dist/target__codecs.mjs +3 -2
  91. package/dist/target__control.d.mts +2 -2
  92. package/dist/target__control.mjs +38 -32
  93. package/dist/target__control.mjs.map +1 -1
  94. package/dist/target__data-types.d.mts +3 -3
  95. package/dist/target__data-types.mjs +3 -3
  96. package/dist/target__default-normalizer.d.mts +1 -1
  97. package/dist/target__default-normalizer.mjs +1 -1
  98. package/dist/target__errors.d.mts +1 -1
  99. package/dist/target__errors.mjs +1 -1
  100. package/dist/target__marker-lock.mjs +1 -1
  101. package/dist/target__migration.mjs +1 -1
  102. package/dist/target__pack.d.mts +1 -1
  103. package/dist/target__pack.mjs +1 -1
  104. package/dist/target__runtime.d.mts +2 -2
  105. package/dist/target__runtime.mjs +3 -3
  106. package/dist/target__runtime.mjs.map +1 -1
  107. package/dist/target__sql-utils.mjs +2 -2
  108. package/dist/target__types.d.mts +2 -0
  109. package/dist/target__types.mjs +2 -0
  110. package/dist/{control-_4epnrIW.d.mts → types-CgrFHUdk.d.mts} +3 -8
  111. package/dist/types-CgrFHUdk.d.mts.map +1 -0
  112. package/package.json +18 -12
  113. package/dist/codec-descriptor-Du6DSz-3-ytBCu_mq.mjs.map +0 -1
  114. package/dist/codec-ids-cjxtOcLM-vFeQhgPm.mjs +0 -10
  115. package/dist/codec-ids-cjxtOcLM-vFeQhgPm.mjs.map +0 -1
  116. package/dist/codec-ids-sMOU8F-B-BQbCq2dr.d.mts +0 -10
  117. package/dist/codec-ids-sMOU8F-B-BQbCq2dr.d.mts.map +0 -1
  118. package/dist/codec-types-Bd7DL1Mr-CZWNfnp9.d.mts +0 -21
  119. package/dist/codec-types-Bd7DL1Mr-CZWNfnp9.d.mts.map +0 -1
  120. package/dist/codec-types-Bo3Jfilx.d.mts +0 -1
  121. package/dist/codec-types-Ja2kLzLS.d.mts +0 -1
  122. package/dist/codecs-C00kjHgh.mjs +0 -282
  123. package/dist/codecs-C00kjHgh.mjs.map +0 -1
  124. package/dist/codecs-CO_VNEYU-CwAnKzRs.d.mts +0 -102
  125. package/dist/codecs-CO_VNEYU-CwAnKzRs.d.mts.map +0 -1
  126. package/dist/codecs-DM61agRr.d.mts +0 -21
  127. package/dist/codecs-DM61agRr.d.mts.map +0 -1
  128. package/dist/control-H2sjKXXS.mjs.map +0 -1
  129. package/dist/control-_4epnrIW.d.mts.map +0 -1
  130. package/dist/data-type-entries-B0AoBozh-f9AEUIUQ.mjs +0 -42
  131. package/dist/data-type-entries-B0AoBozh-f9AEUIUQ.mjs.map +0 -1
  132. package/dist/data-types-BpihGKoK-BMW-m4EN.d.mts +0 -52
  133. package/dist/data-types-BpihGKoK-BMW-m4EN.d.mts.map +0 -1
  134. package/dist/data-types-Dv9gwVRV-BZPzCWZk.mjs +0 -181
  135. package/dist/data-types-Dv9gwVRV-BZPzCWZk.mjs.map +0 -1
  136. package/dist/data-types-SXrh0Lou.d.mts.map +0 -1
  137. package/dist/default-normalizer-BDUgHXUn-Xk7HQJuI.mjs.map +0 -1
  138. package/dist/descriptor-meta-D7tc0iue-C4W7o0Av.mjs +0 -82
  139. package/dist/descriptor-meta-D7tc0iue-C4W7o0Av.mjs.map +0 -1
  140. package/dist/descriptor-meta-runtime-Cur6umHo-C_4rsCGC.mjs +0 -20
  141. package/dist/descriptor-meta-runtime-Cur6umHo-C_4rsCGC.mjs.map +0 -1
  142. package/dist/errors-rvH_F2Yj-BQrO_--u.mjs +0 -20
  143. package/dist/errors-rvH_F2Yj-BQrO_--u.mjs.map +0 -1
  144. package/dist/mysql-contract-serializer-DLv0uW_f-Cg4A43Ry.mjs.map +0 -1
  145. package/dist/runtime-Cl0BbTZq.d.mts +0 -22
  146. package/dist/runtime-Cl0BbTZq.d.mts.map +0 -1
@@ -0,0 +1,289 @@
1
+ import { s as mysqlError } from "./errors-Cng94tYg-D02Eud2d.mjs";
2
+ import { r as quoteLiteral } from "./sql-utils-Cmv_TVa8-BetrIUcj.mjs";
3
+ import { INT32_RANGE, INT64_RANGE, dateTimeStoredText, numeralText, readJsonInteger, readJsonIntegerText, readJsonString, refuseJsonValue } from "@prisma/orm-framework/components/codec";
4
+ import { structuredError } from "@prisma/orm-framework/utils/structured-error";
5
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
6
+ import { sqlDataType, sqlRawDataType } from "@prisma/orm-family-sql/contract/data-type";
7
+ import { ISO_DURATION_AS_WRITTEN } from "@prisma/orm-framework/type-implementations/duration";
8
+ import { type } from "arktype";
9
+ //#region ../../../3-targets/mysql/1-target/dist/data-types-DOaaPS93.mjs
10
+ const unchanged = (value) => value;
11
+ function wrongShape(value, expected) {
12
+ throw structuredError("CONTRACT.CAST_REFUSED", `Expected ${expected}, got ${JSON.stringify(value)}.`, {
13
+ why: "A cast reads the stored form of the type it takes values of.",
14
+ fix: "Hand the cast a value in the shape its source type stores."
15
+ });
16
+ }
17
+ const asNumeralText = (value) => typeof value === "number" ? numeralText(value) : wrongShape(value, "a number");
18
+ function integerParam(params, name) {
19
+ const value = params[name];
20
+ return typeof value === "number" ? value : void 0;
21
+ }
22
+ /** Text of at most `length` characters, counted as code points, as MySQL counts characters. */
23
+ function readTextOfLength(owner, json, length) {
24
+ const text = readJsonString(owner, json);
25
+ if (length !== void 0 && [...text].length > length) return refuseJsonValue(owner, `a string of at most ${length} ${length === 1 ? "character" : "characters"}`, json);
26
+ return json;
27
+ }
28
+ const mysqlText = sqlDataType("mysql/text", {
29
+ texts: [{
30
+ text: "text",
31
+ written: true,
32
+ catalog: true
33
+ }],
34
+ read: (json) => readJsonString("mysql/text", json),
35
+ casts: {}
36
+ });
37
+ const fromText = { [mysqlText.id]: unchanged };
38
+ /** A signed 32-bit integer, stored as a JSON number. */
39
+ const mysqlInt = sqlDataType("mysql/int", {
40
+ texts: [{
41
+ text: "int",
42
+ written: true,
43
+ catalog: true
44
+ }, { text: "integer" }],
45
+ read: (json) => readJsonInteger("mysql/int", json, INT32_RANGE),
46
+ casts: {}
47
+ });
48
+ /** A signed 64-bit integer, stored as digit text so that no digit is lost. */
49
+ const mysqlBigint = sqlDataType("mysql/bigint", {
50
+ texts: [{
51
+ text: "bigint",
52
+ written: true,
53
+ catalog: true
54
+ }],
55
+ read: (json) => {
56
+ readJsonIntegerText("mysql/bigint", json, INT64_RANGE);
57
+ return json;
58
+ },
59
+ casts: { [mysqlInt.id]: asNumeralText }
60
+ });
61
+ /** The length of `varchar`, which MySQL requires, up to the largest it accepts. */
62
+ const mysqlVarcharParams = type({ length: "number.integer >= 1 & number.integer <= 65535" });
63
+ const mysqlVarchar = sqlDataType("mysql/varchar", {
64
+ params: mysqlVarcharParams,
65
+ texts: [{
66
+ text: "varchar({length})",
67
+ written: true,
68
+ catalog: true
69
+ }],
70
+ read: (json, params) => readTextOfLength("mysql/varchar", json, integerParam(params, "length")),
71
+ casts: fromText
72
+ });
73
+ /** The length of `char`, at most 255; a bare `char` is `char(1)`. */
74
+ const mysqlCharParams = type({ "length?": "number.integer >= 1 & number.integer <= 255" });
75
+ const mysqlChar = sqlDataType("mysql/char", {
76
+ params: mysqlCharParams,
77
+ texts: [{
78
+ text: "char",
79
+ written: true
80
+ }, {
81
+ text: "char({length})",
82
+ written: true,
83
+ catalog: true
84
+ }],
85
+ read: (json, params) => readTextOfLength("mysql/char", json, integerParam(params, "length") ?? 1),
86
+ normalize: (params) => params.length === void 0 ? {
87
+ ...params,
88
+ length: 1
89
+ } : params,
90
+ casts: fromText
91
+ });
92
+ /** The fractional-second precision of `datetime`, `timestamp` and `time`, 0 to 6; MySQL prints a precision of 0 as the bare type. */
93
+ const mysqlDatetimeParams = type({ "precision?": "number.integer >= 0 & number.integer <= 6" });
94
+ /** The years MySQL holds in a `datetime` and a `date`. */
95
+ const MYSQL_DATETIME_RANGE = {
96
+ earliest: "1000-01-01T00:00:00",
97
+ latest: "9999-12-31T23:59:59.999999"
98
+ };
99
+ /** The instants MySQL holds in a `timestamp`, in UTC. */
100
+ const MYSQL_TIMESTAMP_RANGE = {
101
+ earliest: "1970-01-01T00:00:01",
102
+ latest: "2038-01-19T03:14:07.999999"
103
+ };
104
+ const MYSQL_DATE_RANGE = {
105
+ earliest: "1000-01-01",
106
+ latest: "9999-12-31"
107
+ };
108
+ /**
109
+ * The value of `mysql/datetime`: a date and time without a time zone, ISO 8601 text with a `T` and no trailing zeros in the fraction, within MySQL's range. Throws `CONTRACT.CAST_REFUSED` for text that names no such date and time.
110
+ */
111
+ function mysqlDatetimeText(text) {
112
+ return dateTimeStoredText(text, {
113
+ shape: "dateTime",
114
+ ownerId: "mysql/datetime",
115
+ range: MYSQL_DATETIME_RANGE
116
+ });
117
+ }
118
+ /**
119
+ * The value of `mysql/timestamp`: the UTC date and time of an instant from 1970-01-01T00:00:01 to 2038-01-19T03:14:07.999999, in the form `mysql/datetime` stores. Throws `CONTRACT.CAST_REFUSED` for text that names no such date and time.
120
+ */
121
+ function mysqlTimestampText(text) {
122
+ return dateTimeStoredText(text, {
123
+ shape: "dateTime",
124
+ ownerId: "mysql/timestamp",
125
+ range: MYSQL_TIMESTAMP_RANGE
126
+ });
127
+ }
128
+ /** The value of `mysql/date`: a calendar date as ISO 8601 text, `2024-02-29`, in the years 1000 to 9999. Throws `CONTRACT.CAST_REFUSED` for other text. */
129
+ function mysqlDateText(text) {
130
+ return dateTimeStoredText(text, {
131
+ shape: "date",
132
+ ownerId: "mysql/date",
133
+ range: MYSQL_DATE_RANGE
134
+ });
135
+ }
136
+ /**
137
+ * The value of `mysql/time`: a time of day from 00:00:00 to 23:59:59.999999, ISO 8601 text with no trailing zeros in the fraction. MySQL's `time` also holds a negative time and hours past 23, which name no time of day, so they are refused. Throws `CONTRACT.CAST_REFUSED` for other text.
138
+ */
139
+ function mysqlTimeText(text) {
140
+ return dateTimeStoredText(text, {
141
+ shape: "time",
142
+ ownerId: "mysql/time"
143
+ });
144
+ }
145
+ /** The value of `mysql/duration`: an ISO 8601 duration, stored as written. Throws `CONTRACT.CAST_REFUSED` for other text. */
146
+ function mysqlDurationText(text) {
147
+ if (ISO_DURATION_AS_WRITTEN.test(text)) return text;
148
+ throw structuredError("CONTRACT.CAST_REFUSED", `mysql/duration cannot read "${text}". Write an ISO 8601 duration, as in "PT1H30M".`, {
149
+ why: "mysql/duration holds an ISO 8601 duration as Temporal.Duration writes it: an optional sign, P, then years, months, weeks and days, then T and hours, minutes and seconds. A sign on each component instead is read too.",
150
+ fix: "Write the duration in ISO 8601, as in \"P1Y2M3DT4H5M6.5S\"."
151
+ });
152
+ }
153
+ /** What `stored` writes for `text`, or `undefined` when `stored` refuses it. */
154
+ function storedOrUndefined(stored, text) {
155
+ try {
156
+ return stored(text);
157
+ } catch {
158
+ return;
159
+ }
160
+ }
161
+ function readStored(id, stored, expected) {
162
+ return (json) => typeof json === "string" && storedOrUndefined(stored, json) !== void 0 ? json : refuseJsonValue(id, expected, json);
163
+ }
164
+ function spellStored(stored) {
165
+ return (json) => typeof json === "string" ? storedOrUndefined(stored, json) ?? json : json;
166
+ }
167
+ const withoutZeroPrecision = ({ precision, ...rest }) => precision === 0 ? rest : {
168
+ ...rest,
169
+ ...ifDefined("precision", precision)
170
+ };
171
+ const mysqlDatetime = sqlDataType("mysql/datetime", {
172
+ params: mysqlDatetimeParams,
173
+ texts: [{
174
+ text: "datetime",
175
+ written: true,
176
+ catalog: true
177
+ }, {
178
+ text: "datetime({precision})",
179
+ written: true,
180
+ catalog: true
181
+ }],
182
+ read: readStored("mysql/datetime", mysqlDatetimeText, "ISO 8601 date and time text without a UTC offset, as in \"2024-01-01T00:00:00\""),
183
+ spell: spellStored(mysqlDatetimeText),
184
+ normalize: withoutZeroPrecision,
185
+ casts: {}
186
+ });
187
+ /** An instant from 1970 to 2038, which MySQL converts between the session's time zone and UTC; every session runs in UTC. */
188
+ const mysqlTimestamp = sqlDataType("mysql/timestamp", {
189
+ params: mysqlDatetimeParams,
190
+ texts: [{
191
+ text: "timestamp",
192
+ written: true,
193
+ catalog: true
194
+ }, {
195
+ text: "timestamp({precision})",
196
+ written: true,
197
+ catalog: true
198
+ }],
199
+ read: readStored("mysql/timestamp", mysqlTimestampText, "ISO 8601 date and time text in UTC without a UTC offset, from 1970-01-01T00:00:01 to 2038-01-19T03:14:07.999999"),
200
+ spell: spellStored(mysqlTimestampText),
201
+ normalize: withoutZeroPrecision,
202
+ casts: {}
203
+ });
204
+ const mysqlDate = sqlDataType("mysql/date", {
205
+ texts: [{
206
+ text: "date",
207
+ written: true,
208
+ catalog: true
209
+ }],
210
+ read: readStored("mysql/date", mysqlDateText, "ISO 8601 date text, as in \"2024-02-29\""),
211
+ spell: spellStored(mysqlDateText),
212
+ casts: {}
213
+ });
214
+ const mysqlTime = sqlDataType("mysql/time", {
215
+ params: mysqlDatetimeParams,
216
+ texts: [{
217
+ text: "time",
218
+ written: true,
219
+ catalog: true
220
+ }, {
221
+ text: "time({precision})",
222
+ written: true,
223
+ catalog: true
224
+ }],
225
+ read: readStored("mysql/time", mysqlTimeText, "ISO 8601 time of day text from 00:00:00 to 23:59:59.999999, as in \"09:30:00\""),
226
+ spell: spellStored(mysqlTimeText),
227
+ normalize: withoutZeroPrecision,
228
+ casts: {}
229
+ });
230
+ /** The length of the `varchar` a duration column is stored in. A codec reference with none, as a raw parameter writes, reads and writes the same values. */
231
+ const mysqlDurationParams = type({ "length?": "number.integer >= 1 & number.integer <= 65535" });
232
+ /** A length of time, stored in a `varchar` column as the ISO 8601 duration it was written as, `PT1H30M`, so that MySQL can index it. MySQL has no interval type, and equal durations can be written differently, `P1D` and `PT24H`, so a duration keeps its spelling. ADR 315. */
233
+ const mysqlDuration = sqlDataType("mysql/duration", {
234
+ storedAs: mysqlVarchar.id,
235
+ read: readStored("mysql/duration", mysqlDurationText, "an ISO 8601 duration, as in \"PT1H30M\""),
236
+ casts: {}
237
+ });
238
+ /** The members of a native enum column, in the order they are declared. */
239
+ const mysqlEnumParams = type({ "values?": "string[]" });
240
+ /** `enum('A','B')`, the text MySQL's catalog prints for the column type, with each member a quoted literal. */
241
+ function renderMysqlEnumType(values) {
242
+ if (values === void 0 || values.length === 0) throw mysqlError("CONTRACT.TYPE_PARAMS_INVALID", "A MySQL enum column type needs at least one member.", {
243
+ why: "A native enum column is written with its members, and this column has none.",
244
+ fix: "Type the column with a PSL enum or an enumType() that declares its members.",
245
+ meta: { dataType: "mysql/enum" }
246
+ });
247
+ return `enum(${values.map(quoteLiteral).join(",")})`;
248
+ }
249
+ const readEnumMember = (json, params) => {
250
+ const member = readJsonString("mysql/enum", json);
251
+ const values = params["values"];
252
+ if (Array.isArray(values) && !values.includes(member)) return refuseJsonValue("mysql/enum", `one of the members ${values.join(", ")}`, json);
253
+ return json;
254
+ };
255
+ /**
256
+ * A native MySQL enum. Its name is the catalog text `enum('A','B')`, so `db verify` compares the members and their order with what MySQL reports (ADR 273). A column's members are its value set's, written into its parameters by the target's namespace (see `mysql-database.ts`).
257
+ */
258
+ const mysqlEnum = sqlDataType("mysql/enum", {
259
+ params: mysqlEnumParams,
260
+ nameIsCatalogText: true,
261
+ render: ({ values }) => renderMysqlEnumType(values),
262
+ read: readEnumMember,
263
+ casts: fromText
264
+ });
265
+ /** Every data type this target registers. */
266
+ const mysqlDataTypes = [
267
+ mysqlText,
268
+ mysqlInt,
269
+ mysqlBigint,
270
+ mysqlVarchar,
271
+ mysqlChar,
272
+ mysqlDatetime,
273
+ mysqlTimestamp,
274
+ mysqlDate,
275
+ mysqlTime,
276
+ mysqlDuration,
277
+ mysqlEnum,
278
+ sqlRawDataType
279
+ ];
280
+ /** MySQL's text data types, which a SQL discriminator column may have. */
281
+ const mysqlTextDataTypes = [
282
+ mysqlText.id,
283
+ mysqlVarchar.id,
284
+ mysqlChar.id
285
+ ];
286
+ //#endregion
287
+ export { mysqlTimestampText as C, renderMysqlEnumType as E, mysqlTimestamp as S, mysqlVarcharParams as T, mysqlInt as _, mysqlCharParams as a, mysqlTime as b, mysqlDateText as c, mysqlDatetimeText as d, mysqlDuration as f, mysqlEnumParams as g, mysqlEnum as h, mysqlChar as i, mysqlDatetime as l, mysqlDurationText as m, MYSQL_TIMESTAMP_RANGE as n, mysqlDataTypes as o, mysqlDurationParams as p, mysqlBigint as r, mysqlDate as s, MYSQL_DATETIME_RANGE as t, mysqlDatetimeParams as u, mysqlText as v, mysqlVarchar as w, mysqlTimeText as x, mysqlTextDataTypes as y };
288
+
289
+ //# sourceMappingURL=data-types-DOaaPS93-DBkMJyh1.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-types-DOaaPS93-DBkMJyh1.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/data-types-DOaaPS93.mjs"],"sourcesContent":["import { s as mysqlError } from \"./errors-Cng94tYg.mjs\";\nimport { r as quoteLiteral } from \"./sql-utils-Cmv_TVa8.mjs\";\nimport { INT32_RANGE, INT64_RANGE, dateTimeStoredText, numeralText, readJsonInteger, readJsonIntegerText, readJsonString, refuseJsonValue } from \"@internal/framework-components/codec\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { sqlDataType, sqlRawDataType } from \"@internal/sql-contract/data-type\";\nimport { ISO_DURATION_AS_WRITTEN } from \"@internal/type-implementations/duration\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { type } from \"arktype\";\n//#region src/core/data-types.ts\nconst unchanged = (value) => value;\nfunction wrongShape(value, expected) {\n\tthrow structuredError(\"CONTRACT.CAST_REFUSED\", `Expected ${expected}, got ${JSON.stringify(value)}.`, {\n\t\twhy: \"A cast reads the stored form of the type it takes values of.\",\n\t\tfix: \"Hand the cast a value in the shape its source type stores.\"\n\t});\n}\nconst asNumeralText = (value) => typeof value === \"number\" ? numeralText(value) : wrongShape(value, \"a number\");\nfunction integerParam(params, name) {\n\tconst value = params[name];\n\treturn typeof value === \"number\" ? value : void 0;\n}\n/** Text of at most `length` characters, counted as code points, as MySQL counts characters. */\nfunction readTextOfLength(owner, json, length) {\n\tconst text = readJsonString(owner, json);\n\tif (length !== void 0 && [...text].length > length) return refuseJsonValue(owner, `a string of at most ${length} ${length === 1 ? \"character\" : \"characters\"}`, json);\n\treturn json;\n}\nconst mysqlText = sqlDataType(\"mysql/text\", {\n\ttexts: [{\n\t\ttext: \"text\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json) => readJsonString(\"mysql/text\", json),\n\tcasts: {}\n});\nconst fromText = { [mysqlText.id]: unchanged };\n/** A signed 32-bit integer, stored as a JSON number. */\nconst mysqlInt = sqlDataType(\"mysql/int\", {\n\ttexts: [{\n\t\ttext: \"int\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}, { text: \"integer\" }],\n\tread: (json) => readJsonInteger(\"mysql/int\", json, INT32_RANGE),\n\tcasts: {}\n});\n/** A signed 64-bit integer, stored as digit text so that no digit is lost. */\nconst mysqlBigint = sqlDataType(\"mysql/bigint\", {\n\ttexts: [{\n\t\ttext: \"bigint\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json) => {\n\t\treadJsonIntegerText(\"mysql/bigint\", json, INT64_RANGE);\n\t\treturn json;\n\t},\n\tcasts: { [mysqlInt.id]: asNumeralText }\n});\n/** The length of `varchar`, which MySQL requires, up to the largest it accepts. */\nconst mysqlVarcharParams = type({ length: \"number.integer >= 1 & number.integer <= 65535\" });\nconst mysqlVarchar = sqlDataType(\"mysql/varchar\", {\n\tparams: mysqlVarcharParams,\n\ttexts: [{\n\t\ttext: \"varchar({length})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json, params) => readTextOfLength(\"mysql/varchar\", json, integerParam(params, \"length\")),\n\tcasts: fromText\n});\n/** The length of `char`, at most 255; a bare `char` is `char(1)`. */\nconst mysqlCharParams = type({ \"length?\": \"number.integer >= 1 & number.integer <= 255\" });\nconst mysqlChar = sqlDataType(\"mysql/char\", {\n\tparams: mysqlCharParams,\n\ttexts: [{\n\t\ttext: \"char\",\n\t\twritten: true\n\t}, {\n\t\ttext: \"char({length})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: (json, params) => readTextOfLength(\"mysql/char\", json, integerParam(params, \"length\") ?? 1),\n\tnormalize: (params) => params.length === void 0 ? {\n\t\t...params,\n\t\tlength: 1\n\t} : params,\n\tcasts: fromText\n});\n/** The fractional-second precision of `datetime`, `timestamp` and `time`, 0 to 6; MySQL prints a precision of 0 as the bare type. */\nconst mysqlDatetimeParams = type({ \"precision?\": \"number.integer >= 0 & number.integer <= 6\" });\n/** The years MySQL holds in a `datetime` and a `date`. */\nconst MYSQL_DATETIME_RANGE = {\n\tearliest: \"1000-01-01T00:00:00\",\n\tlatest: \"9999-12-31T23:59:59.999999\"\n};\n/** The instants MySQL holds in a `timestamp`, in UTC. */\nconst MYSQL_TIMESTAMP_RANGE = {\n\tearliest: \"1970-01-01T00:00:01\",\n\tlatest: \"2038-01-19T03:14:07.999999\"\n};\nconst MYSQL_DATE_RANGE = {\n\tearliest: \"1000-01-01\",\n\tlatest: \"9999-12-31\"\n};\n/**\n* The value of `mysql/datetime`: a date and time without a time zone, ISO 8601 text with a `T` and no trailing zeros in the fraction, within MySQL's range. Throws `CONTRACT.CAST_REFUSED` for text that names no such date and time.\n*/\nfunction mysqlDatetimeText(text) {\n\treturn dateTimeStoredText(text, {\n\t\tshape: \"dateTime\",\n\t\townerId: \"mysql/datetime\",\n\t\trange: MYSQL_DATETIME_RANGE\n\t});\n}\n/**\n* The value of `mysql/timestamp`: the UTC date and time of an instant from 1970-01-01T00:00:01 to 2038-01-19T03:14:07.999999, in the form `mysql/datetime` stores. Throws `CONTRACT.CAST_REFUSED` for text that names no such date and time.\n*/\nfunction mysqlTimestampText(text) {\n\treturn dateTimeStoredText(text, {\n\t\tshape: \"dateTime\",\n\t\townerId: \"mysql/timestamp\",\n\t\trange: MYSQL_TIMESTAMP_RANGE\n\t});\n}\n/** The value of `mysql/date`: a calendar date as ISO 8601 text, `2024-02-29`, in the years 1000 to 9999. Throws `CONTRACT.CAST_REFUSED` for other text. */\nfunction mysqlDateText(text) {\n\treturn dateTimeStoredText(text, {\n\t\tshape: \"date\",\n\t\townerId: \"mysql/date\",\n\t\trange: MYSQL_DATE_RANGE\n\t});\n}\n/**\n* The value of `mysql/time`: a time of day from 00:00:00 to 23:59:59.999999, ISO 8601 text with no trailing zeros in the fraction. MySQL's `time` also holds a negative time and hours past 23, which name no time of day, so they are refused. Throws `CONTRACT.CAST_REFUSED` for other text.\n*/\nfunction mysqlTimeText(text) {\n\treturn dateTimeStoredText(text, {\n\t\tshape: \"time\",\n\t\townerId: \"mysql/time\"\n\t});\n}\n/** The value of `mysql/duration`: an ISO 8601 duration, stored as written. Throws `CONTRACT.CAST_REFUSED` for other text. */\nfunction mysqlDurationText(text) {\n\tif (ISO_DURATION_AS_WRITTEN.test(text)) return text;\n\tthrow structuredError(\"CONTRACT.CAST_REFUSED\", `mysql/duration cannot read \"${text}\". Write an ISO 8601 duration, as in \"PT1H30M\".`, {\n\t\twhy: \"mysql/duration holds an ISO 8601 duration as Temporal.Duration writes it: an optional sign, P, then years, months, weeks and days, then T and hours, minutes and seconds. A sign on each component instead is read too.\",\n\t\tfix: \"Write the duration in ISO 8601, as in \\\"P1Y2M3DT4H5M6.5S\\\".\"\n\t});\n}\n/** What `stored` writes for `text`, or `undefined` when `stored` refuses it. */\nfunction storedOrUndefined(stored, text) {\n\ttry {\n\t\treturn stored(text);\n\t} catch {\n\t\treturn;\n\t}\n}\nfunction readStored(id, stored, expected) {\n\treturn (json) => typeof json === \"string\" && storedOrUndefined(stored, json) !== void 0 ? json : refuseJsonValue(id, expected, json);\n}\nfunction spellStored(stored) {\n\treturn (json) => typeof json === \"string\" ? storedOrUndefined(stored, json) ?? json : json;\n}\nconst withoutZeroPrecision = ({ precision, ...rest }) => precision === 0 ? rest : {\n\t...rest,\n\t...ifDefined(\"precision\", precision)\n};\nconst mysqlDatetime = sqlDataType(\"mysql/datetime\", {\n\tparams: mysqlDatetimeParams,\n\ttexts: [{\n\t\ttext: \"datetime\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}, {\n\t\ttext: \"datetime({precision})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: readStored(\"mysql/datetime\", mysqlDatetimeText, \"ISO 8601 date and time text without a UTC offset, as in \\\"2024-01-01T00:00:00\\\"\"),\n\tspell: spellStored(mysqlDatetimeText),\n\tnormalize: withoutZeroPrecision,\n\tcasts: {}\n});\n/** An instant from 1970 to 2038, which MySQL converts between the session's time zone and UTC; every session runs in UTC. */\nconst mysqlTimestamp = sqlDataType(\"mysql/timestamp\", {\n\tparams: mysqlDatetimeParams,\n\ttexts: [{\n\t\ttext: \"timestamp\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}, {\n\t\ttext: \"timestamp({precision})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: readStored(\"mysql/timestamp\", mysqlTimestampText, \"ISO 8601 date and time text in UTC without a UTC offset, from 1970-01-01T00:00:01 to 2038-01-19T03:14:07.999999\"),\n\tspell: spellStored(mysqlTimestampText),\n\tnormalize: withoutZeroPrecision,\n\tcasts: {}\n});\nconst mysqlDate = sqlDataType(\"mysql/date\", {\n\ttexts: [{\n\t\ttext: \"date\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: readStored(\"mysql/date\", mysqlDateText, \"ISO 8601 date text, as in \\\"2024-02-29\\\"\"),\n\tspell: spellStored(mysqlDateText),\n\tcasts: {}\n});\nconst mysqlTime = sqlDataType(\"mysql/time\", {\n\tparams: mysqlDatetimeParams,\n\ttexts: [{\n\t\ttext: \"time\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}, {\n\t\ttext: \"time({precision})\",\n\t\twritten: true,\n\t\tcatalog: true\n\t}],\n\tread: readStored(\"mysql/time\", mysqlTimeText, \"ISO 8601 time of day text from 00:00:00 to 23:59:59.999999, as in \\\"09:30:00\\\"\"),\n\tspell: spellStored(mysqlTimeText),\n\tnormalize: withoutZeroPrecision,\n\tcasts: {}\n});\n/** The length of the `varchar` a duration column is stored in. A codec reference with none, as a raw parameter writes, reads and writes the same values. */\nconst mysqlDurationParams = type({ \"length?\": \"number.integer >= 1 & number.integer <= 65535\" });\n/** A length of time, stored in a `varchar` column as the ISO 8601 duration it was written as, `PT1H30M`, so that MySQL can index it. MySQL has no interval type, and equal durations can be written differently, `P1D` and `PT24H`, so a duration keeps its spelling. ADR 315. */\nconst mysqlDuration = sqlDataType(\"mysql/duration\", {\n\tstoredAs: mysqlVarchar.id,\n\tread: readStored(\"mysql/duration\", mysqlDurationText, \"an ISO 8601 duration, as in \\\"PT1H30M\\\"\"),\n\tcasts: {}\n});\n/** The members of a native enum column, in the order they are declared. */\nconst mysqlEnumParams = type({ \"values?\": \"string[]\" });\n/** `enum('A','B')`, the text MySQL's catalog prints for the column type, with each member a quoted literal. */\nfunction renderMysqlEnumType(values) {\n\tif (values === void 0 || values.length === 0) throw mysqlError(\"CONTRACT.TYPE_PARAMS_INVALID\", \"A MySQL enum column type needs at least one member.\", {\n\t\twhy: \"A native enum column is written with its members, and this column has none.\",\n\t\tfix: \"Type the column with a PSL enum or an enumType() that declares its members.\",\n\t\tmeta: { dataType: \"mysql/enum\" }\n\t});\n\treturn `enum(${values.map(quoteLiteral).join(\",\")})`;\n}\nconst readEnumMember = (json, params) => {\n\tconst member = readJsonString(\"mysql/enum\", json);\n\tconst values = params[\"values\"];\n\tif (Array.isArray(values) && !values.includes(member)) return refuseJsonValue(\"mysql/enum\", `one of the members ${values.join(\", \")}`, json);\n\treturn json;\n};\n/**\n* A native MySQL enum. Its name is the catalog text `enum('A','B')`, so `db verify` compares the members and their order with what MySQL reports (ADR 273). A column's members are its value set's, written into its parameters by the target's namespace (see `mysql-database.ts`).\n*/\nconst mysqlEnum = sqlDataType(\"mysql/enum\", {\n\tparams: mysqlEnumParams,\n\tnameIsCatalogText: true,\n\trender: ({ values }) => renderMysqlEnumType(values),\n\tread: readEnumMember,\n\tcasts: fromText\n});\n/** Every data type this target registers. */\nconst mysqlDataTypes = [\n\tmysqlText,\n\tmysqlInt,\n\tmysqlBigint,\n\tmysqlVarchar,\n\tmysqlChar,\n\tmysqlDatetime,\n\tmysqlTimestamp,\n\tmysqlDate,\n\tmysqlTime,\n\tmysqlDuration,\n\tmysqlEnum,\n\tsqlRawDataType\n];\n/** MySQL's text data types, which a SQL discriminator column may have. */\nconst mysqlTextDataTypes = [\n\tmysqlText.id,\n\tmysqlVarchar.id,\n\tmysqlChar.id\n];\n//#endregion\nexport { mysqlTimestampText as C, renderMysqlEnumType as E, mysqlTimestamp as S, mysqlVarcharParams as T, mysqlInt as _, mysqlCharParams as a, mysqlTime as b, mysqlDateText as c, mysqlDatetimeText as d, mysqlDuration as f, mysqlEnumParams as g, mysqlEnum as h, mysqlChar as i, mysqlDatetime as l, mysqlDurationText as m, MYSQL_TIMESTAMP_RANGE as n, mysqlDataTypes as o, mysqlDurationParams as p, mysqlBigint as r, mysqlDate as s, MYSQL_DATETIME_RANGE as t, mysqlDatetimeParams as u, mysqlText as v, mysqlVarchar as w, mysqlTimeText as x, mysqlTextDataTypes as y };\n\n//# sourceMappingURL=data-types-DOaaPS93.mjs.map"],"mappings":"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"}
@@ -0,0 +1,72 @@
1
+ import { o as mysqlDataTypes } from "./data-types-DOaaPS93-DBkMJyh1.mjs";
2
+ import { t as requireTemporal } from "./require-temporal-DeDQhbTn-Bxc65WbA.mjs";
3
+ import * as nowValues from "@prisma/orm-framework/type-implementations/now";
4
+ import { DATE_STRING_NOW_GENERATOR_ID, INSTANT_NOW_GENERATOR_ID, INSTANT_STRING_NOW_GENERATOR_ID, PLAIN_DATE_NOW_GENERATOR_ID, PLAIN_TIME_NOW_GENERATOR_ID, TIME_STRING_NOW_GENERATOR_ID, fractionDigitsOf } from "@prisma/orm-framework/type-implementations/now";
5
+ //#region ../../../3-targets/mysql/1-target/dist/date-time-now-generators-DY-8Bodc.mjs
6
+ /** The runtime-safe part of the MySQL target's metadata: it leaves out `authoring`, which only contract construction reads. Every session runs in UTC, because the datetime codec reads and writes UTC, and at READ COMMITTED, as Postgres does, so a read inside a transaction sees rows other sessions committed. Transaction isolation controls will replace the setting. */
7
+ const mysqlTargetDescriptorMetaRuntime = {
8
+ kind: "target",
9
+ familyId: "sql",
10
+ targetId: "mysql",
11
+ id: "mysql",
12
+ version: "0.0.1",
13
+ capabilities: {},
14
+ dataTypes: mysqlDataTypes,
15
+ sessionSettings: {
16
+ time_zone: "+00:00",
17
+ transaction_isolation: "READ-COMMITTED"
18
+ }
19
+ };
20
+ /** The fraction digits of a bare `datetime`, `timestamp` or `time`. */
21
+ const BARE_TYPE_FRACTION_DIGITS = 0;
22
+ function fractionDigits(params) {
23
+ return fractionDigitsOf(params, BARE_TYPE_FRACTION_DIGITS);
24
+ }
25
+ function instantNow(params) {
26
+ return nowValues.instantNow(requireTemporal({ generatorId: INSTANT_NOW_GENERATOR_ID }), fractionDigits(params));
27
+ }
28
+ function plainDateNow() {
29
+ return nowValues.plainDateNow(requireTemporal({ generatorId: PLAIN_DATE_NOW_GENERATOR_ID }));
30
+ }
31
+ function plainTimeNow(params) {
32
+ return nowValues.plainTimeNow(requireTemporal({ generatorId: PLAIN_TIME_NOW_GENERATOR_ID }), fractionDigits(params));
33
+ }
34
+ function instantStringNow(params) {
35
+ return nowValues.instantStringNow(fractionDigits(params), "trimmed");
36
+ }
37
+ function timeStringNow(params) {
38
+ return nowValues.timeStringNow(fractionDigits(params), "trimmed");
39
+ }
40
+ /**
41
+ * The MySQL "now" generators, one per date and time codec except `mysql/datetime@1` and `mysql/timestamp-date@1`, which use the SQL family's `timestampNow`. All read the clock through `Date.now()` and write UTC. Each rounds down to the column's `precision` param, so MySQL, which rounds a value to the column's fraction digits, stores the value the client holds rather than rounding it up. The string generators write the text their codec reads, with no trailing zeros in the fraction.
42
+ */
43
+ const mysqlNowGenerators = [
44
+ {
45
+ id: INSTANT_NOW_GENERATOR_ID,
46
+ generate: instantNow
47
+ },
48
+ {
49
+ id: PLAIN_DATE_NOW_GENERATOR_ID,
50
+ generate: plainDateNow
51
+ },
52
+ {
53
+ id: PLAIN_TIME_NOW_GENERATOR_ID,
54
+ generate: plainTimeNow
55
+ },
56
+ {
57
+ id: INSTANT_STRING_NOW_GENERATOR_ID,
58
+ generate: instantStringNow
59
+ },
60
+ {
61
+ id: DATE_STRING_NOW_GENERATOR_ID,
62
+ generate: nowValues.dateStringNow
63
+ },
64
+ {
65
+ id: TIME_STRING_NOW_GENERATOR_ID,
66
+ generate: timeStringNow
67
+ }
68
+ ];
69
+ //#endregion
70
+ export { mysqlTargetDescriptorMetaRuntime as n, mysqlNowGenerators as t };
71
+
72
+ //# sourceMappingURL=date-time-now-generators-DY-8Bodc-DcQ3h4Fg.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-time-now-generators-DY-8Bodc-DcQ3h4Fg.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/date-time-now-generators-DY-8Bodc.mjs"],"sourcesContent":["import { o as mysqlDataTypes } from \"./data-types-DOaaPS93.mjs\";\nimport { t as requireTemporal } from \"./require-temporal-DeDQhbTn.mjs\";\nimport * as nowValues from \"@internal/type-implementations/now\";\nimport { DATE_STRING_NOW_GENERATOR_ID, INSTANT_NOW_GENERATOR_ID, INSTANT_STRING_NOW_GENERATOR_ID, PLAIN_DATE_NOW_GENERATOR_ID, PLAIN_TIME_NOW_GENERATOR_ID, TIME_STRING_NOW_GENERATOR_ID, fractionDigitsOf } from \"@internal/type-implementations/now\";\n/** The runtime-safe part of the MySQL target's metadata: it leaves out `authoring`, which only contract construction reads. Every session runs in UTC, because the datetime codec reads and writes UTC, and at READ COMMITTED, as Postgres does, so a read inside a transaction sees rows other sessions committed. Transaction isolation controls will replace the setting. */\nconst mysqlTargetDescriptorMetaRuntime = {\n\tkind: \"target\",\n\tfamilyId: \"sql\",\n\ttargetId: \"mysql\",\n\tid: \"mysql\",\n\tversion: \"0.0.1\",\n\tcapabilities: {},\n\tdataTypes: mysqlDataTypes,\n\tsessionSettings: {\n\t\ttime_zone: \"+00:00\",\n\t\ttransaction_isolation: \"READ-COMMITTED\"\n\t}\n};\n//#endregion\n//#region src/core/date-time-now-generators.ts\n/** The fraction digits of a bare `datetime`, `timestamp` or `time`. */\nconst BARE_TYPE_FRACTION_DIGITS = 0;\nfunction fractionDigits(params) {\n\treturn fractionDigitsOf(params, BARE_TYPE_FRACTION_DIGITS);\n}\nfunction instantNow(params) {\n\treturn nowValues.instantNow(requireTemporal({ generatorId: INSTANT_NOW_GENERATOR_ID }), fractionDigits(params));\n}\nfunction plainDateNow() {\n\treturn nowValues.plainDateNow(requireTemporal({ generatorId: PLAIN_DATE_NOW_GENERATOR_ID }));\n}\nfunction plainTimeNow(params) {\n\treturn nowValues.plainTimeNow(requireTemporal({ generatorId: PLAIN_TIME_NOW_GENERATOR_ID }), fractionDigits(params));\n}\nfunction instantStringNow(params) {\n\treturn nowValues.instantStringNow(fractionDigits(params), \"trimmed\");\n}\nfunction timeStringNow(params) {\n\treturn nowValues.timeStringNow(fractionDigits(params), \"trimmed\");\n}\n/**\n* The MySQL \"now\" generators, one per date and time codec except `mysql/datetime@1` and `mysql/timestamp-date@1`, which use the SQL family's `timestampNow`. All read the clock through `Date.now()` and write UTC. Each rounds down to the column's `precision` param, so MySQL, which rounds a value to the column's fraction digits, stores the value the client holds rather than rounding it up. The string generators write the text their codec reads, with no trailing zeros in the fraction.\n*/\nconst mysqlNowGenerators = [\n\t{\n\t\tid: INSTANT_NOW_GENERATOR_ID,\n\t\tgenerate: instantNow\n\t},\n\t{\n\t\tid: PLAIN_DATE_NOW_GENERATOR_ID,\n\t\tgenerate: plainDateNow\n\t},\n\t{\n\t\tid: PLAIN_TIME_NOW_GENERATOR_ID,\n\t\tgenerate: plainTimeNow\n\t},\n\t{\n\t\tid: INSTANT_STRING_NOW_GENERATOR_ID,\n\t\tgenerate: instantStringNow\n\t},\n\t{\n\t\tid: DATE_STRING_NOW_GENERATOR_ID,\n\t\tgenerate: nowValues.dateStringNow\n\t},\n\t{\n\t\tid: TIME_STRING_NOW_GENERATOR_ID,\n\t\tgenerate: timeStringNow\n\t}\n];\n//#endregion\nexport { mysqlTargetDescriptorMetaRuntime as n, mysqlNowGenerators as t };\n\n//# sourceMappingURL=date-time-now-generators-DY-8Bodc.mjs.map"],"mappings":";;;;;;AAKA,MAAM,mCAAmC;CACxC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,CAAC;CACf,WAAW;CACX,iBAAiB;EAChB,WAAW;EACX,uBAAuB;CACxB;AACD;;AAIA,MAAM,4BAA4B;AAClC,SAAS,eAAe,QAAQ;CAC/B,OAAO,iBAAiB,QAAQ,yBAAyB;AAC1D;AACA,SAAS,WAAW,QAAQ;CAC3B,OAAO,UAAU,WAAW,gBAAgB,EAAE,aAAa,yBAAyB,CAAC,GAAG,eAAe,MAAM,CAAC;AAC/G;AACA,SAAS,eAAe;CACvB,OAAO,UAAU,aAAa,gBAAgB,EAAE,aAAa,4BAA4B,CAAC,CAAC;AAC5F;AACA,SAAS,aAAa,QAAQ;CAC7B,OAAO,UAAU,aAAa,gBAAgB,EAAE,aAAa,4BAA4B,CAAC,GAAG,eAAe,MAAM,CAAC;AACpH;AACA,SAAS,iBAAiB,QAAQ;CACjC,OAAO,UAAU,iBAAiB,eAAe,MAAM,GAAG,SAAS;AACpE;AACA,SAAS,cAAc,QAAQ;CAC9B,OAAO,UAAU,cAAc,eAAe,MAAM,GAAG,SAAS;AACjE;;;;AAIA,MAAM,qBAAqB;CAC1B;EACC,IAAI;EACJ,UAAU;CACX;CACA;EACC,IAAI;EACJ,UAAU;CACX;CACA;EACC,IAAI;EACJ,UAAU;CACX;CACA;EACC,IAAI;EACJ,UAAU;CACX;CACA;EACC,IAAI;EACJ,UAAU,UAAU;CACrB;CACA;EACC,IAAI;EACJ,UAAU;CACX;AACD"}
@@ -1,13 +1,18 @@
1
- //#region ../../../3-targets/mysql/1-target/dist/default-normalizer-BDUgHXUn.mjs
1
+ import { i as mysqlCurrentValueFor, n as MYSQL_INSTANT_NOW, r as MYSQL_TIME_NOW, t as MYSQL_DATE_NOW } from "./now-expression-DVD18CUc-00buJUto.mjs";
2
+ //#region ../../../3-targets/mysql/1-target/dist/default-normalizer-C8pc7SbL.mjs
2
3
  const AUTOINCREMENT = {
3
4
  kind: "function",
4
5
  expression: "autoincrement()"
5
6
  };
6
- const NOW = {
7
- kind: "function",
8
- expression: "now()"
9
- };
10
7
  const CURRENT_TIMESTAMP = /^(?:current_timestamp|now|localtime|localtimestamp)(?:\s*\(\s*\d*\s*\))?$/i;
8
+ const CURRENT_DATE = /^(?:curdate|current_date)(?:\s*\(\s*\))?$/i;
9
+ const CURRENT_TIME = /^(?:curtime|current_time)(?:\s*\(\s*\d*\s*\))?$/i;
10
+ /** The name of the current value `expression` writes: `now()` for the current instant, and its own name for the current date and the current time of day, which hold different values. `undefined` for any other expression. */
11
+ function currentValueNamed(expression) {
12
+ if (CURRENT_TIMESTAMP.test(expression)) return MYSQL_INSTANT_NOW;
13
+ if (CURRENT_DATE.test(expression)) return MYSQL_DATE_NOW;
14
+ if (CURRENT_TIME.test(expression)) return MYSQL_TIME_NOW;
15
+ }
11
16
  const SQL_ESCAPES = {
12
17
  "0": "\0",
13
18
  b: "\b",
@@ -48,7 +53,7 @@ function extraFlags(extra) {
48
53
  return extra.toLowerCase().split(/\s+/);
49
54
  }
50
55
  /**
51
- * Reads a column's reported default from `COLUMN_DEFAULT` and `EXTRA`. `auto_increment` is `autoincrement()`; a string with a character set introducer, the form MySQL reports for a literal default on a text, blob or JSON column, is that literal; an expression default that writes the current time, such as `CURRENT_TIMESTAMP(3)`, is `now()`; any other expression default is a function default kept as reported; and anything else is a literal. `undefined` when the column has no default.
56
+ * Reads a column's reported default from `COLUMN_DEFAULT` and `EXTRA`. `auto_increment` is `autoincrement()`; a string with a character set introducer, the form MySQL reports for a literal default on a text, blob or JSON column, is that literal; an expression default that writes the current instant, such as `CURRENT_TIMESTAMP(3)`, is `now()`, and one that writes the current date or time of day, `curdate()` or `curtime(6)`, is `CURRENT_DATE` or `CURRENT_TIME`; any other expression default is a function default kept as reported; and anything else is a literal. `undefined` when the column has no default.
52
57
  */
53
58
  function readMysqlDefault(columnDefault, extra) {
54
59
  const flags = extraFlags(extra);
@@ -64,9 +69,9 @@ function readMysqlDefault(columnDefault, extra) {
64
69
  }
65
70
  };
66
71
  const expression = columnDefault.trim();
67
- return CURRENT_TIMESTAMP.test(expression) ? NOW : {
72
+ return {
68
73
  kind: "function",
69
- expression
74
+ expression: currentValueNamed(expression) ?? expression
70
75
  };
71
76
  }
72
77
  return {
@@ -78,13 +83,18 @@ function readMysqlDefault(columnDefault, extra) {
78
83
  };
79
84
  }
80
85
  /**
81
- * Names a contract's expression default the way {@link readMysqlDefault} names the same function in the database, so `` sql`CURRENT_TIMESTAMP(3)` `` and the database's `now()` compare equal. Every other default passes through unchanged.
86
+ * Names a contract's expression default the way {@link readMysqlDefault} names the same function in the database, so `` sql`CURRENT_TIMESTAMP(3)` `` and the database's `now()` compare equal. A `now()` default is named as the current value its column's data type writes, so a `now()` on a `date` column and one on a `datetime` column differ, as the values they write do. Every other default passes through unchanged.
82
87
  */
83
- function mysqlResolveDefault(def, _column) {
88
+ function mysqlResolveDefault(def, column) {
84
89
  if (def.kind !== "function") return def;
85
- return CURRENT_TIMESTAMP.test(def.expression.trim()) ? NOW : def;
90
+ const expression = def.expression.trim();
91
+ const named = expression === "now()" ? mysqlCurrentValueFor(column.dataTypeId) : currentValueNamed(expression);
92
+ return named === void 0 ? def : {
93
+ kind: "function",
94
+ expression: named
95
+ };
86
96
  }
87
97
  //#endregion
88
98
  export { readMysqlDefault as n, mysqlResolveDefault as t };
89
99
 
90
- //# sourceMappingURL=default-normalizer-BDUgHXUn-Xk7HQJuI.mjs.map
100
+ //# sourceMappingURL=default-normalizer-C8pc7SbL-CKgOEnGl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-normalizer-C8pc7SbL-CKgOEnGl.mjs","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/default-normalizer-C8pc7SbL.mjs"],"sourcesContent":["import { i as mysqlCurrentValueFor, n as MYSQL_INSTANT_NOW, r as MYSQL_TIME_NOW, t as MYSQL_DATE_NOW } from \"./now-expression-DVD18CUc.mjs\";\n//#region src/core/default-normalizer.ts\nconst AUTOINCREMENT = {\n\tkind: \"function\",\n\texpression: \"autoincrement()\"\n};\nconst CURRENT_TIMESTAMP = /^(?:current_timestamp|now|localtime|localtimestamp)(?:\\s*\\(\\s*\\d*\\s*\\))?$/i;\nconst CURRENT_DATE = /^(?:curdate|current_date)(?:\\s*\\(\\s*\\))?$/i;\nconst CURRENT_TIME = /^(?:curtime|current_time)(?:\\s*\\(\\s*\\d*\\s*\\))?$/i;\n/** The name of the current value `expression` writes: `now()` for the current instant, and its own name for the current date and the current time of day, which hold different values. `undefined` for any other expression. */\nfunction currentValueNamed(expression) {\n\tif (CURRENT_TIMESTAMP.test(expression)) return MYSQL_INSTANT_NOW;\n\tif (CURRENT_DATE.test(expression)) return MYSQL_DATE_NOW;\n\tif (CURRENT_TIME.test(expression)) return MYSQL_TIME_NOW;\n}\nconst SQL_ESCAPES = {\n\t\"0\": \"\\0\",\n\tb: \"\\b\",\n\tn: \"\\n\",\n\tr: \"\\r\",\n\tt: \"\t\",\n\tZ: \"\u001a\"\n};\nconst INTRODUCED_STRING = /^_[A-Za-z0-9]+'/;\nfunction withoutBackslashEscapes(text) {\n\treturn text.replace(/\\\\(.)/gs, \"$1\");\n}\n/** The text of a MySQL string literal whose opening quote ends `start`, when the literal runs to the end of `text`. */\nfunction stringLiteralBody(text, start) {\n\tlet body = \"\";\n\tfor (let index = start; index < text.length; index += 1) {\n\t\tconst char = text.charAt(index);\n\t\tif (char === \"\\\\\") {\n\t\t\tindex += 1;\n\t\t\tconst escaped = text.charAt(index);\n\t\t\tbody += escaped === \"%\" || escaped === \"_\" ? `\\\\${escaped}` : SQL_ESCAPES[escaped] ?? escaped;\n\t\t} else if (char === \"'\" && text.charAt(index + 1) === \"'\") {\n\t\t\tbody += \"'\";\n\t\t\tindex += 1;\n\t\t} else if (char === \"'\") return index === text.length - 1 ? body : void 0;\n\t\telse body += char;\n\t}\n}\n/**\n* The value of a default MySQL reports as a string with a character set introducer, such as `_utf8mb4\\'abc\\'`: the form a literal default on a text, blob or JSON column takes, because MySQL writes it as an expression. `undefined` for any other expression.\n*/\nfunction introducedStringValue(reported) {\n\tconst expression = withoutBackslashEscapes(reported.trim());\n\tconst opening = INTRODUCED_STRING.exec(expression);\n\treturn opening === null ? void 0 : stringLiteralBody(expression, opening[0].length);\n}\nfunction extraFlags(extra) {\n\treturn extra.toLowerCase().split(/\\s+/);\n}\n/**\n* Reads a column's reported default from `COLUMN_DEFAULT` and `EXTRA`. `auto_increment` is `autoincrement()`; a string with a character set introducer, the form MySQL reports for a literal default on a text, blob or JSON column, is that literal; an expression default that writes the current instant, such as `CURRENT_TIMESTAMP(3)`, is `now()`, and one that writes the current date or time of day, `curdate()` or `curtime(6)`, is `CURRENT_DATE` or `CURRENT_TIME`; any other expression default is a function default kept as reported; and anything else is a literal. `undefined` when the column has no default.\n*/\nfunction readMysqlDefault(columnDefault, extra) {\n\tconst flags = extraFlags(extra);\n\tif (flags.includes(\"auto_increment\")) return AUTOINCREMENT;\n\tif (columnDefault === null) return void 0;\n\tif (flags.includes(\"default_generated\")) {\n\t\tconst introduced = introducedStringValue(columnDefault);\n\t\tif (introduced !== void 0) return {\n\t\t\tkind: \"literal\",\n\t\t\tliteral: {\n\t\t\t\tkind: \"value\",\n\t\t\t\tbody: introduced\n\t\t\t}\n\t\t};\n\t\tconst expression = columnDefault.trim();\n\t\treturn {\n\t\t\tkind: \"function\",\n\t\t\texpression: currentValueNamed(expression) ?? expression\n\t\t};\n\t}\n\treturn {\n\t\tkind: \"literal\",\n\t\tliteral: {\n\t\t\tkind: \"value\",\n\t\t\tbody: columnDefault\n\t\t}\n\t};\n}\n/**\n* Names a contract's expression default the way {@link readMysqlDefault} names the same function in the database, so `` sql`CURRENT_TIMESTAMP(3)` `` and the database's `now()` compare equal. A `now()` default is named as the current value its column's data type writes, so a `now()` on a `date` column and one on a `datetime` column differ, as the values they write do. Every other default passes through unchanged.\n*/\nfunction mysqlResolveDefault(def, column) {\n\tif (def.kind !== \"function\") return def;\n\tconst expression = def.expression.trim();\n\tconst named = expression === \"now()\" ? mysqlCurrentValueFor(column.dataTypeId) : currentValueNamed(expression);\n\treturn named === void 0 ? def : {\n\t\tkind: \"function\",\n\t\texpression: named\n\t};\n}\n//#endregion\nexport { readMysqlDefault as n, mysqlResolveDefault as t };\n\n//# sourceMappingURL=default-normalizer-C8pc7SbL.mjs.map"],"mappings":";;AAEA,MAAM,gBAAgB;CACrB,MAAM;CACN,YAAY;AACb;AACA,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,eAAe;;AAErB,SAAS,kBAAkB,YAAY;CACtC,IAAI,kBAAkB,KAAK,UAAU,GAAG,OAAO;CAC/C,IAAI,aAAa,KAAK,UAAU,GAAG,OAAO;CAC1C,IAAI,aAAa,KAAK,UAAU,GAAG,OAAO;AAC3C;AACA,MAAM,cAAc;CACnB,KAAK;CACL,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;AACJ;AACA,MAAM,oBAAoB;AAC1B,SAAS,wBAAwB,MAAM;CACtC,OAAO,KAAK,QAAQ,WAAW,IAAI;AACpC;;AAEA,SAAS,kBAAkB,MAAM,OAAO;CACvC,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,OAAO,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACxD,MAAM,OAAO,KAAK,OAAO,KAAK;EAC9B,IAAI,SAAS,MAAM;GAClB,SAAS;GACT,MAAM,UAAU,KAAK,OAAO,KAAK;GACjC,QAAQ,YAAY,OAAO,YAAY,MAAM,KAAK,YAAY,YAAY,YAAY;EACvF,OAAO,IAAI,SAAS,OAAO,KAAK,OAAO,QAAQ,CAAC,MAAM,KAAK;GAC1D,QAAQ;GACR,SAAS;EACV,OAAO,IAAI,SAAS,KAAK,OAAO,UAAU,KAAK,SAAS,IAAI,OAAO,KAAK;OACnE,QAAQ;CACd;AACD;;;;AAIA,SAAS,sBAAsB,UAAU;CACxC,MAAM,aAAa,wBAAwB,SAAS,KAAK,CAAC;CAC1D,MAAM,UAAU,kBAAkB,KAAK,UAAU;CACjD,OAAO,YAAY,OAAO,KAAK,IAAI,kBAAkB,YAAY,QAAQ,EAAE,CAAC,MAAM;AACnF;AACA,SAAS,WAAW,OAAO;CAC1B,OAAO,MAAM,YAAY,CAAC,CAAC,MAAM,KAAK;AACvC;;;;AAIA,SAAS,iBAAiB,eAAe,OAAO;CAC/C,MAAM,QAAQ,WAAW,KAAK;CAC9B,IAAI,MAAM,SAAS,gBAAgB,GAAG,OAAO;CAC7C,IAAI,kBAAkB,MAAM,OAAO,KAAK;CACxC,IAAI,MAAM,SAAS,mBAAmB,GAAG;EACxC,MAAM,aAAa,sBAAsB,aAAa;EACtD,IAAI,eAAe,KAAK,GAAG,OAAO;GACjC,MAAM;GACN,SAAS;IACR,MAAM;IACN,MAAM;GACP;EACD;EACA,MAAM,aAAa,cAAc,KAAK;EACtC,OAAO;GACN,MAAM;GACN,YAAY,kBAAkB,UAAU,KAAK;EAC9C;CACD;CACA,OAAO;EACN,MAAM;EACN,SAAS;GACR,MAAM;GACN,MAAM;EACP;CACD;AACD;;;;AAIA,SAAS,oBAAoB,KAAK,QAAQ;CACzC,IAAI,IAAI,SAAS,YAAY,OAAO;CACpC,MAAM,aAAa,IAAI,WAAW,KAAK;CACvC,MAAM,QAAQ,eAAe,UAAU,qBAAqB,OAAO,UAAU,IAAI,kBAAkB,UAAU;CAC7G,OAAO,UAAU,KAAK,IAAI,MAAM;EAC/B,MAAM;EACN,YAAY;CACb;AACD"}
@@ -15,13 +15,13 @@ type MysqlReportedDefault = {
15
15
  };
16
16
  };
17
17
  /**
18
- * Reads a column's reported default from `COLUMN_DEFAULT` and `EXTRA`. `auto_increment` is `autoincrement()`; a string with a character set introducer, the form MySQL reports for a literal default on a text, blob or JSON column, is that literal; an expression default that writes the current time, such as `CURRENT_TIMESTAMP(3)`, is `now()`; any other expression default is a function default kept as reported; and anything else is a literal. `undefined` when the column has no default.
18
+ * Reads a column's reported default from `COLUMN_DEFAULT` and `EXTRA`. `auto_increment` is `autoincrement()`; a string with a character set introducer, the form MySQL reports for a literal default on a text, blob or JSON column, is that literal; an expression default that writes the current instant, such as `CURRENT_TIMESTAMP(3)`, is `now()`, and one that writes the current date or time of day, `curdate()` or `curtime(6)`, is `CURRENT_DATE` or `CURRENT_TIME`; any other expression default is a function default kept as reported; and anything else is a literal. `undefined` when the column has no default.
19
19
  */
20
20
  declare function readMysqlDefault(columnDefault: string | null, extra: string): MysqlReportedDefault | undefined;
21
21
  /**
22
- * Names a contract's expression default the way {@link readMysqlDefault} names the same function in the database, so `` sql`CURRENT_TIMESTAMP(3)` `` and the database's `now()` compare equal. Every other default passes through unchanged.
22
+ * Names a contract's expression default the way {@link readMysqlDefault} names the same function in the database, so `` sql`CURRENT_TIMESTAMP(3)` `` and the database's `now()` compare equal. A `now()` default is named as the current value its column's data type writes, so a `now()` on a `date` column and one on a `datetime` column differ, as the values they write do. Every other default passes through unchanged.
23
23
  */
24
- declare function mysqlResolveDefault(def: ColumnDefault, _column: DefaultResolverColumn): ColumnDefault;
24
+ declare function mysqlResolveDefault(def: ColumnDefault, column: DefaultResolverColumn): ColumnDefault;
25
25
  //#endregion
26
26
  export { mysqlResolveDefault as n, readMysqlDefault as r, MysqlReportedDefault as t };
27
- //# sourceMappingURL=default-normalizer-BBhGpw7r.d.mts.map
27
+ //# sourceMappingURL=default-normalizer-CGIwQiKB.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-normalizer-BBhGpw7r.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/default-normalizer.d.mts"],"mappings":";;;;;KAIK;WACM;WACA;;WAEA;WACA,SAAS,QAAQ;aACf;;aAEA;;;;;;iBAMI,iBAAiB,8BAA8B,gBAAgB;;;;iBAI/D,oBAAoB,KAAK,eAAe,SAAS,wBAAwB"}
1
+ {"version":3,"file":"default-normalizer-CGIwQiKB.d.mts","names":[],"sources":["../../../../3-targets/mysql/1-target/dist/default-normalizer.d.mts"],"mappings":";;;;;KAIK;WACM;WACA;;WAEA;WACA,SAAS,QAAQ;aACf;;aAEA;;;;;;iBAMI,iBAAiB,8BAA8B,gBAAgB;;;;iBAI/D,oBAAoB,KAAK,eAAe,QAAQ,wBAAwB"}