@standards/schema 0.0.0-stage → 1.0.0-alpha.382
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +111 -0
- package/README.md +8 -2
- package/dist/all-BgYwavNm.d.mts +2956 -0
- package/dist/all-DjdKldjX.d.ts +2956 -0
- package/dist/api/index.d.mts +11838 -0
- package/dist/api/index.d.ts +11838 -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-aTeqx6cK.d.mts +557 -0
- package/dist/attributes-kAhQzg8-.d.ts +557 -0
- package/dist/checkbox-BZvZOraX.d.mts +11 -0
- package/dist/checkbox-n0YV1O13.d.ts +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-CxqDOhA0.d.mts +24 -0
- package/dist/date-D007KyTI.d.ts +24 -0
- package/dist/exceptions-DjPVyS-Q.d.mts +761 -0
- package/dist/exceptions-DjPVyS-Q.d.ts +761 -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-3HZjBOpj.d.mts +53 -0
- package/dist/index-BmNMneu3.d.mts +278 -0
- package/dist/index-Bu9xF5Nq.d.ts +278 -0
- package/dist/index-CiTBL4gH.d.ts +101 -0
- package/dist/index-D7TEaPqX.d.ts +16519 -0
- package/dist/index-DLO8JpnY.d.ts +53 -0
- package/dist/index-DPO5w-fC.d.mts +101 -0
- package/dist/index-DwQWBzYJ.d.mts +16519 -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-CgBxEbjI.d.mts +11 -0
- package/dist/number-DncH-WRO.d.ts +11 -0
- package/dist/object-DcgxLvip.js +4 -0
- package/dist/object-Dzl7sfq8.mjs +4 -0
- package/dist/objects-B4DgFZ82.d.ts +398 -0
- package/dist/objects-C9f6hFW_.d.mts +398 -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-BSXczk7v.js +2 -0
- package/dist/record-operation-C9oXHmfF.mjs +2 -0
- package/dist/text-A9AJ1wUO.js +2 -0
- package/dist/text-C8Lb-NFo.mjs +2 -0
- package/dist/text-DDoY_LcQ.d.ts +11 -0
- package/dist/text-DeUqCFp9.d.mts +11 -0
- package/dist/utils-B7Dlrtnx.d.ts +163 -0
- package/dist/utils-DbRMK8NI.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-BQ9tU_9G.js +2 -0
- package/dist/view-config.schema-BmjCQJ51.mjs +2 -0
- package/package.json +279 -3
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
|
|
2
|
+
import { J as ImageShape, u as RecordAppearance } from "./objects-B4DgFZ82.js";
|
|
3
|
+
import { i as AttributeType, n as Attribute } from "./attributes-kAhQzg8-.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
|
+
imageShape?: ImageShape;
|
|
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. */
|
|
43
|
+
imageShape?: ImageShape | 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
|
+
objectImageShape?: ImageShape;
|
|
56
|
+
/** The target record's own icon / image; absent when it has neither. */
|
|
57
|
+
appearance?: RecordAppearance;
|
|
58
|
+
label: string;
|
|
59
|
+
}
|
|
60
|
+
interface RelationOptionsResponse {
|
|
61
|
+
options: RelationOption[];
|
|
62
|
+
hasMore: boolean;
|
|
63
|
+
total: number;
|
|
64
|
+
nextOffset?: number;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/validation/config/schemas.d.ts
|
|
68
|
+
/**
|
|
69
|
+
* `baseConfigSchema`'s keys — the model never sets these directly, and the
|
|
70
|
+
* prompt (`attribute-reference.ts`'s `BASE_CONFIG_KEYS`) already hides them
|
|
71
|
+
* from every `<attribute_types>` line. `ADD_ATTRIBUTE_WIRE` omits them from
|
|
72
|
+
* each per-type wire config for the same reason, so the wire never offers a
|
|
73
|
+
* key the model was never told about — and never exposes `metadata`, the one
|
|
74
|
+
* genuine open record among them, on the wire. Single source: the runtime
|
|
75
|
+
* prompt imports this instead of keeping its own copy.
|
|
76
|
+
*/
|
|
77
|
+
declare const WIRE_OMITTED_CONFIG_KEYS: readonly ["placeholder", "description", "defaultValue", "icon", "order", "hidden", "archived", "deprecated", "metadata"];
|
|
78
|
+
/**
|
|
79
|
+
* The omitted base keys one attribute type's wire offers back, each with the
|
|
80
|
+
* wire schema it is validated by. Karl's ruling on #4537 (2026-09-27, «
|
|
81
|
+
* Relations seulement »): a relation field takes its own icon, a catalogue
|
|
82
|
+
* name the agent finds with `search_icons`, exactly as an object icon; every
|
|
83
|
+
* other type keeps `icon` omitted. Single source for the wire
|
|
84
|
+
* (`ADD_ATTRIBUTE_WIRE`) and the prompt (`attribute-reference.ts`), so the
|
|
85
|
+
* key the model is told about is the key the wire accepts.
|
|
86
|
+
*/
|
|
87
|
+
declare const WIRE_OFFERED_BASE_CONFIG: Partial<Record<AttributeType, Partial<Record<(typeof WIRE_OMITTED_CONFIG_KEYS)[number], z$1.ZodType>>>>;
|
|
88
|
+
/** The keys hidden from `attributeType`'s wire config and its prompt line. */
|
|
89
|
+
declare function wireOmittedConfigKeysFor(attributeType: AttributeType): readonly string[];
|
|
90
|
+
/** `omit()` mask of the type keys hidden from `attributeType`'s wire. */
|
|
91
|
+
declare function wireHiddenTypeConfigMask(attributeType: AttributeType): Record<string, true>;
|
|
92
|
+
/**
|
|
93
|
+
* Builds the `superRefine` that refuses a key belonging to a DIFFERENT type
|
|
94
|
+
* than the one sent.
|
|
95
|
+
*
|
|
96
|
+
* Two wire shapes merge several types into one member for size — the nine
|
|
97
|
+
* simple attribute types of `ADD_ATTRIBUTE_WIRE`, and the seven simple
|
|
98
|
+
* qualified-property types below — so a merged member structurally accepts
|
|
99
|
+
* every merged type's keys. Without this, a `text`-only `format` sent on a
|
|
100
|
+
* `number` parses and is then silently `.strip()`-ped at store: a key lost
|
|
101
|
+
* with no feedback. Checked against the SENT type, and the message names the
|
|
102
|
+
* keys that type does accept so the next call is right. One factory rather
|
|
103
|
+
* than two near-identical loops — the second one drifted first.
|
|
104
|
+
*/
|
|
105
|
+
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;
|
|
106
|
+
declare const statusGroupSchema: z$1.ZodEnum<{
|
|
107
|
+
idle: "idle";
|
|
108
|
+
in_progress: "in_progress";
|
|
109
|
+
finished: "finished";
|
|
110
|
+
}>;
|
|
111
|
+
declare const selectOptionWriteSchema: z$1.ZodObject<{
|
|
112
|
+
value: z$1.ZodString;
|
|
113
|
+
label: z$1.ZodString;
|
|
114
|
+
description: z$1.ZodOptional<z$1.ZodString>;
|
|
115
|
+
inverse: z$1.ZodOptional<z$1.ZodString>;
|
|
116
|
+
archived: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
117
|
+
color: z$1.ZodEnum<{
|
|
118
|
+
stone: "stone";
|
|
119
|
+
clay: "clay";
|
|
120
|
+
brick: "brick";
|
|
121
|
+
terra: "terra";
|
|
122
|
+
ochre: "ochre";
|
|
123
|
+
moss: "moss";
|
|
124
|
+
sage: "sage";
|
|
125
|
+
lagoon: "lagoon";
|
|
126
|
+
ink: "ink";
|
|
127
|
+
iris: "iris";
|
|
128
|
+
peony: "peony";
|
|
129
|
+
}>;
|
|
130
|
+
}, z$1.core.$strict>;
|
|
131
|
+
declare const multiselectOptionWriteSchema: z$1.ZodObject<{
|
|
132
|
+
value: z$1.ZodString;
|
|
133
|
+
label: z$1.ZodString;
|
|
134
|
+
description: z$1.ZodOptional<z$1.ZodString>;
|
|
135
|
+
inverse: z$1.ZodOptional<z$1.ZodString>;
|
|
136
|
+
archived: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
137
|
+
color: z$1.ZodEnum<{
|
|
138
|
+
stone: "stone";
|
|
139
|
+
clay: "clay";
|
|
140
|
+
brick: "brick";
|
|
141
|
+
terra: "terra";
|
|
142
|
+
ochre: "ochre";
|
|
143
|
+
moss: "moss";
|
|
144
|
+
sage: "sage";
|
|
145
|
+
lagoon: "lagoon";
|
|
146
|
+
ink: "ink";
|
|
147
|
+
iris: "iris";
|
|
148
|
+
peony: "peony";
|
|
149
|
+
}>;
|
|
150
|
+
}, z$1.core.$strict>;
|
|
151
|
+
declare const statusOptionWriteSchema: z$1.ZodObject<{
|
|
152
|
+
value: z$1.ZodString;
|
|
153
|
+
label: z$1.ZodString;
|
|
154
|
+
description: z$1.ZodOptional<z$1.ZodString>;
|
|
155
|
+
inverse: z$1.ZodOptional<z$1.ZodString>;
|
|
156
|
+
archived: z$1.ZodOptional<z$1.ZodBoolean>;
|
|
157
|
+
color: z$1.ZodEnum<{
|
|
158
|
+
stone: "stone";
|
|
159
|
+
clay: "clay";
|
|
160
|
+
brick: "brick";
|
|
161
|
+
terra: "terra";
|
|
162
|
+
ochre: "ochre";
|
|
163
|
+
moss: "moss";
|
|
164
|
+
sage: "sage";
|
|
165
|
+
lagoon: "lagoon";
|
|
166
|
+
ink: "ink";
|
|
167
|
+
iris: "iris";
|
|
168
|
+
peony: "peony";
|
|
169
|
+
}>;
|
|
170
|
+
group: z$1.ZodEnum<{
|
|
171
|
+
idle: "idle";
|
|
172
|
+
in_progress: "in_progress";
|
|
173
|
+
finished: "finished";
|
|
174
|
+
}>;
|
|
175
|
+
}, z$1.core.$strict>;
|
|
176
|
+
/**
|
|
177
|
+
* Drops, from every option of an attribute config or body, the keys
|
|
178
|
+
* `optionSchema` does not know — typically an `id` the code builder accepted
|
|
179
|
+
* without complaint (#4356). Sync stores options through it, and the schema
|
|
180
|
+
* state reads them through it, so one stale key no longer 400s the whole state.
|
|
181
|
+
* The options of a `relation()`/`document()`'s `.qualifyWith()` properties are
|
|
182
|
+
* validated by the same schema, so each property definition goes through it too.
|
|
183
|
+
*
|
|
184
|
+
* Order is kept, and a config with nothing to drop is returned as is. A list
|
|
185
|
+
* or option that is not the expected shape is left for strict validation to
|
|
186
|
+
* refuse.
|
|
187
|
+
*/
|
|
188
|
+
declare function withoutUnknownOptionKeys<T extends object>(config: T): T;
|
|
189
|
+
/**
|
|
190
|
+
* Property types whose config differs from `baseConfigSchema` only by
|
|
191
|
+
* independent optional scalars — no options array, no relation targets. Same
|
|
192
|
+
* shape as `SIMPLE_ATTRIBUTE_TYPES` in `architect/operations/schema.ts` minus
|
|
193
|
+
* `richtext`/`user` (not valid property types) — none of these seven types'
|
|
194
|
+
* keys collide, proven by `tests/validation/config/property-config.test.ts`.
|
|
195
|
+
* Merged into one wire member for the same reason `ADD_ATTRIBUTE_WIRE` merges
|
|
196
|
+
* its nine: the model reads one shape instead of seven near-identical ones,
|
|
197
|
+
* and this is also what keeps a qualified relation/document's `add_attribute`
|
|
198
|
+
* leaf under its wire-size cap (`tests/architect/wire-schema-size.test.ts`) —
|
|
199
|
+
* ten separate members, each paying its own JSON Schema object/`$defs`
|
|
200
|
+
* boilerplate, blew the budget even after the base config keys were omitted.
|
|
201
|
+
*/
|
|
202
|
+
declare const SIMPLE_PROPERTY_TYPES: readonly ["text", "number", "checkbox", "date", "phone", "currency", "location"];
|
|
203
|
+
declare const propertyAttributeSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<Readonly<{
|
|
204
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
205
|
+
}>, z$1.core.$strip>, ...z$1.ZodObject<Readonly<{
|
|
206
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
207
|
+
}>, z$1.core.$strip>[]], "type">;
|
|
208
|
+
declare const propertySchemaSchema: z$1.ZodObject<{
|
|
209
|
+
definitions: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<Readonly<{
|
|
210
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
211
|
+
}>, z$1.core.$strip>, ...z$1.ZodObject<Readonly<{
|
|
212
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
213
|
+
}>, z$1.core.$strip>[]], "type">>;
|
|
214
|
+
}, z$1.core.$strip>;
|
|
215
|
+
/**
|
|
216
|
+
* The wire-facing property union, derived from the stored one: the same seven
|
|
217
|
+
* simple types merged into one member, the option-carrying types alongside,
|
|
218
|
+
* everything the model never sets omitted, and `.strict()` so an invented key
|
|
219
|
+
* is refused by name instead of silently stripped at store.
|
|
220
|
+
*/
|
|
221
|
+
declare const propertyAttributeWireSchema: z$1.ZodDiscriminatedUnion<[z$1.ZodObject<Readonly<{
|
|
222
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
223
|
+
}>, z$1.core.$strip>, ...z$1.ZodObject<Readonly<{
|
|
224
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
225
|
+
}>, z$1.core.$strip>[]], "type">;
|
|
226
|
+
declare const propertySchemaWireSchema: z$1.ZodObject<{
|
|
227
|
+
definitions: z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<Readonly<{
|
|
228
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
229
|
+
}>, z$1.core.$strip>, ...z$1.ZodObject<Readonly<{
|
|
230
|
+
[k: string]: z$1.core.$ZodType<unknown, unknown, z$1.core.$ZodTypeInternals<unknown, unknown>>;
|
|
231
|
+
}>, z$1.core.$strip>[]], "type">>;
|
|
232
|
+
}, z$1.core.$strict>;
|
|
233
|
+
/**
|
|
234
|
+
* A month or a year has no time of day and no range end to pair with in this
|
|
235
|
+
* slice (#5325): `precision` narrower than a day is refused beside
|
|
236
|
+
* `includeTime` or `endDate`, on the attribute and on each date property it
|
|
237
|
+
* qualifies an edge with.
|
|
238
|
+
*/
|
|
239
|
+
declare function datePrecisionIssues(type: string, config: Record<string, unknown>, path?: PropertyKey[]): {
|
|
240
|
+
path: PropertyKey[];
|
|
241
|
+
message: string;
|
|
242
|
+
}[];
|
|
243
|
+
/**
|
|
244
|
+
* Map of attribute type to config schema
|
|
245
|
+
*/
|
|
246
|
+
declare const attributeConfigSchemas: Record<AttributeType, z$1.ZodObject<z$1.ZodRawShape>>;
|
|
247
|
+
/**
|
|
248
|
+
* Get the config schema for a specific attribute type
|
|
249
|
+
*/
|
|
250
|
+
declare function getAttributeConfigSchema(type: AttributeType): z$1.ZodObject<z$1.ZodRawShape>;
|
|
251
|
+
/**
|
|
252
|
+
* Validate and strip unknown properties from attribute config
|
|
253
|
+
* This ensures only allowed properties are stored in the database
|
|
254
|
+
*/
|
|
255
|
+
declare function parseAttributeConfig(type: AttributeType, config: Record<string, unknown>): Record<string, unknown>;
|
|
256
|
+
/**
|
|
257
|
+
* The config contract as a WRITE applies it: the stored schema plus the
|
|
258
|
+
* stricter option and icon rules newly written values must satisfy.
|
|
259
|
+
*/
|
|
260
|
+
declare function getAttributeConfigWriteSchema(type: AttributeType): z$1.ZodObject<z$1.ZodRawShape>;
|
|
261
|
+
/**
|
|
262
|
+
* Strict parser for newly created attribute definitions.
|
|
263
|
+
*
|
|
264
|
+
* Top-level config remains strip-compatible with the historical config
|
|
265
|
+
* contract, while newly written icons and select-like option objects are
|
|
266
|
+
* validated strictly.
|
|
267
|
+
*/
|
|
268
|
+
declare function parseAttributeConfigForCreate(type: AttributeType, input: unknown): Record<string, unknown>;
|
|
269
|
+
/**
|
|
270
|
+
* Patch-aware parser for persisted attributes.
|
|
271
|
+
*
|
|
272
|
+
* An explicit options patch owns and strictly validates the complete new
|
|
273
|
+
* list. Omission means the stored legacy list is preserved without
|
|
274
|
+
* reconstruction, including options that predate required colours/groups.
|
|
275
|
+
*/
|
|
276
|
+
declare function parseAttributeConfigForUpdate(stored: Attribute, patch: Partial<AddAttributeInput>): Record<string, unknown>;
|
|
277
|
+
//#endregion
|
|
278
|
+
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,101 @@
|
|
|
1
|
+
|
|
2
|
+
import { i as ObjectDefinition } from "./objects-B4DgFZ82.js";
|
|
3
|
+
import { n as Attribute } from "./attributes-kAhQzg8-.js";
|
|
4
|
+
import { i as ValidationResult, r as ValidationMessages } from "./index-DLO8JpnY.js";
|
|
5
|
+
import { z as z$1 } from "zod";
|
|
6
|
+
//#region src/validation/object/attribute-factory.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Create a Zod schema for any attribute type.
|
|
9
|
+
* Returns a strict validator that does NOT handle optional fields.
|
|
10
|
+
* Use createFormAttributeValidator for form validation with optional support.
|
|
11
|
+
*
|
|
12
|
+
* @param attr - The attribute to create a validator for
|
|
13
|
+
* @param messages - Custom validation messages for i18n support
|
|
14
|
+
*/
|
|
15
|
+
declare function createAttributeValidator(attr: Attribute, messages?: ValidationMessages): z$1.ZodTypeAny;
|
|
16
|
+
/**
|
|
17
|
+
* Create a Zod schema for form validation.
|
|
18
|
+
* - Normalizes empty values (empty strings, empty objects) to null for optional fields
|
|
19
|
+
* - Accepts custom messages for i18n support
|
|
20
|
+
*
|
|
21
|
+
* Use this in UI forms where optional fields may have null/undefined values.
|
|
22
|
+
*
|
|
23
|
+
* @param attr - The attribute to create a validator for
|
|
24
|
+
* @param messages - Custom validation messages for i18n support
|
|
25
|
+
*/
|
|
26
|
+
declare function createFormAttributeValidator(attr: Attribute, messages?: ValidationMessages): z$1.ZodTypeAny;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/validation/object/object-validator.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* Create a Zod schema for an entire object
|
|
31
|
+
*
|
|
32
|
+
* Uses passthrough mode to allow computed fields (formula, rollup) that may be
|
|
33
|
+
* present in record data but are not part of the mutable schema.
|
|
34
|
+
*
|
|
35
|
+
* Result is cached per ObjectDefinition instance — safe because ObjectDefinitions
|
|
36
|
+
* are stable after module load and never mutated at runtime.
|
|
37
|
+
*/
|
|
38
|
+
declare function createObjectValidator(objectDef: ObjectDefinition): z$1.ZodType<Record<string, unknown>>;
|
|
39
|
+
/**
|
|
40
|
+
* Create a Zod schema for draft validation.
|
|
41
|
+
* All attributes become optional, but provided values are still validated.
|
|
42
|
+
*
|
|
43
|
+
* Uses passthrough mode to allow computed fields (formula, rollup) that may be
|
|
44
|
+
* present in record data but are not part of the mutable schema.
|
|
45
|
+
*
|
|
46
|
+
* Result is cached per ObjectDefinition instance — safe because ObjectDefinitions
|
|
47
|
+
* are stable after module load and never mutated at runtime.
|
|
48
|
+
*/
|
|
49
|
+
declare function createDraftValidator(objectDef: ObjectDefinition): z$1.ZodType<Record<string, unknown>>;
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/validation/object/helpers.d.ts
|
|
52
|
+
/**
|
|
53
|
+
* Validate data against an attribute schema
|
|
54
|
+
*/
|
|
55
|
+
declare function validateAttribute(attr: Attribute, value: unknown): ValidationResult;
|
|
56
|
+
/**
|
|
57
|
+
* Validate data against an object schema
|
|
58
|
+
*/
|
|
59
|
+
declare function validateObject(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
|
|
60
|
+
/**
|
|
61
|
+
* Validate and throw if invalid.
|
|
62
|
+
*
|
|
63
|
+
* Throws `ValidationError` (code `SCHEMA_VALIDATION_FAILED`) on failure so HTTP
|
|
64
|
+
* adapters can map it to 400. Generic `Error` would bubble up to a 500.
|
|
65
|
+
*/
|
|
66
|
+
declare function validateObjectOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
|
|
67
|
+
/**
|
|
68
|
+
* Validate data in draft mode.
|
|
69
|
+
* - All attributes are treated as optional (no required validation)
|
|
70
|
+
* - Provided values are still validated for format/type correctness
|
|
71
|
+
*/
|
|
72
|
+
declare function validateDraft(objectDef: ObjectDefinition, data: Record<string, unknown>): ValidationResult;
|
|
73
|
+
/**
|
|
74
|
+
* Validate draft data and throw if format validation fails.
|
|
75
|
+
*
|
|
76
|
+
* Same contract as `validateObjectOrThrow` but skips `required()` checks.
|
|
77
|
+
* Throws `ValidationError` so HTTP adapters map it to 400.
|
|
78
|
+
*/
|
|
79
|
+
declare function validateDraftOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): Record<string, unknown>;
|
|
80
|
+
/**
|
|
81
|
+
* Throw a `ValidationError` when `data` contains keys that do not correspond
|
|
82
|
+
* to any attribute declared on `objectDef`.
|
|
83
|
+
*
|
|
84
|
+
* Call this on **client-supplied input** before Zod validation so the error
|
|
85
|
+
* message clearly names every offending key. Do NOT call on merged data that
|
|
86
|
+
* includes existing record values — older records may legitimately carry stale
|
|
87
|
+
* keys that predate this guard (see issue #658).
|
|
88
|
+
*
|
|
89
|
+
* Maps to HTTP 400 via `SchemaExceptionFilter` (code SCHEMA_VALIDATION_FAILED).
|
|
90
|
+
*/
|
|
91
|
+
declare function rejectUnknownAttributesOrThrow(objectDef: ObjectDefinition, data: Record<string, unknown>): void;
|
|
92
|
+
/**
|
|
93
|
+
* Get the list of required attributes that are missing values.
|
|
94
|
+
*/
|
|
95
|
+
declare function getMissingRequiredAttributes(objectDef: ObjectDefinition, data: Record<string, unknown>): Attribute[];
|
|
96
|
+
/**
|
|
97
|
+
* Check if a record is complete (all required attributes have valid values).
|
|
98
|
+
*/
|
|
99
|
+
declare function isRecordComplete(objectDef: ObjectDefinition, data: Record<string, unknown>): boolean;
|
|
100
|
+
//#endregion
|
|
101
|
+
export { validateDraft as a, validateObjectOrThrow as c, createAttributeValidator as d, createFormAttributeValidator as f, validateAttribute as i, createDraftValidator as l, isRecordComplete as n, validateDraftOrThrow as o, rejectUnknownAttributesOrThrow as r, validateObject as s, getMissingRequiredAttributes as t, createObjectValidator as u };
|