@amaster.ai/client 1.1.0-beta.7 → 1.1.0-beta.71
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 +340 -76
- package/dist/index.cjs +95 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +151 -23
- package/dist/index.d.ts +151 -23
- package/dist/index.js +97 -8
- package/dist/index.js.map +1 -1
- package/package.json +15 -11
- package/types/__tests__/type-checks.test-d.ts +163 -0
- package/types/asr.d.ts +299 -164
- package/types/auth/code-auth.d.ts +8 -157
- package/types/auth/index.d.ts +81 -96
- package/types/auth/oauth.d.ts +6 -143
- package/types/auth/password-auth.d.ts +38 -137
- package/types/auth/profile.d.ts +4 -103
- package/types/auth/user.d.ts +10 -34
- package/types/bpm.d.ts +305 -92
- package/types/common.d.ts +52 -44
- package/types/copilot.d.ts +62 -338
- package/types/entity.d.ts +65 -342
- package/types/function.d.ts +11 -88
- package/types/http.d.ts +95 -0
- package/types/index.d.ts +136 -354
- package/types/s3.d.ts +96 -0
- package/types/tts.d.ts +16 -130
- package/types/workflow.d.ts +16 -165
- package/types/auth/permissions.d.ts +0 -254
package/types/entity.d.ts
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ============================================================================
|
|
3
|
-
* Entity Module - Type Definitions
|
|
4
|
-
* ============================================================================
|
|
5
|
-
*
|
|
6
|
-
* This module provides CRUD operations for entities in the Amaster platform.
|
|
7
|
-
*
|
|
8
|
-
* ## Key Features
|
|
9
|
-
* - List entities with pagination, sorting, and filtering
|
|
10
|
-
* - Get single entity by ID
|
|
11
|
-
* - Create, update, and delete entities
|
|
12
|
-
* - Advanced filtering with AND/OR conditions
|
|
13
|
-
* - Full-text search across multiple fields
|
|
14
|
-
* - Relation loading (eager loading)
|
|
15
|
-
* - Field selection (only fetch specific fields)
|
|
16
|
-
* - Bulk operations
|
|
17
|
-
*
|
|
18
|
-
* ## Filter Operators
|
|
19
|
-
* - `eq` (default): Equal
|
|
20
|
-
* - `ne`: Not equal
|
|
21
|
-
* - `gt`: Greater than
|
|
22
|
-
* - `ge`: Greater or equal
|
|
23
|
-
* - `lt`: Less than
|
|
24
|
-
* - `le`: Less or equal
|
|
25
|
-
* - `like`: Fuzzy match (auto wraps with %)
|
|
26
|
-
* - `sw`: Starts with
|
|
27
|
-
* - `ew`: Ends with
|
|
28
|
-
* - `bt`: Between (requires {from, to})
|
|
29
|
-
* - `in`: In array
|
|
30
2
|
*
|
|
31
3
|
* @module entity
|
|
32
4
|
*/
|
|
@@ -39,16 +11,7 @@ import type { ClientResult } from './common';
|
|
|
39
11
|
* Simple filter operators for query string format
|
|
40
12
|
*
|
|
41
13
|
* Usage: `{ 'field[op]': value }`
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```typescript
|
|
45
|
-
* {
|
|
46
|
-
* 'status[eq]': 'active',
|
|
47
|
-
* 'price[gt]': 100,
|
|
48
|
-
* 'name[like]': 'test',
|
|
49
|
-
* 'id[in]': [1, 2, 3]
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
14
|
+
*
|
|
52
15
|
*/
|
|
53
16
|
export type FilterOperator =
|
|
54
17
|
| 'eq' // Equal (default if no operator specified)
|
|
@@ -65,15 +28,7 @@ export type FilterOperator =
|
|
|
65
28
|
|
|
66
29
|
/**
|
|
67
30
|
* Advanced filter operators for condition builder
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* {
|
|
72
|
-
* op: 'equal',
|
|
73
|
-
* left: { field: 'status' },
|
|
74
|
-
* right: 'active'
|
|
75
|
-
* }
|
|
76
|
-
* ```
|
|
31
|
+
*
|
|
77
32
|
*/
|
|
78
33
|
export type AdvancedFilterOperator =
|
|
79
34
|
| 'equal'
|
|
@@ -94,26 +49,7 @@ export type AdvancedFilterOperator =
|
|
|
94
49
|
|
|
95
50
|
/**
|
|
96
51
|
* Advanced filter item (single condition)
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* Single condition:
|
|
100
|
-
* ```typescript
|
|
101
|
-
* {
|
|
102
|
-
* op: 'equal',
|
|
103
|
-
* left: { field: 'status' },
|
|
104
|
-
* right: 'active'
|
|
105
|
-
* }
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* Relation field:
|
|
110
|
-
* ```typescript
|
|
111
|
-
* {
|
|
112
|
-
* op: 'equal',
|
|
113
|
-
* left: { field: 'user.email' },
|
|
114
|
-
* right: 'test@example.com'
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
52
|
+
*
|
|
117
53
|
*/
|
|
118
54
|
export interface FilterItem {
|
|
119
55
|
op: AdvancedFilterOperator;
|
|
@@ -126,35 +62,7 @@ export interface FilterItem {
|
|
|
126
62
|
|
|
127
63
|
/**
|
|
128
64
|
* Advanced filter group (supports AND/OR with nesting)
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* (status = 'active') AND (priority > 5 OR assignee IS NOT NULL):
|
|
132
|
-
* ```typescript
|
|
133
|
-
* {
|
|
134
|
-
* conjunction: 'and',
|
|
135
|
-
* children: [
|
|
136
|
-
* {
|
|
137
|
-
* op: 'equal',
|
|
138
|
-
* left: { field: 'status' },
|
|
139
|
-
* right: 'active'
|
|
140
|
-
* },
|
|
141
|
-
* {
|
|
142
|
-
* conjunction: 'or',
|
|
143
|
-
* children: [
|
|
144
|
-
* {
|
|
145
|
-
* op: 'greater',
|
|
146
|
-
* left: { field: 'priority' },
|
|
147
|
-
* right: 5
|
|
148
|
-
* },
|
|
149
|
-
* {
|
|
150
|
-
* op: 'is_not_empty',
|
|
151
|
-
* left: { field: 'assignee' }
|
|
152
|
-
* }
|
|
153
|
-
* ]
|
|
154
|
-
* }
|
|
155
|
-
* ]
|
|
156
|
-
* }
|
|
157
|
-
* ```
|
|
65
|
+
*
|
|
158
66
|
*/
|
|
159
67
|
export interface FilterGroup {
|
|
160
68
|
conjunction: 'and' | 'or';
|
|
@@ -163,15 +71,7 @@ export interface FilterGroup {
|
|
|
163
71
|
|
|
164
72
|
/**
|
|
165
73
|
* Keywords search configuration
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
* Search in specific fields:
|
|
169
|
-
* ```typescript
|
|
170
|
-
* {
|
|
171
|
-
* fields: ['name', 'description'],
|
|
172
|
-
* value: 'search term'
|
|
173
|
-
* }
|
|
174
|
-
* ```
|
|
74
|
+
*
|
|
175
75
|
*/
|
|
176
76
|
export interface KeywordsSearch {
|
|
177
77
|
/** Fields to search in */
|
|
@@ -182,16 +82,7 @@ export interface KeywordsSearch {
|
|
|
182
82
|
|
|
183
83
|
/**
|
|
184
84
|
* Between filter value
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```typescript
|
|
188
|
-
* {
|
|
189
|
-
* 'created_at[bt]': {
|
|
190
|
-
* from: '2024-01-01',
|
|
191
|
-
* to: '2024-12-31'
|
|
192
|
-
* }
|
|
193
|
-
* }
|
|
194
|
-
* ```
|
|
85
|
+
*
|
|
195
86
|
*/
|
|
196
87
|
export interface BetweenValue {
|
|
197
88
|
from?: string | number | Date;
|
|
@@ -204,67 +95,7 @@ export interface BetweenValue {
|
|
|
204
95
|
* Entity query parameters
|
|
205
96
|
*
|
|
206
97
|
* Supports pagination, sorting, filtering, searching, and relation loading.
|
|
207
|
-
*
|
|
208
|
-
* @example
|
|
209
|
-
* Basic pagination and sorting:
|
|
210
|
-
* ```typescript
|
|
211
|
-
* {
|
|
212
|
-
* page: 1,
|
|
213
|
-
* perPage: 20,
|
|
214
|
-
* orderBy: 'created_at',
|
|
215
|
-
* orderDir: 'desc'
|
|
216
|
-
* }
|
|
217
|
-
* ```
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* Simple field filter:
|
|
221
|
-
* ```typescript
|
|
222
|
-
* {
|
|
223
|
-
* status: 'active',
|
|
224
|
-
* 'price[gt]': 100,
|
|
225
|
-
* 'name[like]': 'test'
|
|
226
|
-
* }
|
|
227
|
-
* ```
|
|
228
|
-
*
|
|
229
|
-
* @example
|
|
230
|
-
* Keywords search:
|
|
231
|
-
* ```typescript
|
|
232
|
-
* {
|
|
233
|
-
* __keywords: {
|
|
234
|
-
* fields: ['name', 'description'],
|
|
235
|
-
* value: 'search term'
|
|
236
|
-
* }
|
|
237
|
-
* }
|
|
238
|
-
* ```
|
|
239
|
-
*
|
|
240
|
-
* @example
|
|
241
|
-
* Load relations and select fields:
|
|
242
|
-
* ```typescript
|
|
243
|
-
* {
|
|
244
|
-
* __relations: ['user', 'category'],
|
|
245
|
-
* __fields: ['id', 'name', 'status', 'user.email']
|
|
246
|
-
* }
|
|
247
|
-
* ```
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* Advanced filter with AND/OR:
|
|
251
|
-
* ```typescript
|
|
252
|
-
* {
|
|
253
|
-
* __filter: {
|
|
254
|
-
* conjunction: 'and',
|
|
255
|
-
* children: [
|
|
256
|
-
* { op: 'equal', left: { field: 'status' }, right: 'active' },
|
|
257
|
-
* {
|
|
258
|
-
* conjunction: 'or',
|
|
259
|
-
* children: [
|
|
260
|
-
* { op: 'greater', left: { field: 'priority' }, right: 5 },
|
|
261
|
-
* { op: 'is_not_empty', left: { field: 'assignee' } }
|
|
262
|
-
* ]
|
|
263
|
-
* }
|
|
264
|
-
* ]
|
|
265
|
-
* }
|
|
266
|
-
* }
|
|
267
|
-
* ```
|
|
98
|
+
*
|
|
268
99
|
*/
|
|
269
100
|
export interface EntityQueryParams {
|
|
270
101
|
// ==================== Pagination ====================
|
|
@@ -295,7 +126,6 @@ export interface EntityQueryParams {
|
|
|
295
126
|
|
|
296
127
|
/**
|
|
297
128
|
* Field to sort by
|
|
298
|
-
* @example 'created_at'
|
|
299
129
|
*/
|
|
300
130
|
orderBy?: string;
|
|
301
131
|
|
|
@@ -308,7 +138,6 @@ export interface EntityQueryParams {
|
|
|
308
138
|
/**
|
|
309
139
|
* Multiple sort orders (comma-separated)
|
|
310
140
|
* Format: "field1:asc,field2:desc"
|
|
311
|
-
* @example 'priority:desc,created_at:asc'
|
|
312
141
|
*/
|
|
313
142
|
__orders?: string;
|
|
314
143
|
|
|
@@ -318,9 +147,7 @@ export interface EntityQueryParams {
|
|
|
318
147
|
* Keywords search
|
|
319
148
|
* - String: search all searchable fields (backend determines)
|
|
320
149
|
* - Object: search specific fields
|
|
321
|
-
*
|
|
322
|
-
* @example '__keywords=search'
|
|
323
|
-
* @example { __keywords: { fields: ['name', 'description'], value: 'keyword' } }
|
|
150
|
+
*
|
|
324
151
|
*/
|
|
325
152
|
__keywords?: string | KeywordsSearch;
|
|
326
153
|
|
|
@@ -328,13 +155,11 @@ export interface EntityQueryParams {
|
|
|
328
155
|
|
|
329
156
|
/**
|
|
330
157
|
* Relations to load (eager loading)
|
|
331
|
-
* @example ['user', 'category', 'tags']
|
|
332
158
|
*/
|
|
333
159
|
__relations?: string[];
|
|
334
160
|
|
|
335
161
|
/**
|
|
336
162
|
* Fields to select (only return these fields)
|
|
337
|
-
* @example ['id', 'name', 'status', 'user.email']
|
|
338
163
|
*/
|
|
339
164
|
__fields?: string[];
|
|
340
165
|
|
|
@@ -342,13 +167,11 @@ export interface EntityQueryParams {
|
|
|
342
167
|
|
|
343
168
|
/**
|
|
344
169
|
* Advanced filter (condition builder with AND/OR)
|
|
345
|
-
* @example { conjunction: 'and', children: [...] }
|
|
346
170
|
*/
|
|
347
171
|
__filter?: FilterGroup;
|
|
348
172
|
|
|
349
173
|
/**
|
|
350
174
|
* Simple filters using field=value or field[op]=value
|
|
351
|
-
* @example { status: 'active', 'price[gt]': 100 }
|
|
352
175
|
*/
|
|
353
176
|
[key: string]: unknown;
|
|
354
177
|
}
|
|
@@ -359,19 +182,7 @@ export interface EntityQueryParams {
|
|
|
359
182
|
* Entity list response
|
|
360
183
|
*
|
|
361
184
|
* @template T - The entity type
|
|
362
|
-
*
|
|
363
|
-
* @example
|
|
364
|
-
* ```typescript
|
|
365
|
-
* interface User {
|
|
366
|
-
* id: number;
|
|
367
|
-
* name: string;
|
|
368
|
-
* email: string;
|
|
369
|
-
* }
|
|
370
|
-
*
|
|
371
|
-
* const result = await client.entity.list<User>('default', 'users');
|
|
372
|
-
* const users: User[] = result.data.items;
|
|
373
|
-
* const total: number = result.data.total;
|
|
374
|
-
* ```
|
|
185
|
+
*
|
|
375
186
|
*/
|
|
376
187
|
export interface EntityListResponse<T = Record<string, unknown>> {
|
|
377
188
|
/** Array of entities */
|
|
@@ -391,36 +202,7 @@ export interface EntityListResponse<T = Record<string, unknown>> {
|
|
|
391
202
|
*
|
|
392
203
|
* Provides methods for creating, reading, updating, and deleting entities.
|
|
393
204
|
*
|
|
394
|
-
* @
|
|
395
|
-
* Complete CRUD operations:
|
|
396
|
-
* ```typescript
|
|
397
|
-
* const client = createClient({ baseURL: 'https://api.amaster.ai' });
|
|
398
|
-
*
|
|
399
|
-
* // 1. List entities
|
|
400
|
-
* const list = await client.entity.list('default', 'users', {
|
|
401
|
-
* page: 1,
|
|
402
|
-
* perPage: 20,
|
|
403
|
-
* orderBy: 'createdAt',
|
|
404
|
-
* orderDir: 'desc'
|
|
405
|
-
* });
|
|
406
|
-
*
|
|
407
|
-
* // 2. Get single entity
|
|
408
|
-
* const user = await client.entity.get('default', 'users', 1);
|
|
409
|
-
*
|
|
410
|
-
* // 3. Create entity
|
|
411
|
-
* const newUser = await client.entity.create('default', 'users', {
|
|
412
|
-
* name: 'John Doe',
|
|
413
|
-
* email: 'john@example.com'
|
|
414
|
-
* });
|
|
415
|
-
*
|
|
416
|
-
* // 4. Update entity
|
|
417
|
-
* const updated = await client.entity.update('default', 'users', 1, {
|
|
418
|
-
* name: 'Jane Doe'
|
|
419
|
-
* });
|
|
420
|
-
*
|
|
421
|
-
* // 5. Delete entity
|
|
422
|
-
* await client.entity.delete('default', 'users', 1);
|
|
423
|
-
* ```
|
|
205
|
+
* @since 1.0.0
|
|
424
206
|
*/
|
|
425
207
|
export interface EntityClientAPI {
|
|
426
208
|
/**
|
|
@@ -433,53 +215,39 @@ export interface EntityClientAPI {
|
|
|
433
215
|
* @returns List of entities with pagination info
|
|
434
216
|
*
|
|
435
217
|
* @example
|
|
436
|
-
* Basic
|
|
437
|
-
* ```typescript
|
|
218
|
+
* // Basic usage
|
|
438
219
|
* const result = await client.entity.list('default', 'users');
|
|
439
|
-
* console.log(result.data.items);
|
|
440
|
-
* console.log(result.data.total); // Total count
|
|
441
|
-
* ```
|
|
220
|
+
* console.log('Users:', result.data.items);
|
|
442
221
|
*
|
|
443
222
|
* @example
|
|
444
|
-
* With pagination
|
|
445
|
-
* ```typescript
|
|
223
|
+
* // With pagination
|
|
446
224
|
* const result = await client.entity.list('default', 'users', {
|
|
447
|
-
* page:
|
|
448
|
-
* perPage:
|
|
449
|
-
* orderBy: 'createdAt',
|
|
450
|
-
* orderDir: 'desc'
|
|
225
|
+
* page: 1,
|
|
226
|
+
* perPage: 20
|
|
451
227
|
* });
|
|
452
|
-
* ```
|
|
453
228
|
*
|
|
454
229
|
* @example
|
|
455
|
-
* With
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
* '
|
|
460
|
-
*
|
|
230
|
+
* // With filters and sorting
|
|
231
|
+
* const result = await client.entity.list('default', 'users', {
|
|
232
|
+
* page: 1,
|
|
233
|
+
* perPage: 20,
|
|
234
|
+
* orderBy: 'createdAt',
|
|
235
|
+
* orderDir: 'desc',
|
|
236
|
+
* 'status[eq]': 'active',
|
|
237
|
+
* 'age[gt]': 18
|
|
461
238
|
* });
|
|
462
|
-
* ```
|
|
463
239
|
*
|
|
464
240
|
* @example
|
|
465
|
-
* With
|
|
466
|
-
*
|
|
467
|
-
* const result = await client.entity.list('default', '
|
|
468
|
-
*
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
* }
|
|
472
|
-
* }
|
|
473
|
-
* ```
|
|
241
|
+
* // With type safety
|
|
242
|
+
* type User = { id: number; name: string; email: string };
|
|
243
|
+
* const result = await client.entity.list<User>('default', 'users');
|
|
244
|
+
* if (result.success) {
|
|
245
|
+
* result.data.items.forEach(user => {
|
|
246
|
+
* console.log(user.name); // Type-safe
|
|
247
|
+
* });
|
|
248
|
+
* }
|
|
474
249
|
*
|
|
475
|
-
* @
|
|
476
|
-
* With relations:
|
|
477
|
-
* ```typescript
|
|
478
|
-
* const result = await client.entity.list('default', 'orders', {
|
|
479
|
-
* __relations: ['user', 'items'],
|
|
480
|
-
* __fields: ['id', 'total', 'user.name', 'items.product']
|
|
481
|
-
* });
|
|
482
|
-
* ```
|
|
250
|
+
* @since 1.0.0
|
|
483
251
|
*/
|
|
484
252
|
list<T = Record<string, unknown>>(
|
|
485
253
|
source: string,
|
|
@@ -497,25 +265,17 @@ export interface EntityClientAPI {
|
|
|
497
265
|
* @returns The entity data
|
|
498
266
|
*
|
|
499
267
|
* @example
|
|
500
|
-
* ```typescript
|
|
501
268
|
* const result = await client.entity.get('default', 'users', 123);
|
|
502
|
-
* if (result.
|
|
269
|
+
* if (result.success) {
|
|
503
270
|
* console.log('User:', result.data);
|
|
504
271
|
* }
|
|
505
|
-
* ```
|
|
506
272
|
*
|
|
507
273
|
* @example
|
|
508
|
-
* With type safety
|
|
509
|
-
*
|
|
510
|
-
* interface User {
|
|
511
|
-
* id: number;
|
|
512
|
-
* name: string;
|
|
513
|
-
* email: string;
|
|
514
|
-
* }
|
|
515
|
-
*
|
|
274
|
+
* // With type safety
|
|
275
|
+
* type User = { id: number; name: string };
|
|
516
276
|
* const result = await client.entity.get<User>('default', 'users', 123);
|
|
517
|
-
*
|
|
518
|
-
*
|
|
277
|
+
*
|
|
278
|
+
* @since 1.0.0
|
|
519
279
|
*/
|
|
520
280
|
get<T = Record<string, unknown>>(
|
|
521
281
|
source: string,
|
|
@@ -533,28 +293,17 @@ export interface EntityClientAPI {
|
|
|
533
293
|
* @returns The created entity
|
|
534
294
|
*
|
|
535
295
|
* @example
|
|
536
|
-
* ```typescript
|
|
537
296
|
* const result = await client.entity.create('default', 'users', {
|
|
538
297
|
* name: 'John Doe',
|
|
539
298
|
* email: 'john@example.com',
|
|
540
|
-
*
|
|
299
|
+
* status: 'active'
|
|
541
300
|
* });
|
|
542
301
|
*
|
|
543
|
-
* if (result.
|
|
544
|
-
* console.log('Created user ID:', result.data.id);
|
|
302
|
+
* if (result.success) {
|
|
303
|
+
* console.log('Created user with ID:', result.data.id);
|
|
545
304
|
* }
|
|
546
|
-
* ```
|
|
547
305
|
*
|
|
548
|
-
* @
|
|
549
|
-
* With Date handling:
|
|
550
|
-
* ```typescript
|
|
551
|
-
* await client.entity.create('default', 'events', {
|
|
552
|
-
* title: 'Meeting',
|
|
553
|
-
* startTime: new Date('2026-02-07T10:00:00Z'),
|
|
554
|
-
* endTime: new Date('2026-02-07T11:00:00Z')
|
|
555
|
-
* });
|
|
556
|
-
* // Dates are automatically converted to backend format
|
|
557
|
-
* ```
|
|
306
|
+
* @since 1.0.0
|
|
558
307
|
*/
|
|
559
308
|
create<T = Record<string, unknown>>(
|
|
560
309
|
source: string,
|
|
@@ -573,21 +322,16 @@ export interface EntityClientAPI {
|
|
|
573
322
|
* @returns The updated entity
|
|
574
323
|
*
|
|
575
324
|
* @example
|
|
576
|
-
* ```typescript
|
|
577
325
|
* const result = await client.entity.update('default', 'users', 123, {
|
|
578
326
|
* name: 'Jane Doe',
|
|
579
|
-
*
|
|
327
|
+
* status: 'inactive'
|
|
580
328
|
* });
|
|
581
|
-
* ```
|
|
582
329
|
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
* status: 'completed'
|
|
589
|
-
* });
|
|
590
|
-
* ```
|
|
330
|
+
* if (result.success) {
|
|
331
|
+
* console.log('Updated:', result.data);
|
|
332
|
+
* }
|
|
333
|
+
*
|
|
334
|
+
* @since 1.0.0
|
|
591
335
|
*/
|
|
592
336
|
update<T = Record<string, unknown>>(
|
|
593
337
|
source: string,
|
|
@@ -605,20 +349,12 @@ export interface EntityClientAPI {
|
|
|
605
349
|
* @returns null on success
|
|
606
350
|
*
|
|
607
351
|
* @example
|
|
608
|
-
* ```typescript
|
|
609
352
|
* const result = await client.entity.delete('default', 'users', 123);
|
|
610
|
-
* if (result.
|
|
611
|
-
* console.log('User deleted
|
|
353
|
+
* if (result.success) {
|
|
354
|
+
* console.log('User deleted');
|
|
612
355
|
* }
|
|
613
|
-
* ```
|
|
614
356
|
*
|
|
615
|
-
* @
|
|
616
|
-
* With confirmation:
|
|
617
|
-
* ```typescript
|
|
618
|
-
* if (confirm('Are you sure?')) {
|
|
619
|
-
* await client.entity.delete('default', 'users', userId);
|
|
620
|
-
* }
|
|
621
|
-
* ```
|
|
357
|
+
* @since 1.0.0
|
|
622
358
|
*/
|
|
623
359
|
delete(
|
|
624
360
|
source: string,
|
|
@@ -636,19 +372,12 @@ export interface EntityClientAPI {
|
|
|
636
372
|
* @returns Array of option objects
|
|
637
373
|
*
|
|
638
374
|
* @example
|
|
639
|
-
* Get user options for dropdown:
|
|
640
|
-
* ```typescript
|
|
641
375
|
* const result = await client.entity.options('default', 'users', ['id', 'name']);
|
|
642
|
-
*
|
|
376
|
+
* if (result.success) {
|
|
377
|
+
* result.data.forEach(opt => console.log(opt.name));
|
|
378
|
+
* }
|
|
643
379
|
*
|
|
644
|
-
*
|
|
645
|
-
* result.data.forEach(user => {
|
|
646
|
-
* const option = document.createElement('option');
|
|
647
|
-
* option.value = user.id;
|
|
648
|
-
* option.text = user.name;
|
|
649
|
-
* selectElement.appendChild(option);
|
|
650
|
-
* });
|
|
651
|
-
* ```
|
|
380
|
+
* @since 1.0.0
|
|
652
381
|
*/
|
|
653
382
|
options<T = Record<string, unknown>>(
|
|
654
383
|
source: string,
|
|
@@ -666,13 +395,13 @@ export interface EntityClientAPI {
|
|
|
666
395
|
* @returns Update result
|
|
667
396
|
*
|
|
668
397
|
* @example
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
* { id:
|
|
672
|
-
* { id:
|
|
673
|
-
* { id: 3, status: 'in_progress' }
|
|
398
|
+
* const result = await client.entity.bulkUpdate('default', 'users', [
|
|
399
|
+
* { id: 1, status: 'active' },
|
|
400
|
+
* { id: 2, status: 'inactive' },
|
|
401
|
+
* { id: 3, status: 'active' }
|
|
674
402
|
* ]);
|
|
675
|
-
*
|
|
403
|
+
*
|
|
404
|
+
* @since 1.0.0
|
|
676
405
|
*/
|
|
677
406
|
bulkUpdate<T = Record<string, unknown>>(
|
|
678
407
|
source: string,
|
|
@@ -689,18 +418,12 @@ export interface EntityClientAPI {
|
|
|
689
418
|
* @returns null on success
|
|
690
419
|
*
|
|
691
420
|
* @example
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
*
|
|
696
|
-
* @example
|
|
697
|
-
* Delete selected items:
|
|
698
|
-
* ```typescript
|
|
699
|
-
* const selectedIds = [123, 456, 789];
|
|
700
|
-
* if (confirm(`Delete ${selectedIds.length} items?`)) {
|
|
701
|
-
* await client.entity.bulkDelete('default', 'items', selectedIds);
|
|
421
|
+
* const result = await client.entity.bulkDelete('default', 'users', [1, 2, 3]);
|
|
422
|
+
* if (result.success) {
|
|
423
|
+
* console.log('3 users deleted');
|
|
702
424
|
* }
|
|
703
|
-
*
|
|
425
|
+
*
|
|
426
|
+
* @since 1.0.0
|
|
704
427
|
*/
|
|
705
428
|
bulkDelete(
|
|
706
429
|
source: string,
|