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