@standards/schema 0.0.0-stage → 1.0.0-alpha.382

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 (133) hide show
  1. package/LICENSE +111 -0
  2. package/README.md +8 -2
  3. package/dist/all-BgYwavNm.d.mts +2956 -0
  4. package/dist/all-DjdKldjX.d.ts +2956 -0
  5. package/dist/api/index.d.mts +11838 -0
  6. package/dist/api/index.d.ts +11838 -0
  7. package/dist/api/index.js +2 -0
  8. package/dist/api/index.mjs +2 -0
  9. package/dist/attribute-validators-DRqhAt2t.mjs +11 -0
  10. package/dist/attribute-validators-WAoJbap5.js +11 -0
  11. package/dist/attributes-aTeqx6cK.d.mts +557 -0
  12. package/dist/attributes-kAhQzg8-.d.ts +557 -0
  13. package/dist/checkbox-BZvZOraX.d.mts +11 -0
  14. package/dist/checkbox-n0YV1O13.d.ts +11 -0
  15. package/dist/config-BIxnbUN8.mjs +2 -0
  16. package/dist/config-DdjlHdPg.js +2 -0
  17. package/dist/core-397tQy5q.js +2 -0
  18. package/dist/core-BLHhNykL.mjs +2 -0
  19. package/dist/date-CxqDOhA0.d.mts +24 -0
  20. package/dist/date-D007KyTI.d.ts +24 -0
  21. package/dist/exceptions-DjPVyS-Q.d.mts +761 -0
  22. package/dist/exceptions-DjPVyS-Q.d.ts +761 -0
  23. package/dist/exceptions.d.mts +3 -0
  24. package/dist/exceptions.d.ts +3 -0
  25. package/dist/exceptions.js +2 -0
  26. package/dist/exceptions.mjs +2 -0
  27. package/dist/index-3HZjBOpj.d.mts +53 -0
  28. package/dist/index-BmNMneu3.d.mts +278 -0
  29. package/dist/index-Bu9xF5Nq.d.ts +278 -0
  30. package/dist/index-CiTBL4gH.d.ts +101 -0
  31. package/dist/index-D7TEaPqX.d.ts +16519 -0
  32. package/dist/index-DLO8JpnY.d.ts +53 -0
  33. package/dist/index-DPO5w-fC.d.mts +101 -0
  34. package/dist/index-DwQWBzYJ.d.mts +16519 -0
  35. package/dist/index.d.mts +15 -0
  36. package/dist/index.d.ts +15 -0
  37. package/dist/index.js +2 -0
  38. package/dist/index.mjs +2 -0
  39. package/dist/number-CgBxEbjI.d.mts +11 -0
  40. package/dist/number-DncH-WRO.d.ts +11 -0
  41. package/dist/object-DcgxLvip.js +4 -0
  42. package/dist/object-Dzl7sfq8.mjs +4 -0
  43. package/dist/objects-B4DgFZ82.d.ts +398 -0
  44. package/dist/objects-C9f6hFW_.d.mts +398 -0
  45. package/dist/phone-BB-tzcSr.js +2 -0
  46. package/dist/phone-Bca_xiOX.mjs +2 -0
  47. package/dist/record-aggregates-CzG86pUS.mjs +2 -0
  48. package/dist/record-aggregates-DwpIJ2Dv.js +2 -0
  49. package/dist/record-operation-BSXczk7v.js +2 -0
  50. package/dist/record-operation-C9oXHmfF.mjs +2 -0
  51. package/dist/text-A9AJ1wUO.js +2 -0
  52. package/dist/text-C8Lb-NFo.mjs +2 -0
  53. package/dist/text-DDoY_LcQ.d.ts +11 -0
  54. package/dist/text-DeUqCFp9.d.mts +11 -0
  55. package/dist/utils-B7Dlrtnx.d.ts +163 -0
  56. package/dist/utils-DbRMK8NI.d.mts +163 -0
  57. package/dist/utils-fXIvFFl6.mjs +2 -0
  58. package/dist/utils-gY3d9Dwp.js +2 -0
  59. package/dist/utils.d.mts +3 -0
  60. package/dist/utils.d.ts +3 -0
  61. package/dist/utils.js +2 -0
  62. package/dist/utils.mjs +2 -0
  63. package/dist/validation/all.d.mts +6 -0
  64. package/dist/validation/all.d.ts +6 -0
  65. package/dist/validation/all.js +2 -0
  66. package/dist/validation/all.mjs +2 -0
  67. package/dist/validation/complex/currency.d.mts +13 -0
  68. package/dist/validation/complex/currency.d.ts +13 -0
  69. package/dist/validation/complex/currency.js +2 -0
  70. package/dist/validation/complex/currency.mjs +2 -0
  71. package/dist/validation/complex/location.d.mts +20 -0
  72. package/dist/validation/complex/location.d.ts +20 -0
  73. package/dist/validation/complex/location.js +2 -0
  74. package/dist/validation/complex/location.mjs +2 -0
  75. package/dist/validation/complex/phone.d.mts +20 -0
  76. package/dist/validation/complex/phone.d.ts +20 -0
  77. package/dist/validation/complex/phone.js +2 -0
  78. package/dist/validation/complex/phone.mjs +2 -0
  79. package/dist/validation/complex/relation.d.mts +23 -0
  80. package/dist/validation/complex/relation.d.ts +23 -0
  81. package/dist/validation/complex/relation.js +2 -0
  82. package/dist/validation/complex/relation.mjs +2 -0
  83. package/dist/validation/complex/richtext.d.mts +11 -0
  84. package/dist/validation/complex/richtext.d.ts +11 -0
  85. package/dist/validation/complex/richtext.js +2 -0
  86. package/dist/validation/complex/richtext.mjs +2 -0
  87. package/dist/validation/complex/select.d.mts +18 -0
  88. package/dist/validation/complex/select.d.ts +18 -0
  89. package/dist/validation/complex/select.js +2 -0
  90. package/dist/validation/complex/select.mjs +2 -0
  91. package/dist/validation/complex/user.d.mts +11 -0
  92. package/dist/validation/complex/user.d.ts +11 -0
  93. package/dist/validation/complex/user.js +2 -0
  94. package/dist/validation/complex/user.mjs +2 -0
  95. package/dist/validation/computed/formula.d.mts +12 -0
  96. package/dist/validation/computed/formula.d.ts +12 -0
  97. package/dist/validation/computed/formula.js +2 -0
  98. package/dist/validation/computed/formula.mjs +2 -0
  99. package/dist/validation/computed/rollup.d.mts +12 -0
  100. package/dist/validation/computed/rollup.d.ts +12 -0
  101. package/dist/validation/computed/rollup.js +2 -0
  102. package/dist/validation/computed/rollup.mjs +2 -0
  103. package/dist/validation/config/index.d.mts +3 -0
  104. package/dist/validation/config/index.d.ts +3 -0
  105. package/dist/validation/config/index.js +2 -0
  106. package/dist/validation/config/index.mjs +2 -0
  107. package/dist/validation/core/index.d.mts +3 -0
  108. package/dist/validation/core/index.d.ts +3 -0
  109. package/dist/validation/core/index.js +2 -0
  110. package/dist/validation/core/index.mjs +2 -0
  111. package/dist/validation/object/index.d.mts +3 -0
  112. package/dist/validation/object/index.d.ts +3 -0
  113. package/dist/validation/object/index.js +2 -0
  114. package/dist/validation/object/index.mjs +2 -0
  115. package/dist/validation/primitives/checkbox.d.mts +3 -0
  116. package/dist/validation/primitives/checkbox.d.ts +3 -0
  117. package/dist/validation/primitives/checkbox.js +2 -0
  118. package/dist/validation/primitives/checkbox.mjs +2 -0
  119. package/dist/validation/primitives/date.d.mts +3 -0
  120. package/dist/validation/primitives/date.d.ts +3 -0
  121. package/dist/validation/primitives/date.js +2 -0
  122. package/dist/validation/primitives/date.mjs +2 -0
  123. package/dist/validation/primitives/number.d.mts +3 -0
  124. package/dist/validation/primitives/number.d.ts +3 -0
  125. package/dist/validation/primitives/number.js +2 -0
  126. package/dist/validation/primitives/number.mjs +2 -0
  127. package/dist/validation/primitives/text.d.mts +3 -0
  128. package/dist/validation/primitives/text.d.ts +3 -0
  129. package/dist/validation/primitives/text.js +2 -0
  130. package/dist/validation/primitives/text.mjs +2 -0
  131. package/dist/view-config.schema-BQ9tU_9G.js +2 -0
  132. package/dist/view-config.schema-BmjCQJ51.mjs +2 -0
  133. package/package.json +279 -3
