diff --git a/src/packages/emmett-sqlite/src/connection/index.ts b/src/packages/emmett-sqlite/src/connection/index.ts new file mode 100644 index 00000000..77911132 --- /dev/null +++ b/src/packages/emmett-sqlite/src/connection/index.ts @@ -0,0 +1 @@ +export * from './sqliteConnection'; diff --git a/src/packages/emmett-sqlite/src/sqliteConnection.ts b/src/packages/emmett-sqlite/src/connection/sqliteConnection.ts similarity index 100% rename from src/packages/emmett-sqlite/src/sqliteConnection.ts rename to src/packages/emmett-sqlite/src/connection/sqliteConnection.ts diff --git a/src/packages/emmett-sqlite/src/eventStore/SQLiteEventStore.e2e.spec.ts b/src/packages/emmett-sqlite/src/eventStore/SQLiteEventStore.e2e.spec.ts index c58dc1f5..3da6c80d 100644 --- a/src/packages/emmett-sqlite/src/eventStore/SQLiteEventStore.e2e.spec.ts +++ b/src/packages/emmett-sqlite/src/eventStore/SQLiteEventStore.e2e.spec.ts @@ -10,7 +10,10 @@ import { afterEach, beforeEach, describe, it } from 'node:test'; import path from 'path'; import { fileURLToPath } from 'url'; import { v4 as uuid } from 'uuid'; -import { InMemorySQLiteDatabase, sqliteConnection } from '../sqliteConnection'; +import { + InMemorySQLiteDatabase, + sqliteConnection, +} from '../connection/sqliteConnection'; import { type DiscountApplied, type PricedProductItem, diff --git a/src/packages/emmett-sqlite/src/eventStore/SQLiteEventStore.ts b/src/packages/emmett-sqlite/src/eventStore/SQLiteEventStore.ts index e4462bed..94033ade 100644 --- a/src/packages/emmett-sqlite/src/eventStore/SQLiteEventStore.ts +++ b/src/packages/emmett-sqlite/src/eventStore/SQLiteEventStore.ts @@ -21,7 +21,7 @@ import { InMemorySQLiteDatabase, sqliteConnection, type SQLiteConnection, -} from '../sqliteConnection'; +} from '../connection/sqliteConnection'; import { createEventStoreSchema } from './schema'; import { appendToStream } from './schema/appendToStream'; import { readStream } from './schema/readStream'; diff --git a/src/packages/emmett-sqlite/src/eventStore/index.ts b/src/packages/emmett-sqlite/src/eventStore/index.ts new file mode 100644 index 00000000..dcfaf52f --- /dev/null +++ b/src/packages/emmett-sqlite/src/eventStore/index.ts @@ -0,0 +1,2 @@ +export * from './schema'; +export * from './SQLiteEventStore'; diff --git a/src/packages/emmett-sqlite/src/eventStore/schema/appendToStream.int.spec.ts b/src/packages/emmett-sqlite/src/eventStore/schema/appendToStream.int.spec.ts index f655add2..7baa81bf 100644 --- a/src/packages/emmett-sqlite/src/eventStore/schema/appendToStream.int.spec.ts +++ b/src/packages/emmett-sqlite/src/eventStore/schema/appendToStream.int.spec.ts @@ -13,7 +13,7 @@ import { InMemorySQLiteDatabase, sqliteConnection, type SQLiteConnection, -} from '../../sqliteConnection'; +} from '../../connection/sqliteConnection'; import { appendToStream } from './appendToStream'; export type PricedProductItem = { diff --git a/src/packages/emmett-sqlite/src/eventStore/schema/appendToStream.ts b/src/packages/emmett-sqlite/src/eventStore/schema/appendToStream.ts index 247978d1..7bcad1d0 100644 --- a/src/packages/emmett-sqlite/src/eventStore/schema/appendToStream.ts +++ b/src/packages/emmett-sqlite/src/eventStore/schema/appendToStream.ts @@ -14,7 +14,7 @@ import { type Parameters, type SQLiteConnection, type SQLiteError, -} from '../../sqliteConnection'; +} from '../../connection'; import { defaultTag, messagesTable, streamsTable } from './typing'; export type AppendEventResult = diff --git a/src/packages/emmett-sqlite/src/eventStore/schema/createEventStoreSchema.int.spec.ts b/src/packages/emmett-sqlite/src/eventStore/schema/createEventStoreSchema.int.spec.ts index d8d2963f..7bbebc61 100644 --- a/src/packages/emmett-sqlite/src/eventStore/schema/createEventStoreSchema.int.spec.ts +++ b/src/packages/emmett-sqlite/src/eventStore/schema/createEventStoreSchema.int.spec.ts @@ -4,7 +4,7 @@ import { InMemorySQLiteDatabase, sqliteConnection, type SQLiteConnection, -} from '../../sqliteConnection'; +} from '../../connection'; import { createEventStoreSchema } from '../schema'; type TableExists = { diff --git a/src/packages/emmett-sqlite/src/eventStore/schema/index.ts b/src/packages/emmett-sqlite/src/eventStore/schema/index.ts index 5f672ed3..bf5634f3 100644 --- a/src/packages/emmett-sqlite/src/eventStore/schema/index.ts +++ b/src/packages/emmett-sqlite/src/eventStore/schema/index.ts @@ -1,14 +1,4 @@ -import { type SQLiteConnection } from '../../sqliteConnection'; -import { messagesTableSQL, streamsTableSQL } from './tables'; - +export * from './appendToStream'; +export * from './readStream'; export * from './tables'; - -export const schemaSQL: string[] = [streamsTableSQL, messagesTableSQL]; - -export const createEventStoreSchema = async ( - db: SQLiteConnection, -): Promise => { - for (const sql of schemaSQL) { - await db.command(sql); - } -}; +export * from './typing'; diff --git a/src/packages/emmett-sqlite/src/eventStore/schema/readStream.int.spec.ts b/src/packages/emmett-sqlite/src/eventStore/schema/readStream.int.spec.ts index c1ee9ae0..92fbccf2 100644 --- a/src/packages/emmett-sqlite/src/eventStore/schema/readStream.int.spec.ts +++ b/src/packages/emmett-sqlite/src/eventStore/schema/readStream.int.spec.ts @@ -12,7 +12,7 @@ import { InMemorySQLiteDatabase, sqliteConnection, type SQLiteConnection, -} from '../../sqliteConnection'; +} from '../../connection/sqliteConnection'; import { appendToStream } from './appendToStream'; import { readStream } from './readStream'; diff --git a/src/packages/emmett-sqlite/src/eventStore/schema/readStream.ts b/src/packages/emmett-sqlite/src/eventStore/schema/readStream.ts index 5b708f43..c4db8318 100644 --- a/src/packages/emmett-sqlite/src/eventStore/schema/readStream.ts +++ b/src/packages/emmett-sqlite/src/eventStore/schema/readStream.ts @@ -7,7 +7,7 @@ import { type ReadStreamOptions, type ReadStreamResult, } from '@event-driven-io/emmett'; -import { type SQLiteConnection } from '../../sqliteConnection'; +import { type SQLiteConnection } from '../../connection/sqliteConnection'; import { SQLiteEventStoreDefaultStreamVersion } from '../SQLiteEventStore'; import { defaultTag, messagesTable } from './typing'; diff --git a/src/packages/emmett-sqlite/src/eventStore/schema/tables.ts b/src/packages/emmett-sqlite/src/eventStore/schema/tables.ts index 18d10afe..2ab89efa 100644 --- a/src/packages/emmett-sqlite/src/eventStore/schema/tables.ts +++ b/src/packages/emmett-sqlite/src/eventStore/schema/tables.ts @@ -1,3 +1,4 @@ +import type { SQLiteConnection } from '../../connection'; import { globalTag, messagesTable, streamsTable } from './typing'; export const sql = (sql: string) => sql; @@ -33,3 +34,13 @@ export const messagesTableSQL = sql( ); `, ); + +export const schemaSQL: string[] = [streamsTableSQL, messagesTableSQL]; + +export const createEventStoreSchema = async ( + db: SQLiteConnection, +): Promise => { + for (const sql of schemaSQL) { + await db.command(sql); + } +}; diff --git a/src/packages/emmett-sqlite/src/index.ts b/src/packages/emmett-sqlite/src/index.ts index e69de29b..8cd0777e 100644 --- a/src/packages/emmett-sqlite/src/index.ts +++ b/src/packages/emmett-sqlite/src/index.ts @@ -0,0 +1,2 @@ +export * from './connection'; +export * from './eventStore';