@standards/schema 1.0.0-alpha.413 → 1.0.0-alpha.415

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 (136) hide show
  1. package/dist/all-Bldqj4jl.d.ts +4360 -0
  2. package/dist/all-BxsoHW0V.js +4 -0
  3. package/dist/all-C27HT84u.mjs +4 -0
  4. package/dist/all-CmG4j3B_.d.mts +4360 -0
  5. package/dist/api/index.d.mts +376 -709
  6. package/dist/api/index.d.ts +376 -709
  7. package/dist/api/index.js +1 -1
  8. package/dist/api/index.mjs +1 -1
  9. package/dist/{exceptions-BHqt4Omx.d.ts → exceptions-BIqEbF4H.d.mts} +0 -1
  10. package/dist/{exceptions-BHqt4Omx.d.mts → exceptions-BIqEbF4H.d.ts} +0 -1
  11. package/dist/exceptions.d.mts +1 -1
  12. package/dist/exceptions.d.ts +1 -1
  13. package/dist/exceptions.js +1 -1
  14. package/dist/exceptions.mjs +1 -1
  15. package/dist/{index-CkhBfmkf.d.mts → index-BGdQIO0V.d.mts} +535 -524
  16. package/dist/{index-C8VygCbt.d.ts → index-DIo9VcVh.d.ts} +535 -524
  17. package/dist/index.d.mts +5 -10
  18. package/dist/index.d.ts +5 -10
  19. package/dist/index.js +1653 -1
  20. package/dist/index.mjs +1653 -1
  21. package/dist/primitives-DpBFjzxV.mjs +11 -0
  22. package/dist/primitives-s7GS1T3w.js +11 -0
  23. package/dist/record-operation-C-qr4zs3.js +2 -0
  24. package/dist/record-operation-DM8ZJvmH.mjs +2 -0
  25. package/dist/{utils-BT8u9zYO.d.mts → utils-CIVBFpC3.d.mts} +1 -1
  26. package/dist/{utils-CChBw_3d.d.ts → utils-iNW5feob.d.ts} +1 -1
  27. package/dist/utils.d.mts +1 -1
  28. package/dist/utils.d.ts +1 -1
  29. package/dist/validation/all.d.mts +1 -4
  30. package/dist/validation/all.d.ts +1 -4
  31. package/dist/validation/all.js +1 -1
  32. package/dist/validation/all.mjs +1 -1
  33. package/package.json +2 -172
  34. package/dist/all-B9epSh3g.mjs +0 -2
  35. package/dist/all-Cg6JJd0x.d.ts +0 -2967
  36. package/dist/all-CkcnOJxd.d.mts +0 -2967
  37. package/dist/all-iuPkq14_.js +0 -2
  38. package/dist/attributes-DW19xkoM.d.ts +0 -561
  39. package/dist/attributes-QBySx30F.d.mts +0 -561
  40. package/dist/checkbox-O7Onsazk.d.mts +0 -10
  41. package/dist/checkbox-u5bh3lq-.d.ts +0 -10
  42. package/dist/config-YSw2jzWj.js +0 -2
  43. package/dist/config-iUwnquKr.mjs +0 -2
  44. package/dist/core-DAxRlJ5i.js +0 -2
  45. package/dist/core-rKI7Q9_U.mjs +0 -2
  46. package/dist/date-Bn8fqwCq.d.ts +0 -23
  47. package/dist/date-D7JMxFgD.d.mts +0 -23
  48. package/dist/index-BFKJEyq-.d.ts +0 -52
  49. package/dist/index-Cc3a-97k.d.ts +0 -271
  50. package/dist/index-CtmwL85u.d.ts +0 -100
  51. package/dist/index-DR5eSskq.d.mts +0 -271
  52. package/dist/index-D_IPqiMd.d.mts +0 -100
  53. package/dist/index-jE6uAt4g.d.mts +0 -52
  54. package/dist/number-DGfXEFnt.d.mts +0 -10
  55. package/dist/number-DiV9wvFE.d.ts +0 -10
  56. package/dist/object-5-wnsH0o.js +0 -4
  57. package/dist/object-BF5y6bgs.mjs +0 -4
  58. package/dist/objects-B4OojzI4.d.mts +0 -478
  59. package/dist/objects-Cvd1pe1g.d.ts +0 -478
  60. package/dist/phone-BGJea5sr.mjs +0 -2
  61. package/dist/phone-DHXyNkVY.js +0 -2
  62. package/dist/primitives-BCJLtpaI.mjs +0 -11
  63. package/dist/primitives-CVbrjJ24.js +0 -11
  64. package/dist/record-aggregates-BrLE4IsX.mjs +0 -2
  65. package/dist/record-aggregates-BuOfVWPJ.js +0 -2
  66. package/dist/record-operation-B4DrBgkp.mjs +0 -2
  67. package/dist/record-operation-BA4V9LB0.js +0 -2
  68. package/dist/rolldown-runtime-DETHMehu.js +0 -2
  69. package/dist/text-8GklpZzL.d.mts +0 -10
  70. package/dist/text-BaxaZ5Vv.mjs +0 -2
  71. package/dist/text-Biomo4m8.d.ts +0 -10
  72. package/dist/text-DVrTGjjX.js +0 -2
  73. package/dist/validation/complex/currency.d.mts +0 -13
  74. package/dist/validation/complex/currency.d.ts +0 -13
  75. package/dist/validation/complex/currency.js +0 -2
  76. package/dist/validation/complex/currency.mjs +0 -2
  77. package/dist/validation/complex/location.d.mts +0 -20
  78. package/dist/validation/complex/location.d.ts +0 -20
  79. package/dist/validation/complex/location.js +0 -2
  80. package/dist/validation/complex/location.mjs +0 -2
  81. package/dist/validation/complex/phone.d.mts +0 -20
  82. package/dist/validation/complex/phone.d.ts +0 -20
  83. package/dist/validation/complex/phone.js +0 -2
  84. package/dist/validation/complex/phone.mjs +0 -2
  85. package/dist/validation/complex/relation.d.mts +0 -23
  86. package/dist/validation/complex/relation.d.ts +0 -23
  87. package/dist/validation/complex/relation.js +0 -2
  88. package/dist/validation/complex/relation.mjs +0 -2
  89. package/dist/validation/complex/richtext.d.mts +0 -11
  90. package/dist/validation/complex/richtext.d.ts +0 -11
  91. package/dist/validation/complex/richtext.js +0 -2
  92. package/dist/validation/complex/richtext.mjs +0 -2
  93. package/dist/validation/complex/select.d.mts +0 -18
  94. package/dist/validation/complex/select.d.ts +0 -18
  95. package/dist/validation/complex/select.js +0 -2
  96. package/dist/validation/complex/select.mjs +0 -2
  97. package/dist/validation/complex/user.d.mts +0 -11
  98. package/dist/validation/complex/user.d.ts +0 -11
  99. package/dist/validation/complex/user.js +0 -2
  100. package/dist/validation/complex/user.mjs +0 -2
  101. package/dist/validation/computed/formula.d.mts +0 -12
  102. package/dist/validation/computed/formula.d.ts +0 -12
  103. package/dist/validation/computed/formula.js +0 -2
  104. package/dist/validation/computed/formula.mjs +0 -2
  105. package/dist/validation/computed/rollup.d.mts +0 -12
  106. package/dist/validation/computed/rollup.d.ts +0 -12
  107. package/dist/validation/computed/rollup.js +0 -2
  108. package/dist/validation/computed/rollup.mjs +0 -2
  109. package/dist/validation/config/index.d.mts +0 -3
  110. package/dist/validation/config/index.d.ts +0 -3
  111. package/dist/validation/config/index.js +0 -2
  112. package/dist/validation/config/index.mjs +0 -2
  113. package/dist/validation/core/index.d.mts +0 -3
  114. package/dist/validation/core/index.d.ts +0 -3
  115. package/dist/validation/core/index.js +0 -2
  116. package/dist/validation/core/index.mjs +0 -2
  117. package/dist/validation/object/index.d.mts +0 -3
  118. package/dist/validation/object/index.d.ts +0 -3
  119. package/dist/validation/object/index.js +0 -2
  120. package/dist/validation/object/index.mjs +0 -2
  121. package/dist/validation/primitives/checkbox.d.mts +0 -3
  122. package/dist/validation/primitives/checkbox.d.ts +0 -3
  123. package/dist/validation/primitives/checkbox.js +0 -2
  124. package/dist/validation/primitives/checkbox.mjs +0 -2
  125. package/dist/validation/primitives/date.d.mts +0 -3
  126. package/dist/validation/primitives/date.d.ts +0 -3
  127. package/dist/validation/primitives/date.js +0 -2
  128. package/dist/validation/primitives/date.mjs +0 -2
  129. package/dist/validation/primitives/number.d.mts +0 -3
  130. package/dist/validation/primitives/number.d.ts +0 -3
  131. package/dist/validation/primitives/number.js +0 -2
  132. package/dist/validation/primitives/number.mjs +0 -2
  133. package/dist/validation/primitives/text.d.mts +0 -3
  134. package/dist/validation/primitives/text.d.ts +0 -3
  135. package/dist/validation/primitives/text.js +0 -2
  136. package/dist/validation/primitives/text.mjs +0 -2
