@stndrds/schema 0.1.0-alpha.67 → 1.0.0-alpha.102

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 (155) hide show
  1. package/dist/attributes-D7yQuTJK.d.mts +665 -0
  2. package/dist/attributes-DcbQC-4b.d.ts +665 -0
  3. package/dist/chunk-3JINFUN3.js +81 -0
  4. package/dist/chunk-4KRLCWJM.mjs +8 -0
  5. package/dist/chunk-4TC27SMF.mjs +18 -0
  6. package/dist/chunk-56QI6UTK.js +32 -0
  7. package/dist/chunk-5JVVPJJW.mjs +208 -0
  8. package/dist/chunk-5XL3JP73.mjs +83 -0
  9. package/dist/chunk-7HFZ7MVR.mjs +28 -0
  10. package/dist/chunk-ACQ3TUFK.js +10 -0
  11. package/dist/chunk-AYCSVKI2.mjs +14 -0
  12. package/dist/chunk-BLXQGQLK.mjs +10 -0
  13. package/dist/chunk-D7WFIGXW.js +14 -0
  14. package/dist/chunk-FRCDMQER.js +47 -0
  15. package/dist/chunk-GCRHSPZN.js +16 -0
  16. package/dist/chunk-IRTRJH37.mjs +8 -0
  17. package/dist/chunk-ITTQ4FGR.mjs +14 -0
  18. package/dist/chunk-J5HRK3WD.js +10 -0
  19. package/dist/chunk-KNYZH2WD.mjs +18 -0
  20. package/dist/chunk-KWVCGQ7N.mjs +78 -0
  21. package/dist/chunk-MAKSIK3P.js +10 -0
  22. package/dist/chunk-N7T66JVY.js +86 -0
  23. package/dist/chunk-OAQWRMTP.js +10 -0
  24. package/dist/chunk-OLJLCVNY.mjs +8 -0
  25. package/dist/chunk-P2BE2A2G.js +64 -0
  26. package/dist/chunk-PGERPYDR.js +2 -0
  27. package/dist/chunk-QWZHR2OO.js +12 -0
  28. package/dist/chunk-QY6QFRRV.mjs +41 -0
  29. package/dist/chunk-QYNPB37W.js +221 -0
  30. package/dist/chunk-R4CJHCC4.mjs +60 -0
  31. package/dist/chunk-RJ4LOX7P.js +22 -0
  32. package/dist/chunk-ROAZLZA2.js +20 -0
  33. package/dist/chunk-RUYUFXNW.mjs +12 -0
  34. package/dist/chunk-SP3PNHYF.mjs +1 -0
  35. package/dist/chunk-SS2NR6DH.mjs +176 -0
  36. package/dist/chunk-T225DB55.js +33 -0
  37. package/dist/chunk-TKN73433.js +20 -0
  38. package/dist/chunk-TMYBEXBT.mjs +8 -0
  39. package/dist/chunk-UQVW4KPP.mjs +30 -0
  40. package/dist/chunk-V6DE3MXC.js +180 -0
  41. package/dist/chunk-VXOTYFEW.js +16 -0
  42. package/dist/chunk-WV4V64D5.mjs +20 -0
  43. package/dist/helpers-DD6JzYfI.d.mts +860 -0
  44. package/dist/helpers-kMS5R7KX.d.ts +860 -0
  45. package/dist/index.d.mts +3597 -1768
  46. package/dist/index.d.ts +3597 -1768
  47. package/dist/index.js +4957 -1955
  48. package/dist/index.mjs +3920 -1116
  49. package/dist/types-BAPgWlpX.d.mts +39 -0
  50. package/dist/types-mZPUEZl0.d.ts +39 -0
  51. package/dist/utils.d.mts +20 -55
  52. package/dist/utils.d.ts +20 -55
  53. package/dist/utils.js +26 -19
  54. package/dist/utils.mjs +1 -19
  55. package/dist/validation/all.d.mts +8 -0
  56. package/dist/validation/all.d.ts +8 -0
  57. package/dist/validation/all.js +56 -0
  58. package/dist/validation/all.mjs +19 -0
  59. package/dist/validation/complex/currency.d.mts +15 -0
  60. package/dist/validation/complex/currency.d.ts +15 -0
  61. package/dist/validation/complex/currency.js +11 -0
  62. package/dist/validation/complex/currency.mjs +2 -0
  63. package/dist/validation/complex/file.d.mts +13 -0
  64. package/dist/validation/complex/file.d.ts +13 -0
  65. package/dist/validation/complex/file.js +11 -0
  66. package/dist/validation/complex/file.mjs +2 -0
  67. package/dist/validation/complex/location.d.mts +22 -0
  68. package/dist/validation/complex/location.d.ts +22 -0
  69. package/dist/validation/complex/location.js +11 -0
  70. package/dist/validation/complex/location.mjs +2 -0
  71. package/dist/validation/complex/phone.d.mts +22 -0
  72. package/dist/validation/complex/phone.d.ts +22 -0
  73. package/dist/validation/complex/phone.js +11 -0
  74. package/dist/validation/complex/phone.mjs +2 -0
  75. package/dist/validation/complex/relation.d.mts +25 -0
  76. package/dist/validation/complex/relation.d.ts +25 -0
  77. package/dist/validation/complex/relation.js +19 -0
  78. package/dist/validation/complex/relation.mjs +2 -0
  79. package/dist/validation/complex/richtext.d.mts +13 -0
  80. package/dist/validation/complex/richtext.d.ts +13 -0
  81. package/dist/validation/complex/richtext.js +11 -0
  82. package/dist/validation/complex/richtext.mjs +2 -0
  83. package/dist/validation/complex/select.d.mts +20 -0
  84. package/dist/validation/complex/select.d.ts +20 -0
  85. package/dist/validation/complex/select.js +19 -0
  86. package/dist/validation/complex/select.mjs +2 -0
  87. package/dist/validation/complex/user.d.mts +13 -0
  88. package/dist/validation/complex/user.d.ts +13 -0
  89. package/dist/validation/complex/user.js +11 -0
  90. package/dist/validation/complex/user.mjs +2 -0
  91. package/dist/validation/computed/formula.d.mts +14 -0
  92. package/dist/validation/computed/formula.d.ts +14 -0
  93. package/dist/validation/computed/formula.js +11 -0
  94. package/dist/validation/computed/formula.mjs +2 -0
  95. package/dist/validation/computed/rollup.d.mts +14 -0
  96. package/dist/validation/computed/rollup.d.ts +14 -0
  97. package/dist/validation/computed/rollup.js +11 -0
  98. package/dist/validation/computed/rollup.mjs +2 -0
  99. package/dist/validation/config/index.d.mts +20 -0
  100. package/dist/validation/config/index.d.ts +20 -0
  101. package/dist/validation/config/index.js +18 -0
  102. package/dist/validation/config/index.mjs +1 -0
  103. package/dist/validation/core/index.d.mts +19 -0
  104. package/dist/validation/core/index.d.ts +19 -0
  105. package/dist/validation/core/index.js +14 -0
  106. package/dist/validation/core/index.mjs +1 -0
  107. package/dist/validation/object/index.d.mts +31 -0
  108. package/dist/validation/object/index.d.ts +31 -0
  109. package/dist/validation/object/index.js +70 -0
  110. package/dist/validation/object/index.mjs +17 -0
  111. package/dist/validation/primitives/checkbox.d.mts +12 -0
  112. package/dist/validation/primitives/checkbox.d.ts +12 -0
  113. package/dist/validation/primitives/checkbox.js +11 -0
  114. package/dist/validation/primitives/checkbox.mjs +2 -0
  115. package/dist/validation/primitives/date.d.mts +12 -0
  116. package/dist/validation/primitives/date.d.ts +12 -0
  117. package/dist/validation/primitives/date.js +11 -0
  118. package/dist/validation/primitives/date.mjs +2 -0
  119. package/dist/validation/primitives/number.d.mts +12 -0
  120. package/dist/validation/primitives/number.d.ts +12 -0
  121. package/dist/validation/primitives/number.js +11 -0
  122. package/dist/validation/primitives/number.mjs +2 -0
  123. package/dist/validation/primitives/rating.d.mts +12 -0
  124. package/dist/validation/primitives/rating.d.ts +12 -0
  125. package/dist/validation/primitives/rating.js +11 -0
  126. package/dist/validation/primitives/rating.mjs +2 -0
  127. package/dist/validation/primitives/text.d.mts +17 -0
  128. package/dist/validation/primitives/text.d.ts +17 -0
  129. package/dist/validation/primitives/text.js +15 -0
  130. package/dist/validation/primitives/text.mjs +2 -0
  131. package/package.json +108 -13
  132. package/dist/chunk-36UBIXJN.js +0 -82
  133. package/dist/chunk-3RG5ZIWI.js +0 -10
  134. package/dist/chunk-A6T4UUZ2.mjs +0 -18669
  135. package/dist/chunk-NEVERCM3.js +0 -41
  136. package/dist/chunk-SV4BCGQU.mjs +0 -617
  137. package/dist/chunk-TOTUS3YS.js +0 -18669
  138. package/dist/chunk-U4AB53AM.js +0 -617
  139. package/dist/chunk-V2RPPE2Y.mjs +0 -41
  140. package/dist/chunk-V5QXU2OK.mjs +0 -82
  141. package/dist/chunk-Y6FXYEAI.mjs +0 -10
  142. package/dist/default-roles-42X3TJI5.mjs +0 -21
  143. package/dist/default-roles-C3FYDYMN.js +0 -21
  144. package/dist/runtime-BgtwoMx5.d.ts +0 -12759
  145. package/dist/runtime-DQlTgVZJ.d.mts +0 -12759
  146. package/dist/runtime.d.mts +0 -6
  147. package/dist/runtime.d.ts +0 -6
  148. package/dist/runtime.js +0 -323
  149. package/dist/runtime.mjs +0 -323
  150. package/dist/validation/validators.d.mts +0 -4
  151. package/dist/validation/validators.d.ts +0 -4
  152. package/dist/validation/validators.js +0 -121
  153. package/dist/validation/validators.mjs +0 -121
  154. package/dist/validators-BROsLGn4.d.mts +0 -1556
  155. package/dist/validators-CEzdvxEq.d.ts +0 -1556
