Skip to content

Commit

Permalink
Exported the missing SQLite package code
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Mar 1, 2025
1 parent 1b09e44 commit bdcac83
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/packages/emmett-sqlite/src/connection/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './sqliteConnection';
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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';
import {
type DiscountApplied,
type PricedProductItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
InMemorySQLiteDatabase,
sqliteConnection,
type SQLiteConnection,
} from '../sqliteConnection';
} from '../connection';
import { createEventStoreSchema } from './schema';
import { appendToStream } from './schema/appendToStream';
import { readStream } from './schema/readStream';
Expand Down
2 changes: 2 additions & 0 deletions src/packages/emmett-sqlite/src/eventStore/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './schema';
export * from './SQLiteEventStore';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
InMemorySQLiteDatabase,
sqliteConnection,
type SQLiteConnection,
} from '../../sqliteConnection';
} from '../../connection';
import { appendToStream } from './appendToStream';

export type PricedProductItem = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
type Parameters,
type SQLiteConnection,
type SQLiteError,
} from '../../sqliteConnection';
} from '../../connection';
import { defaultTag, messagesTable, streamsTable } from './typing';

export type AppendEventResult =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
InMemorySQLiteDatabase,
sqliteConnection,
type SQLiteConnection,
} from '../../sqliteConnection';
} from '../../connection';
import { createEventStoreSchema } from '../schema';

type TableExists = {
Expand Down
16 changes: 3 additions & 13 deletions src/packages/emmett-sqlite/src/eventStore/schema/index.ts
Original file line number Diff line number Diff line change
@@ -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<void> => {
for (const sql of schemaSQL) {
await db.command(sql);
}
};
export * from './typing';
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
InMemorySQLiteDatabase,
sqliteConnection,
type SQLiteConnection,
} from '../../sqliteConnection';
} from '../../connection';
import { appendToStream } from './appendToStream';
import { readStream } from './readStream';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type ReadStreamOptions,
type ReadStreamResult,
} from '@event-driven-io/emmett';
import { type SQLiteConnection } from '../../sqliteConnection';
import { type SQLiteConnection } from '../../connection';
import { SQLiteEventStoreDefaultStreamVersion } from '../SQLiteEventStore';
import { defaultTag, messagesTable } from './typing';

Expand Down
11 changes: 11 additions & 0 deletions src/packages/emmett-sqlite/src/eventStore/schema/tables.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { SQLiteConnection } from '../../connection';
import { globalTag, messagesTable, streamsTable } from './typing';

export const sql = (sql: string) => sql;
Expand Down Expand Up @@ -33,3 +34,13 @@ export const messagesTableSQL = sql(
);
`,
);

export const schemaSQL: string[] = [streamsTableSQL, messagesTableSQL];

export const createEventStoreSchema = async (
db: SQLiteConnection,
): Promise<void> => {
for (const sql of schemaSQL) {
await db.command(sql);
}
};
2 changes: 2 additions & 0 deletions src/packages/emmett-sqlite/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './connection';
export * from './eventStore';

0 comments on commit bdcac83

Please sign in to comment.