@stndrds/schema 1.0.0-alpha.294 → 1.0.0-alpha.69

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 (161) hide show
  1. package/dist/chunk-36UBIXJN.js +82 -0
  2. package/dist/chunk-3RG5ZIWI.js +10 -0
  3. package/dist/chunk-IXHWBBIY.mjs +721 -0
  4. package/dist/chunk-KG75T7MA.mjs +18664 -0
  5. package/dist/chunk-NEVERCM3.js +41 -0
  6. package/dist/chunk-V2RPPE2Y.mjs +41 -0
  7. package/dist/chunk-V32FQLWX.js +721 -0
  8. package/dist/chunk-V5QXU2OK.mjs +82 -0
  9. package/dist/chunk-XGFBT4K2.js +18664 -0
  10. package/dist/chunk-Y6FXYEAI.mjs +10 -0
  11. package/dist/default-roles-42X3TJI5.mjs +21 -0
  12. package/dist/default-roles-C3FYDYMN.js +21 -0
  13. package/dist/index.d.mts +3392 -10868
  14. package/dist/index.d.ts +3392 -10868
  15. package/dist/index.js +1705 -10256
  16. package/dist/index.mjs +1735 -9398
  17. package/dist/runtime-B0G6eBXO.d.ts +12810 -0
  18. package/dist/runtime-fj4EKCWH.d.mts +12810 -0
  19. package/dist/runtime.d.mts +6 -0
  20. package/dist/runtime.d.ts +6 -0
  21. package/dist/runtime.js +323 -0
  22. package/dist/runtime.mjs +323 -0
  23. package/dist/utils.d.mts +55 -35
  24. package/dist/utils.d.ts +55 -35
  25. package/dist/utils.js +19 -31
  26. package/dist/utils.mjs +19 -2
  27. package/dist/validation/validators.d.mts +4 -0
  28. package/dist/validation/validators.d.ts +4 -0
  29. package/dist/validation/validators.js +121 -0
  30. package/dist/validation/validators.mjs +121 -0
  31. package/dist/validators-B6L_hVBw.d.ts +1564 -0
  32. package/dist/validators-CgiGGhyH.d.mts +1564 -0
  33. package/package.json +16 -106
  34. package/dist/all-CDJSpI46.d.ts +0 -978
  35. package/dist/all-Cru_CaSY.d.mts +0 -978
  36. package/dist/attributes-CNYwg_Nr.d.ts +0 -584
  37. package/dist/attributes-CWPLbp7c.d.mts +0 -584
  38. package/dist/capabilities.d.mts +0 -146
  39. package/dist/capabilities.d.ts +0 -146
  40. package/dist/capabilities.js +0 -77
  41. package/dist/capabilities.mjs +0 -70
  42. package/dist/chunk-2WWGHULM.mjs +0 -226
  43. package/dist/chunk-4KMUATDG.js +0 -609
  44. package/dist/chunk-5WATIVCA.js +0 -10
  45. package/dist/chunk-ACKMC6FL.js +0 -17
  46. package/dist/chunk-AYVHMVKQ.mjs +0 -15
  47. package/dist/chunk-CLZORRMS.mjs +0 -570
  48. package/dist/chunk-DVXGSTWJ.js +0 -81
  49. package/dist/chunk-E6JUYGJX.js +0 -22
  50. package/dist/chunk-EEH4XQ7W.js +0 -61
  51. package/dist/chunk-EW5XR2X3.js +0 -12
  52. package/dist/chunk-GO6LQADH.mjs +0 -57
  53. package/dist/chunk-HRQEZUAA.mjs +0 -29
  54. package/dist/chunk-HTSTPTNZ.js +0 -10
  55. package/dist/chunk-HURC6CW3.js +0 -241
  56. package/dist/chunk-JZNR4HKQ.mjs +0 -1432
  57. package/dist/chunk-KAWYU7TE.js +0 -657
  58. package/dist/chunk-KNGWHQLR.js +0 -16
  59. package/dist/chunk-LV3FEUKU.mjs +0 -14
  60. package/dist/chunk-NS63SPNN.mjs +0 -8
  61. package/dist/chunk-O73ROMWQ.mjs +0 -85
  62. package/dist/chunk-OSSGN43B.mjs +0 -8
  63. package/dist/chunk-Q44QKLN4.mjs +0 -43
  64. package/dist/chunk-Q4SZAMJT.js +0 -72
  65. package/dist/chunk-QT35SI3K.mjs +0 -641
  66. package/dist/chunk-QVLQPW3O.mjs +0 -10
  67. package/dist/chunk-QWKLQRBX.js +0 -35
  68. package/dist/chunk-R2DAEDRF.mjs +0 -74
  69. package/dist/chunk-R5LAJCBU.mjs +0 -67
  70. package/dist/chunk-SI34M4IC.js +0 -45
  71. package/dist/chunk-T5PM73EF.js +0 -1504
  72. package/dist/chunk-UANQJ2GH.mjs +0 -25
  73. package/dist/chunk-UXAHLSWC.mjs +0 -8
  74. package/dist/chunk-V2UA2D4E.js +0 -10
  75. package/dist/chunk-YIP5FJ5H.js +0 -27
  76. package/dist/chunk-YKWSHBT5.js +0 -32
  77. package/dist/chunk-YUFTHPOE.mjs +0 -20
  78. package/dist/chunk-ZDQ5AP26.mjs +0 -31
  79. package/dist/chunk-ZPFOKBIN.js +0 -89
  80. package/dist/exceptions.d.mts +0 -511
  81. package/dist/exceptions.d.ts +0 -511
  82. package/dist/exceptions.js +0 -158
  83. package/dist/exceptions.mjs +0 -1
  84. package/dist/helpers-CXkVwpsl.d.ts +0 -76
  85. package/dist/helpers-Dul_r9rJ.d.mts +0 -76
  86. package/dist/index-BdVnHL3F.d.mts +0 -853
  87. package/dist/index-CFhPHQaI.d.ts +0 -853
  88. package/dist/migrations-DaFneOfx.d.ts +0 -39
  89. package/dist/migrations-fRvadl6i.d.mts +0 -39
  90. package/dist/objects-CDwMSnqv.d.mts +0 -250
  91. package/dist/objects-DJv6WrDE.d.ts +0 -250
  92. package/dist/types-CVYiFc69.d.mts +0 -38
  93. package/dist/types-NGEww_ln.d.ts +0 -38
  94. package/dist/validation/all.d.mts +0 -11
  95. package/dist/validation/all.d.ts +0 -11
  96. package/dist/validation/all.js +0 -131
  97. package/dist/validation/all.mjs +0 -18
  98. package/dist/validation/complex/currency.d.mts +0 -15
  99. package/dist/validation/complex/currency.d.ts +0 -15
  100. package/dist/validation/complex/currency.js +0 -11
  101. package/dist/validation/complex/currency.mjs +0 -2
  102. package/dist/validation/complex/location.d.mts +0 -22
  103. package/dist/validation/complex/location.d.ts +0 -22
  104. package/dist/validation/complex/location.js +0 -11
  105. package/dist/validation/complex/location.mjs +0 -2
  106. package/dist/validation/complex/phone.d.mts +0 -22
  107. package/dist/validation/complex/phone.d.ts +0 -22
  108. package/dist/validation/complex/phone.js +0 -11
  109. package/dist/validation/complex/phone.mjs +0 -2
  110. package/dist/validation/complex/relation.d.mts +0 -25
  111. package/dist/validation/complex/relation.d.ts +0 -25
  112. package/dist/validation/complex/relation.js +0 -19
  113. package/dist/validation/complex/relation.mjs +0 -2
  114. package/dist/validation/complex/richtext.d.mts +0 -13
  115. package/dist/validation/complex/richtext.d.ts +0 -13
  116. package/dist/validation/complex/richtext.js +0 -11
  117. package/dist/validation/complex/richtext.mjs +0 -2
  118. package/dist/validation/complex/select.d.mts +0 -20
  119. package/dist/validation/complex/select.d.ts +0 -20
  120. package/dist/validation/complex/select.js +0 -19
  121. package/dist/validation/complex/select.mjs +0 -2
  122. package/dist/validation/complex/user.d.mts +0 -13
  123. package/dist/validation/complex/user.d.ts +0 -13
  124. package/dist/validation/complex/user.js +0 -11
  125. package/dist/validation/complex/user.mjs +0 -2
  126. package/dist/validation/computed/formula.d.mts +0 -14
  127. package/dist/validation/computed/formula.d.ts +0 -14
  128. package/dist/validation/computed/formula.js +0 -11
  129. package/dist/validation/computed/formula.mjs +0 -2
  130. package/dist/validation/computed/rollup.d.mts +0 -14
  131. package/dist/validation/computed/rollup.d.ts +0 -14
  132. package/dist/validation/computed/rollup.js +0 -11
  133. package/dist/validation/computed/rollup.mjs +0 -2
  134. package/dist/validation/config/index.d.mts +0 -7
  135. package/dist/validation/config/index.d.ts +0 -7
  136. package/dist/validation/config/index.js +0 -52
  137. package/dist/validation/config/index.mjs +0 -7
  138. package/dist/validation/core/index.d.mts +0 -19
  139. package/dist/validation/core/index.d.ts +0 -19
  140. package/dist/validation/core/index.js +0 -14
  141. package/dist/validation/core/index.mjs +0 -1
  142. package/dist/validation/object/index.d.mts +0 -32
  143. package/dist/validation/object/index.d.ts +0 -32
  144. package/dist/validation/object/index.js +0 -69
  145. package/dist/validation/object/index.mjs +0 -16
  146. package/dist/validation/primitives/checkbox.d.mts +0 -12
  147. package/dist/validation/primitives/checkbox.d.ts +0 -12
  148. package/dist/validation/primitives/checkbox.js +0 -11
  149. package/dist/validation/primitives/checkbox.mjs +0 -2
  150. package/dist/validation/primitives/date.d.mts +0 -25
  151. package/dist/validation/primitives/date.d.ts +0 -25
  152. package/dist/validation/primitives/date.js +0 -11
  153. package/dist/validation/primitives/date.mjs +0 -2
  154. package/dist/validation/primitives/number.d.mts +0 -12
  155. package/dist/validation/primitives/number.d.ts +0 -12
  156. package/dist/validation/primitives/number.js +0 -11
  157. package/dist/validation/primitives/number.mjs +0 -2
  158. package/dist/validation/primitives/text.d.mts +0 -12
  159. package/dist/validation/primitives/text.d.ts +0 -12
  160. package/dist/validation/primitives/text.js +0 -11
  161. package/dist/validation/primitives/text.mjs +0 -2
