@toonstore/torm 0.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 +421 -0
- package/check.sh +22 -0
- package/dist/index.d.ts +149 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +310 -0
- package/dist/index.js.map +1 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
# @toonstore/torm
|
|
2
|
+
|
|
3
|
+
> ToonStore ORM Client for Node.js & TypeScript
|
|
4
|
+
|
|
5
|
+
A Mongoose-style ORM client for ToonStore, providing type-safe models, validation, and query building.
|
|
6
|
+
|
|
7
|
+
## ✨ Features
|
|
8
|
+
|
|
9
|
+
- ✅ **Type-Safe** - Full TypeScript support
|
|
10
|
+
- ✅ **Validation** - Built-in validators (email, URL, min/max, patterns)
|
|
11
|
+
- ✅ **Query Builder** - Fluent API for filtering and sorting
|
|
12
|
+
- ✅ **Schema Definition** - Define your data models
|
|
13
|
+
- ✅ **Async/Await** - Promise-based API
|
|
14
|
+
- ✅ **HTTP-Based** - Communicates with TORM Server
|
|
15
|
+
|
|
16
|
+
## 📦 Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @toonstore/torm
|
|
20
|
+
# or
|
|
21
|
+
yarn add @toonstore/torm
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 🚀 Quick Start
|
|
25
|
+
|
|
26
|
+
### Prerequisites
|
|
27
|
+
|
|
28
|
+
Make sure TORM server is running:
|
|
29
|
+
```bash
|
|
30
|
+
cargo run --package torm-server --release
|
|
31
|
+
# Server runs on http://localhost:3001
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Basic Usage
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { TormClient } from '@toonstore/torm';
|
|
38
|
+
|
|
39
|
+
// 1. Create client
|
|
40
|
+
const torm = new TormClient({
|
|
41
|
+
baseURL: 'http://localhost:3001',
|
|
42
|
+
timeout: 5000,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// 2. Define model with schema
|
|
46
|
+
interface User {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
email: string;
|
|
50
|
+
age: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const User = torm.model<User>('User', {
|
|
54
|
+
name: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
required: true,
|
|
57
|
+
minLength: 3,
|
|
58
|
+
maxLength: 50,
|
|
59
|
+
},
|
|
60
|
+
email: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
required: true,
|
|
63
|
+
email: true,
|
|
64
|
+
},
|
|
65
|
+
age: {
|
|
66
|
+
type: 'number',
|
|
67
|
+
required: true,
|
|
68
|
+
min: 13,
|
|
69
|
+
max: 120,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// 3. Create document
|
|
74
|
+
const user = await User.create({
|
|
75
|
+
id: 'user:1',
|
|
76
|
+
name: 'Alice',
|
|
77
|
+
email: 'alice@example.com',
|
|
78
|
+
age: 30,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// 4. Find documents
|
|
82
|
+
const allUsers = await User.find();
|
|
83
|
+
const specificUser = await User.findById('user:1');
|
|
84
|
+
|
|
85
|
+
// 5. Query with filters
|
|
86
|
+
const adults = await User.query()
|
|
87
|
+
.filter('age', 'gte', 18)
|
|
88
|
+
.sort('name', 'asc')
|
|
89
|
+
.limit(10)
|
|
90
|
+
.exec();
|
|
91
|
+
|
|
92
|
+
// 6. Update document
|
|
93
|
+
await User.update('user:1', { age: 31 });
|
|
94
|
+
|
|
95
|
+
// 7. Delete document
|
|
96
|
+
await User.delete('user:1');
|
|
97
|
+
|
|
98
|
+
// 8. Count documents
|
|
99
|
+
const count = await User.count();
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 📖 API Documentation
|
|
103
|
+
|
|
104
|
+
### TormClient
|
|
105
|
+
|
|
106
|
+
#### Constructor
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const torm = new TormClient(options?: TormClientOptions);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Options:**
|
|
113
|
+
- `baseURL` (string) - TORM server URL (default: `http://localhost:3001`)
|
|
114
|
+
- `timeout` (number) - Request timeout in ms (default: `5000`)
|
|
115
|
+
|
|
116
|
+
#### Methods
|
|
117
|
+
|
|
118
|
+
- `model<T>(name, schema?, options?)` - Create a model
|
|
119
|
+
- `health()` - Check server health
|
|
120
|
+
- `info()` - Get server info
|
|
121
|
+
|
|
122
|
+
### Model
|
|
123
|
+
|
|
124
|
+
#### CRUD Operations
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
// Create
|
|
128
|
+
const doc = await Model.create(data);
|
|
129
|
+
|
|
130
|
+
// Read
|
|
131
|
+
const all = await Model.find();
|
|
132
|
+
const one = await Model.findById(id);
|
|
133
|
+
|
|
134
|
+
// Update
|
|
135
|
+
const updated = await Model.update(id, data);
|
|
136
|
+
|
|
137
|
+
// Delete
|
|
138
|
+
const deleted = await Model.delete(id);
|
|
139
|
+
|
|
140
|
+
// Count
|
|
141
|
+
const count = await Model.count();
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### Query Builder
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
const results = await Model.query()
|
|
148
|
+
.filter(field, operator, value) // Add filter
|
|
149
|
+
.where(field, value) // Shorthand for .filter(field, 'eq', value)
|
|
150
|
+
.sort(field, order) // Sort results
|
|
151
|
+
.limit(n) // Limit results
|
|
152
|
+
.skip(n) // Skip results
|
|
153
|
+
.exec(); // Execute query
|
|
154
|
+
|
|
155
|
+
// Count with filters
|
|
156
|
+
const count = await Model.query()
|
|
157
|
+
.filter('status', 'eq', 'active')
|
|
158
|
+
.count();
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Query Operators:**
|
|
162
|
+
- `eq` - Equal to
|
|
163
|
+
- `ne` - Not equal to
|
|
164
|
+
- `gt` - Greater than
|
|
165
|
+
- `gte` - Greater than or equal
|
|
166
|
+
- `lt` - Less than
|
|
167
|
+
- `lte` - Less than or equal
|
|
168
|
+
- `contains` - String contains
|
|
169
|
+
- `in` - Value in array
|
|
170
|
+
- `not_in` - Value not in array
|
|
171
|
+
|
|
172
|
+
### Validation
|
|
173
|
+
|
|
174
|
+
#### Schema Rules
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
const schema = {
|
|
178
|
+
fieldName: {
|
|
179
|
+
type: 'string' | 'number' | 'boolean' | 'object' | 'array',
|
|
180
|
+
required: boolean,
|
|
181
|
+
|
|
182
|
+
// String validations
|
|
183
|
+
minLength: number,
|
|
184
|
+
maxLength: number,
|
|
185
|
+
pattern: RegExp,
|
|
186
|
+
email: boolean,
|
|
187
|
+
url: boolean,
|
|
188
|
+
|
|
189
|
+
// Number validations
|
|
190
|
+
min: number,
|
|
191
|
+
max: number,
|
|
192
|
+
|
|
193
|
+
// Custom validation
|
|
194
|
+
validate: (value) => boolean,
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Built-in Validators
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
// Email validation
|
|
203
|
+
email: { type: 'string', email: true }
|
|
204
|
+
|
|
205
|
+
// URL validation
|
|
206
|
+
website: { type: 'string', url: true }
|
|
207
|
+
|
|
208
|
+
// String length
|
|
209
|
+
name: { type: 'string', minLength: 3, maxLength: 50 }
|
|
210
|
+
|
|
211
|
+
// Number range
|
|
212
|
+
age: { type: 'number', min: 0, max: 120 }
|
|
213
|
+
|
|
214
|
+
// Pattern matching
|
|
215
|
+
phone: { type: 'string', pattern: /^\d{10}$/ }
|
|
216
|
+
|
|
217
|
+
// Custom validation
|
|
218
|
+
username: {
|
|
219
|
+
type: 'string',
|
|
220
|
+
validate: (value) => /^[a-z0-9_]+$/.test(value),
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## 📝 Examples
|
|
225
|
+
|
|
226
|
+
### Example 1: User Management
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
import { TormClient } from '@toonstore/torm';
|
|
230
|
+
|
|
231
|
+
const torm = new TormClient();
|
|
232
|
+
|
|
233
|
+
interface User {
|
|
234
|
+
id: string;
|
|
235
|
+
username: string;
|
|
236
|
+
email: string;
|
|
237
|
+
age: number;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const User = torm.model<User>('User', {
|
|
241
|
+
username: {
|
|
242
|
+
type: 'string',
|
|
243
|
+
required: true,
|
|
244
|
+
minLength: 3,
|
|
245
|
+
pattern: /^[a-z0-9_]+$/,
|
|
246
|
+
},
|
|
247
|
+
email: {
|
|
248
|
+
type: 'string',
|
|
249
|
+
required: true,
|
|
250
|
+
email: true,
|
|
251
|
+
},
|
|
252
|
+
age: {
|
|
253
|
+
type: 'number',
|
|
254
|
+
min: 18,
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// Create users
|
|
259
|
+
await User.create({
|
|
260
|
+
id: 'user:1',
|
|
261
|
+
username: 'alice',
|
|
262
|
+
email: 'alice@example.com',
|
|
263
|
+
age: 30,
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
// Find adults
|
|
267
|
+
const adults = await User.query()
|
|
268
|
+
.filter('age', 'gte', 18)
|
|
269
|
+
.sort('username', 'asc')
|
|
270
|
+
.exec();
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Example 2: Blog Posts
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
interface Post {
|
|
277
|
+
id: string;
|
|
278
|
+
title: string;
|
|
279
|
+
content: string;
|
|
280
|
+
author_id: string;
|
|
281
|
+
published: boolean;
|
|
282
|
+
tags: string[];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const Post = torm.model<Post>('Post', {
|
|
286
|
+
title: {
|
|
287
|
+
type: 'string',
|
|
288
|
+
required: true,
|
|
289
|
+
minLength: 5,
|
|
290
|
+
maxLength: 200,
|
|
291
|
+
},
|
|
292
|
+
content: {
|
|
293
|
+
type: 'string',
|
|
294
|
+
required: true,
|
|
295
|
+
minLength: 10,
|
|
296
|
+
},
|
|
297
|
+
author_id: {
|
|
298
|
+
type: 'string',
|
|
299
|
+
required: true,
|
|
300
|
+
},
|
|
301
|
+
published: {
|
|
302
|
+
type: 'boolean',
|
|
303
|
+
},
|
|
304
|
+
tags: {
|
|
305
|
+
type: 'array',
|
|
306
|
+
},
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// Create post
|
|
310
|
+
await Post.create({
|
|
311
|
+
id: 'post:1',
|
|
312
|
+
title: 'Getting Started with TORM',
|
|
313
|
+
content: 'TORM is an amazing ORM for ToonStore...',
|
|
314
|
+
author_id: 'user:1',
|
|
315
|
+
published: true,
|
|
316
|
+
tags: ['orm', 'database', 'toonstore'],
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// Find published posts
|
|
320
|
+
const published = await Post.query()
|
|
321
|
+
.filter('published', 'eq', true)
|
|
322
|
+
.sort('created_at', 'desc')
|
|
323
|
+
.limit(10)
|
|
324
|
+
.exec();
|
|
325
|
+
|
|
326
|
+
// Find posts by author
|
|
327
|
+
const authorPosts = await Post.query()
|
|
328
|
+
.filter('author_id', 'eq', 'user:1')
|
|
329
|
+
.exec();
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Example 3: E-Commerce Products
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
interface Product {
|
|
336
|
+
id: string;
|
|
337
|
+
name: string;
|
|
338
|
+
price: number;
|
|
339
|
+
stock: number;
|
|
340
|
+
sku: string;
|
|
341
|
+
category: string;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const Product = torm.model<Product>('Product', {
|
|
345
|
+
name: {
|
|
346
|
+
type: 'string',
|
|
347
|
+
required: true,
|
|
348
|
+
},
|
|
349
|
+
price: {
|
|
350
|
+
type: 'number',
|
|
351
|
+
required: true,
|
|
352
|
+
min: 0,
|
|
353
|
+
},
|
|
354
|
+
stock: {
|
|
355
|
+
type: 'number',
|
|
356
|
+
required: true,
|
|
357
|
+
min: 0,
|
|
358
|
+
},
|
|
359
|
+
sku: {
|
|
360
|
+
type: 'string',
|
|
361
|
+
required: true,
|
|
362
|
+
pattern: /^[A-Z]{3}-\d{5}$/,
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
// Create product
|
|
367
|
+
await Product.create({
|
|
368
|
+
id: 'product:1',
|
|
369
|
+
name: 'Laptop',
|
|
370
|
+
price: 999.99,
|
|
371
|
+
stock: 50,
|
|
372
|
+
sku: 'LAP-12345',
|
|
373
|
+
category: 'electronics',
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// Find products in stock
|
|
377
|
+
const inStock = await Product.query()
|
|
378
|
+
.filter('stock', 'gt', 0)
|
|
379
|
+
.sort('price', 'asc')
|
|
380
|
+
.exec();
|
|
381
|
+
|
|
382
|
+
// Find expensive products
|
|
383
|
+
const expensive = await Product.query()
|
|
384
|
+
.filter('price', 'gte', 1000)
|
|
385
|
+
.exec();
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
## 🧪 Running Examples
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
# Install dependencies
|
|
392
|
+
npm install
|
|
393
|
+
|
|
394
|
+
# Build TypeScript
|
|
395
|
+
npm run build
|
|
396
|
+
|
|
397
|
+
# Run basic example
|
|
398
|
+
npm run example
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
## 🛠️ Development
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
# Install dependencies
|
|
405
|
+
npm install
|
|
406
|
+
|
|
407
|
+
# Build TypeScript
|
|
408
|
+
npm run build
|
|
409
|
+
|
|
410
|
+
# Watch mode (auto-rebuild)
|
|
411
|
+
npm run dev
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
## 📄 License
|
|
415
|
+
|
|
416
|
+
MIT
|
|
417
|
+
|
|
418
|
+
## 🙏 Credits
|
|
419
|
+
|
|
420
|
+
- Inspired by [Mongoose](https://mongoosejs.com/)
|
|
421
|
+
- Built for [ToonStore](https://github.com/toon-format/toon)
|
package/check.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
echo "🔧 Formatting, linting, and building Node.js SDK..."
|
|
5
|
+
|
|
6
|
+
# Format with prettier
|
|
7
|
+
echo "📝 Formatting with prettier..."
|
|
8
|
+
npm run format
|
|
9
|
+
|
|
10
|
+
# Lint with ESLint
|
|
11
|
+
echo "🔍 Linting with ESLint..."
|
|
12
|
+
npm run lint
|
|
13
|
+
|
|
14
|
+
# Build with TypeScript
|
|
15
|
+
echo "🏗️ Building with TypeScript..."
|
|
16
|
+
npm run build
|
|
17
|
+
|
|
18
|
+
# Run tests
|
|
19
|
+
echo "🧪 Running tests..."
|
|
20
|
+
npm test
|
|
21
|
+
|
|
22
|
+
echo "✅ All checks passed!"
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @toonstore/torm - ToonStore ORM Client for Node.js
|
|
3
|
+
*
|
|
4
|
+
* A Mongoose-style ORM client for ToonStore
|
|
5
|
+
*/
|
|
6
|
+
import { AxiosInstance } from 'axios';
|
|
7
|
+
export interface TormClientOptions {
|
|
8
|
+
baseURL?: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface QueryFilter {
|
|
12
|
+
field: string;
|
|
13
|
+
operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'in' | 'not_in';
|
|
14
|
+
value: any;
|
|
15
|
+
}
|
|
16
|
+
export interface QueryOptions {
|
|
17
|
+
filters?: QueryFilter[];
|
|
18
|
+
sort?: {
|
|
19
|
+
field: string;
|
|
20
|
+
order: 'asc' | 'desc';
|
|
21
|
+
};
|
|
22
|
+
limit?: number;
|
|
23
|
+
skip?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ValidationRule {
|
|
26
|
+
type?: 'string' | 'number' | 'boolean' | 'object' | 'array';
|
|
27
|
+
required?: boolean;
|
|
28
|
+
min?: number;
|
|
29
|
+
max?: number;
|
|
30
|
+
minLength?: number;
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
pattern?: RegExp;
|
|
33
|
+
email?: boolean;
|
|
34
|
+
url?: boolean;
|
|
35
|
+
validate?: (value: any) => boolean | Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
export interface ModelSchema {
|
|
38
|
+
[key: string]: ValidationRule;
|
|
39
|
+
}
|
|
40
|
+
export interface ModelOptions {
|
|
41
|
+
collection?: string;
|
|
42
|
+
validate?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare class TormClient {
|
|
45
|
+
private client;
|
|
46
|
+
private baseURL;
|
|
47
|
+
constructor(options?: TormClientOptions);
|
|
48
|
+
/**
|
|
49
|
+
* Create a new model class
|
|
50
|
+
*/
|
|
51
|
+
model<T extends Record<string, any>>(name: string, schema?: ModelSchema, options?: ModelOptions): Model<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Get HTTP client instance
|
|
54
|
+
*/
|
|
55
|
+
getClient(): AxiosInstance;
|
|
56
|
+
/**
|
|
57
|
+
* Check server health
|
|
58
|
+
*/
|
|
59
|
+
health(): Promise<{
|
|
60
|
+
status: string;
|
|
61
|
+
database?: string;
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Get server info
|
|
65
|
+
*/
|
|
66
|
+
info(): Promise<any>;
|
|
67
|
+
}
|
|
68
|
+
export declare class Model<T extends Record<string, any>> {
|
|
69
|
+
private client;
|
|
70
|
+
private collectionName;
|
|
71
|
+
private schema?;
|
|
72
|
+
private options;
|
|
73
|
+
constructor(client: TormClient, name: string, schema?: ModelSchema, options?: ModelOptions);
|
|
74
|
+
/**
|
|
75
|
+
* Create a new document
|
|
76
|
+
*/
|
|
77
|
+
create(data: Partial<T>): Promise<T>;
|
|
78
|
+
/**
|
|
79
|
+
* Find all documents
|
|
80
|
+
*/
|
|
81
|
+
find(): Promise<T[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Find document by ID
|
|
84
|
+
*/
|
|
85
|
+
findById(id: string): Promise<T | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Update document by ID
|
|
88
|
+
*/
|
|
89
|
+
update(id: string, data: Partial<T>): Promise<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Delete document by ID
|
|
92
|
+
*/
|
|
93
|
+
delete(id: string): Promise<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Count documents
|
|
96
|
+
*/
|
|
97
|
+
count(): Promise<number>;
|
|
98
|
+
/**
|
|
99
|
+
* Query documents with filters
|
|
100
|
+
*/
|
|
101
|
+
query(): QueryBuilder<T>;
|
|
102
|
+
/**
|
|
103
|
+
* Validate data against schema
|
|
104
|
+
*/
|
|
105
|
+
private validate;
|
|
106
|
+
private isEmail;
|
|
107
|
+
private isURL;
|
|
108
|
+
}
|
|
109
|
+
export declare class QueryBuilder<T> {
|
|
110
|
+
private client;
|
|
111
|
+
private collectionName;
|
|
112
|
+
private filters;
|
|
113
|
+
private sortField?;
|
|
114
|
+
private sortOrder?;
|
|
115
|
+
private limitValue?;
|
|
116
|
+
private skipValue?;
|
|
117
|
+
constructor(client: TormClient, collectionName: string);
|
|
118
|
+
/**
|
|
119
|
+
* Add a filter
|
|
120
|
+
*/
|
|
121
|
+
filter(field: string, operator: QueryFilter['operator'], value: any): QueryBuilder<T>;
|
|
122
|
+
/**
|
|
123
|
+
* Filter where field equals value
|
|
124
|
+
*/
|
|
125
|
+
where(field: string, value: any): QueryBuilder<T>;
|
|
126
|
+
/**
|
|
127
|
+
* Sort results
|
|
128
|
+
*/
|
|
129
|
+
sort(field: string, order?: 'asc' | 'desc'): QueryBuilder<T>;
|
|
130
|
+
/**
|
|
131
|
+
* Limit results
|
|
132
|
+
*/
|
|
133
|
+
limit(n: number): QueryBuilder<T>;
|
|
134
|
+
/**
|
|
135
|
+
* Skip results
|
|
136
|
+
*/
|
|
137
|
+
skip(n: number): QueryBuilder<T>;
|
|
138
|
+
/**
|
|
139
|
+
* Execute query
|
|
140
|
+
*/
|
|
141
|
+
exec(): Promise<T[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Count matching documents
|
|
144
|
+
*/
|
|
145
|
+
count(): Promise<number>;
|
|
146
|
+
private matchesFilter;
|
|
147
|
+
}
|
|
148
|
+
export default TormClient;
|
|
149
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAM7C,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,UAAU,GAAG,IAAI,GAAG,QAAQ,CAAC;IACnF,KAAK,EAAE,GAAG,CAAC;CACZ;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAAA;KAAE,CAAC;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE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AKtD;;OAEG;IACH,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,EACjC,KAAK,EAAE,GAAG,GACT,YAAY,CAAC,CAAC,CAAC;IAKlB;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,YAAY,CAAC,CAAC,CAAC;IAIjD;;OAEG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,KAAK,GAAG,MAAc,GAAG,YAAY,CAAC,CAAC,CAAC;IAMnE;;OAEG;IACH,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC;IAKjC;;OAEG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC;IAKhC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC;IA8C1B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAK9B,OAAO,CAAC,aAAa;CAwBtB;AAMD,eAAe,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @toonstore/torm - ToonStore ORM Client for Node.js
|
|
4
|
+
*
|
|
5
|
+
* A Mongoose-style ORM client for ToonStore
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.QueryBuilder = exports.Model = exports.TormClient = void 0;
|
|
12
|
+
const axios_1 = __importDefault(require("axios"));
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// TormClient
|
|
15
|
+
// ============================================================================
|
|
16
|
+
class TormClient {
|
|
17
|
+
constructor(options = {}) {
|
|
18
|
+
this.baseURL = options.baseURL || 'http://localhost:3001';
|
|
19
|
+
this.client = axios_1.default.create({
|
|
20
|
+
baseURL: this.baseURL,
|
|
21
|
+
timeout: options.timeout || 5000,
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a new model class
|
|
29
|
+
*/
|
|
30
|
+
model(name, schema, options) {
|
|
31
|
+
return new Model(this, name, schema, options);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get HTTP client instance
|
|
35
|
+
*/
|
|
36
|
+
getClient() {
|
|
37
|
+
return this.client;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check server health
|
|
41
|
+
*/
|
|
42
|
+
async health() {
|
|
43
|
+
const response = await this.client.get('/health');
|
|
44
|
+
return response.data;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get server info
|
|
48
|
+
*/
|
|
49
|
+
async info() {
|
|
50
|
+
const response = await this.client.get('/');
|
|
51
|
+
return response.data;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.TormClient = TormClient;
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Model
|
|
57
|
+
// ============================================================================
|
|
58
|
+
class Model {
|
|
59
|
+
constructor(client, name, schema, options) {
|
|
60
|
+
this.client = client;
|
|
61
|
+
this.collectionName = options?.collection || name.toLowerCase();
|
|
62
|
+
this.schema = schema;
|
|
63
|
+
this.options = { validate: true, ...options };
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Create a new document
|
|
67
|
+
*/
|
|
68
|
+
async create(data) {
|
|
69
|
+
if (this.options.validate && this.schema) {
|
|
70
|
+
this.validate(data);
|
|
71
|
+
}
|
|
72
|
+
const response = await this.client.getClient().post(`/api/${this.collectionName}`, { data });
|
|
73
|
+
return response.data.data;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Find all documents
|
|
77
|
+
*/
|
|
78
|
+
async find() {
|
|
79
|
+
const response = await this.client.getClient().get(`/api/${this.collectionName}`);
|
|
80
|
+
return response.data.documents;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Find document by ID
|
|
84
|
+
*/
|
|
85
|
+
async findById(id) {
|
|
86
|
+
try {
|
|
87
|
+
const response = await this.client.getClient().get(`/api/${this.collectionName}/${id}`);
|
|
88
|
+
return response.data;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (error.response?.status === 404) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Update document by ID
|
|
99
|
+
*/
|
|
100
|
+
async update(id, data) {
|
|
101
|
+
if (this.options.validate && this.schema) {
|
|
102
|
+
this.validate(data);
|
|
103
|
+
}
|
|
104
|
+
const response = await this.client.getClient().put(`/api/${this.collectionName}/${id}`, { data });
|
|
105
|
+
return response.data.data;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Delete document by ID
|
|
109
|
+
*/
|
|
110
|
+
async delete(id) {
|
|
111
|
+
const response = await this.client.getClient().delete(`/api/${this.collectionName}/${id}`);
|
|
112
|
+
return response.data.success === true;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Count documents
|
|
116
|
+
*/
|
|
117
|
+
async count() {
|
|
118
|
+
const response = await this.client.getClient().get(`/api/${this.collectionName}/count`);
|
|
119
|
+
return response.data.count;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Query documents with filters
|
|
123
|
+
*/
|
|
124
|
+
query() {
|
|
125
|
+
return new QueryBuilder(this.client, this.collectionName);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Validate data against schema
|
|
129
|
+
*/
|
|
130
|
+
validate(data) {
|
|
131
|
+
if (!this.schema)
|
|
132
|
+
return;
|
|
133
|
+
for (const [field, rules] of Object.entries(this.schema)) {
|
|
134
|
+
const value = data[field];
|
|
135
|
+
// Required check
|
|
136
|
+
if (rules.required && (value === undefined || value === null)) {
|
|
137
|
+
throw new Error(`Validation error: Field '${field}' is required`);
|
|
138
|
+
}
|
|
139
|
+
// Skip validation if value is undefined/null and not required
|
|
140
|
+
if (value === undefined || value === null)
|
|
141
|
+
continue;
|
|
142
|
+
// Type check
|
|
143
|
+
if (rules.type) {
|
|
144
|
+
const actualType = Array.isArray(value) ? 'array' : typeof value;
|
|
145
|
+
if (actualType !== rules.type) {
|
|
146
|
+
throw new Error(`Validation error: Field '${field}' must be of type ${rules.type}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// String validations
|
|
150
|
+
if (typeof value === 'string') {
|
|
151
|
+
if (rules.minLength !== undefined && value.length < rules.minLength) {
|
|
152
|
+
throw new Error(`Validation error: Field '${field}' must be at least ${rules.minLength} characters`);
|
|
153
|
+
}
|
|
154
|
+
if (rules.maxLength !== undefined && value.length > rules.maxLength) {
|
|
155
|
+
throw new Error(`Validation error: Field '${field}' must be at most ${rules.maxLength} characters`);
|
|
156
|
+
}
|
|
157
|
+
if (rules.pattern && !rules.pattern.test(value)) {
|
|
158
|
+
throw new Error(`Validation error: Field '${field}' does not match pattern`);
|
|
159
|
+
}
|
|
160
|
+
if (rules.email && !this.isEmail(value)) {
|
|
161
|
+
throw new Error(`Validation error: Field '${field}' must be a valid email`);
|
|
162
|
+
}
|
|
163
|
+
if (rules.url && !this.isURL(value)) {
|
|
164
|
+
throw new Error(`Validation error: Field '${field}' must be a valid URL`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
// Number validations
|
|
168
|
+
if (typeof value === 'number') {
|
|
169
|
+
if (rules.min !== undefined && value < rules.min) {
|
|
170
|
+
throw new Error(`Validation error: Field '${field}' must be at least ${rules.min}`);
|
|
171
|
+
}
|
|
172
|
+
if (rules.max !== undefined && value > rules.max) {
|
|
173
|
+
throw new Error(`Validation error: Field '${field}' must be at most ${rules.max}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// Custom validation
|
|
177
|
+
if (rules.validate && !rules.validate(value)) {
|
|
178
|
+
throw new Error(`Validation error: Field '${field}' failed custom validation`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
isEmail(value) {
|
|
183
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
184
|
+
}
|
|
185
|
+
isURL(value) {
|
|
186
|
+
return /^https?:\/\/.+/.test(value);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.Model = Model;
|
|
190
|
+
// ============================================================================
|
|
191
|
+
// QueryBuilder
|
|
192
|
+
// ============================================================================
|
|
193
|
+
class QueryBuilder {
|
|
194
|
+
constructor(client, collectionName) {
|
|
195
|
+
this.filters = [];
|
|
196
|
+
this.client = client;
|
|
197
|
+
this.collectionName = collectionName;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Add a filter
|
|
201
|
+
*/
|
|
202
|
+
filter(field, operator, value) {
|
|
203
|
+
this.filters.push({ field, operator, value });
|
|
204
|
+
return this;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Filter where field equals value
|
|
208
|
+
*/
|
|
209
|
+
where(field, value) {
|
|
210
|
+
return this.filter(field, 'eq', value);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Sort results
|
|
214
|
+
*/
|
|
215
|
+
sort(field, order = 'asc') {
|
|
216
|
+
this.sortField = field;
|
|
217
|
+
this.sortOrder = order;
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Limit results
|
|
222
|
+
*/
|
|
223
|
+
limit(n) {
|
|
224
|
+
this.limitValue = n;
|
|
225
|
+
return this;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Skip results
|
|
229
|
+
*/
|
|
230
|
+
skip(n) {
|
|
231
|
+
this.skipValue = n;
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Execute query
|
|
236
|
+
*/
|
|
237
|
+
async exec() {
|
|
238
|
+
const queryOptions = {};
|
|
239
|
+
if (this.filters.length > 0) {
|
|
240
|
+
queryOptions.filters = this.filters;
|
|
241
|
+
}
|
|
242
|
+
if (this.sortField) {
|
|
243
|
+
queryOptions.sort = { field: this.sortField, order: this.sortOrder };
|
|
244
|
+
}
|
|
245
|
+
if (this.limitValue !== undefined) {
|
|
246
|
+
queryOptions.limit = this.limitValue;
|
|
247
|
+
}
|
|
248
|
+
if (this.skipValue !== undefined) {
|
|
249
|
+
queryOptions.skip = this.skipValue;
|
|
250
|
+
}
|
|
251
|
+
const response = await this.client.getClient().post(`/api/${this.collectionName}/query`, queryOptions);
|
|
252
|
+
let documents = response.data.documents;
|
|
253
|
+
// Apply client-side filtering (since server returns all for now)
|
|
254
|
+
if (this.filters.length > 0) {
|
|
255
|
+
documents = documents.filter((doc) => {
|
|
256
|
+
return this.filters.every((filter) => {
|
|
257
|
+
const value = doc[filter.field];
|
|
258
|
+
return this.matchesFilter(value, filter.operator, filter.value);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
// Apply client-side sorting
|
|
263
|
+
if (this.sortField) {
|
|
264
|
+
documents.sort((a, b) => {
|
|
265
|
+
const aVal = a[this.sortField];
|
|
266
|
+
const bVal = b[this.sortField];
|
|
267
|
+
const comparison = aVal > bVal ? 1 : aVal < bVal ? -1 : 0;
|
|
268
|
+
return this.sortOrder === 'desc' ? -comparison : comparison;
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return documents;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Count matching documents
|
|
275
|
+
*/
|
|
276
|
+
async count() {
|
|
277
|
+
const documents = await this.exec();
|
|
278
|
+
return documents.length;
|
|
279
|
+
}
|
|
280
|
+
matchesFilter(value, operator, filterValue) {
|
|
281
|
+
switch (operator) {
|
|
282
|
+
case 'eq':
|
|
283
|
+
return value === filterValue;
|
|
284
|
+
case 'ne':
|
|
285
|
+
return value !== filterValue;
|
|
286
|
+
case 'gt':
|
|
287
|
+
return value > filterValue;
|
|
288
|
+
case 'gte':
|
|
289
|
+
return value >= filterValue;
|
|
290
|
+
case 'lt':
|
|
291
|
+
return value < filterValue;
|
|
292
|
+
case 'lte':
|
|
293
|
+
return value <= filterValue;
|
|
294
|
+
case 'contains':
|
|
295
|
+
return String(value).includes(String(filterValue));
|
|
296
|
+
case 'in':
|
|
297
|
+
return Array.isArray(filterValue) && filterValue.includes(value);
|
|
298
|
+
case 'not_in':
|
|
299
|
+
return Array.isArray(filterValue) && !filterValue.includes(value);
|
|
300
|
+
default:
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
exports.QueryBuilder = QueryBuilder;
|
|
306
|
+
// ============================================================================
|
|
307
|
+
// Exports
|
|
308
|
+
// ============================================================================
|
|
309
|
+
exports.default = TormClient;
|
|
310
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,kDAA6C;AA8C7C,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,MAAa,UAAU;IAIrB,YAAY,UAA6B,EAAE;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,uBAAuB,CAAC;QAC1D,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,IAAI;YAChC,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,KAAK,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;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACpC,OAAO,SAAS,CAAC,MAAM,CAAC;IAC1B,CAAC;IAEO,aAAa,CAAC,KAAU,EAAE,QAAgB,EAAE,WAAgB;QAClE,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,IAAI;gBACP,OAAO,KAAK,KAAK,WAAW,CAAC;YAC/B,KAAK,IAAI;gBACP,OAAO,KAAK,KAAK,WAAW,CAAC;YAC/B,KAAK,IAAI;gBACP,OAAO,KAAK,GAAG,WAAW,CAAC;YAC7B,KAAK,KAAK;gBACR,OAAO,KAAK,IAAI,WAAW,CAAC;YAC9B,KAAK,IAAI;gBACP,OAAO,KAAK,GAAG,WAAW,CAAC;YAC7B,KAAK,KAAK;gBACR,OAAO,KAAK,IAAI,WAAW,CAAC;YAC9B,KAAK,UAAU;gBACb,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;YACrD,KAAK,IAAI;gBACP,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACnE,KAAK,QAAQ;gBACX,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACpE;gBACE,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;CACF;AA3ID,oCA2IC;AAED,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,kBAAe,UAAU,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@toonstore/torm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "ToonStore ORM client for Node.js",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"example": "node examples/basic-usage.js",
|
|
11
|
+
"test": "echo \"No tests yet\" && exit 0"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"toonstore",
|
|
15
|
+
"orm",
|
|
16
|
+
"database",
|
|
17
|
+
"redis",
|
|
18
|
+
"toon"
|
|
19
|
+
],
|
|
20
|
+
"author": "ToonStore Team",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"axios": "^1.6.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^20.10.0",
|
|
27
|
+
"typescript": "^5.3.0"
|
|
28
|
+
}
|
|
29
|
+
}
|