@an5/adapters 0.1.3 → 0.2.1
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 +44 -44
- package/dotnet/An5Adapter.cs +275 -275
- package/package.json +17 -10
- package/python/base/metadata.py +10 -10
- package/python/table_client.py +216 -219
- package/typescript/googlesheets/adapter.d.ts +3 -2
- package/typescript/googlesheets/adapter.js +74 -4
- package/typescript/googlesheets/adapter.ts +82 -8
- package/typescript/googlesheets/config.d.ts +11 -0
- package/typescript/googlesheets/config.js +7 -0
- package/typescript/googlesheets/config.ts +11 -0
- package/typescript/googlesheets/helpers.js +1 -1
- package/typescript/googlesheets/helpers.ts +1 -1
- package/typescript/googlesheets/retry.js +21 -8
- package/typescript/googlesheets/retry.ts +17 -8
- package/typescript/googlesheets/tableClient.js +4 -3
- package/typescript/googlesheets/tableClient.ts +6 -5
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# an5Adapters
|
|
2
2
|
|
|
3
|
-
Standalone runtime adapters for AN5 ORM. Provides connection pooling, query execution, typed table clients in TypeScript, Python, .NET, and Google Sheets API.
|
|
4
|
-
|
|
5
|
-
Adapters are runtime packages only. They do not import generated `an5Client` artifacts; generated clients or applications can pass model metadata explicitly when table-name mapping or field type coercion is needed.
|
|
3
|
+
Standalone runtime adapters for AN5 ORM. Provides connection pooling, query execution, typed table clients in TypeScript, Python, .NET, and Google Sheets API.
|
|
4
|
+
|
|
5
|
+
Adapters are runtime packages only. They do not import generated `an5Client` artifacts; generated clients or applications can pass model metadata explicitly when table-name mapping or field type coercion is needed.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -19,7 +19,7 @@ Adapters are runtime packages only. They do not import generated `an5Client` art
|
|
|
19
19
|
### TypeScript
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npm install
|
|
22
|
+
npm install an5-adapters
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Python
|
|
@@ -39,17 +39,17 @@ dotnet add package An5Adapters
|
|
|
39
39
|
### TypeScript
|
|
40
40
|
|
|
41
41
|
```typescript
|
|
42
|
-
import { createAn5Adapter, setAdapterMetadata } from '
|
|
43
|
-
|
|
44
|
-
setAdapterMetadata({
|
|
45
|
-
modelToTable: { User: 'dbo.users' },
|
|
46
|
-
modelFields: {
|
|
47
|
-
User: {
|
|
48
|
-
id: { ts: 'string', sql: 'uniqueidentifier', isId: true },
|
|
49
|
-
active: { ts: 'boolean', sql: 'bit' },
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
42
|
+
import { createAn5Adapter, setAdapterMetadata } from 'an5-adapters';
|
|
43
|
+
|
|
44
|
+
setAdapterMetadata({
|
|
45
|
+
modelToTable: { User: 'dbo.users' },
|
|
46
|
+
modelFields: {
|
|
47
|
+
User: {
|
|
48
|
+
id: { ts: 'string', sql: 'uniqueidentifier', isId: true },
|
|
49
|
+
active: { ts: 'boolean', sql: 'bit' },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
53
|
|
|
54
54
|
const db = createAn5Adapter({
|
|
55
55
|
connectionString: 'sqlserver://localhost:1433;database=mydb;user=sa;password=pass',
|
|
@@ -71,18 +71,18 @@ await db.$transaction(async (tx) => {
|
|
|
71
71
|
### Python
|
|
72
72
|
|
|
73
73
|
```python
|
|
74
|
-
from an5_adapter import create_an5_adapter
|
|
75
|
-
from base.metadata import set_adapter_metadata
|
|
76
|
-
|
|
77
|
-
set_adapter_metadata({
|
|
78
|
-
"modelToTable": {"User": "dbo.users"},
|
|
79
|
-
"modelFields": {
|
|
80
|
-
"User": {
|
|
81
|
-
"id": {"py": "str", "sql": "uniqueidentifier", "isId": True},
|
|
82
|
-
"active": {"py": "bool", "sql": "bit"},
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
})
|
|
74
|
+
from an5_adapter import create_an5_adapter
|
|
75
|
+
from base.metadata import set_adapter_metadata
|
|
76
|
+
|
|
77
|
+
set_adapter_metadata({
|
|
78
|
+
"modelToTable": {"User": "dbo.users"},
|
|
79
|
+
"modelFields": {
|
|
80
|
+
"User": {
|
|
81
|
+
"id": {"py": "str", "sql": "uniqueidentifier", "isId": True},
|
|
82
|
+
"active": {"py": "bool", "sql": "bit"},
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
86
|
|
|
87
87
|
db = create_an5_adapter("sqlserver://localhost:1433;database=mydb;user=sa;password=pass")
|
|
88
88
|
|
|
@@ -120,9 +120,9 @@ db.Transaction(tx => {
|
|
|
120
120
|
### Google Sheets
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
|
-
import {
|
|
124
|
-
|
|
125
|
-
const db =
|
|
123
|
+
import { createAn5SheetsAdapter } from 'an5-adapters';
|
|
124
|
+
|
|
125
|
+
const db = createAn5SheetsAdapter({
|
|
126
126
|
spreadsheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms',
|
|
127
127
|
// Option 1: client email + private key
|
|
128
128
|
clientEmail: 'sa@project.iam.gserviceaccount.com',
|
|
@@ -160,7 +160,7 @@ await db.table('users').deleteAll();
|
|
|
160
160
|
### Integrated factory (auto-detect adapter)
|
|
161
161
|
|
|
162
162
|
```typescript
|
|
163
|
-
import { createAn5Adapter, createAdapter, An5Adapter } from '
|
|
163
|
+
import { createAn5Adapter, createAdapter, An5Adapter } from 'an5-adapters';
|
|
164
164
|
|
|
165
165
|
// Auto-detects from connection string
|
|
166
166
|
const sqlDb = createAn5Adapter({ connectionString: 'sqlserver://localhost:1433;database=mydb;user=sa;password=pass' });
|
|
@@ -189,18 +189,18 @@ const sheetsDb3 = new An5Adapter({
|
|
|
189
189
|
- Numeric strings (without leading zeros) are auto-coerced; `"00123"` stays string
|
|
190
190
|
- Boolean strings `"true"` / `"false"` are auto-coerced
|
|
191
191
|
- Sheet names with spaces are automatically escaped (A1 notation)
|
|
192
|
-
- Supports service account JSON or individual `clientEmail`+`privateKey`
|
|
193
|
-
- Automatic retry with exponential backoff for rate limits (429/500/503)
|
|
194
|
-
|
|
195
|
-
### Provider Imports
|
|
196
|
-
|
|
197
|
-
Use the package root for normal applications:
|
|
198
|
-
|
|
199
|
-
```typescript
|
|
200
|
-
import { createAn5Adapter } from '
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
Provider folders are still available to source-level consumers through `typescript/*`, but the public factory in `typescript/an5Adapter.ts` is the preferred entry point. The old `unified.ts` entry point has been removed because the factory now lives directly in `An5Adapter`.
|
|
192
|
+
- Supports service account JSON or individual `clientEmail`+`privateKey`
|
|
193
|
+
- Automatic retry with exponential backoff for rate limits (429/500/503)
|
|
194
|
+
|
|
195
|
+
### Provider Imports
|
|
196
|
+
|
|
197
|
+
Use the package root for normal applications:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import { createAn5Adapter, createAn5SheetsAdapter } from 'an5-adapters';
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Provider folders are still available to source-level consumers through `typescript/*`, but the public factory in `typescript/an5Adapter.ts` is the preferred entry point. The old `unified.ts` entry point has been removed because the factory now lives directly in `An5Adapter`.
|
|
204
204
|
|
|
205
205
|
## API Reference
|
|
206
206
|
|
|
@@ -245,7 +245,7 @@ Provider folders are still available to source-level consumers through `typescri
|
|
|
245
245
|
- TypeScript providers live under `typescript/{base,mssql,postgres,mysql,sqlite,googlesheets}`.
|
|
246
246
|
- Python providers live under `python/{base,mssql,postgres}`, with `python/an5_adapter.py` kept as the public facade.
|
|
247
247
|
- .NET providers live under `dotnet/{Base,Mssql,Postgres}`, with `dotnet/an5Adapter.cs` kept as the public facade.
|
|
248
|
-
- Adapters do not depend on generated `
|
|
248
|
+
- Adapters do not depend on generated `an5-client` artifacts; generated clients may pass metadata in explicitly when they need model/table mapping.
|
|
249
249
|
|
|
250
250
|
## Testing
|
|
251
251
|
|