@standards/schema 0.0.0-stage → 1.0.0-alpha.384
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/LICENSE +111 -0
- package/README.md +8 -2
- package/dist/all-C9OPP-r1.d.ts +2956 -0
- package/dist/all-CYmW48oj.d.mts +2956 -0
- package/dist/api/index.d.mts +11901 -0
- package/dist/api/index.d.ts +11901 -0
- package/dist/api/index.js +2 -0
- package/dist/api/index.mjs +2 -0
- package/dist/attribute-validators-DRqhAt2t.mjs +11 -0
- package/dist/attribute-validators-WAoJbap5.js +11 -0
- package/dist/attributes-CZD_B0mZ.d.mts +557 -0
- package/dist/attributes-D35Lcoui.d.ts +557 -0
- package/dist/checkbox-CQRDh5tF.d.ts +11 -0
- package/dist/checkbox-D00iEidf.d.mts +11 -0
- package/dist/config-BIxnbUN8.mjs +2 -0
- package/dist/config-DdjlHdPg.js +2 -0
- package/dist/core-397tQy5q.js +2 -0
- package/dist/core-BLHhNykL.mjs +2 -0
- package/dist/date-B9051Wxe.d.mts +24 -0
- package/dist/date-CQdP6Dxe.d.ts +24 -0
- package/dist/exceptions-DoP6VK0v.d.mts +762 -0
- package/dist/exceptions-DoP6VK0v.d.ts +762 -0
- package/dist/exceptions.d.mts +3 -0
- package/dist/exceptions.d.ts +3 -0
- package/dist/exceptions.js +2 -0
- package/dist/exceptions.mjs +2 -0
- package/dist/index-B3wdnfLl.d.mts +279 -0
- package/dist/index-BLXzRQr9.d.ts +53 -0
- package/dist/index-BS-60koN.d.mts +16591 -0
- package/dist/index-CH-Vc-pK.d.ts +279 -0
- package/dist/index-CSDAHifu.d.mts +53 -0
- package/dist/index-CgEVJG3l.d.ts +16591 -0
- package/dist/index-D0L0GHU0.d.mts +101 -0
- package/dist/index-E9rSexij.d.ts +101 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +2 -0
- package/dist/index.mjs +2 -0
- package/dist/number-BwCSeK20.d.ts +11 -0
- package/dist/number-CisXUosg.d.mts +11 -0
- package/dist/object-DcgxLvip.js +4 -0
- package/dist/object-Dzl7sfq8.mjs +4 -0
- package/dist/objects-CH22DJOx.d.ts +408 -0
- package/dist/objects-DhKrQEo4.d.mts +408 -0
- package/dist/phone-BB-tzcSr.js +2 -0
- package/dist/phone-Bca_xiOX.mjs +2 -0
- package/dist/record-aggregates-CzG86pUS.mjs +2 -0
- package/dist/record-aggregates-DwpIJ2Dv.js +2 -0
- package/dist/record-operation-B7t5aXW3.js +2 -0
- package/dist/record-operation-DueJTyDh.mjs +2 -0
- package/dist/text-A9AJ1wUO.js +2 -0
- package/dist/text-C8Lb-NFo.mjs +2 -0
- package/dist/text-SkYUYEnE.d.ts +11 -0
- package/dist/text-Z1_WL8cd.d.mts +11 -0
- package/dist/utils-C_J_p_tL.d.ts +163 -0
- package/dist/utils-CkcPS_M9.d.mts +163 -0
- package/dist/utils-fXIvFFl6.mjs +2 -0
- package/dist/utils-gY3d9Dwp.js +2 -0
- package/dist/utils.d.mts +3 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +2 -0
- package/dist/utils.mjs +2 -0
- package/dist/validation/all.d.mts +6 -0
- package/dist/validation/all.d.ts +6 -0
- package/dist/validation/all.js +2 -0
- package/dist/validation/all.mjs +2 -0
- package/dist/validation/complex/currency.d.mts +13 -0
- package/dist/validation/complex/currency.d.ts +13 -0
- package/dist/validation/complex/currency.js +2 -0
- package/dist/validation/complex/currency.mjs +2 -0
- package/dist/validation/complex/location.d.mts +20 -0
- package/dist/validation/complex/location.d.ts +20 -0
- package/dist/validation/complex/location.js +2 -0
- package/dist/validation/complex/location.mjs +2 -0
- package/dist/validation/complex/phone.d.mts +20 -0
- package/dist/validation/complex/phone.d.ts +20 -0
- package/dist/validation/complex/phone.js +2 -0
- package/dist/validation/complex/phone.mjs +2 -0
- package/dist/validation/complex/relation.d.mts +23 -0
- package/dist/validation/complex/relation.d.ts +23 -0
- package/dist/validation/complex/relation.js +2 -0
- package/dist/validation/complex/relation.mjs +2 -0
- package/dist/validation/complex/richtext.d.mts +11 -0
- package/dist/validation/complex/richtext.d.ts +11 -0
- package/dist/validation/complex/richtext.js +2 -0
- package/dist/validation/complex/richtext.mjs +2 -0
- package/dist/validation/complex/select.d.mts +18 -0
- package/dist/validation/complex/select.d.ts +18 -0
- package/dist/validation/complex/select.js +2 -0
- package/dist/validation/complex/select.mjs +2 -0
- package/dist/validation/complex/user.d.mts +11 -0
- package/dist/validation/complex/user.d.ts +11 -0
- package/dist/validation/complex/user.js +2 -0
- package/dist/validation/complex/user.mjs +2 -0
- package/dist/validation/computed/formula.d.mts +12 -0
- package/dist/validation/computed/formula.d.ts +12 -0
- package/dist/validation/computed/formula.js +2 -0
- package/dist/validation/computed/formula.mjs +2 -0
- package/dist/validation/computed/rollup.d.mts +12 -0
- package/dist/validation/computed/rollup.d.ts +12 -0
- package/dist/validation/computed/rollup.js +2 -0
- package/dist/validation/computed/rollup.mjs +2 -0
- package/dist/validation/config/index.d.mts +3 -0
- package/dist/validation/config/index.d.ts +3 -0
- package/dist/validation/config/index.js +2 -0
- package/dist/validation/config/index.mjs +2 -0
- package/dist/validation/core/index.d.mts +3 -0
- package/dist/validation/core/index.d.ts +3 -0
- package/dist/validation/core/index.js +2 -0
- package/dist/validation/core/index.mjs +2 -0
- package/dist/validation/object/index.d.mts +3 -0
- package/dist/validation/object/index.d.ts +3 -0
- package/dist/validation/object/index.js +2 -0
- package/dist/validation/object/index.mjs +2 -0
- package/dist/validation/primitives/checkbox.d.mts +3 -0
- package/dist/validation/primitives/checkbox.d.ts +3 -0
- package/dist/validation/primitives/checkbox.js +2 -0
- package/dist/validation/primitives/checkbox.mjs +2 -0
- package/dist/validation/primitives/date.d.mts +3 -0
- package/dist/validation/primitives/date.d.ts +3 -0
- package/dist/validation/primitives/date.js +2 -0
- package/dist/validation/primitives/date.mjs +2 -0
- package/dist/validation/primitives/number.d.mts +3 -0
- package/dist/validation/primitives/number.d.ts +3 -0
- package/dist/validation/primitives/number.js +2 -0
- package/dist/validation/primitives/number.mjs +2 -0
- package/dist/validation/primitives/text.d.mts +3 -0
- package/dist/validation/primitives/text.d.ts +3 -0
- package/dist/validation/primitives/text.js +2 -0
- package/dist/validation/primitives/text.mjs +2 -0
- package/dist/view-config.schema-BqO1hmWR.mjs +2 -0
- package/dist/view-config.schema-DVoE_g3g.js +2 -0
- package/package.json +279 -3
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
|
|
2
|
+
import { Y as ObjectImage, u as RecordAppearance } from "./objects-CH22DJOx.js";
|
|
3
|
+
import { i as AttributeType, n as Attribute } from "./attributes-D35Lcoui.js";
|
|
4
|
+
import { z as z$1 } from "zod";
|
|
5
|
+
import { ColorId, IconName } from "@standards/constants";
|
|
6
|
+
//#region src/types/mutations.d.ts
|
|
7
|
+
interface AddAttributeInput {
|
|
8
|
+
name: string;
|
|
9
|
+
label: string;
|
|
10
|
+
type: AttributeType;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
unique?: boolean;
|
|
13
|
+
description?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
icon?: IconName;
|
|
16
|
+
defaultValue?: unknown;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
interface CreateCustomObjectInput {
|
|
21
|
+
name: string;
|
|
22
|
+
label: string;
|
|
23
|
+
pluralLabel?: string;
|
|
24
|
+
labelExpression: string;
|
|
25
|
+
embeddingExpression?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
icon?: IconName;
|
|
28
|
+
color?: ColorId;
|
|
29
|
+
image?: ObjectImage;
|
|
30
|
+
attributes?: (Attribute | {
|
|
31
|
+
build: () => Attribute;
|
|
32
|
+
})[];
|
|
33
|
+
metadata?: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
interface UpdateObjectInput {
|
|
36
|
+
label?: string;
|
|
37
|
+
pluralLabel?: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
icon?: IconName;
|
|
40
|
+
/** `null` clears it: the colour then derives from the object name. */
|
|
41
|
+
color?: ColorId | null;
|
|
42
|
+
/** `null` clears it: record images then crop to a square, and are found nowhere. */
|
|
43
|
+
image?: ObjectImage | null;
|
|
44
|
+
labelExpression?: string;
|
|
45
|
+
embeddingExpression?: string;
|
|
46
|
+
metadata?: Record<string, unknown>;
|
|
47
|
+
}
|
|
48
|
+
interface RelationOption {
|
|
49
|
+
id: string;
|
|
50
|
+
objectId: string;
|
|
51
|
+
objectName: string;
|
|
52
|
+
objectLabel: string;
|
|
53
|
+
objectIcon?: string;
|
|
54
|
+
objectColor?: ColorId;
|
|
55
|
+
/** How the target object crops its records' images: all an option needs of its image settings. */
|
|
56
|
+
objectImage?: Pick<ObjectImage, "shape">;
|
|
57
|
+
/** The target record's own icon / image; absent when it has neither. */
|
|
58
|
+
appearance?: RecordAppearance;
|
|
59
|
+
label: string;
|
|
60
|
+
}
|
|
61
|
+
interface RelationOptionsResponse {
|
|
62
|
+
options: RelationOption[];
|
|
63
|
+
hasMore: boolean;
|
|
64
|
+
total: number;
|
|
65
|
+
nextOffset?: number;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/validation/config/schemas.d.ts
|
|
69
|
+
/**
|
|
70
|
+
* `baseConfigSchema`'s keys — the model never sets these directly, and the
|
|
71
|
+
* prompt (`attribute-reference.ts`'s `BASE_CONFIG_KEYS`) already hides them
|
|
72
|
+
* from every `<attribute_types>` line. `ADD_ATTRIBUTE_WIRE` omits them from
|
|
73
|
+
* each per-type wire config for the same reason, so the wire never offers a
|
|
74
|
+
* key the model was never told about — and never exposes `metadata`, the one
|
|
75
|
+
* genuine open record among them, on the wire. Single source: the runtime
|
|
76
|
+
* prompt imports this instead of keeping its own copy.
|
|
77
|
+
*/
|
|
78
|
+
declare const WIRE_OMITTED_CONFIG_KEYS: readonly ["placeholder", "description", "defaultValue", "icon", "order", "hidden", "archived", "deprecated", "metadata"];
|
|
79
|
+
/**
|
|
80
|
+
* The omitted base keys one attribute type's wire offers back, each with the
|
|
81
|
+
* wire schema it is validated by. Karl's ruling on #4537 (2026-09-27, «
|
|
82
|
+
* Relations seulement »): a relation field takes its own icon, a catalogue
|
|
83
|
+
* name the agent finds with `search_icons`, exactly as an object icon; every
|
|
84
|
+
* other type keeps `icon` omitted. Single source for the wire
|
|
85
|
+
* (`ADD_ATTRIBUTE_WIRE`) and the prompt (`attribute-reference.ts`), so the
|
|
86
|
+
* key the model is told about is the key the wire accepts.
|
|
87
|
+
*/
|
|
88
|
+
declare const WIRE_OFFERED_BASE_CONFIG: Partial<Record<AttributeType, Partial<Record<(typeof WIRE_OMITTED_CONFIG_KEYS)[number], z$1.ZodType>>>>;
|
|
89
|
+
/** The keys hidden from `attributeType`'s wire config and its prompt line. */
|
|
90
|
+
declare function wireOmittedConfigKeysFor(attributeType: AttributeType): readonly string[];
|
|
91
|
+
/** `omit()` mask of the type keys hidden from `attributeType`'s wire. */
|
|
92
|
+
declare function wireHiddenTypeConfigMask(attributeType: AttributeType): Record<string, true>;
|
|
93
|
+
/**
|
|
94
|
+
* Builds the `superRefine` that refuses a key belonging to a DIFFERENT type
|
|
95
|
+
* than the one sent.
|
|
96
|
+
*
|
|
97
|
+
* Two wire shapes merge several types into one member for size — the nine
|
|
98
|
+
* simple attribute types of `ADD_ATTRIBUTE_WIRE`, and the seven simple
|
|
99
|
+
* qualified-property types below — so a merged member structurally accepts
|
|
100
|
+
* every merged type's keys. Without this, a `text`-only `format` sent on a
|
|
101
|
+
* `number` parses and is then silently `.strip()`-ped at store: a key lost
|
|
102
|
+
* with no feedback. Checked against the SENT type, and the message names the
|
|
103
|
+
* keys that type does accept so the next call is right. One factory rather
|
|
104
|
+
* than two near-identical loops — the second one drifted first.
|
|
105
|
+
*/
|
|
106
|
+
declare function refuseForeignKeys<T extends string>(keysByType: Readonly<Record<T, ReadonlySet<string>>>, noun: string, alwaysAllowed?: readonly string[]): (type: T, subject: Record<string, unknown> | undefined, ctx: z$1.RefinementCtx, path?: readonly string[]) => void;
|
|
107
|
+
declare const statusGroupSchema: z$1.ZodEnum<{
|
|
108
|
+
idle: "idle";
|
|
109
|
+
in_progress: "in_progress";
|
|
110
|
+
finished: "finished";
|
|
111
|
+
}>;
|
|
112
|
+
declare const selectOptionWriteSchema: z$1.ZodObject<{
|
|
113
|
+
value: z$1.ZodString;
|
|
114
|
+
label: z$1.ZodString;
|
|
115
|
+
description: z$1.ZodOptional<z$1.ZodString>;
|
|
116
|
+
inverse: z$1.ZodOptional<z$1.ZodString>;
|
|
117
|
+
archived: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
118
|
+
color: z$1.ZodEnum<{
|
|
119
|
+
stone: "stone";
|
|
120
|
+
clay: "clay";
|
|
121
|
+
brick: "brick";
|
|
122
|
+
terra: "terra";
|
|
123
|
+
ochre: "ochre";
|
|
124
|
+
moss: "moss";
|
|
125
|
+
sage: "sage";
|
|
126
|
+
lagoon: "lagoon";
|
|
127
|
+
ink: "ink";
|
|
128
|
+
iris: "iris";
|
|
129
|
+
peony: "peony";
|
|
130
|
+
}>;
|
|
131
|
+
}, z$1.core.$strict>;
|
|
132
|
+
declare const multiselectOptionWriteSchema: z$1.ZodObject<{
|
|
133
|
+
value: z$1.ZodString;
|
|
134
|
+
label: z$1.ZodString;
|
|
135
|
+
description: z$1.ZodOptional<z$1.ZodString>;
|
|
136
|
+
inverse: z$1.ZodOptional<z$1.ZodString>;
|
|
137
|
+
archived: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
138
|
+
color: z$1.ZodEnum<{
|
|
139
|
+
stone: "stone";
|
|
140
|
+
clay: "clay";
|
|
141
|
+
brick: "brick";
|
|
142
|
+
terra: "terra";
|
|
143
|
+
ochre: "ochre";
|
|
144
|
+
moss: "moss";
|
|
145
|
+
sage: "sage";
|
|
146
|
+
lagoon: "lagoon";
|
|
147
|
+
ink: "ink";
|
|
148
|
+
iris: "iris";
|
|
149
|
+
peony: "peony";
|
|
150
|
+
}>;
|
|
151
|
+
}, z$1.core.$strict>;
|
|
152
|
+
declare const statusOptionWriteSchema: z$1.ZodObject<{
|
|
153
|
+
value: z$1.ZodString;
|
|
154
|
+
label: z$1.ZodString;
|
|
155
|
+
description: z$1.ZodOptional<z$1.ZodString>;
|
|
156
|
+
inverse: z$1.ZodOptional<z$1.ZodString>;
|
|
157
|
+
archived: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
158
|
+
color: z$1.ZodEnum<{
|
|
159
|
+
stone: "stone";
|
|
160
|
+
clay: "clay";
|
|
161
|
+
brick: "brick";
|
|
162
|
+
terra: "terra";
|
|
163
|
+
ochre: "ochre";
|
|
164
|
+
moss: "moss";
|
|
165
|
+
sage: "sage";
|
|
166
|
+
lagoon: "lagoon";
|
|
167
|
+
ink: "ink";
|
|
168
|
+
iris: "iris";
|
|
169
|
+
peony: "peony";
|
|
170
|
+
}>;
|
|
171
|
+
group: z$1.ZodEnum<{
|
|
172
|
+
idle: "idle";
|
|
173
|
+
in_progress: "in_progress";
|
|
174
|
+
finished: "finished";
|
|
175
|
+
}>;
|
|
176
|
+
}, z$1.core.$strict>;
|
|
177
|
+
/**
|
|
178
|
+
* Drops, from every option of an attribute config or body, the keys
|
|
179
|
+
* `optionSchema` does not know — typically an `id` the code builder accepted
|
|
180
|
+
* without complaint (#4356). Sync stores options through it, and the schema
|
|
181
|
+
* state reads them through it, so one stale key no longer 400s the whole state.
|
|
182
|
+
* The options of a `relation()`/`document()`'s `.qualifyWith()` properties are
|
|
183
|
+
* validated by the same schema, so each property definition goes through it too.
|
|
184
|
+
*
|
|
185
|
+
* Order is kept, and a config with nothing to drop is returned as is. A list
|
|
186
|
+
* or option that is not the expected shape is left for strict validation to
|
|
187
|
+
* refuse.
|
|
188
|
+
*/
|
|
189
|
+
declare function withoutUnknownOptionKeys<T extends object>(config: T): T;
|
|
190
|
+
/**
|
|
191
|
+
* Property types whose config differs from `baseConfigSchema` only by
|
|
192
|
+
* independent optional scalars — no options array, no relation targets. Same
|
|
193
|
+
* shape as `SIMPLE_ATTRIBUTE_TYPES` in `architect/operations/schema.ts` minus
|
|
194
|
+
* `richtext`/`user` (not valid property types) — none of these seven types'
|
|
195
|
+
* keys collide, proven by `tests/validation/config/property-config.test.ts`.
|
|
196
|
+
* Merged into one wire member for the same reason `ADD_ATTRIBUTE_WIRE` merges
|
|
197
|
+
* its nine: the model reads one shape instead of seven near-identical ones,
|
|
198
|
+
* and this is also what keeps a qualified relation/document's `add_attribute`
|
|
199
|
+
* leaf under its wire-size cap (`tests/architect/wire-schema-size.test.ts`) —
|
|
200
|
+
* ten separate members, each paying its own JSON Schema object/`$defs`
|
|
201
|
+
* boilerplate, blew the budget even after the base config keys were omitted.
|
|
202
|
+
*/
|
|
203
|
+
declare const SIMPLE_PROPERTY_TYPES: readonly ["text", "number", "checkbox", "date", "phone", "currency", "location"];
|
|
204
|
+
declare const propertyAttributeSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<Readonly<{
|
|
205
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
206
|
+
}>, z$1.core.$strip>, ...z$1.ZodObject<Readonly<{
|
|
207
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
208
|
+
}>, z$1.core.$strip>[]], "type">;
|
|
209
|
+
declare const propertySchemaSchema: z$1.ZodObject<{
|
|
210
|
+
definitions: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<Readonly<{
|
|
211
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
212
|
+
}>, z$1.core.$strip>, ...z$1.ZodObject<Readonly<{
|
|
213
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
214
|
+
}>, z$1.core.$strip>[]], "type">>;
|
|
215
|
+
}, z$1.core.$strip>;
|
|
216
|
+
/**
|
|
217
|
+
* The wire-facing property union, derived from the stored one: the same seven
|
|
218
|
+
* simple types merged into one member, the option-carrying types alongside,
|
|
219
|
+
* everything the model never sets omitted, and `.strict()` so an invented key
|
|
220
|
+
* is refused by name instead of silently stripped at store.
|
|
221
|
+
*/
|
|
222
|
+
declare const propertyAttributeWireSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<Readonly<{
|
|
223
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
224
|
+
}>, z$1.core.$strip>, ...z$1.ZodObject<Readonly<{
|
|
225
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
226
|
+
}>, z$1.core.$strip>[]], "type">;
|
|
227
|
+
declare const propertySchemaWireSchema: z$1.ZodObject<{
|
|
228
|
+
definitions: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<Readonly<{
|
|
229
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
230
|
+
}>, z$1.core.$strip>, ...z$1.ZodObject<Readonly<{
|
|
231
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
232
|
+
}>, z$1.core.$strip>[]], "type">>;
|
|
233
|
+
}, z$1.core.$strict>;
|
|
234
|
+
/**
|
|
235
|
+
* A month or a year has no time of day and no range end to pair with in this
|
|
236
|
+
* slice (#5325): `precision` narrower than a day is refused beside
|
|
237
|
+
* `includeTime` or `endDate`, on the attribute and on each date property it
|
|
238
|
+
* qualifies an edge with.
|
|
239
|
+
*/
|
|
240
|
+
declare function datePrecisionIssues(type: string, config: Record<string, unknown>, path?: PropertyKey[]): {
|
|
241
|
+
path: PropertyKey[];
|
|
242
|
+
message: string;
|
|
243
|
+
}[];
|
|
244
|
+
/**
|
|
245
|
+
* Map of attribute type to config schema
|
|
246
|
+
*/
|
|
247
|
+
declare const attributeConfigSchemas: Record<AttributeType, z$1.ZodObject<z$1.ZodRawShape>>;
|
|
248
|
+
/**
|
|
249
|
+
* Get the config schema for a specific attribute type
|
|
250
|
+
*/
|
|
251
|
+
declare function getAttributeConfigSchema(type: AttributeType): z$1.ZodObject<z$1.ZodRawShape>;
|
|
252
|
+
/**
|
|
253
|
+
* Validate and strip unknown properties from attribute config
|
|
254
|
+
* This ensures only allowed properties are stored in the database
|
|
255
|
+
*/
|
|
256
|
+
declare function parseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown>;
|
|
257
|
+
/**
|
|
258
|
+
* The config contract as a WRITE applies it: the stored schema plus the
|
|
259
|
+
* stricter option and icon rules newly written values must satisfy.
|
|
260
|
+
*/
|
|
261
|
+
declare function getAttributeConfigWriteSchema(type: AttributeType): z$1.ZodObject<z$1.ZodRawShape>;
|
|
262
|
+
/**
|
|
263
|
+
* Strict parser for newly created attribute definitions.
|
|
264
|
+
*
|
|
265
|
+
* Top-level config remains strip-compatible with the historical config
|
|
266
|
+
* contract, while newly written icons and select-like option objects are
|
|
267
|
+
* validated strictly.
|
|
268
|
+
*/
|
|
269
|
+
declare function parseAttributeConfigForCreate(type: AttributeType, input: unknown): Record<string, unknown>;
|
|
270
|
+
/**
|
|
271
|
+
* Patch-aware parser for persisted attributes.
|
|
272
|
+
*
|
|
273
|
+
* An explicit options patch owns and strictly validates the complete new
|
|
274
|
+
* list. Omission means the stored legacy list is preserved without
|
|
275
|
+
* reconstruction, including options that predate required colours/groups.
|
|
276
|
+
*/
|
|
277
|
+
declare function parseAttributeConfigForUpdate(stored: Attribute, patch: Partial<AddAttributeInput>): Record<string, unknown>;
|
|
278
|
+
//#endregion
|
|
279
|
+
export { AddAttributeInput as C, UpdateObjectInput as D, RelationOptionsResponse as E, withoutUnknownOptionKeys as S, RelationOption as T, selectOptionWriteSchema as _, datePrecisionIssues as a, wireHiddenTypeConfigMask as b, multiselectOptionWriteSchema as c, parseAttributeConfigForUpdate as d, propertyAttributeSchema as f, refuseForeignKeys as g, propertySchemaWireSchema as h, attributeConfigSchemas as i, parseAttributeConfig as l, propertySchemaSchema as m, WIRE_OFFERED_BASE_CONFIG as n, getAttributeConfigSchema as o, propertyAttributeWireSchema as p, WIRE_OMITTED_CONFIG_KEYS as r, getAttributeConfigWriteSchema as s, SIMPLE_PROPERTY_TYPES as t, parseAttributeConfigForCreate as u, statusGroupSchema as v, CreateCustomObjectInput as w, wireOmittedConfigKeysFor as x, statusOptionWriteSchema as y };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
import { n as Attribute } from "./attributes-CZD_B0mZ.mjs";
|
|
3
|
+
import { z as z$1 } from "zod";
|
|
4
|
+
//#region src/validation/core/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Validation messages for Zod validators.
|
|
7
|
+
* All functions receive the full Attribute to access label, type, etc.
|
|
8
|
+
* Can be customized for i18n support.
|
|
9
|
+
*/
|
|
10
|
+
interface ValidationMessages {
|
|
11
|
+
required: (attr: Attribute) => string;
|
|
12
|
+
invalidType: (attr: Attribute, expected: string) => string;
|
|
13
|
+
minLength: (attr: Attribute, min: number) => string;
|
|
14
|
+
maxLength: (attr: Attribute, max: number) => string;
|
|
15
|
+
invalidPattern: (attr: Attribute) => string;
|
|
16
|
+
minValue: (attr: Attribute, min: number) => string;
|
|
17
|
+
maxValue: (attr: Attribute, max: number) => string;
|
|
18
|
+
mustBeInteger: (attr: Attribute) => string;
|
|
19
|
+
invalidDate: (attr: Attribute) => string;
|
|
20
|
+
invalidOption: (attr: Attribute, options: string[]) => string;
|
|
21
|
+
invalidId: (attr: Attribute) => string;
|
|
22
|
+
maxItems: (attr: Attribute, max: number) => string;
|
|
23
|
+
invalidRichtext: (attr: Attribute) => string;
|
|
24
|
+
invalidPhone: (attr: Attribute) => string;
|
|
25
|
+
invalidCurrency: (attr: Attribute) => string;
|
|
26
|
+
invalidLocation: (attr: Attribute) => string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Validation result
|
|
30
|
+
*/
|
|
31
|
+
interface ValidationResult {
|
|
32
|
+
success: boolean;
|
|
33
|
+
data?: Record<string, unknown>;
|
|
34
|
+
errors?: Array<{
|
|
35
|
+
path: string[];
|
|
36
|
+
message: string;
|
|
37
|
+
}>;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/validation/core/messages.d.ts
|
|
41
|
+
declare const DEFAULT_VALIDATION_MESSAGES: ValidationMessages;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/validation/core/errors.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* Format Zod validation errors into a consistent structure.
|
|
46
|
+
* This eliminates code duplication across multiple validation functions.
|
|
47
|
+
*/
|
|
48
|
+
declare function formatZodErrors(error: z$1.ZodError): Array<{
|
|
49
|
+
path: string[];
|
|
50
|
+
message: string;
|
|
51
|
+
}>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { ValidationResult as i, DEFAULT_VALIDATION_MESSAGES as n, ValidationMessages as r, formatZodErrors as t };
|