@baasix/types 1.0.5 → 1.0.7

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
@@ -309,6 +309,8 @@ interface FieldValues {
309
309
  values?: string[];
310
310
  /** Spatial reference system identifier (for geometry types) */
311
311
  srid?: number;
312
+ /** Vector dimensions (for pgvector types: Vector, HalfVec, SparseVec) */
313
+ dimensions?: number;
312
314
  }
313
315
  /**
314
316
  * Field definition
@@ -410,6 +412,13 @@ interface SchemaDefinition {
410
412
  timestamps?: boolean;
411
413
  paranoid?: boolean;
412
414
  sortEnabled?: boolean;
415
+ /**
416
+ * Controls tenant context enforcement for this collection.
417
+ * - true: enforce tenant scoping
418
+ * - false: global/shared collection (no tenant enforcement)
419
+ * - undefined: use default runtime behavior
420
+ */
421
+ tenantScoped?: boolean;
413
422
  /**
414
423
  * Track user who created/updated records (adds createdBy_Id, updatedBy_Id)
415
424
  */
package/dist/index.d.ts CHANGED
@@ -309,6 +309,8 @@ interface FieldValues {
309
309
  values?: string[];
310
310
  /** Spatial reference system identifier (for geometry types) */
311
311
  srid?: number;
312
+ /** Vector dimensions (for pgvector types: Vector, HalfVec, SparseVec) */
313
+ dimensions?: number;
312
314
  }
