@baasix/types 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +242 -0
- package/dist/index.d.mts +2065 -0
- package/dist/index.d.ts +2065 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +43 -0
- package/src/auth.ts +281 -0
- package/src/cache.ts +66 -0
- package/src/common.ts +241 -0
- package/src/files.ts +191 -0
- package/src/index.ts +309 -0
- package/src/notification.ts +52 -0
- package/src/plugin.ts +711 -0
- package/src/query.ts +443 -0
- package/src/response.ts +71 -0
- package/src/schema.ts +343 -0
- package/src/spatial.ts +37 -0
- package/src/workflow.ts +146 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@baasix/types",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Shared TypeScript types for Baasix packages",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"src"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"dev": "tsup --watch",
|
|
27
|
+
"clean": "rm -rf dist",
|
|
28
|
+
"prepublishOnly": "npm run build"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"baasix",
|
|
32
|
+
"types",
|
|
33
|
+
"typescript"
|
|
34
|
+
],
|
|
35
|
+
"author": "Baasix",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"tsup": "^8.0.0",
|
|
39
|
+
"typescript": "^5.3.0"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {},
|
|
42
|
+
"peerDependenciesMeta": {}
|
|
43
|
+
}
|
package/src/auth.ts
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication & Authorization Types
|
|
3
|
+
* Shared across core, sdk, cli, and app packages
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// User Types
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Base user interface
|
|
12
|
+
*/
|
|
13
|
+
export interface User {
|
|
14
|
+
id: string;
|
|
15
|
+
email: string;
|
|
16
|
+
firstName?: string;
|
|
17
|
+
lastName?: string;
|
|
18
|
+
avatar?: string;
|
|
19
|
+
role?: Role;
|
|
20
|
+
role_Id?: string;
|
|
21
|
+
tenant_Id?: string;
|
|
22
|
+
status?: string;
|
|
23
|
+
createdAt?: string;
|
|
24
|
+
updatedAt?: string;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* User with password (internal use only)
|
|
30
|
+
*/
|
|
31
|
+
export interface UserWithPassword extends User {
|
|
32
|
+
password?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* User with expanded roles and permissions
|
|
37
|
+
*/
|
|
38
|
+
export interface UserWithRolesAndPermissions {
|
|
39
|
+
id: string | number;
|
|
40
|
+
email?: string;
|
|
41
|
+
roles: string[];
|
|
42
|
+
permissions: string[];
|
|
43
|
+
tenantId?: string | number;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Role & Permission Types
|
|
49
|
+
// ============================================================================
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Role interface
|
|
53
|
+
*/
|
|
54
|
+
export interface Role {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
isTenantSpecific?: boolean;
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Permission action types
|
|
64
|
+
*/
|
|
65
|
+
export type PermissionAction = "create" | "read" | "update" | "delete";
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Permission interface
|
|
69
|
+
*/
|
|
70
|
+
export interface Permission {
|
|
71
|
+
id: string;
|
|
72
|
+
role_Id: string;
|
|
73
|
+
collection: string;
|
|
74
|
+
action: PermissionAction;
|
|
75
|
+
fields?: string[] | null;
|
|
76
|
+
conditions?: Record<string, unknown>;
|
|
77
|
+
defaultValues?: Record<string, unknown>;
|
|
78
|
+
relConditions?: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Permission data structure (internal to PermissionService)
|
|
83
|
+
*/
|
|
84
|
+
export interface PermissionData {
|
|
85
|
+
fields: string[] | null;
|
|
86
|
+
conditions: Record<string, unknown>;
|
|
87
|
+
relConditions: Record<string, unknown>;
|
|
88
|
+
defaultValues: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Data for creating a new permission
|
|
93
|
+
*/
|
|
94
|
+
export interface CreatePermissionData {
|
|
95
|
+
role_Id: string;
|
|
96
|
+
collection: string;
|
|
97
|
+
action: PermissionAction;
|
|
98
|
+
fields?: string[];
|
|
99
|
+
conditions?: Record<string, unknown>;
|
|
100
|
+
defaultValues?: Record<string, unknown>;
|
|
101
|
+
relConditions?: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// ============================================================================
|
|
105
|
+
// Tenant Types
|
|
106
|
+
// ============================================================================
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Tenant interface
|
|
110
|
+
*/
|
|
111
|
+
export interface Tenant {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
[key: string]: unknown;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ============================================================================
|
|
118
|
+
// Session & Token Types
|
|
119
|
+
// ============================================================================
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Session interface
|
|
123
|
+
*/
|
|
124
|
+
export interface Session {
|
|
125
|
+
id: string;
|
|
126
|
+
token: string;
|
|
127
|
+
user_Id: string;
|
|
128
|
+
expiresAt: Date | string;
|
|
129
|
+
ipAddress?: string;
|
|
130
|
+
userAgent?: string;
|
|
131
|
+
createdAt?: string;
|
|
132
|
+
updatedAt?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Auth tokens
|
|
137
|
+
*/
|
|
138
|
+
export interface AuthTokens {
|
|
139
|
+
accessToken: string;
|
|
140
|
+
refreshToken?: string;
|
|
141
|
+
expiresAt?: number;
|
|
142
|
+
expiresIn?: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* JWT payload interface
|
|
147
|
+
*/
|
|
148
|
+
export interface JWTPayload {
|
|
149
|
+
id: string;
|
|
150
|
+
email: string;
|
|
151
|
+
role: string;
|
|
152
|
+
sessionToken: string;
|
|
153
|
+
tenant_Id?: string | number | null;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ============================================================================
|
|
157
|
+
// Accountability Types
|
|
158
|
+
// ============================================================================
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Accountability object interface - used for permission checking
|
|
162
|
+
*/
|
|
163
|
+
export interface Accountability {
|
|
164
|
+
user?: { id: string | number; email?: string; isAdmin?: boolean; [key: string]: any };
|
|
165
|
+
role?: { id: string | number; name?: string; isTenantSpecific?: boolean } | string | number;
|
|
166
|
+
permissions?: any[];
|
|
167
|
+
tenant?: string | number;
|
|
168
|
+
ipaddress?: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ============================================================================
|
|
172
|
+
// Auth Request/Response Types
|
|
173
|
+
// ============================================================================
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Login credentials
|
|
177
|
+
*/
|
|
178
|
+
export interface LoginCredentials {
|
|
179
|
+
email: string;
|
|
180
|
+
password: string;
|
|
181
|
+
tenantId?: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Registration data
|
|
186
|
+
*/
|
|
187
|
+
export interface RegisterData {
|
|
188
|
+
email: string;
|
|
189
|
+
password: string;
|
|
190
|
+
firstName?: string;
|
|
191
|
+
lastName?: string;
|
|
192
|
+
[key: string]: unknown;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Auth response
|
|
197
|
+
*/
|
|
198
|
+
export interface AuthResponse {
|
|
199
|
+
token: string;
|
|
200
|
+
refreshToken?: string;
|
|
201
|
+
user: User;
|
|
202
|
+
role?: Role;
|
|
203
|
+
expiresIn?: number;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Auth state events
|
|
208
|
+
*/
|
|
209
|
+
export type AuthStateEvent =
|
|
210
|
+
| "SIGNED_IN"
|
|
211
|
+
| "SIGNED_OUT"
|
|
212
|
+
| "TOKEN_REFRESHED"
|
|
213
|
+
| "USER_UPDATED"
|
|
214
|
+
| "TENANT_SWITCHED";
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Auth state
|
|
218
|
+
*/
|
|
219
|
+
export interface AuthState {
|
|
220
|
+
user: User | null;
|
|
221
|
+
isAuthenticated: boolean;
|
|
222
|
+
isLoading: boolean;
|
|
223
|
+
error: Error | null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Magic link options
|
|
228
|
+
*/
|
|
229
|
+
export interface MagicLinkOptions {
|
|
230
|
+
email: string;
|
|
231
|
+
redirectUrl?: string;
|
|
232
|
+
mode?: "link" | "code";
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Password reset options
|
|
237
|
+
*/
|
|
238
|
+
export interface PasswordResetOptions {
|
|
239
|
+
email: string;
|
|
240
|
+
redirectUrl?: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// ============================================================================
|
|
244
|
+
// Auth Mode Types
|
|
245
|
+
// ============================================================================
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Authentication mode for the SDK/app
|
|
249
|
+
* - 'jwt': Use JWT tokens stored in the configured storage adapter (default)
|
|
250
|
+
* - 'cookie': Use HTTP-only cookies (server handles token storage)
|
|
251
|
+
*/
|
|
252
|
+
export type AuthMode = "jwt" | "cookie";
|
|
253
|
+
|
|
254
|
+
// ============================================================================
|
|
255
|
+
// OAuth Types
|
|
256
|
+
// ============================================================================
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* OAuth2 tokens
|
|
260
|
+
*/
|
|
261
|
+
export interface OAuth2Tokens {
|
|
262
|
+
accessToken: string;
|
|
263
|
+
refreshToken?: string;
|
|
264
|
+
idToken?: string;
|
|
265
|
+
expiresAt?: Date;
|
|
266
|
+
tokenType?: string;
|
|
267
|
+
scope?: string;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* OAuth2 user info
|
|
272
|
+
*/
|
|
273
|
+
export interface OAuth2UserInfo {
|
|
274
|
+
id: string;
|
|
275
|
+
email: string;
|
|
276
|
+
name?: string;
|
|
277
|
+
firstName?: string;
|
|
278
|
+
lastName?: string;
|
|
279
|
+
picture?: string;
|
|
280
|
+
[key: string]: unknown;
|
|
281
|
+
}
|
package/src/cache.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Types
|
|
3
|
+
* Types for caching functionality
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Cache Configuration Types
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Cache configuration (SDK/app level)
|
|
12
|
+
*/
|
|
13
|
+
export interface CacheConfig {
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
ttl?: number;
|
|
16
|
+
prefix?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Cache set options (Redis-style options for cache.set operations)
|
|
21
|
+
*/
|
|
22
|
+
export interface CacheSetOptions {
|
|
23
|
+
/** Expiration in seconds */
|
|
24
|
+
ex?: number;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Cache strategy
|
|
30
|
+
*/
|
|
31
|
+
export type CacheStrategy = "explicit" | "all";
|
|
32
|
+
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Cache Entry Types
|
|
35
|
+
// ============================================================================
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Cache entry structure
|
|
39
|
+
*/
|
|
40
|
+
export interface CacheEntry {
|
|
41
|
+
value: any;
|
|
42
|
+
expiry: number;
|
|
43
|
+
tables: string[];
|
|
44
|
+
tags: string[];
|
|
45
|
+
tenant?: string | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Cache Adapter Interface
|
|
50
|
+
// ============================================================================
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Base interface for all cache adapters
|
|
54
|
+
* Implement this interface to create custom cache adapters
|
|
55
|
+
*/
|
|
56
|
+
export interface ICacheAdapter {
|
|
57
|
+
get(key: string): Promise<any | null>;
|
|
58
|
+
set(key: string, value: any, ttl?: number, metadata?: { tables: string[]; tags: string[]; tenant?: string | null }): Promise<void>;
|
|
59
|
+
delete(key: string): Promise<void>;
|
|
60
|
+
clear(): Promise<void>;
|
|
61
|
+
invalidateByPattern(pattern: string): Promise<void>;
|
|
62
|
+
invalidateByTables(tables: string[], tenant?: string | null): Promise<void>;
|
|
63
|
+
invalidateByTags(tags: string[], tenant?: string | null): Promise<void>;
|
|
64
|
+
getStats(): Promise<{ keys: number; size?: number }>;
|
|
65
|
+
close(): Promise<void>;
|
|
66
|
+
}
|
package/src/common.ts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common/Utility Types
|
|
3
|
+
* Shared across all packages
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Base Types
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generic record type with ID
|
|
12
|
+
*/
|
|
13
|
+
export interface BaseItem {
|
|
14
|
+
id: string;
|
|
15
|
+
createdAt?: string;
|
|
16
|
+
updatedAt?: string;
|
|
17
|
+
deletedAt?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Timestamped item
|
|
23
|
+
*/
|
|
24
|
+
export interface TimestampedItem {
|
|
25
|
+
createdAt: string;
|
|
26
|
+
updatedAt?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Soft deletable item
|
|
31
|
+
*/
|
|
32
|
+
export interface SoftDeletableItem {
|
|
33
|
+
deletedAt?: string | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Utility Types
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Make all properties of T optional recursively
|
|
42
|
+
*/
|
|
43
|
+
export type DeepPartial<T> = {
|
|
44
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Extract the item type from a collection
|
|
49
|
+
*/
|
|
50
|
+
export type CollectionItem<T> = T extends Array<infer U> ? U : T;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Make specific properties required
|
|
54
|
+
*/
|
|
55
|
+
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Make specific properties optional
|
|
59
|
+
*/
|
|
60
|
+
export type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Extract keys of T that have values of type V
|
|
64
|
+
*/
|
|
65
|
+
export type KeysOfType<T, V> = { [K in keyof T]: T[K] extends V ? K : never }[keyof T];
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Record with string keys and unknown values
|
|
69
|
+
*/
|
|
70
|
+
export type AnyRecord = Record<string, unknown>;
|
|
71
|
+
|
|
72
|
+
// ============================================================================
|
|
73
|
+
// Settings Types
|
|
74
|
+
// ============================================================================
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Generic settings
|
|
78
|
+
*/
|
|
79
|
+
export interface Settings {
|
|
80
|
+
[key: string]: unknown;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Tenant settings
|
|
85
|
+
*/
|
|
86
|
+
export interface TenantSettings {
|
|
87
|
+
tenant_Id?: string | number | null;
|
|
88
|
+
project_name?: string;
|
|
89
|
+
title?: string;
|
|
90
|
+
project_url?: string | null;
|
|
91
|
+
app_url?: string | null;
|
|
92
|
+
project_color?: string;
|
|
93
|
+
secondary_color?: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
keywords?: string;
|
|
96
|
+
from_email_name?: string;
|
|
97
|
+
smtp_enabled?: boolean;
|
|
98
|
+
smtp_host?: string;
|
|
99
|
+
smtp_port?: number;
|
|
100
|
+
smtp_secure?: boolean;
|
|
101
|
+
smtp_user?: string;
|
|
102
|
+
smtp_pass?: string;
|
|
103
|
+
smtp_from_address?: string;
|
|
104
|
+
timezone?: string;
|
|
105
|
+
language?: string;
|
|
106
|
+
date_format?: string;
|
|
107
|
+
currency?: string;
|
|
108
|
+
email_signature?: string;
|
|
109
|
+
email_icon?: any;
|
|
110
|
+
metadata?: Record<string, any>;
|
|
111
|
+
modules?: Record<string, any>;
|
|
112
|
+
[key: string]: any;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// Task Types
|
|
117
|
+
// ============================================================================
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Background task
|
|
121
|
+
*/
|
|
122
|
+
export interface BackgroundTask {
|
|
123
|
+
id: string | number;
|
|
124
|
+
task_status: string;
|
|
125
|
+
scheduled_time: Date;
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ============================================================================
|
|
130
|
+
// Hook Types
|
|
131
|
+
// ============================================================================
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Hook events
|
|
135
|
+
*/
|
|
136
|
+
export type HookEvent =
|
|
137
|
+
| "items.create"
|
|
138
|
+
| "items.read"
|
|
139
|
+
| "items.update"
|
|
140
|
+
| "items.delete"
|
|
141
|
+
| "auth.login"
|
|
142
|
+
| "auth.logout"
|
|
143
|
+
| "auth.register";
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Hook handler context
|
|
147
|
+
*/
|
|
148
|
+
export interface HookContext {
|
|
149
|
+
event: HookEvent;
|
|
150
|
+
collection?: string;
|
|
151
|
+
payload?: unknown;
|
|
152
|
+
keys?: string[];
|
|
153
|
+
accountability?: {
|
|
154
|
+
user?: { id: string };
|
|
155
|
+
role?: { id: string; name: string };
|
|
156
|
+
tenant?: { id: string };
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Hook handler function
|
|
162
|
+
*/
|
|
163
|
+
export type HookHandler = (context: HookContext) => void | Promise<void>;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Hook definition
|
|
167
|
+
*/
|
|
168
|
+
export interface Hook {
|
|
169
|
+
event: HookEvent;
|
|
170
|
+
collection?: string;
|
|
171
|
+
handler: HookHandler;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ============================================================================
|
|
175
|
+
// HTTP Types
|
|
176
|
+
// ============================================================================
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* HTTP methods
|
|
180
|
+
*/
|
|
181
|
+
export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
|
|
182
|
+
|
|
183
|
+
// ============================================================================
|
|
184
|
+
// Mail Types
|
|
185
|
+
// ============================================================================
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Mail options for sending emails
|
|
189
|
+
*/
|
|
190
|
+
export interface MailOptions {
|
|
191
|
+
to: string | string[];
|
|
192
|
+
subject: string;
|
|
193
|
+
html?: string;
|
|
194
|
+
text?: string;
|
|
195
|
+
from?: string;
|
|
196
|
+
cc?: string | string[];
|
|
197
|
+
bcc?: string | string[];
|
|
198
|
+
replyTo?: string;
|
|
199
|
+
attachments?: Array<{
|
|
200
|
+
filename: string;
|
|
201
|
+
content?: string | Buffer;
|
|
202
|
+
path?: string;
|
|
203
|
+
contentType?: string;
|
|
204
|
+
}>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Sender configuration for email
|
|
209
|
+
*/
|
|
210
|
+
export interface SenderConfig {
|
|
211
|
+
from: string;
|
|
212
|
+
name?: string;
|
|
213
|
+
replyTo?: string;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ============================================================================
|
|
217
|
+
// Seed Types
|
|
218
|
+
// ============================================================================
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Seed data configuration
|
|
222
|
+
*/
|
|
223
|
+
export interface SeedData {
|
|
224
|
+
collection: string;
|
|
225
|
+
data: Record<string, unknown> | Record<string, unknown>[];
|
|
226
|
+
/** Whether to clear existing data before seeding */
|
|
227
|
+
clearBefore?: boolean;
|
|
228
|
+
/** Whether to skip if data already exists (check by unique fields) */
|
|
229
|
+
skipDuplicates?: boolean;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Seed operation result
|
|
234
|
+
*/
|
|
235
|
+
export interface SeedResult {
|
|
236
|
+
collection: string;
|
|
237
|
+
created: number;
|
|
238
|
+
skipped: number;
|
|
239
|
+
errors: number;
|
|
240
|
+
errorDetails?: Array<{ item: unknown; error: string }>;
|
|
241
|
+
}
|