kern-orm 0.4.0 → 0.6.0
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/database-CP4oapsQ.mjs +4693 -0
- package/dist/{index--0tyG7sU.d.mts → index-CoKpXcBp.d.mts} +1347 -703
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +87 -3961
- package/dist/testing.d.mts +28 -2
- package/dist/testing.mjs +530 -1
- package/dist/{text-BTFErHIi.mjs → text-Cti9QLK7.mjs} +7 -1
- package/dist/types-DfoL8Oi9.mjs +248 -0
- package/dist/types.d.mts +49 -49
- package/dist/types.mjs +2 -247
- package/package.json +3 -1
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { A as hasEquality, E as defineType, T as getBooleanType, a as stringifyJson, d as orderingOperators, i as formatTypeName, k as equalityOperators, l as defineNumberType, o as decodeBytea, s as encodeBytea, u as getIntegerType } from "./text-Cti9QLK7.mjs";
|
|
2
|
+
// src/type/builtins/array.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a one-dimensional array type of `element` values.
|
|
5
|
+
*
|
|
6
|
+
* A `NULL` element decodes to `null`; a nullable `element` type, such as `array(text.nullable())`, types such elements.
|
|
7
|
+
* Elements are separated by commas, as in arrays of all built-in types; a custom type with another delimiter, such as `box`, is not supported.
|
|
8
|
+
* An array has `eq`, `ne`, and `in` when its element type has SQL `=`.
|
|
9
|
+
*/
|
|
10
|
+
function array(element) {
|
|
11
|
+
const type = defineType({
|
|
12
|
+
sqlType: `${element.sqlType}[]`,
|
|
13
|
+
castType: `${element.castType}[]`
|
|
14
|
+
}).transform({
|
|
15
|
+
decode(text) {
|
|
16
|
+
const values = parseArray(text);
|
|
17
|
+
for (let index = 0; index < values.length; index++) {
|
|
18
|
+
const value = values[index];
|
|
19
|
+
values[index] = value === null ? null : element.decode(value);
|
|
20
|
+
}
|
|
21
|
+
return values;
|
|
22
|
+
},
|
|
23
|
+
encode(values) {
|
|
24
|
+
let text = "{";
|
|
25
|
+
for (let index = 0; index < values.length; index++) {
|
|
26
|
+
const value = values[index];
|
|
27
|
+
text += `${index === 0 ? "" : ","}${formatArrayElement(value === null ? null : element.encode(value))}`;
|
|
28
|
+
}
|
|
29
|
+
return `${text}}`;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return hasEquality(element) ? type.withOperators(equalityOperators) : type;
|
|
33
|
+
}
|
|
34
|
+
/** Parses a one-dimensional array literal, such as `{a,"b c",NULL}`, into the text representations of its elements. */
|
|
35
|
+
function parseArray(text) {
|
|
36
|
+
const start = text.startsWith("[") ? text.indexOf("=") + 1 : 0;
|
|
37
|
+
if (text[start] !== "{" || !text.endsWith("}")) throw new Error(`Unsupported array value "${text}"`);
|
|
38
|
+
const elements = [];
|
|
39
|
+
const end = text.length - 1;
|
|
40
|
+
if (start + 1 === end) return elements;
|
|
41
|
+
let index = start + 1;
|
|
42
|
+
while (true) {
|
|
43
|
+
if (text[index] === "{") throw new Error("Multidimensional arrays are not supported");
|
|
44
|
+
if (text[index] === "\"") {
|
|
45
|
+
let element = "";
|
|
46
|
+
index++;
|
|
47
|
+
while (index < end && text[index] !== "\"") {
|
|
48
|
+
if (text[index] === "\\") {
|
|
49
|
+
index++;
|
|
50
|
+
if (index === end) break;
|
|
51
|
+
}
|
|
52
|
+
element += text[index];
|
|
53
|
+
index++;
|
|
54
|
+
}
|
|
55
|
+
if (index === end) throw new Error(`Unterminated quoted element in array value "${text}"`);
|
|
56
|
+
elements.push(element);
|
|
57
|
+
index++;
|
|
58
|
+
} else {
|
|
59
|
+
let next = text.indexOf(",", index);
|
|
60
|
+
if (next === -1) next = end;
|
|
61
|
+
if (next === index) throw new Error(`Malformed array value "${text}"`);
|
|
62
|
+
const element = text.slice(index, next);
|
|
63
|
+
elements.push(element === "NULL" ? null : element);
|
|
64
|
+
index = next;
|
|
65
|
+
}
|
|
66
|
+
if (index === end) return elements;
|
|
67
|
+
if (text[index] !== ",") throw new Error(`Malformed array value "${text}"`);
|
|
68
|
+
index++;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Formats the text representation of an array element, quoting it unless it is `NULL`. */
|
|
72
|
+
function formatArrayElement(element) {
|
|
73
|
+
return element === null ? "NULL" : `"${element.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"")}"`;
|
|
74
|
+
}
|
|
75
|
+
// src/type/builtins/binary.ts
|
|
76
|
+
/** Binary data; PostgreSQL represents it in hex, which requires the default `bytea_output` setting. */
|
|
77
|
+
const bytea = /* @__PURE__ */ defineType({ sqlType: "bytea" }).transform({
|
|
78
|
+
decode: decodeBytea,
|
|
79
|
+
encode: encodeBytea
|
|
80
|
+
}).withOperators(equalityOperators);
|
|
81
|
+
// src/type/builtins/boolean.ts
|
|
82
|
+
/** `boolean` values. */
|
|
83
|
+
const boolean = /* @__PURE__ */ getBooleanType();
|
|
84
|
+
// src/type/builtins/datetime.ts
|
|
85
|
+
/** Point in time as a UTC ISO 8601 string with microseconds, such as `2026-01-15T07:00:00.123456Z`; accepts a `Date` too. */
|
|
86
|
+
const timestamptz = /* @__PURE__ */ defineType({ sqlType: "timestamptz" }).transform({
|
|
87
|
+
decode: normalizeTimestamptz,
|
|
88
|
+
encode: (value) => toPostgresYear(value instanceof Date ? value.toISOString() : value)
|
|
89
|
+
}).withOperators(orderingOperators).withParameters(/* @__PURE__ */ createPrecisionFormatter("timestamptz"));
|
|
90
|
+
/** Date and time without a time zone as an ISO 8601 string with microseconds, such as `2026-01-15T10:00:00.000000`. */
|
|
91
|
+
const timestamp = /* @__PURE__ */ defineType({ sqlType: "timestamp" }).transform({
|
|
92
|
+
decode: normalizeTimestamp,
|
|
93
|
+
encode: toPostgresYear
|
|
94
|
+
}).withOperators(orderingOperators).withParameters(/* @__PURE__ */ createPrecisionFormatter("timestamp"));
|
|
95
|
+
/** Calendar date as an ISO 8601 string, such as `2026-01-15`. */
|
|
96
|
+
const date = /* @__PURE__ */ defineType({ sqlType: "date" }).transform({
|
|
97
|
+
decode: normalizeDate,
|
|
98
|
+
encode: toPostgresYear
|
|
99
|
+
}).withOperators(orderingOperators);
|
|
100
|
+
/** Time of day as a string with microseconds, such as `10:00:00.000000`. */
|
|
101
|
+
const time = /* @__PURE__ */ defineType({ sqlType: "time" }).transform({ decode: normalizeTime }).withOperators(orderingOperators).withParameters(/* @__PURE__ */ createPrecisionFormatter("time"));
|
|
102
|
+
/** Interval in the PostgreSQL output format, such as `1 day 02:00:00`. */
|
|
103
|
+
const interval = /* @__PURE__ */ defineType({ sqlType: "interval" }).withOperators(orderingOperators);
|
|
104
|
+
function createPrecisionFormatter(name) {
|
|
105
|
+
return (precision) => formatTypeName(name, precision);
|
|
106
|
+
}
|
|
107
|
+
const timestamptzPattern = /^(\d{4,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?([+-])(\d{2})(?::(\d{2}))?(?::(\d{2}))?( BC)?$/;
|
|
108
|
+
const timestampPattern = /^(\d{4,})(-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?( BC)?$/;
|
|
109
|
+
const datePattern = /^(\d{4,})(-\d{2}-\d{2})( BC)?$/;
|
|
110
|
+
const timePattern = /^(\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?$/;
|
|
111
|
+
/** Leading ISO 8601 year that PostgreSQL does not accept: an expanded year, such as `+010000`, or year `0000`. */
|
|
112
|
+
const isoYearPattern = /^([+-]\d{6,}|0000)(-.*)$/s;
|
|
113
|
+
/** Special date and time values that PostgreSQL returns as they are. */
|
|
114
|
+
const infinities = /* @__PURE__ */ new Set(["infinity", "-infinity"]);
|
|
115
|
+
/**
|
|
116
|
+
* Normalizes a `timestamptz` value to UTC ISO 8601 with microseconds, such as `2026-01-15T07:00:00.123456Z`.
|
|
117
|
+
*
|
|
118
|
+
* The fixed format keeps microseconds that `Date` would lose; the arithmetic avoids `Date`, whose range is narrower than that of PostgreSQL.
|
|
119
|
+
*/
|
|
120
|
+
function normalizeTimestamptz(text) {
|
|
121
|
+
if (infinities.has(text)) return text;
|
|
122
|
+
const match = timestamptzPattern.exec(text);
|
|
123
|
+
if (!match) throw new Error(`Unsupported timestamptz value "${text}"; kern-orm expects DateStyle ISO`);
|
|
124
|
+
const offset = (match[8] === "-" ? -1 : 1) * (Number(match[9]) * 3600 + Number(match[10] ?? 0) * 60 + Number(match[11] ?? 0));
|
|
125
|
+
const seconds = countDays(toAstronomicalYear(match[1], match[12]), Number(match[2]), Number(match[3])) * 86400 + Number(match[4]) * 3600 + Number(match[5]) * 60 + Number(match[6]) - offset;
|
|
126
|
+
const days = Math.floor(seconds / 86400);
|
|
127
|
+
const time = seconds - days * 86400;
|
|
128
|
+
return `${formatDate(days)}T${padTwo(Math.floor(time / 3600))}:${padTwo(Math.floor(time / 60) % 60)}:${padTwo(time % 60)}.${padFraction(match[7])}Z`;
|
|
129
|
+
}
|
|
130
|
+
/** Normalizes a `timestamp` value to ISO 8601 without a time zone, such as `2026-01-15T10:00:00.000000`. */
|
|
131
|
+
function normalizeTimestamp(text) {
|
|
132
|
+
if (infinities.has(text)) return text;
|
|
133
|
+
const match = timestampPattern.exec(text);
|
|
134
|
+
if (!match) throw new Error(`Unsupported timestamp value "${text}"; kern-orm expects DateStyle ISO`);
|
|
135
|
+
return `${formatYear(toAstronomicalYear(match[1], match[5]))}${match[2]}T${match[3]}.${padFraction(match[4])}`;
|
|
136
|
+
}
|
|
137
|
+
/** Normalizes a `date` value to ISO 8601, such as `2026-01-15`. */
|
|
138
|
+
function normalizeDate(text) {
|
|
139
|
+
if (infinities.has(text)) return text;
|
|
140
|
+
const match = datePattern.exec(text);
|
|
141
|
+
if (!match) throw new Error(`Unsupported date value "${text}"; kern-orm expects DateStyle ISO`);
|
|
142
|
+
return `${formatYear(toAstronomicalYear(match[1], match[3]))}${match[2]}`;
|
|
143
|
+
}
|
|
144
|
+
/** Normalizes a `time` value to `HH:MM:SS.ffffff`. */
|
|
145
|
+
function normalizeTime(text) {
|
|
146
|
+
const match = timePattern.exec(text);
|
|
147
|
+
if (!match) throw new Error(`Unsupported time value "${text}"`);
|
|
148
|
+
return `${match[1]}.${padFraction(match[2])}`;
|
|
149
|
+
}
|
|
150
|
+
/** Converts a leading ISO 8601 year outside 1 to 9999 into the PostgreSQL format: unsigned after 9999 and with a `BC` suffix before 1. */
|
|
151
|
+
function toPostgresYear(text) {
|
|
152
|
+
const match = isoYearPattern.exec(text);
|
|
153
|
+
if (!match) return text;
|
|
154
|
+
const year = Number(match[1]);
|
|
155
|
+
return year > 0 ? `${year}${match[2]}` : `${String(1 - year).padStart(4, "0")}${match[2]} BC`;
|
|
156
|
+
}
|
|
157
|
+
/** Returns the astronomical year of a PostgreSQL year, where 1 BC is year 0. */
|
|
158
|
+
function toAstronomicalYear(year, era) {
|
|
159
|
+
return era === void 0 ? Number(year) : 1 - Number(year);
|
|
160
|
+
}
|
|
161
|
+
/** Formats an astronomical year as an ISO 8601 year, expanded with a sign outside 0 to 9999. */
|
|
162
|
+
function formatYear(year) {
|
|
163
|
+
if (year >= 0 && year <= 9999) return String(year).padStart(4, "0");
|
|
164
|
+
return `${year < 0 ? "-" : "+"}${String(Math.abs(year)).padStart(6, "0")}`;
|
|
165
|
+
}
|
|
166
|
+
/** Counts the days from 1970-01-01 to a date of an astronomical year. */
|
|
167
|
+
function countDays(year, month, day) {
|
|
168
|
+
const shifted = month <= 2 ? year - 1 : year;
|
|
169
|
+
const era = Math.floor(shifted / 400);
|
|
170
|
+
const yearOfEra = shifted - era * 400;
|
|
171
|
+
const dayOfYear = Math.floor((153 * (month > 2 ? month - 3 : month + 9) + 2) / 5) + day - 1;
|
|
172
|
+
const dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;
|
|
173
|
+
return era * 146097 + dayOfEra - 719468;
|
|
174
|
+
}
|
|
175
|
+
/** Formats the date a number of days after 1970-01-01 as an ISO 8601 date. */
|
|
176
|
+
function formatDate(days) {
|
|
177
|
+
const shifted = days + 719468;
|
|
178
|
+
const era = Math.floor(shifted / 146097);
|
|
179
|
+
const dayOfEra = shifted - era * 146097;
|
|
180
|
+
const yearOfEra = Math.floor((dayOfEra - Math.floor(dayOfEra / 1460) + Math.floor(dayOfEra / 36524) - Math.floor(dayOfEra / 146096)) / 365);
|
|
181
|
+
const dayOfYear = dayOfEra - (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));
|
|
182
|
+
const shiftedMonth = Math.floor((5 * dayOfYear + 2) / 153);
|
|
183
|
+
const day = dayOfYear - Math.floor((153 * shiftedMonth + 2) / 5) + 1;
|
|
184
|
+
const month = shiftedMonth < 10 ? shiftedMonth + 3 : shiftedMonth - 9;
|
|
185
|
+
return `${formatYear(yearOfEra + era * 400 + (month <= 2 ? 1 : 0))}-${padTwo(month)}-${padTwo(day)}`;
|
|
186
|
+
}
|
|
187
|
+
function padTwo(value) {
|
|
188
|
+
return value < 10 ? `0${value}` : String(value);
|
|
189
|
+
}
|
|
190
|
+
function padFraction(fraction) {
|
|
191
|
+
return (fraction ?? "").padEnd(6, "0");
|
|
192
|
+
}
|
|
193
|
+
// src/type/builtins/enum.ts
|
|
194
|
+
/** Creates a type of an existing PostgreSQL enum; values are ordered as declared in the enum. */
|
|
195
|
+
function enumOf(name, _values) {
|
|
196
|
+
return defineType({
|
|
197
|
+
sqlType: name,
|
|
198
|
+
castType: name
|
|
199
|
+
}).transform({
|
|
200
|
+
decode: (value) => value,
|
|
201
|
+
encode: (value) => value
|
|
202
|
+
}).withOperators(orderingOperators);
|
|
203
|
+
}
|
|
204
|
+
// src/type/builtins/json.ts
|
|
205
|
+
function createJsonType(sqlType) {
|
|
206
|
+
return defineType({ sqlType }).transform({
|
|
207
|
+
decode: (text) => JSON.parse(text),
|
|
208
|
+
encode: stringifyJson
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function addShape(type) {
|
|
212
|
+
return Object.freeze({
|
|
213
|
+
...type,
|
|
214
|
+
of: () => type
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
/** `json` values; `json.of<T>()` declares their shape. PostgreSQL has no `=` for `json`, so its expressions have no `eq`, `ne`, or `in`. */
|
|
218
|
+
const json = /* @__PURE__ */ addShape(/* @__PURE__ */ createJsonType("json"));
|
|
219
|
+
/** `jsonb` values; `jsonb.of<T>()` declares their shape. */
|
|
220
|
+
const jsonb = /* @__PURE__ */ addShape(/* @__PURE__ */ createJsonType("jsonb").withOperators(equalityOperators));
|
|
221
|
+
// src/type/builtins/network.ts
|
|
222
|
+
/** IP address with an optional netmask as a string, such as `192.168.0.1`. */
|
|
223
|
+
const inet = /* @__PURE__ */ defineType({ sqlType: "inet" }).withOperators(orderingOperators);
|
|
224
|
+
/** IP network as a string, such as `10.0.0.0/8`. */
|
|
225
|
+
const cidr = /* @__PURE__ */ defineType({ sqlType: "cidr" }).withOperators(orderingOperators);
|
|
226
|
+
// src/type/builtins/numeric.ts
|
|
227
|
+
/** 2-byte integer as a `number`. */
|
|
228
|
+
const smallint = /* @__PURE__ */ defineNumberType("smallint");
|
|
229
|
+
/** 4-byte integer as a `number`. */
|
|
230
|
+
const integer = /* @__PURE__ */ getIntegerType();
|
|
231
|
+
/** 8-byte integer as a `bigint`, which keeps values beyond `Number.MAX_SAFE_INTEGER`; accepts a `number` too. */
|
|
232
|
+
const bigint = /* @__PURE__ */ defineType({ sqlType: "bigint" }).transform({
|
|
233
|
+
decode: BigInt,
|
|
234
|
+
encode: (value) => String(value)
|
|
235
|
+
}).withOperators(orderingOperators);
|
|
236
|
+
/** 4-byte floating-point number as a `number`. */
|
|
237
|
+
const real = /* @__PURE__ */ defineNumberType("real");
|
|
238
|
+
/** 8-byte floating-point number as a `number`. */
|
|
239
|
+
const doublePrecision = /* @__PURE__ */ defineNumberType("double precision");
|
|
240
|
+
/** Exact number as a decimal string, so that no precision is lost; `numeric.with(precision, scale)` constrains it. */
|
|
241
|
+
const numeric = /* @__PURE__ */ defineType({ sqlType: "numeric" }).transform({
|
|
242
|
+
decode: (value) => value,
|
|
243
|
+
encode: (value) => String(value)
|
|
244
|
+
}).withOperators(orderingOperators).withParameters((precision, scale) => formatTypeName("numeric", precision, scale));
|
|
245
|
+
// src/type/builtins/uuid.ts
|
|
246
|
+
/** UUID as a string. */
|
|
247
|
+
const uuid = /* @__PURE__ */ defineType({ sqlType: "uuid" }).withOperators(orderingOperators);
|
|
248
|
+
export { timestamptz as _, numeric as a, array as b, cidr as c, jsonb as d, enumOf as f, timestamp as g, time as h, integer as i, inet as l, interval as m, bigint as n, real as o, date as p, doublePrecision as r, smallint as s, uuid as t, json as u, boolean as v, bytea as y };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bi as MergeOperators, Di as Type, Hi as OperatorDefinitions, Lr as ComparisonSignature, Mr as EqualityOperators, Nr as HasEquality, Pr as InSignature, S as AnyExpression, Ti as BaseType, Ui as GenericOperator, Vi as NoOperators, _ as TextOperators, b as NumberTypeOperators, jr as EqualityOperator, v as TextTypeOperators } from "./index-CoKpXcBp.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a one-dimensional array type of `element` values.
|
|
4
4
|
*
|
|
@@ -13,63 +13,63 @@ export declare const bytea: BaseType<Uint8Array<ArrayBufferLike>, Uint8Array<Arr
|
|
|
13
13
|
export declare const boolean: BaseType<boolean, boolean, EqualityOperators, undefined>;
|
|
14
14
|
/** Point in time as a UTC ISO 8601 string with microseconds, such as `2026-01-15T07:00:00.123456Z`; accepts a `Date` too. */
|
|
15
15
|
export declare const timestamptz: Type<string, string | Date, MergeOperators<NoOperators, {
|
|
16
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
17
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
18
|
+
in: EqualityOperator<InSignature>;
|
|
16
19
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
17
20
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
18
21
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
19
22
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
20
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
21
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
22
|
-
in: EqualityOperator<InSignature>;
|
|
23
23
|
}>, [precision: number]>;
|
|
24
24
|
/** Date and time without a time zone as an ISO 8601 string with microseconds, such as `2026-01-15T10:00:00.000000`. */
|
|
25
25
|
export declare const timestamp: Type<string, string, MergeOperators<NoOperators, {
|
|
26
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
27
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
28
|
+
in: EqualityOperator<InSignature>;
|
|
26
29
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
27
30
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
28
31
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
29
32
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
30
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
31
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
32
|
-
in: EqualityOperator<InSignature>;
|
|
33
33
|
}>, [precision: number]>;
|
|
34
34
|
/** Calendar date as an ISO 8601 string, such as `2026-01-15`. */
|
|
35
35
|
export declare const date: BaseType<string, string, MergeOperators<NoOperators, {
|
|
36
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
37
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
38
|
+
in: EqualityOperator<InSignature>;
|
|
36
39
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
37
40
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
38
41
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
39
42
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
40
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
41
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
42
|
-
in: EqualityOperator<InSignature>;
|
|
43
43
|
}>, undefined>;
|
|
44
44
|
/** Time of day as a string with microseconds, such as `10:00:00.000000`. */
|
|
45
45
|
export declare const time: Type<string, string, MergeOperators<NoOperators, {
|
|
46
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
47
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
48
|
+
in: EqualityOperator<InSignature>;
|
|
46
49
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
47
50
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
48
51
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
49
52
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
50
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
51
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
52
|
-
in: EqualityOperator<InSignature>;
|
|
53
53
|
}>, [precision: number]>;
|
|
54
54
|
/** Interval in the PostgreSQL output format, such as `1 day 02:00:00`. */
|
|
55
55
|
export declare const interval: BaseType<string, string, MergeOperators<NoOperators, {
|
|
56
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
57
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
58
|
+
in: EqualityOperator<InSignature>;
|
|
56
59
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
57
60
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
58
61
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
59
62
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
60
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
61
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
62
|
-
in: EqualityOperator<InSignature>;
|
|
63
63
|
}>, undefined>;
|
|
64
64
|
/** Creates a type of an existing PostgreSQL enum; values are ordered as declared in the enum. */
|
|
65
65
|
declare function enumOf<const Values extends readonly string[]>(name: string, _values: Values): BaseType<Values[number], Values[number], MergeOperators<NoOperators, {
|
|
66
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
67
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
68
|
+
in: EqualityOperator<InSignature>;
|
|
66
69
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
67
70
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
68
71
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
69
72
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
70
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
71
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
72
|
-
in: EqualityOperator<InSignature>;
|
|
73
73
|
}>, undefined>;
|
|
74
74
|
/** JSON type of `unknown` values with operators `O` and `of`, which declares their shape. */
|
|
75
75
|
type JsonType<O extends OperatorDefinitions = NoOperators> = Type<unknown, unknown, O> & {
|
|
@@ -82,106 +82,106 @@ export declare const json: JsonType<NoOperators>;
|
|
|
82
82
|
export declare const jsonb: JsonType<MergeOperators<NoOperators, EqualityOperators>>;
|
|
83
83
|
/** IP address with an optional netmask as a string, such as `192.168.0.1`. */
|
|
84
84
|
export declare const inet: BaseType<string, string, MergeOperators<NoOperators, {
|
|
85
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
86
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
87
|
+
in: EqualityOperator<InSignature>;
|
|
85
88
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
86
89
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
87
90
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
88
91
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
89
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
90
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
91
|
-
in: EqualityOperator<InSignature>;
|
|
92
92
|
}>, undefined>;
|
|
93
93
|
/** IP network as a string, such as `10.0.0.0/8`. */
|
|
94
94
|
export declare const cidr: BaseType<string, string, MergeOperators<NoOperators, {
|
|
95
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
96
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
97
|
+
in: EqualityOperator<InSignature>;
|
|
95
98
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
96
99
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
97
100
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
98
101
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
99
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
100
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
101
|
-
in: EqualityOperator<InSignature>;
|
|
102
102
|
}>, undefined>;
|
|
103
103
|
/** 2-byte integer as a `number`. */
|
|
104
104
|
export declare const smallint: BaseType<number, number, MergeOperators<NoOperators, {
|
|
105
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
106
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
107
|
+
in: EqualityOperator<InSignature>;
|
|
105
108
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
106
109
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
107
110
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
108
111
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
109
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
110
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
111
|
-
in: EqualityOperator<InSignature>;
|
|
112
112
|
}>, undefined>;
|
|
113
113
|
/** 4-byte integer as a `number`. */
|
|
114
114
|
export declare const integer: BaseType<number, number, NumberTypeOperators, undefined>;
|
|
115
115
|
/** 8-byte integer as a `bigint`, which keeps values beyond `Number.MAX_SAFE_INTEGER`; accepts a `number` too. */
|
|
116
116
|
export declare const bigint: BaseType<bigint, number | bigint, MergeOperators<NoOperators, {
|
|
117
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
118
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
119
|
+
in: EqualityOperator<InSignature>;
|
|
117
120
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
118
121
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
119
122
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
120
123
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
121
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
122
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
123
|
-
in: EqualityOperator<InSignature>;
|
|
124
124
|
}>, undefined>;
|
|
125
125
|
/** 4-byte floating-point number as a `number`. */
|
|
126
126
|
export declare const real: BaseType<number, number, MergeOperators<NoOperators, {
|
|
127
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
128
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
129
|
+
in: EqualityOperator<InSignature>;
|
|
127
130
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
128
131
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
129
132
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
130
133
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
131
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
132
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
133
|
-
in: EqualityOperator<InSignature>;
|
|
134
134
|
}>, undefined>;
|
|
135
135
|
/** 8-byte floating-point number as a `number`. */
|
|
136
136
|
export declare const doublePrecision: BaseType<number, number, MergeOperators<NoOperators, {
|
|
137
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
138
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
139
|
+
in: EqualityOperator<InSignature>;
|
|
137
140
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
138
141
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
139
142
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
140
143
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
141
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
142
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
143
|
-
in: EqualityOperator<InSignature>;
|
|
144
144
|
}>, undefined>;
|
|
145
145
|
/** Exact number as a decimal string, so that no precision is lost; `numeric.with(precision, scale)` constrains it. */
|
|
146
146
|
export declare const numeric: Type<string, string | number | bigint, MergeOperators<NoOperators, {
|
|
147
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
148
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
149
|
+
in: EqualityOperator<InSignature>;
|
|
147
150
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
148
151
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
149
152
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
150
153
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
151
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
152
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
153
|
-
in: EqualityOperator<InSignature>;
|
|
154
154
|
}>, [precision: number, scale?: number | undefined]>;
|
|
155
155
|
/** Variable-length string without a limit. */
|
|
156
156
|
export declare const text: BaseType<string, string, TextTypeOperators, undefined>;
|
|
157
157
|
/** Variable-length string; `varchar.with(length)` limits its length. */
|
|
158
158
|
export declare const varchar: Type<string, string, MergeOperators<MergeOperators<NoOperators, {
|
|
159
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
160
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
161
|
+
in: EqualityOperator<InSignature>;
|
|
159
162
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
160
163
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
161
164
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
162
165
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
163
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
164
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
165
|
-
in: EqualityOperator<InSignature>;
|
|
166
166
|
}>, TextOperators>, [length: number]>;
|
|
167
167
|
/** Fixed-length string that PostgreSQL pads with spaces; `char` alone has length 1, and `char.with(length)` sets the length. */
|
|
168
168
|
export declare const char: Type<string, string, MergeOperators<MergeOperators<NoOperators, {
|
|
169
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
170
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
171
|
+
in: EqualityOperator<InSignature>;
|
|
169
172
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
170
173
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
171
174
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
172
175
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
173
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
174
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
175
|
-
in: EqualityOperator<InSignature>;
|
|
176
176
|
}>, TextOperators>, [length: number]>;
|
|
177
177
|
/** UUID as a string. */
|
|
178
178
|
export declare const uuid: BaseType<string, string, MergeOperators<NoOperators, {
|
|
179
|
+
eq: EqualityOperator<ComparisonSignature>;
|
|
180
|
+
ne: EqualityOperator<ComparisonSignature>;
|
|
181
|
+
in: EqualityOperator<InSignature>;
|
|
179
182
|
lt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
180
183
|
lte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
181
184
|
gt: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
182
185
|
gte: GenericOperator<ComparisonSignature, AnyExpression<unknown, unknown>>;
|
|
183
|
-
eq: EqualityOperator<ComparisonSignature>;
|
|
184
|
-
ne: EqualityOperator<ComparisonSignature>;
|
|
185
|
-
in: EqualityOperator<InSignature>;
|
|
186
186
|
}>, undefined>;
|
|
187
187
|
export { enumOf as enum };
|