@atscript/db-sqlite 0.1.34 → 0.1.36

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { BaseDbAdapter, TDbInsertResult, TDbInsertManyResult, DbQuery, FilterExpr, TDbUpdateResult, TDbDeleteResult, TExistingColumn, TColumnDiff, TSyncColumnResult, DbSpace } from '@atscript/utils-db';
1
2
  import { TAtscriptAnnotatedType } from '@atscript/typescript/utils';
2
- import { BaseDbAdapter, TDbInsertResult, TDbInsertManyResult, DbQuery, FilterExpr, TDbUpdateResult, TDbDeleteResult } from '@atscript/utils-db';
3
3
  import * as better_sqlite3 from 'better-sqlite3';
4
4
  import { FilterExpr as FilterExpr$1 } from '@uniqu/core';
5
5
 
@@ -66,9 +66,19 @@ interface TSqliteDriver {
66
66
  declare class SqliteAdapter extends BaseDbAdapter {
67
67
  protected readonly driver: TSqliteDriver;
68
68
  constructor(driver: TSqliteDriver);
69
+ protected _beginTransaction(): Promise<unknown>;
70
+ protected _commitTransaction(): Promise<void>;
71
+ protected _rollbackTransaction(): Promise<void>;
69
72
  /** SQLite does not use schemas — override to always exclude schema. */
70
73
  resolveTableName(): string;
74
+ /** SQLite enforces FK constraints natively via PRAGMA foreign_keys. */
75
+ supportsNativeForeignKeys(): boolean;
71
76
  prepareId(id: unknown, _fieldType: TAtscriptAnnotatedType): unknown;
77
+ /**
78
+ * Wraps a write operation to catch native SQLite constraint errors
79
+ * and rethrow as structured `DbError`.
80
+ */
81
+ private _wrapConstraintError;
72
82
  insertOne(data: Record<string, unknown>): Promise<TDbInsertResult>;
73
83
  insertMany(data: Array<Record<string, unknown>>): Promise<TDbInsertManyResult>;
74
84
  findOne(query: DbQuery): Promise<Record<string, unknown> | null>;
@@ -81,6 +91,20 @@ declare class SqliteAdapter extends BaseDbAdapter {
81
91
  deleteOne(filter: FilterExpr): Promise<TDbDeleteResult>;
82
92
  deleteMany(filter: FilterExpr): Promise<TDbDeleteResult>;
83
93
  ensureTable(): Promise<void>;
94
+ ensureView(): Promise<void>;
95
+ getExistingColumns(): Promise<TExistingColumn[]>;
96
+ syncColumns(diff: TColumnDiff): Promise<TSyncColumnResult>;
97
+ recreateTable(): Promise<void>;
98
+ dropTable(): Promise<void>;
99
+ dropColumns(columns: string[]): Promise<void>;
100
+ dropTableByName(tableName: string): Promise<void>;
101
+ dropViewByName(viewName: string): Promise<void>;
102
+ renameTable(oldName: string): Promise<void>;
103
+ typeMapper(field: {
104
+ designType: string;
105
+ isPrimaryKey: boolean;
106
+ }): string;
107
+ getExistingColumnsForTable(tableName: string): Promise<TExistingColumn[]>;
84
108
  syncIndexes(): Promise<void>;
85
109
  }
86
110
 
@@ -132,5 +156,7 @@ interface TSqlFragment {
132
156
  */
133
157
  declare function buildWhere(filter: FilterExpr$1): TSqlFragment;
134
158
 
135
- export { BetterSqlite3Driver, SqliteAdapter, buildWhere };
159
+ declare function createAdapter(connection: string, options?: Record<string, unknown>): DbSpace;
160
+
161
+ export { BetterSqlite3Driver, SqliteAdapter, buildWhere, createAdapter };
136
162
  export type { TSqlFragment, TSqliteDriver, TSqliteRunResult };