@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-B7Dlrtnx.js";
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 };
@@ -0,0 +1,11 @@
1
+
2
+ import { s as CheckboxAttribute } from "./attributes-aTeqx6cK.mjs";
3
+ import { r as ValidationMessages } from "./index-3HZjBOpj.mjs";
4
+ import { z as z$1 } from "zod";
5
+ //#region src/validation/primitives/checkbox.d.ts
6
+ /**
7
+ * Create a Zod schema for a checkbox attribute
8
+ */
9
+ declare function createCheckboxValidator(_attr: CheckboxAttribute, _messages?: ValidationMessages): z$1.ZodBoolean;
10
+ //#endregion
11
+ export { createCheckboxValidator as t };
@@ -0,0 +1,11 @@
1
+
2
+ import { s as CheckboxAttribute } from "./attributes-kAhQzg8-.js";
3
+ import { r as ValidationMessages } from "./index-DLO8JpnY.js";
4
+ import { z as z$1 } from "zod";
5
+ //#region src/validation/primitives/checkbox.d.ts
6
+ /**
7
+ * Create a Zod schema for a checkbox attribute
8
+ */
9
+ declare function createCheckboxValidator(_attr: CheckboxAttribute, _messages?: ValidationMessages): z$1.ZodBoolean;
10
+ //#endregion
11
+ export { createCheckboxValidator as t };
@@ -0,0 +1,2 @@
1
+ /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ import{ValidationError as e}from"./exceptions.mjs";import{d as t,f as n,p as r,t as i,u as a}from"./attribute-validators-DRqhAt2t.mjs";import{z as o}from"zod";const s=[`text`,`number`,`boolean`,`date`,`select`,`multiselect`],c=o.object({placeholder:o.string().optional(),description:o.string().optional(),defaultValue:o.unknown().optional(),icon:o.string().optional(),order:o.number().int().optional(),hidden:o.boolean().optional(),archived:o.boolean().optional(),deprecated:o.boolean().optional(),metadata:o.record(o.string(),o.unknown()).optional()}),l=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`],u={relation:{icon:n.optional().describe(`Field icon from search_icons`)}},d={date:[`precision`],user:[`notifiesOnAssign`]};function wireOmittedConfigKeysFor(e){let t=u[e]??{};return[...l.filter(e=>!(e in t)),...d[e]??[]]}function wireHiddenTypeConfigMask(e){return Object.fromEntries((d[e]??[]).map(e=>[e,!0]))}function refuseForeignKeys(e,t,n=[]){let r=new Set(n);return function refuse(n,i,a,o=[]){let s=e[n];if(s!==void 0&&i!==void 0)for(let e of Object.keys(i))s.has(e)||r.has(e)||a.addIssue({code:`custom`,path:[...o,e],message:`"${e}" is not a ${n} ${t}; keys of ${n}: ${[...s].join(`, `)}`})}}const f=o.object({value:o.string().min(1).describe(`Stored value`),label:o.string().min(1).describe(`Label people see`),description:o.string().describe(`Extra context`).optional(),inverse:o.string().describe(`Paired option's value (symmetric)`).optional(),archived:o.boolean().describe(`Hides without deleting`).optional()}),p=o.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),m=f.extend({color:t}).strict(),h=m,g=f.extend({color:t,group:p}).strict(),_=f.extend({color:o.string().optional().describe(`A color id`),group:p.optional()}).strict(),v=new Set(_.keyof().options),y=[`options`,`targetAttributeOptions`];function withoutUnknownOptionKeys(e){let t=e;for(let n of y){let r=e[n];if(!Array.isArray(r))continue;let i=!1,o=r.map(e=>!a(e)||Object.keys(e).every(e=>v.has(e))?e:(i=!0,Object.fromEntries(Object.entries(e).filter(([e])=>v.has(e)))));i&&(t={...t,[n]:o})}let n=e.properties;if(a(n)&&Array.isArray(n.definitions)){let e=n.definitions,r=e.map(e=>a(e)?withoutUnknownOptionKeys(e):e);r.some((t,n)=>t!==e[n])&&(t={...t,properties:{...n,definitions:r}})}return t}const b=o.array(_).min(1).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`});function writeOptionsArraySchema(e){return o.array(e).min(1).max(r.optionsPerAttribute).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`})}const x=writeOptionsArraySchema(m),S=writeOptionsArraySchema(h),C=writeOptionsArraySchema(g),ee=o.object({object:o.string().min(1).describe(`Target object`),displayTemplate:o.string().optional().describe(`Linked record label template`),filter:o.record(o.string(),o.unknown()).optional().describe(`Restricts linkable records`)}),w=o.object({object:o.string().min(1).describe(`Other side's object`),attribute:o.string().min(1).describe(`Other side's attribute`),cardinality:o.enum([`one`,`many`]).optional().describe(`Other side's cardinality`),label:o.string().min(1).optional().describe(`Other side's label`),storageOwner:o.boolean().optional().describe(`Owns the join storage`)}),T=o.object({objectName:o.string().min(1).describe(`API name of the object whose options are mirrored`),attributeName:o.string().min(1).describe(`API name of the select/status attribute to mirror options from`),attributeId:o.string().optional().describe(`Id of the source attribute, resolved by the server`)}),E=c.extend({multiline:o.boolean().describe(`Renders as a multi-line textarea`).optional(),minLength:o.number().int().min(0).describe(`Minimum character count`).optional(),maxLength:o.number().int().min(1).describe(`Maximum character count`).optional(),pattern:o.string().describe(`Regular expression the value must match`).optional(),format:o.enum([`email`,`url`,`slug`]).describe(`Validates and renders as this format`).optional()}),D=c,O=c.extend({renderAs:o.enum([`number`,`rating`]).describe(`Plain number or a star rating`).optional(),min:o.number().describe(`Minimum allowed value`).optional(),max:o.number().describe(`Maximum allowed value`).optional(),unit:o.enum([`integer`,`decimal`,`percentage`]).describe(`How the value is stored and rendered`).optional(),decimals:o.number().int().min(0).max(10).describe(`Decimal places shown`).optional()}),k=c,A=c.extend({dateFormat:o.enum([`short`,`long`,`full`,`relative`]).describe(`How the date is rendered`).optional(),precision:o.enum([`day`,`month`,`year`]).describe(`Whether the value records a day, a month or a year`).optional(),minDate:o.string().describe(`Earliest allowed date (ISO)`).optional(),maxDate:o.string().describe(`Latest allowed date (ISO)`).optional(),includeTime:o.boolean().describe(`Also captures a time of day`).optional(),endDate:o.boolean().describe(`Paired with another date attribute as a range's end`).optional(),timeFormat:o.enum([`12h`,`24h`]).describe(`Clock format when a time is included`).optional()}),j=c.extend({defaultCountryCode:o.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),M=c.extend({defaultCurrency:o.string().length(3).describe(`ISO currency code preselected for new values`).optional(),allowedCurrencies:o.array(o.string().length(3)).describe(`ISO currency codes a value may use; any currency when omitted`).optional(),allowNegative:o.boolean().describe(`Whether a negative amount is accepted`).optional()}),N=c.extend({options:b.describe(`The workflow statuses, in order`)}),P=c.extend({granularity:o.enum([`full`,`address`,`city`,`state`,`country`,`coordinates`]).describe(`How precise a location must be captured`).optional(),defaultCountry:o.string().length(3).describe(`ISO country code preselected for new values`).optional(),allowedCountries:o.array(o.string().length(3)).describe(`ISO country codes a value may use; any country when omitted`).optional()}),F=c.extend({options:b.describe(`Options`),renderAs:o.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),I=c.extend({options:b.describe(`Options`),renderAs:o.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),L=c.extend({types:o.array(o.enum([`user`,`agent`])).min(1).optional().describe(`Which kinds of actor can be picked; both when omitted`),multiple:o.boolean().optional().describe(`Whether more than one actor can be picked`),notifiesOnAssign:o.boolean().optional().describe(`Whether each person added to the value is notified`)}),R={name:i.describe(`Property API name`),label:o.string().min(1).describe(`Label people see`),required:o.boolean().describe(`Required on every edge`).optional()},z={id:o.string().optional(),objectId:o.string().optional(),system:o.boolean().optional(),unique:o.boolean().optional()},B=Object.fromEntries(l.map(e=>[e,!0])),V=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],H=[...V,`select`,`multiselect`,`status`],U={text:E,number:O,checkbox:k,date:A,phone:j,currency:M,location:P,select:F,multiselect:I,status:N},W={...U,select:F.extend({options:x.describe(`Options`)}),multiselect:I.extend({options:S.describe(`Options`)}),status:N.extend({options:C.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>W[e].omit(B).omit(wireHiddenTypeConfigMask(e)).shape,storedPropertyMember=e=>o.object({...R,...z,type:o.literal(e).describe(`Property type`),...U[e].shape}).strip(),G=o.discriminatedUnion(`type`,H.map(storedPropertyMember)),K=o.object({definitions:o.array(G).min(1).max(r.optionsPerAttribute).describe(`Edge properties`)}).strip().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),q=refuseForeignKeys(Object.fromEntries(H.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(R),`type`]);function refuseForeignPropertyKeys(e,t){q(e.type,e,t)}const J=V.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>o.object({...R,type:e.length===1?o.literal(e[0]).describe(`Property type`):o.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),Y=o.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),o.object({...R,type:o.enum(V).describe(`Property type`),...J}).strict().superRefine(refuseForeignPropertyKeys)]),X=o.object({definitions:o.array(Y).min(1).max(r.optionsPerAttribute).describe(`Edge properties`)}).strict().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),Z=c.extend({targets:o.array(ee).min(1).describe(`Target object(s)`),cardinality:o.enum([`one`,`many`]).describe(`one or many`),maxItems:o.number().int().min(1).optional().describe(`Max linked records`),bilateral:w.optional().describe(`Syncs the other side's attribute`),properties:K.optional()}),Q=c.extend({expression:o.string().min(1).describe(`The formula expression, compiled against this object's attributes`),returnType:o.enum(s).describe(`The formula's result type`),decimals:o.number().int().min(0).max(10).optional().describe(`Decimal places shown for a number result`),currencyCode:o.string().length(3).optional().describe(`ISO 4217 code a number result renders with; presentation only`),allowRelations:o.boolean().optional().describe(`Whether the expression may read across a relation`),optionsSource:T.optional().describe(`Mirrors an option set`)}),te=c.extend({relationAttribute:o.string().min(1).optional().describe(`API name of the relation this rollup aggregates through`),relationPath:o.string().optional().describe(`Not supported yet — single-hop only`),targetAttribute:o.string().min(1).optional().describe(`API name of the attribute aggregated on the relation's target object; not read by count`),function:o.enum([`sum`,`avg`,`earliest`,`latest`,`count`,`countValues`,`countUniqueValues`,`countEmpty`,`percentEmpty`,`percentNotEmpty`,`original`]).describe(`The aggregation applied across the linked records`),decimals:o.number().int().min(0).max(10).optional().describe(`Decimal places shown for a numeric result`),targetAttributeType:o.string().optional().describe(`Server-set`),targetAttributeOptions:o.array(_).optional().describe(`Server-set`),targetCurrencyCode:o.string().length(3).optional().describe(`Server-set`),optionsSource:T.optional().describe(`Mirrors an option set`)});function rollupTargetIssue(e,t){if(e===`rollup`&&t.function!==`count`&&t.targetAttribute===void 0)return{path:[`targetAttribute`],message:`targetAttribute is required for a "${String(t.function)}" rollup`}}function datePrecisionIssues(e,t,n=[]){let r=[],i=t.precision;if(e===`date`&&i!==void 0&&i!==`day`)for(let e of[`includeTime`,`endDate`])t[e]===!0&&r.push({path:[...n,`precision`],message:`A "${String(i)}" precision cannot be combined with ${e}`});let o=t.properties;return a(o)&&Array.isArray(o.definitions)&&o.definitions.forEach((e,t)=>{a(e)&&r.push(...datePrecisionIssues(String(e.type),e,[...n,`properties`,`definitions`,t]))}),r}const $={text:E,richtext:D,number:O,checkbox:k,date:A,phone:j,currency:M,status:N,location:P,select:F,multiselect:I,user:L,relation:Z,formula:Q,rollup:te,document:c.extend({properties:K.optional(),accepts:o.array(o.string().min(1)).optional().describe("MIME prefixes or globs a file must match (e.g. `image/*`, `*.pdf`)"),maxFileSize:o.number().int().min(1).optional().describe(`Maximum file size in bytes`)})};function getAttributeConfigSchema(t){let n=$[t];if(!n)throw new e(`Unsupported attribute type: ${t}`,[]);return n}function parseAttributeConfig(e,t){let n=getAttributeConfigSchema(e).strip().parse(t),r=rollupTargetIssue(e,n);if(r)throw validationErrorFromIssues([r]);return n}function getAttributeConfigWriteSchema(e){let t=getAttributeConfigSchema(e).extend({icon:n.optional()});switch(e){case`select`:return t.extend({options:x.describe(`Options`)});case`multiselect`:return t.extend({options:S.describe(`Options`)});case`status`:return t.extend({options:C.describe(`Statuses`)});default:return t}}function validationErrorFromIssues(t){return e.fromZodErrors(t.map(e=>({path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message})))}function parseWriteSchema(e,t){let n=getAttributeConfigWriteSchema(e).strip().safeParse(t);if(!n.success)throw validationErrorFromIssues(n.error.issues);let r=rollupTargetIssue(e,n.data);if(r)throw validationErrorFromIssues([r]);let i=datePrecisionIssues(e,n.data);if(i.length>0)throw validationErrorFromIssues(i);return n.data}function parseAttributeConfigForCreate(e,t){return parseWriteSchema(e,t)}function validatePatchedIcon(t){if(!Object.prototype.hasOwnProperty.call(t,`icon`))return;let r=n.optional().safeParse(t.icon);if(!r.success)throw e.fromZodErrors(r.error.issues.map(e=>({path:[`icon`,...e.path.map(e=>typeof e==`symbol`?String(e):e)],message:e.message})))}function isSelectLike(e){return e===`select`||e===`multiselect`||e===`status`}function parseAttributeConfigForUpdate(e,t){let n=Object.prototype.hasOwnProperty.call(t,`options`),r=Object.prototype.hasOwnProperty.call(t,`icon`),i={...e,...t};if(validatePatchedIcon(t),n){let{icon:t,...n}=i,a=parseWriteSchema(e.type,r?i:n);return!r&&t!==void 0&&(a.icon=t),a}let a=e.options;isSelectLike(e.type)&&(i.options=[{value:`__legacy__`,label:`__legacy__`}]);let o=getAttributeConfigSchema(e.type).strip().safeParse(i);if(!o.success)throw validationErrorFromIssues(o.error.issues);let s=o.data,c=datePrecisionIssues(e.type,s);if(c.length>0)throw validationErrorFromIssues(c);return isSelectLike(e.type)&&(s.options=a),s}export{s as C,withoutUnknownOptionKeys as S,m as _,datePrecisionIssues as a,wireHiddenTypeConfigMask as b,h as c,parseAttributeConfigForUpdate as d,G as f,refuseForeignKeys as g,X as h,$ as i,parseAttributeConfig as l,K as m,u as n,getAttributeConfigSchema as o,Y as p,l as r,getAttributeConfigWriteSchema as s,V as t,parseAttributeConfigForCreate as u,p as v,wireOmittedConfigKeysFor as x,g as y};
@@ -0,0 +1,2 @@
1
+ /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ const e=require("./attribute-validators-WAoJbap5.js"),t=require("./exceptions.js");let n=require("zod");const r=[`text`,`number`,`boolean`,`date`,`select`,`multiselect`],i=n.z.object({placeholder:n.z.string().optional(),description:n.z.string().optional(),defaultValue:n.z.unknown().optional(),icon:n.z.string().optional(),order:n.z.number().int().optional(),hidden:n.z.boolean().optional(),archived:n.z.boolean().optional(),deprecated:n.z.boolean().optional(),metadata:n.z.record(n.z.string(),n.z.unknown()).optional()}),a=[`placeholder`,`description`,`defaultValue`,`icon`,`order`,`hidden`,`archived`,`deprecated`,`metadata`],o={relation:{icon:e.f.optional().describe(`Field icon from search_icons`)}},s={date:[`precision`],user:[`notifiesOnAssign`]};function wireOmittedConfigKeysFor(e){let t=o[e]??{};return[...a.filter(e=>!(e in t)),...s[e]??[]]}function wireHiddenTypeConfigMask(e){return Object.fromEntries((s[e]??[]).map(e=>[e,!0]))}function refuseForeignKeys(e,t,n=[]){let r=new Set(n);return function refuse(n,i,a,o=[]){let s=e[n];if(s!==void 0&&i!==void 0)for(let e of Object.keys(i))s.has(e)||r.has(e)||a.addIssue({code:`custom`,path:[...o,e],message:`"${e}" is not a ${n} ${t}; keys of ${n}: ${[...s].join(`, `)}`})}}const c=n.z.object({value:n.z.string().min(1).describe(`Stored value`),label:n.z.string().min(1).describe(`Label people see`),description:n.z.string().describe(`Extra context`).optional(),inverse:n.z.string().describe(`Paired option's value (symmetric)`).optional(),archived:n.z.boolean().describe(`Hides without deleting`).optional()}),l=n.z.enum([`idle`,`in_progress`,`finished`]).describe(`Workflow stage`),u=c.extend({color:e.d}).strict(),d=u,f=c.extend({color:e.d,group:l}).strict(),p=c.extend({color:n.z.string().optional().describe(`A color id`),group:l.optional()}).strict(),m=new Set(p.keyof().options),h=[`options`,`targetAttributeOptions`];function withoutUnknownOptionKeys(t){let n=t;for(let r of h){let i=t[r];if(!Array.isArray(i))continue;let a=!1,o=i.map(t=>!e.u(t)||Object.keys(t).every(e=>m.has(e))?t:(a=!0,Object.fromEntries(Object.entries(t).filter(([e])=>m.has(e)))));a&&(n={...n,[r]:o})}let r=t.properties;if(e.u(r)&&Array.isArray(r.definitions)){let t=r.definitions,i=t.map(t=>e.u(t)?withoutUnknownOptionKeys(t):t);i.some((e,n)=>e!==t[n])&&(n={...n,properties:{...r,definitions:i}})}return n}const g=n.z.array(p).min(1).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`});function writeOptionsArraySchema(t){return n.z.array(t).min(1).max(e.p.optionsPerAttribute).refine(e=>{let t=e.map(e=>e.value);return new Set(t).size===t.length},{message:`Duplicate option values are not allowed`})}const _=writeOptionsArraySchema(u),v=writeOptionsArraySchema(d),y=writeOptionsArraySchema(f),b=n.z.object({object:n.z.string().min(1).describe(`Target object`),displayTemplate:n.z.string().optional().describe(`Linked record label template`),filter:n.z.record(n.z.string(),n.z.unknown()).optional().describe(`Restricts linkable records`)}),x=n.z.object({object:n.z.string().min(1).describe(`Other side's object`),attribute:n.z.string().min(1).describe(`Other side's attribute`),cardinality:n.z.enum([`one`,`many`]).optional().describe(`Other side's cardinality`),label:n.z.string().min(1).optional().describe(`Other side's label`),storageOwner:n.z.boolean().optional().describe(`Owns the join storage`)}),S=n.z.object({objectName:n.z.string().min(1).describe(`API name of the object whose options are mirrored`),attributeName:n.z.string().min(1).describe(`API name of the select/status attribute to mirror options from`),attributeId:n.z.string().optional().describe(`Id of the source attribute, resolved by the server`)}),C=i.extend({multiline:n.z.boolean().describe(`Renders as a multi-line textarea`).optional(),minLength:n.z.number().int().min(0).describe(`Minimum character count`).optional(),maxLength:n.z.number().int().min(1).describe(`Maximum character count`).optional(),pattern:n.z.string().describe(`Regular expression the value must match`).optional(),format:n.z.enum([`email`,`url`,`slug`]).describe(`Validates and renders as this format`).optional()}),w=i,T=i.extend({renderAs:n.z.enum([`number`,`rating`]).describe(`Plain number or a star rating`).optional(),min:n.z.number().describe(`Minimum allowed value`).optional(),max:n.z.number().describe(`Maximum allowed value`).optional(),unit:n.z.enum([`integer`,`decimal`,`percentage`]).describe(`How the value is stored and rendered`).optional(),decimals:n.z.number().int().min(0).max(10).describe(`Decimal places shown`).optional()}),E=i,D=i.extend({dateFormat:n.z.enum([`short`,`long`,`full`,`relative`]).describe(`How the date is rendered`).optional(),precision:n.z.enum([`day`,`month`,`year`]).describe(`Whether the value records a day, a month or a year`).optional(),minDate:n.z.string().describe(`Earliest allowed date (ISO)`).optional(),maxDate:n.z.string().describe(`Latest allowed date (ISO)`).optional(),includeTime:n.z.boolean().describe(`Also captures a time of day`).optional(),endDate:n.z.boolean().describe(`Paired with another date attribute as a range's end`).optional(),timeFormat:n.z.enum([`12h`,`24h`]).describe(`Clock format when a time is included`).optional()}),O=i.extend({defaultCountryCode:n.z.string().length(3).describe(`ISO country code preselected in the dialer`).optional()}),k=i.extend({defaultCurrency:n.z.string().length(3).describe(`ISO currency code preselected for new values`).optional(),allowedCurrencies:n.z.array(n.z.string().length(3)).describe(`ISO currency codes a value may use; any currency when omitted`).optional(),allowNegative:n.z.boolean().describe(`Whether a negative amount is accepted`).optional()}),A=i.extend({options:g.describe(`The workflow statuses, in order`)}),j=i.extend({granularity:n.z.enum([`full`,`address`,`city`,`state`,`country`,`coordinates`]).describe(`How precise a location must be captured`).optional(),defaultCountry:n.z.string().length(3).describe(`ISO country code preselected for new values`).optional(),allowedCountries:n.z.array(n.z.string().length(3)).describe(`ISO country codes a value may use; any country when omitted`).optional()}),M=i.extend({options:g.describe(`Options`),renderAs:n.z.literal(`badges`).optional().describe(`Renders the chosen option as a colored badge`)}),N=i.extend({options:g.describe(`Options`),renderAs:n.z.literal(`badges`).optional().describe(`Renders the chosen options as colored badges`)}),P=i.extend({types:n.z.array(n.z.enum([`user`,`agent`])).min(1).optional().describe(`Which kinds of actor can be picked; both when omitted`),multiple:n.z.boolean().optional().describe(`Whether more than one actor can be picked`),notifiesOnAssign:n.z.boolean().optional().describe(`Whether each person added to the value is notified`)}),F={name:e.t.describe(`Property API name`),label:n.z.string().min(1).describe(`Label people see`),required:n.z.boolean().describe(`Required on every edge`).optional()},I={id:n.z.string().optional(),objectId:n.z.string().optional(),system:n.z.boolean().optional(),unique:n.z.boolean().optional()},L=Object.fromEntries(a.map(e=>[e,!0])),R=[`text`,`number`,`checkbox`,`date`,`phone`,`currency`,`location`],z=[...R,`select`,`multiselect`,`status`],B={text:C,number:T,checkbox:E,date:D,phone:O,currency:k,location:j,select:M,multiselect:N,status:A},V={...B,select:M.extend({options:_.describe(`Options`)}),multiselect:N.extend({options:v.describe(`Options`)}),status:A.extend({options:y.describe(`Statuses`)})},propertyWireConfigShapeFor=e=>V[e].omit(L).omit(wireHiddenTypeConfigMask(e)).shape,storedPropertyMember=e=>n.z.object({...F,...I,type:n.z.literal(e).describe(`Property type`),...B[e].shape}).strip(),H=n.z.discriminatedUnion(`type`,z.map(storedPropertyMember)),U=n.z.object({definitions:n.z.array(H).min(1).max(e.p.optionsPerAttribute).describe(`Edge properties`)}).strip().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),W=refuseForeignKeys(Object.fromEntries(z.map(e=>[e,new Set(Object.keys(propertyWireConfigShapeFor(e)))])),`property key`,[...Object.keys(F),`type`]);function refuseForeignPropertyKeys(e,t){W(e.type,e,t)}const G=R.reduce((e,t)=>(Object.assign(e,propertyWireConfigShapeFor(t)),e),{}),optionPropertyWireMember=e=>n.z.object({...F,type:e.length===1?n.z.literal(e[0]).describe(`Property type`):n.z.enum(e).describe(`Property type`),...propertyWireConfigShapeFor(e[0])}).strict(),K=n.z.discriminatedUnion(`type`,[optionPropertyWireMember([`select`,`multiselect`]),optionPropertyWireMember([`status`]),n.z.object({...F,type:n.z.enum(R).describe(`Property type`),...G}).strict().superRefine(refuseForeignPropertyKeys)]),q=n.z.object({definitions:n.z.array(K).min(1).max(e.p.optionsPerAttribute).describe(`Edge properties`)}).strict().describe(`Properties carried by the edge itself (role, share, since…), never a third object`),J=i.extend({targets:n.z.array(b).min(1).describe(`Target object(s)`),cardinality:n.z.enum([`one`,`many`]).describe(`one or many`),maxItems:n.z.number().int().min(1).optional().describe(`Max linked records`),bilateral:x.optional().describe(`Syncs the other side's attribute`),properties:U.optional()}),Y=i.extend({expression:n.z.string().min(1).describe(`The formula expression, compiled against this object's attributes`),returnType:n.z.enum(r).describe(`The formula's result type`),decimals:n.z.number().int().min(0).max(10).optional().describe(`Decimal places shown for a number result`),currencyCode:n.z.string().length(3).optional().describe(`ISO 4217 code a number result renders with; presentation only`),allowRelations:n.z.boolean().optional().describe(`Whether the expression may read across a relation`),optionsSource:S.optional().describe(`Mirrors an option set`)}),X=i.extend({relationAttribute:n.z.string().min(1).optional().describe(`API name of the relation this rollup aggregates through`),relationPath:n.z.string().optional().describe(`Not supported yet — single-hop only`),targetAttribute:n.z.string().min(1).optional().describe(`API name of the attribute aggregated on the relation's target object; not read by count`),function:n.z.enum([`sum`,`avg`,`earliest`,`latest`,`count`,`countValues`,`countUniqueValues`,`countEmpty`,`percentEmpty`,`percentNotEmpty`,`original`]).describe(`The aggregation applied across the linked records`),decimals:n.z.number().int().min(0).max(10).optional().describe(`Decimal places shown for a numeric result`),targetAttributeType:n.z.string().optional().describe(`Server-set`),targetAttributeOptions:n.z.array(p).optional().describe(`Server-set`),targetCurrencyCode:n.z.string().length(3).optional().describe(`Server-set`),optionsSource:S.optional().describe(`Mirrors an option set`)});function rollupTargetIssue(e,t){if(e===`rollup`&&t.function!==`count`&&t.targetAttribute===void 0)return{path:[`targetAttribute`],message:`targetAttribute is required for a "${String(t.function)}" rollup`}}function datePrecisionIssues(t,n,r=[]){let i=[],a=n.precision;if(t===`date`&&a!==void 0&&a!==`day`)for(let e of[`includeTime`,`endDate`])n[e]===!0&&i.push({path:[...r,`precision`],message:`A "${String(a)}" precision cannot be combined with ${e}`});let o=n.properties;return e.u(o)&&Array.isArray(o.definitions)&&o.definitions.forEach((t,n)=>{e.u(t)&&i.push(...datePrecisionIssues(String(t.type),t,[...r,`properties`,`definitions`,n]))}),i}const Z={text:C,richtext:w,number:T,checkbox:E,date:D,phone:O,currency:k,status:A,location:j,select:M,multiselect:N,user:P,relation:J,formula:Y,rollup:X,document:i.extend({properties:U.optional(),accepts:n.z.array(n.z.string().min(1)).optional().describe("MIME prefixes or globs a file must match (e.g. `image/*`, `*.pdf`)"),maxFileSize:n.z.number().int().min(1).optional().describe(`Maximum file size in bytes`)})};function getAttributeConfigSchema(e){let n=Z[e];if(!n)throw new t.ValidationError(`Unsupported attribute type: ${e}`,[]);return n}function parseAttributeConfig(e,t){let n=getAttributeConfigSchema(e).strip().parse(t),r=rollupTargetIssue(e,n);if(r)throw validationErrorFromIssues([r]);return n}function getAttributeConfigWriteSchema(t){let n=getAttributeConfigSchema(t).extend({icon:e.f.optional()});switch(t){case`select`:return n.extend({options:_.describe(`Options`)});case`multiselect`:return n.extend({options:v.describe(`Options`)});case`status`:return n.extend({options:y.describe(`Statuses`)});default:return n}}function validationErrorFromIssues(e){return t.ValidationError.fromZodErrors(e.map(e=>({path:e.path.map(e=>typeof e==`symbol`?String(e):e),message:e.message})))}function parseWriteSchema(e,t){let n=getAttributeConfigWriteSchema(e).strip().safeParse(t);if(!n.success)throw validationErrorFromIssues(n.error.issues);let r=rollupTargetIssue(e,n.data);if(r)throw validationErrorFromIssues([r]);let i=datePrecisionIssues(e,n.data);if(i.length>0)throw validationErrorFromIssues(i);return n.data}function parseAttributeConfigForCreate(e,t){return parseWriteSchema(e,t)}function validatePatchedIcon(n){if(!Object.prototype.hasOwnProperty.call(n,`icon`))return;let r=e.f.optional().safeParse(n.icon);if(!r.success)throw t.ValidationError.fromZodErrors(r.error.issues.map(e=>({path:[`icon`,...e.path.map(e=>typeof e==`symbol`?String(e):e)],message:e.message})))}function isSelectLike(e){return e===`select`||e===`multiselect`||e===`status`}function parseAttributeConfigForUpdate(e,t){let n=Object.prototype.hasOwnProperty.call(t,`options`),r=Object.prototype.hasOwnProperty.call(t,`icon`),i={...e,...t};if(validatePatchedIcon(t),n){let{icon:t,...n}=i,a=parseWriteSchema(e.type,r?i:n);return!r&&t!==void 0&&(a.icon=t),a}let a=e.options;isSelectLike(e.type)&&(i.options=[{value:`__legacy__`,label:`__legacy__`}]);let o=getAttributeConfigSchema(e.type).strip().safeParse(i);if(!o.success)throw validationErrorFromIssues(o.error.issues);let s=o.data,c=datePrecisionIssues(e.type,s);if(c.length>0)throw validationErrorFromIssues(c);return isSelectLike(e.type)&&(s.options=a),s}Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return withoutUnknownOptionKeys}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return datePrecisionIssues}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return wireHiddenTypeConfigMask}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return parseAttributeConfigForUpdate}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return refuseForeignKeys}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return parseAttributeConfig}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return getAttributeConfigSchema}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return getAttributeConfigWriteSchema}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return parseAttributeConfigForCreate}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return wireOmittedConfigKeysFor}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return f}});
@@ -0,0 +1,2 @@
1
+ /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ const e={required:e=>`${e.label} is required`,invalidType:(e,t)=>`${e.label} must be a ${t}`,minLength:(e,t)=>`${e.label} must be at least ${t} characters`,maxLength:(e,t)=>`${e.label} must be at most ${t} characters`,invalidPattern:e=>`${e.label} format is invalid`,minValue:(e,t)=>`${e.label} must be at least ${t}`,maxValue:(e,t)=>`${e.label} must be at most ${t}`,mustBeInteger:e=>`${e.label} must be an integer`,invalidDate:e=>`${e.label} must be a valid date`,invalidOption:(e,t)=>`${e.label} must be one of: ${t.join(`, `)}`,invalidId:e=>`${e.label} must be a valid ID`,maxItems:(e,t)=>`${e.label} must have at most ${t} item${t>1?`s`:``}`,invalidRichtext:e=>`${e.label} must be valid rich text content`,invalidPhone:e=>`${e.label} must be a valid phone number`,invalidCurrency:e=>`${e.label} must be a valid currency value`,invalidLocation:e=>`${e.label} must be a valid location`};function formatZodErrors(e){return e.issues.map(e=>({path:e.path.map(String),message:e.message}))}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return formatZodErrors}});
@@ -0,0 +1,2 @@
1
+ /*! © 2025-2026 AND YOU CREATE SAS (RCS Paris 940 190 614). Proprietary — see LICENSE (Standards SDK License 1.0). */
2
+ const e={required:e=>`${e.label} is required`,invalidType:(e,t)=>`${e.label} must be a ${t}`,minLength:(e,t)=>`${e.label} must be at least ${t} characters`,maxLength:(e,t)=>`${e.label} must be at most ${t} characters`,invalidPattern:e=>`${e.label} format is invalid`,minValue:(e,t)=>`${e.label} must be at least ${t}`,maxValue:(e,t)=>`${e.label} must be at most ${t}`,mustBeInteger:e=>`${e.label} must be an integer`,invalidDate:e=>`${e.label} must be a valid date`,invalidOption:(e,t)=>`${e.label} must be one of: ${t.join(`, `)}`,invalidId:e=>`${e.label} must be a valid ID`,maxItems:(e,t)=>`${e.label} must have at most ${t} item${t>1?`s`:``}`,invalidRichtext:e=>`${e.label} must be valid rich text content`,invalidPhone:e=>`${e.label} must be a valid phone number`,invalidCurrency:e=>`${e.label} must be a valid currency value`,invalidLocation:e=>`${e.label} must be a valid location`};function formatZodErrors(e){return e.issues.map(e=>({path:e.path.map(String),message:e.message}))}export{e as n,formatZodErrors as t};