@snackbase/sdk 0.2.0 → 0.3.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/dist/index.cjs +283 -83
- package/dist/index.d.cts +169 -11
- package/dist/index.d.mts +169 -11
- package/dist/index.mjs +271 -84
- package/package.json +4 -1
package/dist/index.d.cts
CHANGED
|
@@ -14,6 +14,11 @@ interface SnackBaseConfig {
|
|
|
14
14
|
* Optional API key for service authentication
|
|
15
15
|
*/
|
|
16
16
|
apiKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional override for system account detection
|
|
19
|
+
* (useful for testing/custom deployments)
|
|
20
|
+
*/
|
|
21
|
+
systemAccountId?: string;
|
|
17
22
|
/**
|
|
18
23
|
* Enable automatic token refresh (default: true)
|
|
19
24
|
*/
|
|
@@ -190,10 +195,12 @@ interface User {
|
|
|
190
195
|
id: string;
|
|
191
196
|
email: string;
|
|
192
197
|
role: string;
|
|
198
|
+
account_id: string;
|
|
193
199
|
groups: string[];
|
|
194
200
|
is_active: boolean;
|
|
195
201
|
created_at: string;
|
|
196
202
|
last_login: string | null;
|
|
203
|
+
token_type: TokenType;
|
|
197
204
|
}
|
|
198
205
|
interface UserCreate {
|
|
199
206
|
email: string;
|
|
@@ -223,6 +230,15 @@ interface UserListResponse {
|
|
|
223
230
|
}
|
|
224
231
|
//#endregion
|
|
225
232
|
//#region src/types/auth.d.ts
|
|
233
|
+
/**
|
|
234
|
+
* Token type enum matching backend TokenType
|
|
235
|
+
*/
|
|
236
|
+
declare enum TokenType {
|
|
237
|
+
JWT = "jwt",
|
|
238
|
+
API_KEY = "api_key",
|
|
239
|
+
PERSONAL_TOKEN = "personal_token",
|
|
240
|
+
OAUTH = "oauth"
|
|
241
|
+
}
|
|
226
242
|
interface AuthState {
|
|
227
243
|
user: User | null;
|
|
228
244
|
account: Account | null;
|
|
@@ -230,6 +246,7 @@ interface AuthState {
|
|
|
230
246
|
refreshToken: string | null;
|
|
231
247
|
isAuthenticated: boolean;
|
|
232
248
|
expiresAt: string | null;
|
|
249
|
+
tokenType: TokenType;
|
|
233
250
|
}
|
|
234
251
|
type AuthEvent = 'auth:login' | 'auth:logout' | 'auth:refresh' | 'auth:error';
|
|
235
252
|
interface AuthEvents {
|
|
@@ -323,6 +340,28 @@ declare class AuthManager {
|
|
|
323
340
|
get token(): string | null;
|
|
324
341
|
get refreshToken(): string | null;
|
|
325
342
|
get isAuthenticated(): boolean;
|
|
343
|
+
get tokenType(): TokenType;
|
|
344
|
+
/**
|
|
345
|
+
* Update auth state (enhanced to extract token_type)
|
|
346
|
+
*/
|
|
347
|
+
updateState(data: AuthResponse): Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* Check if current user is superadmin
|
|
350
|
+
*/
|
|
351
|
+
isSuperadmin(): boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Check if current session uses API key authentication
|
|
354
|
+
*/
|
|
355
|
+
isApiKeySession(): boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Check if current session uses personal token authentication
|
|
358
|
+
*/
|
|
359
|
+
isPersonalTokenSession(): boolean;
|
|
360
|
+
/**
|
|
361
|
+
* Check if current session uses OAuth authentication
|
|
362
|
+
*/
|
|
363
|
+
isOAuthSession(): boolean;
|
|
364
|
+
private calculateExpiry;
|
|
326
365
|
setState(newState: Partial<AuthState>): Promise<void>;
|
|
327
366
|
clear(): Promise<void>;
|
|
328
367
|
on<K extends keyof AuthEvents>(event: K, listener: AuthEvents[K]): () => void;
|
|
@@ -1105,10 +1144,11 @@ interface ApiKey {
|
|
|
1105
1144
|
name: string;
|
|
1106
1145
|
/**
|
|
1107
1146
|
* The full API key. Only returned once during creation.
|
|
1147
|
+
* Format: sb_ak.<payload>.<signature>
|
|
1108
1148
|
*/
|
|
1109
1149
|
key?: string;
|
|
1110
1150
|
/**
|
|
1111
|
-
* The masked version of the key (e.g., "
|
|
1151
|
+
* The masked version of the key (e.g., "sb_ak....SIGN").
|
|
1112
1152
|
*/
|
|
1113
1153
|
masked_key: string;
|
|
1114
1154
|
/**
|
|
@@ -1124,6 +1164,12 @@ interface ApiKeyCreate {
|
|
|
1124
1164
|
name: string;
|
|
1125
1165
|
expires_at?: string;
|
|
1126
1166
|
}
|
|
1167
|
+
interface ApiKeyListParams {
|
|
1168
|
+
limit?: number;
|
|
1169
|
+
offset?: number;
|
|
1170
|
+
[key: string]: string | number | boolean | undefined;
|
|
1171
|
+
}
|
|
1172
|
+
type ApiKeyListResponse = ApiKey[];
|
|
1127
1173
|
//#endregion
|
|
1128
1174
|
//#region src/core/api-key-service.d.ts
|
|
1129
1175
|
/**
|
|
@@ -1134,23 +1180,23 @@ declare class ApiKeyService {
|
|
|
1134
1180
|
private http;
|
|
1135
1181
|
constructor(http: HttpClient);
|
|
1136
1182
|
/**
|
|
1137
|
-
* List all API keys
|
|
1138
|
-
*
|
|
1183
|
+
* List all API keys
|
|
1184
|
+
* GET /api/v1/admin/api-keys
|
|
1139
1185
|
*/
|
|
1140
|
-
list(): Promise<
|
|
1186
|
+
list(params?: ApiKeyListParams): Promise<ApiKeyListResponse>;
|
|
1141
1187
|
/**
|
|
1142
|
-
* Get
|
|
1143
|
-
*
|
|
1188
|
+
* Get specific API key
|
|
1189
|
+
* GET /api/v1/admin/api-keys/{id}
|
|
1144
1190
|
*/
|
|
1145
1191
|
get(keyId: string): Promise<ApiKey>;
|
|
1146
1192
|
/**
|
|
1147
|
-
* Create a new API key
|
|
1148
|
-
*
|
|
1193
|
+
* Create a new API key
|
|
1194
|
+
* POST /api/v1/admin/api-keys
|
|
1149
1195
|
*/
|
|
1150
1196
|
create(data: ApiKeyCreate): Promise<ApiKey>;
|
|
1151
1197
|
/**
|
|
1152
|
-
* Revoke an
|
|
1153
|
-
*
|
|
1198
|
+
* Revoke an API key
|
|
1199
|
+
* DELETE /api/v1/admin/api-keys/{id}
|
|
1154
1200
|
*/
|
|
1155
1201
|
revoke(keyId: string): Promise<{
|
|
1156
1202
|
success: boolean;
|
|
@@ -1158,6 +1204,13 @@ declare class ApiKeyService {
|
|
|
1158
1204
|
}
|
|
1159
1205
|
//#endregion
|
|
1160
1206
|
//#region src/types/audit-log.d.ts
|
|
1207
|
+
/**
|
|
1208
|
+
* Audit log extra metadata
|
|
1209
|
+
*/
|
|
1210
|
+
interface AuditLogExtraMetadata {
|
|
1211
|
+
auth_method?: 'jwt' | 'api_key' | 'personal_token' | 'oauth' | 'unknown';
|
|
1212
|
+
[key: string]: any;
|
|
1213
|
+
}
|
|
1161
1214
|
interface AuditLog {
|
|
1162
1215
|
id: string;
|
|
1163
1216
|
account_id: string;
|
|
@@ -1168,6 +1221,7 @@ interface AuditLog {
|
|
|
1168
1221
|
before: Record<string, any> | null;
|
|
1169
1222
|
after: Record<string, any> | null;
|
|
1170
1223
|
created_at: string;
|
|
1224
|
+
extra_metadata?: AuditLogExtraMetadata;
|
|
1171
1225
|
}
|
|
1172
1226
|
interface AuditLogFilters {
|
|
1173
1227
|
account_id?: string;
|
|
@@ -2083,6 +2137,26 @@ declare class SnackBaseClient {
|
|
|
2083
2137
|
* Returns whether the client is currently authenticated.
|
|
2084
2138
|
*/
|
|
2085
2139
|
get isAuthenticated(): boolean;
|
|
2140
|
+
/**
|
|
2141
|
+
* Check if current user is superadmin.
|
|
2142
|
+
*/
|
|
2143
|
+
get isSuperadmin(): boolean;
|
|
2144
|
+
/**
|
|
2145
|
+
* Check if current session uses API key authentication.
|
|
2146
|
+
*/
|
|
2147
|
+
get isApiKeySession(): boolean;
|
|
2148
|
+
/**
|
|
2149
|
+
* Check if current session uses personal token authentication.
|
|
2150
|
+
*/
|
|
2151
|
+
get isPersonalTokenSession(): boolean;
|
|
2152
|
+
/**
|
|
2153
|
+
* Check if current session uses OAuth authentication.
|
|
2154
|
+
*/
|
|
2155
|
+
get isOAuthSession(): boolean;
|
|
2156
|
+
/**
|
|
2157
|
+
* Returns the current token type.
|
|
2158
|
+
*/
|
|
2159
|
+
get tokenType(): TokenType;
|
|
2086
2160
|
/**
|
|
2087
2161
|
* Access to authentication methods.
|
|
2088
2162
|
*/
|
|
@@ -2231,6 +2305,90 @@ declare class SnackBaseClient {
|
|
|
2231
2305
|
private validateConfig;
|
|
2232
2306
|
}
|
|
2233
2307
|
//#endregion
|
|
2308
|
+
//#region src/core/errors.d.ts
|
|
2309
|
+
/**
|
|
2310
|
+
* Base error class for all SnackBase SDK errors.
|
|
2311
|
+
*/
|
|
2312
|
+
declare class SnackBaseError extends Error {
|
|
2313
|
+
redirectUrl?: string | undefined;
|
|
2314
|
+
authProvider?: string | undefined;
|
|
2315
|
+
providerName?: string | undefined;
|
|
2316
|
+
readonly code: string;
|
|
2317
|
+
readonly status?: number;
|
|
2318
|
+
readonly details?: any;
|
|
2319
|
+
readonly field?: string;
|
|
2320
|
+
readonly retryable: boolean;
|
|
2321
|
+
constructor(message: string, code: string, status?: number, details?: any, retryable?: boolean, field?: string, redirectUrl?: string | undefined, authProvider?: string | undefined, providerName?: string | undefined);
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* Thrown when authentication fails (401).
|
|
2325
|
+
*/
|
|
2326
|
+
declare class AuthenticationError extends SnackBaseError {
|
|
2327
|
+
constructor(message?: string, details?: any);
|
|
2328
|
+
}
|
|
2329
|
+
/**
|
|
2330
|
+
* Thrown when the user is not authorized to perform an action (403).
|
|
2331
|
+
*/
|
|
2332
|
+
declare class AuthorizationError extends SnackBaseError {
|
|
2333
|
+
constructor(message?: string, details?: any);
|
|
2334
|
+
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Thrown when an API key is restricted to superadmin users (403).
|
|
2337
|
+
*/
|
|
2338
|
+
declare class ApiKeyRestrictedError extends SnackBaseError {
|
|
2339
|
+
constructor(message?: string, details?: any);
|
|
2340
|
+
}
|
|
2341
|
+
/**
|
|
2342
|
+
* Thrown when email verification is required (401).
|
|
2343
|
+
*/
|
|
2344
|
+
declare class EmailVerificationRequiredError extends SnackBaseError {
|
|
2345
|
+
constructor(message?: string, details?: any);
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Thrown when a resource is not found (404).
|
|
2349
|
+
*/
|
|
2350
|
+
declare class NotFoundError extends SnackBaseError {
|
|
2351
|
+
constructor(message?: string, details?: any);
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Thrown when a conflict occurs (409).
|
|
2355
|
+
*/
|
|
2356
|
+
declare class ConflictError extends SnackBaseError {
|
|
2357
|
+
constructor(message?: string, details?: any);
|
|
2358
|
+
}
|
|
2359
|
+
/**
|
|
2360
|
+
* Thrown when validation fails (422).
|
|
2361
|
+
*/
|
|
2362
|
+
declare class ValidationError extends SnackBaseError {
|
|
2363
|
+
readonly fields?: Record<string, string[]>;
|
|
2364
|
+
constructor(message?: string, details?: any);
|
|
2365
|
+
}
|
|
2366
|
+
/**
|
|
2367
|
+
* Thrown when rate limit is exceeded (429).
|
|
2368
|
+
*/
|
|
2369
|
+
declare class RateLimitError extends SnackBaseError {
|
|
2370
|
+
readonly retryAfter?: number;
|
|
2371
|
+
constructor(message?: string, details?: any, retryAfter?: number);
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Thrown when a network failure occurs.
|
|
2375
|
+
*/
|
|
2376
|
+
declare class NetworkError extends SnackBaseError {
|
|
2377
|
+
constructor(message?: string, details?: any);
|
|
2378
|
+
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Thrown when a request times out.
|
|
2381
|
+
*/
|
|
2382
|
+
declare class TimeoutError extends SnackBaseError {
|
|
2383
|
+
constructor(message?: string, details?: any);
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Thrown when a server error occurs (500+).
|
|
2387
|
+
*/
|
|
2388
|
+
declare class ServerError extends SnackBaseError {
|
|
2389
|
+
constructor(message?: string, status?: number, details?: any);
|
|
2390
|
+
}
|
|
2391
|
+
//#endregion
|
|
2234
2392
|
//#region src/types/utils.d.ts
|
|
2235
2393
|
/**
|
|
2236
2394
|
* Generic record type with system fields.
|
|
@@ -2286,4 +2444,4 @@ type InferSchema<T extends readonly FieldDefinition[]> = { [K in T[number] as K[
|
|
|
2286
2444
|
*/
|
|
2287
2445
|
declare function getAutoDetectedStorage(): StorageBackend;
|
|
2288
2446
|
//#endregion
|
|
2289
|
-
export { type Account, ApiKey, ApiKeyCreate, AuditLog, AuditLogExportFormat, AuditLogFilters, AuditLogListResponse, AuthEvent, AuthEvents, AuthResponse, AuthState, BaseRecord, Collection, CollectionCreate, CollectionExportData, CollectionExportFieldDefinition, CollectionExportItem, CollectionExportParams, CollectionExportRules, CollectionImportItemResult, CollectionImportRequest, CollectionImportResult, CollectionRecord, CollectionRule, CollectionRuleUpdate, CollectionUpdate, Configuration, ConfigurationCreate, ConfigurationStats, ConnectionTestResult, CurrentRevisionResponse, DEFAULT_CONFIG, DashboardStats, EmailLog, EmailLogFilters, EmailLogListResponse, EmailTemplate, EmailTemplateFilters, EmailTemplateRenderRequest, EmailTemplateRenderResponse, EmailTemplateType, EmailTemplateUpdate, FieldDefinition, FieldType, FieldTypeToTs, FileMetadata, FileUploadOptions, Filter, FilterExpression, FilterOperator, Group, GroupCreate, GroupListParams, GroupListResponse, GroupUpdate, ImportStrategy, InferSchema, Invitation, InvitationCreate, InvitationListParams, ListResponse, LogLevel, LoginCredentials, MigrationHistoryItem, MigrationHistoryResponse, MigrationListResponse, MigrationRevision, OAuthCallbackParams, OAuthProvider, OAuthResponse, OAuthUrlResponse, PasswordResetConfirm, PasswordResetRequest, Permission, ProviderDefinition, QueryBuilder, QueryParams, RealTimeConfig, RealTimeEvent, RealTimeEventHandler, RealTimeEvents, RealTimeState, RealtimeEvent, RecentConfiguration, RecordListParams, RecordListResponse, RegisterData, Role, RoleCreate, RoleListResponse, RoleUpdate, RuleTestResult, RuleValidationParams, RuleValidationResult, SAMLCallbackParams, SAMLProvider, SAMLResponse, SAMLUrlResponse, ServerMessage, type SnackBaseClient as SnackBase, SnackBaseClient, SnackBaseConfig, SortDirection, SortExpression, StorageBackend, SystemHealth, type User, UserCreate, UserListParams, type UserListResponse, UserUpdate, WebSocketAction, WebSocketMessage, getAutoDetectedStorage };
|
|
2447
|
+
export { type Account, ApiKey, ApiKeyCreate, ApiKeyListParams, ApiKeyListResponse, ApiKeyRestrictedError, AuditLog, AuditLogExportFormat, AuditLogExtraMetadata, AuditLogFilters, AuditLogListResponse, AuthEvent, AuthEvents, AuthResponse, AuthState, AuthenticationError, AuthorizationError, BaseRecord, Collection, CollectionCreate, CollectionExportData, CollectionExportFieldDefinition, CollectionExportItem, CollectionExportParams, CollectionExportRules, CollectionImportItemResult, CollectionImportRequest, CollectionImportResult, CollectionRecord, CollectionRule, CollectionRuleUpdate, CollectionUpdate, Configuration, ConfigurationCreate, ConfigurationStats, ConflictError, ConnectionTestResult, CurrentRevisionResponse, DEFAULT_CONFIG, DashboardStats, EmailLog, EmailLogFilters, EmailLogListResponse, EmailTemplate, EmailTemplateFilters, EmailTemplateRenderRequest, EmailTemplateRenderResponse, EmailTemplateType, EmailTemplateUpdate, EmailVerificationRequiredError, FieldDefinition, FieldType, FieldTypeToTs, FileMetadata, FileUploadOptions, Filter, FilterExpression, FilterOperator, Group, GroupCreate, GroupListParams, GroupListResponse, GroupUpdate, ImportStrategy, InferSchema, Invitation, InvitationCreate, InvitationListParams, ListResponse, LogLevel, LoginCredentials, MigrationHistoryItem, MigrationHistoryResponse, MigrationListResponse, MigrationRevision, NetworkError, NotFoundError, OAuthCallbackParams, OAuthProvider, OAuthResponse, OAuthUrlResponse, PasswordResetConfirm, PasswordResetRequest, Permission, ProviderDefinition, QueryBuilder, QueryParams, RateLimitError, RealTimeConfig, RealTimeEvent, RealTimeEventHandler, RealTimeEvents, RealTimeState, RealtimeEvent, RecentConfiguration, RecordListParams, RecordListResponse, RegisterData, Role, RoleCreate, RoleListResponse, RoleUpdate, RuleTestResult, RuleValidationParams, RuleValidationResult, SAMLCallbackParams, SAMLProvider, SAMLResponse, SAMLUrlResponse, ServerError, ServerMessage, type SnackBaseClient as SnackBase, SnackBaseClient, SnackBaseConfig, SnackBaseError, SortDirection, SortExpression, StorageBackend, SystemHealth, TimeoutError, TokenType, type User, UserCreate, UserListParams, type UserListResponse, UserUpdate, ValidationError, WebSocketAction, WebSocketMessage, getAutoDetectedStorage };
|
package/dist/index.d.mts
CHANGED
|
@@ -14,6 +14,11 @@ interface SnackBaseConfig {
|
|
|
14
14
|
* Optional API key for service authentication
|
|
15
15
|
*/
|
|
16
16
|
apiKey?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional override for system account detection
|
|
19
|
+
* (useful for testing/custom deployments)
|
|
20
|
+
*/
|
|
21
|
+
systemAccountId?: string;
|
|
17
22
|
/**
|
|
18
23
|
* Enable automatic token refresh (default: true)
|
|
19
24
|
*/
|
|
@@ -190,10 +195,12 @@ interface User {
|
|
|
190
195
|
id: string;
|
|
191
196
|
email: string;
|
|
192
197
|
role: string;
|
|
198
|
+
account_id: string;
|
|
193
199
|
groups: string[];
|
|
194
200
|
is_active: boolean;
|
|
195
201
|
created_at: string;
|
|
196
202
|
last_login: string | null;
|
|
203
|
+
token_type: TokenType;
|
|
197
204
|
}
|
|
198
205
|
interface UserCreate {
|
|
199
206
|
email: string;
|
|
@@ -223,6 +230,15 @@ interface UserListResponse {
|
|
|
223
230
|
}
|
|
224
231
|
//#endregion
|
|
225
232
|
//#region src/types/auth.d.ts
|
|
233
|
+
/**
|
|
234
|
+
* Token type enum matching backend TokenType
|
|
235
|
+
*/
|
|
236
|
+
declare enum TokenType {
|
|
237
|
+
JWT = "jwt",
|
|
238
|
+
API_KEY = "api_key",
|
|
239
|
+
PERSONAL_TOKEN = "personal_token",
|
|
240
|
+
OAUTH = "oauth"
|
|
241
|
+
}
|
|
226
242
|
interface AuthState {
|
|
227
243
|
user: User | null;
|
|
228
244
|
account: Account | null;
|
|
@@ -230,6 +246,7 @@ interface AuthState {
|
|
|
230
246
|
refreshToken: string | null;
|
|
231
247
|
isAuthenticated: boolean;
|
|
232
248
|
expiresAt: string | null;
|
|
249
|
+
tokenType: TokenType;
|
|
233
250
|
}
|
|
234
251
|
type AuthEvent = 'auth:login' | 'auth:logout' | 'auth:refresh' | 'auth:error';
|
|
235
252
|
interface AuthEvents {
|
|
@@ -323,6 +340,28 @@ declare class AuthManager {
|
|
|
323
340
|
get token(): string | null;
|
|
324
341
|
get refreshToken(): string | null;
|
|
325
342
|
get isAuthenticated(): boolean;
|
|
343
|
+
get tokenType(): TokenType;
|
|
344
|
+
/**
|
|
345
|
+
* Update auth state (enhanced to extract token_type)
|
|
346
|
+
*/
|
|
347
|
+
updateState(data: AuthResponse): Promise<void>;
|
|
348
|
+
/**
|
|
349
|
+
* Check if current user is superadmin
|
|
350
|
+
*/
|
|
351
|
+
isSuperadmin(): boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Check if current session uses API key authentication
|
|
354
|
+
*/
|
|
355
|
+
isApiKeySession(): boolean;
|
|
356
|
+
/**
|
|
357
|
+
* Check if current session uses personal token authentication
|
|
358
|
+
*/
|
|
359
|
+
isPersonalTokenSession(): boolean;
|
|
360
|
+
/**
|
|
361
|
+
* Check if current session uses OAuth authentication
|
|
362
|
+
*/
|
|
363
|
+
isOAuthSession(): boolean;
|
|
364
|
+
private calculateExpiry;
|
|
326
365
|
setState(newState: Partial<AuthState>): Promise<void>;
|
|
327
366
|
clear(): Promise<void>;
|
|
328
367
|
on<K extends keyof AuthEvents>(event: K, listener: AuthEvents[K]): () => void;
|
|
@@ -1105,10 +1144,11 @@ interface ApiKey {
|
|
|
1105
1144
|
name: string;
|
|
1106
1145
|
/**
|
|
1107
1146
|
* The full API key. Only returned once during creation.
|
|
1147
|
+
* Format: sb_ak.<payload>.<signature>
|
|
1108
1148
|
*/
|
|
1109
1149
|
key?: string;
|
|
1110
1150
|
/**
|
|
1111
|
-
* The masked version of the key (e.g., "
|
|
1151
|
+
* The masked version of the key (e.g., "sb_ak....SIGN").
|
|
1112
1152
|
*/
|
|
1113
1153
|
masked_key: string;
|
|
1114
1154
|
/**
|
|
@@ -1124,6 +1164,12 @@ interface ApiKeyCreate {
|
|
|
1124
1164
|
name: string;
|
|
1125
1165
|
expires_at?: string;
|
|
1126
1166
|
}
|
|
1167
|
+
interface ApiKeyListParams {
|
|
1168
|
+
limit?: number;
|
|
1169
|
+
offset?: number;
|
|
1170
|
+
[key: string]: string | number | boolean | undefined;
|
|
1171
|
+
}
|
|
1172
|
+
type ApiKeyListResponse = ApiKey[];
|
|
1127
1173
|
//#endregion
|
|
1128
1174
|
//#region src/core/api-key-service.d.ts
|
|
1129
1175
|
/**
|
|
@@ -1134,23 +1180,23 @@ declare class ApiKeyService {
|
|
|
1134
1180
|
private http;
|
|
1135
1181
|
constructor(http: HttpClient);
|
|
1136
1182
|
/**
|
|
1137
|
-
* List all API keys
|
|
1138
|
-
*
|
|
1183
|
+
* List all API keys
|
|
1184
|
+
* GET /api/v1/admin/api-keys
|
|
1139
1185
|
*/
|
|
1140
|
-
list(): Promise<
|
|
1186
|
+
list(params?: ApiKeyListParams): Promise<ApiKeyListResponse>;
|
|
1141
1187
|
/**
|
|
1142
|
-
* Get
|
|
1143
|
-
*
|
|
1188
|
+
* Get specific API key
|
|
1189
|
+
* GET /api/v1/admin/api-keys/{id}
|
|
1144
1190
|
*/
|
|
1145
1191
|
get(keyId: string): Promise<ApiKey>;
|
|
1146
1192
|
/**
|
|
1147
|
-
* Create a new API key
|
|
1148
|
-
*
|
|
1193
|
+
* Create a new API key
|
|
1194
|
+
* POST /api/v1/admin/api-keys
|
|
1149
1195
|
*/
|
|
1150
1196
|
create(data: ApiKeyCreate): Promise<ApiKey>;
|
|
1151
1197
|
/**
|
|
1152
|
-
* Revoke an
|
|
1153
|
-
*
|
|
1198
|
+
* Revoke an API key
|
|
1199
|
+
* DELETE /api/v1/admin/api-keys/{id}
|
|
1154
1200
|
*/
|
|
1155
1201
|
revoke(keyId: string): Promise<{
|
|
1156
1202
|
success: boolean;
|
|
@@ -1158,6 +1204,13 @@ declare class ApiKeyService {
|
|
|
1158
1204
|
}
|
|
1159
1205
|
//#endregion
|
|
1160
1206
|
//#region src/types/audit-log.d.ts
|
|
1207
|
+
/**
|
|
1208
|
+
* Audit log extra metadata
|
|
1209
|
+
*/
|
|
1210
|
+
interface AuditLogExtraMetadata {
|
|
1211
|
+
auth_method?: 'jwt' | 'api_key' | 'personal_token' | 'oauth' | 'unknown';
|
|
1212
|
+
[key: string]: any;
|
|
1213
|
+
}
|
|
1161
1214
|
interface AuditLog {
|
|
1162
1215
|
id: string;
|
|
1163
1216
|
account_id: string;
|
|
@@ -1168,6 +1221,7 @@ interface AuditLog {
|
|
|
1168
1221
|
before: Record<string, any> | null;
|
|
1169
1222
|
after: Record<string, any> | null;
|
|
1170
1223
|
created_at: string;
|
|
1224
|
+
extra_metadata?: AuditLogExtraMetadata;
|
|
1171
1225
|
}
|
|
1172
1226
|
interface AuditLogFilters {
|
|
1173
1227
|
account_id?: string;
|
|
@@ -2083,6 +2137,26 @@ declare class SnackBaseClient {
|
|
|
2083
2137
|
* Returns whether the client is currently authenticated.
|
|
2084
2138
|
*/
|
|
2085
2139
|
get isAuthenticated(): boolean;
|
|
2140
|
+
/**
|
|
2141
|
+
* Check if current user is superadmin.
|
|
2142
|
+
*/
|
|
2143
|
+
get isSuperadmin(): boolean;
|
|
2144
|
+
/**
|
|
2145
|
+
* Check if current session uses API key authentication.
|
|
2146
|
+
*/
|
|
2147
|
+
get isApiKeySession(): boolean;
|
|
2148
|
+
/**
|
|
2149
|
+
* Check if current session uses personal token authentication.
|
|
2150
|
+
*/
|
|
2151
|
+
get isPersonalTokenSession(): boolean;
|
|
2152
|
+
/**
|
|
2153
|
+
* Check if current session uses OAuth authentication.
|
|
2154
|
+
*/
|
|
2155
|
+
get isOAuthSession(): boolean;
|
|
2156
|
+
/**
|
|
2157
|
+
* Returns the current token type.
|
|
2158
|
+
*/
|
|
2159
|
+
get tokenType(): TokenType;
|
|
2086
2160
|
/**
|
|
2087
2161
|
* Access to authentication methods.
|
|
2088
2162
|
*/
|
|
@@ -2231,6 +2305,90 @@ declare class SnackBaseClient {
|
|
|
2231
2305
|
private validateConfig;
|
|
2232
2306
|
}
|
|
2233
2307
|
//#endregion
|
|
2308
|
+
//#region src/core/errors.d.ts
|
|
2309
|
+
/**
|
|
2310
|
+
* Base error class for all SnackBase SDK errors.
|
|
2311
|
+
*/
|
|
2312
|
+
declare class SnackBaseError extends Error {
|
|
2313
|
+
redirectUrl?: string | undefined;
|
|
2314
|
+
authProvider?: string | undefined;
|
|
2315
|
+
providerName?: string | undefined;
|
|
2316
|
+
readonly code: string;
|
|
2317
|
+
readonly status?: number;
|
|
2318
|
+
readonly details?: any;
|
|
2319
|
+
readonly field?: string;
|
|
2320
|
+
readonly retryable: boolean;
|
|
2321
|
+
constructor(message: string, code: string, status?: number, details?: any, retryable?: boolean, field?: string, redirectUrl?: string | undefined, authProvider?: string | undefined, providerName?: string | undefined);
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* Thrown when authentication fails (401).
|
|
2325
|
+
*/
|
|
2326
|
+
declare class AuthenticationError extends SnackBaseError {
|
|
2327
|
+
constructor(message?: string, details?: any);
|
|
2328
|
+
}
|
|
2329
|
+
/**
|
|
2330
|
+
* Thrown when the user is not authorized to perform an action (403).
|
|
2331
|
+
*/
|
|
2332
|
+
declare class AuthorizationError extends SnackBaseError {
|
|
2333
|
+
constructor(message?: string, details?: any);
|
|
2334
|
+
}
|
|
2335
|
+
/**
|
|
2336
|
+
* Thrown when an API key is restricted to superadmin users (403).
|
|
2337
|
+
*/
|
|
2338
|
+
declare class ApiKeyRestrictedError extends SnackBaseError {
|
|
2339
|
+
constructor(message?: string, details?: any);
|
|
2340
|
+
}
|
|
2341
|
+
/**
|
|
2342
|
+
* Thrown when email verification is required (401).
|
|
2343
|
+
*/
|
|
2344
|
+
declare class EmailVerificationRequiredError extends SnackBaseError {
|
|
2345
|
+
constructor(message?: string, details?: any);
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Thrown when a resource is not found (404).
|
|
2349
|
+
*/
|
|
2350
|
+
declare class NotFoundError extends SnackBaseError {
|
|
2351
|
+
constructor(message?: string, details?: any);
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Thrown when a conflict occurs (409).
|
|
2355
|
+
*/
|
|
2356
|
+
declare class ConflictError extends SnackBaseError {
|
|
2357
|
+
constructor(message?: string, details?: any);
|
|
2358
|
+
}
|
|
2359
|
+
/**
|
|
2360
|
+
* Thrown when validation fails (422).
|
|
2361
|
+
*/
|
|
2362
|
+
declare class ValidationError extends SnackBaseError {
|
|
2363
|
+
readonly fields?: Record<string, string[]>;
|
|
2364
|
+
constructor(message?: string, details?: any);
|
|
2365
|
+
}
|
|
2366
|
+
/**
|
|
2367
|
+
* Thrown when rate limit is exceeded (429).
|
|
2368
|
+
*/
|
|
2369
|
+
declare class RateLimitError extends SnackBaseError {
|
|
2370
|
+
readonly retryAfter?: number;
|
|
2371
|
+
constructor(message?: string, details?: any, retryAfter?: number);
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Thrown when a network failure occurs.
|
|
2375
|
+
*/
|
|
2376
|
+
declare class NetworkError extends SnackBaseError {
|
|
2377
|
+
constructor(message?: string, details?: any);
|
|
2378
|
+
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Thrown when a request times out.
|
|
2381
|
+
*/
|
|
2382
|
+
declare class TimeoutError extends SnackBaseError {
|
|
2383
|
+
constructor(message?: string, details?: any);
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Thrown when a server error occurs (500+).
|
|
2387
|
+
*/
|
|
2388
|
+
declare class ServerError extends SnackBaseError {
|
|
2389
|
+
constructor(message?: string, status?: number, details?: any);
|
|
2390
|
+
}
|
|
2391
|
+
//#endregion
|
|
2234
2392
|
//#region src/types/utils.d.ts
|
|
2235
2393
|
/**
|
|
2236
2394
|
* Generic record type with system fields.
|
|
@@ -2286,4 +2444,4 @@ type InferSchema<T extends readonly FieldDefinition[]> = { [K in T[number] as K[
|
|
|
2286
2444
|
*/
|
|
2287
2445
|
declare function getAutoDetectedStorage(): StorageBackend;
|
|
2288
2446
|
//#endregion
|
|
2289
|
-
export { type Account, ApiKey, ApiKeyCreate, AuditLog, AuditLogExportFormat, AuditLogFilters, AuditLogListResponse, AuthEvent, AuthEvents, AuthResponse, AuthState, BaseRecord, Collection, CollectionCreate, CollectionExportData, CollectionExportFieldDefinition, CollectionExportItem, CollectionExportParams, CollectionExportRules, CollectionImportItemResult, CollectionImportRequest, CollectionImportResult, CollectionRecord, CollectionRule, CollectionRuleUpdate, CollectionUpdate, Configuration, ConfigurationCreate, ConfigurationStats, ConnectionTestResult, CurrentRevisionResponse, DEFAULT_CONFIG, DashboardStats, EmailLog, EmailLogFilters, EmailLogListResponse, EmailTemplate, EmailTemplateFilters, EmailTemplateRenderRequest, EmailTemplateRenderResponse, EmailTemplateType, EmailTemplateUpdate, FieldDefinition, FieldType, FieldTypeToTs, FileMetadata, FileUploadOptions, Filter, FilterExpression, FilterOperator, Group, GroupCreate, GroupListParams, GroupListResponse, GroupUpdate, ImportStrategy, InferSchema, Invitation, InvitationCreate, InvitationListParams, ListResponse, LogLevel, LoginCredentials, MigrationHistoryItem, MigrationHistoryResponse, MigrationListResponse, MigrationRevision, OAuthCallbackParams, OAuthProvider, OAuthResponse, OAuthUrlResponse, PasswordResetConfirm, PasswordResetRequest, Permission, ProviderDefinition, QueryBuilder, QueryParams, RealTimeConfig, RealTimeEvent, RealTimeEventHandler, RealTimeEvents, RealTimeState, RealtimeEvent, RecentConfiguration, RecordListParams, RecordListResponse, RegisterData, Role, RoleCreate, RoleListResponse, RoleUpdate, RuleTestResult, RuleValidationParams, RuleValidationResult, SAMLCallbackParams, SAMLProvider, SAMLResponse, SAMLUrlResponse, ServerMessage, type SnackBaseClient as SnackBase, SnackBaseClient, SnackBaseConfig, SortDirection, SortExpression, StorageBackend, SystemHealth, type User, UserCreate, UserListParams, type UserListResponse, UserUpdate, WebSocketAction, WebSocketMessage, getAutoDetectedStorage };
|
|
2447
|
+
export { type Account, ApiKey, ApiKeyCreate, ApiKeyListParams, ApiKeyListResponse, ApiKeyRestrictedError, AuditLog, AuditLogExportFormat, AuditLogExtraMetadata, AuditLogFilters, AuditLogListResponse, AuthEvent, AuthEvents, AuthResponse, AuthState, AuthenticationError, AuthorizationError, BaseRecord, Collection, CollectionCreate, CollectionExportData, CollectionExportFieldDefinition, CollectionExportItem, CollectionExportParams, CollectionExportRules, CollectionImportItemResult, CollectionImportRequest, CollectionImportResult, CollectionRecord, CollectionRule, CollectionRuleUpdate, CollectionUpdate, Configuration, ConfigurationCreate, ConfigurationStats, ConflictError, ConnectionTestResult, CurrentRevisionResponse, DEFAULT_CONFIG, DashboardStats, EmailLog, EmailLogFilters, EmailLogListResponse, EmailTemplate, EmailTemplateFilters, EmailTemplateRenderRequest, EmailTemplateRenderResponse, EmailTemplateType, EmailTemplateUpdate, EmailVerificationRequiredError, FieldDefinition, FieldType, FieldTypeToTs, FileMetadata, FileUploadOptions, Filter, FilterExpression, FilterOperator, Group, GroupCreate, GroupListParams, GroupListResponse, GroupUpdate, ImportStrategy, InferSchema, Invitation, InvitationCreate, InvitationListParams, ListResponse, LogLevel, LoginCredentials, MigrationHistoryItem, MigrationHistoryResponse, MigrationListResponse, MigrationRevision, NetworkError, NotFoundError, OAuthCallbackParams, OAuthProvider, OAuthResponse, OAuthUrlResponse, PasswordResetConfirm, PasswordResetRequest, Permission, ProviderDefinition, QueryBuilder, QueryParams, RateLimitError, RealTimeConfig, RealTimeEvent, RealTimeEventHandler, RealTimeEvents, RealTimeState, RealtimeEvent, RecentConfiguration, RecordListParams, RecordListResponse, RegisterData, Role, RoleCreate, RoleListResponse, RoleUpdate, RuleTestResult, RuleValidationParams, RuleValidationResult, SAMLCallbackParams, SAMLProvider, SAMLResponse, SAMLUrlResponse, ServerError, ServerMessage, type SnackBaseClient as SnackBase, SnackBaseClient, SnackBaseConfig, SnackBaseError, SortDirection, SortExpression, StorageBackend, SystemHealth, TimeoutError, TokenType, type User, UserCreate, UserListParams, type UserListResponse, UserUpdate, ValidationError, WebSocketAction, WebSocketMessage, getAutoDetectedStorage };
|