@aouda/client 0.0.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/LICENSE +21 -0
- package/README.md +151 -0
- package/dist/cli/index.cjs +5906 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +52 -0
- package/dist/cli/index.d.ts +52 -0
- package/dist/cli/index.js +5875 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client-DXT2ZAeO.d.cts +3356 -0
- package/dist/client-DXT2ZAeO.d.ts +3356 -0
- package/dist/index.cjs +5535 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +196 -0
- package/dist/index.d.ts +196 -0
- package/dist/index.js +5460 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aouda
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# @aouda/client
|
|
2
|
+
|
|
3
|
+
Official TypeScript/JavaScript client library for [Aouda](https://github.com/aouda/aouda).
|
|
4
|
+
|
|
5
|
+
**Quickstart — start a Aouda server first:**
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# CLI
|
|
9
|
+
aouda dev --db myapp
|
|
10
|
+
|
|
11
|
+
# or Docker
|
|
12
|
+
docker run -p 5000:5000 aouda/server
|
|
13
|
+
|
|
14
|
+
# or Docker Compose (server + Studio at http://localhost:3000)
|
|
15
|
+
docker compose up
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
See [Getting Started](https://github.com/aouda/aouda/blob/main/docs/dev/Getting-Started.md) for full setup options.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install @aouda/client
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { createAoudaClient } from '@aouda/client';
|
|
30
|
+
|
|
31
|
+
// Create client
|
|
32
|
+
const client = createAoudaClient({
|
|
33
|
+
serverUrl: 'http://localhost:5000',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Query data
|
|
37
|
+
const orders = await client.table('orders')
|
|
38
|
+
.where('status', '=', 'active')
|
|
39
|
+
.where('total', '>', 100)
|
|
40
|
+
.orderBy('createdAt', 'desc')
|
|
41
|
+
.limit(50)
|
|
42
|
+
.execute();
|
|
43
|
+
|
|
44
|
+
// List tables
|
|
45
|
+
const tables = await client.tables.list();
|
|
46
|
+
|
|
47
|
+
// Get table schema
|
|
48
|
+
const schema = await client.tables.schema('orders');
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Typed client
|
|
52
|
+
|
|
53
|
+
Pass a schema type as the generic parameter to get table and column name autocomplete and inferred result row types:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import { createAoudaClient } from '@aouda/client';
|
|
57
|
+
import type { SchemaLike } from '@aouda/client';
|
|
58
|
+
|
|
59
|
+
interface Order { id: number; status: string; }
|
|
60
|
+
interface Schema extends SchemaLike { tables: { orders: Order }; }
|
|
61
|
+
|
|
62
|
+
const client = createAoudaClient<Schema>({ serverUrl: 'http://localhost:5000' });
|
|
63
|
+
|
|
64
|
+
const query = client.table('orders'); // TableQuery<Order>
|
|
65
|
+
const result = await query.execute(); // QueryResult<Order> — result.rows is Order[]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Without a type argument, `createAoudaClient(options)` behaves as before: `table(name)` accepts any string and rows are `Record<string, unknown>`.
|
|
69
|
+
|
|
70
|
+
## Type Generation
|
|
71
|
+
|
|
72
|
+
Generate TypeScript types from your Aouda schema (B.8 CLI):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npx @aouda/client generate --server http://localhost:5000 --output ./types/
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The generated file (e.g. `schema.ts`) exports a `Schema` interface, a `TableName` union, and one interface per table. That shape is compatible with the typed client: use it as the generic for `createAoudaClient<Schema>(options)`.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { createAoudaClient } from '@aouda/client';
|
|
82
|
+
import type { Schema } from './types/schema';
|
|
83
|
+
|
|
84
|
+
const client = createAoudaClient<Schema>({
|
|
85
|
+
serverUrl: 'http://localhost:5000',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const orders = await client.table('orders')
|
|
89
|
+
.where('customerId', '=', 123)
|
|
90
|
+
.execute(); // result.rows is Order[]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## API Reference
|
|
94
|
+
|
|
95
|
+
### Client Creation
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
interface AoudaClientOptions {
|
|
99
|
+
serverUrl: string;
|
|
100
|
+
timeout?: number; // Request timeout in ms (default: 30000)
|
|
101
|
+
retryPolicy?: RetryPolicy;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const client = createAoudaClient(options);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Query Builder
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
client.table('tableName')
|
|
111
|
+
.where('column', 'op', value) // Filter (eq, ne, gt, gte, lt, lte)
|
|
112
|
+
.orderBy('column', 'asc') // Sort
|
|
113
|
+
.limit(100) // Limit rows
|
|
114
|
+
.offset(0) // Skip rows
|
|
115
|
+
.select('col1', 'col2') // Select columns
|
|
116
|
+
.execute(); // Execute query
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Table Operations
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
client.tables.list(); // Get all tables
|
|
123
|
+
client.tables.get('name'); // Get table metadata
|
|
124
|
+
client.tables.schema('name'); // Get detailed schema
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Mutations
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
client.table('orders').insert({ ... });
|
|
131
|
+
client.table('orders').insertMany([...]);
|
|
132
|
+
client.table('orders').where(...).update({ ... });
|
|
133
|
+
client.table('orders').where(...).delete();
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm install # Install dependencies
|
|
140
|
+
npm run build # Build package
|
|
141
|
+
npm run test # Run tests
|
|
142
|
+
npm run lint # Lint code
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Contributing
|
|
146
|
+
|
|
147
|
+
See [AGENTS.md](./AGENTS.md) for development workflow.
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
MIT
|