@stndrds/schema 0.1.0-alpha.14 → 0.1.0-alpha.16

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.
Files changed (72) hide show
  1. package/dist/chunk-2ASXJITY.mjs +5360 -0
  2. package/dist/chunk-5AWYVQKR.mjs +5310 -0
  3. package/dist/chunk-65HUQZHK.mjs +5374 -0
  4. package/dist/chunk-73P4F2OU.mjs +5809 -0
  5. package/dist/chunk-BHKKVBPP.mjs +5527 -0
  6. package/dist/chunk-BTVPMGYW.mjs +6327 -0
  7. package/dist/chunk-BUWVNOSK.mjs +5457 -0
  8. package/dist/chunk-C7HZ55GJ.mjs +6882 -0
  9. package/dist/chunk-CCEHW4E7.mjs +6071 -0
  10. package/dist/chunk-CNR3BZLU.mjs +5163 -0
  11. package/dist/chunk-DLMVX6DN.mjs +6074 -0
  12. package/dist/chunk-DUUORFHI.mjs +5379 -0
  13. package/dist/chunk-DWTD7YPJ.mjs +74 -0
  14. package/dist/chunk-FAR5ENGR.mjs +78 -0
  15. package/dist/chunk-ITWOVZOW.mjs +5809 -0
  16. package/dist/chunk-JDUTFH3J.mjs +6940 -0
  17. package/dist/chunk-KJLKY5X7.mjs +6314 -0
  18. package/dist/chunk-KTJXMGBR.mjs +5397 -0
  19. package/dist/chunk-NOVHQ7B2.mjs +6327 -0
  20. package/dist/chunk-PMFQ4ZL4.mjs +6230 -0
  21. package/dist/chunk-QAGN53HE.mjs +6327 -0
  22. package/dist/chunk-QC47SMCZ.mjs +5467 -0
  23. package/dist/chunk-UUOAVXAI.mjs +6327 -0
  24. package/dist/chunk-VYZ3BOSB.mjs +6946 -0
  25. package/dist/chunk-XAX75NSP.mjs +6321 -0
  26. package/dist/chunk-Z6LIJ5PO.mjs +5362 -0
  27. package/dist/chunk-ZG3PT3RL.mjs +6944 -0
  28. package/dist/default-roles-G4TOWUVM.mjs +20 -0
  29. package/dist/default-roles-QEZPRSUL.mjs +20 -0
  30. package/dist/index.d.mts +419 -16
  31. package/dist/index.d.ts +419 -16
  32. package/dist/index.js +2580 -406
  33. package/dist/index.mjs +80 -163
  34. package/dist/runtime-B1_syHVj.d.mts +4787 -0
  35. package/dist/runtime-B1_syHVj.d.ts +4787 -0
  36. package/dist/runtime-B7N-oycb.d.mts +4854 -0
  37. package/dist/runtime-B7N-oycb.d.ts +4854 -0
  38. package/dist/runtime-BDoAIuTe.d.mts +4872 -0
  39. package/dist/runtime-BDoAIuTe.d.ts +4872 -0
  40. package/dist/runtime-BPYJWZfC.d.mts +5130 -0
  41. package/dist/runtime-BPYJWZfC.d.ts +5130 -0
  42. package/dist/runtime-BVRmzg3d.d.mts +4718 -0
  43. package/dist/runtime-BVRmzg3d.d.ts +4718 -0
  44. package/dist/runtime-BrXwIidf.d.mts +4794 -0
  45. package/dist/runtime-BrXwIidf.d.ts +4794 -0
  46. package/dist/runtime-CC_HZhVN.d.mts +5224 -0
  47. package/dist/runtime-CC_HZhVN.d.ts +5224 -0
  48. package/dist/runtime-CEx57sBZ.d.mts +4791 -0
  49. package/dist/runtime-CEx57sBZ.d.ts +4791 -0
  50. package/dist/runtime-COGvuXIq.d.mts +4790 -0
  51. package/dist/runtime-COGvuXIq.d.ts +4790 -0
  52. package/dist/runtime-CSGWjztI.d.mts +5166 -0
  53. package/dist/runtime-CSGWjztI.d.ts +5166 -0
  54. package/dist/runtime-DRc_OhnM.d.mts +5142 -0
  55. package/dist/runtime-DRc_OhnM.d.ts +5142 -0
  56. package/dist/runtime-DUxWyRcq.d.mts +5399 -0
  57. package/dist/runtime-DUxWyRcq.d.ts +5399 -0
  58. package/dist/runtime-D_S3m9jf.d.mts +5142 -0
  59. package/dist/runtime-D_S3m9jf.d.ts +5142 -0
  60. package/dist/runtime-Db3rRxbJ.d.mts +4821 -0
  61. package/dist/runtime-Db3rRxbJ.d.ts +4821 -0
  62. package/dist/runtime-DlCiIIfr.d.mts +5130 -0
  63. package/dist/runtime-DlCiIIfr.d.ts +5130 -0
  64. package/dist/runtime-LO17NDk1.d.mts +5292 -0
  65. package/dist/runtime-LO17NDk1.d.ts +5292 -0
  66. package/dist/runtime-WqYxjhjJ.d.mts +5125 -0
  67. package/dist/runtime-WqYxjhjJ.d.ts +5125 -0
  68. package/dist/runtime.d.mts +1 -1
  69. package/dist/runtime.d.ts +1 -1
  70. package/dist/runtime.js +2178 -370
  71. package/dist/runtime.mjs +9 -1
  72. package/package.json +3 -3
