stabilize-orm 1.1.2 → 1.1.4

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/types.ts CHANGED
@@ -1,14 +1,52 @@
1
- // src/types.ts
1
+ /**
2
+ * @file types.ts
3
+ * @description Contains all shared type definitions and enums for the Stabilize ORM.
4
+ * @author ElectronSz
5
+ */
6
+
2
7
  export enum DBType {
3
- SQLite = "sqlite",
4
- MySQL = "mysql",
5
8
  Postgres = "postgres",
9
+ MySQL = "mysql",
10
+ SQLite = "sqlite",
11
+ }
12
+
13
+ export enum LogLevel {
14
+ Debug,
15
+ Info,
16
+ Warn,
17
+ Error,
18
+ }
19
+
20
+ export enum RelationType {
21
+ OneToOne,
22
+ OneToMany,
23
+ ManyToOne,
24
+ ManyToMany,
25
+ }
26
+
27
+ /**
28
+ * An enumeration of abstract data types that are mapped to database-specific types.
29
+ * This allows models to be defined in a database-agnostic way.
30
+ */
31
+ export enum DataTypes {
32
+ STRING, // Maps to VARCHAR or TEXT
33
+ TEXT, // Maps to TEXT
34
+ INTEGER, // Maps to INTEGER or INT
35
+ BIGINT, // Maps to BIGINT
36
+ FLOAT, // Maps to REAL or FLOAT
37
+ DOUBLE, // Maps to DOUBLE PRECISION
38
+ DECIMAL, // Maps to DECIMAL or NUMERIC
39
+ BOOLEAN, // Maps to BOOLEAN or TINYINT/INTEGER
40
+ DATE, // Maps to DATE or TEXT
41
+ DATETIME, // Maps to TIMESTAMP, DATETIME, or TEXT
42
+ JSON, // Maps to JSON, JSONB, or TEXT
43
+ UUID, // Maps to UUID or VARCHAR(36)
44
+ BLOB, // Maps to BYTEA or BLOB
6
45
  }
7
46
 
8
47
  export interface DBConfig {
9
48
  type: DBType;
10
49
  connectionString: string;
11
- poolSize?: number;
12
50
  retryAttempts?: number;
13
51
  retryDelay?: number;
14
52
  maxJitter?: number;
@@ -22,6 +60,9 @@ export interface CacheConfig {
22
60
  strategy?: "cache-aside" | "write-through";
23
61
  }
24
62
 
63
+ /**
64
+ * Configuration for the logger.
65
+ */
25
66
  export interface LoggerConfig {
26
67
  level?: LogLevel;
27
68
  filePath?: string;
@@ -29,38 +70,25 @@ export interface LoggerConfig {
29
70
  maxFiles?: number;
30
71
  }
31
72
 
32
- export enum LogLevel {
33
- ERROR = "error",
34
- WARN = "warn",
35
- INFO = "info",
36
- DEBUG = "debug",
37
- }
38
-
39
- export interface CacheStats {
40
- hits: number;
41
- misses: number;
42
- keys: number;
43
- }
44
-
45
- export enum RelationType {
46
- OneToOne = "one-to-one",
47
- OneToMany = "one-to-many",
48
- ManyToOne = "many-to-one",
49
- ManyToMany = "many-to-many",
73
+ export interface PoolMetrics {
74
+ activeConnections: number;
75
+ idleConnections: number;
76
+ totalConnections: number;
50
77
  }
51
78
 
52
79
  export interface QueryHint {
53
- type: "INDEX" | "FORCE_INDEX" | "USE_INDEX";
80
+ type: string;
54
81
  value: string;
55
82
  }
56
83
 
57
- export interface PoolMetrics {
58
- activeConnections: number;
59
- idleConnections: number;
60
- totalConnections: number;
84
+ export interface CacheStats {
85
+ hits: number;
86
+ misses: number;
87
+ keys: number;
61
88
  }
62
89
 
63
90
  export interface Migration {
91
+ name: string;
64
92
  up: string[];
65
93
  down: string[];
66
94
  }
@@ -68,9 +96,10 @@ export interface Migration {
68
96
  export class StabilizeError extends Error {
69
97
  constructor(
70
98
  message: string,
71
- public readonly code?: string,
99
+ public code: string,
100
+ public originalError?: Error,
72
101
  ) {
73
102
  super(message);
74
103
  this.name = "StabilizeError";
75
104
  }
76
- }
105
+ }