@stndrds/schema 0.1.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/chunk-3ABIOLKO.mjs +4624 -0
  2. package/dist/chunk-3IRX2BDY.mjs +3970 -0
  3. package/dist/chunk-4OTLPWSP.mjs +4448 -0
  4. package/dist/chunk-54ODQBUN.mjs +3867 -0
  5. package/dist/chunk-6HIA3FR2.mjs +4230 -0
  6. package/dist/chunk-6P3XHNLD.mjs +4171 -0
  7. package/dist/chunk-7LJECNAS.mjs +4167 -0
  8. package/dist/chunk-A2WNLUKV.mjs +4475 -0
  9. package/dist/chunk-AA3234RM.mjs +4475 -0
  10. package/dist/chunk-ADNXDLLD.mjs +3136 -0
  11. package/dist/chunk-B4DCDQUI.mjs +4695 -0
  12. package/dist/chunk-B4PSXY6I.mjs +4527 -0
  13. package/dist/chunk-BJHJBZCM.mjs +4228 -0
  14. package/dist/chunk-C3ZWTO6G.mjs +4474 -0
  15. package/dist/chunk-CLOGNKDD.mjs +4040 -0
  16. package/dist/chunk-EW4V63PA.mjs +3053 -0
  17. package/dist/chunk-FR2LCO6R.mjs +2485 -0
  18. package/dist/chunk-GJSF2RKL.mjs +2786 -0
  19. package/dist/chunk-GO5NPP2X.mjs +4726 -0
  20. package/dist/chunk-H3ZYJUDS.mjs +3050 -0
  21. package/dist/chunk-IDDLSFSK.mjs +4230 -0
  22. package/dist/chunk-JRADUJQ7.mjs +4726 -0
  23. package/dist/chunk-NEDR6N7R.mjs +3118 -0
  24. package/dist/chunk-NESPRMDF.mjs +2482 -0
  25. package/dist/chunk-NWFGRJBW.mjs +4612 -0
  26. package/dist/chunk-NXJ57GSN.mjs +2918 -0
  27. package/dist/chunk-O4C5FCTS.mjs +3961 -0
  28. package/dist/chunk-O4PRB27Q.mjs +2513 -0
  29. package/dist/chunk-OJDFNUCR.mjs +4463 -0
  30. package/dist/chunk-OSEKVBHC.mjs +4627 -0
  31. package/dist/chunk-QX4U6U6K.mjs +2484 -0
  32. package/dist/chunk-RMDQ6LKV.mjs +3046 -0
  33. package/dist/chunk-SBXKDATH.mjs +2673 -0
  34. package/dist/chunk-SKMP3AP3.mjs +2918 -0
  35. package/dist/chunk-STMS7WZD.mjs +2623 -0
  36. package/dist/chunk-T3T6PTFG.mjs +3057 -0
  37. package/dist/chunk-TPW72RAH.mjs +4624 -0
  38. package/dist/chunk-TUQEGNGV.mjs +2534 -0
  39. package/dist/chunk-TVKFS3YN.mjs +2449 -0
  40. package/dist/chunk-TZTH3BHG.mjs +3110 -0
  41. package/dist/chunk-W6MU3XPG.mjs +4612 -0
  42. package/dist/chunk-WL7Z3YFR.mjs +4603 -0
  43. package/dist/chunk-XNVVYHH3.mjs +4602 -0
  44. package/dist/chunk-XTA3WY64.mjs +2918 -0
  45. package/dist/chunk-YV7DEZFZ.mjs +2528 -0
  46. package/dist/chunk-ZLJPJND6.mjs +4474 -0
  47. package/dist/chunk-ZNZXTCEX.mjs +4234 -0
  48. package/dist/index.d.mts +1222 -0
  49. package/dist/index.d.ts +1222 -0
  50. package/dist/index.js +5320 -0
  51. package/dist/index.mjs +635 -0
  52. package/dist/runtime-2iKarXtl.d.mts +1924 -0
  53. package/dist/runtime-2iKarXtl.d.ts +1924 -0
  54. package/dist/runtime-4l2ddHZ7.d.mts +2242 -0
  55. package/dist/runtime-4l2ddHZ7.d.ts +2243 -0
  56. package/dist/runtime-8hKS6zAv.d.mts +2226 -0
  57. package/dist/runtime-8hKS6zAv.d.ts +2226 -0
  58. package/dist/runtime-B6yjtoR3.d.mts +4142 -0
  59. package/dist/runtime-B6yjtoR3.d.ts +4142 -0
  60. package/dist/runtime-BGCShrZB.d.mts +2001 -0
  61. package/dist/runtime-BGCShrZB.d.ts +2001 -0
  62. package/dist/runtime-BRW4NGAk.d.mts +1668 -0
  63. package/dist/runtime-BRW4NGAk.d.ts +1668 -0
  64. package/dist/runtime-BnfBr314.d.mts +1683 -0
  65. package/dist/runtime-BnfBr314.d.ts +1683 -0
  66. package/dist/runtime-BrqhiJUF.d.mts +4151 -0
  67. package/dist/runtime-BrqhiJUF.d.ts +4151 -0
  68. package/dist/runtime-Bvj8c-BE.d.mts +4277 -0
  69. package/dist/runtime-Bvj8c-BE.d.ts +4277 -0
  70. package/dist/runtime-C03qT4qU.d.mts +4267 -0
  71. package/dist/runtime-C03qT4qU.d.ts +4267 -0
  72. package/dist/runtime-CaCZ7mSf.d.mts +2974 -0
  73. package/dist/runtime-CaCZ7mSf.d.ts +2974 -0
  74. package/dist/runtime-CaIzNX0Z.d.mts +4091 -0
  75. package/dist/runtime-CaIzNX0Z.d.ts +4091 -0
  76. package/dist/runtime-ChPTgmLP.d.mts +4320 -0
  77. package/dist/runtime-ChPTgmLP.d.ts +4320 -0
  78. package/dist/runtime-CnImZ1Vv.d.mts +4267 -0
  79. package/dist/runtime-CnImZ1Vv.d.ts +4267 -0
  80. package/dist/runtime-Cp-B26Nj.d.mts +2890 -0
  81. package/dist/runtime-Cp-B26Nj.d.ts +2890 -0
  82. package/dist/runtime-Cq8jfk3c.d.mts +4277 -0
  83. package/dist/runtime-Cq8jfk3c.d.ts +4277 -0
  84. package/dist/runtime-CqDFXhhP.d.mts +1685 -0
  85. package/dist/runtime-CqDFXhhP.d.ts +1685 -0
  86. package/dist/runtime-CqtpZLdL.d.mts +4280 -0
  87. package/dist/runtime-CqtpZLdL.d.ts +4280 -0
  88. package/dist/runtime-D-4DblaZ.d.mts +4147 -0
  89. package/dist/runtime-D-4DblaZ.d.ts +4147 -0
  90. package/dist/runtime-D59sSqNl.d.mts +4146 -0
  91. package/dist/runtime-D59sSqNl.d.ts +4146 -0
  92. package/dist/runtime-DEfPk3wT.d.mts +1840 -0
  93. package/dist/runtime-DEfPk3wT.d.ts +1840 -0
  94. package/dist/runtime-DGV-7vES.d.mts +1685 -0
  95. package/dist/runtime-DGV-7vES.d.ts +1685 -0
  96. package/dist/runtime-DNacghqc.d.mts +3971 -0
  97. package/dist/runtime-DNacghqc.d.ts +3971 -0
  98. package/dist/runtime-DPLsUHYK.d.mts +3977 -0
  99. package/dist/runtime-DPLsUHYK.d.ts +3977 -0
  100. package/dist/runtime-DTxCw60F.d.mts +2973 -0
  101. package/dist/runtime-DTxCw60F.d.ts +2973 -0
  102. package/dist/runtime-DUXJ-zNS.d.mts +2788 -0
  103. package/dist/runtime-DUXJ-zNS.d.ts +2788 -0
  104. package/dist/runtime-DbljInhV.d.mts +2237 -0
  105. package/dist/runtime-DbljInhV.d.ts +2237 -0
  106. package/dist/runtime-DcH3y6Yu.d.mts +4272 -0
  107. package/dist/runtime-DcH3y6Yu.d.ts +4272 -0
  108. package/dist/runtime-DdBFz85g.d.mts +4229 -0
  109. package/dist/runtime-DdBFz85g.d.ts +4229 -0
  110. package/dist/runtime-DjMWhjkm.d.mts +4321 -0
  111. package/dist/runtime-DjMWhjkm.d.ts +4321 -0
  112. package/dist/runtime-Djz3fOBE.d.mts +2078 -0
  113. package/dist/runtime-Djz3fOBE.d.ts +2078 -0
  114. package/dist/runtime-Dli8g3Aq.d.mts +2082 -0
  115. package/dist/runtime-Dli8g3Aq.d.ts +2082 -0
  116. package/dist/runtime-a8J378im.d.mts +4123 -0
  117. package/dist/runtime-a8J378im.d.ts +4123 -0
  118. package/dist/runtime-dp3rb3Lf.d.mts +2968 -0
  119. package/dist/runtime-dp3rb3Lf.d.ts +2968 -0
  120. package/dist/runtime-iWXlSN_H.d.mts +1683 -0
  121. package/dist/runtime-iWXlSN_H.d.ts +1683 -0
  122. package/dist/runtime-yMql0npY.d.mts +4321 -0
  123. package/dist/runtime-yMql0npY.d.ts +4321 -0
  124. package/dist/runtime.d.mts +3 -0
  125. package/dist/runtime.d.ts +3 -0
  126. package/dist/runtime.js +3626 -0
  127. package/dist/runtime.mjs +48 -0
  128. package/package.json +58 -0
