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,11 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `bigint` (8 bytes) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* Range: `-9_223_372_036_854_775_808 to +9_223_372_036_854_775_807`
|
|
6
|
+
* @param name Column name in database
|
|
7
|
+
* @returns Serializable column definition for a bigint column.
|
|
8
|
+
*/
|
|
9
|
+
export declare function bigint<const TName extends string>(name: TName): ColumnDefinition<TName, ColumnConfig<bigint, string>>;
|
|
10
|
+
export { bigint as int8 };
|
|
11
|
+
//# sourceMappingURL=bigint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bigint.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/bigint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;GAMG;AAEH,wBAAgB,MAAM,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,yDAQ7D;AAED,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `bigint` (8 bytes) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* Range: `-9_223_372_036_854_775_808 to +9_223_372_036_854_775_807`
|
|
6
|
+
* @param name Column name in database
|
|
7
|
+
* @returns Serializable column definition for a bigint column.
|
|
8
|
+
*/
|
|
9
|
+
export function bigint(name) {
|
|
10
|
+
return new ColumnDefinition(name, {
|
|
11
|
+
dataType: "bigint",
|
|
12
|
+
codec: {
|
|
13
|
+
encode: (value) => value.toString(),
|
|
14
|
+
decode: (value) => BigInt(value),
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { bigint as int8 };
|
|
19
|
+
//# sourceMappingURL=bigint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bigint.js","sourceRoot":"","sources":["../../../src/schema/columns/bigint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;GAMG;AAEH,MAAM,UAAU,MAAM,CAA6B,IAAW;IAC5D,OAAO,IAAI,gBAAgB,CAAsC,IAAI,EAAE;QACrE,QAAQ,EAAE,QAAQ;QAClB,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;SACjC;KACF,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,MAAM,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `boolean` type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* @param name Column name in database
|
|
6
|
+
* @returns Serializable column definition for a boolean column.
|
|
7
|
+
*/
|
|
8
|
+
export declare function boolean<const TName extends string>(name: TName): ColumnDefinition<TName, ColumnConfig<boolean, boolean>>;
|
|
9
|
+
export { boolean as bool };
|
|
10
|
+
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;GAKG;AAEH,wBAAgB,OAAO,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,2DAQ9D;AAED,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `boolean` type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* @param name Column name in database
|
|
6
|
+
* @returns Serializable column definition for a boolean column.
|
|
7
|
+
*/
|
|
8
|
+
export function boolean(name) {
|
|
9
|
+
return new ColumnDefinition(name, {
|
|
10
|
+
dataType: "boolean",
|
|
11
|
+
codec: {
|
|
12
|
+
encode: (value) => value,
|
|
13
|
+
decode: (value) => value,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { boolean as bool };
|
|
18
|
+
//# sourceMappingURL=boolean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../src/schema/columns/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;GAKG;AAEH,MAAM,UAAU,OAAO,CAA6B,IAAW;IAC7D,OAAO,IAAI,gBAAgB,CAAwC,IAAI,EAAE;QACvE,QAAQ,EAAE,SAAS;QACnB,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;YACxB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;SACzB;KACF,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `bytea` data type column in the database schema.
|
|
4
|
+
* @param name Column name in database
|
|
5
|
+
* @returns Serializable column definition for a bytea column.
|
|
6
|
+
*/
|
|
7
|
+
export declare function bytea<const TName extends string>(name: TName): ColumnDefinition<TName, ColumnConfig<Uint8Array<ArrayBufferLike>, Buffer<ArrayBufferLike>>>;
|
|
8
|
+
//# sourceMappingURL=bytea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytea.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/bytea.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;GAIG;AAEH,wBAAgB,KAAK,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,+FAQ5D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `bytea` data type column in the database schema.
|
|
4
|
+
* @param name Column name in database
|
|
5
|
+
* @returns Serializable column definition for a bytea column.
|
|
6
|
+
*/
|
|
7
|
+
export function bytea(name) {
|
|
8
|
+
return new ColumnDefinition(name, {
|
|
9
|
+
dataType: "bytea",
|
|
10
|
+
codec: {
|
|
11
|
+
encode: (value) => Buffer.from(value),
|
|
12
|
+
decode: (value) => new Uint8Array(value),
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=bytea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytea.js","sourceRoot":"","sources":["../../../src/schema/columns/bytea.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;GAIG;AAEH,MAAM,UAAU,KAAK,CAA6B,IAAW;IAC3D,OAAO,IAAI,gBAAgB,CAA0C,IAAI,EAAE;QACzE,QAAQ,EAAE,OAAO;QACjB,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YACrC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC;SACzC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core/definition";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `char(n)` type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* @param name Name of the column in database
|
|
6
|
+
* @param length Fixed length of the char field
|
|
7
|
+
* @returns Serializable column definition for a char column.
|
|
8
|
+
*/
|
|
9
|
+
export declare function char<const TName extends string, const TLength extends number>(name: TName, length: TLength): ColumnDefinition<TName, ColumnConfig<string, string>>;
|
|
10
|
+
//# sourceMappingURL=char.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"char.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/char.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE3E;;;;;;GAMG;AAEH,wBAAgB,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,CAAC,OAAO,SAAS,MAAM,EAC3E,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,OAAO,yDAShB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core/definition";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `char(n)` type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* @param name Name of the column in database
|
|
6
|
+
* @param length Fixed length of the char field
|
|
7
|
+
* @returns Serializable column definition for a char column.
|
|
8
|
+
*/
|
|
9
|
+
export function char(name, length) {
|
|
10
|
+
return new ColumnDefinition(name, {
|
|
11
|
+
dataType: `char(${length})`,
|
|
12
|
+
codec: {
|
|
13
|
+
encode: (value) => value,
|
|
14
|
+
decode: (value) => value,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=char.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"char.js","sourceRoot":"","sources":["../../../src/schema/columns/char.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE3E;;;;;;GAMG;AAEH,MAAM,UAAU,IAAI,CAClB,IAAW,EACX,MAAe;IAEf,OAAO,IAAI,gBAAgB,CAAsC,IAAI,EAAE;QACrE,QAAQ,EAAE,QAAQ,MAAM,GAAG;QAC3B,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;YACxB,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;SACzB;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core/definition";
|
|
2
|
+
import { DateTimeMode } from "../utils/date.js";
|
|
3
|
+
export interface DateColumnOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Determines how the date is parsed and formatted, at runtime:
|
|
6
|
+
* - `"date"`: The column will handle JavaScript Date objects and store them in 'YYYY-MM-DD' format.
|
|
7
|
+
* - `"iso"`: The column will handle ISO 8601 date strings directly, without converting them to Date objects.
|
|
8
|
+
* - `"string"`: Same as `"iso"`, but explicitly indicates that the value is a string.
|
|
9
|
+
*
|
|
10
|
+
* @default "date"
|
|
11
|
+
*/
|
|
12
|
+
mode?: DateTimeMode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Defines a `date` type column in the database schema.
|
|
16
|
+
*
|
|
17
|
+
* @param name Name of the column in database
|
|
18
|
+
* @param options Optional configuration for date parsing and formatting
|
|
19
|
+
* @returns Serializable column definition for a date column.
|
|
20
|
+
*/
|
|
21
|
+
export declare function date<const TName extends string, const TOptions extends DateColumnOptions>(name: TName, options?: TOptions): ColumnDefinition<TName, ColumnConfig<DateValueType<TOptions>, string>>;
|
|
22
|
+
export type DateValueType<TOptions extends DateColumnOptions> = TOptions["mode"] extends "iso" | "string" ? string : Date;
|
|
23
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,YAAY,EAA6B,MAAM,kBAAkB,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;GAMG;AAEH,wBAAgB,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,CAAC,QAAQ,SAAS,iBAAiB,EACvF,IAAI,EAAE,KAAK,EACX,OAAO,CAAC,EAAE,QAAQ,0EAoBnB;AAED,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,iBAAiB,IAAI,QAAQ,CAAC,MAAM,CAAC,SAC5E,KAAK,GACL,QAAQ,GACR,MAAM,GACN,IAAI,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core/definition";
|
|
2
|
+
import { formatDate, safeParseDate } from "../utils/date.js";
|
|
3
|
+
/**
|
|
4
|
+
* Defines a `date` type column in the database schema.
|
|
5
|
+
*
|
|
6
|
+
* @param name Name of the column in database
|
|
7
|
+
* @param options Optional configuration for date parsing and formatting
|
|
8
|
+
* @returns Serializable column definition for a date column.
|
|
9
|
+
*/
|
|
10
|
+
export function date(name, options) {
|
|
11
|
+
return new ColumnDefinition(name, {
|
|
12
|
+
dataType: "date",
|
|
13
|
+
codec: {
|
|
14
|
+
encode: (value) => formatDate(safeParseDate(value)),
|
|
15
|
+
decode: (value) => {
|
|
16
|
+
const date = safeParseDate(value);
|
|
17
|
+
switch (options?.mode) {
|
|
18
|
+
case "iso":
|
|
19
|
+
case "string":
|
|
20
|
+
return formatDate(date);
|
|
21
|
+
case "date":
|
|
22
|
+
default:
|
|
23
|
+
return date;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=date.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../src/schema/columns/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAgB,UAAU,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAc3E;;;;;;GAMG;AAEH,MAAM,UAAU,IAAI,CAClB,IAAW,EACX,OAAkB;IAElB,OAAO,IAAI,gBAAgB,CAAuD,IAAI,EAAE;QACtF,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YACnD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;gBAElC,QAAQ,OAAO,EAAE,IAAI,EAAE,CAAC;oBACtB,KAAK,KAAK,CAAC;oBACX,KAAK,QAAQ;wBACX,OAAO,UAAU,CAAC,IAAI,CAA4B,CAAC;oBACrD,KAAK,MAAM,CAAC;oBACZ;wBACE,OAAO,IAA+B,CAAC;gBAC3C,CAAC;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `double precision` (8 bytes) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* - Precision: 15 decimal digits
|
|
6
|
+
* - Range: `-1.7976931348623157e+308 to +1.7976931348623157e+308`
|
|
7
|
+
*
|
|
8
|
+
* @param name Column name in database
|
|
9
|
+
* @returns Serializable column definition for a double precision column.
|
|
10
|
+
*/
|
|
11
|
+
export declare function double<const TName extends string>(name: TName): ColumnDefinition<TName, ColumnConfig<number, string>>;
|
|
12
|
+
export { double as float8 };
|
|
13
|
+
//# sourceMappingURL=double.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"double.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/double.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;;;GAQG;AAEH,wBAAgB,MAAM,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,yDAQ7D;AAED,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `double precision` (8 bytes) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* - Precision: 15 decimal digits
|
|
6
|
+
* - Range: `-1.7976931348623157e+308 to +1.7976931348623157e+308`
|
|
7
|
+
*
|
|
8
|
+
* @param name Column name in database
|
|
9
|
+
* @returns Serializable column definition for a double precision column.
|
|
10
|
+
*/
|
|
11
|
+
export function double(name) {
|
|
12
|
+
return new ColumnDefinition(name, {
|
|
13
|
+
dataType: "double precision",
|
|
14
|
+
codec: {
|
|
15
|
+
encode: (value) => value.toString(),
|
|
16
|
+
decode: (value) => parseFloat(value),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export { double as float8 };
|
|
21
|
+
//# sourceMappingURL=double.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"double.js","sourceRoot":"","sources":["../../../src/schema/columns/double.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;;;GAQG;AAEH,MAAM,UAAU,MAAM,CAA6B,IAAW;IAC5D,OAAO,IAAI,gBAAgB,CAAsC,IAAI,EAAE;QACrE,QAAQ,EAAE,kBAAkB;QAC5B,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;SACrC;KACF,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition, ColumnGeneratedType, ColumnIdentityConfig } from "@dsqlbase/core/definition";
|
|
2
|
+
export interface IdentityConfig<T extends IdentityColumnOptions> {
|
|
3
|
+
type: T["type"] extends "BY DEFAULT" ? "BY DEFAULT" : "ALWAYS";
|
|
4
|
+
sequenceName?: T["sequenceName"];
|
|
5
|
+
options: {
|
|
6
|
+
dataType: "bigint";
|
|
7
|
+
cache: number;
|
|
8
|
+
startValue: number;
|
|
9
|
+
increment: number;
|
|
10
|
+
minValue: number;
|
|
11
|
+
maxValue: number;
|
|
12
|
+
cycle: boolean;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare class IdentityColumnDefinition<TName extends string, TIdentity extends IdentityConfig<IdentityColumnOptions>> extends ColumnDefinition<TName, Omit<ColumnConfig<number, string>, "identity"> & {
|
|
16
|
+
notNull: true;
|
|
17
|
+
hasDefault: true;
|
|
18
|
+
identity: TIdentity;
|
|
19
|
+
}> {
|
|
20
|
+
protected _identity: ColumnIdentityConfig;
|
|
21
|
+
constructor(name: TName, config: Partial<Omit<ColumnConfig<number, string>, "identity"> & {
|
|
22
|
+
notNull: true;
|
|
23
|
+
hasDefault: true;
|
|
24
|
+
identity: TIdentity;
|
|
25
|
+
}>);
|
|
26
|
+
sequenceName(name: string): this;
|
|
27
|
+
cycle(cycle?: boolean): this;
|
|
28
|
+
cache(cache: number): this;
|
|
29
|
+
startValue(startValue: number): this;
|
|
30
|
+
increment(increment: number): this;
|
|
31
|
+
minValue(minValue: number): this;
|
|
32
|
+
maxValue(maxValue: number): this;
|
|
33
|
+
}
|
|
34
|
+
export interface IdentityColumnOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Determines how the identity value is generated:
|
|
37
|
+
* - `ALWAYS`: The identity value is always generated by the database, and cannot be overridden by insert statements.
|
|
38
|
+
* - `BY DEFAULT`: The identity value is generated by the database if no value is provided in the insert statement, but can be overridden by providing a value.
|
|
39
|
+
*
|
|
40
|
+
* @default "ALWAYS"
|
|
41
|
+
*/
|
|
42
|
+
type: ColumnGeneratedType;
|
|
43
|
+
/**
|
|
44
|
+
* Name of the identity sequence to use for generating values. If not provided, an unused sequence name will be generated automatically.
|
|
45
|
+
*/
|
|
46
|
+
sequenceName?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Defines an identity column in the database schema, which automatically generates unique numeric values for new rows.
|
|
50
|
+
*
|
|
51
|
+
* @param name Column name in the database
|
|
52
|
+
* @param options Configuration options for the identity column
|
|
53
|
+
* @returns Serializable column definition for an identity column.
|
|
54
|
+
*/
|
|
55
|
+
export declare function identity<const TName extends string, const TOptions extends IdentityColumnOptions>(name: TName, options?: TOptions): IdentityColumnDefinition<TName, IdentityConfig<TOptions>>;
|
|
56
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,qBAAqB;IAC7D,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,YAAY,GAAG,YAAY,GAAG,QAAQ,CAAC;IAC/D,YAAY,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC;IACjC,OAAO,EAAE;QACP,QAAQ,EAAE,QAAQ,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;CACH;AAED,qBAAa,wBAAwB,CACnC,KAAK,SAAS,MAAM,EACpB,SAAS,SAAS,cAAc,CAAC,qBAAqB,CAAC,CACvD,SAAQ,gBAAgB,CACxB,KAAK,EACL,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;IAC/C,OAAO,EAAE,IAAI,CAAC;IACd,UAAU,EAAE,IAAI,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACrB,CACF;IACC,SAAS,CAAC,SAAS,EAAE,oBAAoB,CAAC;gBAGxC,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,OAAO,CACb,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,GAAG;QAC/C,OAAO,EAAE,IAAI,CAAC;QACd,UAAU,EAAE,IAAI,CAAC;QACjB,QAAQ,EAAE,SAAS,CAAC;KACrB,CACF;IAMI,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKhC,KAAK,CAAC,KAAK,UAAO,GAAG,IAAI;IAKzB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAKpC,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKlC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKhC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAIxC;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;;OAMG;IACH,IAAI,EAAE,mBAAmB,CAAC;IAE1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AAEH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,CAAC,QAAQ,SAAS,qBAAqB,EAC/F,IAAI,EAAE,KAAK,EACX,OAAO,CAAC,EAAE,QAAQ,6DAsBnB"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ColumnDefinition, } from "@dsqlbase/core/definition";
|
|
2
|
+
export class IdentityColumnDefinition extends ColumnDefinition {
|
|
3
|
+
_identity;
|
|
4
|
+
constructor(name, config) {
|
|
5
|
+
super(name, config);
|
|
6
|
+
this._identity = config.identity;
|
|
7
|
+
}
|
|
8
|
+
sequenceName(name) {
|
|
9
|
+
this._identity.sequenceName = name;
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
cycle(cycle = true) {
|
|
13
|
+
this._identity.options.cycle = cycle;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
cache(cache) {
|
|
17
|
+
this._identity.options.cache = cache;
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
startValue(startValue) {
|
|
21
|
+
this._identity.options.startValue = startValue;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
increment(increment) {
|
|
25
|
+
this._identity.options.increment = increment;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
minValue(minValue) {
|
|
29
|
+
this._identity.options.minValue = minValue;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
maxValue(maxValue) {
|
|
33
|
+
this._identity.options.maxValue = maxValue;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Defines an identity column in the database schema, which automatically generates unique numeric values for new rows.
|
|
39
|
+
*
|
|
40
|
+
* @param name Column name in the database
|
|
41
|
+
* @param options Configuration options for the identity column
|
|
42
|
+
* @returns Serializable column definition for an identity column.
|
|
43
|
+
*/
|
|
44
|
+
export function identity(name, options) {
|
|
45
|
+
const identity = {
|
|
46
|
+
type: options?.type ?? "ALWAYS",
|
|
47
|
+
options: {
|
|
48
|
+
dataType: "bigint",
|
|
49
|
+
cache: 1,
|
|
50
|
+
startValue: 1,
|
|
51
|
+
increment: 1,
|
|
52
|
+
minValue: 1,
|
|
53
|
+
cycle: false,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
return new IdentityColumnDefinition(name, {
|
|
57
|
+
dataType: "bigint",
|
|
58
|
+
identity,
|
|
59
|
+
codec: {
|
|
60
|
+
encode: (value) => value.toString(),
|
|
61
|
+
decode: (value) => Number(value),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/schema/columns/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,GAGjB,MAAM,2BAA2B,CAAC;AAgBnC,MAAM,OAAO,wBAGX,SAAQ,gBAOT;IACW,SAAS,CAAuB;IAE1C,YACE,IAAW,EACX,MAMC;QAED,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,QAAqB,CAAC;IAChD,CAAC;IAEM,YAAY,CAAC,IAAY;QAC9B,IAAI,CAAC,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,KAAK,GAAG,IAAI;QACvB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,KAAa;QACxB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,UAAU,CAAC,UAAkB;QAClC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC;QAC/C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,SAAS,CAAC,SAAiB;QAChC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,QAAQ,CAAC,QAAgB;QAC9B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,QAAQ,CAAC,QAAgB;QAC9B,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAkBD;;;;;;GAMG;AAEH,MAAM,UAAU,QAAQ,CACtB,IAAW,EACX,OAAkB;IAElB,MAAM,QAAQ,GAAG;QACf,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,QAAQ;QAC/B,OAAO,EAAE;YACP,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,CAAC;YACR,UAAU,EAAE,CAAC;YACb,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,CAAC;YACX,KAAK,EAAE,KAAK;SACb;KAC0B,CAAC;IAE9B,OAAO,IAAI,wBAAwB,CAAkC,IAAI,EAAE;QACzE,QAAQ,EAAE,QAAQ;QAClB,QAAQ;QACR,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;SACjC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines an `int` (4 bytes) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* Range: `-2_147_483_648 to +2_147_483_647`
|
|
6
|
+
* @param name
|
|
7
|
+
* @returns Serializable column definition for an int column.
|
|
8
|
+
*/
|
|
9
|
+
export declare function int<const TName extends string>(name: TName): ColumnDefinition<TName, ColumnConfig<number, string>>;
|
|
10
|
+
export { int as int4 };
|
|
11
|
+
//# sourceMappingURL=int.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"int.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/int.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;GAMG;AAEH,wBAAgB,GAAG,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,yDAQ1D;AAED,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines an `int` (4 bytes) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* Range: `-2_147_483_648 to +2_147_483_647`
|
|
6
|
+
* @param name
|
|
7
|
+
* @returns Serializable column definition for an int column.
|
|
8
|
+
*/
|
|
9
|
+
export function int(name) {
|
|
10
|
+
return new ColumnDefinition(name, {
|
|
11
|
+
dataType: "int",
|
|
12
|
+
codec: {
|
|
13
|
+
encode: (value) => value.toString(),
|
|
14
|
+
decode: (value) => parseInt(value, 10),
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { int as int4 };
|
|
19
|
+
//# sourceMappingURL=int.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"int.js","sourceRoot":"","sources":["../../../src/schema/columns/int.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;GAMG;AAEH,MAAM,UAAU,GAAG,CAA6B,IAAW;IACzD,OAAO,IAAI,gBAAgB,CAAsC,IAAI,EAAE;QACrE,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;SACvC;KACF,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
import { Duration } from "../utils/duration.js";
|
|
3
|
+
export interface IntervalColumnOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Determines how the interval is parsed and formatted, at runtime:
|
|
6
|
+
* - `"iso"`: The column will handle interval values as ISO 8601 duration strings (e.g., 'P3Y6M4DT12H30M5S').
|
|
7
|
+
* - `"string"`: The column will handle interval values as human-readable strings (e.g., '3 years 6 months 4 days 12 hours 30 minutes 5 seconds').
|
|
8
|
+
* - `"object"`: The column will handle interval values as `Duration` objects with properties for years, months, days, hours, minutes, and seconds (e.g., `{ years: 3, months: 6, days: 4, hours: 12, minutes: 30, seconds: 5 }`).
|
|
9
|
+
*
|
|
10
|
+
* @default "object"
|
|
11
|
+
*/
|
|
12
|
+
mode?: "iso" | "string" | "object";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Defines an `interval` data type column in the database schema.
|
|
16
|
+
* @param name Column name
|
|
17
|
+
* @param options Config options
|
|
18
|
+
* @returns Serializable column definition for an interval column.
|
|
19
|
+
*/
|
|
20
|
+
export declare function interval<const TName extends string, const TOptions extends IntervalColumnOptions>(name: TName, options?: TOptions): ColumnDefinition<TName, ColumnConfig<IntervalValueType<TOptions>, string>>;
|
|
21
|
+
export { interval as duration };
|
|
22
|
+
export type IntervalValueType<TOptions extends IntervalColumnOptions> = TOptions["mode"] extends "iso" | "string" ? string : Duration;
|
|
23
|
+
//# sourceMappingURL=interval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interval.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/interval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EACL,QAAQ,EAIT,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,qBAAqB;IACpC;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACpC;AAED;;;;;GAKG;AAEH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,CAAC,QAAQ,SAAS,qBAAqB,EAC/F,IAAI,EAAE,KAAK,EACX,OAAO,CAAC,EAAE,QAAQ,8EAgCnB;AAED,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,CAAC;AAEhC,MAAM,MAAM,iBAAiB,CAAC,QAAQ,SAAS,qBAAqB,IAAI,QAAQ,CAAC,MAAM,CAAC,SACpF,KAAK,GACL,QAAQ,GACR,MAAM,GACN,QAAQ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
import { formatISODuration, formatStringDuration, safeParseDuration, } from "../utils/duration.js";
|
|
3
|
+
/**
|
|
4
|
+
* Defines an `interval` data type column in the database schema.
|
|
5
|
+
* @param name Column name
|
|
6
|
+
* @param options Config options
|
|
7
|
+
* @returns Serializable column definition for an interval column.
|
|
8
|
+
*/
|
|
9
|
+
export function interval(name, options) {
|
|
10
|
+
return new ColumnDefinition(name, {
|
|
11
|
+
dataType: "interval",
|
|
12
|
+
codec: {
|
|
13
|
+
encode: (value) => {
|
|
14
|
+
const duration = safeParseDuration(value);
|
|
15
|
+
switch (options?.mode) {
|
|
16
|
+
case "iso":
|
|
17
|
+
return formatISODuration(duration);
|
|
18
|
+
case "object":
|
|
19
|
+
case "string":
|
|
20
|
+
default:
|
|
21
|
+
return formatStringDuration(duration);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
decode: (value) => {
|
|
25
|
+
const duration = safeParseDuration(value);
|
|
26
|
+
switch (options?.mode) {
|
|
27
|
+
case "iso":
|
|
28
|
+
return formatISODuration(duration);
|
|
29
|
+
case "string":
|
|
30
|
+
return formatStringDuration(duration);
|
|
31
|
+
case "object":
|
|
32
|
+
default:
|
|
33
|
+
return duration;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export { interval as duration };
|
|
40
|
+
//# sourceMappingURL=interval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interval.js","sourceRoot":"","sources":["../../../src/schema/columns/interval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAEL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAc9B;;;;;GAKG;AAEH,MAAM,UAAU,QAAQ,CACtB,IAAW,EACX,OAAkB;IAElB,OAAO,IAAI,gBAAgB,CAA2D,IAAI,EAAE;QAC1F,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBAE1C,QAAQ,OAAO,EAAE,IAAI,EAAE,CAAC;oBACtB,KAAK,KAAK;wBACR,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;oBACrC,KAAK,QAAQ,CAAC;oBACd,KAAK,QAAQ,CAAC;oBACd;wBACE,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC;YACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;gBAChB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBAE1C,QAAQ,OAAO,EAAE,IAAI,EAAE,CAAC;oBACtB,KAAK,KAAK;wBACR,OAAO,iBAAiB,CAAC,QAAQ,CAAgC,CAAC;oBACpE,KAAK,QAAQ;wBACX,OAAO,oBAAoB,CAAC,QAAQ,CAAgC,CAAC;oBACvE,KAAK,QAAQ,CAAC;oBACd;wBACE,OAAO,QAAuC,CAAC;gBACnD,CAAC;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `json` data type column.
|
|
4
|
+
*
|
|
5
|
+
* @param name Column name in database
|
|
6
|
+
* @returns Serializable column definition for a JSON column.
|
|
7
|
+
*/
|
|
8
|
+
export declare function json<const TName extends string>(name: TName): ColumnDefinition<TName, ColumnConfig<unknown, string>>;
|
|
9
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGhE;;;;;GAKG;AAEH,wBAAgB,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,0DAQ3D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
import { safeParseJson } from "../utils/json.js";
|
|
3
|
+
/**
|
|
4
|
+
* Defines a `json` data type column.
|
|
5
|
+
*
|
|
6
|
+
* @param name Column name in database
|
|
7
|
+
* @returns Serializable column definition for a JSON column.
|
|
8
|
+
*/
|
|
9
|
+
export function json(name) {
|
|
10
|
+
return new ColumnDefinition(name, {
|
|
11
|
+
dataType: "json",
|
|
12
|
+
codec: {
|
|
13
|
+
encode: (value) => JSON.stringify(value),
|
|
14
|
+
decode: (value) => safeParseJson(value),
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/schema/columns/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD;;;;;GAKG;AAEH,MAAM,UAAU,IAAI,CAA6B,IAAW;IAC1D,OAAO,IAAI,gBAAgB,CAAuC,IAAI,EAAE;QACtE,QAAQ,EAAE,MAAM;QAChB,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YACxC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC;SACxC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `numeric` (variable precision) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* - Precision: Exact numeric of selectable precision. The maximum precision is 38 and the maximum scale is 37.
|
|
6
|
+
* @param name Column name in database
|
|
7
|
+
* @returns Serializable column definition for a numeric column.
|
|
8
|
+
*/
|
|
9
|
+
export declare function numeric<const TName extends string>(name: TName): ColumnDefinition<TName, ColumnConfig<number, string>>;
|
|
10
|
+
export { numeric as decimal };
|
|
11
|
+
//# sourceMappingURL=numeric.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/numeric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;GAMG;AAEH,wBAAgB,OAAO,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,yDAQ9D;AAED,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `numeric` (variable precision) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* - Precision: Exact numeric of selectable precision. The maximum precision is 38 and the maximum scale is 37.
|
|
6
|
+
* @param name Column name in database
|
|
7
|
+
* @returns Serializable column definition for a numeric column.
|
|
8
|
+
*/
|
|
9
|
+
export function numeric(name) {
|
|
10
|
+
return new ColumnDefinition(name, {
|
|
11
|
+
dataType: "numeric",
|
|
12
|
+
codec: {
|
|
13
|
+
encode: (value) => value.toString(),
|
|
14
|
+
decode: (value) => parseFloat(value),
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { numeric as decimal };
|
|
19
|
+
//# sourceMappingURL=numeric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numeric.js","sourceRoot":"","sources":["../../../src/schema/columns/numeric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;GAMG;AAEH,MAAM,UAAU,OAAO,CAA6B,IAAW;IAC7D,OAAO,IAAI,gBAAgB,CAAsC,IAAI,EAAE;QACrE,QAAQ,EAAE,SAAS;QACnB,KAAK,EAAE;YACL,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;SACrC;KACF,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ColumnConfig, ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `real` (4 bytes) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* - Precision: 6 decimal digits
|
|
6
|
+
* - Range: `-3.4028235e+38 to +3.4028235e+38`
|
|
7
|
+
*
|
|
8
|
+
* @param name Column name in database
|
|
9
|
+
* @returns Serializable column definition for a real column.
|
|
10
|
+
*/
|
|
11
|
+
export declare function real<const TName extends string>(name: TName): ColumnDefinition<TName, ColumnConfig<number, string>>;
|
|
12
|
+
export { real as float4 };
|
|
13
|
+
//# sourceMappingURL=real.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real.d.ts","sourceRoot":"","sources":["../../../src/schema/columns/real.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,IAAI,EAAE,KAAK,yDAQ3D;AAED,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ColumnDefinition } from "@dsqlbase/core";
|
|
2
|
+
/**
|
|
3
|
+
* Defines a `real` (4 bytes) data type column in the database schema.
|
|
4
|
+
*
|
|
5
|
+
* - Precision: 6 decimal digits
|
|
6
|
+
* - Range: `-3.4028235e+38 to +3.4028235e+38`
|
|
7
|
+
*
|
|
8
|
+
* @param name Column name in database
|
|
9
|
+
* @returns Serializable column definition for a real column.
|
|
10
|
+
*/
|
|
11
|
+
export function real(name) {
|
|
12
|
+
return new ColumnDefinition(name, {
|
|
13
|
+
dataType: "real",
|
|
14
|
+
codec: {
|
|
15
|
+
encode: (value) => value.toString(),
|
|
16
|
+
decode: (value) => parseFloat(value),
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export { real as float4 };
|
|
21
|
+
//# sourceMappingURL=real.js.map
|