hysteria-orm 10.5.7 → 10.5.9
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/lib/cli.js +21 -21
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +13 -13
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +65 -10
- package/lib/index.d.ts +65 -10
- package/lib/index.js +13 -13
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -117,7 +117,7 @@ interface SqliteDataSourceInput extends CommonDataSourceInput {
|
|
|
117
117
|
* @description The filename of the database file for SQLite
|
|
118
118
|
* @default ":memory:"
|
|
119
119
|
*/
|
|
120
|
-
readonly database?: string;
|
|
120
|
+
readonly database?: ":memory:" | (string & {});
|
|
121
121
|
}
|
|
122
122
|
interface NotNullableSqliteDataSourceInput extends SqliteDataSourceInput {
|
|
123
123
|
readonly type?: "sqlite";
|
|
@@ -876,6 +876,24 @@ type OracledbTableOptions = {
|
|
|
876
876
|
inMemory?: boolean;
|
|
877
877
|
compressFor?: "QUERY LOW" | "QUERY HIGH" | "ARCHIVE LOW" | "ARCHIVE HIGH";
|
|
878
878
|
};
|
|
879
|
+
type DateTimeOptions = {
|
|
880
|
+
/**
|
|
881
|
+
* @description Whether to include the timezone in the datetime column
|
|
882
|
+
*/
|
|
883
|
+
withTimezone?: boolean;
|
|
884
|
+
/**
|
|
885
|
+
* @description The precision of the datetime column
|
|
886
|
+
*/
|
|
887
|
+
precision?: number;
|
|
888
|
+
/**
|
|
889
|
+
* @description Sets DEFAULT CURRENT_TIMESTAMP on the column
|
|
890
|
+
*/
|
|
891
|
+
autoCreate?: boolean;
|
|
892
|
+
/**
|
|
893
|
+
* @description Automatically updates the column on row update. Uses ON UPDATE CURRENT_TIMESTAMP on MySQL/MariaDB, auto-generates a trigger on other databases
|
|
894
|
+
*/
|
|
895
|
+
autoUpdate?: boolean;
|
|
896
|
+
};
|
|
879
897
|
/**
|
|
880
898
|
* @description Union type for all database-specific table options
|
|
881
899
|
*/
|
|
@@ -1517,6 +1535,8 @@ declare class ColumnTypeNode extends QueryNode {
|
|
|
1517
1535
|
enumValues?: readonly string[];
|
|
1518
1536
|
autoIncrement?: boolean;
|
|
1519
1537
|
withTimezone?: boolean;
|
|
1538
|
+
autoCreate?: boolean;
|
|
1539
|
+
autoUpdate?: boolean;
|
|
1520
1540
|
collate?: string;
|
|
1521
1541
|
chainsWith: string;
|
|
1522
1542
|
canKeywordBeSeenMultipleTimes: boolean;
|
|
@@ -1530,6 +1550,8 @@ declare class ColumnTypeNode extends QueryNode {
|
|
|
1530
1550
|
enumValues?: readonly string[];
|
|
1531
1551
|
withTimezone?: boolean;
|
|
1532
1552
|
autoIncrement?: boolean;
|
|
1553
|
+
autoCreate?: boolean;
|
|
1554
|
+
autoUpdate?: boolean;
|
|
1533
1555
|
collate?: string;
|
|
1534
1556
|
isRawValue?: boolean;
|
|
1535
1557
|
});
|
|
@@ -1576,6 +1598,17 @@ declare class ConstraintBuilder extends BaseBuilder {
|
|
|
1576
1598
|
* @param options is the options for the unique constraint
|
|
1577
1599
|
*/
|
|
1578
1600
|
unique(options?: CommonConstraintOptions): this;
|
|
1601
|
+
/**
|
|
1602
|
+
* @description Adds a CHECK constraint to the column
|
|
1603
|
+
* @param expression SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
|
|
1604
|
+
* @param options Optional constraint name
|
|
1605
|
+
* @example
|
|
1606
|
+
* ```ts
|
|
1607
|
+
* table.integer("age").check("age >= 18");
|
|
1608
|
+
* table.decimal("price").check("price > 0", { constraintName: "positive_price" });
|
|
1609
|
+
* ```
|
|
1610
|
+
*/
|
|
1611
|
+
check(expression: string, options?: CommonConstraintOptions): this;
|
|
1579
1612
|
/**
|
|
1580
1613
|
* @description Sets the column to be after another column
|
|
1581
1614
|
* @param columnName is the name of the column to be after
|
|
@@ -1780,21 +1813,19 @@ declare class CreateTableBuilder extends BaseBuilder {
|
|
|
1780
1813
|
* @mysql DATETIME(precision)
|
|
1781
1814
|
* @postgres TIMESTAMP(precision) WITHOUT TIME ZONE
|
|
1782
1815
|
* @sqlite TEXT
|
|
1816
|
+
* @param options.autoCreate Sets DEFAULT CURRENT_TIMESTAMP on the column
|
|
1817
|
+
* @param options.autoUpdate Automatically updates the column on row update. Uses ON UPDATE CURRENT_TIMESTAMP on MySQL/MariaDB, auto-generates a trigger on other databases
|
|
1783
1818
|
*/
|
|
1784
|
-
datetime(name: string, options?:
|
|
1785
|
-
withTimezone?: boolean;
|
|
1786
|
-
precision?: number;
|
|
1787
|
-
}): ConstraintBuilder;
|
|
1819
|
+
datetime(name: string, options?: DateTimeOptions): ConstraintBuilder;
|
|
1788
1820
|
/**
|
|
1789
1821
|
* Timestamp type
|
|
1790
1822
|
* @mysql TIMESTAMP(precision)
|
|
1791
1823
|
* @postgres TIMESTAMP(precision) WITH/WITHOUT TIME ZONE
|
|
1792
1824
|
* @sqlite TEXT
|
|
1825
|
+
* @param options.autoCreate Sets DEFAULT CURRENT_TIMESTAMP on the column
|
|
1826
|
+
* @param options.autoUpdate Automatically updates the column on row update. Uses ON UPDATE CURRENT_TIMESTAMP on MySQL/MariaDB, auto-generates a trigger on other databases
|
|
1793
1827
|
*/
|
|
1794
|
-
timestamp(name: string, options?:
|
|
1795
|
-
withTimezone?: boolean;
|
|
1796
|
-
precision?: number;
|
|
1797
|
-
}): ConstraintBuilder;
|
|
1828
|
+
timestamp(name: string, options?: DateTimeOptions): ConstraintBuilder;
|
|
1798
1829
|
/**
|
|
1799
1830
|
* Boolean type
|
|
1800
1831
|
* @mysql BOOLEAN
|
|
@@ -1921,7 +1952,7 @@ declare class CreateTableBuilder extends BaseBuilder {
|
|
|
1921
1952
|
getNamedConstraints(): QueryNode[];
|
|
1922
1953
|
}
|
|
1923
1954
|
|
|
1924
|
-
type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default";
|
|
1955
|
+
type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default" | "check";
|
|
1925
1956
|
declare class ConstraintNode extends QueryNode {
|
|
1926
1957
|
constraintType: ConstraintType;
|
|
1927
1958
|
columns?: (string | (() => string))[];
|
|
@@ -7723,6 +7754,28 @@ declare class Schema {
|
|
|
7723
7754
|
* @description Drops a constraint from a table
|
|
7724
7755
|
*/
|
|
7725
7756
|
dropConstraint(table: string, constraintName: string): void;
|
|
7757
|
+
/**
|
|
7758
|
+
* @description Adds a CHECK constraint to a table
|
|
7759
|
+
* @param table The table name
|
|
7760
|
+
* @param expression The SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
|
|
7761
|
+
* @param options Optional constraint name and other options
|
|
7762
|
+
* @example
|
|
7763
|
+
* ```ts
|
|
7764
|
+
* schema.addCheck("users", "age >= 18", { constraintName: "users_age_check" });
|
|
7765
|
+
* schema.addCheck("products", "price > 0 AND stock >= 0");
|
|
7766
|
+
* ```
|
|
7767
|
+
*/
|
|
7768
|
+
addCheck(table: string, expression: string, options?: CommonConstraintOptions): void;
|
|
7769
|
+
/**
|
|
7770
|
+
* @description Drops a CHECK constraint from a table
|
|
7771
|
+
* @param table The table name
|
|
7772
|
+
* @param constraintName The name of the check constraint to drop
|
|
7773
|
+
* @example
|
|
7774
|
+
* ```ts
|
|
7775
|
+
* schema.dropCheck("users", "users_age_check");
|
|
7776
|
+
* ```
|
|
7777
|
+
*/
|
|
7778
|
+
dropCheck(table: string, constraintName: string): void;
|
|
7726
7779
|
/**
|
|
7727
7780
|
* @description Create database extension, only supported for postgres
|
|
7728
7781
|
* @postgres Supports extensions like PostGIS, uuid-ossp, hstore, etc.
|
|
@@ -7733,6 +7786,8 @@ declare class Schema {
|
|
|
7733
7786
|
*/
|
|
7734
7787
|
createExtension(extensionName: CommonPostgresExtensions, ifNotExists?: boolean): void;
|
|
7735
7788
|
createExtension(extensionName: string, ifNotExists?: boolean): void;
|
|
7789
|
+
private generateAutoUpdateTriggers;
|
|
7790
|
+
private getAutoUpdateTriggerSql;
|
|
7736
7791
|
private generateAstInstance;
|
|
7737
7792
|
}
|
|
7738
7793
|
|
package/lib/index.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ interface SqliteDataSourceInput extends CommonDataSourceInput {
|
|
|
117
117
|
* @description The filename of the database file for SQLite
|
|
118
118
|
* @default ":memory:"
|
|
119
119
|
*/
|
|
120
|
-
readonly database?: string;
|
|
120
|
+
readonly database?: ":memory:" | (string & {});
|
|
121
121
|
}
|
|
122
122
|
interface NotNullableSqliteDataSourceInput extends SqliteDataSourceInput {
|
|
123
123
|
readonly type?: "sqlite";
|
|
@@ -876,6 +876,24 @@ type OracledbTableOptions = {
|
|
|
876
876
|
inMemory?: boolean;
|
|
877
877
|
compressFor?: "QUERY LOW" | "QUERY HIGH" | "ARCHIVE LOW" | "ARCHIVE HIGH";
|
|
878
878
|
};
|
|
879
|
+
type DateTimeOptions = {
|
|
880
|
+
/**
|
|
881
|
+
* @description Whether to include the timezone in the datetime column
|
|
882
|
+
*/
|
|
883
|
+
withTimezone?: boolean;
|
|
884
|
+
/**
|
|
885
|
+
* @description The precision of the datetime column
|
|
886
|
+
*/
|
|
887
|
+
precision?: number;
|
|
888
|
+
/**
|
|
889
|
+
* @description Sets DEFAULT CURRENT_TIMESTAMP on the column
|
|
890
|
+
*/
|
|
891
|
+
autoCreate?: boolean;
|
|
892
|
+
/**
|
|
893
|
+
* @description Automatically updates the column on row update. Uses ON UPDATE CURRENT_TIMESTAMP on MySQL/MariaDB, auto-generates a trigger on other databases
|
|
894
|
+
*/
|
|
895
|
+
autoUpdate?: boolean;
|
|
896
|
+
};
|
|
879
897
|
/**
|
|
880
898
|
* @description Union type for all database-specific table options
|
|
881
899
|
*/
|
|
@@ -1517,6 +1535,8 @@ declare class ColumnTypeNode extends QueryNode {
|
|
|
1517
1535
|
enumValues?: readonly string[];
|
|
1518
1536
|
autoIncrement?: boolean;
|
|
1519
1537
|
withTimezone?: boolean;
|
|
1538
|
+
autoCreate?: boolean;
|
|
1539
|
+
autoUpdate?: boolean;
|
|
1520
1540
|
collate?: string;
|
|
1521
1541
|
chainsWith: string;
|
|
1522
1542
|
canKeywordBeSeenMultipleTimes: boolean;
|
|
@@ -1530,6 +1550,8 @@ declare class ColumnTypeNode extends QueryNode {
|
|
|
1530
1550
|
enumValues?: readonly string[];
|
|
1531
1551
|
withTimezone?: boolean;
|
|
1532
1552
|
autoIncrement?: boolean;
|
|
1553
|
+
autoCreate?: boolean;
|
|
1554
|
+
autoUpdate?: boolean;
|
|
1533
1555
|
collate?: string;
|
|
1534
1556
|
isRawValue?: boolean;
|
|
1535
1557
|
});
|
|
@@ -1576,6 +1598,17 @@ declare class ConstraintBuilder extends BaseBuilder {
|
|
|
1576
1598
|
* @param options is the options for the unique constraint
|
|
1577
1599
|
*/
|
|
1578
1600
|
unique(options?: CommonConstraintOptions): this;
|
|
1601
|
+
/**
|
|
1602
|
+
* @description Adds a CHECK constraint to the column
|
|
1603
|
+
* @param expression SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
|
|
1604
|
+
* @param options Optional constraint name
|
|
1605
|
+
* @example
|
|
1606
|
+
* ```ts
|
|
1607
|
+
* table.integer("age").check("age >= 18");
|
|
1608
|
+
* table.decimal("price").check("price > 0", { constraintName: "positive_price" });
|
|
1609
|
+
* ```
|
|
1610
|
+
*/
|
|
1611
|
+
check(expression: string, options?: CommonConstraintOptions): this;
|
|
1579
1612
|
/**
|
|
1580
1613
|
* @description Sets the column to be after another column
|
|
1581
1614
|
* @param columnName is the name of the column to be after
|
|
@@ -1780,21 +1813,19 @@ declare class CreateTableBuilder extends BaseBuilder {
|
|
|
1780
1813
|
* @mysql DATETIME(precision)
|
|
1781
1814
|
* @postgres TIMESTAMP(precision) WITHOUT TIME ZONE
|
|
1782
1815
|
* @sqlite TEXT
|
|
1816
|
+
* @param options.autoCreate Sets DEFAULT CURRENT_TIMESTAMP on the column
|
|
1817
|
+
* @param options.autoUpdate Automatically updates the column on row update. Uses ON UPDATE CURRENT_TIMESTAMP on MySQL/MariaDB, auto-generates a trigger on other databases
|
|
1783
1818
|
*/
|
|
1784
|
-
datetime(name: string, options?:
|
|
1785
|
-
withTimezone?: boolean;
|
|
1786
|
-
precision?: number;
|
|
1787
|
-
}): ConstraintBuilder;
|
|
1819
|
+
datetime(name: string, options?: DateTimeOptions): ConstraintBuilder;
|
|
1788
1820
|
/**
|
|
1789
1821
|
* Timestamp type
|
|
1790
1822
|
* @mysql TIMESTAMP(precision)
|
|
1791
1823
|
* @postgres TIMESTAMP(precision) WITH/WITHOUT TIME ZONE
|
|
1792
1824
|
* @sqlite TEXT
|
|
1825
|
+
* @param options.autoCreate Sets DEFAULT CURRENT_TIMESTAMP on the column
|
|
1826
|
+
* @param options.autoUpdate Automatically updates the column on row update. Uses ON UPDATE CURRENT_TIMESTAMP on MySQL/MariaDB, auto-generates a trigger on other databases
|
|
1793
1827
|
*/
|
|
1794
|
-
timestamp(name: string, options?:
|
|
1795
|
-
withTimezone?: boolean;
|
|
1796
|
-
precision?: number;
|
|
1797
|
-
}): ConstraintBuilder;
|
|
1828
|
+
timestamp(name: string, options?: DateTimeOptions): ConstraintBuilder;
|
|
1798
1829
|
/**
|
|
1799
1830
|
* Boolean type
|
|
1800
1831
|
* @mysql BOOLEAN
|
|
@@ -1921,7 +1952,7 @@ declare class CreateTableBuilder extends BaseBuilder {
|
|
|
1921
1952
|
getNamedConstraints(): QueryNode[];
|
|
1922
1953
|
}
|
|
1923
1954
|
|
|
1924
|
-
type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default";
|
|
1955
|
+
type ConstraintType = "primary_key" | "foreign_key" | "unique" | "not_null" | "null" | "default" | "check";
|
|
1925
1956
|
declare class ConstraintNode extends QueryNode {
|
|
1926
1957
|
constraintType: ConstraintType;
|
|
1927
1958
|
columns?: (string | (() => string))[];
|
|
@@ -7723,6 +7754,28 @@ declare class Schema {
|
|
|
7723
7754
|
* @description Drops a constraint from a table
|
|
7724
7755
|
*/
|
|
7725
7756
|
dropConstraint(table: string, constraintName: string): void;
|
|
7757
|
+
/**
|
|
7758
|
+
* @description Adds a CHECK constraint to a table
|
|
7759
|
+
* @param table The table name
|
|
7760
|
+
* @param expression The SQL expression for the check constraint (e.g., "age >= 18", "price > 0")
|
|
7761
|
+
* @param options Optional constraint name and other options
|
|
7762
|
+
* @example
|
|
7763
|
+
* ```ts
|
|
7764
|
+
* schema.addCheck("users", "age >= 18", { constraintName: "users_age_check" });
|
|
7765
|
+
* schema.addCheck("products", "price > 0 AND stock >= 0");
|
|
7766
|
+
* ```
|
|
7767
|
+
*/
|
|
7768
|
+
addCheck(table: string, expression: string, options?: CommonConstraintOptions): void;
|
|
7769
|
+
/**
|
|
7770
|
+
* @description Drops a CHECK constraint from a table
|
|
7771
|
+
* @param table The table name
|
|
7772
|
+
* @param constraintName The name of the check constraint to drop
|
|
7773
|
+
* @example
|
|
7774
|
+
* ```ts
|
|
7775
|
+
* schema.dropCheck("users", "users_age_check");
|
|
7776
|
+
* ```
|
|
7777
|
+
*/
|
|
7778
|
+
dropCheck(table: string, constraintName: string): void;
|
|
7726
7779
|
/**
|
|
7727
7780
|
* @description Create database extension, only supported for postgres
|
|
7728
7781
|
* @postgres Supports extensions like PostGIS, uuid-ossp, hstore, etc.
|
|
@@ -7733,6 +7786,8 @@ declare class Schema {
|
|
|
7733
7786
|
*/
|
|
7734
7787
|
createExtension(extensionName: CommonPostgresExtensions, ifNotExists?: boolean): void;
|
|
7735
7788
|
createExtension(extensionName: string, ifNotExists?: boolean): void;
|
|
7789
|
+
private generateAutoUpdateTriggers;
|
|
7790
|
+
private getAutoUpdateTriggerSql;
|
|
7736
7791
|
private generateAstInstance;
|
|
7737
7792
|
}
|
|
7738
7793
|
|