@@ -0,0 +1,1222 @@
1
+ import { A as Attribute, S as StatusAttribute, a as SelectAttribute, M as MultiselectAttribute, P as Phone, C as Currency, L as Location, T as TextAttribute, b as TextAreaAttribute, N as NumberAttribute, c as CheckboxAttribute, D as DateAttribute, d as PhoneAttribute, e as CurrencyAttribute, O as Option, f as LocationAttribute, g as TimestampAttribute, F as FileAttribute, U as UserAttribute, h as SingleRelationAttribute, R as RelationOnDelete, i as MultiRelationAttribute, j as RelationTarget, k as RatingAttribute, l as ObjectDefinition, m as Field, n as AttributeGroupField, G as Group, V as ViewDefinition, o as Tab } from './runtime-yMql0npY.js';
2
+ export { bS as AddAttributeInput, aa as AdvancedFilterState, bA as AttributeChange, r as AttributeGroup, p as AttributeType, bJ as AttributesRepository, B as BaseAttribute, Y as CheckboxFilterOperator, at as CompletionStatus, bR as CreateCustomObjectInput, cm as CreateDBAttribute, ci as CreateDBObject, cw as CreateDBView, K as CreateFile, cp as CreateObjectRecord, ay as CreateUserProfile, c2 as CreateViewInput, a3 as CurrencyFilterValue, aD as CustomTab, cl as DBAttribute, ch as DBObject, cv as DBView, cd as DEFAULT_LABEL_FALLBACK, bz as DatabaseAdapter, Z as DateFilterOperator, t as DateFormat, u as DateValue, x as DocumentFace, w as DocumentType, y as DocumentTypeConfig, J as File, cu as FileListOptions, bO as FileService, z as FileVerificationConfig, I as FileVisibility, bL as FilesRepository, a7 as FilterCombinator, a9 as FilterGroup, a1 as FilterOperator, a6 as FilterRule, a8 as FilterState, a5 as FilterValue, aB as FormTab, cb as FullSyncOptions, ca as FullSyncResult, ap as GeocodingAdapter, am as GeocodingAutocompleteParams, ao as GeocodingParams, bP as GeocodingService, al as GeocodingSuggestion, b$ as GetRelationOptionsParams, cs as GlobalSearchOptions, ct as GlobalSearchResultItem, bQ as GlobalSearchService, bB as HookContext, bC as HookDefinition, bD as HookHandler, bG as HookRegistry, bE as HookType, cq as ListOptions, v as LocationGranularity, $ as MultiselectFilterOperator, aj as NO_VALUE_OPERATORS, ai as NoValueOperator, aq as NoopGeocodingAdapter, bF as NoopHookRegistry, X as NumberFilterOperator, s as NumberUnit, ah as OPERATORS_BY_TYPE, as as ObjectAttribute, au as ObjectRecord, bM as ObjectRecordsRepository, bU as ObjectSchemaService, bI as ObjectsRepository, cz as OperationResult, a4 as PhoneFilterValue, ag as QueryState, bW as RecordService, bV as RecordServiceOptions, E as RelationAttribute, a0 as RelationFilterOperator, bZ as RelationOption, b_ as RelationOptionsResponse, c0 as RelationService, bY as RelationValidationError, bX as RelationValidationResult, a2 as RelativeDateValue, an as ReverseGeocodingParams, cr as SearchOptions, _ as SelectFilterOperator, ae as SortDirection, af as SortRule, q as StatusGroup, H as StorageProvider, c6 as SyncOptions, c5 as SyncResult, aA as TabType, aC as TableTab, aI as TenantId, W as TextFilterOperator, ar as Timestamps, cn as UpdateDBAttribute, cj as UpdateDBObject, cx as UpdateDBView, Q as UpdateFile, bT as UpdateObjectInput, az as UpdateUserProfile, c3 as UpdateViewInput, co as UpsertDBAttribute, ck as UpsertDBObject, cy as UpsertDBView, ax as UserProfile, c1 as UserProfileService, bK as UserProfilesRepository, av as UserRole, aw as UserStatus, aH as Uuid, bp as ValidationResult, c4 as ViewService, cB as ViewSyncOptions, cA as ViewSyncResult, bN as ViewsRepository, b1 as attributeConfigSchemas, aQ as checkboxConfigSchema, by as computeRecordStatus, bn as createAttributeValidator, b8 as createCheckboxValidator, bb as createCurrencyValidator, b9 as createDateValidator, bt as createDraftValidator, bh as createFileValidator, bf as createLocationValidator, bH as createMockAdapter, bk as createMultiRelationValidator, be as createMultiselectValidator, b7 as createNumberValidator, bo as createObjectValidator, ba as createPhoneValidator, bm as createRatingValidator, bl as createRelationValidator, bd as createSelectValidator, bj as createSingleRelationValidator, bc as createStatusValidator, b6 as createTextValidator, bg as createTimestampValidator, bi as createUserValidator, aT as currencyConfigSchema, aR as dateConfigSchema, cg as extractAttributeNames, aZ as fileConfigSchema, aJ as generateId, aK as generatePrefixedId, b2 as getAttributeConfigSchema, bw as getMissingRequiredAttributes, c9 as getSyncPreview, cE as getViewSyncPreview, ab as isAdvancedFilterState, aG as isCustomTab, aE as isFormTab, cf as isLabelExpression, ak as isNoValueOperator, bx as isRecordComplete, aF as isTableTab, aV as locationConfigSchema, aY as multiselectConfigSchema, aP as numberConfigSchema, b4 as parseAttributeConfig, aS as phoneConfigSchema, b0 as ratingConfigSchema, aL as registry, a$ as relationConfigSchema, ce as renderLabelExpression, b5 as safeParseAttributeConfig, aX as selectConfigSchema, aU as statusConfigSchema, cc as syncAll, c7 as syncNativeObjects, cC as syncNativeViews, aN as textConfigSchema, aO as textareaConfigSchema, aW as timestampConfigSchema, ac as toAdvancedFilterState, ad as toSimpleFilterState, a_ as userConfigSchema, bq as validateAttribute, b3 as validateAttributeConfig, bu as validateDraft, bv as validateDraftOrThrow, br as validateObject, bs as validateObjectOrThrow, c8 as verifyNativeObjectsSync, cD as verifyNativeViewsSync, aM as viewRegistry } from './runtime-yMql0npY.js';
3
+ import { IconName, CountryIso3, CurrencyCode, MimeType } from '@stndrds/constants';
4
+ import 'zod';
5
+
6
+ /**
7
+ * Common configuration for all builders (Objects & Attributes)
8
+ */
9
+ interface BuilderConfig {
10
+ /**
11
+ * Technical name (snake_case, kebab-case, camelCase)
12
+ * Used as identifier in database and API
13
+ */
14
+ name: string;
15
+ /**
16
+ * Human-readable label
17
+ * Used in UI
18
+ */
19
+ label: string;
20
+ }
21
+
22
+ /**
23
+ * Lookup table for primitive attribute types
24
+ * Maps attribute type name to its runtime value type
25
+ */
26
+ type AttributeValueMap = {
27
+ text: string;
28
+ textarea: string;
29
+ number: number;
30
+ checkbox: boolean;
31
+ date: string;
32
+ phone: Phone;
33
+ currency: Currency;
34
+ location: Location;
35
+ timestamp: number;
36
+ file: string;
37
+ user: string;
38
+ relation: string;
39
+ rating: number;
40
+ };
41
+ /**
42
+ * Infer status value from options (union of option values)
43
+ */
44
+ type InferStatusValue<A extends StatusAttribute> = A["options"] extends readonly {
45
+ value: infer V;
46
+ }[] ? V : string;
47
+ /**
48
+ * Infer select value from options (union of option values)
49
+ */
50
+ type InferSelectValue<A extends SelectAttribute> = A["options"] extends readonly {
51
+ value: infer V;
52
+ }[] ? V : string;
53
+ /**
54
+ * Infer multiselect value from options (array of option values)
55
+ */
56
+ type InferMultiselectValue<A extends MultiselectAttribute> = A["options"] extends readonly {
57
+ value: infer V;
58
+ }[] ? V[] : string[];
59
+ /**
60
+ * Maps an Attribute type to its runtime value type
61
+ * Uses a flat lookup table + 3 special cases for option-based attributes
62
+ * This avoids deep conditional nesting that causes TS2589 on large objects
63
+ */
64
+ type InferAttributeValue<A extends Attribute> = A extends StatusAttribute ? InferStatusValue<A> : A extends SelectAttribute ? InferSelectValue<A> : A extends MultiselectAttribute ? InferMultiselectValue<A> : A["type"] extends keyof AttributeValueMap ? AttributeValueMap[A["type"]] : unknown;
65
+ /**
66
+ * Schema definition type for type-safe object definitions
67
+ * Maps attribute names to their builder types
68
+ */
69
+ type AttributeSchema = Record<string, Attribute>;
70
+ /**
71
+ * Infer record type from an attribute schema
72
+ * Creates a typed object with all attribute values
73
+ */
74
+ type InferRecordFromSchema<TSchema extends AttributeSchema> = {
75
+ [K in keyof TSchema]: InferAttributeValue<TSchema[K]>;
76
+ };
77
+ /**
78
+ * Make required attributes required and optional ones optional
79
+ */
80
+ type InferRecordWithRequirements<TSchema extends AttributeSchema> = {
81
+ [K in RequiredAttributeKeys<TSchema>]: InferAttributeValue<TSchema[K]>;
82
+ } & {
83
+ [K in OptionalAttributeKeys<TSchema>]?: InferAttributeValue<TSchema[K]>;
84
+ };
85
+ /**
86
+ * Extract keys of required attributes
87
+ */
88
+ type RequiredAttributeKeys<TSchema extends AttributeSchema> = {
89
+ [K in keyof TSchema]: TSchema[K]["required"] extends true ? K : never;
90
+ }[keyof TSchema];
91
+ /**
92
+ * Extract keys of optional attributes
93
+ */
94
+ type OptionalAttributeKeys<TSchema extends AttributeSchema> = {
95
+ [K in keyof TSchema]: TSchema[K]["required"] extends true ? never : K;
96
+ }[keyof TSchema];
97
+ /**
98
+ * Type-safe attribute entry for builder accumulation
99
+ * Preserves the attribute name as a literal type
100
+ */
101
+ type TypedAttribute<TName extends string = string, TAttr extends Attribute = Attribute> = TAttr & {
102
+ readonly name: TName;
103
+ };
104
+ /**
105
+ * Accumulated attributes map (built via chained .attribute() calls)
106
+ */
107
+ type AttributeMap = Record<string, Attribute>;
108
+ /**
109
+ * Add an attribute to an existing map
110
+ */
111
+ type AddAttribute$1<TMap extends AttributeMap, TName extends string, TAttr extends Attribute> = TMap & {
112
+ [K in TName]: TAttr;
113
+ };
114
+ /**
115
+ * Infer record type from accumulated attribute map
116
+ */
117
+ type InferRecord<TMap extends AttributeMap> = InferRecordWithRequirements<TMap>;
118
+ /**
119
+ * Infer input type for creating a record (all required + partial optional)
120
+ */
121
+ type InferRecordInput<TMap extends AttributeMap> = InferRecordWithRequirements<TMap>;
122
+ /**
123
+ * Infer update type (all fields optional)
124
+ */
125
+ type InferRecordUpdate<TMap extends AttributeMap> = Partial<InferRecordFromSchema<TMap>>;
126
+ /**
127
+ * Base type for custom attribute values added via UI
128
+ * Supports all possible attribute value types
129
+ */
130
+ type CustomAttributeValue = Attribute["defaultValue"] | undefined;
131
+ /**
132
+ * Adds support for custom attributes (added via UI) to a record type
133
+ * Preserves autocompletion for known attributes while allowing additional properties
134
+ */
135
+ type WithCustomAttributes<T> = T & {
136
+ [key: string]: CustomAttributeValue;
137
+ };
138
+ /**
139
+ * Extract the record type from an ObjectBuilder instance
140
+ * Includes support for custom attributes added via UI
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const PRODUCT = object({ name: "products", label: "Product" })
145
+ * .attribute(text({ name: "name", label: "Name" }).required())
146
+ * .attribute(number({ name: "price", label: "Price" }));
147
+ *
148
+ * type ProductRecord = ExtractRecord<typeof PRODUCT>;
149
+ * // → { name: string; price?: number } & { [key: string]: CustomAttributeValue }
150
+ *
151
+ * const product: ProductRecord = {
152
+ * name: "Nike Air Max",
153
+ * price: 129.99,
154
+ * customField: "added via UI", // ✅ Allowed
155
+ * };
156
+ * ```
157
+ */
158
+ type ExtractRecord<TBuilder> = TBuilder extends {
159
+ _types: {
160
+ record: infer R;
161
+ };
162
+ } ? WithCustomAttributes<R> : never;
163
+ /**
164
+ * Extract the record type without custom attributes (strict mode)
165
+ * Use this when you only want the defined attributes
166
+ */
167
+ type ExtractRecordStrict<TBuilder> = TBuilder extends {
168
+ _types: {
169
+ record: infer R;
170
+ };
171
+ } ? R : never;
172
+ /**
173
+ * Extract the input type from an ObjectBuilder instance
174
+ * Includes support for custom attributes
175
+ */
176
+ type ExtractRecordInput<TBuilder> = TBuilder extends {
177
+ _types: {
178
+ input: infer R;
179
+ };
180
+ } ? WithCustomAttributes<R> : never;
181
+ /**
182
+ * Extract the input type without custom attributes (strict mode)
183
+ */
184
+ type ExtractRecordInputStrict<TBuilder> = TBuilder extends {
185
+ _types: {
186
+ input: infer R;
187
+ };
188
+ } ? R : never;
189
+ /**
190
+ * Extract the update type from an ObjectBuilder instance
191
+ * Includes support for custom attributes
192
+ */
193
+ type ExtractRecordUpdate<TBuilder> = TBuilder extends {
194
+ _types: {
195
+ update: infer R;
196
+ };
197
+ } ? WithCustomAttributes<R> : never;
198
+ /**
199
+ * Extract the update type without custom attributes (strict mode)
200
+ */
201
+ type ExtractRecordUpdateStrict<TBuilder> = TBuilder extends {
202
+ _types: {
203
+ update: infer R;
204
+ };
205
+ } ? R : never;
206
+ /**
207
+ * Extract the attribute map from an ObjectBuilder instance
208
+ */
209
+ type ExtractAttributes<TBuilder> = TBuilder extends {
210
+ _types: {
211
+ attributes: infer A;
212
+ };
213
+ } ? A : never;
214
+
215
+ /**
216
+ * Error codes for schema exceptions
217
+ */
218
+ declare const SchemaErrorCode: {
219
+ readonly UNKNOWN: "SCHEMA_UNKNOWN_ERROR";
220
+ readonly OBJECT_NOT_FOUND: "SCHEMA_OBJECT_NOT_FOUND";
221
+ readonly ATTRIBUTE_NOT_FOUND: "SCHEMA_ATTRIBUTE_NOT_FOUND";
222
+ readonly RECORD_NOT_FOUND: "SCHEMA_RECORD_NOT_FOUND";
223
+ readonly USER_PROFILE_NOT_FOUND: "SCHEMA_USER_PROFILE_NOT_FOUND";
224
+ readonly FILE_NOT_FOUND: "SCHEMA_FILE_NOT_FOUND";
225
+ readonly VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED";
226
+ readonly INVALID_ATTRIBUTE_NAME: "SCHEMA_INVALID_ATTRIBUTE_NAME";
227
+ readonly INVALID_OBJECT_NAME: "SCHEMA_INVALID_OBJECT_NAME";
228
+ readonly PROTECTED_OBJECT: "SCHEMA_PROTECTED_OBJECT";
229
+ readonly PROTECTED_ATTRIBUTE: "SCHEMA_PROTECTED_ATTRIBUTE";
230
+ readonly SYNC_FAILED: "SCHEMA_SYNC_FAILED";
231
+ readonly NOT_SYSTEM_OBJECT: "SCHEMA_NOT_SYSTEM_OBJECT";
232
+ readonly DUPLICATE_OBJECT: "SCHEMA_DUPLICATE_OBJECT";
233
+ readonly DUPLICATE_ATTRIBUTE: "SCHEMA_DUPLICATE_ATTRIBUTE";
234
+ };
235
+ type SchemaErrorCode = (typeof SchemaErrorCode)[keyof typeof SchemaErrorCode];
236
+ /**
237
+ * Base error class for all schema-related errors
238
+ */
239
+ declare class SchemaError extends Error {
240
+ readonly code: SchemaErrorCode;
241
+ readonly details?: Record<string, unknown>;
242
+ constructor(message: string, code?: SchemaErrorCode, details?: Record<string, unknown>);
243
+ toJSON(): {
244
+ name: string;
245
+ code: SchemaErrorCode;
246
+ message: string;
247
+ details: Record<string, unknown> | undefined;
248
+ };
249
+ }
250
+ /**
251
+ * Base class for "not found" errors
252
+ */
253
+ declare class NotFoundError extends SchemaError {
254
+ readonly resourceType: string;
255
+ readonly resourceId: string;
256
+ constructor(resourceType: string, resourceId: string, code?: SchemaErrorCode);
257
+ }
258
+ /**
259
+ * Object not found error
260
+ */
261
+ declare class ObjectNotFoundError extends NotFoundError {
262
+ constructor(objectId: string);
263
+ }
264
+ /**
265
+ * Attribute not found error
266
+ */
267
+ declare class AttributeNotFoundError extends NotFoundError {
268
+ constructor(attributeId: string);
269
+ }
270
+ /**
271
+ * Record not found error
272
+ */
273
+ declare class RecordNotFoundError extends NotFoundError {
274
+ constructor(recordId: string);
275
+ }
276
+ /**
277
+ * User profile not found error
278
+ */
279
+ declare class UserProfileNotFoundError extends NotFoundError {
280
+ constructor(identifier: string);
281
+ }
282
+ /**
283
+ * File not found error
284
+ */
285
+ declare class FileNotFoundError extends NotFoundError {
286
+ constructor(fileId: string);
287
+ }
288
+ /**
289
+ * Validation error with field-level details
290
+ */
291
+ interface ValidationErrorDetail {
292
+ path: string[];
293
+ message: string;
294
+ code?: string;
295
+ }
296
+ /**
297
+ * Validation error thrown when data fails schema validation
298
+ */
299
+ declare class ValidationError extends SchemaError {
300
+ readonly errors: ValidationErrorDetail[];
301
+ constructor(message: string, errors: ValidationErrorDetail[]);
302
+ /**
303
+ * Create a validation error from Zod-style errors
304
+ */
305
+ static fromZodErrors(errors: Array<{
306
+ path: (string | number)[];
307
+ message: string;
308
+ }>): ValidationError;
309
+ }
310
+ /**
311
+ * Error thrown when attempting to modify a protected (system) resource
312
+ */
313
+ declare class ProtectedResourceError extends SchemaError {
314
+ readonly resourceType: "object" | "attribute";
315
+ readonly resourceName: string;
316
+ readonly operation: "delete" | "modify";
317
+ constructor(resourceType: "object" | "attribute", resourceName: string, operation: "delete" | "modify");
318
+ }
319
+ /**
320
+ * Error thrown during native object synchronization
321
+ */
322
+ declare class SyncError extends SchemaError {
323
+ readonly objectName: string;
324
+ readonly cause?: Error;
325
+ constructor(objectName: string, message: string, cause?: Error);
326
+ }
327
+ /**
328
+ * Error thrown when trying to sync a non-system object as native
329
+ */
330
+ declare class NotSystemObjectError extends SchemaError {
331
+ readonly objectName: string;
332
+ constructor(objectName: string);
333
+ }
334
+ /**
335
+ * Error thrown when attempting to create a duplicate resource
336
+ */
337
+ declare class DuplicateError extends SchemaError {
338
+ readonly resourceType: "object" | "attribute";
339
+ readonly resourceName: string;
340
+ constructor(resourceType: "object" | "attribute", resourceName: string);
341
+ }
342
+ /**
343
+ * Check if an error is a SchemaError
344
+ */
345
+ declare function isSchemaError(error: unknown): error is SchemaError;
346
+ /**
347
+ * Check if an error is a NotFoundError
348
+ */
349
+ declare function isNotFoundError(error: unknown): error is NotFoundError;
350
+ /**
351
+ * Check if an error is a ValidationError
352
+ */
353
+ declare function isValidationError(error: unknown): error is ValidationError;
354
+ /**
355
+ * Check if an error is a ProtectedResourceError
356
+ */
357
+ declare function isProtectedResourceError(error: unknown): error is ProtectedResourceError;
358
+
359
+ /**
360
+ * Builder config with literal name type preservation
361
+ */
362
+ interface TypedBuilderConfig<TName extends string> extends BuilderConfig {
363
+ name: TName;
364
+ }
365
+ /**
366
+ * Base attribute builder
367
+ * Type tracking is done via the `_types` phantom property
368
+ */
369
+ declare abstract class BaseAttributeBuilder<TAttr extends Attribute> {
370
+ protected attr: Partial<TAttr>;
371
+ constructor(type: TAttr["type"], name: string, label: string);
372
+ protected setRequired(value: boolean): void;
373
+ system(): this;
374
+ disabled(): this;
375
+ hidden(): this;
376
+ placeholder(value: string): this;
377
+ description(value: string): this;
378
+ icon(value: IconName): this;
379
+ order(value: number): this;
380
+ defaultValue(value: TAttr["defaultValue"]): this;
381
+ metadata(value: Record<string, unknown>): this;
382
+ build(): TAttr;
383
+ }
384
+ declare class TextAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<TextAttribute> {
385
+ /**
386
+ * Phantom type for inference
387
+ */
388
+ readonly _types: {
389
+ name: TName;
390
+ attribute: TextAttribute;
391
+ required: TRequired;
392
+ };
393
+ constructor(name: TName, label: string);
394
+ minLength(value: number): this;
395
+ maxLength(value: number): this;
396
+ pattern(value: string): this;
397
+ required(): TextAttributeBuilder<TName, true>;
398
+ optional(): TextAttributeBuilder<TName, false>;
399
+ /**
400
+ * Set email validation pattern
401
+ */
402
+ email(): this;
403
+ /**
404
+ * Set URL validation pattern
405
+ */
406
+ url(): this;
407
+ /**
408
+ * Set slug validation pattern
409
+ */
410
+ slug(): this;
411
+ }
412
+ declare function text<TName extends string>(config: TypedBuilderConfig<TName>): TextAttributeBuilder<TName, false>;
413
+ declare class TextAreaAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<TextAreaAttribute> {
414
+ /**
415
+ * Phantom type for inference
416
+ */
417
+ readonly _types: {
418
+ name: TName;
419
+ attribute: TextAreaAttribute;
420
+ required: TRequired;
421
+ };
422
+ constructor(name: TName, label: string);
423
+ required(): TextAreaAttributeBuilder<TName, true>;
424
+ optional(): TextAreaAttributeBuilder<TName, false>;
425
+ }
426
+ declare function textarea<TName extends string>(config: TypedBuilderConfig<TName>): TextAreaAttributeBuilder<TName, false>;
427
+ declare class NumberAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<NumberAttribute> {
428
+ readonly _types: {
429
+ name: TName;
430
+ attribute: NumberAttribute;
431
+ required: TRequired;
432
+ };
433
+ constructor(name: TName, label: string);
434
+ min(value: number): this;
435
+ max(value: number): this;
436
+ integer(): this;
437
+ decimal(decimals?: number): this;
438
+ percentage(): this;
439
+ required(): NumberAttributeBuilder<TName, true>;
440
+ optional(): NumberAttributeBuilder<TName, false>;
441
+ }
442
+ declare function number<TName extends string>(config: TypedBuilderConfig<TName>): NumberAttributeBuilder<TName, false>;
443
+ declare class CheckboxAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<CheckboxAttribute> {
444
+ readonly _types: {
445
+ name: TName;
446
+ attribute: CheckboxAttribute;
447
+ required: TRequired;
448
+ };
449
+ constructor(name: TName, label: string);
450
+ required(): CheckboxAttributeBuilder<TName, true>;
451
+ optional(): CheckboxAttributeBuilder<TName, false>;
452
+ }
453
+ declare function checkbox<TName extends string>(config: TypedBuilderConfig<TName>): CheckboxAttributeBuilder<TName, false>;
454
+ declare class DateAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<DateAttribute> {
455
+ readonly _types: {
456
+ name: TName;
457
+ attribute: DateAttribute;
458
+ required: TRequired;
459
+ };
460
+ constructor(name: TName, label: string);
461
+ format(value: DateAttribute["dateFormat"]): this;
462
+ minDate(value: DateAttribute["minDate"]): this;
463
+ maxDate(value: DateAttribute["maxDate"]): this;
464
+ required(): DateAttributeBuilder<TName, true>;
465
+ optional(): DateAttributeBuilder<TName, false>;
466
+ }
467
+ declare function date<TName extends string>(config: TypedBuilderConfig<TName>): DateAttributeBuilder<TName, false>;
468
+ declare class PhoneAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<PhoneAttribute> {
469
+ readonly _types: {
470
+ name: TName;
471
+ attribute: PhoneAttribute;
472
+ required: TRequired;
473
+ };
474
+ constructor(name: TName, label: string);
475
+ defaultCountry(value: CountryIso3): this;
476
+ required(): PhoneAttributeBuilder<TName, true>;
477
+ optional(): PhoneAttributeBuilder<TName, false>;
478
+ }
479
+ declare function phone<TName extends string>(config: TypedBuilderConfig<TName>): PhoneAttributeBuilder<TName, false>;
480
+ declare class CurrencyAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<CurrencyAttribute> {
481
+ readonly _types: {
482
+ name: TName;
483
+ attribute: CurrencyAttribute;
484
+ required: TRequired;
485
+ };
486
+ constructor(name: TName, label: string);
487
+ defaultCurrency(value: CurrencyCode): this;
488
+ allowedCurrencies(value: CurrencyCode[]): this;
489
+ required(): CurrencyAttributeBuilder<TName, true>;
490
+ optional(): CurrencyAttributeBuilder<TName, false>;
491
+ }
492
+ declare function currency<TName extends string>(config: TypedBuilderConfig<TName>): CurrencyAttributeBuilder<TName, false>;
493
+ declare class StatusAttributeBuilder<TName extends string, TOptions extends readonly Option[] = Option[], TRequired extends boolean = false> extends BaseAttributeBuilder<StatusAttribute> {
494
+ readonly _types: {
495
+ name: TName;
496
+ attribute: StatusAttribute & {
497
+ options: TOptions;
498
+ };
499
+ required: TRequired;
500
+ };
501
+ constructor(name: TName, label: string);
502
+ /**
503
+ * Set all options at once (preserves literal types for values)
504
+ */
505
+ options<const T extends readonly Option[]>(value: T): StatusAttributeBuilder<TName, T, TRequired>;
506
+ option(config: Option): this;
507
+ required(): StatusAttributeBuilder<TName, TOptions, true>;
508
+ optional(): StatusAttributeBuilder<TName, TOptions, false>;
509
+ }
510
+ declare function status<TName extends string>(config: TypedBuilderConfig<TName>): StatusAttributeBuilder<TName, Option[], false>;
511
+ declare class SelectAttributeBuilder<TName extends string, TOptions extends readonly Option[] = Option[], TRequired extends boolean = false> extends BaseAttributeBuilder<SelectAttribute> {
512
+ readonly _types: {
513
+ name: TName;
514
+ attribute: SelectAttribute & {
515
+ options: TOptions;
516
+ };
517
+ required: TRequired;
518
+ };
519
+ constructor(name: TName, label: string);
520
+ /**
521
+ * Set all options at once (preserves literal types for values)
522
+ */
523
+ options<const T extends readonly Option[]>(value: T): SelectAttributeBuilder<TName, T, TRequired>;
524
+ option(config: Option): this;
525
+ required(): SelectAttributeBuilder<TName, TOptions, true>;
526
+ optional(): SelectAttributeBuilder<TName, TOptions, false>;
527
+ }
528
+ declare function select<TName extends string>(config: TypedBuilderConfig<TName>): SelectAttributeBuilder<TName, Option[], false>;
529
+ declare class MultiselectAttributeBuilder<TName extends string, TOptions extends readonly Option[] = Option[], TRequired extends boolean = false> extends BaseAttributeBuilder<MultiselectAttribute> {
530
+ readonly _types: {
531
+ name: TName;
532
+ attribute: MultiselectAttribute & {
533
+ options: TOptions;
534
+ };
535
+ required: TRequired;
536
+ };
537
+ constructor(name: TName, label: string);
538
+ /**
539
+ * Set all options at once (preserves literal types for values)
540
+ */
541
+ options<const T extends readonly Option[]>(value: T): MultiselectAttributeBuilder<TName, T, TRequired>;
542
+ option(config: Option): this;
543
+ required(): MultiselectAttributeBuilder<TName, TOptions, true>;
544
+ optional(): MultiselectAttributeBuilder<TName, TOptions, false>;
545
+ }
546
+ declare function multiselect<TName extends string>(config: TypedBuilderConfig<TName>): MultiselectAttributeBuilder<TName, Option[], false>;
547
+ declare class LocationAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<LocationAttribute> {
548
+ readonly _types: {
549
+ name: TName;
550
+ attribute: LocationAttribute;
551
+ required: TRequired;
552
+ };
553
+ constructor(name: TName, label: string);
554
+ granularity(value: LocationAttribute["granularity"]): this;
555
+ enableAutocomplete(): this;
556
+ enableMap(): this;
557
+ defaultCountry(value: CountryIso3): this;
558
+ allowedCountries(value: CountryIso3[]): this;
559
+ displayFormat(value: LocationAttribute["displayFormat"]): this;
560
+ required(): LocationAttributeBuilder<TName, true>;
561
+ optional(): LocationAttributeBuilder<TName, false>;
562
+ }
563
+ declare function location<TName extends string>(config: TypedBuilderConfig<TName>): LocationAttributeBuilder<TName, false>;
564
+ declare class TimestampAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<TimestampAttribute> {
565
+ readonly _types: {
566
+ name: TName;
567
+ attribute: TimestampAttribute;
568
+ required: TRequired;
569
+ };
570
+ constructor(name: TName, label: string);
571
+ autoUpdate(): this;
572
+ required(): TimestampAttributeBuilder<TName, true>;
573
+ optional(): TimestampAttributeBuilder<TName, false>;
574
+ }
575
+ declare function timestamp<TName extends string>(config: TypedBuilderConfig<TName>): TimestampAttributeBuilder<TName, false>;
576
+ declare class FileAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<FileAttribute> {
577
+ readonly _types: {
578
+ name: TName;
579
+ attribute: FileAttribute;
580
+ required: TRequired;
581
+ };
582
+ constructor(name: TName, label: string);
583
+ maxFiles(value: number): this;
584
+ maxSize(bytes: number): this;
585
+ allowedTypes(types: MimeType[] | readonly MimeType[]): this;
586
+ verification(config: FileAttribute["verification"]): this;
587
+ required(): FileAttributeBuilder<TName, true>;
588
+ optional(): FileAttributeBuilder<TName, false>;
589
+ }
590
+ declare function file<TName extends string>(config: TypedBuilderConfig<TName>): FileAttributeBuilder<TName, false>;
591
+ declare class UserAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<UserAttribute> {
592
+ readonly _types: {
593
+ name: TName;
594
+ attribute: UserAttribute;
595
+ required: TRequired;
596
+ };
597
+ constructor(name: TName, label: string);
598
+ allowedRoles(roles: string[]): this;
599
+ required(): UserAttributeBuilder<TName, true>;
600
+ optional(): UserAttributeBuilder<TName, false>;
601
+ }
602
+ declare function user<TName extends string>(config: TypedBuilderConfig<TName>): UserAttributeBuilder<TName, false>;
603
+ /**
604
+ * Options for adding a relation target
605
+ */
606
+ interface RelationTargetOptions {
607
+ /** Display template using mustache syntax, e.g., "{name}" or "{firstName} {lastName}" */
608
+ displayTemplate?: string;
609
+ /** Filter to restrict available records */
610
+ filter?: Record<string, unknown>;
611
+ }
612
+ /**
613
+ * Internal options for creating a relation builder from existing data
614
+ */
615
+ interface RelationBuilderInitOptions {
616
+ targets?: RelationTarget[];
617
+ onDelete?: RelationOnDelete;
618
+ isRequired?: boolean;
619
+ }
620
+ /**
621
+ * Builder for single relation attributes (cardinality: "one")
622
+ */
623
+ declare class SingleRelationAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<SingleRelationAttribute> {
624
+ readonly _types: {
625
+ name: TName;
626
+ attribute: SingleRelationAttribute;
627
+ required: TRequired;
628
+ };
629
+ constructor(name: TName, label: string);
630
+ /**
631
+ * Add a target object that can be linked
632
+ * @param objectName - Name of the object (e.g., "companies")
633
+ * @param options - Display template and filter options
634
+ */
635
+ to(objectName: string, options?: RelationTargetOptions): this;
636
+ /**
637
+ * Set the deletion strategy when target record is deleted
638
+ * @param strategy - "restrict" (default), "cascade", or "set_null"
639
+ */
640
+ onDelete(strategy: RelationOnDelete): this;
641
+ /**
642
+ * Convert to a multi-relation (cardinality: "many")
643
+ */
644
+ many(): MultiRelationAttributeBuilder<TName, TRequired>;
645
+ required(): SingleRelationAttributeBuilder<TName, true>;
646
+ optional(): SingleRelationAttributeBuilder<TName, false>;
647
+ }
648
+ /**
649
+ * Builder for multi relation attributes (cardinality: "many")
650
+ */
651
+ declare class MultiRelationAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<MultiRelationAttribute> {
652
+ readonly _types: {
653
+ name: TName;
654
+ attribute: MultiRelationAttribute;
655
+ required: TRequired;
656
+ };
657
+ constructor(name: TName, label: string, initOptions?: RelationBuilderInitOptions);
658
+ /**
659
+ * Add a target object that can be linked
660
+ * @param objectName - Name of the object (e.g., "companies")
661
+ * @param options - Display template and filter options
662
+ */
663
+ to(objectName: string, options?: RelationTargetOptions): this;
664
+ /**
665
+ * Set the deletion strategy when target record is deleted
666
+ * @param strategy - "restrict" (default), "cascade", or "set_null"
667
+ */
668
+ onDelete(strategy: RelationOnDelete): this;
669
+ /**
670
+ * Set minimum number of relations required
671
+ */
672
+ minItems(count: number): this;
673
+ /**
674
+ * Set maximum number of relations allowed
675
+ */
676
+ maxItems(count: number): this;
677
+ required(): MultiRelationAttributeBuilder<TName, true>;
678
+ optional(): MultiRelationAttributeBuilder<TName, false>;
679
+ }
680
+ /**
681
+ * Create a relation attribute builder
682
+ *
683
+ * @example Single relation (default)
684
+ * ```typescript
685
+ * relation({ name: "company", label: "Company" })
686
+ * .to("companies")
687
+ * .required()
688
+ * ```
689
+ *
690
+ * @example Multi relation
691
+ * ```typescript
692
+ * relation({ name: "contacts", label: "Contacts" })
693
+ * .to("contacts", { displayTemplate: "{firstName} {lastName}" })
694
+ * .many()
695
+ * .maxItems(5)
696
+ * ```
697
+ *
698
+ * @example Polymorphic relation
699
+ * ```typescript
700
+ * relation({ name: "linked", label: "Linked Items" })
701
+ * .to("companies")
702
+ * .to("contacts")
703
+ * .many()
704
+ * .onDelete("cascade")
705
+ * ```
706
+ */
707
+ declare function relation<TName extends string>(config: TypedBuilderConfig<TName>): SingleRelationAttributeBuilder<TName, false>;
708
+ declare class RatingAttributeBuilder<TName extends string, TRequired extends boolean = false> extends BaseAttributeBuilder<RatingAttribute> {
709
+ readonly _types: {
710
+ name: TName;
711
+ attribute: RatingAttribute;
712
+ required: TRequired;
713
+ };
714
+ constructor(name: TName, label: string);
715
+ max(value: number): this;
716
+ iconType(value: RatingAttribute["iconType"]): this;
717
+ required(): RatingAttributeBuilder<TName, true>;
718
+ optional(): RatingAttributeBuilder<TName, false>;
719
+ }
720
+ declare function rating<TName extends string>(config: TypedBuilderConfig<TName>): RatingAttributeBuilder<TName, false>;
721
+ /**
722
+ * Union of all attribute builder types
723
+ */
724
+ type AnyAttributeBuilder = TextAttributeBuilder<string, boolean> | TextAreaAttributeBuilder<string, boolean> | NumberAttributeBuilder<string, boolean> | CheckboxAttributeBuilder<string, boolean> | DateAttributeBuilder<string, boolean> | PhoneAttributeBuilder<string, boolean> | CurrencyAttributeBuilder<string, boolean> | StatusAttributeBuilder<string, readonly Option[], boolean> | SelectAttributeBuilder<string, readonly Option[], boolean> | MultiselectAttributeBuilder<string, readonly Option[], boolean> | LocationAttributeBuilder<string, boolean> | TimestampAttributeBuilder<string, boolean> | FileAttributeBuilder<string, boolean> | UserAttributeBuilder<string, boolean> | SingleRelationAttributeBuilder<string, boolean> | MultiRelationAttributeBuilder<string, boolean> | RatingAttributeBuilder<string, boolean>;
725
+ /**
726
+ * Extract the attribute name from a builder
727
+ */
728
+ type ExtractAttributeName<T> = T extends {
729
+ _types: {
730
+ name: infer N;
731
+ };
732
+ } ? N : never;
733
+ /**
734
+ * Extract the required flag from a builder
735
+ */
736
+ type ExtractAttributeRequired<T> = T extends {
737
+ _types: {
738
+ required: infer R;
739
+ };
740
+ } ? R : false;
741
+
742
+ /**
743
+ * Extract attribute info from a builder instance
744
+ */
745
+ type ExtractBuilderInfo<T> = T extends {
746
+ _types: {
747
+ name: infer N;
748
+ attribute: infer A;
749
+ required: infer R;
750
+ };
751
+ } ? {
752
+ name: N;
753
+ attribute: A;
754
+ required: R;
755
+ } : T extends Attribute ? {
756
+ name: T["name"];
757
+ attribute: T;
758
+ required: T["required"];
759
+ } : never;
760
+ /**
761
+ * Flatten and simplify an intersection type for better IDE display
762
+ */
763
+ type Flatten<T> = T extends object ? {
764
+ [K in keyof T]: T[K];
765
+ } : T;
766
+ /**
767
+ * Add a required attribute to the record type
768
+ */
769
+ type WithRequiredAttr<TRecord extends Record<string, unknown>, TName extends string, TValue> = Flatten<Omit<TRecord, TName> & {
770
+ [K in TName]: TValue;
771
+ }>;
772
+ /**
773
+ * Add an optional attribute to the record type
774
+ */
775
+ type WithOptionalAttr<TRecord extends Record<string, unknown>, TName extends string, TValue> = Flatten<Omit<TRecord, TName> & {
776
+ [K in TName]?: TValue;
777
+ }>;
778
+ /**
779
+ * Add an attribute to the accumulated record type
780
+ */
781
+ type AddAttribute<TRecord extends Record<string, unknown>, TName extends string, TAttr extends Attribute, TRequired extends boolean> = TRequired extends true ? WithRequiredAttr<TRecord, TName, InferAttributeValue<TAttr>> : WithOptionalAttr<TRecord, TName, InferAttributeValue<TAttr>>;
782
+ /**
783
+ * Fluent builder for creating ObjectDefinition with full type inference
784
+ *
785
+ * The generic parameter TRecord accumulates attribute types as you chain
786
+ * .attribute() calls, enabling full autocompletion on the inferred record type.
787
+ *
788
+ * IMPORTANT: Every object MUST define a `labelExpression` to specify how records
789
+ * are displayed. Use `.labelExpression("{{ name }}")` to define the display template.
790
+ *
791
+ * @example
792
+ * ```typescript
793
+ * import { object, text, number, status } from "@stndrds/schema";
794
+ * import type { ExtractRecord } from "@stndrds/schema";
795
+ *
796
+ * const PRODUCT = object({ name: "products", label: "Product" })
797
+ * .system()
798
+ * .attribute(text({ name: "name", label: "Name" }).required()) // This becomes the title
799
+ * .attribute(number({ name: "price", label: "Price" }).decimal(2))
800
+ * .attribute(
801
+ * status({ name: "status", label: "Status" })
802
+ * .options([
803
+ * { id: "active", label: "Active", value: "active", color: "green" },
804
+ * { id: "draft", label: "Draft", value: "draft", color: "yellow" }
805
+ * ])
806
+ * .required()
807
+ * );
808
+ *
809
+ * // Full autocompletion! ✨
810
+ * type ProductRecord = ExtractRecord<typeof PRODUCT>;
811
+ * // → { name: string; price?: number; status: string }
812
+ * ```
813
+ */
814
+ declare class ObjectBuilder<TRecord extends Record<string, unknown> = {}> {
815
+ private obj;
816
+ private _labelExpression?;
817
+ private _pluralLabel?;
818
+ /**
819
+ * Phantom type property for type extraction
820
+ * Never used at runtime, only for TypeScript inference
821
+ */
822
+ readonly _types: {
823
+ record: TRecord;
824
+ input: TRecord;
825
+ update: {
826
+ [K in keyof TRecord]?: TRecord[K];
827
+ };
828
+ };
829
+ constructor(config: BuilderConfig);
830
+ /**
831
+ * Set object description
832
+ */
833
+ description(value: string): this;
834
+ /**
835
+ * Set the plural form of the label (e.g., "Products" for "Product")
836
+ * Used in UI when displaying collections
837
+ */
838
+ pluralLabel(value: string): this;
839
+ /**
840
+ * Set object icon
841
+ */
842
+ icon(value: IconName): this;
843
+ /**
844
+ * Mark as system/native object (defined in code, protected)
845
+ * System objects cannot be deleted/modified by clients
846
+ */
847
+ system(): this;
848
+ /**
849
+ * Add an attribute to the object with type accumulation
850
+ *
851
+ * The return type accumulates the attribute's name and value type
852
+ * into the TRecord generic, enabling full inference.
853
+ *
854
+ * @param attr - Attribute definition or builder (auto-builds if builder)
855
+ */
856
+ attribute<TBuilder extends {
857
+ _types: unknown;
858
+ } | Attribute, TInfo extends ExtractBuilderInfo<TBuilder> = ExtractBuilderInfo<TBuilder>, TName extends string = TInfo["name"] extends string ? TInfo["name"] : string, TAttr extends Attribute = TInfo["attribute"] extends Attribute ? TInfo["attribute"] : Attribute, TRequired extends boolean = TInfo["required"] extends true ? true : false>(attr: TBuilder): ObjectBuilder<AddAttribute<TRecord, TName, TAttr, TRequired>>;
859
+ /**
860
+ * Add multiple attributes at once
861
+ * Note: For full type inference, prefer chaining .attribute() calls
862
+ */
863
+ attributes(attrs: Array<Attribute | {
864
+ build: () => Attribute;
865
+ }>): this;
866
+ /**
867
+ * Set metadata
868
+ */
869
+ metadata(value: Record<string, unknown>): this;
870
+ /**
871
+ * Set the label expression template for displaying records
872
+ * This is REQUIRED for every object.
873
+ *
874
+ * Supports variable interpolation with `{{ attribute }}` syntax
875
+ * and pipes for formatting: `{{ name | UPPER }}`, `{{ name | capitalize }}`
876
+ *
877
+ * Available pipes: UPPER, LOWER, capitalize, trim
878
+ *
879
+ * @param template - The label expression template
880
+ *
881
+ * @example
882
+ * ```typescript
883
+ * object({ name: "contacts", label: "Contact" })
884
+ * .labelExpression("{{ firstName }} {{ lastName }}")
885
+ * .attribute(text({ name: "firstName", label: "First Name" }).required())
886
+ * .attribute(text({ name: "lastName", label: "Last Name" }).required())
887
+ * ```
888
+ */
889
+ labelExpression(template: string): this;
890
+ /**
891
+ * Build the final ObjectDefinition
892
+ * @throws Error if required fields are missing or invalid
893
+ */
894
+ build(): ObjectDefinition;
895
+ /**
896
+ * Validate object name format
897
+ * Must be kebab-case (slug format), max 63 characters
898
+ * @internal
899
+ */
900
+ private validateName;
901
+ }
902
+ /**
903
+ * Create a new object builder with type inference
904
+ *
905
+ * @example
906
+ * ```typescript
907
+ * import { object, text, number } from "@stndrds/schema";
908
+ * import type { ExtractRecord } from "@stndrds/schema";
909
+ *
910
+ * // Define object with fluent API
911
+ * const PRODUCT = object({ name: "products", label: "Product" })
912
+ * .system()
913
+ * .attribute(text({ name: "name", label: "Name" }).required())
914
+ * .attribute(number({ name: "price", label: "Price" }));
915
+ *
916
+ * // Extract the inferred record type
917
+ * type ProductRecord = ExtractRecord<typeof PRODUCT>;
918
+ * // → { name: string; price?: number }
919
+ *
920
+ * // Full autocompletion when creating records! ✨
921
+ * const product: ProductRecord = {
922
+ * name: "Nike Air Max", // required
923
+ * price: 129.99 // optional
924
+ * };
925
+ * ```
926
+ */
927
+ declare function object(config: BuilderConfig): ObjectBuilder<{}>;
928
+
929
+ /**
930
+ * Builder for creating form groups
931
+ *
932
+ * @example
933
+ * ```typescript
934
+ * group("identity", "Identity")
935
+ * .field("name", { span: 8 })
936
+ * .field("status", { span: 4 })
937
+ * .fields("description", "website")
938
+ * .collapsible()
939
+ * ```
940
+ */
941
+ declare class GroupBuilder {
942
+ private data;
943
+ constructor(id: string, label: string);
944
+ /**
945
+ * Set group description
946
+ */
947
+ description(value: string): this;
948
+ /**
949
+ * Make group collapsible
950
+ * @param collapsed - Initial collapsed state (default: false)
951
+ */
952
+ collapsible(collapsed?: boolean): this;
953
+ /**
954
+ * Set display order
955
+ */
956
+ order(value: number): this;
957
+ /**
958
+ * Add multiple fields with default options
959
+ * @example .fields("name", "email", "phone")
960
+ */
961
+ fields(...names: string[]): this;
962
+ /**
963
+ * Add a single field with options
964
+ * @example .field("name", { span: 8, readOnly: true })
965
+ */
966
+ field(attribute: string, options?: Omit<Field, "attribute" | "attributeGroup">): this;
967
+ /**
968
+ * Add an inline attribute group (composite field with dropdown)
969
+ * Groups multiple attributes into a single field
970
+ * @example .attributeGroup({ id: "address", label: "Address", attributes: ["street", "city", "postal_code"], displayTemplate: "{street}, {city}" })
971
+ */
972
+ attributeGroup(config: AttributeGroupField, options?: Omit<Field, "attribute" | "attributeGroup">): this;
973
+ /**
974
+ * Build the group definition
975
+ */
976
+ build(): Group;
977
+ }
978
+ /**
979
+ * Base tab configuration shared across tab types
980
+ */
981
+ interface BaseTabConfig {
982
+ id: string;
983
+ name: string;
984
+ label: string;
985
+ icon?: IconName;
986
+ order?: number;
987
+ system?: boolean;
988
+ }
989
+ /**
990
+ * Builder for configuring table tabs
991
+ */
992
+ declare class TableTabConfig {
993
+ private view;
994
+ private tabData;
995
+ /** @internal */
996
+ constructor(view: ViewBuilder, base: BaseTabConfig, relation: string);
997
+ /**
998
+ * Set columns to display
999
+ * @example .columns("firstName", "lastName", "email")
1000
+ */
1001
+ columns(...names: string[]): this;
1002
+ /**
1003
+ * Allow creating new records
1004
+ */
1005
+ create(): this;
1006
+ /**
1007
+ * Allow inline editing
1008
+ */
1009
+ edit(): this;
1010
+ /**
1011
+ * Allow deleting records
1012
+ */
1013
+ delete(): this;
1014
+ /**
1015
+ * Enable all CRUD operations (create, edit, delete)
1016
+ */
1017
+ crud(): this;
1018
+ /**
1019
+ * Set default filters
1020
+ */
1021
+ filters(value: Record<string, unknown>): this;
1022
+ /**
1023
+ * Set default sort
1024
+ * @example .sort("lastName") or .sort("createdAt", "desc")
1025
+ */
1026
+ sort(field: string, order?: "asc" | "desc"): this;
1027
+ /**
1028
+ * Continue building with a new tab
1029
+ */
1030
+ tab(name: string, label: string): TabBuilder;
1031
+ /**
1032
+ * Finish this tab and return to ViewBuilder
1033
+ */
1034
+ done(): ViewBuilder;
1035
+ /**
1036
+ * Build the final view definition
1037
+ */
1038
+ build(): ViewDefinition;
1039
+ private finalize;
1040
+ }
1041
+ /**
1042
+ * Builder for configuring custom tabs
1043
+ */
1044
+ declare class CustomTabConfig {
1045
+ private view;
1046
+ private tabData;
1047
+ /** @internal */
1048
+ constructor(view: ViewBuilder, base: BaseTabConfig, component: string);
1049
+ /**
1050
+ * Set props to pass to the component
1051
+ */
1052
+ props(value: Record<string, unknown>): this;
1053
+ /**
1054
+ * Continue building with a new tab
1055
+ */
1056
+ tab(name: string, label: string): TabBuilder;
1057
+ /**
1058
+ * Finish this tab and return to ViewBuilder
1059
+ */
1060
+ done(): ViewBuilder;
1061
+ /**
1062
+ * Build the final view definition
1063
+ */
1064
+ build(): ViewDefinition;
1065
+ }
1066
+ /**
1067
+ * Builder for creating tabs with type discrimination
1068
+ *
1069
+ * @example
1070
+ * ```typescript
1071
+ * .tab("general", "Info").form(group(...))
1072
+ * .tab("contacts", "Contacts").table("contacts").columns("name", "email")
1073
+ * .tab("analytics", "Stats").custom("AnalyticsWidget")
1074
+ * ```
1075
+ */
1076
+ declare class TabBuilder {
1077
+ private view;
1078
+ private base;
1079
+ /** @internal */
1080
+ constructor(view: ViewBuilder, name: string, label: string);
1081
+ /**
1082
+ * Set tab icon
1083
+ */
1084
+ icon(value: IconName): this;
1085
+ /**
1086
+ * Set display order
1087
+ */
1088
+ order(value: number): this;
1089
+ /**
1090
+ * Mark as system tab (protected)
1091
+ */
1092
+ system(): this;
1093
+ /**
1094
+ * Create a form tab with groups
1095
+ * @example .form(group("info", "Info").fields("name", "email"))
1096
+ */
1097
+ form(...groups: (GroupBuilder | Group)[]): ViewBuilder;
1098
+ /**
1099
+ * Create a table tab for a relation
1100
+ * @example .table("contacts").columns("name", "email").crud()
1101
+ */
1102
+ table(relation: string): TableTabConfig;
1103
+ /**
1104
+ * Create a custom tab with a component
1105
+ * @example .custom("AnalyticsWidget").props({ period: "12m" })
1106
+ */
1107
+ custom(component: string): CustomTabConfig;
1108
+ }
1109
+ /**
1110
+ * Builder for creating view definitions
1111
+ *
1112
+ * @example
1113
+ * ```typescript
1114
+ * const COMPANY_VIEW = view("detail", "Company Detail")
1115
+ * .for("companies")
1116
+ * .default()
1117
+ * .system()
1118
+ * .icon("building")
1119
+ *
1120
+ * .tab("general", "Info").icon("info")
1121
+ * .form(
1122
+ * group("identity", "Identity").fields("name", "status"),
1123
+ * group("address", "Address").fields("location").collapsible()
1124
+ * )
1125
+ *
1126
+ * .tab("contacts", "Contacts").icon("users")
1127
+ * .table("contacts")
1128
+ * .columns("firstName", "lastName", "email")
1129
+ * .crud()
1130
+ *
1131
+ * .tab("analytics", "Stats").icon("bar-chart")
1132
+ * .custom("CompanyAnalytics")
1133
+ * .props({ period: "12m" })
1134
+ *
1135
+ * .build();
1136
+ * ```
1137
+ */
1138
+ declare class ViewBuilder {
1139
+ private data;
1140
+ private validated;
1141
+ constructor(name: string, label: string);
1142
+ /**
1143
+ * Set view description
1144
+ */
1145
+ description(value: string): this;
1146
+ /**
1147
+ * Set view icon
1148
+ */
1149
+ icon(value: IconName): this;
1150
+ /**
1151
+ * Associate view with an object
1152
+ * @param objectName - Object name (kebab-case)
1153
+ */
1154
+ for(objectName: string): this;
1155
+ /**
1156
+ * Mark as default view for the object
1157
+ */
1158
+ default(): this;
1159
+ /**
1160
+ * Mark as system view (protected, defined by developer)
1161
+ */
1162
+ system(): this;
1163
+ /**
1164
+ * Set metadata
1165
+ */
1166
+ metadata(value: Record<string, unknown>): this;
1167
+ /**
1168
+ * Start building a new tab
1169
+ */
1170
+ tab(name: string, label: string): TabBuilder;
1171
+ /**
1172
+ * Add a pre-built tab
1173
+ */
1174
+ addTab(tab: Tab): this;
1175
+ /**
1176
+ * @internal Used by TabBuilder to add tabs
1177
+ */
1178
+ _addTab(tab: Tab): this;
1179
+ /**
1180
+ * Build the final view definition
1181
+ */
1182
+ build(): ViewDefinition;
1183
+ /**
1184
+ * Validate view name format (kebab-case)
1185
+ */
1186
+ private validateName;
1187
+ }
1188
+ /**
1189
+ * Create a new view builder
1190
+ *
1191
+ * @param name - View name (kebab-case)
1192
+ * @param label - Display label
1193
+ *
1194
+ * @example
1195
+ * ```typescript
1196
+ * const COMPANY_VIEW = view("detail", "Company Detail")
1197
+ * .for("companies")
1198
+ * .default()
1199
+ * .system()
1200
+ * .tab("general", "Info")
1201
+ * .form(group("main", "Main").fields("name", "status"))
1202
+ * .build();
1203
+ * ```
1204
+ */
1205
+ declare function view(name: string, label: string): ViewBuilder;
1206
+ /**
1207
+ * Create a new group builder
1208
+ *
1209
+ * @param id - Group identifier
1210
+ * @param label - Display label
1211
+ *
1212
+ * @example
1213
+ * ```typescript
1214
+ * group("identity", "Identity")
1215
+ * .field("name", { span: 8 })
1216
+ * .field("status", { span: 4 })
1217
+ * .collapsible()
1218
+ * ```
1219
+ */
1220
+ declare function group(id: string, label: string): GroupBuilder;
1221
+
1222
+ export { type AddAttribute$1 as AddAttribute, type AnyAttributeBuilder, Attribute, AttributeGroupField, type AttributeMap, AttributeNotFoundError, type AttributeSchema, type BuilderConfig, CheckboxAttribute, Currency, CurrencyAttribute, type CustomAttributeValue, CustomTabConfig, DateAttribute, DuplicateError, type ExtractAttributeName, type ExtractAttributeRequired, type ExtractAttributes, type ExtractRecord, type ExtractRecordInput, type ExtractRecordInputStrict, type ExtractRecordStrict, type ExtractRecordUpdate, type ExtractRecordUpdateStrict, Field, FileAttribute, FileNotFoundError, Group, GroupBuilder, type InferAttributeValue, type InferRecord, type InferRecordFromSchema, type InferRecordInput, type InferRecordUpdate, type InferRecordWithRequirements, Location, LocationAttribute, MultiRelationAttribute, MultiselectAttribute, NotFoundError, NotSystemObjectError, NumberAttribute, ObjectBuilder, ObjectDefinition, ObjectNotFoundError, Option, Phone, PhoneAttribute, ProtectedResourceError, RatingAttribute, RecordNotFoundError, RelationOnDelete, RelationTarget, SchemaError, SchemaErrorCode, SelectAttribute, SingleRelationAttribute, StatusAttribute, SyncError, Tab, TabBuilder, TableTabConfig, TextAreaAttribute, TextAttribute, TimestampAttribute, type TypedAttribute, type TypedBuilderConfig, UserAttribute, UserProfileNotFoundError, ValidationError, type ValidationErrorDetail, ViewBuilder, ViewDefinition, type WithCustomAttributes, checkbox, currency, date, file, group, isNotFoundError, isProtectedResourceError, isSchemaError, isValidationError, location, multiselect, number, object, phone, rating, relation, select, status, text, textarea, timestamp, user, view };