@@ -0,0 +1,1564 @@
1
+ import { z } from 'zod';
2
+ import { IconName, CountryIso3, CurrencyCode, ColorId, MimeType } from '@stndrds/constants';
3
+ import { Uuid } from './utils.js';
4
+
5
+ /**
6
+ * Feature flag levels (resolution priority: user > tenant > global).
7
+ *
8
+ * - `global`: Applies to all tenants and users
9
+ * - `tenant`: Applies to a specific tenant
10
+ * - `user`: Applies to a specific user within a tenant
11
+ */
12
+ type FlagLevel = "global" | "tenant" | "user";
13
+ /**
14
+ * Flag value types supported by the system.
15
+ */
16
+ type FlagValueType = "boolean" | "string" | "number" | "json";
17
+ /**
18
+ * Definition of a feature flag.
19
+ * Created using the flag builders (booleanFlag, stringFlag, etc.)
20
+ */
21
+ interface FeatureFlagDefinition<T = unknown> {
22
+ /** Unique identifier for the flag (kebab-case) */
23
+ name: string;
24
+ /** Human-readable label */
25
+ label: string;
26
+ /** Optional description */
27
+ description?: string;
28
+ /** Type of the flag value */
29
+ valueType: FlagValueType;
30
+ /** Default value when no override exists */
31
+ defaultValue: T;
32
+ /** Levels at which this flag can be overridden */
33
+ allowedLevels: FlagLevel[];
34
+ /** Grouping category for UI */
35
+ category?: string;
36
+ /** System flag - cannot be modified via API */
37
+ system?: boolean;
38
+ }
39
+ /**
40
+ * Stored override for a feature flag.
41
+ * Represents a row in the feature_flag_overrides table.
42
+ */
43
+ interface FlagOverride<T = unknown> {
44
+ /** Name of the flag being overridden */
45
+ flagName: string;
46
+ /** Level of the override */
47
+ level: FlagLevel;
48
+ /** Target ID (tenantId for tenant-level, userId for user-level) */
49
+ targetId?: string;
50
+ /** Override value */
51
+ value: T;
52
+ /** Optional expiration date */
53
+ expiresAt?: Date;
54
+ /** Who created this override */
55
+ createdBy?: string;
56
+ /** When the override was created */
57
+ createdAt: Date;
58
+ /** When the override was last updated */
59
+ updatedAt: Date;
60
+ }
61
+ /**
62
+ * Resolved flag value with source information.
63
+ * Result of flag resolution including where the value came from.
64
+ */
65
+ interface ResolvedFlag<T = unknown> {
66
+ /** Flag name */
67
+ name: string;
68
+ /** Resolved value */
69
+ value: T;
70
+ /** Where the value came from */
71
+ source: FlagLevel | "default";
72
+ /** ID of the source (tenantId or userId) if not default */
73
+ sourceId?: string;
74
+ }
75
+ /**
76
+ * Feature gate configuration for conditional attribute visibility.
77
+ * Used with the `.featureGate()` builder method.
78
+ */
79
+ interface FeatureGate {
80
+ /** Name of the flag to check */
81
+ flag: string;
82
+ /**
83
+ * Expected value for the gate to pass.
84
+ * For boolean flags, defaults to `true`.
85
+ * For other types, compares with strict equality.
86
+ */
87
+ expectedValue?: unknown;
88
+ /**
89
+ * Behavior when the gate fails.
90
+ * - `hide`: Attribute is completely hidden (default)
91
+ * - `show`: Attribute is shown regardless (no gating)
92
+ * - `disable`: Attribute is visible but read-only
93
+ */
94
+ fallback?: "hide" | "show" | "disable";
95
+ }
96
+ /**
97
+ * Repository interface for feature flag overrides storage.
98
+ * Added to DatabaseAdapter as an optional repository.
99
+ *
100
+ * If not provided, only static defaults from module config are used.
101
+ */
102
+ interface FeatureFlagsRepository {
103
+ /**
104
+ * Get all overrides matching the criteria.
105
+ * Returns overrides from the database (global, tenant, or user level).
106
+ */
107
+ getOverrides(options: {
108
+ /** Filter by level */
109
+ level?: FlagLevel;
110
+ /** Filter by target ID (tenantId or userId) */
111
+ targetId?: string;
112
+ }): Promise<FlagOverride[]>;
113
+ /**
114
+ * Create or update an override.
115
+ * Uses upsert semantics based on (flagName, level, targetId).
116
+ */
117
+ setOverride(override: Omit<FlagOverride, "createdAt" | "updatedAt">): Promise<FlagOverride>;
118
+ /**
119
+ * Delete an override.
120
+ */
121
+ deleteOverride(flagName: string, level: FlagLevel, targetId?: string): Promise<void>;
122
+ }
123
+ /**
124
+ * Static flag default value for module configuration.
125
+ */
126
+ interface StaticFlagDefault {
127
+ /** Flag name */
128
+ name: string;
129
+ /** Default value */
130
+ value: unknown;
131
+ }
132
+ /**
133
+ * Feature flags configuration for SchemaModule.
134
+ */
135
+ interface FeatureFlagsConfig {
136
+ /**
137
+ * Static default values for flags.
138
+ * These are always applied and used when no database override exists.
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * featureFlags: {
143
+ * defaults: [
144
+ * { name: "architect-mode", value: false },
145
+ * { name: "ai-chat", value: false },
146
+ * { name: "tier", value: "free" },
147
+ * ],
148
+ * }
149
+ * ```
150
+ */
151
+ defaults?: StaticFlagDefault[];
152
+ }
153
+
154
+ /**
155
+ * Allowed attribute types in .qualifyWith()
156
+ *
157
+ * IMPORTANT: Complex types (formula, rollup, relation, file, user, document, richtext)
158
+ * are NOT supported to avoid duplicating backend behavior.
159
+ */
160
+ type PropertyType = "text" | "textarea" | "number" | "checkbox" | "date" | "phone" | "currency" | "status" | "select" | "multiselect" | "rating" | "location";
161
+ /**
162
+ * Forbidden property types that would require complex backend duplication
163
+ */
164
+ declare const FORBIDDEN_PROPERTY_TYPES: readonly ["formula", "rollup", "relation", "file", "user", "document", "richtext"];
165
+ type ForbiddenPropertyType = (typeof FORBIDDEN_PROPERTY_TYPES)[number];
166
+ /**
167
+ * Union of attribute types allowed as qualified relation properties.
168
+ *
169
+ * These are the same Attribute types used for object attributes,
170
+ * restricted to simple types that don't require complex backend duplication.
171
+ */
172
+ type PropertyAttribute = TextAttribute | TextAreaAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | SelectAttribute | MultiselectAttribute | RatingAttribute | LocationAttribute;
173
+ /**
174
+ * Schema defining properties for a qualified relation.
175
+ *
176
+ * Uses the same Attribute types as object attributes, enabling DRY builders:
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * relation({ name: "companies", label: "Companies" })
181
+ * .to("companies").many()
182
+ * .qualifyWith(
183
+ * select({ name: "role", label: "Role" }).options([...]).required(),
184
+ * number({ name: "shares", label: "Shares" }).min(0),
185
+ * )
186
+ * ```
187
+ */
188
+ interface PropertySchema {
189
+ definitions: PropertyAttribute[];
190
+ }
191
+
192
+ type AttributeType = "text" | "textarea" | "richtext" | "number" | "checkbox" | "date" | "phone" | "currency" | "status" | "location" | "select" | "multiselect" | "file" | "user" | "relation" | "rating" | "formula" | "rollup" | "document";
193
+ /**
194
+ * Status group categorization
195
+ */
196
+ type StatusGroup = "idle" | "in_progress" | "finished";
197
+ /**
198
+ * Unified option type for select-like fields
199
+ */
200
+ interface Option {
201
+ id: string;
202
+ label: string;
203
+ value: string;
204
+ color?: ColorId;
205
+ icon?: IconName;
206
+ description?: string;
207
+ group?: StatusGroup;
208
+ }
209
+ /**
210
+ * Attribute grouping for UI organization
211
+ */
212
+ interface AttributeGroup {
213
+ id: string;
214
+ label: string;
215
+ description?: string;
216
+ attributeIds: string[];
217
+ collapsible?: boolean;
218
+ collapsed?: boolean;
219
+ order?: number;
220
+ }
221
+ interface BaseAttribute<DefaultValueType = unknown> {
222
+ id: Uuid;
223
+ name: string;
224
+ label: string;
225
+ type: AttributeType;
226
+ required: boolean;
227
+ disabled?: boolean;
228
+ placeholder?: string;
229
+ description?: string;
230
+ defaultValue?: DefaultValueType;
231
+ icon?: IconName;
232
+ order?: number;
233
+ hidden?: boolean;
234
+ archived?: boolean;
235
+ deprecated?: boolean;
236
+ system?: boolean;
237
+ /**
238
+ * Feature gate to conditionally show/hide/disable this attribute.
239
+ * When the flag condition is not met, the attribute behavior depends on `fallback`:
240
+ * - "hide" (default): Attribute is completely hidden
241
+ * - "disable": Attribute is visible but read-only
242
+ * - "show": No gating (useful for overriding parent settings)
243
+ */
244
+ featureGate?: FeatureGate;
245
+ metadata?: Record<string, unknown>;
246
+ }
247
+ interface TextAttribute extends BaseAttribute<string> {
248
+ type: "text";
249
+ minLength?: number;
250
+ maxLength?: number;
251
+ pattern?: string;
252
+ }
253
+ type NumberUnit = "integer" | "decimal" | "percentage";
254
+ interface NumberAttribute extends BaseAttribute<number> {
255
+ type: "number";
256
+ min?: number;
257
+ max?: number;
258
+ unit?: NumberUnit;
259
+ decimals?: number;
260
+ }
261
+ interface CheckboxAttribute extends BaseAttribute<boolean> {
262
+ type: "checkbox";
263
+ }
264
+ type DateFormat = "short" | "long" | "full" | "relative";
265
+ type DateValue = string | "today";
266
+ interface DateAttribute extends BaseAttribute<string> {
267
+ type: "date";
268
+ dateFormat?: DateFormat;
269
+ minDate?: DateValue;
270
+ maxDate?: DateValue;
271
+ }
272
+ interface Phone {
273
+ countryCode: CountryIso3;
274
+ phoneNumber: string;
275
+ }
276
+ interface PhoneAttribute extends BaseAttribute<Phone> {
277
+ type: "phone";
278
+ defaultCountryCode?: CountryIso3;
279
+ }
280
+ interface Currency {
281
+ code: CurrencyCode;
282
+ value: number;
283
+ }
284
+ interface CurrencyAttribute extends BaseAttribute<Currency> {
285
+ type: "currency";
286
+ defaultCurrency?: CurrencyCode;
287
+ allowedCurrencies?: CurrencyCode[];
288
+ }
289
+ /**
290
+ * StatusAttribute - For workflow states with semantic grouping (idle/in_progress/finished)
291
+ * Use this for: Task status, Order status, Project phases, Process states
292
+ * Use SelectAttribute for: Categories, Types, simple choices without workflow
293
+ */
294
+ interface StatusAttribute extends BaseAttribute<string> {
295
+ type: "status";
296
+ options: Option[];
297
+ }
298
+ interface Location {
299
+ address?: string;
300
+ address2?: string;
301
+ city?: string;
302
+ state?: string;
303
+ postalCode?: string;
304
+ country?: CountryIso3;
305
+ latitude?: number;
306
+ longitude?: number;
307
+ }
308
+ type LocationGranularity = "full" | "address" | "city" | "state" | "country" | "coordinates";
309
+ interface LocationAttribute extends BaseAttribute<Location> {
310
+ type: "location";
311
+ granularity: LocationGranularity;
312
+ enableAutocomplete?: boolean;
313
+ enableMap?: boolean;
314
+ defaultCountry?: CountryIso3;
315
+ allowedCountries?: CountryIso3[];
316
+ displayFormat?: "single_line" | "multi_line" | "compact";
317
+ }
318
+ /**
319
+ * SelectAttribute - For simple single-choice selection
320
+ * Use this for: Categories, Document types, Departments, Priorities
321
+ * Options can be grouped (e.g., countries by continent) but no workflow logic
322
+ */
323
+ interface SelectAttribute extends BaseAttribute<string> {
324
+ type: "select";
325
+ options: Option[];
326
+ }
327
+ interface MultiselectAttribute extends BaseAttribute<string[]> {
328
+ type: "multiselect";
329
+ options: Option[];
330
+ }
331
+ interface FileAttribute extends BaseAttribute<string> {
332
+ type: "file";
333
+ maxFiles?: number;
334
+ maxSize?: number;
335
+ allowedTypes?: MimeType[] | readonly MimeType[];
336
+ multiple?: boolean;
337
+ }
338
+ interface UserAttribute extends BaseAttribute<string> {
339
+ type: "user";
340
+ allowedRoles?: string[];
341
+ multiple?: boolean;
342
+ }
343
+ /**
344
+ * Wildcard marker for universal relations (can link to any object)
345
+ * Use with `.toAny()` builder method
346
+ */
347
+ declare const RELATION_TARGET_ANY: "*";
348
+ /**
349
+ * Configuration for bilateral synchronization (bidirectional relations)
350
+ */
351
+ interface BilateralConfig {
352
+ /** Target object containing the inverse attribute */
353
+ object: string;
354
+ /** Name of the inverse attribute */
355
+ attribute: string;
356
+ /** Optional cardinality override (inferred by default) */
357
+ cardinality?: "one" | "many";
358
+ /** When true, this side owns the storage direction for qualified properties.
359
+ * Set to false on the inverse side (enriched at read time). */
360
+ storageOwner?: boolean;
361
+ }
362
+ /**
363
+ * Target object for a relation - defines which objects can be linked
364
+ */
365
+ interface RelationTarget {
366
+ /** Object name (e.g., "companies", "contacts") or "*" for any object */
367
+ object: string;
368
+ /**
369
+ * Display template for the label using mustache-like syntax
370
+ * @example "{name}" or "{firstName} {lastName} — {email}"
371
+ */
372
+ displayTemplate?: string;
373
+ /**
374
+ * Optional filter to restrict available records
375
+ * @example { status: "active" }
376
+ */
377
+ filter?: Record<string, unknown>;
378
+ }
379
+ /**
380
+ * Base properties shared by both single and multi relation attributes
381
+ *
382
+ * Note: Deletion behavior is always "restrict" - if a record is referenced
383
+ * by other records, it cannot be deleted until those references are removed.
384
+ * This is enforced by RecordService.deleteRecord() which throws
385
+ * RecordReferencedError when attempting to delete a referenced record.
386
+ */
387
+ interface RelationAttributeBase extends Omit<BaseAttribute<unknown>, "defaultValue"> {
388
+ type: "relation";
389
+ /** Target objects that can be linked */
390
+ targets: RelationTarget[];
391
+ /** Optional properties schema for qualified relations */
392
+ properties?: PropertySchema;
393
+ /** Configuration for bilateral synchronization (opt-in) */
394
+ bilateral?: BilateralConfig;
395
+ }
396
+ /**
397
+ * Single relation attribute (one-to-one or many-to-one)
398
+ * Stores a single record ID or null
399
+ */
400
+ interface SingleRelationAttribute extends RelationAttributeBase {
401
+ cardinality: "one";
402
+ defaultValue?: string | null;
403
+ }
404
+ /**
405
+ * Multi relation attribute (one-to-many or many-to-many)
406
+ * Stores an array of record IDs
407
+ */
408
+ interface MultiRelationAttribute extends RelationAttributeBase {
409
+ cardinality: "many";
410
+ defaultValue?: string[];
411
+ /** Minimum number of relations required */
412
+ minItems?: number;
413
+ /** Maximum number of relations allowed */
414
+ maxItems?: number;
415
+ }
416
+ /**
417
+ * RelationAttribute links to other objects/records
418
+ * Discriminated union by cardinality for type-safe value handling
419
+ *
420
+ * @example Single relation (many-to-one)
421
+ * ```typescript
422
+ * relation({ name: "company", label: "Company" })
423
+ * .to("companies")
424
+ * .required()
425
+ * // → Value: "rec-uuid-123" | null
426
+ * ```
427
+ *
428
+ * @example Multi relation (many-to-many)
429
+ * ```typescript
430
+ * relation({ name: "contacts", label: "Contacts" })
431
+ * .to("contacts", { displayTemplate: "{firstName} {lastName}" })
432
+ * .many()
433
+ * .maxItems(5)
434
+ * // → Value: ["rec-1", "rec-2", ...]
435
+ * ```
436
+ *
437
+ * @example Polymorphic relation (multiple target objects)
438
+ * ```typescript
439
+ * relation({ name: "linked", label: "Linked Items" })
440
+ * .to("companies")
441
+ * .to("contacts")
442
+ * .to("deals")
443
+ * .many()
444
+ * // → Can link to records from any of these objects
445
+ * ```
446
+ */
447
+ type RelationAttribute = SingleRelationAttribute | MultiRelationAttribute;
448
+ /**
449
+ * Check if a relation attribute is universal (can link to any object)
450
+ * Universal relations have `targets: [{ object: "*" }]`
451
+ */
452
+ declare function isUniversalRelation(attr: RelationAttribute): boolean;
453
+ /**
454
+ * Check if a relation attribute has bilateral synchronization enabled
455
+ */
456
+ declare function isBilateralRelation(attr: RelationAttribute): attr is RelationAttribute & {
457
+ bilateral: BilateralConfig;
458
+ };
459
+ /**
460
+ * Infer the cardinality of the inverse relation
461
+ * - one → many (contact.company ↔ company.contacts)
462
+ * - many → many (contact.tags ↔ tag.contacts)
463
+ */
464
+ declare function inferInverseCardinality(cardinality: "one" | "many"): "one" | "many";
465
+ interface TextAreaAttribute extends BaseAttribute<string> {
466
+ type: "textarea";
467
+ }
468
+ /**
469
+ * Available features for richtext editor
470
+ */
471
+ type RichtextFeature = "headings" | "bold" | "italic" | "lists" | "links" | "images" | "codeBlocks" | "tables";
472
+ /**
473
+ * RichtextAttribute - Rich text content using semantic markdown
474
+ *
475
+ * Stores content as semantic markdown string (with directives like :::callout).
476
+ * Parsed at runtime to Tiptap JSON for editing.
477
+ * Use this for: Notes, articles, descriptions, long-form content.
478
+ *
479
+ * @example
480
+ * ```typescript
481
+ * richtext({ name: "content", label: "Content" })
482
+ * .features(["headings", "bold", "italic", "lists", "links"])
483
+ * .required()
484
+ * ```
485
+ */
486
+ interface RichtextAttribute extends BaseAttribute<string> {
487
+ type: "richtext";
488
+ /** Enabled features. If undefined, all features are enabled. */
489
+ features?: RichtextFeature[];
490
+ }
491
+ interface RatingAttribute extends BaseAttribute<number> {
492
+ type: "rating";
493
+ max?: number;
494
+ iconType?: "star" | "heart" | "thumbs" | "number";
495
+ }
496
+ /**
497
+ * Return type for formula expressions
498
+ */
499
+ type FormulaReturnType = "text" | "number" | "boolean" | "date";
500
+ /**
501
+ * FormulaAttribute - Computed value based on other attributes
502
+ *
503
+ * Formulas are calculated at read-time and are always read-only.
504
+ * Users cannot directly edit formula values.
505
+ *
506
+ * @example Simple calculation
507
+ * ```typescript
508
+ * formula({ name: "total", label: "Total" })
509
+ * .expression("price * quantity")
510
+ * .returns("number")
511
+ * .decimals(2)
512
+ * ```
513
+ *
514
+ * @example With functions
515
+ * ```typescript
516
+ * formula({ name: "fullName", label: "Full Name" })
517
+ * .expression("CONCAT(firstName, ' ', lastName)")
518
+ * .returns("text")
519
+ * ```
520
+ */
521
+ interface FormulaAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
522
+ type: "formula";
523
+ /** Expression to evaluate (e.g., "price * quantity") */
524
+ expression: string;
525
+ /** Expected return type for formatting */
526
+ returnType: FormulaReturnType;
527
+ /** Decimal places for number results */
528
+ decimals?: number;
529
+ /** Whether to allow relation references in the expression (e.g., "company.name") */
530
+ allowRelations?: boolean;
531
+ /** Formula is always not required (read-only) */
532
+ required: false;
533
+ }
534
+ /**
535
+ * Aggregation functions for rollup attributes
536
+ *
537
+ * Categories:
538
+ * - Numeric (sum, avg): Only for number, currency, rating types
539
+ * - Date (earliest, latest): Only for date type
540
+ * - Count (count, countValues, countUniqueValues, countEmpty): Universal
541
+ * - Percent (percentEmpty, percentNotEmpty): Universal
542
+ * - Lookup (original): Returns all values as array, rendered as target type
543
+ */
544
+ type RollupFunction = "sum" | "avg" | "earliest" | "latest" | "count" | "countValues" | "countUniqueValues" | "countEmpty" | "percentEmpty" | "percentNotEmpty" | "original";
545
+ /**
546
+ * RollupAttribute - Aggregates values from related records
547
+ *
548
+ * Rollups are calculated and stored (denormalized) for performance.
549
+ * They are automatically recalculated when related records change.
550
+ * Users cannot directly edit rollup values.
551
+ *
552
+ * @example Sum of related amounts
553
+ * ```typescript
554
+ * rollup({ name: "totalOrders", label: "Total Orders" })
555
+ * .from("orders") // relation attribute name
556
+ * .aggregate("amount") // target attribute to sum
557
+ * .using("sum")
558
+ * .decimals(2)
559
+ * ```
560
+ *
561
+ * @example Count of related records
562
+ * ```typescript
563
+ * rollup({ name: "orderCount", label: "Number of Orders" })
564
+ * .from("orders")
565
+ * .using("count")
566
+ * ```
567
+ */
568
+ interface RollupAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
569
+ type: "rollup";
570
+ /** Name of the relation attribute on this object */
571
+ relationAttribute: string;
572
+ /**
573
+ * Dot notation path for multi-level traversal (Phase 4+)
574
+ * @example "orders.items" - traverse through orders to items
575
+ */
576
+ relationPath?: string;
577
+ /** Attribute name on the target object to aggregate */
578
+ targetAttribute: string;
579
+ /** Aggregation function to apply */
580
+ function: RollupFunction;
581
+ /** Decimal places for numeric results */
582
+ decimals?: number;
583
+ /** Rollup is always not required (read-only) */
584
+ required: false;
585
+ /**
586
+ * Cached type of the target attribute for display purposes
587
+ * Used when function="original" to render values as the target type
588
+ */
589
+ targetAttributeType?: AttributeType;
590
+ /**
591
+ * Cached options from target attribute (for select/status/multiselect display)
592
+ * Required when function="original" and target is a select-like type
593
+ */
594
+ targetAttributeOptions?: Option[];
595
+ }
596
+ /**
597
+ * DocumentAttribute - References one or multiple documents with templates.
598
+ *
599
+ * Unlike FileAttribute which stores raw file references, DocumentAttribute
600
+ * provides structured document handling with templates, multi-file support,
601
+ * and automatic processing (OCR, signature, identity verification).
602
+ *
603
+ * @example Single document with template choice
604
+ * ```typescript
605
+ * document({ name: "identityDocument", label: "Pièce d'identité" })
606
+ * .templates(["french_id_card", "passport"])
607
+ * .autoProcess()
608
+ * .required()
609
+ * ```
610
+ *
611
+ * @example Multiple documents with fixed template
612
+ * ```typescript
613
+ * document({ name: "contracts", label: "Contrats" })
614
+ * .template("signable_contract")
615
+ * .multiple()
616
+ * .maxDocuments(10)
617
+ * ```
618
+ */
619
+ interface DocumentAttribute extends BaseAttribute<string | string[]> {
620
+ type: "document";
621
+ /**
622
+ * Single template ID (strict mode).
623
+ * If set, only documents using this template can be attached.
624
+ */
625
+ templateId?: string;
626
+ /**
627
+ * Multiple allowed template IDs.
628
+ * User can choose which template to use when uploading.
629
+ */
630
+ allowedTemplates?: string[];
631
+ /**
632
+ * Allow multiple documents.
633
+ * If true, value is string[] (document IDs).
634
+ * If false/undefined, value is string (single document ID).
635
+ */
636
+ multiple?: boolean;
637
+ /**
638
+ * Maximum number of documents when multiple: true.
639
+ */
640
+ maxDocuments?: number;
641
+ /**
642
+ * Automatically trigger processing (OCR, verification) on upload.
643
+ */
644
+ autoProcess?: boolean;
645
+ }
646
+ type Attribute = TextAttribute | TextAreaAttribute | RichtextAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | LocationAttribute | SelectAttribute | MultiselectAttribute | FileAttribute | UserAttribute | RelationAttribute | RatingAttribute | FormulaAttribute | RollupAttribute | DocumentAttribute;
647
+
648
+ /**
649
+ * Timestamps for tracking creation and updates
650
+ */
651
+ interface Timestamps {
652
+ createdAt: Date;
653
+ updatedAt: Date;
654
+ }
655
+ /**
656
+ * Sharing mode for multi-tenant object access.
657
+ *
658
+ * - `private`: Object is only visible to its owner tenant (default)
659
+ * - `shared`: Object is readable by all tenants, but only writable by the owner tenant
660
+ *
661
+ * Records inherit the sharing mode of their parent object.
662
+ */
663
+ type SharingMode = "private" | "shared";
664
+ /**
665
+ * Object definition - Represents a database table/entity
666
+ */
667
+ interface ObjectDefinition {
668
+ id?: Uuid;
669
+ name: string;
670
+ label: string;
671
+ pluralLabel?: string;
672
+ description?: string;
673
+ icon?: IconName;
674
+ /**
675
+ * Template expression used to compute the object's display label.
676
+ * Supports variable interpolation and pipes for formatting.
677
+ *
678
+ * @example
679
+ * ```typescript
680
+ * // Simple attribute reference
681
+ * labelExpression: "{{ name }}"
682
+ *
683
+ * // Multiple attributes
684
+ * labelExpression: "{{ firstName }} {{ lastName }}"
685
+ *
686
+ * // With pipes for formatting
687
+ * labelExpression: "{{ code | UPPER }} - {{ name | capitalize }}"
688
+ * ```
689
+ *
690
+ * Available pipes: UPPER, LOWER, capitalize, trim
691
+ */
692
+ labelExpression: string;
693
+ attributes: Attribute[];
694
+ system?: boolean;
695
+ /**
696
+ * Sharing mode for multi-tenant access.
697
+ * - `private`: Only visible to the owner tenant (default)
698
+ * - `shared`: Readable by all tenants, writable only by the owner
699
+ *
700
+ * Records inherit the sharing mode of their parent object.
701
+ * @default "private"
702
+ */
703
+ sharingMode?: SharingMode;
704
+ metadata?: Record<string, unknown>;
705
+ }
706
+ /**
707
+ * Links an attribute to an object
708
+ */
709
+ interface ObjectAttribute {
710
+ objectId: Uuid;
711
+ attributeId: Uuid;
712
+ order?: number;
713
+ required?: boolean;
714
+ }
715
+ /**
716
+ * Completion status of a record based on data completeness.
717
+ *
718
+ * - `draft`: Record is missing one or more required attribute values.
719
+ * Can be saved but is considered incomplete.
720
+ * - `complete`: All required attribute values are present and valid.
721
+ * Record is ready for use.
722
+ *
723
+ * This is different from workflow status (e.g., "pending", "approved").
724
+ * Completion status is computed dynamically based on the object schema.
725
+ */
726
+ type CompletionStatus = "draft" | "complete";
727
+ /**
728
+ * Record - Instance of an Object (a row in the database)
729
+ */
730
+ interface ObjectRecord extends Timestamps {
731
+ id: Uuid;
732
+ objectId: Uuid;
733
+ /**
734
+ * Display label computed from the object's labelExpression.
735
+ * Computed dynamically based on record values.
736
+ *
737
+ * @example "John Doe" (from "{{ firstName }} {{ lastName }}")
738
+ */
739
+ label: string;
740
+ /**
741
+ * Completion status of the record.
742
+ * - `draft`: Missing required values, record is incomplete
743
+ * - `complete`: All required values present and valid
744
+ *
745
+ * Computed dynamically based on the object's schema.
746
+ */
747
+ completionStatus: CompletionStatus;
748
+ values: Record<string, unknown>;
749
+ /**
750
+ * Custom metadata for the record.
751
+ * Use this for UI/UX state, feature flags, or any application-specific data.
752
+ * Unlike system fields (id, createdAt, updatedAt), metadata can be updated.
753
+ */
754
+ metadata?: Record<string, unknown>;
755
+ /**
756
+ * Soft delete timestamp.
757
+ * If set, the record is considered deleted but can be restored.
758
+ * Queries exclude soft-deleted records by default.
759
+ */
760
+ deletedAt?: Date | null;
761
+ /**
762
+ * User ID who created this record.
763
+ * Automatically set by RecordService when userId is configured.
764
+ * Optional for backward compatibility with existing records.
765
+ */
766
+ createdBy?: string;
767
+ /**
768
+ * User ID who last updated this record.
769
+ * Automatically set by RecordService when userId is configured.
770
+ * Optional for backward compatibility with existing records.
771
+ */
772
+ lastUpdatedBy?: string;
773
+ }
774
+ /**
775
+ * System-managed field names on ObjectRecord.
776
+ * These are stored as SQL columns (not in JSONB `values`).
777
+ *
778
+ * Use this in adapters to determine if a filter/sort attribute is a table column
779
+ * vs. a JSONB value field.
780
+ *
781
+ * @example
782
+ * ```typescript
783
+ * if (SYSTEM_FIELD_NAMES.includes(filter.attribute)) {
784
+ * // Filter on SQL column (e.g., WHERE created_at > ...)
785
+ * } else {
786
+ * // Filter on JSONB field (e.g., WHERE values->>'name' = ...)
787
+ * }
788
+ * ```
789
+ */
790
+ declare const SYSTEM_FIELD_NAMES: readonly ["id", "createdAt", "updatedAt", "createdBy", "lastUpdatedBy"];
791
+ /**
792
+ * Type for system field names
793
+ */
794
+ type SystemFieldName = (typeof SYSTEM_FIELD_NAMES)[number];
795
+ /**
796
+ * Reserved attribute names that cannot be used for custom attributes.
797
+ * These names conflict with ObjectRecord properties.
798
+ *
799
+ * Includes:
800
+ * - System fields (id, createdAt, updatedAt, createdBy, lastUpdatedBy)
801
+ * - Other ObjectRecord properties (objectId, label, completionStatus, values, metadata, deletedAt)
802
+ *
803
+ * @example
804
+ * ```typescript
805
+ * if (RESERVED_ATTRIBUTE_NAMES.includes(attributeName)) {
806
+ * throw new Error(`"${attributeName}" is a reserved name`);
807
+ * }
808
+ * ```
809
+ */
810
+ declare const RESERVED_ATTRIBUTE_NAMES: readonly ["id", "createdAt", "updatedAt", "createdBy", "lastUpdatedBy", "objectId", "label", "completionStatus", "values", "metadata", "deletedAt"];
811
+ /**
812
+ * Type for reserved attribute names
813
+ */
814
+ type ReservedAttributeName = (typeof RESERVED_ATTRIBUTE_NAMES)[number];
815
+
816
+ /**
817
+ * Format Zod validation errors into a consistent structure.
818
+ * This eliminates code duplication across multiple validation functions.
819
+ */
820
+ declare function formatZodErrors(error: z.ZodError): Array<{
821
+ path: string[];
822
+ message: string;
823
+ }>;
824
+ /**
825
+ * Validation messages for Zod validators.
826
+ * All functions receive the full Attribute to access label, type, etc.
827
+ * Can be customized for i18n support.
828
+ */
829
+ interface ValidationMessages {
830
+ required: (attr: Attribute) => string;
831
+ invalidType: (attr: Attribute, expected: string) => string;
832
+ minLength: (attr: Attribute, min: number) => string;
833
+ maxLength: (attr: Attribute, max: number) => string;
834
+ invalidPattern: (attr: Attribute) => string;
835
+ minValue: (attr: Attribute, min: number) => string;
836
+ maxValue: (attr: Attribute, max: number) => string;
837
+ mustBeInteger: (attr: Attribute) => string;
838
+ invalidDate: (attr: Attribute) => string;
839
+ invalidOption: (attr: Attribute, options: string[]) => string;
840
+ invalidId: (attr: Attribute) => string;
841
+ minItems: (attr: Attribute, min: number) => string;
842
+ maxItems: (attr: Attribute, max: number) => string;
843
+ invalidRichtext: (attr: Attribute) => string;
844
+ invalidPhone: (attr: Attribute) => string;
845
+ invalidCurrency: (attr: Attribute) => string;
846
+ invalidLocation: (attr: Attribute) => string;
847
+ }
848
+ declare const DEFAULT_VALIDATION_MESSAGES: ValidationMessages;
849
+ /**
850
+ * Text attribute config schema
851
+ */
852
+ declare const textConfigSchema: z.ZodObject<{
853
+ disabled: z.ZodOptional<z.ZodBoolean>;
854
+ placeholder: z.ZodOptional<z.ZodString>;
855
+ description: z.ZodOptional<z.ZodString>;
856
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
857
+ icon: z.ZodOptional<z.ZodString>;
858
+ order: z.ZodOptional<z.ZodNumber>;
859
+ hidden: z.ZodOptional<z.ZodBoolean>;
860
+ archived: z.ZodOptional<z.ZodBoolean>;
861
+ deprecated: z.ZodOptional<z.ZodBoolean>;
862
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
863
+ minLength: z.ZodOptional<z.ZodNumber>;
864
+ maxLength: z.ZodOptional<z.ZodNumber>;
865
+ pattern: z.ZodOptional<z.ZodString>;
866
+ }, z.core.$strip>;
867
+ /**
868
+ * Textarea attribute config schema
869
+ */
870
+ declare const textareaConfigSchema: z.ZodObject<{
871
+ disabled: z.ZodOptional<z.ZodBoolean>;
872
+ placeholder: z.ZodOptional<z.ZodString>;
873
+ description: z.ZodOptional<z.ZodString>;
874
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
875
+ icon: z.ZodOptional<z.ZodString>;
876
+ order: z.ZodOptional<z.ZodNumber>;
877
+ hidden: z.ZodOptional<z.ZodBoolean>;
878
+ archived: z.ZodOptional<z.ZodBoolean>;
879
+ deprecated: z.ZodOptional<z.ZodBoolean>;
880
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
881
+ }, z.core.$strip>;
882
+ /**
883
+ * Richtext attribute config schema
884
+ */
885
+ declare const richtextConfigSchema: z.ZodObject<{
886
+ disabled: z.ZodOptional<z.ZodBoolean>;
887
+ placeholder: z.ZodOptional<z.ZodString>;
888
+ description: z.ZodOptional<z.ZodString>;
889
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
890
+ icon: z.ZodOptional<z.ZodString>;
891
+ order: z.ZodOptional<z.ZodNumber>;
892
+ hidden: z.ZodOptional<z.ZodBoolean>;
893
+ archived: z.ZodOptional<z.ZodBoolean>;
894
+ deprecated: z.ZodOptional<z.ZodBoolean>;
895
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
896
+ features: z.ZodOptional<z.ZodArray<z.ZodEnum<{
897
+ headings: "headings";
898
+ bold: "bold";
899
+ italic: "italic";
900
+ lists: "lists";
901
+ links: "links";
902
+ images: "images";
903
+ codeBlocks: "codeBlocks";
904
+ tables: "tables";
905
+ }>>>;
906
+ }, z.core.$strip>;
907
+ /**
908
+ * Number attribute config schema
909
+ */
910
+ declare const numberConfigSchema: z.ZodObject<{
911
+ disabled: z.ZodOptional<z.ZodBoolean>;
912
+ placeholder: z.ZodOptional<z.ZodString>;
913
+ description: z.ZodOptional<z.ZodString>;
914
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
915
+ icon: z.ZodOptional<z.ZodString>;
916
+ order: z.ZodOptional<z.ZodNumber>;
917
+ hidden: z.ZodOptional<z.ZodBoolean>;
918
+ archived: z.ZodOptional<z.ZodBoolean>;
919
+ deprecated: z.ZodOptional<z.ZodBoolean>;
920
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
921
+ min: z.ZodOptional<z.ZodNumber>;
922
+ max: z.ZodOptional<z.ZodNumber>;
923
+ unit: z.ZodOptional<z.ZodEnum<{
924
+ percentage: "percentage";
925
+ integer: "integer";
926
+ decimal: "decimal";
927
+ }>>;
928
+ decimals: z.ZodOptional<z.ZodNumber>;
929
+ }, z.core.$strip>;
930
+ /**
931
+ * Checkbox attribute config schema
932
+ */
933
+ declare const checkboxConfigSchema: z.ZodObject<{
934
+ disabled: z.ZodOptional<z.ZodBoolean>;
935
+ placeholder: z.ZodOptional<z.ZodString>;
936
+ description: z.ZodOptional<z.ZodString>;
937
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
938
+ icon: z.ZodOptional<z.ZodString>;
939
+ order: z.ZodOptional<z.ZodNumber>;
940
+ hidden: z.ZodOptional<z.ZodBoolean>;
941
+ archived: z.ZodOptional<z.ZodBoolean>;
942
+ deprecated: z.ZodOptional<z.ZodBoolean>;
943
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
944
+ }, z.core.$strip>;
945
+ /**
946
+ * Date attribute config schema
947
+ */
948
+ declare const dateConfigSchema: z.ZodObject<{
949
+ disabled: z.ZodOptional<z.ZodBoolean>;
950
+ placeholder: z.ZodOptional<z.ZodString>;
951
+ description: z.ZodOptional<z.ZodString>;
952
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
953
+ icon: z.ZodOptional<z.ZodString>;
954
+ order: z.ZodOptional<z.ZodNumber>;
955
+ hidden: z.ZodOptional<z.ZodBoolean>;
956
+ archived: z.ZodOptional<z.ZodBoolean>;
957
+ deprecated: z.ZodOptional<z.ZodBoolean>;
958
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
959
+ dateFormat: z.ZodOptional<z.ZodEnum<{
960
+ short: "short";
961
+ long: "long";
962
+ full: "full";
963
+ relative: "relative";
964
+ }>>;
965
+ minDate: z.ZodOptional<z.ZodString>;
966
+ maxDate: z.ZodOptional<z.ZodString>;
967
+ }, z.core.$strip>;
968
+ /**
969
+ * Phone attribute config schema
970
+ */
971
+ declare const phoneConfigSchema: z.ZodObject<{
972
+ disabled: z.ZodOptional<z.ZodBoolean>;
973
+ placeholder: z.ZodOptional<z.ZodString>;
974
+ description: z.ZodOptional<z.ZodString>;
975
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
976
+ icon: z.ZodOptional<z.ZodString>;
977
+ order: z.ZodOptional<z.ZodNumber>;
978
+ hidden: z.ZodOptional<z.ZodBoolean>;
979
+ archived: z.ZodOptional<z.ZodBoolean>;
980
+ deprecated: z.ZodOptional<z.ZodBoolean>;
981
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
982
+ defaultCountryCode: z.ZodOptional<z.ZodString>;
983
+ }, z.core.$strip>;
984
+ /**
985
+ * Currency attribute config schema
986
+ */
987
+ declare const currencyConfigSchema: z.ZodObject<{
988
+ disabled: z.ZodOptional<z.ZodBoolean>;
989
+ placeholder: z.ZodOptional<z.ZodString>;
990
+ description: z.ZodOptional<z.ZodString>;
991
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
992
+ icon: z.ZodOptional<z.ZodString>;
993
+ order: z.ZodOptional<z.ZodNumber>;
994
+ hidden: z.ZodOptional<z.ZodBoolean>;
995
+ archived: z.ZodOptional<z.ZodBoolean>;
996
+ deprecated: z.ZodOptional<z.ZodBoolean>;
997
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
998
+ defaultCurrency: z.ZodOptional<z.ZodString>;
999
+ allowedCurrencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
1000
+ }, z.core.$strip>;
1001
+ /**
1002
+ * Status attribute config schema
1003
+ */
1004
+ declare const statusConfigSchema: z.ZodObject<{
1005
+ disabled: z.ZodOptional<z.ZodBoolean>;
1006
+ placeholder: z.ZodOptional<z.ZodString>;
1007
+ description: z.ZodOptional<z.ZodString>;
1008
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1009
+ icon: z.ZodOptional<z.ZodString>;
1010
+ order: z.ZodOptional<z.ZodNumber>;
1011
+ hidden: z.ZodOptional<z.ZodBoolean>;
1012
+ archived: z.ZodOptional<z.ZodBoolean>;
1013
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1014
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1015
+ options: z.ZodArray<z.ZodObject<{
1016
+ id: z.ZodString;
1017
+ label: z.ZodString;
1018
+ value: z.ZodString;
1019
+ color: z.ZodOptional<z.ZodString>;
1020
+ icon: z.ZodOptional<z.ZodString>;
1021
+ description: z.ZodOptional<z.ZodString>;
1022
+ group: z.ZodOptional<z.ZodEnum<{
1023
+ in_progress: "in_progress";
1024
+ idle: "idle";
1025
+ finished: "finished";
1026
+ }>>;
1027
+ }, z.core.$strip>>;
1028
+ }, z.core.$strip>;
1029
+ /**
1030
+ * Location attribute config schema
1031
+ */
1032
+ declare const locationConfigSchema: z.ZodObject<{
1033
+ disabled: z.ZodOptional<z.ZodBoolean>;
1034
+ placeholder: z.ZodOptional<z.ZodString>;
1035
+ description: z.ZodOptional<z.ZodString>;
1036
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1037
+ icon: z.ZodOptional<z.ZodString>;
1038
+ order: z.ZodOptional<z.ZodNumber>;
1039
+ hidden: z.ZodOptional<z.ZodBoolean>;
1040
+ archived: z.ZodOptional<z.ZodBoolean>;
1041
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1042
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1043
+ granularity: z.ZodEnum<{
1044
+ full: "full";
1045
+ address: "address";
1046
+ city: "city";
1047
+ state: "state";
1048
+ country: "country";
1049
+ coordinates: "coordinates";
1050
+ }>;
1051
+ enableAutocomplete: z.ZodOptional<z.ZodBoolean>;
1052
+ enableMap: z.ZodOptional<z.ZodBoolean>;
1053
+ defaultCountry: z.ZodOptional<z.ZodString>;
1054
+ allowedCountries: z.ZodOptional<z.ZodArray<z.ZodString>>;
1055
+ displayFormat: z.ZodOptional<z.ZodEnum<{
1056
+ single_line: "single_line";
1057
+ multi_line: "multi_line";
1058
+ compact: "compact";
1059
+ }>>;
1060
+ }, z.core.$strip>;
1061
+ /**
1062
+ * Select attribute config schema
1063
+ */
1064
+ declare const selectConfigSchema: z.ZodObject<{
1065
+ disabled: z.ZodOptional<z.ZodBoolean>;
1066
+ placeholder: z.ZodOptional<z.ZodString>;
1067
+ description: z.ZodOptional<z.ZodString>;
1068
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1069
+ icon: z.ZodOptional<z.ZodString>;
1070
+ order: z.ZodOptional<z.ZodNumber>;
1071
+ hidden: z.ZodOptional<z.ZodBoolean>;
1072
+ archived: z.ZodOptional<z.ZodBoolean>;
1073
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1074
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1075
+ options: z.ZodArray<z.ZodObject<{
1076
+ id: z.ZodString;
1077
+ label: z.ZodString;
1078
+ value: z.ZodString;
1079
+ color: z.ZodOptional<z.ZodString>;
1080
+ icon: z.ZodOptional<z.ZodString>;
1081
+ description: z.ZodOptional<z.ZodString>;
1082
+ group: z.ZodOptional<z.ZodEnum<{
1083
+ in_progress: "in_progress";
1084
+ idle: "idle";
1085
+ finished: "finished";
1086
+ }>>;
1087
+ }, z.core.$strip>>;
1088
+ }, z.core.$strip>;
1089
+ /**
1090
+ * Multiselect attribute config schema
1091
+ */
1092
+ declare const multiselectConfigSchema: z.ZodObject<{
1093
+ disabled: z.ZodOptional<z.ZodBoolean>;
1094
+ placeholder: z.ZodOptional<z.ZodString>;
1095
+ description: z.ZodOptional<z.ZodString>;
1096
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1097
+ icon: z.ZodOptional<z.ZodString>;
1098
+ order: z.ZodOptional<z.ZodNumber>;
1099
+ hidden: z.ZodOptional<z.ZodBoolean>;
1100
+ archived: z.ZodOptional<z.ZodBoolean>;
1101
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1102
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1103
+ options: z.ZodArray<z.ZodObject<{
1104
+ id: z.ZodString;
1105
+ label: z.ZodString;
1106
+ value: z.ZodString;
1107
+ color: z.ZodOptional<z.ZodString>;
1108
+ icon: z.ZodOptional<z.ZodString>;
1109
+ description: z.ZodOptional<z.ZodString>;
1110
+ group: z.ZodOptional<z.ZodEnum<{
1111
+ in_progress: "in_progress";
1112
+ idle: "idle";
1113
+ finished: "finished";
1114
+ }>>;
1115
+ }, z.core.$strip>>;
1116
+ }, z.core.$strip>;
1117
+ /**
1118
+ * File attribute config schema
1119
+ */
1120
+ declare const fileConfigSchema: z.ZodObject<{
1121
+ disabled: z.ZodOptional<z.ZodBoolean>;
1122
+ placeholder: z.ZodOptional<z.ZodString>;
1123
+ description: z.ZodOptional<z.ZodString>;
1124
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1125
+ icon: z.ZodOptional<z.ZodString>;
1126
+ order: z.ZodOptional<z.ZodNumber>;
1127
+ hidden: z.ZodOptional<z.ZodBoolean>;
1128
+ archived: z.ZodOptional<z.ZodBoolean>;
1129
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1130
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1131
+ maxFiles: z.ZodOptional<z.ZodNumber>;
1132
+ maxSize: z.ZodOptional<z.ZodNumber>;
1133
+ allowedTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
1134
+ multiple: z.ZodOptional<z.ZodBoolean>;
1135
+ }, z.core.$strip>;
1136
+ /**
1137
+ * User attribute config schema
1138
+ */
1139
+ declare const userConfigSchema: z.ZodObject<{
1140
+ disabled: z.ZodOptional<z.ZodBoolean>;
1141
+ placeholder: z.ZodOptional<z.ZodString>;
1142
+ description: z.ZodOptional<z.ZodString>;
1143
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1144
+ icon: z.ZodOptional<z.ZodString>;
1145
+ order: z.ZodOptional<z.ZodNumber>;
1146
+ hidden: z.ZodOptional<z.ZodBoolean>;
1147
+ archived: z.ZodOptional<z.ZodBoolean>;
1148
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1149
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1150
+ allowedRoles: z.ZodOptional<z.ZodArray<z.ZodString>>;
1151
+ multiple: z.ZodOptional<z.ZodBoolean>;
1152
+ }, z.core.$strip>;
1153
+ /**
1154
+ * Relation attribute config schema
1155
+ */
1156
+ declare const relationConfigSchema: z.ZodObject<{
1157
+ disabled: z.ZodOptional<z.ZodBoolean>;
1158
+ placeholder: z.ZodOptional<z.ZodString>;
1159
+ description: z.ZodOptional<z.ZodString>;
1160
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1161
+ icon: z.ZodOptional<z.ZodString>;
1162
+ order: z.ZodOptional<z.ZodNumber>;
1163
+ hidden: z.ZodOptional<z.ZodBoolean>;
1164
+ archived: z.ZodOptional<z.ZodBoolean>;
1165
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1166
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1167
+ targets: z.ZodArray<z.ZodObject<{
1168
+ object: z.ZodString;
1169
+ displayTemplate: z.ZodOptional<z.ZodString>;
1170
+ filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1171
+ }, z.core.$strip>>;
1172
+ cardinality: z.ZodEnum<{
1173
+ one: "one";
1174
+ many: "many";
1175
+ }>;
1176
+ minItems: z.ZodOptional<z.ZodNumber>;
1177
+ maxItems: z.ZodOptional<z.ZodNumber>;
1178
+ }, z.core.$strip>;
1179
+ /**
1180
+ * Rating attribute config schema
1181
+ */
1182
+ declare const ratingConfigSchema: z.ZodObject<{
1183
+ disabled: z.ZodOptional<z.ZodBoolean>;
1184
+ placeholder: z.ZodOptional<z.ZodString>;
1185
+ description: z.ZodOptional<z.ZodString>;
1186
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1187
+ icon: z.ZodOptional<z.ZodString>;
1188
+ order: z.ZodOptional<z.ZodNumber>;
1189
+ hidden: z.ZodOptional<z.ZodBoolean>;
1190
+ archived: z.ZodOptional<z.ZodBoolean>;
1191
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1192
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1193
+ max: z.ZodOptional<z.ZodNumber>;
1194
+ iconType: z.ZodOptional<z.ZodEnum<{
1195
+ number: "number";
1196
+ heart: "heart";
1197
+ star: "star";
1198
+ thumbs: "thumbs";
1199
+ }>>;
1200
+ }, z.core.$strip>;
1201
+ /**
1202
+ * Formula attribute config schema
1203
+ */
1204
+ declare const formulaConfigSchema: z.ZodObject<{
1205
+ disabled: z.ZodOptional<z.ZodBoolean>;
1206
+ placeholder: z.ZodOptional<z.ZodString>;
1207
+ description: z.ZodOptional<z.ZodString>;
1208
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1209
+ icon: z.ZodOptional<z.ZodString>;
1210
+ order: z.ZodOptional<z.ZodNumber>;
1211
+ hidden: z.ZodOptional<z.ZodBoolean>;
1212
+ archived: z.ZodOptional<z.ZodBoolean>;
1213
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1214
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1215
+ expression: z.ZodString;
1216
+ returnType: z.ZodEnum<{
1217
+ number: "number";
1218
+ boolean: "boolean";
1219
+ text: "text";
1220
+ date: "date";
1221
+ }>;
1222
+ decimals: z.ZodOptional<z.ZodNumber>;
1223
+ allowRelations: z.ZodOptional<z.ZodBoolean>;
1224
+ }, z.core.$strip>;
1225
+ /**
1226
+ * Rollup attribute config schema
1227
+ */
1228
+ declare const rollupConfigSchema: z.ZodObject<{
1229
+ disabled: z.ZodOptional<z.ZodBoolean>;
1230
+ placeholder: z.ZodOptional<z.ZodString>;
1231
+ description: z.ZodOptional<z.ZodString>;
1232
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1233
+ icon: z.ZodOptional<z.ZodString>;
1234
+ order: z.ZodOptional<z.ZodNumber>;
1235
+ hidden: z.ZodOptional<z.ZodBoolean>;
1236
+ archived: z.ZodOptional<z.ZodBoolean>;
1237
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1238
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1239
+ relationAttribute: z.ZodOptional<z.ZodString>;
1240
+ relationPath: z.ZodOptional<z.ZodString>;
1241
+ targetAttribute: z.ZodString;
1242
+ function: z.ZodEnum<{
1243
+ sum: "sum";
1244
+ avg: "avg";
1245
+ earliest: "earliest";
1246
+ latest: "latest";
1247
+ count: "count";
1248
+ countValues: "countValues";
1249
+ countUniqueValues: "countUniqueValues";
1250
+ countEmpty: "countEmpty";
1251
+ percentEmpty: "percentEmpty";
1252
+ percentNotEmpty: "percentNotEmpty";
1253
+ original: "original";
1254
+ }>;
1255
+ decimals: z.ZodOptional<z.ZodNumber>;
1256
+ targetAttributeType: z.ZodOptional<z.ZodString>;
1257
+ targetAttributeOptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
1258
+ id: z.ZodString;
1259
+ label: z.ZodString;
1260
+ value: z.ZodString;
1261
+ color: z.ZodOptional<z.ZodString>;
1262
+ icon: z.ZodOptional<z.ZodString>;
1263
+ description: z.ZodOptional<z.ZodString>;
1264
+ group: z.ZodOptional<z.ZodEnum<{
1265
+ in_progress: "in_progress";
1266
+ idle: "idle";
1267
+ finished: "finished";
1268
+ }>>;
1269
+ }, z.core.$strip>>>;
1270
+ }, z.core.$strip>;
1271
+ /**
1272
+ * Document attribute config schema
1273
+ */
1274
+ declare const documentConfigSchema: z.ZodObject<{
1275
+ disabled: z.ZodOptional<z.ZodBoolean>;
1276
+ placeholder: z.ZodOptional<z.ZodString>;
1277
+ description: z.ZodOptional<z.ZodString>;
1278
+ defaultValue: z.ZodOptional<z.ZodUnknown>;
1279
+ icon: z.ZodOptional<z.ZodString>;
1280
+ order: z.ZodOptional<z.ZodNumber>;
1281
+ hidden: z.ZodOptional<z.ZodBoolean>;
1282
+ archived: z.ZodOptional<z.ZodBoolean>;
1283
+ deprecated: z.ZodOptional<z.ZodBoolean>;
1284
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1285
+ templateId: z.ZodOptional<z.ZodString>;
1286
+ allowedTemplates: z.ZodOptional<z.ZodArray<z.ZodString>>;
1287
+ multiple: z.ZodOptional<z.ZodBoolean>;
1288
+ maxDocuments: z.ZodOptional<z.ZodNumber>;
1289
+ autoProcess: z.ZodOptional<z.ZodBoolean>;
1290
+ }, z.core.$strip>;
1291
+ /**
1292
+ * Map of attribute type to config schema
1293
+ */
1294
+ declare const attributeConfigSchemas: Record<AttributeType, z.ZodObject<z.ZodRawShape>>;
1295
+ /**
1296
+ * Get the config schema for a specific attribute type
1297
+ */
1298
+ declare function getAttributeConfigSchema(type: AttributeType): z.ZodObject<z.ZodRawShape>;
1299
+ /**
1300
+ * Validate attribute config for a specific type
1301
+ * Returns the validated config with only allowed properties
1302
+ */
1303
+ declare function validateAttributeConfig(type: AttributeType, config: Record<string, unknown>): {
1304
+ success: true;
1305
+ data: Record<string, unknown>;
1306
+ } | {
1307
+ success: false;
1308
+ errors: string[];
1309
+ };
1310
+ /**
1311
+ * Validate and strip unknown properties from attribute config
1312
+ * This ensures only allowed properties are stored in the database
1313
+ */
1314
+ declare function parseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown>;
1315
+ /**
1316
+ * Safely parse attribute config, returning undefined for invalid configs
1317
+ */
1318
+ declare function safeParseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown> | undefined;
1319
+ /**
1320
+ * Create a Zod schema for a text attribute
1321
+ */
1322
+ declare function createTextValidator(attr: TextAttribute, messages?: ValidationMessages): z.ZodString;
1323
+ /**
1324
+ * Create a Zod schema for a number attribute
1325
+ */
1326
+ declare function createNumberValidator(attr: NumberAttribute, messages?: ValidationMessages): z.ZodNumber;
1327
+ /**
1328
+ * Create a Zod schema for a checkbox attribute
1329
+ */
1330
+ declare function createCheckboxValidator(_attr: CheckboxAttribute, _messages?: ValidationMessages): z.ZodBoolean;
1331
+ /**
1332
+ * Create a Zod schema for a date attribute
1333
+ */
1334
+ declare function createDateValidator(attr: DateAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1335
+ /**
1336
+ * Create a Zod schema for a phone attribute.
1337
+ *
1338
+ * Validates:
1339
+ * - countryCode is a valid ISO3 country code
1340
+ * - phoneNumber contains valid digits for the given country
1341
+ *
1342
+ * Transforms:
1343
+ * - Normalizes phoneNumber to national digits without trunk prefix
1344
+ */
1345
+ declare function createPhoneValidator(attr: PhoneAttribute, messages?: ValidationMessages): z.ZodType<{
1346
+ countryCode: string;
1347
+ phoneNumber: string;
1348
+ }>;
1349
+ /**
1350
+ * Create a Zod schema for a currency attribute
1351
+ */
1352
+ declare function createCurrencyValidator(attr: CurrencyAttribute, messages?: ValidationMessages): z.ZodType<{
1353
+ code: string;
1354
+ value: number;
1355
+ }>;
1356
+ /**
1357
+ * Create a Zod schema for a status attribute
1358
+ */
1359
+ declare function createStatusValidator(attr: StatusAttribute, messages?: ValidationMessages): z.ZodEnum<Readonly<Record<string, string>>>;
1360
+ /**
1361
+ * Create a Zod schema for a select attribute
1362
+ */
1363
+ declare function createSelectValidator(attr: SelectAttribute, messages?: ValidationMessages): z.ZodEnum<Readonly<Record<string, string>>>;
1364
+ /**
1365
+ * Create a Zod schema for a multiselect attribute
1366
+ */
1367
+ declare function createMultiselectValidator(attr: MultiselectAttribute, messages?: ValidationMessages): z.ZodArray<z.ZodEnum<Readonly<Record<string, string>>>>;
1368
+ /**
1369
+ * Create a Zod schema for a location attribute
1370
+ */
1371
+ type LocationShape = {
1372
+ address?: string;
1373
+ address2?: string;
1374
+ city?: string;
1375
+ state?: string;
1376
+ postalCode?: string;
1377
+ country?: string;
1378
+ latitude?: number;
1379
+ longitude?: number;
1380
+ };
1381
+ declare function createLocationValidator(attr: LocationAttribute, messages?: ValidationMessages): z.ZodType<LocationShape>;
1382
+ /**
1383
+ * Create a Zod schema for a file attribute
1384
+ * Supports both single file (UUID) and multiple files (array of UUIDs)
1385
+ */
1386
+ declare function createFileValidator(attr: FileAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1387
+ /**
1388
+ * Create a Zod schema for a user attribute
1389
+ * Supports both single user (UUID) and multiple users (array of UUIDs)
1390
+ */
1391
+ declare function createUserValidator(attr: UserAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1392
+ /**
1393
+ * Create a Zod schema for a single relation attribute (cardinality: "one")
1394
+ * Supports hybrid format `{ id, props }` from qualified relations.
1395
+ */
1396
+ declare function createSingleRelationValidator(attr: SingleRelationAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1397
+ /**
1398
+ * Create a Zod schema for a multi relation attribute (cardinality: "many")
1399
+ * Supports hybrid format arrays with `{ id, props }` items from qualified relations.
1400
+ */
1401
+ declare function createMultiRelationValidator(attr: MultiRelationAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1402
+ /**
1403
+ * Create a Zod schema for a relation attribute
1404
+ * Dispatches to single or multi validator based on cardinality
1405
+ */
1406
+ declare function createRelationValidator(attr: RelationAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1407
+ /**
1408
+ * Create a Zod schema for a rating attribute
1409
+ */
1410
+ declare function createRatingValidator(attr: RatingAttribute, messages?: ValidationMessages): z.ZodNumber;
1411
+ /**
1412
+ * Create a Zod schema for a formula attribute.
1413
+ * Formula attributes are read-only (computed at runtime).
1414
+ * They accept any value during validation but are ignored during record creation/update.
1415
+ */
1416
+ declare function createFormulaValidator(_attr: FormulaAttribute, _messages?: ValidationMessages): z.ZodUnknown;
1417
+ /**
1418
+ * Create a Zod schema for a rollup attribute.
1419
+ * Rollup attributes are read-only (computed from related records).
1420
+ * They accept any value during validation but are ignored during record creation/update.
1421
+ */
1422
+ declare function createRollupValidator(_attr: RollupAttribute, _messages?: ValidationMessages): z.ZodUnknown;
1423
+ /**
1424
+ * Create a Zod schema for a textarea attribute.
1425
+ * Validates that the value is a string.
1426
+ */
1427
+ declare function createTextAreaValidator(_attr: TextAreaAttribute, _messages?: ValidationMessages): z.ZodString;
1428
+ /**
1429
+ * Create a Zod schema for a richtext attribute.
1430
+ * Validates semantic markdown content as a string.
1431
+ *
1432
+ * @example Valid richtext content (semantic markdown)
1433
+ * ```typescript
1434
+ * `# Heading
1435
+ *
1436
+ * Some paragraph text.
1437
+ *
1438
+ * :::callout{variant="info"}
1439
+ * This is a callout block
1440
+ * :::
1441
+ * `
1442
+ * ```
1443
+ */
1444
+ declare function createRichtextValidator(attr: RichtextAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1445
+ /**
1446
+ * Create a Zod schema for any attribute type.
1447
+ * Returns a strict validator that does NOT handle optional fields.
1448
+ * Use createFormAttributeValidator for form validation with optional support.
1449
+ *
1450
+ * @param attr - The attribute to create a validator for
1451
+ * @param messages - Custom validation messages for i18n support
1452
+ */
1453
+ declare function createAttributeValidator(attr: Attribute, messages?: ValidationMessages): z.ZodTypeAny;
1454
+ /**
1455
+ * Create a Zod schema for form validation.
1456
+ * - Normalizes empty values (empty strings, empty objects) to null for optional fields
1457
+ * - Accepts custom messages for i18n support
1458
+ *
1459
+ * Use this in UI forms where optional fields may have null/undefined values.
1460
+ *
1461
+ * @param attr - The attribute to create a validator for
1462
+ * @param messages - Custom validation messages for i18n support
1463
+ */
1464
+ declare function createFormAttributeValidator(attr: Attribute, messages?: ValidationMessages): z.ZodTypeAny;
1465
+ /**
1466
+ * Create a Zod schema for an entire object
1467
+ *
1468
+ * Uses passthrough mode to allow computed fields (formula, rollup) that may be
1469
+ * present in record data but are not part of the mutable schema.
1470
+ */
1471
+ declare function createObjectValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
1472
+ /**
1473
+ * Validation result
1474
+ */
1475
+ interface ValidationResult {
1476
+ success: boolean;
1477
+ data?: Record<string, unknown>;
1478
+ errors?: Array<{
1479
+ path: string[];
1480
+ message: string;
1481
+ }>;
1482
+ }
1483
+ /**
1484
+ * Validate data against an attribute schema
1485
+ */
1486
+ declare function validateAttribute(attr: Attribute, value: unknown): ValidationResult;
1487
+ /**
1488
+ * Validate data against an object schema
1489
+ */
1490
+ declare function validateObject(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
1491
+ /**
1492
+ * Validate and throw if invalid
1493
+ */
1494
+ declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
1495
+ /**
1496
+ * Create a Zod schema for draft validation.
1497
+ * All attributes become optional, but provided values are still validated.
1498
+ *
1499
+ * Uses passthrough mode to allow computed fields (formula, rollup) that may be
1500
+ * present in record data but are not part of the mutable schema.
1501
+ */
1502
+ declare function createDraftValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
1503
+ /**
1504
+ * Validate data in draft mode.
1505
+ * - All attributes are treated as optional (no required validation)
1506
+ * - Provided values are still validated for format/type correctness
1507
+ *
1508
+ * Use this when creating records that may be incomplete (drafts).
1509
+ *
1510
+ * @example
1511
+ * ```typescript
1512
+ * const result = validateDraft(PRODUCT, { name: "Draft" });
1513
+ * // → success even if "price" is required but missing
1514
+ *
1515
+ * const result2 = validateDraft(PRODUCT, { price: -10 });
1516
+ * // → fails because price must be >= 0 (format validation still applies)
1517
+ * ```
1518
+ */
1519
+ declare function validateDraft(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
1520
+ /**
1521
+ * Validate draft data and throw if format validation fails.
1522
+ */
1523
+ declare function validateDraftOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
1524
+ /**
1525
+ * Get the list of required attributes that are missing values.
1526
+ *
1527
+ * @example
1528
+ * ```typescript
1529
+ * const missing = getMissingRequiredAttributes(PRODUCT, { name: "Test" });
1530
+ * // → [priceAttribute, statusAttribute] if price and status are required but missing
1531
+ * ```
1532
+ */
1533
+ declare function getMissingRequiredAttributes(objectDef: ObjectDefinition, data: Record<string, unknown>): Attribute[];
1534
+ /**
1535
+ * Check if a record is complete (all required attributes have valid values).
1536
+ *
1537
+ * @returns `true` if all required values are present and valid, `false` otherwise
1538
+ */
1539
+ declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<string, unknown>): boolean;
1540
+ /**
1541
+ * Compute the completion status of a record based on its data.
1542
+ *
1543
+ * - `"complete"`: All required values are present and valid
1544
+ * - `"draft"`: One or more required values are missing or invalid
1545
+ *
1546
+ * This function is used to dynamically determine the status when
1547
+ * creating or updating records.
1548
+ *
1549
+ * @example
1550
+ * ```typescript
1551
+ * const status = computeRecordStatus(PRODUCT, {
1552
+ * name: "Nike Air Max",
1553
+ * price: 129.99,
1554
+ * status: "active"
1555
+ * });
1556
+ * // → "complete"
1557
+ *
1558
+ * const status2 = computeRecordStatus(PRODUCT, { name: "Draft Product" });
1559
+ * // → "draft" (missing required fields)
1560
+ * ```
1561
+ */
1562
+ declare function computeRecordStatus(objectDef: ObjectDefinition, data: Record<string, unknown>): CompletionStatus;
1563
+
1564
+ export { RESERVED_ATTRIBUTE_NAMES as $, type Attribute as A, type BilateralConfig as B, type CheckboxAttribute as C, type DateAttribute as D, type BaseAttribute as E, type FeatureGate as F, type NumberUnit as G, type DateFormat as H, type DateValue as I, type Currency as J, type Location as K, type LocationAttribute as L, type MultiselectAttribute as M, type NumberAttribute as N, type Option as O, type Phone as P, type LocationGranularity as Q, type RichtextAttribute as R, type StatusAttribute as S, type TextAttribute as T, type UserAttribute as U, RELATION_TARGET_ANY as V, isUniversalRelation as W, isBilateralRelation as X, inferInverseCardinality as Y, type FlagOverride as Z, type FeatureFlagsConfig as _, type DocumentAttribute as a, type ValidationResult as a$, SYSTEM_FIELD_NAMES as a0, type ReservedAttributeName as a1, type SystemFieldName as a2, type Timestamps as a3, type SharingMode as a4, type ObjectAttribute as a5, type CompletionStatus as a6, type ObjectRecord as a7, type PropertyType as a8, FORBIDDEN_PROPERTY_TYPES as a9, getAttributeConfigSchema as aA, validateAttributeConfig as aB, parseAttributeConfig as aC, safeParseAttributeConfig as aD, createTextValidator as aE, createNumberValidator as aF, createCheckboxValidator as aG, createDateValidator as aH, createPhoneValidator as aI, createCurrencyValidator as aJ, createStatusValidator as aK, createSelectValidator as aL, createMultiselectValidator as aM, createLocationValidator as aN, createFileValidator as aO, createUserValidator as aP, createSingleRelationValidator as aQ, createMultiRelationValidator as aR, createRelationValidator as aS, createRatingValidator as aT, createFormulaValidator as aU, createRollupValidator as aV, createTextAreaValidator as aW, createRichtextValidator as aX, createAttributeValidator as aY, createFormAttributeValidator as aZ, createObjectValidator as a_, type ForbiddenPropertyType as aa, type PropertyAttribute as ab, type PropertySchema as ac, formatZodErrors as ad, type ValidationMessages as ae, DEFAULT_VALIDATION_MESSAGES as af, textConfigSchema as ag, textareaConfigSchema as ah, richtextConfigSchema as ai, numberConfigSchema as aj, checkboxConfigSchema as ak, dateConfigSchema as al, phoneConfigSchema as am, currencyConfigSchema as an, statusConfigSchema as ao, locationConfigSchema as ap, selectConfigSchema as aq, multiselectConfigSchema as ar, fileConfigSchema as as, userConfigSchema as at, relationConfigSchema as au, ratingConfigSchema as av, formulaConfigSchema as aw, rollupConfigSchema as ax, documentConfigSchema as ay, attributeConfigSchemas as az, type TextAreaAttribute as b, validateAttribute as b0, validateObject as b1, validateObjectOrThrow as b2, createDraftValidator as b3, validateDraft as b4, validateDraftOrThrow as b5, getMissingRequiredAttributes as b6, isRecordComplete as b7, computeRecordStatus as b8, type RichtextFeature as c, type PhoneAttribute as d, type CurrencyAttribute as e, type SelectAttribute as f, type FileAttribute as g, type RatingAttribute as h, type RelationAttribute as i, type SingleRelationAttribute as j, type MultiRelationAttribute as k, type RelationTarget as l, type FormulaAttribute as m, type FormulaReturnType as n, type RollupAttribute as o, type RollupFunction as p, type AttributeType as q, type ObjectDefinition as r, type FlagValueType as s, type FeatureFlagDefinition as t, type FlagLevel as u, type FeatureFlagsRepository as v, type StaticFlagDefault as w, type ResolvedFlag as x, type StatusGroup as y, type AttributeGroup as z };