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