@baasix/types 1.0.9 → 1.0.11

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.d.mts CHANGED
@@ -125,6 +125,8 @@ interface JWTPayload {
125
125
  role: string;
126
126
  sessionToken: string;
127
127
  tenant_Id?: string | number | null;
128
+ /** Pinned baasix_UserRole row id (assignment switching). Absent on legacy tokens. */
129
+ userRole_Id?: string | null;
128
130
  }
129
131
  /**
130
132
  * Accountability object interface - used for permission checking
@@ -141,6 +143,8 @@ interface Accountability {
141
143
  name?: string;
142
144
  isTenantSpecific?: boolean;
143
145
  } | string | number;
146
+ /** Full active baasix_UserRole row (assignment) — custom columns included. */
147
+ userRole?: Record<string, any>;
144
148
  permissions?: any[];
145
149
  tenant?: string | number;
146
150
  ipaddress?: string;
@@ -404,6 +408,19 @@ interface IndexDefinition {
404
408
  nullsNotDistinct?: boolean;
405
409
  type?: "btree" | "hash" | "gin" | "gist";
406
410
  }
411
+ /**
412
+ * Partitioning options
413
+ */
414
+ interface PartitioningOptions {
415
+ /** Partitioning strategy: LIST by tenant, RANGE by time, or composite */
416
+ strategy: "tenant" | "time" | "tenant+time";
417
+ /** DateTime field used for RANGE partitioning (default "createdAt") */
418
+ timeField?: string;
419
+ /** Time partition width (default "year") */
420
+ interval?: "month" | "quarter" | "year";
421
+ /** Future periods to pre-create (default 1) */
422
+ premake?: number;
423
+ }
407
424
  /**
408
425
  * Schema definition
409
426
  */