@@ -1,561 +0,0 @@
1
-
2
- import { Uuid } from "./utils-CChBw_3d.js";
3
- import { ColorId, CountryIso3, CurrencyCode, IconName } from "@standards/constants";
4
- //#region src/types/computed.d.ts
5
- export declare const COMPUTED_RETURN_TYPES: readonly ["text", "number", "boolean", "date", "select", "multiselect"];
6
- export type ComputedReturnType = (typeof COMPUTED_RETURN_TYPES)[number];
7
- export 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
- export 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
- export 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
- export 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
- export declare function resolvePropertyDefinitions(attr: unknown): PropertyAttribute[];
53
- /**
54
- * Property attribute types that have an `options` array.
55
- */
56
- export 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
- export declare function hasOptions(attr: PropertyAttribute): attr is OptionPropertyAttribute;
76
- //#endregion
77
- //#region src/types/attributes.d.ts
78
- export declare const ATTRIBUTE_TYPES: readonly ["text", "richtext", "number", "checkbox", "date", "phone", "currency", "status", "location", "select", "multiselect", "user", "relation", "formula", "rollup", "document"];
79
- export type AttributeType = (typeof ATTRIBUTE_TYPES)[number];
80
- /**
81
- * Status group categorization
82
- */
83
- export type StatusGroup = "idle" | "in_progress" | "finished";
84
- /**
85
- * Unified option type for select-like fields
86
- */
87
- export 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
- export 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
- export 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
- export 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
- export type NumberUnit = "integer" | "decimal" | "percentage";
137
- export 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
- export interface CheckboxAttribute extends BaseAttribute<boolean> {
146
- type: "checkbox";
147
- }
148
- export type DateFormat = "short" | "long" | "full" | "relative";
149
- export type DateValue = string | "today";
150
- export type TimeFormat = "12h" | "24h";
151
- /** Stored value of a date attribute configured with `.endDate()`. */
152
- export 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
- export type DatePrecision = "day" | "month" | "year";
162
- export 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
- export interface Phone {
177
- countryCode: CountryIso3;
178
- phoneNumber: string;
179
- }
180
- export interface PhoneAttribute extends BaseAttribute<Phone> {
181
- type: "phone";
182
- defaultCountryCode?: CountryIso3;
183
- }
184
- export interface Currency {
185
- code: CurrencyCode;
186
- value: number;
187
- }
188
- export 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
- export interface StatusAttribute extends BaseAttribute<string> {
201
- type: "status";
202
- options: Option[];
203
- }
204
- export 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
- export type LocationGranularity = "full" | "address" | "city" | "state" | "country" | "coordinates";
215
- export 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
- export interface SelectAttribute extends BaseAttribute<string> {
227
- type: "select";
228
- options: Option[];
229
- renderAs?: "badges";
230
- }
231
- export interface MultiselectAttribute extends BaseAttribute<string[]> {
232
- type: "multiselect";
233
- options: Option[];
234
- renderAs?: "badges";
235
- }
236
- export type UserReferenceType = "user" | "agent";
237
- export 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
- * The value holds actor ids — members and agents, within `types` — named by
245
- * each actor's current display name rather than looked up as users. (The
246
- * built-in `createdBy` / `lastUpdatedBy` also name API keys and the system.)
247
- */
248
- actors?: boolean;
249
- }
250
- /**
251
- * Wildcard marker for universal relations (can link to any object)
252
- * Use with `.toAny()` builder method
253
- */
254
- export declare const RELATION_TARGET_ANY: "*";
255
- /**
256
- * Configuration for bilateral synchronization (bidirectional relations)
257
- */
258
- export interface BilateralConfig {
259
- /** Target object containing the inverse attribute */
260
- object: string;
261
- /** Name of the inverse attribute */
262
- attribute: string;
263
- /** Optional cardinality override (inferred by default) */
264
- cardinality?: "one" | "many";
265
- /** Label for the inverse attribute when it is generated from this declaration. */
266
- label?: string;
267
- /** When true, this side owns the storage direction for qualified properties.
268
- * Set to false on the inverse side (enriched at read time). */
269
- storageOwner?: boolean;
270
- }
271
- /**
272
- * Target object for a relation - defines which objects can be linked
273
- */
274
- export interface RelationTarget {
275
- /** Object name (e.g., "companies", "contacts") or "*" for any object */
276
- object: string;
277
- /**
278
- * Display template for the label using mustache-like syntax
279
- * @example "{name}" or "{firstName} {lastName} — {email}"
280
- */
281
- displayTemplate?: string;
282
- /**
283
- * Optional filter to restrict available records
284
- * @example { status: "active" }
285
- */
286
- filter?: Record<string, unknown>;
287
- }
288
- /**
289
- * Base properties shared by both single and multi relation attributes
290
- *
291
- * Note: Deletion behavior is always "restrict" - if a record is referenced
292
- * by other records, it cannot be deleted until those references are removed.
293
- * This is enforced by RecordService.deleteRecord() which throws
294
- * RecordReferencedError when attempting to delete a referenced record.
295
- */
296
- interface RelationAttributeBase extends Omit<BaseAttribute<unknown>, "defaultValue"> {
297
- type: "relation";
298
- /** Target objects that can be linked */
299
- targets: RelationTarget[];
300
- /** Optional properties schema for qualified relations */
301
- properties?: PropertySchema;
302
- /** Configuration for bilateral synchronization (opt-in) */
303
- bilateral?: BilateralConfig;
304
- }
305
- /**
306
- * Single relation attribute (one-to-one or many-to-one)
307
- * Stores a single record ID or null
308
- */
309
- export interface SingleRelationAttribute extends RelationAttributeBase {
310
- cardinality: "one";
311
- defaultValue?: string | null;
312
- }
313
- /**
314
- * Multi relation attribute (one-to-many or many-to-many)
315
- * Stores an array of record IDs
316
- */
317
- export interface MultiRelationAttribute extends RelationAttributeBase {
318
- cardinality: "many";
319
- defaultValue?: string[];
320
- /** Maximum number of relations allowed */
321
- maxItems?: number;
322
- }
323
- /**
324
- * RelationAttribute links to other objects/records
325
- * Discriminated union by cardinality for type-safe value handling
326
- *
327
- * @example Single relation (many-to-one)
328
- * ```typescript
329
- * relation("company", "Company")
330
- * .to("companies")
331
- * .required()
332
- * // → Value: "rec-uuid-123" | null
333
- * ```
334
- *
335
- * @example Multi relation (many-to-many)
336
- * ```typescript
337
- * relation("contacts", "Contacts")
338
- * .to("contacts", { displayTemplate: "{firstName} {lastName}" })
339
- * .many()
340
- * .maxItems(5)
341
- * // → Value: ["rec-1", "rec-2", ...]
342
- * ```
343
- *
344
- * @example Polymorphic relation (multiple target objects)
345
- * ```typescript
346
- * relation("linked", "Linked Items")
347
- * .to("companies")
348
- * .to("contacts")
349
- * .to("deals")
350
- * .many()
351
- * // → Can link to records from any of these objects
352
- * ```
353
- */
354
- export type RelationAttribute = SingleRelationAttribute | MultiRelationAttribute;
355
- /**
356
- * Check if a relation attribute is universal (can link to any object)
357
- * Universal relations have `targets: [{ object: "*" }]`
358
- */
359
- /**
360
- * The object names a relation attribute can point at, universal marker
361
- * stripped. Any other attribute type — and a relation row whose config lost
362
- * its `targets` — yields no names.
363
- */
364
- export declare function relationTargetsOf(attribute: Attribute): string[];
365
- export declare function isUniversalRelation(attr: RelationAttribute): boolean;
366
- /**
367
- * Check if a relation attribute has bilateral synchronization enabled
368
- */
369
- export declare function isBilateralRelation(attr: RelationAttribute): attr is RelationAttribute & {
370
- bilateral: BilateralConfig;
371
- };
372
- /**
373
- * Infer the cardinality of the inverse relation
374
- * - one → many (contact.company ↔ company.contacts)
375
- * - many → many (contact.tags ↔ tag.contacts)
376
- */
377
- export declare function inferInverseCardinality(cardinality: "one" | "many"): "one" | "many";
378
- /**
379
- * RichtextAttribute - Rich text content using semantic markdown
380
- *
381
- * Stores content as semantic markdown string (with directives like :::callout).
382
- * Parsed at runtime to Tiptap JSON for editing.
383
- * Use this for: Notes, articles, descriptions, long-form content.
384
- *
385
- * @example
386
- * ```typescript
387
- * richtext("content", "Content").required()
388
- * ```
389
- */
390
- export interface RichtextAttribute extends BaseAttribute<string> {
391
- type: "richtext";
392
- }
393
- /**
394
- * Return type for formula expressions
395
- */
396
- export type FormulaReturnType = ComputedReturnType;
397
- /**
398
- * FormulaAttribute - Computed value based on other attributes
399
- *
400
- * Formulas are calculated at read-time and are always read-only.
401
- * Users cannot directly edit formula values.
402
- *
403
- * @example Simple calculation
404
- * ```typescript
405
- * formula("total", "Total")
406
- * .expression("price * quantity")
407
- * .returns("number")
408
- * .decimals(2)
409
- * ```
410
- *
411
- * @example With functions
412
- * ```typescript
413
- * formula("fullName", "Full Name")
414
- * .expression("CONCAT(firstName, ' ', lastName)")
415
- * .returns("text")
416
- * ```
417
- */
418
- export interface FormulaAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
419
- type: "formula";
420
- /** Expression to evaluate (e.g., "price * quantity") */
421
- expression: string;
422
- /** Expected return type for formatting */
423
- returnType: FormulaReturnType;
424
- /** Decimal places for number results */
425
- decimals?: number;
426
- /**
427
- * ISO 4217 code a `number` result renders with — `123 456 €` instead of
428
- * `123456` — for a formula over money (#3419). Presentation only: the
429
- * stored value stays a number, sort, filter and aggregation are untouched,
430
- * and `returnType` stays `"number"` because that IS what the expression
431
- * returns. The rollup's `targetCurrencyCode` (#2644), mirrored. Absent →
432
- * the bare number, exactly as before.
433
- */
434
- currencyCode?: CurrencyCode;
435
- /** Source attribute for select-like computed options */
436
- optionsSource?: ComputedOptionsSource;
437
- /** Whether to allow relation references in the expression (e.g., "company.name") */
438
- allowRelations?: boolean;
439
- /** Formula is always not required (read-only) */
440
- required: false;
441
- }
442
- /**
443
- * Aggregation functions for rollup attributes
444
- *
445
- * Categories:
446
- * - Numeric (sum, avg): Only for number and currency types
447
- * - Date (earliest, latest): Only for date type
448
- * - Count (count, countValues, countUniqueValues, countEmpty): Universal
449
- * - Percent (percentEmpty, percentNotEmpty): Universal
450
- * - Lookup (original): Returns all values as array, rendered as target type
451
- */
452
- export type RollupFunction = "sum" | "avg" | "earliest" | "latest" | "count" | "countValues" | "countUniqueValues" | "countEmpty" | "percentEmpty" | "percentNotEmpty" | "original";
453
- /**
454
- * RollupAttribute - Aggregates values from related records
455
- *
456
- * Rollups are calculated and stored (denormalized) for performance.
457
- * They are automatically recalculated when related records change.
458
- * Users cannot directly edit rollup values.
459
- *
460
- * @example Sum of related amounts
461
- * ```typescript
462
- * rollup("totalOrders", "Total Orders")
463
- * .from("orders") // relation attribute name
464
- * .aggregate("amount") // target attribute to sum
465
- * .using("sum")
466
- * .decimals(2)
467
- * ```
468
- *
469
- * @example Count of related records
470
- * ```typescript
471
- * rollup("orderCount", "Number of Orders")
472
- * .from("orders")
473
- * .using("count")
474
- * ```
475
- */
476
- export interface RollupAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
477
- type: "rollup";
478
- /** Name of the relation attribute on this object */
479
- relationAttribute: string;
480
- /**
481
- * Dot notation path for multi-level traversal (Phase 4+)
482
- * @example "orders.items" - traverse through orders to items
483
- */
484
- relationPath?: string;
485
- /**
486
- * Attribute name on the target object to aggregate. Absent for `count`,
487
- * which aggregates the linked records themselves (#3571).
488
- */
489
- targetAttribute?: string;
490
- /** Aggregation function to apply */
491
- function: RollupFunction;
492
- /** Decimal places for numeric results */
493
- decimals?: number;
494
- /** Rollup is always not required (read-only) */
495
- required: false;
496
- /**
497
- * Cached type of the target attribute for display purposes
498
- * Used when function="original" to render values as the target type
499
- */
500
- targetAttributeType?: AttributeType;
501
- /**
502
- * Cached currency code of a currency target, from its `defaultCurrency`
503
- * (#2644). The stored rollup value stays a bare number; this is the
504
- * schema-derived channel that lets a single-code sum/avg render with its
505
- * symbol. Absent → the value renders bare, exactly as before.
506
- *
507
- * Named for what it holds — an ISO 4217 CODE — rather than the siblings'
508
- * `targetAttribute*` prefix: `targetAttributeCurrency` would read as a
509
- * `Currency` value, which this deliberately is not.
510
- */
511
- targetCurrencyCode?: CurrencyCode;
512
- /**
513
- * Cached options from target attribute (for select/status/multiselect display)
514
- * Required when function="original" and target is a select-like type
515
- */
516
- targetAttributeOptions?: Option[];
517
- /** Source attribute for select-like computed options */
518
- optionsSource?: ComputedOptionsSource;
519
- }
520
- /**
521
- * DocumentAttribute - References structured documents.
522
- *
523
- * A DocumentAttribute references packs of anonymous files with typed edge
524
- * properties.
525
- *
526
- * Every document attribute is multi by construction — the underlying storage
527
- * (documents + files) supports 1 Doc → N files uniformly.
528
- *
529
- * @example
530
- * ```typescript
531
- * document("contracts", "Contrats")
532
- * .accepts(["application/pdf"])
533
- * ```
534
- */
535
- export interface DocumentAttribute extends BaseAttribute<string[]> {
536
- type: "document";
537
- /**
538
- * Schema for typed properties on the record→document edge.
539
- * Symmetric with `RelationAttribute.properties`; populated by `.qualifyWith(...)`.
540
- * Stored on `record_reference_edges.properties`, not on the document itself.
541
- */
542
- properties?: PropertySchema;
543
- /** MIME prefixes/globs (e.g. "image/*", "application/pdf") applied to every file of the pack. */
544
- accepts?: string[];
545
- /** Hard ceiling in bytes applied to every file of the pack. */
546
- maxFileSize?: number;
547
- }
548
- /**
549
- * Union of every attribute definition supported by Standards objects.
550
- *
551
- * Use this type when code needs to inspect or render attributes generically
552
- * across primitive, relation, computed, user, and document fields.
553
- */
554
- export type Attribute = TextAttribute | RichtextAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | LocationAttribute | SelectAttribute | MultiselectAttribute | UserAttribute | RelationAttribute | FormulaAttribute | RollupAttribute | DocumentAttribute;
555
- /**
556
- * Check if an attribute supports sorting based on its type.
557
- */
558
- export declare function isAttributeSortable(attr: {
559
- type: AttributeType;
560
- }): boolean;
561
- //#endregion