313
315
  /**
314
316
  * Field definition
@@ -410,6 +412,13 @@ interface SchemaDefinition {
410
412
  timestamps?: boolean;
411
413
  paranoid?: boolean;
412
414
  sortEnabled?: boolean;
415
+ /**
416
+ * Controls tenant context enforcement for this collection.
417
+ * - true: enforce tenant scoping
418
+ * - false: global/shared collection (no tenant enforcement)
419
+ * - undefined: use default runtime behavior
420
+ */
421
+ tenantScoped?: boolean;
413
422
  /**
414
423
  * Track user who created/updated records (adds createdBy_Id, updatedBy_Id)
415
424
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baasix/types",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Shared TypeScript types for Baasix packages",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
package/src/common.ts CHANGED
@@ -1,244 +1,244 @@
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
- max_retries?: number;
127
- retry_count?: number;
128
- started_at?: Date | null;
129
- [key: string]: unknown;
130
- }
131
-
132
- // ============================================================================
133
- // Hook Types
134
- // ============================================================================
135
-
136
- /**
137
- * Hook events
138
- */
139
- export type HookEvent =
140
- | "items.create"
141
- | "items.read"
142
- | "items.update"
143
- | "items.delete"
144
- | "auth.login"
145
- | "auth.logout"
146
- | "auth.register";
147
-
148
- /**
149
- * Hook handler context
150
- */
151
- export interface HookContext {
152
- event: HookEvent;
153
- collection?: string;
154
- payload?: unknown;
155
- keys?: string[];
156
- accountability?: {
157
- user?: { id: string };
158
- role?: { id: string; name: string };
159
- tenant?: { id: string };
160
- };
161
- }
162
-
163
- /**
164
- * Hook handler function
165
- */
166
- export type HookHandler = (context: HookContext) => void | Promise<void>;
167
-
168
- /**
169
- * Hook definition
170
- */
171
- export interface Hook {
172
- event: HookEvent;
173
- collection?: string;
174
- handler: HookHandler;
175
- }
176
-
177
- // ============================================================================
178
- // HTTP Types
179
- // ============================================================================
180
-
181
- /**
182
- * HTTP methods
183
- */
184
- export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
185
-
186
- // ============================================================================
187
- // Mail Types
188
- // ============================================================================
189
-
190
- /**
191
- * Mail options for sending emails
192
- */
193
- export interface MailOptions {
194
- to: string | string[];
195
- subject: string;
196
- html?: string;
197
- text?: string;
198
- from?: string;
199
- cc?: string | string[];
200
- bcc?: string | string[];
201
- replyTo?: string;
202
- attachments?: Array<{
203
- filename: string;
204
- content?: string | Buffer;
205
- path?: string;
206
- contentType?: string;
207
- }>;
208
- }
209
-
210
- /**
211
- * Sender configuration for email
212
- */
213
- export interface SenderConfig {
214
- from: string;
215
- name?: string;
216
- replyTo?: string;
217
- }
218
-
219
- // ============================================================================
220
- // Seed Types
221
- // ============================================================================
222
-
223
- /**
224
- * Seed data configuration
225
- */
226
- export interface SeedData {
227
- collection: string;
228
- data: Record<string, unknown> | Record<string, unknown>[];
229
- /** Whether to clear existing data before seeding */
230
- clearBefore?: boolean;
231
- /** Whether to skip if data already exists (check by unique fields) */
232
- skipDuplicates?: boolean;
233
- }
234
-
235
- /**
236
- * Seed operation result
237
- */
238
- export interface SeedResult {
239
- collection: string;
240
- created: number;
241
- skipped: number;
242
- errors: number;
243
- errorDetails?: Array<{ item: unknown; error: string }>;
244
- }
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
+ max_retries?: number;
127
+ retry_count?: number;
128
+ started_at?: Date | null;
129
+ [key: string]: unknown;
130
+ }
131
+
132
+ // ============================================================================
133
+ // Hook Types
134
+ // ============================================================================
135
+
136
+ /**
137
+ * Hook events
138
+ */
139
+ export type HookEvent =
140
+ | "items.create"
141
+ | "items.read"
142
+ | "items.update"
143
+ | "items.delete"
144
+ | "auth.login"
145
+ | "auth.logout"
146
+ | "auth.register";
147
+
148
+ /**
149
+ * Hook handler context
150
+ */
151
+ export interface HookContext {
152
+ event: HookEvent;
153
+ collection?: string;
154
+ payload?: unknown;
155
+ keys?: string[];
156
+ accountability?: {
157
+ user?: { id: string };
158
+ role?: { id: string; name: string };
159
+ tenant?: { id: string };
160
+ };
161
+ }
162
+
163
+ /**
164
+ * Hook handler function
165
+ */
166
+ export type HookHandler = (context: HookContext) => void | Promise<void>;
167
+
168
+ /**
169
+ * Hook definition
170
+ */
171
+ export interface Hook {
172
+ event: HookEvent;
173
+ collection?: string;
174
+ handler: HookHandler;
175
+ }
176
+
177
+ // ============================================================================
178
+ // HTTP Types
179
+ // ============================================================================
180
+
181
+ /**
182
+ * HTTP methods
183
+ */
184
+ export type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
185
+
186
+ // ============================================================================
187
+ // Mail Types
188
+ // ============================================================================
189
+
190
+ /**
191
+ * Mail options for sending emails
192
+ */
193
+ export interface MailOptions {
194
+ to: string | string[];
195
+ subject: string;
196
+ html?: string;
197
+ text?: string;
198
+ from?: string;
199
+ cc?: string | string[];
200
+ bcc?: string | string[];
201
+ replyTo?: string;
202
+ attachments?: Array<{
203
+ filename: string;
204
+ content?: string | Buffer;
205
+ path?: string;
206
+ contentType?: string;
207
+ }>;
208
+ }
209
+
210
+ /**
211
+ * Sender configuration for email
212
+ */
213
+ export interface SenderConfig {
214
+ from: string;
215
+ name?: string;
216
+ replyTo?: string;
217
+ }
218
+
219
+ // ============================================================================
220
+ // Seed Types
221
+ // ============================================================================
222
+
223
+ /**
224
+ * Seed data configuration
225
+ */
226
+ export interface SeedData {
227
+ collection: string;
228
+ data: Record<string, unknown> | Record<string, unknown>[];
229
+ /** Whether to clear existing data before seeding */
230
+ clearBefore?: boolean;
231
+ /** Whether to skip if data already exists (check by unique fields) */
232
+ skipDuplicates?: boolean;
233
+ }
234
+
235
+ /**
236
+ * Seed operation result
237
+ */
238
+ export interface SeedResult {
239
+ collection: string;
240
+ created: number;
241
+ skipped: number;
242
+ errors: number;
243
+ errorDetails?: Array<{ item: unknown; error: string }>;
244
+ }
package/src/schema.ts CHANGED
@@ -95,6 +95,8 @@ export interface FieldValues {
95
95
  values?: string[];
96
96
  /** Spatial reference system identifier (for geometry types) */
97
97
  srid?: number;
98
+ /** Vector dimensions (for pgvector types: Vector, HalfVec, SparseVec) */
99
+ dimensions?: number;
98
100
  }
99
101
 
100
102
  /**
@@ -205,6 +207,13 @@ export interface SchemaDefinition {
205
207
  timestamps?: boolean;
206
208
  paranoid?: boolean;
207
209
  sortEnabled?: boolean;
210
+ /**
211
+ * Controls tenant context enforcement for this collection.
212
+ * - true: enforce tenant scoping
213
+ * - false: global/shared collection (no tenant enforcement)
214
+ * - undefined: use default runtime behavior
215
+ */
216
+ tenantScoped?: boolean;
208
217
  /**
209
218
  * Track user who created/updated records (adds createdBy_Id, updatedBy_Id)
210
219
  */