@stacksjs/database 0.70.73 → 0.70.75

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.
@@ -1,4 +1,5 @@
1
- import type { QueryBuilder, QueryBuilderConfig, SupportedDialect } from '@stacksjs/query-builder';
1
+ import { createQueryBuilder } from '@stacksjs/query-builder';
2
+ import type { QueryBuilderConfig, StacksDialect } from '@stacksjs/query-builder';
2
3
  /**
3
4
  * Create a database connection with the given options
4
5
  */
@@ -24,7 +25,7 @@ export declare interface DatabaseConnectionConfig {
24
25
  url?: string
25
26
  }
26
27
  export declare interface DatabaseOptions {
27
- driver: SupportedDialect
28
+ driver: StacksDialect
28
29
  connection: DatabaseConnectionConfig
29
30
  verbose?: boolean
30
31
  timestamps?: {
@@ -68,15 +69,15 @@ export declare interface DatabaseOptions {
68
69
  */
69
70
  export declare class Database {
70
71
  constructor(options: DatabaseOptions);
71
- get driver(): SupportedDialect;
72
+ get driver(): StacksDialect;
72
73
  get connection(): DatabaseConnectionConfig;
73
74
  get isInitialized(): boolean;
74
- get query(): QueryBuilder<any>;
75
+ get query(): ReturnType<typeof createQueryBuilder>;
75
76
  initialize(): void;
76
- switchDriver(driver: SupportedDialect, connection: DatabaseConnectionConfig): void;
77
+ switchDriver(driver: StacksDialect, connection: DatabaseConnectionConfig): void;
77
78
  close(): Promise<void>;
78
79
  static fromConfig(config: {
79
- default: SupportedDialect
80
+ default: StacksDialect
80
81
  connections: {
81
82
  sqlite?: { database: string }
82
83
  mysql?: { name: string, host?: string, port?: number, username?: string, password?: string }
@@ -1,12 +1,12 @@
1
- import type { SupportedDialect } from '@stacksjs/query-builder';
1
+ import type { StacksDialect } from '@stacksjs/query-builder';
2
2
  /**
3
3
  * Get the connection string for a given driver and configuration
4
4
  */
5
- export declare function getConnectionString(driver: SupportedDialect, config: DatabaseConnections[keyof DatabaseConnections]): string;
5
+ export declare function getConnectionString(driver: StacksDialect, config: DatabaseConnections[keyof DatabaseConnections]): string;
6
6
  /**
7
7
  * Validate driver configuration
8
8
  */
9
- export declare function validateDriverConfig(driver: SupportedDialect, config: DatabaseConnections[keyof DatabaseConnections]): { valid: boolean, errors: string[] };
9
+ export declare function validateDriverConfig(driver: StacksDialect, config: DatabaseConnections[keyof DatabaseConnections]): { valid: boolean, errors: string[] };
10
10
  /**
11
11
  * Merge user configuration with defaults
12
12
  */
@@ -14,50 +14,50 @@ export declare function mergeWithDefaults<T extends keyof DatabaseConnections>(d
14
14
  /**
15
15
  * Get the appropriate configuration for a driver from environment variables
16
16
  */
17
- export declare function getConfigFromEnv(driver: SupportedDialect): DatabaseConnections[keyof DatabaseConnections];
17
+ export declare function getConfigFromEnv(driver: StacksDialect): DatabaseConnections[keyof DatabaseConnections];
18
18
  /**
19
19
  * Detect the best available driver based on environment
20
20
  */
21
- export declare function detectDriver(): SupportedDialect;
21
+ export declare function detectDriver(): StacksDialect;
22
22
  /**
23
23
  * Default configuration values for each driver
24
+ * @defaultValue
25
+ * ```ts
26
+ * {
27
+ * sqlite: { database: 'database/stacks.sqlite', prefix: '' },
28
+ * mysql: {
29
+ * name: 'stacks',
30
+ * host: '127.0.0.1',
31
+ * port: 3306,
32
+ * username: 'root',
33
+ * password: '',
34
+ * prefix: '',
35
+ * charset: 'utf8mb4',
36
+ * collation: 'utf8mb4_unicode_ci'
37
+ * },
38
+ * singlestore: {
39
+ * name: 'stacks',
40
+ * host: '127.0.0.1',
41
+ * port: 3306,
42
+ * username: 'root',
43
+ * password: '',
44
+ * prefix: '',
45
+ * charset: 'utf8mb4',
46
+ * ssl: false
47
+ * },
48
+ * postgres: {
49
+ * name: 'stacks',
50
+ * host: '127.0.0.1',
51
+ * port: 5432,
52
+ * username: 'postgres',
53
+ * password: '',
54
+ * prefix: '',
55
+ * schema: 'public'
56
+ * }
57
+ * }
58
+ * ```
24
59
  */
25
- export declare const driverDefaults: {
26
- sqlite: {
27
- database: 'database/stacks.sqlite';
28
- prefix: ''
29
- };
30
- mysql: {
31
- name: 'stacks';
32
- host: '127.0.0.1';
33
- port: 3306;
34
- username: 'root';
35
- password: '';
36
- prefix: '';
37
- charset: 'utf8mb4';
38
- collation: 'utf8mb4_unicode_ci'
39
- };
40
- singlestore: {
41
- name: 'stacks';
42
- host: '127.0.0.1';
43
- port: 3306;
44
- username: 'root';
45
- password: '';
46
- prefix: '';
47
- charset: 'utf8mb4';
48
- ssl: false
49
- };
50
- postgres: {
51
- name: 'stacks';
52
- host: '127.0.0.1';
53
- port: 5432;
54
- username: 'postgres';
55
- password: '';
56
- prefix: '';
57
- schema: 'public'
58
- };
59
- browser: {}
60
- };
60
+ export declare const driverDefaults: Record<StacksDialect, Partial<SqliteConfig | MysqlConfig | SinglestoreConfig | PostgresConfig | DynamoDbConfig>>;
61
61
  /**
62
62
  * SQLite specific configuration
63
63
  */
@@ -142,7 +142,7 @@ export declare interface DatabaseConnections {
142
142
  * Full database configuration
143
143
  */
144
144
  export declare interface FullDatabaseConfig {
145
- default: SupportedDialect
145
+ default: StacksDialect
146
146
  connections: DatabaseConnections
147
147
  migrations?: string
148
148
  migrationLocks?: string
@@ -9,5 +9,8 @@ export * from './helpers';
9
9
  export * from './mysql';
10
10
  export * from './postgres';
11
11
  export * from './sqlite';
12
+ export { generateIndexCreationSQL } from './mysql';
13
+ export { generateIndexCreationSQL as generatePostgresIndexCreationSQL } from './postgres';
14
+ export { generateIndexCreationSQL as generateSqliteIndexCreationSQL } from './sqlite';
12
15
  export * from './defaults/index';
13
16
  export * from './dynamodb';
package/dist/factory.d.ts CHANGED
@@ -30,7 +30,7 @@ export declare function buildSeederPayload(modelInput: unknown, options?: Genera
30
30
  */
31
31
  export declare function generate(modelInput: unknown, options?: GenerateOptions): Promise<SeedResult>;
32
32
  export declare const factory: {
33
-
33
+ generate: typeof generate
34
34
  };
35
35
  export declare interface GenerateOptions {
36
36
  count?: number