@promakeai/dbreact 1.0.8 → 1.1.0
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 +36 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ React hooks and providers for schema-driven, multi-language databases. Type-safe
|
|
|
7
7
|
- **Type-Safe Hooks** - Generic React hooks with generated TypeScript types
|
|
8
8
|
- **Multi-Language Support** - Automatic translation queries with fallback
|
|
9
9
|
- **Browser SQLite** - sql.js WASM adapter for offline-first apps
|
|
10
|
+
- **REST API Adapter** - Remote database access with dynamic Bearer auth
|
|
10
11
|
- **React Query Integration** - Built-in caching, loading states, optimistic updates
|
|
11
12
|
- **Zero-Config Language Switching** - Change language, queries refetch automatically
|
|
12
13
|
- **MongoDB-Style Queries** - Intuitive filter syntax (`$gt`, `$in`, `$like`, `$contains`, etc.)
|
|
@@ -289,6 +290,41 @@ const adapter = new SqliteAdapter({
|
|
|
289
290
|
- localStorage limit: ~5-10MB (browser dependent)
|
|
290
291
|
- Best for < 10,000 records
|
|
291
292
|
|
|
293
|
+
### RestAdapter
|
|
294
|
+
|
|
295
|
+
REST API adapter for remote database access. Supports static tokens and dynamic `getToken` callbacks.
|
|
296
|
+
|
|
297
|
+
```tsx
|
|
298
|
+
import { RestAdapter } from '@promakeai/dbreact';
|
|
299
|
+
|
|
300
|
+
const adapter = new RestAdapter({
|
|
301
|
+
baseUrl: 'https://api.example.com',
|
|
302
|
+
databasePrefix: '/database',
|
|
303
|
+
schema,
|
|
304
|
+
defaultLang: 'en',
|
|
305
|
+
// Dynamic token — called on every request
|
|
306
|
+
getToken: () => {
|
|
307
|
+
try {
|
|
308
|
+
const raw = localStorage.getItem('auth-storage');
|
|
309
|
+
return raw ? JSON.parse(raw)?.state?.tokens?.accessToken ?? null : null;
|
|
310
|
+
} catch { return null; }
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Config:**
|
|
316
|
+
|
|
317
|
+
| Option | Type | Required | Description |
|
|
318
|
+
|--------|------|----------|-------------|
|
|
319
|
+
| `baseUrl` | `string` | Yes | API base URL |
|
|
320
|
+
| `databasePrefix` | `string` | No | Endpoint prefix (default: `/database`) |
|
|
321
|
+
| `token` | `string` | No | Static Bearer token |
|
|
322
|
+
| `getToken` | `() => string \| null` | No | Dynamic token getter (priority over `token`) |
|
|
323
|
+
| `schema` | `SchemaDefinition` | No | Schema for translation support |
|
|
324
|
+
| `defaultLang` | `string` | No | Default language |
|
|
325
|
+
| `headers` | `Record<string, string>` | No | Custom headers |
|
|
326
|
+
| `timeout` | `number` | No | Request timeout in ms (default: 30000) |
|
|
327
|
+
|
|
292
328
|
---
|
|
293
329
|
|
|
294
330
|
## Query Options
|
package/dist/index.d.ts
CHANGED
|
@@ -10,4 +10,5 @@ export type { DbProviderConfig, DbLangContextValue, DbContextValue, } from "./ty
|
|
|
10
10
|
export { DbProvider, useDb, useAdapter, useDbLang, } from "./providers/DbProvider";
|
|
11
11
|
export { useDbList, useDbGet, useDbCreate, useDbUpdate, useDbDelete, type ListOptions, type FindOneOptions, } from "./hooks/useDbHooks";
|
|
12
12
|
export { SqliteAdapter, type SqliteAdapterConfig } from "./adapters/SqliteAdapter";
|
|
13
|
+
export { RestAdapter, type RestAdapterConfig } from "@promakeai/orm";
|
|
13
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,GAAG,EACH,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,SAAS,EACT,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,UAAU,EACV,KAAK,EACL,UAAU,EACV,SAAS,GACV,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,WAAW,EACX,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,GAAG,EACH,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,SAAS,EACT,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAGxB,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,UAAU,EACV,KAAK,EACL,UAAU,EACV,SAAS,GACV,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,WAAW,EACX,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,3 +12,4 @@ export { DbProvider, useDb, useAdapter, useDbLang, } from "./providers/DbProvide
|
|
|
12
12
|
export { useDbList, useDbGet, useDbCreate, useDbUpdate, useDbDelete, } from "./hooks/useDbHooks";
|
|
13
13
|
// Adapters
|
|
14
14
|
export { SqliteAdapter } from "./adapters/SqliteAdapter";
|
|
15
|
+
export { RestAdapter } from "@promakeai/orm";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promakeai/dbreact",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "React client for schema-driven multi-language database",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"sql.js": ">=1.11.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@promakeai/orm": "1.0
|
|
45
|
+
"@promakeai/orm": "1.2.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@tanstack/query-core": "5.90.20",
|