kern-db 0.0.0-stage → 0.2.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.
@@ -0,0 +1,113 @@
1
+ declare const typeValues: unique symbol;
2
+ /**
3
+ * Type of PostgreSQL values: the SQL names of the type and the conversion between JavaScript values and their PostgreSQL text representation.
4
+ *
5
+ * `Output` are the values that it returns and `Input` those that it accepts, where `null` stands for `NULL`.
6
+ * `defineType` creates a type, and an object that copies the members of a type is a type too.
7
+ */
8
+ interface Type<Output, Input = Output> {
9
+ /** Value types for type inference; absent at runtime. */
10
+ readonly [typeValues]: {
11
+ output: Output;
12
+ input: Input;
13
+ };
14
+ /** SQL type name used in DDL, such as `numeric` or `vector(1536)`. */
15
+ readonly sqlType: string;
16
+ /**
17
+ * SQL type name that a parameter is cast to, such as `numeric` for `numeric(10,2)`.
18
+ *
19
+ * It omits type parameters, so that their precision, scale, or length do not constrain a parameter.
20
+ */
21
+ readonly castType: string;
22
+ readonly isNullable: boolean;
23
+ /** Converts a non-null value to its PostgreSQL text representation; it does not read `this`. */
24
+ readonly encode: (value: NonNullable<Input>) => string;
25
+ /** Converts a non-null PostgreSQL text representation to a value; it does not read `this`. */
26
+ readonly decode: (text: string) => Exclude<Output, null>;
27
+ }
28
+ /** Type of any values. */
29
+ type AnyType = Type<any, any>;
30
+ /** Values that a type returns. */
31
+ type TypeOutput<T extends AnyType> = T[typeof typeValues]["output"];
32
+ /** Values that a type accepts. */
33
+ type TypeInput<T extends AnyType> = T[typeof typeValues]["input"];
34
+ /**
35
+ * Type that derives other types of its PostgreSQL type, as `defineType` creates it.
36
+ *
37
+ * A type with PostgreSQL type parameters, such as the length of `varchar(255)`, has `with`.
38
+ */
39
+ type DerivableType<Output, Input = Output, Parameters extends unknown[] | undefined = undefined> = BaseDerivableType<Output, Input, Parameters> & (Parameters extends unknown[] ? DerivableTypeWithParameters<Output, Input, Parameters> : unknown);
40
+ /** Members of every derivable type; see `DerivableType`. */
41
+ interface BaseDerivableType<Output, Input, Parameters extends unknown[] | undefined> extends Type<Output, Input> {
42
+ /**
43
+ * Creates a type that accepts PostgreSQL type parameters with `with`.
44
+ *
45
+ * `format` returns the SQL type name with the parameters, such as `vector(1536)` for `1536`.
46
+ */
47
+ withParameters<P extends unknown[]>(format: (...parameters: P) => string): DerivableType<Output, Input, P>;
48
+ /**
49
+ * Creates a type with another representation of the values of this type, keeping its SQL type and nullability.
50
+ * An `encode` that takes `null` also makes the result nullable.
51
+ *
52
+ * `decode` receives the values that this type decodes from values other than `NULL`, including `undefined` that an earlier decoder returns, and returns a value other than `null`; `encode` returns values that this type encodes; `NULL` stays `null` without them.
53
+ */
54
+ transform<NewOutput extends {} | undefined, NewInput>(options: TypeTransform<Exclude<Output, null>, NonNullable<Input>, NewOutput, NewInput>): DerivableType<NewOutput | AcceptedNull<NewInput | Input>, NewInput | AcceptedNull<Input>, Parameters>;
55
+ /** Creates a type that decodes the values of this type into another representation, other than `null`, and accepts the values that this type accepts. */
56
+ transform<NewOutput extends {} | undefined>(options: {
57
+ decode: (value: Exclude<Output, null>) => NewOutput;
58
+ }): DerivableType<NewOutput | AcceptedNull<Input>, Input, Parameters>;
59
+ /** Creates a type whose values include `null`, which stands for `NULL`. */
60
+ nullable(): DerivableType<Output | null, Input | null, Parameters>;
61
+ /**
62
+ * Narrows the values of this type to `T` in TypeScript, such as to a union of strings that a `CHECK` constraint allows, or to the shape of JSON values.
63
+ *
64
+ * The values are not validated at runtime. `T` must be among the values that this type both returns and accepts, and `nullable` keeps `null` apart from it.
65
+ */
66
+ of<T extends AcceptedValues<Exclude<Output, null>, Exclude<Input, null>>>(): DerivableType<T | AcceptedNull<Input>, T | AcceptedNull<Input>, Parameters>;
67
+ }
68
+ /** Members of a derivable type with PostgreSQL type parameters; see `DerivableType`. */
69
+ interface DerivableTypeWithParameters<Output, Input, Parameters extends unknown[]> {
70
+ /** Creates this type with PostgreSQL type parameters, such as `varchar.with(255)` for `varchar(255)`; other changes of the type are kept. */
71
+ with(...parameters: Parameters): DerivableType<Output, Input, Parameters>;
72
+ }
73
+ /** Derivable type of any values and parameters. */
74
+ type AnyDerivableType = DerivableType<any, any, any>;
75
+ /**
76
+ * Values that `of` can narrow a type to: those both among the values `O` that it returns and among the values `I` that it accepts, or `UnacceptedValues` when there are none.
77
+ *
78
+ * A narrowed value is also accepted, so its encoder must take it.
79
+ */
80
+ type AcceptedValues<O, I> = [O] extends [I] ? O : [I] extends [O] ? I : [O & I] extends [never] ? UnacceptedValues : O & I;
81
+ /** `null` when the accepted values `I` include it, also as `unknown`; `never` otherwise. */
82
+ type AcceptedNull<I> = null extends I ? null : never;
83
+ /** Type that `AcceptedValues` names for a type that accepts none of the values it returns. */
84
+ interface UnacceptedValues {
85
+ readonly "of narrows only a type that accepts the values it returns": never;
86
+ }
87
+ /** Conversion between the values of a type and their new representation. */
88
+ interface TypeTransform<Output, Input, NewOutput, NewInput> {
89
+ decode: (value: Output) => NewOutput;
90
+ encode: (value: NewInput) => Input;
91
+ }
92
+ /** Type definition. */
93
+ interface TypeOptions {
94
+ /** SQL type name, such as `ltree`; `withParameters` adds type parameters to it, and a name with them requires `castType`. */
95
+ sqlType: string;
96
+ /** SQL type name that parameters are cast to when `sqlType` constrains values, such as `bpchar` for `char`, whose length is 1. */
97
+ castType?: string;
98
+ }
99
+ /**
100
+ * Defines a type whose values are the PostgreSQL text representations as they are.
101
+ *
102
+ * `transform` converts them to other values, such as `number[]` for `vector`.
103
+ */
104
+ declare function defineType(options: TypeOptions & {
105
+ readonly [typeValues]?: NotTypeOptions;
106
+ }): DerivableType<string>;
107
+ /** Type that the options of `defineType` are checked against when they are a type, naming the reason. */
108
+ interface NotTypeOptions {
109
+ readonly "defineType of kern-db takes options, not a type": never;
110
+ }
111
+ /** Tells whether `value` is a type, including an object that copies the members of one. */
112
+ declare function isType(value: unknown): value is AnyType;
113
+ export { BaseDerivableType as a, Type as c, TypeOutput as d, TypeTransform as f, typeValues as h, AnyType as i, TypeInput as l, isType as m, AcceptedValues as n, DerivableType as o, defineType as p, AnyDerivableType as r, DerivableTypeWithParameters as s, AcceptedNull as t, TypeOptions as u };
@@ -0,0 +1,186 @@
1
+ import { o as defineType } from "./bytea-DNZ_ftio.mjs";
2
+ // src/type/type-name.ts
3
+ /** Appends type parameters, such as the precision and scale in `numeric(10,2)`, to a type name. */
4
+ function formatTypeName(name, ...parameters) {
5
+ const defined = parameters.filter((parameter) => parameter !== void 0);
6
+ return defined.length === 0 ? name : `${name}(${defined.join(",")})`;
7
+ }
8
+ // src/type/builtins/datetime.ts
9
+ /** Point in time as a UTC ISO 8601 string with microseconds, such as `2026-01-15T07:00:00.123456Z`; accepts a `Date` too. */
10
+ const timestamptz = /* @__PURE__ */ defineType({ sqlType: "timestamptz" }).transform({
11
+ decode: normalizeTimestamptz,
12
+ encode: (value) => toPostgresYear(value instanceof Date ? value.toISOString() : value)
13
+ }).withParameters(/* @__PURE__ */ createPrecisionFormatter("timestamptz"));
14
+ /** Date and time without a time zone as an ISO 8601 string with microseconds, such as `2026-01-15T10:00:00.000000`. */
15
+ const timestamp = /* @__PURE__ */ defineType({ sqlType: "timestamp" }).transform({
16
+ decode: normalizeTimestamp,
17
+ encode: toPostgresYear
18
+ }).withParameters(/* @__PURE__ */ createPrecisionFormatter("timestamp"));
19
+ /** Calendar date as an ISO 8601 string, such as `2026-01-15`. */
20
+ const date = /* @__PURE__ */ defineType({ sqlType: "date" }).transform({
21
+ decode: normalizeDate,
22
+ encode: toPostgresYear
23
+ });
24
+ /** Time of day as a string with microseconds, such as `10:00:00.000000`. */
25
+ const time = /* @__PURE__ */ defineType({ sqlType: "time" }).transform({ decode: normalizeTime }).withParameters(/* @__PURE__ */ createPrecisionFormatter("time"));
26
+ /** Interval in the PostgreSQL output format, such as `1 day 02:00:00`. */
27
+ const interval = /* @__PURE__ */ defineType({ sqlType: "interval" });
28
+ function createPrecisionFormatter(name) {
29
+ return (precision) => formatTypeName(name, precision);
30
+ }
31
+ const timestamptzPattern = /^(\d{4,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,6}))?([+-])(\d{2})(?::(\d{2}))?(?::(\d{2}))?( BC)?$/;
32
+ const timestampPattern = /^(\d{4,})(-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?( BC)?$/;
33
+ const datePattern = /^(\d{4,})(-\d{2}-\d{2})( BC)?$/;
34
+ const timePattern = /^(\d{2}:\d{2}:\d{2})(?:\.(\d{1,6}))?$/;
35
+ /** Leading ISO 8601 year that PostgreSQL does not accept: an expanded year, such as `+010000`, or year `0000`. */
36
+ const isoYearPattern = /^([+-]\d{6,}|0000)(-.*)$/s;
37
+ /** Special date and time values that PostgreSQL returns as they are. */
38
+ const infinities = /* @__PURE__ */ new Set(["infinity", "-infinity"]);
39
+ /**
40
+ * Normalizes a `timestamptz` value to UTC ISO 8601 with microseconds, such as `2026-01-15T07:00:00.123456Z`.
41
+ *
42
+ * The fixed format keeps microseconds that `Date` would lose; the arithmetic avoids `Date`, whose range is narrower than that of PostgreSQL.
43
+ */
44
+ function normalizeTimestamptz(text) {
45
+ if (infinities.has(text)) return text;
46
+ const match = timestamptzPattern.exec(text);
47
+ if (!match) throw new Error(`Unsupported timestamptz value "${text}"; kern-db expects DateStyle ISO`);
48
+ const offset = (match[8] === "-" ? -1 : 1) * (Number(match[9]) * 3600 + Number(match[10] ?? 0) * 60 + Number(match[11] ?? 0));
49
+ 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;
50
+ const days = Math.floor(seconds / 86400);
51
+ const time = seconds - days * 86400;
52
+ return `${formatDate(days)}T${padTwo(Math.floor(time / 3600))}:${padTwo(Math.floor(time / 60) % 60)}:${padTwo(time % 60)}.${padFraction(match[7])}Z`;
53
+ }
54
+ /** Normalizes a `timestamp` value to ISO 8601 without a time zone, such as `2026-01-15T10:00:00.000000`. */
55
+ function normalizeTimestamp(text) {
56
+ if (infinities.has(text)) return text;
57
+ const match = timestampPattern.exec(text);
58
+ if (!match) throw new Error(`Unsupported timestamp value "${text}"; kern-db expects DateStyle ISO`);
59
+ return `${formatYear(toAstronomicalYear(match[1], match[5]))}${match[2]}T${match[3]}.${padFraction(match[4])}`;
60
+ }
61
+ /** Normalizes a `date` value to ISO 8601, such as `2026-01-15`. */
62
+ function normalizeDate(text) {
63
+ if (infinities.has(text)) return text;
64
+ const match = datePattern.exec(text);
65
+ if (!match) throw new Error(`Unsupported date value "${text}"; kern-db expects DateStyle ISO`);
66
+ return `${formatYear(toAstronomicalYear(match[1], match[3]))}${match[2]}`;
67
+ }
68
+ /** Normalizes a `time` value to `HH:MM:SS.ffffff`. */
69
+ function normalizeTime(text) {
70
+ const match = timePattern.exec(text);
71
+ if (!match) throw new Error(`Unsupported time value "${text}"`);
72
+ return `${match[1]}.${padFraction(match[2])}`;
73
+ }
74
+ /** Converts a leading ISO 8601 year outside 1 to 9999 into the PostgreSQL format: unsigned after 9999 and with a `BC` suffix before 1. */
75
+ function toPostgresYear(text) {
76
+ const match = isoYearPattern.exec(text);
77
+ if (!match) return text;
78
+ const year = Number(match[1]);
79
+ return year > 0 ? `${year}${match[2]}` : `${String(1 - year).padStart(4, "0")}${match[2]} BC`;
80
+ }
81
+ /** Returns the astronomical year of a PostgreSQL year, where 1 BC is year 0. */
82
+ function toAstronomicalYear(year, era) {
83
+ return era === void 0 ? Number(year) : 1 - Number(year);
84
+ }
85
+ /** Formats an astronomical year as an ISO 8601 year, expanded with a sign outside 0 to 9999. */
86
+ function formatYear(year) {
87
+ if (year >= 0 && year <= 9999) return String(year).padStart(4, "0");
88
+ return `${year < 0 ? "-" : "+"}${String(Math.abs(year)).padStart(6, "0")}`;
89
+ }
90
+ /** Counts the days from 1970-01-01 to a date of an astronomical year. */
91
+ function countDays(year, month, day) {
92
+ const shifted = month <= 2 ? year - 1 : year;
93
+ const era = Math.floor(shifted / 400);
94
+ const yearOfEra = shifted - era * 400;
95
+ const dayOfYear = Math.floor((153 * (month > 2 ? month - 3 : month + 9) + 2) / 5) + day - 1;
96
+ const dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;
97
+ return era * 146097 + dayOfEra - 719468;
98
+ }
99
+ /** Formats the date a number of days after 1970-01-01 as an ISO 8601 date. */
100
+ function formatDate(days) {
101
+ const shifted = days + 719468;
102
+ const era = Math.floor(shifted / 146097);
103
+ const dayOfEra = shifted - era * 146097;
104
+ const yearOfEra = Math.floor((dayOfEra - Math.floor(dayOfEra / 1460) + Math.floor(dayOfEra / 36524) - Math.floor(dayOfEra / 146096)) / 365);
105
+ const dayOfYear = dayOfEra - (365 * yearOfEra + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100));
106
+ const shiftedMonth = Math.floor((5 * dayOfYear + 2) / 153);
107
+ const day = dayOfYear - Math.floor((153 * shiftedMonth + 2) / 5) + 1;
108
+ const month = shiftedMonth < 10 ? shiftedMonth + 3 : shiftedMonth - 9;
109
+ return `${formatYear(yearOfEra + era * 400 + (month <= 2 ? 1 : 0))}-${padTwo(month)}-${padTwo(day)}`;
110
+ }
111
+ function padTwo(value) {
112
+ return value < 10 ? `0${value}` : String(value);
113
+ }
114
+ function padFraction(fraction) {
115
+ return (fraction ?? "").padEnd(6, "0");
116
+ }
117
+ // src/type/builtins/enum.ts
118
+ /** Creates a type of an existing PostgreSQL enum of `values`. */
119
+ function enumOf(name, _values) {
120
+ return defineType({
121
+ sqlType: name,
122
+ castType: name
123
+ }).of();
124
+ }
125
+ // src/type/builtins/json.ts
126
+ /** `json` values; `json.of<T>()` declares their shape. */
127
+ const json = /* @__PURE__ */ defineJsonType("json");
128
+ /** `jsonb` values; `jsonb.of<T>()` declares their shape. */
129
+ const jsonb = /* @__PURE__ */ defineJsonType("jsonb");
130
+ /** Serializes a value as JSON text; values without a JSON representation, such as functions, are rejected. */
131
+ function stringifyJson(value) {
132
+ const text = JSON.stringify(value);
133
+ if (text === void 0) throw new TypeError(`Cannot encode ${typeof value} as JSON`);
134
+ return text;
135
+ }
136
+ function defineJsonType(sqlType) {
137
+ return defineType({ sqlType }).transform({
138
+ decode: (text) => JSON.parse(text),
139
+ encode: stringifyJson
140
+ });
141
+ }
142
+ // src/type/builtins/network.ts
143
+ /** IP address with an optional netmask as a string, such as `192.168.0.1`. */
144
+ const inet = /* @__PURE__ */ defineType({ sqlType: "inet" });
145
+ /** IP network as a string, such as `10.0.0.0/8`. */
146
+ const cidr = /* @__PURE__ */ defineType({ sqlType: "cidr" });
147
+ // src/type/builtins/numeric.ts
148
+ /** 2-byte integer as a `number`. */
149
+ const smallint = /* @__PURE__ */ defineNumberType("smallint");
150
+ /** 4-byte integer as a `number`. */
151
+ const integer = /* @__PURE__ */ defineNumberType("integer");
152
+ /** 8-byte integer as a `bigint`, which keeps values beyond `Number.MAX_SAFE_INTEGER`; accepts a `number` too. */
153
+ const bigint = /* @__PURE__ */ defineType({ sqlType: "bigint" }).transform({
154
+ decode: BigInt,
155
+ encode: (value) => String(value)
156
+ });
157
+ /** 4-byte floating-point number as a `number`. */
158
+ const real = /* @__PURE__ */ defineNumberType("real");
159
+ /** 8-byte floating-point number as a `number`. */
160
+ const doublePrecision = /* @__PURE__ */ defineNumberType("double precision");
161
+ /** Exact number as a decimal string, so that no precision is lost; `numeric.with(precision, scale)` constrains it. */
162
+ const numeric = /* @__PURE__ */ defineType({ sqlType: "numeric" }).transform({
163
+ decode: (value) => value,
164
+ encode: (value) => String(value)
165
+ }).withParameters((precision, scale) => formatTypeName("numeric", precision, scale));
166
+ /** Defines a type of a PostgreSQL type of numbers whose values are JavaScript numbers. */
167
+ function defineNumberType(sqlType) {
168
+ return defineType({ sqlType }).transform({
169
+ decode: Number,
170
+ encode: (value) => String(value)
171
+ });
172
+ }
173
+ // src/type/builtins/text.ts
174
+ /** Variable-length string without a limit. */
175
+ const text = /* @__PURE__ */ defineType({ sqlType: "text" });
176
+ /** Variable-length string; `varchar.with(length)` limits its length. */
177
+ const varchar = /* @__PURE__ */ defineType({ sqlType: "varchar" }).withParameters((length) => formatTypeName("varchar", length));
178
+ /** Fixed-length string that PostgreSQL pads with spaces; `char` alone has length 1, and `char.with(length)` sets the length. */
179
+ const char = /* @__PURE__ */ defineType({
180
+ sqlType: "char",
181
+ castType: "bpchar"
182
+ }).withParameters((length) => formatTypeName("char", length));
183
+ // src/type/builtins/uuid.ts
184
+ /** UUID as a string. */
185
+ const uuid = /* @__PURE__ */ defineType({ sqlType: "uuid" });
186
+ export { interval as _, bigint as a, timestamptz as b, numeric as c, cidr as d, inet as f, date as g, enumOf as h, varchar as i, real as l, jsonb as m, char as n, doublePrecision as o, json as p, text as r, integer as s, uuid as t, smallint as u, time as v, timestamp as y };
@@ -0,0 +1,53 @@
1
+ import { a as BaseDerivableType, c as Type, o as DerivableType, s as DerivableTypeWithParameters } from "./type-CbrtxvDF.mjs";
2
+ /**
3
+ * Creates a type of one-dimensional arrays of `element` values.
4
+ *
5
+ * A `NULL` element decodes to `null`; a nullable `element` type, such as `array(text.nullable())`, types such elements.
6
+ * 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.
7
+ */
8
+ export declare function array<Output, Input>(element: Type<Output, Input>): DerivableType<Output[], Input[]>;
9
+ /** Binary data; PostgreSQL represents it in hex, which requires the default `bytea_output` setting. */
10
+ export declare const bytea: BaseDerivableType<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, undefined>;
11
+ /** `boolean` values. */
12
+ export declare const boolean: BaseDerivableType<boolean, boolean, undefined>;
13
+ /** Point in time as a UTC ISO 8601 string with microseconds, such as `2026-01-15T07:00:00.123456Z`; accepts a `Date` too. */
14
+ export declare const timestamptz: DerivableType<string, string | Date, [precision: number]>;
15
+ /** Date and time without a time zone as an ISO 8601 string with microseconds, such as `2026-01-15T10:00:00.000000`. */
16
+ export declare const timestamp: DerivableType<string, string, [precision: number]>;
17
+ /** Calendar date as an ISO 8601 string, such as `2026-01-15`. */
18
+ export declare const date: BaseDerivableType<string, string, undefined>;
19
+ /** Time of day as a string with microseconds, such as `10:00:00.000000`. */
20
+ export declare const time: DerivableType<string, string, [precision: number]>;
21
+ /** Interval in the PostgreSQL output format, such as `1 day 02:00:00`. */
22
+ export declare const interval: BaseDerivableType<string, string, undefined>;
23
+ /** Creates a type of an existing PostgreSQL enum of `values`. */
24
+ declare function enumOf<const Values extends readonly string[]>(name: string, _values: Values): BaseDerivableType<Values[number], Values[number], undefined>;
25
+ /** `json` values; `json.of<T>()` declares their shape. */
26
+ export declare const json: BaseDerivableType<unknown, {}, undefined>;
27
+ /** `jsonb` values; `jsonb.of<T>()` declares their shape. */
28
+ export declare const jsonb: BaseDerivableType<unknown, {}, undefined>;
29
+ /** IP address with an optional netmask as a string, such as `192.168.0.1`. */
30
+ export declare const inet: BaseDerivableType<string, string, undefined>;
31
+ /** IP network as a string, such as `10.0.0.0/8`. */
32
+ export declare const cidr: BaseDerivableType<string, string, undefined>;
33
+ /** 2-byte integer as a `number`. */
34
+ export declare const smallint: BaseDerivableType<number, number, undefined>;
35
+ /** 4-byte integer as a `number`. */
36
+ export declare const integer: BaseDerivableType<number, number, undefined>;
37
+ /** 8-byte integer as a `bigint`, which keeps values beyond `Number.MAX_SAFE_INTEGER`; accepts a `number` too. */
38
+ export declare const bigint: BaseDerivableType<bigint, number | bigint, undefined>;
39
+ /** 4-byte floating-point number as a `number`. */
40
+ export declare const real: BaseDerivableType<number, number, undefined>;
41
+ /** 8-byte floating-point number as a `number`. */
42
+ export declare const doublePrecision: BaseDerivableType<number, number, undefined>;
43
+ /** Exact number as a decimal string, so that no precision is lost; `numeric.with(precision, scale)` constrains it. */
44
+ export declare const numeric: DerivableType<string, string | number | bigint, [precision: number, scale?: number | undefined]>;
45
+ /** Variable-length string without a limit. */
46
+ export declare const text: BaseDerivableType<string, string, undefined>;
47
+ /** Variable-length string; `varchar.with(length)` limits its length. */
48
+ export declare const varchar: DerivableType<string, string, [length: number]>;
49
+ /** Fixed-length string that PostgreSQL pads with spaces; `char` alone has length 1, and `char.with(length)` sets the length. */
50
+ export declare const char: DerivableType<string, string, [length: number]>;
51
+ /** UUID as a string. */
52
+ export declare const uuid: BaseDerivableType<string, string, undefined>;
53
+ export { type BaseDerivableType, type DerivableType, type DerivableTypeWithParameters, enumOf as enum };
package/dist/types.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { r as boolean, t as bytea } from "./bytea-DNZ_ftio.mjs";
2
+ import { t as array } from "./array-BLt8ZNR5.mjs";
3
+ import { _ as interval, a as bigint, b as timestamptz, c as numeric, d as cidr, f as inet, g as date, h as enumOf, i as varchar, l as real, m as jsonb, n as char, o as doublePrecision, p as json, r as text, s as integer, t as uuid, u as smallint, v as time, y as timestamp } from "./types-Dl2oicjV.mjs";
4
+ export { array, bigint, boolean, bytea, char, cidr, date, doublePrecision, enumOf as enum, inet, integer, interval, json, jsonb, numeric, real, smallint, text, time, timestamp, timestamptz, uuid, varchar };
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "kern-db",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "PostgreSQL database layer with ambient transactions, typed SQL queries, and test transactions",
5
+ "keywords": [
6
+ "database",
7
+ "postgres",
8
+ "postgresql",
9
+ "sql",
10
+ "transactions",
11
+ "typescript"
12
+ ],
13
+ "homepage": "https://ilyasemenov.github.io/kern-orm/",
14
+ "bugs": "https://github.com/IlyaSemenov/kern-orm/issues",
15
+ "license": "MIT",
16
+ "author": "Ilya Semenov",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/IlyaSemenov/kern-orm.git",
20
+ "directory": "packages/db"
21
+ },
22
+ "files": [
23
+ "README.md",
24
+ "dist"
25
+ ],
26
+ "type": "module",
27
+ "sideEffects": false,
28
+ "types": "./dist/index.d.mts",
29
+ "exports": {
30
+ ".": "./dist/index.mjs",
31
+ "./builder": "./dist/builder.mjs",
32
+ "./node-postgres": "./dist/node-postgres.mjs",
33
+ "./postgres-js": "./dist/postgres-js.mjs",
34
+ "./testing": "./dist/testing.mjs",
35
+ "./types": "./dist/types.mjs",
36
+ "./package.json": "./package.json"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "scripts": {
42
+ "build": "tsdown",
43
+ "prepublishOnly": "bun run build"
44
+ },
45
+ "devDependencies": {
46
+ "@kern-orm/test-harness": "workspace:*",
47
+ "@types/pg": "catalog:",
48
+ "pg": "catalog:",
49
+ "postgres": "catalog:"
50
+ },
51
+ "peerDependencies": {
52
+ "@types/pg": "^8.0.0",
53
+ "pg": "^8.23.1",
54
+ "postgres": "^4.0.0"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "@types/pg": {
58
+ "optional": true
59
+ },
60
+ "pg": {
61
+ "optional": true
62
+ },
63
+ "postgres": {
64
+ "optional": true
65
+ }
66
+ },
67
+ "engines": {
68
+ "bun": ">=1.4",
69
+ "node": ">=24"
70
+ }
71
+ }