@@ -0,0 +1,557 @@
1
+
2
+ import { r as Uuid } from "./utils-DbRMK8NI.mjs";
3
+ import { ColorId, CountryIso3, CurrencyCode, IconName } from "@standards/constants";
4
+ //#region src/types/computed.d.ts
5
+ declare const COMPUTED_RETURN_TYPES: readonly ["text", "number", "boolean", "date", "select", "multiselect"];
6
+ type ComputedReturnType = (typeof COMPUTED_RETURN_TYPES)[number];
7
+ interface ComputedOptionsSource {
8
+ objectName: string;
9
+ attributeName: string;
10
+ attributeId?: string;
11
+ }
12
+ //#endregion
13
+ //#region src/types/relation-properties.d.ts
14
+ /**
15
+ * Allowed attribute types in .qualifyWith()
16
+ *
17
+ * IMPORTANT: Complex types (formula, rollup, relation, file, user, document, richtext)
18
+ * are NOT supported to avoid duplicating backend behavior.
19
+ */
20
+ type PropertyType = "text" | "number" | "checkbox" | "date" | "phone" | "currency" | "status" | "select" | "multiselect" | "location";
21
+ /**
22
+ * Union of attribute types allowed as qualified relation properties.
23
+ *
24
+ * These are the same Attribute types used for object attributes,
25
+ * restricted to simple types that don't require complex backend duplication.
26
+ */
27
+ type PropertyAttribute = TextAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | SelectAttribute | MultiselectAttribute | LocationAttribute;
28
+ /**
29
+ * Schema defining properties for a qualified relation.
30
+ *
31
+ * Uses the same Attribute types as object attributes, enabling DRY builders:
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * relation("companies", "Companies")
36
+ * .to("companies").many()
37
+ * .qualifyWith(
38
+ * select("role", "Role").options([...]).required(),
39
+ * number("shares", "Shares").min(0),
40
+ * )
41
+ * ```
42
+ */
43
+ interface PropertySchema {
44
+ definitions: PropertyAttribute[];
45
+ }
46
+ /**
47
+ * Normalizes an attribute's `properties` field to a flat list of
48
+ * {@link PropertyAttribute}. Handles both the production {@link PropertySchema}
49
+ * shape (`{ definitions: [...] }`) and the raw-array shape used in test
50
+ * fixtures (`PropertyAttribute[]`).
51
+ */
52
+ declare function resolvePropertyDefinitions(attr: unknown): PropertyAttribute[];
53
+ /**
54
+ * Property attribute types that have an `options` array.
55
+ */
56
+ type OptionPropertyAttribute = SelectAttribute | StatusAttribute | MultiselectAttribute;
57
+ /**
58
+ * Type guard to check if a property attribute has options.
59
+ *
60
+ * @param attr - The property attribute to check
61
+ * @returns true if the attribute is a select, status, or multiselect type with options
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * for (const def of definitions) {
66
+ * if (hasOptions(def)) {
67
+ * // TypeScript knows def.options exists and is Option[]
68
+ * for (const option of def.options) {
69
+ * console.log(option.value);
70
+ * }
71
+ * }
72
+ * }
73
+ * ```
74
+ */
75
+ declare function hasOptions(attr: PropertyAttribute): attr is OptionPropertyAttribute;
76
+ //#endregion
77
+ //#region src/types/attributes.d.ts
78
+ declare const ATTRIBUTE_TYPES: readonly ["text", "richtext", "number", "checkbox", "date", "phone", "currency", "status", "location", "select", "multiselect", "user", "relation", "formula", "rollup", "document"];
79
+ type AttributeType = (typeof ATTRIBUTE_TYPES)[number];
80
+ /**
81
+ * Status group categorization
82
+ */
83
+ type StatusGroup = "idle" | "in_progress" | "finished";
84
+ /**
85
+ * Unified option type for select-like fields
86
+ */
87
+ interface Option {
88
+ value: string;
89
+ label: string;
90
+ color?: ColorId;
91
+ description?: string;
92
+ group?: StatusGroup;
93
+ /** Value of the inverse option for bilateral relations (e.g. "parent" → "child") */
94
+ inverse?: string;
95
+ archived?: boolean;
96
+ }
97
+ /**
98
+ * Attribute grouping for UI organization
99
+ */
100
+ interface AttributeGroup {
101
+ id: string;
102
+ label: string;
103
+ description?: string;
104
+ attributeIds: string[];
105
+ collapsible?: boolean;
106
+ collapsed?: boolean;
107
+ order?: number;
108
+ }
109
+ interface BaseAttribute<DefaultValueType = unknown> {
110
+ id?: Uuid;
111
+ objectId?: Uuid;
112
+ name: string;
113
+ label: string;
114
+ type: AttributeType;
115
+ required?: boolean;
116
+ placeholder?: string;
117
+ description?: string;
118
+ defaultValue?: DefaultValueType;
119
+ icon?: IconName;
120
+ order?: number;
121
+ hidden?: boolean;
122
+ archived?: boolean;
123
+ deprecated?: boolean;
124
+ system?: boolean;
125
+ unique?: boolean;
126
+ metadata?: Record<string, unknown>;
127
+ }
128
+ interface TextAttribute extends BaseAttribute<string> {
129
+ type: "text";
130
+ multiline?: boolean;
131
+ minLength?: number;
132
+ maxLength?: number;
133
+ pattern?: string;
134
+ format?: "email" | "url" | "slug";
135
+ }
136
+ type NumberUnit = "integer" | "decimal" | "percentage";
137
+ interface NumberAttribute extends BaseAttribute<number> {
138
+ type: "number";
139
+ min?: number;
140
+ max?: number;
141
+ unit?: NumberUnit;
142
+ decimals?: number;
143
+ renderAs?: "number" | "rating";
144
+ }
145
+ interface CheckboxAttribute extends BaseAttribute<boolean> {
146
+ type: "checkbox";
147
+ }
148
+ type DateFormat = "short" | "long" | "full" | "relative";
149
+ type DateValue = string | "today";
150
+ type TimeFormat = "12h" | "24h";
151
+ /** Stored value of a date attribute configured with `.endDate()`. */
152
+ interface DateRangeValue {
153
+ start: string;
154
+ end: string | null;
155
+ }
156
+ /**
157
+ * How much of a calendar date the value is meant to carry. The stored value is
158
+ * always a full day; a narrower precision says the day (and the month, for a
159
+ * year) is not part of the fact.
160
+ */
161
+ type DatePrecision = "day" | "month" | "year";
162
+ interface DateAttribute extends BaseAttribute<string | DateRangeValue> {
163
+ type: "date";
164
+ dateFormat?: DateFormat;
165
+ /** Defaults to "day". Refused with `includeTime` or `endDate` when narrower. */
166
+ precision?: DatePrecision;
167
+ minDate?: DateValue;
168
+ maxDate?: DateValue;
169
+ /** Values carry a time component; stored as full ISO UTC datetimes. */
170
+ includeTime?: boolean;
171
+ /** Values are ranges stored as { start, end } objects. */
172
+ endDate?: boolean;
173
+ /** Display format for the time component. Defaults to "24h". */
174
+ timeFormat?: TimeFormat;
175
+ }
176
+ interface Phone {
177
+ countryCode: CountryIso3;
178
+ phoneNumber: string;
179
+ }
180
+ interface PhoneAttribute extends BaseAttribute<Phone> {
181
+ type: "phone";
182
+ defaultCountryCode?: CountryIso3;
183
+ }
184
+ interface Currency {
185
+ code: CurrencyCode;
186
+ value: number;
187
+ }
188
+ interface CurrencyAttribute extends BaseAttribute<Currency> {
189
+ type: "currency";
190
+ defaultCurrency?: CurrencyCode;
191
+ allowedCurrencies?: CurrencyCode[];
192
+ /** Allow negative currency values (e.g. refunds, credits). Defaults to false. */
193
+ allowNegative?: boolean;
194
+ }
195
+ /**
196
+ * StatusAttribute - For workflow states with semantic grouping (idle/in_progress/finished)
197
+ * Use this for: Task status, Order status, Project phases, Process states
198
+ * Use SelectAttribute for: Categories, Types, simple choices without workflow
199
+ */
200
+ interface StatusAttribute extends BaseAttribute<string> {
201
+ type: "status";
202
+ options: Option[];
203
+ }
204
+ interface Location {
205
+ address?: string;
206
+ address2?: string;
207
+ city?: string;
208
+ state?: string;
209
+ postalCode?: string;
210
+ country?: CountryIso3;
211
+ latitude?: number;
212
+ longitude?: number;
213
+ }
214
+ type LocationGranularity = "full" | "address" | "city" | "state" | "country" | "coordinates";
215
+ interface LocationAttribute extends BaseAttribute<Location> {
216
+ type: "location";
217
+ granularity?: LocationGranularity;
218
+ defaultCountry?: CountryIso3;
219
+ allowedCountries?: CountryIso3[];
220
+ }
221
+ /**
222
+ * SelectAttribute - For simple single-choice selection
223
+ * Use this for: Categories, Document types, Departments, Priorities
224
+ * Options can be grouped (e.g., countries by continent) but no workflow logic
225
+ */
226
+ interface SelectAttribute extends BaseAttribute<string> {
227
+ type: "select";
228
+ options: Option[];
229
+ renderAs?: "badges";
230
+ }
231
+ interface MultiselectAttribute extends BaseAttribute<string[]> {
232
+ type: "multiselect";
233
+ options: Option[];
234
+ renderAs?: "badges";
235
+ }
236
+ type UserReferenceType = "user" | "agent";
237
+ interface UserAttribute extends BaseAttribute<string | string[]> {
238
+ type: "user";
239
+ types?: UserReferenceType[];
240
+ multiple?: boolean;
241
+ /** Each person added to the value is notified (`record.assigned`), when they can read the record. */
242
+ notifiesOnAssign?: boolean;
243
+ }
244
+ /**
245
+ * Wildcard marker for universal relations (can link to any object)
246
+ * Use with `.toAny()` builder method
247
+ */
248
+ declare const RELATION_TARGET_ANY: "*";
249
+ /**
250
+ * Configuration for bilateral synchronization (bidirectional relations)
251
+ */
252
+ interface BilateralConfig {
253
+ /** Target object containing the inverse attribute */
254
+ object: string;
255
+ /** Name of the inverse attribute */
256
+ attribute: string;
257
+ /** Optional cardinality override (inferred by default) */
258
+ cardinality?: "one" | "many";
259
+ /** Label for the inverse attribute when it is generated from this declaration. */
260
+ label?: string;
261
+ /** When true, this side owns the storage direction for qualified properties.
262
+ * Set to false on the inverse side (enriched at read time). */
263
+ storageOwner?: boolean;
264
+ }
265
+ /**
266
+ * Target object for a relation - defines which objects can be linked
267
+ */
268
+ interface RelationTarget {
269
+ /** Object name (e.g., "companies", "contacts") or "*" for any object */
270
+ object: string;
271
+ /**
272
+ * Display template for the label using mustache-like syntax
273
+ * @example "{name}" or "{firstName} {lastName} — {email}"
274
+ */
275
+ displayTemplate?: string;
276
+ /**
277
+ * Optional filter to restrict available records
278
+ * @example { status: "active" }
279
+ */
280
+ filter?: Record<string, unknown>;
281
+ }
282
+ /**
283
+ * Base properties shared by both single and multi relation attributes
284
+ *
285
+ * Note: Deletion behavior is always "restrict" - if a record is referenced
286
+ * by other records, it cannot be deleted until those references are removed.
287
+ * This is enforced by RecordService.deleteRecord() which throws
288
+ * RecordReferencedError when attempting to delete a referenced record.
289
+ */
290
+ interface RelationAttributeBase extends Omit<BaseAttribute<unknown>, "defaultValue"> {
291
+ type: "relation";
292
+ /** Target objects that can be linked */
293
+ targets: RelationTarget[];
294
+ /** Optional properties schema for qualified relations */
295
+ properties?: PropertySchema;
296
+ /** Configuration for bilateral synchronization (opt-in) */
297
+ bilateral?: BilateralConfig;
298
+ }
299
+ /**
300
+ * Single relation attribute (one-to-one or many-to-one)
301
+ * Stores a single record ID or null
302
+ */
303
+ interface SingleRelationAttribute extends RelationAttributeBase {
304
+ cardinality: "one";
305
+ defaultValue?: string | null;
306
+ }
307
+ /**
308
+ * Multi relation attribute (one-to-many or many-to-many)
309
+ * Stores an array of record IDs
310
+ */
311
+ interface MultiRelationAttribute extends RelationAttributeBase {
312
+ cardinality: "many";
313
+ defaultValue?: string[];
314
+ /** Maximum number of relations allowed */
315
+ maxItems?: number;
316
+ }
317
+ /**
318
+ * RelationAttribute links to other objects/records
319
+ * Discriminated union by cardinality for type-safe value handling
320
+ *
321
+ * @example Single relation (many-to-one)
322
+ * ```typescript
323
+ * relation("company", "Company")
324
+ * .to("companies")
325
+ * .required()
326
+ * // → Value: "rec-uuid-123" | null
327
+ * ```
328
+ *
329
+ * @example Multi relation (many-to-many)
330
+ * ```typescript
331
+ * relation("contacts", "Contacts")
332
+ * .to("contacts", { displayTemplate: "{firstName} {lastName}" })
333
+ * .many()
334
+ * .maxItems(5)
335
+ * // → Value: ["rec-1", "rec-2", ...]
336
+ * ```
337
+ *
338
+ * @example Polymorphic relation (multiple target objects)
339
+ * ```typescript
340
+ * relation("linked", "Linked Items")
341
+ * .to("companies")
342
+ * .to("contacts")
343
+ * .to("deals")
344
+ * .many()
345
+ * // → Can link to records from any of these objects
346
+ * ```
347
+ */
348
+ type RelationAttribute = SingleRelationAttribute | MultiRelationAttribute;
349
+ /**
350
+ * Check if a relation attribute is universal (can link to any object)
351
+ * Universal relations have `targets: [{ object: "*" }]`
352
+ */
353
+ /**
354
+ * The object names a relation attribute can point at, universal marker
355
+ * stripped. Any other attribute type — and a relation row whose config lost
356
+ * its `targets` — yields no names.
357
+ */
358
+ declare function relationTargetsOf(attribute: Attribute): string[];
359
+ declare function isUniversalRelation(attr: RelationAttribute): boolean;
360
+ /**
361
+ * Check if a relation attribute has bilateral synchronization enabled
362
+ */
363
+ declare function isBilateralRelation(attr: RelationAttribute): attr is RelationAttribute & {
364
+ bilateral: BilateralConfig;
365
+ };
366
+ /**
367
+ * Infer the cardinality of the inverse relation
368
+ * - one → many (contact.company ↔ company.contacts)
369
+ * - many → many (contact.tags ↔ tag.contacts)
370
+ */
371
+ declare function inferInverseCardinality(cardinality: "one" | "many"): "one" | "many";
372
+ /**
373
+ * RichtextAttribute - Rich text content using semantic markdown
374
+ *
375
+ * Stores content as semantic markdown string (with directives like :::callout).
376
+ * Parsed at runtime to Tiptap JSON for editing.
377
+ * Use this for: Notes, articles, descriptions, long-form content.
378
+ *
379
+ * @example
380
+ * ```typescript
381
+ * richtext("content", "Content").required()
382
+ * ```
383
+ */
384
+ interface RichtextAttribute extends BaseAttribute<string> {
385
+ type: "richtext";
386
+ }
387
+ type RichTextAttribute = RichtextAttribute;
388
+ /**
389
+ * Return type for formula expressions
390
+ */
391
+ type FormulaReturnType = ComputedReturnType;
392
+ /**
393
+ * FormulaAttribute - Computed value based on other attributes
394
+ *
395
+ * Formulas are calculated at read-time and are always read-only.
396
+ * Users cannot directly edit formula values.
397
+ *
398
+ * @example Simple calculation
399
+ * ```typescript
400
+ * formula("total", "Total")
401
+ * .expression("price * quantity")
402
+ * .returns("number")
403
+ * .decimals(2)
404
+ * ```
405
+ *
406
+ * @example With functions
407
+ * ```typescript
408
+ * formula("fullName", "Full Name")
409
+ * .expression("CONCAT(firstName, ' ', lastName)")
410
+ * .returns("text")
411
+ * ```
412
+ */
413
+ interface FormulaAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
414
+ type: "formula";
415
+ /** Expression to evaluate (e.g., "price * quantity") */
416
+ expression: string;
417
+ /** Expected return type for formatting */
418
+ returnType: FormulaReturnType;
419
+ /** Decimal places for number results */
420
+ decimals?: number;
421
+ /**
422
+ * ISO 4217 code a `number` result renders with — `123 456 €` instead of
423
+ * `123456` — for a formula over money (#3419). Presentation only: the
424
+ * stored value stays a number, sort, filter and aggregation are untouched,
425
+ * and `returnType` stays `"number"` because that IS what the expression
426
+ * returns. The rollup's `targetCurrencyCode` (#2644), mirrored. Absent →
427
+ * the bare number, exactly as before.
428
+ */
429
+ currencyCode?: CurrencyCode;
430
+ /** Source attribute for select-like computed options */
431
+ optionsSource?: ComputedOptionsSource;
432
+ /** Whether to allow relation references in the expression (e.g., "company.name") */
433
+ allowRelations?: boolean;
434
+ /** Formula is always not required (read-only) */
435
+ required: false;
436
+ }
437
+ /**
438
+ * Aggregation functions for rollup attributes
439
+ *
440
+ * Categories:
441
+ * - Numeric (sum, avg): Only for number and currency types
442
+ * - Date (earliest, latest): Only for date type
443
+ * - Count (count, countValues, countUniqueValues, countEmpty): Universal
444
+ * - Percent (percentEmpty, percentNotEmpty): Universal
445
+ * - Lookup (original): Returns all values as array, rendered as target type
446
+ */
447
+ type RollupFunction = "sum" | "avg" | "earliest" | "latest" | "count" | "countValues" | "countUniqueValues" | "countEmpty" | "percentEmpty" | "percentNotEmpty" | "original";
448
+ /**
449
+ * RollupAttribute - Aggregates values from related records
450
+ *
451
+ * Rollups are calculated and stored (denormalized) for performance.
452
+ * They are automatically recalculated when related records change.
453
+ * Users cannot directly edit rollup values.
454
+ *
455
+ * @example Sum of related amounts
456
+ * ```typescript
457
+ * rollup("totalOrders", "Total Orders")
458
+ * .from("orders") // relation attribute name
459
+ * .aggregate("amount") // target attribute to sum
460
+ * .using("sum")
461
+ * .decimals(2)
462
+ * ```
463
+ *
464
+ * @example Count of related records
465
+ * ```typescript
466
+ * rollup("orderCount", "Number of Orders")
467
+ * .from("orders")
468
+ * .using("count")
469
+ * ```
470
+ */
471
+ interface RollupAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
472
+ type: "rollup";
473
+ /** Name of the relation attribute on this object */
474
+ relationAttribute: string;
475
+ /**
476
+ * Dot notation path for multi-level traversal (Phase 4+)
477
+ * @example "orders.items" - traverse through orders to items
478
+ */
479
+ relationPath?: string;
480
+ /**
481
+ * Attribute name on the target object to aggregate. Absent for `count`,
482
+ * which aggregates the linked records themselves (#3571).
483
+ */
484
+ targetAttribute?: string;
485
+ /** Aggregation function to apply */
486
+ function: RollupFunction;
487
+ /** Decimal places for numeric results */
488
+ decimals?: number;
489
+ /** Rollup is always not required (read-only) */
490
+ required: false;
491
+ /**
492
+ * Cached type of the target attribute for display purposes
493
+ * Used when function="original" to render values as the target type
494
+ */
495
+ targetAttributeType?: AttributeType;
496
+ /**
497
+ * Cached currency code of a currency target, from its `defaultCurrency`
498
+ * (#2644). The stored rollup value stays a bare number; this is the
499
+ * schema-derived channel that lets a single-code sum/avg render with its
500
+ * symbol. Absent → the value renders bare, exactly as before.
501
+ *
502
+ * Named for what it holds — an ISO 4217 CODE — rather than the siblings'
503
+ * `targetAttribute*` prefix: `targetAttributeCurrency` would read as a
504
+ * `Currency` value, which this deliberately is not.
505
+ */
506
+ targetCurrencyCode?: CurrencyCode;
507
+ /**
508
+ * Cached options from target attribute (for select/status/multiselect display)
509
+ * Required when function="original" and target is a select-like type
510
+ */
511
+ targetAttributeOptions?: Option[];
512
+ /** Source attribute for select-like computed options */
513
+ optionsSource?: ComputedOptionsSource;
514
+ }
515
+ /**
516
+ * DocumentAttribute - References structured documents.
517
+ *
518
+ * A DocumentAttribute references packs of anonymous files with typed edge
519
+ * properties.
520
+ *
521
+ * Every document attribute is multi by construction — the underlying storage
522
+ * (documents + files) supports 1 Doc → N files uniformly.
523
+ *
524
+ * @example
525
+ * ```typescript
526
+ * document("contracts", "Contrats")
527
+ * .accepts(["application/pdf"])
528
+ * ```
529
+ */
530
+ interface DocumentAttribute extends BaseAttribute<string[]> {
531
+ type: "document";
532
+ /**
533
+ * Schema for typed properties on the record→document edge.
534
+ * Symmetric with `RelationAttribute.properties`; populated by `.qualifyWith(...)`.
535
+ * Stored on `record_reference_edges.properties`, not on the document itself.
536
+ */
537
+ properties?: PropertySchema;
538
+ /** MIME prefixes/globs (e.g. "image/*", "application/pdf") applied to every file of the pack. */
539
+ accepts?: string[];
540
+ /** Hard ceiling in bytes applied to every file of the pack. */
541
+ maxFileSize?: number;
542
+ }
543
+ /**
544
+ * Union of every attribute definition supported by Standards objects.
545
+ *
546
+ * Use this type when code needs to inspect or render attributes generically
547
+ * across primitive, relation, computed, user, and document fields.
548
+ */
549
+ type Attribute = TextAttribute | RichtextAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | LocationAttribute | SelectAttribute | MultiselectAttribute | UserAttribute | RelationAttribute | FormulaAttribute | RollupAttribute | DocumentAttribute;
550
+ /**
551
+ * Check if an attribute supports sorting based on its type.
552
+ */
553
+ declare function isAttributeSortable(attr: {
554
+ type: AttributeType;
555
+ }): boolean;
556
+ //#endregion
557
+ export { resolvePropertyDefinitions as $, RelationTarget as A, TimeFormat as B, NumberAttribute as C, PhoneAttribute as D, Phone as E, SelectAttribute as F, isBilateralRelation as G, UserReferenceType as H, SingleRelationAttribute as I, OptionPropertyAttribute as J, isUniversalRelation as K, StatusAttribute as L, RichtextAttribute as M, RollupAttribute as N, RELATION_TARGET_ANY as O, RollupFunction as P, hasOptions as Q, StatusGroup as R, MultiselectAttribute as S, Option as T, inferInverseCardinality as U, UserAttribute as V, isAttributeSortable as W, PropertySchema as X, PropertyAttribute as Y, PropertyType as Z, FormulaReturnType as _, BaseAttribute as a, LocationGranularity as b, Currency as c, DateFormat as d, COMPUTED_RETURN_TYPES as et, DatePrecision as f, FormulaAttribute as g, DocumentAttribute as h, AttributeType as i, RichTextAttribute as j, RelationAttribute as k, CurrencyAttribute as l, DateValue as m, Attribute as n, ComputedReturnType as nt, BilateralConfig as o, DateRangeValue as p, relationTargetsOf as q, AttributeGroup as r, CheckboxAttribute as s, ATTRIBUTE_TYPES as t, ComputedOptionsSource as tt, DateAttribute as u, Location as v, NumberUnit as w, MultiRelationAttribute as x, LocationAttribute as y, TextAttribute as z };