@@ -0,0 +1,4794 @@
1
+ import { ColorId, IconName, CountryIso3, CurrencyCode, MimeType } from '@stndrds/constants';
2
+ import { z } from 'zod';
3
+
4
+ /**
5
+ * UUID string type for all identifiers
6
+ */
7
+ type Uuid = string;
8
+ /**
9
+ * Tenant identifier for multi-tenant isolation
10
+ * Phase 1: Type defined but not yet used in interfaces
11
+ * Phase 2+: Will be added to ObjectRecord and services for SaaS mode
12
+ */
13
+ type TenantId = string;
14
+ /**
15
+ * Generate a unique UUID v4
16
+ * Uses crypto.randomUUID() when available (Node.js 19+, modern browsers)
17
+ * Falls back to a manual implementation for older environments
18
+ *
19
+ * @returns A UUID v4 string
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const id = generateId();
24
+ * // "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
25
+ * ```
26
+ */
27
+ declare function generateId(): Uuid;
28
+ /**
29
+ * Generate a prefixed ID for better debugging and readability
30
+ *
31
+ * @param prefix - Prefix for the ID (e.g., "obj", "attr", "rec")
32
+ * @returns A prefixed UUID string
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const objectId = generatePrefixedId("obj");
37
+ * // "obj_a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
38
+ *
39
+ * const attrId = generatePrefixedId("attr");
40
+ * // "attr_a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
41
+ * ```
42
+ */
43
+ declare function generatePrefixedId(prefix: string): Uuid;
44
+
45
+ type AttributeType = "text" | "textarea" | "number" | "checkbox" | "date" | "phone" | "currency" | "status" | "location" | "timestamp" | "select" | "multiselect" | "file" | "user" | "relation" | "rating";
46
+ /**
47
+ * Status group categorization
48
+ */
49
+ type StatusGroup = "idle" | "in_progress" | "finished";
50
+ /**
51
+ * Unified option type for select-like fields
52
+ */
53
+ interface Option {
54
+ id: string;
55
+ label: string;
56
+ value: string;
57
+ color?: ColorId;
58
+ icon?: IconName;
59
+ description?: string;
60
+ group?: StatusGroup;
61
+ }
62
+ /**
63
+ * Attribute grouping for UI organization
64
+ */
65
+ interface AttributeGroup {
66
+ id: string;
67
+ label: string;
68
+ description?: string;
69
+ attributeIds: string[];
70
+ collapsible?: boolean;
71
+ collapsed?: boolean;
72
+ order?: number;
73
+ }
74
+ interface BaseAttribute<DefaultValueType = unknown> {
75
+ id: Uuid;
76
+ name: string;
77
+ label: string;
78
+ type: AttributeType;
79
+ required: boolean;
80
+ disabled?: boolean;
81
+ placeholder?: string;
82
+ description?: string;
83
+ defaultValue?: DefaultValueType;
84
+ icon?: IconName;
85
+ order?: number;
86
+ hidden?: boolean;
87
+ archived?: boolean;
88
+ deprecated?: boolean;
89
+ system?: boolean;
90
+ metadata?: Record<string, unknown>;
91
+ }
92
+ interface TextAttribute extends BaseAttribute<string> {
93
+ type: "text";
94
+ minLength?: number;
95
+ maxLength?: number;
96
+ pattern?: string;
97
+ }
98
+ type NumberUnit = "integer" | "decimal" | "percentage";
99
+ interface NumberAttribute extends BaseAttribute<number> {
100
+ type: "number";
101
+ min?: number;
102
+ max?: number;
103
+ unit?: NumberUnit;
104
+ decimals?: number;
105
+ }
106
+ interface CheckboxAttribute extends BaseAttribute<boolean> {
107
+ type: "checkbox";
108
+ }
109
+ type DateFormat = "short" | "long" | "full" | "relative";
110
+ type DateValue = string | "today";
111
+ interface DateAttribute extends BaseAttribute<string> {
112
+ type: "date";
113
+ dateFormat?: DateFormat;
114
+ minDate?: DateValue;
115
+ maxDate?: DateValue;
116
+ }
117
+ interface Phone {
118
+ countryCode: CountryIso3;
119
+ phoneNumber: string;
120
+ }
121
+ interface PhoneAttribute extends BaseAttribute<Phone> {
122
+ type: "phone";
123
+ defaultCountryCode?: CountryIso3;
124
+ }
125
+ interface Currency {
126
+ code: CurrencyCode;
127
+ value: number;
128
+ }
129
+ interface CurrencyAttribute extends BaseAttribute<Currency> {
130
+ type: "currency";
131
+ defaultCurrency?: CurrencyCode;
132
+ allowedCurrencies?: CurrencyCode[];
133
+ }
134
+ /**
135
+ * StatusAttribute - For workflow states with semantic grouping (idle/in_progress/finished)
136
+ * Use this for: Task status, Order status, Project phases, Process states
137
+ * Use SelectAttribute for: Categories, Types, simple choices without workflow
138
+ */
139
+ interface StatusAttribute extends BaseAttribute<string> {
140
+ type: "status";
141
+ options: Option[];
142
+ }
143
+ interface Location {
144
+ address?: string;
145
+ address2?: string;
146
+ city?: string;
147
+ state?: string;
148
+ postalCode?: string;
149
+ country?: CountryIso3;
150
+ latitude?: number;
151
+ longitude?: number;
152
+ }
153
+ type LocationGranularity = "full" | "address" | "city" | "state" | "country" | "coordinates";
154
+ interface LocationAttribute extends BaseAttribute<Location> {
155
+ type: "location";
156
+ granularity: LocationGranularity;
157
+ enableAutocomplete?: boolean;
158
+ enableMap?: boolean;
159
+ defaultCountry?: CountryIso3;
160
+ allowedCountries?: CountryIso3[];
161
+ displayFormat?: "single_line" | "multi_line" | "compact";
162
+ }
163
+ interface TimestampAttribute extends BaseAttribute<number> {
164
+ type: "timestamp";
165
+ autoUpdate?: boolean;
166
+ }
167
+ /**
168
+ * SelectAttribute - For simple single-choice selection
169
+ * Use this for: Categories, Document types, Departments, Priorities
170
+ * Options can be grouped (e.g., countries by continent) but no workflow logic
171
+ */
172
+ interface SelectAttribute extends BaseAttribute<string> {
173
+ type: "select";
174
+ options: Option[];
175
+ }
176
+ interface MultiselectAttribute extends BaseAttribute<string[]> {
177
+ type: "multiselect";
178
+ options: Option[];
179
+ }
180
+ type DocumentType = "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
181
+ type DocumentFace = "front" | "back" | "single";
182
+ interface DocumentTypeConfig {
183
+ type: DocumentType;
184
+ label: string;
185
+ faces: DocumentFace[];
186
+ attributeMapping?: {
187
+ attributeId: string;
188
+ extractedKey: string;
189
+ face?: DocumentFace;
190
+ required?: boolean;
191
+ }[];
192
+ }
193
+ interface FileVerificationConfig {
194
+ enabled: boolean;
195
+ documentTypes: DocumentTypeConfig[];
196
+ autoExtract?: boolean;
197
+ autoValidate?: boolean;
198
+ }
199
+ interface FileAttribute extends BaseAttribute<string> {
200
+ type: "file";
201
+ maxFiles?: number;
202
+ maxSize?: number;
203
+ allowedTypes?: MimeType[] | readonly MimeType[];
204
+ verification?: FileVerificationConfig;
205
+ }
206
+ interface UserAttribute extends BaseAttribute<string> {
207
+ type: "user";
208
+ allowedRoles?: string[];
209
+ }
210
+ /**
211
+ * Target object for a relation - defines which objects can be linked
212
+ */
213
+ interface RelationTarget {
214
+ /** Object name (e.g., "companies", "contacts") */
215
+ object: string;
216
+ /**
217
+ * Display template for the label using mustache-like syntax
218
+ * @example "{name}" or "{firstName} {lastName} — {email}"
219
+ */
220
+ displayTemplate?: string;
221
+ /**
222
+ * Optional filter to restrict available records
223
+ * @example { status: "active" }
224
+ */
225
+ filter?: Record<string, unknown>;
226
+ }
227
+ /**
228
+ * Strategy when a target record is deleted
229
+ * - "restrict": Prevent deletion if relations exist (default)
230
+ * - "cascade": Delete this record too
231
+ * - "set_null": Set the relation value to null
232
+ */
233
+ type RelationOnDelete = "restrict" | "cascade" | "set_null";
234
+ /**
235
+ * Base properties shared by both single and multi relation attributes
236
+ */
237
+ interface RelationAttributeBase extends Omit<BaseAttribute<unknown>, "defaultValue"> {
238
+ type: "relation";
239
+ /** Target objects that can be linked */
240
+ targets: RelationTarget[];
241
+ /** Deletion strategy when target record is deleted */
242
+ onDelete?: RelationOnDelete;
243
+ }
244
+ /**
245
+ * Single relation attribute (one-to-one or many-to-one)
246
+ * Stores a single record ID or null
247
+ */
248
+ interface SingleRelationAttribute extends RelationAttributeBase {
249
+ cardinality: "one";
250
+ defaultValue?: string | null;
251
+ }
252
+ /**
253
+ * Multi relation attribute (one-to-many or many-to-many)
254
+ * Stores an array of record IDs
255
+ */
256
+ interface MultiRelationAttribute extends RelationAttributeBase {
257
+ cardinality: "many";
258
+ defaultValue?: string[];
259
+ /** Minimum number of relations required */
260
+ minItems?: number;
261
+ /** Maximum number of relations allowed */
262
+ maxItems?: number;
263
+ }
264
+ /**
265
+ * RelationAttribute links to other objects/records
266
+ * Discriminated union by cardinality for type-safe value handling
267
+ *
268
+ * @example Single relation (many-to-one)
269
+ * ```typescript
270
+ * relation({ name: "company", label: "Company" })
271
+ * .to("companies")
272
+ * .required()
273
+ * // → Value: "rec-uuid-123" | null
274
+ * ```
275
+ *
276
+ * @example Multi relation (many-to-many)
277
+ * ```typescript
278
+ * relation({ name: "contacts", label: "Contacts" })
279
+ * .to("contacts", { displayTemplate: "{firstName} {lastName}" })
280
+ * .many()
281
+ * .maxItems(5)
282
+ * // → Value: ["rec-1", "rec-2", ...]
283
+ * ```
284
+ *
285
+ * @example Polymorphic relation (multiple target objects)
286
+ * ```typescript
287
+ * relation({ name: "linked", label: "Linked Items" })
288
+ * .to("companies")
289
+ * .to("contacts")
290
+ * .to("deals")
291
+ * .many()
292
+ * // → Can link to records from any of these objects
293
+ * ```
294
+ */
295
+ type RelationAttribute = SingleRelationAttribute | MultiRelationAttribute;
296
+ interface TextAreaAttribute extends BaseAttribute<string> {
297
+ type: "textarea";
298
+ }
299
+ interface RatingAttribute extends BaseAttribute<number> {
300
+ type: "rating";
301
+ max?: number;
302
+ iconType?: "star" | "heart" | "thumbs" | "number";
303
+ }
304
+ type Attribute = TextAttribute | TextAreaAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | LocationAttribute | TimestampAttribute | SelectAttribute | MultiselectAttribute | FileAttribute | UserAttribute | RelationAttribute | RatingAttribute;
305
+
306
+ /**
307
+ * Timestamps for tracking creation and updates
308
+ */
309
+ interface Timestamps {
310
+ createdAt: Date;
311
+ updatedAt: Date;
312
+ }
313
+ /**
314
+ * Object definition - Represents a database table/entity
315
+ */
316
+ interface ObjectDefinition {
317
+ id?: Uuid;
318
+ name: string;
319
+ label: string;
320
+ pluralLabel?: string;
321
+ description?: string;
322
+ icon?: IconName;
323
+ /**
324
+ * Template expression used to compute the object's display label.
325
+ * Supports variable interpolation and pipes for formatting.
326
+ *
327
+ * @example
328
+ * ```typescript
329
+ * // Simple attribute reference
330
+ * labelExpression: "{{ name }}"
331
+ *
332
+ * // Multiple attributes
333
+ * labelExpression: "{{ firstName }} {{ lastName }}"
334
+ *
335
+ * // With pipes for formatting
336
+ * labelExpression: "{{ code | UPPER }} - {{ name | capitalize }}"
337
+ * ```
338
+ *
339
+ * Available pipes: UPPER, LOWER, capitalize, trim
340
+ */
341
+ labelExpression: string;
342
+ attributes: Attribute[];
343
+ system?: boolean;
344
+ metadata?: Record<string, unknown>;
345
+ }
346
+ /**
347
+ * Links an attribute to an object
348
+ */
349
+ interface ObjectAttribute {
350
+ objectId: Uuid;
351
+ attributeId: Uuid;
352
+ order?: number;
353
+ required?: boolean;
354
+ }
355
+ /**
356
+ * Completion status of a record based on data completeness.
357
+ *
358
+ * - `draft`: Record is missing one or more required attribute values.
359
+ * Can be saved but is considered incomplete.
360
+ * - `complete`: All required attribute values are present and valid.
361
+ * Record is ready for use.
362
+ *
363
+ * This is different from workflow status (e.g., "pending", "approved").
364
+ * Completion status is computed dynamically based on the object schema.
365
+ */
366
+ type CompletionStatus = "draft" | "complete";
367
+ /**
368
+ * Record - Instance of an Object (a row in the database)
369
+ */
370
+ interface ObjectRecord extends Timestamps {
371
+ id: Uuid;
372
+ objectId: Uuid;
373
+ /**
374
+ * Display label computed from the object's labelExpression.
375
+ * Computed dynamically based on record values.
376
+ *
377
+ * @example "John Doe" (from "{{ firstName }} {{ lastName }}")
378
+ */
379
+ label: string;
380
+ /**
381
+ * Completion status of the record.
382
+ * - `draft`: Missing required values, record is incomplete
383
+ * - `complete`: All required values present and valid
384
+ *
385
+ * Computed dynamically based on the object's schema.
386
+ */
387
+ completionStatus: CompletionStatus;
388
+ values: Record<string, unknown>;
389
+ }
390
+
391
+ /**
392
+ * Storage provider type
393
+ */
394
+ type StorageProvider = "s3" | "gcs" | "azure" | "local" | "cloudflare-r2" | string;
395
+ /**
396
+ * File visibility level
397
+ */
398
+ type FileVisibility = "public" | "private" | "restricted";
399
+ /**
400
+ * File - Represents uploaded file metadata and storage info
401
+ *
402
+ * ARCHITECTURE:
403
+ * - Fixed table (no custom attributes)
404
+ * - Manages file storage, permissions, and metadata
405
+ * - uploadedBy links to user_profiles table
406
+ * - Supports soft delete via deletedAt
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * const file: File = {
411
+ * id: "file-123",
412
+ * tenantId: "tenant-456",
413
+ * name: "contract-2025.pdf",
414
+ * originalName: "Contract Acme Corp 2025.pdf",
415
+ * mimeType: "application/pdf",
416
+ * size: 2458624,
417
+ * storageProvider: "s3",
418
+ * storagePath: "tenants/456/files/2025/11/contract-2025.pdf",
419
+ * storageBucket: "my-app-files",
420
+ * url: "https://cdn.example.com/files/file-123",
421
+ * uploadedBy: "profile-789",
422
+ * folderPath: "/contracts/2025",
423
+ * tags: ["contract", "legal"],
424
+ * visibility: "restricted",
425
+ * allowedUsers: ["profile-789", "profile-456"],
426
+ * createdAt: new Date(),
427
+ * updatedAt: new Date(),
428
+ * };
429
+ * ```
430
+ */
431
+ interface File extends Timestamps {
432
+ id: Uuid;
433
+ tenantId: Uuid;
434
+ /**
435
+ * File name (sanitized for storage)
436
+ */
437
+ name: string;
438
+ /**
439
+ * Original file name (as uploaded by user)
440
+ */
441
+ originalName: string;
442
+ /**
443
+ * MIME type (e.g., "application/pdf", "image/jpeg")
444
+ */
445
+ mimeType: MimeType | string;
446
+ /**
447
+ * File size in bytes
448
+ */
449
+ size: number;
450
+ /**
451
+ * Storage provider (s3, gcs, azure, local, etc.)
452
+ */
453
+ storageProvider: StorageProvider;
454
+ /**
455
+ * Path in the storage bucket
456
+ */
457
+ storagePath: string;
458
+ /**
459
+ * Storage bucket name (if applicable)
460
+ */
461
+ storageBucket?: string;
462
+ /**
463
+ * Public or signed URL to access the file
464
+ */
465
+ url: string;
466
+ /**
467
+ * User who uploaded the file (FK to user_profiles)
468
+ */
469
+ uploadedBy: Uuid;
470
+ /**
471
+ * Folder path for organization (e.g., "/contracts/2025")
472
+ */
473
+ folderPath?: string;
474
+ /**
475
+ * Tags for search and categorization
476
+ */
477
+ tags?: string[];
478
+ /**
479
+ * File visibility level
480
+ * - public: Anyone with the URL can access
481
+ * - private: Only uploadedBy can access
482
+ * - restricted: Only specific users (allowedUsers) can access
483
+ */
484
+ visibility: FileVisibility;
485
+ /**
486
+ * List of user IDs authorized to access this file (if visibility = "restricted")
487
+ */
488
+ allowedUsers?: Uuid[];
489
+ /**
490
+ * Soft delete timestamp (null = not deleted)
491
+ */
492
+ deletedAt?: Date;
493
+ }
494
+ /**
495
+ * Data required to create a new file record
496
+ */
497
+ interface CreateFile {
498
+ tenantId: Uuid;
499
+ name: string;
500
+ originalName: string;
501
+ mimeType: MimeType | string;
502
+ size: number;
503
+ storageProvider: StorageProvider;
504
+ storagePath: string;
505
+ storageBucket?: string;
506
+ url: string;
507
+ uploadedBy: Uuid;
508
+ folderPath?: string;
509
+ tags?: string[];
510
+ visibility?: FileVisibility;
511
+ allowedUsers?: Uuid[];
512
+ }
513
+ /**
514
+ * Data for updating an existing file record
515
+ */
516
+ interface UpdateFile {
517
+ name?: string;
518
+ folderPath?: string;
519
+ tags?: string[];
520
+ visibility?: FileVisibility;
521
+ allowedUsers?: Uuid[];
522
+ }
523
+
524
+ /** Operators for text-based attributes */
525
+ type TextFilterOperator = "is" | "is_not" | "contains" | "not_contains" | "starts_with" | "ends_with" | "is_empty" | "is_not_empty";
526
+ /** Operators for number-based attributes */
527
+ type NumberFilterOperator = "eq" | "neq" | "lt" | "gt" | "lte" | "gte" | "is_empty" | "is_not_empty";
528
+ /** Operators for checkbox */
529
+ type CheckboxFilterOperator = "is_checked" | "is_not_checked";
530
+ /** Operators for date-based attributes */
531
+ type DateFilterOperator = "is" | "is_not" | "before" | "after" | "on_or_before" | "on_or_after" | "is_within" | "is_empty" | "is_not_empty";
532
+ /** Operators for select-based attributes (supports single or multi-value filtering) */
533
+ type SelectFilterOperator = "is" | "is_not" | "any_of" | "none_of" | "is_empty" | "is_not_empty";
534
+ /** Operators for multiselect-based attributes */
535
+ type MultiselectFilterOperator = "contains" | "not_contains" | "is_empty" | "is_not_empty";
536
+ /** Operators for relation-based attributes (supports single or multi-value filtering) */
537
+ type RelationFilterOperator = "any_of" | "none_of" | "contains" | "not_contains" | "is_empty" | "is_not_empty";
538
+ /** All possible filter operators */
539
+ type FilterOperator = TextFilterOperator | NumberFilterOperator | CheckboxFilterOperator | DateFilterOperator | SelectFilterOperator | MultiselectFilterOperator | RelationFilterOperator;
540
+ /** Relative date value for "is_within" operator */
541
+ interface RelativeDateValue {
542
+ amount: number;
543
+ unit: "days" | "weeks" | "months" | "years";
544
+ direction: "past" | "future";
545
+ }
546
+ /** Currency filter value with amount and optional currency codes
547
+ * - code: undefined or [] = any currency
548
+ * - code: string[] = filter by specific currencies
549
+ */
550
+ interface CurrencyFilterValue {
551
+ value: number | null;
552
+ code?: string[];
553
+ }
554
+ /** Phone filter value with number and optional country code */
555
+ interface PhoneFilterValue {
556
+ phoneNumber: string | null;
557
+ countryCode?: string;
558
+ }
559
+ /** Filter value can be various types depending on the attribute */
560
+ type FilterValue = string | number | boolean | string[] | RelativeDateValue | CurrencyFilterValue | PhoneFilterValue | null;
561
+ /** A single filter rule */
562
+ interface FilterRule {
563
+ /** Attribute name to filter on */
564
+ attribute: string;
565
+ /** Filter operator */
566
+ operator: FilterOperator;
567
+ /** Filter value (null for operators like is_empty) */
568
+ value: FilterValue;
569
+ }
570
+ /** Combinator for filter rules */
571
+ type FilterCombinator = "and" | "or";
572
+ /** Complete filter state (simple mode) */
573
+ interface FilterState {
574
+ /** How to combine rules */
575
+ combinator: FilterCombinator;
576
+ /** List of filter rules */
577
+ rules: FilterRule[];
578
+ }
579
+ /**
580
+ * A filter group containing rules (used in advanced mode)
581
+ * Groups can be nested up to 2 levels deep
582
+ */
583
+ interface FilterGroup {
584
+ /** Unique identifier for this group */
585
+ id: string;
586
+ /** How to combine rules within this group */
587
+ combinator: FilterCombinator;
588
+ /** List of filter rules in this group */
589
+ rules: FilterRule[];
590
+ }
591
+ /**
592
+ * Advanced filter state with nested groups
593
+ * Structure: AdvancedFilterState -> FilterGroup[] -> FilterRule[]
594
+ * Maximum 2 levels of nesting
595
+ */
596
+ interface AdvancedFilterState {
597
+ /** How to combine groups at the top level */
598
+ combinator: FilterCombinator;
599
+ /** List of filter groups */
600
+ groups: FilterGroup[];
601
+ }
602
+ /**
603
+ * Type guard to check if a filter state is advanced
604
+ */
605
+ declare function isAdvancedFilterState(state: FilterState | AdvancedFilterState): state is AdvancedFilterState;
606
+ /**
607
+ * Convert simple filter state to advanced filter state
608
+ */
609
+ declare function toAdvancedFilterState(state: FilterState): AdvancedFilterState;
610
+ /**
611
+ * Convert advanced filter state to simple filter state (flattens groups)
612
+ * Note: This loses group structure - use with caution
613
+ */
614
+ declare function toSimpleFilterState(state: AdvancedFilterState): FilterState;
615
+ /** Sort direction */
616
+ type SortDirection = "asc" | "desc";
617
+ /** A single sort rule */
618
+ interface SortRule {
619
+ /** Attribute name to sort by */
620
+ attribute: string;
621
+ /** Sort direction */
622
+ direction: SortDirection;
623
+ }
624
+ /** Complete query state with search, filters, sorts, and pagination */
625
+ interface QueryState {
626
+ /** Full-text search query */
627
+ search?: string;
628
+ /** Filter configuration (simple mode) */
629
+ filters?: FilterState;
630
+ /** Advanced filter configuration (grouped mode) */
631
+ advancedFilters?: AdvancedFilterState;
632
+ /** Sort configuration (multiple sorts supported) */
633
+ sorts?: SortRule[];
634
+ /** Pagination */
635
+ limit?: number;
636
+ offset?: number;
637
+ }
638
+ /** Mapping of attribute types to their valid operators */
639
+ declare const OPERATORS_BY_TYPE: Record<AttributeType, readonly FilterOperator[]>;
640
+ /** Check if an operator requires a value */
641
+ type NoValueOperator = "is_empty" | "is_not_empty" | "is_checked" | "is_not_checked";
642
+ /** Operators that don't require a value */
643
+ declare const NO_VALUE_OPERATORS: readonly NoValueOperator[];
644
+ /**
645
+ * Check if an operator requires a value
646
+ */
647
+ declare function isNoValueOperator(operator: FilterOperator): operator is NoValueOperator;
648
+
649
+ /**
650
+ * Autocomplete suggestion from geocoding service
651
+ */
652
+ interface GeocodingSuggestion {
653
+ /** Unique identifier from the provider */
654
+ id: string;
655
+ /** Human-readable label for display */
656
+ label: string;
657
+ /** Structured location data */
658
+ location: Location;
659
+ /** Optional match score/confidence (0-1) */
660
+ score?: number;
661
+ /** Optional additional metadata from the provider */
662
+ metadata?: Record<string, unknown>;
663
+ }
664
+ /**
665
+ * Parameters for autocomplete search
666
+ */
667
+ interface GeocodingAutocompleteParams {
668
+ /** Search query */
669
+ query: string;
670
+ /** Restrict results to specific countries */
671
+ countries?: CountryIso3[];
672
+ /** Preferred language for results (ISO 639-1) */
673
+ language?: string;
674
+ /** Maximum number of results */
675
+ limit?: number;
676
+ /** Bias results toward a specific location */
677
+ biasLocation?: {
678
+ latitude: number;
679
+ longitude: number;
680
+ };
681
+ /** Session token for billing optimization (some providers) */
682
+ sessionToken?: string;
683
+ /**
684
+ * Level of address detail expected
685
+ * Adapters can use this to filter/optimize results
686
+ * - "full": Full address with street, city, postal code, etc.
687
+ * - "address": Street address without postal code
688
+ * - "city": City level only
689
+ * - "state": State/region level only
690
+ * - "country": Country level only
691
+ * - "coordinates": Only coordinates (lat/lng)
692
+ */
693
+ granularity?: LocationGranularity;
694
+ }
695
+ /**
696
+ * Parameters for reverse geocoding
697
+ */
698
+ interface ReverseGeocodingParams {
699
+ /** Latitude */
700
+ latitude: number;
701
+ /** Longitude */
702
+ longitude: number;
703
+ /** Preferred language for results */
704
+ language?: string;
705
+ }
706
+ /**
707
+ * Parameters for geocoding a structured address
708
+ */
709
+ interface GeocodingParams {
710
+ /** Structured address components */
711
+ address: Partial<Location>;
712
+ /** Preferred language for results */
713
+ language?: string;
714
+ }
715
+ /**
716
+ * Abstract geocoding adapter interface
717
+ * Implement this interface for different geocoding providers
718
+ *
719
+ * @example Google Maps implementation
720
+ * ```typescript
721
+ * class GoogleMapsGeocodingAdapter implements GeocodingAdapter {
722
+ * async autocomplete(params) {
723
+ * const response = await fetch(
724
+ * `https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${params.query}&key=${this.apiKey}`
725
+ * );
726
+ * // Transform response to GeocodingSuggestion[]
727
+ * }
728
+ * }
729
+ * ```
730
+ *
731
+ * @example Mapbox implementation
732
+ * ```typescript
733
+ * class MapboxGeocodingAdapter implements GeocodingAdapter {
734
+ * async autocomplete(params) {
735
+ * const response = await fetch(
736
+ * `https://api.mapbox.com/geocoding/v5/mapbox.places/${params.query}.json?access_token=${this.token}`
737
+ * );
738
+ * // Transform response to GeocodingSuggestion[]
739
+ * }
740
+ * }
741
+ * ```
742
+ */
743
+ interface GeocodingAdapter {
744
+ /**
745
+ * Autocomplete address search
746
+ * Returns suggestions as the user types
747
+ */
748
+ autocomplete(params: GeocodingAutocompleteParams): Promise<GeocodingSuggestion[]>;
749
+ /**
750
+ * Reverse geocode coordinates to an address
751
+ * Optional - some providers may not support this
752
+ */
753
+ reverse?(params: ReverseGeocodingParams): Promise<GeocodingSuggestion | null>;
754
+ /**
755
+ * Geocode a structured address to coordinates
756
+ * Optional - some providers may not support this
757
+ */
758
+ geocode?(params: GeocodingParams): Promise<GeocodingSuggestion | null>;
759
+ }
760
+ /**
761
+ * No-op geocoding adapter
762
+ * Returns empty results when no geocoding provider is configured
763
+ */
764
+ declare class NoopGeocodingAdapter implements GeocodingAdapter {
765
+ autocomplete(): Promise<GeocodingSuggestion[]>;
766
+ reverse(): Promise<null>;
767
+ geocode(): Promise<null>;
768
+ }
769
+
770
+ /**
771
+ * Scope of a permission rule.
772
+ * - `object`: Controls access to an entire object type
773
+ * - `attribute`: Controls access to specific fields (Phase 2)
774
+ * - `record`: Controls access to specific records via filters (Phase 3)
775
+ */
776
+ type PermissionScope = "object" | "attribute" | "record";
777
+ /**
778
+ * Actions that can be performed on an object.
779
+ */
780
+ type ObjectAction = "read" | "create" | "update" | "delete";
781
+ /**
782
+ * Role definition - Groups permissions together.
783
+ *
784
+ * Roles are tenant-scoped and can be system-defined (immutable) or custom.
785
+ *
786
+ * @example
787
+ * ```typescript
788
+ * const adminRole: Role = {
789
+ * id: "role-123",
790
+ * tenantId: "tenant-456",
791
+ * name: "admin",
792
+ * label: "Administrator",
793
+ * description: "Full access to all objects",
794
+ * system: true,
795
+ * createdAt: new Date(),
796
+ * updatedAt: new Date(),
797
+ * };
798
+ * ```
799
+ */
800
+ interface Role extends Timestamps {
801
+ id: Uuid;
802
+ tenantId: Uuid;
803
+ /**
804
+ * Technical name (unique per tenant, used in code).
805
+ * Examples: "admin", "member", "sales_manager"
806
+ */
807
+ name: string;
808
+ /**
809
+ * Display name shown in UI.
810
+ */
811
+ label: string;
812
+ /**
813
+ * Optional description of the role's purpose.
814
+ */
815
+ description?: string;
816
+ /**
817
+ * If true, this role cannot be modified or deleted.
818
+ * Used for built-in roles like "admin".
819
+ * Follows the same naming convention as ObjectDefinition.system.
820
+ */
821
+ system: boolean;
822
+ }
823
+ /**
824
+ * Permission definition - Grants specific actions on a target.
825
+ *
826
+ * A permission belongs to a role and defines what actions are allowed
827
+ * on a specific target (object, attribute, or record filter).
828
+ *
829
+ * @example
830
+ * ```typescript
831
+ * // Allow read and update on companies object
832
+ * const permission: Permission = {
833
+ * id: "perm-123",
834
+ * roleId: "role-456",
835
+ * scope: "object",
836
+ * target: "companies",
837
+ * actions: ["read", "update"],
838
+ * createdAt: new Date(),
839
+ * };
840
+ *
841
+ * // Wildcard permission for all objects
842
+ * const wildcardPerm: Permission = {
843
+ * id: "perm-789",
844
+ * roleId: "role-456",
845
+ * scope: "object",
846
+ * target: "*",
847
+ * actions: ["read", "create", "update", "delete"],
848
+ * createdAt: new Date(),
849
+ * };
850
+ * ```
851
+ */
852
+ interface Permission {
853
+ id: Uuid;
854
+ roleId: Uuid;
855
+ /**
856
+ * Scope of this permission.
857
+ */
858
+ scope: PermissionScope;
859
+ /**
860
+ * Target of the permission.
861
+ * - For `object` scope: object name (e.g., "companies") or "*" for all
862
+ * - For `attribute` scope: "objectName.attributeName"
863
+ * - For `record` scope: object name (filter is in `filter` field)
864
+ */
865
+ target: string;
866
+ /**
867
+ * Actions allowed on the target.
868
+ */
869
+ actions: ObjectAction[];
870
+ /**
871
+ * JSON filter for record-level permissions (Phase 3).
872
+ * Supports template variables like `{{ currentUser.id }}`.
873
+ */
874
+ filter?: Record<string, unknown>;
875
+ createdAt: Date;
876
+ }
877
+ /**
878
+ * Links a user profile to a role within a tenant.
879
+ *
880
+ * A user can have multiple roles, and their permissions are additive (union).
881
+ *
882
+ * Note: `userProfileId` references UserProfile.id from the user_profiles table,
883
+ * NOT the auth provider ID (authId). This keeps permissions tied to the
884
+ * application's user management, not the authentication layer.
885
+ */
886
+ interface UserRoleAssignment {
887
+ id: Uuid;
888
+ /**
889
+ * User profile ID (UserProfile.id from user_profiles table).
890
+ * This links to the application's user management system,
891
+ * not the auth provider's user ID.
892
+ */
893
+ userProfileId: Uuid;
894
+ roleId: Uuid;
895
+ tenantId: Uuid;
896
+ /**
897
+ * When the role was assigned.
898
+ */
899
+ assignedAt: Date;
900
+ /**
901
+ * User profile ID of who assigned this role (for audit trail).
902
+ */
903
+ assignedBy?: Uuid;
904
+ }
905
+ /**
906
+ * Computed permissions for a user.
907
+ *
908
+ * This is the merged result of all roles assigned to a user.
909
+ * Returned by the API for permission checks.
910
+ */
911
+ interface EffectivePermissions {
912
+ /**
913
+ * If true, the user has full admin access and bypasses all permission checks.
914
+ */
915
+ isAdmin: boolean;
916
+ /**
917
+ * Object-level permissions.
918
+ * Key is the object name, value is array of allowed actions.
919
+ * Special key "*" means permission applies to all objects.
920
+ */
921
+ objectPermissions: Record<string, ObjectAction[]>;
922
+ }
923
+ /**
924
+ * Permissions for a specific object.
925
+ * Convenience type for frontend use.
926
+ */
927
+ interface ObjectPermissions {
928
+ canRead: boolean;
929
+ canCreate: boolean;
930
+ canUpdate: boolean;
931
+ canDelete: boolean;
932
+ }
933
+ /**
934
+ * Input for creating a new role.
935
+ */
936
+ interface CreateRoleInput {
937
+ tenantId: Uuid;
938
+ name: string;
939
+ label: string;
940
+ description?: string;
941
+ }
942
+ /**
943
+ * Input for updating an existing role.
944
+ */
945
+ interface UpdateRoleInput {
946
+ label?: string;
947
+ description?: string;
948
+ }
949
+ /**
950
+ * Input for creating a permission.
951
+ */
952
+ interface CreatePermissionInput {
953
+ scope: PermissionScope;
954
+ target: string;
955
+ actions: ObjectAction[];
956
+ filter?: Record<string, unknown>;
957
+ }
958
+ /**
959
+ * Input for assigning a role to a user.
960
+ */
961
+ interface AssignRoleInput {
962
+ /**
963
+ * User profile ID (UserProfile.id).
964
+ */
965
+ userProfileId: Uuid;
966
+ roleId: Uuid;
967
+ tenantId: Uuid;
968
+ assignedBy?: Uuid;
969
+ }
970
+
971
+ /**
972
+ * Simple user role for basic authorization.
973
+ *
974
+ * COEXISTENCE WITH RBAC:
975
+ * This simple role system coexists with the granular RBAC system (see `permissions.ts`).
976
+ *
977
+ * - **UserProfile.role**: Simple string-based role for quick access checks.
978
+ * Used for high-level authorization (e.g., "is this user an admin?").
979
+ * Values: "admin" | "member" | "guest" | custom strings.
980
+ *
981
+ * - **RBAC System (Role, Permission, UserRoleAssignment)**: Fine-grained permissions
982
+ * for object-level access control (read/create/update/delete per object type).
983
+ * Used for detailed authorization (e.g., "can this user update companies?").
984
+ *
985
+ * MIGRATION STRATEGY:
986
+ * 1. For simple apps: Use only `UserProfile.role` - sufficient for basic admin/member checks.
987
+ * 2. For complex apps: Use RBAC for granular permissions, `UserProfile.role` becomes informational.
988
+ * 3. The `PermissionService.getEffectivePermissions()` automatically grants admin bypass
989
+ * when a user has a role named "admin" in the RBAC system.
990
+ *
991
+ * @see permissions.ts for the full RBAC implementation
992
+ */
993
+ type UserRole = "admin" | "member" | "guest" | string;
994
+ /**
995
+ * User status for account management
996
+ */
997
+ type UserStatus = "active" | "pending" | "inactive" | "suspended";
998
+ /**
999
+ * User Profile - Represents application user data (authorization)
1000
+ *
1001
+ * ARCHITECTURE:
1002
+ * - authId links to external auth provider (Supabase, Clerk, Auth0, etc.)
1003
+ * - email is denormalized from auth provider for performance
1004
+ * - Auth provider handles authentication (passwords, sessions, OAuth)
1005
+ * - This type handles authorization (roles, permissions, tenant membership)
1006
+ *
1007
+ * RELATIONSHIP WITH RBAC:
1008
+ * - `UserProfile.id` is used as `userProfileId` in `UserRoleAssignment`
1009
+ * - The RBAC system assigns multiple roles to a UserProfile
1010
+ * - For simple use cases, `UserProfile.role` is sufficient
1011
+ * - For granular permissions, use the RBAC system via `PermissionService`
1012
+ *
1013
+ * @example
1014
+ * ```typescript
1015
+ * const profile: UserProfile = {
1016
+ * id: "profile-123",
1017
+ * tenantId: "tenant-456",
1018
+ * authId: "supabase-auth-uuid-789",
1019
+ * email: "john@example.com",
1020
+ * firstName: "John",
1021
+ * lastName: "Doe",
1022
+ * role: "admin",
1023
+ * status: "active",
1024
+ * createdAt: new Date(),
1025
+ * updatedAt: new Date(),
1026
+ * };
1027
+ * ```
1028
+ */
1029
+ interface UserProfile extends Timestamps {
1030
+ id: Uuid;
1031
+ tenantId: Uuid;
1032
+ /**
1033
+ * Link to external auth provider (Supabase auth.users.id, Clerk user ID, etc.)
1034
+ * This is the bridge between authentication (provider) and authorization (your app)
1035
+ */
1036
+ authId: string;
1037
+ /**
1038
+ * Email address (denormalized from auth provider)
1039
+ * Allows efficient querying and filtering without hitting auth provider API
1040
+ */
1041
+ email: string;
1042
+ /**
1043
+ * User's first name
1044
+ */
1045
+ firstName?: string;
1046
+ /**
1047
+ * User's last name
1048
+ */
1049
+ lastName?: string;
1050
+ /**
1051
+ * Avatar/profile picture URL
1052
+ */
1053
+ avatarUrl?: string;
1054
+ /**
1055
+ * Simple role for basic authorization checks.
1056
+ *
1057
+ * Common values: "admin", "member", "guest"
1058
+ *
1059
+ * NOTE: For granular object-level permissions, use the RBAC system
1060
+ * (Role, Permission, UserRoleAssignment) via PermissionService.
1061
+ * This field is kept for backward compatibility and simple use cases.
1062
+ *
1063
+ * @see UserRoleAssignment for the RBAC relationship
1064
+ */
1065
+ role: UserRole;
1066
+ /**
1067
+ * Account status
1068
+ * - active: Normal user, full access
1069
+ * - pending: Awaiting activation/approval
1070
+ * - inactive: Deactivated account
1071
+ * - suspended: Temporarily blocked
1072
+ */
1073
+ status: UserStatus;
1074
+ /**
1075
+ * Last login timestamp (updated on each successful auth)
1076
+ */
1077
+ lastLoginAt?: Date;
1078
+ }
1079
+ /**
1080
+ * Data required to create a new user profile
1081
+ */
1082
+ interface CreateUserProfile {
1083
+ tenantId: Uuid;
1084
+ authId: string;
1085
+ email: string;
1086
+ firstName?: string;
1087
+ lastName?: string;
1088
+ avatarUrl?: string;
1089
+ role?: UserRole;
1090
+ status?: UserStatus;
1091
+ }
1092
+ /**
1093
+ * Data for updating an existing user profile
1094
+ */
1095
+ interface UpdateUserProfile {
1096
+ firstName?: string;
1097
+ lastName?: string;
1098
+ avatarUrl?: string;
1099
+ role?: UserRole;
1100
+ status?: UserStatus;
1101
+ lastLoginAt?: Date;
1102
+ }
1103
+
1104
+ /**
1105
+ * Inline attribute group configuration
1106
+ * Groups multiple attributes into a single composite field with dropdown editing
1107
+ */
1108
+ interface AttributeGroupField {
1109
+ /** Unique identifier for the group */
1110
+ id: string;
1111
+ /** Display label for the composite field */
1112
+ label: string;
1113
+ /** Description shown in the dropdown */
1114
+ description?: string;
1115
+ /** Attribute names to include in this group */
1116
+ attributes: string[];
1117
+ /**
1118
+ * Template for the display value
1119
+ * Uses {attributeName} syntax for interpolation
1120
+ * @example "{billing_street}, {billing_city} {billing_postal_code}"
1121
+ */
1122
+ displayTemplate?: string;
1123
+ }
1124
+ /**
1125
+ * Field definition within a form group
1126
+ * Can be either a single attribute or an inline attribute group
1127
+ */
1128
+ interface Field {
1129
+ /** Attribute name to display (for single attribute fields) */
1130
+ attribute?: string;
1131
+ /** Inline attribute group (groups multiple attributes into one composite field) */
1132
+ attributeGroup?: AttributeGroupField;
1133
+ /** Grid span (1-12 columns) */
1134
+ span?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
1135
+ /** Override label for this view (only for single attribute fields) */
1136
+ label?: string;
1137
+ /** Force read-only display */
1138
+ readOnly?: boolean;
1139
+ }
1140
+ /**
1141
+ * Group of fields for organizing forms
1142
+ */
1143
+ interface Group {
1144
+ id: string;
1145
+ label: string;
1146
+ description?: string;
1147
+ fields: Field[];
1148
+ collapsible?: boolean;
1149
+ collapsed?: boolean;
1150
+ order?: number;
1151
+ }
1152
+ type TabType = "form" | "table" | "custom";
1153
+ /**
1154
+ * Base properties shared by all tab types
1155
+ */
1156
+ interface BaseTab {
1157
+ id: string;
1158
+ name: string;
1159
+ label: string;
1160
+ icon?: IconName;
1161
+ order?: number;
1162
+ /** If true, tab is defined by developer (protected) */
1163
+ system?: boolean;
1164
+ }
1165
+ /**
1166
+ * Form tab - displays attributes organized in groups
1167
+ */
1168
+ interface FormTab extends BaseTab {
1169
+ type: "form";
1170
+ groups: Group[];
1171
+ }
1172
+ /**
1173
+ * Table tab - displays records from a relation attribute
1174
+ */
1175
+ interface TableTab extends BaseTab {
1176
+ type: "table";
1177
+ /** Name of the relation attribute */
1178
+ relation: string;
1179
+ /** Columns to display (attribute names from target object) */
1180
+ columns: string[];
1181
+ /** Allow creating new records */
1182
+ allowCreate?: boolean;
1183
+ /** Allow inline editing */
1184
+ allowEdit?: boolean;
1185
+ /** Allow deleting records */
1186
+ allowDelete?: boolean;
1187
+ /** Default filters */
1188
+ filters?: Record<string, unknown>;
1189
+ /** Default sort */
1190
+ sort?: {
1191
+ field: string;
1192
+ order: "asc" | "desc";
1193
+ };
1194
+ }
1195
+ /**
1196
+ * Custom tab - renders a developer-defined component
1197
+ */
1198
+ interface CustomTab extends BaseTab {
1199
+ type: "custom";
1200
+ /** Component identifier to render */
1201
+ component: string;
1202
+ /** Props to pass to the component */
1203
+ props?: Record<string, unknown>;
1204
+ }
1205
+ /**
1206
+ * Union of all tab types
1207
+ */
1208
+ type Tab = FormTab | TableTab | CustomTab;
1209
+ /**
1210
+ * View definition - organizes object attributes into tabs/pages
1211
+ *
1212
+ * @example
1213
+ * ```typescript
1214
+ * const companyView: ViewDefinition = {
1215
+ * name: "detail",
1216
+ * label: "Company Detail",
1217
+ * object: "companies",
1218
+ * tabs: [
1219
+ * { type: "form", name: "general", label: "Info", groups: [...] },
1220
+ * { type: "table", name: "contacts", label: "Contacts", relation: "contacts", columns: [...] }
1221
+ * ],
1222
+ * default: true,
1223
+ * system: true
1224
+ * };
1225
+ * ```
1226
+ */
1227
+ interface ViewDefinition {
1228
+ id?: Uuid;
1229
+ /** Technical name (kebab-case) */
1230
+ name: string;
1231
+ /** Display label */
1232
+ label: string;
1233
+ /** Description */
1234
+ description?: string;
1235
+ /** Icon */
1236
+ icon?: IconName;
1237
+ /** Object this view belongs to (object name) */
1238
+ object: string;
1239
+ /** Tabs in this view */
1240
+ tabs: Tab[];
1241
+ /** Default view for this object */
1242
+ default?: boolean;
1243
+ /** System view (defined by developer, protected) */
1244
+ system?: boolean;
1245
+ /** Extensible metadata */
1246
+ metadata?: Record<string, unknown>;
1247
+ }
1248
+ /**
1249
+ * Check if a tab is a form tab
1250
+ */
1251
+ declare function isFormTab(tab: Tab): tab is FormTab;
1252
+ /**
1253
+ * Check if a tab is a table tab
1254
+ */
1255
+ declare function isTableTab(tab: Tab): tab is TableTab;
1256
+ /**
1257
+ * Check if a tab is a custom tab
1258
+ */
1259
+ declare function isCustomTab(tab: Tab): tab is CustomTab;
1260
+
1261
+ /**
1262
+ * Registry for native objects defined in code
1263
+ * Native objects are system objects that cannot be deleted/modified by clients
1264
+ * They are defined by developers and synced to the database at startup
1265
+ */
1266
+ declare class NativeObjectRegistryClass {
1267
+ private objects;
1268
+ /**
1269
+ * Register one or more native objects
1270
+ * Auto-builds if ObjectBuilder is passed instead of ObjectDefinition
1271
+ * @param objects - Single object/builder or array of objects/builders to register
1272
+ * @returns this (for chaining)
1273
+ * @throws Error if object is invalid or already registered
1274
+ *
1275
+ * @example
1276
+ * ```typescript
1277
+ * // No .build() needed - registry auto-builds!
1278
+ * const PRODUCT = object({ id: "obj-product", name: "products", label: "Product" })
1279
+ * .system()
1280
+ * .attribute(text({ id: "attr-name", name: "name", label: "Name" }));
1281
+ *
1282
+ * registry.register(PRODUCT); // ← Auto-builds here
1283
+ *
1284
+ * // Can still explicitly .build() if you want
1285
+ * registry.register(PRODUCT.build());
1286
+ *
1287
+ * // Register multiple
1288
+ * registry.register([PRODUCT, ORDER, CUSTOMER]);
1289
+ * ```
1290
+ */
1291
+ register(objects: ObjectDefinition | ObjectDefinition[] | {
1292
+ build: () => ObjectDefinition;
1293
+ } | Array<{
1294
+ build: () => ObjectDefinition;
1295
+ }>): this;
1296
+ /**
1297
+ * Validate and register a single object
1298
+ * @internal
1299
+ */
1300
+ private validateAndRegister;
1301
+ /**
1302
+ * Get a native object by its name
1303
+ * @param name - The object name
1304
+ * @returns The object definition or undefined if not found
1305
+ *
1306
+ * @example
1307
+ * ```typescript
1308
+ * const product = registry.getByName("products");
1309
+ * if (product) {
1310
+ * console.log(product.label); // "Product"
1311
+ * }
1312
+ * ```
1313
+ */
1314
+ getByName(name: string): ObjectDefinition | undefined;
1315
+ /**
1316
+ * Get a native object or throw if not found
1317
+ * @param name - The object name
1318
+ * @returns The object definition
1319
+ * @throws Error if not found
1320
+ */
1321
+ getByNameOrThrow(name: string): ObjectDefinition;
1322
+ /**
1323
+ * Get all registered native objects
1324
+ * @returns Array of all registered object definitions
1325
+ */
1326
+ getAll(): ObjectDefinition[];
1327
+ /**
1328
+ * Get all registered native object names
1329
+ * @returns Array of object names
1330
+ */
1331
+ listNames(): string[];
1332
+ /**
1333
+ * Check if a native object is registered
1334
+ * @param name - The object name
1335
+ * @returns true if registered, false otherwise
1336
+ */
1337
+ has(name: string): boolean;
1338
+ /**
1339
+ * Get the number of registered objects
1340
+ */
1341
+ get size(): number;
1342
+ /**
1343
+ * Clear all registered objects (useful for testing)
1344
+ * @internal
1345
+ */
1346
+ clear(): void;
1347
+ /**
1348
+ * Get registry summary for debugging
1349
+ */
1350
+ summary(): string;
1351
+ /**
1352
+ * Log registry summary to console
1353
+ */
1354
+ debug(): void;
1355
+ }
1356
+ /**
1357
+ * Singleton instance of the registry
1358
+ * Use this to register and retrieve native objects
1359
+ *
1360
+ * @example
1361
+ * ```typescript
1362
+ * import { registry } from "@stndrds/schema";
1363
+ *
1364
+ * // Register objects
1365
+ * registry.register([PRODUCT, ORDER, CUSTOMER]);
1366
+ *
1367
+ * // Get object by name
1368
+ * const product = registry.getByName("products");
1369
+ *
1370
+ * // List all
1371
+ * console.log(registry.listNames()); // ["products", "orders", ...]
1372
+ *
1373
+ * // Debug
1374
+ * registry.debug();
1375
+ * ```
1376
+ */
1377
+ declare const registry: NativeObjectRegistryClass;
1378
+
1379
+ /**
1380
+ * Registry for native view definitions
1381
+ *
1382
+ * Views registered here are considered "system" views, defined by the developer.
1383
+ * They are protected from modification by end-users and synced to the database
1384
+ * at application startup.
1385
+ *
1386
+ * @example
1387
+ * ```typescript
1388
+ * import { view, group, viewRegistry } from "@stndrds/schema";
1389
+ *
1390
+ * const COMPANY_DETAIL = view("detail", "Detail")
1391
+ * .for("companies")
1392
+ * .system()
1393
+ * .tab("general", "Info")
1394
+ * .form(group("main", "Main").fields("name", "status"))
1395
+ * .build();
1396
+ *
1397
+ * viewRegistry.register(COMPANY_DETAIL);
1398
+ * ```
1399
+ */
1400
+ declare class ViewRegistry {
1401
+ private views;
1402
+ private byObject;
1403
+ /**
1404
+ * Register a native view
1405
+ * @param viewOrViews - Single view or array of views
1406
+ * @throws Error if view is not marked as system
1407
+ * @throws Error if view with same name already exists for the object
1408
+ */
1409
+ register(viewOrViews: ViewDefinition | ViewDefinition[]): this;
1410
+ private registerSingle;
1411
+ /**
1412
+ * Get all views for an object
1413
+ */
1414
+ getByObjectName(objectName: string): ViewDefinition[];
1415
+ /**
1416
+ * Get a specific view by object and view name
1417
+ */
1418
+ get(objectName: string, viewName: string): ViewDefinition | undefined;
1419
+ /**
1420
+ * Get a view or throw if not found
1421
+ */
1422
+ getOrThrow(objectName: string, viewName: string): ViewDefinition;
1423
+ /**
1424
+ * Get all registered views
1425
+ */
1426
+ getAll(): ViewDefinition[];
1427
+ /**
1428
+ * Check if a view exists
1429
+ */
1430
+ has(objectName: string, viewName: string): boolean;
1431
+ /**
1432
+ * Check if any views exist for an object
1433
+ */
1434
+ hasObject(objectName: string): boolean;
1435
+ /**
1436
+ * Get number of registered views
1437
+ */
1438
+ get size(): number;
1439
+ /**
1440
+ * List all object names that have views
1441
+ */
1442
+ listObjectNames(): string[];
1443
+ /**
1444
+ * Get default view for an object (if any)
1445
+ */
1446
+ getDefault(objectName: string): ViewDefinition | undefined;
1447
+ /**
1448
+ * Clear all registered views (for testing)
1449
+ */
1450
+ clear(): void;
1451
+ /**
1452
+ * Generate summary string for debugging
1453
+ */
1454
+ summary(): string;
1455
+ /**
1456
+ * Log summary to console
1457
+ */
1458
+ debug(): void;
1459
+ private makeKey;
1460
+ }
1461
+ /**
1462
+ * Global registry for native views
1463
+ */
1464
+ declare const viewRegistry: ViewRegistry;
1465
+
1466
+ /**
1467
+ * Text attribute config schema
1468
+ */
1469
+ declare const textConfigSchema: z.ZodObject<{
1470
+ disabled: z.ZodOptional<z.ZodBoolean>;
1471
+ placeholder: z.ZodOptional<z.ZodString>;
1472
+ description: z.ZodOptional<z.ZodString>;
1473
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1474
+ icon: z.ZodOptional<z.ZodString>;
1475
+ order: z.ZodOptional<z.ZodNumber>;
1476
+ hidden: z.ZodOptional<z.ZodBoolean>;
1477
+ archived: z.ZodOptional<z.ZodBoolean>;
1478
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1479
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1480
+ } & {
1481
+ minLength: z.ZodOptional<z.ZodNumber>;
1482
+ maxLength: z.ZodOptional<z.ZodNumber>;
1483
+ pattern: z.ZodOptional<z.ZodString>;
1484
+ }, "strip", z.ZodTypeAny, {
1485
+ defaultValue?: unknown;
1486
+ disabled?: boolean | undefined;
1487
+ placeholder?: string | undefined;
1488
+ description?: string | undefined;
1489
+ icon?: string | undefined;
1490
+ order?: number | undefined;
1491
+ hidden?: boolean | undefined;
1492
+ archived?: boolean | undefined;
1493
+ deprecated?: boolean | undefined;
1494
+ metadata?: Record<string, unknown> | undefined;
1495
+ minLength?: number | undefined;
1496
+ maxLength?: number | undefined;
1497
+ pattern?: string | undefined;
1498
+ }, {
1499
+ defaultValue?: unknown;
1500
+ disabled?: boolean | undefined;
1501
+ placeholder?: string | undefined;
1502
+ description?: string | undefined;
1503
+ icon?: string | undefined;
1504
+ order?: number | undefined;
1505
+ hidden?: boolean | undefined;
1506
+ archived?: boolean | undefined;
1507
+ deprecated?: boolean | undefined;
1508
+ metadata?: Record<string, unknown> | undefined;
1509
+ minLength?: number | undefined;
1510
+ maxLength?: number | undefined;
1511
+ pattern?: string | undefined;
1512
+ }>;
1513
+ /**
1514
+ * Textarea attribute config schema
1515
+ */
1516
+ declare const textareaConfigSchema: z.ZodObject<{
1517
+ disabled: z.ZodOptional<z.ZodBoolean>;
1518
+ placeholder: z.ZodOptional<z.ZodString>;
1519
+ description: z.ZodOptional<z.ZodString>;
1520
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1521
+ icon: z.ZodOptional<z.ZodString>;
1522
+ order: z.ZodOptional<z.ZodNumber>;
1523
+ hidden: z.ZodOptional<z.ZodBoolean>;
1524
+ archived: z.ZodOptional<z.ZodBoolean>;
1525
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1526
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1527
+ }, "strip", z.ZodTypeAny, {
1528
+ defaultValue?: unknown;
1529
+ disabled?: boolean | undefined;
1530
+ placeholder?: string | undefined;
1531
+ description?: string | undefined;
1532
+ icon?: string | undefined;
1533
+ order?: number | undefined;
1534
+ hidden?: boolean | undefined;
1535
+ archived?: boolean | undefined;
1536
+ deprecated?: boolean | undefined;
1537
+ metadata?: Record<string, unknown> | undefined;
1538
+ }, {
1539
+ defaultValue?: unknown;
1540
+ disabled?: boolean | undefined;
1541
+ placeholder?: string | undefined;
1542
+ description?: string | undefined;
1543
+ icon?: string | undefined;
1544
+ order?: number | undefined;
1545
+ hidden?: boolean | undefined;
1546
+ archived?: boolean | undefined;
1547
+ deprecated?: boolean | undefined;
1548
+ metadata?: Record<string, unknown> | undefined;
1549
+ }>;
1550
+ /**
1551
+ * Number attribute config schema
1552
+ */
1553
+ declare const numberConfigSchema: z.ZodObject<{
1554
+ disabled: z.ZodOptional<z.ZodBoolean>;
1555
+ placeholder: z.ZodOptional<z.ZodString>;
1556
+ description: z.ZodOptional<z.ZodString>;
1557
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1558
+ icon: z.ZodOptional<z.ZodString>;
1559
+ order: z.ZodOptional<z.ZodNumber>;
1560
+ hidden: z.ZodOptional<z.ZodBoolean>;
1561
+ archived: z.ZodOptional<z.ZodBoolean>;
1562
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1563
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1564
+ } & {
1565
+ min: z.ZodOptional<z.ZodNumber>;
1566
+ max: z.ZodOptional<z.ZodNumber>;
1567
+ unit: z.ZodOptional<z.ZodEnum<["integer", "decimal", "percentage"]>>;
1568
+ decimals: z.ZodOptional<z.ZodNumber>;
1569
+ }, "strip", z.ZodTypeAny, {
1570
+ defaultValue?: unknown;
1571
+ disabled?: boolean | undefined;
1572
+ placeholder?: string | undefined;
1573
+ description?: string | undefined;
1574
+ icon?: string | undefined;
1575
+ order?: number | undefined;
1576
+ hidden?: boolean | undefined;
1577
+ archived?: boolean | undefined;
1578
+ deprecated?: boolean | undefined;
1579
+ metadata?: Record<string, unknown> | undefined;
1580
+ min?: number | undefined;
1581
+ max?: number | undefined;
1582
+ unit?: "percentage" | "integer" | "decimal" | undefined;
1583
+ decimals?: number | undefined;
1584
+ }, {
1585
+ defaultValue?: unknown;
1586
+ disabled?: boolean | undefined;
1587
+ placeholder?: string | undefined;
1588
+ description?: string | undefined;
1589
+ icon?: string | undefined;
1590
+ order?: number | undefined;
1591
+ hidden?: boolean | undefined;
1592
+ archived?: boolean | undefined;
1593
+ deprecated?: boolean | undefined;
1594
+ metadata?: Record<string, unknown> | undefined;
1595
+ min?: number | undefined;
1596
+ max?: number | undefined;
1597
+ unit?: "percentage" | "integer" | "decimal" | undefined;
1598
+ decimals?: number | undefined;
1599
+ }>;
1600
+ /**
1601
+ * Checkbox attribute config schema
1602
+ */
1603
+ declare const checkboxConfigSchema: z.ZodObject<{
1604
+ disabled: z.ZodOptional<z.ZodBoolean>;
1605
+ placeholder: z.ZodOptional<z.ZodString>;
1606
+ description: z.ZodOptional<z.ZodString>;
1607
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1608
+ icon: z.ZodOptional<z.ZodString>;
1609
+ order: z.ZodOptional<z.ZodNumber>;
1610
+ hidden: z.ZodOptional<z.ZodBoolean>;
1611
+ archived: z.ZodOptional<z.ZodBoolean>;
1612
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1613
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1614
+ }, "strip", z.ZodTypeAny, {
1615
+ defaultValue?: unknown;
1616
+ disabled?: boolean | undefined;
1617
+ placeholder?: string | undefined;
1618
+ description?: string | undefined;
1619
+ icon?: string | undefined;
1620
+ order?: number | undefined;
1621
+ hidden?: boolean | undefined;
1622
+ archived?: boolean | undefined;
1623
+ deprecated?: boolean | undefined;
1624
+ metadata?: Record<string, unknown> | undefined;
1625
+ }, {
1626
+ defaultValue?: unknown;
1627
+ disabled?: boolean | undefined;
1628
+ placeholder?: string | undefined;
1629
+ description?: string | undefined;
1630
+ icon?: string | undefined;
1631
+ order?: number | undefined;
1632
+ hidden?: boolean | undefined;
1633
+ archived?: boolean | undefined;
1634
+ deprecated?: boolean | undefined;
1635
+ metadata?: Record<string, unknown> | undefined;
1636
+ }>;
1637
+ /**
1638
+ * Date attribute config schema
1639
+ */
1640
+ declare const dateConfigSchema: z.ZodObject<{
1641
+ disabled: z.ZodOptional<z.ZodBoolean>;
1642
+ placeholder: z.ZodOptional<z.ZodString>;
1643
+ description: z.ZodOptional<z.ZodString>;
1644
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1645
+ icon: z.ZodOptional<z.ZodString>;
1646
+ order: z.ZodOptional<z.ZodNumber>;
1647
+ hidden: z.ZodOptional<z.ZodBoolean>;
1648
+ archived: z.ZodOptional<z.ZodBoolean>;
1649
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1650
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1651
+ } & {
1652
+ dateFormat: z.ZodOptional<z.ZodEnum<["short", "long", "full", "relative"]>>;
1653
+ minDate: z.ZodOptional<z.ZodString>;
1654
+ maxDate: z.ZodOptional<z.ZodString>;
1655
+ }, "strip", z.ZodTypeAny, {
1656
+ defaultValue?: unknown;
1657
+ disabled?: boolean | undefined;
1658
+ placeholder?: string | undefined;
1659
+ description?: string | undefined;
1660
+ icon?: string | undefined;
1661
+ order?: number | undefined;
1662
+ hidden?: boolean | undefined;
1663
+ archived?: boolean | undefined;
1664
+ deprecated?: boolean | undefined;
1665
+ metadata?: Record<string, unknown> | undefined;
1666
+ dateFormat?: "short" | "long" | "full" | "relative" | undefined;
1667
+ minDate?: string | undefined;
1668
+ maxDate?: string | undefined;
1669
+ }, {
1670
+ defaultValue?: unknown;
1671
+ disabled?: boolean | undefined;
1672
+ placeholder?: string | undefined;
1673
+ description?: string | undefined;
1674
+ icon?: string | undefined;
1675
+ order?: number | undefined;
1676
+ hidden?: boolean | undefined;
1677
+ archived?: boolean | undefined;
1678
+ deprecated?: boolean | undefined;
1679
+ metadata?: Record<string, unknown> | undefined;
1680
+ dateFormat?: "short" | "long" | "full" | "relative" | undefined;
1681
+ minDate?: string | undefined;
1682
+ maxDate?: string | undefined;
1683
+ }>;
1684
+ /**
1685
+ * Phone attribute config schema
1686
+ */
1687
+ declare const phoneConfigSchema: z.ZodObject<{
1688
+ disabled: z.ZodOptional<z.ZodBoolean>;
1689
+ placeholder: z.ZodOptional<z.ZodString>;
1690
+ description: z.ZodOptional<z.ZodString>;
1691
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1692
+ icon: z.ZodOptional<z.ZodString>;
1693
+ order: z.ZodOptional<z.ZodNumber>;
1694
+ hidden: z.ZodOptional<z.ZodBoolean>;
1695
+ archived: z.ZodOptional<z.ZodBoolean>;
1696
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1697
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1698
+ } & {
1699
+ defaultCountryCode: z.ZodOptional<z.ZodString>;
1700
+ }, "strip", z.ZodTypeAny, {
1701
+ defaultValue?: unknown;
1702
+ disabled?: boolean | undefined;
1703
+ placeholder?: string | undefined;
1704
+ description?: string | undefined;
1705
+ icon?: string | undefined;
1706
+ order?: number | undefined;
1707
+ hidden?: boolean | undefined;
1708
+ archived?: boolean | undefined;
1709
+ deprecated?: boolean | undefined;
1710
+ metadata?: Record<string, unknown> | undefined;
1711
+ defaultCountryCode?: string | undefined;
1712
+ }, {
1713
+ defaultValue?: unknown;
1714
+ disabled?: boolean | undefined;
1715
+ placeholder?: string | undefined;
1716
+ description?: string | undefined;
1717
+ icon?: string | undefined;
1718
+ order?: number | undefined;
1719
+ hidden?: boolean | undefined;
1720
+ archived?: boolean | undefined;
1721
+ deprecated?: boolean | undefined;
1722
+ metadata?: Record<string, unknown> | undefined;
1723
+ defaultCountryCode?: string | undefined;
1724
+ }>;
1725
+ /**
1726
+ * Currency attribute config schema
1727
+ */
1728
+ declare const currencyConfigSchema: z.ZodObject<{
1729
+ disabled: z.ZodOptional<z.ZodBoolean>;
1730
+ placeholder: z.ZodOptional<z.ZodString>;
1731
+ description: z.ZodOptional<z.ZodString>;
1732
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1733
+ icon: z.ZodOptional<z.ZodString>;
1734
+ order: z.ZodOptional<z.ZodNumber>;
1735
+ hidden: z.ZodOptional<z.ZodBoolean>;
1736
+ archived: z.ZodOptional<z.ZodBoolean>;
1737
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1738
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1739
+ } & {
1740
+ defaultCurrency: z.ZodOptional<z.ZodString>;
1741
+ allowedCurrencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1742
+ }, "strip", z.ZodTypeAny, {
1743
+ defaultValue?: unknown;
1744
+ disabled?: boolean | undefined;
1745
+ placeholder?: string | undefined;
1746
+ description?: string | undefined;
1747
+ icon?: string | undefined;
1748
+ order?: number | undefined;
1749
+ hidden?: boolean | undefined;
1750
+ archived?: boolean | undefined;
1751
+ deprecated?: boolean | undefined;
1752
+ metadata?: Record<string, unknown> | undefined;
1753
+ defaultCurrency?: string | undefined;
1754
+ allowedCurrencies?: string[] | undefined;
1755
+ }, {
1756
+ defaultValue?: unknown;
1757
+ disabled?: boolean | undefined;
1758
+ placeholder?: string | undefined;
1759
+ description?: string | undefined;
1760
+ icon?: string | undefined;
1761
+ order?: number | undefined;
1762
+ hidden?: boolean | undefined;
1763
+ archived?: boolean | undefined;
1764
+ deprecated?: boolean | undefined;
1765
+ metadata?: Record<string, unknown> | undefined;
1766
+ defaultCurrency?: string | undefined;
1767
+ allowedCurrencies?: string[] | undefined;
1768
+ }>;
1769
+ /**
1770
+ * Status attribute config schema
1771
+ */
1772
+ declare const statusConfigSchema: z.ZodObject<{
1773
+ disabled: z.ZodOptional<z.ZodBoolean>;
1774
+ placeholder: z.ZodOptional<z.ZodString>;
1775
+ description: z.ZodOptional<z.ZodString>;
1776
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1777
+ icon: z.ZodOptional<z.ZodString>;
1778
+ order: z.ZodOptional<z.ZodNumber>;
1779
+ hidden: z.ZodOptional<z.ZodBoolean>;
1780
+ archived: z.ZodOptional<z.ZodBoolean>;
1781
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1782
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1783
+ } & {
1784
+ options: z.ZodArray<z.ZodObject<{
1785
+ id: z.ZodString;
1786
+ label: z.ZodString;
1787
+ value: z.ZodString;
1788
+ color: z.ZodOptional<z.ZodString>;
1789
+ icon: z.ZodOptional<z.ZodString>;
1790
+ description: z.ZodOptional<z.ZodString>;
1791
+ group: z.ZodOptional<z.ZodEnum<["idle", "in_progress", "finished"]>>;
1792
+ }, "strip", z.ZodTypeAny, {
1793
+ label: string;
1794
+ id: string;
1795
+ value: string;
1796
+ description?: string | undefined;
1797
+ icon?: string | undefined;
1798
+ color?: string | undefined;
1799
+ group?: "idle" | "in_progress" | "finished" | undefined;
1800
+ }, {
1801
+ label: string;
1802
+ id: string;
1803
+ value: string;
1804
+ description?: string | undefined;
1805
+ icon?: string | undefined;
1806
+ color?: string | undefined;
1807
+ group?: "idle" | "in_progress" | "finished" | undefined;
1808
+ }>, "many">;
1809
+ }, "strip", z.ZodTypeAny, {
1810
+ options: {
1811
+ label: string;
1812
+ id: string;
1813
+ value: string;
1814
+ description?: string | undefined;
1815
+ icon?: string | undefined;
1816
+ color?: string | undefined;
1817
+ group?: "idle" | "in_progress" | "finished" | undefined;
1818
+ }[];
1819
+ defaultValue?: unknown;
1820
+ disabled?: boolean | undefined;
1821
+ placeholder?: string | undefined;
1822
+ description?: string | undefined;
1823
+ icon?: string | undefined;
1824
+ order?: number | undefined;
1825
+ hidden?: boolean | undefined;
1826
+ archived?: boolean | undefined;
1827
+ deprecated?: boolean | undefined;
1828
+ metadata?: Record<string, unknown> | undefined;
1829
+ }, {
1830
+ options: {
1831
+ label: string;
1832
+ id: string;
1833
+ value: string;
1834
+ description?: string | undefined;
1835
+ icon?: string | undefined;
1836
+ color?: string | undefined;
1837
+ group?: "idle" | "in_progress" | "finished" | undefined;
1838
+ }[];
1839
+ defaultValue?: unknown;
1840
+ disabled?: boolean | undefined;
1841
+ placeholder?: string | undefined;
1842
+ description?: string | undefined;
1843
+ icon?: string | undefined;
1844
+ order?: number | undefined;
1845
+ hidden?: boolean | undefined;
1846
+ archived?: boolean | undefined;
1847
+ deprecated?: boolean | undefined;
1848
+ metadata?: Record<string, unknown> | undefined;
1849
+ }>;
1850
+ /**
1851
+ * Location attribute config schema
1852
+ */
1853
+ declare const locationConfigSchema: z.ZodObject<{
1854
+ disabled: z.ZodOptional<z.ZodBoolean>;
1855
+ placeholder: z.ZodOptional<z.ZodString>;
1856
+ description: z.ZodOptional<z.ZodString>;
1857
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1858
+ icon: z.ZodOptional<z.ZodString>;
1859
+ order: z.ZodOptional<z.ZodNumber>;
1860
+ hidden: z.ZodOptional<z.ZodBoolean>;
1861
+ archived: z.ZodOptional<z.ZodBoolean>;
1862
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1863
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1864
+ } & {
1865
+ granularity: z.ZodEnum<["full", "address", "city", "state", "country", "coordinates"]>;
1866
+ enableAutocomplete: z.ZodOptional<z.ZodBoolean>;
1867
+ enableMap: z.ZodOptional<z.ZodBoolean>;
1868
+ defaultCountry: z.ZodOptional<z.ZodString>;
1869
+ allowedCountries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1870
+ displayFormat: z.ZodOptional<z.ZodEnum<["single_line", "multi_line", "compact"]>>;
1871
+ }, "strip", z.ZodTypeAny, {
1872
+ granularity: "full" | "address" | "city" | "state" | "country" | "coordinates";
1873
+ defaultValue?: unknown;
1874
+ disabled?: boolean | undefined;
1875
+ placeholder?: string | undefined;
1876
+ description?: string | undefined;
1877
+ icon?: string | undefined;
1878
+ order?: number | undefined;
1879
+ hidden?: boolean | undefined;
1880
+ archived?: boolean | undefined;
1881
+ deprecated?: boolean | undefined;
1882
+ metadata?: Record<string, unknown> | undefined;
1883
+ enableAutocomplete?: boolean | undefined;
1884
+ enableMap?: boolean | undefined;
1885
+ defaultCountry?: string | undefined;
1886
+ allowedCountries?: string[] | undefined;
1887
+ displayFormat?: "single_line" | "multi_line" | "compact" | undefined;
1888
+ }, {
1889
+ granularity: "full" | "address" | "city" | "state" | "country" | "coordinates";
1890
+ defaultValue?: unknown;
1891
+ disabled?: boolean | undefined;
1892
+ placeholder?: string | undefined;
1893
+ description?: string | undefined;
1894
+ icon?: string | undefined;
1895
+ order?: number | undefined;
1896
+ hidden?: boolean | undefined;
1897
+ archived?: boolean | undefined;
1898
+ deprecated?: boolean | undefined;
1899
+ metadata?: Record<string, unknown> | undefined;
1900
+ enableAutocomplete?: boolean | undefined;
1901
+ enableMap?: boolean | undefined;
1902
+ defaultCountry?: string | undefined;
1903
+ allowedCountries?: string[] | undefined;
1904
+ displayFormat?: "single_line" | "multi_line" | "compact" | undefined;
1905
+ }>;
1906
+ /**
1907
+ * Timestamp attribute config schema
1908
+ */
1909
+ declare const timestampConfigSchema: z.ZodObject<{
1910
+ disabled: z.ZodOptional<z.ZodBoolean>;
1911
+ placeholder: z.ZodOptional<z.ZodString>;
1912
+ description: z.ZodOptional<z.ZodString>;
1913
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1914
+ icon: z.ZodOptional<z.ZodString>;
1915
+ order: z.ZodOptional<z.ZodNumber>;
1916
+ hidden: z.ZodOptional<z.ZodBoolean>;
1917
+ archived: z.ZodOptional<z.ZodBoolean>;
1918
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1919
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1920
+ } & {
1921
+ autoUpdate: z.ZodOptional<z.ZodBoolean>;
1922
+ }, "strip", z.ZodTypeAny, {
1923
+ defaultValue?: unknown;
1924
+ disabled?: boolean | undefined;
1925
+ placeholder?: string | undefined;
1926
+ description?: string | undefined;
1927
+ icon?: string | undefined;
1928
+ order?: number | undefined;
1929
+ hidden?: boolean | undefined;
1930
+ archived?: boolean | undefined;
1931
+ deprecated?: boolean | undefined;
1932
+ metadata?: Record<string, unknown> | undefined;
1933
+ autoUpdate?: boolean | undefined;
1934
+ }, {
1935
+ defaultValue?: unknown;
1936
+ disabled?: boolean | undefined;
1937
+ placeholder?: string | undefined;
1938
+ description?: string | undefined;
1939
+ icon?: string | undefined;
1940
+ order?: number | undefined;
1941
+ hidden?: boolean | undefined;
1942
+ archived?: boolean | undefined;
1943
+ deprecated?: boolean | undefined;
1944
+ metadata?: Record<string, unknown> | undefined;
1945
+ autoUpdate?: boolean | undefined;
1946
+ }>;
1947
+ /**
1948
+ * Select attribute config schema
1949
+ */
1950
+ declare const selectConfigSchema: z.ZodObject<{
1951
+ disabled: z.ZodOptional<z.ZodBoolean>;
1952
+ placeholder: z.ZodOptional<z.ZodString>;
1953
+ description: z.ZodOptional<z.ZodString>;
1954
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1955
+ icon: z.ZodOptional<z.ZodString>;
1956
+ order: z.ZodOptional<z.ZodNumber>;
1957
+ hidden: z.ZodOptional<z.ZodBoolean>;
1958
+ archived: z.ZodOptional<z.ZodBoolean>;
1959
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1960
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1961
+ } & {
1962
+ options: z.ZodArray<z.ZodObject<{
1963
+ id: z.ZodString;
1964
+ label: z.ZodString;
1965
+ value: z.ZodString;
1966
+ color: z.ZodOptional<z.ZodString>;
1967
+ icon: z.ZodOptional<z.ZodString>;
1968
+ description: z.ZodOptional<z.ZodString>;
1969
+ group: z.ZodOptional<z.ZodEnum<["idle", "in_progress", "finished"]>>;
1970
+ }, "strip", z.ZodTypeAny, {
1971
+ label: string;
1972
+ id: string;
1973
+ value: string;
1974
+ description?: string | undefined;
1975
+ icon?: string | undefined;
1976
+ color?: string | undefined;
1977
+ group?: "idle" | "in_progress" | "finished" | undefined;
1978
+ }, {
1979
+ label: string;
1980
+ id: string;
1981
+ value: string;
1982
+ description?: string | undefined;
1983
+ icon?: string | undefined;
1984
+ color?: string | undefined;
1985
+ group?: "idle" | "in_progress" | "finished" | undefined;
1986
+ }>, "many">;
1987
+ }, "strip", z.ZodTypeAny, {
1988
+ options: {
1989
+ label: string;
1990
+ id: string;
1991
+ value: string;
1992
+ description?: string | undefined;
1993
+ icon?: string | undefined;
1994
+ color?: string | undefined;
1995
+ group?: "idle" | "in_progress" | "finished" | undefined;
1996
+ }[];
1997
+ defaultValue?: unknown;
1998
+ disabled?: boolean | undefined;
1999
+ placeholder?: string | undefined;
2000
+ description?: string | undefined;
2001
+ icon?: string | undefined;
2002
+ order?: number | undefined;
2003
+ hidden?: boolean | undefined;
2004
+ archived?: boolean | undefined;
2005
+ deprecated?: boolean | undefined;
2006
+ metadata?: Record<string, unknown> | undefined;
2007
+ }, {
2008
+ options: {
2009
+ label: string;
2010
+ id: string;
2011
+ value: string;
2012
+ description?: string | undefined;
2013
+ icon?: string | undefined;
2014
+ color?: string | undefined;
2015
+ group?: "idle" | "in_progress" | "finished" | undefined;
2016
+ }[];
2017
+ defaultValue?: unknown;
2018
+ disabled?: boolean | undefined;
2019
+ placeholder?: string | undefined;
2020
+ description?: string | undefined;
2021
+ icon?: string | undefined;
2022
+ order?: number | undefined;
2023
+ hidden?: boolean | undefined;
2024
+ archived?: boolean | undefined;
2025
+ deprecated?: boolean | undefined;
2026
+ metadata?: Record<string, unknown> | undefined;
2027
+ }>;
2028
+ /**
2029
+ * Multiselect attribute config schema
2030
+ */
2031
+ declare const multiselectConfigSchema: z.ZodObject<{
2032
+ disabled: z.ZodOptional<z.ZodBoolean>;
2033
+ placeholder: z.ZodOptional<z.ZodString>;
2034
+ description: z.ZodOptional<z.ZodString>;
2035
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2036
+ icon: z.ZodOptional<z.ZodString>;
2037
+ order: z.ZodOptional<z.ZodNumber>;
2038
+ hidden: z.ZodOptional<z.ZodBoolean>;
2039
+ archived: z.ZodOptional<z.ZodBoolean>;
2040
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2041
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2042
+ } & {
2043
+ options: z.ZodArray<z.ZodObject<{
2044
+ id: z.ZodString;
2045
+ label: z.ZodString;
2046
+ value: z.ZodString;
2047
+ color: z.ZodOptional<z.ZodString>;
2048
+ icon: z.ZodOptional<z.ZodString>;
2049
+ description: z.ZodOptional<z.ZodString>;
2050
+ group: z.ZodOptional<z.ZodEnum<["idle", "in_progress", "finished"]>>;
2051
+ }, "strip", z.ZodTypeAny, {
2052
+ label: string;
2053
+ id: string;
2054
+ value: string;
2055
+ description?: string | undefined;
2056
+ icon?: string | undefined;
2057
+ color?: string | undefined;
2058
+ group?: "idle" | "in_progress" | "finished" | undefined;
2059
+ }, {
2060
+ label: string;
2061
+ id: string;
2062
+ value: string;
2063
+ description?: string | undefined;
2064
+ icon?: string | undefined;
2065
+ color?: string | undefined;
2066
+ group?: "idle" | "in_progress" | "finished" | undefined;
2067
+ }>, "many">;
2068
+ }, "strip", z.ZodTypeAny, {
2069
+ options: {
2070
+ label: string;
2071
+ id: string;
2072
+ value: string;
2073
+ description?: string | undefined;
2074
+ icon?: string | undefined;
2075
+ color?: string | undefined;
2076
+ group?: "idle" | "in_progress" | "finished" | undefined;
2077
+ }[];
2078
+ defaultValue?: unknown;
2079
+ disabled?: boolean | undefined;
2080
+ placeholder?: string | undefined;
2081
+ description?: string | undefined;
2082
+ icon?: string | undefined;
2083
+ order?: number | undefined;
2084
+ hidden?: boolean | undefined;
2085
+ archived?: boolean | undefined;
2086
+ deprecated?: boolean | undefined;
2087
+ metadata?: Record<string, unknown> | undefined;
2088
+ }, {
2089
+ options: {
2090
+ label: string;
2091
+ id: string;
2092
+ value: string;
2093
+ description?: string | undefined;
2094
+ icon?: string | undefined;
2095
+ color?: string | undefined;
2096
+ group?: "idle" | "in_progress" | "finished" | undefined;
2097
+ }[];
2098
+ defaultValue?: unknown;
2099
+ disabled?: boolean | undefined;
2100
+ placeholder?: string | undefined;
2101
+ description?: string | undefined;
2102
+ icon?: string | undefined;
2103
+ order?: number | undefined;
2104
+ hidden?: boolean | undefined;
2105
+ archived?: boolean | undefined;
2106
+ deprecated?: boolean | undefined;
2107
+ metadata?: Record<string, unknown> | undefined;
2108
+ }>;
2109
+ /**
2110
+ * File attribute config schema
2111
+ */
2112
+ declare const fileConfigSchema: z.ZodObject<{
2113
+ disabled: z.ZodOptional<z.ZodBoolean>;
2114
+ placeholder: z.ZodOptional<z.ZodString>;
2115
+ description: z.ZodOptional<z.ZodString>;
2116
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2117
+ icon: z.ZodOptional<z.ZodString>;
2118
+ order: z.ZodOptional<z.ZodNumber>;
2119
+ hidden: z.ZodOptional<z.ZodBoolean>;
2120
+ archived: z.ZodOptional<z.ZodBoolean>;
2121
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2122
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2123
+ } & {
2124
+ maxFiles: z.ZodOptional<z.ZodNumber>;
2125
+ maxSize: z.ZodOptional<z.ZodNumber>;
2126
+ allowedTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2127
+ verification: z.ZodOptional<z.ZodObject<{
2128
+ enabled: z.ZodBoolean;
2129
+ documentTypes: z.ZodArray<z.ZodObject<{
2130
+ type: z.ZodEnum<["id_card", "passport", "incorporation_certificate", "driver_license", "birth_certificate", "residence_permit", "bank_statement", "proof_of_address", "custom"]>;
2131
+ label: z.ZodString;
2132
+ faces: z.ZodArray<z.ZodEnum<["front", "back", "single"]>, "many">;
2133
+ attributeMapping: z.ZodOptional<z.ZodArray<z.ZodObject<{
2134
+ attributeId: z.ZodString;
2135
+ extractedKey: z.ZodString;
2136
+ face: z.ZodOptional<z.ZodEnum<["front", "back", "single"]>>;
2137
+ required: z.ZodOptional<z.ZodBoolean>;
2138
+ }, "strip", z.ZodTypeAny, {
2139
+ attributeId: string;
2140
+ extractedKey: string;
2141
+ required?: boolean | undefined;
2142
+ face?: "front" | "back" | "single" | undefined;
2143
+ }, {
2144
+ attributeId: string;
2145
+ extractedKey: string;
2146
+ required?: boolean | undefined;
2147
+ face?: "front" | "back" | "single" | undefined;
2148
+ }>, "many">>;
2149
+ }, "strip", z.ZodTypeAny, {
2150
+ label: string;
2151
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2152
+ faces: ("front" | "back" | "single")[];
2153
+ attributeMapping?: {
2154
+ attributeId: string;
2155
+ extractedKey: string;
2156
+ required?: boolean | undefined;
2157
+ face?: "front" | "back" | "single" | undefined;
2158
+ }[] | undefined;
2159
+ }, {
2160
+ label: string;
2161
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2162
+ faces: ("front" | "back" | "single")[];
2163
+ attributeMapping?: {
2164
+ attributeId: string;
2165
+ extractedKey: string;
2166
+ required?: boolean | undefined;
2167
+ face?: "front" | "back" | "single" | undefined;
2168
+ }[] | undefined;
2169
+ }>, "many">;
2170
+ autoExtract: z.ZodOptional<z.ZodBoolean>;
2171
+ autoValidate: z.ZodOptional<z.ZodBoolean>;
2172
+ }, "strip", z.ZodTypeAny, {
2173
+ enabled: boolean;
2174
+ documentTypes: {
2175
+ label: string;
2176
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2177
+ faces: ("front" | "back" | "single")[];
2178
+ attributeMapping?: {
2179
+ attributeId: string;
2180
+ extractedKey: string;
2181
+ required?: boolean | undefined;
2182
+ face?: "front" | "back" | "single" | undefined;
2183
+ }[] | undefined;
2184
+ }[];
2185
+ autoExtract?: boolean | undefined;
2186
+ autoValidate?: boolean | undefined;
2187
+ }, {
2188
+ enabled: boolean;
2189
+ documentTypes: {
2190
+ label: string;
2191
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2192
+ faces: ("front" | "back" | "single")[];
2193
+ attributeMapping?: {
2194
+ attributeId: string;
2195
+ extractedKey: string;
2196
+ required?: boolean | undefined;
2197
+ face?: "front" | "back" | "single" | undefined;
2198
+ }[] | undefined;
2199
+ }[];
2200
+ autoExtract?: boolean | undefined;
2201
+ autoValidate?: boolean | undefined;
2202
+ }>>;
2203
+ }, "strip", z.ZodTypeAny, {
2204
+ defaultValue?: unknown;
2205
+ disabled?: boolean | undefined;
2206
+ placeholder?: string | undefined;
2207
+ description?: string | undefined;
2208
+ icon?: string | undefined;
2209
+ order?: number | undefined;
2210
+ hidden?: boolean | undefined;
2211
+ archived?: boolean | undefined;
2212
+ deprecated?: boolean | undefined;
2213
+ metadata?: Record<string, unknown> | undefined;
2214
+ maxFiles?: number | undefined;
2215
+ maxSize?: number | undefined;
2216
+ allowedTypes?: string[] | undefined;
2217
+ verification?: {
2218
+ enabled: boolean;
2219
+ documentTypes: {
2220
+ label: string;
2221
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2222
+ faces: ("front" | "back" | "single")[];
2223
+ attributeMapping?: {
2224
+ attributeId: string;
2225
+ extractedKey: string;
2226
+ required?: boolean | undefined;
2227
+ face?: "front" | "back" | "single" | undefined;
2228
+ }[] | undefined;
2229
+ }[];
2230
+ autoExtract?: boolean | undefined;
2231
+ autoValidate?: boolean | undefined;
2232
+ } | undefined;
2233
+ }, {
2234
+ defaultValue?: unknown;
2235
+ disabled?: boolean | undefined;
2236
+ placeholder?: string | undefined;
2237
+ description?: string | undefined;
2238
+ icon?: string | undefined;
2239
+ order?: number | undefined;
2240
+ hidden?: boolean | undefined;
2241
+ archived?: boolean | undefined;
2242
+ deprecated?: boolean | undefined;
2243
+ metadata?: Record<string, unknown> | undefined;
2244
+ maxFiles?: number | undefined;
2245
+ maxSize?: number | undefined;
2246
+ allowedTypes?: string[] | undefined;
2247
+ verification?: {
2248
+ enabled: boolean;
2249
+ documentTypes: {
2250
+ label: string;
2251
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2252
+ faces: ("front" | "back" | "single")[];
2253
+ attributeMapping?: {
2254
+ attributeId: string;
2255
+ extractedKey: string;
2256
+ required?: boolean | undefined;
2257
+ face?: "front" | "back" | "single" | undefined;
2258
+ }[] | undefined;
2259
+ }[];
2260
+ autoExtract?: boolean | undefined;
2261
+ autoValidate?: boolean | undefined;
2262
+ } | undefined;
2263
+ }>;
2264
+ /**
2265
+ * User attribute config schema
2266
+ */
2267
+ declare const userConfigSchema: z.ZodObject<{
2268
+ disabled: z.ZodOptional<z.ZodBoolean>;
2269
+ placeholder: z.ZodOptional<z.ZodString>;
2270
+ description: z.ZodOptional<z.ZodString>;
2271
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2272
+ icon: z.ZodOptional<z.ZodString>;
2273
+ order: z.ZodOptional<z.ZodNumber>;
2274
+ hidden: z.ZodOptional<z.ZodBoolean>;
2275
+ archived: z.ZodOptional<z.ZodBoolean>;
2276
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2277
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2278
+ } & {
2279
+ allowedRoles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2280
+ }, "strip", z.ZodTypeAny, {
2281
+ defaultValue?: unknown;
2282
+ disabled?: boolean | undefined;
2283
+ placeholder?: string | undefined;
2284
+ description?: string | undefined;
2285
+ icon?: string | undefined;
2286
+ order?: number | undefined;
2287
+ hidden?: boolean | undefined;
2288
+ archived?: boolean | undefined;
2289
+ deprecated?: boolean | undefined;
2290
+ metadata?: Record<string, unknown> | undefined;
2291
+ allowedRoles?: string[] | undefined;
2292
+ }, {
2293
+ defaultValue?: unknown;
2294
+ disabled?: boolean | undefined;
2295
+ placeholder?: string | undefined;
2296
+ description?: string | undefined;
2297
+ icon?: string | undefined;
2298
+ order?: number | undefined;
2299
+ hidden?: boolean | undefined;
2300
+ archived?: boolean | undefined;
2301
+ deprecated?: boolean | undefined;
2302
+ metadata?: Record<string, unknown> | undefined;
2303
+ allowedRoles?: string[] | undefined;
2304
+ }>;
2305
+ /**
2306
+ * Relation attribute config schema
2307
+ */
2308
+ declare const relationConfigSchema: z.ZodObject<{
2309
+ disabled: z.ZodOptional<z.ZodBoolean>;
2310
+ placeholder: z.ZodOptional<z.ZodString>;
2311
+ description: z.ZodOptional<z.ZodString>;
2312
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2313
+ icon: z.ZodOptional<z.ZodString>;
2314
+ order: z.ZodOptional<z.ZodNumber>;
2315
+ hidden: z.ZodOptional<z.ZodBoolean>;
2316
+ archived: z.ZodOptional<z.ZodBoolean>;
2317
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2318
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2319
+ } & {
2320
+ targets: z.ZodArray<z.ZodObject<{
2321
+ object: z.ZodString;
2322
+ displayTemplate: z.ZodOptional<z.ZodString>;
2323
+ filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2324
+ }, "strip", z.ZodTypeAny, {
2325
+ object: string;
2326
+ filter?: Record<string, unknown> | undefined;
2327
+ displayTemplate?: string | undefined;
2328
+ }, {
2329
+ object: string;
2330
+ filter?: Record<string, unknown> | undefined;
2331
+ displayTemplate?: string | undefined;
2332
+ }>, "many">;
2333
+ onDelete: z.ZodOptional<z.ZodEnum<["restrict", "cascade", "set_null"]>>;
2334
+ cardinality: z.ZodEnum<["one", "many"]>;
2335
+ minItems: z.ZodOptional<z.ZodNumber>;
2336
+ maxItems: z.ZodOptional<z.ZodNumber>;
2337
+ }, "strip", z.ZodTypeAny, {
2338
+ cardinality: "one" | "many";
2339
+ targets: {
2340
+ object: string;
2341
+ filter?: Record<string, unknown> | undefined;
2342
+ displayTemplate?: string | undefined;
2343
+ }[];
2344
+ defaultValue?: unknown;
2345
+ disabled?: boolean | undefined;
2346
+ placeholder?: string | undefined;
2347
+ description?: string | undefined;
2348
+ icon?: string | undefined;
2349
+ order?: number | undefined;
2350
+ hidden?: boolean | undefined;
2351
+ archived?: boolean | undefined;
2352
+ deprecated?: boolean | undefined;
2353
+ metadata?: Record<string, unknown> | undefined;
2354
+ onDelete?: "restrict" | "cascade" | "set_null" | undefined;
2355
+ minItems?: number | undefined;
2356
+ maxItems?: number | undefined;
2357
+ }, {
2358
+ cardinality: "one" | "many";
2359
+ targets: {
2360
+ object: string;
2361
+ filter?: Record<string, unknown> | undefined;
2362
+ displayTemplate?: string | undefined;
2363
+ }[];
2364
+ defaultValue?: unknown;
2365
+ disabled?: boolean | undefined;
2366
+ placeholder?: string | undefined;
2367
+ description?: string | undefined;
2368
+ icon?: string | undefined;
2369
+ order?: number | undefined;
2370
+ hidden?: boolean | undefined;
2371
+ archived?: boolean | undefined;
2372
+ deprecated?: boolean | undefined;
2373
+ metadata?: Record<string, unknown> | undefined;
2374
+ onDelete?: "restrict" | "cascade" | "set_null" | undefined;
2375
+ minItems?: number | undefined;
2376
+ maxItems?: number | undefined;
2377
+ }>;
2378
+ /**
2379
+ * Rating attribute config schema
2380
+ */
2381
+ declare const ratingConfigSchema: z.ZodObject<{
2382
+ disabled: z.ZodOptional<z.ZodBoolean>;
2383
+ placeholder: z.ZodOptional<z.ZodString>;
2384
+ description: z.ZodOptional<z.ZodString>;
2385
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2386
+ icon: z.ZodOptional<z.ZodString>;
2387
+ order: z.ZodOptional<z.ZodNumber>;
2388
+ hidden: z.ZodOptional<z.ZodBoolean>;
2389
+ archived: z.ZodOptional<z.ZodBoolean>;
2390
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2391
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2392
+ } & {
2393
+ max: z.ZodOptional<z.ZodNumber>;
2394
+ iconType: z.ZodOptional<z.ZodEnum<["star", "heart", "thumbs", "number"]>>;
2395
+ }, "strip", z.ZodTypeAny, {
2396
+ defaultValue?: unknown;
2397
+ disabled?: boolean | undefined;
2398
+ placeholder?: string | undefined;
2399
+ description?: string | undefined;
2400
+ icon?: string | undefined;
2401
+ order?: number | undefined;
2402
+ hidden?: boolean | undefined;
2403
+ archived?: boolean | undefined;
2404
+ deprecated?: boolean | undefined;
2405
+ metadata?: Record<string, unknown> | undefined;
2406
+ max?: number | undefined;
2407
+ iconType?: "number" | "heart" | "star" | "thumbs" | undefined;
2408
+ }, {
2409
+ defaultValue?: unknown;
2410
+ disabled?: boolean | undefined;
2411
+ placeholder?: string | undefined;
2412
+ description?: string | undefined;
2413
+ icon?: string | undefined;
2414
+ order?: number | undefined;
2415
+ hidden?: boolean | undefined;
2416
+ archived?: boolean | undefined;
2417
+ deprecated?: boolean | undefined;
2418
+ metadata?: Record<string, unknown> | undefined;
2419
+ max?: number | undefined;
2420
+ iconType?: "number" | "heart" | "star" | "thumbs" | undefined;
2421
+ }>;
2422
+ /**
2423
+ * Map of attribute type to config schema
2424
+ */
2425
+ declare const attributeConfigSchemas: Record<AttributeType, z.ZodObject<z.ZodRawShape>>;
2426
+ /**
2427
+ * Get the config schema for a specific attribute type
2428
+ */
2429
+ declare function getAttributeConfigSchema(type: AttributeType): z.ZodObject<z.ZodRawShape>;
2430
+ /**
2431
+ * Validate attribute config for a specific type
2432
+ * Returns the validated config with only allowed properties
2433
+ */
2434
+ declare function validateAttributeConfig(type: AttributeType, config: Record<string, unknown>): {
2435
+ success: true;
2436
+ data: Record<string, unknown>;
2437
+ } | {
2438
+ success: false;
2439
+ errors: string[];
2440
+ };
2441
+ /**
2442
+ * Validate and strip unknown properties from attribute config
2443
+ * This ensures only allowed properties are stored in the database
2444
+ */
2445
+ declare function parseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown>;
2446
+ /**
2447
+ * Safely parse attribute config, returning undefined for invalid configs
2448
+ */
2449
+ declare function safeParseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown> | undefined;
2450
+ /**
2451
+ * Create a Zod schema for a text attribute
2452
+ */
2453
+ declare function createTextValidator(attr: TextAttribute): z.ZodString;
2454
+ /**
2455
+ * Create a Zod schema for a number attribute
2456
+ */
2457
+ declare function createNumberValidator(attr: NumberAttribute): z.ZodNumber;
2458
+ /**
2459
+ * Create a Zod schema for a checkbox attribute
2460
+ */
2461
+ declare function createCheckboxValidator(_attr: CheckboxAttribute): z.ZodBoolean;
2462
+ /**
2463
+ * Create a Zod schema for a date attribute
2464
+ */
2465
+ declare function createDateValidator(attr: DateAttribute): z.ZodString;
2466
+ /**
2467
+ * Create a Zod schema for a phone attribute
2468
+ */
2469
+ declare function createPhoneValidator(_attr: PhoneAttribute): z.ZodType<{
2470
+ countryCode: string;
2471
+ phoneNumber: string;
2472
+ }>;
2473
+ /**
2474
+ * Create a Zod schema for a currency attribute
2475
+ */
2476
+ declare function createCurrencyValidator(_attr: CurrencyAttribute): z.ZodType<{
2477
+ code: string;
2478
+ value: number;
2479
+ }>;
2480
+ /**
2481
+ * Create a Zod schema for a status attribute
2482
+ */
2483
+ declare function createStatusValidator(attr: StatusAttribute): z.ZodEnum<[string, ...string[]]>;
2484
+ /**
2485
+ * Create a Zod schema for a select attribute
2486
+ */
2487
+ declare function createSelectValidator(attr: SelectAttribute): z.ZodEnum<[string, ...string[]]>;
2488
+ /**
2489
+ * Create a Zod schema for a multiselect attribute
2490
+ */
2491
+ declare function createMultiselectValidator(attr: MultiselectAttribute): z.ZodArray<z.ZodEnum<[string, ...string[]]>>;
2492
+ /**
2493
+ * Create a Zod schema for a location attribute
2494
+ */
2495
+ type LocationShape = {
2496
+ address?: string;
2497
+ address2?: string;
2498
+ city?: string;
2499
+ state?: string;
2500
+ postalCode?: string;
2501
+ country?: string;
2502
+ latitude?: number;
2503
+ longitude?: number;
2504
+ };
2505
+ declare function createLocationValidator(_attr: LocationAttribute): z.ZodType<LocationShape>;
2506
+ /**
2507
+ * Create a Zod schema for a timestamp attribute
2508
+ */
2509
+ declare function createTimestampValidator(_attr: TimestampAttribute): z.ZodNumber;
2510
+ /**
2511
+ * Create a Zod schema for a file attribute
2512
+ */
2513
+ declare function createFileValidator(_attr: FileAttribute): z.ZodString;
2514
+ /**
2515
+ * Create a Zod schema for a user attribute
2516
+ */
2517
+ declare function createUserValidator(_attr: UserAttribute): z.ZodString;
2518
+ /**
2519
+ * Create a Zod schema for a single relation attribute (cardinality: "one")
2520
+ */
2521
+ declare function createSingleRelationValidator(attr: SingleRelationAttribute): z.ZodUnion<[z.ZodString, z.ZodNull]>;
2522
+ /**
2523
+ * Create a Zod schema for a multi relation attribute (cardinality: "many")
2524
+ */
2525
+ declare function createMultiRelationValidator(attr: MultiRelationAttribute): z.ZodArray<z.ZodString>;
2526
+ /**
2527
+ * Create a Zod schema for a relation attribute
2528
+ * Dispatches to single or multi validator based on cardinality
2529
+ */
2530
+ declare function createRelationValidator(attr: RelationAttribute): z.ZodUnion<[z.ZodString, z.ZodNull]> | z.ZodArray<z.ZodString>;
2531
+ /**
2532
+ * Create a Zod schema for a rating attribute
2533
+ */
2534
+ declare function createRatingValidator(attr: RatingAttribute): z.ZodNumber;
2535
+ /**
2536
+ * Create a Zod schema for any attribute type
2537
+ */
2538
+ declare function createAttributeValidator(attr: Attribute): z.ZodTypeAny;
2539
+ /**
2540
+ * Create a Zod schema for an entire object
2541
+ */
2542
+ declare function createObjectValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
2543
+ /**
2544
+ * Validation result
2545
+ */
2546
+ interface ValidationResult {
2547
+ success: boolean;
2548
+ data?: Record<string, unknown>;
2549
+ errors?: Array<{
2550
+ path: string[];
2551
+ message: string;
2552
+ }>;
2553
+ }
2554
+ /**
2555
+ * Validate data against an attribute schema
2556
+ */
2557
+ declare function validateAttribute(attr: Attribute, value: unknown): ValidationResult;
2558
+ /**
2559
+ * Validate data against an object schema
2560
+ */
2561
+ declare function validateObject(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
2562
+ /**
2563
+ * Validate and throw if invalid
2564
+ */
2565
+ declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
2566
+ /**
2567
+ * Create a Zod schema for draft validation.
2568
+ * All attributes become optional, but provided values are still validated.
2569
+ */
2570
+ declare function createDraftValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
2571
+ /**
2572
+ * Validate data in draft mode.
2573
+ * - All attributes are treated as optional (no required validation)
2574
+ * - Provided values are still validated for format/type correctness
2575
+ *
2576
+ * Use this when creating records that may be incomplete (drafts).
2577
+ *
2578
+ * @example
2579
+ * ```typescript
2580
+ * const result = validateDraft(PRODUCT, { name: "Draft" });
2581
+ * // → success even if "price" is required but missing
2582
+ *
2583
+ * const result2 = validateDraft(PRODUCT, { price: -10 });
2584
+ * // → fails because price must be >= 0 (format validation still applies)
2585
+ * ```
2586
+ */
2587
+ declare function validateDraft(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
2588
+ /**
2589
+ * Validate draft data and throw if format validation fails.
2590
+ */
2591
+ declare function validateDraftOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
2592
+ /**
2593
+ * Get the list of required attributes that are missing values.
2594
+ *
2595
+ * @example
2596
+ * ```typescript
2597
+ * const missing = getMissingRequiredAttributes(PRODUCT, { name: "Test" });
2598
+ * // → [priceAttribute, statusAttribute] if price and status are required but missing
2599
+ * ```
2600
+ */
2601
+ declare function getMissingRequiredAttributes(objectDef: ObjectDefinition, data: Record<string, unknown>): Attribute[];
2602
+ /**
2603
+ * Check if a record is complete (all required attributes have valid values).
2604
+ *
2605
+ * @returns `true` if all required values are present and valid, `false` otherwise
2606
+ */
2607
+ declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<string, unknown>): boolean;
2608
+ /**
2609
+ * Compute the completion status of a record based on its data.
2610
+ *
2611
+ * - `"complete"`: All required values are present and valid
2612
+ * - `"draft"`: One or more required values are missing or invalid
2613
+ *
2614
+ * This function is used to dynamically determine the status when
2615
+ * creating or updating records.
2616
+ *
2617
+ * @example
2618
+ * ```typescript
2619
+ * const status = computeRecordStatus(PRODUCT, {
2620
+ * name: "Nike Air Max",
2621
+ * price: 129.99,
2622
+ * status: "active"
2623
+ * });
2624
+ * // → "complete"
2625
+ *
2626
+ * const status2 = computeRecordStatus(PRODUCT, { name: "Draft Product" });
2627
+ * // → "draft" (missing required fields)
2628
+ * ```
2629
+ */
2630
+ declare function computeRecordStatus(objectDef: ObjectDefinition, data: Record<string, unknown>): CompletionStatus;
2631
+
2632
+ /**
2633
+ * Object as stored in database (metadata)
2634
+ */
2635
+ interface DBObject extends Timestamps {
2636
+ id: Uuid;
2637
+ tenantId: TenantId;
2638
+ name: string;
2639
+ label: string;
2640
+ pluralLabel?: string;
2641
+ description?: string;
2642
+ icon?: IconName;
2643
+ labelExpression: string;
2644
+ system: boolean;
2645
+ metadata?: Record<string, unknown>;
2646
+ }
2647
+ interface CreateDBObject {
2648
+ tenantId: TenantId;
2649
+ name: string;
2650
+ label: string;
2651
+ pluralLabel?: string;
2652
+ description?: string;
2653
+ icon?: IconName;
2654
+ labelExpression: string;
2655
+ system?: boolean;
2656
+ metadata?: Record<string, unknown>;
2657
+ }
2658
+ interface UpdateDBObject {
2659
+ label?: string;
2660
+ pluralLabel?: string;
2661
+ description?: string;
2662
+ icon?: IconName;
2663
+ labelExpression?: string;
2664
+ metadata?: Record<string, unknown>;
2665
+ }
2666
+ interface UpsertDBObject extends CreateDBObject {
2667
+ system: boolean;
2668
+ }
2669
+ /**
2670
+ * Attribute as stored in database (metadata)
2671
+ */
2672
+ interface DBAttribute extends Timestamps {
2673
+ id: Uuid;
2674
+ objectId: Uuid;
2675
+ name: string;
2676
+ label: string;
2677
+ type: AttributeType;
2678
+ description?: string;
2679
+ icon?: IconName;
2680
+ system: boolean;
2681
+ required: boolean;
2682
+ unique: boolean;
2683
+ order: number;
2684
+ hidden?: boolean;
2685
+ archived?: boolean;
2686
+ deprecated?: boolean;
2687
+ defaultValue?: unknown;
2688
+ config: Record<string, unknown>;
2689
+ }
2690
+ interface CreateDBAttribute {
2691
+ objectId: Uuid;
2692
+ name: string;
2693
+ label: string;
2694
+ type: AttributeType;
2695
+ description?: string;
2696
+ icon?: IconName;
2697
+ system?: boolean;
2698
+ required?: boolean;
2699
+ unique?: boolean;
2700
+ order?: number;
2701
+ hidden?: boolean;
2702
+ archived?: boolean;
2703
+ deprecated?: boolean;
2704
+ defaultValue?: unknown;
2705
+ config?: Record<string, unknown>;
2706
+ }
2707
+ interface UpdateDBAttribute {
2708
+ label?: string;
2709
+ type?: AttributeType;
2710
+ description?: string;
2711
+ icon?: IconName;
2712
+ required?: boolean;
2713
+ order?: number;
2714
+ hidden?: boolean;
2715
+ archived?: boolean;
2716
+ deprecated?: boolean;
2717
+ defaultValue?: unknown;
2718
+ config?: Record<string, unknown>;
2719
+ }
2720
+ interface UpsertDBAttribute extends CreateDBAttribute {
2721
+ objectId: Uuid;
2722
+ name: string;
2723
+ }
2724
+
2725
+ /**
2726
+ * Object record creation data
2727
+ */
2728
+ interface CreateObjectRecord {
2729
+ tenantId: TenantId;
2730
+ objectId: Uuid;
2731
+ data: Record<string, unknown>;
2732
+ /**
2733
+ * Computed display label from labelExpression.
2734
+ * Stored for performance - avoids recomputation on every read.
2735
+ */
2736
+ label: string;
2737
+ /**
2738
+ * Completion status of the record.
2739
+ * - `draft`: Record is incomplete (missing required values)
2740
+ * - `complete`: All required values are present and valid
2741
+ */
2742
+ completionStatus: "draft" | "complete";
2743
+ }
2744
+ /**
2745
+ * Generic list options for pagination and sorting
2746
+ */
2747
+ interface ListOptions {
2748
+ limit?: number;
2749
+ offset?: number;
2750
+ /** @deprecated Use sorts instead */
2751
+ orderBy?: string;
2752
+ /** @deprecated Use sorts instead */
2753
+ orderDirection?: "asc" | "desc";
2754
+ /** Multiple sort rules */
2755
+ sorts?: SortRule[];
2756
+ /** Filter state */
2757
+ filters?: FilterState;
2758
+ }
2759
+ /**
2760
+ * Search options for full-text search
2761
+ */
2762
+ interface SearchOptions extends ListOptions {
2763
+ highlight?: boolean;
2764
+ }
2765
+ /**
2766
+ * Global search options
2767
+ */
2768
+ interface GlobalSearchOptions extends ListOptions {
2769
+ /**
2770
+ * Limit results to specific object names
2771
+ */
2772
+ objectNames?: string[];
2773
+ /**
2774
+ * Whether to include object metadata in results
2775
+ */
2776
+ includeObjectInfo?: boolean;
2777
+ }
2778
+ /**
2779
+ * Global search result item
2780
+ */
2781
+ interface GlobalSearchResultItem {
2782
+ objectId: string;
2783
+ objectName: string;
2784
+ objectLabel: string;
2785
+ /** Computed label from labelExpression */
2786
+ label: string;
2787
+ recordId: string;
2788
+ values: Record<string, unknown>;
2789
+ completionStatus: "draft" | "complete";
2790
+ createdAt: Date;
2791
+ updatedAt: Date;
2792
+ }
2793
+ /**
2794
+ * File-specific list options
2795
+ */
2796
+ interface FileListOptions extends ListOptions {
2797
+ folderPath?: string;
2798
+ mimeType?: string;
2799
+ uploadedBy?: Uuid;
2800
+ includeDeleted?: boolean;
2801
+ }
2802
+ /**
2803
+ * View as stored in database
2804
+ */
2805
+ interface DBView extends Timestamps {
2806
+ id: Uuid;
2807
+ tenantId: TenantId;
2808
+ objectId?: Uuid;
2809
+ objectName: string;
2810
+ name: string;
2811
+ label: string;
2812
+ description?: string;
2813
+ icon?: IconName;
2814
+ tabs: Tab[];
2815
+ default: boolean;
2816
+ system: boolean;
2817
+ metadata?: Record<string, unknown>;
2818
+ }
2819
+ interface CreateDBView {
2820
+ tenantId: TenantId;
2821
+ objectId?: Uuid;
2822
+ objectName: string;
2823
+ name: string;
2824
+ label: string;
2825
+ description?: string;
2826
+ icon?: IconName;
2827
+ tabs: Tab[];
2828
+ default?: boolean;
2829
+ system?: boolean;
2830
+ metadata?: Record<string, unknown>;
2831
+ }
2832
+ interface UpdateDBView {
2833
+ label?: string;
2834
+ description?: string;
2835
+ icon?: IconName;
2836
+ tabs?: Tab[];
2837
+ default?: boolean;
2838
+ metadata?: Record<string, unknown>;
2839
+ }
2840
+ interface UpsertDBView {
2841
+ tenantId: TenantId;
2842
+ objectName: string;
2843
+ name: string;
2844
+ label: string;
2845
+ description?: string;
2846
+ icon?: IconName;
2847
+ tabs: Tab[];
2848
+ default?: boolean;
2849
+ system?: boolean;
2850
+ metadata?: Record<string, unknown>;
2851
+ }
2852
+ /**
2853
+ * Result of an operation
2854
+ */
2855
+ interface OperationResult<T = unknown> {
2856
+ success: boolean;
2857
+ data?: T;
2858
+ error?: {
2859
+ code: string;
2860
+ message: string;
2861
+ details?: Record<string, unknown>;
2862
+ };
2863
+ }
2864
+
2865
+ /**
2866
+ * Repository for objects table (metadata)
2867
+ */
2868
+ interface ObjectsRepository {
2869
+ /**
2870
+ * Find object by ID
2871
+ */
2872
+ findById(id: Uuid): Promise<DBObject | null>;
2873
+ /**
2874
+ * Find object by name and tenant
2875
+ */
2876
+ findByName(tenantId: TenantId, name: string): Promise<DBObject | null>;
2877
+ /**
2878
+ * Find system/native object by name (system=true, for sync)
2879
+ */
2880
+ findSystemByName(name: string): Promise<DBObject | null>;
2881
+ /**
2882
+ * Create object
2883
+ */
2884
+ create(data: CreateDBObject): Promise<DBObject>;
2885
+ /**
2886
+ * Update object
2887
+ */
2888
+ update(id: Uuid, data: Partial<UpdateDBObject>): Promise<DBObject>;
2889
+ /**
2890
+ * Delete object
2891
+ */
2892
+ delete(id: Uuid): Promise<void>;
2893
+ /**
2894
+ * List all objects for a tenant
2895
+ */
2896
+ list(tenantId: TenantId): Promise<DBObject[]>;
2897
+ /**
2898
+ * Upsert object (create or update based on nativeObjectId)
2899
+ */
2900
+ upsert(data: UpsertDBObject): Promise<DBObject>;
2901
+ }
2902
+ /**
2903
+ * Repository for attributes table (metadata)
2904
+ */
2905
+ interface AttributesRepository {
2906
+ /**
2907
+ * Find attribute by ID
2908
+ */
2909
+ findById(id: Uuid): Promise<DBAttribute | null>;
2910
+ /**
2911
+ * Find attributes by object ID
2912
+ */
2913
+ findByObjectId(objectId: Uuid): Promise<DBAttribute[]>;
2914
+ /**
2915
+ * Create attribute
2916
+ */
2917
+ create(data: CreateDBAttribute): Promise<DBAttribute>;
2918
+ /**
2919
+ * Update attribute
2920
+ */
2921
+ update(id: Uuid, data: Partial<UpdateDBAttribute>): Promise<DBAttribute>;
2922
+ /**
2923
+ * Delete attribute
2924
+ */
2925
+ delete(id: Uuid): Promise<void>;
2926
+ /**
2927
+ * Delete multiple attributes by names (for sync cleanup)
2928
+ */
2929
+ deleteByNames(objectId: Uuid, excludeNames: string[]): Promise<number>;
2930
+ /**
2931
+ * Upsert attribute (create or update based on objectId + name)
2932
+ */
2933
+ upsert(data: UpsertDBAttribute): Promise<DBAttribute>;
2934
+ }
2935
+ /**
2936
+ * Repository for user_profiles table
2937
+ */
2938
+ interface UserProfilesRepository {
2939
+ /**
2940
+ * Find user profile by ID
2941
+ */
2942
+ findById(id: Uuid): Promise<UserProfile | null>;
2943
+ /**
2944
+ * Find user profile by auth ID (external auth provider)
2945
+ */
2946
+ findByAuthId(authId: string): Promise<UserProfile | null>;
2947
+ /**
2948
+ * Find user profile by email
2949
+ */
2950
+ findByEmail(tenantId: TenantId, email: string): Promise<UserProfile | null>;
2951
+ /**
2952
+ * Create user profile
2953
+ */
2954
+ create(data: CreateUserProfile): Promise<UserProfile>;
2955
+ /**
2956
+ * Update user profile
2957
+ */
2958
+ update(id: Uuid, data: UpdateUserProfile): Promise<UserProfile>;
2959
+ /**
2960
+ * Delete user profile
2961
+ */
2962
+ delete(id: Uuid): Promise<void>;
2963
+ /**
2964
+ * List all user profiles for a tenant
2965
+ */
2966
+ list(tenantId: TenantId, options?: ListOptions): Promise<UserProfile[]>;
2967
+ /**
2968
+ * Count user profiles by role within a tenant.
2969
+ * Useful for checking if last admin before deletion.
2970
+ */
2971
+ countByRole(tenantId: TenantId, role: string): Promise<number>;
2972
+ /**
2973
+ * Update last login timestamp
2974
+ */
2975
+ updateLastLogin(id: Uuid): Promise<void>;
2976
+ }
2977
+ /**
2978
+ * Repository for files table
2979
+ */
2980
+ interface FilesRepository {
2981
+ /**
2982
+ * Find file by ID
2983
+ */
2984
+ findById(id: Uuid): Promise<File | null>;
2985
+ /**
2986
+ * Create file
2987
+ */
2988
+ create(data: CreateFile): Promise<File>;
2989
+ /**
2990
+ * Update file
2991
+ */
2992
+ update(id: Uuid, data: UpdateFile): Promise<File>;
2993
+ /**
2994
+ * Delete file (soft delete)
2995
+ */
2996
+ delete(id: Uuid): Promise<void>;
2997
+ /**
2998
+ * Hard delete file (permanent)
2999
+ */
3000
+ hardDelete(id: Uuid): Promise<void>;
3001
+ /**
3002
+ * List files for a tenant
3003
+ */
3004
+ list(tenantId: TenantId, options?: FileListOptions): Promise<File[]>;
3005
+ /**
3006
+ * Find files by folder path
3007
+ */
3008
+ findByFolder(tenantId: TenantId, folderPath: string): Promise<File[]>;
3009
+ /**
3010
+ * Find files by uploader
3011
+ */
3012
+ findByUploader(uploadedBy: Uuid): Promise<File[]>;
3013
+ }
3014
+ /**
3015
+ * Repository for object_records table (unified JSONB)
3016
+ */
3017
+ interface ObjectRecordsRepository {
3018
+ /**
3019
+ * Find record by ID
3020
+ */
3021
+ findById(id: Uuid): Promise<ObjectRecord | null>;
3022
+ /**
3023
+ * Find multiple records by IDs (batch fetch)
3024
+ * Returns records in no particular order. Missing IDs are simply not included.
3025
+ */
3026
+ findByIds(ids: Uuid[]): Promise<ObjectRecord[]>;
3027
+ /**
3028
+ * Create record
3029
+ */
3030
+ create(data: CreateObjectRecord): Promise<ObjectRecord>;
3031
+ /**
3032
+ * Update record
3033
+ */
3034
+ update(id: Uuid, data: Partial<Record<string, unknown>>): Promise<ObjectRecord>;
3035
+ /**
3036
+ * Delete record
3037
+ */
3038
+ delete(id: Uuid): Promise<void>;
3039
+ /**
3040
+ * List records for an object
3041
+ */
3042
+ list(tenantId: TenantId, objectId: Uuid, options?: ListOptions): Promise<{
3043
+ records: ObjectRecord[];
3044
+ total: number;
3045
+ }>;
3046
+ /**
3047
+ * Search records using PostgreSQL full-text search
3048
+ */
3049
+ search(tenantId: TenantId, objectId: Uuid, query: string, options?: SearchOptions): Promise<{
3050
+ records: ObjectRecord[];
3051
+ total: number;
3052
+ }>;
3053
+ /**
3054
+ * Global search across all object records for a tenant
3055
+ * Searches in all objects or a subset specified by objectNames
3056
+ */
3057
+ globalSearch(tenantId: TenantId, query: string, options?: GlobalSearchOptions): Promise<{
3058
+ results: GlobalSearchResultItem[];
3059
+ total: number;
3060
+ }>;
3061
+ }
3062
+ /**
3063
+ * Repository for views table
3064
+ */
3065
+ interface ViewsRepository {
3066
+ /**
3067
+ * Find view by ID
3068
+ */
3069
+ findById(id: Uuid): Promise<DBView | null>;
3070
+ /**
3071
+ * Find view by name for an object and tenant
3072
+ */
3073
+ findByName(tenantId: TenantId, objectName: string, viewName: string): Promise<DBView | null>;
3074
+ /**
3075
+ * Find all views for an object and tenant
3076
+ */
3077
+ findByObjectName(tenantId: TenantId, objectName: string): Promise<DBView[]>;
3078
+ /**
3079
+ * Find all views for a tenant
3080
+ */
3081
+ findAllForTenant(tenantId: TenantId): Promise<DBView[]>;
3082
+ /**
3083
+ * Find system view by name (for sync)
3084
+ */
3085
+ findSystemByName(objectName: string, viewName: string): Promise<DBView | null>;
3086
+ /**
3087
+ * Find all system views for an object
3088
+ */
3089
+ findSystemByObjectName(objectName: string): Promise<DBView[]>;
3090
+ /**
3091
+ * Create view
3092
+ */
3093
+ create(data: CreateDBView): Promise<DBView>;
3094
+ /**
3095
+ * Update view
3096
+ */
3097
+ update(id: Uuid, data: Partial<UpdateDBView>): Promise<DBView>;
3098
+ /**
3099
+ * Delete view
3100
+ */
3101
+ delete(id: Uuid): Promise<void>;
3102
+ /**
3103
+ * Delete views not in the list (for sync cleanup)
3104
+ * @returns Number of deleted views
3105
+ */
3106
+ deleteNotIn(objectName: string, keepViewNames: string[]): Promise<number>;
3107
+ /**
3108
+ * Upsert view (create or update based on objectName + name)
3109
+ */
3110
+ upsert(data: UpsertDBView): Promise<DBView>;
3111
+ }
3112
+ /**
3113
+ * Repository for roles, permissions, and user role assignments.
3114
+ *
3115
+ * This repository is optional - if not provided in the DatabaseAdapter,
3116
+ * permission checks are disabled (backward compatible behavior).
3117
+ */
3118
+ interface PermissionsRepository {
3119
+ /**
3120
+ * Get all roles for a tenant
3121
+ */
3122
+ getRolesByTenant(tenantId: TenantId): Promise<Role[]>;
3123
+ /**
3124
+ * Get a role by ID
3125
+ */
3126
+ getRoleById(roleId: Uuid): Promise<Role | null>;
3127
+ /**
3128
+ * Get a role by name for a tenant
3129
+ */
3130
+ getRoleByName(tenantId: TenantId, name: string): Promise<Role | null>;
3131
+ /**
3132
+ * Create a new role
3133
+ */
3134
+ createRole(input: CreateRoleInput): Promise<Role>;
3135
+ /**
3136
+ * Update an existing role
3137
+ */
3138
+ updateRole(roleId: Uuid, updates: UpdateRoleInput): Promise<Role>;
3139
+ /**
3140
+ * Delete a role (fails if role is system role)
3141
+ */
3142
+ deleteRole(roleId: Uuid): Promise<void>;
3143
+ /**
3144
+ * Get all permissions for a role
3145
+ */
3146
+ getPermissionsByRole(roleId: Uuid): Promise<Permission[]>;
3147
+ /**
3148
+ * Set permissions for a role (replaces existing permissions)
3149
+ */
3150
+ setPermissions(roleId: Uuid, permissions: CreatePermissionInput[]): Promise<void>;
3151
+ /**
3152
+ * Get all roles assigned to a user profile within a tenant
3153
+ */
3154
+ getUserRoles(userProfileId: Uuid, tenantId: TenantId): Promise<Role[]>;
3155
+ /**
3156
+ * Assign a role to a user profile
3157
+ */
3158
+ assignRole(input: AssignRoleInput): Promise<UserRoleAssignment>;
3159
+ /**
3160
+ * Revoke a role from a user profile
3161
+ */
3162
+ revokeRole(userProfileId: Uuid, roleId: Uuid, tenantId: TenantId): Promise<void>;
3163
+ /**
3164
+ * Get effective permissions for a user profile (merged from all assigned roles)
3165
+ *
3166
+ * This method should:
3167
+ * 1. Get all roles assigned to the user profile
3168
+ * 2. Get all permissions for those roles
3169
+ * 3. Merge permissions (union of actions per object)
3170
+ * 4. Determine if user has admin privileges
3171
+ */
3172
+ getEffectivePermissions(userProfileId: Uuid, tenantId: TenantId): Promise<EffectivePermissions>;
3173
+ }
3174
+
3175
+ /**
3176
+ * Generic database adapter interface
3177
+ * Any ORM (Drizzle, Prisma, Kysely, TypeORM) can implement this interface
3178
+ * to work with @stndrds/schema runtime services
3179
+ *
3180
+ * @example
3181
+ * ```typescript
3182
+ * // Drizzle implementation
3183
+ * import { createDrizzleAdapter } from "./adapters/drizzle";
3184
+ * import { db } from "./db";
3185
+ *
3186
+ * const adapter = createDrizzleAdapter(db);
3187
+ *
3188
+ * // Prisma implementation
3189
+ * import { createPrismaAdapter } from "./adapters/prisma";
3190
+ * import { prisma } from "./db";
3191
+ *
3192
+ * const adapter = createPrismaAdapter(prisma);
3193
+ * ```
3194
+ */
3195
+ interface DatabaseAdapter {
3196
+ objects: ObjectsRepository;
3197
+ attributes: AttributesRepository;
3198
+ views: ViewsRepository;
3199
+ userProfiles: UserProfilesRepository;
3200
+ files: FilesRepository;
3201
+ objectRecords: ObjectRecordsRepository;
3202
+ permissions?: PermissionsRepository;
3203
+ transaction<T>(callback: (adapter: DatabaseAdapter) => Promise<T>): Promise<T>;
3204
+ }
3205
+
3206
+ /**
3207
+ * Types of hooks supported by the system
3208
+ */
3209
+ type HookType = "beforeCreate" | "afterCreate" | "beforeUpdate" | "afterUpdate" | "beforeDelete" | "afterDelete";
3210
+ /**
3211
+ * Change information for a specific attribute
3212
+ */
3213
+ interface AttributeChange<T = unknown> {
3214
+ oldValue: T | undefined;
3215
+ newValue: T | undefined;
3216
+ changed: boolean;
3217
+ }
3218
+ /**
3219
+ * Context passed to hooks - abstract, no framework dependencies
3220
+ *
3221
+ * This interface is designed to be extended by framework-specific implementations
3222
+ * (e.g., TriggerContext in schema-nestjs adds NestJS services)
3223
+ */
3224
+ interface HookContext<T = unknown> {
3225
+ objectId: string;
3226
+ objectName: string;
3227
+ recordId: string;
3228
+ tenantId: string;
3229
+ record: ObjectRecord;
3230
+ oldValues: Record<string, unknown>;
3231
+ newValues: Record<string, unknown>;
3232
+ changedAttributes: string[];
3233
+ /**
3234
+ * Get change information for a specific attribute
3235
+ * @param attributeName - The name of the attribute to check
3236
+ * @returns Change information including old value, new value, and whether it changed
3237
+ */
3238
+ getChange<V = T>(attributeName: string): AttributeChange<V>;
3239
+ metadata: Record<string, unknown>;
3240
+ timestamp: Date;
3241
+ }
3242
+ /**
3243
+ * Generic hook handler function
3244
+ */
3245
+ type HookHandler = (ctx: HookContext) => Promise<void> | void;
3246
+ /**
3247
+ * Definition of a hook for registration
3248
+ */
3249
+ interface HookDefinition {
3250
+ type: HookType;
3251
+ objectName: string;
3252
+ /** Attribute name to watch, or '*' for all attributes */
3253
+ attributeName?: string | "*";
3254
+ /** Execution priority (lower = earlier), default 0 */
3255
+ priority?: number;
3256
+ handler: HookHandler;
3257
+ }
3258
+
3259
+ /**
3260
+ * Abstract interface for hook registry
3261
+ *
3262
+ * This interface is implemented by TriggerRegistry in schema-nestjs
3263
+ * to provide NestJS-specific functionality like dependency injection
3264
+ * and automatic discovery of trigger classes.
3265
+ */
3266
+ interface HookRegistry {
3267
+ /**
3268
+ * Execute all hooks of a given type for an object
3269
+ *
3270
+ * @param type - The type of hook to execute (beforeUpdate, afterUpdate, etc.)
3271
+ * @param objectName - The name of the object being modified
3272
+ * @param ctx - The hook context containing record data and changes
3273
+ */
3274
+ execute(type: HookType, objectName: string, ctx: HookContext): Promise<void>;
3275
+ /**
3276
+ * Register a hook manually (optional)
3277
+ * Not all implementations need to support this (e.g., decorator-based discovery)
3278
+ */
3279
+ register?(hook: HookDefinition): void;
3280
+ }
3281
+ /**
3282
+ * No-op implementation of HookRegistry
3283
+ *
3284
+ * Used as default when no registry is provided to RecordService.
3285
+ * This allows the schema package to work independently without triggers.
3286
+ */
3287
+ declare class NoopHookRegistry implements HookRegistry {
3288
+ execute(): Promise<void>;
3289
+ }
3290
+
3291
+ interface InternalObjectRecord extends ObjectRecord {
3292
+ tenantId: TenantId;
3293
+ }
3294
+ interface MockStores {
3295
+ objects: Map<Uuid, DBObject>;
3296
+ attributes: Map<Uuid, DBAttribute>;
3297
+ userProfiles: Map<Uuid, UserProfile>;
3298
+ files: Map<Uuid, File>;
3299
+ objectRecords: Map<Uuid, InternalObjectRecord>;
3300
+ views: Map<Uuid, DBView>;
3301
+ roles: Map<Uuid, Role>;
3302
+ permissions: Map<Uuid, Permission>;
3303
+ userRoles: Map<Uuid, UserRoleAssignment>;
3304
+ }
3305
+ /**
3306
+ * Create an in-memory mock adapter for testing and development
3307
+ *
3308
+ * This adapter stores all data in memory and is perfect for:
3309
+ * - Unit tests
3310
+ * - Integration tests
3311
+ * - Local development without a database
3312
+ * - Understanding the adapter interface
3313
+ *
3314
+ * @returns A DatabaseAdapter implementation using in-memory storage
3315
+ *
3316
+ * @example
3317
+ * ```typescript
3318
+ * import { createMockAdapter, RecordService } from "@stndrds/schema";
3319
+ *
3320
+ * // Create adapter
3321
+ * const adapter = createMockAdapter();
3322
+ *
3323
+ * // Use with services
3324
+ * const recordService = new RecordService(adapter, "tenant-123");
3325
+ *
3326
+ * // Create a record
3327
+ * const product = await recordService.createRecord("obj-product", {
3328
+ * name: "Nike Air Max",
3329
+ * price: 129.99
3330
+ * });
3331
+ *
3332
+ * // List records
3333
+ * const { records, total } = await recordService.listRecords("obj-product");
3334
+ * ```
3335
+ */
3336
+ declare function createMockAdapter(): DatabaseAdapter & {
3337
+ _stores: MockStores;
3338
+ reset(): void;
3339
+ };
3340
+
3341
+ /**
3342
+ * Service for managing files
3343
+ * Handles file metadata CRUD, permissions, and soft delete
3344
+ */
3345
+ declare class FileService {
3346
+ private adapter;
3347
+ private tenantId;
3348
+ constructor(adapter: DatabaseAdapter, tenantId: string);
3349
+ /**
3350
+ * Create a new file record (after upload to storage)
3351
+ *
3352
+ * @param data - File metadata
3353
+ * @returns Created file record
3354
+ *
3355
+ * @example
3356
+ * ```typescript
3357
+ * const service = new FileService(adapter, "tenant-123");
3358
+ *
3359
+ * // After uploading to S3
3360
+ * const file = await service.createFile({
3361
+ * tenantId: "tenant-123",
3362
+ * name: "contract-2025.pdf",
3363
+ * originalName: "Contract Acme Corp 2025.pdf",
3364
+ * mimeType: "application/pdf",
3365
+ * size: 2458624,
3366
+ * storageProvider: "s3",
3367
+ * storagePath: "tenants/123/files/2025/contract.pdf",
3368
+ * storageBucket: "my-app-files",
3369
+ * url: "https://cdn.example.com/files/file-123",
3370
+ * uploadedBy: "profile-456",
3371
+ * visibility: "private"
3372
+ * });
3373
+ * ```
3374
+ */
3375
+ createFile(data: CreateFile): Promise<File>;
3376
+ /**
3377
+ * Get file by ID
3378
+ */
3379
+ getFile(fileId: string): Promise<File | null>;
3380
+ /**
3381
+ * Get file by ID or throw
3382
+ */
3383
+ getFileOrThrow(fileId: string): Promise<File>;
3384
+ /**
3385
+ * Update file metadata
3386
+ *
3387
+ * @param fileId - File UUID
3388
+ * @param data - Data to update
3389
+ * @returns Updated file
3390
+ */
3391
+ updateFile(fileId: string, data: UpdateFile): Promise<File>;
3392
+ /**
3393
+ * Delete file (soft delete)
3394
+ *
3395
+ * @param fileId - File UUID
3396
+ * @param options - Delete options
3397
+ */
3398
+ deleteFile(fileId: string, options?: {
3399
+ hard?: boolean;
3400
+ checkOwnership?: boolean;
3401
+ userId?: string;
3402
+ }): Promise<void>;
3403
+ /**
3404
+ * List files for the tenant
3405
+ */
3406
+ listFiles(options?: FileListOptions): Promise<File[]>;
3407
+ /**
3408
+ * List files by folder
3409
+ */
3410
+ listFilesByFolder(folderPath: string): Promise<File[]>;
3411
+ /**
3412
+ * List files uploaded by a specific user
3413
+ */
3414
+ listFilesByUploader(uploadedBy: string): Promise<File[]>;
3415
+ /**
3416
+ * Change file visibility
3417
+ *
3418
+ * @param fileId - File UUID
3419
+ * @param visibility - New visibility level
3420
+ * @param allowedUsers - Users allowed to access (if restricted)
3421
+ */
3422
+ changeVisibility(fileId: string, visibility: "public" | "private" | "restricted", allowedUsers?: string[]): Promise<File>;
3423
+ /**
3424
+ * Grant access to a file for specific users
3425
+ *
3426
+ * @param fileId - File UUID
3427
+ * @param userIds - User IDs to grant access
3428
+ */
3429
+ grantAccess(fileId: string, userIds: string[]): Promise<File>;
3430
+ /**
3431
+ * Revoke access to a file for specific users
3432
+ *
3433
+ * @param fileId - File UUID
3434
+ * @param userIds - User IDs to revoke access
3435
+ */
3436
+ revokeAccess(fileId: string, userIds: string[]): Promise<File>;
3437
+ /**
3438
+ * Check if user has access to a file
3439
+ *
3440
+ * @param fileId - File UUID
3441
+ * @param userId - User ID to check
3442
+ * @returns true if user can access the file
3443
+ */
3444
+ canAccess(fileId: string, userId: string): Promise<boolean>;
3445
+ /**
3446
+ * Move file to different folder
3447
+ */
3448
+ moveToFolder(fileId: string, newFolderPath: string): Promise<File>;
3449
+ /**
3450
+ * Add tags to file
3451
+ */
3452
+ addTags(fileId: string, tags: string[]): Promise<File>;
3453
+ /**
3454
+ * Remove tags from file
3455
+ */
3456
+ removeTags(fileId: string, tags: string[]): Promise<File>;
3457
+ }
3458
+
3459
+ /**
3460
+ * Geocoding service for address autocomplete and geocoding operations
3461
+ *
3462
+ * @example
3463
+ * ```typescript
3464
+ * import { GeocodingService } from "@stndrds/schema";
3465
+ * import { GoogleMapsAdapter } from "./adapters/google-maps";
3466
+ *
3467
+ * const geocoding = new GeocodingService(new GoogleMapsAdapter({ apiKey: "..." }));
3468
+ *
3469
+ * const suggestions = await geocoding.autocomplete({
3470
+ * query: "40 Quai des Belges",
3471
+ * countries: ["FRA"],
3472
+ * limit: 5,
3473
+ * });
3474
+ * ```
3475
+ */
3476
+ declare class GeocodingService {
3477
+ private readonly adapter;
3478
+ constructor(adapter: GeocodingAdapter);
3479
+ /**
3480
+ * Search for address suggestions as the user types
3481
+ */
3482
+ autocomplete(params: GeocodingAutocompleteParams): Promise<GeocodingSuggestion[]>;
3483
+ /**
3484
+ * Reverse geocode coordinates to an address
3485
+ */
3486
+ reverse(params: ReverseGeocodingParams): Promise<GeocodingSuggestion | null>;
3487
+ /**
3488
+ * Geocode a structured address to coordinates
3489
+ */
3490
+ geocode(params: GeocodingParams): Promise<GeocodingSuggestion | null>;
3491
+ }
3492
+
3493
+ /**
3494
+ * Service for global search across all object records
3495
+ * Allows searching across all objects or a subset of objects for a tenant
3496
+ *
3497
+ * @example
3498
+ * ```typescript
3499
+ * const service = new GlobalSearchService(adapter, "tenant-123");
3500
+ *
3501
+ * // Search across all objects
3502
+ * const { results, total } = await service.search("nike");
3503
+ *
3504
+ * // Search only in specific objects
3505
+ * const { results, total } = await service.search("nike", {
3506
+ * objectNames: ["products", "orders"],
3507
+ * limit: 20
3508
+ * });
3509
+ * ```
3510
+ */
3511
+ declare class GlobalSearchService {
3512
+ private adapter;
3513
+ private tenantId;
3514
+ constructor(adapter: DatabaseAdapter, tenantId: string);
3515
+ /**
3516
+ * Search across all object records for the tenant
3517
+ *
3518
+ * @param query - Search query string
3519
+ * @param options - Search options (pagination, object filters)
3520
+ * @returns Matching records with object metadata and total count
3521
+ *
3522
+ * @example
3523
+ * ```typescript
3524
+ * // Basic search
3525
+ * const { results, total } = await service.search("nike air");
3526
+ *
3527
+ * // With pagination
3528
+ * const { results, total } = await service.search("nike", {
3529
+ * limit: 10,
3530
+ * offset: 20
3531
+ * });
3532
+ *
3533
+ * // Filter by object types
3534
+ * const { results, total } = await service.search("nike", {
3535
+ * objectNames: ["products", "orders"]
3536
+ * });
3537
+ * ```
3538
+ */
3539
+ search(query: string, options?: GlobalSearchOptions): Promise<{
3540
+ results: GlobalSearchResultItem[];
3541
+ total: number;
3542
+ }>;
3543
+ /**
3544
+ * Search and group results by object type
3545
+ *
3546
+ * @param query - Search query string
3547
+ * @param options - Search options
3548
+ * @returns Results grouped by object name
3549
+ */
3550
+ searchGrouped(query: string, options?: Omit<GlobalSearchOptions, "limit" | "offset">): Promise<{
3551
+ groups: Array<{
3552
+ objectName: string;
3553
+ objectLabel: string;
3554
+ results: GlobalSearchResultItem[];
3555
+ count: number;
3556
+ }>;
3557
+ total: number;
3558
+ }>;
3559
+ }
3560
+
3561
+ /**
3562
+ * Input for creating a custom object
3563
+ */
3564
+ interface CreateCustomObjectInput {
3565
+ name: string;
3566
+ label: string;
3567
+ /**
3568
+ * Plural form of the label (e.g., "Products" for "Product")
3569
+ * Used in UI when displaying collections
3570
+ */
3571
+ pluralLabel?: string;
3572
+ /**
3573
+ * Template expression for computing record display labels.
3574
+ * Example: "{{ name }}" or "{{ firstName }} {{ lastName }}"
3575
+ */
3576
+ labelExpression: string;
3577
+ description?: string;
3578
+ icon?: IconName;
3579
+ attributes?: (Attribute | {
3580
+ build: () => Attribute;
3581
+ })[];
3582
+ metadata?: Record<string, unknown>;
3583
+ }
3584
+ /**
3585
+ * Input for adding an attribute to an object
3586
+ */
3587
+ interface AddAttributeInput {
3588
+ name: string;
3589
+ label: string;
3590
+ type: AttributeType;
3591
+ required?: boolean;
3592
+ unique?: boolean;
3593
+ description?: string;
3594
+ placeholder?: string;
3595
+ icon?: IconName;
3596
+ defaultValue?: unknown;
3597
+ metadata?: Record<string, unknown>;
3598
+ [key: string]: unknown;
3599
+ }
3600
+ /**
3601
+ * Input for updating an object
3602
+ * Only custom objects (system=false) can be updated
3603
+ * Note: `name` cannot be changed after creation
3604
+ */
3605
+ interface UpdateObjectInput {
3606
+ label?: string;
3607
+ pluralLabel?: string;
3608
+ description?: string;
3609
+ icon?: IconName;
3610
+ labelExpression?: string;
3611
+ metadata?: Record<string, unknown>;
3612
+ }
3613
+ /**
3614
+ * Service for managing object schemas
3615
+ * Handles fusion of native objects (from registry) and custom objects (from database)
3616
+ */
3617
+ declare class ObjectSchemaService {
3618
+ private adapter;
3619
+ private nativeRegistry;
3620
+ constructor(adapter: DatabaseAdapter, nativeRegistry: typeof registry);
3621
+ /**
3622
+ * Create a new custom object
3623
+ * Validates name format and ensures system=false
3624
+ *
3625
+ * @param definition - Object definition (attributes can be raw definitions or builders)
3626
+ * @param tenantId - Tenant ID owning the object
3627
+ * @returns Created ObjectDefinition
3628
+ */
3629
+ createCustomObject(definition: CreateCustomObjectInput, tenantId: string): Promise<ObjectDefinition>;
3630
+ /**
3631
+ * Add a custom attribute to an existing object
3632
+ * Can be used on both custom and native objects
3633
+ * Attributes added via API are always custom (system=false)
3634
+ *
3635
+ * @param objectId - Object UUID from database
3636
+ * @param attribute - Attribute definition
3637
+ * @param tenantId - Tenant ID (required for relation validation)
3638
+ * @returns Created Attribute
3639
+ */
3640
+ addAttributeToObject(objectId: string, attribute: AddAttributeInput, tenantId?: string): Promise<Attribute>;
3641
+ /**
3642
+ * Update an attribute
3643
+ * Can only update custom attributes (system=false)
3644
+ *
3645
+ * @param attributeId - Attribute UUID
3646
+ * @param updates - Partial attribute updates
3647
+ * @param tenantId - Tenant ID (required for relation validation)
3648
+ * @returns Updated Attribute
3649
+ */
3650
+ updateAttribute(attributeId: string, updates: Partial<AddAttributeInput>, tenantId?: string): Promise<Attribute>;
3651
+ /**
3652
+ * Delete an attribute
3653
+ * Can only delete custom attributes (system=false)
3654
+ *
3655
+ * @param attributeId - Attribute UUID
3656
+ */
3657
+ deleteAttribute(attributeId: string): Promise<void>;
3658
+ /**
3659
+ * List attributes for an object
3660
+ *
3661
+ * @param objectId - Object UUID
3662
+ * @param options - Filter options
3663
+ * @returns List of attributes
3664
+ */
3665
+ listAttributes(objectId: string, options?: {
3666
+ systemOnly?: boolean;
3667
+ customOnly?: boolean;
3668
+ }): Promise<Attribute[]>;
3669
+ /**
3670
+ * Update a custom object
3671
+ * Can only update custom objects (system=false)
3672
+ *
3673
+ * @param objectId - Object UUID
3674
+ * @param updates - Partial object updates
3675
+ * @returns Updated ObjectDefinition
3676
+ *
3677
+ * @example
3678
+ * ```typescript
3679
+ * const updated = await service.updateObject("obj-123", {
3680
+ * label: "Updated Label",
3681
+ * description: "New description",
3682
+ * });
3683
+ * ```
3684
+ */
3685
+ updateObject(objectId: string, updates: UpdateObjectInput): Promise<ObjectDefinition>;
3686
+ /**
3687
+ * Delete a custom object
3688
+ * Can only delete custom objects (system=false)
3689
+ * This will also delete all associated attributes and records
3690
+ *
3691
+ * @param objectId - Object UUID
3692
+ *
3693
+ * @example
3694
+ * ```typescript
3695
+ * await service.deleteObject("obj-123");
3696
+ * ```
3697
+ */
3698
+ deleteObject(objectId: string): Promise<void>;
3699
+ /**
3700
+ * Validate attribute name format (variable identifier)
3701
+ * @internal
3702
+ */
3703
+ private validateAttributeName;
3704
+ /**
3705
+ * Get complete object schema (system + custom attributes)
3706
+ * If object is native, merges registry definition with DB custom attributes
3707
+ * If object is custom, returns DB definition only
3708
+ *
3709
+ * @param objectId - Object UUID from database
3710
+ * @returns Complete ObjectDefinition with all attributes
3711
+ *
3712
+ * @example
3713
+ * ```typescript
3714
+ * const service = new ObjectSchemaService(adapter, registry);
3715
+ * const productSchema = await service.getObjectSchema("obj-123");
3716
+ *
3717
+ * console.log(productSchema.attributes); // System + custom attributes
3718
+ * ```
3719
+ */
3720
+ getObjectSchema(objectId: string): Promise<ObjectDefinition>;
3721
+ /**
3722
+ * Get object schema by name (for system/native objects)
3723
+ * @deprecated Use getObjectSchemaByNameForTenant for custom objects support
3724
+ */
3725
+ getObjectSchemaByName(name: string): Promise<ObjectDefinition>;
3726
+ /**
3727
+ * Get object schema by name for a tenant (supports both native and custom objects)
3728
+ */
3729
+ getObjectSchemaByNameForTenant(name: string, tenantId: string): Promise<ObjectDefinition>;
3730
+ /**
3731
+ * List all object schemas for a tenant
3732
+ */
3733
+ listObjectSchemas(tenantId: string): Promise<ObjectDefinition[]>;
3734
+ /**
3735
+ * Merge native object from registry with custom attributes from DB
3736
+ * @internal
3737
+ */
3738
+ private mergeNativeObject;
3739
+ /**
3740
+ * Convert DB object + attributes to ObjectDefinition
3741
+ * @internal
3742
+ */
3743
+ private convertDBObjectToDefinition;
3744
+ /**
3745
+ * Validate attribute input and return parsed config
3746
+ * Validates: name format, config schema, relation targets
3747
+ * @internal
3748
+ */
3749
+ private validateAttributeInput;
3750
+ /**
3751
+ * Build and validate attribute config from input
3752
+ * Uses Zod schema to validate and strip unknown properties
3753
+ * @internal
3754
+ */
3755
+ private buildAttributeConfig;
3756
+ /**
3757
+ * Validate that relation target objects exist
3758
+ * @internal
3759
+ */
3760
+ private validateRelationTargets;
3761
+ /**
3762
+ * Convert DB attribute to Attribute type
3763
+ * @internal
3764
+ */
3765
+ private convertDBAttributeToAttribute;
3766
+ }
3767
+
3768
+ /**
3769
+ * Options for PermissionService constructor
3770
+ */
3771
+ interface PermissionServiceOptions {
3772
+ /**
3773
+ * Cache TTL in milliseconds.
3774
+ * @default 60000 (1 minute)
3775
+ */
3776
+ cacheTtlMs?: number;
3777
+ /**
3778
+ * Maximum number of entries in the cache.
3779
+ * Oldest entries are evicted when limit is reached (LRU-like).
3780
+ * @default 10000
3781
+ */
3782
+ maxCacheSize?: number;
3783
+ }
3784
+ /**
3785
+ * Service for checking and managing permissions.
3786
+ *
3787
+ * Features:
3788
+ * - In-memory cache with TTL and size limit for effective permissions
3789
+ * - Admin bypass for full access
3790
+ * - Wildcard permission support (target: "*")
3791
+ * - Object-level permission checks
3792
+ *
3793
+ * @example
3794
+ * ```typescript
3795
+ * const permissionService = new PermissionService(adapter, "tenant-123");
3796
+ *
3797
+ * // Check if user can read companies
3798
+ * const canRead = await permissionService.canAccessObject(userId, "companies", "read");
3799
+ *
3800
+ * // Throw if user cannot update
3801
+ * await permissionService.checkObjectAccess(userId, "companies", "update");
3802
+ * ```
3803
+ */
3804
+ declare class PermissionService {
3805
+ private readonly adapter;
3806
+ private readonly tenantId;
3807
+ private cache;
3808
+ private readonly cacheTtlMs;
3809
+ private readonly maxCacheSize;
3810
+ private readonly permissionsRepo;
3811
+ constructor(adapter: DatabaseAdapter, tenantId: string, options?: PermissionServiceOptions);
3812
+ /**
3813
+ * Check if user can perform an action on an object.
3814
+ *
3815
+ * @param userProfileId - User profile ID to check
3816
+ * @param objectName - Object name to check access for
3817
+ * @param action - Action to check (read, create, update, delete)
3818
+ * @returns true if user has permission, false otherwise
3819
+ */
3820
+ canAccessObject(userProfileId: string, objectName: string, action: ObjectAction): Promise<boolean>;
3821
+ /**
3822
+ * Check if user can access an object, throw ForbiddenError if not.
3823
+ *
3824
+ * @param userProfileId - User profile ID to check
3825
+ * @param objectName - Object name to check access for
3826
+ * @param action - Action to check
3827
+ * @throws ForbiddenError if user lacks permission
3828
+ */
3829
+ checkObjectAccess(userProfileId: string, objectName: string, action: ObjectAction): Promise<void>;
3830
+ /**
3831
+ * Get permissions for a specific object as boolean flags.
3832
+ * Optimized to fetch permissions once and compute all flags.
3833
+ *
3834
+ * @param userProfileId - User profile ID to check
3835
+ * @param objectName - Object name to check
3836
+ * @returns Object with canRead, canCreate, canUpdate, canDelete flags
3837
+ */
3838
+ getObjectPermissions(userProfileId: string, objectName: string): Promise<ObjectPermissions>;
3839
+ /**
3840
+ * Get effective permissions for a user.
3841
+ * Results are cached with TTL and size limit.
3842
+ *
3843
+ * @param userProfileId - User profile ID
3844
+ * @returns Merged permissions from all user's roles
3845
+ */
3846
+ getEffectivePermissions(userProfileId: string): Promise<EffectivePermissions>;
3847
+ /**
3848
+ * Invalidate cached permissions for a specific user.
3849
+ * Call this after role/permission changes.
3850
+ */
3851
+ invalidateCache(userProfileId: string): void;
3852
+ /**
3853
+ * Invalidate all cached permissions.
3854
+ * Call this after bulk role/permission changes.
3855
+ */
3856
+ invalidateAllCache(): void;
3857
+ /**
3858
+ * Get current cache size (for monitoring).
3859
+ */
3860
+ getCacheSize(): number;
3861
+ private getCacheKey;
3862
+ /**
3863
+ * Get all roles for the current tenant.
3864
+ */
3865
+ getRoles(): Promise<Role[]>;
3866
+ /**
3867
+ * Get a role by ID.
3868
+ */
3869
+ getRoleById(roleId: string): Promise<Role | null>;
3870
+ /**
3871
+ * Create a new role.
3872
+ */
3873
+ createRole(input: Omit<CreateRoleInput, "tenantId">): Promise<Role>;
3874
+ /**
3875
+ * Update a role.
3876
+ */
3877
+ updateRole(roleId: string, updates: UpdateRoleInput): Promise<Role>;
3878
+ /**
3879
+ * Delete a role.
3880
+ */
3881
+ deleteRole(roleId: string): Promise<void>;
3882
+ /**
3883
+ * Get all permissions for a role.
3884
+ */
3885
+ getPermissionsByRole(roleId: string): Promise<Permission[]>;
3886
+ /**
3887
+ * Set permissions for a role (replaces existing).
3888
+ */
3889
+ setPermissions(roleId: string, permissions: CreatePermissionInput[]): Promise<void>;
3890
+ /**
3891
+ * Get all roles assigned to a user.
3892
+ */
3893
+ getUserRoles(userProfileId: string): Promise<Role[]>;
3894
+ /**
3895
+ * Assign a role to a user.
3896
+ */
3897
+ assignRole(userProfileId: string, roleId: string, assignedBy?: string): Promise<UserRoleAssignment>;
3898
+ /**
3899
+ * Revoke a role from a user.
3900
+ */
3901
+ revokeRole(userProfileId: string, roleId: string): Promise<void>;
3902
+ }
3903
+
3904
+ /**
3905
+ * Options for RecordService constructor
3906
+ */
3907
+ interface RecordServiceOptions {
3908
+ /**
3909
+ * Hook registry for executing triggers before/after operations.
3910
+ * If not provided, a no-op registry is used (no hooks executed).
3911
+ */
3912
+ hookRegistry?: HookRegistry;
3913
+ /**
3914
+ * Permission service for access control.
3915
+ * If provided along with userId, permission checks are enforced.
3916
+ * If not provided, no permission checks are performed (backward compatible).
3917
+ */
3918
+ permissionService?: PermissionService;
3919
+ /**
3920
+ * Current user ID for permission checks.
3921
+ * Required when permissionService is provided.
3922
+ */
3923
+ userId?: string;
3924
+ }
3925
+ /**
3926
+ * Service for managing object records (CRUD operations)
3927
+ * Handles validation, dispatch to correct table, and data consistency
3928
+ *
3929
+ * Supports optional hook system for triggers on attribute changes.
3930
+ * Supports optional permission checks when permissionService and userId are provided.
3931
+ */
3932
+ declare class RecordService {
3933
+ private adapter;
3934
+ private tenantId;
3935
+ private schemaService;
3936
+ private relationService;
3937
+ private hookRegistry;
3938
+ private permissionService?;
3939
+ private userId?;
3940
+ constructor(adapter: DatabaseAdapter, tenantId: string, options?: RecordServiceOptions);
3941
+ /**
3942
+ * Check permission for an action on an object.
3943
+ * Only checks if permissionService and userId are configured.
3944
+ * @internal
3945
+ */
3946
+ private checkPermission;
3947
+ /**
3948
+ * Compute display label from schema expression
3949
+ * Automatically resolves relation attribute values to their labels
3950
+ * @internal
3951
+ */
3952
+ private computeLabel;
3953
+ /**
3954
+ * Create a new record with validation
3955
+ *
3956
+ * Triggers beforeCreate and afterCreate hooks if a HookRegistry is configured.
3957
+ *
3958
+ * @param objectId - Object UUID
3959
+ * @param data - Record data (attribute values)
3960
+ * @param options - Creation options
3961
+ * @returns Created record with computed completionStatus
3962
+ *
3963
+ * @example
3964
+ * ```typescript
3965
+ * const service = new RecordService(adapter, "tenant-123");
3966
+ *
3967
+ * // Create a complete record (strict validation)
3968
+ * const product = await service.createRecord("obj-product", {
3969
+ * name: "Nike Air Max",
3970
+ * price: 129.99,
3971
+ * status: "active"
3972
+ * });
3973
+ * // → product.completionStatus = "complete"
3974
+ *
3975
+ * // Create a draft record (allows missing required fields)
3976
+ * const draft = await service.createRecord("obj-product", {
3977
+ * name: "Draft Product"
3978
+ * }, { allowDraft: true });
3979
+ * // → draft.completionStatus = "draft"
3980
+ * ```
3981
+ */
3982
+ createRecord(objectId: string, data: Record<string, unknown>, options?: {
3983
+ /**
3984
+ * Allow creating records with missing required fields.
3985
+ * Format validation still applies to provided values.
3986
+ * @default false
3987
+ */
3988
+ allowDraft?: boolean;
3989
+ /**
3990
+ * Skip all validation (format + relations).
3991
+ * @default true
3992
+ */
3993
+ validate?: boolean;
3994
+ /**
3995
+ * Skip relation validation only.
3996
+ * Useful for bulk imports where relations are validated separately.
3997
+ * @default false
3998
+ */
3999
+ skipRelationValidation?: boolean;
4000
+ skipSystemCheck?: boolean;
4001
+ /**
4002
+ * Skip hook execution.
4003
+ * @default false
4004
+ */
4005
+ skipHooks?: boolean;
4006
+ /**
4007
+ * Additional metadata to pass to hooks (e.g., userId, requestId).
4008
+ */
4009
+ hookMetadata?: Record<string, unknown>;
4010
+ }): Promise<ObjectRecord>;
4011
+ /**
4012
+ * Get a record by ID
4013
+ *
4014
+ * @param recordId - Record UUID
4015
+ * @param options - Query options
4016
+ * @returns Record or null if not found
4017
+ */
4018
+ getRecord(recordId: string, options?: {
4019
+ includeSchema?: boolean;
4020
+ }): Promise<ObjectRecord | null>;
4021
+ /**
4022
+ * Get a record by ID or throw if not found
4023
+ */
4024
+ getRecordOrThrow(recordId: string): Promise<ObjectRecord>;
4025
+ /**
4026
+ * Update a record with validation
4027
+ *
4028
+ * The completion status is automatically recalculated after each update.
4029
+ * A draft record becomes complete when all required fields are filled.
4030
+ *
4031
+ * Triggers beforeUpdate and afterUpdate hooks if a HookRegistry is configured.
4032
+ *
4033
+ * @param recordId - Record UUID
4034
+ * @param data - Partial data to update
4035
+ * @param options - Update options
4036
+ * @returns Updated record with recalculated completionStatus
4037
+ *
4038
+ * @example
4039
+ * ```typescript
4040
+ * // Update a draft record to make it complete
4041
+ * const updated = await service.updateRecord(draftId, {
4042
+ * price: 99.99,
4043
+ * status: "active"
4044
+ * });
4045
+ * // → updated.completionStatus = "complete" if all required fields now present
4046
+ * ```
4047
+ */
4048
+ updateRecord(recordId: string, data: Partial<Record<string, unknown>>, options?: {
4049
+ /**
4050
+ * Skip validation entirely (format + relations).
4051
+ * @default true
4052
+ */
4053
+ validate?: boolean;
4054
+ /**
4055
+ * Allow partial updates without strict validation.
4056
+ * Format validation still applies to provided values.
4057
+ * @default false
4058
+ */
4059
+ partial?: boolean;
4060
+ /**
4061
+ * Skip relation validation only.
4062
+ * @default false
4063
+ */
4064
+ skipRelationValidation?: boolean;
4065
+ /**
4066
+ * Skip hook execution.
4067
+ * @default false
4068
+ */
4069
+ skipHooks?: boolean;
4070
+ /**
4071
+ * Additional metadata to pass to hooks (e.g., userId, requestId).
4072
+ */
4073
+ hookMetadata?: Record<string, unknown>;
4074
+ }): Promise<ObjectRecord>;
4075
+ /**
4076
+ * Build hook context for update operations
4077
+ * @internal
4078
+ */
4079
+ private buildHookContext;
4080
+ /**
4081
+ * Build hook context for create operations (no existing record)
4082
+ * @internal
4083
+ */
4084
+ private buildCreateHookContext;
4085
+ /**
4086
+ * Build hook context for delete operations
4087
+ * @internal
4088
+ */
4089
+ private buildDeleteHookContext;
4090
+ /**
4091
+ * Delete a record
4092
+ *
4093
+ * Triggers beforeDelete and afterDelete hooks if a HookRegistry is configured.
4094
+ *
4095
+ * @param recordId - Record UUID
4096
+ * @param options - Delete options
4097
+ */
4098
+ deleteRecord(recordId: string, options?: {
4099
+ checkSystem?: boolean;
4100
+ /**
4101
+ * Skip hook execution.
4102
+ * @default false
4103
+ */
4104
+ skipHooks?: boolean;
4105
+ /**
4106
+ * Additional metadata to pass to hooks (e.g., userId, requestId).
4107
+ */
4108
+ hookMetadata?: Record<string, unknown>;
4109
+ }): Promise<void>;
4110
+ /**
4111
+ * List records for an object with pagination
4112
+ *
4113
+ * @param objectId - Object UUID
4114
+ * @param options - List options
4115
+ * @returns Records and total count
4116
+ */
4117
+ listRecords(objectId: string, options?: ListOptions): Promise<{
4118
+ records: ObjectRecord[];
4119
+ total: number;
4120
+ }>;
4121
+ /**
4122
+ * Search records using full-text search
4123
+ *
4124
+ * @param objectId - Object UUID
4125
+ * @param query - Search query
4126
+ * @param options - Search options
4127
+ * @returns Matching records and total count
4128
+ */
4129
+ searchRecords(objectId: string, query: string, options?: SearchOptions): Promise<{
4130
+ records: ObjectRecord[];
4131
+ total: number;
4132
+ }>;
4133
+ /**
4134
+ * Validate data against object schema without saving
4135
+ *
4136
+ * @param objectId - Object UUID
4137
+ * @param data - Data to validate
4138
+ * @returns Validation result
4139
+ */
4140
+ validateData(objectId: string, data: Record<string, unknown>): Promise<ValidationResult>;
4141
+ /**
4142
+ * Compute the completion status for given data without saving.
4143
+ * Useful for UI to show draft/complete status before submitting.
4144
+ *
4145
+ * @param objectId - Object UUID
4146
+ * @param data - Data to check
4147
+ * @returns Computed completion status
4148
+ */
4149
+ computeStatus(objectId: string, data: Record<string, unknown>): Promise<CompletionStatus>;
4150
+ /**
4151
+ * Refresh the completion status of an existing record.
4152
+ * Useful when schema changes and you need to recompute statuses.
4153
+ *
4154
+ * @param recordId - Record UUID
4155
+ * @returns Updated completion status
4156
+ */
4157
+ refreshRecordStatus(recordId: string): Promise<CompletionStatus>;
4158
+ }
4159
+
4160
+ /**
4161
+ * Result of relation validation
4162
+ */
4163
+ interface RelationValidationResult {
4164
+ valid: boolean;
4165
+ errors: RelationValidationError[];
4166
+ }
4167
+ /**
4168
+ * Individual relation validation error
4169
+ */
4170
+ interface RelationValidationError {
4171
+ /** Attribute name */
4172
+ attribute: string;
4173
+ /** Error message */
4174
+ message: string;
4175
+ /** Invalid record IDs */
4176
+ invalidIds?: string[];
4177
+ }
4178
+ /**
4179
+ * Resolved relation option
4180
+ *
4181
+ * SECURITY: This type intentionally excludes raw record data.
4182
+ * Only the computed label is exposed to prevent unauthorized data access
4183
+ * through relation lookups. Users must have explicit read permissions
4184
+ * on an object to access its record data.
4185
+ */
4186
+ interface RelationOption {
4187
+ /** Record ID */
4188
+ id: string;
4189
+ /** Object ID */
4190
+ objectId: string;
4191
+ /** Object name (technical name) */
4192
+ objectName: string;
4193
+ /** Object label (display name) */
4194
+ objectLabel: string;
4195
+ /** Object icon */
4196
+ objectIcon?: string;
4197
+ /** Display label (computed from labelExpression) */
4198
+ label: string;
4199
+ }
4200
+ /**
4201
+ * Response for relation options
4202
+ */
4203
+ interface RelationOptionsResponse {
4204
+ options: RelationOption[];
4205
+ hasMore: boolean;
4206
+ total: number;
4207
+ }
4208
+ /**
4209
+ * Parameters for fetching relation options
4210
+ */
4211
+ interface GetRelationOptionsParams {
4212
+ /** Search query */
4213
+ query?: string;
4214
+ /** Page number (1-based) */
4215
+ page?: number;
4216
+ /** Page size */
4217
+ pageSize?: number;
4218
+ /** Filter by specific target object */
4219
+ targetObject?: string;
4220
+ }
4221
+ /**
4222
+ * Service for validating relation attributes
4223
+ * Ensures referenced records exist and belong to valid target objects
4224
+ */
4225
+ declare class RelationService {
4226
+ private adapter;
4227
+ private schemaService;
4228
+ constructor(adapter: DatabaseAdapter, nativeRegistry: typeof registry);
4229
+ /**
4230
+ * Validate all relation attributes in the data
4231
+ *
4232
+ * @param schema - Object schema containing attribute definitions
4233
+ * @param data - Record data to validate
4234
+ * @returns Validation result with errors if any
4235
+ *
4236
+ * @example
4237
+ * ```typescript
4238
+ * const result = await relationService.validateRelations(schema, {
4239
+ * company: "rec-123",
4240
+ * contacts: ["rec-456", "rec-789"]
4241
+ * });
4242
+ *
4243
+ * if (!result.valid) {
4244
+ * console.log(result.errors);
4245
+ * // [{ attribute: "company", message: "Record not found", invalidIds: ["rec-123"] }]
4246
+ * }
4247
+ * ```
4248
+ */
4249
+ validateRelations(schema: ObjectDefinition, data: Record<string, unknown>): Promise<RelationValidationResult>;
4250
+ /**
4251
+ * Validate a single relation attribute value
4252
+ */
4253
+ private validateRelationAttribute;
4254
+ /**
4255
+ * Extract IDs from relation value based on cardinality
4256
+ */
4257
+ private extractIds;
4258
+ /**
4259
+ * Get valid object IDs from relation targets
4260
+ */
4261
+ private getValidObjectIds;
4262
+ /**
4263
+ * Validate relations and throw if invalid
4264
+ */
4265
+ validateRelationsOrThrow(schema: ObjectDefinition, data: Record<string, unknown>): Promise<void>;
4266
+ /**
4267
+ * Get available options for a relation attribute
4268
+ * Searches across all target objects defined in the relation
4269
+ *
4270
+ * @param attribute - Relation attribute definition
4271
+ * @param tenantId - Tenant ID for multi-tenant isolation
4272
+ * @param params - Query parameters
4273
+ *
4274
+ * @example
4275
+ * ```typescript
4276
+ * const options = await relationService.getOptions(attribute, "tenant-1", {
4277
+ * query: "nike",
4278
+ * page: 1,
4279
+ * pageSize: 20
4280
+ * });
4281
+ * ```
4282
+ */
4283
+ getOptions(attribute: RelationAttribute, tenantId: string, params?: GetRelationOptionsParams): Promise<RelationOptionsResponse>;
4284
+ /**
4285
+ * Resolve record IDs to their display labels
4286
+ * Useful for displaying current values in the UI
4287
+ *
4288
+ * Uses batch fetching for performance - fetches all records in one query,
4289
+ * then groups by objectId to minimize schema lookups.
4290
+ *
4291
+ * @param ids - Record IDs to resolve
4292
+ * @param _tenantId - Tenant ID for multi-tenant isolation (unused but kept for API compatibility)
4293
+ * @param attributeId - Optional relation attribute ID to use its displayTemplate instead of object's labelExpression
4294
+ *
4295
+ * @example
4296
+ * ```typescript
4297
+ * // Using object's default labelExpression
4298
+ * const resolved = await relationService.resolveIds(["rec-1", "rec-2"], "tenant-1");
4299
+ *
4300
+ * // Using attribute's displayTemplate
4301
+ * const resolved = await relationService.resolveIds(["rec-1"], "tenant-1", "attr-123");
4302
+ * ```
4303
+ */
4304
+ resolveIds(ids: string[], _tenantId: string, attributeId?: string): Promise<RelationOption[]>;
4305
+ /**
4306
+ * Find a relation attribute by ID
4307
+ */
4308
+ findAttributeById(attributeId: string): Promise<RelationAttribute | null>;
4309
+ }
4310
+
4311
+ /**
4312
+ * Service for managing user profiles
4313
+ * Handles user profile CRUD, auth provider sync, and role management
4314
+ */
4315
+ declare class UserProfileService {
4316
+ private adapter;
4317
+ private tenantId;
4318
+ constructor(adapter: DatabaseAdapter, tenantId: string);
4319
+ /**
4320
+ * Create a new user profile (typically after first auth)
4321
+ *
4322
+ * @param data - User profile creation data
4323
+ * @returns Created user profile
4324
+ *
4325
+ * @example
4326
+ * ```typescript
4327
+ * const service = new UserProfileService(adapter, "tenant-123");
4328
+ *
4329
+ * // After Supabase auth
4330
+ * const profile = await service.createProfile({
4331
+ * tenantId: "tenant-123",
4332
+ * authId: authUser.id,
4333
+ * email: authUser.email,
4334
+ * firstName: authUser.user_metadata.first_name,
4335
+ * lastName: authUser.user_metadata.last_name,
4336
+ * role: "member",
4337
+ * status: "active"
4338
+ * });
4339
+ * ```
4340
+ */
4341
+ createProfile(data: CreateUserProfile): Promise<UserProfile>;
4342
+ /**
4343
+ * Get user profile by ID
4344
+ */
4345
+ getProfile(profileId: string): Promise<UserProfile | null>;
4346
+ /**
4347
+ * Get user profile by ID or throw
4348
+ */
4349
+ getProfileOrThrow(profileId: string): Promise<UserProfile>;
4350
+ /**
4351
+ * Get user profile by auth provider ID
4352
+ *
4353
+ * @param authId - Auth provider user ID (Supabase, Clerk, etc.)
4354
+ * @returns User profile or null
4355
+ */
4356
+ getProfileByAuthId(authId: string): Promise<UserProfile | null>;
4357
+ /**
4358
+ * Get or create user profile (idempotent operation)
4359
+ * Useful for auth callbacks - ensures profile exists
4360
+ *
4361
+ * @param authId - Auth provider user ID
4362
+ * @param data - Profile data to create if doesn't exist
4363
+ * @returns Existing or newly created profile
4364
+ *
4365
+ * @example
4366
+ * ```typescript
4367
+ * // In Supabase auth callback
4368
+ * const profile = await service.getOrCreateProfile(
4369
+ * authUser.id,
4370
+ * {
4371
+ * tenantId: "tenant-123",
4372
+ * authId: authUser.id,
4373
+ * email: authUser.email,
4374
+ * role: "member",
4375
+ * status: "active"
4376
+ * }
4377
+ * );
4378
+ * ```
4379
+ */
4380
+ getOrCreateProfile(authId: string, data: CreateUserProfile): Promise<UserProfile>;
4381
+ /**
4382
+ * Update user profile
4383
+ */
4384
+ updateProfile(profileId: string, data: UpdateUserProfile): Promise<UserProfile>;
4385
+ /**
4386
+ * Delete user profile
4387
+ *
4388
+ * @param profileId - Profile UUID
4389
+ * @param options - Delete options
4390
+ */
4391
+ deleteProfile(profileId: string, options?: {
4392
+ checkAdmin?: boolean;
4393
+ }): Promise<void>;
4394
+ /**
4395
+ * List all user profiles for the tenant
4396
+ */
4397
+ listProfiles(options?: ListOptions): Promise<UserProfile[]>;
4398
+ /**
4399
+ * Update last login timestamp
4400
+ *
4401
+ * @param profileId - Profile UUID
4402
+ *
4403
+ * @example
4404
+ * ```typescript
4405
+ * // After successful auth
4406
+ * await service.updateLastLogin(profile.id);
4407
+ * ```
4408
+ */
4409
+ updateLastLogin(profileId: string): Promise<void>;
4410
+ /**
4411
+ * Change user role
4412
+ *
4413
+ * @param profileId - Profile UUID
4414
+ * @param newRole - New role
4415
+ */
4416
+ changeRole(profileId: string, newRole: string): Promise<UserProfile>;
4417
+ /**
4418
+ * Change user status
4419
+ *
4420
+ * @param profileId - Profile UUID
4421
+ * @param newStatus - New status
4422
+ */
4423
+ changeStatus(profileId: string, newStatus: "active" | "pending" | "inactive" | "suspended"): Promise<UserProfile>;
4424
+ /**
4425
+ * Get user by email
4426
+ */
4427
+ getProfileByEmail(email: string): Promise<UserProfile | null>;
4428
+ /**
4429
+ * Check if user has role
4430
+ */
4431
+ hasRole(profileId: string, role: string): Promise<boolean>;
4432
+ /**
4433
+ * Check if user is admin
4434
+ */
4435
+ isAdmin(profileId: string): Promise<boolean>;
4436
+ }
4437
+
4438
+ /**
4439
+ * Input for creating a custom view
4440
+ */
4441
+ interface CreateViewInput {
4442
+ name: string;
4443
+ label: string;
4444
+ objectName: string;
4445
+ description?: string;
4446
+ icon?: IconName;
4447
+ tabs: Tab[];
4448
+ default?: boolean;
4449
+ metadata?: Record<string, unknown>;
4450
+ }
4451
+ /**
4452
+ * Input for updating a view
4453
+ */
4454
+ interface UpdateViewInput {
4455
+ label?: string;
4456
+ description?: string;
4457
+ icon?: IconName;
4458
+ tabs?: Tab[];
4459
+ default?: boolean;
4460
+ metadata?: Record<string, unknown>;
4461
+ }
4462
+ /**
4463
+ * Service for managing views
4464
+ * Handles fusion of native views (from registry) and custom views (from database)
4465
+ */
4466
+ declare class ViewService {
4467
+ private adapter;
4468
+ private nativeViews;
4469
+ constructor(adapter: DatabaseAdapter, nativeViews: typeof viewRegistry);
4470
+ /**
4471
+ * Get all views for an object (native + custom)
4472
+ *
4473
+ * @param objectName - Object name
4474
+ * @param tenantId - Tenant ID
4475
+ * @returns All views for the object
4476
+ */
4477
+ getViewsForObject(objectName: string, tenantId: string): Promise<ViewDefinition[]>;
4478
+ /**
4479
+ * Get a specific view by name
4480
+ *
4481
+ * @param objectName - Object name
4482
+ * @param viewName - View name
4483
+ * @param tenantId - Tenant ID
4484
+ * @returns View definition or null
4485
+ */
4486
+ getView(objectName: string, viewName: string, tenantId: string): Promise<ViewDefinition | null>;
4487
+ /**
4488
+ * Get the default view for an object
4489
+ *
4490
+ * Priority:
4491
+ * 1. Custom view marked as default
4492
+ * 2. Native view marked as default
4493
+ * 3. First available view
4494
+ *
4495
+ * @param objectName - Object name
4496
+ * @param tenantId - Tenant ID
4497
+ * @returns Default view or null
4498
+ */
4499
+ getDefaultView(objectName: string, tenantId: string): Promise<ViewDefinition | null>;
4500
+ /**
4501
+ * Create a custom view
4502
+ *
4503
+ * @param input - View definition
4504
+ * @param tenantId - Tenant ID
4505
+ * @returns Created view
4506
+ */
4507
+ createView(input: CreateViewInput, tenantId: string): Promise<ViewDefinition>;
4508
+ /**
4509
+ * Update a custom view
4510
+ *
4511
+ * @param viewId - View ID
4512
+ * @param input - Update data
4513
+ * @returns Updated view
4514
+ */
4515
+ updateView(viewId: string, input: UpdateViewInput): Promise<ViewDefinition>;
4516
+ /**
4517
+ * Delete a custom view
4518
+ *
4519
+ * @param viewId - View ID
4520
+ */
4521
+ deleteView(viewId: string): Promise<void>;
4522
+ /**
4523
+ * Set a view as default for its object
4524
+ *
4525
+ * @param viewId - View ID
4526
+ * @param tenantId - Tenant ID
4527
+ * @returns Updated view
4528
+ */
4529
+ setDefaultView(viewId: string, tenantId: string): Promise<ViewDefinition>;
4530
+ /**
4531
+ * Validate view name format (kebab-case)
4532
+ */
4533
+ private validateViewName;
4534
+ /**
4535
+ * Convert database view to ViewDefinition
4536
+ */
4537
+ private convertDBViewToDefinition;
4538
+ }
4539
+
4540
+ /**
4541
+ * Result of view sync operation
4542
+ */
4543
+ interface ViewSyncResult {
4544
+ success: boolean;
4545
+ viewsSynced: number;
4546
+ viewsCreated: number;
4547
+ viewsUpdated: number;
4548
+ viewsDeleted: number;
4549
+ errors: Array<{
4550
+ viewName: string;
4551
+ objectName: string;
4552
+ error: string;
4553
+ }>;
4554
+ }
4555
+ /**
4556
+ * Options for view sync
4557
+ */
4558
+ interface ViewSyncOptions {
4559
+ dryRun?: boolean;
4560
+ verbose?: boolean;
4561
+ tenantId?: string;
4562
+ }
4563
+ /**
4564
+ * Sync native views from registry to database
4565
+ *
4566
+ * This function:
4567
+ * 1. Reads all registered native views from the registry
4568
+ * 2. Upserts them into the database (views table)
4569
+ * 3. Marks them as system=true for protection
4570
+ * 4. Removes views that were deleted from code
4571
+ *
4572
+ * @param adapter - Database adapter implementing DatabaseAdapter interface
4573
+ * @param nativeViewRegistry - Registry containing native views
4574
+ * @param options - Sync options (dryRun, verbose, tenantId)
4575
+ * @returns Sync result with statistics
4576
+ *
4577
+ * @example
4578
+ * ```typescript
4579
+ * import { syncNativeViews, viewRegistry } from "@stndrds/schema";
4580
+ * import { drizzleAdapter } from "./db/adapter";
4581
+ *
4582
+ * const result = await syncNativeViews(drizzleAdapter, viewRegistry, {
4583
+ * verbose: true,
4584
+ * tenantId: "default"
4585
+ * });
4586
+ *
4587
+ * if (result.success) {
4588
+ * console.log(`✓ Synced ${result.viewsSynced} views`);
4589
+ * }
4590
+ * ```
4591
+ */
4592
+ declare function syncNativeViews(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry, options?: ViewSyncOptions): Promise<ViewSyncResult>;
4593
+ /**
4594
+ * Verify that all native views are synced to database
4595
+ *
4596
+ * @param adapter - Database adapter
4597
+ * @param nativeViewRegistry - Registry containing native views
4598
+ * @returns true if all views are synced, false otherwise
4599
+ *
4600
+ * @example
4601
+ * ```typescript
4602
+ * const isSynced = await verifyNativeViewsSync(adapter, viewRegistry);
4603
+ * if (!isSynced) {
4604
+ * console.warn("Native views not synced, running sync...");
4605
+ * await syncNativeViews(adapter, viewRegistry);
4606
+ * }
4607
+ * ```
4608
+ */
4609
+ declare function verifyNativeViewsSync(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry): Promise<boolean>;
4610
+ /**
4611
+ * Get sync preview without modifying database
4612
+ *
4613
+ * @param adapter - Database adapter
4614
+ * @param nativeViewRegistry - Registry containing native views
4615
+ * @returns Sync result (dry run)
4616
+ */
4617
+ declare function getViewSyncPreview(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry): Promise<ViewSyncResult>;
4618
+
4619
+ /**
4620
+ * Result of sync operation
4621
+ */
4622
+ interface SyncResult {
4623
+ success: boolean;
4624
+ objectsSynced: number;
4625
+ attributesSynced: number;
4626
+ objectsCreated: number;
4627
+ objectsUpdated: number;
4628
+ attributesCreated: number;
4629
+ attributesUpdated: number;
4630
+ attributesDeleted: number;
4631
+ errors: Array<{
4632
+ objectName: string;
4633
+ error: string;
4634
+ }>;
4635
+ }
4636
+ /**
4637
+ * Sync options
4638
+ */
4639
+ interface SyncOptions {
4640
+ dryRun?: boolean;
4641
+ verbose?: boolean;
4642
+ tenantId?: string;
4643
+ }
4644
+ /**
4645
+ * Sync native objects from registry to database
4646
+ *
4647
+ * This function:
4648
+ * 1. Reads all registered native objects from the registry
4649
+ * 2. Upserts them into the database (objects + attributes tables)
4650
+ * 3. Marks them as system=true for protection
4651
+ * 4. Removes attributes that were deleted from code
4652
+ *
4653
+ * @param adapter - Database adapter implementing DatabaseAdapter interface
4654
+ * @param nativeRegistry - Registry containing native objects
4655
+ * @param options - Sync options (dryRun, verbose, tenantId)
4656
+ * @returns Sync result with statistics
4657
+ *
4658
+ * @example
4659
+ * ```typescript
4660
+ * import { syncNativeObjects } from "@stndrds/schema/runtime";
4661
+ * import { registry } from "./objects/native";
4662
+ * import { drizzleAdapter } from "./db/adapter";
4663
+ *
4664
+ * const result = await syncNativeObjects(drizzleAdapter, registry, {
4665
+ * verbose: true,
4666
+ * tenantId: "default"
4667
+ * });
4668
+ *
4669
+ * if (result.success) {
4670
+ * console.log(`✓ Synced ${result.objectsSynced} objects`);
4671
+ * } else {
4672
+ * console.error("Sync errors:", result.errors);
4673
+ * }
4674
+ * ```
4675
+ */
4676
+ declare function syncNativeObjects(adapter: DatabaseAdapter, nativeRegistry: typeof registry, options?: SyncOptions): Promise<SyncResult>;
4677
+ /**
4678
+ * Verify that all native objects are synced to database
4679
+ *
4680
+ * @param adapter - Database adapter
4681
+ * @param nativeRegistry - Registry containing native objects
4682
+ * @returns true if all objects are synced, false otherwise
4683
+ *
4684
+ * @example
4685
+ * ```typescript
4686
+ * const isSynced = await verifyNativeObjectsSync(adapter, registry);
4687
+ * if (!isSynced) {
4688
+ * console.warn("Native objects not synced, running sync...");
4689
+ * await syncNativeObjects(adapter, registry);
4690
+ * }
4691
+ * ```
4692
+ */
4693
+ declare function verifyNativeObjectsSync(adapter: DatabaseAdapter, nativeRegistry: typeof registry): Promise<boolean>;
4694
+ /**
4695
+ * Get sync statistics without modifying database
4696
+ *
4697
+ * @param adapter - Database adapter
4698
+ * @param nativeRegistry - Registry containing native objects
4699
+ * @returns Sync result (dry run)
4700
+ */
4701
+ declare function getSyncPreview(adapter: DatabaseAdapter, nativeRegistry: typeof registry): Promise<SyncResult>;
4702
+ /**
4703
+ * Result of full sync operation (objects + views)
4704
+ */
4705
+ interface FullSyncResult {
4706
+ success: boolean;
4707
+ objects: SyncResult;
4708
+ views: ViewSyncResult;
4709
+ }
4710
+ /**
4711
+ * Options for full sync
4712
+ */
4713
+ interface FullSyncOptions extends SyncOptions, ViewSyncOptions {
4714
+ }
4715
+ /**
4716
+ * Sync all native objects and views from registries to database
4717
+ *
4718
+ * This is a convenience function that:
4719
+ * 1. Syncs native objects first (views may depend on objects)
4720
+ * 2. Syncs native views
4721
+ *
4722
+ * @param adapter - Database adapter
4723
+ * @param objectRegistry - Registry containing native objects
4724
+ * @param nativeViewRegistry - Registry containing native views
4725
+ * @param options - Sync options
4726
+ * @returns Combined sync result
4727
+ *
4728
+ * @example
4729
+ * ```typescript
4730
+ * import { syncAll, registry, viewRegistry } from "@stndrds/schema";
4731
+ * import { adapter } from "./db";
4732
+ *
4733
+ * const result = await syncAll(adapter, registry, viewRegistry, {
4734
+ * verbose: true,
4735
+ * tenantId: "default"
4736
+ * });
4737
+ *
4738
+ * if (result.success) {
4739
+ * console.log(`✓ Synced ${result.objects.objectsSynced} objects, ${result.views.viewsSynced} views`);
4740
+ * }
4741
+ * ```
4742
+ */
4743
+ declare function syncAll(adapter: DatabaseAdapter, objectRegistry: typeof registry, nativeViewRegistry: typeof viewRegistry, options?: FullSyncOptions): Promise<FullSyncResult>;
4744
+
4745
+ /**
4746
+ * Default fallback value when expression resolves to empty string
4747
+ */
4748
+ declare const DEFAULT_LABEL_FALLBACK = "(Untitled)";
4749
+ /**
4750
+ * Render a label expression template with values
4751
+ *
4752
+ * Supports:
4753
+ * - Variable interpolation: `{{ fieldName }}`
4754
+ * - Dot notation: `{{ user.firstName }}`
4755
+ * - Pipes: `{{ name | UPPER }}`, `{{ name | capitalize | trim }}`
4756
+ *
4757
+ * @param template - The label expression template (e.g., "{{ firstName }} {{ lastName }}")
4758
+ * @param values - Record values to interpolate
4759
+ * @param fallback - Fallback value if result is empty (default: "(Untitled)")
4760
+ * @returns The rendered label string
4761
+ *
4762
+ * @example
4763
+ * ```typescript
4764
+ * const label = renderLabelExpression(
4765
+ * "{{ firstName }} {{ lastName | UPPER }}",
4766
+ * { firstName: "John", lastName: "Doe" }
4767
+ * );
4768
+ * // → "John DOE"
4769
+ *
4770
+ * // With missing values
4771
+ * const label = renderLabelExpression(
4772
+ * "{{ name }}",
4773
+ * { }
4774
+ * );
4775
+ * // → "(Untitled)"
4776
+ * ```
4777
+ */
4778
+ declare function renderLabelExpression(template: string, values: Record<string, unknown>, fallback?: string): string;
4779
+ /**
4780
+ * Check if a string is a valid label expression template
4781
+ * A valid template contains at least one {{ variable }} block with a non-empty variable
4782
+ */
4783
+ declare function isLabelExpression(value: string): boolean;
4784
+ /**
4785
+ * Extract attribute names referenced in a label expression
4786
+ * Useful for validation or dependency tracking
4787
+ *
4788
+ * @example
4789
+ * extractAttributeNames("{{ firstName }} {{ lastName | UPPER }}")
4790
+ * // → ["firstName", "lastName"]
4791
+ */
4792
+ declare function extractAttributeNames(template: string): string[];
4793
+
4794
+ export { type MultiselectFilterOperator as $, type Attribute as A, type BaseAttribute as B, type Currency as C, type DateAttribute as D, type RelationAttribute as E, type FileAttribute as F, type Group as G, type StorageProvider as H, type FileVisibility as I, type File as J, type CreateFile as K, type Location as L, type MultiselectAttribute as M, type NumberAttribute as N, type Option as O, type Phone as P, type UpdateFile as Q, type RelationOnDelete as R, type StatusAttribute as S, type TextAttribute as T, type UserAttribute as U, type ViewDefinition as V, type TextFilterOperator as W, type NumberFilterOperator as X, type CheckboxFilterOperator as Y, type DateFilterOperator as Z, type SelectFilterOperator as _, type SelectAttribute as a, checkboxConfigSchema as a$, type RelationFilterOperator as a0, type FilterOperator as a1, type RelativeDateValue as a2, type CurrencyFilterValue as a3, type PhoneFilterValue as a4, type FilterValue as a5, type FilterRule as a6, type FilterCombinator as a7, type FilterState as a8, type FilterGroup as a9, type EffectivePermissions as aA, type ObjectPermissions as aB, type CreateRoleInput as aC, type UpdateRoleInput as aD, type CreatePermissionInput as aE, type AssignRoleInput as aF, type UserRole as aG, type UserStatus as aH, type UserProfile as aI, type CreateUserProfile as aJ, type UpdateUserProfile as aK, type TabType as aL, type FormTab as aM, type TableTab as aN, type CustomTab as aO, isFormTab as aP, isTableTab as aQ, isCustomTab as aR, type Uuid as aS, type TenantId as aT, generateId as aU, generatePrefixedId as aV, registry as aW, viewRegistry as aX, textConfigSchema as aY, textareaConfigSchema as aZ, numberConfigSchema as a_, type AdvancedFilterState as aa, isAdvancedFilterState as ab, toAdvancedFilterState as ac, toSimpleFilterState as ad, type SortDirection as ae, type SortRule as af, type QueryState as ag, OPERATORS_BY_TYPE as ah, type NoValueOperator as ai, NO_VALUE_OPERATORS as aj, isNoValueOperator as ak, type GeocodingSuggestion as al, type GeocodingAutocompleteParams as am, type ReverseGeocodingParams as an, type GeocodingParams as ao, type GeocodingAdapter as ap, NoopGeocodingAdapter as aq, type Timestamps as ar, type ObjectAttribute as as, type CompletionStatus as at, type ObjectRecord as au, type PermissionScope as av, type ObjectAction as aw, type Role as ax, type Permission as ay, type UserRoleAssignment as az, type TextAreaAttribute as b, GeocodingService as b$, dateConfigSchema as b0, phoneConfigSchema as b1, currencyConfigSchema as b2, statusConfigSchema as b3, locationConfigSchema as b4, timestampConfigSchema as b5, selectConfigSchema as b6, multiselectConfigSchema as b7, fileConfigSchema as b8, userConfigSchema as b9, type ValidationResult as bA, validateAttribute as bB, validateObject as bC, validateObjectOrThrow as bD, createDraftValidator as bE, validateDraft as bF, validateDraftOrThrow as bG, getMissingRequiredAttributes as bH, isRecordComplete as bI, computeRecordStatus as bJ, type DatabaseAdapter as bK, type AttributeChange as bL, type HookContext as bM, type HookDefinition as bN, type HookHandler as bO, type HookType as bP, NoopHookRegistry as bQ, type HookRegistry as bR, createMockAdapter as bS, type ObjectsRepository as bT, type AttributesRepository as bU, type UserProfilesRepository as bV, type FilesRepository as bW, type ObjectRecordsRepository as bX, type ViewsRepository as bY, type PermissionsRepository as bZ, FileService as b_, relationConfigSchema as ba, ratingConfigSchema as bb, attributeConfigSchemas as bc, getAttributeConfigSchema as bd, validateAttributeConfig as be, parseAttributeConfig as bf, safeParseAttributeConfig as bg, createTextValidator as bh, createNumberValidator as bi, createCheckboxValidator as bj, createDateValidator as bk, createPhoneValidator as bl, createCurrencyValidator as bm, createStatusValidator as bn, createSelectValidator as bo, createMultiselectValidator as bp, createLocationValidator as bq, createTimestampValidator as br, createFileValidator as bs, createUserValidator as bt, createSingleRelationValidator as bu, createMultiRelationValidator as bv, createRelationValidator as bw, createRatingValidator as bx, createAttributeValidator as by, createObjectValidator as bz, type CheckboxAttribute as c, GlobalSearchService as c0, type CreateCustomObjectInput as c1, type AddAttributeInput as c2, type UpdateObjectInput as c3, ObjectSchemaService as c4, type PermissionServiceOptions as c5, PermissionService as c6, type RecordServiceOptions as c7, RecordService as c8, type RelationValidationResult as c9, type CreateDBAttribute as cA, type UpdateDBAttribute as cB, type UpsertDBAttribute as cC, type CreateObjectRecord as cD, type ListOptions as cE, type SearchOptions as cF, type GlobalSearchOptions as cG, type GlobalSearchResultItem as cH, type FileListOptions as cI, type DBView as cJ, type CreateDBView as cK, type UpdateDBView as cL, type UpsertDBView as cM, type OperationResult as cN, type ViewSyncResult as cO, type ViewSyncOptions as cP, syncNativeViews as cQ, verifyNativeViewsSync as cR, getViewSyncPreview as cS, type RelationValidationError as ca, type RelationOption as cb, type RelationOptionsResponse as cc, type GetRelationOptionsParams as cd, RelationService as ce, UserProfileService as cf, type CreateViewInput as cg, type UpdateViewInput as ch, ViewService as ci, type SyncResult as cj, type SyncOptions as ck, syncNativeObjects as cl, verifyNativeObjectsSync as cm, getSyncPreview as cn, type FullSyncResult as co, type FullSyncOptions as cp, syncAll as cq, DEFAULT_LABEL_FALLBACK as cr, renderLabelExpression as cs, isLabelExpression as ct, extractAttributeNames as cu, type DBObject as cv, type CreateDBObject as cw, type UpdateDBObject as cx, type UpsertDBObject as cy, type DBAttribute as cz, type PhoneAttribute as d, type CurrencyAttribute as e, type LocationAttribute as f, type TimestampAttribute as g, type SingleRelationAttribute as h, type MultiRelationAttribute as i, type RelationTarget as j, type RatingAttribute as k, type ObjectDefinition as l, type Field as m, type AttributeGroupField as n, type Tab as o, type AttributeType as p, type StatusGroup as q, type AttributeGroup as r, type NumberUnit as s, type DateFormat as t, type DateValue as u, type LocationGranularity as v, type DocumentType as w, type DocumentFace as x, type DocumentTypeConfig as y, type FileVerificationConfig as z };