@prisma/orm-family-sql 8.0.0-rc.19-dev.6 → 8.0.0-rc.19-dev.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{authoring-entity-types-DUQLeBf_-DSWWvkLJ.d.mts → authoring-entity-types-CgKIgWq5-Dxf_T0Ih.d.mts} +3 -3
- package/dist/authoring-entity-types-CgKIgWq5-Dxf_T0Ih.d.mts.map +1 -0
- package/dist/{config-types-BLDwd9wS.mjs → config-types-BbBY5_GQ.mjs} +2 -2
- package/dist/{config-types-BLDwd9wS.mjs.map → config-types-BbBY5_GQ.mjs.map} +1 -1
- package/dist/{contract-builder-CNeGxqP_.mjs → contract-builder-D7cTmhfs.mjs} +4 -5
- package/dist/contract-builder-D7cTmhfs.mjs.map +1 -0
- package/dist/contract-prisma7__provider.mjs +10 -4
- package/dist/contract-prisma7__provider.mjs.map +1 -1
- package/dist/contract-psl.mjs +1 -1
- package/dist/contract-psl__attribute-specs.mjs +1 -1
- package/dist/contract-psl__provider.mjs +2 -2
- package/dist/contract-psl__provider.mjs.map +1 -1
- package/dist/contract-ts.mjs +3 -3
- package/dist/contract-ts__config-types.mjs +1 -1
- package/dist/contract-ts__contract-builder.mjs +2 -2
- package/dist/contract.d.mts +3 -3
- package/dist/contract.mjs +3 -3
- package/dist/contract__data-type-support.d.mts +2 -2
- package/dist/contract__data-type-support.mjs +2 -2
- package/dist/contract__data-type.d.mts +2 -2
- package/dist/contract__data-type.mjs +2 -2
- package/dist/{control-Dv1ea79q.d.mts → control-BW6gbqvb.d.mts} +2 -2
- package/dist/{control-Dv1ea79q.d.mts.map → control-BW6gbqvb.d.mts.map} +1 -1
- package/dist/{control-Cih61sJa.mjs → control-DnFJf5_F.mjs} +3 -3
- package/dist/{control-Cih61sJa.mjs.map → control-DnFJf5_F.mjs.map} +1 -1
- package/dist/{data-type-CUJMZOHo.mjs → data-type-BMnEHaW3.mjs} +2 -17
- package/dist/data-type-BMnEHaW3.mjs.map +1 -0
- package/dist/{data-type-CWFhlpaq.d.mts → data-type-iatMyRs6.d.mts} +2 -9
- package/dist/data-type-iatMyRs6.d.mts.map +1 -0
- package/dist/data-type-support-a9BR-PbH.d.mts +7 -0
- package/dist/data-type-support-a9BR-PbH.d.mts.map +1 -0
- package/dist/data-type-support-juGV2d9c.mjs +9 -0
- package/dist/data-type-support-juGV2d9c.mjs.map +1 -0
- package/dist/{derived-checks-iXF3y0Ki-28vqz_8w.mjs → derived-checks-D5HVRvqN-B37oe30Z.mjs} +2 -2
- package/dist/{derived-checks-iXF3y0Ki-28vqz_8w.mjs.map → derived-checks-D5HVRvqN-B37oe30Z.mjs.map} +1 -1
- package/dist/{exports-CRROThzp-BNz0pGj0.mjs → exports-C3wGYtID-Bg6ThaBe.mjs} +88 -39
- package/dist/exports-C3wGYtID-Bg6ThaBe.mjs.map +1 -0
- package/dist/family.d.mts +3 -3
- package/dist/family.mjs +4 -4
- package/dist/family__control.d.mts +1 -1
- package/dist/family__control.mjs +1 -1
- package/dist/family__pack.d.mts +1 -1
- package/dist/family__pack.mjs +2 -2
- package/dist/family__psl-build.d.mts +1 -1
- package/dist/family__psl-build.mjs +1 -1
- package/dist/{generator-functions-DuDZSQHE-Dl5EP61A.mjs → generator-functions-D_qdqBV--BoeJwWsz.mjs} +4 -4
- package/dist/generator-functions-D_qdqBV--BoeJwWsz.mjs.map +1 -0
- package/dist/{index-3aEIvk82.d.mts → index-BAxGJxON.d.mts} +11 -9
- package/dist/index-BAxGJxON.d.mts.map +1 -0
- package/dist/{interpreter-BGgim2OE-D9BG-4aU.mjs → interpreter-BDpym-rc-BZVFp5GU.mjs} +112 -77
- package/dist/interpreter-BDpym-rc-BZVFp5GU.mjs.map +1 -0
- package/dist/orm-client.d.mts +1 -1
- package/dist/orm-client.mjs +1 -1
- package/dist/{pack-B5_CfdgT.mjs → pack-BifOs83a.mjs} +3 -3
- package/dist/{pack-B5_CfdgT.mjs.map → pack-BifOs83a.mjs.map} +1 -1
- package/dist/{pack-BJ53Inwa.d.mts → pack-CdaZMfI_.d.mts} +2 -2
- package/dist/{pack-BJ53Inwa.d.mts.map → pack-CdaZMfI_.d.mts.map} +1 -1
- package/dist/{psl-build-prdUw3sC.d.mts → psl-build-BYXXz2XD.d.mts} +2 -2
- package/dist/{psl-build-prdUw3sC.d.mts.map → psl-build-BYXXz2XD.d.mts.map} +1 -1
- package/dist/{psl-build-D5VG40ej.mjs → psl-build-fwoI6rBO.mjs} +3 -4
- package/dist/{psl-build-D5VG40ej.mjs.map → psl-build-fwoI6rBO.mjs.map} +1 -1
- package/dist/{psl-field-resolution-C9zwpsAu-DCc7Eifv.mjs → psl-field-resolution-C5KQ7kzP-DH8oSBIL.mjs} +4 -22
- package/dist/psl-field-resolution-C5KQ7kzP-DH8oSBIL.mjs.map +1 -0
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +1 -1
- package/package.json +18 -18
- package/dist/authoring-entity-types-DUQLeBf_-DSWWvkLJ.d.mts.map +0 -1
- package/dist/contract-builder-CNeGxqP_.mjs.map +0 -1
- package/dist/data-type-CUJMZOHo.mjs.map +0 -1
- package/dist/data-type-CWFhlpaq.d.mts.map +0 -1
- package/dist/data-type-support-C5-XxxeB.mjs +0 -364
- package/dist/data-type-support-C5-XxxeB.mjs.map +0 -1
- package/dist/data-type-support-CBcYhSkD.d.mts +0 -88
- package/dist/data-type-support-CBcYhSkD.d.mts.map +0 -1
- package/dist/exports-CRROThzp-BNz0pGj0.mjs.map +0 -1
- package/dist/generator-functions-DuDZSQHE-Dl5EP61A.mjs.map +0 -1
- package/dist/index-3aEIvk82.d.mts.map +0 -1
- package/dist/interpreter-BGgim2OE-D9BG-4aU.mjs.map +0 -1
- package/dist/psl-field-resolution-C9zwpsAu-DCc7Eifv.mjs.map +0 -1
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
import { structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
2
|
-
import { isNonFiniteText } from "@prisma/orm-framework/components/codec";
|
|
3
|
-
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
4
|
-
//#region ../../../2-sql/1-core/contract/dist/data-type-support.mjs
|
|
5
|
-
const WRITTEN_INTEGER_TEXT = /^[+-]?\d+$/;
|
|
6
|
-
const WRITTEN_DECIMAL_TEXT = /^[+-]?\d+\.\d+$/;
|
|
7
|
-
const DECIMAL_NUMERAL = /^([+-]?)0*(\d+)(\.\d+)?$/;
|
|
8
|
-
/** Whether `text` is a whole number or a decimal as a contract source writes one. */
|
|
9
|
-
function isNumeralText(text) {
|
|
10
|
-
return WRITTEN_INTEGER_TEXT.test(text) || WRITTEN_DECIMAL_TEXT.test(text);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* A written numeral as the contract stores it. Leading zeros and the sign of zero never change a
|
|
14
|
-
* number, so they go; trailing zeros stay, because a type without a scale keeps them.
|
|
15
|
-
*/
|
|
16
|
-
function storedNumeralText(text) {
|
|
17
|
-
const numeral = DECIMAL_NUMERAL.exec(text);
|
|
18
|
-
if (numeral === null) return text;
|
|
19
|
-
const [, sign = "", whole = "", fraction = ""] = numeral;
|
|
20
|
-
const digits = `${whole}${fraction}`;
|
|
21
|
-
return sign !== "-" || /^[0.]+$/.test(digits) ? digits : `-${digits}`;
|
|
22
|
-
}
|
|
23
|
-
/** A string as a contract source writes it, with the escapes its string reader resolves. */
|
|
24
|
-
function escapePslString(value) {
|
|
25
|
-
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
26
|
-
}
|
|
27
|
-
/** The range of a signed integer of `bits` bits. */
|
|
28
|
-
function signedRange(bits) {
|
|
29
|
-
const half = 2n ** (BigInt(bits) - 1n);
|
|
30
|
-
return {
|
|
31
|
-
min: -half,
|
|
32
|
-
max: half - 1n
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* The classifier one target's plain-number authoring entry carries: it reads the digits and says
|
|
37
|
-
* which of the target's types the value is, in that type's stored form. `undefined` means no
|
|
38
|
-
* type of this target holds the number.
|
|
39
|
-
*/
|
|
40
|
-
function createNumberClassifier(spec) {
|
|
41
|
-
const as = (classification, value) => classification === void 0 ? void 0 : {
|
|
42
|
-
type: classification.type,
|
|
43
|
-
value
|
|
44
|
-
};
|
|
45
|
-
return (text) => {
|
|
46
|
-
if (isNonFiniteText(text)) return as(spec.words, spec.words?.form === "number" ? Number(text) : text);
|
|
47
|
-
if (WRITTEN_DECIMAL_TEXT.test(text)) {
|
|
48
|
-
const canonical = storedNumeralText(text);
|
|
49
|
-
return as(spec.fraction, spec.fraction?.form === "number" ? Number(canonical) : canonical);
|
|
50
|
-
}
|
|
51
|
-
if (!WRITTEN_INTEGER_TEXT.test(text)) return void 0;
|
|
52
|
-
const digits = BigInt(text);
|
|
53
|
-
const classification = spec.integers.find(({ min, max }) => digits >= min && digits <= max) ?? spec.largerWhole;
|
|
54
|
-
return as(classification, classification?.form === "number" ? Number(digits) : digits.toString());
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Read JSON text into the document it holds.
|
|
59
|
-
*
|
|
60
|
-
* `JSON.parse` reads a numeral too large for a double as `Infinity`, and `JSON.stringify` writes
|
|
61
|
-
* that back as `null`, so a document holding one would not be the document stored; it is refused
|
|
62
|
-
* here instead, naming where the number is.
|
|
63
|
-
*/
|
|
64
|
-
function parseJsonText(text) {
|
|
65
|
-
let value;
|
|
66
|
-
try {
|
|
67
|
-
value = JSON.parse(text);
|
|
68
|
-
} catch (error) {
|
|
69
|
-
throw structuredError("CONTRACT.INVALID_JSON_LITERAL", error instanceof Error ? error.message : String(error), {
|
|
70
|
-
why: "The text is not a JSON document.",
|
|
71
|
-
fix: "Write a JSON document."
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
const overflowed = nonFiniteNumberIn(value, "");
|
|
75
|
-
if (overflowed !== void 0) throw structuredError("CONTRACT.INVALID_JSON_LITERAL", `${overflowed.path} is ${overflowed.value}, which JSON cannot write back: the number in the text is outside the range a JSON number holds.`, {
|
|
76
|
-
why: "JSON.parse reads a numeral too large for a double as Infinity, which JSON.stringify writes back as null.",
|
|
77
|
-
fix: "Write a number JSON can hold, or write it as text."
|
|
78
|
-
});
|
|
79
|
-
return value;
|
|
80
|
-
}
|
|
81
|
-
/** Write a document as the text of a JSON literal. */
|
|
82
|
-
function printJsonText(value) {
|
|
83
|
-
return JSON.stringify(value);
|
|
84
|
-
}
|
|
85
|
-
function nonFiniteNumberIn(value, path) {
|
|
86
|
-
if (typeof value === "number") return Number.isFinite(value) ? void 0 : {
|
|
87
|
-
path: path === "" ? "The value" : path,
|
|
88
|
-
value
|
|
89
|
-
};
|
|
90
|
-
if (Array.isArray(value)) {
|
|
91
|
-
for (const [index, element] of value.entries()) {
|
|
92
|
-
const found = nonFiniteNumberIn(element, `${path}[${index}]`);
|
|
93
|
-
if (found !== void 0) return found;
|
|
94
|
-
}
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (typeof value === "object" && value !== null) for (const [key, member] of Object.entries(value)) {
|
|
98
|
-
const found = nonFiniteNumberIn(member, path === "" ? key : `${path}.${key}`);
|
|
99
|
-
if (found !== void 0) return found;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* The reader the SQL targets build the stored form of each date and time type with; ADR 254
|
|
104
|
-
* states the forms and the text it reads.
|
|
105
|
-
*/
|
|
106
|
-
const SHAPES = {
|
|
107
|
-
date: {
|
|
108
|
-
description: "a date",
|
|
109
|
-
plural: "dates",
|
|
110
|
-
example: "2024-01-01",
|
|
111
|
-
date: true,
|
|
112
|
-
time: false,
|
|
113
|
-
offset: false
|
|
114
|
-
},
|
|
115
|
-
time: {
|
|
116
|
-
description: "a time of day",
|
|
117
|
-
plural: "times of day",
|
|
118
|
-
example: "12:34:56",
|
|
119
|
-
date: false,
|
|
120
|
-
time: true,
|
|
121
|
-
offset: false
|
|
122
|
-
},
|
|
123
|
-
timeWithOffset: {
|
|
124
|
-
description: "a time of day with a UTC offset",
|
|
125
|
-
plural: "times of day with a UTC offset",
|
|
126
|
-
example: "12:34:56+02:00",
|
|
127
|
-
date: false,
|
|
128
|
-
time: true,
|
|
129
|
-
offset: true
|
|
130
|
-
},
|
|
131
|
-
dateTime: {
|
|
132
|
-
description: "a date and time",
|
|
133
|
-
plural: "dates and times",
|
|
134
|
-
example: "2024-01-01T12:34:56",
|
|
135
|
-
date: true,
|
|
136
|
-
time: true,
|
|
137
|
-
offset: false
|
|
138
|
-
},
|
|
139
|
-
instant: {
|
|
140
|
-
description: "a date and time with a UTC offset",
|
|
141
|
-
plural: "instants",
|
|
142
|
-
example: "2024-01-01T12:34:56Z",
|
|
143
|
-
date: true,
|
|
144
|
-
time: true,
|
|
145
|
-
offset: true
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
const DATE_PREFIX = /^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})/;
|
|
149
|
-
const TIME_PREFIX = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?/;
|
|
150
|
-
const OFFSET = /^([+-])(\d{2})(?::(\d{2})(?::(\d{2}))?)?$/;
|
|
151
|
-
const MAX_FRACTION_DIGITS = 6;
|
|
152
|
-
const FRACTION_UNITS = {
|
|
153
|
-
3: "milliseconds",
|
|
154
|
-
6: "microseconds"
|
|
155
|
-
};
|
|
156
|
-
const SECONDS_PER_DAY = 86400;
|
|
157
|
-
const MIDNIGHT = {
|
|
158
|
-
hour: 0,
|
|
159
|
-
minute: 0,
|
|
160
|
-
second: 0,
|
|
161
|
-
fraction: ""
|
|
162
|
-
};
|
|
163
|
-
function refused(message) {
|
|
164
|
-
throw structuredError("CONTRACT.CAST_REFUSED", message, {
|
|
165
|
-
why: "A date or time type stores one form for each value (ADR 254).",
|
|
166
|
-
fix: "Write text the type holds, as the message shows."
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
function isLeapYear(year) {
|
|
170
|
-
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
171
|
-
}
|
|
172
|
-
function daysInMonth(year, month) {
|
|
173
|
-
if (month === 2) return isLeapYear(year) ? 29 : 28;
|
|
174
|
-
return [
|
|
175
|
-
4,
|
|
176
|
-
6,
|
|
177
|
-
9,
|
|
178
|
-
11
|
|
179
|
-
].includes(month) ? 30 : 31;
|
|
180
|
-
}
|
|
181
|
-
/** Days from 1970-01-01 to a date of the proleptic Gregorian calendar, with year 0 as 1 BC. */
|
|
182
|
-
function daysFromCivil({ year, month, day }) {
|
|
183
|
-
const shifted = month <= 2 ? year - 1 : year;
|
|
184
|
-
const era = Math.floor(shifted / 400);
|
|
185
|
-
const yearOfEra = shifted - era * 400;
|
|
186
|
-
const dayOfYear = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;
|
|
187
|
-
const dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;
|
|
188
|
-
return era * 146097 + dayOfEra - 719468;
|
|
189
|
-
}
|
|
190
|
-
function civilFromDays(days) {
|
|
191
|
-
const shifted = days + 719468;
|
|
192
|
-
const era = Math.floor(shifted / 146097);
|
|
193
|
-
const dayOfEra = shifted - era * 146097;
|
|
194
|
-
const yearOfEra = Math.floor((dayOfEra - Math.floor(dayOfEra / 1460) + Math.floor(dayOfEra / 36524) - Math.floor(dayOfEra / 146096)) / 365);
|
|
195
|
-
const dayOfYear = dayOfEra - (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));
|
|
196
|
-
const monthIndex = Math.floor((5 * dayOfYear + 2) / 153);
|
|
197
|
-
const day = dayOfYear - Math.floor((153 * monthIndex + 2) / 5) + 1;
|
|
198
|
-
const month = monthIndex < 10 ? monthIndex + 3 : monthIndex - 9;
|
|
199
|
-
return {
|
|
200
|
-
year: yearOfEra + era * 400 + (month <= 2 ? 1 : 0),
|
|
201
|
-
month,
|
|
202
|
-
day
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
function pad(value, width = 2) {
|
|
206
|
-
return String(value).padStart(width, "0");
|
|
207
|
-
}
|
|
208
|
-
function yearText(year) {
|
|
209
|
-
if (year >= 0 && year <= 9999) return pad(year, 4);
|
|
210
|
-
return `${year < 0 ? "-" : "+"}${pad(Math.abs(year), 6)}`;
|
|
211
|
-
}
|
|
212
|
-
function dateText(date) {
|
|
213
|
-
return `${yearText(date.year)}-${pad(date.month)}-${pad(date.day)}`;
|
|
214
|
-
}
|
|
215
|
-
function timeText(time) {
|
|
216
|
-
const fraction = time.fraction.replace(/0+$/, "");
|
|
217
|
-
return `${pad(time.hour)}:${pad(time.minute)}:${pad(time.second)}${fraction === "" ? "" : `.${fraction}`}`;
|
|
218
|
-
}
|
|
219
|
-
function offsetText(seconds) {
|
|
220
|
-
if (seconds === 0) return "Z";
|
|
221
|
-
const magnitude = Math.abs(seconds);
|
|
222
|
-
const rest = magnitude % 60;
|
|
223
|
-
return `${seconds < 0 ? "-" : "+"}${pad(Math.floor(magnitude / 3600))}:${pad(Math.floor(magnitude / 60) % 60)}${rest === 0 ? "" : `:${pad(rest)}`}`;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* The fields of an ISO 8601 date, time, or date and time, or `undefined` when the text is not one.
|
|
227
|
-
* Ranges are checked by the caller, which words the refusal.
|
|
228
|
-
*/
|
|
229
|
-
function readWritten(text) {
|
|
230
|
-
let rest = text;
|
|
231
|
-
let date;
|
|
232
|
-
let timeFollows = true;
|
|
233
|
-
const dateMatch = DATE_PREFIX.exec(rest);
|
|
234
|
-
if (dateMatch !== null) {
|
|
235
|
-
const [whole, yearDigits = "", month = "", day = ""] = dateMatch;
|
|
236
|
-
if (yearDigits === "-000000") return void 0;
|
|
237
|
-
date = {
|
|
238
|
-
year: Number(yearDigits),
|
|
239
|
-
month: Number(month),
|
|
240
|
-
day: Number(day)
|
|
241
|
-
};
|
|
242
|
-
rest = rest.slice(whole.length);
|
|
243
|
-
timeFollows = /^[Tt ]/.test(rest);
|
|
244
|
-
if (timeFollows) rest = rest.slice(1);
|
|
245
|
-
}
|
|
246
|
-
let time;
|
|
247
|
-
let fractionDigits = 0;
|
|
248
|
-
if (timeFollows) {
|
|
249
|
-
const timeMatch = TIME_PREFIX.exec(rest);
|
|
250
|
-
if (timeMatch === null) return void 0;
|
|
251
|
-
const [whole, hour = "", minute = "", second = "00", fraction = ""] = timeMatch;
|
|
252
|
-
time = {
|
|
253
|
-
hour: Number(hour),
|
|
254
|
-
minute: Number(minute),
|
|
255
|
-
second: Number(second),
|
|
256
|
-
fraction
|
|
257
|
-
};
|
|
258
|
-
fractionDigits = fraction.length;
|
|
259
|
-
rest = rest.slice(whole.length);
|
|
260
|
-
}
|
|
261
|
-
let offsetSeconds;
|
|
262
|
-
if (rest === "Z" || rest === "z") offsetSeconds = 0;
|
|
263
|
-
else if (rest !== "") {
|
|
264
|
-
const offset = OFFSET.exec(rest);
|
|
265
|
-
if (offset === null) return void 0;
|
|
266
|
-
const [, sign, hours = "", minutes = "00", seconds = "00"] = offset;
|
|
267
|
-
if (Number(minutes) > 59 || Number(seconds) > 59) return void 0;
|
|
268
|
-
const magnitude = Number(hours) * 3600 + Number(minutes) * 60 + Number(seconds);
|
|
269
|
-
offsetSeconds = sign === "-" ? -magnitude : magnitude;
|
|
270
|
-
}
|
|
271
|
-
return {
|
|
272
|
-
date,
|
|
273
|
-
time,
|
|
274
|
-
offsetSeconds,
|
|
275
|
-
fractionDigits
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
function withFraction(example, digits) {
|
|
279
|
-
return example.replace(/(\d{2}:\d{2}:\d{2})/, `$1.${"123456".slice(0, digits)}`);
|
|
280
|
-
}
|
|
281
|
-
/** The value with an instant moved to UTC. */
|
|
282
|
-
function normalized(written, shape) {
|
|
283
|
-
const clock = written.time ?? MIDNIGHT;
|
|
284
|
-
const offsetSeconds = written.offsetSeconds ?? 0;
|
|
285
|
-
if (written.date === void 0 || shape !== "instant") return {
|
|
286
|
-
date: written.date,
|
|
287
|
-
time: clock,
|
|
288
|
-
offsetSeconds
|
|
289
|
-
};
|
|
290
|
-
const utc = daysFromCivil(written.date) * SECONDS_PER_DAY + clock.hour * 3600 + clock.minute * 60 + clock.second - offsetSeconds;
|
|
291
|
-
const days = Math.floor(utc / SECONDS_PER_DAY);
|
|
292
|
-
const secondOfDay = utc - days * SECONDS_PER_DAY;
|
|
293
|
-
return {
|
|
294
|
-
date: civilFromDays(days),
|
|
295
|
-
time: {
|
|
296
|
-
hour: Math.floor(secondOfDay / 3600),
|
|
297
|
-
minute: Math.floor(secondOfDay / 60) % 60,
|
|
298
|
-
second: secondOfDay % 60,
|
|
299
|
-
fraction: clock.fraction
|
|
300
|
-
},
|
|
301
|
-
offsetSeconds: 0
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
function position(value) {
|
|
305
|
-
const { time } = value;
|
|
306
|
-
return [
|
|
307
|
-
value.date === void 0 ? 0 : daysFromCivil(value.date),
|
|
308
|
-
time.hour * 3600 + time.minute * 60 + time.second,
|
|
309
|
-
time.fraction.padEnd(MAX_FRACTION_DIGITS, "0")
|
|
310
|
-
];
|
|
311
|
-
}
|
|
312
|
-
function isBefore(left, right) {
|
|
313
|
-
if (left[0] !== right[0]) return left[0] < right[0];
|
|
314
|
-
if (left[1] !== right[1]) return left[1] < right[1];
|
|
315
|
-
return left[2] < right[2];
|
|
316
|
-
}
|
|
317
|
-
function printed(value, shape) {
|
|
318
|
-
const { date, time, offsetSeconds } = value;
|
|
319
|
-
if (date === void 0) return shape === "timeWithOffset" ? `${timeText(time)}${offsetText(offsetSeconds)}` : timeText(time);
|
|
320
|
-
if (shape === "date") return dateText(date);
|
|
321
|
-
if (shape === "dateTime") return `${dateText(date)}T${timeText(time)}`;
|
|
322
|
-
return `${dateText(date)}T${timeText(time)}Z`;
|
|
323
|
-
}
|
|
324
|
-
/** The position of a range bound, which the data type declares in stored form. */
|
|
325
|
-
function boundPosition(text, shape) {
|
|
326
|
-
const written = readWritten(text);
|
|
327
|
-
if (written === void 0) throw new InternalError(`The range bound "${text}" is not in its stored form.`);
|
|
328
|
-
return position(normalized(written, shape));
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* The stored form of written date or time text, or a refusal with a message that says what is
|
|
332
|
-
* wrong and shows text the type holds. `written` is the text as its author wrote it, which the
|
|
333
|
-
* message shows, when a target rewrote it into ISO 8601 before calling this.
|
|
334
|
-
*/
|
|
335
|
-
function dateTimeStoredText(text, options, written = text) {
|
|
336
|
-
const shape = SHAPES[options.shape];
|
|
337
|
-
const { ownerId: id } = options;
|
|
338
|
-
const parts = readWritten(text);
|
|
339
|
-
if (parts === void 0) refused(`${id} cannot read "${written}". Write ${shape.description}, as in "${shape.example}".`);
|
|
340
|
-
if (parts.date !== void 0 && !shape.date) refused(`${id} holds a time of day without a date, but "${written}" has a date. Write the time alone, as in "${shape.example}".`);
|
|
341
|
-
if (parts.date === void 0 && shape.date) refused(shape.time ? `${id} holds ${shape.description}, but "${written}" has no date. Write the date too, as in "${shape.example}".` : `${id} holds a date, and "${written}" is a time of day. Write a date, as in "${shape.example}".`);
|
|
342
|
-
if (parts.time !== void 0 && !shape.time) refused(`${id} holds a date without a time of day, but "${written}" has a time. Write the date alone, as in "${shape.example}".`);
|
|
343
|
-
if (parts.time === void 0 && shape.offset) refused(`${id} holds ${shape.description}, but "${written}" has no time of day. Write the time too, as in "${shape.example}".`);
|
|
344
|
-
if (parts.offsetSeconds !== void 0 && !shape.offset) refused(`${id} holds no UTC offset, but "${written}" has one. Leave it out, as in "${shape.example}".`);
|
|
345
|
-
if (parts.offsetSeconds === void 0 && shape.offset) refused(`${id} needs a UTC offset, but "${written}" has none. Add Z for UTC or an offset such as +02:00, as in "${shape.example}".`);
|
|
346
|
-
const maxFractionDigits = options.maxFractionDigits ?? MAX_FRACTION_DIGITS;
|
|
347
|
-
if (parts.fractionDigits > maxFractionDigits) refused(`"${written}" has ${parts.fractionDigits} digits after the decimal point, but ${id} holds ${FRACTION_UNITS[maxFractionDigits]}, so at most ${maxFractionDigits}. Round it, as in "${withFraction(shape.example, maxFractionDigits)}".`);
|
|
348
|
-
const { date, time } = parts;
|
|
349
|
-
if (date !== void 0 && (date.month < 1 || date.month > 12 || date.day < 1 || date.day > daysInMonth(date.year, date.month))) refused(`"${written}" is not a date that exists. Write a real date, as in "${shape.example}".`);
|
|
350
|
-
if (time !== void 0 && (time.hour > 23 || time.minute > 59 || time.second > 59)) refused(`"${written}" is not a time of day that exists: hours run from 00 to 23, and minutes and seconds from 00 to 59. Write one, as in "${shape.example}".`);
|
|
351
|
-
const offsetLimit = options.maxOffsetHours ?? 23;
|
|
352
|
-
if (parts.offsetSeconds !== void 0 && Math.abs(parts.offsetSeconds) >= (offsetLimit + 1) * 3600) refused(`"${written}" has a UTC offset outside -${pad(offsetLimit)}:59 to +${pad(offsetLimit)}:59, which ${id} does not hold. Write a smaller offset, as in "${shape.example}".`);
|
|
353
|
-
const value = normalized(parts, options.shape);
|
|
354
|
-
const { range } = options;
|
|
355
|
-
if (range !== void 0) {
|
|
356
|
-
const at = position(value);
|
|
357
|
-
if (isBefore(at, boundPosition(range.earliest, options.shape)) || isBefore(boundPosition(range.latest, options.shape), at)) refused(`${id} holds ${shape.plural} from ${range.earliest} to ${range.latest}, and "${written}" is outside them.`);
|
|
358
|
-
}
|
|
359
|
-
return printed(value, options.shape);
|
|
360
|
-
}
|
|
361
|
-
//#endregion
|
|
362
|
-
export { parseJsonText as a, storedNumeralText as c, isNumeralText as i, dateTimeStoredText as n, printJsonText as o, escapePslString as r, signedRange as s, createNumberClassifier as t };
|
|
363
|
-
|
|
364
|
-
//# sourceMappingURL=data-type-support-C5-XxxeB.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-type-support-C5-XxxeB.mjs","names":[],"sources":["../../../../2-sql/1-core/contract/dist/data-type-support.mjs"],"sourcesContent":["import { structuredError } from \"@internal/utils/structured-error\";\nimport { isNonFiniteText } from \"@internal/framework-components/codec\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/data-type-support.ts\nconst WRITTEN_INTEGER_TEXT = /^[+-]?\\d+$/;\nconst WRITTEN_DECIMAL_TEXT = /^[+-]?\\d+\\.\\d+$/;\nconst DECIMAL_NUMERAL = /^([+-]?)0*(\\d+)(\\.\\d+)?$/;\n/** Whether `text` is a whole number or a decimal as a contract source writes one. */\nfunction isNumeralText(text) {\n\treturn WRITTEN_INTEGER_TEXT.test(text) || WRITTEN_DECIMAL_TEXT.test(text);\n}\n/**\n* A written numeral as the contract stores it. Leading zeros and the sign of zero never change a\n* number, so they go; trailing zeros stay, because a type without a scale keeps them.\n*/\nfunction storedNumeralText(text) {\n\tconst numeral = DECIMAL_NUMERAL.exec(text);\n\tif (numeral === null) return text;\n\tconst [, sign = \"\", whole = \"\", fraction = \"\"] = numeral;\n\tconst digits = `${whole}${fraction}`;\n\treturn sign !== \"-\" || /^[0.]+$/.test(digits) ? digits : `-${digits}`;\n}\n/** A string as a contract source writes it, with the escapes its string reader resolves. */\nfunction escapePslString(value) {\n\treturn value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, \"\\\\\\\"\").replace(/\\n/g, \"\\\\n\").replace(/\\r/g, \"\\\\r\");\n}\n/** The range of a signed integer of `bits` bits. */\nfunction signedRange(bits) {\n\tconst half = 2n ** (BigInt(bits) - 1n);\n\treturn {\n\t\tmin: -half,\n\t\tmax: half - 1n\n\t};\n}\n/**\n* The classifier one target's plain-number authoring entry carries: it reads the digits and says\n* which of the target's types the value is, in that type's stored form. `undefined` means no\n* type of this target holds the number.\n*/\nfunction createNumberClassifier(spec) {\n\tconst as = (classification, value) => classification === void 0 ? void 0 : {\n\t\ttype: classification.type,\n\t\tvalue\n\t};\n\treturn (text) => {\n\t\tif (isNonFiniteText(text)) return as(spec.words, spec.words?.form === \"number\" ? Number(text) : text);\n\t\tif (WRITTEN_DECIMAL_TEXT.test(text)) {\n\t\t\tconst canonical = storedNumeralText(text);\n\t\t\treturn as(spec.fraction, spec.fraction?.form === \"number\" ? Number(canonical) : canonical);\n\t\t}\n\t\tif (!WRITTEN_INTEGER_TEXT.test(text)) return void 0;\n\t\tconst digits = BigInt(text);\n\t\tconst classification = spec.integers.find(({ min, max }) => digits >= min && digits <= max) ?? spec.largerWhole;\n\t\treturn as(classification, classification?.form === \"number\" ? Number(digits) : digits.toString());\n\t};\n}\n/**\n* Read JSON text into the document it holds.\n*\n* `JSON.parse` reads a numeral too large for a double as `Infinity`, and `JSON.stringify` writes\n* that back as `null`, so a document holding one would not be the document stored; it is refused\n* here instead, naming where the number is.\n*/\nfunction parseJsonText(text) {\n\tlet value;\n\ttry {\n\t\tvalue = JSON.parse(text);\n\t} catch (error) {\n\t\tthrow structuredError(\"CONTRACT.INVALID_JSON_LITERAL\", error instanceof Error ? error.message : String(error), {\n\t\t\twhy: \"The text is not a JSON document.\",\n\t\t\tfix: \"Write a JSON document.\"\n\t\t});\n\t}\n\tconst overflowed = nonFiniteNumberIn(value, \"\");\n\tif (overflowed !== void 0) throw structuredError(\"CONTRACT.INVALID_JSON_LITERAL\", `${overflowed.path} is ${overflowed.value}, which JSON cannot write back: the number in the text is outside the range a JSON number holds.`, {\n\t\twhy: \"JSON.parse reads a numeral too large for a double as Infinity, which JSON.stringify writes back as null.\",\n\t\tfix: \"Write a number JSON can hold, or write it as text.\"\n\t});\n\treturn value;\n}\n/** Write a document as the text of a JSON literal. */\nfunction printJsonText(value) {\n\treturn JSON.stringify(value);\n}\nfunction nonFiniteNumberIn(value, path) {\n\tif (typeof value === \"number\") return Number.isFinite(value) ? void 0 : {\n\t\tpath: path === \"\" ? \"The value\" : path,\n\t\tvalue\n\t};\n\tif (Array.isArray(value)) {\n\t\tfor (const [index, element] of value.entries()) {\n\t\t\tconst found = nonFiniteNumberIn(element, `${path}[${index}]`);\n\t\t\tif (found !== void 0) return found;\n\t\t}\n\t\treturn;\n\t}\n\tif (typeof value === \"object\" && value !== null) for (const [key, member] of Object.entries(value)) {\n\t\tconst found = nonFiniteNumberIn(member, path === \"\" ? key : `${path}.${key}`);\n\t\tif (found !== void 0) return found;\n\t}\n}\n//#endregion\n//#region src/date-time-stored-form.ts\n/**\n* The reader the SQL targets build the stored form of each date and time type with; ADR 254\n* states the forms and the text it reads.\n*/\nconst SHAPES = {\n\tdate: {\n\t\tdescription: \"a date\",\n\t\tplural: \"dates\",\n\t\texample: \"2024-01-01\",\n\t\tdate: true,\n\t\ttime: false,\n\t\toffset: false\n\t},\n\ttime: {\n\t\tdescription: \"a time of day\",\n\t\tplural: \"times of day\",\n\t\texample: \"12:34:56\",\n\t\tdate: false,\n\t\ttime: true,\n\t\toffset: false\n\t},\n\ttimeWithOffset: {\n\t\tdescription: \"a time of day with a UTC offset\",\n\t\tplural: \"times of day with a UTC offset\",\n\t\texample: \"12:34:56+02:00\",\n\t\tdate: false,\n\t\ttime: true,\n\t\toffset: true\n\t},\n\tdateTime: {\n\t\tdescription: \"a date and time\",\n\t\tplural: \"dates and times\",\n\t\texample: \"2024-01-01T12:34:56\",\n\t\tdate: true,\n\t\ttime: true,\n\t\toffset: false\n\t},\n\tinstant: {\n\t\tdescription: \"a date and time with a UTC offset\",\n\t\tplural: \"instants\",\n\t\texample: \"2024-01-01T12:34:56Z\",\n\t\tdate: true,\n\t\ttime: true,\n\t\toffset: true\n\t}\n};\nconst DATE_PREFIX = /^([+-]\\d{6}|\\d{4})-(\\d{2})-(\\d{2})/;\nconst TIME_PREFIX = /^(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d+))?)?/;\nconst OFFSET = /^([+-])(\\d{2})(?::(\\d{2})(?::(\\d{2}))?)?$/;\nconst MAX_FRACTION_DIGITS = 6;\nconst FRACTION_UNITS = {\n\t3: \"milliseconds\",\n\t6: \"microseconds\"\n};\nconst SECONDS_PER_DAY = 86400;\nconst MIDNIGHT = {\n\thour: 0,\n\tminute: 0,\n\tsecond: 0,\n\tfraction: \"\"\n};\nfunction refused(message) {\n\tthrow structuredError(\"CONTRACT.CAST_REFUSED\", message, {\n\t\twhy: \"A date or time type stores one form for each value (ADR 254).\",\n\t\tfix: \"Write text the type holds, as the message shows.\"\n\t});\n}\nfunction isLeapYear(year) {\n\treturn year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;\n}\nfunction daysInMonth(year, month) {\n\tif (month === 2) return isLeapYear(year) ? 29 : 28;\n\treturn [\n\t\t4,\n\t\t6,\n\t\t9,\n\t\t11\n\t].includes(month) ? 30 : 31;\n}\n/** Days from 1970-01-01 to a date of the proleptic Gregorian calendar, with year 0 as 1 BC. */\nfunction daysFromCivil({ year, month, day }) {\n\tconst shifted = month <= 2 ? year - 1 : year;\n\tconst era = Math.floor(shifted / 400);\n\tconst yearOfEra = shifted - era * 400;\n\tconst dayOfYear = Math.floor((153 * (month + (month > 2 ? -3 : 9)) + 2) / 5) + day - 1;\n\tconst dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;\n\treturn era * 146097 + dayOfEra - 719468;\n}\nfunction civilFromDays(days) {\n\tconst shifted = days + 719468;\n\tconst era = Math.floor(shifted / 146097);\n\tconst dayOfEra = shifted - era * 146097;\n\tconst yearOfEra = Math.floor((dayOfEra - Math.floor(dayOfEra / 1460) + Math.floor(dayOfEra / 36524) - Math.floor(dayOfEra / 146096)) / 365);\n\tconst dayOfYear = dayOfEra - (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));\n\tconst monthIndex = Math.floor((5 * dayOfYear + 2) / 153);\n\tconst day = dayOfYear - Math.floor((153 * monthIndex + 2) / 5) + 1;\n\tconst month = monthIndex < 10 ? monthIndex + 3 : monthIndex - 9;\n\treturn {\n\t\tyear: yearOfEra + era * 400 + (month <= 2 ? 1 : 0),\n\t\tmonth,\n\t\tday\n\t};\n}\nfunction pad(value, width = 2) {\n\treturn String(value).padStart(width, \"0\");\n}\nfunction yearText(year) {\n\tif (year >= 0 && year <= 9999) return pad(year, 4);\n\treturn `${year < 0 ? \"-\" : \"+\"}${pad(Math.abs(year), 6)}`;\n}\nfunction dateText(date) {\n\treturn `${yearText(date.year)}-${pad(date.month)}-${pad(date.day)}`;\n}\nfunction timeText(time) {\n\tconst fraction = time.fraction.replace(/0+$/, \"\");\n\treturn `${pad(time.hour)}:${pad(time.minute)}:${pad(time.second)}${fraction === \"\" ? \"\" : `.${fraction}`}`;\n}\nfunction offsetText(seconds) {\n\tif (seconds === 0) return \"Z\";\n\tconst magnitude = Math.abs(seconds);\n\tconst rest = magnitude % 60;\n\treturn `${seconds < 0 ? \"-\" : \"+\"}${pad(Math.floor(magnitude / 3600))}:${pad(Math.floor(magnitude / 60) % 60)}${rest === 0 ? \"\" : `:${pad(rest)}`}`;\n}\n/**\n* The fields of an ISO 8601 date, time, or date and time, or `undefined` when the text is not one.\n* Ranges are checked by the caller, which words the refusal.\n*/\nfunction readWritten(text) {\n\tlet rest = text;\n\tlet date;\n\tlet timeFollows = true;\n\tconst dateMatch = DATE_PREFIX.exec(rest);\n\tif (dateMatch !== null) {\n\t\tconst [whole, yearDigits = \"\", month = \"\", day = \"\"] = dateMatch;\n\t\tif (yearDigits === \"-000000\") return void 0;\n\t\tdate = {\n\t\t\tyear: Number(yearDigits),\n\t\t\tmonth: Number(month),\n\t\t\tday: Number(day)\n\t\t};\n\t\trest = rest.slice(whole.length);\n\t\ttimeFollows = /^[Tt ]/.test(rest);\n\t\tif (timeFollows) rest = rest.slice(1);\n\t}\n\tlet time;\n\tlet fractionDigits = 0;\n\tif (timeFollows) {\n\t\tconst timeMatch = TIME_PREFIX.exec(rest);\n\t\tif (timeMatch === null) return void 0;\n\t\tconst [whole, hour = \"\", minute = \"\", second = \"00\", fraction = \"\"] = timeMatch;\n\t\ttime = {\n\t\t\thour: Number(hour),\n\t\t\tminute: Number(minute),\n\t\t\tsecond: Number(second),\n\t\t\tfraction\n\t\t};\n\t\tfractionDigits = fraction.length;\n\t\trest = rest.slice(whole.length);\n\t}\n\tlet offsetSeconds;\n\tif (rest === \"Z\" || rest === \"z\") offsetSeconds = 0;\n\telse if (rest !== \"\") {\n\t\tconst offset = OFFSET.exec(rest);\n\t\tif (offset === null) return void 0;\n\t\tconst [, sign, hours = \"\", minutes = \"00\", seconds = \"00\"] = offset;\n\t\tif (Number(minutes) > 59 || Number(seconds) > 59) return void 0;\n\t\tconst magnitude = Number(hours) * 3600 + Number(minutes) * 60 + Number(seconds);\n\t\toffsetSeconds = sign === \"-\" ? -magnitude : magnitude;\n\t}\n\treturn {\n\t\tdate,\n\t\ttime,\n\t\toffsetSeconds,\n\t\tfractionDigits\n\t};\n}\nfunction withFraction(example, digits) {\n\treturn example.replace(/(\\d{2}:\\d{2}:\\d{2})/, `$1.${\"123456\".slice(0, digits)}`);\n}\n/** The value with an instant moved to UTC. */\nfunction normalized(written, shape) {\n\tconst clock = written.time ?? MIDNIGHT;\n\tconst offsetSeconds = written.offsetSeconds ?? 0;\n\tif (written.date === void 0 || shape !== \"instant\") return {\n\t\tdate: written.date,\n\t\ttime: clock,\n\t\toffsetSeconds\n\t};\n\tconst utc = daysFromCivil(written.date) * SECONDS_PER_DAY + clock.hour * 3600 + clock.minute * 60 + clock.second - offsetSeconds;\n\tconst days = Math.floor(utc / SECONDS_PER_DAY);\n\tconst secondOfDay = utc - days * SECONDS_PER_DAY;\n\treturn {\n\t\tdate: civilFromDays(days),\n\t\ttime: {\n\t\t\thour: Math.floor(secondOfDay / 3600),\n\t\t\tminute: Math.floor(secondOfDay / 60) % 60,\n\t\t\tsecond: secondOfDay % 60,\n\t\t\tfraction: clock.fraction\n\t\t},\n\t\toffsetSeconds: 0\n\t};\n}\nfunction position(value) {\n\tconst { time } = value;\n\treturn [\n\t\tvalue.date === void 0 ? 0 : daysFromCivil(value.date),\n\t\ttime.hour * 3600 + time.minute * 60 + time.second,\n\t\ttime.fraction.padEnd(MAX_FRACTION_DIGITS, \"0\")\n\t];\n}\nfunction isBefore(left, right) {\n\tif (left[0] !== right[0]) return left[0] < right[0];\n\tif (left[1] !== right[1]) return left[1] < right[1];\n\treturn left[2] < right[2];\n}\nfunction printed(value, shape) {\n\tconst { date, time, offsetSeconds } = value;\n\tif (date === void 0) return shape === \"timeWithOffset\" ? `${timeText(time)}${offsetText(offsetSeconds)}` : timeText(time);\n\tif (shape === \"date\") return dateText(date);\n\tif (shape === \"dateTime\") return `${dateText(date)}T${timeText(time)}`;\n\treturn `${dateText(date)}T${timeText(time)}Z`;\n}\n/** The position of a range bound, which the data type declares in stored form. */\nfunction boundPosition(text, shape) {\n\tconst written = readWritten(text);\n\tif (written === void 0) throw new InternalError(`The range bound \"${text}\" is not in its stored form.`);\n\treturn position(normalized(written, shape));\n}\n/**\n* The stored form of written date or time text, or a refusal with a message that says what is\n* wrong and shows text the type holds. `written` is the text as its author wrote it, which the\n* message shows, when a target rewrote it into ISO 8601 before calling this.\n*/\nfunction dateTimeStoredText(text, options, written = text) {\n\tconst shape = SHAPES[options.shape];\n\tconst { ownerId: id } = options;\n\tconst parts = readWritten(text);\n\tif (parts === void 0) refused(`${id} cannot read \"${written}\". Write ${shape.description}, as in \"${shape.example}\".`);\n\tif (parts.date !== void 0 && !shape.date) refused(`${id} holds a time of day without a date, but \"${written}\" has a date. Write the time alone, as in \"${shape.example}\".`);\n\tif (parts.date === void 0 && shape.date) refused(shape.time ? `${id} holds ${shape.description}, but \"${written}\" has no date. Write the date too, as in \"${shape.example}\".` : `${id} holds a date, and \"${written}\" is a time of day. Write a date, as in \"${shape.example}\".`);\n\tif (parts.time !== void 0 && !shape.time) refused(`${id} holds a date without a time of day, but \"${written}\" has a time. Write the date alone, as in \"${shape.example}\".`);\n\tif (parts.time === void 0 && shape.offset) refused(`${id} holds ${shape.description}, but \"${written}\" has no time of day. Write the time too, as in \"${shape.example}\".`);\n\tif (parts.offsetSeconds !== void 0 && !shape.offset) refused(`${id} holds no UTC offset, but \"${written}\" has one. Leave it out, as in \"${shape.example}\".`);\n\tif (parts.offsetSeconds === void 0 && shape.offset) refused(`${id} needs a UTC offset, but \"${written}\" has none. Add Z for UTC or an offset such as +02:00, as in \"${shape.example}\".`);\n\tconst maxFractionDigits = options.maxFractionDigits ?? MAX_FRACTION_DIGITS;\n\tif (parts.fractionDigits > maxFractionDigits) refused(`\"${written}\" has ${parts.fractionDigits} digits after the decimal point, but ${id} holds ${FRACTION_UNITS[maxFractionDigits]}, so at most ${maxFractionDigits}. Round it, as in \"${withFraction(shape.example, maxFractionDigits)}\".`);\n\tconst { date, time } = parts;\n\tif (date !== void 0 && (date.month < 1 || date.month > 12 || date.day < 1 || date.day > daysInMonth(date.year, date.month))) refused(`\"${written}\" is not a date that exists. Write a real date, as in \"${shape.example}\".`);\n\tif (time !== void 0 && (time.hour > 23 || time.minute > 59 || time.second > 59)) refused(`\"${written}\" is not a time of day that exists: hours run from 00 to 23, and minutes and seconds from 00 to 59. Write one, as in \"${shape.example}\".`);\n\tconst offsetLimit = options.maxOffsetHours ?? 23;\n\tif (parts.offsetSeconds !== void 0 && Math.abs(parts.offsetSeconds) >= (offsetLimit + 1) * 3600) refused(`\"${written}\" has a UTC offset outside -${pad(offsetLimit)}:59 to +${pad(offsetLimit)}:59, which ${id} does not hold. Write a smaller offset, as in \"${shape.example}\".`);\n\tconst value = normalized(parts, options.shape);\n\tconst { range } = options;\n\tif (range !== void 0) {\n\t\tconst at = position(value);\n\t\tif (isBefore(at, boundPosition(range.earliest, options.shape)) || isBefore(boundPosition(range.latest, options.shape), at)) refused(`${id} holds ${shape.plural} from ${range.earliest} to ${range.latest}, and \"${written}\" is outside them.`);\n\t}\n\treturn printed(value, options.shape);\n}\n//#endregion\nexport { createNumberClassifier, dateTimeStoredText, escapePslString, isNumeralText, parseJsonText, printJsonText, signedRange, storedNumeralText };\n\n//# sourceMappingURL=data-type-support.mjs.map"],"mappings":";;;;AAIA,MAAM,uBAAuB;AAC7B,MAAM,uBAAuB;AAC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AAQ,8BAA8B,IAAI,WAAW,EAAE,UAAU,IAAI,WAAW,EAAE,aAAa,GAAG,iDAAiD,MAAM,QAAQ,GAAG;CACjR,MAAM,QAAQ,WAAW,OAAO,QAAQ,KAAK;CAC7C,MAAM,EAAE,UAAU;CAClB,IAAI,UAAU,KAAK,GAAG;EACrB,MAAM,KAAK,SAAS,KAAK;EACzB,IAAI,SAAS,IAAI,cAAc,MAAM,UAAU,QAAQ,KAAK,CAAC,KAAK,SAAS,cAAc,MAAM,QAAQ,QAAQ,KAAK,GAAG,EAAE,GAAG,QAAQ,GAAG,GAAG,SAAS,MAAM,OAAO,QAAQ,MAAM,SAAS,MAAM,MAAM,OAAO,SAAS,QAAQ,mBAAmB;CAC/O;CACA,OAAO,QAAQ,OAAO,QAAQ,KAAK;AACpC"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { DataTypeId } from "@prisma/orm-framework/components/codec";
|
|
2
|
-
import { JsonValue } from "@prisma/orm-framework/contract/types";
|
|
3
|
-
//#region ../../../2-sql/1-core/contract/dist/data-type-support.d.mts
|
|
4
|
-
//#region src/data-type-support.d.ts
|
|
5
|
-
/** Whether `text` is a whole number or a decimal as a contract source writes one. */
|
|
6
|
-
declare function isNumeralText(text: string): boolean;
|
|
7
|
-
/**
|
|
8
|
-
* A written numeral as the contract stores it. Leading zeros and the sign of zero never change a
|
|
9
|
-
* number, so they go; trailing zeros stay, because a type without a scale keeps them.
|
|
10
|
-
*/
|
|
11
|
-
declare function storedNumeralText(text: string): string;
|
|
12
|
-
/** A string as a contract source writes it, with the escapes its string reader resolves. */
|
|
13
|
-
declare function escapePslString(value: string): string;
|
|
14
|
-
/** Which data type a written number is, and whether that type stores it as a number or as text. */
|
|
15
|
-
interface NumberClassification {
|
|
16
|
-
readonly type: DataTypeId;
|
|
17
|
-
readonly form: 'number' | 'text';
|
|
18
|
-
}
|
|
19
|
-
/** One integer type and the range of whole numbers it holds. */
|
|
20
|
-
interface IntegerStep extends NumberClassification {
|
|
21
|
-
readonly min: bigint;
|
|
22
|
-
readonly max: bigint;
|
|
23
|
-
}
|
|
24
|
-
/** The range of a signed integer of `bits` bits. */
|
|
25
|
-
declare function signedRange(bits: number): {
|
|
26
|
-
readonly min: bigint;
|
|
27
|
-
readonly max: bigint;
|
|
28
|
-
};
|
|
29
|
-
interface NumberClassifierSpec {
|
|
30
|
-
/** Tried in order; the first whose range holds the digits wins. */
|
|
31
|
-
readonly integers: readonly IntegerStep[];
|
|
32
|
-
/** A whole number no step holds. Absent means the target has no type for it. */
|
|
33
|
-
readonly largerWhole?: NumberClassification | undefined;
|
|
34
|
-
/** A number with a fraction. Absent means the target has no type for it. */
|
|
35
|
-
readonly fraction?: NumberClassification | undefined;
|
|
36
|
-
/** `NaN`, `Infinity` and `-Infinity`. Absent means the target has no type for them. */
|
|
37
|
-
readonly words?: NumberClassification | undefined;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* The classifier one target's plain-number authoring entry carries: it reads the digits and says
|
|
41
|
-
* which of the target's types the value is, in that type's stored form. `undefined` means no
|
|
42
|
-
* type of this target holds the number.
|
|
43
|
-
*/
|
|
44
|
-
declare function createNumberClassifier(spec: NumberClassifierSpec): (text: string) => {
|
|
45
|
-
readonly type: DataTypeId;
|
|
46
|
-
readonly value: JsonValue;
|
|
47
|
-
} | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Read JSON text into the document it holds.
|
|
50
|
-
*
|
|
51
|
-
* `JSON.parse` reads a numeral too large for a double as `Infinity`, and `JSON.stringify` writes
|
|
52
|
-
* that back as `null`, so a document holding one would not be the document stored; it is refused
|
|
53
|
-
* here instead, naming where the number is.
|
|
54
|
-
*/
|
|
55
|
-
declare function parseJsonText(text: string): JsonValue;
|
|
56
|
-
/** Write a document as the text of a JSON literal. */
|
|
57
|
-
declare function printJsonText(value: JsonValue): string;
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/date-time-stored-form.d.ts
|
|
60
|
-
/**
|
|
61
|
-
* The reader the SQL targets build the stored form of each date and time type with; ADR 254
|
|
62
|
-
* states the forms and the text it reads.
|
|
63
|
-
*/
|
|
64
|
-
/** What a date or time type holds, which decides the text it reads and writes. */
|
|
65
|
-
type DateTimeShape = 'date' | 'time' | 'timeWithOffset' | 'dateTime' | 'instant';
|
|
66
|
-
interface DateTimeStoredTextOptions {
|
|
67
|
-
readonly shape: DateTimeShape;
|
|
68
|
-
/** The id of the data type or codec that declares this stored form, which messages name. */
|
|
69
|
-
readonly ownerId: string;
|
|
70
|
-
/** The largest UTC offset the type holds, in hours. Defaults to 23. */
|
|
71
|
-
readonly maxOffsetHours?: number;
|
|
72
|
-
/** The most digits after the decimal point the type holds. Defaults to 6, microseconds. */
|
|
73
|
-
readonly maxFractionDigits?: 3 | 6;
|
|
74
|
-
/** The earliest and latest values the type holds, each in stored form. */
|
|
75
|
-
readonly range?: {
|
|
76
|
-
readonly earliest: string;
|
|
77
|
-
readonly latest: string;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* The stored form of written date or time text, or a refusal with a message that says what is
|
|
82
|
-
* wrong and shows text the type holds. `written` is the text as its author wrote it, which the
|
|
83
|
-
* message shows, when a target rewrote it into ISO 8601 before calling this.
|
|
84
|
-
*/
|
|
85
|
-
declare function dateTimeStoredText(text: string, options: DateTimeStoredTextOptions, written?: string): string;
|
|
86
|
-
//#endregion
|
|
87
|
-
export { NumberClassifierSpec as a, escapePslString as c, printJsonText as d, signedRange as f, NumberClassification as i, isNumeralText as l, DateTimeStoredTextOptions as n, createNumberClassifier as o, storedNumeralText as p, IntegerStep as r, dateTimeStoredText as s, DateTimeShape as t, parseJsonText as u };
|
|
88
|
-
//# sourceMappingURL=data-type-support-CBcYhSkD.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-type-support-CBcYhSkD.d.mts","names":[],"sources":["../../../../2-sql/1-core/contract/dist/data-type-support.d.mts"],"mappings":";;;;;iBAIiB,cAAc;;;;;iBAKd,kBAAkB;;iBAElB,gBAAgB;;UAEvB;WACC,MAAM;WACN;;;UAGD,oBAAoB;WACnB;WACA;;;iBAGM,YAAY;WAClB;WACA;;UAED;;WAEC,mBAAmB;;WAEnB,cAAc;;WAEd,WAAW;;WAEX,QAAQ;;;;;;;iBAOF,uBAAuB,MAAM,wBAAwB;WAC3D,MAAM;WACN,OAAO;;;;;;;;;iBASD,cAAc,eAAe;;iBAE7B,cAAc,OAAO;;;;;;;;KAQjC;UACK;WACC,OAAO;;WAEP;;WAEA;;WAEA;;WAEA;aACE;aACA;;;;;;;;iBAQI,mBAAmB,cAAc,SAAS,2BAA2B"}
|