@an5/adapters 0.2.3 → 0.2.4
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/README.md +304 -283
- package/dotnet/An5Adapter.cs +275 -275
- package/dotnet/Base/Core.cs +82 -82
- package/dotnet/Mssql/MssqlEngine.cs +144 -144
- package/dotnet/Postgres/PostgresEngine.cs +121 -121
- package/package.json +20 -10
- package/python/an5_adapter.py +97 -97
- package/python/base/__init__.py +3 -3
- package/python/base/dialects.py +8 -8
- package/python/base/metadata.py +10 -10
- package/python/base/sql.py +121 -121
- package/python/mssql/__init__.py +1 -1
- package/python/mssql/provider.py +62 -62
- package/python/postgres/__init__.py +1 -1
- package/python/postgres/provider.py +15 -15
- package/python/table_client.py +216 -216
- package/typescript/src/an5Adapter.ts +505 -505
- package/typescript/src/base/index.ts +3 -3
- package/typescript/src/base/metadata.ts +28 -28
- package/typescript/src/base/sql.ts +98 -98
- package/typescript/src/base/types.ts +24 -24
- package/typescript/src/browser.ts +6 -6
- package/typescript/src/config.ts +95 -95
- package/typescript/src/googlesheets/adapter.ts +259 -259
- package/typescript/src/googlesheets/an5SheetsAdapter.ts +3 -3
- package/typescript/src/googlesheets/config.ts +47 -47
- package/typescript/src/googlesheets/helpers.ts +143 -143
- package/typescript/src/googlesheets/index.ts +3 -3
- package/typescript/src/googlesheets/parseConnectionString.ts +46 -46
- package/typescript/src/googlesheets/retry.ts +126 -126
- package/typescript/src/googlesheets/sqlExecutor.ts +301 -301
- package/typescript/src/googlesheets/tableClient.ts +455 -455
- package/typescript/src/googlesheets/types.ts +6 -6
- package/typescript/src/index.ts +18 -18
- package/typescript/src/mssql/engine.ts +132 -132
- package/typescript/src/mssql/index.ts +1 -1
- package/typescript/src/mysql/engine.ts +80 -80
- package/typescript/src/mysql/index.ts +1 -1
- package/typescript/src/postgres/engine.ts +87 -87
- package/typescript/src/postgres/index.ts +1 -1
- package/typescript/src/sqlite/engine.ts +55 -55
- package/typescript/src/sqlite/index.ts +1 -1
- /package/{typescript → dist}/an5Adapter.d.ts +0 -0
- /package/{typescript → dist}/an5Adapter.js +0 -0
- /package/{typescript → dist}/base/index.d.ts +0 -0
- /package/{typescript → dist}/base/index.js +0 -0
- /package/{typescript → dist}/base/metadata.d.ts +0 -0
- /package/{typescript → dist}/base/metadata.js +0 -0
- /package/{typescript → dist}/base/sql.d.ts +0 -0
- /package/{typescript → dist}/base/sql.js +0 -0
- /package/{typescript → dist}/base/types.d.ts +0 -0
- /package/{typescript → dist}/base/types.js +0 -0
- /package/{typescript → dist}/base/uuid.d.ts +0 -0
- /package/{typescript → dist}/base/uuid.js +0 -0
- /package/{typescript → dist}/browser.d.ts +0 -0
- /package/{typescript → dist}/browser.js +0 -0
- /package/{typescript → dist}/config.d.ts +0 -0
- /package/{typescript → dist}/config.js +0 -0
- /package/{typescript → dist}/googlesheets/adapter.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/adapter.js +0 -0
- /package/{typescript → dist}/googlesheets/an5SheetsAdapter.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/an5SheetsAdapter.js +0 -0
- /package/{typescript → dist}/googlesheets/config.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/config.js +0 -0
- /package/{typescript → dist}/googlesheets/helpers.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/helpers.js +0 -0
- /package/{typescript → dist}/googlesheets/index.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/index.js +0 -0
- /package/{typescript → dist}/googlesheets/parseConnectionString.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/parseConnectionString.js +0 -0
- /package/{typescript → dist}/googlesheets/retry.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/retry.js +0 -0
- /package/{typescript → dist}/googlesheets/sqlExecutor.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/sqlExecutor.js +0 -0
- /package/{typescript → dist}/googlesheets/tableClient.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/tableClient.js +0 -0
- /package/{typescript → dist}/googlesheets/types.d.ts +0 -0
- /package/{typescript → dist}/googlesheets/types.js +0 -0
- /package/{typescript → dist}/index.d.ts +0 -0
- /package/{typescript → dist}/index.js +0 -0
- /package/{typescript → dist}/mssql/engine.d.ts +0 -0
- /package/{typescript → dist}/mssql/engine.js +0 -0
- /package/{typescript → dist}/mssql/index.d.ts +0 -0
- /package/{typescript → dist}/mssql/index.js +0 -0
- /package/{typescript → dist}/mysql/engine.d.ts +0 -0
- /package/{typescript → dist}/mysql/engine.js +0 -0
- /package/{typescript → dist}/mysql/index.d.ts +0 -0
- /package/{typescript → dist}/mysql/index.js +0 -0
- /package/{typescript → dist}/postgres/engine.d.ts +0 -0
- /package/{typescript → dist}/postgres/engine.js +0 -0
- /package/{typescript → dist}/postgres/index.d.ts +0 -0
- /package/{typescript → dist}/postgres/index.js +0 -0
- /package/{typescript → dist}/sqlite/engine.d.ts +0 -0
- /package/{typescript → dist}/sqlite/engine.js +0 -0
- /package/{typescript → dist}/sqlite/index.d.ts +0 -0
- /package/{typescript → dist}/sqlite/index.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './engine';
|
|
1
|
+
export * from './engine';
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import type { An5AdapterConfig, Dialect, QueryEngine, TransactionHandle } from '../base/types';
|
|
2
|
-
|
|
3
|
-
// ─── SQLite Engine ─────────────────────────────────────────────────────────────────
|
|
4
|
-
|
|
5
|
-
let BetterSqlite3: any = null;
|
|
6
|
-
try { BetterSqlite3 = require('better-sqlite3'); } catch { }
|
|
7
|
-
|
|
8
|
-
export class SqliteEngine implements QueryEngine {
|
|
9
|
-
dialect: Dialect = 'sqlite';
|
|
10
|
-
private db: any = null;
|
|
11
|
-
private readonly filePath: string;
|
|
12
|
-
|
|
13
|
-
constructor(adapterConfig: An5AdapterConfig) {
|
|
14
|
-
if (!BetterSqlite3) throw new Error('better-sqlite3 package is required for SQLite support. Run: npm install better-sqlite3');
|
|
15
|
-
this.filePath = adapterConfig.connectionString
|
|
16
|
-
.replace(/^sqlite:\/\/\//i, '/')
|
|
17
|
-
.replace(/^sqlite:\/\//i, '');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private getDb(): any {
|
|
21
|
-
if (!this.db) this.db = new BetterSqlite3(this.filePath);
|
|
22
|
-
return this.db;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// better-sqlite3 natively supports @name parameters
|
|
26
|
-
async exec<T = any>(query: string, params?: Record<string, any>): Promise<T[]> {
|
|
27
|
-
return this.getDb().prepare(query).all(params ?? {}) as T[];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async executeRaw(query: string, params?: Record<string, any>): Promise<number> {
|
|
31
|
-
const info = this.getDb().prepare(query).run(params ?? {});
|
|
32
|
-
return info.changes ?? 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async connect(): Promise<void> { this.getDb(); }
|
|
36
|
-
|
|
37
|
-
async disconnect(): Promise<void> {
|
|
38
|
-
if (this.db) { this.db.close(); this.db = null; }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async beginTransaction(): Promise<TransactionHandle> {
|
|
42
|
-
const db = this.getDb();
|
|
43
|
-
db.prepare('BEGIN').run();
|
|
44
|
-
let done = false;
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
exec: async <T>(q: string, p?: Record<string, any>) =>
|
|
48
|
-
db.prepare(q).all(p ?? {}) as T[],
|
|
49
|
-
executeRaw: async (q: string, p?: Record<string, any>) =>
|
|
50
|
-
(db.prepare(q).run(p ?? {}).changes ?? 0),
|
|
51
|
-
commit: async () => { if (!done) { db.prepare('COMMIT').run(); done = true; } },
|
|
52
|
-
rollback: async () => { if (!done) { db.prepare('ROLLBACK').run(); done = true; } },
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
import type { An5AdapterConfig, Dialect, QueryEngine, TransactionHandle } from '../base/types';
|
|
2
|
+
|
|
3
|
+
// ─── SQLite Engine ─────────────────────────────────────────────────────────────────
|
|
4
|
+
|
|
5
|
+
let BetterSqlite3: any = null;
|
|
6
|
+
try { BetterSqlite3 = require('better-sqlite3'); } catch { }
|
|
7
|
+
|
|
8
|
+
export class SqliteEngine implements QueryEngine {
|
|
9
|
+
dialect: Dialect = 'sqlite';
|
|
10
|
+
private db: any = null;
|
|
11
|
+
private readonly filePath: string;
|
|
12
|
+
|
|
13
|
+
constructor(adapterConfig: An5AdapterConfig) {
|
|
14
|
+
if (!BetterSqlite3) throw new Error('better-sqlite3 package is required for SQLite support. Run: npm install better-sqlite3');
|
|
15
|
+
this.filePath = adapterConfig.connectionString
|
|
16
|
+
.replace(/^sqlite:\/\/\//i, '/')
|
|
17
|
+
.replace(/^sqlite:\/\//i, '');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private getDb(): any {
|
|
21
|
+
if (!this.db) this.db = new BetterSqlite3(this.filePath);
|
|
22
|
+
return this.db;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// better-sqlite3 natively supports @name parameters
|
|
26
|
+
async exec<T = any>(query: string, params?: Record<string, any>): Promise<T[]> {
|
|
27
|
+
return this.getDb().prepare(query).all(params ?? {}) as T[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async executeRaw(query: string, params?: Record<string, any>): Promise<number> {
|
|
31
|
+
const info = this.getDb().prepare(query).run(params ?? {});
|
|
32
|
+
return info.changes ?? 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async connect(): Promise<void> { this.getDb(); }
|
|
36
|
+
|
|
37
|
+
async disconnect(): Promise<void> {
|
|
38
|
+
if (this.db) { this.db.close(); this.db = null; }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async beginTransaction(): Promise<TransactionHandle> {
|
|
42
|
+
const db = this.getDb();
|
|
43
|
+
db.prepare('BEGIN').run();
|
|
44
|
+
let done = false;
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
exec: async <T>(q: string, p?: Record<string, any>) =>
|
|
48
|
+
db.prepare(q).all(p ?? {}) as T[],
|
|
49
|
+
executeRaw: async (q: string, p?: Record<string, any>) =>
|
|
50
|
+
(db.prepare(q).run(p ?? {}).changes ?? 0),
|
|
51
|
+
commit: async () => { if (!done) { db.prepare('COMMIT').run(); done = true; } },
|
|
52
|
+
rollback: async () => { if (!done) { db.prepare('ROLLBACK').run(); done = true; } },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './engine';
|
|
1
|
+
export * from './engine';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|