@baasix/sdk 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/LICENSE +21 -0
- package/README.md +1197 -0
- package/dist/client-DeXa-R9w.d.ts +680 -0
- package/dist/client-VT7NckyI.d.cts +680 -0
- package/dist/index.cjs +4567 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1788 -0
- package/dist/index.d.ts +1788 -0
- package/dist/index.js +4543 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/auth.cjs +650 -0
- package/dist/modules/auth.cjs.map +1 -0
- package/dist/modules/auth.d.cts +384 -0
- package/dist/modules/auth.d.ts +384 -0
- package/dist/modules/auth.js +648 -0
- package/dist/modules/auth.js.map +1 -0
- package/dist/modules/files.cjs +269 -0
- package/dist/modules/files.cjs.map +1 -0
- package/dist/modules/files.d.cts +187 -0
- package/dist/modules/files.d.ts +187 -0
- package/dist/modules/files.js +267 -0
- package/dist/modules/files.js.map +1 -0
- package/dist/modules/items.cjs +640 -0
- package/dist/modules/items.cjs.map +1 -0
- package/dist/modules/items.d.cts +465 -0
- package/dist/modules/items.d.ts +465 -0
- package/dist/modules/items.js +637 -0
- package/dist/modules/items.js.map +1 -0
- package/dist/modules/schemas.cjs +322 -0
- package/dist/modules/schemas.cjs.map +1 -0
- package/dist/modules/schemas.d.cts +260 -0
- package/dist/modules/schemas.d.ts +260 -0
- package/dist/modules/schemas.js +320 -0
- package/dist/modules/schemas.js.map +1 -0
- package/dist/storage/index.cjs +162 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.cts +96 -0
- package/dist/storage/index.d.ts +96 -0
- package/dist/storage/index.js +157 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types-BdjsGANq.d.cts +40 -0
- package/dist/types-BdjsGANq.d.ts +40 -0
- package/package.json +108 -0
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
import { S as StorageAdapter } from './types-BdjsGANq.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Authentication mode for the SDK
|
|
5
|
+
* - 'jwt': Use JWT tokens stored in the configured storage adapter (default)
|
|
6
|
+
* - 'cookie': Use HTTP-only cookies (server handles token storage)
|
|
7
|
+
*/
|
|
8
|
+
type AuthMode = "jwt" | "cookie";
|
|
9
|
+
/**
|
|
10
|
+
* SDK Configuration options
|
|
11
|
+
*/
|
|
12
|
+
interface BaasixConfig {
|
|
13
|
+
/**
|
|
14
|
+
* The base URL of your Baasix instance
|
|
15
|
+
* @example 'https://api.example.com' or 'http://localhost:8056'
|
|
16
|
+
*/
|
|
17
|
+
url: string;
|
|
18
|
+
/**
|
|
19
|
+
* Authentication mode
|
|
20
|
+
* @default 'jwt'
|
|
21
|
+
*/
|
|
22
|
+
authMode?: AuthMode;
|
|
23
|
+
/**
|
|
24
|
+
* Storage adapter for persisting tokens and user data
|
|
25
|
+
* @default LocalStorageAdapter (web) or MemoryStorageAdapter (SSR)
|
|
26
|
+
*/
|
|
27
|
+
storage?: StorageAdapter;
|
|
28
|
+
/**
|
|
29
|
+
* Static access token (useful for server-side or service accounts)
|
|
30
|
+
* When provided, this token is used instead of stored tokens
|
|
31
|
+
*/
|
|
32
|
+
token?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Custom headers to include in all requests
|
|
35
|
+
*/
|
|
36
|
+
headers?: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Request timeout in milliseconds
|
|
39
|
+
* @default 30000 (30 seconds)
|
|
40
|
+
*/
|
|
41
|
+
timeout?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to automatically refresh tokens before expiry
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
autoRefresh?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Credentials mode for fetch requests (important for cookies)
|
|
49
|
+
* @default 'include' for cookie mode, 'same-origin' for jwt mode
|
|
50
|
+
*/
|
|
51
|
+
credentials?: RequestCredentials;
|
|
52
|
+
/**
|
|
53
|
+
* Tenant ID for multi-tenant mode
|
|
54
|
+
*/
|
|
55
|
+
tenantId?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Global error handler
|
|
58
|
+
*/
|
|
59
|
+
onError?: (error: BaasixError) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Called when authentication state changes
|
|
62
|
+
*/
|
|
63
|
+
onAuthStateChange?: (event: AuthStateEvent, user: User | null) => void;
|
|
64
|
+
/**
|
|
65
|
+
* WebSocket server URL for realtime features
|
|
66
|
+
* @default Same as url
|
|
67
|
+
*/
|
|
68
|
+
socketUrl?: string;
|
|
69
|
+
/**
|
|
70
|
+
* WebSocket path
|
|
71
|
+
* @default '/socket'
|
|
72
|
+
*/
|
|
73
|
+
socketPath?: string;
|
|
74
|
+
}
|
|
75
|
+
interface User {
|
|
76
|
+
id: string;
|
|
77
|
+
email: string;
|
|
78
|
+
firstName?: string;
|
|
79
|
+
lastName?: string;
|
|
80
|
+
avatar?: string;
|
|
81
|
+
role?: Role;
|
|
82
|
+
role_Id?: string;
|
|
83
|
+
tenant_Id?: string;
|
|
84
|
+
status?: string;
|
|
85
|
+
createdAt?: string;
|
|
86
|
+
updatedAt?: string;
|
|
87
|
+
[key: string]: unknown;
|
|
88
|
+
}
|
|
89
|
+
interface Role {
|
|
90
|
+
id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
description?: string;
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}
|
|
95
|
+
interface Tenant {
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
[key: string]: unknown;
|
|
99
|
+
}
|
|
100
|
+
interface AuthTokens {
|
|
101
|
+
accessToken: string;
|
|
102
|
+
refreshToken?: string;
|
|
103
|
+
expiresAt?: number;
|
|
104
|
+
expiresIn?: number;
|
|
105
|
+
}
|
|
106
|
+
interface LoginCredentials {
|
|
107
|
+
email: string;
|
|
108
|
+
password: string;
|
|
109
|
+
tenantId?: string;
|
|
110
|
+
}
|
|
111
|
+
interface RegisterData {
|
|
112
|
+
email: string;
|
|
113
|
+
password: string;
|
|
114
|
+
firstName?: string;
|
|
115
|
+
lastName?: string;
|
|
116
|
+
[key: string]: unknown;
|
|
117
|
+
}
|
|
118
|
+
interface AuthResponse {
|
|
119
|
+
token: string;
|
|
120
|
+
refreshToken?: string;
|
|
121
|
+
user: User;
|
|
122
|
+
expiresIn?: number;
|
|
123
|
+
}
|
|
124
|
+
type AuthStateEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "USER_UPDATED" | "TENANT_SWITCHED";
|
|
125
|
+
interface AuthState {
|
|
126
|
+
user: User | null;
|
|
127
|
+
isAuthenticated: boolean;
|
|
128
|
+
isLoading: boolean;
|
|
129
|
+
error: BaasixError | null;
|
|
130
|
+
}
|
|
131
|
+
interface MagicLinkOptions {
|
|
132
|
+
email: string;
|
|
133
|
+
redirectUrl?: string;
|
|
134
|
+
mode?: "link" | "code";
|
|
135
|
+
}
|
|
136
|
+
interface PasswordResetOptions {
|
|
137
|
+
email: string;
|
|
138
|
+
redirectUrl?: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Filter operators supported by Baasix
|
|
142
|
+
*/
|
|
143
|
+
type FilterOperator = "eq" | "ne" | "neq" | "gt" | "gte" | "lt" | "lte" | "is" | "not" | "in" | "notIn" | "nin" | "like" | "notLike" | "iLike" | "notILike" | "ilike" | "contains" | "icontains" | "ncontains" | "startsWith" | "startsWiths" | "endsWith" | "endsWiths" | "nstartsWith" | "nstartsWiths" | "nendsWith" | "nendsWiths" | "between" | "notBetween" | "nbetween" | "isNull" | "isNotNull" | "arraycontains" | "arraycontained" | "arrayoverlap" | "arraylength" | "jsonbContains" | "jsonbContainedBy" | "jsonbNotContains" | "jsonbHasKey" | "jsonbHasAnyKeys" | "jsonbHasAllKeys" | "jsonbKeyEquals" | "jsonbKeyNotEquals" | "jsonbKeyGt" | "jsonbKeyGte" | "jsonbKeyLt" | "jsonbKeyLte" | "jsonbKeyIn" | "jsonbKeyNotIn" | "jsonbKeyLike" | "jsonbKeyIsNull" | "jsonbKeyIsNotNull" | "jsonbPathExists" | "jsonbPathMatch" | "jsonbDeepValue" | "jsonbArrayLength" | "jsonbTypeOf" | "within" | "containsGEO" | "intersects" | "nIntersects" | "dwithin";
|
|
144
|
+
/**
|
|
145
|
+
* Filter value with operator
|
|
146
|
+
*/
|
|
147
|
+
type FilterValue<T = unknown> = T | {
|
|
148
|
+
[K in FilterOperator]?: T | T[];
|
|
149
|
+
} | {
|
|
150
|
+
cast?: string;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Filter condition for a field
|
|
154
|
+
*/
|
|
155
|
+
type FilterCondition = {
|
|
156
|
+
[field: string]: FilterValue | FilterCondition;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Logical filter operators
|
|
160
|
+
*/
|
|
161
|
+
interface LogicalFilter {
|
|
162
|
+
AND?: (FilterCondition | LogicalFilter)[];
|
|
163
|
+
OR?: (FilterCondition | LogicalFilter)[];
|
|
164
|
+
NOT?: FilterCondition | LogicalFilter;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Complete filter type
|
|
168
|
+
*/
|
|
169
|
+
type Filter = FilterCondition | LogicalFilter;
|
|
170
|
+
/**
|
|
171
|
+
* Sort direction
|
|
172
|
+
*/
|
|
173
|
+
type SortDirection = "asc" | "desc" | "ASC" | "DESC";
|
|
174
|
+
/**
|
|
175
|
+
* Sort configuration
|
|
176
|
+
*/
|
|
177
|
+
type Sort = string | string[] | Record<string, SortDirection> | {
|
|
178
|
+
column: string;
|
|
179
|
+
order: SortDirection;
|
|
180
|
+
}[];
|
|
181
|
+
/**
|
|
182
|
+
* Aggregation function
|
|
183
|
+
*/
|
|
184
|
+
type AggregateFunction = "count" | "sum" | "avg" | "min" | "max";
|
|
185
|
+
/**
|
|
186
|
+
* Aggregation configuration
|
|
187
|
+
*/
|
|
188
|
+
interface AggregateConfig {
|
|
189
|
+
function: AggregateFunction;
|
|
190
|
+
field: string;
|
|
191
|
+
}
|
|
192
|
+
type Aggregate = Record<string, AggregateConfig>;
|
|
193
|
+
/**
|
|
194
|
+
* Query parameters for listing items
|
|
195
|
+
*/
|
|
196
|
+
interface QueryParams<T = unknown> {
|
|
197
|
+
/**
|
|
198
|
+
* Fields to return
|
|
199
|
+
* @example ['*'], ['id', 'name'], ['*', 'author.*']
|
|
200
|
+
*/
|
|
201
|
+
fields?: string[];
|
|
202
|
+
/**
|
|
203
|
+
* Filter conditions
|
|
204
|
+
*/
|
|
205
|
+
filter?: Filter;
|
|
206
|
+
/**
|
|
207
|
+
* Sorting configuration
|
|
208
|
+
* @example { createdAt: 'desc' } or ['-createdAt', 'name']
|
|
209
|
+
*/
|
|
210
|
+
sort?: Sort;
|
|
211
|
+
/**
|
|
212
|
+
* Number of items per page (-1 for all)
|
|
213
|
+
* @default 10
|
|
214
|
+
*/
|
|
215
|
+
limit?: number;
|
|
216
|
+
/**
|
|
217
|
+
* Page number (1-indexed)
|
|
218
|
+
* @default 1
|
|
219
|
+
*/
|
|
220
|
+
page?: number;
|
|
221
|
+
/**
|
|
222
|
+
* Number of items to skip
|
|
223
|
+
*/
|
|
224
|
+
offset?: number;
|
|
225
|
+
/**
|
|
226
|
+
* Full-text search query
|
|
227
|
+
*/
|
|
228
|
+
search?: string;
|
|
229
|
+
/**
|
|
230
|
+
* Fields to search in
|
|
231
|
+
*/
|
|
232
|
+
searchFields?: string[];
|
|
233
|
+
/**
|
|
234
|
+
* Aggregation configuration
|
|
235
|
+
*/
|
|
236
|
+
aggregate?: Aggregate;
|
|
237
|
+
/**
|
|
238
|
+
* Fields to group by (used with aggregate)
|
|
239
|
+
*/
|
|
240
|
+
groupBy?: string[];
|
|
241
|
+
/**
|
|
242
|
+
* Include soft-deleted items
|
|
243
|
+
* @default false
|
|
244
|
+
*/
|
|
245
|
+
paranoid?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Filter conditions for related items (O2M/M2M)
|
|
248
|
+
*/
|
|
249
|
+
relConditions?: Record<string, Filter>;
|
|
250
|
+
/**
|
|
251
|
+
* Additional metadata
|
|
252
|
+
*/
|
|
253
|
+
meta?: T;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Paginated response
|
|
257
|
+
*/
|
|
258
|
+
interface PaginatedResponse<T> {
|
|
259
|
+
data: T[];
|
|
260
|
+
totalCount?: number;
|
|
261
|
+
page?: number;
|
|
262
|
+
limit?: number;
|
|
263
|
+
totalPages?: number;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Single item response
|
|
267
|
+
*/
|
|
268
|
+
interface SingleResponse<T> {
|
|
269
|
+
data: T;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Create/Update response
|
|
273
|
+
*/
|
|
274
|
+
interface MutationResponse<T = string> {
|
|
275
|
+
data: T;
|
|
276
|
+
message?: string;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Delete response
|
|
280
|
+
*/
|
|
281
|
+
interface DeleteResponse {
|
|
282
|
+
data: {
|
|
283
|
+
deleted: boolean;
|
|
284
|
+
count?: number;
|
|
285
|
+
};
|
|
286
|
+
message?: string;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Bulk operation response
|
|
290
|
+
*/
|
|
291
|
+
interface BulkResponse<T = string[]> {
|
|
292
|
+
data: T;
|
|
293
|
+
message?: string;
|
|
294
|
+
errors?: Array<{
|
|
295
|
+
index: number;
|
|
296
|
+
error: string;
|
|
297
|
+
}>;
|
|
298
|
+
}
|
|
299
|
+
type FieldType = "String" | "Text" | "HTML" | "Integer" | "BigInt" | "Float" | "Real" | "Double" | "Decimal" | "Boolean" | "Date" | "DateTime" | "Time" | "UUID" | "SUID" | "JSON" | "JSONB" | "Array" | "Geometry" | "Point" | "LineString" | "Polygon" | "Enum";
|
|
300
|
+
/**
|
|
301
|
+
* Default value types supported by Baasix
|
|
302
|
+
*/
|
|
303
|
+
type DefaultValueType = {
|
|
304
|
+
type: "UUIDV4";
|
|
305
|
+
} | {
|
|
306
|
+
type: "SUID";
|
|
307
|
+
} | {
|
|
308
|
+
type: "NOW";
|
|
309
|
+
} | {
|
|
310
|
+
type: "AUTOINCREMENT";
|
|
311
|
+
} | {
|
|
312
|
+
type: "SQL";
|
|
313
|
+
value: string;
|
|
314
|
+
} | {
|
|
315
|
+
type: "CURRENT_USER";
|
|
316
|
+
} | {
|
|
317
|
+
type: "CURRENT_TENANT";
|
|
318
|
+
};
|
|
319
|
+
interface FieldDefinition {
|
|
320
|
+
type: FieldType;
|
|
321
|
+
primaryKey?: boolean;
|
|
322
|
+
allowNull?: boolean;
|
|
323
|
+
unique?: boolean;
|
|
324
|
+
/**
|
|
325
|
+
* Default value for the field
|
|
326
|
+
* Can be a static value or a dynamic type
|
|
327
|
+
* @example
|
|
328
|
+
* // Static values
|
|
329
|
+
* defaultValue: "active"
|
|
330
|
+
* defaultValue: 0
|
|
331
|
+
* defaultValue: false
|
|
332
|
+
* defaultValue: []
|
|
333
|
+
*
|
|
334
|
+
* // Dynamic types
|
|
335
|
+
* defaultValue: { type: "UUIDV4" }
|
|
336
|
+
* defaultValue: { type: "SUID" }
|
|
337
|
+
* defaultValue: { type: "NOW" }
|
|
338
|
+
* defaultValue: { type: "AUTOINCREMENT" }
|
|
339
|
+
* defaultValue: { type: "SQL", value: "CURRENT_DATE" }
|
|
340
|
+
*/
|
|
341
|
+
defaultValue?: DefaultValueType | string | number | boolean | null | unknown[] | Record<string, unknown>;
|
|
342
|
+
values?: {
|
|
343
|
+
length?: number;
|
|
344
|
+
precision?: number;
|
|
345
|
+
scale?: number;
|
|
346
|
+
type?: string;
|
|
347
|
+
values?: string[];
|
|
348
|
+
};
|
|
349
|
+
validate?: {
|
|
350
|
+
/** Minimum value for numeric fields */
|
|
351
|
+
min?: number;
|
|
352
|
+
/** Maximum value for numeric fields */
|
|
353
|
+
max?: number;
|
|
354
|
+
/** Validate as integer */
|
|
355
|
+
isInt?: boolean;
|
|
356
|
+
/** String must not be empty */
|
|
357
|
+
notEmpty?: boolean;
|
|
358
|
+
/** Validate email format */
|
|
359
|
+
isEmail?: boolean;
|
|
360
|
+
/** Validate URL format */
|
|
361
|
+
isUrl?: boolean;
|
|
362
|
+
/** String length range [min, max] */
|
|
363
|
+
len?: [number, number];
|
|
364
|
+
/** Pattern matching with regex (alias: matches) */
|
|
365
|
+
is?: string;
|
|
366
|
+
/** Pattern matching with regex (alias: is) */
|
|
367
|
+
matches?: string;
|
|
368
|
+
/** @deprecated Use 'is' or 'matches' instead */
|
|
369
|
+
regex?: string;
|
|
370
|
+
};
|
|
371
|
+
comment?: string;
|
|
372
|
+
}
|
|
373
|
+
interface SchemaDefinition {
|
|
374
|
+
name: string;
|
|
375
|
+
timestamps?: boolean;
|
|
376
|
+
paranoid?: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* True for M2M/M2A junction tables (system-generated)
|
|
379
|
+
* Junction tables are auto-created when defining M2M or M2A relationships
|
|
380
|
+
*/
|
|
381
|
+
isJunction?: boolean;
|
|
382
|
+
fields: Record<string, FieldDefinition>;
|
|
383
|
+
indexes?: IndexDefinition[];
|
|
384
|
+
}
|
|
385
|
+
interface IndexDefinition {
|
|
386
|
+
name: string;
|
|
387
|
+
fields: string[];
|
|
388
|
+
unique?: boolean;
|
|
389
|
+
/** When true, NULL values are considered equal for unique indexes (PostgreSQL 15+) */
|
|
390
|
+
nullsNotDistinct?: boolean;
|
|
391
|
+
}
|
|
392
|
+
type RelationshipType = "M2O" | "O2M" | "M2M" | "M2A" | "O2O";
|
|
393
|
+
interface RelationshipDefinition {
|
|
394
|
+
type: RelationshipType;
|
|
395
|
+
target: string;
|
|
396
|
+
name: string;
|
|
397
|
+
alias?: string;
|
|
398
|
+
/**
|
|
399
|
+
* Custom junction table name for M2M/M2A relationships (max 63 chars for PostgreSQL)
|
|
400
|
+
* If not provided, auto-generated as: {source}_{target}_{name}_junction
|
|
401
|
+
* @example "product_tags" or "comment_refs"
|
|
402
|
+
*/
|
|
403
|
+
through?: string;
|
|
404
|
+
onDelete?: "CASCADE" | "RESTRICT" | "SET NULL";
|
|
405
|
+
onUpdate?: "CASCADE" | "RESTRICT" | "SET NULL";
|
|
406
|
+
/** Target tables for M2A (polymorphic) relationships */
|
|
407
|
+
tables?: string[];
|
|
408
|
+
}
|
|
409
|
+
interface SchemaInfo {
|
|
410
|
+
collectionName: string;
|
|
411
|
+
schema: SchemaDefinition;
|
|
412
|
+
relationships?: RelationshipDefinition[];
|
|
413
|
+
}
|
|
414
|
+
interface FileMetadata {
|
|
415
|
+
id: string;
|
|
416
|
+
title?: string;
|
|
417
|
+
description?: string;
|
|
418
|
+
filename: string;
|
|
419
|
+
mimeType: string;
|
|
420
|
+
size: number;
|
|
421
|
+
width?: number;
|
|
422
|
+
height?: number;
|
|
423
|
+
duration?: number;
|
|
424
|
+
storage: string;
|
|
425
|
+
path: string;
|
|
426
|
+
isPublic?: boolean;
|
|
427
|
+
uploadedBy?: string;
|
|
428
|
+
createdAt: string;
|
|
429
|
+
updatedAt?: string;
|
|
430
|
+
[key: string]: unknown;
|
|
431
|
+
}
|
|
432
|
+
interface UploadOptions {
|
|
433
|
+
title?: string;
|
|
434
|
+
description?: string;
|
|
435
|
+
folder?: string;
|
|
436
|
+
storage?: "local" | "s3";
|
|
437
|
+
isPublic?: boolean;
|
|
438
|
+
metadata?: Record<string, unknown>;
|
|
439
|
+
onProgress?: (progress: number) => void;
|
|
440
|
+
/** Request timeout in milliseconds (default: 30000). Set to 0 for no timeout. */
|
|
441
|
+
timeout?: number;
|
|
442
|
+
}
|
|
443
|
+
interface AssetTransformOptions {
|
|
444
|
+
width?: number;
|
|
445
|
+
height?: number;
|
|
446
|
+
fit?: "cover" | "contain" | "fill" | "inside" | "outside";
|
|
447
|
+
quality?: number;
|
|
448
|
+
format?: "jpeg" | "png" | "webp" | "avif";
|
|
449
|
+
}
|
|
450
|
+
type PermissionAction = "create" | "read" | "update" | "delete";
|
|
451
|
+
interface Permission {
|
|
452
|
+
id: string;
|
|
453
|
+
role_Id: string;
|
|
454
|
+
collection: string;
|
|
455
|
+
action: PermissionAction;
|
|
456
|
+
fields?: string[];
|
|
457
|
+
conditions?: Filter;
|
|
458
|
+
defaultValues?: Record<string, unknown>;
|
|
459
|
+
relConditions?: Record<string, Filter>;
|
|
460
|
+
}
|
|
461
|
+
interface CreatePermissionData {
|
|
462
|
+
role_Id: string;
|
|
463
|
+
collection: string;
|
|
464
|
+
action: PermissionAction;
|
|
465
|
+
fields?: string[];
|
|
466
|
+
conditions?: Filter;
|
|
467
|
+
defaultValues?: Record<string, unknown>;
|
|
468
|
+
relConditions?: Record<string, Filter>;
|
|
469
|
+
}
|
|
470
|
+
interface Notification {
|
|
471
|
+
id: string;
|
|
472
|
+
type: string;
|
|
473
|
+
title: string;
|
|
474
|
+
message: string;
|
|
475
|
+
data?: Record<string, unknown>;
|
|
476
|
+
seen: boolean;
|
|
477
|
+
user_Id: string;
|
|
478
|
+
createdAt: string;
|
|
479
|
+
}
|
|
480
|
+
interface SendNotificationData {
|
|
481
|
+
type?: string;
|
|
482
|
+
title: string;
|
|
483
|
+
message: string;
|
|
484
|
+
data?: Record<string, unknown>;
|
|
485
|
+
userIds: string[];
|
|
486
|
+
}
|
|
487
|
+
interface Workflow {
|
|
488
|
+
id: string;
|
|
489
|
+
name: string;
|
|
490
|
+
description?: string;
|
|
491
|
+
trigger: WorkflowTrigger;
|
|
492
|
+
nodes: WorkflowNode[];
|
|
493
|
+
edges: WorkflowEdge[];
|
|
494
|
+
isActive: boolean;
|
|
495
|
+
createdAt: string;
|
|
496
|
+
updatedAt?: string;
|
|
497
|
+
}
|
|
498
|
+
interface WorkflowTrigger {
|
|
499
|
+
type: "manual" | "webhook" | "schedule" | "hook";
|
|
500
|
+
config?: Record<string, unknown>;
|
|
501
|
+
}
|
|
502
|
+
interface WorkflowNode {
|
|
503
|
+
id: string;
|
|
504
|
+
type: string;
|
|
505
|
+
config: Record<string, unknown>;
|
|
506
|
+
position?: {
|
|
507
|
+
x: number;
|
|
508
|
+
y: number;
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
interface WorkflowEdge {
|
|
512
|
+
id: string;
|
|
513
|
+
source: string;
|
|
514
|
+
target: string;
|
|
515
|
+
condition?: string;
|
|
516
|
+
}
|
|
517
|
+
interface WorkflowExecution {
|
|
518
|
+
id: string;
|
|
519
|
+
workflow_Id: string;
|
|
520
|
+
status: "pending" | "running" | "completed" | "failed";
|
|
521
|
+
triggerData?: Record<string, unknown>;
|
|
522
|
+
result?: Record<string, unknown>;
|
|
523
|
+
error?: string;
|
|
524
|
+
startedAt: string;
|
|
525
|
+
completedAt?: string;
|
|
526
|
+
}
|
|
527
|
+
interface ReportConfig {
|
|
528
|
+
collection: string;
|
|
529
|
+
filter?: Filter;
|
|
530
|
+
groupBy?: string;
|
|
531
|
+
aggregate?: Aggregate;
|
|
532
|
+
dateRange?: {
|
|
533
|
+
start: string;
|
|
534
|
+
end: string;
|
|
535
|
+
field?: string;
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
interface ReportResult {
|
|
539
|
+
data: Record<string, unknown>[];
|
|
540
|
+
summary?: Record<string, unknown>;
|
|
541
|
+
}
|
|
542
|
+
interface BaasixErrorDetails {
|
|
543
|
+
code?: string;
|
|
544
|
+
field?: string;
|
|
545
|
+
message?: string;
|
|
546
|
+
[key: string]: unknown;
|
|
547
|
+
}
|
|
548
|
+
declare class BaasixError extends Error {
|
|
549
|
+
readonly status: number;
|
|
550
|
+
readonly code?: string;
|
|
551
|
+
readonly details?: BaasixErrorDetails[];
|
|
552
|
+
readonly isRetryable: boolean;
|
|
553
|
+
constructor(message: string, status?: number, code?: string, details?: BaasixErrorDetails[]);
|
|
554
|
+
toJSON(): {
|
|
555
|
+
name: string;
|
|
556
|
+
message: string;
|
|
557
|
+
status: number;
|
|
558
|
+
code: string | undefined;
|
|
559
|
+
details: BaasixErrorDetails[] | undefined;
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Make all properties of T optional recursively
|
|
564
|
+
*/
|
|
565
|
+
type DeepPartial<T> = {
|
|
566
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* Extract the item type from a collection
|
|
570
|
+
*/
|
|
571
|
+
type CollectionItem<T> = T extends Array<infer U> ? U : T;
|
|
572
|
+
/**
|
|
573
|
+
* Generic record type with ID
|
|
574
|
+
*/
|
|
575
|
+
interface BaseItem {
|
|
576
|
+
id: string;
|
|
577
|
+
createdAt?: string;
|
|
578
|
+
updatedAt?: string;
|
|
579
|
+
deletedAt?: string;
|
|
580
|
+
[key: string]: unknown;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Settings configuration
|
|
584
|
+
*/
|
|
585
|
+
interface Settings {
|
|
586
|
+
[key: string]: unknown;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
interface RequestOptions extends RequestInit {
|
|
590
|
+
params?: Record<string, unknown>;
|
|
591
|
+
timeout?: number;
|
|
592
|
+
skipAuth?: boolean;
|
|
593
|
+
rawResponse?: boolean;
|
|
594
|
+
}
|
|
595
|
+
interface HttpClientConfig {
|
|
596
|
+
baseUrl: string;
|
|
597
|
+
authMode: AuthMode;
|
|
598
|
+
storage: StorageAdapter;
|
|
599
|
+
timeout: number;
|
|
600
|
+
autoRefresh: boolean;
|
|
601
|
+
credentials: RequestCredentials;
|
|
602
|
+
headers: Record<string, string>;
|
|
603
|
+
token?: string;
|
|
604
|
+
tenantId?: string;
|
|
605
|
+
onAuthError?: () => void;
|
|
606
|
+
onTokenRefresh?: (tokens: AuthTokens) => void;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Core HTTP client for making API requests.
|
|
610
|
+
* Handles authentication, token refresh, and error handling.
|
|
611
|
+
*/
|
|
612
|
+
declare class HttpClient {
|
|
613
|
+
private config;
|
|
614
|
+
private refreshPromise;
|
|
615
|
+
constructor(config: HttpClientConfig);
|
|
616
|
+
/**
|
|
617
|
+
* Update client configuration
|
|
618
|
+
*/
|
|
619
|
+
updateConfig(config: Partial<HttpClientConfig>): void;
|
|
620
|
+
/**
|
|
621
|
+
* Get the current base URL
|
|
622
|
+
*/
|
|
623
|
+
getBaseUrl(): string;
|
|
624
|
+
/**
|
|
625
|
+
* Build the full URL with query parameters
|
|
626
|
+
*/
|
|
627
|
+
private buildUrl;
|
|
628
|
+
/**
|
|
629
|
+
* Get the current access token
|
|
630
|
+
*/
|
|
631
|
+
private getAccessToken;
|
|
632
|
+
/**
|
|
633
|
+
* Check if token is expired or about to expire (within 60 seconds)
|
|
634
|
+
*/
|
|
635
|
+
private isTokenExpired;
|
|
636
|
+
/**
|
|
637
|
+
* Refresh the access token
|
|
638
|
+
*/
|
|
639
|
+
private refreshToken;
|
|
640
|
+
/**
|
|
641
|
+
* Build request headers
|
|
642
|
+
*/
|
|
643
|
+
private buildHeaders;
|
|
644
|
+
/**
|
|
645
|
+
* Parse error response
|
|
646
|
+
*/
|
|
647
|
+
private parseError;
|
|
648
|
+
/**
|
|
649
|
+
* Make an HTTP request
|
|
650
|
+
*/
|
|
651
|
+
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
652
|
+
/**
|
|
653
|
+
* GET request
|
|
654
|
+
*/
|
|
655
|
+
get<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
656
|
+
/**
|
|
657
|
+
* POST request
|
|
658
|
+
*/
|
|
659
|
+
post<T>(path: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
660
|
+
/**
|
|
661
|
+
* PATCH request
|
|
662
|
+
*/
|
|
663
|
+
patch<T>(path: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
664
|
+
/**
|
|
665
|
+
* PUT request
|
|
666
|
+
*/
|
|
667
|
+
put<T>(path: string, data?: unknown, options?: RequestOptions): Promise<T>;
|
|
668
|
+
/**
|
|
669
|
+
* DELETE request
|
|
670
|
+
*/
|
|
671
|
+
delete<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
672
|
+
/**
|
|
673
|
+
* Upload file with multipart/form-data
|
|
674
|
+
*/
|
|
675
|
+
upload<T>(path: string, formData: FormData, options?: Omit<RequestOptions, "body"> & {
|
|
676
|
+
onProgress?: (progress: number) => void;
|
|
677
|
+
}): Promise<T>;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
export { type PermissionAction as $, type AuthMode as A, type BaseItem as B, type CreatePermissionData as C, type DeleteResponse as D, type FilterValue as E, type Filter as F, type FilterCondition as G, HttpClient as H, type IndexDefinition as I, type LogicalFilter as J, type SortDirection as K, type LoginCredentials as L, type MagicLinkOptions as M, type Notification as N, type AggregateFunction as O, type PasswordResetOptions as P, type QueryParams as Q, type RegisterData as R, type Sort as S, type Tenant as T, type User as U, type AggregateConfig as V, type Workflow as W, type FieldType as X, type DefaultValueType as Y, type FieldDefinition as Z, type RelationshipType as _, type AuthStateEvent as a, type WorkflowTrigger as a0, type WorkflowNode as a1, type WorkflowEdge as a2, type BaasixErrorDetails as a3, BaasixError as a4, type DeepPartial as a5, type CollectionItem as a6, type AuthResponse as b, type AuthTokens as c, type AuthState as d, type PaginatedResponse as e, type BulkResponse as f, type MutationResponse as g, type SingleResponse as h, type UploadOptions as i, type FileMetadata as j, type AssetTransformOptions as k, type SchemaInfo as l, type SchemaDefinition as m, type RelationshipDefinition as n, type SendNotificationData as o, type Permission as p, type Role as q, type Settings as r, type ReportConfig as s, type ReportResult as t, type Aggregate as u, type WorkflowExecution as v, type BaasixConfig as w, type RequestOptions as x, type HttpClientConfig as y, type FilterOperator as z };
|