@baasix/types 1.0.12 → 1.0.13

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
@@ -64,6 +64,8 @@ interface Permission {
64
64
  conditions?: Record<string, unknown>;
65
65
  defaultValues?: Record<string, unknown>;
66
66
  relConditions?: Record<string, unknown>;
67
+ /** WITH CHECK filter — see PermissionData.checkConditions */
68
+ checkConditions?: Record<string, unknown> | null;
67
69
  }
68
70
  /**
69
71
  * Permission data structure (internal to PermissionService)
@@ -73,6 +75,12 @@ interface PermissionData {
73
75
  conditions: Record<string, unknown>;
74
76
  relConditions: Record<string, unknown>;
75
77
  defaultValues: Record<string, unknown>;
78
+ /**
79
+ * WITH CHECK (RLS-style) filter: what a written row must satisfy, enforced
80
+ * post-write pre-commit on both create and update. null/absent = no check.
81
+ * `conditions` never applies to create grants.
82
+ */
83
+ checkConditions?: Record<string, unknown> | null;
76
84
  }
77
85
  /**
78
86
  * Data for creating a new permission
@@ -85,6 +93,8 @@ interface CreatePermissionData {
85
93
  conditions?: Record<string, unknown>;
86
94
  defaultValues?: Record<string, unknown>;
87
95
  relConditions?: Record<string, unknown>;
96
+ /** WITH CHECK filter — see PermissionData.checkConditions */
97
+ checkConditions?: Record<string, unknown> | null;
88
98
  }
89
99
  /**
90
100
  * Tenant interface
package/dist/index.d.ts CHANGED
@@ -64,6 +64,8 @@ interface Permission {
64
64
  conditions?: Record<string, unknown>;
65
65
  defaultValues?: Record<string, unknown>;
66
66
  relConditions?: Record<string, unknown>;
67
+ /** WITH CHECK filter — see PermissionData.checkConditions */
68
+ checkConditions?: Record<string, unknown> | null;
67
69
  }
68
70
  /**
69
71
  * Permission data structure (internal to PermissionService)
@@ -73,6 +75,12 @@ interface PermissionData {
73
75
  conditions: Record<string, unknown>;
74
76
  relConditions: Record<string, unknown>;
75
77
  defaultValues: Record<string, unknown>;
78
+ /**
79
+ * WITH CHECK (RLS-style) filter: what a written row must satisfy, enforced
80
+ * post-write pre-commit on both create and update. null/absent = no check.
81
+ * `conditions` never applies to create grants.
82
+ */
83
+ checkConditions?: Record<string, unknown> | null;
76
84
  }
77
85
  /**
78
86
  * Data for creating a new permission
@@ -85,6 +93,8 @@ interface CreatePermissionData {
85
93
  conditions?: Record<string, unknown>;
86
94
  defaultValues?: Record<string, unknown>;
87
95
  relConditions?: Record<string, unknown>;
96
+ /** WITH CHECK filter — see PermissionData.checkConditions */
97
+ checkConditions?: Record<string, unknown> | null;
88
98
  }
