@stndrds/schema 0.1.0-alpha.14

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 (128) hide show
  1. package/dist/chunk-3ABIOLKO.mjs +4624 -0
  2. package/dist/chunk-3IRX2BDY.mjs +3970 -0
  3. package/dist/chunk-4OTLPWSP.mjs +4448 -0
  4. package/dist/chunk-54ODQBUN.mjs +3867 -0
  5. package/dist/chunk-6HIA3FR2.mjs +4230 -0
  6. package/dist/chunk-6P3XHNLD.mjs +4171 -0
  7. package/dist/chunk-7LJECNAS.mjs +4167 -0
  8. package/dist/chunk-A2WNLUKV.mjs +4475 -0
  9. package/dist/chunk-AA3234RM.mjs +4475 -0
  10. package/dist/chunk-ADNXDLLD.mjs +3136 -0
  11. package/dist/chunk-B4DCDQUI.mjs +4695 -0
  12. package/dist/chunk-B4PSXY6I.mjs +4527 -0
  13. package/dist/chunk-BJHJBZCM.mjs +4228 -0
  14. package/dist/chunk-C3ZWTO6G.mjs +4474 -0
  15. package/dist/chunk-CLOGNKDD.mjs +4040 -0
  16. package/dist/chunk-EW4V63PA.mjs +3053 -0
  17. package/dist/chunk-FR2LCO6R.mjs +2485 -0
  18. package/dist/chunk-GJSF2RKL.mjs +2786 -0
  19. package/dist/chunk-GO5NPP2X.mjs +4726 -0
  20. package/dist/chunk-H3ZYJUDS.mjs +3050 -0
  21. package/dist/chunk-IDDLSFSK.mjs +4230 -0
  22. package/dist/chunk-JRADUJQ7.mjs +4726 -0
  23. package/dist/chunk-NEDR6N7R.mjs +3118 -0
  24. package/dist/chunk-NESPRMDF.mjs +2482 -0
  25. package/dist/chunk-NWFGRJBW.mjs +4612 -0
  26. package/dist/chunk-NXJ57GSN.mjs +2918 -0
  27. package/dist/chunk-O4C5FCTS.mjs +3961 -0
  28. package/dist/chunk-O4PRB27Q.mjs +2513 -0
  29. package/dist/chunk-OJDFNUCR.mjs +4463 -0
  30. package/dist/chunk-OSEKVBHC.mjs +4627 -0
  31. package/dist/chunk-QX4U6U6K.mjs +2484 -0
  32. package/dist/chunk-RMDQ6LKV.mjs +3046 -0
  33. package/dist/chunk-SBXKDATH.mjs +2673 -0
  34. package/dist/chunk-SKMP3AP3.mjs +2918 -0
  35. package/dist/chunk-STMS7WZD.mjs +2623 -0
  36. package/dist/chunk-T3T6PTFG.mjs +3057 -0
  37. package/dist/chunk-TPW72RAH.mjs +4624 -0
  38. package/dist/chunk-TUQEGNGV.mjs +2534 -0
  39. package/dist/chunk-TVKFS3YN.mjs +2449 -0
  40. package/dist/chunk-TZTH3BHG.mjs +3110 -0
  41. package/dist/chunk-W6MU3XPG.mjs +4612 -0
  42. package/dist/chunk-WL7Z3YFR.mjs +4603 -0
  43. package/dist/chunk-XNVVYHH3.mjs +4602 -0
  44. package/dist/chunk-XTA3WY64.mjs +2918 -0
  45. package/dist/chunk-YV7DEZFZ.mjs +2528 -0
  46. package/dist/chunk-ZLJPJND6.mjs +4474 -0
  47. package/dist/chunk-ZNZXTCEX.mjs +4234 -0
  48. package/dist/index.d.mts +1222 -0
  49. package/dist/index.d.ts +1222 -0
  50. package/dist/index.js +5320 -0
  51. package/dist/index.mjs +635 -0
  52. package/dist/runtime-2iKarXtl.d.mts +1924 -0
  53. package/dist/runtime-2iKarXtl.d.ts +1924 -0
  54. package/dist/runtime-4l2ddHZ7.d.mts +2242 -0
  55. package/dist/runtime-4l2ddHZ7.d.ts +2243 -0
  56. package/dist/runtime-8hKS6zAv.d.mts +2226 -0
  57. package/dist/runtime-8hKS6zAv.d.ts +2226 -0
  58. package/dist/runtime-B6yjtoR3.d.mts +4142 -0
  59. package/dist/runtime-B6yjtoR3.d.ts +4142 -0
  60. package/dist/runtime-BGCShrZB.d.mts +2001 -0
  61. package/dist/runtime-BGCShrZB.d.ts +2001 -0
  62. package/dist/runtime-BRW4NGAk.d.mts +1668 -0
  63. package/dist/runtime-BRW4NGAk.d.ts +1668 -0
  64. package/dist/runtime-BnfBr314.d.mts +1683 -0
  65. package/dist/runtime-BnfBr314.d.ts +1683 -0
  66. package/dist/runtime-BrqhiJUF.d.mts +4151 -0
  67. package/dist/runtime-BrqhiJUF.d.ts +4151 -0
  68. package/dist/runtime-Bvj8c-BE.d.mts +4277 -0
  69. package/dist/runtime-Bvj8c-BE.d.ts +4277 -0
  70. package/dist/runtime-C03qT4qU.d.mts +4267 -0
  71. package/dist/runtime-C03qT4qU.d.ts +4267 -0
  72. package/dist/runtime-CaCZ7mSf.d.mts +2974 -0
  73. package/dist/runtime-CaCZ7mSf.d.ts +2974 -0
  74. package/dist/runtime-CaIzNX0Z.d.mts +4091 -0
  75. package/dist/runtime-CaIzNX0Z.d.ts +4091 -0
  76. package/dist/runtime-ChPTgmLP.d.mts +4320 -0
  77. package/dist/runtime-ChPTgmLP.d.ts +4320 -0
  78. package/dist/runtime-CnImZ1Vv.d.mts +4267 -0
  79. package/dist/runtime-CnImZ1Vv.d.ts +4267 -0
  80. package/dist/runtime-Cp-B26Nj.d.mts +2890 -0
  81. package/dist/runtime-Cp-B26Nj.d.ts +2890 -0
  82. package/dist/runtime-Cq8jfk3c.d.mts +4277 -0
  83. package/dist/runtime-Cq8jfk3c.d.ts +4277 -0
  84. package/dist/runtime-CqDFXhhP.d.mts +1685 -0
  85. package/dist/runtime-CqDFXhhP.d.ts +1685 -0
  86. package/dist/runtime-CqtpZLdL.d.mts +4280 -0
  87. package/dist/runtime-CqtpZLdL.d.ts +4280 -0
  88. package/dist/runtime-D-4DblaZ.d.mts +4147 -0
  89. package/dist/runtime-D-4DblaZ.d.ts +4147 -0
  90. package/dist/runtime-D59sSqNl.d.mts +4146 -0
  91. package/dist/runtime-D59sSqNl.d.ts +4146 -0
  92. package/dist/runtime-DEfPk3wT.d.mts +1840 -0
  93. package/dist/runtime-DEfPk3wT.d.ts +1840 -0
  94. package/dist/runtime-DGV-7vES.d.mts +1685 -0
  95. package/dist/runtime-DGV-7vES.d.ts +1685 -0
  96. package/dist/runtime-DNacghqc.d.mts +3971 -0
  97. package/dist/runtime-DNacghqc.d.ts +3971 -0
  98. package/dist/runtime-DPLsUHYK.d.mts +3977 -0
  99. package/dist/runtime-DPLsUHYK.d.ts +3977 -0
  100. package/dist/runtime-DTxCw60F.d.mts +2973 -0
  101. package/dist/runtime-DTxCw60F.d.ts +2973 -0
  102. package/dist/runtime-DUXJ-zNS.d.mts +2788 -0
  103. package/dist/runtime-DUXJ-zNS.d.ts +2788 -0
  104. package/dist/runtime-DbljInhV.d.mts +2237 -0
  105. package/dist/runtime-DbljInhV.d.ts +2237 -0
  106. package/dist/runtime-DcH3y6Yu.d.mts +4272 -0
  107. package/dist/runtime-DcH3y6Yu.d.ts +4272 -0
  108. package/dist/runtime-DdBFz85g.d.mts +4229 -0
  109. package/dist/runtime-DdBFz85g.d.ts +4229 -0
  110. package/dist/runtime-DjMWhjkm.d.mts +4321 -0
  111. package/dist/runtime-DjMWhjkm.d.ts +4321 -0
  112. package/dist/runtime-Djz3fOBE.d.mts +2078 -0
  113. package/dist/runtime-Djz3fOBE.d.ts +2078 -0
  114. package/dist/runtime-Dli8g3Aq.d.mts +2082 -0
  115. package/dist/runtime-Dli8g3Aq.d.ts +2082 -0
  116. package/dist/runtime-a8J378im.d.mts +4123 -0
  117. package/dist/runtime-a8J378im.d.ts +4123 -0
  118. package/dist/runtime-dp3rb3Lf.d.mts +2968 -0
  119. package/dist/runtime-dp3rb3Lf.d.ts +2968 -0
  120. package/dist/runtime-iWXlSN_H.d.mts +1683 -0
  121. package/dist/runtime-iWXlSN_H.d.ts +1683 -0
  122. package/dist/runtime-yMql0npY.d.mts +4321 -0
  123. package/dist/runtime-yMql0npY.d.ts +4321 -0
  124. package/dist/runtime.d.mts +3 -0
  125. package/dist/runtime.d.ts +3 -0
  126. package/dist/runtime.js +3626 -0
  127. package/dist/runtime.mjs +48 -0
  128. package/package.json +58 -0
