@stndrds/schema 1.0.0-alpha.349 → 1.0.0-alpha.351
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/{all-CnoQ40WJ.d.mts → all-CxrR3FfQ.d.mts} +8 -8
- package/dist/{all-DZp7BWOq.d.ts → all-DgCMEIjc.d.ts} +8 -8
- package/dist/attributes-BrWmES5w.d.mts +684 -0
- package/dist/attributes-DF899HOt.d.ts +684 -0
- package/dist/{checkbox-Cli_fh_9.d.ts → checkbox-Clb_FZ4C.d.mts} +2 -2
- package/dist/{checkbox-De7-FSiU.d.mts → checkbox-DdyYfy8E.d.ts} +2 -2
- package/dist/config-CYuFravl.js +13 -0
- package/dist/config-CiAtjzem.mjs +13 -0
- package/dist/{date-CxGxPeHR.d.mts → date-CXp1zJM4.d.mts} +2 -2
- package/dist/{date-CJGbHQZF.d.ts → date-DhwNqFU4.d.ts} +2 -2
- package/dist/empty-BgAwlO54.mjs +2 -0
- package/dist/empty-CRCKZcwK.js +2 -0
- package/dist/exceptions-DrrzAhuA.d.mts +590 -0
- package/dist/exceptions-DrrzAhuA.d.ts +590 -0
- package/dist/exceptions.d.mts +2 -2
- package/dist/exceptions.d.ts +2 -2
- package/dist/exceptions.js +1 -2
- package/dist/exceptions.mjs +1 -2
- package/dist/{index-DqfX-ct_.d.mts → index-BOibflWy.d.ts} +15 -2
- package/dist/{index-UancE_wI.d.ts → index-Bfvc4AZB.d.mts} +15 -2
- package/dist/{index-Dz6tbe0o.d.ts → index-DCw-X_sc.d.ts} +3 -6
- package/dist/{index-fWrEgqge.d.mts → index-DggAjGTr.d.mts} +1 -1
- package/dist/{index-DRfeDI4f.d.mts → index-Lp5dhlhc.d.mts} +3 -6
- package/dist/{index-C9whsQlG.d.ts → index-OvRk1isl.d.ts} +1 -1
- package/dist/index.d.mts +221 -115
- package/dist/index.d.ts +221 -115
- package/dist/index.js +9 -9
- package/dist/index.mjs +9 -9
- package/dist/{number-BtJHcFCQ.d.ts → number-C_ZN3qJO.d.mts} +2 -2
- package/dist/{number-DJ-nhMMq.d.mts → number-CoTBX03I.d.ts} +2 -2
- package/dist/object-AqI3n2CP.mjs +4 -0
- package/dist/object-BEwZx-Fu.js +4 -0
- package/dist/{text-RUwIi6jM.d.mts → text-D_rs4VYZ.d.mts} +2 -2
- package/dist/{text-qHaUKcUU.d.ts → text-Z8QjbxUx.d.ts} +2 -2
- package/dist/utils-Cl3b_6d8.d.mts +163 -0
- package/dist/utils-Cuz_wSKI.d.ts +163 -0
- package/dist/utils.d.mts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/validation/all.d.mts +5 -5
- package/dist/validation/all.d.ts +5 -5
- package/dist/validation/all.js +1 -1
- package/dist/validation/all.mjs +1 -1
- package/dist/validation/complex/currency.d.mts +2 -2
- package/dist/validation/complex/currency.d.ts +2 -2
- package/dist/validation/complex/location.d.mts +2 -2
- package/dist/validation/complex/location.d.ts +2 -2
- package/dist/validation/complex/phone.d.mts +2 -2
- package/dist/validation/complex/phone.d.ts +2 -2
- package/dist/validation/complex/relation.d.mts +2 -2
- package/dist/validation/complex/relation.d.ts +2 -2
- package/dist/validation/complex/richtext.d.mts +2 -2
- package/dist/validation/complex/richtext.d.ts +2 -2
- package/dist/validation/complex/select.d.mts +2 -2
- package/dist/validation/complex/select.d.ts +2 -2
- package/dist/validation/complex/user.d.mts +2 -2
- package/dist/validation/complex/user.d.ts +2 -2
- package/dist/validation/computed/formula.d.mts +2 -2
- package/dist/validation/computed/formula.d.ts +2 -2
- package/dist/validation/computed/rollup.d.mts +2 -2
- package/dist/validation/computed/rollup.d.ts +2 -2
- package/dist/validation/config/index.d.mts +2 -2
- package/dist/validation/config/index.d.ts +2 -2
- package/dist/validation/config/index.js +1 -1
- package/dist/validation/config/index.mjs +1 -1
- package/dist/validation/core/index.d.mts +1 -1
- package/dist/validation/core/index.d.ts +1 -1
- package/dist/validation/object/index.d.mts +1 -1
- package/dist/validation/object/index.d.ts +1 -1
- package/dist/validation/object/index.js +1 -1
- package/dist/validation/object/index.mjs +1 -1
- package/dist/validation/primitives/checkbox.d.mts +1 -1
- package/dist/validation/primitives/checkbox.d.ts +1 -1
- package/dist/validation/primitives/date.d.mts +1 -1
- package/dist/validation/primitives/date.d.ts +1 -1
- package/dist/validation/primitives/number.d.mts +1 -1
- package/dist/validation/primitives/number.d.ts +1 -1
- package/dist/validation/primitives/text.d.mts +1 -1
- package/dist/validation/primitives/text.d.ts +1 -1
- package/dist/view-config.schema-CCrM5b-O.mjs +2 -0
- package/dist/view-config.schema-CgU86fLj.js +2 -0
- package/package.json +2 -2
- package/dist/config-BiQGgy7f.mjs +0 -13
- package/dist/config-WUWITOeW.js +0 -13
- package/dist/exceptions-B2EKDci0.d.mts +0 -1460
- package/dist/exceptions-B2EKDci0.d.ts +0 -1460
- package/dist/object-BA3vKFl0.js +0 -4
- package/dist/object-C92B0Oei.mjs +0 -4
- package/dist/view-config.schema-PCAznd98.mjs +0 -2
- package/dist/view-config.schema-VEoY_VAd.js +0 -2
|
@@ -0,0 +1,684 @@
|
|
|
1
|
+
|
|
2
|
+
import { r as Uuid } from "./utils-Cl3b_6d8.mjs";
|
|
3
|
+
import { ColorId, CountryIso3, CurrencyCode, IconName } from "@stndrds/constants";
|
|
4
|
+
//#region src/computed/parser.d.ts
|
|
5
|
+
type ComputedFormulaAstNode = ComputedFormulaLiteralNode | ComputedFormulaPathNode | ComputedFormulaCallNode | ComputedFormulaBinaryNode;
|
|
6
|
+
interface ComputedFormulaLiteralNode {
|
|
7
|
+
kind: "literal";
|
|
8
|
+
value: string | number | boolean | null;
|
|
9
|
+
}
|
|
10
|
+
interface ComputedFormulaPathNode {
|
|
11
|
+
kind: "path";
|
|
12
|
+
parts: string[];
|
|
13
|
+
}
|
|
14
|
+
interface ComputedFormulaCallNode {
|
|
15
|
+
kind: "call";
|
|
16
|
+
functionName: string;
|
|
17
|
+
args: ComputedFormulaAstNode[];
|
|
18
|
+
}
|
|
19
|
+
interface ComputedFormulaBinaryNode {
|
|
20
|
+
kind: "binary";
|
|
21
|
+
operator: ComputedFormulaBinaryOperator;
|
|
22
|
+
left: ComputedFormulaAstNode;
|
|
23
|
+
right: ComputedFormulaAstNode;
|
|
24
|
+
}
|
|
25
|
+
type ComputedFormulaBinaryOperator = ">" | "<" | ">=" | "<=" | "==" | "!=" | "+" | "-" | "*" | "/";
|
|
26
|
+
declare class ComputedFormulaParseError extends Error {
|
|
27
|
+
constructor(message: string);
|
|
28
|
+
}
|
|
29
|
+
declare function parseComputedFormula(expression: string): ComputedFormulaAstNode;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/computed/types.d.ts
|
|
32
|
+
type ComputedReturnType = "text" | "number" | "boolean" | "date" | "select" | "multiselect";
|
|
33
|
+
type ComputedFieldKind = "formula" | "rollup";
|
|
34
|
+
type ComputedValueType = {
|
|
35
|
+
kind: "scalar";
|
|
36
|
+
type: Exclude<ComputedReturnType, "multiselect">;
|
|
37
|
+
} | {
|
|
38
|
+
kind: "collection";
|
|
39
|
+
itemType: "text" | "number" | "boolean" | "date" | "select";
|
|
40
|
+
};
|
|
41
|
+
interface ComputedOptionsSource {
|
|
42
|
+
objectName: string;
|
|
43
|
+
attributeName: string;
|
|
44
|
+
attributeId?: string;
|
|
45
|
+
}
|
|
46
|
+
type ComputedDependency = {
|
|
47
|
+
kind: "local";
|
|
48
|
+
attributeName: string;
|
|
49
|
+
} | {
|
|
50
|
+
kind: "relation";
|
|
51
|
+
relationName: string;
|
|
52
|
+
targetAttributeName?: string;
|
|
53
|
+
cardinality?: "one" | "many";
|
|
54
|
+
} | {
|
|
55
|
+
kind: "computed";
|
|
56
|
+
attributeName: string;
|
|
57
|
+
} | {
|
|
58
|
+
kind: "options";
|
|
59
|
+
source: ComputedOptionsSource;
|
|
60
|
+
};
|
|
61
|
+
interface ComputedPlan {
|
|
62
|
+
kind: ComputedFieldKind;
|
|
63
|
+
attributeName: string;
|
|
64
|
+
expression: string;
|
|
65
|
+
returnType: ComputedReturnType;
|
|
66
|
+
valueType: ComputedValueType;
|
|
67
|
+
dependencies: ComputedDependency[];
|
|
68
|
+
optionsSource?: ComputedOptionsSource;
|
|
69
|
+
targetAttributeType?: AttributeType;
|
|
70
|
+
dependenciesHash: string;
|
|
71
|
+
ast?: ComputedFormulaAstNode;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/computed/functions.d.ts
|
|
75
|
+
declare const COMPUTED_FUNCTION_NAMES: readonly ["if", "concat", "sum", "avg", "count", "min", "max", "earliest", "latest", "unique", "first", "percent_empty", "percent_not_empty", "count_empty", "count_not_empty", "count_unique"];
|
|
76
|
+
type ComputedFunctionName = (typeof COMPUTED_FUNCTION_NAMES)[number];
|
|
77
|
+
interface ComputedFunctionSignature {
|
|
78
|
+
name: ComputedFunctionName;
|
|
79
|
+
returnType: ComputedValueType | "argument" | "branch" | "source_item";
|
|
80
|
+
minArgs: number;
|
|
81
|
+
maxArgs?: number;
|
|
82
|
+
}
|
|
83
|
+
declare const COMPUTED_FUNCTIONS: Record<ComputedFunctionName, ComputedFunctionSignature>;
|
|
84
|
+
declare function isComputedFunctionName(name: string): name is ComputedFunctionName;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/computed/compiler.d.ts
|
|
87
|
+
interface ComputedCompileAttribute {
|
|
88
|
+
name: string;
|
|
89
|
+
type: AttributeType;
|
|
90
|
+
id?: string;
|
|
91
|
+
returnType?: ComputedReturnType;
|
|
92
|
+
optionsSource?: ComputedOptionsSource;
|
|
93
|
+
options?: readonly unknown[];
|
|
94
|
+
cardinality?: "one" | "many";
|
|
95
|
+
targetObjectName?: string;
|
|
96
|
+
targets?: readonly {
|
|
97
|
+
object: string;
|
|
98
|
+
}[];
|
|
99
|
+
}
|
|
100
|
+
interface ComputedCompileObject {
|
|
101
|
+
objectName: string;
|
|
102
|
+
attributes: readonly ComputedCompileAttribute[];
|
|
103
|
+
}
|
|
104
|
+
interface ComputedCompileSchema extends ComputedCompileObject {
|
|
105
|
+
relatedObjects?: Record<string, ComputedCompileObject>;
|
|
106
|
+
}
|
|
107
|
+
interface CompileComputedFormulaInput {
|
|
108
|
+
attributeName: string;
|
|
109
|
+
expression: string;
|
|
110
|
+
returnType: ComputedReturnType;
|
|
111
|
+
schema: ComputedCompileSchema;
|
|
112
|
+
}
|
|
113
|
+
interface ComputedDependencyGraphNode {
|
|
114
|
+
attributeName: string;
|
|
115
|
+
dependencies: readonly ComputedDependency[];
|
|
116
|
+
}
|
|
117
|
+
declare class ComputedFormulaCompileError extends Error {
|
|
118
|
+
constructor(message: string);
|
|
119
|
+
}
|
|
120
|
+
declare function compileComputedFormula(input: CompileComputedFormulaInput): ComputedPlan;
|
|
121
|
+
declare function assertAcyclicComputedDependencies(nodes: readonly ComputedDependencyGraphNode[]): void;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/computed/rollup-compiler.d.ts
|
|
124
|
+
declare function rollupToFormulaExpression(attr: RollupAttribute): string;
|
|
125
|
+
declare function inferRollupReturnType(attr: RollupAttribute, schema: ComputedCompileSchema): ComputedReturnType;
|
|
126
|
+
declare function compileRollupAttribute(attr: RollupAttribute, schema: ComputedCompileSchema): ComputedPlan;
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/computed/evaluator.d.ts
|
|
129
|
+
declare function isPlainRecord(value: unknown): value is Record<string, unknown>;
|
|
130
|
+
declare function formatComputedResult(value: unknown, returnType: ComputedReturnType, decimals?: number): unknown;
|
|
131
|
+
declare function evaluateComputedAst(node: ComputedFormulaAstNode, input: Record<string, unknown>): unknown;
|
|
132
|
+
declare function evaluateComputedFormula(expression: string, input: Record<string, unknown>): unknown;
|
|
133
|
+
interface ComputedFormulaResult {
|
|
134
|
+
value: unknown;
|
|
135
|
+
error?: string;
|
|
136
|
+
}
|
|
137
|
+
declare function evaluateComputedFormulaWithResult(expression: string, input: Record<string, unknown>, returnType?: ComputedReturnType, decimals?: number): ComputedFormulaResult;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/computed/function-metadata.d.ts
|
|
140
|
+
type ComputedFunctionCategory = "logic" | "text" | "number" | "date" | "collection";
|
|
141
|
+
interface ComputedFunctionMetadata {
|
|
142
|
+
name: ComputedFunctionName;
|
|
143
|
+
signature: string;
|
|
144
|
+
description: string;
|
|
145
|
+
category: ComputedFunctionCategory;
|
|
146
|
+
example: string;
|
|
147
|
+
}
|
|
148
|
+
declare const COMPUTED_FUNCTION_METADATA: ComputedFunctionMetadata[];
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/types/relation-properties.d.ts
|
|
151
|
+
/**
|
|
152
|
+
* Allowed attribute types in .qualifyWith()
|
|
153
|
+
*
|
|
154
|
+
* IMPORTANT: Complex types (formula, rollup, relation, file, user, document, richtext)
|
|
155
|
+
* are NOT supported to avoid duplicating backend behavior.
|
|
156
|
+
*/
|
|
157
|
+
type PropertyType = "text" | "number" | "checkbox" | "date" | "phone" | "currency" | "status" | "select" | "multiselect" | "location";
|
|
158
|
+
/**
|
|
159
|
+
* Union of attribute types allowed as qualified relation properties.
|
|
160
|
+
*
|
|
161
|
+
* These are the same Attribute types used for object attributes,
|
|
162
|
+
* restricted to simple types that don't require complex backend duplication.
|
|
163
|
+
*/
|
|
164
|
+
type PropertyAttribute = TextAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | SelectAttribute | MultiselectAttribute | LocationAttribute;
|
|
165
|
+
/**
|
|
166
|
+
* Schema defining properties for a qualified relation.
|
|
167
|
+
*
|
|
168
|
+
* Uses the same Attribute types as object attributes, enabling DRY builders:
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* relation({ name: "companies", label: "Companies" })
|
|
173
|
+
* .to("companies").many()
|
|
174
|
+
* .qualifyWith(
|
|
175
|
+
* select({ name: "role", label: "Role" }).options([...]).required(),
|
|
176
|
+
* number({ name: "shares", label: "Shares" }).min(0),
|
|
177
|
+
* )
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
interface PropertySchema {
|
|
181
|
+
definitions: PropertyAttribute[];
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Normalizes an attribute's `properties` field to a flat list of
|
|
185
|
+
* {@link PropertyAttribute}. Handles both the production {@link PropertySchema}
|
|
186
|
+
* shape (`{ definitions: [...] }`) and the raw-array shape used in test
|
|
187
|
+
* fixtures (`PropertyAttribute[]`).
|
|
188
|
+
*/
|
|
189
|
+
declare function resolvePropertyDefinitions(attr: unknown): PropertyAttribute[];
|
|
190
|
+
/**
|
|
191
|
+
* Property attribute types that have an `options` array.
|
|
192
|
+
*/
|
|
193
|
+
type OptionPropertyAttribute = SelectAttribute | StatusAttribute | MultiselectAttribute;
|
|
194
|
+
/**
|
|
195
|
+
* Type guard to check if a property attribute has options.
|
|
196
|
+
*
|
|
197
|
+
* @param attr - The property attribute to check
|
|
198
|
+
* @returns true if the attribute is a select, status, or multiselect type with options
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* for (const def of definitions) {
|
|
203
|
+
* if (hasOptions(def)) {
|
|
204
|
+
* // TypeScript knows def.options exists and is Option[]
|
|
205
|
+
* for (const option of def.options) {
|
|
206
|
+
* console.log(option.value);
|
|
207
|
+
* }
|
|
208
|
+
* }
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
declare function hasOptions(attr: PropertyAttribute): attr is OptionPropertyAttribute;
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/types/attributes.d.ts
|
|
215
|
+
declare const ATTRIBUTE_TYPES: readonly ["text", "richtext", "number", "checkbox", "date", "phone", "currency", "status", "location", "select", "multiselect", "user", "relation", "formula", "rollup", "document"];
|
|
216
|
+
type AttributeType = (typeof ATTRIBUTE_TYPES)[number];
|
|
217
|
+
/**
|
|
218
|
+
* Status group categorization
|
|
219
|
+
*/
|
|
220
|
+
type StatusGroup = "idle" | "in_progress" | "finished";
|
|
221
|
+
/**
|
|
222
|
+
* Unified option type for select-like fields
|
|
223
|
+
*/
|
|
224
|
+
interface Option {
|
|
225
|
+
value: string;
|
|
226
|
+
label: string;
|
|
227
|
+
color?: ColorId;
|
|
228
|
+
description?: string;
|
|
229
|
+
group?: StatusGroup;
|
|
230
|
+
/** Value of the inverse option for bilateral relations (e.g. "parent" → "child") */
|
|
231
|
+
inverse?: string;
|
|
232
|
+
archived?: boolean;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Attribute grouping for UI organization
|
|
236
|
+
*/
|
|
237
|
+
interface AttributeGroup {
|
|
238
|
+
id: string;
|
|
239
|
+
label: string;
|
|
240
|
+
description?: string;
|
|
241
|
+
attributeIds: string[];
|
|
242
|
+
collapsible?: boolean;
|
|
243
|
+
collapsed?: boolean;
|
|
244
|
+
order?: number;
|
|
245
|
+
}
|
|
246
|
+
interface BaseAttribute<DefaultValueType = unknown> {
|
|
247
|
+
id?: Uuid;
|
|
248
|
+
objectId?: Uuid;
|
|
249
|
+
name: string;
|
|
250
|
+
label: string;
|
|
251
|
+
type: AttributeType;
|
|
252
|
+
required?: boolean;
|
|
253
|
+
placeholder?: string;
|
|
254
|
+
description?: string;
|
|
255
|
+
defaultValue?: DefaultValueType;
|
|
256
|
+
icon?: IconName;
|
|
257
|
+
order?: number;
|
|
258
|
+
hidden?: boolean;
|
|
259
|
+
archived?: boolean;
|
|
260
|
+
deprecated?: boolean;
|
|
261
|
+
system?: boolean;
|
|
262
|
+
unique?: boolean;
|
|
263
|
+
metadata?: Record<string, unknown>;
|
|
264
|
+
}
|
|
265
|
+
interface TextAttribute extends BaseAttribute<string> {
|
|
266
|
+
type: "text";
|
|
267
|
+
multiline?: boolean;
|
|
268
|
+
minLength?: number;
|
|
269
|
+
maxLength?: number;
|
|
270
|
+
pattern?: string;
|
|
271
|
+
format?: "email" | "url" | "slug";
|
|
272
|
+
}
|
|
273
|
+
type NumberUnit = "integer" | "decimal" | "percentage";
|
|
274
|
+
interface NumberAttribute extends BaseAttribute<number> {
|
|
275
|
+
type: "number";
|
|
276
|
+
min?: number;
|
|
277
|
+
max?: number;
|
|
278
|
+
unit?: NumberUnit;
|
|
279
|
+
decimals?: number;
|
|
280
|
+
renderAs?: "number" | "rating";
|
|
281
|
+
}
|
|
282
|
+
interface CheckboxAttribute extends BaseAttribute<boolean> {
|
|
283
|
+
type: "checkbox";
|
|
284
|
+
}
|
|
285
|
+
type DateFormat = "short" | "long" | "full" | "relative";
|
|
286
|
+
type DateValue = string | "today";
|
|
287
|
+
type TimeFormat = "12h" | "24h";
|
|
288
|
+
/** Stored value of a date attribute configured with `.endDate()`. */
|
|
289
|
+
interface DateRangeValue {
|
|
290
|
+
start: string;
|
|
291
|
+
end: string | null;
|
|
292
|
+
}
|
|
293
|
+
interface DateAttribute extends BaseAttribute<string | DateRangeValue> {
|
|
294
|
+
type: "date";
|
|
295
|
+
dateFormat?: DateFormat;
|
|
296
|
+
minDate?: DateValue;
|
|
297
|
+
maxDate?: DateValue;
|
|
298
|
+
/** Values carry a time component; stored as full ISO UTC datetimes. */
|
|
299
|
+
includeTime?: boolean;
|
|
300
|
+
/** Values are ranges stored as { start, end } objects. */
|
|
301
|
+
endDate?: boolean;
|
|
302
|
+
/** Display format for the time component. Defaults to "24h". */
|
|
303
|
+
timeFormat?: TimeFormat;
|
|
304
|
+
}
|
|
305
|
+
interface Phone {
|
|
306
|
+
countryCode: CountryIso3;
|
|
307
|
+
phoneNumber: string;
|
|
308
|
+
}
|
|
309
|
+
interface PhoneAttribute extends BaseAttribute<Phone> {
|
|
310
|
+
type: "phone";
|
|
311
|
+
defaultCountryCode?: CountryIso3;
|
|
312
|
+
}
|
|
313
|
+
interface Currency {
|
|
314
|
+
code: CurrencyCode;
|
|
315
|
+
value: number;
|
|
316
|
+
}
|
|
317
|
+
interface CurrencyAttribute extends BaseAttribute<Currency> {
|
|
318
|
+
type: "currency";
|
|
319
|
+
defaultCurrency?: CurrencyCode;
|
|
320
|
+
allowedCurrencies?: CurrencyCode[];
|
|
321
|
+
/** Allow negative currency values (e.g. refunds, credits). Defaults to false. */
|
|
322
|
+
allowNegative?: boolean;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* StatusAttribute - For workflow states with semantic grouping (idle/in_progress/finished)
|
|
326
|
+
* Use this for: Task status, Order status, Project phases, Process states
|
|
327
|
+
* Use SelectAttribute for: Categories, Types, simple choices without workflow
|
|
328
|
+
*/
|
|
329
|
+
interface StatusAttribute extends BaseAttribute<string> {
|
|
330
|
+
type: "status";
|
|
331
|
+
options: Option[];
|
|
332
|
+
}
|
|
333
|
+
interface Location {
|
|
334
|
+
address?: string;
|
|
335
|
+
address2?: string;
|
|
336
|
+
city?: string;
|
|
337
|
+
state?: string;
|
|
338
|
+
postalCode?: string;
|
|
339
|
+
country?: CountryIso3;
|
|
340
|
+
latitude?: number;
|
|
341
|
+
longitude?: number;
|
|
342
|
+
}
|
|
343
|
+
type LocationGranularity = "full" | "address" | "city" | "state" | "country" | "coordinates";
|
|
344
|
+
interface LocationAttribute extends BaseAttribute<Location> {
|
|
345
|
+
type: "location";
|
|
346
|
+
granularity?: LocationGranularity;
|
|
347
|
+
defaultCountry?: CountryIso3;
|
|
348
|
+
allowedCountries?: CountryIso3[];
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* SelectAttribute - For simple single-choice selection
|
|
352
|
+
* Use this for: Categories, Document types, Departments, Priorities
|
|
353
|
+
* Options can be grouped (e.g., countries by continent) but no workflow logic
|
|
354
|
+
*/
|
|
355
|
+
interface SelectAttribute extends BaseAttribute<string> {
|
|
356
|
+
type: "select";
|
|
357
|
+
options: Option[];
|
|
358
|
+
renderAs?: "badges";
|
|
359
|
+
}
|
|
360
|
+
interface MultiselectAttribute extends BaseAttribute<string[]> {
|
|
361
|
+
type: "multiselect";
|
|
362
|
+
options: Option[];
|
|
363
|
+
renderAs?: "badges";
|
|
364
|
+
}
|
|
365
|
+
type UserReferenceType = "user" | "agent";
|
|
366
|
+
interface UserAttribute extends BaseAttribute<string | string[]> {
|
|
367
|
+
type: "user";
|
|
368
|
+
types?: UserReferenceType[];
|
|
369
|
+
multiple?: boolean;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Wildcard marker for universal relations (can link to any object)
|
|
373
|
+
* Use with `.toAny()` builder method
|
|
374
|
+
*/
|
|
375
|
+
declare const RELATION_TARGET_ANY: "*";
|
|
376
|
+
/**
|
|
377
|
+
* Configuration for bilateral synchronization (bidirectional relations)
|
|
378
|
+
*/
|
|
379
|
+
interface BilateralConfig {
|
|
380
|
+
/** Target object containing the inverse attribute */
|
|
381
|
+
object: string;
|
|
382
|
+
/** Name of the inverse attribute */
|
|
383
|
+
attribute: string;
|
|
384
|
+
/** Optional cardinality override (inferred by default) */
|
|
385
|
+
cardinality?: "one" | "many";
|
|
386
|
+
/** Label for the inverse attribute when it is generated from this declaration. */
|
|
387
|
+
label?: string;
|
|
388
|
+
/** When true, this side owns the storage direction for qualified properties.
|
|
389
|
+
* Set to false on the inverse side (enriched at read time). */
|
|
390
|
+
storageOwner?: boolean;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Target object for a relation - defines which objects can be linked
|
|
394
|
+
*/
|
|
395
|
+
interface RelationTarget {
|
|
396
|
+
/** Object name (e.g., "companies", "contacts") or "*" for any object */
|
|
397
|
+
object: string;
|
|
398
|
+
/**
|
|
399
|
+
* Display template for the label using mustache-like syntax
|
|
400
|
+
* @example "{name}" or "{firstName} {lastName} — {email}"
|
|
401
|
+
*/
|
|
402
|
+
displayTemplate?: string;
|
|
403
|
+
/**
|
|
404
|
+
* Optional filter to restrict available records
|
|
405
|
+
* @example { status: "active" }
|
|
406
|
+
*/
|
|
407
|
+
filter?: Record<string, unknown>;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Base properties shared by both single and multi relation attributes
|
|
411
|
+
*
|
|
412
|
+
* Note: Deletion behavior is always "restrict" - if a record is referenced
|
|
413
|
+
* by other records, it cannot be deleted until those references are removed.
|
|
414
|
+
* This is enforced by RecordService.deleteRecord() which throws
|
|
415
|
+
* RecordReferencedError when attempting to delete a referenced record.
|
|
416
|
+
*/
|
|
417
|
+
interface RelationAttributeBase extends Omit<BaseAttribute<unknown>, "defaultValue"> {
|
|
418
|
+
type: "relation";
|
|
419
|
+
/** Target objects that can be linked */
|
|
420
|
+
targets: RelationTarget[];
|
|
421
|
+
/** Optional properties schema for qualified relations */
|
|
422
|
+
properties?: PropertySchema;
|
|
423
|
+
/** Configuration for bilateral synchronization (opt-in) */
|
|
424
|
+
bilateral?: BilateralConfig;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Single relation attribute (one-to-one or many-to-one)
|
|
428
|
+
* Stores a single record ID or null
|
|
429
|
+
*/
|
|
430
|
+
interface SingleRelationAttribute extends RelationAttributeBase {
|
|
431
|
+
cardinality: "one";
|
|
432
|
+
defaultValue?: string | null;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Multi relation attribute (one-to-many or many-to-many)
|
|
436
|
+
* Stores an array of record IDs
|
|
437
|
+
*/
|
|
438
|
+
interface MultiRelationAttribute extends RelationAttributeBase {
|
|
439
|
+
cardinality: "many";
|
|
440
|
+
defaultValue?: string[];
|
|
441
|
+
/** Maximum number of relations allowed */
|
|
442
|
+
maxItems?: number;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* RelationAttribute links to other objects/records
|
|
446
|
+
* Discriminated union by cardinality for type-safe value handling
|
|
447
|
+
*
|
|
448
|
+
* @example Single relation (many-to-one)
|
|
449
|
+
* ```typescript
|
|
450
|
+
* relation({ name: "company", label: "Company" })
|
|
451
|
+
* .to("companies")
|
|
452
|
+
* .required()
|
|
453
|
+
* // → Value: "rec-uuid-123" | null
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
456
|
+
* @example Multi relation (many-to-many)
|
|
457
|
+
* ```typescript
|
|
458
|
+
* relation({ name: "contacts", label: "Contacts" })
|
|
459
|
+
* .to("contacts", { displayTemplate: "{firstName} {lastName}" })
|
|
460
|
+
* .many()
|
|
461
|
+
* .maxItems(5)
|
|
462
|
+
* // → Value: ["rec-1", "rec-2", ...]
|
|
463
|
+
* ```
|
|
464
|
+
*
|
|
465
|
+
* @example Polymorphic relation (multiple target objects)
|
|
466
|
+
* ```typescript
|
|
467
|
+
* relation({ name: "linked", label: "Linked Items" })
|
|
468
|
+
* .to("companies")
|
|
469
|
+
* .to("contacts")
|
|
470
|
+
* .to("deals")
|
|
471
|
+
* .many()
|
|
472
|
+
* // → Can link to records from any of these objects
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
type RelationAttribute = SingleRelationAttribute | MultiRelationAttribute;
|
|
476
|
+
/**
|
|
477
|
+
* Check if a relation attribute is universal (can link to any object)
|
|
478
|
+
* Universal relations have `targets: [{ object: "*" }]`
|
|
479
|
+
*/
|
|
480
|
+
/**
|
|
481
|
+
* The object names a relation attribute can point at, universal marker
|
|
482
|
+
* stripped. Any other attribute type — and a relation row whose config lost
|
|
483
|
+
* its `targets` — yields no names.
|
|
484
|
+
*/
|
|
485
|
+
declare function relationTargetsOf(attribute: Attribute): string[];
|
|
486
|
+
declare function isUniversalRelation(attr: RelationAttribute): boolean;
|
|
487
|
+
/**
|
|
488
|
+
* Check if a relation attribute has bilateral synchronization enabled
|
|
489
|
+
*/
|
|
490
|
+
declare function isBilateralRelation(attr: RelationAttribute): attr is RelationAttribute & {
|
|
491
|
+
bilateral: BilateralConfig;
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* Infer the cardinality of the inverse relation
|
|
495
|
+
* - one → many (contact.company ↔ company.contacts)
|
|
496
|
+
* - many → many (contact.tags ↔ tag.contacts)
|
|
497
|
+
*/
|
|
498
|
+
declare function inferInverseCardinality(cardinality: "one" | "many"): "one" | "many";
|
|
499
|
+
/**
|
|
500
|
+
* RichtextAttribute - Rich text content using semantic markdown
|
|
501
|
+
*
|
|
502
|
+
* Stores content as semantic markdown string (with directives like :::callout).
|
|
503
|
+
* Parsed at runtime to Tiptap JSON for editing.
|
|
504
|
+
* Use this for: Notes, articles, descriptions, long-form content.
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* richtext({ name: "content", label: "Content" }).required()
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
interface RichtextAttribute extends BaseAttribute<string> {
|
|
512
|
+
type: "richtext";
|
|
513
|
+
}
|
|
514
|
+
type RichTextAttribute = RichtextAttribute;
|
|
515
|
+
/**
|
|
516
|
+
* Return type for formula expressions
|
|
517
|
+
*/
|
|
518
|
+
type FormulaReturnType = ComputedReturnType;
|
|
519
|
+
/**
|
|
520
|
+
* FormulaAttribute - Computed value based on other attributes
|
|
521
|
+
*
|
|
522
|
+
* Formulas are calculated at read-time and are always read-only.
|
|
523
|
+
* Users cannot directly edit formula values.
|
|
524
|
+
*
|
|
525
|
+
* @example Simple calculation
|
|
526
|
+
* ```typescript
|
|
527
|
+
* formula({ name: "total", label: "Total" })
|
|
528
|
+
* .expression("price * quantity")
|
|
529
|
+
* .returns("number")
|
|
530
|
+
* .decimals(2)
|
|
531
|
+
* ```
|
|
532
|
+
*
|
|
533
|
+
* @example With functions
|
|
534
|
+
* ```typescript
|
|
535
|
+
* formula({ name: "fullName", label: "Full Name" })
|
|
536
|
+
* .expression("CONCAT(firstName, ' ', lastName)")
|
|
537
|
+
* .returns("text")
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
interface FormulaAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
|
|
541
|
+
type: "formula";
|
|
542
|
+
/** Expression to evaluate (e.g., "price * quantity") */
|
|
543
|
+
expression: string;
|
|
544
|
+
/** Expected return type for formatting */
|
|
545
|
+
returnType: FormulaReturnType;
|
|
546
|
+
/** Decimal places for number results */
|
|
547
|
+
decimals?: number;
|
|
548
|
+
/**
|
|
549
|
+
* ISO 4217 code a `number` result renders with — `123 456 €` instead of
|
|
550
|
+
* `123456` — for a formula over money (#3419). Presentation only: the
|
|
551
|
+
* stored value stays a number, sort, filter and aggregation are untouched,
|
|
552
|
+
* and `returnType` stays `"number"` because that IS what the expression
|
|
553
|
+
* returns. The rollup's `targetCurrencyCode` (#2644), mirrored. Absent →
|
|
554
|
+
* the bare number, exactly as before.
|
|
555
|
+
*/
|
|
556
|
+
currencyCode?: CurrencyCode;
|
|
557
|
+
/** Source attribute for select-like computed options */
|
|
558
|
+
optionsSource?: ComputedOptionsSource;
|
|
559
|
+
/** Whether to allow relation references in the expression (e.g., "company.name") */
|
|
560
|
+
allowRelations?: boolean;
|
|
561
|
+
/** Formula is always not required (read-only) */
|
|
562
|
+
required: false;
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Aggregation functions for rollup attributes
|
|
566
|
+
*
|
|
567
|
+
* Categories:
|
|
568
|
+
* - Numeric (sum, avg): Only for number and currency types
|
|
569
|
+
* - Date (earliest, latest): Only for date type
|
|
570
|
+
* - Count (count, countValues, countUniqueValues, countEmpty): Universal
|
|
571
|
+
* - Percent (percentEmpty, percentNotEmpty): Universal
|
|
572
|
+
* - Lookup (original): Returns all values as array, rendered as target type
|
|
573
|
+
*/
|
|
574
|
+
type RollupFunction = "sum" | "avg" | "earliest" | "latest" | "count" | "countValues" | "countUniqueValues" | "countEmpty" | "percentEmpty" | "percentNotEmpty" | "original";
|
|
575
|
+
/**
|
|
576
|
+
* RollupAttribute - Aggregates values from related records
|
|
577
|
+
*
|
|
578
|
+
* Rollups are calculated and stored (denormalized) for performance.
|
|
579
|
+
* They are automatically recalculated when related records change.
|
|
580
|
+
* Users cannot directly edit rollup values.
|
|
581
|
+
*
|
|
582
|
+
* @example Sum of related amounts
|
|
583
|
+
* ```typescript
|
|
584
|
+
* rollup({ name: "totalOrders", label: "Total Orders" })
|
|
585
|
+
* .from("orders") // relation attribute name
|
|
586
|
+
* .aggregate("amount") // target attribute to sum
|
|
587
|
+
* .using("sum")
|
|
588
|
+
* .decimals(2)
|
|
589
|
+
* ```
|
|
590
|
+
*
|
|
591
|
+
* @example Count of related records
|
|
592
|
+
* ```typescript
|
|
593
|
+
* rollup({ name: "orderCount", label: "Number of Orders" })
|
|
594
|
+
* .from("orders")
|
|
595
|
+
* .using("count")
|
|
596
|
+
* ```
|
|
597
|
+
*/
|
|
598
|
+
interface RollupAttribute extends Omit<BaseAttribute<never>, "defaultValue" | "required"> {
|
|
599
|
+
type: "rollup";
|
|
600
|
+
/** Name of the relation attribute on this object */
|
|
601
|
+
relationAttribute: string;
|
|
602
|
+
/**
|
|
603
|
+
* Dot notation path for multi-level traversal (Phase 4+)
|
|
604
|
+
* @example "orders.items" - traverse through orders to items
|
|
605
|
+
*/
|
|
606
|
+
relationPath?: string;
|
|
607
|
+
/**
|
|
608
|
+
* Attribute name on the target object to aggregate. Absent for `count`,
|
|
609
|
+
* which aggregates the linked records themselves (#3571).
|
|
610
|
+
*/
|
|
611
|
+
targetAttribute?: string;
|
|
612
|
+
/** Aggregation function to apply */
|
|
613
|
+
function: RollupFunction;
|
|
614
|
+
/** Decimal places for numeric results */
|
|
615
|
+
decimals?: number;
|
|
616
|
+
/** Rollup is always not required (read-only) */
|
|
617
|
+
required: false;
|
|
618
|
+
/**
|
|
619
|
+
* Cached type of the target attribute for display purposes
|
|
620
|
+
* Used when function="original" to render values as the target type
|
|
621
|
+
*/
|
|
622
|
+
targetAttributeType?: AttributeType;
|
|
623
|
+
/**
|
|
624
|
+
* Cached currency code of a currency target, from its `defaultCurrency`
|
|
625
|
+
* (#2644). The stored rollup value stays a bare number; this is the
|
|
626
|
+
* schema-derived channel that lets a single-code sum/avg render with its
|
|
627
|
+
* symbol. Absent → the value renders bare, exactly as before.
|
|
628
|
+
*
|
|
629
|
+
* Named for what it holds — an ISO 4217 CODE — rather than the siblings'
|
|
630
|
+
* `targetAttribute*` prefix: `targetAttributeCurrency` would read as a
|
|
631
|
+
* `Currency` value, which this deliberately is not.
|
|
632
|
+
*/
|
|
633
|
+
targetCurrencyCode?: CurrencyCode;
|
|
634
|
+
/**
|
|
635
|
+
* Cached options from target attribute (for select/status/multiselect display)
|
|
636
|
+
* Required when function="original" and target is a select-like type
|
|
637
|
+
*/
|
|
638
|
+
targetAttributeOptions?: Option[];
|
|
639
|
+
/** Source attribute for select-like computed options */
|
|
640
|
+
optionsSource?: ComputedOptionsSource;
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* DocumentAttribute - References structured documents.
|
|
644
|
+
*
|
|
645
|
+
* A DocumentAttribute references packs of anonymous files with typed edge
|
|
646
|
+
* properties.
|
|
647
|
+
*
|
|
648
|
+
* Every document attribute is multi by construction — the underlying storage
|
|
649
|
+
* (documents + files) supports 1 Doc → N files uniformly.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* ```typescript
|
|
653
|
+
* document({ name: "contracts", label: "Contrats" })
|
|
654
|
+
* .accepts(["application/pdf"])
|
|
655
|
+
* ```
|
|
656
|
+
*/
|
|
657
|
+
interface DocumentAttribute extends BaseAttribute<string[]> {
|
|
658
|
+
type: "document";
|
|
659
|
+
/**
|
|
660
|
+
* Schema for typed properties on the record→document edge.
|
|
661
|
+
* Symmetric with `RelationAttribute.properties`; populated by `.qualifyWith(...)`.
|
|
662
|
+
* Stored on `record_reference_edges.properties`, not on the document itself.
|
|
663
|
+
*/
|
|
664
|
+
properties?: PropertySchema;
|
|
665
|
+
/** MIME prefixes/globs (e.g. "image/*", "application/pdf") applied to every file of the pack. */
|
|
666
|
+
accepts?: string[];
|
|
667
|
+
/** Hard ceiling in bytes applied to every file of the pack. */
|
|
668
|
+
maxFileSize?: number;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Union of every attribute definition supported by Standards objects.
|
|
672
|
+
*
|
|
673
|
+
* Use this type when code needs to inspect or render attributes generically
|
|
674
|
+
* across primitive, relation, computed, user, and document fields.
|
|
675
|
+
*/
|
|
676
|
+
type Attribute = TextAttribute | RichtextAttribute | NumberAttribute | CheckboxAttribute | DateAttribute | PhoneAttribute | CurrencyAttribute | StatusAttribute | LocationAttribute | SelectAttribute | MultiselectAttribute | UserAttribute | RelationAttribute | FormulaAttribute | RollupAttribute | DocumentAttribute;
|
|
677
|
+
/**
|
|
678
|
+
* Check if an attribute supports sorting based on its type.
|
|
679
|
+
*/
|
|
680
|
+
declare function isAttributeSortable(attr: {
|
|
681
|
+
type: AttributeType;
|
|
682
|
+
}): boolean;
|
|
683
|
+
//#endregion
|
|
684
|
+
export { COMPUTED_FUNCTION_METADATA as $, RichTextAttribute as A, ComputedFormulaAstNode as At, UserAttribute as B, NumberUnit as C, isComputedFunctionName as Ct, RELATION_TARGET_ANY as D, ComputedPlan as Dt, PhoneAttribute as E, ComputedOptionsSource as Et, SingleRelationAttribute as F, ComputedFormulaParseError as Ft, isUniversalRelation as G, inferInverseCardinality as H, StatusAttribute as I, ComputedFormulaPathNode as It, PropertyAttribute as J, relationTargetsOf as K, StatusGroup as L, parseComputedFormula as Lt, RollupAttribute as M, ComputedFormulaBinaryOperator as Mt, RollupFunction as N, ComputedFormulaCallNode as Nt, RelationAttribute as O, ComputedReturnType as Ot, SelectAttribute as P, ComputedFormulaLiteralNode as Pt, resolvePropertyDefinitions as Q, TextAttribute as R, NumberAttribute as S, ComputedFunctionSignature as St, Phone as T, ComputedFieldKind as Tt, isAttributeSortable as U, UserReferenceType as V, isBilateralRelation as W, PropertyType as X, PropertySchema as Y, hasOptions as Z, Location as _, assertAcyclicComputedDependencies as _t, BaseAttribute as a, evaluateComputedFormulaWithResult as at, MultiRelationAttribute as b, COMPUTED_FUNCTION_NAMES as bt, Currency as c, compileRollupAttribute as ct, DateFormat as d, CompileComputedFormulaInput as dt, ComputedFunctionCategory as et, DateRangeValue as f, ComputedCompileAttribute as ft, FormulaReturnType as g, ComputedFormulaCompileError as gt, FormulaAttribute as h, ComputedDependencyGraphNode as ht, AttributeType as i, evaluateComputedFormula as it, RichtextAttribute as j, ComputedFormulaBinaryNode as jt, RelationTarget as k, ComputedValueType as kt, CurrencyAttribute as l, inferRollupReturnType as lt, DocumentAttribute as m, ComputedCompileSchema as mt, Attribute as n, ComputedFormulaResult as nt, BilateralConfig as o, formatComputedResult as ot, DateValue as p, ComputedCompileObject as pt, OptionPropertyAttribute as q, AttributeGroup as r, evaluateComputedAst as rt, CheckboxAttribute as s, isPlainRecord as st, ATTRIBUTE_TYPES as t, ComputedFunctionMetadata as tt, DateAttribute as u, rollupToFormulaExpression as ut, LocationAttribute as v, compileComputedFormula as vt, Option as w, ComputedDependency as wt, MultiselectAttribute as x, ComputedFunctionName as xt, LocationGranularity as y, COMPUTED_FUNCTIONS as yt, TimeFormat as z };
|