@shoppexio/builder-contracts 0.1.0
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/builder-contracts.test.d.ts +2 -0
- package/dist/builder-contracts.test.d.ts.map +1 -0
- package/dist/builder-contracts.test.js +361 -0
- package/dist/builder-settings.d.ts +801 -0
- package/dist/builder-settings.d.ts.map +1 -0
- package/dist/builder-settings.js +65 -0
- package/dist/events.d.ts +512 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +104 -0
- package/dist/fields.d.ts +300 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +111 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/legacy-manifest.d.ts +172 -0
- package/dist/legacy-manifest.d.ts.map +1 -0
- package/dist/legacy-manifest.js +272 -0
- package/dist/migrations.d.ts +31 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +175 -0
- package/dist/preview-protocol.d.ts +687 -0
- package/dist/preview-protocol.d.ts.map +1 -0
- package/dist/preview-protocol.js +79 -0
- package/dist/style-slots.d.ts +209 -0
- package/dist/style-slots.d.ts.map +1 -0
- package/dist/style-slots.js +93 -0
- package/dist/theme-manifest.d.ts +845 -0
- package/dist/theme-manifest.d.ts.map +1 -0
- package/dist/theme-manifest.js +119 -0
- package/dist/validation.d.ts +16 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +131 -0
- package/package.json +95 -0
- package/src/builder-contracts.test.ts +405 -0
- package/src/builder-settings.ts +85 -0
- package/src/events.ts +121 -0
- package/src/fields.ts +134 -0
- package/src/index.ts +9 -0
- package/src/legacy-manifest.ts +321 -0
- package/src/migrations.ts +240 -0
- package/src/preview-protocol.ts +93 -0
- package/src/style-slots.ts +111 -0
- package/src/theme-manifest.ts +140 -0
- package/src/validation.ts +196 -0
package/dist/events.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { BlockInstanceSchema, CustomPageSchema, PageIdSchema } from "./builder-settings.js";
|
|
3
|
+
import { StyleSlotIdSchema } from "./style-slots.js";
|
|
4
|
+
const EventBaseSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
id: z.string().min(1),
|
|
7
|
+
revision: z.number().int().nonnegative(),
|
|
8
|
+
createdAt: z.string().datetime(),
|
|
9
|
+
source: z.enum(['dashboard', 'preview', 'migration', 'agent']),
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
12
|
+
const ContentSetEventSchema = EventBaseSchema.extend({
|
|
13
|
+
type: z.literal('content.set'),
|
|
14
|
+
path: z.string().min(1),
|
|
15
|
+
value: z.unknown(),
|
|
16
|
+
}).strict();
|
|
17
|
+
const ListSetEventSchema = EventBaseSchema.extend({
|
|
18
|
+
type: z.literal('content.list.set'),
|
|
19
|
+
path: z.string().min(1),
|
|
20
|
+
value: z.array(z.unknown()),
|
|
21
|
+
}).strict();
|
|
22
|
+
const BlockAddEventSchema = EventBaseSchema.extend({
|
|
23
|
+
type: z.literal('block.add'),
|
|
24
|
+
pageId: PageIdSchema,
|
|
25
|
+
block: BlockInstanceSchema,
|
|
26
|
+
index: z.number().int().nonnegative().optional(),
|
|
27
|
+
}).strict();
|
|
28
|
+
const BlockDuplicateEventSchema = EventBaseSchema.extend({
|
|
29
|
+
type: z.literal('block.duplicate'),
|
|
30
|
+
pageId: PageIdSchema,
|
|
31
|
+
sourceBlockId: z.string().min(1),
|
|
32
|
+
block: BlockInstanceSchema,
|
|
33
|
+
}).strict();
|
|
34
|
+
const BlockRemoveEventSchema = EventBaseSchema.extend({
|
|
35
|
+
type: z.literal('block.remove'),
|
|
36
|
+
pageId: PageIdSchema,
|
|
37
|
+
blockId: z.string().min(1),
|
|
38
|
+
}).strict();
|
|
39
|
+
const BlockReorderEventSchema = EventBaseSchema.extend({
|
|
40
|
+
type: z.literal('block.reorder'),
|
|
41
|
+
pageId: PageIdSchema,
|
|
42
|
+
blockIds: z.array(z.string().min(1)).min(1),
|
|
43
|
+
}).strict();
|
|
44
|
+
const BlockVisibilityEventSchema = EventBaseSchema.extend({
|
|
45
|
+
type: z.literal('block.visibility.set'),
|
|
46
|
+
pageId: PageIdSchema,
|
|
47
|
+
blockId: z.string().min(1),
|
|
48
|
+
visible: z.boolean(),
|
|
49
|
+
}).strict();
|
|
50
|
+
const BlockVariantEventSchema = EventBaseSchema.extend({
|
|
51
|
+
type: z.literal('block.variant.set'),
|
|
52
|
+
pageId: PageIdSchema,
|
|
53
|
+
blockId: z.string().min(1),
|
|
54
|
+
variant: z.string().min(1),
|
|
55
|
+
}).strict();
|
|
56
|
+
const BlockSettingsEventSchema = EventBaseSchema.extend({
|
|
57
|
+
type: z.literal('block.settings.set'),
|
|
58
|
+
pageId: PageIdSchema,
|
|
59
|
+
blockId: z.string().min(1),
|
|
60
|
+
path: z.string().min(1),
|
|
61
|
+
value: z.unknown(),
|
|
62
|
+
}).strict();
|
|
63
|
+
const StyleSlotSetEventSchema = EventBaseSchema.extend({
|
|
64
|
+
type: z.literal('style.slot.set'),
|
|
65
|
+
slotId: StyleSlotIdSchema,
|
|
66
|
+
value: z.unknown(),
|
|
67
|
+
blockId: z.string().min(1).optional(),
|
|
68
|
+
breakpoint: z.enum(['base', 'sm', 'md', 'lg', 'xl']).optional(),
|
|
69
|
+
}).strict();
|
|
70
|
+
const StyleSlotResetEventSchema = EventBaseSchema.extend({
|
|
71
|
+
type: z.literal('style.slot.reset'),
|
|
72
|
+
slotId: StyleSlotIdSchema,
|
|
73
|
+
blockId: z.string().min(1).optional(),
|
|
74
|
+
breakpoint: z.enum(['base', 'sm', 'md', 'lg', 'xl']).optional(),
|
|
75
|
+
}).strict();
|
|
76
|
+
const PageUpsertEventSchema = EventBaseSchema.extend({
|
|
77
|
+
type: z.literal('page.upsert'),
|
|
78
|
+
page: CustomPageSchema,
|
|
79
|
+
}).strict();
|
|
80
|
+
const PageRemoveEventSchema = EventBaseSchema.extend({
|
|
81
|
+
type: z.literal('page.remove'),
|
|
82
|
+
pageId: PageIdSchema,
|
|
83
|
+
}).strict();
|
|
84
|
+
const TermsSetEventSchema = EventBaseSchema.extend({
|
|
85
|
+
type: z.literal('terms.set'),
|
|
86
|
+
key: z.enum(['termsOfService', 'privacyPolicy', 'refundPolicy', 'imprint']),
|
|
87
|
+
value: z.string(),
|
|
88
|
+
}).strict();
|
|
89
|
+
export const BuilderEventSchema = z.discriminatedUnion('type', [
|
|
90
|
+
ContentSetEventSchema,
|
|
91
|
+
ListSetEventSchema,
|
|
92
|
+
BlockAddEventSchema,
|
|
93
|
+
BlockDuplicateEventSchema,
|
|
94
|
+
BlockRemoveEventSchema,
|
|
95
|
+
BlockReorderEventSchema,
|
|
96
|
+
BlockVisibilityEventSchema,
|
|
97
|
+
BlockVariantEventSchema,
|
|
98
|
+
BlockSettingsEventSchema,
|
|
99
|
+
StyleSlotSetEventSchema,
|
|
100
|
+
StyleSlotResetEventSchema,
|
|
101
|
+
PageUpsertEventSchema,
|
|
102
|
+
PageRemoveEventSchema,
|
|
103
|
+
TermsSetEventSchema,
|
|
104
|
+
]);
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
export declare const FieldOptionSchema: z.ZodObject<{
|
|
3
|
+
label: z.ZodString;
|
|
4
|
+
value: z.ZodString;
|
|
5
|
+
}, z.core.$strict>;
|
|
6
|
+
export type FieldOption = z.infer<typeof FieldOptionSchema>;
|
|
7
|
+
export declare const ListItemFieldTypeSchema: z.ZodEnum<{
|
|
8
|
+
number: "number";
|
|
9
|
+
boolean: "boolean";
|
|
10
|
+
text: "text";
|
|
11
|
+
richtext: "richtext";
|
|
12
|
+
link: "link";
|
|
13
|
+
image: "image";
|
|
14
|
+
range: "range";
|
|
15
|
+
select: "select";
|
|
16
|
+
color: "color";
|
|
17
|
+
product: "product";
|
|
18
|
+
}>;
|
|
19
|
+
export type ListItemFieldType = z.infer<typeof ListItemFieldTypeSchema>;
|
|
20
|
+
export declare const ListItemFieldSchema: z.ZodObject<{
|
|
21
|
+
label: z.ZodString;
|
|
22
|
+
description: z.ZodOptional<z.ZodString>;
|
|
23
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
24
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
type: z.ZodEnum<{
|
|
26
|
+
number: "number";
|
|
27
|
+
boolean: "boolean";
|
|
28
|
+
text: "text";
|
|
29
|
+
richtext: "richtext";
|
|
30
|
+
link: "link";
|
|
31
|
+
image: "image";
|
|
32
|
+
range: "range";
|
|
33
|
+
select: "select";
|
|
34
|
+
color: "color";
|
|
35
|
+
product: "product";
|
|
36
|
+
}>;
|
|
37
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
|
+
label: z.ZodString;
|
|
39
|
+
value: z.ZodString;
|
|
40
|
+
}, z.core.$strict>>>;
|
|
41
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
45
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strict>;
|
|
47
|
+
export type ListItemField = z.infer<typeof ListItemFieldSchema>;
|
|
48
|
+
export declare const BuilderFieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
49
|
+
label: z.ZodString;
|
|
50
|
+
description: z.ZodOptional<z.ZodString>;
|
|
51
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
52
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
type: z.ZodLiteral<"text">;
|
|
54
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
55
|
+
minLength: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
label: z.ZodString;
|
|
59
|
+
description: z.ZodOptional<z.ZodString>;
|
|
60
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
61
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
type: z.ZodLiteral<"richtext">;
|
|
63
|
+
allowedMarks: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
64
|
+
bold: "bold";
|
|
65
|
+
italic: "italic";
|
|
66
|
+
link: "link";
|
|
67
|
+
code: "code";
|
|
68
|
+
}>>>;
|
|
69
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
70
|
+
label: z.ZodString;
|
|
71
|
+
description: z.ZodOptional<z.ZodString>;
|
|
72
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
73
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
type: z.ZodLiteral<"image">;
|
|
75
|
+
aspectRatio: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
77
|
+
label: z.ZodString;
|
|
78
|
+
description: z.ZodOptional<z.ZodString>;
|
|
79
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
80
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
type: z.ZodLiteral<"link">;
|
|
82
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
83
|
+
label: z.ZodString;
|
|
84
|
+
description: z.ZodOptional<z.ZodString>;
|
|
85
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
86
|
+
type: z.ZodLiteral<"boolean">;
|
|
87
|
+
defaultValue: z.ZodOptional<z.ZodBoolean>;
|
|
88
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
89
|
+
label: z.ZodString;
|
|
90
|
+
description: z.ZodOptional<z.ZodString>;
|
|
91
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
type: z.ZodLiteral<"number">;
|
|
93
|
+
defaultValue: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
98
|
+
label: z.ZodString;
|
|
99
|
+
description: z.ZodOptional<z.ZodString>;
|
|
100
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
+
type: z.ZodLiteral<"range">;
|
|
102
|
+
defaultValue: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
min: z.ZodNumber;
|
|
104
|
+
max: z.ZodNumber;
|
|
105
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
107
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
108
|
+
label: z.ZodString;
|
|
109
|
+
description: z.ZodOptional<z.ZodString>;
|
|
110
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
111
|
+
type: z.ZodLiteral<"select">;
|
|
112
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
113
|
+
options: z.ZodArray<z.ZodObject<{
|
|
114
|
+
label: z.ZodString;
|
|
115
|
+
value: z.ZodString;
|
|
116
|
+
}, z.core.$strict>>;
|
|
117
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
118
|
+
label: z.ZodString;
|
|
119
|
+
description: z.ZodOptional<z.ZodString>;
|
|
120
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
121
|
+
type: z.ZodLiteral<"color">;
|
|
122
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
123
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
124
|
+
label: z.ZodString;
|
|
125
|
+
description: z.ZodOptional<z.ZodString>;
|
|
126
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
127
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
128
|
+
type: z.ZodLiteral<"product">;
|
|
129
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
130
|
+
label: z.ZodString;
|
|
131
|
+
description: z.ZodOptional<z.ZodString>;
|
|
132
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
133
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
134
|
+
type: z.ZodLiteral<"products">;
|
|
135
|
+
minItems: z.ZodOptional<z.ZodNumber>;
|
|
136
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
137
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
138
|
+
label: z.ZodString;
|
|
139
|
+
description: z.ZodOptional<z.ZodString>;
|
|
140
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
141
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
142
|
+
type: z.ZodLiteral<"list">;
|
|
143
|
+
minItems: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
145
|
+
itemShape: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
146
|
+
label: z.ZodString;
|
|
147
|
+
description: z.ZodOptional<z.ZodString>;
|
|
148
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
149
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
150
|
+
type: z.ZodEnum<{
|
|
151
|
+
number: "number";
|
|
152
|
+
boolean: "boolean";
|
|
153
|
+
text: "text";
|
|
154
|
+
richtext: "richtext";
|
|
155
|
+
link: "link";
|
|
156
|
+
image: "image";
|
|
157
|
+
range: "range";
|
|
158
|
+
select: "select";
|
|
159
|
+
color: "color";
|
|
160
|
+
product: "product";
|
|
161
|
+
}>;
|
|
162
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
163
|
+
label: z.ZodString;
|
|
164
|
+
value: z.ZodString;
|
|
165
|
+
}, z.core.$strict>>>;
|
|
166
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
168
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
170
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
171
|
+
}, z.core.$strict>>;
|
|
172
|
+
}, z.core.$strict>], "type">;
|
|
173
|
+
export type BuilderField = z.infer<typeof BuilderFieldSchema>;
|
|
174
|
+
export declare const BlockSettingsSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
175
|
+
label: z.ZodString;
|
|
176
|
+
description: z.ZodOptional<z.ZodString>;
|
|
177
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
178
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
179
|
+
type: z.ZodLiteral<"text">;
|
|
180
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
181
|
+
minLength: z.ZodOptional<z.ZodNumber>;
|
|
182
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
183
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
184
|
+
label: z.ZodString;
|
|
185
|
+
description: z.ZodOptional<z.ZodString>;
|
|
186
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
187
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
188
|
+
type: z.ZodLiteral<"richtext">;
|
|
189
|
+
allowedMarks: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
190
|
+
bold: "bold";
|
|
191
|
+
italic: "italic";
|
|
192
|
+
link: "link";
|
|
193
|
+
code: "code";
|
|
194
|
+
}>>>;
|
|
195
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
196
|
+
label: z.ZodString;
|
|
197
|
+
description: z.ZodOptional<z.ZodString>;
|
|
198
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
199
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
200
|
+
type: z.ZodLiteral<"image">;
|
|
201
|
+
aspectRatio: z.ZodOptional<z.ZodString>;
|
|
202
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
203
|
+
label: z.ZodString;
|
|
204
|
+
description: z.ZodOptional<z.ZodString>;
|
|
205
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
206
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
207
|
+
type: z.ZodLiteral<"link">;
|
|
208
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
209
|
+
label: z.ZodString;
|
|
210
|
+
description: z.ZodOptional<z.ZodString>;
|
|
211
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
212
|
+
type: z.ZodLiteral<"boolean">;
|
|
213
|
+
defaultValue: z.ZodOptional<z.ZodBoolean>;
|
|
214
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
215
|
+
label: z.ZodString;
|
|
216
|
+
description: z.ZodOptional<z.ZodString>;
|
|
217
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
218
|
+
type: z.ZodLiteral<"number">;
|
|
219
|
+
defaultValue: z.ZodOptional<z.ZodNumber>;
|
|
220
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
221
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
222
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
224
|
+
label: z.ZodString;
|
|
225
|
+
description: z.ZodOptional<z.ZodString>;
|
|
226
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
227
|
+
type: z.ZodLiteral<"range">;
|
|
228
|
+
defaultValue: z.ZodOptional<z.ZodNumber>;
|
|
229
|
+
min: z.ZodNumber;
|
|
230
|
+
max: z.ZodNumber;
|
|
231
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
233
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
234
|
+
label: z.ZodString;
|
|
235
|
+
description: z.ZodOptional<z.ZodString>;
|
|
236
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
237
|
+
type: z.ZodLiteral<"select">;
|
|
238
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
239
|
+
options: z.ZodArray<z.ZodObject<{
|
|
240
|
+
label: z.ZodString;
|
|
241
|
+
value: z.ZodString;
|
|
242
|
+
}, z.core.$strict>>;
|
|
243
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
244
|
+
label: z.ZodString;
|
|
245
|
+
description: z.ZodOptional<z.ZodString>;
|
|
246
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
247
|
+
type: z.ZodLiteral<"color">;
|
|
248
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
249
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
250
|
+
label: z.ZodString;
|
|
251
|
+
description: z.ZodOptional<z.ZodString>;
|
|
252
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
253
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
254
|
+
type: z.ZodLiteral<"product">;
|
|
255
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
256
|
+
label: z.ZodString;
|
|
257
|
+
description: z.ZodOptional<z.ZodString>;
|
|
258
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
259
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
260
|
+
type: z.ZodLiteral<"products">;
|
|
261
|
+
minItems: z.ZodOptional<z.ZodNumber>;
|
|
262
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
263
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
264
|
+
label: z.ZodString;
|
|
265
|
+
description: z.ZodOptional<z.ZodString>;
|
|
266
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
267
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
268
|
+
type: z.ZodLiteral<"list">;
|
|
269
|
+
minItems: z.ZodOptional<z.ZodNumber>;
|
|
270
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
271
|
+
itemShape: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
272
|
+
label: z.ZodString;
|
|
273
|
+
description: z.ZodOptional<z.ZodString>;
|
|
274
|
+
defaultValue: z.ZodOptional<z.ZodUnknown>;
|
|
275
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
276
|
+
type: z.ZodEnum<{
|
|
277
|
+
number: "number";
|
|
278
|
+
boolean: "boolean";
|
|
279
|
+
text: "text";
|
|
280
|
+
richtext: "richtext";
|
|
281
|
+
link: "link";
|
|
282
|
+
image: "image";
|
|
283
|
+
range: "range";
|
|
284
|
+
select: "select";
|
|
285
|
+
color: "color";
|
|
286
|
+
product: "product";
|
|
287
|
+
}>;
|
|
288
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
289
|
+
label: z.ZodString;
|
|
290
|
+
value: z.ZodString;
|
|
291
|
+
}, z.core.$strict>>>;
|
|
292
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
293
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
294
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
295
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
296
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
297
|
+
}, z.core.$strict>>;
|
|
298
|
+
}, z.core.$strict>], "type">>;
|
|
299
|
+
export type BlockSettings = z.infer<typeof BlockSettingsSchema>;
|
|
300
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAY5B,eAAO,MAAM,iBAAiB;;;kBAKnB,CAAC;AACZ,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAkE5D,eAAO,MAAM,uBAAuB;;;;;;;;;;;EAWlC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;kBAQrB,CAAC;AACZ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAShE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAa7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAAkD,CAAC;AACnF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/fields.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as z from 'zod/v4';
|
|
2
|
+
import { ColorSchema } from "./style-slots.js";
|
|
3
|
+
const FieldBaseSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
label: z.string().min(1),
|
|
6
|
+
description: z.string().min(1).optional(),
|
|
7
|
+
defaultValue: z.unknown().optional(),
|
|
8
|
+
required: z.boolean().optional(),
|
|
9
|
+
})
|
|
10
|
+
.strict();
|
|
11
|
+
export const FieldOptionSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
label: z.string().min(1),
|
|
14
|
+
value: z.string().min(1),
|
|
15
|
+
})
|
|
16
|
+
.strict();
|
|
17
|
+
const TextFieldSchema = FieldBaseSchema.extend({
|
|
18
|
+
type: z.literal('text'),
|
|
19
|
+
placeholder: z.string().optional(),
|
|
20
|
+
minLength: z.number().int().nonnegative().optional(),
|
|
21
|
+
maxLength: z.number().int().positive().optional(),
|
|
22
|
+
}).strict();
|
|
23
|
+
const RichTextFieldSchema = FieldBaseSchema.extend({
|
|
24
|
+
type: z.literal('richtext'),
|
|
25
|
+
allowedMarks: z.array(z.enum(['bold', 'italic', 'link', 'code'])).optional(),
|
|
26
|
+
}).strict();
|
|
27
|
+
const ImageFieldSchema = FieldBaseSchema.extend({
|
|
28
|
+
type: z.literal('image'),
|
|
29
|
+
aspectRatio: z.string().min(1).optional(),
|
|
30
|
+
}).strict();
|
|
31
|
+
const LinkFieldSchema = FieldBaseSchema.extend({
|
|
32
|
+
type: z.literal('link'),
|
|
33
|
+
}).strict();
|
|
34
|
+
const BooleanFieldSchema = FieldBaseSchema.extend({
|
|
35
|
+
type: z.literal('boolean'),
|
|
36
|
+
defaultValue: z.boolean().optional(),
|
|
37
|
+
}).strict();
|
|
38
|
+
const NumberFieldSchema = FieldBaseSchema.extend({
|
|
39
|
+
type: z.literal('number'),
|
|
40
|
+
defaultValue: z.number().optional(),
|
|
41
|
+
min: z.number().optional(),
|
|
42
|
+
max: z.number().optional(),
|
|
43
|
+
step: z.number().positive().optional(),
|
|
44
|
+
}).strict();
|
|
45
|
+
const RangeFieldSchema = FieldBaseSchema.extend({
|
|
46
|
+
type: z.literal('range'),
|
|
47
|
+
defaultValue: z.number().optional(),
|
|
48
|
+
min: z.number(),
|
|
49
|
+
max: z.number(),
|
|
50
|
+
step: z.number().positive().optional(),
|
|
51
|
+
unit: z.string().min(1).optional(),
|
|
52
|
+
}).strict();
|
|
53
|
+
const SelectFieldSchema = FieldBaseSchema.extend({
|
|
54
|
+
type: z.literal('select'),
|
|
55
|
+
defaultValue: z.string().optional(),
|
|
56
|
+
options: z.array(FieldOptionSchema).min(1),
|
|
57
|
+
}).strict();
|
|
58
|
+
const ColorFieldSchema = FieldBaseSchema.extend({
|
|
59
|
+
type: z.literal('color'),
|
|
60
|
+
defaultValue: ColorSchema.optional(),
|
|
61
|
+
}).strict();
|
|
62
|
+
const ProductFieldSchema = FieldBaseSchema.extend({
|
|
63
|
+
type: z.literal('product'),
|
|
64
|
+
}).strict();
|
|
65
|
+
const ProductsFieldSchema = FieldBaseSchema.extend({
|
|
66
|
+
type: z.literal('products'),
|
|
67
|
+
minItems: z.number().int().nonnegative().optional(),
|
|
68
|
+
maxItems: z.number().int().positive().optional(),
|
|
69
|
+
}).strict();
|
|
70
|
+
export const ListItemFieldTypeSchema = z.enum([
|
|
71
|
+
'text',
|
|
72
|
+
'richtext',
|
|
73
|
+
'image',
|
|
74
|
+
'link',
|
|
75
|
+
'boolean',
|
|
76
|
+
'number',
|
|
77
|
+
'range',
|
|
78
|
+
'select',
|
|
79
|
+
'color',
|
|
80
|
+
'product',
|
|
81
|
+
]);
|
|
82
|
+
export const ListItemFieldSchema = FieldBaseSchema.extend({
|
|
83
|
+
type: ListItemFieldTypeSchema,
|
|
84
|
+
options: z.array(FieldOptionSchema).optional(),
|
|
85
|
+
min: z.number().optional(),
|
|
86
|
+
max: z.number().optional(),
|
|
87
|
+
step: z.number().positive().optional(),
|
|
88
|
+
unit: z.string().min(1).optional(),
|
|
89
|
+
placeholder: z.string().optional(),
|
|
90
|
+
}).strict();
|
|
91
|
+
const ListFieldSchema = FieldBaseSchema.extend({
|
|
92
|
+
type: z.literal('list'),
|
|
93
|
+
minItems: z.number().int().nonnegative().optional(),
|
|
94
|
+
maxItems: z.number().int().positive().optional(),
|
|
95
|
+
itemShape: z.record(z.string().min(1), ListItemFieldSchema),
|
|
96
|
+
}).strict();
|
|
97
|
+
export const BuilderFieldSchema = z.discriminatedUnion('type', [
|
|
98
|
+
TextFieldSchema,
|
|
99
|
+
RichTextFieldSchema,
|
|
100
|
+
ImageFieldSchema,
|
|
101
|
+
LinkFieldSchema,
|
|
102
|
+
BooleanFieldSchema,
|
|
103
|
+
NumberFieldSchema,
|
|
104
|
+
RangeFieldSchema,
|
|
105
|
+
SelectFieldSchema,
|
|
106
|
+
ColorFieldSchema,
|
|
107
|
+
ProductFieldSchema,
|
|
108
|
+
ProductsFieldSchema,
|
|
109
|
+
ListFieldSchema,
|
|
110
|
+
]);
|
|
111
|
+
export const BlockSettingsSchema = z.record(z.string().min(1), BuilderFieldSchema);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './builder-settings.ts';
|
|
2
|
+
export * from './events.ts';
|
|
3
|
+
export * from './fields.ts';
|
|
4
|
+
export * from './legacy-manifest.ts';
|
|
5
|
+
export * from './migrations.ts';
|
|
6
|
+
export * from './preview-protocol.ts';
|
|
7
|
+
export * from './style-slots.ts';
|
|
8
|
+
export * from './theme-manifest.ts';
|
|
9
|
+
export * from './validation.ts';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./builder-settings.js";
|
|
2
|
+
export * from "./events.js";
|
|
3
|
+
export * from "./fields.js";
|
|
4
|
+
export * from "./legacy-manifest.js";
|
|
5
|
+
export * from "./migrations.js";
|
|
6
|
+
export * from "./preview-protocol.js";
|
|
7
|
+
export * from "./style-slots.js";
|
|
8
|
+
export * from "./theme-manifest.js";
|
|
9
|
+
export * from "./validation.js";
|