@@ -0,0 +1,4277 @@
1
+ import { ColorId, IconName, CountryIso3, CurrencyCode, MimeType } from '@andyoucreate/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 code */
547
+ interface CurrencyFilterValue {
548
+ value: number | null;
549
+ code?: string;
550
+ }
551
+ /** Phone filter value with number and optional country code */
552
+ interface PhoneFilterValue {
553
+ phoneNumber: string | null;
554
+ countryCode?: string;
555
+ }
556
+ /** Filter value can be various types depending on the attribute */
557
+ type FilterValue = string | number | boolean | string[] | RelativeDateValue | CurrencyFilterValue | PhoneFilterValue | null;
558
+ /** A single filter rule */
559
+ interface FilterRule {
560
+ /** Attribute name to filter on */
561
+ attribute: string;
562
+ /** Filter operator */
563
+ operator: FilterOperator;
564
+ /** Filter value (null for operators like is_empty) */
565
+ value: FilterValue;
566
+ }
567
+ /** Combinator for filter rules */
568
+ type FilterCombinator = "and" | "or";
569
+ /** Complete filter state (simple mode) */
570
+ interface FilterState {
571
+ /** How to combine rules */
572
+ combinator: FilterCombinator;
573
+ /** List of filter rules */
574
+ rules: FilterRule[];
575
+ }
576
+ /**
577
+ * A filter group containing rules (used in advanced mode)
578
+ * Groups can be nested up to 2 levels deep
579
+ */
580
+ interface FilterGroup {
581
+ /** Unique identifier for this group */
582
+ id: string;
583
+ /** How to combine rules within this group */
584
+ combinator: FilterCombinator;
585
+ /** List of filter rules in this group */
586
+ rules: FilterRule[];
587
+ }
588
+ /**
589
+ * Advanced filter state with nested groups
590
+ * Structure: AdvancedFilterState -> FilterGroup[] -> FilterRule[]
591
+ * Maximum 2 levels of nesting
592
+ */
593
+ interface AdvancedFilterState {
594
+ /** How to combine groups at the top level */
595
+ combinator: FilterCombinator;
596
+ /** List of filter groups */
597
+ groups: FilterGroup[];
598
+ }
599
+ /**
600
+ * Type guard to check if a filter state is advanced
601
+ */
602
+ declare function isAdvancedFilterState(state: FilterState | AdvancedFilterState): state is AdvancedFilterState;
603
+ /**
604
+ * Convert simple filter state to advanced filter state
605
+ */
606
+ declare function toAdvancedFilterState(state: FilterState): AdvancedFilterState;
607
+ /**
608
+ * Convert advanced filter state to simple filter state (flattens groups)
609
+ * Note: This loses group structure - use with caution
610
+ */
611
+ declare function toSimpleFilterState(state: AdvancedFilterState): FilterState;
612
+ /** Sort direction */
613
+ type SortDirection = "asc" | "desc";
614
+ /** A single sort rule */
615
+ interface SortRule {
616
+ /** Attribute name to sort by */
617
+ attribute: string;
618
+ /** Sort direction */
619
+ direction: SortDirection;
620
+ }
621
+ /** Complete query state with search, filters, sorts, and pagination */
622
+ interface QueryState {
623
+ /** Full-text search query */
624
+ search?: string;
625
+ /** Filter configuration (simple mode) */
626
+ filters?: FilterState;
627
+ /** Advanced filter configuration (grouped mode) */
628
+ advancedFilters?: AdvancedFilterState;
629
+ /** Sort configuration (multiple sorts supported) */
630
+ sorts?: SortRule[];
631
+ /** Pagination */
632
+ limit?: number;
633
+ offset?: number;
634
+ }
635
+ /** Mapping of attribute types to their valid operators */
636
+ declare const OPERATORS_BY_TYPE: Record<AttributeType, readonly FilterOperator[]>;
637
+ /** Check if an operator requires a value */
638
+ type NoValueOperator = "is_empty" | "is_not_empty" | "is_checked" | "is_not_checked";
639
+ /** Operators that don't require a value */
640
+ declare const NO_VALUE_OPERATORS: readonly NoValueOperator[];
641
+ /**
642
+ * Check if an operator requires a value
643
+ */
644
+ declare function isNoValueOperator(operator: FilterOperator): operator is NoValueOperator;
645
+
646
+ /**
647
+ * Autocomplete suggestion from geocoding service
648
+ */
649
+ interface GeocodingSuggestion {
650
+ /** Unique identifier from the provider */
651
+ id: string;
652
+ /** Human-readable label for display */
653
+ label: string;
654
+ /** Structured location data */
655
+ location: Location;
656
+ /** Optional match score/confidence (0-1) */
657
+ score?: number;
658
+ /** Optional additional metadata from the provider */
659
+ metadata?: Record<string, unknown>;
660
+ }
661
+ /**
662
+ * Parameters for autocomplete search
663
+ */
664
+ interface GeocodingAutocompleteParams {
665
+ /** Search query */
666
+ query: string;
667
+ /** Restrict results to specific countries */
668
+ countries?: CountryIso3[];
669
+ /** Preferred language for results (ISO 639-1) */
670
+ language?: string;
671
+ /** Maximum number of results */
672
+ limit?: number;
673
+ /** Bias results toward a specific location */
674
+ biasLocation?: {
675
+ latitude: number;
676
+ longitude: number;
677
+ };
678
+ /** Session token for billing optimization (some providers) */
679
+ sessionToken?: string;
680
+ /**
681
+ * Level of address detail expected
682
+ * Adapters can use this to filter/optimize results
683
+ * - "full": Full address with street, city, postal code, etc.
684
+ * - "address": Street address without postal code
685
+ * - "city": City level only
686
+ * - "state": State/region level only
687
+ * - "country": Country level only
688
+ * - "coordinates": Only coordinates (lat/lng)
689
+ */
690
+ granularity?: LocationGranularity;
691
+ }
692
+ /**
693
+ * Parameters for reverse geocoding
694
+ */
695
+ interface ReverseGeocodingParams {
696
+ /** Latitude */
697
+ latitude: number;
698
+ /** Longitude */
699
+ longitude: number;
700
+ /** Preferred language for results */
701
+ language?: string;
702
+ }
703
+ /**
704
+ * Parameters for geocoding a structured address
705
+ */
706
+ interface GeocodingParams {
707
+ /** Structured address components */
708
+ address: Partial<Location>;
709
+ /** Preferred language for results */
710
+ language?: string;
711
+ }
712
+ /**
713
+ * Abstract geocoding adapter interface
714
+ * Implement this interface for different geocoding providers
715
+ *
716
+ * @example Google Maps implementation
717
+ * ```typescript
718
+ * class GoogleMapsGeocodingAdapter implements GeocodingAdapter {
719
+ * async autocomplete(params) {
720
+ * const response = await fetch(
721
+ * `https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${params.query}&key=${this.apiKey}`
722
+ * );
723
+ * // Transform response to GeocodingSuggestion[]
724
+ * }
725
+ * }
726
+ * ```
727
+ *
728
+ * @example Mapbox implementation
729
+ * ```typescript
730
+ * class MapboxGeocodingAdapter implements GeocodingAdapter {
731
+ * async autocomplete(params) {
732
+ * const response = await fetch(
733
+ * `https://api.mapbox.com/geocoding/v5/mapbox.places/${params.query}.json?access_token=${this.token}`
734
+ * );
735
+ * // Transform response to GeocodingSuggestion[]
736
+ * }
737
+ * }
738
+ * ```
739
+ */
740
+ interface GeocodingAdapter {
741
+ /**
742
+ * Autocomplete address search
743
+ * Returns suggestions as the user types
744
+ */
745
+ autocomplete(params: GeocodingAutocompleteParams): Promise<GeocodingSuggestion[]>;
746
+ /**
747
+ * Reverse geocode coordinates to an address
748
+ * Optional - some providers may not support this
749
+ */
750
+ reverse?(params: ReverseGeocodingParams): Promise<GeocodingSuggestion | null>;
751
+ /**
752
+ * Geocode a structured address to coordinates
753
+ * Optional - some providers may not support this
754
+ */
755
+ geocode?(params: GeocodingParams): Promise<GeocodingSuggestion | null>;
756
+ }
757
+ /**
758
+ * No-op geocoding adapter
759
+ * Returns empty results when no geocoding provider is configured
760
+ */
761
+ declare class NoopGeocodingAdapter implements GeocodingAdapter {
762
+ autocomplete(): Promise<GeocodingSuggestion[]>;
763
+ reverse(): Promise<null>;
764
+ geocode(): Promise<null>;
765
+ }
766
+
767
+ /**
768
+ * User role in the application
769
+ * Can be extended with custom roles as needed
770
+ */
771
+ type UserRole = "admin" | "member" | "guest" | string;
772
+ /**
773
+ * User status for account management
774
+ */
775
+ type UserStatus = "active" | "pending" | "inactive" | "suspended";
776
+ /**
777
+ * User Profile - Represents application user data (authorization)
778
+ *
779
+ * ARCHITECTURE:
780
+ * - authId links to external auth provider (Supabase, Clerk, Auth0, etc.)
781
+ * - email is denormalized from auth provider for performance
782
+ * - Auth provider handles authentication (passwords, sessions, OAuth)
783
+ * - This type handles authorization (roles, permissions, tenant membership)
784
+ *
785
+ * @example
786
+ * ```typescript
787
+ * const profile: UserProfile = {
788
+ * id: "profile-123",
789
+ * tenantId: "tenant-456",
790
+ * authId: "supabase-auth-uuid-789",
791
+ * email: "john@example.com",
792
+ * firstName: "John",
793
+ * lastName: "Doe",
794
+ * role: "admin",
795
+ * status: "active",
796
+ * createdAt: new Date(),
797
+ * updatedAt: new Date(),
798
+ * };
799
+ * ```
800
+ */
801
+ interface UserProfile extends Timestamps {
802
+ id: Uuid;
803
+ tenantId: Uuid;
804
+ /**
805
+ * Link to external auth provider (Supabase auth.users.id, Clerk user ID, etc.)
806
+ * This is the bridge between authentication (provider) and authorization (your app)
807
+ */
808
+ authId: string;
809
+ /**
810
+ * Email address (denormalized from auth provider)
811
+ * Allows efficient querying and filtering without hitting auth provider API
812
+ */
813
+ email: string;
814
+ /**
815
+ * User's first name
816
+ */
817
+ firstName?: string;
818
+ /**
819
+ * User's last name
820
+ */
821
+ lastName?: string;
822
+ /**
823
+ * Avatar/profile picture URL
824
+ */
825
+ avatarUrl?: string;
826
+ /**
827
+ * User role for authorization
828
+ * Common values: "admin", "member", "guest"
829
+ * Can be extended with custom roles
830
+ */
831
+ role: UserRole;
832
+ /**
833
+ * Account status
834
+ * - active: Normal user, full access
835
+ * - pending: Awaiting activation/approval
836
+ * - inactive: Deactivated account
837
+ * - suspended: Temporarily blocked
838
+ */
839
+ status: UserStatus;
840
+ /**
841
+ * Last login timestamp (updated on each successful auth)
842
+ */
843
+ lastLoginAt?: Date;
844
+ }
845
+ /**
846
+ * Data required to create a new user profile
847
+ */
848
+ interface CreateUserProfile {
849
+ tenantId: Uuid;
850
+ authId: string;
851
+ email: string;
852
+ firstName?: string;
853
+ lastName?: string;
854
+ avatarUrl?: string;
855
+ role?: UserRole;
856
+ status?: UserStatus;
857
+ }
858
+ /**
859
+ * Data for updating an existing user profile
860
+ */
861
+ interface UpdateUserProfile {
862
+ firstName?: string;
863
+ lastName?: string;
864
+ avatarUrl?: string;
865
+ role?: UserRole;
866
+ status?: UserStatus;
867
+ lastLoginAt?: Date;
868
+ }
869
+
870
+ /**
871
+ * Inline attribute group configuration
872
+ * Groups multiple attributes into a single composite field with dropdown editing
873
+ */
874
+ interface AttributeGroupField {
875
+ /** Unique identifier for the group */
876
+ id: string;
877
+ /** Display label for the composite field */
878
+ label: string;
879
+ /** Description shown in the dropdown */
880
+ description?: string;
881
+ /** Attribute names to include in this group */
882
+ attributes: string[];
883
+ /**
884
+ * Template for the display value
885
+ * Uses {attributeName} syntax for interpolation
886
+ * @example "{billing_street}, {billing_city} {billing_postal_code}"
887
+ */
888
+ displayTemplate?: string;
889
+ }
890
+ /**
891
+ * Field definition within a form group
892
+ * Can be either a single attribute or an inline attribute group
893
+ */
894
+ interface Field {
895
+ /** Attribute name to display (for single attribute fields) */
896
+ attribute?: string;
897
+ /** Inline attribute group (groups multiple attributes into one composite field) */
898
+ attributeGroup?: AttributeGroupField;
899
+ /** Grid span (1-12 columns) */
900
+ span?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
901
+ /** Override label for this view (only for single attribute fields) */
902
+ label?: string;
903
+ /** Force read-only display */
904
+ readOnly?: boolean;
905
+ }
906
+ /**
907
+ * Group of fields for organizing forms
908
+ */
909
+ interface Group {
910
+ id: string;
911
+ label: string;
912
+ description?: string;
913
+ fields: Field[];
914
+ collapsible?: boolean;
915
+ collapsed?: boolean;
916
+ order?: number;
917
+ }
918
+ type TabType = "form" | "table" | "custom";
919
+ /**
920
+ * Base properties shared by all tab types
921
+ */
922
+ interface BaseTab {
923
+ id: string;
924
+ name: string;
925
+ label: string;
926
+ icon?: IconName;
927
+ order?: number;
928
+ /** If true, tab is defined by developer (protected) */
929
+ system?: boolean;
930
+ }
931
+ /**
932
+ * Form tab - displays attributes organized in groups
933
+ */
934
+ interface FormTab extends BaseTab {
935
+ type: "form";
936
+ groups: Group[];
937
+ }
938
+ /**
939
+ * Table tab - displays records from a relation attribute
940
+ */
941
+ interface TableTab extends BaseTab {
942
+ type: "table";
943
+ /** Name of the relation attribute */
944
+ relation: string;
945
+ /** Columns to display (attribute names from target object) */
946
+ columns: string[];
947
+ /** Allow creating new records */
948
+ allowCreate?: boolean;
949
+ /** Allow inline editing */
950
+ allowEdit?: boolean;
951
+ /** Allow deleting records */
952
+ allowDelete?: boolean;
953
+ /** Default filters */
954
+ filters?: Record<string, unknown>;
955
+ /** Default sort */
956
+ sort?: {
957
+ field: string;
958
+ order: "asc" | "desc";
959
+ };
960
+ }
961
+ /**
962
+ * Custom tab - renders a developer-defined component
963
+ */
964
+ interface CustomTab extends BaseTab {
965
+ type: "custom";
966
+ /** Component identifier to render */
967
+ component: string;
968
+ /** Props to pass to the component */
969
+ props?: Record<string, unknown>;
970
+ }
971
+ /**
972
+ * Union of all tab types
973
+ */
974
+ type Tab = FormTab | TableTab | CustomTab;
975
+ /**
976
+ * View definition - organizes object attributes into tabs/pages
977
+ *
978
+ * @example
979
+ * ```typescript
980
+ * const companyView: ViewDefinition = {
981
+ * name: "detail",
982
+ * label: "Company Detail",
983
+ * object: "companies",
984
+ * tabs: [
985
+ * { type: "form", name: "general", label: "Info", groups: [...] },
986
+ * { type: "table", name: "contacts", label: "Contacts", relation: "contacts", columns: [...] }
987
+ * ],
988
+ * default: true,
989
+ * system: true
990
+ * };
991
+ * ```
992
+ */
993
+ interface ViewDefinition {
994
+ id?: Uuid;
995
+ /** Technical name (kebab-case) */
996
+ name: string;
997
+ /** Display label */
998
+ label: string;
999
+ /** Description */
1000
+ description?: string;
1001
+ /** Icon */
1002
+ icon?: IconName;
1003
+ /** Object this view belongs to (object name) */
1004
+ object: string;
1005
+ /** Tabs in this view */
1006
+ tabs: Tab[];
1007
+ /** Default view for this object */
1008
+ default?: boolean;
1009
+ /** System view (defined by developer, protected) */
1010
+ system?: boolean;
1011
+ /** Extensible metadata */
1012
+ metadata?: Record<string, unknown>;
1013
+ }
1014
+ /**
1015
+ * Check if a tab is a form tab
1016
+ */
1017
+ declare function isFormTab(tab: Tab): tab is FormTab;
1018
+ /**
1019
+ * Check if a tab is a table tab
1020
+ */
1021
+ declare function isTableTab(tab: Tab): tab is TableTab;
1022
+ /**
1023
+ * Check if a tab is a custom tab
1024
+ */
1025
+ declare function isCustomTab(tab: Tab): tab is CustomTab;
1026
+
1027
+ /**
1028
+ * Registry for native objects defined in code
1029
+ * Native objects are system objects that cannot be deleted/modified by clients
1030
+ * They are defined by developers and synced to the database at startup
1031
+ */
1032
+ declare class NativeObjectRegistryClass {
1033
+ private objects;
1034
+ /**
1035
+ * Register one or more native objects
1036
+ * Auto-builds if ObjectBuilder is passed instead of ObjectDefinition
1037
+ * @param objects - Single object/builder or array of objects/builders to register
1038
+ * @returns this (for chaining)
1039
+ * @throws Error if object is invalid or already registered
1040
+ *
1041
+ * @example
1042
+ * ```typescript
1043
+ * // No .build() needed - registry auto-builds!
1044
+ * const PRODUCT = object({ id: "obj-product", name: "products", label: "Product" })
1045
+ * .system()
1046
+ * .attribute(text({ id: "attr-name", name: "name", label: "Name" }));
1047
+ *
1048
+ * registry.register(PRODUCT); // ← Auto-builds here
1049
+ *
1050
+ * // Can still explicitly .build() if you want
1051
+ * registry.register(PRODUCT.build());
1052
+ *
1053
+ * // Register multiple
1054
+ * registry.register([PRODUCT, ORDER, CUSTOMER]);
1055
+ * ```
1056
+ */
1057
+ register(objects: ObjectDefinition | ObjectDefinition[] | {
1058
+ build: () => ObjectDefinition;
1059
+ } | Array<{
1060
+ build: () => ObjectDefinition;
1061
+ }>): this;
1062
+ /**
1063
+ * Validate and register a single object
1064
+ * @internal
1065
+ */
1066
+ private validateAndRegister;
1067
+ /**
1068
+ * Get a native object by its name
1069
+ * @param name - The object name
1070
+ * @returns The object definition or undefined if not found
1071
+ *
1072
+ * @example
1073
+ * ```typescript
1074
+ * const product = registry.getByName("products");
1075
+ * if (product) {
1076
+ * console.log(product.label); // "Product"
1077
+ * }
1078
+ * ```
1079
+ */
1080
+ getByName(name: string): ObjectDefinition | undefined;
1081
+ /**
1082
+ * Get a native object or throw if not found
1083
+ * @param name - The object name
1084
+ * @returns The object definition
1085
+ * @throws Error if not found
1086
+ */
1087
+ getByNameOrThrow(name: string): ObjectDefinition;
1088
+ /**
1089
+ * Get all registered native objects
1090
+ * @returns Array of all registered object definitions
1091
+ */
1092
+ getAll(): ObjectDefinition[];
1093
+ /**
1094
+ * Get all registered native object names
1095
+ * @returns Array of object names
1096
+ */
1097
+ listNames(): string[];
1098
+ /**
1099
+ * Check if a native object is registered
1100
+ * @param name - The object name
1101
+ * @returns true if registered, false otherwise
1102
+ */
1103
+ has(name: string): boolean;
1104
+ /**
1105
+ * Get the number of registered objects
1106
+ */
1107
+ get size(): number;
1108
+ /**
1109
+ * Clear all registered objects (useful for testing)
1110
+ * @internal
1111
+ */
1112
+ clear(): void;
1113
+ /**
1114
+ * Get registry summary for debugging
1115
+ */
1116
+ summary(): string;
1117
+ /**
1118
+ * Log registry summary to console
1119
+ */
1120
+ debug(): void;
1121
+ }
1122
+ /**
1123
+ * Singleton instance of the registry
1124
+ * Use this to register and retrieve native objects
1125
+ *
1126
+ * @example
1127
+ * ```typescript
1128
+ * import { registry } from "@andyoucreate/schema";
1129
+ *
1130
+ * // Register objects
1131
+ * registry.register([PRODUCT, ORDER, CUSTOMER]);
1132
+ *
1133
+ * // Get object by name
1134
+ * const product = registry.getByName("products");
1135
+ *
1136
+ * // List all
1137
+ * console.log(registry.listNames()); // ["products", "orders", ...]
1138
+ *
1139
+ * // Debug
1140
+ * registry.debug();
1141
+ * ```
1142
+ */
1143
+ declare const registry: NativeObjectRegistryClass;
1144
+
1145
+ /**
1146
+ * Registry for native view definitions
1147
+ *
1148
+ * Views registered here are considered "system" views, defined by the developer.
1149
+ * They are protected from modification by end-users and synced to the database
1150
+ * at application startup.
1151
+ *
1152
+ * @example
1153
+ * ```typescript
1154
+ * import { view, group, viewRegistry } from "@andyoucreate/schema";
1155
+ *
1156
+ * const COMPANY_DETAIL = view("detail", "Detail")
1157
+ * .for("companies")
1158
+ * .system()
1159
+ * .tab("general", "Info")
1160
+ * .form(group("main", "Main").fields("name", "status"))
1161
+ * .build();
1162
+ *
1163
+ * viewRegistry.register(COMPANY_DETAIL);
1164
+ * ```
1165
+ */
1166
+ declare class ViewRegistry {
1167
+ private views;
1168
+ private byObject;
1169
+ /**
1170
+ * Register a native view
1171
+ * @param viewOrViews - Single view or array of views
1172
+ * @throws Error if view is not marked as system
1173
+ * @throws Error if view with same name already exists for the object
1174
+ */
1175
+ register(viewOrViews: ViewDefinition | ViewDefinition[]): this;
1176
+ private registerSingle;
1177
+ /**
1178
+ * Get all views for an object
1179
+ */
1180
+ getByObjectName(objectName: string): ViewDefinition[];
1181
+ /**
1182
+ * Get a specific view by object and view name
1183
+ */
1184
+ get(objectName: string, viewName: string): ViewDefinition | undefined;
1185
+ /**
1186
+ * Get a view or throw if not found
1187
+ */
1188
+ getOrThrow(objectName: string, viewName: string): ViewDefinition;
1189
+ /**
1190
+ * Get all registered views
1191
+ */
1192
+ getAll(): ViewDefinition[];
1193
+ /**
1194
+ * Check if a view exists
1195
+ */
1196
+ has(objectName: string, viewName: string): boolean;
1197
+ /**
1198
+ * Check if any views exist for an object
1199
+ */
1200
+ hasObject(objectName: string): boolean;
1201
+ /**
1202
+ * Get number of registered views
1203
+ */
1204
+ get size(): number;
1205
+ /**
1206
+ * List all object names that have views
1207
+ */
1208
+ listObjectNames(): string[];
1209
+ /**
1210
+ * Get default view for an object (if any)
1211
+ */
1212
+ getDefault(objectName: string): ViewDefinition | undefined;
1213
+ /**
1214
+ * Clear all registered views (for testing)
1215
+ */
1216
+ clear(): void;
1217
+ /**
1218
+ * Generate summary string for debugging
1219
+ */
1220
+ summary(): string;
1221
+ /**
1222
+ * Log summary to console
1223
+ */
1224
+ debug(): void;
1225
+ private makeKey;
1226
+ }
1227
+ /**
1228
+ * Global registry for native views
1229
+ */
1230
+ declare const viewRegistry: ViewRegistry;
1231
+
1232
+ /**
1233
+ * Text attribute config schema
1234
+ */
1235
+ declare const textConfigSchema: z.ZodObject<{
1236
+ disabled: z.ZodOptional<z.ZodBoolean>;
1237
+ placeholder: z.ZodOptional<z.ZodString>;
1238
+ description: z.ZodOptional<z.ZodString>;
1239
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1240
+ icon: z.ZodOptional<z.ZodString>;
1241
+ order: z.ZodOptional<z.ZodNumber>;
1242
+ hidden: z.ZodOptional<z.ZodBoolean>;
1243
+ archived: z.ZodOptional<z.ZodBoolean>;
1244
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1245
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1246
+ } & {
1247
+ minLength: z.ZodOptional<z.ZodNumber>;
1248
+ maxLength: z.ZodOptional<z.ZodNumber>;
1249
+ pattern: z.ZodOptional<z.ZodString>;
1250
+ }, "strip", z.ZodTypeAny, {
1251
+ defaultValue?: unknown;
1252
+ disabled?: boolean | undefined;
1253
+ placeholder?: string | undefined;
1254
+ description?: string | undefined;
1255
+ icon?: string | undefined;
1256
+ order?: number | undefined;
1257
+ hidden?: boolean | undefined;
1258
+ archived?: boolean | undefined;
1259
+ deprecated?: boolean | undefined;
1260
+ metadata?: Record<string, unknown> | undefined;
1261
+ minLength?: number | undefined;
1262
+ maxLength?: number | undefined;
1263
+ pattern?: string | undefined;
1264
+ }, {
1265
+ defaultValue?: unknown;
1266
+ disabled?: boolean | undefined;
1267
+ placeholder?: string | undefined;
1268
+ description?: string | undefined;
1269
+ icon?: string | undefined;
1270
+ order?: number | undefined;
1271
+ hidden?: boolean | undefined;
1272
+ archived?: boolean | undefined;
1273
+ deprecated?: boolean | undefined;
1274
+ metadata?: Record<string, unknown> | undefined;
1275
+ minLength?: number | undefined;
1276
+ maxLength?: number | undefined;
1277
+ pattern?: string | undefined;
1278
+ }>;
1279
+ /**
1280
+ * Textarea attribute config schema
1281
+ */
1282
+ declare const textareaConfigSchema: z.ZodObject<{
1283
+ disabled: z.ZodOptional<z.ZodBoolean>;
1284
+ placeholder: z.ZodOptional<z.ZodString>;
1285
+ description: z.ZodOptional<z.ZodString>;
1286
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1287
+ icon: z.ZodOptional<z.ZodString>;
1288
+ order: z.ZodOptional<z.ZodNumber>;
1289
+ hidden: z.ZodOptional<z.ZodBoolean>;
1290
+ archived: z.ZodOptional<z.ZodBoolean>;
1291
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1292
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1293
+ }, "strip", z.ZodTypeAny, {
1294
+ defaultValue?: unknown;
1295
+ disabled?: boolean | undefined;
1296
+ placeholder?: string | undefined;
1297
+ description?: string | undefined;
1298
+ icon?: string | undefined;
1299
+ order?: number | undefined;
1300
+ hidden?: boolean | undefined;
1301
+ archived?: boolean | undefined;
1302
+ deprecated?: boolean | undefined;
1303
+ metadata?: Record<string, unknown> | undefined;
1304
+ }, {
1305
+ defaultValue?: unknown;
1306
+ disabled?: boolean | undefined;
1307
+ placeholder?: string | undefined;
1308
+ description?: string | undefined;
1309
+ icon?: string | undefined;
1310
+ order?: number | undefined;
1311
+ hidden?: boolean | undefined;
1312
+ archived?: boolean | undefined;
1313
+ deprecated?: boolean | undefined;
1314
+ metadata?: Record<string, unknown> | undefined;
1315
+ }>;
1316
+ /**
1317
+ * Number attribute config schema
1318
+ */
1319
+ declare const numberConfigSchema: z.ZodObject<{
1320
+ disabled: z.ZodOptional<z.ZodBoolean>;
1321
+ placeholder: z.ZodOptional<z.ZodString>;
1322
+ description: z.ZodOptional<z.ZodString>;
1323
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1324
+ icon: z.ZodOptional<z.ZodString>;
1325
+ order: z.ZodOptional<z.ZodNumber>;
1326
+ hidden: z.ZodOptional<z.ZodBoolean>;
1327
+ archived: z.ZodOptional<z.ZodBoolean>;
1328
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1329
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1330
+ } & {
1331
+ min: z.ZodOptional<z.ZodNumber>;
1332
+ max: z.ZodOptional<z.ZodNumber>;
1333
+ unit: z.ZodOptional<z.ZodEnum<["integer", "decimal", "percentage"]>>;
1334
+ decimals: z.ZodOptional<z.ZodNumber>;
1335
+ }, "strip", z.ZodTypeAny, {
1336
+ defaultValue?: unknown;
1337
+ disabled?: boolean | undefined;
1338
+ placeholder?: string | undefined;
1339
+ description?: string | undefined;
1340
+ icon?: string | undefined;
1341
+ order?: number | undefined;
1342
+ hidden?: boolean | undefined;
1343
+ archived?: boolean | undefined;
1344
+ deprecated?: boolean | undefined;
1345
+ metadata?: Record<string, unknown> | undefined;
1346
+ min?: number | undefined;
1347
+ max?: number | undefined;
1348
+ unit?: "percentage" | "integer" | "decimal" | undefined;
1349
+ decimals?: number | undefined;
1350
+ }, {
1351
+ defaultValue?: unknown;
1352
+ disabled?: boolean | undefined;
1353
+ placeholder?: string | undefined;
1354
+ description?: string | undefined;
1355
+ icon?: string | undefined;
1356
+ order?: number | undefined;
1357
+ hidden?: boolean | undefined;
1358
+ archived?: boolean | undefined;
1359
+ deprecated?: boolean | undefined;
1360
+ metadata?: Record<string, unknown> | undefined;
1361
+ min?: number | undefined;
1362
+ max?: number | undefined;
1363
+ unit?: "percentage" | "integer" | "decimal" | undefined;
1364
+ decimals?: number | undefined;
1365
+ }>;
1366
+ /**
1367
+ * Checkbox attribute config schema
1368
+ */
1369
+ declare const checkboxConfigSchema: z.ZodObject<{
1370
+ disabled: z.ZodOptional<z.ZodBoolean>;
1371
+ placeholder: z.ZodOptional<z.ZodString>;
1372
+ description: z.ZodOptional<z.ZodString>;
1373
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1374
+ icon: z.ZodOptional<z.ZodString>;
1375
+ order: z.ZodOptional<z.ZodNumber>;
1376
+ hidden: z.ZodOptional<z.ZodBoolean>;
1377
+ archived: z.ZodOptional<z.ZodBoolean>;
1378
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1379
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1380
+ }, "strip", z.ZodTypeAny, {
1381
+ defaultValue?: unknown;
1382
+ disabled?: boolean | undefined;
1383
+ placeholder?: string | undefined;
1384
+ description?: string | undefined;
1385
+ icon?: string | undefined;
1386
+ order?: number | undefined;
1387
+ hidden?: boolean | undefined;
1388
+ archived?: boolean | undefined;
1389
+ deprecated?: boolean | undefined;
1390
+ metadata?: Record<string, unknown> | undefined;
1391
+ }, {
1392
+ defaultValue?: unknown;
1393
+ disabled?: boolean | undefined;
1394
+ placeholder?: string | undefined;
1395
+ description?: string | undefined;
1396
+ icon?: string | undefined;
1397
+ order?: number | undefined;
1398
+ hidden?: boolean | undefined;
1399
+ archived?: boolean | undefined;
1400
+ deprecated?: boolean | undefined;
1401
+ metadata?: Record<string, unknown> | undefined;
1402
+ }>;
1403
+ /**
1404
+ * Date attribute config schema
1405
+ */
1406
+ declare const dateConfigSchema: z.ZodObject<{
1407
+ disabled: z.ZodOptional<z.ZodBoolean>;
1408
+ placeholder: z.ZodOptional<z.ZodString>;
1409
+ description: z.ZodOptional<z.ZodString>;
1410
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1411
+ icon: z.ZodOptional<z.ZodString>;
1412
+ order: z.ZodOptional<z.ZodNumber>;
1413
+ hidden: z.ZodOptional<z.ZodBoolean>;
1414
+ archived: z.ZodOptional<z.ZodBoolean>;
1415
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1416
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1417
+ } & {
1418
+ dateFormat: z.ZodOptional<z.ZodEnum<["short", "long", "full", "relative"]>>;
1419
+ minDate: z.ZodOptional<z.ZodString>;
1420
+ maxDate: z.ZodOptional<z.ZodString>;
1421
+ }, "strip", z.ZodTypeAny, {
1422
+ defaultValue?: unknown;
1423
+ disabled?: boolean | undefined;
1424
+ placeholder?: string | undefined;
1425
+ description?: string | undefined;
1426
+ icon?: string | undefined;
1427
+ order?: number | undefined;
1428
+ hidden?: boolean | undefined;
1429
+ archived?: boolean | undefined;
1430
+ deprecated?: boolean | undefined;
1431
+ metadata?: Record<string, unknown> | undefined;
1432
+ dateFormat?: "short" | "long" | "full" | "relative" | undefined;
1433
+ minDate?: string | undefined;
1434
+ maxDate?: string | undefined;
1435
+ }, {
1436
+ defaultValue?: unknown;
1437
+ disabled?: boolean | undefined;
1438
+ placeholder?: string | undefined;
1439
+ description?: string | undefined;
1440
+ icon?: string | undefined;
1441
+ order?: number | undefined;
1442
+ hidden?: boolean | undefined;
1443
+ archived?: boolean | undefined;
1444
+ deprecated?: boolean | undefined;
1445
+ metadata?: Record<string, unknown> | undefined;
1446
+ dateFormat?: "short" | "long" | "full" | "relative" | undefined;
1447
+ minDate?: string | undefined;
1448
+ maxDate?: string | undefined;
1449
+ }>;
1450
+ /**
1451
+ * Phone attribute config schema
1452
+ */
1453
+ declare const phoneConfigSchema: z.ZodObject<{
1454
+ disabled: z.ZodOptional<z.ZodBoolean>;
1455
+ placeholder: z.ZodOptional<z.ZodString>;
1456
+ description: z.ZodOptional<z.ZodString>;
1457
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1458
+ icon: z.ZodOptional<z.ZodString>;
1459
+ order: z.ZodOptional<z.ZodNumber>;
1460
+ hidden: z.ZodOptional<z.ZodBoolean>;
1461
+ archived: z.ZodOptional<z.ZodBoolean>;
1462
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1463
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1464
+ } & {
1465
+ defaultCountryCode: z.ZodOptional<z.ZodString>;
1466
+ }, "strip", z.ZodTypeAny, {
1467
+ defaultValue?: unknown;
1468
+ disabled?: boolean | undefined;
1469
+ placeholder?: string | undefined;
1470
+ description?: string | undefined;
1471
+ icon?: string | undefined;
1472
+ order?: number | undefined;
1473
+ hidden?: boolean | undefined;
1474
+ archived?: boolean | undefined;
1475
+ deprecated?: boolean | undefined;
1476
+ metadata?: Record<string, unknown> | undefined;
1477
+ defaultCountryCode?: string | undefined;
1478
+ }, {
1479
+ defaultValue?: unknown;
1480
+ disabled?: boolean | undefined;
1481
+ placeholder?: string | undefined;
1482
+ description?: string | undefined;
1483
+ icon?: string | undefined;
1484
+ order?: number | undefined;
1485
+ hidden?: boolean | undefined;
1486
+ archived?: boolean | undefined;
1487
+ deprecated?: boolean | undefined;
1488
+ metadata?: Record<string, unknown> | undefined;
1489
+ defaultCountryCode?: string | undefined;
1490
+ }>;
1491
+ /**
1492
+ * Currency attribute config schema
1493
+ */
1494
+ declare const currencyConfigSchema: z.ZodObject<{
1495
+ disabled: z.ZodOptional<z.ZodBoolean>;
1496
+ placeholder: z.ZodOptional<z.ZodString>;
1497
+ description: z.ZodOptional<z.ZodString>;
1498
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1499
+ icon: z.ZodOptional<z.ZodString>;
1500
+ order: z.ZodOptional<z.ZodNumber>;
1501
+ hidden: z.ZodOptional<z.ZodBoolean>;
1502
+ archived: z.ZodOptional<z.ZodBoolean>;
1503
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1504
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1505
+ } & {
1506
+ defaultCurrency: z.ZodOptional<z.ZodString>;
1507
+ allowedCurrencies: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1508
+ }, "strip", z.ZodTypeAny, {
1509
+ defaultValue?: unknown;
1510
+ disabled?: boolean | undefined;
1511
+ placeholder?: string | undefined;
1512
+ description?: string | undefined;
1513
+ icon?: string | undefined;
1514
+ order?: number | undefined;
1515
+ hidden?: boolean | undefined;
1516
+ archived?: boolean | undefined;
1517
+ deprecated?: boolean | undefined;
1518
+ metadata?: Record<string, unknown> | undefined;
1519
+ defaultCurrency?: string | undefined;
1520
+ allowedCurrencies?: string[] | undefined;
1521
+ }, {
1522
+ defaultValue?: unknown;
1523
+ disabled?: boolean | undefined;
1524
+ placeholder?: string | undefined;
1525
+ description?: string | undefined;
1526
+ icon?: string | undefined;
1527
+ order?: number | undefined;
1528
+ hidden?: boolean | undefined;
1529
+ archived?: boolean | undefined;
1530
+ deprecated?: boolean | undefined;
1531
+ metadata?: Record<string, unknown> | undefined;
1532
+ defaultCurrency?: string | undefined;
1533
+ allowedCurrencies?: string[] | undefined;
1534
+ }>;
1535
+ /**
1536
+ * Status attribute config schema
1537
+ */
1538
+ declare const statusConfigSchema: z.ZodObject<{
1539
+ disabled: z.ZodOptional<z.ZodBoolean>;
1540
+ placeholder: z.ZodOptional<z.ZodString>;
1541
+ description: z.ZodOptional<z.ZodString>;
1542
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1543
+ icon: z.ZodOptional<z.ZodString>;
1544
+ order: z.ZodOptional<z.ZodNumber>;
1545
+ hidden: z.ZodOptional<z.ZodBoolean>;
1546
+ archived: z.ZodOptional<z.ZodBoolean>;
1547
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1548
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1549
+ } & {
1550
+ options: z.ZodArray<z.ZodObject<{
1551
+ id: z.ZodString;
1552
+ label: z.ZodString;
1553
+ value: z.ZodString;
1554
+ color: z.ZodOptional<z.ZodString>;
1555
+ icon: z.ZodOptional<z.ZodString>;
1556
+ description: z.ZodOptional<z.ZodString>;
1557
+ group: z.ZodOptional<z.ZodEnum<["idle", "in_progress", "finished"]>>;
1558
+ }, "strip", z.ZodTypeAny, {
1559
+ label: string;
1560
+ id: string;
1561
+ value: string;
1562
+ description?: string | undefined;
1563
+ icon?: string | undefined;
1564
+ color?: string | undefined;
1565
+ group?: "idle" | "in_progress" | "finished" | undefined;
1566
+ }, {
1567
+ label: string;
1568
+ id: string;
1569
+ value: string;
1570
+ description?: string | undefined;
1571
+ icon?: string | undefined;
1572
+ color?: string | undefined;
1573
+ group?: "idle" | "in_progress" | "finished" | undefined;
1574
+ }>, "many">;
1575
+ }, "strip", z.ZodTypeAny, {
1576
+ options: {
1577
+ label: string;
1578
+ id: string;
1579
+ value: string;
1580
+ description?: string | undefined;
1581
+ icon?: string | undefined;
1582
+ color?: string | undefined;
1583
+ group?: "idle" | "in_progress" | "finished" | undefined;
1584
+ }[];
1585
+ defaultValue?: unknown;
1586
+ disabled?: boolean | undefined;
1587
+ placeholder?: string | undefined;
1588
+ description?: string | undefined;
1589
+ icon?: string | undefined;
1590
+ order?: number | undefined;
1591
+ hidden?: boolean | undefined;
1592
+ archived?: boolean | undefined;
1593
+ deprecated?: boolean | undefined;
1594
+ metadata?: Record<string, unknown> | undefined;
1595
+ }, {
1596
+ options: {
1597
+ label: string;
1598
+ id: string;
1599
+ value: string;
1600
+ description?: string | undefined;
1601
+ icon?: string | undefined;
1602
+ color?: string | undefined;
1603
+ group?: "idle" | "in_progress" | "finished" | undefined;
1604
+ }[];
1605
+ defaultValue?: unknown;
1606
+ disabled?: boolean | undefined;
1607
+ placeholder?: string | undefined;
1608
+ description?: string | undefined;
1609
+ icon?: string | undefined;
1610
+ order?: number | undefined;
1611
+ hidden?: boolean | undefined;
1612
+ archived?: boolean | undefined;
1613
+ deprecated?: boolean | undefined;
1614
+ metadata?: Record<string, unknown> | undefined;
1615
+ }>;
1616
+ /**
1617
+ * Location attribute config schema
1618
+ */
1619
+ declare const locationConfigSchema: z.ZodObject<{
1620
+ disabled: z.ZodOptional<z.ZodBoolean>;
1621
+ placeholder: z.ZodOptional<z.ZodString>;
1622
+ description: z.ZodOptional<z.ZodString>;
1623
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1624
+ icon: z.ZodOptional<z.ZodString>;
1625
+ order: z.ZodOptional<z.ZodNumber>;
1626
+ hidden: z.ZodOptional<z.ZodBoolean>;
1627
+ archived: z.ZodOptional<z.ZodBoolean>;
1628
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1629
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1630
+ } & {
1631
+ granularity: z.ZodEnum<["full", "address", "city", "state", "country", "coordinates"]>;
1632
+ enableAutocomplete: z.ZodOptional<z.ZodBoolean>;
1633
+ enableMap: z.ZodOptional<z.ZodBoolean>;
1634
+ defaultCountry: z.ZodOptional<z.ZodString>;
1635
+ allowedCountries: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1636
+ displayFormat: z.ZodOptional<z.ZodEnum<["single_line", "multi_line", "compact"]>>;
1637
+ }, "strip", z.ZodTypeAny, {
1638
+ granularity: "full" | "address" | "city" | "state" | "country" | "coordinates";
1639
+ defaultValue?: unknown;
1640
+ disabled?: boolean | undefined;
1641
+ placeholder?: string | undefined;
1642
+ description?: string | undefined;
1643
+ icon?: string | undefined;
1644
+ order?: number | undefined;
1645
+ hidden?: boolean | undefined;
1646
+ archived?: boolean | undefined;
1647
+ deprecated?: boolean | undefined;
1648
+ metadata?: Record<string, unknown> | undefined;
1649
+ enableAutocomplete?: boolean | undefined;
1650
+ enableMap?: boolean | undefined;
1651
+ defaultCountry?: string | undefined;
1652
+ allowedCountries?: string[] | undefined;
1653
+ displayFormat?: "single_line" | "multi_line" | "compact" | undefined;
1654
+ }, {
1655
+ granularity: "full" | "address" | "city" | "state" | "country" | "coordinates";
1656
+ defaultValue?: unknown;
1657
+ disabled?: boolean | undefined;
1658
+ placeholder?: string | undefined;
1659
+ description?: string | undefined;
1660
+ icon?: string | undefined;
1661
+ order?: number | undefined;
1662
+ hidden?: boolean | undefined;
1663
+ archived?: boolean | undefined;
1664
+ deprecated?: boolean | undefined;
1665
+ metadata?: Record<string, unknown> | undefined;
1666
+ enableAutocomplete?: boolean | undefined;
1667
+ enableMap?: boolean | undefined;
1668
+ defaultCountry?: string | undefined;
1669
+ allowedCountries?: string[] | undefined;
1670
+ displayFormat?: "single_line" | "multi_line" | "compact" | undefined;
1671
+ }>;
1672
+ /**
1673
+ * Timestamp attribute config schema
1674
+ */
1675
+ declare const timestampConfigSchema: z.ZodObject<{
1676
+ disabled: z.ZodOptional<z.ZodBoolean>;
1677
+ placeholder: z.ZodOptional<z.ZodString>;
1678
+ description: z.ZodOptional<z.ZodString>;
1679
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1680
+ icon: z.ZodOptional<z.ZodString>;
1681
+ order: z.ZodOptional<z.ZodNumber>;
1682
+ hidden: z.ZodOptional<z.ZodBoolean>;
1683
+ archived: z.ZodOptional<z.ZodBoolean>;
1684
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1685
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1686
+ } & {
1687
+ autoUpdate: z.ZodOptional<z.ZodBoolean>;
1688
+ }, "strip", z.ZodTypeAny, {
1689
+ defaultValue?: unknown;
1690
+ disabled?: boolean | undefined;
1691
+ placeholder?: string | undefined;
1692
+ description?: string | undefined;
1693
+ icon?: string | undefined;
1694
+ order?: number | undefined;
1695
+ hidden?: boolean | undefined;
1696
+ archived?: boolean | undefined;
1697
+ deprecated?: boolean | undefined;
1698
+ metadata?: Record<string, unknown> | undefined;
1699
+ autoUpdate?: boolean | undefined;
1700
+ }, {
1701
+ defaultValue?: unknown;
1702
+ disabled?: boolean | undefined;
1703
+ placeholder?: string | undefined;
1704
+ description?: string | undefined;
1705
+ icon?: string | undefined;
1706
+ order?: number | undefined;
1707
+ hidden?: boolean | undefined;
1708
+ archived?: boolean | undefined;
1709
+ deprecated?: boolean | undefined;
1710
+ metadata?: Record<string, unknown> | undefined;
1711
+ autoUpdate?: boolean | undefined;
1712
+ }>;
1713
+ /**
1714
+ * Select attribute config schema
1715
+ */
1716
+ declare const selectConfigSchema: z.ZodObject<{
1717
+ disabled: z.ZodOptional<z.ZodBoolean>;
1718
+ placeholder: z.ZodOptional<z.ZodString>;
1719
+ description: z.ZodOptional<z.ZodString>;
1720
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1721
+ icon: z.ZodOptional<z.ZodString>;
1722
+ order: z.ZodOptional<z.ZodNumber>;
1723
+ hidden: z.ZodOptional<z.ZodBoolean>;
1724
+ archived: z.ZodOptional<z.ZodBoolean>;
1725
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1726
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1727
+ } & {
1728
+ options: z.ZodArray<z.ZodObject<{
1729
+ id: z.ZodString;
1730
+ label: z.ZodString;
1731
+ value: z.ZodString;
1732
+ color: z.ZodOptional<z.ZodString>;
1733
+ icon: z.ZodOptional<z.ZodString>;
1734
+ description: z.ZodOptional<z.ZodString>;
1735
+ group: z.ZodOptional<z.ZodEnum<["idle", "in_progress", "finished"]>>;
1736
+ }, "strip", z.ZodTypeAny, {
1737
+ label: string;
1738
+ id: string;
1739
+ value: string;
1740
+ description?: string | undefined;
1741
+ icon?: string | undefined;
1742
+ color?: string | undefined;
1743
+ group?: "idle" | "in_progress" | "finished" | undefined;
1744
+ }, {
1745
+ label: string;
1746
+ id: string;
1747
+ value: string;
1748
+ description?: string | undefined;
1749
+ icon?: string | undefined;
1750
+ color?: string | undefined;
1751
+ group?: "idle" | "in_progress" | "finished" | undefined;
1752
+ }>, "many">;
1753
+ }, "strip", z.ZodTypeAny, {
1754
+ options: {
1755
+ label: string;
1756
+ id: string;
1757
+ value: string;
1758
+ description?: string | undefined;
1759
+ icon?: string | undefined;
1760
+ color?: string | undefined;
1761
+ group?: "idle" | "in_progress" | "finished" | undefined;
1762
+ }[];
1763
+ defaultValue?: unknown;
1764
+ disabled?: boolean | undefined;
1765
+ placeholder?: string | undefined;
1766
+ description?: string | undefined;
1767
+ icon?: string | undefined;
1768
+ order?: number | undefined;
1769
+ hidden?: boolean | undefined;
1770
+ archived?: boolean | undefined;
1771
+ deprecated?: boolean | undefined;
1772
+ metadata?: Record<string, unknown> | undefined;
1773
+ }, {
1774
+ options: {
1775
+ label: string;
1776
+ id: string;
1777
+ value: string;
1778
+ description?: string | undefined;
1779
+ icon?: string | undefined;
1780
+ color?: string | undefined;
1781
+ group?: "idle" | "in_progress" | "finished" | undefined;
1782
+ }[];
1783
+ defaultValue?: unknown;
1784
+ disabled?: boolean | undefined;
1785
+ placeholder?: string | undefined;
1786
+ description?: string | undefined;
1787
+ icon?: string | undefined;
1788
+ order?: number | undefined;
1789
+ hidden?: boolean | undefined;
1790
+ archived?: boolean | undefined;
1791
+ deprecated?: boolean | undefined;
1792
+ metadata?: Record<string, unknown> | undefined;
1793
+ }>;
1794
+ /**
1795
+ * Multiselect attribute config schema
1796
+ */
1797
+ declare const multiselectConfigSchema: z.ZodObject<{
1798
+ disabled: z.ZodOptional<z.ZodBoolean>;
1799
+ placeholder: z.ZodOptional<z.ZodString>;
1800
+ description: z.ZodOptional<z.ZodString>;
1801
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1802
+ icon: z.ZodOptional<z.ZodString>;
1803
+ order: z.ZodOptional<z.ZodNumber>;
1804
+ hidden: z.ZodOptional<z.ZodBoolean>;
1805
+ archived: z.ZodOptional<z.ZodBoolean>;
1806
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1807
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1808
+ } & {
1809
+ options: z.ZodArray<z.ZodObject<{
1810
+ id: z.ZodString;
1811
+ label: z.ZodString;
1812
+ value: z.ZodString;
1813
+ color: z.ZodOptional<z.ZodString>;
1814
+ icon: z.ZodOptional<z.ZodString>;
1815
+ description: z.ZodOptional<z.ZodString>;
1816
+ group: z.ZodOptional<z.ZodEnum<["idle", "in_progress", "finished"]>>;
1817
+ }, "strip", z.ZodTypeAny, {
1818
+ label: string;
1819
+ id: string;
1820
+ value: string;
1821
+ description?: string | undefined;
1822
+ icon?: string | undefined;
1823
+ color?: string | undefined;
1824
+ group?: "idle" | "in_progress" | "finished" | undefined;
1825
+ }, {
1826
+ label: string;
1827
+ id: string;
1828
+ value: string;
1829
+ description?: string | undefined;
1830
+ icon?: string | undefined;
1831
+ color?: string | undefined;
1832
+ group?: "idle" | "in_progress" | "finished" | undefined;
1833
+ }>, "many">;
1834
+ }, "strip", z.ZodTypeAny, {
1835
+ options: {
1836
+ label: string;
1837
+ id: string;
1838
+ value: string;
1839
+ description?: string | undefined;
1840
+ icon?: string | undefined;
1841
+ color?: string | undefined;
1842
+ group?: "idle" | "in_progress" | "finished" | undefined;
1843
+ }[];
1844
+ defaultValue?: unknown;
1845
+ disabled?: boolean | undefined;
1846
+ placeholder?: string | undefined;
1847
+ description?: string | undefined;
1848
+ icon?: string | undefined;
1849
+ order?: number | undefined;
1850
+ hidden?: boolean | undefined;
1851
+ archived?: boolean | undefined;
1852
+ deprecated?: boolean | undefined;
1853
+ metadata?: Record<string, unknown> | undefined;
1854
+ }, {
1855
+ options: {
1856
+ label: string;
1857
+ id: string;
1858
+ value: string;
1859
+ description?: string | undefined;
1860
+ icon?: string | undefined;
1861
+ color?: string | undefined;
1862
+ group?: "idle" | "in_progress" | "finished" | undefined;
1863
+ }[];
1864
+ defaultValue?: unknown;
1865
+ disabled?: boolean | undefined;
1866
+ placeholder?: string | undefined;
1867
+ description?: string | undefined;
1868
+ icon?: string | undefined;
1869
+ order?: number | undefined;
1870
+ hidden?: boolean | undefined;
1871
+ archived?: boolean | undefined;
1872
+ deprecated?: boolean | undefined;
1873
+ metadata?: Record<string, unknown> | undefined;
1874
+ }>;
1875
+ /**
1876
+ * File attribute config schema
1877
+ */
1878
+ declare const fileConfigSchema: z.ZodObject<{
1879
+ disabled: z.ZodOptional<z.ZodBoolean>;
1880
+ placeholder: z.ZodOptional<z.ZodString>;
1881
+ description: z.ZodOptional<z.ZodString>;
1882
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1883
+ icon: z.ZodOptional<z.ZodString>;
1884
+ order: z.ZodOptional<z.ZodNumber>;
1885
+ hidden: z.ZodOptional<z.ZodBoolean>;
1886
+ archived: z.ZodOptional<z.ZodBoolean>;
1887
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1888
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1889
+ } & {
1890
+ maxFiles: z.ZodOptional<z.ZodNumber>;
1891
+ maxSize: z.ZodOptional<z.ZodNumber>;
1892
+ allowedTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1893
+ verification: z.ZodOptional<z.ZodObject<{
1894
+ enabled: z.ZodBoolean;
1895
+ documentTypes: z.ZodArray<z.ZodObject<{
1896
+ type: z.ZodEnum<["id_card", "passport", "incorporation_certificate", "driver_license", "birth_certificate", "residence_permit", "bank_statement", "proof_of_address", "custom"]>;
1897
+ label: z.ZodString;
1898
+ faces: z.ZodArray<z.ZodEnum<["front", "back", "single"]>, "many">;
1899
+ attributeMapping: z.ZodOptional<z.ZodArray<z.ZodObject<{
1900
+ attributeId: z.ZodString;
1901
+ extractedKey: z.ZodString;
1902
+ face: z.ZodOptional<z.ZodEnum<["front", "back", "single"]>>;
1903
+ required: z.ZodOptional<z.ZodBoolean>;
1904
+ }, "strip", z.ZodTypeAny, {
1905
+ attributeId: string;
1906
+ extractedKey: string;
1907
+ required?: boolean | undefined;
1908
+ face?: "front" | "back" | "single" | undefined;
1909
+ }, {
1910
+ attributeId: string;
1911
+ extractedKey: string;
1912
+ required?: boolean | undefined;
1913
+ face?: "front" | "back" | "single" | undefined;
1914
+ }>, "many">>;
1915
+ }, "strip", z.ZodTypeAny, {
1916
+ label: string;
1917
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
1918
+ faces: ("front" | "back" | "single")[];
1919
+ attributeMapping?: {
1920
+ attributeId: string;
1921
+ extractedKey: string;
1922
+ required?: boolean | undefined;
1923
+ face?: "front" | "back" | "single" | undefined;
1924
+ }[] | undefined;
1925
+ }, {
1926
+ label: string;
1927
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
1928
+ faces: ("front" | "back" | "single")[];
1929
+ attributeMapping?: {
1930
+ attributeId: string;
1931
+ extractedKey: string;
1932
+ required?: boolean | undefined;
1933
+ face?: "front" | "back" | "single" | undefined;
1934
+ }[] | undefined;
1935
+ }>, "many">;
1936
+ autoExtract: z.ZodOptional<z.ZodBoolean>;
1937
+ autoValidate: z.ZodOptional<z.ZodBoolean>;
1938
+ }, "strip", z.ZodTypeAny, {
1939
+ enabled: boolean;
1940
+ documentTypes: {
1941
+ label: string;
1942
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
1943
+ faces: ("front" | "back" | "single")[];
1944
+ attributeMapping?: {
1945
+ attributeId: string;
1946
+ extractedKey: string;
1947
+ required?: boolean | undefined;
1948
+ face?: "front" | "back" | "single" | undefined;
1949
+ }[] | undefined;
1950
+ }[];
1951
+ autoExtract?: boolean | undefined;
1952
+ autoValidate?: boolean | undefined;
1953
+ }, {
1954
+ enabled: boolean;
1955
+ documentTypes: {
1956
+ label: string;
1957
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
1958
+ faces: ("front" | "back" | "single")[];
1959
+ attributeMapping?: {
1960
+ attributeId: string;
1961
+ extractedKey: string;
1962
+ required?: boolean | undefined;
1963
+ face?: "front" | "back" | "single" | undefined;
1964
+ }[] | undefined;
1965
+ }[];
1966
+ autoExtract?: boolean | undefined;
1967
+ autoValidate?: boolean | undefined;
1968
+ }>>;
1969
+ }, "strip", z.ZodTypeAny, {
1970
+ defaultValue?: unknown;
1971
+ disabled?: boolean | undefined;
1972
+ placeholder?: string | undefined;
1973
+ description?: string | undefined;
1974
+ icon?: string | undefined;
1975
+ order?: number | undefined;
1976
+ hidden?: boolean | undefined;
1977
+ archived?: boolean | undefined;
1978
+ deprecated?: boolean | undefined;
1979
+ metadata?: Record<string, unknown> | undefined;
1980
+ maxFiles?: number | undefined;
1981
+ maxSize?: number | undefined;
1982
+ allowedTypes?: string[] | undefined;
1983
+ verification?: {
1984
+ enabled: boolean;
1985
+ documentTypes: {
1986
+ label: string;
1987
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
1988
+ faces: ("front" | "back" | "single")[];
1989
+ attributeMapping?: {
1990
+ attributeId: string;
1991
+ extractedKey: string;
1992
+ required?: boolean | undefined;
1993
+ face?: "front" | "back" | "single" | undefined;
1994
+ }[] | undefined;
1995
+ }[];
1996
+ autoExtract?: boolean | undefined;
1997
+ autoValidate?: boolean | undefined;
1998
+ } | undefined;
1999
+ }, {
2000
+ defaultValue?: unknown;
2001
+ disabled?: boolean | undefined;
2002
+ placeholder?: string | undefined;
2003
+ description?: string | undefined;
2004
+ icon?: string | undefined;
2005
+ order?: number | undefined;
2006
+ hidden?: boolean | undefined;
2007
+ archived?: boolean | undefined;
2008
+ deprecated?: boolean | undefined;
2009
+ metadata?: Record<string, unknown> | undefined;
2010
+ maxFiles?: number | undefined;
2011
+ maxSize?: number | undefined;
2012
+ allowedTypes?: string[] | undefined;
2013
+ verification?: {
2014
+ enabled: boolean;
2015
+ documentTypes: {
2016
+ label: string;
2017
+ type: "id_card" | "passport" | "incorporation_certificate" | "driver_license" | "birth_certificate" | "residence_permit" | "bank_statement" | "proof_of_address" | "custom";
2018
+ faces: ("front" | "back" | "single")[];
2019
+ attributeMapping?: {
2020
+ attributeId: string;
2021
+ extractedKey: string;
2022
+ required?: boolean | undefined;
2023
+ face?: "front" | "back" | "single" | undefined;
2024
+ }[] | undefined;
2025
+ }[];
2026
+ autoExtract?: boolean | undefined;
2027
+ autoValidate?: boolean | undefined;
2028
+ } | undefined;
2029
+ }>;
2030
+ /**
2031
+ * User attribute config schema
2032
+ */
2033
+ declare const userConfigSchema: z.ZodObject<{
2034
+ disabled: z.ZodOptional<z.ZodBoolean>;
2035
+ placeholder: z.ZodOptional<z.ZodString>;
2036
+ description: z.ZodOptional<z.ZodString>;
2037
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2038
+ icon: z.ZodOptional<z.ZodString>;
2039
+ order: z.ZodOptional<z.ZodNumber>;
2040
+ hidden: z.ZodOptional<z.ZodBoolean>;
2041
+ archived: z.ZodOptional<z.ZodBoolean>;
2042
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2043
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2044
+ } & {
2045
+ allowedRoles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2046
+ }, "strip", z.ZodTypeAny, {
2047
+ defaultValue?: unknown;
2048
+ disabled?: boolean | undefined;
2049
+ placeholder?: string | undefined;
2050
+ description?: string | undefined;
2051
+ icon?: string | undefined;
2052
+ order?: number | undefined;
2053
+ hidden?: boolean | undefined;
2054
+ archived?: boolean | undefined;
2055
+ deprecated?: boolean | undefined;
2056
+ metadata?: Record<string, unknown> | undefined;
2057
+ allowedRoles?: string[] | undefined;
2058
+ }, {
2059
+ defaultValue?: unknown;
2060
+ disabled?: boolean | undefined;
2061
+ placeholder?: string | undefined;
2062
+ description?: string | undefined;
2063
+ icon?: string | undefined;
2064
+ order?: number | undefined;
2065
+ hidden?: boolean | undefined;
2066
+ archived?: boolean | undefined;
2067
+ deprecated?: boolean | undefined;
2068
+ metadata?: Record<string, unknown> | undefined;
2069
+ allowedRoles?: string[] | undefined;
2070
+ }>;
2071
+ /**
2072
+ * Relation attribute config schema
2073
+ */
2074
+ declare const relationConfigSchema: z.ZodObject<{
2075
+ disabled: z.ZodOptional<z.ZodBoolean>;
2076
+ placeholder: z.ZodOptional<z.ZodString>;
2077
+ description: z.ZodOptional<z.ZodString>;
2078
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2079
+ icon: z.ZodOptional<z.ZodString>;
2080
+ order: z.ZodOptional<z.ZodNumber>;
2081
+ hidden: z.ZodOptional<z.ZodBoolean>;
2082
+ archived: z.ZodOptional<z.ZodBoolean>;
2083
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2084
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2085
+ } & {
2086
+ targets: z.ZodArray<z.ZodObject<{
2087
+ object: z.ZodString;
2088
+ displayTemplate: z.ZodOptional<z.ZodString>;
2089
+ filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2090
+ }, "strip", z.ZodTypeAny, {
2091
+ object: string;
2092
+ filter?: Record<string, unknown> | undefined;
2093
+ displayTemplate?: string | undefined;
2094
+ }, {
2095
+ object: string;
2096
+ filter?: Record<string, unknown> | undefined;
2097
+ displayTemplate?: string | undefined;
2098
+ }>, "many">;
2099
+ onDelete: z.ZodOptional<z.ZodEnum<["restrict", "cascade", "set_null"]>>;
2100
+ cardinality: z.ZodEnum<["one", "many"]>;
2101
+ minItems: z.ZodOptional<z.ZodNumber>;
2102
+ maxItems: z.ZodOptional<z.ZodNumber>;
2103
+ }, "strip", z.ZodTypeAny, {
2104
+ cardinality: "one" | "many";
2105
+ targets: {
2106
+ object: string;
2107
+ filter?: Record<string, unknown> | undefined;
2108
+ displayTemplate?: string | undefined;
2109
+ }[];
2110
+ defaultValue?: unknown;
2111
+ disabled?: boolean | undefined;
2112
+ placeholder?: string | undefined;
2113
+ description?: string | undefined;
2114
+ icon?: string | undefined;
2115
+ order?: number | undefined;
2116
+ hidden?: boolean | undefined;
2117
+ archived?: boolean | undefined;
2118
+ deprecated?: boolean | undefined;
2119
+ metadata?: Record<string, unknown> | undefined;
2120
+ onDelete?: "restrict" | "cascade" | "set_null" | undefined;
2121
+ minItems?: number | undefined;
2122
+ maxItems?: number | undefined;
2123
+ }, {
2124
+ cardinality: "one" | "many";
2125
+ targets: {
2126
+ object: string;
2127
+ filter?: Record<string, unknown> | undefined;
2128
+ displayTemplate?: string | undefined;
2129
+ }[];
2130
+ defaultValue?: unknown;
2131
+ disabled?: boolean | undefined;
2132
+ placeholder?: string | undefined;
2133
+ description?: string | undefined;
2134
+ icon?: string | undefined;
2135
+ order?: number | undefined;
2136
+ hidden?: boolean | undefined;
2137
+ archived?: boolean | undefined;
2138
+ deprecated?: boolean | undefined;
2139
+ metadata?: Record<string, unknown> | undefined;
2140
+ onDelete?: "restrict" | "cascade" | "set_null" | undefined;
2141
+ minItems?: number | undefined;
2142
+ maxItems?: number | undefined;
2143
+ }>;
2144
+ /**
2145
+ * Rating attribute config schema
2146
+ */
2147
+ declare const ratingConfigSchema: z.ZodObject<{
2148
+ disabled: z.ZodOptional<z.ZodBoolean>;
2149
+ placeholder: z.ZodOptional<z.ZodString>;
2150
+ description: z.ZodOptional<z.ZodString>;
2151
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
2152
+ icon: z.ZodOptional<z.ZodString>;
2153
+ order: z.ZodOptional<z.ZodNumber>;
2154
+ hidden: z.ZodOptional<z.ZodBoolean>;
2155
+ archived: z.ZodOptional<z.ZodBoolean>;
2156
+ deprecated: z.ZodOptional<z.ZodBoolean>;
2157
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2158
+ } & {
2159
+ max: z.ZodOptional<z.ZodNumber>;
2160
+ iconType: z.ZodOptional<z.ZodEnum<["star", "heart", "thumbs", "number"]>>;
2161
+ }, "strip", z.ZodTypeAny, {
2162
+ defaultValue?: unknown;
2163
+ disabled?: boolean | undefined;
2164
+ placeholder?: string | undefined;
2165
+ description?: string | undefined;
2166
+ icon?: string | undefined;
2167
+ order?: number | undefined;
2168
+ hidden?: boolean | undefined;
2169
+ archived?: boolean | undefined;
2170
+ deprecated?: boolean | undefined;
2171
+ metadata?: Record<string, unknown> | undefined;
2172
+ max?: number | undefined;
2173
+ iconType?: "number" | "heart" | "star" | "thumbs" | undefined;
2174
+ }, {
2175
+ defaultValue?: unknown;
2176
+ disabled?: boolean | undefined;
2177
+ placeholder?: string | undefined;
2178
+ description?: string | undefined;
2179
+ icon?: string | undefined;
2180
+ order?: number | undefined;
2181
+ hidden?: boolean | undefined;
2182
+ archived?: boolean | undefined;
2183
+ deprecated?: boolean | undefined;
2184
+ metadata?: Record<string, unknown> | undefined;
2185
+ max?: number | undefined;
2186
+ iconType?: "number" | "heart" | "star" | "thumbs" | undefined;
2187
+ }>;
2188
+ /**
2189
+ * Map of attribute type to config schema
2190
+ */
2191
+ declare const attributeConfigSchemas: Record<AttributeType, z.ZodObject<z.ZodRawShape>>;
2192
+ /**
2193
+ * Get the config schema for a specific attribute type
2194
+ */
2195
+ declare function getAttributeConfigSchema(type: AttributeType): z.ZodObject<z.ZodRawShape>;
2196
+ /**
2197
+ * Validate attribute config for a specific type
2198
+ * Returns the validated config with only allowed properties
2199
+ */
2200
+ declare function validateAttributeConfig(type: AttributeType, config: Record<string, unknown>): {
2201
+ success: true;
2202
+ data: Record<string, unknown>;
2203
+ } | {
2204
+ success: false;
2205
+ errors: string[];
2206
+ };
2207
+ /**
2208
+ * Validate and strip unknown properties from attribute config
2209
+ * This ensures only allowed properties are stored in the database
2210
+ */
2211
+ declare function parseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown>;
2212
+ /**
2213
+ * Safely parse attribute config, returning undefined for invalid configs
2214
+ */
2215
+ declare function safeParseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown> | undefined;
2216
+ /**
2217
+ * Create a Zod schema for a text attribute
2218
+ */
2219
+ declare function createTextValidator(attr: TextAttribute): z.ZodString;
2220
+ /**
2221
+ * Create a Zod schema for a number attribute
2222
+ */
2223
+ declare function createNumberValidator(attr: NumberAttribute): z.ZodNumber;
2224
+ /**
2225
+ * Create a Zod schema for a checkbox attribute
2226
+ */
2227
+ declare function createCheckboxValidator(_attr: CheckboxAttribute): z.ZodBoolean;
2228
+ /**
2229
+ * Create a Zod schema for a date attribute
2230
+ */
2231
+ declare function createDateValidator(attr: DateAttribute): z.ZodString;
2232
+ /**
2233
+ * Create a Zod schema for a phone attribute
2234
+ */
2235
+ declare function createPhoneValidator(_attr: PhoneAttribute): z.ZodType<{
2236
+ countryCode: string;
2237
+ phoneNumber: string;
2238
+ }>;
2239
+ /**
2240
+ * Create a Zod schema for a currency attribute
2241
+ */
2242
+ declare function createCurrencyValidator(_attr: CurrencyAttribute): z.ZodType<{
2243
+ code: string;
2244
+ value: number;
2245
+ }>;
2246
+ /**
2247
+ * Create a Zod schema for a status attribute
2248
+ */
2249
+ declare function createStatusValidator(attr: StatusAttribute): z.ZodEnum<[string, ...string[]]>;
2250
+ /**
2251
+ * Create a Zod schema for a select attribute
2252
+ */
2253
+ declare function createSelectValidator(attr: SelectAttribute): z.ZodEnum<[string, ...string[]]>;
2254
+ /**
2255
+ * Create a Zod schema for a multiselect attribute
2256
+ */
2257
+ declare function createMultiselectValidator(attr: MultiselectAttribute): z.ZodArray<z.ZodEnum<[string, ...string[]]>>;
2258
+ /**
2259
+ * Create a Zod schema for a location attribute
2260
+ */
2261
+ type LocationShape = {
2262
+ address?: string;
2263
+ address2?: string;
2264
+ city?: string;
2265
+ state?: string;
2266
+ postalCode?: string;
2267
+ country?: string;
2268
+ latitude?: number;
2269
+ longitude?: number;
2270
+ };
2271
+ declare function createLocationValidator(_attr: LocationAttribute): z.ZodType<LocationShape>;
2272
+ /**
2273
+ * Create a Zod schema for a timestamp attribute
2274
+ */
2275
+ declare function createTimestampValidator(_attr: TimestampAttribute): z.ZodNumber;
2276
+ /**
2277
+ * Create a Zod schema for a file attribute
2278
+ */
2279
+ declare function createFileValidator(_attr: FileAttribute): z.ZodString;
2280
+ /**
2281
+ * Create a Zod schema for a user attribute
2282
+ */
2283
+ declare function createUserValidator(_attr: UserAttribute): z.ZodString;
2284
+ /**
2285
+ * Create a Zod schema for a single relation attribute (cardinality: "one")
2286
+ */
2287
+ declare function createSingleRelationValidator(attr: SingleRelationAttribute): z.ZodUnion<[z.ZodString, z.ZodNull]>;
2288
+ /**
2289
+ * Create a Zod schema for a multi relation attribute (cardinality: "many")
2290
+ */
2291
+ declare function createMultiRelationValidator(attr: MultiRelationAttribute): z.ZodArray<z.ZodString>;
2292
+ /**
2293
+ * Create a Zod schema for a relation attribute
2294
+ * Dispatches to single or multi validator based on cardinality
2295
+ */
2296
+ declare function createRelationValidator(attr: RelationAttribute): z.ZodUnion<[z.ZodString, z.ZodNull]> | z.ZodArray<z.ZodString>;
2297
+ /**
2298
+ * Create a Zod schema for a rating attribute
2299
+ */
2300
+ declare function createRatingValidator(attr: RatingAttribute): z.ZodNumber;
2301
+ /**
2302
+ * Create a Zod schema for any attribute type
2303
+ */
2304
+ declare function createAttributeValidator(attr: Attribute): z.ZodTypeAny;
2305
+ /**
2306
+ * Create a Zod schema for an entire object
2307
+ */
2308
+ declare function createObjectValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
2309
+ /**
2310
+ * Validation result
2311
+ */
2312
+ interface ValidationResult {
2313
+ success: boolean;
2314
+ data?: Record<string, unknown>;
2315
+ errors?: Array<{
2316
+ path: string[];
2317
+ message: string;
2318
+ }>;
2319
+ }
2320
+ /**
2321
+ * Validate data against an attribute schema
2322
+ */
2323
+ declare function validateAttribute(attr: Attribute, value: unknown): ValidationResult;
2324
+ /**
2325
+ * Validate data against an object schema
2326
+ */
2327
+ declare function validateObject(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
2328
+ /**
2329
+ * Validate and throw if invalid
2330
+ */
2331
+ declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
2332
+ /**
2333
+ * Create a Zod schema for draft validation.
2334
+ * All attributes become optional, but provided values are still validated.
2335
+ */
2336
+ declare function createDraftValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
2337
+ /**
2338
+ * Validate data in draft mode.
2339
+ * - All attributes are treated as optional (no required validation)
2340
+ * - Provided values are still validated for format/type correctness
2341
+ *
2342
+ * Use this when creating records that may be incomplete (drafts).
2343
+ *
2344
+ * @example
2345
+ * ```typescript
2346
+ * const result = validateDraft(PRODUCT, { name: "Draft" });
2347
+ * // → success even if "price" is required but missing
2348
+ *
2349
+ * const result2 = validateDraft(PRODUCT, { price: -10 });
2350
+ * // → fails because price must be >= 0 (format validation still applies)
2351
+ * ```
2352
+ */
2353
+ declare function validateDraft(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
2354
+ /**
2355
+ * Validate draft data and throw if format validation fails.
2356
+ */
2357
+ declare function validateDraftOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
2358
+ /**
2359
+ * Get the list of required attributes that are missing values.
2360
+ *
2361
+ * @example
2362
+ * ```typescript
2363
+ * const missing = getMissingRequiredAttributes(PRODUCT, { name: "Test" });
2364
+ * // → [priceAttribute, statusAttribute] if price and status are required but missing
2365
+ * ```
2366
+ */
2367
+ declare function getMissingRequiredAttributes(objectDef: ObjectDefinition, data: Record<string, unknown>): Attribute[];
2368
+ /**
2369
+ * Check if a record is complete (all required attributes have valid values).
2370
+ *
2371
+ * @returns `true` if all required values are present and valid, `false` otherwise
2372
+ */
2373
+ declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<string, unknown>): boolean;
2374
+ /**
2375
+ * Compute the completion status of a record based on its data.
2376
+ *
2377
+ * - `"complete"`: All required values are present and valid
2378
+ * - `"draft"`: One or more required values are missing or invalid
2379
+ *
2380
+ * This function is used to dynamically determine the status when
2381
+ * creating or updating records.
2382
+ *
2383
+ * @example
2384
+ * ```typescript
2385
+ * const status = computeRecordStatus(PRODUCT, {
2386
+ * name: "Nike Air Max",
2387
+ * price: 129.99,
2388
+ * status: "active"
2389
+ * });
2390
+ * // → "complete"
2391
+ *
2392
+ * const status2 = computeRecordStatus(PRODUCT, { name: "Draft Product" });
2393
+ * // → "draft" (missing required fields)
2394
+ * ```
2395
+ */
2396
+ declare function computeRecordStatus(objectDef: ObjectDefinition, data: Record<string, unknown>): CompletionStatus;
2397
+
2398
+ /**
2399
+ * Object as stored in database (metadata)
2400
+ */
2401
+ interface DBObject extends Timestamps {
2402
+ id: Uuid;
2403
+ tenantId: TenantId;
2404
+ name: string;
2405
+ label: string;
2406
+ pluralLabel?: string;
2407
+ description?: string;
2408
+ icon?: IconName;
2409
+ labelExpression: string;
2410
+ system: boolean;
2411
+ metadata?: Record<string, unknown>;
2412
+ }
2413
+ interface CreateDBObject {
2414
+ tenantId: TenantId;
2415
+ name: string;
2416
+ label: string;
2417
+ pluralLabel?: string;
2418
+ description?: string;
2419
+ icon?: IconName;
2420
+ labelExpression: string;
2421
+ system?: boolean;
2422
+ metadata?: Record<string, unknown>;
2423
+ }
2424
+ interface UpdateDBObject {
2425
+ label?: string;
2426
+ pluralLabel?: string;
2427
+ description?: string;
2428
+ icon?: IconName;
2429
+ labelExpression?: string;
2430
+ metadata?: Record<string, unknown>;
2431
+ }
2432
+ interface UpsertDBObject extends CreateDBObject {
2433
+ system: boolean;
2434
+ }
2435
+ /**
2436
+ * Attribute as stored in database (metadata)
2437
+ */
2438
+ interface DBAttribute extends Timestamps {
2439
+ id: Uuid;
2440
+ objectId: Uuid;
2441
+ name: string;
2442
+ label: string;
2443
+ type: AttributeType;
2444
+ description?: string;
2445
+ icon?: IconName;
2446
+ system: boolean;
2447
+ required: boolean;
2448
+ unique: boolean;
2449
+ order: number;
2450
+ hidden?: boolean;
2451
+ archived?: boolean;
2452
+ deprecated?: boolean;
2453
+ defaultValue?: unknown;
2454
+ config: Record<string, unknown>;
2455
+ }
2456
+ interface CreateDBAttribute {
2457
+ objectId: Uuid;
2458
+ name: string;
2459
+ label: string;
2460
+ type: AttributeType;
2461
+ description?: string;
2462
+ icon?: IconName;
2463
+ system?: boolean;
2464
+ required?: boolean;
2465
+ unique?: boolean;
2466
+ order?: number;
2467
+ hidden?: boolean;
2468
+ archived?: boolean;
2469
+ deprecated?: boolean;
2470
+ defaultValue?: unknown;
2471
+ config?: Record<string, unknown>;
2472
+ }
2473
+ interface UpdateDBAttribute {
2474
+ label?: string;
2475
+ type?: AttributeType;
2476
+ description?: string;
2477
+ icon?: IconName;
2478
+ required?: boolean;
2479
+ order?: number;
2480
+ hidden?: boolean;
2481
+ archived?: boolean;
2482
+ deprecated?: boolean;
2483
+ defaultValue?: unknown;
2484
+ config?: Record<string, unknown>;
2485
+ }
2486
+ interface UpsertDBAttribute extends CreateDBAttribute {
2487
+ objectId: Uuid;
2488
+ name: string;
2489
+ }
2490
+
2491
+ /**
2492
+ * Object record creation data
2493
+ */
2494
+ interface CreateObjectRecord {
2495
+ tenantId: TenantId;
2496
+ objectId: Uuid;
2497
+ data: Record<string, unknown>;
2498
+ /**
2499
+ * Computed display label from labelExpression.
2500
+ * Stored for performance - avoids recomputation on every read.
2501
+ */
2502
+ label: string;
2503
+ /**
2504
+ * Completion status of the record.
2505
+ * - `draft`: Record is incomplete (missing required values)
2506
+ * - `complete`: All required values are present and valid
2507
+ */
2508
+ completionStatus: "draft" | "complete";
2509
+ }
2510
+ /**
2511
+ * Generic list options for pagination and sorting
2512
+ */
2513
+ interface ListOptions {
2514
+ limit?: number;
2515
+ offset?: number;
2516
+ /** @deprecated Use sorts instead */
2517
+ orderBy?: string;
2518
+ /** @deprecated Use sorts instead */
2519
+ orderDirection?: "asc" | "desc";
2520
+ /** Multiple sort rules */
2521
+ sorts?: SortRule[];
2522
+ /** Filter state */
2523
+ filters?: FilterState;
2524
+ }
2525
+ /**
2526
+ * Search options for full-text search
2527
+ */
2528
+ interface SearchOptions extends ListOptions {
2529
+ highlight?: boolean;
2530
+ }
2531
+ /**
2532
+ * Global search options
2533
+ */
2534
+ interface GlobalSearchOptions extends ListOptions {
2535
+ /**
2536
+ * Limit results to specific object names
2537
+ */
2538
+ objectNames?: string[];
2539
+ /**
2540
+ * Whether to include object metadata in results
2541
+ */
2542
+ includeObjectInfo?: boolean;
2543
+ }
2544
+ /**
2545
+ * Global search result item
2546
+ */
2547
+ interface GlobalSearchResultItem {
2548
+ objectId: string;
2549
+ objectName: string;
2550
+ objectLabel: string;
2551
+ /** Computed label from labelExpression */
2552
+ label: string;
2553
+ recordId: string;
2554
+ values: Record<string, unknown>;
2555
+ completionStatus: "draft" | "complete";
2556
+ createdAt: Date;
2557
+ updatedAt: Date;
2558
+ }
2559
+ /**
2560
+ * File-specific list options
2561
+ */
2562
+ interface FileListOptions extends ListOptions {
2563
+ folderPath?: string;
2564
+ mimeType?: string;
2565
+ uploadedBy?: Uuid;
2566
+ includeDeleted?: boolean;
2567
+ }
2568
+ /**
2569
+ * View as stored in database
2570
+ */
2571
+ interface DBView extends Timestamps {
2572
+ id: Uuid;
2573
+ tenantId: TenantId;
2574
+ objectId?: Uuid;
2575
+ objectName: string;
2576
+ name: string;
2577
+ label: string;
2578
+ description?: string;
2579
+ icon?: IconName;
2580
+ tabs: Tab[];
2581
+ default: boolean;
2582
+ system: boolean;
2583
+ metadata?: Record<string, unknown>;
2584
+ }
2585
+ interface CreateDBView {
2586
+ tenantId: TenantId;
2587
+ objectId?: Uuid;
2588
+ objectName: string;
2589
+ name: string;
2590
+ label: string;
2591
+ description?: string;
2592
+ icon?: IconName;
2593
+ tabs: Tab[];
2594
+ default?: boolean;
2595
+ system?: boolean;
2596
+ metadata?: Record<string, unknown>;
2597
+ }
2598
+ interface UpdateDBView {
2599
+ label?: string;
2600
+ description?: string;
2601
+ icon?: IconName;
2602
+ tabs?: Tab[];
2603
+ default?: boolean;
2604
+ metadata?: Record<string, unknown>;
2605
+ }
2606
+ interface UpsertDBView {
2607
+ tenantId: TenantId;
2608
+ objectName: string;
2609
+ name: string;
2610
+ label: string;
2611
+ description?: string;
2612
+ icon?: IconName;
2613
+ tabs: Tab[];
2614
+ default?: boolean;
2615
+ system?: boolean;
2616
+ metadata?: Record<string, unknown>;
2617
+ }
2618
+ /**
2619
+ * Result of an operation
2620
+ */
2621
+ interface OperationResult<T = unknown> {
2622
+ success: boolean;
2623
+ data?: T;
2624
+ error?: {
2625
+ code: string;
2626
+ message: string;
2627
+ details?: Record<string, unknown>;
2628
+ };
2629
+ }
2630
+
2631
+ /**
2632
+ * Repository for objects table (metadata)
2633
+ */
2634
+ interface ObjectsRepository {
2635
+ /**
2636
+ * Find object by ID
2637
+ */
2638
+ findById(id: Uuid): Promise<DBObject | null>;
2639
+ /**
2640
+ * Find object by name and tenant
2641
+ */
2642
+ findByName(tenantId: TenantId, name: string): Promise<DBObject | null>;
2643
+ /**
2644
+ * Find system/native object by name (system=true, for sync)
2645
+ */
2646
+ findSystemByName(name: string): Promise<DBObject | null>;
2647
+ /**
2648
+ * Create object
2649
+ */
2650
+ create(data: CreateDBObject): Promise<DBObject>;
2651
+ /**
2652
+ * Update object
2653
+ */
2654
+ update(id: Uuid, data: Partial<UpdateDBObject>): Promise<DBObject>;
2655
+ /**
2656
+ * Delete object
2657
+ */
2658
+ delete(id: Uuid): Promise<void>;
2659
+ /**
2660
+ * List all objects for a tenant
2661
+ */
2662
+ list(tenantId: TenantId): Promise<DBObject[]>;
2663
+ /**
2664
+ * Upsert object (create or update based on nativeObjectId)
2665
+ */
2666
+ upsert(data: UpsertDBObject): Promise<DBObject>;
2667
+ }
2668
+ /**
2669
+ * Repository for attributes table (metadata)
2670
+ */
2671
+ interface AttributesRepository {
2672
+ /**
2673
+ * Find attribute by ID
2674
+ */
2675
+ findById(id: Uuid): Promise<DBAttribute | null>;
2676
+ /**
2677
+ * Find attributes by object ID
2678
+ */
2679
+ findByObjectId(objectId: Uuid): Promise<DBAttribute[]>;
2680
+ /**
2681
+ * Create attribute
2682
+ */
2683
+ create(data: CreateDBAttribute): Promise<DBAttribute>;
2684
+ /**
2685
+ * Update attribute
2686
+ */
2687
+ update(id: Uuid, data: Partial<UpdateDBAttribute>): Promise<DBAttribute>;
2688
+ /**
2689
+ * Delete attribute
2690
+ */
2691
+ delete(id: Uuid): Promise<void>;
2692
+ /**
2693
+ * Delete multiple attributes by names (for sync cleanup)
2694
+ */
2695
+ deleteByNames(objectId: Uuid, excludeNames: string[]): Promise<number>;
2696
+ /**
2697
+ * Upsert attribute (create or update based on objectId + name)
2698
+ */
2699
+ upsert(data: UpsertDBAttribute): Promise<DBAttribute>;
2700
+ }
2701
+ /**
2702
+ * Repository for user_profiles table
2703
+ */
2704
+ interface UserProfilesRepository {
2705
+ /**
2706
+ * Find user profile by ID
2707
+ */
2708
+ findById(id: Uuid): Promise<UserProfile | null>;
2709
+ /**
2710
+ * Find user profile by auth ID (external auth provider)
2711
+ */
2712
+ findByAuthId(authId: string): Promise<UserProfile | null>;
2713
+ /**
2714
+ * Find user profile by email
2715
+ */
2716
+ findByEmail(tenantId: TenantId, email: string): Promise<UserProfile | null>;
2717
+ /**
2718
+ * Create user profile
2719
+ */
2720
+ create(data: CreateUserProfile): Promise<UserProfile>;
2721
+ /**
2722
+ * Update user profile
2723
+ */
2724
+ update(id: Uuid, data: UpdateUserProfile): Promise<UserProfile>;
2725
+ /**
2726
+ * Delete user profile
2727
+ */
2728
+ delete(id: Uuid): Promise<void>;
2729
+ /**
2730
+ * List all user profiles for a tenant
2731
+ */
2732
+ list(tenantId: TenantId, options?: ListOptions): Promise<UserProfile[]>;
2733
+ /**
2734
+ * Update last login timestamp
2735
+ */
2736
+ updateLastLogin(id: Uuid): Promise<void>;
2737
+ }
2738
+ /**
2739
+ * Repository for files table
2740
+ */
2741
+ interface FilesRepository {
2742
+ /**
2743
+ * Find file by ID
2744
+ */
2745
+ findById(id: Uuid): Promise<File | null>;
2746
+ /**
2747
+ * Create file
2748
+ */
2749
+ create(data: CreateFile): Promise<File>;
2750
+ /**
2751
+ * Update file
2752
+ */
2753
+ update(id: Uuid, data: UpdateFile): Promise<File>;
2754
+ /**
2755
+ * Delete file (soft delete)
2756
+ */
2757
+ delete(id: Uuid): Promise<void>;
2758
+ /**
2759
+ * Hard delete file (permanent)
2760
+ */
2761
+ hardDelete(id: Uuid): Promise<void>;
2762
+ /**
2763
+ * List files for a tenant
2764
+ */
2765
+ list(tenantId: TenantId, options?: FileListOptions): Promise<File[]>;
2766
+ /**
2767
+ * Find files by folder path
2768
+ */
2769
+ findByFolder(tenantId: TenantId, folderPath: string): Promise<File[]>;
2770
+ /**
2771
+ * Find files by uploader
2772
+ */
2773
+ findByUploader(uploadedBy: Uuid): Promise<File[]>;
2774
+ }
2775
+ /**
2776
+ * Repository for object_records table (unified JSONB)
2777
+ */
2778
+ interface ObjectRecordsRepository {
2779
+ /**
2780
+ * Find record by ID
2781
+ */
2782
+ findById(id: Uuid): Promise<ObjectRecord | null>;
2783
+ /**
2784
+ * Create record
2785
+ */
2786
+ create(data: CreateObjectRecord): Promise<ObjectRecord>;
2787
+ /**
2788
+ * Update record
2789
+ */
2790
+ update(id: Uuid, data: Partial<Record<string, unknown>>): Promise<ObjectRecord>;
2791
+ /**
2792
+ * Delete record
2793
+ */
2794
+ delete(id: Uuid): Promise<void>;
2795
+ /**
2796
+ * List records for an object
2797
+ */
2798
+ list(tenantId: TenantId, objectId: Uuid, options?: ListOptions): Promise<{
2799
+ records: ObjectRecord[];
2800
+ total: number;
2801
+ }>;
2802
+ /**
2803
+ * Search records using PostgreSQL full-text search
2804
+ */
2805
+ search(tenantId: TenantId, objectId: Uuid, query: string, options?: SearchOptions): Promise<{
2806
+ records: ObjectRecord[];
2807
+ total: number;
2808
+ }>;
2809
+ /**
2810
+ * Global search across all object records for a tenant
2811
+ * Searches in all objects or a subset specified by objectNames
2812
+ */
2813
+ globalSearch(tenantId: TenantId, query: string, options?: GlobalSearchOptions): Promise<{
2814
+ results: GlobalSearchResultItem[];
2815
+ total: number;
2816
+ }>;
2817
+ }
2818
+ /**
2819
+ * Repository for views table
2820
+ */
2821
+ interface ViewsRepository {
2822
+ /**
2823
+ * Find view by ID
2824
+ */
2825
+ findById(id: Uuid): Promise<DBView | null>;
2826
+ /**
2827
+ * Find view by name for an object and tenant
2828
+ */
2829
+ findByName(tenantId: TenantId, objectName: string, viewName: string): Promise<DBView | null>;
2830
+ /**
2831
+ * Find all views for an object and tenant
2832
+ */
2833
+ findByObjectName(tenantId: TenantId, objectName: string): Promise<DBView[]>;
2834
+ /**
2835
+ * Find all views for a tenant
2836
+ */
2837
+ findAllForTenant(tenantId: TenantId): Promise<DBView[]>;
2838
+ /**
2839
+ * Find system view by name (for sync)
2840
+ */
2841
+ findSystemByName(objectName: string, viewName: string): Promise<DBView | null>;
2842
+ /**
2843
+ * Find all system views for an object
2844
+ */
2845
+ findSystemByObjectName(objectName: string): Promise<DBView[]>;
2846
+ /**
2847
+ * Create view
2848
+ */
2849
+ create(data: CreateDBView): Promise<DBView>;
2850
+ /**
2851
+ * Update view
2852
+ */
2853
+ update(id: Uuid, data: Partial<UpdateDBView>): Promise<DBView>;
2854
+ /**
2855
+ * Delete view
2856
+ */
2857
+ delete(id: Uuid): Promise<void>;
2858
+ /**
2859
+ * Delete views not in the list (for sync cleanup)
2860
+ * @returns Number of deleted views
2861
+ */
2862
+ deleteNotIn(objectName: string, keepViewNames: string[]): Promise<number>;
2863
+ /**
2864
+ * Upsert view (create or update based on objectName + name)
2865
+ */
2866
+ upsert(data: UpsertDBView): Promise<DBView>;
2867
+ }
2868
+
2869
+ /**
2870
+ * Generic database adapter interface
2871
+ * Any ORM (Drizzle, Prisma, Kysely, TypeORM) can implement this interface
2872
+ * to work with @andyoucreate/schema runtime services
2873
+ *
2874
+ * @example
2875
+ * ```typescript
2876
+ * // Drizzle implementation
2877
+ * import { createDrizzleAdapter } from "./adapters/drizzle";
2878
+ * import { db } from "./db";
2879
+ *
2880
+ * const adapter = createDrizzleAdapter(db);
2881
+ *
2882
+ * // Prisma implementation
2883
+ * import { createPrismaAdapter } from "./adapters/prisma";
2884
+ * import { prisma } from "./db";
2885
+ *
2886
+ * const adapter = createPrismaAdapter(prisma);
2887
+ * ```
2888
+ */
2889
+ interface DatabaseAdapter {
2890
+ objects: ObjectsRepository;
2891
+ attributes: AttributesRepository;
2892
+ views: ViewsRepository;
2893
+ userProfiles: UserProfilesRepository;
2894
+ files: FilesRepository;
2895
+ objectRecords: ObjectRecordsRepository;
2896
+ transaction<T>(callback: (adapter: DatabaseAdapter) => Promise<T>): Promise<T>;
2897
+ }
2898
+
2899
+ /**
2900
+ * Types of hooks supported by the system
2901
+ */
2902
+ type HookType = "beforeCreate" | "afterCreate" | "beforeUpdate" | "afterUpdate" | "beforeDelete" | "afterDelete";
2903
+ /**
2904
+ * Change information for a specific attribute
2905
+ */
2906
+ interface AttributeChange<T = unknown> {
2907
+ oldValue: T | undefined;
2908
+ newValue: T | undefined;
2909
+ changed: boolean;
2910
+ }
2911
+ /**
2912
+ * Context passed to hooks - abstract, no framework dependencies
2913
+ *
2914
+ * This interface is designed to be extended by framework-specific implementations
2915
+ * (e.g., TriggerContext in schema-nestjs adds NestJS services)
2916
+ */
2917
+ interface HookContext<T = unknown> {
2918
+ objectId: string;
2919
+ objectName: string;
2920
+ recordId: string;
2921
+ tenantId: string;
2922
+ record: ObjectRecord;
2923
+ oldValues: Record<string, unknown>;
2924
+ newValues: Record<string, unknown>;
2925
+ changedAttributes: string[];
2926
+ /**
2927
+ * Get change information for a specific attribute
2928
+ * @param attributeName - The name of the attribute to check
2929
+ * @returns Change information including old value, new value, and whether it changed
2930
+ */
2931
+ getChange<V = T>(attributeName: string): AttributeChange<V>;
2932
+ metadata: Record<string, unknown>;
2933
+ timestamp: Date;
2934
+ }
2935
+ /**
2936
+ * Generic hook handler function
2937
+ */
2938
+ type HookHandler = (ctx: HookContext) => Promise<void> | void;
2939
+ /**
2940
+ * Definition of a hook for registration
2941
+ */
2942
+ interface HookDefinition {
2943
+ type: HookType;
2944
+ objectName: string;
2945
+ /** Attribute name to watch, or '*' for all attributes */
2946
+ attributeName?: string | "*";
2947
+ /** Execution priority (lower = earlier), default 0 */
2948
+ priority?: number;
2949
+ handler: HookHandler;
2950
+ }
2951
+
2952
+ /**
2953
+ * Abstract interface for hook registry
2954
+ *
2955
+ * This interface is implemented by TriggerRegistry in schema-nestjs
2956
+ * to provide NestJS-specific functionality like dependency injection
2957
+ * and automatic discovery of trigger classes.
2958
+ */
2959
+ interface HookRegistry {
2960
+ /**
2961
+ * Execute all hooks of a given type for an object
2962
+ *
2963
+ * @param type - The type of hook to execute (beforeUpdate, afterUpdate, etc.)
2964
+ * @param objectName - The name of the object being modified
2965
+ * @param ctx - The hook context containing record data and changes
2966
+ */
2967
+ execute(type: HookType, objectName: string, ctx: HookContext): Promise<void>;
2968
+ /**
2969
+ * Register a hook manually (optional)
2970
+ * Not all implementations need to support this (e.g., decorator-based discovery)
2971
+ */
2972
+ register?(hook: HookDefinition): void;
2973
+ }
2974
+ /**
2975
+ * No-op implementation of HookRegistry
2976
+ *
2977
+ * Used as default when no registry is provided to RecordService.
2978
+ * This allows the schema package to work independently without triggers.
2979
+ */
2980
+ declare class NoopHookRegistry implements HookRegistry {
2981
+ execute(): Promise<void>;
2982
+ }
2983
+
2984
+ interface InternalObjectRecord extends ObjectRecord {
2985
+ tenantId: TenantId;
2986
+ }
2987
+ interface MockStores {
2988
+ objects: Map<Uuid, DBObject>;
2989
+ attributes: Map<Uuid, DBAttribute>;
2990
+ userProfiles: Map<Uuid, UserProfile>;
2991
+ files: Map<Uuid, File>;
2992
+ objectRecords: Map<Uuid, InternalObjectRecord>;
2993
+ views: Map<Uuid, DBView>;
2994
+ }
2995
+ /**
2996
+ * Create an in-memory mock adapter for testing and development
2997
+ *
2998
+ * This adapter stores all data in memory and is perfect for:
2999
+ * - Unit tests
3000
+ * - Integration tests
3001
+ * - Local development without a database
3002
+ * - Understanding the adapter interface
3003
+ *
3004
+ * @returns A DatabaseAdapter implementation using in-memory storage
3005
+ *
3006
+ * @example
3007
+ * ```typescript
3008
+ * import { createMockAdapter, RecordService } from "@andyoucreate/schema";
3009
+ *
3010
+ * // Create adapter
3011
+ * const adapter = createMockAdapter();
3012
+ *
3013
+ * // Use with services
3014
+ * const recordService = new RecordService(adapter, "tenant-123");
3015
+ *
3016
+ * // Create a record
3017
+ * const product = await recordService.createRecord("obj-product", {
3018
+ * name: "Nike Air Max",
3019
+ * price: 129.99
3020
+ * });
3021
+ *
3022
+ * // List records
3023
+ * const { records, total } = await recordService.listRecords("obj-product");
3024
+ * ```
3025
+ */
3026
+ declare function createMockAdapter(): DatabaseAdapter & {
3027
+ _stores: MockStores;
3028
+ reset(): void;
3029
+ };
3030
+
3031
+ /**
3032
+ * Service for managing files
3033
+ * Handles file metadata CRUD, permissions, and soft delete
3034
+ */
3035
+ declare class FileService {
3036
+ private adapter;
3037
+ private tenantId;
3038
+ constructor(adapter: DatabaseAdapter, tenantId: string);
3039
+ /**
3040
+ * Create a new file record (after upload to storage)
3041
+ *
3042
+ * @param data - File metadata
3043
+ * @returns Created file record
3044
+ *
3045
+ * @example
3046
+ * ```typescript
3047
+ * const service = new FileService(adapter, "tenant-123");
3048
+ *
3049
+ * // After uploading to S3
3050
+ * const file = await service.createFile({
3051
+ * tenantId: "tenant-123",
3052
+ * name: "contract-2025.pdf",
3053
+ * originalName: "Contract Acme Corp 2025.pdf",
3054
+ * mimeType: "application/pdf",
3055
+ * size: 2458624,
3056
+ * storageProvider: "s3",
3057
+ * storagePath: "tenants/123/files/2025/contract.pdf",
3058
+ * storageBucket: "my-app-files",
3059
+ * url: "https://cdn.example.com/files/file-123",
3060
+ * uploadedBy: "profile-456",
3061
+ * visibility: "private"
3062
+ * });
3063
+ * ```
3064
+ */
3065
+ createFile(data: CreateFile): Promise<File>;
3066
+ /**
3067
+ * Get file by ID
3068
+ */
3069
+ getFile(fileId: string): Promise<File | null>;
3070
+ /**
3071
+ * Get file by ID or throw
3072
+ */
3073
+ getFileOrThrow(fileId: string): Promise<File>;
3074
+ /**
3075
+ * Update file metadata
3076
+ *
3077
+ * @param fileId - File UUID
3078
+ * @param data - Data to update
3079
+ * @returns Updated file
3080
+ */
3081
+ updateFile(fileId: string, data: UpdateFile): Promise<File>;
3082
+ /**
3083
+ * Delete file (soft delete)
3084
+ *
3085
+ * @param fileId - File UUID
3086
+ * @param options - Delete options
3087
+ */
3088
+ deleteFile(fileId: string, options?: {
3089
+ hard?: boolean;
3090
+ checkOwnership?: boolean;
3091
+ userId?: string;
3092
+ }): Promise<void>;
3093
+ /**
3094
+ * List files for the tenant
3095
+ */
3096
+ listFiles(options?: FileListOptions): Promise<File[]>;
3097
+ /**
3098
+ * List files by folder
3099
+ */
3100
+ listFilesByFolder(folderPath: string): Promise<File[]>;
3101
+ /**
3102
+ * List files uploaded by a specific user
3103
+ */
3104
+ listFilesByUploader(uploadedBy: string): Promise<File[]>;
3105
+ /**
3106
+ * Change file visibility
3107
+ *
3108
+ * @param fileId - File UUID
3109
+ * @param visibility - New visibility level
3110
+ * @param allowedUsers - Users allowed to access (if restricted)
3111
+ */
3112
+ changeVisibility(fileId: string, visibility: "public" | "private" | "restricted", allowedUsers?: string[]): Promise<File>;
3113
+ /**
3114
+ * Grant access to a file for specific users
3115
+ *
3116
+ * @param fileId - File UUID
3117
+ * @param userIds - User IDs to grant access
3118
+ */
3119
+ grantAccess(fileId: string, userIds: string[]): Promise<File>;
3120
+ /**
3121
+ * Revoke access to a file for specific users
3122
+ *
3123
+ * @param fileId - File UUID
3124
+ * @param userIds - User IDs to revoke access
3125
+ */
3126
+ revokeAccess(fileId: string, userIds: string[]): Promise<File>;
3127
+ /**
3128
+ * Check if user has access to a file
3129
+ *
3130
+ * @param fileId - File UUID
3131
+ * @param userId - User ID to check
3132
+ * @returns true if user can access the file
3133
+ */
3134
+ canAccess(fileId: string, userId: string): Promise<boolean>;
3135
+ /**
3136
+ * Move file to different folder
3137
+ */
3138
+ moveToFolder(fileId: string, newFolderPath: string): Promise<File>;
3139
+ /**
3140
+ * Add tags to file
3141
+ */
3142
+ addTags(fileId: string, tags: string[]): Promise<File>;
3143
+ /**
3144
+ * Remove tags from file
3145
+ */
3146
+ removeTags(fileId: string, tags: string[]): Promise<File>;
3147
+ }
3148
+
3149
+ /**
3150
+ * Geocoding service for address autocomplete and geocoding operations
3151
+ *
3152
+ * @example
3153
+ * ```typescript
3154
+ * import { GeocodingService } from "@andyoucreate/schema";
3155
+ * import { GoogleMapsAdapter } from "./adapters/google-maps";
3156
+ *
3157
+ * const geocoding = new GeocodingService(new GoogleMapsAdapter({ apiKey: "..." }));
3158
+ *
3159
+ * const suggestions = await geocoding.autocomplete({
3160
+ * query: "40 Quai des Belges",
3161
+ * countries: ["FRA"],
3162
+ * limit: 5,
3163
+ * });
3164
+ * ```
3165
+ */
3166
+ declare class GeocodingService {
3167
+ private readonly adapter;
3168
+ constructor(adapter: GeocodingAdapter);
3169
+ /**
3170
+ * Search for address suggestions as the user types
3171
+ */
3172
+ autocomplete(params: GeocodingAutocompleteParams): Promise<GeocodingSuggestion[]>;
3173
+ /**
3174
+ * Reverse geocode coordinates to an address
3175
+ */
3176
+ reverse(params: ReverseGeocodingParams): Promise<GeocodingSuggestion | null>;
3177
+ /**
3178
+ * Geocode a structured address to coordinates
3179
+ */
3180
+ geocode(params: GeocodingParams): Promise<GeocodingSuggestion | null>;
3181
+ }
3182
+
3183
+ /**
3184
+ * Service for global search across all object records
3185
+ * Allows searching across all objects or a subset of objects for a tenant
3186
+ *
3187
+ * @example
3188
+ * ```typescript
3189
+ * const service = new GlobalSearchService(adapter, "tenant-123");
3190
+ *
3191
+ * // Search across all objects
3192
+ * const { results, total } = await service.search("nike");
3193
+ *
3194
+ * // Search only in specific objects
3195
+ * const { results, total } = await service.search("nike", {
3196
+ * objectNames: ["products", "orders"],
3197
+ * limit: 20
3198
+ * });
3199
+ * ```
3200
+ */
3201
+ declare class GlobalSearchService {
3202
+ private adapter;
3203
+ private tenantId;
3204
+ constructor(adapter: DatabaseAdapter, tenantId: string);
3205
+ /**
3206
+ * Search across all object records for the tenant
3207
+ *
3208
+ * @param query - Search query string
3209
+ * @param options - Search options (pagination, object filters)
3210
+ * @returns Matching records with object metadata and total count
3211
+ *
3212
+ * @example
3213
+ * ```typescript
3214
+ * // Basic search
3215
+ * const { results, total } = await service.search("nike air");
3216
+ *
3217
+ * // With pagination
3218
+ * const { results, total } = await service.search("nike", {
3219
+ * limit: 10,
3220
+ * offset: 20
3221
+ * });
3222
+ *
3223
+ * // Filter by object types
3224
+ * const { results, total } = await service.search("nike", {
3225
+ * objectNames: ["products", "orders"]
3226
+ * });
3227
+ * ```
3228
+ */
3229
+ search(query: string, options?: GlobalSearchOptions): Promise<{
3230
+ results: GlobalSearchResultItem[];
3231
+ total: number;
3232
+ }>;
3233
+ /**
3234
+ * Search and group results by object type
3235
+ *
3236
+ * @param query - Search query string
3237
+ * @param options - Search options
3238
+ * @returns Results grouped by object name
3239
+ */
3240
+ searchGrouped(query: string, options?: Omit<GlobalSearchOptions, "limit" | "offset">): Promise<{
3241
+ groups: Array<{
3242
+ objectName: string;
3243
+ objectLabel: string;
3244
+ results: GlobalSearchResultItem[];
3245
+ count: number;
3246
+ }>;
3247
+ total: number;
3248
+ }>;
3249
+ }
3250
+
3251
+ /**
3252
+ * Input for creating a custom object
3253
+ */
3254
+ interface CreateCustomObjectInput {
3255
+ name: string;
3256
+ label: string;
3257
+ /**
3258
+ * Template expression for computing record display labels.
3259
+ * Example: "{{ name }}" or "{{ firstName }} {{ lastName }}"
3260
+ */
3261
+ labelExpression: string;
3262
+ description?: string;
3263
+ icon?: IconName;
3264
+ attributes?: (Attribute | {
3265
+ build: () => Attribute;
3266
+ })[];
3267
+ metadata?: Record<string, unknown>;
3268
+ }
3269
+ /**
3270
+ * Input for adding an attribute to an object
3271
+ */
3272
+ interface AddAttributeInput {
3273
+ name: string;
3274
+ label: string;
3275
+ type: AttributeType;
3276
+ required?: boolean;
3277
+ unique?: boolean;
3278
+ description?: string;
3279
+ placeholder?: string;
3280
+ icon?: IconName;
3281
+ defaultValue?: unknown;
3282
+ metadata?: Record<string, unknown>;
3283
+ [key: string]: unknown;
3284
+ }
3285
+ /**
3286
+ * Service for managing object schemas
3287
+ * Handles fusion of native objects (from registry) and custom objects (from database)
3288
+ */
3289
+ declare class ObjectSchemaService {
3290
+ private adapter;
3291
+ private nativeRegistry;
3292
+ constructor(adapter: DatabaseAdapter, nativeRegistry: typeof registry);
3293
+ /**
3294
+ * Create a new custom object
3295
+ * Validates name format and ensures system=false
3296
+ *
3297
+ * @param definition - Object definition (attributes can be raw definitions or builders)
3298
+ * @param tenantId - Tenant ID owning the object
3299
+ * @returns Created ObjectDefinition
3300
+ */
3301
+ createCustomObject(definition: CreateCustomObjectInput, tenantId: string): Promise<ObjectDefinition>;
3302
+ /**
3303
+ * Add a custom attribute to an existing object
3304
+ * Can be used on both custom and native objects
3305
+ * Attributes added via API are always custom (system=false)
3306
+ *
3307
+ * @param objectId - Object UUID from database
3308
+ * @param attribute - Attribute definition
3309
+ * @param tenantId - Tenant ID (required for relation validation)
3310
+ * @returns Created Attribute
3311
+ */
3312
+ addAttributeToObject(objectId: string, attribute: AddAttributeInput, tenantId?: string): Promise<Attribute>;
3313
+ /**
3314
+ * Update an attribute
3315
+ * Can only update custom attributes (system=false)
3316
+ *
3317
+ * @param attributeId - Attribute UUID
3318
+ * @param updates - Partial attribute updates
3319
+ * @param tenantId - Tenant ID (required for relation validation)
3320
+ * @returns Updated Attribute
3321
+ */
3322
+ updateAttribute(attributeId: string, updates: Partial<AddAttributeInput>, tenantId?: string): Promise<Attribute>;
3323
+ /**
3324
+ * Delete an attribute
3325
+ * Can only delete custom attributes (system=false)
3326
+ *
3327
+ * @param attributeId - Attribute UUID
3328
+ */
3329
+ deleteAttribute(attributeId: string): Promise<void>;
3330
+ /**
3331
+ * List attributes for an object
3332
+ *
3333
+ * @param objectId - Object UUID
3334
+ * @param options - Filter options
3335
+ * @returns List of attributes
3336
+ */
3337
+ listAttributes(objectId: string, options?: {
3338
+ systemOnly?: boolean;
3339
+ customOnly?: boolean;
3340
+ }): Promise<Attribute[]>;
3341
+ /**
3342
+ * Validate attribute name format (variable identifier)
3343
+ * @internal
3344
+ */
3345
+ private validateAttributeName;
3346
+ /**
3347
+ * Get complete object schema (system + custom attributes)
3348
+ * If object is native, merges registry definition with DB custom attributes
3349
+ * If object is custom, returns DB definition only
3350
+ *
3351
+ * @param objectId - Object UUID from database
3352
+ * @returns Complete ObjectDefinition with all attributes
3353
+ *
3354
+ * @example
3355
+ * ```typescript
3356
+ * const service = new ObjectSchemaService(adapter, registry);
3357
+ * const productSchema = await service.getObjectSchema("obj-123");
3358
+ *
3359
+ * console.log(productSchema.attributes); // System + custom attributes
3360
+ * ```
3361
+ */
3362
+ getObjectSchema(objectId: string): Promise<ObjectDefinition>;
3363
+ /**
3364
+ * Get object schema by name (for system/native objects)
3365
+ * @deprecated Use getObjectSchemaByNameForTenant for custom objects support
3366
+ */
3367
+ getObjectSchemaByName(name: string): Promise<ObjectDefinition>;
3368
+ /**
3369
+ * Get object schema by name for a tenant (supports both native and custom objects)
3370
+ */
3371
+ getObjectSchemaByNameForTenant(name: string, tenantId: string): Promise<ObjectDefinition>;
3372
+ /**
3373
+ * List all object schemas for a tenant
3374
+ */
3375
+ listObjectSchemas(tenantId: string): Promise<ObjectDefinition[]>;
3376
+ /**
3377
+ * Merge native object from registry with custom attributes from DB
3378
+ * @internal
3379
+ */
3380
+ private mergeNativeObject;
3381
+ /**
3382
+ * Convert DB object + attributes to ObjectDefinition
3383
+ * @internal
3384
+ */
3385
+ private convertDBObjectToDefinition;
3386
+ /**
3387
+ * Validate attribute input and return parsed config
3388
+ * Validates: name format, config schema, relation targets
3389
+ * @internal
3390
+ */
3391
+ private validateAttributeInput;
3392
+ /**
3393
+ * Build and validate attribute config from input
3394
+ * Uses Zod schema to validate and strip unknown properties
3395
+ * @internal
3396
+ */
3397
+ private buildAttributeConfig;
3398
+ /**
3399
+ * Validate that relation target objects exist
3400
+ * @internal
3401
+ */
3402
+ private validateRelationTargets;
3403
+ /**
3404
+ * Convert DB attribute to Attribute type
3405
+ * @internal
3406
+ */
3407
+ private convertDBAttributeToAttribute;
3408
+ }
3409
+
3410
+ /**
3411
+ * Options for RecordService constructor
3412
+ */
3413
+ interface RecordServiceOptions {
3414
+ /**
3415
+ * Hook registry for executing triggers before/after operations.
3416
+ * If not provided, a no-op registry is used (no hooks executed).
3417
+ */
3418
+ hookRegistry?: HookRegistry;
3419
+ }
3420
+ /**
3421
+ * Service for managing object records (CRUD operations)
3422
+ * Handles validation, dispatch to correct table, and data consistency
3423
+ *
3424
+ * Supports optional hook system for triggers on attribute changes.
3425
+ */
3426
+ declare class RecordService {
3427
+ private adapter;
3428
+ private tenantId;
3429
+ private schemaService;
3430
+ private relationService;
3431
+ private hookRegistry;
3432
+ constructor(adapter: DatabaseAdapter, tenantId: string, options?: RecordServiceOptions);
3433
+ /**
3434
+ * Compute display label from schema expression
3435
+ * @internal
3436
+ */
3437
+ private computeLabel;
3438
+ /**
3439
+ * Create a new record with validation
3440
+ *
3441
+ * Triggers beforeCreate and afterCreate hooks if a HookRegistry is configured.
3442
+ *
3443
+ * @param objectId - Object UUID
3444
+ * @param data - Record data (attribute values)
3445
+ * @param options - Creation options
3446
+ * @returns Created record with computed completionStatus
3447
+ *
3448
+ * @example
3449
+ * ```typescript
3450
+ * const service = new RecordService(adapter, "tenant-123");
3451
+ *
3452
+ * // Create a complete record (strict validation)
3453
+ * const product = await service.createRecord("obj-product", {
3454
+ * name: "Nike Air Max",
3455
+ * price: 129.99,
3456
+ * status: "active"
3457
+ * });
3458
+ * // → product.completionStatus = "complete"
3459
+ *
3460
+ * // Create a draft record (allows missing required fields)
3461
+ * const draft = await service.createRecord("obj-product", {
3462
+ * name: "Draft Product"
3463
+ * }, { allowDraft: true });
3464
+ * // → draft.completionStatus = "draft"
3465
+ * ```
3466
+ */
3467
+ createRecord(objectId: string, data: Record<string, unknown>, options?: {
3468
+ /**
3469
+ * Allow creating records with missing required fields.
3470
+ * Format validation still applies to provided values.
3471
+ * @default false
3472
+ */
3473
+ allowDraft?: boolean;
3474
+ /**
3475
+ * Skip all validation (format + relations).
3476
+ * @default true
3477
+ */
3478
+ validate?: boolean;
3479
+ /**
3480
+ * Skip relation validation only.
3481
+ * Useful for bulk imports where relations are validated separately.
3482
+ * @default false
3483
+ */
3484
+ skipRelationValidation?: boolean;
3485
+ skipSystemCheck?: boolean;
3486
+ /**
3487
+ * Skip hook execution.
3488
+ * @default false
3489
+ */
3490
+ skipHooks?: boolean;
3491
+ /**
3492
+ * Additional metadata to pass to hooks (e.g., userId, requestId).
3493
+ */
3494
+ hookMetadata?: Record<string, unknown>;
3495
+ }): Promise<ObjectRecord>;
3496
+ /**
3497
+ * Get a record by ID
3498
+ *
3499
+ * @param recordId - Record UUID
3500
+ * @param options - Query options
3501
+ * @returns Record or null if not found
3502
+ */
3503
+ getRecord(recordId: string, options?: {
3504
+ includeSchema?: boolean;
3505
+ }): Promise<ObjectRecord | null>;
3506
+ /**
3507
+ * Get a record by ID or throw if not found
3508
+ */
3509
+ getRecordOrThrow(recordId: string): Promise<ObjectRecord>;
3510
+ /**
3511
+ * Update a record with validation
3512
+ *
3513
+ * The completion status is automatically recalculated after each update.
3514
+ * A draft record becomes complete when all required fields are filled.
3515
+ *
3516
+ * Triggers beforeUpdate and afterUpdate hooks if a HookRegistry is configured.
3517
+ *
3518
+ * @param recordId - Record UUID
3519
+ * @param data - Partial data to update
3520
+ * @param options - Update options
3521
+ * @returns Updated record with recalculated completionStatus
3522
+ *
3523
+ * @example
3524
+ * ```typescript
3525
+ * // Update a draft record to make it complete
3526
+ * const updated = await service.updateRecord(draftId, {
3527
+ * price: 99.99,
3528
+ * status: "active"
3529
+ * });
3530
+ * // → updated.completionStatus = "complete" if all required fields now present
3531
+ * ```
3532
+ */
3533
+ updateRecord(recordId: string, data: Partial<Record<string, unknown>>, options?: {
3534
+ /**
3535
+ * Skip validation entirely (format + relations).
3536
+ * @default true
3537
+ */
3538
+ validate?: boolean;
3539
+ /**
3540
+ * Allow partial updates without strict validation.
3541
+ * Format validation still applies to provided values.
3542
+ * @default false
3543
+ */
3544
+ partial?: boolean;
3545
+ /**
3546
+ * Skip relation validation only.
3547
+ * @default false
3548
+ */
3549
+ skipRelationValidation?: boolean;
3550
+ /**
3551
+ * Skip hook execution.
3552
+ * @default false
3553
+ */
3554
+ skipHooks?: boolean;
3555
+ /**
3556
+ * Additional metadata to pass to hooks (e.g., userId, requestId).
3557
+ */
3558
+ hookMetadata?: Record<string, unknown>;
3559
+ }): Promise<ObjectRecord>;
3560
+ /**
3561
+ * Build hook context for update operations
3562
+ * @internal
3563
+ */
3564
+ private buildHookContext;
3565
+ /**
3566
+ * Build hook context for create operations (no existing record)
3567
+ * @internal
3568
+ */
3569
+ private buildCreateHookContext;
3570
+ /**
3571
+ * Build hook context for delete operations
3572
+ * @internal
3573
+ */
3574
+ private buildDeleteHookContext;
3575
+ /**
3576
+ * Delete a record
3577
+ *
3578
+ * Triggers beforeDelete and afterDelete hooks if a HookRegistry is configured.
3579
+ *
3580
+ * @param recordId - Record UUID
3581
+ * @param options - Delete options
3582
+ */
3583
+ deleteRecord(recordId: string, options?: {
3584
+ checkSystem?: boolean;
3585
+ /**
3586
+ * Skip hook execution.
3587
+ * @default false
3588
+ */
3589
+ skipHooks?: boolean;
3590
+ /**
3591
+ * Additional metadata to pass to hooks (e.g., userId, requestId).
3592
+ */
3593
+ hookMetadata?: Record<string, unknown>;
3594
+ }): Promise<void>;
3595
+ /**
3596
+ * List records for an object with pagination
3597
+ *
3598
+ * @param objectId - Object UUID
3599
+ * @param options - List options
3600
+ * @returns Records and total count
3601
+ */
3602
+ listRecords(objectId: string, options?: {
3603
+ limit?: number;
3604
+ offset?: number;
3605
+ orderBy?: string;
3606
+ orderDirection?: "asc" | "desc";
3607
+ }): Promise<{
3608
+ records: ObjectRecord[];
3609
+ total: number;
3610
+ }>;
3611
+ /**
3612
+ * Search records using full-text search
3613
+ *
3614
+ * @param objectId - Object UUID
3615
+ * @param query - Search query
3616
+ * @param options - Search options
3617
+ * @returns Matching records and total count
3618
+ */
3619
+ searchRecords(objectId: string, query: string, options?: {
3620
+ limit?: number;
3621
+ offset?: number;
3622
+ }): Promise<{
3623
+ records: ObjectRecord[];
3624
+ total: number;
3625
+ }>;
3626
+ /**
3627
+ * Validate data against object schema without saving
3628
+ *
3629
+ * @param objectId - Object UUID
3630
+ * @param data - Data to validate
3631
+ * @returns Validation result
3632
+ */
3633
+ validateData(objectId: string, data: Record<string, unknown>): Promise<ValidationResult>;
3634
+ /**
3635
+ * Compute the completion status for given data without saving.
3636
+ * Useful for UI to show draft/complete status before submitting.
3637
+ *
3638
+ * @param objectId - Object UUID
3639
+ * @param data - Data to check
3640
+ * @returns Computed completion status
3641
+ */
3642
+ computeStatus(objectId: string, data: Record<string, unknown>): Promise<CompletionStatus>;
3643
+ /**
3644
+ * Refresh the completion status of an existing record.
3645
+ * Useful when schema changes and you need to recompute statuses.
3646
+ *
3647
+ * @param recordId - Record UUID
3648
+ * @returns Updated completion status
3649
+ */
3650
+ refreshRecordStatus(recordId: string): Promise<CompletionStatus>;
3651
+ }
3652
+
3653
+ /**
3654
+ * Result of relation validation
3655
+ */
3656
+ interface RelationValidationResult {
3657
+ valid: boolean;
3658
+ errors: RelationValidationError[];
3659
+ }
3660
+ /**
3661
+ * Individual relation validation error
3662
+ */
3663
+ interface RelationValidationError {
3664
+ /** Attribute name */
3665
+ attribute: string;
3666
+ /** Error message */
3667
+ message: string;
3668
+ /** Invalid record IDs */
3669
+ invalidIds?: string[];
3670
+ }
3671
+ /**
3672
+ * Resolved relation option
3673
+ */
3674
+ interface RelationOption {
3675
+ /** Record ID */
3676
+ id: string;
3677
+ /** Object ID */
3678
+ objectId: string;
3679
+ /** Object name (technical name) */
3680
+ objectName: string;
3681
+ /** Object label (display name) */
3682
+ objectLabel: string;
3683
+ /** Object icon */
3684
+ objectIcon?: string;
3685
+ /** Display label (computed from labelExpression) */
3686
+ label: string;
3687
+ /** Additional record data */
3688
+ data?: Record<string, unknown>;
3689
+ }
3690
+ /**
3691
+ * Response for relation options
3692
+ */
3693
+ interface RelationOptionsResponse {
3694
+ options: RelationOption[];
3695
+ hasMore: boolean;
3696
+ total: number;
3697
+ }
3698
+ /**
3699
+ * Parameters for fetching relation options
3700
+ */
3701
+ interface GetRelationOptionsParams {
3702
+ /** Search query */
3703
+ query?: string;
3704
+ /** Page number (1-based) */
3705
+ page?: number;
3706
+ /** Page size */
3707
+ pageSize?: number;
3708
+ /** Filter by specific target object */
3709
+ targetObject?: string;
3710
+ }
3711
+ /**
3712
+ * Service for validating relation attributes
3713
+ * Ensures referenced records exist and belong to valid target objects
3714
+ */
3715
+ declare class RelationService {
3716
+ private adapter;
3717
+ private schemaService;
3718
+ constructor(adapter: DatabaseAdapter, nativeRegistry: typeof registry);
3719
+ /**
3720
+ * Validate all relation attributes in the data
3721
+ *
3722
+ * @param schema - Object schema containing attribute definitions
3723
+ * @param data - Record data to validate
3724
+ * @returns Validation result with errors if any
3725
+ *
3726
+ * @example
3727
+ * ```typescript
3728
+ * const result = await relationService.validateRelations(schema, {
3729
+ * company: "rec-123",
3730
+ * contacts: ["rec-456", "rec-789"]
3731
+ * });
3732
+ *
3733
+ * if (!result.valid) {
3734
+ * console.log(result.errors);
3735
+ * // [{ attribute: "company", message: "Record not found", invalidIds: ["rec-123"] }]
3736
+ * }
3737
+ * ```
3738
+ */
3739
+ validateRelations(schema: ObjectDefinition, data: Record<string, unknown>): Promise<RelationValidationResult>;
3740
+ /**
3741
+ * Validate a single relation attribute value
3742
+ */
3743
+ private validateRelationAttribute;
3744
+ /**
3745
+ * Extract IDs from relation value based on cardinality
3746
+ */
3747
+ private extractIds;
3748
+ /**
3749
+ * Get valid object IDs from relation targets
3750
+ */
3751
+ private getValidObjectIds;
3752
+ /**
3753
+ * Validate relations and throw if invalid
3754
+ */
3755
+ validateRelationsOrThrow(schema: ObjectDefinition, data: Record<string, unknown>): Promise<void>;
3756
+ /**
3757
+ * Get available options for a relation attribute
3758
+ * Searches across all target objects defined in the relation
3759
+ *
3760
+ * @param attribute - Relation attribute definition
3761
+ * @param tenantId - Tenant ID for multi-tenant isolation
3762
+ * @param params - Query parameters
3763
+ *
3764
+ * @example
3765
+ * ```typescript
3766
+ * const options = await relationService.getOptions(attribute, "tenant-1", {
3767
+ * query: "nike",
3768
+ * page: 1,
3769
+ * pageSize: 20
3770
+ * });
3771
+ * ```
3772
+ */
3773
+ getOptions(attribute: RelationAttribute, tenantId: string, params?: GetRelationOptionsParams): Promise<RelationOptionsResponse>;
3774
+ /**
3775
+ * Resolve record IDs to their display labels
3776
+ * Useful for displaying current values in the UI
3777
+ *
3778
+ * @param ids - Record IDs to resolve
3779
+ * @param tenantId - Tenant ID for multi-tenant isolation
3780
+ *
3781
+ * @example
3782
+ * ```typescript
3783
+ * const resolved = await relationService.resolveIds(["rec-1", "rec-2"], "tenant-1");
3784
+ * // [{ id: "rec-1", label: "Nike Air Max", objectName: "products", ... }]
3785
+ * ```
3786
+ */
3787
+ resolveIds(ids: string[], tenantId: string): Promise<RelationOption[]>;
3788
+ /**
3789
+ * Find a relation attribute by ID
3790
+ */
3791
+ findAttributeById(attributeId: string): Promise<RelationAttribute | null>;
3792
+ }
3793
+
3794
+ /**
3795
+ * Service for managing user profiles
3796
+ * Handles user profile CRUD, auth provider sync, and role management
3797
+ */
3798
+ declare class UserProfileService {
3799
+ private adapter;
3800
+ private tenantId;
3801
+ constructor(adapter: DatabaseAdapter, tenantId: string);
3802
+ /**
3803
+ * Create a new user profile (typically after first auth)
3804
+ *
3805
+ * @param data - User profile creation data
3806
+ * @returns Created user profile
3807
+ *
3808
+ * @example
3809
+ * ```typescript
3810
+ * const service = new UserProfileService(adapter, "tenant-123");
3811
+ *
3812
+ * // After Supabase auth
3813
+ * const profile = await service.createProfile({
3814
+ * tenantId: "tenant-123",
3815
+ * authId: authUser.id,
3816
+ * email: authUser.email,
3817
+ * firstName: authUser.user_metadata.first_name,
3818
+ * lastName: authUser.user_metadata.last_name,
3819
+ * role: "member",
3820
+ * status: "active"
3821
+ * });
3822
+ * ```
3823
+ */
3824
+ createProfile(data: CreateUserProfile): Promise<UserProfile>;
3825
+ /**
3826
+ * Get user profile by ID
3827
+ */
3828
+ getProfile(profileId: string): Promise<UserProfile | null>;
3829
+ /**
3830
+ * Get user profile by ID or throw
3831
+ */
3832
+ getProfileOrThrow(profileId: string): Promise<UserProfile>;
3833
+ /**
3834
+ * Get user profile by auth provider ID
3835
+ *
3836
+ * @param authId - Auth provider user ID (Supabase, Clerk, etc.)
3837
+ * @returns User profile or null
3838
+ */
3839
+ getProfileByAuthId(authId: string): Promise<UserProfile | null>;
3840
+ /**
3841
+ * Get or create user profile (idempotent operation)
3842
+ * Useful for auth callbacks - ensures profile exists
3843
+ *
3844
+ * @param authId - Auth provider user ID
3845
+ * @param data - Profile data to create if doesn't exist
3846
+ * @returns Existing or newly created profile
3847
+ *
3848
+ * @example
3849
+ * ```typescript
3850
+ * // In Supabase auth callback
3851
+ * const profile = await service.getOrCreateProfile(
3852
+ * authUser.id,
3853
+ * {
3854
+ * tenantId: "tenant-123",
3855
+ * authId: authUser.id,
3856
+ * email: authUser.email,
3857
+ * role: "member",
3858
+ * status: "active"
3859
+ * }
3860
+ * );
3861
+ * ```
3862
+ */
3863
+ getOrCreateProfile(authId: string, data: CreateUserProfile): Promise<UserProfile>;
3864
+ /**
3865
+ * Update user profile
3866
+ */
3867
+ updateProfile(profileId: string, data: UpdateUserProfile): Promise<UserProfile>;
3868
+ /**
3869
+ * Delete user profile
3870
+ *
3871
+ * @param profileId - Profile UUID
3872
+ * @param options - Delete options
3873
+ */
3874
+ deleteProfile(profileId: string, options?: {
3875
+ checkAdmin?: boolean;
3876
+ }): Promise<void>;
3877
+ /**
3878
+ * List all user profiles for the tenant
3879
+ */
3880
+ listProfiles(options?: ListOptions): Promise<UserProfile[]>;
3881
+ /**
3882
+ * Update last login timestamp
3883
+ *
3884
+ * @param profileId - Profile UUID
3885
+ *
3886
+ * @example
3887
+ * ```typescript
3888
+ * // After successful auth
3889
+ * await service.updateLastLogin(profile.id);
3890
+ * ```
3891
+ */
3892
+ updateLastLogin(profileId: string): Promise<void>;
3893
+ /**
3894
+ * Change user role
3895
+ *
3896
+ * @param profileId - Profile UUID
3897
+ * @param newRole - New role
3898
+ */
3899
+ changeRole(profileId: string, newRole: string): Promise<UserProfile>;
3900
+ /**
3901
+ * Change user status
3902
+ *
3903
+ * @param profileId - Profile UUID
3904
+ * @param newStatus - New status
3905
+ */
3906
+ changeStatus(profileId: string, newStatus: "active" | "pending" | "inactive" | "suspended"): Promise<UserProfile>;
3907
+ /**
3908
+ * Get user by email
3909
+ */
3910
+ getProfileByEmail(email: string): Promise<UserProfile | null>;
3911
+ /**
3912
+ * Check if user has role
3913
+ */
3914
+ hasRole(profileId: string, role: string): Promise<boolean>;
3915
+ /**
3916
+ * Check if user is admin
3917
+ */
3918
+ isAdmin(profileId: string): Promise<boolean>;
3919
+ }
3920
+
3921
+ /**
3922
+ * Input for creating a custom view
3923
+ */
3924
+ interface CreateViewInput {
3925
+ name: string;
3926
+ label: string;
3927
+ objectName: string;
3928
+ description?: string;
3929
+ icon?: IconName;
3930
+ tabs: Tab[];
3931
+ default?: boolean;
3932
+ metadata?: Record<string, unknown>;
3933
+ }
3934
+ /**
3935
+ * Input for updating a view
3936
+ */
3937
+ interface UpdateViewInput {
3938
+ label?: string;
3939
+ description?: string;
3940
+ icon?: IconName;
3941
+ tabs?: Tab[];
3942
+ default?: boolean;
3943
+ metadata?: Record<string, unknown>;
3944
+ }
3945
+ /**
3946
+ * Service for managing views
3947
+ * Handles fusion of native views (from registry) and custom views (from database)
3948
+ */
3949
+ declare class ViewService {
3950
+ private adapter;
3951
+ private nativeViews;
3952
+ constructor(adapter: DatabaseAdapter, nativeViews: typeof viewRegistry);
3953
+ /**
3954
+ * Get all views for an object (native + custom)
3955
+ *
3956
+ * @param objectName - Object name
3957
+ * @param tenantId - Tenant ID
3958
+ * @returns All views for the object
3959
+ */
3960
+ getViewsForObject(objectName: string, tenantId: string): Promise<ViewDefinition[]>;
3961
+ /**
3962
+ * Get a specific view by name
3963
+ *
3964
+ * @param objectName - Object name
3965
+ * @param viewName - View name
3966
+ * @param tenantId - Tenant ID
3967
+ * @returns View definition or null
3968
+ */
3969
+ getView(objectName: string, viewName: string, tenantId: string): Promise<ViewDefinition | null>;
3970
+ /**
3971
+ * Get the default view for an object
3972
+ *
3973
+ * Priority:
3974
+ * 1. Custom view marked as default
3975
+ * 2. Native view marked as default
3976
+ * 3. First available view
3977
+ *
3978
+ * @param objectName - Object name
3979
+ * @param tenantId - Tenant ID
3980
+ * @returns Default view or null
3981
+ */
3982
+ getDefaultView(objectName: string, tenantId: string): Promise<ViewDefinition | null>;
3983
+ /**
3984
+ * Create a custom view
3985
+ *
3986
+ * @param input - View definition
3987
+ * @param tenantId - Tenant ID
3988
+ * @returns Created view
3989
+ */
3990
+ createView(input: CreateViewInput, tenantId: string): Promise<ViewDefinition>;
3991
+ /**
3992
+ * Update a custom view
3993
+ *
3994
+ * @param viewId - View ID
3995
+ * @param input - Update data
3996
+ * @returns Updated view
3997
+ */
3998
+ updateView(viewId: string, input: UpdateViewInput): Promise<ViewDefinition>;
3999
+ /**
4000
+ * Delete a custom view
4001
+ *
4002
+ * @param viewId - View ID
4003
+ */
4004
+ deleteView(viewId: string): Promise<void>;
4005
+ /**
4006
+ * Set a view as default for its object
4007
+ *
4008
+ * @param viewId - View ID
4009
+ * @param tenantId - Tenant ID
4010
+ * @returns Updated view
4011
+ */
4012
+ setDefaultView(viewId: string, tenantId: string): Promise<ViewDefinition>;
4013
+ /**
4014
+ * Validate view name format (kebab-case)
4015
+ */
4016
+ private validateViewName;
4017
+ /**
4018
+ * Convert database view to ViewDefinition
4019
+ */
4020
+ private convertDBViewToDefinition;
4021
+ }
4022
+
4023
+ /**
4024
+ * Result of view sync operation
4025
+ */
4026
+ interface ViewSyncResult {
4027
+ success: boolean;
4028
+ viewsSynced: number;
4029
+ viewsCreated: number;
4030
+ viewsUpdated: number;
4031
+ viewsDeleted: number;
4032
+ errors: Array<{
4033
+ viewName: string;
4034
+ objectName: string;
4035
+ error: string;
4036
+ }>;
4037
+ }
4038
+ /**
4039
+ * Options for view sync
4040
+ */
4041
+ interface ViewSyncOptions {
4042
+ dryRun?: boolean;
4043
+ verbose?: boolean;
4044
+ tenantId?: string;
4045
+ }
4046
+ /**
4047
+ * Sync native views from registry to database
4048
+ *
4049
+ * This function:
4050
+ * 1. Reads all registered native views from the registry
4051
+ * 2. Upserts them into the database (views table)
4052
+ * 3. Marks them as system=true for protection
4053
+ * 4. Removes views that were deleted from code
4054
+ *
4055
+ * @param adapter - Database adapter implementing DatabaseAdapter interface
4056
+ * @param nativeViewRegistry - Registry containing native views
4057
+ * @param options - Sync options (dryRun, verbose, tenantId)
4058
+ * @returns Sync result with statistics
4059
+ *
4060
+ * @example
4061
+ * ```typescript
4062
+ * import { syncNativeViews, viewRegistry } from "@andyoucreate/schema";
4063
+ * import { drizzleAdapter } from "./db/adapter";
4064
+ *
4065
+ * const result = await syncNativeViews(drizzleAdapter, viewRegistry, {
4066
+ * verbose: true,
4067
+ * tenantId: "default"
4068
+ * });
4069
+ *
4070
+ * if (result.success) {
4071
+ * console.log(`✓ Synced ${result.viewsSynced} views`);
4072
+ * }
4073
+ * ```
4074
+ */
4075
+ declare function syncNativeViews(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry, options?: ViewSyncOptions): Promise<ViewSyncResult>;
4076
+ /**
4077
+ * Verify that all native views are synced to database
4078
+ *
4079
+ * @param adapter - Database adapter
4080
+ * @param nativeViewRegistry - Registry containing native views
4081
+ * @returns true if all views are synced, false otherwise
4082
+ *
4083
+ * @example
4084
+ * ```typescript
4085
+ * const isSynced = await verifyNativeViewsSync(adapter, viewRegistry);
4086
+ * if (!isSynced) {
4087
+ * console.warn("Native views not synced, running sync...");
4088
+ * await syncNativeViews(adapter, viewRegistry);
4089
+ * }
4090
+ * ```
4091
+ */
4092
+ declare function verifyNativeViewsSync(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry): Promise<boolean>;
4093
+ /**
4094
+ * Get sync preview without modifying database
4095
+ *
4096
+ * @param adapter - Database adapter
4097
+ * @param nativeViewRegistry - Registry containing native views
4098
+ * @returns Sync result (dry run)
4099
+ */
4100
+ declare function getViewSyncPreview(adapter: DatabaseAdapter, nativeViewRegistry: typeof viewRegistry): Promise<ViewSyncResult>;
4101
+
4102
+ /**
4103
+ * Result of sync operation
4104
+ */
4105
+ interface SyncResult {
4106
+ success: boolean;
4107
+ objectsSynced: number;
4108
+ attributesSynced: number;
4109
+ objectsCreated: number;
4110
+ objectsUpdated: number;
4111
+ attributesCreated: number;
4112
+ attributesUpdated: number;
4113
+ attributesDeleted: number;
4114
+ errors: Array<{
4115
+ objectName: string;
4116
+ error: string;
4117
+ }>;
4118
+ }
4119
+ /**
4120
+ * Sync options
4121
+ */
4122
+ interface SyncOptions {
4123
+ dryRun?: boolean;
4124
+ verbose?: boolean;
4125
+ tenantId?: string;
4126
+ }
4127
+ /**
4128
+ * Sync native objects from registry to database
4129
+ *
4130
+ * This function:
4131
+ * 1. Reads all registered native objects from the registry
4132
+ * 2. Upserts them into the database (objects + attributes tables)
4133
+ * 3. Marks them as system=true for protection
4134
+ * 4. Removes attributes that were deleted from code
4135
+ *
4136
+ * @param adapter - Database adapter implementing DatabaseAdapter interface
4137
+ * @param nativeRegistry - Registry containing native objects
4138
+ * @param options - Sync options (dryRun, verbose, tenantId)
4139
+ * @returns Sync result with statistics
4140
+ *
4141
+ * @example
4142
+ * ```typescript
4143
+ * import { syncNativeObjects } from "@andyoucreate/schema/runtime";
4144
+ * import { registry } from "./objects/native";
4145
+ * import { drizzleAdapter } from "./db/adapter";
4146
+ *
4147
+ * const result = await syncNativeObjects(drizzleAdapter, registry, {
4148
+ * verbose: true,
4149
+ * tenantId: "default"
4150
+ * });
4151
+ *
4152
+ * if (result.success) {
4153
+ * console.log(`✓ Synced ${result.objectsSynced} objects`);
4154
+ * } else {
4155
+ * console.error("Sync errors:", result.errors);
4156
+ * }
4157
+ * ```
4158
+ */
4159
+ declare function syncNativeObjects(adapter: DatabaseAdapter, nativeRegistry: typeof registry, options?: SyncOptions): Promise<SyncResult>;
4160
+ /**
4161
+ * Verify that all native objects are synced to database
4162
+ *
4163
+ * @param adapter - Database adapter
4164
+ * @param nativeRegistry - Registry containing native objects
4165
+ * @returns true if all objects are synced, false otherwise
4166
+ *
4167
+ * @example
4168
+ * ```typescript
4169
+ * const isSynced = await verifyNativeObjectsSync(adapter, registry);
4170
+ * if (!isSynced) {
4171
+ * console.warn("Native objects not synced, running sync...");
4172
+ * await syncNativeObjects(adapter, registry);
4173
+ * }
4174
+ * ```
4175
+ */
4176
+ declare function verifyNativeObjectsSync(adapter: DatabaseAdapter, nativeRegistry: typeof registry): Promise<boolean>;
4177
+ /**
4178
+ * Get sync statistics without modifying database
4179
+ *
4180
+ * @param adapter - Database adapter
4181
+ * @param nativeRegistry - Registry containing native objects
4182
+ * @returns Sync result (dry run)
4183
+ */
4184
+ declare function getSyncPreview(adapter: DatabaseAdapter, nativeRegistry: typeof registry): Promise<SyncResult>;
4185
+ /**
4186
+ * Result of full sync operation (objects + views)
4187
+ */
4188
+ interface FullSyncResult {
4189
+ success: boolean;
4190
+ objects: SyncResult;
4191
+ views: ViewSyncResult;
4192
+ }
4193
+ /**
4194
+ * Options for full sync
4195
+ */
4196
+ interface FullSyncOptions extends SyncOptions, ViewSyncOptions {
4197
+ }
4198
+ /**
4199
+ * Sync all native objects and views from registries to database
4200
+ *
4201
+ * This is a convenience function that:
4202
+ * 1. Syncs native objects first (views may depend on objects)
4203
+ * 2. Syncs native views
4204
+ *
4205
+ * @param adapter - Database adapter
4206
+ * @param objectRegistry - Registry containing native objects
4207
+ * @param nativeViewRegistry - Registry containing native views
4208
+ * @param options - Sync options
4209
+ * @returns Combined sync result
4210
+ *
4211
+ * @example
4212
+ * ```typescript
4213
+ * import { syncAll, registry, viewRegistry } from "@andyoucreate/schema";
4214
+ * import { adapter } from "./db";
4215
+ *
4216
+ * const result = await syncAll(adapter, registry, viewRegistry, {
4217
+ * verbose: true,
4218
+ * tenantId: "default"
4219
+ * });
4220
+ *
4221
+ * if (result.success) {
4222
+ * console.log(`✓ Synced ${result.objects.objectsSynced} objects, ${result.views.viewsSynced} views`);
4223
+ * }
4224
+ * ```
4225
+ */
4226
+ declare function syncAll(adapter: DatabaseAdapter, objectRegistry: typeof registry, nativeViewRegistry: typeof viewRegistry, options?: FullSyncOptions): Promise<FullSyncResult>;
4227
+
4228
+ /**
4229
+ * Default fallback value when expression resolves to empty string
4230
+ */
4231
+ declare const DEFAULT_LABEL_FALLBACK = "(Untitled)";
4232
+ /**
4233
+ * Render a label expression template with values
4234
+ *
4235
+ * Supports:
4236
+ * - Variable interpolation: `{{ fieldName }}`
4237
+ * - Dot notation: `{{ user.firstName }}`
4238
+ * - Pipes: `{{ name | UPPER }}`, `{{ name | capitalize | trim }}`
4239
+ *
4240
+ * @param template - The label expression template (e.g., "{{ firstName }} {{ lastName }}")
4241
+ * @param values - Record values to interpolate
4242
+ * @param fallback - Fallback value if result is empty (default: "(Untitled)")
4243
+ * @returns The rendered label string
4244
+ *
4245
+ * @example
4246
+ * ```typescript
4247
+ * const label = renderLabelExpression(
4248
+ * "{{ firstName }} {{ lastName | UPPER }}",
4249
+ * { firstName: "John", lastName: "Doe" }
4250
+ * );
4251
+ * // → "John DOE"
4252
+ *
4253
+ * // With missing values
4254
+ * const label = renderLabelExpression(
4255
+ * "{{ name }}",
4256
+ * { }
4257
+ * );
4258
+ * // → "(Untitled)"
4259
+ * ```
4260
+ */
4261
+ declare function renderLabelExpression(template: string, values: Record<string, unknown>, fallback?: string): string;
4262
+ /**
4263
+ * Check if a string is a valid label expression template
4264
+ * A valid template contains at least one {{ variable }} block with a non-empty variable
4265
+ */
4266
+ declare function isLabelExpression(value: string): boolean;
4267
+ /**
4268
+ * Extract attribute names referenced in a label expression
4269
+ * Useful for validation or dependency tracking
4270
+ *
4271
+ * @example
4272
+ * extractAttributeNames("{{ firstName }} {{ lastName | UPPER }}")
4273
+ * // → ["firstName", "lastName"]
4274
+ */
4275
+ declare function extractAttributeNames(template: string): string[];
4276
+
4277
+ 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, relationConfigSchema 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 TabType as aA, type FormTab as aB, type TableTab as aC, type CustomTab as aD, isFormTab as aE, isTableTab as aF, isCustomTab as aG, type Uuid as aH, type TenantId as aI, generateId as aJ, generatePrefixedId as aK, registry as aL, viewRegistry as aM, textConfigSchema as aN, textareaConfigSchema as aO, numberConfigSchema as aP, checkboxConfigSchema as aQ, dateConfigSchema as aR, phoneConfigSchema as aS, currencyConfigSchema as aT, statusConfigSchema as aU, locationConfigSchema as aV, timestampConfigSchema as aW, selectConfigSchema as aX, multiselectConfigSchema as aY, fileConfigSchema as aZ, userConfigSchema 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 UserRole as av, type UserStatus as aw, type UserProfile as ax, type CreateUserProfile as ay, type UpdateUserProfile as az, type TextAreaAttribute as b, RelationService as b$, ratingConfigSchema as b0, attributeConfigSchemas as b1, getAttributeConfigSchema as b2, validateAttributeConfig as b3, parseAttributeConfig as b4, safeParseAttributeConfig as b5, createTextValidator as b6, createNumberValidator as b7, createCheckboxValidator as b8, createDateValidator as b9, type AttributeChange as bA, type HookContext as bB, type HookDefinition as bC, type HookHandler as bD, type HookType as bE, NoopHookRegistry as bF, type HookRegistry as bG, createMockAdapter as bH, type ObjectsRepository as bI, type AttributesRepository as bJ, type UserProfilesRepository as bK, type FilesRepository as bL, type ObjectRecordsRepository as bM, type ViewsRepository as bN, FileService as bO, GeocodingService as bP, GlobalSearchService as bQ, type CreateCustomObjectInput as bR, type AddAttributeInput as bS, ObjectSchemaService as bT, type RecordServiceOptions as bU, RecordService as bV, type RelationValidationResult as bW, type RelationValidationError as bX, type RelationOption as bY, type RelationOptionsResponse as bZ, type GetRelationOptionsParams as b_, createPhoneValidator as ba, createCurrencyValidator as bb, createStatusValidator as bc, createSelectValidator as bd, createMultiselectValidator as be, createLocationValidator as bf, createTimestampValidator as bg, createFileValidator as bh, createUserValidator as bi, createSingleRelationValidator as bj, createMultiRelationValidator as bk, createRelationValidator as bl, createRatingValidator as bm, createAttributeValidator as bn, createObjectValidator as bo, type ValidationResult as bp, validateAttribute as bq, validateObject as br, validateObjectOrThrow as bs, createDraftValidator as bt, validateDraft as bu, validateDraftOrThrow as bv, getMissingRequiredAttributes as bw, isRecordComplete as bx, computeRecordStatus as by, type DatabaseAdapter as bz, type CheckboxAttribute as c, UserProfileService as c0, type CreateViewInput as c1, type UpdateViewInput as c2, ViewService as c3, type SyncResult as c4, type SyncOptions as c5, syncNativeObjects as c6, verifyNativeObjectsSync as c7, getSyncPreview as c8, type FullSyncResult as c9, type ViewSyncOptions as cA, syncNativeViews as cB, verifyNativeViewsSync as cC, getViewSyncPreview as cD, type FullSyncOptions as ca, syncAll as cb, DEFAULT_LABEL_FALLBACK as cc, renderLabelExpression as cd, isLabelExpression as ce, extractAttributeNames as cf, type DBObject as cg, type CreateDBObject as ch, type UpdateDBObject as ci, type UpsertDBObject as cj, type DBAttribute as ck, type CreateDBAttribute as cl, type UpdateDBAttribute as cm, type UpsertDBAttribute as cn, type CreateObjectRecord as co, type ListOptions as cp, type SearchOptions as cq, type GlobalSearchOptions as cr, type GlobalSearchResultItem as cs, type FileListOptions as ct, type DBView as cu, type CreateDBView as cv, type UpdateDBView as cw, type UpsertDBView as cx, type OperationResult as cy, type ViewSyncResult 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 };