89
99
  /**
90
100
  * Tenant interface
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baasix/types",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
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,289 +1,299 @@
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
- }
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
+ /** WITH CHECK filter — see PermissionData.checkConditions */
80
+ checkConditions?: Record<string, unknown> | null;
81
+ }
82
+
83
+ /**
84
+ * Permission data structure (internal to PermissionService)
85
+ */
86
+ export interface PermissionData {
87
+ fields: string[] | null;
88
+ conditions: Record<string, unknown>;
89
+ relConditions: Record<string, unknown>;
90
+ defaultValues: Record<string, unknown>;
91
+ /**
92
+ * WITH CHECK (RLS-style) filter: what a written row must satisfy, enforced
93
+ * post-write pre-commit on both create and update. null/absent = no check.
94
+ * `conditions` never applies to create grants.
95
+ */
96
+ checkConditions?: Record<string, unknown> | null;
97
+ }
98
+
99
+ /**
100
+ * Data for creating a new permission
101
+ */
102
+ export interface CreatePermissionData {
103
+ role_Id: string;
104
+ collection: string;
105
+ action: PermissionAction;
106
+ fields?: string[];
107
+ conditions?: Record<string, unknown>;
108
+ defaultValues?: Record<string, unknown>;
109
+ relConditions?: Record<string, unknown>;
110
+ /** WITH CHECK filter — see PermissionData.checkConditions */
111
+ checkConditions?: Record<string, unknown> | null;
112
+ }
113
+
114
+ // ============================================================================
115
+ // Tenant Types
116
+ // ============================================================================
117
+
118
+ /**
119
+ * Tenant interface
120
+ */
121
+ export interface Tenant {
122
+ id: string;
123
+ name: string;
124
+ [key: string]: unknown;
125
+ }
126
+
127
+ // ============================================================================
128
+ // Session & Token Types
129
+ // ============================================================================
130
+
131
+ /**
132
+ * Session interface
133
+ */
134
+ export interface Session {
135
+ id: string;
136
+ token: string;
137
+ user_Id: string;
138
+ expiresAt: Date | string;
139
+ ipAddress?: string;
140
+ userAgent?: string;
141
+ createdAt?: string;
142
+ updatedAt?: string;
143
+ }
144
+
145
+ /**
146
+ * Auth tokens
147
+ */
148
+ export interface AuthTokens {
149
+ accessToken: string;
150
+ refreshToken?: string;
151
+ expiresAt?: number;
152
+ expiresIn?: number;
153
+ }
154
+
155
+ /**
156
+ * JWT payload interface
157
+ */
158
+ export interface JWTPayload {
159
+ id: string;
160
+ email: string;
161
+ role: string;
162
+ sessionToken: string;
163
+ tenant_Id?: string | number | null;
164
+ /** Pinned baasix_UserRole row id (assignment switching). Absent on legacy tokens. */
165
+ userRole_Id?: string | null;
166
+ }
167
+
168
+ // ============================================================================
169
+ // Accountability Types
170
+ // ============================================================================
171
+
172
+ /**
173
+ * Accountability object interface - used for permission checking
174
+ */
175
+ export interface Accountability {
176
+ user?: { id: string | number; email?: string; isAdmin?: boolean; [key: string]: any };
177
+ role?: { id: string | number; name?: string; isTenantSpecific?: boolean } | string | number;
178
+ /** Full active baasix_UserRole row (assignment) — custom columns included. */
179
+ userRole?: Record<string, any>;
180
+ permissions?: any[];
181
+ tenant?: string | number;
182
+ ipaddress?: string;
183
+ }
184
+
185
+ // ============================================================================
186
+ // Auth Request/Response Types
187
+ // ============================================================================
188
+
189
+ /**
190
+ * Login credentials
191
+ */
192
+ export interface LoginCredentials {
193
+ email: string;
194
+ password: string;
195
+ tenantId?: string;
196
+ /** Authentication mode: 'jwt' for token-based or 'cookie' for cookie-based auth */
197
+ authMode?: "jwt" | "cookie";
198
+ /** Authentication type for session management (e.g., 'web', 'mobile', 'default') */
199
+ authType?: string;
200
+ }
201
+
202
+ /**
203
+ * Registration data
204
+ */
205
+ export interface RegisterData {
206
+ email: string;
207
+ password: string;
208
+ firstName?: string;
209
+ lastName?: string;
210
+ [key: string]: unknown;
211
+ }
212
+
213
+ /**
214
+ * Auth response
215
+ */
216
+ export interface AuthResponse {
217
+ token: string;
218
+ refreshToken?: string;
219
+ user: User;
220
+ role?: Role;
221
+ expiresIn?: number;
222
+ }
223
+
224
+ /**
225
+ * Auth state events
226
+ */
227
+ export type AuthStateEvent =
228
+ | "SIGNED_IN"
229
+ | "SIGNED_OUT"
230
+ | "TOKEN_REFRESHED"
231
+ | "USER_UPDATED"
232
+ | "TENANT_SWITCHED";
233
+
234
+ /**
235
+ * Auth state
236
+ */
237
+ export interface AuthState {
238
+ user: User | null;
239
+ isAuthenticated: boolean;
240
+ isLoading: boolean;
241
+ error: Error | null;
242
+ }
243
+
244
+ /**
245
+ * Magic link options
246
+ */
247
+ export interface MagicLinkOptions {
248
+ email: string;
249
+ redirectUrl?: string;
250
+ mode?: "link" | "code";
251
+ }
252
+
253
+ /**
254
+ * Password reset options
255
+ */
256
+ export interface PasswordResetOptions {
257
+ email: string;
258
+ redirectUrl?: string;
259
+ }
260
+
261
+ // ============================================================================
262
+ // Auth Mode Types
263
+ // ============================================================================
264
+
265
+ /**
266
+ * Authentication mode for the SDK/app
267
+ * - 'jwt': Use JWT tokens stored in the configured storage adapter (default)
268
+ * - 'cookie': Use HTTP-only cookies (server handles token storage)
269
+ */
270
+ export type AuthMode = "jwt" | "cookie";
271
+
272
+ // ============================================================================
273
+ // OAuth Types
274
+ // ============================================================================
275
+
276
+ /**
277
+ * OAuth2 tokens
278
+ */
279
+ export interface OAuth2Tokens {
280
+ accessToken: string;
281
+ refreshToken?: string;
282
+ idToken?: string;
283
+ expiresAt?: Date;
284
+ tokenType?: string;
285
+ scope?: string;
286
+ }
287
+
288
+ /**
289
+ * OAuth2 user info
290
+ */
291
+ export interface OAuth2UserInfo {
292
+ id: string;
293
+ email: string;
294
+ name?: string;
295
+ firstName?: string;
296
+ lastName?: string;
297
+ picture?: string;
298
+ [key: string]: unknown;
299
+ }