dsqlbase 0.1.0 → 0.1.1
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/CHANGELOG.md +8 -0
- package/dist/client/create.d.ts +73 -0
- package/dist/client/create.d.ts.map +1 -0
- package/dist/client/create.js +82 -0
- package/dist/client/create.js.map +1 -0
- package/dist/client/database/base.d.ts +8 -0
- package/dist/client/database/base.d.ts.map +1 -0
- package/dist/client/database/base.js +13 -0
- package/dist/client/database/base.js.map +1 -0
- package/dist/client/database/client.d.ts +5 -0
- package/dist/client/database/client.d.ts.map +1 -0
- package/dist/client/database/client.js +4 -0
- package/dist/client/database/client.js.map +1 -0
- package/dist/client/database/index.d.ts +9 -0
- package/dist/client/database/index.d.ts.map +1 -0
- package/dist/client/database/index.js +3 -0
- package/dist/client/database/index.js.map +1 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +5 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/model/base.d.ts +330 -0
- package/dist/client/model/base.d.ts.map +1 -0
- package/dist/client/model/base.js +7 -0
- package/dist/client/model/base.js.map +1 -0
- package/dist/client/model/client.d.ts +102 -0
- package/dist/client/model/client.d.ts.map +1 -0
- package/dist/client/model/client.js +123 -0
- package/dist/client/model/client.js.map +1 -0
- package/dist/client/model/normalizer.d.ts +19 -0
- package/dist/client/model/normalizer.d.ts.map +1 -0
- package/dist/client/model/normalizer.js +221 -0
- package/dist/client/model/normalizer.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pg/index.d.ts +9 -0
- package/dist/pg/index.d.ts.map +1 -0
- package/dist/pg/index.js +14 -0
- package/dist/pg/index.js.map +1 -0
- package/dist/pglite/index.d.ts +9 -0
- package/dist/pglite/index.d.ts.map +1 -0
- package/dist/pglite/index.js +14 -0
- package/dist/pglite/index.js.map +1 -0
- package/dist/schema/columns/array.d.ts +16 -0
- package/dist/schema/columns/array.d.ts.map +1 -0
- package/dist/schema/columns/array.js +24 -0
- package/dist/schema/columns/array.js.map +1 -0
- package/dist/schema/columns/bigint.d.ts +11 -0
- package/dist/schema/columns/bigint.d.ts.map +1 -0
- package/dist/schema/columns/bigint.js +19 -0
- package/dist/schema/columns/bigint.js.map +1 -0
- package/dist/schema/columns/boolean.d.ts +10 -0
- package/dist/schema/columns/boolean.d.ts.map +1 -0
- package/dist/schema/columns/boolean.js +18 -0
- package/dist/schema/columns/boolean.js.map +1 -0
- package/dist/schema/columns/bytea.d.ts +8 -0
- package/dist/schema/columns/bytea.d.ts.map +1 -0
- package/dist/schema/columns/bytea.js +16 -0
- package/dist/schema/columns/bytea.js.map +1 -0
- package/dist/schema/columns/char.d.ts +10 -0
- package/dist/schema/columns/char.d.ts.map +1 -0
- package/dist/schema/columns/char.js +18 -0
- package/dist/schema/columns/char.js.map +1 -0
- package/dist/schema/columns/date.d.ts +23 -0
- package/dist/schema/columns/date.d.ts.map +1 -0
- package/dist/schema/columns/date.js +29 -0
- package/dist/schema/columns/date.js.map +1 -0
- package/dist/schema/columns/double.d.ts +13 -0
- package/dist/schema/columns/double.d.ts.map +1 -0
- package/dist/schema/columns/double.js +21 -0
- package/dist/schema/columns/double.js.map +1 -0
- package/dist/schema/columns/identity.d.ts +56 -0
- package/dist/schema/columns/identity.d.ts.map +1 -0
- package/dist/schema/columns/identity.js +65 -0
- package/dist/schema/columns/identity.js.map +1 -0
- package/dist/schema/columns/int.d.ts +11 -0
- package/dist/schema/columns/int.d.ts.map +1 -0
- package/dist/schema/columns/int.js +19 -0
- package/dist/schema/columns/int.js.map +1 -0
- package/dist/schema/columns/interval.d.ts +23 -0
- package/dist/schema/columns/interval.d.ts.map +1 -0
- package/dist/schema/columns/interval.js +40 -0
- package/dist/schema/columns/interval.js.map +1 -0
- package/dist/schema/columns/json.d.ts +9 -0
- package/dist/schema/columns/json.d.ts.map +1 -0
- package/dist/schema/columns/json.js +18 -0
- package/dist/schema/columns/json.js.map +1 -0
- package/dist/schema/columns/numeric.d.ts +11 -0
- package/dist/schema/columns/numeric.d.ts.map +1 -0
- package/dist/schema/columns/numeric.js +19 -0
- package/dist/schema/columns/numeric.js.map +1 -0
- package/dist/schema/columns/real.d.ts +13 -0
- package/dist/schema/columns/real.d.ts.map +1 -0
- package/dist/schema/columns/real.js +21 -0
- package/dist/schema/columns/real.js.map +1 -0
- package/dist/schema/columns/smallint.d.ts +11 -0
- package/dist/schema/columns/smallint.d.ts.map +1 -0
- package/dist/schema/columns/smallint.js +19 -0
- package/dist/schema/columns/smallint.js.map +1 -0
- package/dist/schema/columns/text.d.ts +9 -0
- package/dist/schema/columns/text.d.ts.map +1 -0
- package/dist/schema/columns/text.js +17 -0
- package/dist/schema/columns/text.js.map +1 -0
- package/dist/schema/columns/time.d.ts +20 -0
- package/dist/schema/columns/time.d.ts.map +1 -0
- package/dist/schema/columns/time.js +19 -0
- package/dist/schema/columns/time.js.map +1 -0
- package/dist/schema/columns/timestamp.d.ts +40 -0
- package/dist/schema/columns/timestamp.d.ts.map +1 -0
- package/dist/schema/columns/timestamp.js +48 -0
- package/dist/schema/columns/timestamp.js.map +1 -0
- package/dist/schema/columns/uuid.d.ts +17 -0
- package/dist/schema/columns/uuid.d.ts.map +1 -0
- package/dist/schema/columns/uuid.js +27 -0
- package/dist/schema/columns/uuid.js.map +1 -0
- package/dist/schema/columns/varchar.d.ts +9 -0
- package/dist/schema/columns/varchar.d.ts.map +1 -0
- package/dist/schema/columns/varchar.js +17 -0
- package/dist/schema/columns/varchar.js.map +1 -0
- package/dist/schema/domain.d.ts +19 -0
- package/dist/schema/domain.d.ts.map +1 -0
- package/dist/schema/domain.js +37 -0
- package/dist/schema/domain.js.map +1 -0
- package/dist/schema/index.d.ts +27 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +25 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/namespace.d.ts +22 -0
- package/dist/schema/namespace.d.ts.map +1 -0
- package/dist/schema/namespace.js +24 -0
- package/dist/schema/namespace.js.map +1 -0
- package/dist/schema/relations.d.ts +12 -0
- package/dist/schema/relations.d.ts.map +1 -0
- package/dist/schema/relations.js +29 -0
- package/dist/schema/relations.js.map +1 -0
- package/dist/schema/sequence.d.ts +14 -0
- package/dist/schema/sequence.d.ts.map +1 -0
- package/dist/schema/sequence.js +16 -0
- package/dist/schema/sequence.js.map +1 -0
- package/dist/schema/table.d.ts +20 -0
- package/dist/schema/table.d.ts.map +1 -0
- package/dist/schema/table.js +22 -0
- package/dist/schema/table.js.map +1 -0
- package/dist/schema/utils/date.d.ts +33 -0
- package/dist/schema/utils/date.d.ts.map +1 -0
- package/dist/schema/utils/date.js +62 -0
- package/dist/schema/utils/date.js.map +1 -0
- package/dist/schema/utils/duration.d.ts +66 -0
- package/dist/schema/utils/duration.d.ts.map +1 -0
- package/dist/schema/utils/duration.js +167 -0
- package/dist/schema/utils/duration.js.map +1 -0
- package/dist/schema/utils/json.d.ts +2 -0
- package/dist/schema/utils/json.d.ts.map +1 -0
- package/dist/schema/utils/json.js +12 -0
- package/dist/schema/utils/json.js.map +1 -0
- package/package.json +33 -7
- package/dist/schema.d.ts +0 -2
- package/dist/schema.d.ts.map +0 -1
- package/dist/schema.js +0 -8
- package/dist/schema.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TableDefinition, AnyColumnDefinition, AnyNamespaceDefinition } from "@dsqlbase/core/definition";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a table schema with specified columns and optional schema association.
|
|
4
|
+
*
|
|
5
|
+
* @param name Table name in the database
|
|
6
|
+
* @param columns An object defining the columns of the table, where keys are field names used at runtime and values are ColumnDefinition instances that specify the column's properties and constraints.
|
|
7
|
+
* @returns A new instance of TableDefinition representing the defined table schema.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const users = table("users", {
|
|
13
|
+
* id: uuid("id").primaryKey(),
|
|
14
|
+
* name: text("name").notNull(),
|
|
15
|
+
* email: text("email").unique(),
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function table<TName extends string, TColumns extends Record<string, AnyColumnDefinition>>(name: TName, columns: TColumns): TableDefinition<TName, TColumns, AnyNamespaceDefinition>;
|
|
20
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/schema/table.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC9F,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,QAAQ,GAChB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,sBAAsB,CAAC,CAE1D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TableDefinition, } from "@dsqlbase/core/definition";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a table schema with specified columns and optional schema association.
|
|
4
|
+
*
|
|
5
|
+
* @param name Table name in the database
|
|
6
|
+
* @param columns An object defining the columns of the table, where keys are field names used at runtime and values are ColumnDefinition instances that specify the column's properties and constraints.
|
|
7
|
+
* @returns A new instance of TableDefinition representing the defined table schema.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const users = table("users", {
|
|
13
|
+
* id: uuid("id").primaryKey(),
|
|
14
|
+
* name: text("name").notNull(),
|
|
15
|
+
* email: text("email").unique(),
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function table(name, columns) {
|
|
20
|
+
return new TableDefinition(name, { columns });
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/schema/table.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,GAGhB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,UAAU,KAAK,CACnB,IAAW,EACX,OAAiB;IAEjB,OAAO,IAAI,eAAe,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type DateTimeMode = "iso" | "string" | "date";
|
|
2
|
+
export declare const safeParseDate: (value: unknown) => Date;
|
|
3
|
+
export declare const utcDate: (date: Date) => Date;
|
|
4
|
+
/**
|
|
5
|
+
* Formats a `Date` for a Postgres `timestamp` / `timestamp with time zone` literal.
|
|
6
|
+
*
|
|
7
|
+
* - `tz: true` → ISO 8601 in UTC (e.g. `"2026-04-30T09:00:00.000Z"`). Postgres normalises
|
|
8
|
+
* to an absolute instant on insert; downstream reads are session-zone agnostic.
|
|
9
|
+
* - `tz: false` → space-separated **local wall clock** (e.g. `"2026-04-30 12:00:00.000"`).
|
|
10
|
+
* The literal value the caller wrote is the literal value Postgres stores. There is
|
|
11
|
+
* no zone metadata, so `getTime()` parity across machines is not preserved — that is
|
|
12
|
+
* the contract of `timestamp without time zone`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const formatTimestamp: (date: Date, opts: {
|
|
15
|
+
tz: boolean;
|
|
16
|
+
}) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Formats a `Date` as a Postgres `date` literal `YYYY-MM-DD` using the **local**
|
|
19
|
+
* components of the input — Postgres `date` has no timezone concept, so we preserve
|
|
20
|
+
* the wall-clock day the caller authored.
|
|
21
|
+
*/
|
|
22
|
+
export declare const formatDate: (date: Date) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Formats a `Date`'s time-of-day for a Postgres `time` / `time with time zone` literal.
|
|
25
|
+
*
|
|
26
|
+
* - `tz: true` → UTC components with a trailing `Z` (e.g. `"09:00:00.000Z"`), mirroring
|
|
27
|
+
* the absolute-instant convention used for `timestamp with time zone`.
|
|
28
|
+
* - `tz: false` → local clock components (e.g. `"12:00:00.000"`), wall-clock semantics.
|
|
29
|
+
*/
|
|
30
|
+
export declare const formatTime: (date: Date, opts: {
|
|
31
|
+
tz: boolean;
|
|
32
|
+
}) => string;
|
|
33
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/schema/utils/date.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAErD,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,SAoB3C,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,MAAM,IAAI,SAEjC,CAAC;AAIF;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,EAAE,MAAM;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,WAUhE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,IAAI,WAEpC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,IAAI,EAAE,MAAM;IAAE,EAAE,EAAE,OAAO,CAAA;CAAE,WAY3D,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const safeParseDate = (value) => {
|
|
2
|
+
if (typeof value === "string") {
|
|
3
|
+
const parsed = Date.parse(value);
|
|
4
|
+
if (isNaN(parsed)) {
|
|
5
|
+
throw new Error(`Invalid date string: ${value}`);
|
|
6
|
+
}
|
|
7
|
+
return new Date(parsed);
|
|
8
|
+
}
|
|
9
|
+
if (value instanceof Date) {
|
|
10
|
+
if (isNaN(value.getTime())) {
|
|
11
|
+
throw new Error(`Invalid Date object: ${value}`);
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
throw new Error(`Unsupported date value: ${value}`);
|
|
16
|
+
};
|
|
17
|
+
export const utcDate = (date) => {
|
|
18
|
+
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
19
|
+
};
|
|
20
|
+
const pad = (n, width = 2) => String(n).padStart(width, "0");
|
|
21
|
+
/**
|
|
22
|
+
* Formats a `Date` for a Postgres `timestamp` / `timestamp with time zone` literal.
|
|
23
|
+
*
|
|
24
|
+
* - `tz: true` → ISO 8601 in UTC (e.g. `"2026-04-30T09:00:00.000Z"`). Postgres normalises
|
|
25
|
+
* to an absolute instant on insert; downstream reads are session-zone agnostic.
|
|
26
|
+
* - `tz: false` → space-separated **local wall clock** (e.g. `"2026-04-30 12:00:00.000"`).
|
|
27
|
+
* The literal value the caller wrote is the literal value Postgres stores. There is
|
|
28
|
+
* no zone metadata, so `getTime()` parity across machines is not preserved — that is
|
|
29
|
+
* the contract of `timestamp without time zone`.
|
|
30
|
+
*/
|
|
31
|
+
export const formatTimestamp = (date, opts) => {
|
|
32
|
+
if (opts.tz) {
|
|
33
|
+
return date.toISOString();
|
|
34
|
+
}
|
|
35
|
+
return (`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}` +
|
|
36
|
+
` ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}` +
|
|
37
|
+
`.${pad(date.getMilliseconds(), 3)}`);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Formats a `Date` as a Postgres `date` literal `YYYY-MM-DD` using the **local**
|
|
41
|
+
* components of the input — Postgres `date` has no timezone concept, so we preserve
|
|
42
|
+
* the wall-clock day the caller authored.
|
|
43
|
+
*/
|
|
44
|
+
export const formatDate = (date) => {
|
|
45
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Formats a `Date`'s time-of-day for a Postgres `time` / `time with time zone` literal.
|
|
49
|
+
*
|
|
50
|
+
* - `tz: true` → UTC components with a trailing `Z` (e.g. `"09:00:00.000Z"`), mirroring
|
|
51
|
+
* the absolute-instant convention used for `timestamp with time zone`.
|
|
52
|
+
* - `tz: false` → local clock components (e.g. `"12:00:00.000"`), wall-clock semantics.
|
|
53
|
+
*/
|
|
54
|
+
export const formatTime = (date, opts) => {
|
|
55
|
+
if (opts.tz) {
|
|
56
|
+
return (`${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${pad(date.getUTCSeconds())}` +
|
|
57
|
+
`.${pad(date.getUTCMilliseconds(), 3)}Z`);
|
|
58
|
+
}
|
|
59
|
+
return (`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}` +
|
|
60
|
+
`.${pad(date.getMilliseconds(), 3)}`);
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../src/schema/utils/date.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAE,EAAE;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEjC,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC1B,IAAI,KAAK,CAAC,KAAK,CAA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GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAE,EAAE;IACvC,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;AACpF,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAE,IAAqB,EAAE,EAAE;IAC9D,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;QACZ,OAAO,CACL,GAAG,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,EAAE;YACtF,IAAI,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,GAAG,CACzC,CAAC;IACJ,CAAC;IAED,OAAO,CACL,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE;QAC7E,IAAI,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,EAAE,CACrC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export interface Duration {
|
|
2
|
+
years: number;
|
|
3
|
+
months: number;
|
|
4
|
+
days: number;
|
|
5
|
+
hours: number;
|
|
6
|
+
minutes: number;
|
|
7
|
+
seconds: number;
|
|
8
|
+
milliseconds: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const ISO_DURATION_REGEX: RegExp;
|
|
11
|
+
export declare const STRING_DURATION_REGEX: RegExp;
|
|
12
|
+
/**
|
|
13
|
+
* Formats a Duration object into an ISO 8601 duration string.
|
|
14
|
+
*
|
|
15
|
+
* @param duration Duration object
|
|
16
|
+
* @returns ISO 8601 duration string like "P3Y6M4DT12H30M5S"
|
|
17
|
+
*/
|
|
18
|
+
export declare const formatISODuration: (duration: Partial<Duration>) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Parses an ISO 8601 duration string into a Duration object. Supported formats include:
|
|
21
|
+
* - "P3Y6M4DT12H30M5S" (3 years, 6 months, 4 days, 12 hours, 30 minutes, and 5 seconds)
|
|
22
|
+
* - "P2Y" (2 years)
|
|
23
|
+
* - "PT15M" (15 minutes)
|
|
24
|
+
* - "P1DT12H" (1 day and 12 hours)
|
|
25
|
+
* - "PT0.5S" (0.5 seconds)
|
|
26
|
+
* @param isoString
|
|
27
|
+
* @returns Duration object
|
|
28
|
+
*/
|
|
29
|
+
export declare const parseISODuration: (iso: string) => Duration;
|
|
30
|
+
/**
|
|
31
|
+
* Formats a Duration object into a human-readable string format.
|
|
32
|
+
*
|
|
33
|
+
* @param duration Duration object
|
|
34
|
+
* @returns String fomrat like "3 years 6 months 4 days 12 hours 30 minutes 5 seconds"
|
|
35
|
+
*/
|
|
36
|
+
export declare const formatStringDuration: (duration: Partial<Duration>) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Parses a human-readable duration string into a Duration object.
|
|
39
|
+
* Supported formats include:
|
|
40
|
+
* - "3 years 6 months 4 days 12 hours 30 minutes 5 seconds"
|
|
41
|
+
* - "2 hours 15 minutes"
|
|
42
|
+
* - "45 seconds"
|
|
43
|
+
*
|
|
44
|
+
* @param str String formatted duration
|
|
45
|
+
* @returns Duration object
|
|
46
|
+
*/
|
|
47
|
+
export declare const parseStringDuration: (str: string) => Duration;
|
|
48
|
+
export declare const PG_INTERVAL_REGEX: RegExp;
|
|
49
|
+
/**
|
|
50
|
+
* Parses Postgres' default `intervalstyle = 'postgres'` text format into a Duration object.
|
|
51
|
+
* Supported shapes include:
|
|
52
|
+
* - "40:00:00" / "12:30:05.5" (time-only, optional fractional seconds)
|
|
53
|
+
* - "-12:30:05" (signed time)
|
|
54
|
+
* - "4 days 12:30:05"
|
|
55
|
+
* - "3 years 6 mons 4 days 12:30:05" (note: PG uses `mons`, not `months`)
|
|
56
|
+
* - Per-component negatives: "-3 years -6 mons -4 days -12:30:05"
|
|
57
|
+
*
|
|
58
|
+
* Each calendar component carries its own sign; the time portion's leading `-` applies to
|
|
59
|
+
* hours/minutes/seconds/milliseconds together.
|
|
60
|
+
*
|
|
61
|
+
* @param str Postgres-formatted interval string
|
|
62
|
+
* @returns Duration object
|
|
63
|
+
*/
|
|
64
|
+
export declare const parsePGIntervalDuration: (str: string) => Duration;
|
|
65
|
+
export declare const safeParseDuration: (value: unknown) => Duration;
|
|
66
|
+
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../../src/schema/utils/duration.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,kBAAkB,QAC8I,CAAC;AAE9K,eAAO,MAAM,qBAAqB,QACgI,CAAC;AAEnK;;;;;GAKG;AAEH,eAAO,MAAM,iBAAiB,GAAI,UAAU,OAAO,CAAC,QAAQ,CAAC,WAsB5D,CAAC;AAEF;;;;;;;;;GASG;AAEH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,QAkB9C,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,oBAAoB,GAAI,UAAU,OAAO,CAAC,QAAQ,CAAC,WAW/D,CAAC;AAEF;;;;;;;;;GASG;AAEH,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,KAAG,QAiBjD,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAC6K,CAAC;AAE5M;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,uBAAuB,GAAI,KAAK,MAAM,KAAG,QAmBrD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,QA6BlD,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export const ISO_DURATION_REGEX = /^P(?:(?<years>\d+)Y)?(?:(?<months>\d+)M)?(?:(?<weeks>\d+)W)?(?:(?<days>\d+)D)?(?:T(?:(?<hours>\d+)H)?(?:(?<minutes>\d+)M)?(?:(?<seconds>\d+)(?:\.(?<fraction>\d+))?S)?)?$/;
|
|
2
|
+
export const STRING_DURATION_REGEX = /^(?:(\d+)\s*year[s]?)?\s*(?:(\d+)\s*month[s]?)?\s*(?:(\d+)\s*day[s]?)?\s*(?:(\d+)\s*hour[s]?)?\s*(?:(\d+)\s*minute[s]?)?\s*(?:(\d+(?:\.\d+)?)\s*second[s]?)?$/i;
|
|
3
|
+
/**
|
|
4
|
+
* Formats a Duration object into an ISO 8601 duration string.
|
|
5
|
+
*
|
|
6
|
+
* @param duration Duration object
|
|
7
|
+
* @returns ISO 8601 duration string like "P3Y6M4DT12H30M5S"
|
|
8
|
+
*/
|
|
9
|
+
export const formatISODuration = (duration) => {
|
|
10
|
+
let iso = "P";
|
|
11
|
+
if (duration.years)
|
|
12
|
+
iso += `${duration.years}Y`;
|
|
13
|
+
if (duration.months)
|
|
14
|
+
iso += `${duration.months}M`;
|
|
15
|
+
if (duration.days)
|
|
16
|
+
iso += `${duration.days}D`;
|
|
17
|
+
if (duration.hours || duration.minutes || duration.seconds) {
|
|
18
|
+
iso += "T";
|
|
19
|
+
if (duration.hours)
|
|
20
|
+
iso += `${duration.hours}H`;
|
|
21
|
+
if (duration.minutes)
|
|
22
|
+
iso += `${duration.minutes}M`;
|
|
23
|
+
if (duration.seconds) {
|
|
24
|
+
const seconds = duration.milliseconds
|
|
25
|
+
? `${duration.seconds}.${duration.milliseconds}`
|
|
26
|
+
: duration.seconds;
|
|
27
|
+
iso += `${seconds}S`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return iso;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Parses an ISO 8601 duration string into a Duration object. Supported formats include:
|
|
34
|
+
* - "P3Y6M4DT12H30M5S" (3 years, 6 months, 4 days, 12 hours, 30 minutes, and 5 seconds)
|
|
35
|
+
* - "P2Y" (2 years)
|
|
36
|
+
* - "PT15M" (15 minutes)
|
|
37
|
+
* - "P1DT12H" (1 day and 12 hours)
|
|
38
|
+
* - "PT0.5S" (0.5 seconds)
|
|
39
|
+
* @param isoString
|
|
40
|
+
* @returns Duration object
|
|
41
|
+
*/
|
|
42
|
+
export const parseISODuration = (iso) => {
|
|
43
|
+
const match = ISO_DURATION_REGEX.exec(iso);
|
|
44
|
+
if (!match?.groups) {
|
|
45
|
+
throw new Error(`Invalid ISO 8601 duration string: ${iso}`);
|
|
46
|
+
}
|
|
47
|
+
const { years, months, days, hours, minutes, seconds, fraction } = match.groups;
|
|
48
|
+
return {
|
|
49
|
+
years: parseInt(years ?? "0") || 0,
|
|
50
|
+
months: parseInt(months ?? "0") || 0,
|
|
51
|
+
days: parseInt(days ?? "0") || 0,
|
|
52
|
+
hours: parseInt(hours ?? "0") || 0,
|
|
53
|
+
minutes: parseInt(minutes ?? "0") || 0,
|
|
54
|
+
seconds: parseInt(seconds ?? "0") || 0,
|
|
55
|
+
milliseconds: fraction ? Math.round(parseFloat(`0.${fraction}`) * 1000) : 0,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Formats a Duration object into a human-readable string format.
|
|
60
|
+
*
|
|
61
|
+
* @param duration Duration object
|
|
62
|
+
* @returns String fomrat like "3 years 6 months 4 days 12 hours 30 minutes 5 seconds"
|
|
63
|
+
*/
|
|
64
|
+
export const formatStringDuration = (duration) => {
|
|
65
|
+
let str = "";
|
|
66
|
+
if (duration.years)
|
|
67
|
+
str += `${duration.years} year${duration.years > 1 ? "s" : ""} `;
|
|
68
|
+
if (duration.months)
|
|
69
|
+
str += `${duration.months} month${duration.months > 1 ? "s" : ""} `;
|
|
70
|
+
if (duration.days)
|
|
71
|
+
str += `${duration.days} day${duration.days > 1 ? "s" : ""} `;
|
|
72
|
+
if (duration.hours)
|
|
73
|
+
str += `${duration.hours} hour${duration.hours > 1 ? "s" : ""} `;
|
|
74
|
+
if (duration.minutes)
|
|
75
|
+
str += `${duration.minutes} minute${duration.minutes > 1 ? "s" : ""} `;
|
|
76
|
+
if (duration.seconds)
|
|
77
|
+
str += `${duration.seconds} second${duration.seconds > 1 ? "s" : ""} `;
|
|
78
|
+
return str.trim();
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Parses a human-readable duration string into a Duration object.
|
|
82
|
+
* Supported formats include:
|
|
83
|
+
* - "3 years 6 months 4 days 12 hours 30 minutes 5 seconds"
|
|
84
|
+
* - "2 hours 15 minutes"
|
|
85
|
+
* - "45 seconds"
|
|
86
|
+
*
|
|
87
|
+
* @param str String formatted duration
|
|
88
|
+
* @returns Duration object
|
|
89
|
+
*/
|
|
90
|
+
export const parseStringDuration = (str) => {
|
|
91
|
+
const match = STRING_DURATION_REGEX.exec(str);
|
|
92
|
+
if (!match) {
|
|
93
|
+
throw new Error(`Invalid duration string: ${str}`);
|
|
94
|
+
}
|
|
95
|
+
const [, years, months, days, hours, minutes, seconds] = match;
|
|
96
|
+
return {
|
|
97
|
+
years: parseInt(years) || 0,
|
|
98
|
+
months: parseInt(months) || 0,
|
|
99
|
+
days: parseInt(days) || 0,
|
|
100
|
+
hours: parseInt(hours) || 0,
|
|
101
|
+
minutes: parseInt(minutes) || 0,
|
|
102
|
+
seconds: parseFloat(seconds) || 0,
|
|
103
|
+
milliseconds: 0,
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export const PG_INTERVAL_REGEX = /^(?:(?<years>-?\d+)\s+years?\s*)?(?:(?<months>-?\d+)\s+mon(?:th)?s?\s*)?(?:(?<days>-?\d+)\s+days?\s*)?(?:(?<timeSign>-)?(?<hours>\d+):(?<minutes>\d{1,2}):(?<seconds>\d{1,2})(?:\.(?<fraction>\d+))?)?$/;
|
|
107
|
+
/**
|
|
108
|
+
* Parses Postgres' default `intervalstyle = 'postgres'` text format into a Duration object.
|
|
109
|
+
* Supported shapes include:
|
|
110
|
+
* - "40:00:00" / "12:30:05.5" (time-only, optional fractional seconds)
|
|
111
|
+
* - "-12:30:05" (signed time)
|
|
112
|
+
* - "4 days 12:30:05"
|
|
113
|
+
* - "3 years 6 mons 4 days 12:30:05" (note: PG uses `mons`, not `months`)
|
|
114
|
+
* - Per-component negatives: "-3 years -6 mons -4 days -12:30:05"
|
|
115
|
+
*
|
|
116
|
+
* Each calendar component carries its own sign; the time portion's leading `-` applies to
|
|
117
|
+
* hours/minutes/seconds/milliseconds together.
|
|
118
|
+
*
|
|
119
|
+
* @param str Postgres-formatted interval string
|
|
120
|
+
* @returns Duration object
|
|
121
|
+
*/
|
|
122
|
+
export const parsePGIntervalDuration = (str) => {
|
|
123
|
+
const match = PG_INTERVAL_REGEX.exec(str.trim());
|
|
124
|
+
if (!match?.groups) {
|
|
125
|
+
throw new Error(`Invalid Postgres interval string: ${str}`);
|
|
126
|
+
}
|
|
127
|
+
const { years, months, days, timeSign, hours, minutes, seconds, fraction } = match.groups;
|
|
128
|
+
const sign = timeSign === "-" ? -1 : 1;
|
|
129
|
+
return {
|
|
130
|
+
years: parseInt(years ?? "0") || 0,
|
|
131
|
+
months: parseInt(months ?? "0") || 0,
|
|
132
|
+
days: parseInt(days ?? "0") || 0,
|
|
133
|
+
hours: hours ? parseInt(hours) * sign : 0,
|
|
134
|
+
minutes: minutes ? parseInt(minutes) * sign : 0,
|
|
135
|
+
seconds: seconds ? parseInt(seconds) * sign : 0,
|
|
136
|
+
milliseconds: fraction ? Math.round(parseFloat(`0.${fraction}`) * 1000) * sign : 0,
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export const safeParseDuration = (value) => {
|
|
140
|
+
if (typeof value === "string") {
|
|
141
|
+
try {
|
|
142
|
+
return parseISODuration(value);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
try {
|
|
146
|
+
return parsePGIntervalDuration(value);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return parseStringDuration(value);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (typeof value === "object" && value !== null) {
|
|
154
|
+
const { years, months, days, hours, minutes, seconds, milliseconds } = value;
|
|
155
|
+
return {
|
|
156
|
+
years: parseInt(String(years)) || 0,
|
|
157
|
+
months: parseInt(String(months)) || 0,
|
|
158
|
+
days: parseInt(String(days)) || 0,
|
|
159
|
+
hours: parseInt(String(hours)) || 0,
|
|
160
|
+
minutes: parseInt(String(minutes)) || 0,
|
|
161
|
+
seconds: parseFloat(String(seconds)) || 0,
|
|
162
|
+
milliseconds: parseInt(String(milliseconds)) || 0,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
throw new Error(`Unsupported duration value: ${value}`);
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=duration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../../src/schema/utils/duration.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,kBAAkB,GAC7B,2KAA2K,CAAC;AAE9K,MAAM,CAAC,MAAM,qBAAqB,GAChC,gKAAgK,CAAC;AAEnK;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAA2B,EAAE,EAAE;IAC/D,IAAI,GAAG,GAAG,GAAG,CAAC;IAEd,IAAI,QAAQ,CAAC,KAAK;QAAE,GAAG,IAAI,GAAG,QAAQ,CAAC,KAAK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Q,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC;SAClD,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/schema/utils/json.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,QAU3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/schema/utils/json.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAE,EAAE;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsqlbase",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Query client and schema definition for distributed SQL databases",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -40,9 +40,21 @@
|
|
|
40
40
|
"default": "./dist/index.js",
|
|
41
41
|
"types": "./dist/index.d.ts"
|
|
42
42
|
},
|
|
43
|
-
"
|
|
44
|
-
"default": "./dist
|
|
45
|
-
"types": "./dist
|
|
43
|
+
"./client": {
|
|
44
|
+
"default": "./dist/client/index.js",
|
|
45
|
+
"types": "./dist/client/index.d.ts"
|
|
46
|
+
},
|
|
47
|
+
"./pg": {
|
|
48
|
+
"default": "./dist/pg/index.js",
|
|
49
|
+
"types": "./dist/pg/index.d.ts"
|
|
50
|
+
},
|
|
51
|
+
"./pglite": {
|
|
52
|
+
"default": "./dist/pglite/index.js",
|
|
53
|
+
"types": "./dist/pglite/index.d.ts"
|
|
54
|
+
},
|
|
55
|
+
"./schema": {
|
|
56
|
+
"default": "./dist/schema/index.js",
|
|
57
|
+
"types": "./dist/schema/index.d.ts"
|
|
46
58
|
}
|
|
47
59
|
},
|
|
48
60
|
"scripts": {
|
|
@@ -50,8 +62,22 @@
|
|
|
50
62
|
"lint": "eslint src --ext .ts"
|
|
51
63
|
},
|
|
52
64
|
"dependencies": {
|
|
53
|
-
"@dsqlbase/core": "^0.1.
|
|
54
|
-
"@dsqlbase/schema": "^0.1.0"
|
|
55
|
-
|
|
65
|
+
"@dsqlbase/core": "^0.1.1",
|
|
66
|
+
"@dsqlbase/schema": "^0.1.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"@electric-sql/pglite": "^0.4.5",
|
|
70
|
+
"pg": "^8.20.0"
|
|
71
|
+
},
|
|
72
|
+
"peerDependenciesMeta": {
|
|
73
|
+
"pg": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"@electric-sql/pglite": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@types/pg": "^8.20.0"
|
|
56
82
|
}
|
|
57
83
|
}
|
package/dist/schema.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { array, bigint, bool, boolean, bytea, char, date, datetime, decimal, double, duration, float4, float8, identity, int, int2, int4, int8, interval, json, numeric, real, smallint, text, time, timestamp, uuid, varchar, domain, namespace, sequence, schema, table, relations, belongsTo, hasMany, hasOne, type DateColumnOptions, type DateTimeColumnOptions, type IdentityColumnOptions, type IntervalColumnOptions, type TimeColumnOptions, type DateValueType, type Duration, } from "@dsqlbase/schema/definition";
|
|
2
|
-
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,EACL,MAAM,EACN,IAAI,EACJ,OAAO,EACP,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,OAAO,EAEP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,EAEL,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,EAEN,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,6BAA6B,CAAC"}
|
package/dist/schema.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
// Columns
|
|
3
|
-
array, bigint, bool, boolean, bytea, char, date, datetime, decimal, double, duration, float4, float8, identity, int, int2, int4, int8, interval, json, numeric, real, smallint, text, time, timestamp, uuid, varchar,
|
|
4
|
-
// Objects
|
|
5
|
-
domain, namespace, sequence, schema, table,
|
|
6
|
-
// Relations
|
|
7
|
-
relations, belongsTo, hasMany, hasOne, } from "@dsqlbase/schema/definition";
|
|
8
|
-
//# sourceMappingURL=schema.js.map
|
package/dist/schema.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO;AACL,UAAU;AACV,KAAK,EACL,MAAM,EACN,IAAI,EACJ,OAAO,EACP,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,QAAQ,EACR,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,OAAO;AACP,UAAU;AACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK;AACL,YAAY;AACZ,SAAS,EACT,SAAS,EACT,OAAO,EACP,MAAM,GASP,MAAM,6BAA6B,CAAC"}
|