@@ -419,6 +436,8 @@ interface SchemaDefinition {
419
436
  * - undefined: use default runtime behavior
420
437
  */
421
438
  tenantScoped?: boolean;
439
+ /** Partitioning configuration for this collection */
440
+ partitioning?: PartitioningOptions;
422
441
  /**
423
442
  * Track user who created/updated records (adds createdBy_Id, updatedBy_Id)
424
443
  */
package/dist/index.d.ts CHANGED
@@ -125,6 +125,8 @@ interface JWTPayload {
125
125
  role: string;
126
126
  sessionToken: string;
127
127
  tenant_Id?: string | number | null;
128
+ /** Pinned baasix_UserRole row id (assignment switching). Absent on legacy tokens. */
129
+ userRole_Id?: string | null;
128
130
  }
129
131
  /**
130
132
  * Accountability object interface - used for permission checking
@@ -141,6 +143,8 @@ interface Accountability {
141
143
  name?: string;
142
144
  isTenantSpecific?: boolean;
143
145
  } | string | number;
146
+ /** Full active baasix_UserRole row (assignment) — custom columns included. */
147
+ userRole?: Record<string, any>;
144
148
  permissions?: any[];
145
149
  tenant?: string | number;
146
150
  ipaddress?: string;
@@ -404,6 +408,19 @@ interface IndexDefinition {
404
408
  nullsNotDistinct?: boolean;
405
409
  type?: "btree" | "hash" | "gin" | "gist";
406
410
  }
411
+ /**
412
+ * Partitioning options
413
+ */
414
+ interface PartitioningOptions {
415
+ /** Partitioning strategy: LIST by tenant, RANGE by time, or composite */
416
+ strategy: "tenant" | "time" | "tenant+time";
417
+ /** DateTime field used for RANGE partitioning (default "createdAt") */
418
+ timeField?: string;
419
+ /** Time partition width (default "year") */
420
+ interval?: "month" | "quarter" | "year";
421
+ /** Future periods to pre-create (default 1) */
422
+ premake?: number;
423
+ }
407
424
  /**
408
425
  * Schema definition
409
426
  */
@@ -419,6 +436,8 @@ interface SchemaDefinition {
419
436
  * - undefined: use default runtime behavior
420
437
  */
421
438
  tenantScoped?: boolean;
439
+ /** Partitioning configuration for this collection */
440
+ partitioning?: PartitioningOptions;
422
441
  /**
423
442
  * Track user who created/updated records (adds createdBy_Id, updatedBy_Id)
424
443
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baasix/types",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Shared TypeScript types for Baasix packages",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/auth.ts CHANGED
@@ -1,285 +1,289 @@
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
- /** Authentication mode: 'jwt' for token-based or 'cookie' for cookie-based auth */
183
- authMode?: "jwt" | "cookie";
184
- /** Authentication type for session management (e.g., 'web', 'mobile', 'default') */
185
- authType?: string;
186
- }
187
-
188
- /**
189
- * Registration data
190
- */
191
- export interface RegisterData {
192
- email: string;
193
- password: string;
194
- firstName?: string;
195
- lastName?: string;
196
- [key: string]: unknown;
197
- }
198
-
199
- /**
200
- * Auth response
201
- */
202
- export interface AuthResponse {
203
- token: string;
204
- refreshToken?: string;
205
- user: User;
206
- role?: Role;
207
- expiresIn?: number;
208
- }
209
-
210
- /**
211
- * Auth state events
212
- */
213
- export type AuthStateEvent =
214
- | "SIGNED_IN"
215
- | "SIGNED_OUT"
216
- | "TOKEN_REFRESHED"
217
- | "USER_UPDATED"
218
- | "TENANT_SWITCHED";
219
-
220
- /**
221
- * Auth state
222
- */
223
- export interface AuthState {
224
- user: User | null;
225
- isAuthenticated: boolean;
226
- isLoading: boolean;
227
- error: Error | null;
228
- }
229
-
230
- /**
231
- * Magic link options
232
- */
233
- export interface MagicLinkOptions {
234
- email: string;
235
- redirectUrl?: string;
236
- mode?: "link" | "code";
237
- }
238
-
239
- /**
240
- * Password reset options
241
- */
242
- export interface PasswordResetOptions {
243
- email: string;
244
- redirectUrl?: string;
245
- }
246
-
247
- // ============================================================================
248
- // Auth Mode Types
249
- // ============================================================================
250
-
251
- /**
252
- * Authentication mode for the SDK/app
253
- * - 'jwt': Use JWT tokens stored in the configured storage adapter (default)
254
- * - 'cookie': Use HTTP-only cookies (server handles token storage)
255
- */
256
- export type AuthMode = "jwt" | "cookie";
257
-
258
- // ============================================================================
259
- // OAuth Types
260
- // ============================================================================
261
-
262
- /**
263
- * OAuth2 tokens
264
- */
265
- export interface OAuth2Tokens {
266
- accessToken: string;
267
- refreshToken?: string;
268
- idToken?: string;
269
- expiresAt?: Date;
270
- tokenType?: string;
271
- scope?: string;
272
- }
273
-
274
- /**
275
- * OAuth2 user info
276
- */
277
- export interface OAuth2UserInfo {
278
- id: string;
279
- email: string;
280
- name?: string;
281
- firstName?: string;
282
- lastName?: string;
283
- picture?: string;
284
- [key: string]: unknown;
285
- }
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
+ /** Pinned baasix_UserRole row id (assignment switching). Absent on legacy tokens. */
155
+ userRole_Id?: string | null;
156
+ }
157
+
158
+ // ============================================================================
159
+ // Accountability Types
160
+ // ============================================================================
161
+
162
+ /**
163
+ * Accountability object interface - used for permission checking
164
+ */
165
+ export interface Accountability {
166
+ user?: { id: string | number; email?: string; isAdmin?: boolean; [key: string]: any };
167
+ role?: { id: string | number; name?: string; isTenantSpecific?: boolean } | string | number;
168
+ /** Full active baasix_UserRole row (assignment) — custom columns included. */
169
+ userRole?: Record<string, any>;
170
+ permissions?: any[];
171
+ tenant?: string | number;
172
+ ipaddress?: string;
173
+ }
174
+
175
+ // ============================================================================
176
+ // Auth Request/Response Types
177
+ // ============================================================================
178
+
179
+ /**
180
+ * Login credentials
181
+ */
182
+ export interface LoginCredentials {
183
+ email: string;
184
+ password: string;
185
+ tenantId?: string;
186
+ /** Authentication mode: 'jwt' for token-based or 'cookie' for cookie-based auth */
187
+ authMode?: "jwt" | "cookie";
188
+ /** Authentication type for session management (e.g., 'web', 'mobile', 'default') */
189
+ authType?: string;
190
+ }
191
+
192
+ /**
193
+ * Registration data
194
+ */
195
+ export interface RegisterData {
196
+ email: string;
197
+ password: string;
198
+ firstName?: string;
199
+ lastName?: string;
200
+ [key: string]: unknown;
201
+ }
202
+
203
+ /**
204
+ * Auth response
205
+ */
206
+ export interface AuthResponse {
207
+ token: string;
208
+ refreshToken?: string;
209
+ user: User;
210
+ role?: Role;
211
+ expiresIn?: number;
212
+ }
213
+
214
+ /**
215
+ * Auth state events
216
+ */
217
+ export type AuthStateEvent =
218
+ | "SIGNED_IN"
219
+ | "SIGNED_OUT"
220
+ | "TOKEN_REFRESHED"
221
+ | "USER_UPDATED"
222
+ | "TENANT_SWITCHED";
223
+
224
+ /**
225
+ * Auth state
226
+ */
227
+ export interface AuthState {
228
+ user: User | null;
229
+ isAuthenticated: boolean;
230
+ isLoading: boolean;
231
+ error: Error | null;
232
+ }
233
+
234
+ /**
235
+ * Magic link options
236
+ */
237
+ export interface MagicLinkOptions {
238
+ email: string;
239
+ redirectUrl?: string;
240
+ mode?: "link" | "code";
241
+ }
242
+
243
+ /**
244
+ * Password reset options
245
+ */
246
+ export interface PasswordResetOptions {
247
+ email: string;
248
+ redirectUrl?: string;
249
+ }
250
+
251
+ // ============================================================================
252
+ // Auth Mode Types
253
+ // ============================================================================
254
+
255
+ /**
256
+ * Authentication mode for the SDK/app
257
+ * - 'jwt': Use JWT tokens stored in the configured storage adapter (default)
258
+ * - 'cookie': Use HTTP-only cookies (server handles token storage)
259
+ */
260
+ export type AuthMode = "jwt" | "cookie";
261
+
262
+ // ============================================================================
263
+ // OAuth Types
264
+ // ============================================================================
265
+
266
+ /**
267
+ * OAuth2 tokens
268
+ */
269
+ export interface OAuth2Tokens {
270
+ accessToken: string;
271
+ refreshToken?: string;
272
+ idToken?: string;
273
+ expiresAt?: Date;
274
+ tokenType?: string;
275
+ scope?: string;
276
+ }
277
+
278
+ /**
279
+ * OAuth2 user info
280
+ */
281
+ export interface OAuth2UserInfo {
282
+ id: string;
283
+ email: string;
284
+ name?: string;
285
+ firstName?: string;
286
+ lastName?: string;
287
+ picture?: string;
288
+ [key: string]: unknown;
289
+ }