@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,4718 @@
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
+ * isSystem: 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
+ */
820
+ isSystem: boolean;
821
+ }
822
+ /**
823
+ * Permission definition - Grants specific actions on a target.
824
+ *
825
+ * A permission belongs to a role and defines what actions are allowed
826
+ * on a specific target (object, attribute, or record filter).
827
+ *
828
+ * @example
829
+ * ```typescript
830
+ * // Allow read and update on companies object
831
+ * const permission: Permission = {
832
+ * id: "perm-123",
833
+ * roleId: "role-456",
834
+ * scope: "object",
835
+ * target: "companies",
836
+ * actions: ["read", "update"],
837
+ * createdAt: new Date(),
838
+ * };
839
+ *
840
+ * // Wildcard permission for all objects
841
+ * const wildcardPerm: Permission = {
842
+ * id: "perm-789",
843
+ * roleId: "role-456",
844
+ * scope: "object",
845
+ * target: "*",
846
+ * actions: ["read", "create", "update", "delete"],
847
+ * createdAt: new Date(),
848
+ * };
849
+ * ```
850
+ */
851
+ interface Permission {
852
+ id: Uuid;
853
+ roleId: Uuid;
854
+ /**
855
+ * Scope of this permission.
856
+ */
857
+ scope: PermissionScope;
858
+ /**
859
+ * Target of the permission.
860
+ * - For `object` scope: object name (e.g., "companies") or "*" for all
861
+ * - For `attribute` scope: "objectName.attributeName"
862
+ * - For `record` scope: object name (filter is in `filter` field)
863
+ */
864
+ target: string;
865
+ /**
866
+ * Actions allowed on the target.
867
+ */
868
+ actions: ObjectAction[];
869
+ /**
870
+ * JSON filter for record-level permissions (Phase 3).
871
+ * Supports template variables like `{{ currentUser.id }}`.
872
+ */
873
+ filter?: Record<string, unknown>;
874
+ createdAt: Date;
875
+ }
876
+ /**
877
+ * Links a user to a role within a tenant.
878
+ *
879
+ * A user can have multiple roles, and their permissions are additive (union).
880
+ */
881
+ interface UserRoleAssignment {
882
+ id: Uuid;
883
+ userId: Uuid;
884
+ roleId: Uuid;
885
+ tenantId: Uuid;
886
+ /**
887
+ * When the role was assigned.
888
+ */
889
+ assignedAt: Date;
890
+ /**
891
+ * User who assigned this role (for audit trail).
892
+ */
893
+ assignedBy?: Uuid;
894
+ }
895
+ /**
896
+ * Computed permissions for a user.
897
+ *
898
+ * This is the merged result of all roles assigned to a user.
899
+ * Returned by the API for permission checks.
900
+ */
901
+ interface EffectivePermissions {
902
+ /**
903
+ * If true, the user has full admin access and bypasses all permission checks.
904
+ */
905
+ isAdmin: boolean;
906
+ /**
907
+ * Object-level permissions.
908
+ * Key is the object name, value is array of allowed actions.
909
+ * Special key "*" means permission applies to all objects.
910
+ */
911
+ objectPermissions: Record<string, ObjectAction[]>;
912
+ }
913
+ /**
914
+ * Permissions for a specific object.
915
+ * Convenience type for frontend use.
916
+ */
917
+ interface ObjectPermissions {
918
+ canRead: boolean;
919
+ canCreate: boolean;
920
+ canUpdate: boolean;
921
+ canDelete: boolean;
922
+ }
923
+ /**
924
+ * Input for creating a new role.
925
+ */
926
+ interface CreateRoleInput {
927
+ tenantId: Uuid;
928
+ name: string;
929
+ label: string;
930
+ description?: string;
931
+ }
932
+ /**
933
+ * Input for updating an existing role.
934
+ */
935
+ interface UpdateRoleInput {
936
+ label?: string;
937
+ description?: string;
938
+ }
939
+ /**
940
+ * Input for creating a permission.
941
+ */
942
+ interface CreatePermissionInput {
943
+ scope: PermissionScope;
944
+ target: string;
945
+ actions: ObjectAction[];
946
+ filter?: Record<string, unknown>;
947
+ }
948
+ /**
949
+ * Input for assigning a role to a user.
950
+ */
951
+ interface AssignRoleInput {
952
+ userId: Uuid;
953
+ roleId: Uuid;
954
+ tenantId: Uuid;
955
+ assignedBy?: Uuid;
956
+ }
957
+
958
+ /**
959
+ * User role in the application
960
+ * Can be extended with custom roles as needed
961
+ */
962
+ type UserRole = "admin" | "member" | "guest" | string;
963
+ /**
964
+ * User status for account management
965
+ */
966
+ type UserStatus = "active" | "pending" | "inactive" | "suspended";
967
+ /**
968
+ * User Profile - Represents application user data (authorization)
969
+ *
970
+ * ARCHITECTURE:
971
+ * - authId links to external auth provider (Supabase, Clerk, Auth0, etc.)
972
+ * - email is denormalized from auth provider for performance
973
+ * - Auth provider handles authentication (passwords, sessions, OAuth)
974
+ * - This type handles authorization (roles, permissions, tenant membership)
975
+ *
976
+ * @example
977
+ * ```typescript
978
+ * const profile: UserProfile = {
979
+ * id: "profile-123",
980
+ * tenantId: "tenant-456",
981
+ * authId: "supabase-auth-uuid-789",
982
+ * email: "john@example.com",
983
+ * firstName: "John",
984
+ * lastName: "Doe",
985
+ * role: "admin",
986
+ * status: "active",
987
+ * createdAt: new Date(),
988
+ * updatedAt: new Date(),
989
+ * };
990
+ * ```
991
+ */
992
+ interface UserProfile extends Timestamps {
993
+ id: Uuid;
994
+ tenantId: Uuid;
995
+ /**
996
+ * Link to external auth provider (Supabase auth.users.id, Clerk user ID, etc.)
997
+ * This is the bridge between authentication (provider) and authorization (your app)
998
+ */
999
+ authId: string;
1000
+ /**
1001
+ * Email address (denormalized from auth provider)
1002
+ * Allows efficient querying and filtering without hitting auth provider API
1003
+ */
1004
+ email: string;
1005
+ /**
1006
+ * User's first name
1007
+ */
1008
+ firstName?: string;
1009
+ /**
1010
+ * User's last name
1011
+ */
1012
+ lastName?: string;
1013
+ /**
1014
+ * Avatar/profile picture URL
1015
+ */
1016
+ avatarUrl?: string;
1017
+ /**
1018
+ * User role for authorization
1019
+ * Common values: "admin", "member", "guest"
1020
+ * Can be extended with custom roles
1021
+ */
1022
+ role: UserRole;
1023
+ /**
1024
+ * Account status
1025
+ * - active: Normal user, full access
1026
+ * - pending: Awaiting activation/approval
1027
+ * - inactive: Deactivated account
1028
+ * - suspended: Temporarily blocked
1029
+ */
1030
+ status: UserStatus;
1031
+ /**
1032
+ * Last login timestamp (updated on each successful auth)
1033
+ */
1034
+ lastLoginAt?: Date;
1035
+ }
1036
+ /**
1037
+ * Data required to create a new user profile
1038
+ */
1039
+ interface CreateUserProfile {
1040
+ tenantId: Uuid;
1041
+ authId: string;
1042
+ email: string;
1043
+ firstName?: string;
1044
+ lastName?: string;
1045
+ avatarUrl?: string;
1046
+ role?: UserRole;
1047
+ status?: UserStatus;
1048
+ }
1049
+ /**
1050
+ * Data for updating an existing user profile
1051
+ */
1052
+ interface UpdateUserProfile {
1053
+ firstName?: string;
1054
+ lastName?: string;
1055
+ avatarUrl?: string;
1056
+ role?: UserRole;
1057
+ status?: UserStatus;
1058
+ lastLoginAt?: Date;
1059
+ }
1060
+
1061
+ /**
1062
+ * Inline attribute group configuration
1063
+ * Groups multiple attributes into a single composite field with dropdown editing
1064
+ */
1065
+ interface AttributeGroupField {
1066
+ /** Unique identifier for the group */
1067
+ id: string;
1068
+ /** Display label for the composite field */
1069
+ label: string;
1070
+ /** Description shown in the dropdown */
1071
+ description?: string;
1072
+ /** Attribute names to include in this group */
1073
+ attributes: string[];
1074
+ /**
1075
+ * Template for the display value
1076
+ * Uses {attributeName} syntax for interpolation
1077
+ * @example "{billing_street}, {billing_city} {billing_postal_code}"
1078
+ */
1079
+ displayTemplate?: string;
1080
+ }
1081
+ /**
1082
+ * Field definition within a form group
1083
+ * Can be either a single attribute or an inline attribute group
1084
+ */
1085
+ interface Field {
1086
+ /** Attribute name to display (for single attribute fields) */
1087
+ attribute?: string;
1088
+ /** Inline attribute group (groups multiple attributes into one composite field) */
1089
+ attributeGroup?: AttributeGroupField;
1090
+ /** Grid span (1-12 columns) */
1091
+ span?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
1092
+ /** Override label for this view (only for single attribute fields) */
1093
+ label?: string;
1094
+ /** Force read-only display */
1095
+ readOnly?: boolean;
1096
+ }
1097
+ /**
1098
+ * Group of fields for organizing forms
1099
+ */
1100
+ interface Group {
1101
+ id: string;
1102
+ label: string;
1103
+ description?: string;
1104
+ fields: Field[];
1105
+ collapsible?: boolean;
1106
+ collapsed?: boolean;
1107
+ order?: number;
1108
+ }
1109
+ type TabType = "form" | "table" | "custom";
1110
+ /**
1111
+ * Base properties shared by all tab types
1112
+ */
1113
+ interface BaseTab {
1114
+ id: string;
1115
+ name: string;
1116
+ label: string;
1117
+ icon?: IconName;
1118
+ order?: number;
1119
+ /** If true, tab is defined by developer (protected) */
1120
+ system?: boolean;
1121
+ }
1122
+ /**
1123
+ * Form tab - displays attributes organized in groups
1124
+ */
1125
+ interface FormTab extends BaseTab {
1126
+ type: "form";
1127
+ groups: Group[];
1128
+ }
1129
+ /**
1130
+ * Table tab - displays records from a relation attribute
1131
+ */
1132
+ interface TableTab extends BaseTab {
1133
+ type: "table";
1134
+ /** Name of the relation attribute */
1135
+ relation: string;
1136
+ /** Columns to display (attribute names from target object) */
1137
+ columns: string[];
1138
+ /** Allow creating new records */
1139
+ allowCreate?: boolean;
1140
+ /** Allow inline editing */
1141
+ allowEdit?: boolean;
1142
+ /** Allow deleting records */
1143
+ allowDelete?: boolean;
1144
+ /** Default filters */
1145
+ filters?: Record<string, unknown>;
1146
+ /** Default sort */
1147
+ sort?: {
1148
+ field: string;
1149
+ order: "asc" | "desc";
1150
+ };
1151
+ }
1152
+ /**
1153
+ * Custom tab - renders a developer-defined component
1154
+ */
1155
+ interface CustomTab extends BaseTab {
1156
+ type: "custom";
1157
+ /** Component identifier to render */
1158
+ component: string;
1159
+ /** Props to pass to the component */
1160
+ props?: Record<string, unknown>;
1161
+ }
1162
+ /**
1163
+ * Union of all tab types
1164
+ */
1165
+ type Tab = FormTab | TableTab | CustomTab;
1166
+ /**
1167
+ * View definition - organizes object attributes into tabs/pages
1168
+ *
1169
+ * @example
1170
+ * ```typescript
1171
+ * const companyView: ViewDefinition = {
1172
+ * name: "detail",
1173
+ * label: "Company Detail",
1174
+ * object: "companies",
1175
+ * tabs: [
1176
+ * { type: "form", name: "general", label: "Info", groups: [...] },
1177
+ * { type: "table", name: "contacts", label: "Contacts", relation: "contacts", columns: [...] }
1178
+ * ],
1179
+ * default: true,
1180
+ * system: true
1181
+ * };
1182
+ * ```
1183
+ */
1184
+ interface ViewDefinition {
1185
+ id?: Uuid;
1186
+ /** Technical name (kebab-case) */
1187
+ name: string;
1188
+ /** Display label */
1189
+ label: string;
1190
+ /** Description */
1191
+ description?: string;
1192
+ /** Icon */
1193
+ icon?: IconName;
1194
+ /** Object this view belongs to (object name) */
1195
+ object: string;
1196
+ /** Tabs in this view */
1197
+ tabs: Tab[];
1198
+ /** Default view for this object */
1199
+ default?: boolean;
1200
+ /** System view (defined by developer, protected) */
1201
+ system?: boolean;
1202
+ /** Extensible metadata */
1203
+ metadata?: Record<string, unknown>;
1204
+ }
1205
+ /**
1206
+ * Check if a tab is a form tab
1207
+ */
1208
+ declare function isFormTab(tab: Tab): tab is FormTab;
1209
+ /**
1210
+ * Check if a tab is a table tab
1211
+ */
1212
+ declare function isTableTab(tab: Tab): tab is TableTab;
1213
+ /**
1214
+ * Check if a tab is a custom tab
1215
+ */
1216
+ declare function isCustomTab(tab: Tab): tab is CustomTab;
1217
+
1218
+ /**
1219
+ * Registry for native objects defined in code
1220
+ * Native objects are system objects that cannot be deleted/modified by clients
1221
+ * They are defined by developers and synced to the database at startup
1222
+ */
1223
+ declare class NativeObjectRegistryClass {
1224
+ private objects;
1225
+ /**
1226
+ * Register one or more native objects
1227
+ * Auto-builds if ObjectBuilder is passed instead of ObjectDefinition
1228
+ * @param objects - Single object/builder or array of objects/builders to register
1229
+ * @returns this (for chaining)
1230
+ * @throws Error if object is invalid or already registered
1231
+ *
1232
+ * @example
1233
+ * ```typescript
1234
+ * // No .build() needed - registry auto-builds!
1235
+ * const PRODUCT = object({ id: "obj-product", name: "products", label: "Product" })
1236
+ * .system()
1237
+ * .attribute(text({ id: "attr-name", name: "name", label: "Name" }));
1238
+ *
1239
+ * registry.register(PRODUCT); // ← Auto-builds here
1240
+ *
1241
+ * // Can still explicitly .build() if you want
1242
+ * registry.register(PRODUCT.build());
1243
+ *
1244
+ * // Register multiple
1245
+ * registry.register([PRODUCT, ORDER, CUSTOMER]);
1246
+ * ```
1247
+ */
1248
+ register(objects: ObjectDefinition | ObjectDefinition[] | {
1249
+ build: () => ObjectDefinition;
1250
+ } | Array<{
1251
+ build: () => ObjectDefinition;
1252
+ }>): this;
1253
+ /**
1254
+ * Validate and register a single object
1255
+ * @internal
1256
+ */
1257
+ private validateAndRegister;
1258
+ /**
1259
+ * Get a native object by its name
1260
+ * @param name - The object name
1261
+ * @returns The object definition or undefined if not found
1262
+ *
1263
+ * @example
1264
+ * ```typescript
1265
+ * const product = registry.getByName("products");
1266
+ * if (product) {
1267
+ * console.log(product.label); // "Product"
1268
+ * }
1269
+ * ```
1270
+ */
1271
+ getByName(name: string): ObjectDefinition | undefined;
1272
+ /**
1273
+ * Get a native object or throw if not found
1274
+ * @param name - The object name
1275
+ * @returns The object definition
1276
+ * @throws Error if not found
1277
+ */
1278
+ getByNameOrThrow(name: string): ObjectDefinition;
1279
+ /**
1280
+ * Get all registered native objects
1281
+ * @returns Array of all registered object definitions
1282
+ */
1283
+ getAll(): ObjectDefinition[];
1284
+ /**
1285
+ * Get all registered native object names
1286
+ * @returns Array of object names
1287
+ */
1288
+ listNames(): string[];
1289
+ /**
1290
+ * Check if a native object is registered
1291
+ * @param name - The object name
1292
+ * @returns true if registered, false otherwise
1293
+ */
1294
+ has(name: string): boolean;
1295
+ /**
1296
+ * Get the number of registered objects
1297
+ */
1298
+ get size(): number;
1299
+ /**
1300
+ * Clear all registered objects (useful for testing)
1301
+ * @internal
1302
+ */
1303
+ clear(): void;
1304
+ /**
1305
+ * Get registry summary for debugging
1306
+ */
1307
+ summary(): string;
1308
+ /**
1309
+ * Log registry summary to console
1310
+ */
1311
+ debug(): void;
1312
+ }
1313
+ /**
1314
+ * Singleton instance of the registry
1315
+ * Use this to register and retrieve native objects
1316
+ *
1317
+ * @example
1318
+ * ```typescript
1319
+ * import { registry } from "@stndrds/schema";
1320
+ *
1321
+ * // Register objects
1322
+ * registry.register([PRODUCT, ORDER, CUSTOMER]);
1323
+ *
1324
+ * // Get object by name
1325
+ * const product = registry.getByName("products");
1326
+ *
1327
+ * // List all
1328
+ * console.log(registry.listNames()); // ["products", "orders", ...]
1329
+ *
1330
+ * // Debug
1331
+ * registry.debug();
1332
+ * ```
1333
+ */
1334
+ declare const registry: NativeObjectRegistryClass;
1335
+
1336
+ /**
1337
+ * Registry for native view definitions
1338
+ *
1339
+ * Views registered here are considered "system" views, defined by the developer.
1340
+ * They are protected from modification by end-users and synced to the database
1341
+ * at application startup.
1342
+ *
1343
+ * @example
1344
+ * ```typescript
1345
+ * import { view, group, viewRegistry } from "@stndrds/schema";
1346
+ *
1347
+ * const COMPANY_DETAIL = view("detail", "Detail")
1348
+ * .for("companies")
1349
+ * .system()
1350
+ * .tab("general", "Info")
1351
+ * .form(group("main", "Main").fields("name", "status"))
1352
+ * .build();
1353
+ *
1354
+ * viewRegistry.register(COMPANY_DETAIL);
1355
+ * ```
1356
+ */
1357
+ declare class ViewRegistry {
1358
+ private views;
1359
+ private byObject;
1360
+ /**
1361
+ * Register a native view
1362
+ * @param viewOrViews - Single view or array of views
1363
+ * @throws Error if view is not marked as system
1364
+ * @throws Error if view with same name already exists for the object
1365
+ */
1366
+ register(viewOrViews: ViewDefinition | ViewDefinition[]): this;
1367
+ private registerSingle;
1368
+ /**
1369
+ * Get all views for an object
1370
+ */
1371
+ getByObjectName(objectName: string): ViewDefinition[];
1372
+ /**
1373
+ * Get a specific view by object and view name
1374
+ */
1375
+ get(objectName: string, viewName: string): ViewDefinition | undefined;
1376
+ /**
1377
+ * Get a view or throw if not found
1378
+ */
1379
+ getOrThrow(objectName: string, viewName: string): ViewDefinition;
1380
+ /**
1381
+ * Get all registered views
1382
+ */
1383
+ getAll(): ViewDefinition[];
1384
+ /**
1385
+ * Check if a view exists
1386
+ */
1387
+ has(objectName: string, viewName: string): boolean;
1388
+ /**
1389
+ * Check if any views exist for an object
1390
+ */
1391
+ hasObject(objectName: string): boolean;
1392
+ /**
1393
+ * Get number of registered views
1394
+ */
1395
+ get size(): number;
1396
+ /**
1397
+ * List all object names that have views
1398
+ */
1399
+ listObjectNames(): string[];
1400
+ /**
1401
+ * Get default view for an object (if any)
1402
+ */
1403
+ getDefault(objectName: string): ViewDefinition | undefined;
1404
+ /**
1405
+ * Clear all registered views (for testing)
1406
+ */
1407
+ clear(): void;
1408
+ /**
1409
+ * Generate summary string for debugging
1410
+ */
1411
+ summary(): string;
1412
+ /**
1413
+ * Log summary to console
1414
+ */
1415
+ debug(): void;
1416
+ private makeKey;
1417
+ }
1418
+ /**
1419
+ * Global registry for native views
1420
+ */
1421
+ declare const viewRegistry: ViewRegistry;
1422
+
1423
+ /**
1424
+ * Text attribute config schema
1425
+ */
1426
+ declare const textConfigSchema: z.ZodObject<{
1427
+ disabled: z.ZodOptional<z.ZodBoolean>;
1428
+ placeholder: z.ZodOptional<z.ZodString>;
1429
+ description: z.ZodOptional<z.ZodString>;
1430
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1431
+ icon: z.ZodOptional<z.ZodString>;
1432
+ order: z.ZodOptional<z.ZodNumber>;
1433
+ hidden: z.ZodOptional<z.ZodBoolean>;
1434
+ archived: z.ZodOptional<z.ZodBoolean>;
1435
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1436
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1437
+ } & {
1438
+ minLength: z.ZodOptional<z.ZodNumber>;
1439
+ maxLength: z.ZodOptional<z.ZodNumber>;
1440
+ pattern: z.ZodOptional<z.ZodString>;
1441
+ }, "strip", z.ZodTypeAny, {
1442
+ defaultValue?: unknown;
1443
+ disabled?: boolean | undefined;
1444
+ placeholder?: string | undefined;
1445
+ description?: string | undefined;
1446
+ icon?: string | undefined;
1447
+ order?: number | undefined;
1448
+ hidden?: boolean | undefined;
1449
+ archived?: boolean | undefined;
1450
+ deprecated?: boolean | undefined;
1451
+ metadata?: Record<string, unknown> | undefined;
1452
+ minLength?: number | undefined;
1453
+ maxLength?: number | undefined;
1454
+ pattern?: string | undefined;
1455
+ }, {
1456
+ defaultValue?: unknown;
1457
+ disabled?: boolean | undefined;
1458
+ placeholder?: string | undefined;
1459
+ description?: string | undefined;
1460
+ icon?: string | undefined;
1461
+ order?: number | undefined;
1462
+ hidden?: boolean | undefined;
1463
+ archived?: boolean | undefined;
1464
+ deprecated?: boolean | undefined;
1465
+ metadata?: Record<string, unknown> | undefined;
1466
+ minLength?: number | undefined;
1467
+ maxLength?: number | undefined;
1468
+ pattern?: string | undefined;
1469
+ }>;
1470
+ /**
1471
+ * Textarea attribute config schema
1472
+ */
1473
+ declare const textareaConfigSchema: z.ZodObject<{
1474
+ disabled: z.ZodOptional<z.ZodBoolean>;
1475
+ placeholder: z.ZodOptional<z.ZodString>;
1476
+ description: z.ZodOptional<z.ZodString>;
1477
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1478
+ icon: z.ZodOptional<z.ZodString>;
1479
+ order: z.ZodOptional<z.ZodNumber>;
1480
+ hidden: z.ZodOptional<z.ZodBoolean>;
1481
+ archived: z.ZodOptional<z.ZodBoolean>;
1482
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1483
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
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
+ }, {
1496
+ defaultValue?: unknown;
1497
+ disabled?: boolean | undefined;
1498
+ placeholder?: string | undefined;
1499
+ description?: string | undefined;
1500
+ icon?: string | undefined;
1501
+ order?: number | undefined;
1502
+ hidden?: boolean | undefined;
1503
+ archived?: boolean | undefined;
1504
+ deprecated?: boolean | undefined;
1505
+ metadata?: Record<string, unknown> | undefined;
1506
+ }>;
1507
+ /**
1508
+ * Number attribute config schema
1509
+ */
1510
+ declare const numberConfigSchema: z.ZodObject<{
1511
+ disabled: z.ZodOptional<z.ZodBoolean>;
1512
+ placeholder: z.ZodOptional<z.ZodString>;
1513
+ description: z.ZodOptional<z.ZodString>;
1514
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1515
+ icon: z.ZodOptional<z.ZodString>;
1516
+ order: z.ZodOptional<z.ZodNumber>;
1517
+ hidden: z.ZodOptional<z.ZodBoolean>;
1518
+ archived: z.ZodOptional<z.ZodBoolean>;
1519
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1520
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1521
+ } & {
1522
+ min: z.ZodOptional<z.ZodNumber>;
1523
+ max: z.ZodOptional<z.ZodNumber>;
1524
+ unit: z.ZodOptional<z.ZodEnum<["integer", "decimal", "percentage"]>>;
1525
+ decimals: z.ZodOptional<z.ZodNumber>;
1526
+ }, "strip", z.ZodTypeAny, {
1527
+ defaultValue?: unknown;
1528
+ disabled?: boolean | undefined;
1529
+ placeholder?: string | undefined;
1530
+ description?: string | undefined;
1531
+ icon?: string | undefined;
1532
+ order?: number | undefined;
1533
+ hidden?: boolean | undefined;
1534
+ archived?: boolean | undefined;
1535
+ deprecated?: boolean | undefined;
1536
+ metadata?: Record<string, unknown> | undefined;
1537
+ min?: number | undefined;
1538
+ max?: number | undefined;
1539
+ unit?: "percentage" | "integer" | "decimal" | undefined;
1540
+ decimals?: number | undefined;
1541
+ }, {
1542
+ defaultValue?: unknown;
1543
+ disabled?: boolean | undefined;
1544
+ placeholder?: string | undefined;
1545
+ description?: string | undefined;
1546
+ icon?: string | undefined;
1547
+ order?: number | undefined;
1548
+ hidden?: boolean | undefined;
1549
+ archived?: boolean | undefined;
1550
+ deprecated?: boolean | undefined;
1551
+ metadata?: Record<string, unknown> | undefined;
1552
+ min?: number | undefined;
1553
+ max?: number | undefined;
1554
+ unit?: "percentage" | "integer" | "decimal" | undefined;
1555
+ decimals?: number | undefined;
1556
+ }>;
1557
+ /**
1558
+ * Checkbox attribute config schema
1559
+ */
1560
+ declare const checkboxConfigSchema: z.ZodObject<{
1561
+ disabled: z.ZodOptional<z.ZodBoolean>;
1562
+ placeholder: z.ZodOptional<z.ZodString>;
1563
+ description: z.ZodOptional<z.ZodString>;
1564
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1565
+ icon: z.ZodOptional<z.ZodString>;
1566
+ order: z.ZodOptional<z.ZodNumber>;
1567
+ hidden: z.ZodOptional<z.ZodBoolean>;
1568
+ archived: z.ZodOptional<z.ZodBoolean>;
1569
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1570
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1571
+ }, "strip", z.ZodTypeAny, {
1572
+ defaultValue?: unknown;
1573
+ disabled?: boolean | undefined;
1574
+ placeholder?: string | undefined;
1575
+ description?: string | undefined;
1576
+ icon?: string | undefined;
1577
+ order?: number | undefined;
1578
+ hidden?: boolean | undefined;
1579
+ archived?: boolean | undefined;
1580
+ deprecated?: boolean | undefined;
1581
+ metadata?: Record<string, unknown> | undefined;
1582
+ }, {
1583
+ defaultValue?: unknown;
1584
+ disabled?: boolean | undefined;
1585
+ placeholder?: string | undefined;
1586
+ description?: string | undefined;
1587
+ icon?: string | undefined;
1588
+ order?: number | undefined;
1589
+ hidden?: boolean | undefined;
1590
+ archived?: boolean | undefined;
1591
+ deprecated?: boolean | undefined;
1592
+ metadata?: Record<string, unknown> | undefined;
1593
+ }>;
1594
+ /**
1595
+ * Date attribute config schema
1596
+ */
1597
+ declare const dateConfigSchema: z.ZodObject<{
1598
+ disabled: z.ZodOptional<z.ZodBoolean>;
1599
+ placeholder: z.ZodOptional<z.ZodString>;
1600
+ description: z.ZodOptional<z.ZodString>;
1601
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1602
+ icon: z.ZodOptional<z.ZodString>;
1603
+ order: z.ZodOptional<z.ZodNumber>;
1604
+ hidden: z.ZodOptional<z.ZodBoolean>;
1605
+ archived: z.ZodOptional<z.ZodBoolean>;
1606
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1607
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1608
+ } & {
1609
+ dateFormat: z.ZodOptional<z.ZodEnum<["short", "long", "full", "relative"]>>;
1610
+ minDate: z.ZodOptional<z.ZodString>;
1611
+ maxDate: z.ZodOptional<z.ZodString>;
1612
+ }, "strip", z.ZodTypeAny, {
1613
+ defaultValue?: unknown;
1614
+ disabled?: boolean | undefined;
1615
+ placeholder?: string | undefined;
1616
+ description?: string | undefined;
1617
+ icon?: string | undefined;
1618
+ order?: number | undefined;
1619
+ hidden?: boolean | undefined;
1620
+ archived?: boolean | undefined;
1621
+ deprecated?: boolean | undefined;
1622
+ metadata?: Record<string, unknown> | undefined;
1623
+ dateFormat?: "short" | "long" | "full" | "relative" | undefined;
1624
+ minDate?: string | undefined;
1625
+ maxDate?: string | undefined;
1626
+ }, {
1627
+ defaultValue?: unknown;
1628
+ disabled?: boolean | undefined;
1629
+ placeholder?: string | undefined;
1630
+ description?: string | undefined;
1631
+ icon?: string | undefined;
1632
+ order?: number | undefined;
1633
+ hidden?: boolean | undefined;
1634
+ archived?: boolean | undefined;
1635
+ deprecated?: boolean | undefined;
1636
+ metadata?: Record<string, unknown> | undefined;
1637
+ dateFormat?: "short" | "long" | "full" | "relative" | undefined;
1638
+ minDate?: string | undefined;
1639
+ maxDate?: string | undefined;
1640
+ }>;
1641
+ /**
1642
+ * Phone attribute config schema
1643
+ */
1644
+ declare const phoneConfigSchema: z.ZodObject<{
1645
+ disabled: z.ZodOptional<z.ZodBoolean>;
1646
+ placeholder: z.ZodOptional<z.ZodString>;
1647
+ description: z.ZodOptional<z.ZodString>;
1648
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1649
+ icon: z.ZodOptional<z.ZodString>;
1650
+ order: z.ZodOptional<z.ZodNumber>;
1651
+ hidden: z.ZodOptional<z.ZodBoolean>;
1652
+ archived: z.ZodOptional<z.ZodBoolean>;
1653
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1654
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1655
+ } & {
1656
+ defaultCountryCode: z.ZodOptional<z.ZodString>;
1657
+ }, "strip", z.ZodTypeAny, {
1658
+ defaultValue?: unknown;
1659
+ disabled?: boolean | undefined;
1660
+ placeholder?: string | undefined;
1661
+ description?: string | undefined;
1662
+ icon?: string | undefined;
1663
+ order?: number | undefined;
1664
+ hidden?: boolean | undefined;
1665
+ archived?: boolean | undefined;
1666
+ deprecated?: boolean | undefined;
1667
+ metadata?: Record<string, unknown> | undefined;
1668
+ defaultCountryCode?: 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
+ defaultCountryCode?: string | undefined;
1681
+ }>;
1682
+ /**
1683
+ * Currency attribute config schema
1684
+ */
1685
+ declare const currencyConfigSchema: z.ZodObject<{
1686
+ disabled: z.ZodOptional<z.ZodBoolean>;
1687
+ placeholder: z.ZodOptional<z.ZodString>;
1688
+ description: z.ZodOptional<z.ZodString>;
1689
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1690
+ icon: z.ZodOptional<z.ZodString>;
1691
+ order: z.ZodOptional<z.ZodNumber>;
1692
+ hidden: z.ZodOptional<z.ZodBoolean>;
1693
+ archived: z.ZodOptional<z.ZodBoolean>;
1694
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1695
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1696
+ } & {
1697
+ defaultCurrency: z.ZodOptional<z.ZodString>;
1698
+ allowedCurrencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1699
+ }, "strip", z.ZodTypeAny, {
1700
+ defaultValue?: unknown;
1701
+ disabled?: boolean | undefined;
1702
+ placeholder?: string | undefined;
1703
+ description?: string | undefined;
1704
+ icon?: string | undefined;
1705
+ order?: number | undefined;
1706
+ hidden?: boolean | undefined;
1707
+ archived?: boolean | undefined;
1708
+ deprecated?: boolean | undefined;
1709
+ metadata?: Record<string, unknown> | undefined;
1710
+ defaultCurrency?: string | undefined;
1711
+ allowedCurrencies?: 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
+ defaultCurrency?: string | undefined;
1724
+ allowedCurrencies?: string[] | undefined;
1725
+ }>;
1726
+ /**
1727
+ * Status attribute config schema
1728
+ */
1729
+ declare const statusConfigSchema: z.ZodObject<{
1730
+ disabled: z.ZodOptional<z.ZodBoolean>;
1731
+ placeholder: z.ZodOptional<z.ZodString>;
1732
+ description: z.ZodOptional<z.ZodString>;
1733
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1734
+ icon: z.ZodOptional<z.ZodString>;
1735
+ order: z.ZodOptional<z.ZodNumber>;
1736
+ hidden: z.ZodOptional<z.ZodBoolean>;
1737
+ archived: z.ZodOptional<z.ZodBoolean>;
1738
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1739
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1740
+ } & {
1741
+ options: z.ZodArray<z.ZodObject<{
1742
+ id: z.ZodString;
1743
+ label: z.ZodString;
1744
+ value: z.ZodString;
1745
+ color: z.ZodOptional<z.ZodString>;
1746
+ icon: z.ZodOptional<z.ZodString>;
1747
+ description: z.ZodOptional<z.ZodString>;
1748
+ group: z.ZodOptional<z.ZodEnum<["idle", "in_progress", "finished"]>>;
1749
+ }, "strip", z.ZodTypeAny, {
1750
+ label: string;
1751
+ id: string;
1752
+ value: string;
1753
+ description?: string | undefined;
1754
+ icon?: string | undefined;
1755
+ color?: string | undefined;
1756
+ group?: "idle" | "in_progress" | "finished" | undefined;
1757
+ }, {
1758
+ label: string;
1759
+ id: string;
1760
+ value: string;
1761
+ description?: string | undefined;
1762
+ icon?: string | undefined;
1763
+ color?: string | undefined;
1764
+ group?: "idle" | "in_progress" | "finished" | undefined;
1765
+ }>, "many">;
1766
+ }, "strip", z.ZodTypeAny, {
1767
+ options: {
1768
+ label: string;
1769
+ id: string;
1770
+ value: string;
1771
+ description?: string | undefined;
1772
+ icon?: string | undefined;
1773
+ color?: string | undefined;
1774
+ group?: "idle" | "in_progress" | "finished" | undefined;
1775
+ }[];
1776
+ defaultValue?: unknown;
1777
+ disabled?: boolean | undefined;
1778
+ placeholder?: string | undefined;
1779
+ description?: string | undefined;
1780
+ icon?: string | undefined;
1781
+ order?: number | undefined;
1782
+ hidden?: boolean | undefined;
1783
+ archived?: boolean | undefined;
1784
+ deprecated?: boolean | undefined;
1785
+ metadata?: Record<string, unknown> | undefined;
1786
+ }, {
1787
+ options: {
1788
+ label: string;
1789
+ id: string;
1790
+ value: string;
1791
+ description?: string | undefined;
1792
+ icon?: string | undefined;
1793
+ color?: string | undefined;
1794
+ group?: "idle" | "in_progress" | "finished" | undefined;
1795
+ }[];
1796
+ defaultValue?: unknown;
1797
+ disabled?: boolean | undefined;
1798
+ placeholder?: string | undefined;
1799
+ description?: string | undefined;
1800
+ icon?: string | undefined;
1801
+ order?: number | undefined;
1802
+ hidden?: boolean | undefined;
1803
+ archived?: boolean | undefined;
1804
+ deprecated?: boolean | undefined;
1805
+ metadata?: Record<string, unknown> | undefined;
1806
+ }>;
1807
+ /**
1808
+ * Location attribute config schema
1809
+ */
1810
+ declare const locationConfigSchema: z.ZodObject<{
1811
+ disabled: z.ZodOptional<z.ZodBoolean>;
1812
+ placeholder: z.ZodOptional<z.ZodString>;
1813
+ description: z.ZodOptional<z.ZodString>;
1814
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1815
+ icon: z.ZodOptional<z.ZodString>;
1816
+ order: z.ZodOptional<z.ZodNumber>;
1817
+ hidden: z.ZodOptional<z.ZodBoolean>;
1818
+ archived: z.ZodOptional<z.ZodBoolean>;
1819
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1820
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1821
+ } & {
1822
+ granularity: z.ZodEnum<["full", "address", "city", "state", "country", "coordinates"]>;
1823
+ enableAutocomplete: z.ZodOptional<z.ZodBoolean>;
1824
+ enableMap: z.ZodOptional<z.ZodBoolean>;
1825
+ defaultCountry: z.ZodOptional<z.ZodString>;
1826
+ allowedCountries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1827
+ displayFormat: z.ZodOptional<z.ZodEnum<["single_line", "multi_line", "compact"]>>;
1828
+ }, "strip", z.ZodTypeAny, {
1829
+ granularity: "full" | "address" | "city" | "state" | "country" | "coordinates";
1830
+ defaultValue?: unknown;
1831
+ disabled?: boolean | undefined;
1832
+ placeholder?: string | undefined;
1833
+ description?: string | undefined;
1834
+ icon?: string | undefined;
1835
+ order?: number | undefined;
1836
+ hidden?: boolean | undefined;
1837
+ archived?: boolean | undefined;
1838
+ deprecated?: boolean | undefined;
1839
+ metadata?: Record<string, unknown> | undefined;
1840
+ enableAutocomplete?: boolean | undefined;
1841
+ enableMap?: boolean | undefined;
1842
+ defaultCountry?: string | undefined;
1843
+ allowedCountries?: string[] | undefined;
1844
+ displayFormat?: "single_line" | "multi_line" | "compact" | undefined;
1845
+ }, {
1846
+ granularity: "full" | "address" | "city" | "state" | "country" | "coordinates";
1847
+ defaultValue?: unknown;
1848
+ disabled?: boolean | undefined;
1849
+ placeholder?: string | undefined;
1850
+ description?: string | undefined;
1851
+ icon?: string | undefined;
1852
+ order?: number | undefined;
1853
+ hidden?: boolean | undefined;
1854
+ archived?: boolean | undefined;
1855
+ deprecated?: boolean | undefined;
1856
+ metadata?: Record<string, unknown> | undefined;
1857
+ enableAutocomplete?: boolean | undefined;
1858
+ enableMap?: boolean | undefined;
1859
+ defaultCountry?: string | undefined;
1860
+ allowedCountries?: string[] | undefined;
1861
+ displayFormat?: "single_line" | "multi_line" | "compact" | undefined;
1862
+ }>;
1863
+ /**
1864
+ * Timestamp attribute config schema
1865
+ */
1866
+ declare const timestampConfigSchema: z.ZodObject<{
1867
+ disabled: z.ZodOptional<z.ZodBoolean>;
1868
+ placeholder: z.ZodOptional<z.ZodString>;
1869
+ description: z.ZodOptional<z.ZodString>;
1870
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1871
+ icon: z.ZodOptional<z.ZodString>;
1872
+ order: z.ZodOptional<z.ZodNumber>;
1873
+ hidden: z.ZodOptional<z.ZodBoolean>;
1874
+ archived: z.ZodOptional<z.ZodBoolean>;
1875
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1876
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1877
+ } & {
1878
+ autoUpdate: z.ZodOptional<z.ZodBoolean>;
1879
+ }, "strip", z.ZodTypeAny, {
1880
+ defaultValue?: unknown;
1881
+ disabled?: boolean | undefined;
1882
+ placeholder?: string | undefined;
1883
+ description?: string | undefined;
1884
+ icon?: string | undefined;
1885
+ order?: number | undefined;
1886
+ hidden?: boolean | undefined;
1887
+ archived?: boolean | undefined;
1888
+ deprecated?: boolean | undefined;
1889
+ metadata?: Record<string, unknown> | undefined;
1890
+ autoUpdate?: boolean | undefined;
1891
+ }, {
1892
+ defaultValue?: unknown;
1893
+ disabled?: boolean | undefined;
1894
+ placeholder?: string | undefined;
1895
+ description?: string | undefined;
1896
+ icon?: string | undefined;
1897
+ order?: number | undefined;
1898
+ hidden?: boolean | undefined;
1899
+ archived?: boolean | undefined;
1900
+ deprecated?: boolean | undefined;
1901
+ metadata?: Record<string, unknown> | undefined;
1902
+ autoUpdate?: boolean | undefined;
1903
+ }>;
1904
+ /**
1905
+ * Select attribute config schema
1906
+ */
1907
+ declare const selectConfigSchema: z.ZodObject<{
1908
+ disabled: z.ZodOptional<z.ZodBoolean>;
1909
+ placeholder: z.ZodOptional<z.ZodString>;
1910
+ description: z.ZodOptional<z.ZodString>;
1911
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1912
+ icon: z.ZodOptional<z.ZodString>;
1913
+ order: z.ZodOptional<z.ZodNumber>;
1914
+ hidden: z.ZodOptional<z.ZodBoolean>;
1915
+ archived: z.ZodOptional<z.ZodBoolean>;
1916
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1917
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1918
+ } & {
1919
+ options: z.ZodArray<z.ZodObject<{
1920
+ id: z.ZodString;
1921
+ label: z.ZodString;
1922
+ value: z.ZodString;
1923
+ color: z.ZodOptional<z.ZodString>;
1924
+ icon: z.ZodOptional<z.ZodString>;
1925
+ description: z.ZodOptional<z.ZodString>;
1926
+ group: z.ZodOptional<z.ZodEnum<["idle", "in_progress", "finished"]>>;
1927
+ }, "strip", z.ZodTypeAny, {
1928
+ label: string;
1929
+ id: string;
1930
+ value: string;
1931
+ description?: string | undefined;
1932
+ icon?: string | undefined;
1933
+ color?: string | undefined;
1934
+ group?: "idle" | "in_progress" | "finished" | undefined;
1935
+ }, {
1936
+ label: string;
1937
+ id: string;
1938
+ value: string;
1939
+ description?: string | undefined;
1940
+ icon?: string | undefined;
1941
+ color?: string | undefined;
1942
+ group?: "idle" | "in_progress" | "finished" | undefined;
1943
+ }>, "many">;
1944
+ }, "strip", z.ZodTypeAny, {
1945
+ options: {
1946
+ label: string;
1947
+ id: string;
1948
+ value: string;
1949
+ description?: string | undefined;
1950
+ icon?: string | undefined;
1951
+ color?: string | undefined;
1952
+ group?: "idle" | "in_progress" | "finished" | undefined;
1953
+ }[];
1954
+ defaultValue?: unknown;
1955
+ disabled?: boolean | undefined;
1956
+ placeholder?: string | undefined;
1957
+ description?: string | undefined;
1958
+ icon?: string | undefined;
1959
+ order?: number | undefined;
1960
+ hidden?: boolean | undefined;
1961
+ archived?: boolean | undefined;
1962
+ deprecated?: boolean | undefined;
1963
+ metadata?: Record<string, unknown> | undefined;
1964
+ }, {
1965
+ options: {
1966
+ label: string;
1967
+ id: string;
1968
+ value: string;
1969
+ description?: string | undefined;
1970
+ icon?: string | undefined;
1971
+ color?: string | undefined;
1972
+ group?: "idle" | "in_progress" | "finished" | undefined;
1973
+ }[];
1974
+ defaultValue?: unknown;
1975
+ disabled?: boolean | undefined;
1976
+ placeholder?: string | undefined;
1977
+ description?: string | undefined;
1978
+ icon?: string | undefined;
1979
+ order?: number | undefined;
1980
+ hidden?: boolean | undefined;
1981
+ archived?: boolean | undefined;
1982
+ deprecated?: boolean | undefined;
1983
+ metadata?: Record<string, unknown> | undefined;
1984
+ }>;
1985
+ /**
1986
+ * Multiselect attribute config schema
1987
+ */
1988
+ declare const multiselectConfigSchema: z.ZodObject<{
1989
+ disabled: z.ZodOptional<z.ZodBoolean>;
1990
+ placeholder: z.ZodOptional<z.ZodString>;
1991
+ description: z.ZodOptional<z.ZodString>;
1992
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1993
+ icon: z.ZodOptional<z.ZodString>;
1994
+ order: z.ZodOptional<z.ZodNumber>;
1995
+ hidden: z.ZodOptional<z.ZodBoolean>;
1996
+ archived: z.ZodOptional<z.ZodBoolean>;
1997
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1998
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1999
+ } & {
2000
+ options: z.ZodArray<z.ZodObject<{
2001
+ id: z.ZodString;
2002
+ label: z.ZodString;
2003
+ value: z.ZodString;
2004
+ color: z.ZodOptional<z.ZodString>;
2005
+ icon: z.ZodOptional<z.ZodString>;
2006
+ description: z.ZodOptional<z.ZodString>;
2007
+ group: z.ZodOptional<z.ZodEnum<["idle", "in_progress", "finished"]>>;
2008
+ }, "strip", z.ZodTypeAny, {
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
+ label: string;
2018
+ id: string;
2019
+ value: string;
2020
+ description?: string | undefined;
2021
+ icon?: string | undefined;
2022
+ color?: string | undefined;
2023
+ group?: "idle" | "in_progress" | "finished" | undefined;
2024
+ }>, "many">;
2025
+ }, "strip", z.ZodTypeAny, {
2026
+ options: {
2027
+ label: string;
2028
+ id: string;
2029
+ value: string;
2030
+ description?: string | undefined;
2031
+ icon?: string | undefined;
2032
+ color?: string | undefined;
2033
+ group?: "idle" | "in_progress" | "finished" | undefined;
2034
+ }[];
2035
+ defaultValue?: unknown;
2036
+ disabled?: boolean | undefined;
2037
+ placeholder?: string | undefined;
2038
+ description?: string | undefined;
2039
+ icon?: string | undefined;
2040
+ order?: number | undefined;
2041
+ hidden?: boolean | undefined;
2042
+ archived?: boolean | undefined;
2043
+ deprecated?: boolean | undefined;
2044
+ metadata?: Record<string, unknown> | undefined;
2045
+ }, {
2046
+ options: {
2047
+ label: string;
2048
+ id: string;
2049
+ value: string;
2050
+ description?: string | undefined;
2051
+ icon?: string | undefined;
2052
+ color?: string | undefined;
2053
+ group?: "idle" | "in_progress" | "finished" | undefined;
2054
+ }[];
2055
+ defaultValue?: unknown;
2056
+ disabled?: boolean | undefined;
2057
+ placeholder?: string | undefined;
2058
+ description?: string | undefined;
2059
+ icon?: string | undefined;
2060
+ order?: number | undefined;
2061
+ hidden?: boolean | undefined;
2062
+ archived?: boolean | undefined;
2063
+ deprecated?: boolean | undefined;
2064
+ metadata?: Record<string, unknown> | undefined;
2065
+ }>;
2066
+ /**
2067
+ * File attribute config schema
2068
+ */
2069
+ declare const fileConfigSchema: z.ZodObject<{
2070
+ disabled: z.ZodOptional<z.ZodBoolean>;
2071
+ placeholder: z.ZodOptional<z.ZodString>;
2072
+ description: z.ZodOptional<z.ZodString>;
2073
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2074
+ icon: z.ZodOptional<z.ZodString>;
2075
+ order: z.ZodOptional<z.ZodNumber>;
2076
+ hidden: z.ZodOptional<z.ZodBoolean>;
2077
+ archived: z.ZodOptional<z.ZodBoolean>;
2078
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2079
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2080
+ } & {
2081
+ maxFiles: z.ZodOptional<z.ZodNumber>;
2082
+ maxSize: z.ZodOptional<z.ZodNumber>;
2083
+ allowedTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2084
+ verification: z.ZodOptional<z.ZodObject<{
2085
+ enabled: z.ZodBoolean;
2086
+ documentTypes: z.ZodArray<z.ZodObject<{
2087
+ type: z.ZodEnum<["id_card", "passport", "incorporation_certificate", "driver_license", "birth_certificate", "residence_permit", "bank_statement", "proof_of_address", "custom"]>;
2088
+ label: z.ZodString;
2089
+ faces: z.ZodArray<z.ZodEnum<["front", "back", "single"]>, "many">;
2090
+ attributeMapping: z.ZodOptional<z.ZodArray<z.ZodObject<{
2091
+ attributeId: z.ZodString;
2092
+ extractedKey: z.ZodString;
2093
+ face: z.ZodOptional<z.ZodEnum<["front", "back", "single"]>>;
2094
+ required: z.ZodOptional<z.ZodBoolean>;
2095
+ }, "strip", z.ZodTypeAny, {
2096
+ attributeId: string;
2097
+ extractedKey: string;
2098
+ required?: boolean | undefined;
2099
+ face?: "front" | "back" | "single" | undefined;
2100
+ }, {
2101
+ attributeId: string;
2102
+ extractedKey: string;
2103
+ required?: boolean | undefined;
2104
+ face?: "front" | "back" | "single" | undefined;
2105
+ }>, "many">>;
2106
+ }, "strip", z.ZodTypeAny, {
2107
+ label: string;
2108
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2109
+ faces: ("front" | "back" | "single")[];
2110
+ attributeMapping?: {
2111
+ attributeId: string;
2112
+ extractedKey: string;
2113
+ required?: boolean | undefined;
2114
+ face?: "front" | "back" | "single" | undefined;
2115
+ }[] | undefined;
2116
+ }, {
2117
+ label: string;
2118
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2119
+ faces: ("front" | "back" | "single")[];
2120
+ attributeMapping?: {
2121
+ attributeId: string;
2122
+ extractedKey: string;
2123
+ required?: boolean | undefined;
2124
+ face?: "front" | "back" | "single" | undefined;
2125
+ }[] | undefined;
2126
+ }>, "many">;
2127
+ autoExtract: z.ZodOptional<z.ZodBoolean>;
2128
+ autoValidate: z.ZodOptional<z.ZodBoolean>;
2129
+ }, "strip", z.ZodTypeAny, {
2130
+ enabled: boolean;
2131
+ documentTypes: {
2132
+ label: string;
2133
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2134
+ faces: ("front" | "back" | "single")[];
2135
+ attributeMapping?: {
2136
+ attributeId: string;
2137
+ extractedKey: string;
2138
+ required?: boolean | undefined;
2139
+ face?: "front" | "back" | "single" | undefined;
2140
+ }[] | undefined;
2141
+ }[];
2142
+ autoExtract?: boolean | undefined;
2143
+ autoValidate?: boolean | undefined;
2144
+ }, {
2145
+ enabled: boolean;
2146
+ documentTypes: {
2147
+ label: string;
2148
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2149
+ faces: ("front" | "back" | "single")[];
2150
+ attributeMapping?: {
2151
+ attributeId: string;
2152
+ extractedKey: string;
2153
+ required?: boolean | undefined;
2154
+ face?: "front" | "back" | "single" | undefined;
2155
+ }[] | undefined;
2156
+ }[];
2157
+ autoExtract?: boolean | undefined;
2158
+ autoValidate?: boolean | undefined;
2159
+ }>>;
2160
+ }, "strip", z.ZodTypeAny, {
2161
+ defaultValue?: unknown;
2162
+ disabled?: boolean | undefined;
2163
+ placeholder?: string | undefined;
2164
+ description?: string | undefined;
2165
+ icon?: string | undefined;
2166
+ order?: number | undefined;
2167
+ hidden?: boolean | undefined;
2168
+ archived?: boolean | undefined;
2169
+ deprecated?: boolean | undefined;
2170
+ metadata?: Record<string, unknown> | undefined;
2171
+ maxFiles?: number | undefined;
2172
+ maxSize?: number | undefined;
2173
+ allowedTypes?: string[] | undefined;
2174
+ verification?: {
2175
+ enabled: boolean;
2176
+ documentTypes: {
2177
+ label: string;
2178
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2179
+ faces: ("front" | "back" | "single")[];
2180
+ attributeMapping?: {
2181
+ attributeId: string;
2182
+ extractedKey: string;
2183
+ required?: boolean | undefined;
2184
+ face?: "front" | "back" | "single" | undefined;
2185
+ }[] | undefined;
2186
+ }[];
2187
+ autoExtract?: boolean | undefined;
2188
+ autoValidate?: boolean | undefined;
2189
+ } | undefined;
2190
+ }, {
2191
+ defaultValue?: unknown;
2192
+ disabled?: boolean | undefined;
2193
+ placeholder?: string | undefined;
2194
+ description?: string | undefined;
2195
+ icon?: string | undefined;
2196
+ order?: number | undefined;
2197
+ hidden?: boolean | undefined;
2198
+ archived?: boolean | undefined;
2199
+ deprecated?: boolean | undefined;
2200
+ metadata?: Record<string, unknown> | undefined;
2201
+ maxFiles?: number | undefined;
2202
+ maxSize?: number | undefined;
2203
+ allowedTypes?: string[] | undefined;
2204
+ verification?: {
2205
+ enabled: boolean;
2206
+ documentTypes: {
2207
+ label: string;
2208
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2209
+ faces: ("front" | "back" | "single")[];
2210
+ attributeMapping?: {
2211
+ attributeId: string;
2212
+ extractedKey: string;
2213
+ required?: boolean | undefined;
2214
+ face?: "front" | "back" | "single" | undefined;
2215
+ }[] | undefined;
2216
+ }[];
2217
+ autoExtract?: boolean | undefined;
2218
+ autoValidate?: boolean | undefined;
2219
+ } | undefined;
2220
+ }>;
2221
+ /**
2222
+ * User attribute config schema
2223
+ */
2224
+ declare const userConfigSchema: z.ZodObject<{
2225
+ disabled: z.ZodOptional<z.ZodBoolean>;
2226
+ placeholder: z.ZodOptional<z.ZodString>;
2227
+ description: z.ZodOptional<z.ZodString>;
2228
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2229
+ icon: z.ZodOptional<z.ZodString>;
2230
+ order: z.ZodOptional<z.ZodNumber>;
2231
+ hidden: z.ZodOptional<z.ZodBoolean>;
2232
+ archived: z.ZodOptional<z.ZodBoolean>;
2233
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2234
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2235
+ } & {
2236
+ allowedRoles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2237
+ }, "strip", z.ZodTypeAny, {
2238
+ defaultValue?: unknown;
2239
+ disabled?: boolean | undefined;
2240
+ placeholder?: string | undefined;
2241
+ description?: string | undefined;
2242
+ icon?: string | undefined;
2243
+ order?: number | undefined;
2244
+ hidden?: boolean | undefined;
2245
+ archived?: boolean | undefined;
2246
+ deprecated?: boolean | undefined;
2247
+ metadata?: Record<string, unknown> | undefined;
2248
+ allowedRoles?: string[] | undefined;
2249
+ }, {
2250
+ defaultValue?: unknown;
2251
+ disabled?: boolean | undefined;
2252
+ placeholder?: string | undefined;
2253
+ description?: string | undefined;
2254
+ icon?: string | undefined;
2255
+ order?: number | undefined;
2256
+ hidden?: boolean | undefined;
2257
+ archived?: boolean | undefined;
2258
+ deprecated?: boolean | undefined;
2259
+ metadata?: Record<string, unknown> | undefined;
2260
+ allowedRoles?: string[] | undefined;
2261
+ }>;
2262
+ /**
2263
+ * Relation attribute config schema
2264
+ */
2265
+ declare const relationConfigSchema: z.ZodObject<{
2266
+ disabled: z.ZodOptional<z.ZodBoolean>;
2267
+ placeholder: z.ZodOptional<z.ZodString>;
2268
+ description: z.ZodOptional<z.ZodString>;
2269
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2270
+ icon: z.ZodOptional<z.ZodString>;
2271
+ order: z.ZodOptional<z.ZodNumber>;
2272
+ hidden: z.ZodOptional<z.ZodBoolean>;
2273
+ archived: z.ZodOptional<z.ZodBoolean>;
2274
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2275
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2276
+ } & {
2277
+ targets: z.ZodArray<z.ZodObject<{
2278
+ object: z.ZodString;
2279
+ displayTemplate: z.ZodOptional<z.ZodString>;
2280
+ filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2281
+ }, "strip", z.ZodTypeAny, {
2282
+ object: string;
2283
+ filter?: Record<string, unknown> | undefined;
2284
+ displayTemplate?: string | undefined;
2285
+ }, {
2286
+ object: string;
2287
+ filter?: Record<string, unknown> | undefined;
2288
+ displayTemplate?: string | undefined;
2289
+ }>, "many">;
2290
+ onDelete: z.ZodOptional<z.ZodEnum<["restrict", "cascade", "set_null"]>>;
2291
+ cardinality: z.ZodEnum<["one", "many"]>;
2292
+ minItems: z.ZodOptional<z.ZodNumber>;
2293
+ maxItems: z.ZodOptional<z.ZodNumber>;
2294
+ }, "strip", z.ZodTypeAny, {
2295
+ cardinality: "one" | "many";
2296
+ targets: {
2297
+ object: string;
2298
+ filter?: Record<string, unknown> | undefined;
2299
+ displayTemplate?: string | undefined;
2300
+ }[];
2301
+ defaultValue?: unknown;
2302
+ disabled?: boolean | undefined;
2303
+ placeholder?: string | undefined;
2304
+ description?: string | undefined;
2305
+ icon?: string | undefined;
2306
+ order?: number | undefined;
2307
+ hidden?: boolean | undefined;
2308
+ archived?: boolean | undefined;
2309
+ deprecated?: boolean | undefined;
2310
+ metadata?: Record<string, unknown> | undefined;
2311
+ onDelete?: "restrict" | "cascade" | "set_null" | undefined;
2312
+ minItems?: number | undefined;
2313
+ maxItems?: number | undefined;
2314
+ }, {
2315
+ cardinality: "one" | "many";
2316
+ targets: {
2317
+ object: string;
2318
+ filter?: Record<string, unknown> | undefined;
2319
+ displayTemplate?: string | undefined;
2320
+ }[];
2321
+ defaultValue?: unknown;
2322
+ disabled?: boolean | undefined;
2323
+ placeholder?: string | undefined;
2324
+ description?: string | undefined;
2325
+ icon?: string | undefined;
2326
+ order?: number | undefined;
2327
+ hidden?: boolean | undefined;
2328
+ archived?: boolean | undefined;
2329
+ deprecated?: boolean | undefined;
2330
+ metadata?: Record<string, unknown> | undefined;
2331
+ onDelete?: "restrict" | "cascade" | "set_null" | undefined;
2332
+ minItems?: number | undefined;
2333
+ maxItems?: number | undefined;
2334
+ }>;
2335
+ /**
2336
+ * Rating attribute config schema
2337
+ */
2338
+ declare const ratingConfigSchema: z.ZodObject<{
2339
+ disabled: z.ZodOptional<z.ZodBoolean>;
2340
+ placeholder: z.ZodOptional<z.ZodString>;
2341
+ description: z.ZodOptional<z.ZodString>;
2342
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2343
+ icon: z.ZodOptional<z.ZodString>;
2344
+ order: z.ZodOptional<z.ZodNumber>;
2345
+ hidden: z.ZodOptional<z.ZodBoolean>;
2346
+ archived: z.ZodOptional<z.ZodBoolean>;
2347
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2348
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2349
+ } & {
2350
+ max: z.ZodOptional<z.ZodNumber>;
2351
+ iconType: z.ZodOptional<z.ZodEnum<["star", "heart", "thumbs", "number"]>>;
2352
+ }, "strip", z.ZodTypeAny, {
2353
+ defaultValue?: unknown;
2354
+ disabled?: boolean | undefined;
2355
+ placeholder?: string | undefined;
2356
+ description?: string | undefined;
2357
+ icon?: string | undefined;
2358
+ order?: number | undefined;
2359
+ hidden?: boolean | undefined;
2360
+ archived?: boolean | undefined;
2361
+ deprecated?: boolean | undefined;
2362
+ metadata?: Record<string, unknown> | undefined;
2363
+ max?: number | undefined;
2364
+ iconType?: "number" | "heart" | "star" | "thumbs" | undefined;
2365
+ }, {
2366
+ defaultValue?: unknown;
2367
+ disabled?: boolean | undefined;
2368
+ placeholder?: string | undefined;
2369
+ description?: string | undefined;
2370
+ icon?: string | undefined;
2371
+ order?: number | undefined;
2372
+ hidden?: boolean | undefined;
2373
+ archived?: boolean | undefined;
2374
+ deprecated?: boolean | undefined;
2375
+ metadata?: Record<string, unknown> | undefined;
2376
+ max?: number | undefined;
2377
+ iconType?: "number" | "heart" | "star" | "thumbs" | undefined;
2378
+ }>;
2379
+ /**
2380
+ * Map of attribute type to config schema
2381
+ */
2382
+ declare const attributeConfigSchemas: Record<AttributeType, z.ZodObject<z.ZodRawShape>>;
2383
+ /**
2384
+ * Get the config schema for a specific attribute type
2385
+ */
2386
+ declare function getAttributeConfigSchema(type: AttributeType): z.ZodObject<z.ZodRawShape>;
2387
+ /**
2388
+ * Validate attribute config for a specific type
2389
+ * Returns the validated config with only allowed properties
2390
+ */
2391
+ declare function validateAttributeConfig(type: AttributeType, config: Record<string, unknown>): {
2392
+ success: true;
2393
+ data: Record<string, unknown>;
2394
+ } | {
2395
+ success: false;
2396
+ errors: string[];
2397
+ };
2398
+ /**
2399
+ * Validate and strip unknown properties from attribute config
2400
+ * This ensures only allowed properties are stored in the database
2401
+ */
2402
+ declare function parseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown>;
2403
+ /**
2404
+ * Safely parse attribute config, returning undefined for invalid configs
2405
+ */
2406
+ declare function safeParseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown> | undefined;
2407
+ /**
2408
+ * Create a Zod schema for a text attribute
2409
+ */
2410
+ declare function createTextValidator(attr: TextAttribute): z.ZodString;
2411
+ /**
2412
+ * Create a Zod schema for a number attribute
2413
+ */
2414
+ declare function createNumberValidator(attr: NumberAttribute): z.ZodNumber;
2415
+ /**
2416
+ * Create a Zod schema for a checkbox attribute
2417
+ */
2418
+ declare function createCheckboxValidator(_attr: CheckboxAttribute): z.ZodBoolean;
2419
+ /**
2420
+ * Create a Zod schema for a date attribute
2421
+ */
2422
+ declare function createDateValidator(attr: DateAttribute): z.ZodString;
2423
+ /**
2424
+ * Create a Zod schema for a phone attribute
2425
+ */
2426
+ declare function createPhoneValidator(_attr: PhoneAttribute): z.ZodType<{
2427
+ countryCode: string;
2428
+ phoneNumber: string;
2429
+ }>;
2430
+ /**
2431
+ * Create a Zod schema for a currency attribute
2432
+ */
2433
+ declare function createCurrencyValidator(_attr: CurrencyAttribute): z.ZodType<{
2434
+ code: string;
2435
+ value: number;
2436
+ }>;
2437
+ /**
2438
+ * Create a Zod schema for a status attribute
2439
+ */
2440
+ declare function createStatusValidator(attr: StatusAttribute): z.ZodEnum<[string, ...string[]]>;
2441
+ /**
2442
+ * Create a Zod schema for a select attribute
2443
+ */
2444
+ declare function createSelectValidator(attr: SelectAttribute): z.ZodEnum<[string, ...string[]]>;
2445
+ /**
2446
+ * Create a Zod schema for a multiselect attribute
2447
+ */
2448
+ declare function createMultiselectValidator(attr: MultiselectAttribute): z.ZodArray<z.ZodEnum<[string, ...string[]]>>;
2449
+ /**
2450
+ * Create a Zod schema for a location attribute
2451
+ */
2452
+ type LocationShape = {
2453
+ address?: string;
2454
+ address2?: string;
2455
+ city?: string;
2456
+ state?: string;
2457
+ postalCode?: string;
2458
+ country?: string;
2459
+ latitude?: number;
2460
+ longitude?: number;
2461
+ };
2462
+ declare function createLocationValidator(_attr: LocationAttribute): z.ZodType<LocationShape>;
2463
+ /**
2464
+ * Create a Zod schema for a timestamp attribute
2465
+ */
2466
+ declare function createTimestampValidator(_attr: TimestampAttribute): z.ZodNumber;
2467
+ /**
2468
+ * Create a Zod schema for a file attribute
2469
+ */
2470
+ declare function createFileValidator(_attr: FileAttribute): z.ZodString;
2471
+ /**
2472
+ * Create a Zod schema for a user attribute
2473
+ */
2474
+ declare function createUserValidator(_attr: UserAttribute): z.ZodString;
2475
+ /**
2476
+ * Create a Zod schema for a single relation attribute (cardinality: "one")
2477
+ */
2478
+ declare function createSingleRelationValidator(attr: SingleRelationAttribute): z.ZodUnion<[z.ZodString, z.ZodNull]>;
2479
+ /**
2480
+ * Create a Zod schema for a multi relation attribute (cardinality: "many")
2481
+ */
2482
+ declare function createMultiRelationValidator(attr: MultiRelationAttribute): z.ZodArray<z.ZodString>;
2483
+ /**
2484
+ * Create a Zod schema for a relation attribute
2485
+ * Dispatches to single or multi validator based on cardinality
2486
+ */
2487
+ declare function createRelationValidator(attr: RelationAttribute): z.ZodUnion<[z.ZodString, z.ZodNull]> | z.ZodArray<z.ZodString>;
2488
+ /**
2489
+ * Create a Zod schema for a rating attribute
2490
+ */
2491
+ declare function createRatingValidator(attr: RatingAttribute): z.ZodNumber;
2492
+ /**
2493
+ * Create a Zod schema for any attribute type
2494
+ */
2495
+ declare function createAttributeValidator(attr: Attribute): z.ZodTypeAny;
2496
+ /**
2497
+ * Create a Zod schema for an entire object
2498
+ */
2499
+ declare function createObjectValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
2500
+ /**
2501
+ * Validation result
2502
+ */
2503
+ interface ValidationResult {
2504
+ success: boolean;
2505
+ data?: Record<string, unknown>;
2506
+ errors?: Array<{
2507
+ path: string[];
2508
+ message: string;
2509
+ }>;
2510
+ }
2511
+ /**
2512
+ * Validate data against an attribute schema
2513
+ */
2514
+ declare function validateAttribute(attr: Attribute, value: unknown): ValidationResult;
2515
+ /**
2516
+ * Validate data against an object schema
2517
+ */
2518
+ declare function validateObject(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
2519
+ /**
2520
+ * Validate and throw if invalid
2521
+ */
2522
+ declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
2523
+ /**
2524
+ * Create a Zod schema for draft validation.
2525
+ * All attributes become optional, but provided values are still validated.
2526
+ */
2527
+ declare function createDraftValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
2528
+ /**
2529
+ * Validate data in draft mode.
2530
+ * - All attributes are treated as optional (no required validation)
2531
+ * - Provided values are still validated for format/type correctness
2532
+ *
2533
+ * Use this when creating records that may be incomplete (drafts).
2534
+ *
2535
+ * @example
2536
+ * ```typescript
2537
+ * const result = validateDraft(PRODUCT, { name: "Draft" });
2538
+ * // → success even if "price" is required but missing
2539
+ *
2540
+ * const result2 = validateDraft(PRODUCT, { price: -10 });
2541
+ * // → fails because price must be >= 0 (format validation still applies)
2542
+ * ```
2543
+ */
2544
+ declare function validateDraft(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
2545
+ /**
2546
+ * Validate draft data and throw if format validation fails.
2547
+ */
2548
+ declare function validateDraftOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
2549
+ /**
2550
+ * Get the list of required attributes that are missing values.
2551
+ *
2552
+ * @example
2553
+ * ```typescript
2554
+ * const missing = getMissingRequiredAttributes(PRODUCT, { name: "Test" });
2555
+ * // → [priceAttribute, statusAttribute] if price and status are required but missing
2556
+ * ```
2557
+ */
2558
+ declare function getMissingRequiredAttributes(objectDef: ObjectDefinition, data: Record<string, unknown>): Attribute[];
2559
+ /**
2560
+ * Check if a record is complete (all required attributes have valid values).
2561
+ *
2562
+ * @returns `true` if all required values are present and valid, `false` otherwise
2563
+ */
2564
+ declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<string, unknown>): boolean;
2565
+ /**
2566
+ * Compute the completion status of a record based on its data.
2567
+ *
2568
+ * - `"complete"`: All required values are present and valid
2569
+ * - `"draft"`: One or more required values are missing or invalid
2570
+ *
2571
+ * This function is used to dynamically determine the status when
2572
+ * creating or updating records.
2573
+ *
2574
+ * @example
2575
+ * ```typescript
2576
+ * const status = computeRecordStatus(PRODUCT, {
2577
+ * name: "Nike Air Max",
2578
+ * price: 129.99,
2579
+ * status: "active"
2580
+ * });
2581
+ * // → "complete"
2582
+ *
2583
+ * const status2 = computeRecordStatus(PRODUCT, { name: "Draft Product" });
2584
+ * // → "draft" (missing required fields)
2585
+ * ```
2586
+ */
2587
+ declare function computeRecordStatus(objectDef: ObjectDefinition, data: Record<string, unknown>): CompletionStatus;
2588
+
2589
+ /**
2590
+ * Object as stored in database (metadata)
2591
+ */
2592
+ interface DBObject extends Timestamps {
2593
+ id: Uuid;
2594
+ tenantId: TenantId;
2595
+ name: string;
2596
+ label: string;
2597
+ pluralLabel?: string;
2598
+ description?: string;
2599
+ icon?: IconName;
2600
+ labelExpression: string;
2601
+ system: boolean;
2602
+ metadata?: Record<string, unknown>;
2603
+ }
2604
+ interface CreateDBObject {
2605
+ tenantId: TenantId;
2606
+ name: string;
2607
+ label: string;
2608
+ pluralLabel?: string;
2609
+ description?: string;
2610
+ icon?: IconName;
2611
+ labelExpression: string;
2612
+ system?: boolean;
2613
+ metadata?: Record<string, unknown>;
2614
+ }
2615
+ interface UpdateDBObject {
2616
+ label?: string;
2617
+ pluralLabel?: string;
2618
+ description?: string;
2619
+ icon?: IconName;
2620
+ labelExpression?: string;
2621
+ metadata?: Record<string, unknown>;
2622
+ }
2623
+ interface UpsertDBObject extends CreateDBObject {
2624
+ system: boolean;
2625
+ }
2626
+ /**
2627
+ * Attribute as stored in database (metadata)
2628
+ */
2629
+ interface DBAttribute extends Timestamps {
2630
+ id: Uuid;
2631
+ objectId: Uuid;
2632
+ name: string;
2633
+ label: string;
2634
+ type: AttributeType;
2635
+ description?: string;
2636
+ icon?: IconName;
2637
+ system: boolean;
2638
+ required: boolean;
2639
+ unique: boolean;
2640
+ order: number;
2641
+ hidden?: boolean;
2642
+ archived?: boolean;
2643
+ deprecated?: boolean;
2644
+ defaultValue?: unknown;
2645
+ config: Record<string, unknown>;
2646
+ }
2647
+ interface CreateDBAttribute {
2648
+ objectId: Uuid;
2649
+ name: string;
2650
+ label: string;
2651
+ type: AttributeType;
2652
+ description?: string;
2653
+ icon?: IconName;
2654
+ system?: boolean;
2655
+ required?: boolean;
2656
+ unique?: boolean;
2657
+ order?: number;
2658
+ hidden?: boolean;
2659
+ archived?: boolean;
2660
+ deprecated?: boolean;
2661
+ defaultValue?: unknown;
2662
+ config?: Record<string, unknown>;
2663
+ }
2664
+ interface UpdateDBAttribute {
2665
+ label?: string;
2666
+ type?: AttributeType;
2667
+ description?: string;
2668
+ icon?: IconName;
2669
+ required?: boolean;
2670
+ order?: number;
2671
+ hidden?: boolean;
2672
+ archived?: boolean;
2673
+ deprecated?: boolean;
2674
+ defaultValue?: unknown;
2675
+ config?: Record<string, unknown>;
2676
+ }
2677
+ interface UpsertDBAttribute extends CreateDBAttribute {
2678
+ objectId: Uuid;
2679
+ name: string;
2680
+ }
2681
+
2682
+ /**
2683
+ * Object record creation data
2684
+ */
2685
+ interface CreateObjectRecord {
2686
+ tenantId: TenantId;
2687
+ objectId: Uuid;
2688
+ data: Record<string, unknown>;
2689
+ /**
2690
+ * Computed display label from labelExpression.
2691
+ * Stored for performance - avoids recomputation on every read.
2692
+ */
2693
+ label: string;
2694
+ /**
2695
+ * Completion status of the record.
2696
+ * - `draft`: Record is incomplete (missing required values)
2697
+ * - `complete`: All required values are present and valid
2698
+ */
2699
+ completionStatus: "draft" | "complete";
2700
+ }
2701
+ /**
2702
+ * Generic list options for pagination and sorting
2703
+ */
2704
+ interface ListOptions {
2705
+ limit?: number;
2706
+ offset?: number;
2707
+ /** @deprecated Use sorts instead */
2708
+ orderBy?: string;
2709
+ /** @deprecated Use sorts instead */
2710
+ orderDirection?: "asc" | "desc";
2711
+ /** Multiple sort rules */
2712
+ sorts?: SortRule[];
2713
+ /** Filter state */
2714
+ filters?: FilterState;
2715
+ }
2716
+ /**
2717
+ * Search options for full-text search
2718
+ */
2719
+ interface SearchOptions extends ListOptions {
2720
+ highlight?: boolean;
2721
+ }
2722
+ /**
2723
+ * Global search options
2724
+ */
2725
+ interface GlobalSearchOptions extends ListOptions {
2726
+ /**
2727
+ * Limit results to specific object names
2728
+ */
2729
+ objectNames?: string[];
2730
+ /**
2731
+ * Whether to include object metadata in results
2732
+ */
2733
+ includeObjectInfo?: boolean;
2734
+ }
2735
+ /**
2736
+ * Global search result item
2737
+ */
2738
+ interface GlobalSearchResultItem {
2739
+ objectId: string;
2740
+ objectName: string;
2741
+ objectLabel: string;
2742
+ /** Computed label from labelExpression */
2743
+ label: string;
2744
+ recordId: string;
2745
+ values: Record<string, unknown>;
2746
+ completionStatus: "draft" | "complete";
2747
+ createdAt: Date;
2748
+ updatedAt: Date;
2749
+ }
2750
+ /**
2751
+ * File-specific list options
2752
+ */
2753
+ interface FileListOptions extends ListOptions {
2754
+ folderPath?: string;
2755
+ mimeType?: string;
2756
+ uploadedBy?: Uuid;
2757
+ includeDeleted?: boolean;
2758
+ }
2759
+ /**
2760
+ * View as stored in database
2761
+ */
2762
+ interface DBView extends Timestamps {
2763
+ id: Uuid;
2764
+ tenantId: TenantId;
2765
+ objectId?: Uuid;
2766
+ objectName: string;
2767
+ name: string;
2768
+ label: string;
2769
+ description?: string;
2770
+ icon?: IconName;
2771
+ tabs: Tab[];
2772
+ default: boolean;
2773
+ system: boolean;
2774
+ metadata?: Record<string, unknown>;
2775
+ }
2776
+ interface CreateDBView {
2777
+ tenantId: TenantId;
2778
+ objectId?: Uuid;
2779
+ objectName: string;
2780
+ name: string;
2781
+ label: string;
2782
+ description?: string;
2783
+ icon?: IconName;
2784
+ tabs: Tab[];
2785
+ default?: boolean;
2786
+ system?: boolean;
2787
+ metadata?: Record<string, unknown>;
2788
+ }
2789
+ interface UpdateDBView {
2790
+ label?: string;
2791
+ description?: string;
2792
+ icon?: IconName;
2793
+ tabs?: Tab[];
2794
+ default?: boolean;
2795
+ metadata?: Record<string, unknown>;
2796
+ }
2797
+ interface UpsertDBView {
2798
+ tenantId: TenantId;
2799
+ objectName: string;
2800
+ name: string;
2801
+ label: string;
2802
+ description?: string;
2803
+ icon?: IconName;
2804
+ tabs: Tab[];
2805
+ default?: boolean;
2806
+ system?: boolean;
2807
+ metadata?: Record<string, unknown>;
2808
+ }
2809
+ /**
2810
+ * Result of an operation
2811
+ */
2812
+ interface OperationResult<T = unknown> {
2813
+ success: boolean;
2814
+ data?: T;
2815
+ error?: {
2816
+ code: string;
2817
+ message: string;
2818
+ details?: Record<string, unknown>;
2819
+ };
2820
+ }
2821
+
2822
+ /**
2823
+ * Repository for objects table (metadata)
2824
+ */
2825
+ interface ObjectsRepository {
2826
+ /**
2827
+ * Find object by ID
2828
+ */
2829
+ findById(id: Uuid): Promise<DBObject | null>;
2830
+ /**
2831
+ * Find object by name and tenant
2832
+ */
2833
+ findByName(tenantId: TenantId, name: string): Promise<DBObject | null>;
2834
+ /**
2835
+ * Find system/native object by name (system=true, for sync)
2836
+ */
2837
+ findSystemByName(name: string): Promise<DBObject | null>;
2838
+ /**
2839
+ * Create object
2840
+ */
2841
+ create(data: CreateDBObject): Promise<DBObject>;
2842
+ /**
2843
+ * Update object
2844
+ */
2845
+ update(id: Uuid, data: Partial<UpdateDBObject>): Promise<DBObject>;
2846
+ /**
2847
+ * Delete object
2848
+ */
2849
+ delete(id: Uuid): Promise<void>;
2850
+ /**
2851
+ * List all objects for a tenant
2852
+ */
2853
+ list(tenantId: TenantId): Promise<DBObject[]>;
2854
+ /**
2855
+ * Upsert object (create or update based on nativeObjectId)
2856
+ */
2857
+ upsert(data: UpsertDBObject): Promise<DBObject>;
2858
+ }
2859
+ /**
2860
+ * Repository for attributes table (metadata)
2861
+ */
2862
+ interface AttributesRepository {
2863
+ /**
2864
+ * Find attribute by ID
2865
+ */
2866
+ findById(id: Uuid): Promise<DBAttribute | null>;
2867
+ /**
2868
+ * Find attributes by object ID
2869
+ */
2870
+ findByObjectId(objectId: Uuid): Promise<DBAttribute[]>;
2871
+ /**
2872
+ * Create attribute
2873
+ */
2874
+ create(data: CreateDBAttribute): Promise<DBAttribute>;
2875
+ /**
2876
+ * Update attribute
2877
+ */
2878
+ update(id: Uuid, data: Partial<UpdateDBAttribute>): Promise<DBAttribute>;
2879
+ /**
2880
+ * Delete attribute
2881
+ */
2882
+ delete(id: Uuid): Promise<void>;
2883
+ /**
2884
+ * Delete multiple attributes by names (for sync cleanup)
2885
+ */
2886
+ deleteByNames(objectId: Uuid, excludeNames: string[]): Promise<number>;
2887
+ /**
2888
+ * Upsert attribute (create or update based on objectId + name)
2889
+ */
2890
+ upsert(data: UpsertDBAttribute): Promise<DBAttribute>;
2891
+ }
2892
+ /**
2893
+ * Repository for user_profiles table
2894
+ */
2895
+ interface UserProfilesRepository {
2896
+ /**
2897
+ * Find user profile by ID
2898
+ */
2899
+ findById(id: Uuid): Promise<UserProfile | null>;
2900
+ /**
2901
+ * Find user profile by auth ID (external auth provider)
2902
+ */
2903
+ findByAuthId(authId: string): Promise<UserProfile | null>;
2904
+ /**
2905
+ * Find user profile by email
2906
+ */
2907
+ findByEmail(tenantId: TenantId, email: string): Promise<UserProfile | null>;
2908
+ /**
2909
+ * Create user profile
2910
+ */
2911
+ create(data: CreateUserProfile): Promise<UserProfile>;
2912
+ /**
2913
+ * Update user profile
2914
+ */
2915
+ update(id: Uuid, data: UpdateUserProfile): Promise<UserProfile>;
2916
+ /**
2917
+ * Delete user profile
2918
+ */
2919
+ delete(id: Uuid): Promise<void>;
2920
+ /**
2921
+ * List all user profiles for a tenant
2922
+ */
2923
+ list(tenantId: TenantId, options?: ListOptions): Promise<UserProfile[]>;
2924
+ /**
2925
+ * Update last login timestamp
2926
+ */
2927
+ updateLastLogin(id: Uuid): Promise<void>;
2928
+ }
2929
+ /**
2930
+ * Repository for files table
2931
+ */
2932
+ interface FilesRepository {
2933
+ /**
2934
+ * Find file by ID
2935
+ */
2936
+ findById(id: Uuid): Promise<File | null>;
2937
+ /**
2938
+ * Create file
2939
+ */
2940
+ create(data: CreateFile): Promise<File>;
2941
+ /**
2942
+ * Update file
2943
+ */
2944
+ update(id: Uuid, data: UpdateFile): Promise<File>;
2945
+ /**
2946
+ * Delete file (soft delete)
2947
+ */
2948
+ delete(id: Uuid): Promise<void>;
2949
+ /**
2950
+ * Hard delete file (permanent)
2951
+ */
2952
+ hardDelete(id: Uuid): Promise<void>;
2953
+ /**
2954
+ * List files for a tenant
2955
+ */
2956
+ list(tenantId: TenantId, options?: FileListOptions): Promise<File[]>;
2957
+ /**
2958
+ * Find files by folder path
2959
+ */
2960
+ findByFolder(tenantId: TenantId, folderPath: string): Promise<File[]>;
2961
+ /**
2962
+ * Find files by uploader
2963
+ */
2964
+ findByUploader(uploadedBy: Uuid): Promise<File[]>;
2965
+ }
2966
+ /**
2967
+ * Repository for object_records table (unified JSONB)
2968
+ */
2969
+ interface ObjectRecordsRepository {
2970
+ /**
2971
+ * Find record by ID
2972
+ */
2973
+ findById(id: Uuid): Promise<ObjectRecord | null>;
2974
+ /**
2975
+ * Create record
2976
+ */
2977
+ create(data: CreateObjectRecord): Promise<ObjectRecord>;
2978
+ /**
2979
+ * Update record
2980
+ */
2981
+ update(id: Uuid, data: Partial<Record<string, unknown>>): Promise<ObjectRecord>;
2982
+ /**
2983
+ * Delete record
2984
+ */
2985
+ delete(id: Uuid): Promise<void>;
2986
+ /**
2987
+ * List records for an object
2988
+ */
2989
+ list(tenantId: TenantId, objectId: Uuid, options?: ListOptions): Promise<{
2990
+ records: ObjectRecord[];
2991
+ total: number;
2992
+ }>;
2993
+ /**
2994
+ * Search records using PostgreSQL full-text search
2995
+ */
2996
+ search(tenantId: TenantId, objectId: Uuid, query: string, options?: SearchOptions): Promise<{
2997
+ records: ObjectRecord[];
2998
+ total: number;
2999
+ }>;
3000
+ /**
3001
+ * Global search across all object records for a tenant
3002
+ * Searches in all objects or a subset specified by objectNames
3003
+ */
3004
+ globalSearch(tenantId: TenantId, query: string, options?: GlobalSearchOptions): Promise<{
3005
+ results: GlobalSearchResultItem[];
3006
+ total: number;
3007
+ }>;
3008
+ }
3009
+ /**
3010
+ * Repository for views table
3011
+ */
3012
+ interface ViewsRepository {
3013
+ /**
3014
+ * Find view by ID
3015
+ */
3016
+ findById(id: Uuid): Promise<DBView | null>;
3017
+ /**
3018
+ * Find view by name for an object and tenant
3019
+ */
3020
+ findByName(tenantId: TenantId, objectName: string, viewName: string): Promise<DBView | null>;
3021
+ /**
3022
+ * Find all views for an object and tenant
3023
+ */
3024
+ findByObjectName(tenantId: TenantId, objectName: string): Promise<DBView[]>;
3025
+ /**
3026
+ * Find all views for a tenant
3027
+ */
3028
+ findAllForTenant(tenantId: TenantId): Promise<DBView[]>;
3029
+ /**
3030
+ * Find system view by name (for sync)
3031
+ */
3032
+ findSystemByName(objectName: string, viewName: string): Promise<DBView | null>;
3033
+ /**
3034
+ * Find all system views for an object
3035
+ */
3036
+ findSystemByObjectName(objectName: string): Promise<DBView[]>;
3037
+ /**
3038
+ * Create view
3039
+ */
3040
+ create(data: CreateDBView): Promise<DBView>;
3041
+ /**
3042
+ * Update view
3043
+ */
3044
+ update(id: Uuid, data: Partial<UpdateDBView>): Promise<DBView>;
3045
+ /**
3046
+ * Delete view
3047
+ */
3048
+ delete(id: Uuid): Promise<void>;
3049
+ /**
3050
+ * Delete views not in the list (for sync cleanup)
3051
+ * @returns Number of deleted views
3052
+ */
3053
+ deleteNotIn(objectName: string, keepViewNames: string[]): Promise<number>;
3054
+ /**
3055
+ * Upsert view (create or update based on objectName + name)
3056
+ */
3057
+ upsert(data: UpsertDBView): Promise<DBView>;
3058
+ }
3059
+ /**
3060
+ * Repository for roles, permissions, and user role assignments.
3061
+ *
3062
+ * This repository is optional - if not provided in the DatabaseAdapter,
3063
+ * permission checks are disabled (backward compatible behavior).
3064
+ */
3065
+ interface PermissionsRepository {
3066
+ /**
3067
+ * Get all roles for a tenant
3068
+ */
3069
+ getRolesByTenant(tenantId: TenantId): Promise<Role[]>;
3070
+ /**
3071
+ * Get a role by ID
3072
+ */
3073
+ getRoleById(roleId: Uuid): Promise<Role | null>;
3074
+ /**
3075
+ * Get a role by name for a tenant
3076
+ */
3077
+ getRoleByName(tenantId: TenantId, name: string): Promise<Role | null>;
3078
+ /**
3079
+ * Create a new role
3080
+ */
3081
+ createRole(input: CreateRoleInput): Promise<Role>;
3082
+ /**
3083
+ * Update an existing role
3084
+ */
3085
+ updateRole(roleId: Uuid, updates: UpdateRoleInput): Promise<Role>;
3086
+ /**
3087
+ * Delete a role (fails if role is system role)
3088
+ */
3089
+ deleteRole(roleId: Uuid): Promise<void>;
3090
+ /**
3091
+ * Get all permissions for a role
3092
+ */
3093
+ getPermissionsByRole(roleId: Uuid): Promise<Permission[]>;
3094
+ /**
3095
+ * Set permissions for a role (replaces existing permissions)
3096
+ */
3097
+ setPermissions(roleId: Uuid, permissions: CreatePermissionInput[]): Promise<void>;
3098
+ /**
3099
+ * Get all roles assigned to a user within a tenant
3100
+ */
3101
+ getUserRoles(userId: Uuid, tenantId: TenantId): Promise<Role[]>;
3102
+ /**
3103
+ * Assign a role to a user
3104
+ */
3105
+ assignRole(input: AssignRoleInput): Promise<UserRoleAssignment>;
3106
+ /**
3107
+ * Revoke a role from a user
3108
+ */
3109
+ revokeRole(userId: Uuid, roleId: Uuid, tenantId: TenantId): Promise<void>;
3110
+ /**
3111
+ * Get effective permissions for a user (merged from all assigned roles)
3112
+ *
3113
+ * This method should:
3114
+ * 1. Get all roles assigned to the user
3115
+ * 2. Get all permissions for those roles
3116
+ * 3. Merge permissions (union of actions per object)
3117
+ * 4. Determine if user has admin privileges
3118
+ */
3119
+ getEffectivePermissions(userId: Uuid, tenantId: TenantId): Promise<EffectivePermissions>;
3120
+ }
3121
+
3122
+ /**
3123
+ * Generic database adapter interface
3124
+ * Any ORM (Drizzle, Prisma, Kysely, TypeORM) can implement this interface
3125
+ * to work with @stndrds/schema runtime services
3126
+ *
3127
+ * @example
3128
+ * ```typescript
3129
+ * // Drizzle implementation
3130
+ * import { createDrizzleAdapter } from "./adapters/drizzle";
3131
+ * import { db } from "./db";
3132
+ *
3133
+ * const adapter = createDrizzleAdapter(db);
3134
+ *
3135
+ * // Prisma implementation
3136
+ * import { createPrismaAdapter } from "./adapters/prisma";
3137
+ * import { prisma } from "./db";
3138
+ *
3139
+ * const adapter = createPrismaAdapter(prisma);
3140
+ * ```
3141
+ */
3142
+ interface DatabaseAdapter {
3143
+ objects: ObjectsRepository;
3144
+ attributes: AttributesRepository;
3145
+ views: ViewsRepository;
3146
+ userProfiles: UserProfilesRepository;
3147
+ files: FilesRepository;
3148
+ objectRecords: ObjectRecordsRepository;
3149
+ permissions?: PermissionsRepository;
3150
+ transaction<T>(callback: (adapter: DatabaseAdapter) => Promise<T>): Promise<T>;
3151
+ }
3152
+
3153
+ /**
3154
+ * Types of hooks supported by the system
3155
+ */
3156
+ type HookType = "beforeCreate" | "afterCreate" | "beforeUpdate" | "afterUpdate" | "beforeDelete" | "afterDelete";
3157
+ /**
3158
+ * Change information for a specific attribute
3159
+ */
3160
+ interface AttributeChange<T = unknown> {
3161
+ oldValue: T | undefined;
3162
+ newValue: T | undefined;
3163
+ changed: boolean;
3164
+ }
3165
+ /**
3166
+ * Context passed to hooks - abstract, no framework dependencies
3167
+ *
3168
+ * This interface is designed to be extended by framework-specific implementations
3169
+ * (e.g., TriggerContext in schema-nestjs adds NestJS services)
3170
+ */
3171
+ interface HookContext<T = unknown> {
3172
+ objectId: string;
3173
+ objectName: string;
3174
+ recordId: string;
3175
+ tenantId: string;
3176
+ record: ObjectRecord;
3177
+ oldValues: Record<string, unknown>;
3178
+ newValues: Record<string, unknown>;
3179
+ changedAttributes: string[];
3180
+ /**
3181
+ * Get change information for a specific attribute
3182
+ * @param attributeName - The name of the attribute to check
3183
+ * @returns Change information including old value, new value, and whether it changed
3184
+ */
3185
+ getChange<V = T>(attributeName: string): AttributeChange<V>;
3186
+ metadata: Record<string, unknown>;
3187
+ timestamp: Date;
3188
+ }
3189
+ /**
3190
+ * Generic hook handler function
3191
+ */
3192
+ type HookHandler = (ctx: HookContext) => Promise<void> | void;
3193
+ /**
3194
+ * Definition of a hook for registration
3195
+ */
3196
+ interface HookDefinition {
3197
+ type: HookType;
3198
+ objectName: string;
3199
+ /** Attribute name to watch, or '*' for all attributes */
3200
+ attributeName?: string | "*";
3201
+ /** Execution priority (lower = earlier), default 0 */
3202
+ priority?: number;
3203
+ handler: HookHandler;
3204
+ }
3205
+
3206
+ /**
3207
+ * Abstract interface for hook registry
3208
+ *
3209
+ * This interface is implemented by TriggerRegistry in schema-nestjs
3210
+ * to provide NestJS-specific functionality like dependency injection
3211
+ * and automatic discovery of trigger classes.
3212
+ */
3213
+ interface HookRegistry {
3214
+ /**
3215
+ * Execute all hooks of a given type for an object
3216
+ *
3217
+ * @param type - The type of hook to execute (beforeUpdate, afterUpdate, etc.)
3218
+ * @param objectName - The name of the object being modified
3219
+ * @param ctx - The hook context containing record data and changes
3220
+ */
3221
+ execute(type: HookType, objectName: string, ctx: HookContext): Promise<void>;
3222
+ /**
3223
+ * Register a hook manually (optional)
3224
+ * Not all implementations need to support this (e.g., decorator-based discovery)
3225
+ */
3226
+ register?(hook: HookDefinition): void;
3227
+ }
3228
+ /**
3229
+ * No-op implementation of HookRegistry
3230
+ *
3231
+ * Used as default when no registry is provided to RecordService.
3232
+ * This allows the schema package to work independently without triggers.
3233
+ */
3234
+ declare class NoopHookRegistry implements HookRegistry {
3235
+ execute(): Promise<void>;
3236
+ }
3237
+
3238
+ interface InternalObjectRecord extends ObjectRecord {
3239
+ tenantId: TenantId;
3240
+ }
3241
+ interface MockStores {
3242
+ objects: Map<Uuid, DBObject>;
3243
+ attributes: Map<Uuid, DBAttribute>;
3244
+ userProfiles: Map<Uuid, UserProfile>;
3245
+ files: Map<Uuid, File>;
3246
+ objectRecords: Map<Uuid, InternalObjectRecord>;
3247
+ views: Map<Uuid, DBView>;
3248
+ roles: Map<Uuid, Role>;
3249
+ permissions: Map<Uuid, Permission>;
3250
+ userRoles: Map<Uuid, UserRoleAssignment>;
3251
+ }
3252
+ /**
3253
+ * Create an in-memory mock adapter for testing and development
3254
+ *
3255
+ * This adapter stores all data in memory and is perfect for:
3256
+ * - Unit tests
3257
+ * - Integration tests
3258
+ * - Local development without a database
3259
+ * - Understanding the adapter interface
3260
+ *
3261
+ * @returns A DatabaseAdapter implementation using in-memory storage
3262
+ *
3263
+ * @example
3264
+ * ```typescript
3265
+ * import { createMockAdapter, RecordService } from "@stndrds/schema";
3266
+ *
3267
+ * // Create adapter
3268
+ * const adapter = createMockAdapter();
3269
+ *
3270
+ * // Use with services
3271
+ * const recordService = new RecordService(adapter, "tenant-123");
3272
+ *
3273
+ * // Create a record
3274
+ * const product = await recordService.createRecord("obj-product", {
3275
+ * name: "Nike Air Max",
3276
+ * price: 129.99
3277
+ * });
3278
+ *
3279
+ * // List records
3280
+ * const { records, total } = await recordService.listRecords("obj-product");
3281
+ * ```
3282
+ */
3283
+ declare function createMockAdapter(): DatabaseAdapter & {
3284
+ _stores: MockStores;
3285
+ reset(): void;
3286
+ };
3287
+
3288
+ /**
3289
+ * Service for managing files
3290
+ * Handles file metadata CRUD, permissions, and soft delete
3291
+ */
3292
+ declare class FileService {
3293
+ private adapter;
3294
+ private tenantId;
3295
+ constructor(adapter: DatabaseAdapter, tenantId: string);
3296
+ /**
3297
+ * Create a new file record (after upload to storage)
3298
+ *
3299
+ * @param data - File metadata
3300
+ * @returns Created file record
3301
+ *
3302
+ * @example
3303
+ * ```typescript
3304
+ * const service = new FileService(adapter, "tenant-123");
3305
+ *
3306
+ * // After uploading to S3
3307
+ * const file = await service.createFile({
3308
+ * tenantId: "tenant-123",
3309
+ * name: "contract-2025.pdf",
3310
+ * originalName: "Contract Acme Corp 2025.pdf",
3311
+ * mimeType: "application/pdf",
3312
+ * size: 2458624,
3313
+ * storageProvider: "s3",
3314
+ * storagePath: "tenants/123/files/2025/contract.pdf",
3315
+ * storageBucket: "my-app-files",
3316
+ * url: "https://cdn.example.com/files/file-123",
3317
+ * uploadedBy: "profile-456",
3318
+ * visibility: "private"
3319
+ * });
3320
+ * ```
3321
+ */
3322
+ createFile(data: CreateFile): Promise<File>;
3323
+ /**
3324
+ * Get file by ID
3325
+ */
3326
+ getFile(fileId: string): Promise<File | null>;
3327
+ /**
3328
+ * Get file by ID or throw
3329
+ */
3330
+ getFileOrThrow(fileId: string): Promise<File>;
3331
+ /**
3332
+ * Update file metadata
3333
+ *
3334
+ * @param fileId - File UUID
3335
+ * @param data - Data to update
3336
+ * @returns Updated file
3337
+ */
3338
+ updateFile(fileId: string, data: UpdateFile): Promise<File>;
3339
+ /**
3340
+ * Delete file (soft delete)
3341
+ *
3342
+ * @param fileId - File UUID
3343
+ * @param options - Delete options
3344
+ */
3345
+ deleteFile(fileId: string, options?: {
3346
+ hard?: boolean;
3347
+ checkOwnership?: boolean;
3348
+ userId?: string;
3349
+ }): Promise<void>;
3350
+ /**
3351
+ * List files for the tenant
3352
+ */
3353
+ listFiles(options?: FileListOptions): Promise<File[]>;
3354
+ /**
3355
+ * List files by folder
3356
+ */
3357
+ listFilesByFolder(folderPath: string): Promise<File[]>;
3358
+ /**
3359
+ * List files uploaded by a specific user
3360
+ */
3361
+ listFilesByUploader(uploadedBy: string): Promise<File[]>;
3362
+ /**
3363
+ * Change file visibility
3364
+ *
3365
+ * @param fileId - File UUID
3366
+ * @param visibility - New visibility level
3367
+ * @param allowedUsers - Users allowed to access (if restricted)
3368
+ */
3369
+ changeVisibility(fileId: string, visibility: "public" | "private" | "restricted", allowedUsers?: string[]): Promise<File>;
3370
+ /**
3371
+ * Grant access to a file for specific users
3372
+ *
3373
+ * @param fileId - File UUID
3374
+ * @param userIds - User IDs to grant access
3375
+ */
3376
+ grantAccess(fileId: string, userIds: string[]): Promise<File>;
3377
+ /**
3378
+ * Revoke access to a file for specific users
3379
+ *
3380
+ * @param fileId - File UUID
3381
+ * @param userIds - User IDs to revoke access
3382
+ */
3383
+ revokeAccess(fileId: string, userIds: string[]): Promise<File>;
3384
+ /**
3385
+ * Check if user has access to a file
3386
+ *
3387
+ * @param fileId - File UUID
3388
+ * @param userId - User ID to check
3389
+ * @returns true if user can access the file
3390
+ */
3391
+ canAccess(fileId: string, userId: string): Promise<boolean>;
3392
+ /**
3393
+ * Move file to different folder
3394
+ */
3395
+ moveToFolder(fileId: string, newFolderPath: string): Promise<File>;
3396
+ /**
3397
+ * Add tags to file
3398
+ */
3399
+ addTags(fileId: string, tags: string[]): Promise<File>;
3400
+ /**
3401
+ * Remove tags from file
3402
+ */
3403
+ removeTags(fileId: string, tags: string[]): Promise<File>;
3404
+ }
3405
+
3406
+ /**
3407
+ * Geocoding service for address autocomplete and geocoding operations
3408
+ *
3409
+ * @example
3410
+ * ```typescript
3411
+ * import { GeocodingService } from "@stndrds/schema";
3412
+ * import { GoogleMapsAdapter } from "./adapters/google-maps";
3413
+ *
3414
+ * const geocoding = new GeocodingService(new GoogleMapsAdapter({ apiKey: "..." }));
3415
+ *
3416
+ * const suggestions = await geocoding.autocomplete({
3417
+ * query: "40 Quai des Belges",
3418
+ * countries: ["FRA"],
3419
+ * limit: 5,
3420
+ * });
3421
+ * ```
3422
+ */
3423
+ declare class GeocodingService {
3424
+ private readonly adapter;
3425
+ constructor(adapter: GeocodingAdapter);
3426
+ /**
3427
+ * Search for address suggestions as the user types
3428
+ */
3429
+ autocomplete(params: GeocodingAutocompleteParams): Promise<GeocodingSuggestion[]>;
3430
+ /**
3431
+ * Reverse geocode coordinates to an address
3432
+ */
3433
+ reverse(params: ReverseGeocodingParams): Promise<GeocodingSuggestion | null>;
3434
+ /**
3435
+ * Geocode a structured address to coordinates
3436
+ */
3437
+ geocode(params: GeocodingParams): Promise<GeocodingSuggestion | null>;
3438
+ }
3439
+
3440
+ /**
3441
+ * Service for global search across all object records
3442
+ * Allows searching across all objects or a subset of objects for a tenant
3443
+ *
3444
+ * @example
3445
+ * ```typescript
3446
+ * const service = new GlobalSearchService(adapter, "tenant-123");
3447
+ *
3448
+ * // Search across all objects
3449
+ * const { results, total } = await service.search("nike");
3450
+ *
3451
+ * // Search only in specific objects
3452
+ * const { results, total } = await service.search("nike", {
3453
+ * objectNames: ["products", "orders"],
3454
+ * limit: 20
3455
+ * });
3456
+ * ```
3457
+ */
3458
+ declare class GlobalSearchService {
3459
+ private adapter;
3460
+ private tenantId;
3461
+ constructor(adapter: DatabaseAdapter, tenantId: string);
3462
+ /**
3463
+ * Search across all object records for the tenant
3464
+ *
3465
+ * @param query - Search query string
3466
+ * @param options - Search options (pagination, object filters)
3467
+ * @returns Matching records with object metadata and total count
3468
+ *
3469
+ * @example
3470
+ * ```typescript
3471
+ * // Basic search
3472
+ * const { results, total } = await service.search("nike air");
3473
+ *
3474
+ * // With pagination
3475
+ * const { results, total } = await service.search("nike", {
3476
+ * limit: 10,
3477
+ * offset: 20
3478
+ * });
3479
+ *
3480
+ * // Filter by object types
3481
+ * const { results, total } = await service.search("nike", {
3482
+ * objectNames: ["products", "orders"]
3483
+ * });
3484
+ * ```
3485
+ */
3486
+ search(query: string, options?: GlobalSearchOptions): Promise<{
3487
+ results: GlobalSearchResultItem[];
3488
+ total: number;
3489
+ }>;
3490
+ /**
3491
+ * Search and group results by object type
3492
+ *
3493
+ * @param query - Search query string
3494
+ * @param options - Search options
3495
+ * @returns Results grouped by object name
3496
+ */
3497
+ searchGrouped(query: string, options?: Omit<GlobalSearchOptions, "limit" | "offset">): Promise<{
3498
+ groups: Array<{
3499
+ objectName: string;
3500
+ objectLabel: string;
3501
+ results: GlobalSearchResultItem[];
3502
+ count: number;
3503
+ }>;
3504
+ total: number;
3505
+ }>;
3506
+ }
3507
+
3508
+ /**
3509
+ * Input for creating a custom object
3510
+ */
3511
+ interface CreateCustomObjectInput {
3512
+ name: string;
3513
+ label: string;
3514
+ /**
3515
+ * Plural form of the label (e.g., "Products" for "Product")
3516
+ * Used in UI when displaying collections
3517
+ */
3518
+ pluralLabel?: string;
3519
+ /**
3520
+ * Template expression for computing record display labels.
3521
+ * Example: "{{ name }}" or "{{ firstName }} {{ lastName }}"
3522
+ */
3523
+ labelExpression: string;
3524
+ description?: string;
3525
+ icon?: IconName;
3526
+ attributes?: (Attribute | {
3527
+ build: () => Attribute;
3528
+ })[];
3529
+ metadata?: Record<string, unknown>;
3530
+ }
3531
+ /**
3532
+ * Input for adding an attribute to an object
3533
+ */
3534
+ interface AddAttributeInput {
3535
+ name: string;
3536
+ label: string;
3537
+ type: AttributeType;
3538
+ required?: boolean;
3539
+ unique?: boolean;
3540
+ description?: string;
3541
+ placeholder?: string;
3542
+ icon?: IconName;
3543
+ defaultValue?: unknown;
3544
+ metadata?: Record<string, unknown>;
3545
+ [key: string]: unknown;
3546
+ }
3547
+ /**
3548
+ * Input for updating an object
3549
+ * Only custom objects (system=false) can be updated
3550
+ * Note: `name` cannot be changed after creation
3551
+ */
3552
+ interface UpdateObjectInput {
3553
+ label?: string;
3554
+ pluralLabel?: string;
3555
+ description?: string;
3556
+ icon?: IconName;
3557
+ labelExpression?: string;
3558
+ metadata?: Record<string, unknown>;
3559
+ }
3560
+ /**
3561
+ * Service for managing object schemas
3562
+ * Handles fusion of native objects (from registry) and custom objects (from database)
3563
+ */
3564
+ declare class ObjectSchemaService {
3565
+ private adapter;
3566
+ private nativeRegistry;
3567
+ constructor(adapter: DatabaseAdapter, nativeRegistry: typeof registry);
3568
+ /**
3569
+ * Create a new custom object
3570
+ * Validates name format and ensures system=false
3571
+ *
3572
+ * @param definition - Object definition (attributes can be raw definitions or builders)
3573
+ * @param tenantId - Tenant ID owning the object
3574
+ * @returns Created ObjectDefinition
3575
+ */
3576
+ createCustomObject(definition: CreateCustomObjectInput, tenantId: string): Promise<ObjectDefinition>;
3577
+ /**
3578
+ * Add a custom attribute to an existing object
3579
+ * Can be used on both custom and native objects
3580
+ * Attributes added via API are always custom (system=false)
3581
+ *
3582
+ * @param objectId - Object UUID from database
3583
+ * @param attribute - Attribute definition
3584
+ * @param tenantId - Tenant ID (required for relation validation)
3585
+ * @returns Created Attribute
3586
+ */
3587
+ addAttributeToObject(objectId: string, attribute: AddAttributeInput, tenantId?: string): Promise<Attribute>;
3588
+ /**
3589
+ * Update an attribute
3590
+ * Can only update custom attributes (system=false)
3591
+ *
3592
+ * @param attributeId - Attribute UUID
3593
+ * @param updates - Partial attribute updates
3594
+ * @param tenantId - Tenant ID (required for relation validation)
3595
+ * @returns Updated Attribute
3596
+ */
3597
+ updateAttribute(attributeId: string, updates: Partial<AddAttributeInput>, tenantId?: string): Promise<Attribute>;
3598
+ /**
3599
+ * Delete an attribute
3600
+ * Can only delete custom attributes (system=false)
3601
+ *
3602
+ * @param attributeId - Attribute UUID
3603
+ */
3604
+ deleteAttribute(attributeId: string): Promise<void>;
3605
+ /**
3606
+ * List attributes for an object
3607
+ *
3608
+ * @param objectId - Object UUID
3609
+ * @param options - Filter options
3610
+ * @returns List of attributes
3611
+ */
3612
+ listAttributes(objectId: string, options?: {
3613
+ systemOnly?: boolean;
3614
+ customOnly?: boolean;
3615
+ }): Promise<Attribute[]>;
3616
+ /**
3617
+ * Update a custom object
3618
+ * Can only update custom objects (system=false)
3619
+ *
3620
+ * @param objectId - Object UUID
3621
+ * @param updates - Partial object updates
3622
+ * @returns Updated ObjectDefinition
3623
+ *
3624
+ * @example
3625
+ * ```typescript
3626
+ * const updated = await service.updateObject("obj-123", {
3627
+ * label: "Updated Label",
3628
+ * description: "New description",
3629
+ * });
3630
+ * ```
3631
+ */
3632
+ updateObject(objectId: string, updates: UpdateObjectInput): Promise<ObjectDefinition>;
3633
+ /**
3634
+ * Delete a custom object
3635
+ * Can only delete custom objects (system=false)
3636
+ * This will also delete all associated attributes and records
3637
+ *
3638
+ * @param objectId - Object UUID
3639
+ *
3640
+ * @example
3641
+ * ```typescript
3642
+ * await service.deleteObject("obj-123");
3643
+ * ```
3644
+ */
3645
+ deleteObject(objectId: string): Promise<void>;
3646
+ /**
3647
+ * Validate attribute name format (variable identifier)
3648
+ * @internal
3649
+ */
3650
+ private validateAttributeName;
3651
+ /**
3652
+ * Get complete object schema (system + custom attributes)
3653
+ * If object is native, merges registry definition with DB custom attributes
3654
+ * If object is custom, returns DB definition only
3655
+ *
3656
+ * @param objectId - Object UUID from database
3657
+ * @returns Complete ObjectDefinition with all attributes
3658
+ *
3659
+ * @example
3660
+ * ```typescript
3661
+ * const service = new ObjectSchemaService(adapter, registry);
3662
+ * const productSchema = await service.getObjectSchema("obj-123");
3663
+ *
3664
+ * console.log(productSchema.attributes); // System + custom attributes
3665
+ * ```
3666
+ */
3667
+ getObjectSchema(objectId: string): Promise<ObjectDefinition>;
3668
+ /**
3669
+ * Get object schema by name (for system/native objects)
3670
+ * @deprecated Use getObjectSchemaByNameForTenant for custom objects support
3671
+ */
3672
+ getObjectSchemaByName(name: string): Promise<ObjectDefinition>;
3673
+ /**
3674
+ * Get object schema by name for a tenant (supports both native and custom objects)
3675
+ */
3676
+ getObjectSchemaByNameForTenant(name: string, tenantId: string): Promise<ObjectDefinition>;
3677
+ /**
3678
+ * List all object schemas for a tenant
3679
+ */
3680
+ listObjectSchemas(tenantId: string): Promise<ObjectDefinition[]>;
3681
+ /**
3682
+ * Merge native object from registry with custom attributes from DB
3683
+ * @internal
3684
+ */
3685
+ private mergeNativeObject;
3686
+ /**
3687
+ * Convert DB object + attributes to ObjectDefinition
3688
+ * @internal
3689
+ */
3690
+ private convertDBObjectToDefinition;
3691
+ /**
3692
+ * Validate attribute input and return parsed config
3693
+ * Validates: name format, config schema, relation targets
3694
+ * @internal
3695
+ */
3696
+ private validateAttributeInput;
3697
+ /**
3698
+ * Build and validate attribute config from input
3699
+ * Uses Zod schema to validate and strip unknown properties
3700
+ * @internal
3701
+ */
3702
+ private buildAttributeConfig;
3703
+ /**
3704
+ * Validate that relation target objects exist
3705
+ * @internal
3706
+ */
3707
+ private validateRelationTargets;
3708
+ /**
3709
+ * Convert DB attribute to Attribute type
3710
+ * @internal
3711
+ */
3712
+ private convertDBAttributeToAttribute;
3713
+ }
3714
+
3715
+ /**
3716
+ * Options for PermissionService constructor
3717
+ */
3718
+ interface PermissionServiceOptions {
3719
+ /**
3720
+ * Cache TTL in milliseconds.
3721
+ * @default 60000 (1 minute)
3722
+ */
3723
+ cacheTtlMs?: number;
3724
+ }
3725
+ /**
3726
+ * Service for checking and managing permissions.
3727
+ *
3728
+ * Features:
3729
+ * - In-memory cache with TTL for effective permissions
3730
+ * - Admin bypass for full access
3731
+ * - Wildcard permission support (target: "*")
3732
+ * - Object-level permission checks
3733
+ *
3734
+ * @example
3735
+ * ```typescript
3736
+ * const permissionService = new PermissionService(adapter, "tenant-123");
3737
+ *
3738
+ * // Check if user can read companies
3739
+ * const canRead = await permissionService.canAccessObject(userId, "companies", "read");
3740
+ *
3741
+ * // Throw if user cannot update
3742
+ * await permissionService.checkObjectAccess(userId, "companies", "update");
3743
+ * ```
3744
+ */
3745
+ declare class PermissionService {
3746
+ private readonly adapter;
3747
+ private readonly tenantId;
3748
+ private cache;
3749
+ private readonly cacheTtlMs;
3750
+ constructor(adapter: DatabaseAdapter, tenantId: string, options?: PermissionServiceOptions);
3751
+ /**
3752
+ * Check if user can perform an action on an object.
3753
+ *
3754
+ * @param userId - User ID to check
3755
+ * @param objectName - Object name to check access for
3756
+ * @param action - Action to check (read, create, update, delete)
3757
+ * @returns true if user has permission, false otherwise
3758
+ */
3759
+ canAccessObject(userId: string, objectName: string, action: ObjectAction): Promise<boolean>;
3760
+ /**
3761
+ * Check if user can access an object, throw ForbiddenError if not.
3762
+ *
3763
+ * @param userId - User ID to check
3764
+ * @param objectName - Object name to check access for
3765
+ * @param action - Action to check
3766
+ * @throws ForbiddenError if user lacks permission
3767
+ */
3768
+ checkObjectAccess(userId: string, objectName: string, action: ObjectAction): Promise<void>;
3769
+ /**
3770
+ * Get permissions for a specific object as boolean flags.
3771
+ *
3772
+ * @param userId - User ID to check
3773
+ * @param objectName - Object name to check
3774
+ * @returns Object with canRead, canCreate, canUpdate, canDelete flags
3775
+ */
3776
+ getObjectPermissions(userId: string, objectName: string): Promise<ObjectPermissions>;
3777
+ /**
3778
+ * Get effective permissions for a user.
3779
+ * Results are cached with TTL.
3780
+ *
3781
+ * @param userId - User ID
3782
+ * @returns Merged permissions from all user's roles
3783
+ */
3784
+ getEffectivePermissions(userId: string): Promise<EffectivePermissions>;
3785
+ /**
3786
+ * Invalidate cached permissions for a specific user.
3787
+ * Call this after role/permission changes.
3788
+ */
3789
+ invalidateCache(userId: string): void;
3790
+ /**
3791
+ * Invalidate all cached permissions.
3792
+ * Call this after bulk role/permission changes.
3793
+ */
3794
+ invalidateAllCache(): void;
3795
+ private getCacheKey;
3796
+ /**
3797
+ * Get all roles for the current tenant.
3798
+ */
3799
+ getRoles(): Promise<Role[]>;
3800
+ /**
3801
+ * Get a role by ID.
3802
+ */
3803
+ getRoleById(roleId: string): Promise<Role | null>;
3804
+ /**
3805
+ * Create a new role.
3806
+ */
3807
+ createRole(input: Omit<CreateRoleInput, "tenantId">): Promise<Role>;
3808
+ /**
3809
+ * Update a role.
3810
+ */
3811
+ updateRole(roleId: string, updates: UpdateRoleInput): Promise<Role>;
3812
+ /**
3813
+ * Delete a role.
3814
+ */
3815
+ deleteRole(roleId: string): Promise<void>;
3816
+ /**
3817
+ * Get all permissions for a role.
3818
+ */
3819
+ getPermissionsByRole(roleId: string): Promise<Permission[]>;
3820
+ /**
3821
+ * Set permissions for a role (replaces existing).
3822
+ */
3823
+ setPermissions(roleId: string, permissions: CreatePermissionInput[]): Promise<void>;
3824
+ /**
3825
+ * Get all roles assigned to a user.
3826
+ */
3827
+ getUserRoles(userId: string): Promise<Role[]>;
3828
+ /**
3829
+ * Assign a role to a user.
3830
+ */
3831
+ assignRole(userId: string, roleId: string, assignedBy?: string): Promise<UserRoleAssignment>;
3832
+ /**
3833
+ * Revoke a role from a user.
3834
+ */
3835
+ revokeRole(userId: string, roleId: string): Promise<void>;
3836
+ }
3837
+
3838
+ /**
3839
+ * Options for RecordService constructor
3840
+ */
3841
+ interface RecordServiceOptions {
3842
+ /**
3843
+ * Hook registry for executing triggers before/after operations.
3844
+ * If not provided, a no-op registry is used (no hooks executed).
3845
+ */
3846
+ hookRegistry?: HookRegistry;
3847
+ /**
3848
+ * Permission service for access control.
3849
+ * If provided along with userId, permission checks are enforced.
3850
+ * If not provided, no permission checks are performed (backward compatible).
3851
+ */
3852
+ permissionService?: PermissionService;
3853
+ /**
3854
+ * Current user ID for permission checks.
3855
+ * Required when permissionService is provided.
3856
+ */
3857
+ userId?: string;
3858
+ }
3859
+ /**
3860
+ * Service for managing object records (CRUD operations)
3861
+ * Handles validation, dispatch to correct table, and data consistency
3862
+ *
3863
+ * Supports optional hook system for triggers on attribute changes.
3864
+ * Supports optional permission checks when permissionService and userId are provided.
3865
+ */
3866
+ declare class RecordService {
3867
+ private adapter;
3868
+ private tenantId;
3869
+ private schemaService;
3870
+ private relationService;
3871
+ private hookRegistry;
3872
+ private permissionService?;
3873
+ private userId?;
3874
+ constructor(adapter: DatabaseAdapter, tenantId: string, options?: RecordServiceOptions);
3875
+ /**
3876
+ * Check permission for an action on an object.
3877
+ * Only checks if permissionService and userId are configured.
3878
+ * @internal
3879
+ */
3880
+ private checkPermission;
3881
+ /**
3882
+ * Compute display label from schema expression
3883
+ * Automatically resolves relation attribute values to their labels
3884
+ * @internal
3885
+ */
3886
+ private computeLabel;
3887
+ /**
3888
+ * Create a new record with validation
3889
+ *
3890
+ * Triggers beforeCreate and afterCreate hooks if a HookRegistry is configured.
3891
+ *
3892
+ * @param objectId - Object UUID
3893
+ * @param data - Record data (attribute values)
3894
+ * @param options - Creation options
3895
+ * @returns Created record with computed completionStatus
3896
+ *
3897
+ * @example
3898
+ * ```typescript
3899
+ * const service = new RecordService(adapter, "tenant-123");
3900
+ *
3901
+ * // Create a complete record (strict validation)
3902
+ * const product = await service.createRecord("obj-product", {
3903
+ * name: "Nike Air Max",
3904
+ * price: 129.99,
3905
+ * status: "active"
3906
+ * });
3907
+ * // → product.completionStatus = "complete"
3908
+ *
3909
+ * // Create a draft record (allows missing required fields)
3910
+ * const draft = await service.createRecord("obj-product", {
3911
+ * name: "Draft Product"
3912
+ * }, { allowDraft: true });
3913
+ * // → draft.completionStatus = "draft"
3914
+ * ```
3915
+ */
3916
+ createRecord(objectId: string, data: Record<string, unknown>, options?: {
3917
+ /**
3918
+ * Allow creating records with missing required fields.
3919
+ * Format validation still applies to provided values.
3920
+ * @default false
3921
+ */
3922
+ allowDraft?: boolean;
3923
+ /**
3924
+ * Skip all validation (format + relations).
3925
+ * @default true
3926
+ */
3927
+ validate?: boolean;
3928
+ /**
3929
+ * Skip relation validation only.
3930
+ * Useful for bulk imports where relations are validated separately.
3931
+ * @default false
3932
+ */
3933
+ skipRelationValidation?: boolean;
3934
+ skipSystemCheck?: boolean;
3935
+ /**
3936
+ * Skip hook execution.
3937
+ * @default false
3938
+ */
3939
+ skipHooks?: boolean;
3940
+ /**
3941
+ * Additional metadata to pass to hooks (e.g., userId, requestId).
3942
+ */
3943
+ hookMetadata?: Record<string, unknown>;
3944
+ }): Promise<ObjectRecord>;
3945
+ /**
3946
+ * Get a record by ID
3947
+ *
3948
+ * @param recordId - Record UUID
3949
+ * @param options - Query options
3950
+ * @returns Record or null if not found
3951
+ */
3952
+ getRecord(recordId: string, options?: {
3953
+ includeSchema?: boolean;
3954
+ }): Promise<ObjectRecord | null>;
3955
+ /**
3956
+ * Get a record by ID or throw if not found
3957
+ */
3958
+ getRecordOrThrow(recordId: string): Promise<ObjectRecord>;
3959
+ /**
3960
+ * Update a record with validation
3961
+ *
3962
+ * The completion status is automatically recalculated after each update.
3963
+ * A draft record becomes complete when all required fields are filled.
3964
+ *
3965
+ * Triggers beforeUpdate and afterUpdate hooks if a HookRegistry is configured.
3966
+ *
3967
+ * @param recordId - Record UUID
3968
+ * @param data - Partial data to update
3969
+ * @param options - Update options
3970
+ * @returns Updated record with recalculated completionStatus
3971
+ *
3972
+ * @example
3973
+ * ```typescript
3974
+ * // Update a draft record to make it complete
3975
+ * const updated = await service.updateRecord(draftId, {
3976
+ * price: 99.99,
3977
+ * status: "active"
3978
+ * });
3979
+ * // → updated.completionStatus = "complete" if all required fields now present
3980
+ * ```
3981
+ */
3982
+ updateRecord(recordId: string, data: Partial<Record<string, unknown>>, options?: {
3983
+ /**
3984
+ * Skip validation entirely (format + relations).
3985
+ * @default true
3986
+ */
3987
+ validate?: boolean;
3988
+ /**
3989
+ * Allow partial updates without strict validation.
3990
+ * Format validation still applies to provided values.
3991
+ * @default false
3992
+ */
3993
+ partial?: boolean;
3994
+ /**
3995
+ * Skip relation validation only.
3996
+ * @default false
3997
+ */
3998
+ skipRelationValidation?: boolean;
3999
+ /**
4000
+ * Skip hook execution.
4001
+ * @default false
4002
+ */
4003
+ skipHooks?: boolean;
4004
+ /**
4005
+ * Additional metadata to pass to hooks (e.g., userId, requestId).
4006
+ */
4007
+ hookMetadata?: Record<string, unknown>;
4008
+ }): Promise<ObjectRecord>;
4009
+ /**
4010
+ * Build hook context for update operations
4011
+ * @internal
4012
+ */
4013
+ private buildHookContext;
4014
+ /**
4015
+ * Build hook context for create operations (no existing record)
4016
+ * @internal
4017
+ */
4018
+ private buildCreateHookContext;
4019
+ /**
4020
+ * Build hook context for delete operations
4021
+ * @internal
4022
+ */
4023
+ private buildDeleteHookContext;
4024
+ /**
4025
+ * Delete a record
4026
+ *
4027
+ * Triggers beforeDelete and afterDelete hooks if a HookRegistry is configured.
4028
+ *
4029
+ * @param recordId - Record UUID
4030
+ * @param options - Delete options
4031
+ */
4032
+ deleteRecord(recordId: string, options?: {
4033
+ checkSystem?: boolean;
4034
+ /**
4035
+ * Skip hook execution.
4036
+ * @default false
4037
+ */
4038
+ skipHooks?: boolean;
4039
+ /**
4040
+ * Additional metadata to pass to hooks (e.g., userId, requestId).
4041
+ */
4042
+ hookMetadata?: Record<string, unknown>;
4043
+ }): Promise<void>;
4044
+ /**
4045
+ * List records for an object with pagination
4046
+ *
4047
+ * @param objectId - Object UUID
4048
+ * @param options - List options
4049
+ * @returns Records and total count
4050
+ */
4051
+ listRecords(objectId: string, options?: ListOptions): Promise<{
4052
+ records: ObjectRecord[];
4053
+ total: number;
4054
+ }>;
4055
+ /**
4056
+ * Search records using full-text search
4057
+ *
4058
+ * @param objectId - Object UUID
4059
+ * @param query - Search query
4060
+ * @param options - Search options
4061
+ * @returns Matching records and total count
4062
+ */
4063
+ searchRecords(objectId: string, query: string, options?: SearchOptions): Promise<{
4064
+ records: ObjectRecord[];
4065
+ total: number;
4066
+ }>;
4067
+ /**
4068
+ * Validate data against object schema without saving
4069
+ *
4070
+ * @param objectId - Object UUID
4071
+ * @param data - Data to validate
4072
+ * @returns Validation result
4073
+ */
4074
+ validateData(objectId: string, data: Record<string, unknown>): Promise<ValidationResult>;
4075
+ /**
4076
+ * Compute the completion status for given data without saving.
4077
+ * Useful for UI to show draft/complete status before submitting.
4078
+ *
4079
+ * @param objectId - Object UUID
4080
+ * @param data - Data to check
4081
+ * @returns Computed completion status
4082
+ */
4083
+ computeStatus(objectId: string, data: Record<string, unknown>): Promise<CompletionStatus>;
4084
+ /**
4085
+ * Refresh the completion status of an existing record.
4086
+ * Useful when schema changes and you need to recompute statuses.
4087
+ *
4088
+ * @param recordId - Record UUID
4089
+ * @returns Updated completion status
4090
+ */
4091
+ refreshRecordStatus(recordId: string): Promise<CompletionStatus>;
4092
+ }
4093
+
4094
+ /**
4095
+ * Result of relation validation
4096
+ */
4097
+ interface RelationValidationResult {
4098
+ valid: boolean;
4099
+ errors: RelationValidationError[];
4100
+ }
4101
+ /**
4102
+ * Individual relation validation error
4103
+ */
4104
+ interface RelationValidationError {
4105
+ /** Attribute name */
4106
+ attribute: string;
4107
+ /** Error message */
4108
+ message: string;
4109
+ /** Invalid record IDs */
4110
+ invalidIds?: string[];
4111
+ }
4112
+ /**
4113
+ * Resolved relation option
4114
+ */
4115
+ interface RelationOption {
4116
+ /** Record ID */
4117
+ id: string;
4118
+ /** Object ID */
4119
+ objectId: string;
4120
+ /** Object name (technical name) */
4121
+ objectName: string;
4122
+ /** Object label (display name) */
4123
+ objectLabel: string;
4124
+ /** Object icon */
4125
+ objectIcon?: string;
4126
+ /** Display label (computed from labelExpression) */
4127
+ label: string;
4128
+ /** Additional record data */
4129
+ data?: Record<string, unknown>;
4130
+ }
4131
+ /**
4132
+ * Response for relation options
4133
+ */
4134
+ interface RelationOptionsResponse {
4135
+ options: RelationOption[];
4136
+ hasMore: boolean;
4137
+ total: number;
4138
+ }
4139
+ /**
4140
+ * Parameters for fetching relation options
4141
+ */
4142
+ interface GetRelationOptionsParams {
4143
+ /** Search query */
4144
+ query?: string;
4145
+ /** Page number (1-based) */
4146
+ page?: number;
4147
+ /** Page size */
4148
+ pageSize?: number;
4149
+ /** Filter by specific target object */
4150
+ targetObject?: string;
4151
+ }
4152
+ /**
4153
+ * Service for validating relation attributes
4154
+ * Ensures referenced records exist and belong to valid target objects
4155
+ */
4156
+ declare class RelationService {
4157
+ private adapter;
4158
+ private schemaService;
4159
+ constructor(adapter: DatabaseAdapter, nativeRegistry: typeof registry);
4160
+ /**
4161
+ * Validate all relation attributes in the data
4162
+ *
4163
+ * @param schema - Object schema containing attribute definitions
4164
+ * @param data - Record data to validate
4165
+ * @returns Validation result with errors if any
4166
+ *
4167
+ * @example
4168
+ * ```typescript
4169
+ * const result = await relationService.validateRelations(schema, {
4170
+ * company: "rec-123",
4171
+ * contacts: ["rec-456", "rec-789"]
4172
+ * });
4173
+ *
4174
+ * if (!result.valid) {
4175
+ * console.log(result.errors);
4176
+ * // [{ attribute: "company", message: "Record not found", invalidIds: ["rec-123"] }]
4177
+ * }
4178
+ * ```
4179
+ */
4180
+ validateRelations(schema: ObjectDefinition, data: Record<string, unknown>): Promise<RelationValidationResult>;
4181
+ /**
4182
+ * Validate a single relation attribute value
4183
+ */
4184
+ private validateRelationAttribute;
4185
+ /**
4186
+ * Extract IDs from relation value based on cardinality
4187
+ */
4188
+ private extractIds;
4189
+ /**
4190
+ * Get valid object IDs from relation targets
4191
+ */
4192
+ private getValidObjectIds;
4193
+ /**
4194
+ * Validate relations and throw if invalid
4195
+ */
4196
+ validateRelationsOrThrow(schema: ObjectDefinition, data: Record<string, unknown>): Promise<void>;
4197
+ /**
4198
+ * Get available options for a relation attribute
4199
+ * Searches across all target objects defined in the relation
4200
+ *
4201
+ * @param attribute - Relation attribute definition
4202
+ * @param tenantId - Tenant ID for multi-tenant isolation
4203
+ * @param params - Query parameters
4204
+ *
4205
+ * @example
4206
+ * ```typescript
4207
+ * const options = await relationService.getOptions(attribute, "tenant-1", {
4208
+ * query: "nike",
4209
+ * page: 1,
4210
+ * pageSize: 20
4211
+ * });
4212
+ * ```
4213
+ */
4214
+ getOptions(attribute: RelationAttribute, tenantId: string, params?: GetRelationOptionsParams): Promise<RelationOptionsResponse>;
4215
+ /**
4216
+ * Resolve record IDs to their display labels
4217
+ * Useful for displaying current values in the UI
4218
+ *
4219
+ * @param ids - Record IDs to resolve
4220
+ * @param tenantId - Tenant ID for multi-tenant isolation
4221
+ *
4222
+ * @example
4223
+ * ```typescript
4224
+ * const resolved = await relationService.resolveIds(["rec-1", "rec-2"], "tenant-1");
4225
+ * // [{ id: "rec-1", label: "Nike Air Max", objectName: "products", ... }]
4226
+ * ```
4227
+ */
4228
+ resolveIds(ids: string[], tenantId: string): Promise<RelationOption[]>;
4229
+ /**
4230
+ * Find a relation attribute by ID
4231
+ */
4232
+ findAttributeById(attributeId: string): Promise<RelationAttribute | null>;
4233
+ }
4234
+
4235
+ /**
4236
+ * Service for managing user profiles
4237
+ * Handles user profile CRUD, auth provider sync, and role management
4238
+ */
4239
+ declare class UserProfileService {
4240
+ private adapter;
4241
+ private tenantId;
4242
+ constructor(adapter: DatabaseAdapter, tenantId: string);
4243
+ /**
4244
+ * Create a new user profile (typically after first auth)
4245
+ *
4246
+ * @param data - User profile creation data
4247
+ * @returns Created user profile
4248
+ *
4249
+ * @example
4250
+ * ```typescript
4251
+ * const service = new UserProfileService(adapter, "tenant-123");
4252
+ *
4253
+ * // After Supabase auth
4254
+ * const profile = await service.createProfile({
4255
+ * tenantId: "tenant-123",
4256
+ * authId: authUser.id,
4257
+ * email: authUser.email,
4258
+ * firstName: authUser.user_metadata.first_name,
4259
+ * lastName: authUser.user_metadata.last_name,
4260
+ * role: "member",
4261
+ * status: "active"
4262
+ * });
4263
+ * ```
4264
+ */
4265
+ createProfile(data: CreateUserProfile): Promise<UserProfile>;
4266
+ /**
4267
+ * Get user profile by ID
4268
+ */
4269
+ getProfile(profileId: string): Promise<UserProfile | null>;
4270
+ /**
4271
+ * Get user profile by ID or throw
4272
+ */
4273
+ getProfileOrThrow(profileId: string): Promise<UserProfile>;
4274
+ /**
4275
+ * Get user profile by auth provider ID
4276
+ *
4277
+ * @param authId - Auth provider user ID (Supabase, Clerk, etc.)
4278
+ * @returns User profile or null
4279
+ */
4280
+ getProfileByAuthId(authId: string): Promise<UserProfile | null>;
4281
+ /**
4282
+ * Get or create user profile (idempotent operation)
4283
+ * Useful for auth callbacks - ensures profile exists
4284
+ *
4285
+ * @param authId - Auth provider user ID
4286
+ * @param data - Profile data to create if doesn't exist
4287
+ * @returns Existing or newly created profile
4288
+ *
4289
+ * @example
4290
+ * ```typescript
4291
+ * // In Supabase auth callback
4292
+ * const profile = await service.getOrCreateProfile(
4293
+ * authUser.id,
4294
+ * {
4295
+ * tenantId: "tenant-123",
4296
+ * authId: authUser.id,
4297
+ * email: authUser.email,
4298
+ * role: "member",
4299
+ * status: "active"
4300
+ * }
4301
+ * );
4302
+ * ```
4303
+ */
4304
+ getOrCreateProfile(authId: string, data: CreateUserProfile): Promise<UserProfile>;
4305
+ /**
4306
+ * Update user profile
4307
+ */
4308
+ updateProfile(profileId: string, data: UpdateUserProfile): Promise<UserProfile>;
4309
+ /**
4310
+ * Delete user profile
4311
+ *
4312
+ * @param profileId - Profile UUID
4313
+ * @param options - Delete options
4314
+ */
4315
+ deleteProfile(profileId: string, options?: {
4316
+ checkAdmin?: boolean;
4317
+ }): Promise<void>;
4318
+ /**
4319
+ * List all user profiles for the tenant
4320
+ */
4321
+ listProfiles(options?: ListOptions): Promise<UserProfile[]>;
4322
+ /**
4323
+ * Update last login timestamp
4324
+ *
4325
+ * @param profileId - Profile UUID
4326
+ *
4327
+ * @example
4328
+ * ```typescript
4329
+ * // After successful auth
4330
+ * await service.updateLastLogin(profile.id);
4331
+ * ```
4332
+ */
4333
+ updateLastLogin(profileId: string): Promise<void>;
4334
+ /**
4335
+ * Change user role
4336
+ *
4337
+ * @param profileId - Profile UUID
4338
+ * @param newRole - New role
4339
+ */
4340
+ changeRole(profileId: string, newRole: string): Promise<UserProfile>;
4341
+ /**
4342
+ * Change user status
4343
+ *
4344
+ * @param profileId - Profile UUID
4345
+ * @param newStatus - New status
4346
+ */
4347
+ changeStatus(profileId: string, newStatus: "active" | "pending" | "inactive" | "suspended"): Promise<UserProfile>;
4348
+ /**
4349
+ * Get user by email
4350
+ */
4351
+ getProfileByEmail(email: string): Promise<UserProfile | null>;
4352
+ /**
4353
+ * Check if user has role
4354
+ */
4355
+ hasRole(profileId: string, role: string): Promise<boolean>;
4356
+ /**
4357
+ * Check if user is admin
4358
+ */
4359
+ isAdmin(profileId: string): Promise<boolean>;
4360
+ }
4361
+
4362
+ /**
4363
+ * Input for creating a custom view
4364
+ */
4365
+ interface CreateViewInput {
4366
+ name: string;
4367
+ label: string;
4368
+ objectName: string;
4369
+ description?: string;
4370
+ icon?: IconName;
4371
+ tabs: Tab[];
4372
+ default?: boolean;
4373
+ metadata?: Record<string, unknown>;
4374
+ }
4375
+ /**
4376
+ * Input for updating a view
4377
+ */
4378
+ interface UpdateViewInput {
4379
+ label?: string;
4380
+ description?: string;
4381
+ icon?: IconName;
4382
+ tabs?: Tab[];
4383
+ default?: boolean;
4384
+ metadata?: Record<string, unknown>;
4385
+ }
4386
+ /**
4387
+ * Service for managing views
4388
+ * Handles fusion of native views (from registry) and custom views (from database)
4389
+ */
4390
+ declare class ViewService {
4391
+ private adapter;
4392
+ private nativeViews;
4393
+ constructor(adapter: DatabaseAdapter, nativeViews: typeof viewRegistry);
4394
+ /**
4395
+ * Get all views for an object (native + custom)
4396
+ *
4397
+ * @param objectName - Object name
4398
+ * @param tenantId - Tenant ID
4399
+ * @returns All views for the object
4400
+ */
4401
+ getViewsForObject(objectName: string, tenantId: string): Promise<ViewDefinition[]>;
4402
+ /**
4403
+ * Get a specific view by name
4404
+ *
4405
+ * @param objectName - Object name
4406
+ * @param viewName - View name
4407
+ * @param tenantId - Tenant ID
4408
+ * @returns View definition or null
4409
+ */
4410
+ getView(objectName: string, viewName: string, tenantId: string): Promise<ViewDefinition | null>;
4411
+ /**
4412
+ * Get the default view for an object
4413
+ *
4414
+ * Priority:
4415
+ * 1. Custom view marked as default
4416
+ * 2. Native view marked as default
4417
+ * 3. First available view
4418
+ *
4419
+ * @param objectName - Object name
4420
+ * @param tenantId - Tenant ID
4421
+ * @returns Default view or null
4422
+ */
4423
+ getDefaultView(objectName: string, tenantId: string): Promise<ViewDefinition | null>;
4424
+ /**
4425
+ * Create a custom view
4426
+ *
4427
+ * @param input - View definition
4428
+ * @param tenantId - Tenant ID
4429
+ * @returns Created view
4430
+ */
4431
+ createView(input: CreateViewInput, tenantId: string): Promise<ViewDefinition>;
4432
+ /**
4433
+ * Update a custom view
4434
+ *
4435
+ * @param viewId - View ID
4436
+ * @param input - Update data
4437
+ * @returns Updated view
4438
+ */
4439
+ updateView(viewId: string, input: UpdateViewInput): Promise<ViewDefinition>;
4440
+ /**
4441
+ * Delete a custom view
4442
+ *
4443
+ * @param viewId - View ID
4444
+ */
4445
+ deleteView(viewId: string): Promise<void>;
4446
+ /**
4447
+ * Set a view as default for its object
4448
+ *
4449
+ * @param viewId - View ID
4450
+ * @param tenantId - Tenant ID
4451
+ * @returns Updated view
4452
+ */
4453
+ setDefaultView(viewId: string, tenantId: string): Promise<ViewDefinition>;
4454
+ /**
4455
+ * Validate view name format (kebab-case)
4456
+ */
4457
+ private validateViewName;
4458
+ /**
4459
+ * Convert database view to ViewDefinition
4460
+ */
4461
+ private convertDBViewToDefinition;
4462
+ }
4463
+
4464
+ /**
4465
+ * Result of view sync operation
4466
+ */
4467
+ interface ViewSyncResult {
4468
+ success: boolean;
4469
+ viewsSynced: number;
4470
+ viewsCreated: number;
4471
+ viewsUpdated: number;
4472
+ viewsDeleted: number;
4473
+ errors: Array<{
4474
+ viewName: string;
4475
+ objectName: string;
4476
+ error: string;
4477
+ }>;
4478
+ }
4479
+ /**
4480
+ * Options for view sync
4481
+ */
4482
+ interface ViewSyncOptions {
4483
+ dryRun?: boolean;
4484
+ verbose?: boolean;
4485
+ tenantId?: string;
4486
+ }
4487
+ /**
4488
+ * Sync native views from registry to database
4489
+ *
4490
+ * This function:
4491
+ * 1. Reads all registered native views from the registry
4492
+ * 2. Upserts them into the database (views table)
4493
+ * 3. Marks them as system=true for protection
4494
+ * 4. Removes views that were deleted from code
4495
+ *
4496
+ * @param adapter - Database adapter implementing DatabaseAdapter interface
4497
+ * @param nativeViewRegistry - Registry containing native views
4498
+ * @param options - Sync options (dryRun, verbose, tenantId)
4499
+ * @returns Sync result with statistics
4500
+ *
4501
+ * @example
4502
+ * ```typescript
4503
+ * import { syncNativeViews, viewRegistry } from "@stndrds/schema";
4504
+ * import { drizzleAdapter } from "./db/adapter";
4505
+ *
4506
+ * const result = await syncNativeViews(drizzleAdapter, viewRegistry, {
4507
+ * verbose: true,
4508
+ * tenantId: "default"
4509
+ * });
4510
+ *
4511
+ * if (result.success) {
4512
+ * console.log(`✓ Synced ${result.viewsSynced} views`);
4513
+ * }
4514
+ * ```
4515
+ */
4516
+ declare function syncNativeViews(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry, options?: ViewSyncOptions): Promise<ViewSyncResult>;
4517
+ /**
4518
+ * Verify that all native views are synced to database
4519
+ *
4520
+ * @param adapter - Database adapter
4521
+ * @param nativeViewRegistry - Registry containing native views
4522
+ * @returns true if all views are synced, false otherwise
4523
+ *
4524
+ * @example
4525
+ * ```typescript
4526
+ * const isSynced = await verifyNativeViewsSync(adapter, viewRegistry);
4527
+ * if (!isSynced) {
4528
+ * console.warn("Native views not synced, running sync...");
4529
+ * await syncNativeViews(adapter, viewRegistry);
4530
+ * }
4531
+ * ```
4532
+ */
4533
+ declare function verifyNativeViewsSync(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry): Promise<boolean>;
4534
+ /**
4535
+ * Get sync preview without modifying database
4536
+ *
4537
+ * @param adapter - Database adapter
4538
+ * @param nativeViewRegistry - Registry containing native views
4539
+ * @returns Sync result (dry run)
4540
+ */
4541
+ declare function getViewSyncPreview(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry): Promise<ViewSyncResult>;
4542
+
4543
+ /**
4544
+ * Result of sync operation
4545
+ */
4546
+ interface SyncResult {
4547
+ success: boolean;
4548
+ objectsSynced: number;
4549
+ attributesSynced: number;
4550
+ objectsCreated: number;
4551
+ objectsUpdated: number;
4552
+ attributesCreated: number;
4553
+ attributesUpdated: number;
4554
+ attributesDeleted: number;
4555
+ errors: Array<{
4556
+ objectName: string;
4557
+ error: string;
4558
+ }>;
4559
+ }
4560
+ /**
4561
+ * Sync options
4562
+ */
4563
+ interface SyncOptions {
4564
+ dryRun?: boolean;
4565
+ verbose?: boolean;
4566
+ tenantId?: string;
4567
+ }
4568
+ /**
4569
+ * Sync native objects from registry to database
4570
+ *
4571
+ * This function:
4572
+ * 1. Reads all registered native objects from the registry
4573
+ * 2. Upserts them into the database (objects + attributes tables)
4574
+ * 3. Marks them as system=true for protection
4575
+ * 4. Removes attributes that were deleted from code
4576
+ *
4577
+ * @param adapter - Database adapter implementing DatabaseAdapter interface
4578
+ * @param nativeRegistry - Registry containing native objects
4579
+ * @param options - Sync options (dryRun, verbose, tenantId)
4580
+ * @returns Sync result with statistics
4581
+ *
4582
+ * @example
4583
+ * ```typescript
4584
+ * import { syncNativeObjects } from "@stndrds/schema/runtime";
4585
+ * import { registry } from "./objects/native";
4586
+ * import { drizzleAdapter } from "./db/adapter";
4587
+ *
4588
+ * const result = await syncNativeObjects(drizzleAdapter, registry, {
4589
+ * verbose: true,
4590
+ * tenantId: "default"
4591
+ * });
4592
+ *
4593
+ * if (result.success) {
4594
+ * console.log(`✓ Synced ${result.objectsSynced} objects`);
4595
+ * } else {
4596
+ * console.error("Sync errors:", result.errors);
4597
+ * }
4598
+ * ```
4599
+ */
4600
+ declare function syncNativeObjects(adapter: DatabaseAdapter, nativeRegistry: typeof registry, options?: SyncOptions): Promise<SyncResult>;
4601
+ /**
4602
+ * Verify that all native objects are synced to database
4603
+ *
4604
+ * @param adapter - Database adapter
4605
+ * @param nativeRegistry - Registry containing native objects
4606
+ * @returns true if all objects are synced, false otherwise
4607
+ *
4608
+ * @example
4609
+ * ```typescript
4610
+ * const isSynced = await verifyNativeObjectsSync(adapter, registry);
4611
+ * if (!isSynced) {
4612
+ * console.warn("Native objects not synced, running sync...");
4613
+ * await syncNativeObjects(adapter, registry);
4614
+ * }
4615
+ * ```
4616
+ */
4617
+ declare function verifyNativeObjectsSync(adapter: DatabaseAdapter, nativeRegistry: typeof registry): Promise<boolean>;
4618
+ /**
4619
+ * Get sync statistics without modifying database
4620
+ *
4621
+ * @param adapter - Database adapter
4622
+ * @param nativeRegistry - Registry containing native objects
4623
+ * @returns Sync result (dry run)
4624
+ */
4625
+ declare function getSyncPreview(adapter: DatabaseAdapter, nativeRegistry: typeof registry): Promise<SyncResult>;
4626
+ /**
4627
+ * Result of full sync operation (objects + views)
4628
+ */
4629
+ interface FullSyncResult {
4630
+ success: boolean;
4631
+ objects: SyncResult;
4632
+ views: ViewSyncResult;
4633
+ }
4634
+ /**
4635
+ * Options for full sync
4636
+ */
4637
+ interface FullSyncOptions extends SyncOptions, ViewSyncOptions {
4638
+ }
4639
+ /**
4640
+ * Sync all native objects and views from registries to database
4641
+ *
4642
+ * This is a convenience function that:
4643
+ * 1. Syncs native objects first (views may depend on objects)
4644
+ * 2. Syncs native views
4645
+ *
4646
+ * @param adapter - Database adapter
4647
+ * @param objectRegistry - Registry containing native objects
4648
+ * @param nativeViewRegistry - Registry containing native views
4649
+ * @param options - Sync options
4650
+ * @returns Combined sync result
4651
+ *
4652
+ * @example
4653
+ * ```typescript
4654
+ * import { syncAll, registry, viewRegistry } from "@stndrds/schema";
4655
+ * import { adapter } from "./db";
4656
+ *
4657
+ * const result = await syncAll(adapter, registry, viewRegistry, {
4658
+ * verbose: true,
4659
+ * tenantId: "default"
4660
+ * });
4661
+ *
4662
+ * if (result.success) {
4663
+ * console.log(`✓ Synced ${result.objects.objectsSynced} objects, ${result.views.viewsSynced} views`);
4664
+ * }
4665
+ * ```
4666
+ */
4667
+ declare function syncAll(adapter: DatabaseAdapter, objectRegistry: typeof registry, nativeViewRegistry: typeof viewRegistry, options?: FullSyncOptions): Promise<FullSyncResult>;
4668
+
4669
+ /**
4670
+ * Default fallback value when expression resolves to empty string
4671
+ */
4672
+ declare const DEFAULT_LABEL_FALLBACK = "(Untitled)";
4673
+ /**
4674
+ * Render a label expression template with values
4675
+ *
4676
+ * Supports:
4677
+ * - Variable interpolation: `{{ fieldName }}`
4678
+ * - Dot notation: `{{ user.firstName }}`
4679
+ * - Pipes: `{{ name | UPPER }}`, `{{ name | capitalize | trim }}`
4680
+ *
4681
+ * @param template - The label expression template (e.g., "{{ firstName }} {{ lastName }}")
4682
+ * @param values - Record values to interpolate
4683
+ * @param fallback - Fallback value if result is empty (default: "(Untitled)")
4684
+ * @returns The rendered label string
4685
+ *
4686
+ * @example
4687
+ * ```typescript
4688
+ * const label = renderLabelExpression(
4689
+ * "{{ firstName }} {{ lastName | UPPER }}",
4690
+ * { firstName: "John", lastName: "Doe" }
4691
+ * );
4692
+ * // → "John DOE"
4693
+ *
4694
+ * // With missing values
4695
+ * const label = renderLabelExpression(
4696
+ * "{{ name }}",
4697
+ * { }
4698
+ * );
4699
+ * // → "(Untitled)"
4700
+ * ```
4701
+ */
4702
+ declare function renderLabelExpression(template: string, values: Record<string, unknown>, fallback?: string): string;
4703
+ /**
4704
+ * Check if a string is a valid label expression template
4705
+ * A valid template contains at least one {{ variable }} block with a non-empty variable
4706
+ */
4707
+ declare function isLabelExpression(value: string): boolean;
4708
+ /**
4709
+ * Extract attribute names referenced in a label expression
4710
+ * Useful for validation or dependency tracking
4711
+ *
4712
+ * @example
4713
+ * extractAttributeNames("{{ firstName }} {{ lastName | UPPER }}")
4714
+ * // → ["firstName", "lastName"]
4715
+ */
4716
+ declare function extractAttributeNames(template: string): string[];
4717
+
4718
+ 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 };