@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.
Files changed (96) hide show
  1. package/README.md +304 -283
  2. package/dotnet/An5Adapter.cs +275 -275
  3. package/dotnet/Base/Core.cs +82 -82
  4. package/dotnet/Mssql/MssqlEngine.cs +144 -144
  5. package/dotnet/Postgres/PostgresEngine.cs +121 -121
  6. package/package.json +20 -10
  7. package/python/an5_adapter.py +97 -97
  8. package/python/base/__init__.py +3 -3
  9. package/python/base/dialects.py +8 -8
  10. package/python/base/metadata.py +10 -10
  11. package/python/base/sql.py +121 -121
  12. package/python/mssql/__init__.py +1 -1
  13. package/python/mssql/provider.py +62 -62
  14. package/python/postgres/__init__.py +1 -1
  15. package/python/postgres/provider.py +15 -15
  16. package/python/table_client.py +216 -216
  17. package/typescript/src/an5Adapter.ts +505 -505
  18. package/typescript/src/base/index.ts +3 -3
  19. package/typescript/src/base/metadata.ts +28 -28
  20. package/typescript/src/base/sql.ts +98 -98
  21. package/typescript/src/base/types.ts +24 -24
  22. package/typescript/src/browser.ts +6 -6
  23. package/typescript/src/config.ts +95 -95
  24. package/typescript/src/googlesheets/adapter.ts +259 -259
  25. package/typescript/src/googlesheets/an5SheetsAdapter.ts +3 -3
  26. package/typescript/src/googlesheets/config.ts +47 -47
  27. package/typescript/src/googlesheets/helpers.ts +143 -143
  28. package/typescript/src/googlesheets/index.ts +3 -3
  29. package/typescript/src/googlesheets/parseConnectionString.ts +46 -46
  30. package/typescript/src/googlesheets/retry.ts +126 -126
  31. package/typescript/src/googlesheets/sqlExecutor.ts +301 -301
  32. package/typescript/src/googlesheets/tableClient.ts +455 -455
  33. package/typescript/src/googlesheets/types.ts +6 -6
  34. package/typescript/src/index.ts +18 -18
  35. package/typescript/src/mssql/engine.ts +132 -132
  36. package/typescript/src/mssql/index.ts +1 -1
  37. package/typescript/src/mysql/engine.ts +80 -80
  38. package/typescript/src/mysql/index.ts +1 -1
  39. package/typescript/src/postgres/engine.ts +87 -87
  40. package/typescript/src/postgres/index.ts +1 -1
  41. package/typescript/src/sqlite/engine.ts +55 -55
  42. package/typescript/src/sqlite/index.ts +1 -1
  43. /package/{typescript → dist}/an5Adapter.d.ts +0 -0
  44. /package/{typescript → dist}/an5Adapter.js +0 -0
  45. /package/{typescript → dist}/base/index.d.ts +0 -0
  46. /package/{typescript → dist}/base/index.js +0 -0
  47. /package/{typescript → dist}/base/metadata.d.ts +0 -0
  48. /package/{typescript → dist}/base/metadata.js +0 -0
  49. /package/{typescript → dist}/base/sql.d.ts +0 -0
  50. /package/{typescript → dist}/base/sql.js +0 -0
  51. /package/{typescript → dist}/base/types.d.ts +0 -0
  52. /package/{typescript → dist}/base/types.js +0 -0
  53. /package/{typescript → dist}/base/uuid.d.ts +0 -0
  54. /package/{typescript → dist}/base/uuid.js +0 -0
  55. /package/{typescript → dist}/browser.d.ts +0 -0
  56. /package/{typescript → dist}/browser.js +0 -0
  57. /package/{typescript → dist}/config.d.ts +0 -0
  58. /package/{typescript → dist}/config.js +0 -0
  59. /package/{typescript → dist}/googlesheets/adapter.d.ts +0 -0
  60. /package/{typescript → dist}/googlesheets/adapter.js +0 -0
  61. /package/{typescript → dist}/googlesheets/an5SheetsAdapter.d.ts +0 -0
  62. /package/{typescript → dist}/googlesheets/an5SheetsAdapter.js +0 -0
  63. /package/{typescript → dist}/googlesheets/config.d.ts +0 -0
  64. /package/{typescript → dist}/googlesheets/config.js +0 -0
  65. /package/{typescript → dist}/googlesheets/helpers.d.ts +0 -0
  66. /package/{typescript → dist}/googlesheets/helpers.js +0 -0
  67. /package/{typescript → dist}/googlesheets/index.d.ts +0 -0
  68. /package/{typescript → dist}/googlesheets/index.js +0 -0
  69. /package/{typescript → dist}/googlesheets/parseConnectionString.d.ts +0 -0
  70. /package/{typescript → dist}/googlesheets/parseConnectionString.js +0 -0
  71. /package/{typescript → dist}/googlesheets/retry.d.ts +0 -0
  72. /package/{typescript → dist}/googlesheets/retry.js +0 -0
  73. /package/{typescript → dist}/googlesheets/sqlExecutor.d.ts +0 -0
  74. /package/{typescript → dist}/googlesheets/sqlExecutor.js +0 -0
  75. /package/{typescript → dist}/googlesheets/tableClient.d.ts +0 -0
  76. /package/{typescript → dist}/googlesheets/tableClient.js +0 -0
  77. /package/{typescript → dist}/googlesheets/types.d.ts +0 -0
  78. /package/{typescript → dist}/googlesheets/types.js +0 -0
  79. /package/{typescript → dist}/index.d.ts +0 -0
  80. /package/{typescript → dist}/index.js +0 -0
  81. /package/{typescript → dist}/mssql/engine.d.ts +0 -0
  82. /package/{typescript → dist}/mssql/engine.js +0 -0
  83. /package/{typescript → dist}/mssql/index.d.ts +0 -0
  84. /package/{typescript → dist}/mssql/index.js +0 -0
  85. /package/{typescript → dist}/mysql/engine.d.ts +0 -0
  86. /package/{typescript → dist}/mysql/engine.js +0 -0
  87. /package/{typescript → dist}/mysql/index.d.ts +0 -0
  88. /package/{typescript → dist}/mysql/index.js +0 -0
  89. /package/{typescript → dist}/postgres/engine.d.ts +0 -0
  90. /package/{typescript → dist}/postgres/engine.js +0 -0
  91. /package/{typescript → dist}/postgres/index.d.ts +0 -0
  92. /package/{typescript → dist}/postgres/index.js +0 -0
  93. /package/{typescript → dist}/sqlite/engine.d.ts +0 -0
  94. /package/{typescript → dist}/sqlite/engine.js +0 -0
  95. /package/{typescript → dist}/sqlite/index.d.ts +0 -0
  96. /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