@@ -1,1556 +0,0 @@
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
- /**
826
- * Validation messages for Zod validators.
827
- * All functions receive the full Attribute to access label, type, etc.
828
- * Can be customized for i18n support.
829
- */
830
- interface ValidationMessages {
831
- required: (attr: Attribute) => string;
832
- invalidType: (attr: Attribute, expected: string) => string;
833
- minLength: (attr: Attribute, min: number) => string;
834
- maxLength: (attr: Attribute, max: number) => string;
835
- invalidPattern: (attr: Attribute) => string;
836
- minValue: (attr: Attribute, min: number) => string;
837
- maxValue: (attr: Attribute, max: number) => string;
838
- mustBeInteger: (attr: Attribute) => string;
839
- invalidDate: (attr: Attribute) => string;
840
- invalidOption: (attr: Attribute, options: string[]) => string;
841
- invalidId: (attr: Attribute) => string;
842
- minItems: (attr: Attribute, min: number) => string;
843
- maxItems: (attr: Attribute, max: number) => string;
844
- invalidRichtext: (attr: Attribute) => string;
845
- invalidPhone: (attr: Attribute) => string;
846
- invalidCurrency: (attr: Attribute) => string;
847
- invalidLocation: (attr: Attribute) => string;
848
- }
849
- declare const DEFAULT_VALIDATION_MESSAGES: ValidationMessages;
850
- /**
851
- * Text attribute config schema
852
- */
853
- declare const textConfigSchema: z.ZodObject<{
854
- disabled: z.ZodOptional<z.ZodBoolean>;
855
- placeholder: z.ZodOptional<z.ZodString>;
856
- description: z.ZodOptional<z.ZodString>;
857
- defaultValue: z.ZodOptional<z.ZodUnknown>;
858
- icon: z.ZodOptional<z.ZodString>;
859
- order: z.ZodOptional<z.ZodNumber>;
860
- hidden: z.ZodOptional<z.ZodBoolean>;
861
- archived: z.ZodOptional<z.ZodBoolean>;
862
- deprecated: z.ZodOptional<z.ZodBoolean>;
863
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
864
- minLength: z.ZodOptional<z.ZodNumber>;
865
- maxLength: z.ZodOptional<z.ZodNumber>;
866
- pattern: z.ZodOptional<z.ZodString>;
867
- }, z.core.$strip>;
868
- /**
869
- * Textarea attribute config schema
870
- */
871
- declare const textareaConfigSchema: z.ZodObject<{
872
- disabled: z.ZodOptional<z.ZodBoolean>;
873
- placeholder: z.ZodOptional<z.ZodString>;
874
- description: z.ZodOptional<z.ZodString>;
875
- defaultValue: z.ZodOptional<z.ZodUnknown>;
876
- icon: z.ZodOptional<z.ZodString>;
877
- order: z.ZodOptional<z.ZodNumber>;
878
- hidden: z.ZodOptional<z.ZodBoolean>;
879
- archived: z.ZodOptional<z.ZodBoolean>;
880
- deprecated: z.ZodOptional<z.ZodBoolean>;
881
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
882
- }, z.core.$strip>;
883
- /**
884
- * Richtext attribute config schema
885
- */
886
- declare const richtextConfigSchema: z.ZodObject<{
887
- disabled: z.ZodOptional<z.ZodBoolean>;
888
- placeholder: z.ZodOptional<z.ZodString>;
889
- description: z.ZodOptional<z.ZodString>;
890
- defaultValue: z.ZodOptional<z.ZodUnknown>;
891
- icon: z.ZodOptional<z.ZodString>;
892
- order: z.ZodOptional<z.ZodNumber>;
893
- hidden: z.ZodOptional<z.ZodBoolean>;
894
- archived: z.ZodOptional<z.ZodBoolean>;
895
- deprecated: z.ZodOptional<z.ZodBoolean>;
896
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
897
- features: z.ZodOptional<z.ZodArray<z.ZodEnum<{
898
- headings: "headings";
899
- bold: "bold";
900
- italic: "italic";
901
- lists: "lists";
902
- links: "links";
903
- images: "images";
904
- codeBlocks: "codeBlocks";
905
- tables: "tables";
906
- }>>>;
907
- }, z.core.$strip>;
908
- /**
909
- * Number attribute config schema
910
- */
911
- declare const numberConfigSchema: z.ZodObject<{
912
- disabled: z.ZodOptional<z.ZodBoolean>;
913
- placeholder: z.ZodOptional<z.ZodString>;
914
- description: z.ZodOptional<z.ZodString>;
915
- defaultValue: z.ZodOptional<z.ZodUnknown>;
916
- icon: z.ZodOptional<z.ZodString>;
917
- order: z.ZodOptional<z.ZodNumber>;
918
- hidden: z.ZodOptional<z.ZodBoolean>;
919
- archived: z.ZodOptional<z.ZodBoolean>;
920
- deprecated: z.ZodOptional<z.ZodBoolean>;
921
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
922
- min: z.ZodOptional<z.ZodNumber>;
923
- max: z.ZodOptional<z.ZodNumber>;
924
- unit: z.ZodOptional<z.ZodEnum<{
925
- percentage: "percentage";
926
- integer: "integer";
927
- decimal: "decimal";
928
- }>>;
929
- decimals: z.ZodOptional<z.ZodNumber>;
930
- }, z.core.$strip>;
931
- /**
932
- * Checkbox attribute config schema
933
- */
934
- declare const checkboxConfigSchema: z.ZodObject<{
935
- disabled: z.ZodOptional<z.ZodBoolean>;
936
- placeholder: z.ZodOptional<z.ZodString>;
937
- description: z.ZodOptional<z.ZodString>;
938
- defaultValue: z.ZodOptional<z.ZodUnknown>;
939
- icon: z.ZodOptional<z.ZodString>;
940
- order: z.ZodOptional<z.ZodNumber>;
941
- hidden: z.ZodOptional<z.ZodBoolean>;
942
- archived: z.ZodOptional<z.ZodBoolean>;
943
- deprecated: z.ZodOptional<z.ZodBoolean>;
944
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
945
- }, z.core.$strip>;
946
- /**
947
- * Date attribute config schema
948
- */
949
- declare const dateConfigSchema: z.ZodObject<{
950
- disabled: z.ZodOptional<z.ZodBoolean>;
951
- placeholder: z.ZodOptional<z.ZodString>;
952
- description: z.ZodOptional<z.ZodString>;
953
- defaultValue: z.ZodOptional<z.ZodUnknown>;
954
- icon: z.ZodOptional<z.ZodString>;
955
- order: z.ZodOptional<z.ZodNumber>;
956
- hidden: z.ZodOptional<z.ZodBoolean>;
957
- archived: z.ZodOptional<z.ZodBoolean>;
958
- deprecated: z.ZodOptional<z.ZodBoolean>;
959
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
960
- dateFormat: z.ZodOptional<z.ZodEnum<{
961
- short: "short";
962
- long: "long";
963
- full: "full";
964
- relative: "relative";
965
- }>>;
966
- minDate: z.ZodOptional<z.ZodString>;
967
- maxDate: z.ZodOptional<z.ZodString>;
968
- }, z.core.$strip>;
969
- /**
970
- * Phone attribute config schema
971
- */
972
- declare const phoneConfigSchema: z.ZodObject<{
973
- disabled: z.ZodOptional<z.ZodBoolean>;
974
- placeholder: z.ZodOptional<z.ZodString>;
975
- description: z.ZodOptional<z.ZodString>;
976
- defaultValue: z.ZodOptional<z.ZodUnknown>;
977
- icon: z.ZodOptional<z.ZodString>;
978
- order: z.ZodOptional<z.ZodNumber>;
979
- hidden: z.ZodOptional<z.ZodBoolean>;
980
- archived: z.ZodOptional<z.ZodBoolean>;
981
- deprecated: z.ZodOptional<z.ZodBoolean>;
982
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
983
- defaultCountryCode: z.ZodOptional<z.ZodString>;
984
- }, z.core.$strip>;
985
- /**
986
- * Currency attribute config schema
987
- */
988
- declare const currencyConfigSchema: z.ZodObject<{
989
- disabled: z.ZodOptional<z.ZodBoolean>;
990
- placeholder: z.ZodOptional<z.ZodString>;
991
- description: z.ZodOptional<z.ZodString>;
992
- defaultValue: z.ZodOptional<z.ZodUnknown>;
993
- icon: z.ZodOptional<z.ZodString>;
994
- order: z.ZodOptional<z.ZodNumber>;
995
- hidden: z.ZodOptional<z.ZodBoolean>;
996
- archived: z.ZodOptional<z.ZodBoolean>;
997
- deprecated: z.ZodOptional<z.ZodBoolean>;
998
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
999
- defaultCurrency: z.ZodOptional<z.ZodString>;
1000
- allowedCurrencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
1001
- }, z.core.$strip>;
1002
- /**
1003
- * Status attribute config schema
1004
- */
1005
- declare const statusConfigSchema: z.ZodObject<{
1006
- disabled: z.ZodOptional<z.ZodBoolean>;
1007
- placeholder: z.ZodOptional<z.ZodString>;
1008
- description: z.ZodOptional<z.ZodString>;
1009
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1010
- icon: z.ZodOptional<z.ZodString>;
1011
- order: z.ZodOptional<z.ZodNumber>;
1012
- hidden: z.ZodOptional<z.ZodBoolean>;
1013
- archived: z.ZodOptional<z.ZodBoolean>;
1014
- deprecated: z.ZodOptional<z.ZodBoolean>;
1015
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1016
- options: z.ZodArray<z.ZodObject<{
1017
- id: z.ZodString;
1018
- label: z.ZodString;
1019
- value: z.ZodString;
1020
- color: z.ZodOptional<z.ZodString>;
1021
- icon: z.ZodOptional<z.ZodString>;
1022
- description: z.ZodOptional<z.ZodString>;
1023
- group: z.ZodOptional<z.ZodEnum<{
1024
- in_progress: "in_progress";
1025
- idle: "idle";
1026
- finished: "finished";
1027
- }>>;
1028
- }, z.core.$strip>>;
1029
- }, z.core.$strip>;
1030
- /**
1031
- * Location attribute config schema
1032
- */
1033
- declare const locationConfigSchema: z.ZodObject<{
1034
- disabled: z.ZodOptional<z.ZodBoolean>;
1035
- placeholder: z.ZodOptional<z.ZodString>;
1036
- description: z.ZodOptional<z.ZodString>;
1037
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1038
- icon: z.ZodOptional<z.ZodString>;
1039
- order: z.ZodOptional<z.ZodNumber>;
1040
- hidden: z.ZodOptional<z.ZodBoolean>;
1041
- archived: z.ZodOptional<z.ZodBoolean>;
1042
- deprecated: z.ZodOptional<z.ZodBoolean>;
1043
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1044
- granularity: z.ZodEnum<{
1045
- full: "full";
1046
- address: "address";
1047
- city: "city";
1048
- state: "state";
1049
- country: "country";
1050
- coordinates: "coordinates";
1051
- }>;
1052
- enableAutocomplete: z.ZodOptional<z.ZodBoolean>;
1053
- enableMap: z.ZodOptional<z.ZodBoolean>;
1054
- defaultCountry: z.ZodOptional<z.ZodString>;
1055
- allowedCountries: z.ZodOptional<z.ZodArray<z.ZodString>>;
1056
- displayFormat: z.ZodOptional<z.ZodEnum<{
1057
- single_line: "single_line";
1058
- multi_line: "multi_line";
1059
- compact: "compact";
1060
- }>>;
1061
- }, z.core.$strip>;
1062
- /**
1063
- * Select attribute config schema
1064
- */
1065
- declare const selectConfigSchema: z.ZodObject<{
1066
- disabled: z.ZodOptional<z.ZodBoolean>;
1067
- placeholder: z.ZodOptional<z.ZodString>;
1068
- description: z.ZodOptional<z.ZodString>;
1069
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1070
- icon: z.ZodOptional<z.ZodString>;
1071
- order: z.ZodOptional<z.ZodNumber>;
1072
- hidden: z.ZodOptional<z.ZodBoolean>;
1073
- archived: z.ZodOptional<z.ZodBoolean>;
1074
- deprecated: z.ZodOptional<z.ZodBoolean>;
1075
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1076
- options: z.ZodArray<z.ZodObject<{
1077
- id: z.ZodString;
1078
- label: z.ZodString;
1079
- value: z.ZodString;
1080
- color: z.ZodOptional<z.ZodString>;
1081
- icon: z.ZodOptional<z.ZodString>;
1082
- description: z.ZodOptional<z.ZodString>;
1083
- group: z.ZodOptional<z.ZodEnum<{
1084
- in_progress: "in_progress";
1085
- idle: "idle";
1086
- finished: "finished";
1087
- }>>;
1088
- }, z.core.$strip>>;
1089
- }, z.core.$strip>;
1090
- /**
1091
- * Multiselect attribute config schema
1092
- */
1093
- declare const multiselectConfigSchema: z.ZodObject<{
1094
- disabled: z.ZodOptional<z.ZodBoolean>;
1095
- placeholder: z.ZodOptional<z.ZodString>;
1096
- description: z.ZodOptional<z.ZodString>;
1097
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1098
- icon: z.ZodOptional<z.ZodString>;
1099
- order: z.ZodOptional<z.ZodNumber>;
1100
- hidden: z.ZodOptional<z.ZodBoolean>;
1101
- archived: z.ZodOptional<z.ZodBoolean>;
1102
- deprecated: z.ZodOptional<z.ZodBoolean>;
1103
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1104
- options: z.ZodArray<z.ZodObject<{
1105
- id: z.ZodString;
1106
- label: z.ZodString;
1107
- value: z.ZodString;
1108
- color: z.ZodOptional<z.ZodString>;
1109
- icon: z.ZodOptional<z.ZodString>;
1110
- description: z.ZodOptional<z.ZodString>;
1111
- group: z.ZodOptional<z.ZodEnum<{
1112
- in_progress: "in_progress";
1113
- idle: "idle";
1114
- finished: "finished";
1115
- }>>;
1116
- }, z.core.$strip>>;
1117
- }, z.core.$strip>;
1118
- /**
1119
- * File attribute config schema
1120
- */
1121
- declare const fileConfigSchema: z.ZodObject<{
1122
- disabled: z.ZodOptional<z.ZodBoolean>;
1123
- placeholder: z.ZodOptional<z.ZodString>;
1124
- description: z.ZodOptional<z.ZodString>;
1125
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1126
- icon: z.ZodOptional<z.ZodString>;
1127
- order: z.ZodOptional<z.ZodNumber>;
1128
- hidden: z.ZodOptional<z.ZodBoolean>;
1129
- archived: z.ZodOptional<z.ZodBoolean>;
1130
- deprecated: z.ZodOptional<z.ZodBoolean>;
1131
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1132
- maxFiles: z.ZodOptional<z.ZodNumber>;
1133
- maxSize: z.ZodOptional<z.ZodNumber>;
1134
- allowedTypes: z.ZodOptional<z.ZodArray<z.ZodString>>;
1135
- multiple: z.ZodOptional<z.ZodBoolean>;
1136
- }, z.core.$strip>;
1137
- /**
1138
- * User attribute config schema
1139
- */
1140
- declare const userConfigSchema: z.ZodObject<{
1141
- disabled: z.ZodOptional<z.ZodBoolean>;
1142
- placeholder: z.ZodOptional<z.ZodString>;
1143
- description: z.ZodOptional<z.ZodString>;
1144
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1145
- icon: z.ZodOptional<z.ZodString>;
1146
- order: z.ZodOptional<z.ZodNumber>;
1147
- hidden: z.ZodOptional<z.ZodBoolean>;
1148
- archived: z.ZodOptional<z.ZodBoolean>;
1149
- deprecated: z.ZodOptional<z.ZodBoolean>;
1150
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1151
- allowedRoles: z.ZodOptional<z.ZodArray<z.ZodString>>;
1152
- multiple: z.ZodOptional<z.ZodBoolean>;
1153
- }, z.core.$strip>;
1154
- /**
1155
- * Relation attribute config schema
1156
- */
1157
- declare const relationConfigSchema: z.ZodObject<{
1158
- disabled: z.ZodOptional<z.ZodBoolean>;
1159
- placeholder: z.ZodOptional<z.ZodString>;
1160
- description: z.ZodOptional<z.ZodString>;
1161
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1162
- icon: z.ZodOptional<z.ZodString>;
1163
- order: z.ZodOptional<z.ZodNumber>;
1164
- hidden: z.ZodOptional<z.ZodBoolean>;
1165
- archived: z.ZodOptional<z.ZodBoolean>;
1166
- deprecated: z.ZodOptional<z.ZodBoolean>;
1167
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1168
- targets: z.ZodArray<z.ZodObject<{
1169
- object: z.ZodString;
1170
- displayTemplate: z.ZodOptional<z.ZodString>;
1171
- filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1172
- }, z.core.$strip>>;
1173
- cardinality: z.ZodEnum<{
1174
- one: "one";
1175
- many: "many";
1176
- }>;
1177
- minItems: z.ZodOptional<z.ZodNumber>;
1178
- maxItems: z.ZodOptional<z.ZodNumber>;
1179
- }, z.core.$strip>;
1180
- /**
1181
- * Rating attribute config schema
1182
- */
1183
- declare const ratingConfigSchema: z.ZodObject<{
1184
- disabled: z.ZodOptional<z.ZodBoolean>;
1185
- placeholder: z.ZodOptional<z.ZodString>;
1186
- description: z.ZodOptional<z.ZodString>;
1187
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1188
- icon: z.ZodOptional<z.ZodString>;
1189
- order: z.ZodOptional<z.ZodNumber>;
1190
- hidden: z.ZodOptional<z.ZodBoolean>;
1191
- archived: z.ZodOptional<z.ZodBoolean>;
1192
- deprecated: z.ZodOptional<z.ZodBoolean>;
1193
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1194
- max: z.ZodOptional<z.ZodNumber>;
1195
- iconType: z.ZodOptional<z.ZodEnum<{
1196
- number: "number";
1197
- heart: "heart";
1198
- star: "star";
1199
- thumbs: "thumbs";
1200
- }>>;
1201
- }, z.core.$strip>;
1202
- /**
1203
- * Formula attribute config schema
1204
- */
1205
- declare const formulaConfigSchema: z.ZodObject<{
1206
- disabled: z.ZodOptional<z.ZodBoolean>;
1207
- placeholder: z.ZodOptional<z.ZodString>;
1208
- description: z.ZodOptional<z.ZodString>;
1209
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1210
- icon: z.ZodOptional<z.ZodString>;
1211
- order: z.ZodOptional<z.ZodNumber>;
1212
- hidden: z.ZodOptional<z.ZodBoolean>;
1213
- archived: z.ZodOptional<z.ZodBoolean>;
1214
- deprecated: z.ZodOptional<z.ZodBoolean>;
1215
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1216
- expression: z.ZodString;
1217
- returnType: z.ZodEnum<{
1218
- number: "number";
1219
- boolean: "boolean";
1220
- text: "text";
1221
- date: "date";
1222
- }>;
1223
- decimals: z.ZodOptional<z.ZodNumber>;
1224
- allowRelations: z.ZodOptional<z.ZodBoolean>;
1225
- }, z.core.$strip>;
1226
- /**
1227
- * Rollup attribute config schema
1228
- */
1229
- declare const rollupConfigSchema: z.ZodObject<{
1230
- disabled: z.ZodOptional<z.ZodBoolean>;
1231
- placeholder: z.ZodOptional<z.ZodString>;
1232
- description: z.ZodOptional<z.ZodString>;
1233
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1234
- icon: z.ZodOptional<z.ZodString>;
1235
- order: z.ZodOptional<z.ZodNumber>;
1236
- hidden: z.ZodOptional<z.ZodBoolean>;
1237
- archived: z.ZodOptional<z.ZodBoolean>;
1238
- deprecated: z.ZodOptional<z.ZodBoolean>;
1239
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1240
- relationAttribute: z.ZodOptional<z.ZodString>;
1241
- relationPath: z.ZodOptional<z.ZodString>;
1242
- targetAttribute: z.ZodString;
1243
- function: z.ZodEnum<{
1244
- sum: "sum";
1245
- avg: "avg";
1246
- earliest: "earliest";
1247
- latest: "latest";
1248
- count: "count";
1249
- countValues: "countValues";
1250
- countUniqueValues: "countUniqueValues";
1251
- countEmpty: "countEmpty";
1252
- percentEmpty: "percentEmpty";
1253
- percentNotEmpty: "percentNotEmpty";
1254
- original: "original";
1255
- }>;
1256
- decimals: z.ZodOptional<z.ZodNumber>;
1257
- targetAttributeType: z.ZodOptional<z.ZodString>;
1258
- targetAttributeOptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
1259
- id: z.ZodString;
1260
- label: z.ZodString;
1261
- value: z.ZodString;
1262
- color: z.ZodOptional<z.ZodString>;
1263
- icon: z.ZodOptional<z.ZodString>;
1264
- description: z.ZodOptional<z.ZodString>;
1265
- group: z.ZodOptional<z.ZodEnum<{
1266
- in_progress: "in_progress";
1267
- idle: "idle";
1268
- finished: "finished";
1269
- }>>;
1270
- }, z.core.$strip>>>;
1271
- }, z.core.$strip>;
1272
- /**
1273
- * Document attribute config schema
1274
- */
1275
- declare const documentConfigSchema: z.ZodObject<{
1276
- disabled: z.ZodOptional<z.ZodBoolean>;
1277
- placeholder: z.ZodOptional<z.ZodString>;
1278
- description: z.ZodOptional<z.ZodString>;
1279
- defaultValue: z.ZodOptional<z.ZodUnknown>;
1280
- icon: z.ZodOptional<z.ZodString>;
1281
- order: z.ZodOptional<z.ZodNumber>;
1282
- hidden: z.ZodOptional<z.ZodBoolean>;
1283
- archived: z.ZodOptional<z.ZodBoolean>;
1284
- deprecated: z.ZodOptional<z.ZodBoolean>;
1285
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1286
- templateId: z.ZodOptional<z.ZodString>;
1287
- allowedTemplates: z.ZodOptional<z.ZodArray<z.ZodString>>;
1288
- multiple: z.ZodOptional<z.ZodBoolean>;
1289
- maxDocuments: z.ZodOptional<z.ZodNumber>;
1290
- autoProcess: z.ZodOptional<z.ZodBoolean>;
1291
- }, z.core.$strip>;
1292
- /**
1293
- * Map of attribute type to config schema
1294
- */
1295
- declare const attributeConfigSchemas: Record<AttributeType, z.ZodObject<z.ZodRawShape>>;
1296
- /**
1297
- * Get the config schema for a specific attribute type
1298
- */
1299
- declare function getAttributeConfigSchema(type: AttributeType): z.ZodObject<z.ZodRawShape>;
1300
- /**
1301
- * Validate attribute config for a specific type
1302
- * Returns the validated config with only allowed properties
1303
- */
1304
- declare function validateAttributeConfig(type: AttributeType, config: Record<string, unknown>): {
1305
- success: true;
1306
- data: Record<string, unknown>;
1307
- } | {
1308
- success: false;
1309
- errors: string[];
1310
- };
1311
- /**
1312
- * Validate and strip unknown properties from attribute config
1313
- * This ensures only allowed properties are stored in the database
1314
- */
1315
- declare function parseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown>;
1316
- /**
1317
- * Safely parse attribute config, returning undefined for invalid configs
1318
- */
1319
- declare function safeParseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown> | undefined;
1320
- /**
1321
- * Create a Zod schema for a text attribute
1322
- */
1323
- declare function createTextValidator(attr: TextAttribute, messages?: ValidationMessages): z.ZodString;
1324
- /**
1325
- * Create a Zod schema for a number attribute
1326
- */
1327
- declare function createNumberValidator(attr: NumberAttribute, messages?: ValidationMessages): z.ZodNumber;
1328
- /**
1329
- * Create a Zod schema for a checkbox attribute
1330
- */
1331
- declare function createCheckboxValidator(_attr: CheckboxAttribute, _messages?: ValidationMessages): z.ZodBoolean;
1332
- /**
1333
- * Create a Zod schema for a date attribute
1334
- */
1335
- declare function createDateValidator(attr: DateAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1336
- /**
1337
- * Create a Zod schema for a phone attribute
1338
- */
1339
- declare function createPhoneValidator(attr: PhoneAttribute, messages?: ValidationMessages): z.ZodType<{
1340
- countryCode: string;
1341
- phoneNumber: string;
1342
- }>;
1343
- /**
1344
- * Create a Zod schema for a currency attribute
1345
- */
1346
- declare function createCurrencyValidator(attr: CurrencyAttribute, messages?: ValidationMessages): z.ZodType<{
1347
- code: string;
1348
- value: number;
1349
- }>;
1350
- /**
1351
- * Create a Zod schema for a status attribute
1352
- */
1353
- declare function createStatusValidator(attr: StatusAttribute, messages?: ValidationMessages): z.ZodEnum<Readonly<Record<string, string>>>;
1354
- /**
1355
- * Create a Zod schema for a select attribute
1356
- */
1357
- declare function createSelectValidator(attr: SelectAttribute, messages?: ValidationMessages): z.ZodEnum<Readonly<Record<string, string>>>;
1358
- /**
1359
- * Create a Zod schema for a multiselect attribute
1360
- */
1361
- declare function createMultiselectValidator(attr: MultiselectAttribute, messages?: ValidationMessages): z.ZodArray<z.ZodEnum<Readonly<Record<string, string>>>>;
1362
- /**
1363
- * Create a Zod schema for a location attribute
1364
- */
1365
- type LocationShape = {
1366
- address?: string;
1367
- address2?: string;
1368
- city?: string;
1369
- state?: string;
1370
- postalCode?: string;
1371
- country?: string;
1372
- latitude?: number;
1373
- longitude?: number;
1374
- };
1375
- declare function createLocationValidator(attr: LocationAttribute, messages?: ValidationMessages): z.ZodType<LocationShape>;
1376
- /**
1377
- * Create a Zod schema for a file attribute
1378
- * Supports both single file (UUID) and multiple files (array of UUIDs)
1379
- */
1380
- declare function createFileValidator(attr: FileAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1381
- /**
1382
- * Create a Zod schema for a user attribute
1383
- * Supports both single user (UUID) and multiple users (array of UUIDs)
1384
- */
1385
- declare function createUserValidator(attr: UserAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1386
- /**
1387
- * Create a Zod schema for a single relation attribute (cardinality: "one")
1388
- */
1389
- declare function createSingleRelationValidator(attr: SingleRelationAttribute, messages?: ValidationMessages): z.ZodUnion<[z.ZodUUID, z.ZodNull]>;
1390
- /**
1391
- * Create a Zod schema for a multi relation attribute (cardinality: "many")
1392
- */
1393
- declare function createMultiRelationValidator(attr: MultiRelationAttribute, messages?: ValidationMessages): z.ZodArray<z.ZodUUID>;
1394
- /**
1395
- * Create a Zod schema for a relation attribute
1396
- * Dispatches to single or multi validator based on cardinality
1397
- */
1398
- declare function createRelationValidator(attr: RelationAttribute, messages?: ValidationMessages): z.ZodUnion<[z.ZodUUID, z.ZodNull]> | z.ZodArray<z.ZodUUID>;
1399
- /**
1400
- * Create a Zod schema for a rating attribute
1401
- */
1402
- declare function createRatingValidator(attr: RatingAttribute, messages?: ValidationMessages): z.ZodNumber;
1403
- /**
1404
- * Create a Zod schema for a formula attribute.
1405
- * Formula attributes are read-only (computed at runtime).
1406
- * They accept any value during validation but are ignored during record creation/update.
1407
- */
1408
- declare function createFormulaValidator(_attr: FormulaAttribute, _messages?: ValidationMessages): z.ZodUnknown;
1409
- /**
1410
- * Create a Zod schema for a rollup attribute.
1411
- * Rollup attributes are read-only (computed from related records).
1412
- * They accept any value during validation but are ignored during record creation/update.
1413
- */
1414
- declare function createRollupValidator(_attr: RollupAttribute, _messages?: ValidationMessages): z.ZodUnknown;
1415
- /**
1416
- * Create a Zod schema for a textarea attribute.
1417
- * Validates that the value is a string.
1418
- */
1419
- declare function createTextAreaValidator(_attr: TextAreaAttribute, _messages?: ValidationMessages): z.ZodString;
1420
- /**
1421
- * Create a Zod schema for a richtext attribute.
1422
- * Validates semantic markdown content as a string.
1423
- *
1424
- * @example Valid richtext content (semantic markdown)
1425
- * ```typescript
1426
- * `# Heading
1427
- *
1428
- * Some paragraph text.
1429
- *
1430
- * :::callout{variant="info"}
1431
- * This is a callout block
1432
- * :::
1433
- * `
1434
- * ```
1435
- */
1436
- declare function createRichtextValidator(attr: RichtextAttribute, messages?: ValidationMessages): z.ZodTypeAny;
1437
- /**
1438
- * Create a Zod schema for any attribute type.
1439
- * Returns a strict validator that does NOT handle optional fields.
1440
- * Use createFormAttributeValidator for form validation with optional support.
1441
- *
1442
- * @param attr - The attribute to create a validator for
1443
- * @param messages - Custom validation messages for i18n support
1444
- */
1445
- declare function createAttributeValidator(attr: Attribute, messages?: ValidationMessages): z.ZodTypeAny;
1446
- /**
1447
- * Create a Zod schema for form validation.
1448
- * - Normalizes empty values (empty strings, empty objects) to null for optional fields
1449
- * - Accepts custom messages for i18n support
1450
- *
1451
- * Use this in UI forms where optional fields may have null/undefined values.
1452
- *
1453
- * @param attr - The attribute to create a validator for
1454
- * @param messages - Custom validation messages for i18n support
1455
- */
1456
- declare function createFormAttributeValidator(attr: Attribute, messages?: ValidationMessages): z.ZodTypeAny;
1457
- /**
1458
- * Create a Zod schema for an entire object
1459
- *
1460
- * Uses passthrough mode to allow computed fields (formula, rollup) that may be
1461
- * present in record data but are not part of the mutable schema.
1462
- */
1463
- declare function createObjectValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
1464
- /**
1465
- * Validation result
1466
- */
1467
- interface ValidationResult {
1468
- success: boolean;
1469
- data?: Record<string, unknown>;
1470
- errors?: Array<{
1471
- path: string[];
1472
- message: string;
1473
- }>;
1474
- }
1475
- /**
1476
- * Validate data against an attribute schema
1477
- */
1478
- declare function validateAttribute(attr: Attribute, value: unknown): ValidationResult;
1479
- /**
1480
- * Validate data against an object schema
1481
- */
1482
- declare function validateObject(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
1483
- /**
1484
- * Validate and throw if invalid
1485
- */
1486
- declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
1487
- /**
1488
- * Create a Zod schema for draft validation.
1489
- * All attributes become optional, but provided values are still validated.
1490
- *
1491
- * Uses passthrough mode to allow computed fields (formula, rollup) that may be
1492
- * present in record data but are not part of the mutable schema.
1493
- */
1494
- declare function createDraftValidator(objectDef: ObjectDefinition): z.ZodType<Record<string, unknown>>;
1495
- /**
1496
- * Validate data in draft mode.
1497
- * - All attributes are treated as optional (no required validation)
1498
- * - Provided values are still validated for format/type correctness
1499
- *
1500
- * Use this when creating records that may be incomplete (drafts).
1501
- *
1502
- * @example
1503
- * ```typescript
1504
- * const result = validateDraft(PRODUCT, { name: "Draft" });
1505
- * // → success even if "price" is required but missing
1506
- *
1507
- * const result2 = validateDraft(PRODUCT, { price: -10 });
1508
- * // → fails because price must be >= 0 (format validation still applies)
1509
- * ```
1510
- */
1511
- declare function validateDraft(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
1512
- /**
1513
- * Validate draft data and throw if format validation fails.
1514
- */
1515
- declare function validateDraftOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
1516
- /**
1517
- * Get the list of required attributes that are missing values.
1518
- *
1519
- * @example
1520
- * ```typescript
1521
- * const missing = getMissingRequiredAttributes(PRODUCT, { name: "Test" });
1522
- * // → [priceAttribute, statusAttribute] if price and status are required but missing
1523
- * ```
1524
- */
1525
- declare function getMissingRequiredAttributes(objectDef: ObjectDefinition, data: Record<string, unknown>): Attribute[];
1526
- /**
1527
- * Check if a record is complete (all required attributes have valid values).
1528
- *
1529
- * @returns `true` if all required values are present and valid, `false` otherwise
1530
- */
1531
- declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<string, unknown>): boolean;
1532
- /**
1533
- * Compute the completion status of a record based on its data.
1534
- *
1535
- * - `"complete"`: All required values are present and valid
1536
- * - `"draft"`: One or more required values are missing or invalid
1537
- *
1538
- * This function is used to dynamically determine the status when
1539
- * creating or updating records.
1540
- *
1541
- * @example
1542
- * ```typescript
1543
- * const status = computeRecordStatus(PRODUCT, {
1544
- * name: "Nike Air Max",
1545
- * price: 129.99,
1546
- * status: "active"
1547
- * });
1548
- * // → "complete"
1549
- *
1550
- * const status2 = computeRecordStatus(PRODUCT, { name: "Draft Product" });
1551
- * // → "draft" (missing required fields)
1552
- * ```
1553
- */
1554
- declare function computeRecordStatus(objectDef: ObjectDefinition, data: Record<string, unknown>): CompletionStatus;
1555
-
1556
- export { RESERVED_ATTRIBUTE_NAMES as $, type Attribute as A, type BilateralConfig as B, type CheckboxAttribute as C, type DateAttribute as D, type NumberUnit as E, type FeatureGate as F, type DateFormat as G, type DateValue as H, type Phone 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 PhoneAttribute 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 CurrencyAttribute as d, type SelectAttribute as e, type FileAttribute as f, type RatingAttribute as g, type RelationAttribute as h, type SingleRelationAttribute as i, type MultiRelationAttribute as j, type RelationTarget as k, type FormulaAttribute as l, type FormulaReturnType as m, type RollupAttribute as n, type RollupFunction as o, type AttributeType as p, type ObjectDefinition as q, type FlagValueType as r, type FeatureFlagDefinition as s, type FlagLevel as t, type FeatureFlagsRepository as u, type StaticFlagDefault as v, type ResolvedFlag as w, type StatusGroup as x, type AttributeGroup as y, type BaseAttribute as z };