@stndrds/schema 1.0.0-alpha.199 → 1.0.0-alpha.201
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-AAXJJNY6.mjs +509 -0
- package/dist/chunk-NSM2JPC3.js +515 -0
- package/dist/index.js +13 -311
- package/dist/index.mjs +3 -306
- package/dist/validation/all.js +2 -2
- package/dist/validation/all.mjs +1 -1
- package/dist/validation/config/index.js +4 -4
- package/dist/validation/config/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-HXDDJLHD.mjs +0 -190
- package/dist/chunk-M5QIBMIH.js +0 -194
package/dist/chunk-M5QIBMIH.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var zod = require('zod');
|
|
4
|
-
|
|
5
|
-
// src/validation/config/schemas.ts
|
|
6
|
-
var baseConfigSchema = zod.z.object({
|
|
7
|
-
placeholder: zod.z.string().optional(),
|
|
8
|
-
description: zod.z.string().optional(),
|
|
9
|
-
defaultValue: zod.z.unknown().optional(),
|
|
10
|
-
icon: zod.z.string().optional(),
|
|
11
|
-
order: zod.z.number().int().optional(),
|
|
12
|
-
hidden: zod.z.boolean().optional(),
|
|
13
|
-
archived: zod.z.boolean().optional(),
|
|
14
|
-
deprecated: zod.z.boolean().optional(),
|
|
15
|
-
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
16
|
-
});
|
|
17
|
-
var optionSchema = zod.z.object({
|
|
18
|
-
value: zod.z.string().min(1),
|
|
19
|
-
label: zod.z.string().min(1),
|
|
20
|
-
color: zod.z.string().optional(),
|
|
21
|
-
description: zod.z.string().optional(),
|
|
22
|
-
group: zod.z.enum(["idle", "in_progress", "finished"]).optional(),
|
|
23
|
-
inverse: zod.z.string().optional(),
|
|
24
|
-
archived: zod.z.boolean().optional()
|
|
25
|
-
}).strict();
|
|
26
|
-
var optionsArraySchema = zod.z.array(optionSchema).min(1).refine(
|
|
27
|
-
(options) => {
|
|
28
|
-
const values = options.map((o) => o.value);
|
|
29
|
-
return new Set(values).size === values.length;
|
|
30
|
-
},
|
|
31
|
-
{ message: "Duplicate option values are not allowed" }
|
|
32
|
-
);
|
|
33
|
-
var relationTargetSchema = zod.z.object({
|
|
34
|
-
object: zod.z.string().min(1),
|
|
35
|
-
displayTemplate: zod.z.string().optional(),
|
|
36
|
-
filter: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
37
|
-
});
|
|
38
|
-
var bilateralConfigSchema = zod.z.object({
|
|
39
|
-
object: zod.z.string().min(1),
|
|
40
|
-
attribute: zod.z.string().min(1),
|
|
41
|
-
cardinality: zod.z.enum(["one", "many"]).optional(),
|
|
42
|
-
storageOwner: zod.z.boolean().optional()
|
|
43
|
-
});
|
|
44
|
-
var computedOptionsSourceSchema = zod.z.object({
|
|
45
|
-
objectName: zod.z.string().min(1),
|
|
46
|
-
attributeName: zod.z.string().min(1),
|
|
47
|
-
attributeId: zod.z.string().optional()
|
|
48
|
-
});
|
|
49
|
-
var textConfigSchema = baseConfigSchema.extend({
|
|
50
|
-
multiline: zod.z.boolean().optional(),
|
|
51
|
-
minLength: zod.z.number().int().min(0).optional(),
|
|
52
|
-
maxLength: zod.z.number().int().min(1).optional(),
|
|
53
|
-
pattern: zod.z.string().optional(),
|
|
54
|
-
format: zod.z.enum(["email", "url", "slug"]).optional()
|
|
55
|
-
});
|
|
56
|
-
var richtextConfigSchema = baseConfigSchema;
|
|
57
|
-
var numberConfigSchema = baseConfigSchema.extend({
|
|
58
|
-
renderAs: zod.z.enum(["number", "rating"]).optional(),
|
|
59
|
-
min: zod.z.number().optional(),
|
|
60
|
-
max: zod.z.number().optional(),
|
|
61
|
-
unit: zod.z.enum(["integer", "decimal", "percentage"]).optional(),
|
|
62
|
-
decimals: zod.z.number().int().min(0).max(10).optional()
|
|
63
|
-
});
|
|
64
|
-
var checkboxConfigSchema = baseConfigSchema;
|
|
65
|
-
var dateConfigSchema = baseConfigSchema.extend({
|
|
66
|
-
dateFormat: zod.z.enum(["short", "long", "full", "relative"]).optional(),
|
|
67
|
-
minDate: zod.z.string().optional(),
|
|
68
|
-
maxDate: zod.z.string().optional()
|
|
69
|
-
});
|
|
70
|
-
var phoneConfigSchema = baseConfigSchema.extend({
|
|
71
|
-
defaultCountryCode: zod.z.string().length(3).optional()
|
|
72
|
-
});
|
|
73
|
-
var currencyConfigSchema = baseConfigSchema.extend({
|
|
74
|
-
defaultCurrency: zod.z.string().length(3).optional(),
|
|
75
|
-
allowedCurrencies: zod.z.array(zod.z.string().length(3)).optional(),
|
|
76
|
-
allowNegative: zod.z.boolean().optional()
|
|
77
|
-
});
|
|
78
|
-
var statusConfigSchema = baseConfigSchema.extend({
|
|
79
|
-
options: optionsArraySchema
|
|
80
|
-
});
|
|
81
|
-
var locationConfigSchema = baseConfigSchema.extend({
|
|
82
|
-
granularity: zod.z.enum(["full", "address", "city", "state", "country", "coordinates"]).optional(),
|
|
83
|
-
defaultCountry: zod.z.string().length(3).optional(),
|
|
84
|
-
allowedCountries: zod.z.array(zod.z.string().length(3)).optional()
|
|
85
|
-
});
|
|
86
|
-
var selectConfigSchema = baseConfigSchema.extend({
|
|
87
|
-
options: optionsArraySchema
|
|
88
|
-
});
|
|
89
|
-
var multiselectConfigSchema = baseConfigSchema.extend({
|
|
90
|
-
options: optionsArraySchema
|
|
91
|
-
});
|
|
92
|
-
var fileConfigSchema = baseConfigSchema.extend({
|
|
93
|
-
maxFiles: zod.z.number().int().min(1).optional(),
|
|
94
|
-
maxSize: zod.z.number().int().min(1).optional(),
|
|
95
|
-
allowedTypes: zod.z.array(zod.z.string()).optional(),
|
|
96
|
-
multiple: zod.z.boolean().optional()
|
|
97
|
-
});
|
|
98
|
-
var userConfigSchema = baseConfigSchema.extend({
|
|
99
|
-
types: zod.z.array(zod.z.enum(["user", "agent"])).min(1).optional(),
|
|
100
|
-
multiple: zod.z.boolean().optional()
|
|
101
|
-
});
|
|
102
|
-
var relationConfigSchema = baseConfigSchema.extend({
|
|
103
|
-
targets: zod.z.array(relationTargetSchema).min(1),
|
|
104
|
-
cardinality: zod.z.enum(["one", "many"]),
|
|
105
|
-
maxItems: zod.z.number().int().min(1).optional(),
|
|
106
|
-
bilateral: bilateralConfigSchema.optional(),
|
|
107
|
-
/**
|
|
108
|
-
* PropertySchema declared via `.qualifyWith()`. Pass-through; structural
|
|
109
|
-
* validation happens at the builder level — see `propertySchemaPassthrough`
|
|
110
|
-
* comment further below for the rationale.
|
|
111
|
-
*/
|
|
112
|
-
properties: zod.z.object({ definitions: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown())) }).passthrough().optional()
|
|
113
|
-
});
|
|
114
|
-
var formulaConfigSchema = baseConfigSchema.extend({
|
|
115
|
-
expression: zod.z.string().min(1),
|
|
116
|
-
returnType: zod.z.enum(["text", "number", "boolean", "date", "select", "multiselect"]),
|
|
117
|
-
decimals: zod.z.number().int().min(0).max(10).optional(),
|
|
118
|
-
allowRelations: zod.z.boolean().optional(),
|
|
119
|
-
optionsSource: computedOptionsSourceSchema.optional()
|
|
120
|
-
});
|
|
121
|
-
var rollupConfigSchema = baseConfigSchema.extend({
|
|
122
|
-
relationAttribute: zod.z.string().min(1).optional(),
|
|
123
|
-
relationPath: zod.z.string().optional(),
|
|
124
|
-
targetAttribute: zod.z.string().min(1),
|
|
125
|
-
function: zod.z.enum([
|
|
126
|
-
"sum",
|
|
127
|
-
"avg",
|
|
128
|
-
"earliest",
|
|
129
|
-
"latest",
|
|
130
|
-
"count",
|
|
131
|
-
"countValues",
|
|
132
|
-
"countUniqueValues",
|
|
133
|
-
"countEmpty",
|
|
134
|
-
"percentEmpty",
|
|
135
|
-
"percentNotEmpty",
|
|
136
|
-
"original"
|
|
137
|
-
]),
|
|
138
|
-
decimals: zod.z.number().int().min(0).max(10).optional(),
|
|
139
|
-
targetAttributeType: zod.z.string().optional(),
|
|
140
|
-
targetAttributeOptions: zod.z.array(optionSchema).optional(),
|
|
141
|
-
optionsSource: computedOptionsSourceSchema.optional()
|
|
142
|
-
});
|
|
143
|
-
var propertySchemaPassthrough = zod.z.object({ definitions: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown())) }).passthrough();
|
|
144
|
-
var documentSlotConfigPassthrough = zod.z.object({
|
|
145
|
-
name: zod.z.string(),
|
|
146
|
-
label: zod.z.string().optional(),
|
|
147
|
-
description: zod.z.string().optional(),
|
|
148
|
-
required: zod.z.boolean().optional(),
|
|
149
|
-
acceptedMimeTypes: zod.z.array(zod.z.string()).optional(),
|
|
150
|
-
maxSizeBytes: zod.z.number().optional()
|
|
151
|
-
}).passthrough();
|
|
152
|
-
var documentConfigSchema = baseConfigSchema.extend({
|
|
153
|
-
/**
|
|
154
|
-
* PropertySchema declared via `.qualifyWith()` on a document attribute.
|
|
155
|
-
* Drives hydration into `[{id, props}]` shape and write-time validation.
|
|
156
|
-
*/
|
|
157
|
-
properties: propertySchemaPassthrough.optional(),
|
|
158
|
-
/** File slots declared via `.slots(...)`. */
|
|
159
|
-
slots: zod.z.array(documentSlotConfigPassthrough).optional()
|
|
160
|
-
});
|
|
161
|
-
var attributeConfigSchemas = {
|
|
162
|
-
text: textConfigSchema,
|
|
163
|
-
richtext: richtextConfigSchema,
|
|
164
|
-
number: numberConfigSchema,
|
|
165
|
-
checkbox: checkboxConfigSchema,
|
|
166
|
-
date: dateConfigSchema,
|
|
167
|
-
phone: phoneConfigSchema,
|
|
168
|
-
currency: currencyConfigSchema,
|
|
169
|
-
status: statusConfigSchema,
|
|
170
|
-
location: locationConfigSchema,
|
|
171
|
-
select: selectConfigSchema,
|
|
172
|
-
multiselect: multiselectConfigSchema,
|
|
173
|
-
file: fileConfigSchema,
|
|
174
|
-
user: userConfigSchema,
|
|
175
|
-
relation: relationConfigSchema,
|
|
176
|
-
formula: formulaConfigSchema,
|
|
177
|
-
rollup: rollupConfigSchema,
|
|
178
|
-
document: documentConfigSchema
|
|
179
|
-
};
|
|
180
|
-
function getAttributeConfigSchema(type) {
|
|
181
|
-
const schema = attributeConfigSchemas[type];
|
|
182
|
-
if (!schema) {
|
|
183
|
-
throw new Error(`Unsupported attribute type: ${type}`);
|
|
184
|
-
}
|
|
185
|
-
return schema;
|
|
186
|
-
}
|
|
187
|
-
function parseAttributeConfig(type, config) {
|
|
188
|
-
const schema = getAttributeConfigSchema(type);
|
|
189
|
-
return schema.strip().parse(config);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
exports.attributeConfigSchemas = attributeConfigSchemas;
|
|
193
|
-
exports.getAttributeConfigSchema = getAttributeConfigSchema;
|
|
194
|
-
exports.parseAttributeConfig = parseAttributeConfig;
|