@fleettools/db 0.1.0

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.
@@ -0,0 +1,65 @@
1
+ /**
2
+ * FleetTools Database Client Factory
3
+ *
4
+ * Creates and configures Drizzle database client.
5
+ */
6
+ import { drizzle } from 'drizzle-orm/bun-sqlite';
7
+ import type { DatabaseConfig } from '@fleettools/core';
8
+ export type { DatabaseConfig };
9
+ export type DrizzleDB = ReturnType<typeof drizzle>;
10
+ /**
11
+ * Options for creating FleetDB instance
12
+ */
13
+ export interface CreateDbOptions {
14
+ projectPath: string;
15
+ filename?: string;
16
+ readonly?: boolean;
17
+ }
18
+ /**
19
+ * Create an in-memory database for testing
20
+ */
21
+ export declare function createInMemoryDb(): DrizzleDB;
22
+ /**
23
+ * Create a FleetDB instance for a project
24
+ */
25
+ export declare function createFleetDb(options: CreateDbOptions): DrizzleDB;
26
+ /**
27
+ * Create a configured Drizzle database client
28
+ */
29
+ export declare function createDatabaseClient(config?: DatabaseConfig): DrizzleDB;
30
+ /**
31
+ * Database health check function
32
+ */
33
+ export declare function checkDatabaseHealth(db: DrizzleDB): Promise<{
34
+ healthy: boolean;
35
+ error?: string;
36
+ latency?: number;
37
+ }>;
38
+ /**
39
+ * Get database information
40
+ */
41
+ export declare function getDatabaseInfo(db: DrizzleDB): Promise<{
42
+ version: string;
43
+ tables: Array<{
44
+ name: string;
45
+ rows: number;
46
+ }>;
47
+ }>;
48
+ /**
49
+ * Transaction helper with proper error handling
50
+ */
51
+ export declare function withTransaction<T>(db: DrizzleDB, callback: (tx: any) => Promise<T>): Promise<T>;
52
+ /**
53
+ * Create database connection pool (simplified for SQLite)
54
+ */
55
+ export declare class DatabasePool {
56
+ private clients;
57
+ private readonly maxPoolSize;
58
+ private readonly config;
59
+ private currentIndex;
60
+ constructor(config?: DatabaseConfig, maxPoolSize?: number);
61
+ getClient(): DrizzleDB;
62
+ initialize(): Promise<void>;
63
+ close(): Promise<void>;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,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC,GAChC,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,YAAY,CAAK;gBAEb,MAAM,GAAE,cAAmB,EAAE,WAAW,GAAE,MAAW;IAKjE,SAAS,IAAI,SAAS;IAahB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAO3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Drizzle Kit Configuration
3
+ */
4
+ declare const _default: {
5
+ schema: string;
6
+ out: string;
7
+ dialect: "sqlite";
8
+ dbCredentials: {
9
+ url: string;
10
+ };
11
+ };
12
+ export default _default;
13
+ //# sourceMappingURL=drizzle.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drizzle.config.d.ts","sourceRoot":"","sources":["../src/drizzle.config.ts"],"names":[],"mappings":"AAAA;;GAEG;;;;;;;;;AAIH,wBAOmB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * FleetTools Database Package
3
+ *
4
+ * Database layer using Drizzle ORM and libSQL for event sourcing.
5
+ */
6
+ export * from './schema.js';
7
+ export * from './client.js';
8
+ export * from './migrations.js';
9
+ export type { DrizzleDB, DatabaseConfig } from './client.js';
10
+ export type { EventRow, NewEventRow, SnapshotRow, NewSnapshotRow, MetadataRow, NewMetadataRow, AggregateType } from './schema.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,aAAa,CAAC;AAG5B,cAAc,aAAa,CAAC;AAG5B,cAAc,iBAAiB,CAAC;AAGhC,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7D,YAAY,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,cAAc,EACd,WAAW,EACX,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC"}