@snackbase/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/CHANGELOG.md +61 -0
- package/LICENSE +21 -0
- package/README.md +287 -0
- package/dist/index-Dr6K4PMl.d.mts +2118 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2516 -0
- package/dist/react/index.d.mts +63 -0
- package/dist/react/index.mjs +271 -0
- package/package.json +48 -0
|
@@ -0,0 +1,2118 @@
|
|
|
1
|
+
//#region src/types/config.d.ts
|
|
2
|
+
type LogLevel$1 = 'debug' | 'info' | 'warn' | 'error';
|
|
3
|
+
type StorageBackend = 'localStorage' | 'sessionStorage' | 'memory' | 'asyncStorage';
|
|
4
|
+
interface SnackBaseConfig {
|
|
5
|
+
/**
|
|
6
|
+
* API base URL (required)
|
|
7
|
+
*/
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
/**
|
|
10
|
+
* Request timeout in milliseconds (default: 30000)
|
|
11
|
+
*/
|
|
12
|
+
timeout?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Optional API key for service authentication
|
|
15
|
+
*/
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Enable automatic token refresh (default: true)
|
|
19
|
+
*/
|
|
20
|
+
enableAutoRefresh?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Refresh tokens N seconds before expiry (default: 300)
|
|
23
|
+
*/
|
|
24
|
+
refreshBeforeExpiry?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum retry attempts for failed requests (default: 3)
|
|
27
|
+
*/
|
|
28
|
+
maxRetries?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Delay between retries in milliseconds (default: 1000)
|
|
31
|
+
*/
|
|
32
|
+
retryDelay?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Token storage backend.
|
|
35
|
+
* 'localStorage' or 'sessionStorage' for web,
|
|
36
|
+
* 'asyncStorage' for React Native.
|
|
37
|
+
* Default: auto-detect based on platform.
|
|
38
|
+
*/
|
|
39
|
+
storageBackend?: StorageBackend;
|
|
40
|
+
/**
|
|
41
|
+
* Enable request/response logging (default: false in production)
|
|
42
|
+
*/
|
|
43
|
+
enableLogging?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Logging level (default: 'error')
|
|
46
|
+
*/
|
|
47
|
+
logLevel?: LogLevel$1;
|
|
48
|
+
/**
|
|
49
|
+
* Callback for 401 authentication errors
|
|
50
|
+
*/
|
|
51
|
+
onAuthError?: (error: any) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Callback for network failures
|
|
54
|
+
*/
|
|
55
|
+
onNetworkError?: (error: any) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Callback for 429 rate limit errors
|
|
58
|
+
*/
|
|
59
|
+
onRateLimitError?: (error: any) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Default account slug/ID for single-tenant mode (optional)
|
|
62
|
+
*/
|
|
63
|
+
defaultAccount?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Maximum reconnection attempts for real-time (default: 10)
|
|
66
|
+
*/
|
|
67
|
+
maxRealTimeRetries?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Initial delay for real-time reconnection in milliseconds (default: 1000)
|
|
70
|
+
*/
|
|
71
|
+
realTimeReconnectionDelay?: number;
|
|
72
|
+
}
|
|
73
|
+
declare const DEFAULT_CONFIG: Partial<SnackBaseConfig>;
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region src/core/logger.d.ts
|
|
76
|
+
declare enum LogLevel {
|
|
77
|
+
NONE = 0,
|
|
78
|
+
ERROR = 1,
|
|
79
|
+
WARN = 2,
|
|
80
|
+
INFO = 3,
|
|
81
|
+
DEBUG = 4
|
|
82
|
+
}
|
|
83
|
+
interface LogEntry {
|
|
84
|
+
timestamp: string;
|
|
85
|
+
level: LogLevel;
|
|
86
|
+
message: string;
|
|
87
|
+
data?: any;
|
|
88
|
+
}
|
|
89
|
+
declare class Logger {
|
|
90
|
+
private level;
|
|
91
|
+
private handlers;
|
|
92
|
+
private logs;
|
|
93
|
+
private maxLogs;
|
|
94
|
+
constructor(level?: LogLevel);
|
|
95
|
+
setLevel(level: LogLevel): void;
|
|
96
|
+
getLogs(): LogEntry[];
|
|
97
|
+
clearLogs(): void;
|
|
98
|
+
private log;
|
|
99
|
+
error(message: string, data?: any): void;
|
|
100
|
+
warn(message: string, data?: any): void;
|
|
101
|
+
info(message: string, data?: any): void;
|
|
102
|
+
debug(message: string, data?: any): void;
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/core/http-client.d.ts
|
|
106
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
107
|
+
interface HttpRequest {
|
|
108
|
+
url: string;
|
|
109
|
+
method: HttpMethod;
|
|
110
|
+
headers: Record<string, string>;
|
|
111
|
+
body?: any;
|
|
112
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
113
|
+
timeout?: number;
|
|
114
|
+
signal?: AbortSignal;
|
|
115
|
+
}
|
|
116
|
+
interface HttpResponse<T = any> {
|
|
117
|
+
data: T;
|
|
118
|
+
status: number;
|
|
119
|
+
headers: Headers;
|
|
120
|
+
request: HttpRequest;
|
|
121
|
+
}
|
|
122
|
+
type RequestInterceptor = (request: HttpRequest) => HttpRequest | Promise<HttpRequest>;
|
|
123
|
+
type ResponseInterceptor = (response: HttpResponse) => HttpResponse | Promise<HttpResponse>;
|
|
124
|
+
type ErrorInterceptor = (error: any) => any | Promise<any>;
|
|
125
|
+
interface HttpClientConfig {
|
|
126
|
+
baseUrl: string;
|
|
127
|
+
timeout?: number;
|
|
128
|
+
maxRetries?: number;
|
|
129
|
+
retryDelay?: number;
|
|
130
|
+
logger?: Logger;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Robust HTTP client wrapping the fetch API.
|
|
134
|
+
*/
|
|
135
|
+
declare class HttpClient {
|
|
136
|
+
private config;
|
|
137
|
+
private requestInterceptors;
|
|
138
|
+
private responseInterceptors;
|
|
139
|
+
private errorInterceptors;
|
|
140
|
+
constructor(config: HttpClientConfig);
|
|
141
|
+
addRequestInterceptor(interceptor: RequestInterceptor): void;
|
|
142
|
+
addResponseInterceptor(interceptor: ResponseInterceptor): void;
|
|
143
|
+
addErrorInterceptor(interceptor: ErrorInterceptor): void;
|
|
144
|
+
request<T = any>(req: Partial<HttpRequest>): Promise<HttpResponse<T>>;
|
|
145
|
+
get<T = any>(url: string, config?: Partial<HttpRequest>): Promise<HttpResponse<T>>;
|
|
146
|
+
post<T = any>(url: string, body?: any, config?: Partial<HttpRequest>): Promise<HttpResponse<T>>;
|
|
147
|
+
put<T = any>(url: string, body?: any, config?: Partial<HttpRequest>): Promise<HttpResponse<T>>;
|
|
148
|
+
patch<T = any>(url: string, body?: any, config?: Partial<HttpRequest>): Promise<HttpResponse<T>>;
|
|
149
|
+
delete<T = any>(url: string, config?: Partial<HttpRequest>): Promise<HttpResponse<T>>;
|
|
150
|
+
private resolveUrl;
|
|
151
|
+
private shouldRetry;
|
|
152
|
+
private calculateRetryDelay;
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/types/account.d.ts
|
|
156
|
+
interface Account$1 {
|
|
157
|
+
id: string;
|
|
158
|
+
slug: string;
|
|
159
|
+
name: string;
|
|
160
|
+
created_at: string;
|
|
161
|
+
}
|
|
162
|
+
interface AccountCreate {
|
|
163
|
+
name: string;
|
|
164
|
+
slug?: string;
|
|
165
|
+
}
|
|
166
|
+
interface AccountUpdate {
|
|
167
|
+
name: string;
|
|
168
|
+
}
|
|
169
|
+
interface AccountListParams {
|
|
170
|
+
page?: number;
|
|
171
|
+
page_size?: number;
|
|
172
|
+
search?: string;
|
|
173
|
+
is_active?: boolean;
|
|
174
|
+
sort_by?: string;
|
|
175
|
+
sort_order?: 'asc' | 'desc';
|
|
176
|
+
[key: string]: string | number | boolean | undefined;
|
|
177
|
+
}
|
|
178
|
+
interface AccountListResponse {
|
|
179
|
+
items: Account$1[];
|
|
180
|
+
total: number;
|
|
181
|
+
}
|
|
182
|
+
interface AccountUserListParams {
|
|
183
|
+
page?: number;
|
|
184
|
+
page_size?: number;
|
|
185
|
+
[key: string]: string | number | boolean | undefined;
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/types/user.d.ts
|
|
189
|
+
interface User$1 {
|
|
190
|
+
id: string;
|
|
191
|
+
email: string;
|
|
192
|
+
role: string;
|
|
193
|
+
groups: string[];
|
|
194
|
+
is_active: boolean;
|
|
195
|
+
created_at: string;
|
|
196
|
+
last_login: string | null;
|
|
197
|
+
}
|
|
198
|
+
interface UserCreate {
|
|
199
|
+
email: string;
|
|
200
|
+
password?: string;
|
|
201
|
+
account_id: string;
|
|
202
|
+
role?: string;
|
|
203
|
+
}
|
|
204
|
+
interface UserUpdate {
|
|
205
|
+
email?: string;
|
|
206
|
+
role?: string;
|
|
207
|
+
is_active?: boolean;
|
|
208
|
+
}
|
|
209
|
+
interface UserListParams {
|
|
210
|
+
page?: number;
|
|
211
|
+
page_size?: number;
|
|
212
|
+
account_id?: string;
|
|
213
|
+
role_id?: string;
|
|
214
|
+
is_active?: boolean;
|
|
215
|
+
search?: string;
|
|
216
|
+
sort_by?: string;
|
|
217
|
+
sort_order?: 'asc' | 'desc';
|
|
218
|
+
[key: string]: string | number | boolean | undefined;
|
|
219
|
+
}
|
|
220
|
+
interface UserListResponse {
|
|
221
|
+
items: User$1[];
|
|
222
|
+
total: number;
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
225
|
+
//#region src/types/auth.d.ts
|
|
226
|
+
interface AuthState {
|
|
227
|
+
user: User | null;
|
|
228
|
+
account: Account | null;
|
|
229
|
+
token: string | null;
|
|
230
|
+
refreshToken: string | null;
|
|
231
|
+
isAuthenticated: boolean;
|
|
232
|
+
expiresAt: string | null;
|
|
233
|
+
}
|
|
234
|
+
type AuthEvent = 'auth:login' | 'auth:logout' | 'auth:refresh' | 'auth:error';
|
|
235
|
+
interface AuthEvents {
|
|
236
|
+
'auth:login': (state: AuthState) => void;
|
|
237
|
+
'auth:logout': () => void;
|
|
238
|
+
'auth:refresh': (state: AuthState) => void;
|
|
239
|
+
'auth:error': (error: Error) => void;
|
|
240
|
+
}
|
|
241
|
+
interface LoginCredentials {
|
|
242
|
+
account?: string;
|
|
243
|
+
email: string;
|
|
244
|
+
password: string;
|
|
245
|
+
}
|
|
246
|
+
interface RegisterData {
|
|
247
|
+
email: string;
|
|
248
|
+
password: string;
|
|
249
|
+
accountName?: string;
|
|
250
|
+
accountSlug?: string;
|
|
251
|
+
}
|
|
252
|
+
interface AuthResponse {
|
|
253
|
+
user: User;
|
|
254
|
+
account: Account;
|
|
255
|
+
token?: string;
|
|
256
|
+
refreshToken?: string;
|
|
257
|
+
expiresAt?: string;
|
|
258
|
+
}
|
|
259
|
+
interface PasswordResetRequest {
|
|
260
|
+
account?: string;
|
|
261
|
+
email: string;
|
|
262
|
+
}
|
|
263
|
+
interface PasswordResetConfirm {
|
|
264
|
+
token: string;
|
|
265
|
+
newPassword: string;
|
|
266
|
+
}
|
|
267
|
+
type OAuthProvider = 'google' | 'github' | 'microsoft' | 'apple';
|
|
268
|
+
interface OAuthUrlResponse {
|
|
269
|
+
url: string;
|
|
270
|
+
state: string;
|
|
271
|
+
}
|
|
272
|
+
interface OAuthCallbackParams {
|
|
273
|
+
provider: OAuthProvider;
|
|
274
|
+
code: string;
|
|
275
|
+
redirectUri: string;
|
|
276
|
+
state: string;
|
|
277
|
+
}
|
|
278
|
+
interface OAuthResponse extends AuthResponse {
|
|
279
|
+
isNewUser: boolean;
|
|
280
|
+
isNewAccount: boolean;
|
|
281
|
+
}
|
|
282
|
+
type SAMLProvider = 'okta' | 'azure_ad' | 'generic_saml';
|
|
283
|
+
interface SAMLUrlResponse {
|
|
284
|
+
url: string;
|
|
285
|
+
}
|
|
286
|
+
interface SAMLCallbackParams {
|
|
287
|
+
SAMLResponse: string;
|
|
288
|
+
relayState?: string;
|
|
289
|
+
}
|
|
290
|
+
interface SAMLResponse extends AuthResponse {
|
|
291
|
+
isNewUser: boolean;
|
|
292
|
+
isNewAccount: boolean;
|
|
293
|
+
}
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/core/storage.d.ts
|
|
296
|
+
interface AuthStorage {
|
|
297
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
298
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
299
|
+
removeItem(key: string): void | Promise<void>;
|
|
300
|
+
}
|
|
301
|
+
//#endregion
|
|
302
|
+
//#region src/core/auth.d.ts
|
|
303
|
+
interface AuthManagerOptions {
|
|
304
|
+
storage: AuthStorage;
|
|
305
|
+
storageKey?: string;
|
|
306
|
+
}
|
|
307
|
+
declare class AuthManager {
|
|
308
|
+
private state;
|
|
309
|
+
private storage;
|
|
310
|
+
private storageKey;
|
|
311
|
+
private events;
|
|
312
|
+
constructor(options: AuthManagerOptions);
|
|
313
|
+
initialize(): Promise<void>;
|
|
314
|
+
getState(): AuthState;
|
|
315
|
+
get user(): User$1 | null;
|
|
316
|
+
get account(): Account$1 | null;
|
|
317
|
+
get token(): string | null;
|
|
318
|
+
get refreshToken(): string | null;
|
|
319
|
+
get isAuthenticated(): boolean;
|
|
320
|
+
setState(newState: Partial<AuthState>): Promise<void>;
|
|
321
|
+
clear(): Promise<void>;
|
|
322
|
+
on<K extends keyof AuthEvents>(event: K, listener: AuthEvents[K]): () => void;
|
|
323
|
+
private hydrate;
|
|
324
|
+
private persist;
|
|
325
|
+
private validateSession;
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region src/core/auth-service.d.ts
|
|
329
|
+
/**
|
|
330
|
+
* Service for handling authentication operations.
|
|
331
|
+
*/
|
|
332
|
+
declare class AuthService {
|
|
333
|
+
private http;
|
|
334
|
+
private auth;
|
|
335
|
+
private apiKey?;
|
|
336
|
+
private defaultAccount?;
|
|
337
|
+
private oauthStates;
|
|
338
|
+
private readonly STATE_EXPIRY_MS;
|
|
339
|
+
constructor(http: HttpClient, auth: AuthManager, apiKey?: string | undefined, defaultAccount?: string | undefined);
|
|
340
|
+
/**
|
|
341
|
+
* Helper to ensure API key is not used for user-specific operations.
|
|
342
|
+
*/
|
|
343
|
+
private checkApiKeyRestriction;
|
|
344
|
+
/**
|
|
345
|
+
* Authenticate a user with email and password.
|
|
346
|
+
*/
|
|
347
|
+
login(credentials: LoginCredentials): Promise<AuthResponse>;
|
|
348
|
+
/**
|
|
349
|
+
* Register a new user and account.
|
|
350
|
+
*/
|
|
351
|
+
register(data: RegisterData): Promise<AuthResponse>;
|
|
352
|
+
/**
|
|
353
|
+
* Refresh the access token using the refresh token.
|
|
354
|
+
*/
|
|
355
|
+
refreshToken(): Promise<AuthResponse>;
|
|
356
|
+
/**
|
|
357
|
+
* Log out the current user.
|
|
358
|
+
*/
|
|
359
|
+
logout(): Promise<{
|
|
360
|
+
success: boolean;
|
|
361
|
+
}>;
|
|
362
|
+
/**
|
|
363
|
+
* Get the current authenticated user profile.
|
|
364
|
+
*/
|
|
365
|
+
getCurrentUser(): Promise<AuthResponse>;
|
|
366
|
+
/**
|
|
367
|
+
* Initiate password reset flow.
|
|
368
|
+
*/
|
|
369
|
+
forgotPassword(data: PasswordResetRequest): Promise<{
|
|
370
|
+
message: string;
|
|
371
|
+
}>;
|
|
372
|
+
/**
|
|
373
|
+
* Reset password using a token.
|
|
374
|
+
*/
|
|
375
|
+
resetPassword(data: PasswordResetConfirm): Promise<{
|
|
376
|
+
message: string;
|
|
377
|
+
}>;
|
|
378
|
+
/**
|
|
379
|
+
* Verify email using a token.
|
|
380
|
+
*/
|
|
381
|
+
verifyEmail(token: string): Promise<{
|
|
382
|
+
message: string;
|
|
383
|
+
}>;
|
|
384
|
+
/**
|
|
385
|
+
* Resend the verification email to the current user.
|
|
386
|
+
*/
|
|
387
|
+
resendVerificationEmail(): Promise<{
|
|
388
|
+
message: string;
|
|
389
|
+
}>;
|
|
390
|
+
/**
|
|
391
|
+
* Send a verification email to a specific email address.
|
|
392
|
+
* This can be used by admins to send verification emails to users.
|
|
393
|
+
*/
|
|
394
|
+
sendVerification(email: string): Promise<{
|
|
395
|
+
message: string;
|
|
396
|
+
}>;
|
|
397
|
+
/**
|
|
398
|
+
* Verify a password reset token is valid.
|
|
399
|
+
* Returns the email associated with the token if valid.
|
|
400
|
+
*/
|
|
401
|
+
verifyResetToken(token: string): Promise<{
|
|
402
|
+
email: string;
|
|
403
|
+
}>;
|
|
404
|
+
/**
|
|
405
|
+
* Generate OAuth authorization URL for the specified provider.
|
|
406
|
+
*/
|
|
407
|
+
getOAuthUrl(provider: OAuthProvider, redirectUri: string, state?: string): Promise<OAuthUrlResponse>;
|
|
408
|
+
/**
|
|
409
|
+
* Handle OAuth callback and authenticate user.
|
|
410
|
+
*/
|
|
411
|
+
handleOAuthCallback(params: OAuthCallbackParams): Promise<OAuthResponse>;
|
|
412
|
+
/**
|
|
413
|
+
* Generate SAML SSO authorization URL for the specified provider and account.
|
|
414
|
+
*/
|
|
415
|
+
getSAMLUrl(provider: SAMLProvider, account: string, relayState?: string): Promise<SAMLUrlResponse>;
|
|
416
|
+
/**
|
|
417
|
+
* Handle SAML callback (ACS) and authenticate user.
|
|
418
|
+
*/
|
|
419
|
+
handleSAMLCallback(params: SAMLCallbackParams): Promise<SAMLResponse>;
|
|
420
|
+
/**
|
|
421
|
+
* Get SAML metadata for the specified provider and account.
|
|
422
|
+
*/
|
|
423
|
+
getSAMLMetadata(provider: SAMLProvider, account: string): Promise<string>;
|
|
424
|
+
/**
|
|
425
|
+
* Cleanup expired state tokens.
|
|
426
|
+
*/
|
|
427
|
+
private cleanupExpiredStates;
|
|
428
|
+
}
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/core/account-service.d.ts
|
|
431
|
+
/**
|
|
432
|
+
* Service for managing accounts and their users.
|
|
433
|
+
* Requires superadmin authentication.
|
|
434
|
+
*/
|
|
435
|
+
declare class AccountService {
|
|
436
|
+
private http;
|
|
437
|
+
constructor(http: HttpClient);
|
|
438
|
+
/**
|
|
439
|
+
* List all accounts with pagination, filtering, and sorting.
|
|
440
|
+
*/
|
|
441
|
+
list(params?: AccountListParams): Promise<AccountListResponse>;
|
|
442
|
+
/**
|
|
443
|
+
* Get details for a specific account.
|
|
444
|
+
*/
|
|
445
|
+
get(accountId: string): Promise<Account$1>;
|
|
446
|
+
/**
|
|
447
|
+
* Create a new account.
|
|
448
|
+
*/
|
|
449
|
+
create(data: AccountCreate): Promise<Account$1>;
|
|
450
|
+
/**
|
|
451
|
+
* Update an existing account.
|
|
452
|
+
*/
|
|
453
|
+
update(accountId: string, data: AccountUpdate): Promise<Account$1>;
|
|
454
|
+
/**
|
|
455
|
+
* Delete an account and all its associated data.
|
|
456
|
+
*/
|
|
457
|
+
delete(accountId: string): Promise<{
|
|
458
|
+
success: boolean;
|
|
459
|
+
}>;
|
|
460
|
+
/**
|
|
461
|
+
* Get all users belonging to a specific account.
|
|
462
|
+
*/
|
|
463
|
+
getUsers(accountId: string, params?: AccountUserListParams): Promise<UserListResponse>;
|
|
464
|
+
}
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/core/user-service.d.ts
|
|
467
|
+
/**
|
|
468
|
+
* Service for managing users.
|
|
469
|
+
* Requires superadmin authentication for most operations.
|
|
470
|
+
*/
|
|
471
|
+
declare class UserService {
|
|
472
|
+
private http;
|
|
473
|
+
constructor(http: HttpClient);
|
|
474
|
+
/**
|
|
475
|
+
* List all users with pagination, filtering, and sorting.
|
|
476
|
+
*/
|
|
477
|
+
list(params?: UserListParams): Promise<UserListResponse>;
|
|
478
|
+
/**
|
|
479
|
+
* Get details for a specific user.
|
|
480
|
+
*/
|
|
481
|
+
get(userId: string): Promise<User$1>;
|
|
482
|
+
/**
|
|
483
|
+
* Create a new user in a specific account.
|
|
484
|
+
*/
|
|
485
|
+
create(data: UserCreate): Promise<User$1>;
|
|
486
|
+
/**
|
|
487
|
+
* Update an existing user.
|
|
488
|
+
*/
|
|
489
|
+
update(userId: string, data: UserUpdate): Promise<User$1>;
|
|
490
|
+
/**
|
|
491
|
+
* Soft delete (deactivate) a user.
|
|
492
|
+
*/
|
|
493
|
+
delete(userId: string): Promise<{
|
|
494
|
+
success: boolean;
|
|
495
|
+
}>;
|
|
496
|
+
/**
|
|
497
|
+
* Manually set a new password for a user.
|
|
498
|
+
*/
|
|
499
|
+
setPassword(userId: string, password: string): Promise<{
|
|
500
|
+
success: boolean;
|
|
501
|
+
}>;
|
|
502
|
+
/**
|
|
503
|
+
* Manually verify a user's email address.
|
|
504
|
+
*/
|
|
505
|
+
verifyEmail(userId: string): Promise<{
|
|
506
|
+
success: boolean;
|
|
507
|
+
}>;
|
|
508
|
+
/**
|
|
509
|
+
* Resend the verification email to a user.
|
|
510
|
+
*/
|
|
511
|
+
resendVerification(userId: string): Promise<{
|
|
512
|
+
success: boolean;
|
|
513
|
+
}>;
|
|
514
|
+
}
|
|
515
|
+
//#endregion
|
|
516
|
+
//#region src/types/collection.d.ts
|
|
517
|
+
type FieldType = 'text' | 'number' | 'boolean' | 'date' | 'datetime' | 'email' | 'url' | 'phone' | 'select' | 'multi_select' | 'relation' | 'json';
|
|
518
|
+
interface FieldDefinition {
|
|
519
|
+
name: string;
|
|
520
|
+
type: FieldType;
|
|
521
|
+
required?: boolean;
|
|
522
|
+
default?: any;
|
|
523
|
+
unique?: boolean;
|
|
524
|
+
options?: string[];
|
|
525
|
+
collection?: string;
|
|
526
|
+
}
|
|
527
|
+
interface Collection {
|
|
528
|
+
id: string;
|
|
529
|
+
name: string;
|
|
530
|
+
fields: FieldDefinition[];
|
|
531
|
+
record_count: number;
|
|
532
|
+
field_count: number;
|
|
533
|
+
created_at: string;
|
|
534
|
+
updated_at: string;
|
|
535
|
+
}
|
|
536
|
+
interface CollectionCreate {
|
|
537
|
+
name: string;
|
|
538
|
+
fields: FieldDefinition[];
|
|
539
|
+
}
|
|
540
|
+
interface CollectionUpdate {
|
|
541
|
+
name?: string;
|
|
542
|
+
fields?: FieldDefinition[];
|
|
543
|
+
}
|
|
544
|
+
//#endregion
|
|
545
|
+
//#region src/core/collection-service.d.ts
|
|
546
|
+
/**
|
|
547
|
+
* Service for managing collections and their schemas.
|
|
548
|
+
* Requires superadmin authentication.
|
|
549
|
+
*/
|
|
550
|
+
declare class CollectionService {
|
|
551
|
+
private http;
|
|
552
|
+
constructor(http: HttpClient);
|
|
553
|
+
/**
|
|
554
|
+
* List all collections.
|
|
555
|
+
*/
|
|
556
|
+
list(): Promise<Collection[]>;
|
|
557
|
+
/**
|
|
558
|
+
* List collection names only.
|
|
559
|
+
*/
|
|
560
|
+
listNames(): Promise<string[]>;
|
|
561
|
+
/**
|
|
562
|
+
* Get schema details for a specific collection.
|
|
563
|
+
*/
|
|
564
|
+
get(collectionId: string): Promise<Collection>;
|
|
565
|
+
/**
|
|
566
|
+
* Create a new collection and its physical table.
|
|
567
|
+
*/
|
|
568
|
+
create(data: CollectionCreate): Promise<Collection>;
|
|
569
|
+
/**
|
|
570
|
+
* Update an existing collection schema.
|
|
571
|
+
* Note: Field types cannot be changed for data safety.
|
|
572
|
+
*/
|
|
573
|
+
update(collectionId: string, data: CollectionUpdate): Promise<Collection>;
|
|
574
|
+
/**
|
|
575
|
+
* Delete a collection and drop its physical table.
|
|
576
|
+
*/
|
|
577
|
+
delete(collectionId: string): Promise<{
|
|
578
|
+
success: boolean;
|
|
579
|
+
}>;
|
|
580
|
+
}
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region src/types/record.d.ts
|
|
583
|
+
/**
|
|
584
|
+
* Base record fields managed by the system.
|
|
585
|
+
*/
|
|
586
|
+
interface BaseRecord {
|
|
587
|
+
id: string;
|
|
588
|
+
account_id: string;
|
|
589
|
+
created_at: string;
|
|
590
|
+
updated_at: string;
|
|
591
|
+
created_by?: string;
|
|
592
|
+
updated_by?: string;
|
|
593
|
+
[key: string]: any;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Parameters for listing records.
|
|
597
|
+
*/
|
|
598
|
+
interface RecordListParams {
|
|
599
|
+
/**
|
|
600
|
+
* Number of records to skip.
|
|
601
|
+
*/
|
|
602
|
+
skip?: number;
|
|
603
|
+
/**
|
|
604
|
+
* Maximum number of records to return.
|
|
605
|
+
*/
|
|
606
|
+
limit?: number;
|
|
607
|
+
/**
|
|
608
|
+
* Sort expression (e.g., 'created_at' or '-created_at' for descending).
|
|
609
|
+
*/
|
|
610
|
+
sort?: string;
|
|
611
|
+
/**
|
|
612
|
+
* Fields to include in the response.
|
|
613
|
+
*/
|
|
614
|
+
fields?: string[] | string;
|
|
615
|
+
/**
|
|
616
|
+
* Filter parameters.
|
|
617
|
+
*/
|
|
618
|
+
filter?: any;
|
|
619
|
+
/**
|
|
620
|
+
* Related collections to expand.
|
|
621
|
+
*/
|
|
622
|
+
expand?: string[] | string;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Paginated response for records.
|
|
626
|
+
*/
|
|
627
|
+
interface RecordListResponse<T> {
|
|
628
|
+
items: (T & BaseRecord)[];
|
|
629
|
+
total: number;
|
|
630
|
+
skip: number;
|
|
631
|
+
limit: number;
|
|
632
|
+
}
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region src/types/query.d.ts
|
|
635
|
+
/**
|
|
636
|
+
* Supported filter operators.
|
|
637
|
+
*/
|
|
638
|
+
type FilterOperator = '=' | '!=' | '>' | '>=' | '<' | '<=' | '~' | '!~' | '?=' | '?!=';
|
|
639
|
+
/**
|
|
640
|
+
* Filter expression object.
|
|
641
|
+
*/
|
|
642
|
+
interface FilterExpression {
|
|
643
|
+
field: string;
|
|
644
|
+
operator: FilterOperator;
|
|
645
|
+
value?: any;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Sort direction.
|
|
649
|
+
*/
|
|
650
|
+
type SortDirection = 'asc' | 'desc';
|
|
651
|
+
/**
|
|
652
|
+
* Sort expression object.
|
|
653
|
+
*/
|
|
654
|
+
interface SortExpression {
|
|
655
|
+
field: string;
|
|
656
|
+
direction: SortDirection;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Query parameters interface matching the backend expectations.
|
|
660
|
+
* This is similar to RecordListParams but used internally by the builder.
|
|
661
|
+
*/
|
|
662
|
+
interface QueryParams {
|
|
663
|
+
page?: number;
|
|
664
|
+
perPage?: number;
|
|
665
|
+
sort?: string;
|
|
666
|
+
filter?: string;
|
|
667
|
+
expand?: string;
|
|
668
|
+
fields?: string;
|
|
669
|
+
skip?: number;
|
|
670
|
+
limit?: number;
|
|
671
|
+
}
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region src/core/query-builder.d.ts
|
|
674
|
+
/**
|
|
675
|
+
* Fluent interface for building complex queries.
|
|
676
|
+
*/
|
|
677
|
+
declare class QueryBuilder<T = any> {
|
|
678
|
+
private service;
|
|
679
|
+
private collection;
|
|
680
|
+
private _fields;
|
|
681
|
+
private _expand;
|
|
682
|
+
private _filterParts;
|
|
683
|
+
private _sortParts;
|
|
684
|
+
private _page;
|
|
685
|
+
private _perPage;
|
|
686
|
+
private _skip;
|
|
687
|
+
private _limit;
|
|
688
|
+
private _useLegacyPagination;
|
|
689
|
+
constructor(service: RecordService, collection: string);
|
|
690
|
+
/**
|
|
691
|
+
* Specify fields to return.
|
|
692
|
+
* @param fields Array of field names or comma-separated string
|
|
693
|
+
*/
|
|
694
|
+
select(fields: string | string[]): this;
|
|
695
|
+
/**
|
|
696
|
+
* Expand related records.
|
|
697
|
+
* @param relations Array of relation names or comma-separated string
|
|
698
|
+
*/
|
|
699
|
+
expand(relations: string | string[]): this;
|
|
700
|
+
/**
|
|
701
|
+
* Add a filter condition.
|
|
702
|
+
* @param field Field name
|
|
703
|
+
* @param operator Filter operator
|
|
704
|
+
* @param value Value to compare against
|
|
705
|
+
*/
|
|
706
|
+
filter(field: string, operator: FilterOperator, value?: any): this;
|
|
707
|
+
/**
|
|
708
|
+
* Add a raw filter string.
|
|
709
|
+
* @param filterString Raw filter string (e.g., "age > 21")
|
|
710
|
+
*/
|
|
711
|
+
filter(filterString: string): this;
|
|
712
|
+
/**
|
|
713
|
+
* Add sorting.
|
|
714
|
+
* @param field Field name
|
|
715
|
+
* @param direction 'asc' or 'desc' (default: 'asc')
|
|
716
|
+
*/
|
|
717
|
+
sort(field: string, direction?: SortDirection): this;
|
|
718
|
+
/**
|
|
719
|
+
* Set limit (and optionally skip).
|
|
720
|
+
* Note: Using limit/skip switches to manual offset pagination.
|
|
721
|
+
* @param limit Max records
|
|
722
|
+
* @param skip Records to skip
|
|
723
|
+
*/
|
|
724
|
+
limit(limit: number): this;
|
|
725
|
+
/**
|
|
726
|
+
* Set skip.
|
|
727
|
+
* Note: Using limit/skip switches to manual offset pagination.
|
|
728
|
+
* @param skip Records to skip
|
|
729
|
+
*/
|
|
730
|
+
skip(skip: number): this;
|
|
731
|
+
/**
|
|
732
|
+
* Set page number and page size.
|
|
733
|
+
* @param page Page number (1-based)
|
|
734
|
+
* @param perPage Records per page
|
|
735
|
+
*/
|
|
736
|
+
page(page: number, perPage?: number): this;
|
|
737
|
+
/**
|
|
738
|
+
* Execute query and get list of records.
|
|
739
|
+
*/
|
|
740
|
+
get(): Promise<RecordListResponse<T>>;
|
|
741
|
+
/**
|
|
742
|
+
* Execute query and get the first matching record.
|
|
743
|
+
*/
|
|
744
|
+
first(): Promise<(T & BaseRecord) | null>;
|
|
745
|
+
private formatValue;
|
|
746
|
+
}
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region src/core/record-service.d.ts
|
|
749
|
+
/**
|
|
750
|
+
* Service for performing CRUD operations on dynamic collections.
|
|
751
|
+
*/
|
|
752
|
+
declare class RecordService {
|
|
753
|
+
private http;
|
|
754
|
+
constructor(http: HttpClient);
|
|
755
|
+
/**
|
|
756
|
+
* List records from a collection with pagination, filtering, and sorting.
|
|
757
|
+
* @template T The record type
|
|
758
|
+
* @param collection Collection name
|
|
759
|
+
* @param params Query parameters
|
|
760
|
+
*/
|
|
761
|
+
list<T = any>(collection: string, params?: RecordListParams): Promise<RecordListResponse<T>>;
|
|
762
|
+
/**
|
|
763
|
+
* Create a query builder for the collection.
|
|
764
|
+
* @template T The record type
|
|
765
|
+
* @param collection Collection name
|
|
766
|
+
*/
|
|
767
|
+
query<T = any>(collection: string): QueryBuilder<T>;
|
|
768
|
+
/**
|
|
769
|
+
* Get a single record by ID.
|
|
770
|
+
* @template T The record type
|
|
771
|
+
* @param collection Collection name
|
|
772
|
+
* @param recordId Record ID
|
|
773
|
+
* @param params Optional query parameters (e.g., fields)
|
|
774
|
+
*/
|
|
775
|
+
get<T = any>(collection: string, recordId: string, params?: {
|
|
776
|
+
fields?: string[] | string;
|
|
777
|
+
expand?: string[] | string;
|
|
778
|
+
}): Promise<T & BaseRecord>;
|
|
779
|
+
/**
|
|
780
|
+
* Create a new record in a collection.
|
|
781
|
+
* @template T The record type
|
|
782
|
+
* @param collection Collection name
|
|
783
|
+
* @param data Record data
|
|
784
|
+
*/
|
|
785
|
+
create<T = any>(collection: string, data: Partial<T>): Promise<T & BaseRecord>;
|
|
786
|
+
/**
|
|
787
|
+
* Full update of an existing record (PUT).
|
|
788
|
+
* @template T The record type
|
|
789
|
+
* @param collection Collection name
|
|
790
|
+
* @param recordId Record ID
|
|
791
|
+
* @param data Record data
|
|
792
|
+
*/
|
|
793
|
+
update<T = any>(collection: string, recordId: string, data: Partial<T>): Promise<T & BaseRecord>;
|
|
794
|
+
/**
|
|
795
|
+
* Partial update of an existing record (PATCH).
|
|
796
|
+
* @template T The record type
|
|
797
|
+
* @param collection Collection name
|
|
798
|
+
* @param recordId Record ID
|
|
799
|
+
* @param data Partial record data
|
|
800
|
+
*/
|
|
801
|
+
patch<T = any>(collection: string, recordId: string, data: Partial<T>): Promise<T & BaseRecord>;
|
|
802
|
+
/**
|
|
803
|
+
* Delete a record from a collection.
|
|
804
|
+
* @param collection Collection name
|
|
805
|
+
* @param recordId Record ID
|
|
806
|
+
*/
|
|
807
|
+
delete(collection: string, recordId: string): Promise<{
|
|
808
|
+
success: boolean;
|
|
809
|
+
}>;
|
|
810
|
+
}
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region src/types/group.d.ts
|
|
813
|
+
interface Group {
|
|
814
|
+
id: string;
|
|
815
|
+
account_id: string;
|
|
816
|
+
name: string;
|
|
817
|
+
description?: string;
|
|
818
|
+
is_system: boolean;
|
|
819
|
+
created_at: string;
|
|
820
|
+
updated_at: string;
|
|
821
|
+
}
|
|
822
|
+
interface GroupCreate {
|
|
823
|
+
name: string;
|
|
824
|
+
description?: string;
|
|
825
|
+
}
|
|
826
|
+
interface GroupUpdate {
|
|
827
|
+
name?: string;
|
|
828
|
+
description?: string;
|
|
829
|
+
}
|
|
830
|
+
interface GroupListParams {
|
|
831
|
+
page?: number;
|
|
832
|
+
page_size?: number;
|
|
833
|
+
search?: string;
|
|
834
|
+
[key: string]: string | number | boolean | undefined;
|
|
835
|
+
}
|
|
836
|
+
interface GroupListResponse {
|
|
837
|
+
items: Group[];
|
|
838
|
+
total: number;
|
|
839
|
+
page: number;
|
|
840
|
+
page_size: number;
|
|
841
|
+
}
|
|
842
|
+
//#endregion
|
|
843
|
+
//#region src/core/group-service.d.ts
|
|
844
|
+
/**
|
|
845
|
+
* Service for managing groups.
|
|
846
|
+
*/
|
|
847
|
+
declare class GroupsService {
|
|
848
|
+
private http;
|
|
849
|
+
constructor(http: HttpClient);
|
|
850
|
+
/**
|
|
851
|
+
* List all groups in the current account.
|
|
852
|
+
*/
|
|
853
|
+
list(params?: GroupListParams): Promise<GroupListResponse>;
|
|
854
|
+
/**
|
|
855
|
+
* Get details for a specific group.
|
|
856
|
+
*/
|
|
857
|
+
get(groupId: string): Promise<Group>;
|
|
858
|
+
/**
|
|
859
|
+
* Create a new group in the current account.
|
|
860
|
+
*/
|
|
861
|
+
create(data: GroupCreate): Promise<Group>;
|
|
862
|
+
/**
|
|
863
|
+
* Update a group's name or description.
|
|
864
|
+
*/
|
|
865
|
+
update(groupId: string, data: GroupUpdate): Promise<Group>;
|
|
866
|
+
/**
|
|
867
|
+
* Delete a group.
|
|
868
|
+
*/
|
|
869
|
+
delete(groupId: string): Promise<{
|
|
870
|
+
success: boolean;
|
|
871
|
+
}>;
|
|
872
|
+
/**
|
|
873
|
+
* Add a user to a group.
|
|
874
|
+
*/
|
|
875
|
+
addMember(groupId: string, userId: string): Promise<{
|
|
876
|
+
success: boolean;
|
|
877
|
+
}>;
|
|
878
|
+
/**
|
|
879
|
+
* Remove a user from a group.
|
|
880
|
+
*/
|
|
881
|
+
removeMember(groupId: string, userId: string): Promise<{
|
|
882
|
+
success: boolean;
|
|
883
|
+
}>;
|
|
884
|
+
}
|
|
885
|
+
//#endregion
|
|
886
|
+
//#region src/types/invitation.d.ts
|
|
887
|
+
interface Invitation {
|
|
888
|
+
id: string;
|
|
889
|
+
email: string;
|
|
890
|
+
account_id: string;
|
|
891
|
+
role_id?: string;
|
|
892
|
+
status: 'pending' | 'accepted' | 'expired' | 'cancelled';
|
|
893
|
+
token?: string;
|
|
894
|
+
expires_at: string;
|
|
895
|
+
created_at: string;
|
|
896
|
+
updated_at: string;
|
|
897
|
+
}
|
|
898
|
+
interface InvitationCreate {
|
|
899
|
+
email: string;
|
|
900
|
+
role_id?: string;
|
|
901
|
+
}
|
|
902
|
+
interface InvitationListParams {
|
|
903
|
+
status?: 'pending' | 'accepted' | 'expired' | 'cancelled';
|
|
904
|
+
page?: number;
|
|
905
|
+
page_size?: number;
|
|
906
|
+
[key: string]: string | number | boolean | undefined;
|
|
907
|
+
}
|
|
908
|
+
//#endregion
|
|
909
|
+
//#region src/core/invitation-service.d.ts
|
|
910
|
+
/**
|
|
911
|
+
* Service for managing user invitations.
|
|
912
|
+
* Allows admins to invite users and tracks invitation status.
|
|
913
|
+
*/
|
|
914
|
+
declare class InvitationService {
|
|
915
|
+
private http;
|
|
916
|
+
constructor(http: HttpClient);
|
|
917
|
+
/**
|
|
918
|
+
* List all invitations in the current account.
|
|
919
|
+
*/
|
|
920
|
+
list(params?: InvitationListParams): Promise<Invitation[]>;
|
|
921
|
+
/**
|
|
922
|
+
* Create a new invitation for a user.
|
|
923
|
+
*/
|
|
924
|
+
create(data: InvitationCreate): Promise<Invitation>;
|
|
925
|
+
/**
|
|
926
|
+
* Resend an invitation email.
|
|
927
|
+
*/
|
|
928
|
+
resend(invitationId: string): Promise<{
|
|
929
|
+
success: boolean;
|
|
930
|
+
}>;
|
|
931
|
+
/**
|
|
932
|
+
* Get public details of an invitation using a token.
|
|
933
|
+
* No authentication required.
|
|
934
|
+
*/
|
|
935
|
+
getPublic(token: string): Promise<Invitation>;
|
|
936
|
+
/**
|
|
937
|
+
* Accept an invitation using a token and password.
|
|
938
|
+
* Creates the user account and returns authentication tokens.
|
|
939
|
+
*/
|
|
940
|
+
accept(token: string, password: string): Promise<AuthResponse>;
|
|
941
|
+
/**
|
|
942
|
+
* Cancel a pending invitation.
|
|
943
|
+
*/
|
|
944
|
+
cancel(invitationId: string): Promise<{
|
|
945
|
+
success: boolean;
|
|
946
|
+
}>;
|
|
947
|
+
}
|
|
948
|
+
//#endregion
|
|
949
|
+
//#region src/types/api-key.d.ts
|
|
950
|
+
interface ApiKey {
|
|
951
|
+
id: string;
|
|
952
|
+
name: string;
|
|
953
|
+
/**
|
|
954
|
+
* The full API key. Only returned once during creation.
|
|
955
|
+
*/
|
|
956
|
+
key?: string;
|
|
957
|
+
/**
|
|
958
|
+
* The masked version of the key (e.g., "sk_...42").
|
|
959
|
+
*/
|
|
960
|
+
masked_key: string;
|
|
961
|
+
/**
|
|
962
|
+
* The last 4 characters of the key.
|
|
963
|
+
*/
|
|
964
|
+
last_4: string;
|
|
965
|
+
expires_at: string | null;
|
|
966
|
+
created_at: string;
|
|
967
|
+
updated_at: string;
|
|
968
|
+
revoked_at: string | null;
|
|
969
|
+
}
|
|
970
|
+
interface ApiKeyCreate {
|
|
971
|
+
name: string;
|
|
972
|
+
expires_at?: string;
|
|
973
|
+
}
|
|
974
|
+
//#endregion
|
|
975
|
+
//#region src/core/api-key-service.d.ts
|
|
976
|
+
/**
|
|
977
|
+
* Service for managing API keys.
|
|
978
|
+
* API keys are used for service-to-service communication.
|
|
979
|
+
*/
|
|
980
|
+
declare class ApiKeyService {
|
|
981
|
+
private http;
|
|
982
|
+
constructor(http: HttpClient);
|
|
983
|
+
/**
|
|
984
|
+
* List all API keys for the current user.
|
|
985
|
+
* Keys are masked except for the last 4 characters.
|
|
986
|
+
*/
|
|
987
|
+
list(): Promise<ApiKey[]>;
|
|
988
|
+
/**
|
|
989
|
+
* Get details for a specific API key.
|
|
990
|
+
* The key itself is masked.
|
|
991
|
+
*/
|
|
992
|
+
get(keyId: string): Promise<ApiKey>;
|
|
993
|
+
/**
|
|
994
|
+
* Create a new API key.
|
|
995
|
+
* The response includes the full key, which is shown only once.
|
|
996
|
+
*/
|
|
997
|
+
create(data: ApiKeyCreate): Promise<ApiKey>;
|
|
998
|
+
/**
|
|
999
|
+
* Revoke an existing API key.
|
|
1000
|
+
* Once revoked, the key can no longer be used.
|
|
1001
|
+
*/
|
|
1002
|
+
revoke(keyId: string): Promise<{
|
|
1003
|
+
success: boolean;
|
|
1004
|
+
}>;
|
|
1005
|
+
}
|
|
1006
|
+
//#endregion
|
|
1007
|
+
//#region src/types/audit-log.d.ts
|
|
1008
|
+
interface AuditLog {
|
|
1009
|
+
id: string;
|
|
1010
|
+
account_id: string;
|
|
1011
|
+
table_name: string;
|
|
1012
|
+
record_id: string;
|
|
1013
|
+
user_id: string;
|
|
1014
|
+
operation: 'create' | 'update' | 'delete' | 'login' | 'logout' | string;
|
|
1015
|
+
before: Record<string, any> | null;
|
|
1016
|
+
after: Record<string, any> | null;
|
|
1017
|
+
created_at: string;
|
|
1018
|
+
}
|
|
1019
|
+
interface AuditLogFilters {
|
|
1020
|
+
account_id?: string;
|
|
1021
|
+
table_name?: string;
|
|
1022
|
+
record_id?: string;
|
|
1023
|
+
user_id?: string;
|
|
1024
|
+
operation?: string;
|
|
1025
|
+
from_date?: string;
|
|
1026
|
+
to_date?: string;
|
|
1027
|
+
page?: number;
|
|
1028
|
+
skip?: number;
|
|
1029
|
+
limit?: number;
|
|
1030
|
+
sort?: string;
|
|
1031
|
+
}
|
|
1032
|
+
type AuditLogExportFormat = 'csv' | 'json';
|
|
1033
|
+
interface AuditLogListResponse {
|
|
1034
|
+
items: AuditLog[];
|
|
1035
|
+
total: number;
|
|
1036
|
+
page: number;
|
|
1037
|
+
limit: number;
|
|
1038
|
+
audit_logging_enabled: boolean;
|
|
1039
|
+
}
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region src/core/audit-log-service.d.ts
|
|
1042
|
+
declare class AuditLogService {
|
|
1043
|
+
private httpClient;
|
|
1044
|
+
constructor(httpClient: HttpClient);
|
|
1045
|
+
/**
|
|
1046
|
+
* Lists audit logs with optional filtering, pagination, and sorting.
|
|
1047
|
+
*/
|
|
1048
|
+
list(params?: AuditLogFilters): Promise<AuditLogListResponse>;
|
|
1049
|
+
/**
|
|
1050
|
+
* Retrieves a single audit log entry by ID.
|
|
1051
|
+
*/
|
|
1052
|
+
get(logId: string): Promise<AuditLog>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Exports audit logs in the specified format.
|
|
1055
|
+
*/
|
|
1056
|
+
export(params?: AuditLogFilters, format?: AuditLogExportFormat): Promise<string>;
|
|
1057
|
+
}
|
|
1058
|
+
//#endregion
|
|
1059
|
+
//#region src/types/role.d.ts
|
|
1060
|
+
interface Role {
|
|
1061
|
+
id: string;
|
|
1062
|
+
name: string;
|
|
1063
|
+
description: string;
|
|
1064
|
+
created_at: string;
|
|
1065
|
+
updated_at: string;
|
|
1066
|
+
}
|
|
1067
|
+
interface RoleCreate {
|
|
1068
|
+
name: string;
|
|
1069
|
+
description?: string;
|
|
1070
|
+
}
|
|
1071
|
+
interface RoleUpdate {
|
|
1072
|
+
name?: string;
|
|
1073
|
+
description?: string;
|
|
1074
|
+
}
|
|
1075
|
+
interface RoleListResponse {
|
|
1076
|
+
items: Role[];
|
|
1077
|
+
total: number;
|
|
1078
|
+
}
|
|
1079
|
+
interface CollectionRule {
|
|
1080
|
+
list_rule: string | null;
|
|
1081
|
+
view_rule: string | null;
|
|
1082
|
+
create_rule: string | null;
|
|
1083
|
+
update_rule: string | null;
|
|
1084
|
+
delete_rule: string | null;
|
|
1085
|
+
list_fields: string;
|
|
1086
|
+
view_fields: string;
|
|
1087
|
+
create_fields: string;
|
|
1088
|
+
update_fields: string;
|
|
1089
|
+
}
|
|
1090
|
+
interface CollectionRuleUpdate {
|
|
1091
|
+
list_rule?: string | null;
|
|
1092
|
+
view_rule?: string | null;
|
|
1093
|
+
create_rule?: string | null;
|
|
1094
|
+
update_rule?: string | null;
|
|
1095
|
+
delete_rule?: string | null;
|
|
1096
|
+
list_fields?: string;
|
|
1097
|
+
view_fields?: string;
|
|
1098
|
+
create_fields?: string;
|
|
1099
|
+
update_fields?: string;
|
|
1100
|
+
}
|
|
1101
|
+
interface RuleValidationResult {
|
|
1102
|
+
valid: boolean;
|
|
1103
|
+
errors?: string[];
|
|
1104
|
+
}
|
|
1105
|
+
interface RuleTestResult {
|
|
1106
|
+
result: boolean;
|
|
1107
|
+
}
|
|
1108
|
+
interface RuleValidationParams {
|
|
1109
|
+
rule: string;
|
|
1110
|
+
operation: 'list' | 'view' | 'create' | 'update' | 'delete';
|
|
1111
|
+
collectionFields: string[];
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* Permission type alias for CollectionRule (Permission System V2).
|
|
1115
|
+
*/
|
|
1116
|
+
type Permission = CollectionRule;
|
|
1117
|
+
//#endregion
|
|
1118
|
+
//#region src/core/role-service.d.ts
|
|
1119
|
+
/**
|
|
1120
|
+
* Service for managing roles.
|
|
1121
|
+
* Requires superadmin authentication.
|
|
1122
|
+
*/
|
|
1123
|
+
declare class RoleService {
|
|
1124
|
+
private http;
|
|
1125
|
+
constructor(http: HttpClient);
|
|
1126
|
+
/**
|
|
1127
|
+
* List all roles with pagination.
|
|
1128
|
+
*/
|
|
1129
|
+
list(): Promise<RoleListResponse>;
|
|
1130
|
+
/**
|
|
1131
|
+
* Get details for a specific role.
|
|
1132
|
+
*/
|
|
1133
|
+
get(roleId: string): Promise<Role>;
|
|
1134
|
+
/**
|
|
1135
|
+
* Create a new role.
|
|
1136
|
+
*/
|
|
1137
|
+
create(data: RoleCreate): Promise<Role>;
|
|
1138
|
+
/**
|
|
1139
|
+
* Update an existing role.
|
|
1140
|
+
*/
|
|
1141
|
+
update(roleId: string, data: RoleUpdate): Promise<Role>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Delete a role.
|
|
1144
|
+
* Fails if the role is currently in use.
|
|
1145
|
+
*/
|
|
1146
|
+
delete(roleId: string): Promise<{
|
|
1147
|
+
success: boolean;
|
|
1148
|
+
}>;
|
|
1149
|
+
}
|
|
1150
|
+
//#endregion
|
|
1151
|
+
//#region src/core/collection-rule-service.d.ts
|
|
1152
|
+
/**
|
|
1153
|
+
* Service for managing collection-level access rules and field permissions.
|
|
1154
|
+
* Requires superadmin authentication.
|
|
1155
|
+
*/
|
|
1156
|
+
declare class CollectionRuleService {
|
|
1157
|
+
private http;
|
|
1158
|
+
constructor(http: HttpClient);
|
|
1159
|
+
/**
|
|
1160
|
+
* Get access rules and field permissions for a specific collection.
|
|
1161
|
+
*/
|
|
1162
|
+
get(collectionName: string): Promise<CollectionRule>;
|
|
1163
|
+
/**
|
|
1164
|
+
* Update access rules and field permissions for a specific collection.
|
|
1165
|
+
*/
|
|
1166
|
+
update(collectionName: string, data: CollectionRuleUpdate): Promise<CollectionRule>;
|
|
1167
|
+
/**
|
|
1168
|
+
* Validate a rule expression against a collection schema.
|
|
1169
|
+
*/
|
|
1170
|
+
validateRule(rule: string, operation: 'list' | 'view' | 'create' | 'update' | 'delete', collectionFields: string[]): Promise<RuleValidationResult>;
|
|
1171
|
+
/**
|
|
1172
|
+
* Test a rule evaluation with a sample context.
|
|
1173
|
+
*/
|
|
1174
|
+
testRule(rule: string, context: any): Promise<RuleTestResult>;
|
|
1175
|
+
}
|
|
1176
|
+
//#endregion
|
|
1177
|
+
//#region src/types/macro.d.ts
|
|
1178
|
+
interface Macro {
|
|
1179
|
+
id: string;
|
|
1180
|
+
name: string;
|
|
1181
|
+
description: string;
|
|
1182
|
+
sql_query: string;
|
|
1183
|
+
parameters: string[];
|
|
1184
|
+
is_builtin: boolean;
|
|
1185
|
+
created_at: string;
|
|
1186
|
+
updated_at: string;
|
|
1187
|
+
}
|
|
1188
|
+
interface MacroCreate {
|
|
1189
|
+
name: string;
|
|
1190
|
+
description: string;
|
|
1191
|
+
sql_query: string;
|
|
1192
|
+
parameters: string[];
|
|
1193
|
+
}
|
|
1194
|
+
interface MacroUpdate {
|
|
1195
|
+
name?: string;
|
|
1196
|
+
description?: string;
|
|
1197
|
+
sql_query?: string;
|
|
1198
|
+
parameters?: string[];
|
|
1199
|
+
}
|
|
1200
|
+
interface MacroTestResult {
|
|
1201
|
+
success: boolean;
|
|
1202
|
+
result: any;
|
|
1203
|
+
}
|
|
1204
|
+
interface MacroListResponse {
|
|
1205
|
+
items: Macro[];
|
|
1206
|
+
total: number;
|
|
1207
|
+
}
|
|
1208
|
+
//#endregion
|
|
1209
|
+
//#region src/core/macro-service.d.ts
|
|
1210
|
+
/**
|
|
1211
|
+
* Service for managing SQL macros.
|
|
1212
|
+
* Macros can be used in permission rules.
|
|
1213
|
+
* Requires superadmin authentication for most operations.
|
|
1214
|
+
*/
|
|
1215
|
+
declare class MacroService {
|
|
1216
|
+
private http;
|
|
1217
|
+
constructor(http: HttpClient);
|
|
1218
|
+
/**
|
|
1219
|
+
* List all macros, including built-in ones.
|
|
1220
|
+
*/
|
|
1221
|
+
list(): Promise<MacroListResponse>;
|
|
1222
|
+
/**
|
|
1223
|
+
* Get details for a specific macro.
|
|
1224
|
+
*/
|
|
1225
|
+
get(macroId: string): Promise<Macro>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Create a new custom macro.
|
|
1228
|
+
*/
|
|
1229
|
+
create(data: MacroCreate): Promise<Macro>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Update an existing custom macro.
|
|
1232
|
+
* Built-in macros cannot be updated.
|
|
1233
|
+
*/
|
|
1234
|
+
update(macroId: string, data: MacroUpdate): Promise<Macro>;
|
|
1235
|
+
/**
|
|
1236
|
+
* Delete a macro.
|
|
1237
|
+
* Fails if the macro is built-in or currently in use.
|
|
1238
|
+
*/
|
|
1239
|
+
delete(macroId: string): Promise<{
|
|
1240
|
+
success: boolean;
|
|
1241
|
+
}>;
|
|
1242
|
+
/**
|
|
1243
|
+
* Test a macro with parameters.
|
|
1244
|
+
*/
|
|
1245
|
+
test(macroId: string, params: Record<string, any>): Promise<MacroTestResult>;
|
|
1246
|
+
}
|
|
1247
|
+
//#endregion
|
|
1248
|
+
//#region src/types/dashboard.d.ts
|
|
1249
|
+
/**
|
|
1250
|
+
* Dashboard statistics and metrics for superadmins.
|
|
1251
|
+
*/
|
|
1252
|
+
interface DashboardStats {
|
|
1253
|
+
/** Total number of accounts in the system */
|
|
1254
|
+
total_accounts: number;
|
|
1255
|
+
/** Total number of users across all accounts */
|
|
1256
|
+
total_users: number;
|
|
1257
|
+
/** Total number of collections defined */
|
|
1258
|
+
total_collections: number;
|
|
1259
|
+
/** Total number of records across all collections */
|
|
1260
|
+
total_records: number;
|
|
1261
|
+
/** Number of new accounts created in the last 7 days */
|
|
1262
|
+
new_accounts_7d: number;
|
|
1263
|
+
/** Number of new users registered in the last 7 days */
|
|
1264
|
+
new_users_7d: number;
|
|
1265
|
+
/** List of the most recent user registrations */
|
|
1266
|
+
recent_registrations: User$1[];
|
|
1267
|
+
/** Overview of current system health and status */
|
|
1268
|
+
system_health: SystemHealth;
|
|
1269
|
+
/** Number of currently active user sessions */
|
|
1270
|
+
active_sessions: number;
|
|
1271
|
+
/** List of the most recent audit log entries */
|
|
1272
|
+
recent_audit_logs: AuditLog[];
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* System health information.
|
|
1276
|
+
*/
|
|
1277
|
+
interface SystemHealth {
|
|
1278
|
+
/** overall status of the system */
|
|
1279
|
+
status: 'healthy' | 'degraded' | 'unhealthy' | string;
|
|
1280
|
+
/** System uptime (e.g., "7 days, 4 hours") */
|
|
1281
|
+
uptime?: string;
|
|
1282
|
+
/** Current version of the SnackBase server */
|
|
1283
|
+
version?: string;
|
|
1284
|
+
/** Additional health metrics */
|
|
1285
|
+
[key: string]: any;
|
|
1286
|
+
}
|
|
1287
|
+
//#endregion
|
|
1288
|
+
//#region src/core/dashboard-service.d.ts
|
|
1289
|
+
/**
|
|
1290
|
+
* Service for interacting with the Dashboard API.
|
|
1291
|
+
* Provides statistics and metrics for system monitoring.
|
|
1292
|
+
*/
|
|
1293
|
+
declare class DashboardService {
|
|
1294
|
+
private httpClient;
|
|
1295
|
+
constructor(httpClient: HttpClient);
|
|
1296
|
+
/**
|
|
1297
|
+
* Retrieves dashboard statistics including counts for accounts, users,
|
|
1298
|
+
* collections, and records, as well as recent activity and health metrics.
|
|
1299
|
+
*
|
|
1300
|
+
* @returns {Promise<DashboardStats>} A promise that resolves to dashboard statistics.
|
|
1301
|
+
* @throws {AuthenticationError} If not authenticated.
|
|
1302
|
+
* @throws {AuthorizationError} If the user is not a superadmin.
|
|
1303
|
+
*/
|
|
1304
|
+
getStats(): Promise<DashboardStats>;
|
|
1305
|
+
}
|
|
1306
|
+
//#endregion
|
|
1307
|
+
//#region src/types/admin.d.ts
|
|
1308
|
+
/**
|
|
1309
|
+
* Configuration record representing a system or account level setting.
|
|
1310
|
+
*/
|
|
1311
|
+
interface Configuration {
|
|
1312
|
+
id: string;
|
|
1313
|
+
name: string;
|
|
1314
|
+
category: string;
|
|
1315
|
+
provider_name: string;
|
|
1316
|
+
is_system: boolean;
|
|
1317
|
+
account_id?: string;
|
|
1318
|
+
enabled: boolean;
|
|
1319
|
+
created_at: string;
|
|
1320
|
+
updated_at: string;
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Statistics for configurations by category.
|
|
1324
|
+
*/
|
|
1325
|
+
interface ConfigurationStats {
|
|
1326
|
+
system_count: number;
|
|
1327
|
+
account_count: number;
|
|
1328
|
+
by_category: Record<string, {
|
|
1329
|
+
system: number;
|
|
1330
|
+
account: number;
|
|
1331
|
+
}>;
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Available provider definition.
|
|
1335
|
+
*/
|
|
1336
|
+
interface ProviderDefinition {
|
|
1337
|
+
name: string;
|
|
1338
|
+
display_name: string;
|
|
1339
|
+
category: string;
|
|
1340
|
+
description?: string;
|
|
1341
|
+
is_built_in: boolean;
|
|
1342
|
+
icon?: string;
|
|
1343
|
+
}
|
|
1344
|
+
/**
|
|
1345
|
+
* Connection test result.
|
|
1346
|
+
*/
|
|
1347
|
+
interface ConnectionTestResult {
|
|
1348
|
+
success: boolean;
|
|
1349
|
+
message: string;
|
|
1350
|
+
details?: Record<string, any>;
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Request data for creating a configuration.
|
|
1354
|
+
*/
|
|
1355
|
+
interface ConfigurationCreate {
|
|
1356
|
+
name: string;
|
|
1357
|
+
category: string;
|
|
1358
|
+
provider_name: string;
|
|
1359
|
+
values: Record<string, any>;
|
|
1360
|
+
is_system?: boolean;
|
|
1361
|
+
account_id?: string;
|
|
1362
|
+
enabled?: boolean;
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* Recent configuration summary.
|
|
1366
|
+
*/
|
|
1367
|
+
interface RecentConfiguration extends Configuration {
|
|
1368
|
+
last_modified_by?: {
|
|
1369
|
+
id: string;
|
|
1370
|
+
email: string;
|
|
1371
|
+
};
|
|
1372
|
+
}
|
|
1373
|
+
//#endregion
|
|
1374
|
+
//#region src/core/admin-service.d.ts
|
|
1375
|
+
/**
|
|
1376
|
+
* Service for superadmin operations and system configuration management.
|
|
1377
|
+
*/
|
|
1378
|
+
declare class AdminService {
|
|
1379
|
+
private http;
|
|
1380
|
+
constructor(http: HttpClient);
|
|
1381
|
+
/**
|
|
1382
|
+
* Returns configuration statistics by category.
|
|
1383
|
+
*/
|
|
1384
|
+
getConfigurationStats(): Promise<ConfigurationStats>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Returns recently modified configurations.
|
|
1387
|
+
* @param limit Number of configurations to return
|
|
1388
|
+
*/
|
|
1389
|
+
getRecentConfigurations(limit?: number): Promise<RecentConfiguration[]>;
|
|
1390
|
+
/**
|
|
1391
|
+
* Returns all system-level configurations.
|
|
1392
|
+
* @param category Optional category filter
|
|
1393
|
+
*/
|
|
1394
|
+
listSystemConfigurations(category?: string): Promise<Configuration[]>;
|
|
1395
|
+
/**
|
|
1396
|
+
* Returns configurations for specific account.
|
|
1397
|
+
* @param accountId Account ID
|
|
1398
|
+
* @param category Optional category filter
|
|
1399
|
+
*/
|
|
1400
|
+
listAccountConfigurations(accountId: string, category?: string): Promise<Configuration[]>;
|
|
1401
|
+
/**
|
|
1402
|
+
* Returns decrypted configuration values with secrets masked.
|
|
1403
|
+
* @param configId Configuration ID
|
|
1404
|
+
*/
|
|
1405
|
+
getConfigurationValues(configId: string): Promise<Record<string, any>>;
|
|
1406
|
+
/**
|
|
1407
|
+
* Updates configuration values.
|
|
1408
|
+
* @param configId Configuration ID
|
|
1409
|
+
* @param values New configuration values
|
|
1410
|
+
*/
|
|
1411
|
+
updateConfigurationValues(configId: string, values: Record<string, any>): Promise<Record<string, any>>;
|
|
1412
|
+
/**
|
|
1413
|
+
* Enables or disables configuration.
|
|
1414
|
+
* @param configId Configuration ID
|
|
1415
|
+
* @param enabled Enabled status
|
|
1416
|
+
*/
|
|
1417
|
+
updateConfigurationStatus(configId: string, enabled: boolean): Promise<Configuration>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Creates new configuration record.
|
|
1420
|
+
* @param data Configuration data
|
|
1421
|
+
*/
|
|
1422
|
+
createConfiguration(data: ConfigurationCreate): Promise<Configuration>;
|
|
1423
|
+
/**
|
|
1424
|
+
* Deletes configuration.
|
|
1425
|
+
* @param configId Configuration ID
|
|
1426
|
+
*/
|
|
1427
|
+
deleteConfiguration(configId: string): Promise<{
|
|
1428
|
+
success: boolean;
|
|
1429
|
+
}>;
|
|
1430
|
+
/**
|
|
1431
|
+
* Lists all available provider definitions.
|
|
1432
|
+
* @param category Optional category filter
|
|
1433
|
+
*/
|
|
1434
|
+
listProviders(category?: string): Promise<ProviderDefinition[]>;
|
|
1435
|
+
/**
|
|
1436
|
+
* Returns JSON schema for provider configuration.
|
|
1437
|
+
* @param category Provider category
|
|
1438
|
+
* @param providerName Provider name
|
|
1439
|
+
*/
|
|
1440
|
+
getProviderSchema(category: string, providerName: string): Promise<Record<string, any>>;
|
|
1441
|
+
/**
|
|
1442
|
+
* Tests provider connection.
|
|
1443
|
+
* @param category Provider category
|
|
1444
|
+
* @param providerName Provider name
|
|
1445
|
+
* @param config Configuration values to test
|
|
1446
|
+
*/
|
|
1447
|
+
testConnection(category: string, providerName: string, config: Record<string, any>): Promise<ConnectionTestResult>;
|
|
1448
|
+
}
|
|
1449
|
+
//#endregion
|
|
1450
|
+
//#region src/types/email-template.d.ts
|
|
1451
|
+
/**
|
|
1452
|
+
* Email template type.
|
|
1453
|
+
*/
|
|
1454
|
+
type EmailTemplateType = 'verification' | 'reset_password' | 'invitation' | string;
|
|
1455
|
+
/**
|
|
1456
|
+
* Email template interface.
|
|
1457
|
+
*/
|
|
1458
|
+
interface EmailTemplate {
|
|
1459
|
+
id: string;
|
|
1460
|
+
template_type: EmailTemplateType;
|
|
1461
|
+
locale: string;
|
|
1462
|
+
subject: string;
|
|
1463
|
+
html_body: string;
|
|
1464
|
+
text_body: string;
|
|
1465
|
+
enabled: boolean;
|
|
1466
|
+
account_id?: string;
|
|
1467
|
+
created_at: string;
|
|
1468
|
+
updated_at: string;
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Data for updating an email template.
|
|
1472
|
+
*/
|
|
1473
|
+
interface EmailTemplateUpdate {
|
|
1474
|
+
subject?: string;
|
|
1475
|
+
html_body?: string;
|
|
1476
|
+
text_body?: string;
|
|
1477
|
+
enabled?: boolean;
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Filters for listing email templates.
|
|
1481
|
+
*/
|
|
1482
|
+
interface EmailTemplateFilters {
|
|
1483
|
+
[key: string]: string | number | boolean | undefined;
|
|
1484
|
+
template_type?: EmailTemplateType;
|
|
1485
|
+
locale?: string;
|
|
1486
|
+
account_id?: string;
|
|
1487
|
+
enabled?: boolean;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* Request for rendering an email template.
|
|
1491
|
+
*/
|
|
1492
|
+
interface EmailTemplateRenderRequest {
|
|
1493
|
+
template_type: EmailTemplateType;
|
|
1494
|
+
locale: string;
|
|
1495
|
+
variables: Record<string, any>;
|
|
1496
|
+
subject_override?: string;
|
|
1497
|
+
html_body_override?: string;
|
|
1498
|
+
text_body_override?: string;
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Response from rendering an email template.
|
|
1502
|
+
*/
|
|
1503
|
+
interface EmailTemplateRenderResponse {
|
|
1504
|
+
subject: string;
|
|
1505
|
+
html_body: string;
|
|
1506
|
+
text_body: string;
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Email log interface.
|
|
1510
|
+
*/
|
|
1511
|
+
interface EmailLog {
|
|
1512
|
+
id: string;
|
|
1513
|
+
account_id: string;
|
|
1514
|
+
template_type: EmailTemplateType;
|
|
1515
|
+
recipient: string;
|
|
1516
|
+
subject: string;
|
|
1517
|
+
status: 'sent' | 'failed' | 'pending';
|
|
1518
|
+
provider: string;
|
|
1519
|
+
error?: string;
|
|
1520
|
+
sent_at: string;
|
|
1521
|
+
metadata?: Record<string, any>;
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* Filters for listing email logs.
|
|
1525
|
+
*/
|
|
1526
|
+
interface EmailLogFilters {
|
|
1527
|
+
[key: string]: string | number | boolean | undefined;
|
|
1528
|
+
status?: string;
|
|
1529
|
+
template_type?: EmailTemplateType;
|
|
1530
|
+
start_date?: string;
|
|
1531
|
+
end_date?: string;
|
|
1532
|
+
page?: number;
|
|
1533
|
+
limit?: number;
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Paginated response for email logs.
|
|
1537
|
+
*/
|
|
1538
|
+
interface EmailLogListResponse {
|
|
1539
|
+
data: EmailLog[];
|
|
1540
|
+
total: number;
|
|
1541
|
+
page: number;
|
|
1542
|
+
limit: number;
|
|
1543
|
+
last_page: number;
|
|
1544
|
+
}
|
|
1545
|
+
//#endregion
|
|
1546
|
+
//#region src/core/email-template-service.d.ts
|
|
1547
|
+
/**
|
|
1548
|
+
* Service for managing email templates and logs.
|
|
1549
|
+
*/
|
|
1550
|
+
declare class EmailTemplateService {
|
|
1551
|
+
private http;
|
|
1552
|
+
constructor(http: HttpClient);
|
|
1553
|
+
/**
|
|
1554
|
+
* Returns a list of email templates.
|
|
1555
|
+
* @param filters Optional filters for listing templates
|
|
1556
|
+
*/
|
|
1557
|
+
list(filters?: EmailTemplateFilters): Promise<EmailTemplate[]>;
|
|
1558
|
+
/**
|
|
1559
|
+
* Returns email template details.
|
|
1560
|
+
* @param templateId Template ID
|
|
1561
|
+
*/
|
|
1562
|
+
get(templateId: string): Promise<EmailTemplate>;
|
|
1563
|
+
/**
|
|
1564
|
+
* Updates an email template.
|
|
1565
|
+
* @param templateId Template ID
|
|
1566
|
+
* @param data Update data
|
|
1567
|
+
*/
|
|
1568
|
+
update(templateId: string, data: EmailTemplateUpdate): Promise<EmailTemplate>;
|
|
1569
|
+
/**
|
|
1570
|
+
* Renders an email template with provided variables.
|
|
1571
|
+
* @param request Render request data
|
|
1572
|
+
*/
|
|
1573
|
+
render(request: EmailTemplateRenderRequest): Promise<EmailTemplateRenderResponse>;
|
|
1574
|
+
/**
|
|
1575
|
+
* Sends a test email using the specified template.
|
|
1576
|
+
* @param templateId Template ID
|
|
1577
|
+
* @param recipientEmail Recipient email address
|
|
1578
|
+
* @param variables Template variables
|
|
1579
|
+
* @param provider Optional provider override
|
|
1580
|
+
*/
|
|
1581
|
+
sendTest(templateId: string, recipientEmail: string, variables?: Record<string, any>, provider?: string): Promise<{
|
|
1582
|
+
success: boolean;
|
|
1583
|
+
}>;
|
|
1584
|
+
/**
|
|
1585
|
+
* Returns a paginated list of email logs.
|
|
1586
|
+
* @param filters Optional filters for listing logs
|
|
1587
|
+
*/
|
|
1588
|
+
listLogs(filters?: EmailLogFilters): Promise<EmailLogListResponse>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Returns single email log details.
|
|
1591
|
+
* @param logId Log ID
|
|
1592
|
+
*/
|
|
1593
|
+
getLog(logId: string): Promise<EmailLog>;
|
|
1594
|
+
}
|
|
1595
|
+
//#endregion
|
|
1596
|
+
//#region src/types/file.d.ts
|
|
1597
|
+
/**
|
|
1598
|
+
* Metadata for a file.
|
|
1599
|
+
*/
|
|
1600
|
+
interface FileMetadata {
|
|
1601
|
+
/**
|
|
1602
|
+
* Safe filename.
|
|
1603
|
+
*/
|
|
1604
|
+
filename: string;
|
|
1605
|
+
/**
|
|
1606
|
+
* MIME type of the file.
|
|
1607
|
+
*/
|
|
1608
|
+
contentType: string;
|
|
1609
|
+
/**
|
|
1610
|
+
* File size in bytes.
|
|
1611
|
+
*/
|
|
1612
|
+
size: number;
|
|
1613
|
+
/**
|
|
1614
|
+
* Server path to the file.
|
|
1615
|
+
*/
|
|
1616
|
+
path: string;
|
|
1617
|
+
/**
|
|
1618
|
+
* Upload timestamp.
|
|
1619
|
+
*/
|
|
1620
|
+
created_at: string;
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Options for file upload.
|
|
1624
|
+
*/
|
|
1625
|
+
interface FileUploadOptions {
|
|
1626
|
+
/**
|
|
1627
|
+
* Custom filename for the upload.
|
|
1628
|
+
*/
|
|
1629
|
+
filename?: string;
|
|
1630
|
+
/**
|
|
1631
|
+
* Custom content type for the upload.
|
|
1632
|
+
*/
|
|
1633
|
+
contentType?: string;
|
|
1634
|
+
}
|
|
1635
|
+
//#endregion
|
|
1636
|
+
//#region src/core/file-service.d.ts
|
|
1637
|
+
/**
|
|
1638
|
+
* Service for working with files (upload, download, delete).
|
|
1639
|
+
*/
|
|
1640
|
+
declare class FileService {
|
|
1641
|
+
private http;
|
|
1642
|
+
private getBaseUrl;
|
|
1643
|
+
private getToken;
|
|
1644
|
+
constructor(http: HttpClient, getBaseUrl: () => string, getToken: () => string | null);
|
|
1645
|
+
/**
|
|
1646
|
+
* Upload a file to the server.
|
|
1647
|
+
* @param file The file or blob to upload
|
|
1648
|
+
* @param options Optional upload options (filename, contentType)
|
|
1649
|
+
*/
|
|
1650
|
+
upload(file: File | Blob, options?: FileUploadOptions): Promise<FileMetadata>;
|
|
1651
|
+
/**
|
|
1652
|
+
* Get the download URL for a file.
|
|
1653
|
+
* @param path The server path to the file
|
|
1654
|
+
*/
|
|
1655
|
+
getDownloadUrl(path: string): string;
|
|
1656
|
+
/**
|
|
1657
|
+
* Delete a file from the server.
|
|
1658
|
+
* @param path The server path to the file
|
|
1659
|
+
*/
|
|
1660
|
+
delete(path: string): Promise<{
|
|
1661
|
+
success: boolean;
|
|
1662
|
+
}>;
|
|
1663
|
+
}
|
|
1664
|
+
//#endregion
|
|
1665
|
+
//#region src/types/realtime.d.ts
|
|
1666
|
+
type RealTimeState = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
1667
|
+
type RealTimeEvent = 'connecting' | 'connected' | 'disconnected' | 'error' | 'message';
|
|
1668
|
+
type WebSocketAction = 'subscribe' | 'unsubscribe' | 'ping';
|
|
1669
|
+
interface WebSocketMessage {
|
|
1670
|
+
action: WebSocketAction;
|
|
1671
|
+
collection?: string;
|
|
1672
|
+
operations?: string[];
|
|
1673
|
+
}
|
|
1674
|
+
interface ServerMessage {
|
|
1675
|
+
type: string | 'heartbeat' | 'pong' | 'subscribed' | 'unsubscribed';
|
|
1676
|
+
timestamp: string;
|
|
1677
|
+
data?: any;
|
|
1678
|
+
collection?: string;
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* Real-time event object structure
|
|
1682
|
+
* @template T - Type of the event data
|
|
1683
|
+
*/
|
|
1684
|
+
interface RealtimeEvent<T = any> {
|
|
1685
|
+
/** Event type in format: {collection}.{operation} (e.g., "posts.create") */
|
|
1686
|
+
type: string;
|
|
1687
|
+
/** ISO 8601 timestamp */
|
|
1688
|
+
timestamp: string;
|
|
1689
|
+
/** Event data - full record for create/update, ID only for delete */
|
|
1690
|
+
data: T;
|
|
1691
|
+
}
|
|
1692
|
+
interface RealTimeConfig {
|
|
1693
|
+
maxReconnectionAttempts?: number;
|
|
1694
|
+
heartbeatInterval?: number;
|
|
1695
|
+
reconnectionDelay?: (attempt: number) => number;
|
|
1696
|
+
}
|
|
1697
|
+
type RealTimeEventHandler = (data?: any) => void;
|
|
1698
|
+
/**
|
|
1699
|
+
* Real-time event handlers
|
|
1700
|
+
*
|
|
1701
|
+
* Event type formats:
|
|
1702
|
+
* - Connection events: 'connecting', 'connected', 'disconnected', 'error'
|
|
1703
|
+
* - Message event: 'message' - receives full ServerMessage
|
|
1704
|
+
* - Specific events: '{collection}.{operation}' (e.g., 'posts.create')
|
|
1705
|
+
* - Collection wildcard: '{collection}.*' (e.g., 'posts.*') - all events for a collection
|
|
1706
|
+
* - Global wildcard: '*' - all events
|
|
1707
|
+
*/
|
|
1708
|
+
interface RealTimeEvents {
|
|
1709
|
+
connecting: () => void;
|
|
1710
|
+
connected: () => void;
|
|
1711
|
+
disconnected: () => void;
|
|
1712
|
+
error: (error: Error) => void;
|
|
1713
|
+
auth_error: (error: Error) => void;
|
|
1714
|
+
message: (data: ServerMessage) => void;
|
|
1715
|
+
[key: string]: RealTimeEventHandler;
|
|
1716
|
+
}
|
|
1717
|
+
//#endregion
|
|
1718
|
+
//#region src/core/realtime-service.d.ts
|
|
1719
|
+
interface RealTimeOptions {
|
|
1720
|
+
baseUrl: string;
|
|
1721
|
+
getToken: () => string | null;
|
|
1722
|
+
authManager?: AuthManager;
|
|
1723
|
+
maxRetries?: number;
|
|
1724
|
+
reconnectionDelay?: number;
|
|
1725
|
+
logger?: Logger;
|
|
1726
|
+
}
|
|
1727
|
+
declare class RealTimeService {
|
|
1728
|
+
private options;
|
|
1729
|
+
private state;
|
|
1730
|
+
private socket;
|
|
1731
|
+
private sse;
|
|
1732
|
+
private listeners;
|
|
1733
|
+
private retryCount;
|
|
1734
|
+
private reconnectTimer;
|
|
1735
|
+
private heartbeatTimer;
|
|
1736
|
+
private subscriptions;
|
|
1737
|
+
private subscriptionRequests;
|
|
1738
|
+
private pendingSubscriptions;
|
|
1739
|
+
private authUnsubscribe?;
|
|
1740
|
+
private isReconnectingForAuth;
|
|
1741
|
+
constructor(options: RealTimeOptions);
|
|
1742
|
+
connect(): Promise<void>;
|
|
1743
|
+
disconnect(): void;
|
|
1744
|
+
getState(): RealTimeState;
|
|
1745
|
+
on<K extends keyof RealTimeEvents>(event: K, handler: RealTimeEvents[K]): () => void;
|
|
1746
|
+
off<K extends keyof RealTimeEvents>(event: K, handler: RealTimeEvents[K]): void;
|
|
1747
|
+
subscribe(collection: string, operations?: string[]): Promise<void>;
|
|
1748
|
+
unsubscribe(collection: string): Promise<void>;
|
|
1749
|
+
getSubscriptions(): string[];
|
|
1750
|
+
private doConnect;
|
|
1751
|
+
private connectWebSocket;
|
|
1752
|
+
private connectSSE;
|
|
1753
|
+
private handleMessage;
|
|
1754
|
+
private handleReconnect;
|
|
1755
|
+
private handleError;
|
|
1756
|
+
private setState;
|
|
1757
|
+
private emit;
|
|
1758
|
+
private send;
|
|
1759
|
+
private startHeartbeat;
|
|
1760
|
+
private resubscribe;
|
|
1761
|
+
private clearTimers;
|
|
1762
|
+
private closeConnections;
|
|
1763
|
+
/**
|
|
1764
|
+
* Handle token refresh by reconnecting with new token
|
|
1765
|
+
*/
|
|
1766
|
+
private handleTokenRefresh;
|
|
1767
|
+
}
|
|
1768
|
+
//#endregion
|
|
1769
|
+
//#region src/types/migration.d.ts
|
|
1770
|
+
/**
|
|
1771
|
+
* Migration-related type definitions.
|
|
1772
|
+
*/
|
|
1773
|
+
/**
|
|
1774
|
+
* Represents a single migration revision.
|
|
1775
|
+
*/
|
|
1776
|
+
interface MigrationRevision {
|
|
1777
|
+
/** The revision identifier (e.g., "001_abc123") */
|
|
1778
|
+
revision: string;
|
|
1779
|
+
/** Human-readable description of the migration */
|
|
1780
|
+
description: string;
|
|
1781
|
+
/** Whether this revision has been applied to the database */
|
|
1782
|
+
isApplied: boolean;
|
|
1783
|
+
/** Whether this is a dynamic collection migration */
|
|
1784
|
+
isDynamic: boolean;
|
|
1785
|
+
}
|
|
1786
|
+
/**
|
|
1787
|
+
* Response from listing all migrations.
|
|
1788
|
+
*/
|
|
1789
|
+
interface MigrationListResponse {
|
|
1790
|
+
/** All available migration revisions */
|
|
1791
|
+
revisions: MigrationRevision[];
|
|
1792
|
+
/** Total number of revisions */
|
|
1793
|
+
total: number;
|
|
1794
|
+
/** The currently applied revision (if any) */
|
|
1795
|
+
currentRevision: string | null;
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* Response from getting the current migration.
|
|
1799
|
+
*/
|
|
1800
|
+
interface CurrentRevisionResponse {
|
|
1801
|
+
/** The current revision identifier */
|
|
1802
|
+
revision: string;
|
|
1803
|
+
/** Human-readable description of the migration */
|
|
1804
|
+
description: string;
|
|
1805
|
+
/** Timestamp when this revision was applied */
|
|
1806
|
+
appliedAt: string;
|
|
1807
|
+
/** Whether this is a dynamic collection migration */
|
|
1808
|
+
isDynamic: boolean;
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* A single item in the migration history.
|
|
1812
|
+
*/
|
|
1813
|
+
interface MigrationHistoryItem {
|
|
1814
|
+
/** The revision identifier */
|
|
1815
|
+
revision: string;
|
|
1816
|
+
/** Human-readable description of the migration */
|
|
1817
|
+
description: string;
|
|
1818
|
+
/** Whether this is a dynamic collection migration */
|
|
1819
|
+
isDynamic: boolean;
|
|
1820
|
+
/** Timestamp when this revision was applied */
|
|
1821
|
+
createdAt: string;
|
|
1822
|
+
}
|
|
1823
|
+
/**
|
|
1824
|
+
* Response from getting migration history.
|
|
1825
|
+
*/
|
|
1826
|
+
interface MigrationHistoryResponse {
|
|
1827
|
+
/** Applied migrations in chronological order */
|
|
1828
|
+
history: MigrationHistoryItem[];
|
|
1829
|
+
/** Total number of applied migrations */
|
|
1830
|
+
total: number;
|
|
1831
|
+
}
|
|
1832
|
+
//#endregion
|
|
1833
|
+
//#region src/core/migration-service.d.ts
|
|
1834
|
+
/**
|
|
1835
|
+
* Service for viewing migration status and history.
|
|
1836
|
+
* Requires superadmin authentication.
|
|
1837
|
+
*/
|
|
1838
|
+
declare class MigrationService {
|
|
1839
|
+
private http;
|
|
1840
|
+
constructor(http: HttpClient);
|
|
1841
|
+
/**
|
|
1842
|
+
* List all Alembic migration revisions.
|
|
1843
|
+
* Returns all migrations with their application status.
|
|
1844
|
+
*/
|
|
1845
|
+
list(): Promise<MigrationListResponse>;
|
|
1846
|
+
/**
|
|
1847
|
+
* Get the current database revision.
|
|
1848
|
+
* Returns the currently applied migration.
|
|
1849
|
+
*/
|
|
1850
|
+
getCurrent(): Promise<CurrentRevisionResponse | null>;
|
|
1851
|
+
/**
|
|
1852
|
+
* Get full migration history.
|
|
1853
|
+
* Returns all applied migrations in chronological order.
|
|
1854
|
+
*/
|
|
1855
|
+
getHistory(): Promise<MigrationHistoryResponse>;
|
|
1856
|
+
}
|
|
1857
|
+
//#endregion
|
|
1858
|
+
//#region src/core/client.d.ts
|
|
1859
|
+
/**
|
|
1860
|
+
* Main SDK client for interacting with SnackBase API.
|
|
1861
|
+
*/
|
|
1862
|
+
declare class SnackBaseClient {
|
|
1863
|
+
private config;
|
|
1864
|
+
private http;
|
|
1865
|
+
private logger;
|
|
1866
|
+
private authManager;
|
|
1867
|
+
private authService;
|
|
1868
|
+
private accountService;
|
|
1869
|
+
private userService;
|
|
1870
|
+
private collectionService;
|
|
1871
|
+
private recordService;
|
|
1872
|
+
private groupsService;
|
|
1873
|
+
private invitationService;
|
|
1874
|
+
private apiKeyService;
|
|
1875
|
+
private auditLogService;
|
|
1876
|
+
private roleService;
|
|
1877
|
+
private collectionRuleService;
|
|
1878
|
+
private macroService;
|
|
1879
|
+
private dashboardService;
|
|
1880
|
+
private adminService;
|
|
1881
|
+
private emailTemplateService;
|
|
1882
|
+
private fileService;
|
|
1883
|
+
private realtimeService;
|
|
1884
|
+
private migrationService;
|
|
1885
|
+
/**
|
|
1886
|
+
* Initialize a new SnackBaseClient instance.
|
|
1887
|
+
* @param config Configuration options
|
|
1888
|
+
*/
|
|
1889
|
+
constructor(config: SnackBaseConfig);
|
|
1890
|
+
/**
|
|
1891
|
+
* Returns the current client configuration.
|
|
1892
|
+
*/
|
|
1893
|
+
getConfig(): Required<SnackBaseConfig>;
|
|
1894
|
+
/**
|
|
1895
|
+
* Internal helper to access the HTTP client.
|
|
1896
|
+
* @internal
|
|
1897
|
+
*/
|
|
1898
|
+
get httpClient(): HttpClient;
|
|
1899
|
+
/**
|
|
1900
|
+
* Sets up the default interceptors for the HTTP client.
|
|
1901
|
+
*/
|
|
1902
|
+
private setupInterceptors;
|
|
1903
|
+
/**
|
|
1904
|
+
* Returns the current authenticated user.
|
|
1905
|
+
*/
|
|
1906
|
+
get user(): User$1 | null;
|
|
1907
|
+
/**
|
|
1908
|
+
* Returns the current account.
|
|
1909
|
+
*/
|
|
1910
|
+
get account(): Account$1 | null;
|
|
1911
|
+
/**
|
|
1912
|
+
* Returns whether the client is currently authenticated.
|
|
1913
|
+
*/
|
|
1914
|
+
get isAuthenticated(): boolean;
|
|
1915
|
+
/**
|
|
1916
|
+
* Access to authentication methods.
|
|
1917
|
+
*/
|
|
1918
|
+
get auth(): AuthService;
|
|
1919
|
+
/**
|
|
1920
|
+
* Access to account management methods.
|
|
1921
|
+
*/
|
|
1922
|
+
get accounts(): AccountService;
|
|
1923
|
+
/**
|
|
1924
|
+
* Access to user management methods.
|
|
1925
|
+
*/
|
|
1926
|
+
get users(): UserService;
|
|
1927
|
+
/**
|
|
1928
|
+
* Access to collection management methods.
|
|
1929
|
+
*/
|
|
1930
|
+
get collections(): CollectionService;
|
|
1931
|
+
/**
|
|
1932
|
+
* Access to record management methods (CRUD on dynamic collections).
|
|
1933
|
+
*/
|
|
1934
|
+
get records(): RecordService;
|
|
1935
|
+
/**
|
|
1936
|
+
* Access to group management methods.
|
|
1937
|
+
*/
|
|
1938
|
+
get groups(): GroupsService;
|
|
1939
|
+
/**
|
|
1940
|
+
* Access to invitation management methods.
|
|
1941
|
+
*/
|
|
1942
|
+
get invitations(): InvitationService;
|
|
1943
|
+
/**
|
|
1944
|
+
* Access to API key management methods.
|
|
1945
|
+
*/
|
|
1946
|
+
get apiKeys(): ApiKeyService;
|
|
1947
|
+
/**
|
|
1948
|
+
* Access to audit log management methods.
|
|
1949
|
+
*/
|
|
1950
|
+
get auditLogs(): AuditLogService;
|
|
1951
|
+
/**
|
|
1952
|
+
* Access to role management methods.
|
|
1953
|
+
*/
|
|
1954
|
+
get roles(): RoleService;
|
|
1955
|
+
/**
|
|
1956
|
+
* Access to collection rule management methods.
|
|
1957
|
+
*/
|
|
1958
|
+
get collectionRules(): CollectionRuleService;
|
|
1959
|
+
/**
|
|
1960
|
+
* Access to macro management methods.
|
|
1961
|
+
*/
|
|
1962
|
+
get macros(): MacroService;
|
|
1963
|
+
/**
|
|
1964
|
+
* Access to dashboard statistics and monitoring.
|
|
1965
|
+
*/
|
|
1966
|
+
get dashboard(): DashboardService;
|
|
1967
|
+
/**
|
|
1968
|
+
* Access to system administration and configuration methods.
|
|
1969
|
+
*/
|
|
1970
|
+
get admin(): AdminService;
|
|
1971
|
+
/**
|
|
1972
|
+
* Access to email template management methods.
|
|
1973
|
+
*/
|
|
1974
|
+
get emailTemplates(): EmailTemplateService;
|
|
1975
|
+
/**
|
|
1976
|
+
* Access to file management methods.
|
|
1977
|
+
*/
|
|
1978
|
+
get files(): FileService;
|
|
1979
|
+
/**
|
|
1980
|
+
* Access to real-time features and subscriptions.
|
|
1981
|
+
*/
|
|
1982
|
+
get realtime(): RealTimeService;
|
|
1983
|
+
/**
|
|
1984
|
+
* Access to migration status and history.
|
|
1985
|
+
*/
|
|
1986
|
+
get migrations(): MigrationService;
|
|
1987
|
+
/**
|
|
1988
|
+
* Subscribe to authentication events.
|
|
1989
|
+
* @param event Event name
|
|
1990
|
+
* @param listener Callback function
|
|
1991
|
+
*/
|
|
1992
|
+
on<K extends keyof AuthEvents>(event: K, listener: AuthEvents[K]): () => void;
|
|
1993
|
+
/**
|
|
1994
|
+
* Authenticate a user with email and password.
|
|
1995
|
+
*/
|
|
1996
|
+
login(credentials: LoginCredentials): Promise<AuthResponse>;
|
|
1997
|
+
/**
|
|
1998
|
+
* Log out the current user.
|
|
1999
|
+
*/
|
|
2000
|
+
logout(): Promise<{
|
|
2001
|
+
success: boolean;
|
|
2002
|
+
}>;
|
|
2003
|
+
/**
|
|
2004
|
+
* Register a new user and account.
|
|
2005
|
+
*/
|
|
2006
|
+
register(data: RegisterData): Promise<AuthResponse>;
|
|
2007
|
+
/**
|
|
2008
|
+
* Refresh the access token using the refresh token.
|
|
2009
|
+
*/
|
|
2010
|
+
refreshToken(): Promise<AuthResponse>;
|
|
2011
|
+
/**
|
|
2012
|
+
* Get the current authenticated user profile.
|
|
2013
|
+
*/
|
|
2014
|
+
getCurrentUser(): Promise<AuthResponse>;
|
|
2015
|
+
/**
|
|
2016
|
+
* Initiate password reset flow.
|
|
2017
|
+
*/
|
|
2018
|
+
forgotPassword(data: PasswordResetRequest): Promise<{
|
|
2019
|
+
message: string;
|
|
2020
|
+
}>;
|
|
2021
|
+
/**
|
|
2022
|
+
* Reset password using a token.
|
|
2023
|
+
*/
|
|
2024
|
+
resetPassword(data: PasswordResetConfirm): Promise<{
|
|
2025
|
+
message: string;
|
|
2026
|
+
}>;
|
|
2027
|
+
/**
|
|
2028
|
+
* Verify email using a token.
|
|
2029
|
+
*/
|
|
2030
|
+
verifyEmail(token: string): Promise<{
|
|
2031
|
+
message: string;
|
|
2032
|
+
}>;
|
|
2033
|
+
/**
|
|
2034
|
+
* Resend the verification email to the current user.
|
|
2035
|
+
*/
|
|
2036
|
+
resendVerificationEmail(): Promise<{
|
|
2037
|
+
message: string;
|
|
2038
|
+
}>;
|
|
2039
|
+
/**
|
|
2040
|
+
* Generate SAML SSO authorization URL.
|
|
2041
|
+
*/
|
|
2042
|
+
getSAMLUrl(provider: SAMLProvider, account: string, relayState?: string): Promise<SAMLUrlResponse>;
|
|
2043
|
+
/**
|
|
2044
|
+
* Handle SAML callback.
|
|
2045
|
+
*/
|
|
2046
|
+
handleSAMLCallback(params: SAMLCallbackParams): Promise<SAMLResponse>;
|
|
2047
|
+
/**
|
|
2048
|
+
* Get SAML metadata.
|
|
2049
|
+
*/
|
|
2050
|
+
getSAMLMetadata(provider: SAMLProvider, account: string): Promise<string>;
|
|
2051
|
+
/**
|
|
2052
|
+
* Internal access to AuthManager.
|
|
2053
|
+
* @internal
|
|
2054
|
+
*/
|
|
2055
|
+
get internalAuthManager(): AuthManager;
|
|
2056
|
+
/**
|
|
2057
|
+
* Validates the configuration object.
|
|
2058
|
+
* Throws descriptive errors for invalid options.
|
|
2059
|
+
*/
|
|
2060
|
+
private validateConfig;
|
|
2061
|
+
}
|
|
2062
|
+
//#endregion
|
|
2063
|
+
//#region src/types/utils.d.ts
|
|
2064
|
+
/**
|
|
2065
|
+
* Generic record type with system fields.
|
|
2066
|
+
* Use this to define your record interfaces.
|
|
2067
|
+
*
|
|
2068
|
+
* @example
|
|
2069
|
+
* interface Post {
|
|
2070
|
+
* title: string;
|
|
2071
|
+
* content: string;
|
|
2072
|
+
* views: number;
|
|
2073
|
+
* }
|
|
2074
|
+
* type PostRecord = CollectionRecord<Post>;
|
|
2075
|
+
*/
|
|
2076
|
+
type CollectionRecord<T> = T & BaseRecord;
|
|
2077
|
+
/**
|
|
2078
|
+
* Paginated list response type alias.
|
|
2079
|
+
*/
|
|
2080
|
+
type ListResponse<T> = RecordListResponse<T>;
|
|
2081
|
+
/**
|
|
2082
|
+
* Filter object type for a collection.
|
|
2083
|
+
* Allows filtering by fields of T.
|
|
2084
|
+
*
|
|
2085
|
+
* This is a basic typed filter. For complex MongoDB-style queries,
|
|
2086
|
+
* you might need more flexible types.
|
|
2087
|
+
*/
|
|
2088
|
+
type Filter<T> = { [P in keyof T]?: any } & {
|
|
2089
|
+
[key: string]: any;
|
|
2090
|
+
};
|
|
2091
|
+
/**
|
|
2092
|
+
* Helper to map FieldType strings to TypeScript types.
|
|
2093
|
+
*/
|
|
2094
|
+
type FieldTypeToTs<T extends string> = T extends 'text' ? string : T extends 'number' ? number : T extends 'boolean' ? boolean : T extends 'date' ? string : T extends 'datetime' ? string : T extends 'email' ? string : T extends 'url' ? string : T extends 'phone' ? string : T extends 'select' ? string : T extends 'multi_select' ? string[] : T extends 'relation' ? string | string[] : T extends 'json' ? any : any;
|
|
2095
|
+
/**
|
|
2096
|
+
* Infers a record type from a schema definition (array of FieldDefinition).
|
|
2097
|
+
* Note: The schema array must be defined `as const` to work correctly.
|
|
2098
|
+
*
|
|
2099
|
+
* @example
|
|
2100
|
+
* const postSchema = [
|
|
2101
|
+
* { name: 'title', type: 'text' },
|
|
2102
|
+
* { name: 'views', type: 'number' }
|
|
2103
|
+
* ] as const;
|
|
2104
|
+
*
|
|
2105
|
+
* type Post = InferSchema<typeof postSchema>;
|
|
2106
|
+
* // Result: { title: string; views: number }
|
|
2107
|
+
*/
|
|
2108
|
+
type InferSchema<T extends readonly FieldDefinition[]> = { [K in T[number] as K['name']]: FieldTypeToTs<K['type']> | (K['required'] extends true ? never : undefined | null) };
|
|
2109
|
+
//#endregion
|
|
2110
|
+
//#region src/utils/platform.d.ts
|
|
2111
|
+
/**
|
|
2112
|
+
* Detects the platform and returns the recommended storage backend.
|
|
2113
|
+
* - Web: localStorage
|
|
2114
|
+
* - React Native: asyncStorage
|
|
2115
|
+
*/
|
|
2116
|
+
declare function getAutoDetectedStorage(): StorageBackend;
|
|
2117
|
+
//#endregion
|
|
2118
|
+
export { AuditLogFilters as $, EmailTemplateRenderResponse as A, OAuthCallbackParams as At, SystemHealth as B, SAMLUrlResponse as Bt, FileUploadOptions as C, FieldDefinition as Ct, EmailTemplate as D, AuthResponse as Dt, EmailLogListResponse as E, AuthEvents as Et, ConfigurationStats as F, PasswordResetRequest as Ft, RoleCreate as G, UserUpdate as Gt, CollectionRuleUpdate as H, UserCreate as Ht, ConnectionTestResult as I, RegisterData as It, RuleTestResult as J, LogLevel$1 as Jt, RoleListResponse as K, Account$1 as Kt, ProviderDefinition as L, SAMLCallbackParams as Lt, EmailTemplateUpdate as M, OAuthResponse as Mt, Configuration as N, OAuthUrlResponse as Nt, EmailTemplateFilters as O, AuthState as Ot, ConfigurationCreate as P, PasswordResetConfirm as Pt, AuditLogExportFormat as Q, RecentConfiguration as R, SAMLProvider as Rt, FileMetadata as S, CollectionUpdate as St, EmailLogFilters as T, AuthEvent as Tt, Permission as U, UserListParams as Ut, CollectionRule as V, User$1 as Vt, Role as W, UserListResponse as Wt, RuleValidationResult as X, StorageBackend as Xt, RuleValidationParams as Y, SnackBaseConfig as Yt, AuditLog as Z, RealTimeState as _, BaseRecord as _t, InferSchema as a, InvitationListParams as at, WebSocketAction as b, Collection as bt, CurrentRevisionResponse as c, GroupListParams as ct, MigrationListResponse as d, QueryBuilder as dt, AuditLogListResponse as et, MigrationRevision as f, FilterExpression as ft, RealTimeEvents as g, SortExpression as gt, RealTimeEventHandler as h, SortDirection as ht, Filter as i, InvitationCreate as it, EmailTemplateType as j, OAuthProvider as jt, EmailTemplateRenderRequest as k, LoginCredentials as kt, MigrationHistoryItem as l, GroupListResponse as lt, RealTimeEvent as m, QueryParams as mt, CollectionRecord as n, ApiKeyCreate as nt, ListResponse as o, Group as ot, RealTimeConfig as p, FilterOperator as pt, RoleUpdate as q, DEFAULT_CONFIG as qt, FieldTypeToTs as r, Invitation as rt, SnackBaseClient as s, GroupCreate as st, getAutoDetectedStorage as t, ApiKey as tt, MigrationHistoryResponse as u, GroupUpdate as ut, RealtimeEvent as v, RecordListParams as vt, EmailLog as w, FieldType as wt, WebSocketMessage as x, CollectionCreate as xt, ServerMessage as y, RecordListResponse as yt, DashboardStats as z, SAMLResponse as zt };
|