@kubuild/schema 0.0.1 → 0.2.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/LICENSE +21 -0
- package/README.md +117 -0
- package/dist/actions.d.ts +423 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/document.d.ts +23 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/form.d.ts +129 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/index.cjs +920 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +870 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15379 -0
- package/dist/index.mjs.map +1 -0
- package/dist/json-schema.d.ts +782 -0
- package/dist/json-schema.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,93 +20,484 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ACTION_PIPELINE_JSON_SCHEMA_V1: () => ACTION_PIPELINE_JSON_SCHEMA_V1,
|
|
23
24
|
ActionBindingSchema: () => ActionBindingSchema,
|
|
25
|
+
ActionPipelineSchema: () => ActionPipelineSchema,
|
|
26
|
+
ActionStepConditionSchema: () => ActionStepConditionSchema,
|
|
27
|
+
ActionStepSchema: () => ActionStepSchema,
|
|
28
|
+
ActionStepTypeSchema: () => ActionStepTypeSchema,
|
|
29
|
+
ActionTriggerSchema: () => ActionTriggerSchema,
|
|
30
|
+
ActionTriggerTypeSchema: () => ActionTriggerTypeSchema,
|
|
31
|
+
AnimationConfigSchema: () => AnimationConfigSchema,
|
|
32
|
+
ApiRequestStepPayloadSchema: () => ApiRequestStepPayloadSchema,
|
|
24
33
|
AssetReferenceSchema: () => AssetReferenceSchema,
|
|
25
34
|
CURRENT_SCHEMA_VERSION: () => CURRENT_SCHEMA_VERSION,
|
|
35
|
+
CloseModalStepPayloadSchema: () => CloseModalStepPayloadSchema,
|
|
36
|
+
ConditionOperatorSchema: () => ConditionOperatorSchema,
|
|
37
|
+
CopyClipboardStepPayloadSchema: () => CopyClipboardStepPayloadSchema,
|
|
38
|
+
CustomEventStepPayloadSchema: () => CustomEventStepPayloadSchema,
|
|
39
|
+
DEFAULT_ANIMATION_CONFIG: () => DEFAULT_ANIMATION_CONFIG,
|
|
26
40
|
DocumentMetadataSchema: () => DocumentMetadataSchema,
|
|
41
|
+
FORM_CONFIG_JSON_SCHEMA_V1: () => FORM_CONFIG_JSON_SCHEMA_V1,
|
|
42
|
+
FORM_FIELD_BINDING_JSON_SCHEMA_V1: () => FORM_FIELD_BINDING_JSON_SCHEMA_V1,
|
|
43
|
+
FormConfigSchema: () => FormConfigSchema,
|
|
44
|
+
FormFieldBindingSchema: () => FormFieldBindingSchema,
|
|
27
45
|
MANIFEST_JSON_SCHEMA_V1: () => MANIFEST_JSON_SCHEMA_V1,
|
|
28
46
|
ManifestAssetItemSchema: () => ManifestAssetItemSchema,
|
|
29
47
|
ManifestSchema: () => ManifestSchema,
|
|
48
|
+
NavigateStepPayloadSchema: () => NavigateStepPayloadSchema,
|
|
30
49
|
NodeSchema: () => NodeSchema,
|
|
50
|
+
OpenModalStepPayloadSchema: () => OpenModalStepPayloadSchema,
|
|
31
51
|
PAGE_DOCUMENT_JSON_SCHEMA_V1: () => PAGE_DOCUMENT_JSON_SCHEMA_V1,
|
|
32
52
|
PageDocumentSchema: () => PageDocumentSchema,
|
|
33
53
|
PseudoStateStylesSchema: () => PseudoStateStylesSchema,
|
|
54
|
+
ResetFormStepPayloadSchema: () => ResetFormStepPayloadSchema,
|
|
34
55
|
ResponsiveStylesSchema: () => ResponsiveStylesSchema,
|
|
35
56
|
RootPageNodeSchema: () => RootPageNodeSchema,
|
|
36
57
|
SCHEMA_NAME: () => SCHEMA_NAME,
|
|
37
58
|
SafeThumbnailObjectSchema: () => SafeThumbnailObjectSchema,
|
|
38
59
|
SafeThumbnailSchema: () => SafeThumbnailSchema,
|
|
39
60
|
SafeThumbnailUrlSchema: () => SafeThumbnailUrlSchema,
|
|
61
|
+
SetStateStepPayloadSchema: () => SetStateStepPayloadSchema,
|
|
62
|
+
ShowToastStepPayloadSchema: () => ShowToastStepPayloadSchema,
|
|
63
|
+
StepPayloadSchemas: () => StepPayloadSchemas,
|
|
40
64
|
StyleDefinitionSchema: () => StyleDefinitionSchema,
|
|
41
65
|
StyleValueSchema: () => StyleValueSchema,
|
|
42
66
|
TEMPLATE_RECORD_JSON_SCHEMA_V1: () => TEMPLATE_RECORD_JSON_SCHEMA_V1,
|
|
43
67
|
TemplatePackageRefSchema: () => TemplatePackageRefSchema,
|
|
44
68
|
TemplateRecordSchema: () => TemplateRecordSchema,
|
|
45
69
|
TemplateRequirementsSchema: () => TemplateRequirementsSchema,
|
|
70
|
+
ValidateOnEventSchema: () => ValidateOnEventSchema,
|
|
71
|
+
ValidationRuleSchema: () => ValidationRuleSchema,
|
|
72
|
+
ValidationRuleTypeSchema: () => ValidationRuleTypeSchema,
|
|
46
73
|
VariableBindingSchema: () => VariableBindingSchema,
|
|
47
74
|
collectNodeIds: () => collectNodeIds,
|
|
48
75
|
generateDeterministicNodeId: () => generateDeterministicNodeId,
|
|
76
|
+
getActionPipelineJsonSchema: () => getActionPipelineJsonSchema,
|
|
77
|
+
getFormConfigJsonSchema: () => getFormConfigJsonSchema,
|
|
78
|
+
getFormFieldBindingJsonSchema: () => getFormFieldBindingJsonSchema,
|
|
49
79
|
getManifestJsonSchema: () => getManifestJsonSchema,
|
|
50
80
|
getPageDocumentJsonSchema: () => getPageDocumentJsonSchema,
|
|
51
81
|
getTemplateRecordJsonSchema: () => getTemplateRecordJsonSchema,
|
|
52
82
|
isActionBinding: () => isActionBinding,
|
|
83
|
+
isActionPipeline: () => isActionPipeline,
|
|
84
|
+
isActionStep: () => isActionStep,
|
|
85
|
+
isActionStepCondition: () => isActionStepCondition,
|
|
86
|
+
isActionStepType: () => isActionStepType,
|
|
87
|
+
isActionTriggerType: () => isActionTriggerType,
|
|
88
|
+
isAnimationConfig: () => isAnimationConfig,
|
|
53
89
|
isAssetReference: () => isAssetReference,
|
|
90
|
+
isConditionOperator: () => isConditionOperator,
|
|
91
|
+
isFormConfig: () => isFormConfig,
|
|
92
|
+
isFormFieldBinding: () => isFormFieldBinding,
|
|
54
93
|
isManifest: () => isManifest,
|
|
94
|
+
isSafeActionUrl: () => isSafeActionUrl,
|
|
55
95
|
isSafeThumbnail: () => isSafeThumbnail,
|
|
56
96
|
isSafeThumbnailUrl: () => isSafeThumbnailUrl,
|
|
57
97
|
isTemplateRecord: () => isTemplateRecord,
|
|
98
|
+
isValidateOnEvent: () => isValidateOnEvent,
|
|
99
|
+
isValidationRule: () => isValidationRule,
|
|
100
|
+
isValidationRuleType: () => isValidationRuleType,
|
|
58
101
|
isVariableBinding: () => isVariableBinding,
|
|
102
|
+
sanitizeActionPayload: () => sanitizeActionPayload,
|
|
103
|
+
sanitizeActionPipeline: () => sanitizeActionPipeline,
|
|
104
|
+
sanitizeActionStep: () => sanitizeActionStep,
|
|
105
|
+
sanitizeActionString: () => sanitizeActionString,
|
|
106
|
+
sanitizeActionUrl: () => sanitizeActionUrl,
|
|
107
|
+
sanitizeActionValue: () => sanitizeActionValue,
|
|
59
108
|
starterPageFixture: () => starterPageFixture,
|
|
109
|
+
validateActionStepPayload: () => validateActionStepPayload,
|
|
60
110
|
validateNodeIdUniqueness: () => validateNodeIdUniqueness
|
|
61
111
|
});
|
|
62
112
|
module.exports = __toCommonJS(index_exports);
|
|
63
113
|
|
|
64
114
|
// src/document.ts
|
|
115
|
+
var import_zod3 = require("zod");
|
|
116
|
+
|
|
117
|
+
// src/actions.ts
|
|
65
118
|
var import_zod = require("zod");
|
|
119
|
+
var ActionTriggerTypeSchema = import_zod.z.enum([
|
|
120
|
+
"click",
|
|
121
|
+
"submit",
|
|
122
|
+
"change",
|
|
123
|
+
"blur",
|
|
124
|
+
"focus",
|
|
125
|
+
"load"
|
|
126
|
+
]);
|
|
127
|
+
var ActionTriggerSchema = ActionTriggerTypeSchema;
|
|
128
|
+
var ActionStepTypeSchema = import_zod.z.enum([
|
|
129
|
+
"api_request",
|
|
130
|
+
"navigate",
|
|
131
|
+
"set_state",
|
|
132
|
+
"reset_form",
|
|
133
|
+
"show_toast",
|
|
134
|
+
"open_modal",
|
|
135
|
+
"close_modal",
|
|
136
|
+
"copy_clipboard",
|
|
137
|
+
"custom_event"
|
|
138
|
+
]);
|
|
139
|
+
var ConditionOperatorSchema = import_zod.z.enum([
|
|
140
|
+
"equals",
|
|
141
|
+
"not_equals",
|
|
142
|
+
"contains",
|
|
143
|
+
"not_contains",
|
|
144
|
+
"is_truthy",
|
|
145
|
+
"is_falsy",
|
|
146
|
+
"gt",
|
|
147
|
+
"gte",
|
|
148
|
+
"lt",
|
|
149
|
+
"lte",
|
|
150
|
+
"regex"
|
|
151
|
+
]);
|
|
152
|
+
var ActionStepConditionSchema = import_zod.z.object({
|
|
153
|
+
field: import_zod.z.string().min(1, "Condition field cannot be empty"),
|
|
154
|
+
operator: ConditionOperatorSchema,
|
|
155
|
+
value: import_zod.z.unknown().optional()
|
|
156
|
+
});
|
|
157
|
+
var DANGEROUS_URL_PATTERN = /(javascript:|vbscript:|data:text\/html)/i;
|
|
158
|
+
var DANGEROUS_SCRIPT_PATTERN = /<\s*script/i;
|
|
159
|
+
function isSafeActionUrl(url) {
|
|
160
|
+
if (!url || typeof url !== "string") return false;
|
|
161
|
+
const trimmed = url.trim();
|
|
162
|
+
if (DANGEROUS_URL_PATTERN.test(trimmed)) return false;
|
|
163
|
+
if (DANGEROUS_SCRIPT_PATTERN.test(trimmed)) return false;
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
var SafeUrlStringSchema = import_zod.z.string().min(1, "URL cannot be empty").refine(isSafeActionUrl, {
|
|
167
|
+
message: "URL contains disallowed or unsafe protocol/script pattern"
|
|
168
|
+
});
|
|
169
|
+
var SafeEventNameSchema = import_zod.z.string().min(1, "Event name cannot be empty").regex(/^[a-zA-Z0-9_\-:]+$/, {
|
|
170
|
+
message: "Event name must contain only alphanumeric characters, dashes, colons, or underscores"
|
|
171
|
+
});
|
|
172
|
+
var ApiRequestStepPayloadSchema = import_zod.z.object({
|
|
173
|
+
url: SafeUrlStringSchema,
|
|
174
|
+
method: import_zod.z.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).default("GET"),
|
|
175
|
+
headers: import_zod.z.record(import_zod.z.string(), import_zod.z.string()).optional(),
|
|
176
|
+
queryParams: import_zod.z.record(import_zod.z.string(), import_zod.z.union([import_zod.z.string(), import_zod.z.number(), import_zod.z.boolean()])).optional(),
|
|
177
|
+
body: import_zod.z.union([import_zod.z.string(), import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()), import_zod.z.array(import_zod.z.unknown())]).optional(),
|
|
178
|
+
bodyFormat: import_zod.z.enum(["json", "form-data", "formData", "urlencoded", "url-encoded", "raw", "text"]).optional(),
|
|
179
|
+
bodyType: import_zod.z.enum(["json", "form-data", "formData", "urlencoded", "url-encoded", "raw", "text"]).optional(),
|
|
180
|
+
timeout: import_zod.z.number().positive("Timeout must be greater than 0 ms").optional(),
|
|
181
|
+
responseMapping: import_zod.z.record(import_zod.z.string(), import_zod.z.string()).optional()
|
|
182
|
+
});
|
|
183
|
+
var NavigateStepPayloadSchema = import_zod.z.object({
|
|
184
|
+
url: SafeUrlStringSchema,
|
|
185
|
+
target: import_zod.z.enum(["_self", "_blank", "_parent", "_top"]).optional().default("_self"),
|
|
186
|
+
replace: import_zod.z.boolean().optional(),
|
|
187
|
+
scroll: import_zod.z.boolean().optional(),
|
|
188
|
+
behavior: import_zod.z.enum(["smooth", "auto"]).optional()
|
|
189
|
+
});
|
|
190
|
+
var SetStateStepPayloadSchema = import_zod.z.object({
|
|
191
|
+
key: import_zod.z.string().min(1, "State key cannot be empty"),
|
|
192
|
+
value: import_zod.z.unknown(),
|
|
193
|
+
scope: import_zod.z.enum(["runtime", "document", "session", "local"]).optional().default("runtime")
|
|
194
|
+
});
|
|
195
|
+
var ResetFormStepPayloadSchema = import_zod.z.object({
|
|
196
|
+
formId: import_zod.z.string().optional()
|
|
197
|
+
});
|
|
198
|
+
var ShowToastStepPayloadSchema = import_zod.z.object({
|
|
199
|
+
message: import_zod.z.string().min(1, "Toast message cannot be empty"),
|
|
200
|
+
type: import_zod.z.enum(["success", "error", "warning", "info"]).optional().default("info"),
|
|
201
|
+
variant: import_zod.z.enum(["success", "error", "warning", "info"]).optional(),
|
|
202
|
+
title: import_zod.z.string().optional(),
|
|
203
|
+
duration: import_zod.z.number().nonnegative("Duration must be >= 0 ms").optional(),
|
|
204
|
+
position: import_zod.z.enum(["top-right", "top-left", "bottom-right", "bottom-left", "top-center", "bottom-center"]).optional()
|
|
205
|
+
});
|
|
206
|
+
var OpenModalStepPayloadSchema = import_zod.z.object({
|
|
207
|
+
modalId: import_zod.z.string().optional(),
|
|
208
|
+
modalNodeId: import_zod.z.string().optional()
|
|
209
|
+
}).refine((data) => Boolean(data.modalId || data.modalNodeId), {
|
|
210
|
+
message: "Modal ID or Modal Node ID cannot be empty"
|
|
211
|
+
});
|
|
212
|
+
var CloseModalStepPayloadSchema = import_zod.z.object({
|
|
213
|
+
modalId: import_zod.z.string().optional(),
|
|
214
|
+
modalNodeId: import_zod.z.string().optional()
|
|
215
|
+
});
|
|
216
|
+
var CopyClipboardStepPayloadSchema = import_zod.z.object({
|
|
217
|
+
text: import_zod.z.string().optional(),
|
|
218
|
+
value: import_zod.z.unknown().optional(),
|
|
219
|
+
notify: import_zod.z.boolean().optional(),
|
|
220
|
+
toastMessage: import_zod.z.string().optional()
|
|
221
|
+
});
|
|
222
|
+
var CustomEventStepPayloadSchema = import_zod.z.object({
|
|
223
|
+
eventName: SafeEventNameSchema,
|
|
224
|
+
detail: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
|
|
225
|
+
bubbles: import_zod.z.boolean().optional().default(true),
|
|
226
|
+
cancelable: import_zod.z.boolean().optional().default(true)
|
|
227
|
+
});
|
|
228
|
+
var StepPayloadSchemas = {
|
|
229
|
+
api_request: ApiRequestStepPayloadSchema,
|
|
230
|
+
navigate: NavigateStepPayloadSchema,
|
|
231
|
+
set_state: SetStateStepPayloadSchema,
|
|
232
|
+
reset_form: ResetFormStepPayloadSchema,
|
|
233
|
+
show_toast: ShowToastStepPayloadSchema,
|
|
234
|
+
open_modal: OpenModalStepPayloadSchema,
|
|
235
|
+
close_modal: CloseModalStepPayloadSchema,
|
|
236
|
+
copy_clipboard: CopyClipboardStepPayloadSchema,
|
|
237
|
+
custom_event: CustomEventStepPayloadSchema
|
|
238
|
+
};
|
|
239
|
+
var ActionStepSchema = import_zod.z.lazy(
|
|
240
|
+
() => import_zod.z.object({
|
|
241
|
+
id: import_zod.z.string().min(1, "Step ID cannot be empty"),
|
|
242
|
+
type: ActionStepTypeSchema,
|
|
243
|
+
label: import_zod.z.string().optional(),
|
|
244
|
+
payload: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional().default({}),
|
|
245
|
+
condition: ActionStepConditionSchema.optional(),
|
|
246
|
+
timeout: import_zod.z.number().positive().optional(),
|
|
247
|
+
continueOnError: import_zod.z.boolean().optional(),
|
|
248
|
+
onSuccess: import_zod.z.array(ActionStepSchema).optional(),
|
|
249
|
+
onError: import_zod.z.array(ActionStepSchema).optional()
|
|
250
|
+
})
|
|
251
|
+
);
|
|
252
|
+
var ActionPipelineSchema = import_zod.z.object({
|
|
253
|
+
id: import_zod.z.string().min(1, "Pipeline ID cannot be empty"),
|
|
254
|
+
trigger: ActionTriggerTypeSchema,
|
|
255
|
+
label: import_zod.z.string().optional(),
|
|
256
|
+
debounceMs: import_zod.z.number().nonnegative("Debounce ms must be >= 0").optional(),
|
|
257
|
+
preventDuplicate: import_zod.z.boolean().optional(),
|
|
258
|
+
enabled: import_zod.z.boolean().optional().default(true),
|
|
259
|
+
steps: import_zod.z.array(ActionStepSchema).min(1, "Action pipeline must contain at least one step")
|
|
260
|
+
});
|
|
261
|
+
function isActionTriggerType(value) {
|
|
262
|
+
return ActionTriggerTypeSchema.safeParse(value).success;
|
|
263
|
+
}
|
|
264
|
+
function isActionStepType(value) {
|
|
265
|
+
return ActionStepTypeSchema.safeParse(value).success;
|
|
266
|
+
}
|
|
267
|
+
function isConditionOperator(value) {
|
|
268
|
+
return ConditionOperatorSchema.safeParse(value).success;
|
|
269
|
+
}
|
|
270
|
+
function isActionStepCondition(value) {
|
|
271
|
+
return ActionStepConditionSchema.safeParse(value).success;
|
|
272
|
+
}
|
|
273
|
+
function isActionStep(value) {
|
|
274
|
+
return ActionStepSchema.safeParse(value).success;
|
|
275
|
+
}
|
|
276
|
+
function isActionPipeline(value) {
|
|
277
|
+
return ActionPipelineSchema.safeParse(value).success;
|
|
278
|
+
}
|
|
279
|
+
function validateActionStepPayload(type, payload) {
|
|
280
|
+
const schema = StepPayloadSchemas[type];
|
|
281
|
+
if (!schema) {
|
|
282
|
+
return {
|
|
283
|
+
success: false,
|
|
284
|
+
error: new import_zod.z.ZodError([
|
|
285
|
+
{
|
|
286
|
+
code: import_zod.z.ZodIssueCode.custom,
|
|
287
|
+
message: `Unknown step type: ${type}`,
|
|
288
|
+
path: ["type"]
|
|
289
|
+
}
|
|
290
|
+
])
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const result = schema.safeParse(payload);
|
|
294
|
+
if (result.success) {
|
|
295
|
+
return { success: true, data: result.data };
|
|
296
|
+
}
|
|
297
|
+
return { success: false, error: result.error };
|
|
298
|
+
}
|
|
299
|
+
function sanitizeActionUrl(url, fallback = "") {
|
|
300
|
+
if (typeof url !== "string") return fallback;
|
|
301
|
+
const trimmed = url.trim();
|
|
302
|
+
if (!isSafeActionUrl(trimmed)) {
|
|
303
|
+
return fallback;
|
|
304
|
+
}
|
|
305
|
+
return trimmed;
|
|
306
|
+
}
|
|
307
|
+
function sanitizeActionString(value, fallback = "") {
|
|
308
|
+
if (typeof value !== "string") return fallback;
|
|
309
|
+
if (DANGEROUS_SCRIPT_PATTERN.test(value)) {
|
|
310
|
+
return value.replace(/<\s*script[^>]*>[\s\S]*?<\s*\/\s*script\s*>/gi, "").replace(/<\s*script[^>]*>/gi, "");
|
|
311
|
+
}
|
|
312
|
+
return value;
|
|
313
|
+
}
|
|
314
|
+
function sanitizeActionValue(value) {
|
|
315
|
+
if (value === null || value === void 0) return value;
|
|
316
|
+
if (typeof value === "string") {
|
|
317
|
+
const trimmed = value.trim();
|
|
318
|
+
if (DANGEROUS_URL_PATTERN.test(trimmed)) {
|
|
319
|
+
return "";
|
|
320
|
+
}
|
|
321
|
+
return sanitizeActionString(value);
|
|
322
|
+
}
|
|
323
|
+
if (Array.isArray(value)) {
|
|
324
|
+
return value.map((item) => sanitizeActionValue(item));
|
|
325
|
+
}
|
|
326
|
+
if (typeof value === "object") {
|
|
327
|
+
const result = {};
|
|
328
|
+
for (const [k, v] of Object.entries(value)) {
|
|
329
|
+
if (/^(url|href|src|endpoint|targetUrl)$/i.test(k) && typeof v === "string") {
|
|
330
|
+
result[k] = sanitizeActionUrl(v);
|
|
331
|
+
} else {
|
|
332
|
+
result[k] = sanitizeActionValue(v);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return result;
|
|
336
|
+
}
|
|
337
|
+
return value;
|
|
338
|
+
}
|
|
339
|
+
function sanitizeActionPayload(payload) {
|
|
340
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
341
|
+
return {};
|
|
342
|
+
}
|
|
343
|
+
return sanitizeActionValue(payload);
|
|
344
|
+
}
|
|
345
|
+
function sanitizeActionStep(step) {
|
|
346
|
+
const sanitized = {
|
|
347
|
+
...step,
|
|
348
|
+
label: step.label ? sanitizeActionString(step.label) : step.label,
|
|
349
|
+
payload: sanitizeActionPayload(step.payload)
|
|
350
|
+
};
|
|
351
|
+
if (step.condition && step.condition.value !== void 0) {
|
|
352
|
+
sanitized.condition = {
|
|
353
|
+
...step.condition,
|
|
354
|
+
value: sanitizeActionValue(step.condition.value)
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
if (step.onSuccess && Array.isArray(step.onSuccess)) {
|
|
358
|
+
sanitized.onSuccess = step.onSuccess.map((s) => sanitizeActionStep(s));
|
|
359
|
+
}
|
|
360
|
+
if (step.onError && Array.isArray(step.onError)) {
|
|
361
|
+
sanitized.onError = step.onError.map((s) => sanitizeActionStep(s));
|
|
362
|
+
}
|
|
363
|
+
return sanitized;
|
|
364
|
+
}
|
|
365
|
+
function sanitizeActionPipeline(pipeline) {
|
|
366
|
+
return {
|
|
367
|
+
...pipeline,
|
|
368
|
+
label: pipeline.label ? sanitizeActionString(pipeline.label) : pipeline.label,
|
|
369
|
+
steps: Array.isArray(pipeline.steps) ? pipeline.steps.map((s) => sanitizeActionStep(s)) : []
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// src/form.ts
|
|
374
|
+
var import_zod2 = require("zod");
|
|
375
|
+
var ValidationRuleTypeSchema = import_zod2.z.enum([
|
|
376
|
+
"required",
|
|
377
|
+
"email",
|
|
378
|
+
"url",
|
|
379
|
+
"min_length",
|
|
380
|
+
"max_length",
|
|
381
|
+
"numeric_min",
|
|
382
|
+
"numeric_max",
|
|
383
|
+
"pattern",
|
|
384
|
+
"match_field",
|
|
385
|
+
"custom_regex"
|
|
386
|
+
]);
|
|
387
|
+
var ValidateOnEventSchema = import_zod2.z.enum(["blur", "change", "submit"]);
|
|
388
|
+
var ValidationRuleSchema = import_zod2.z.object({
|
|
389
|
+
type: ValidationRuleTypeSchema,
|
|
390
|
+
value: import_zod2.z.unknown().optional(),
|
|
391
|
+
message: import_zod2.z.string().min(1, "Validation error message cannot be empty")
|
|
392
|
+
});
|
|
393
|
+
var FormFieldBindingSchema = import_zod2.z.object({
|
|
394
|
+
name: import_zod2.z.string().min(1, "Field name cannot be empty"),
|
|
395
|
+
label: import_zod2.z.string().optional(),
|
|
396
|
+
defaultValue: import_zod2.z.unknown().optional(),
|
|
397
|
+
rules: import_zod2.z.array(ValidationRuleSchema).optional().default([]),
|
|
398
|
+
validateOn: ValidateOnEventSchema.optional().default("blur"),
|
|
399
|
+
transform: import_zod2.z.enum(["trim", "lowercase", "uppercase", "number"]).optional(),
|
|
400
|
+
disabled: import_zod2.z.boolean().optional(),
|
|
401
|
+
required: import_zod2.z.boolean().optional()
|
|
402
|
+
});
|
|
403
|
+
var FormConfigSchema = import_zod2.z.object({
|
|
404
|
+
formId: import_zod2.z.string().min(1, "Form ID cannot be empty"),
|
|
405
|
+
resetOnSubmit: import_zod2.z.boolean().optional().default(false),
|
|
406
|
+
scrollToFirstError: import_zod2.z.boolean().optional().default(true),
|
|
407
|
+
validateOn: ValidateOnEventSchema.optional().default("blur"),
|
|
408
|
+
initialValues: import_zod2.z.record(import_zod2.z.string(), import_zod2.z.unknown()).optional(),
|
|
409
|
+
rules: import_zod2.z.array(ValidationRuleSchema).optional()
|
|
410
|
+
});
|
|
411
|
+
function isValidationRuleType(value) {
|
|
412
|
+
return ValidationRuleTypeSchema.safeParse(value).success;
|
|
413
|
+
}
|
|
414
|
+
function isValidationRule(value) {
|
|
415
|
+
return ValidationRuleSchema.safeParse(value).success;
|
|
416
|
+
}
|
|
417
|
+
function isValidateOnEvent(value) {
|
|
418
|
+
return ValidateOnEventSchema.safeParse(value).success;
|
|
419
|
+
}
|
|
420
|
+
function isFormFieldBinding(value) {
|
|
421
|
+
return FormFieldBindingSchema.safeParse(value).success;
|
|
422
|
+
}
|
|
423
|
+
function isFormConfig(value) {
|
|
424
|
+
return FormConfigSchema.safeParse(value).success;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// src/document.ts
|
|
66
428
|
var SCHEMA_NAME = "stora.page";
|
|
67
429
|
var CURRENT_SCHEMA_VERSION = "1.0.0";
|
|
68
|
-
var AssetReferenceSchema =
|
|
69
|
-
type:
|
|
70
|
-
assetId:
|
|
71
|
-
filename:
|
|
72
|
-
mimeType:
|
|
73
|
-
fallbackUrl:
|
|
430
|
+
var AssetReferenceSchema = import_zod3.z.object({
|
|
431
|
+
type: import_zod3.z.literal("asset"),
|
|
432
|
+
assetId: import_zod3.z.string().min(1, "Asset ID cannot be empty"),
|
|
433
|
+
filename: import_zod3.z.string().optional(),
|
|
434
|
+
mimeType: import_zod3.z.string().optional(),
|
|
435
|
+
fallbackUrl: import_zod3.z.string().url().optional()
|
|
74
436
|
});
|
|
75
|
-
var VariableBindingSchema =
|
|
76
|
-
type:
|
|
77
|
-
key:
|
|
78
|
-
fallback:
|
|
437
|
+
var VariableBindingSchema = import_zod3.z.object({
|
|
438
|
+
type: import_zod3.z.literal("variable"),
|
|
439
|
+
key: import_zod3.z.string().min(1, "Variable key cannot be empty"),
|
|
440
|
+
fallback: import_zod3.z.unknown().optional()
|
|
79
441
|
});
|
|
80
|
-
var ActionBindingSchema =
|
|
81
|
-
type:
|
|
82
|
-
payload:
|
|
442
|
+
var ActionBindingSchema = import_zod3.z.object({
|
|
443
|
+
type: import_zod3.z.string().min(1, "Action type cannot be empty"),
|
|
444
|
+
payload: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional()
|
|
83
445
|
});
|
|
84
446
|
var DANGEROUS_STYLE_VALUE_PATTERN = /javascript:|expression\(|@import|<script|vbscript:|data:text\/html/i;
|
|
85
|
-
var StyleValueSchema =
|
|
86
|
-
|
|
447
|
+
var StyleValueSchema = import_zod3.z.union([
|
|
448
|
+
import_zod3.z.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
87
449
|
message: "Style value contains a disallowed or unsafe pattern"
|
|
88
450
|
}),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
451
|
+
import_zod3.z.number(),
|
|
452
|
+
import_zod3.z.boolean(),
|
|
453
|
+
import_zod3.z.null(),
|
|
454
|
+
import_zod3.z.undefined()
|
|
93
455
|
]);
|
|
94
|
-
var StyleDefinitionSchema =
|
|
95
|
-
var PseudoStateStylesSchema =
|
|
96
|
-
var ResponsiveStylesSchema =
|
|
456
|
+
var StyleDefinitionSchema = import_zod3.z.record(import_zod3.z.string(), StyleValueSchema);
|
|
457
|
+
var PseudoStateStylesSchema = import_zod3.z.record(import_zod3.z.string(), StyleDefinitionSchema);
|
|
458
|
+
var ResponsiveStylesSchema = import_zod3.z.object({
|
|
97
459
|
base: StyleDefinitionSchema.optional(),
|
|
98
460
|
desktop: StyleDefinitionSchema.optional(),
|
|
99
461
|
tablet: StyleDefinitionSchema.optional(),
|
|
100
462
|
mobile: StyleDefinitionSchema.optional(),
|
|
101
463
|
states: PseudoStateStylesSchema.optional()
|
|
102
|
-
}).
|
|
103
|
-
var
|
|
104
|
-
() =>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
464
|
+
}).passthrough().default({});
|
|
465
|
+
var AnimationConfigSchema = import_zod3.z.object({
|
|
466
|
+
type: import_zod3.z.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
467
|
+
message: "Animation type contains a disallowed or unsafe pattern"
|
|
468
|
+
}).optional().default("none"),
|
|
469
|
+
duration: import_zod3.z.number().min(0, "Duration must be non-negative").optional().default(600),
|
|
470
|
+
delay: import_zod3.z.number().min(0, "Delay must be non-negative").optional().default(0),
|
|
471
|
+
easing: import_zod3.z.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
472
|
+
message: "Animation easing contains a disallowed or unsafe pattern"
|
|
473
|
+
}).optional().default("ease-out"),
|
|
474
|
+
once: import_zod3.z.boolean().optional().default(true),
|
|
475
|
+
hoverEffect: import_zod3.z.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
476
|
+
message: "Hover effect contains a disallowed or unsafe pattern"
|
|
477
|
+
}).optional().default("none"),
|
|
478
|
+
loopEffect: import_zod3.z.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
479
|
+
message: "Loop effect contains a disallowed or unsafe pattern"
|
|
480
|
+
}).optional().default("none")
|
|
481
|
+
});
|
|
482
|
+
var DEFAULT_ANIMATION_CONFIG = {
|
|
483
|
+
type: "none",
|
|
484
|
+
duration: 600,
|
|
485
|
+
delay: 0,
|
|
486
|
+
easing: "ease-out",
|
|
487
|
+
once: true,
|
|
488
|
+
hoverEffect: "none",
|
|
489
|
+
loopEffect: "none"
|
|
490
|
+
};
|
|
491
|
+
var NodeSchema = import_zod3.z.lazy(
|
|
492
|
+
() => import_zod3.z.object({
|
|
493
|
+
id: import_zod3.z.string().min(1, "Node ID must be a non-empty string"),
|
|
494
|
+
type: import_zod3.z.string().min(1, "Node type must be a non-empty string"),
|
|
495
|
+
props: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional().default({}),
|
|
108
496
|
styles: ResponsiveStylesSchema.optional().default({}),
|
|
109
|
-
|
|
497
|
+
animation: AnimationConfigSchema.optional(),
|
|
498
|
+
actions: import_zod3.z.array(ActionPipelineSchema).optional(),
|
|
499
|
+
formConfig: FormConfigSchema.optional(),
|
|
500
|
+
children: import_zod3.z.array(NodeSchema).optional().default([])
|
|
110
501
|
})
|
|
111
502
|
);
|
|
112
503
|
var RootPageNodeSchema = NodeSchema.refine(
|
|
@@ -116,20 +507,20 @@ var RootPageNodeSchema = NodeSchema.refine(
|
|
|
116
507
|
path: ["type"]
|
|
117
508
|
}
|
|
118
509
|
);
|
|
119
|
-
var DocumentMetadataSchema =
|
|
120
|
-
title:
|
|
121
|
-
description:
|
|
122
|
-
author:
|
|
123
|
-
createdAt:
|
|
124
|
-
updatedAt:
|
|
125
|
-
tags:
|
|
126
|
-
category:
|
|
127
|
-
version:
|
|
128
|
-
custom:
|
|
510
|
+
var DocumentMetadataSchema = import_zod3.z.object({
|
|
511
|
+
title: import_zod3.z.string().min(1, "Title is required").default("Untitled Page"),
|
|
512
|
+
description: import_zod3.z.string().optional().default(""),
|
|
513
|
+
author: import_zod3.z.string().optional().default(""),
|
|
514
|
+
createdAt: import_zod3.z.string().optional(),
|
|
515
|
+
updatedAt: import_zod3.z.string().optional(),
|
|
516
|
+
tags: import_zod3.z.array(import_zod3.z.string()).optional().default([]),
|
|
517
|
+
category: import_zod3.z.string().optional().default("general"),
|
|
518
|
+
version: import_zod3.z.string().optional().default("1.0.0"),
|
|
519
|
+
custom: import_zod3.z.record(import_zod3.z.string(), import_zod3.z.unknown()).optional()
|
|
129
520
|
});
|
|
130
|
-
var PageDocumentSchema =
|
|
131
|
-
schema:
|
|
132
|
-
version:
|
|
521
|
+
var PageDocumentSchema = import_zod3.z.object({
|
|
522
|
+
schema: import_zod3.z.literal(SCHEMA_NAME),
|
|
523
|
+
version: import_zod3.z.string().min(1, "Schema version is required").default(CURRENT_SCHEMA_VERSION),
|
|
133
524
|
metadata: DocumentMetadataSchema.optional(),
|
|
134
525
|
document: RootPageNodeSchema
|
|
135
526
|
});
|
|
@@ -142,6 +533,9 @@ function isVariableBinding(value) {
|
|
|
142
533
|
function isActionBinding(value) {
|
|
143
534
|
return ActionBindingSchema.safeParse(value).success;
|
|
144
535
|
}
|
|
536
|
+
function isAnimationConfig(value) {
|
|
537
|
+
return AnimationConfigSchema.safeParse(value).success;
|
|
538
|
+
}
|
|
145
539
|
function generateDeterministicNodeId(prefix, indexOrKey) {
|
|
146
540
|
const cleanPrefix = prefix.toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
147
541
|
return `${cleanPrefix}_${indexOrKey}`;
|
|
@@ -173,30 +567,30 @@ function validateNodeIdUniqueness(node) {
|
|
|
173
567
|
}
|
|
174
568
|
|
|
175
569
|
// src/manifest.ts
|
|
176
|
-
var
|
|
177
|
-
var ManifestAssetItemSchema =
|
|
178
|
-
id:
|
|
179
|
-
path:
|
|
180
|
-
mimeType:
|
|
181
|
-
size:
|
|
182
|
-
checksum:
|
|
570
|
+
var import_zod4 = require("zod");
|
|
571
|
+
var ManifestAssetItemSchema = import_zod4.z.object({
|
|
572
|
+
id: import_zod4.z.string().min(1, "Asset ID cannot be empty"),
|
|
573
|
+
path: import_zod4.z.string().min(1, "Asset archive path cannot be empty"),
|
|
574
|
+
mimeType: import_zod4.z.string().min(1, "MIME type cannot be empty"),
|
|
575
|
+
size: import_zod4.z.number().nonnegative("Asset size must be non-negative"),
|
|
576
|
+
checksum: import_zod4.z.string().optional()
|
|
183
577
|
});
|
|
184
|
-
var ManifestSchema =
|
|
185
|
-
schema:
|
|
186
|
-
schemaVersion:
|
|
187
|
-
packageVersion:
|
|
188
|
-
builderCompatibility:
|
|
189
|
-
requiredComponents:
|
|
190
|
-
requiredCapabilities:
|
|
191
|
-
assets:
|
|
192
|
-
createdAt:
|
|
578
|
+
var ManifestSchema = import_zod4.z.object({
|
|
579
|
+
schema: import_zod4.z.literal(SCHEMA_NAME).default(SCHEMA_NAME),
|
|
580
|
+
schemaVersion: import_zod4.z.string().min(1, "Schema version cannot be empty").default("1.0.0"),
|
|
581
|
+
packageVersion: import_zod4.z.string().min(1, "Package version cannot be empty").default("1.0.0"),
|
|
582
|
+
builderCompatibility: import_zod4.z.string().default(">=0.1.0"),
|
|
583
|
+
requiredComponents: import_zod4.z.array(import_zod4.z.string()).default([]),
|
|
584
|
+
requiredCapabilities: import_zod4.z.array(import_zod4.z.string()).default([]),
|
|
585
|
+
assets: import_zod4.z.array(ManifestAssetItemSchema).default([]),
|
|
586
|
+
createdAt: import_zod4.z.string().optional()
|
|
193
587
|
});
|
|
194
588
|
function isManifest(value) {
|
|
195
589
|
return ManifestSchema.safeParse(value).success;
|
|
196
590
|
}
|
|
197
591
|
|
|
198
592
|
// src/template.ts
|
|
199
|
-
var
|
|
593
|
+
var import_zod5 = require("zod");
|
|
200
594
|
var DANGEROUS_URI_PATTERN = /^(javascript:|vbscript:|data:(?!image\/))|<script/i;
|
|
201
595
|
function isSafeThumbnailUrl(url) {
|
|
202
596
|
if (!url || typeof url !== "string") return false;
|
|
@@ -205,49 +599,49 @@ function isSafeThumbnailUrl(url) {
|
|
|
205
599
|
if (DANGEROUS_URI_PATTERN.test(trimmed)) return false;
|
|
206
600
|
return true;
|
|
207
601
|
}
|
|
208
|
-
var SafeThumbnailUrlSchema =
|
|
602
|
+
var SafeThumbnailUrlSchema = import_zod5.z.string().min(1, "Thumbnail URL cannot be empty").refine(
|
|
209
603
|
(url) => isSafeThumbnailUrl(url),
|
|
210
604
|
{ message: "Thumbnail URL contains an unsafe protocol or payload" }
|
|
211
605
|
);
|
|
212
|
-
var SafeThumbnailObjectSchema =
|
|
606
|
+
var SafeThumbnailObjectSchema = import_zod5.z.object({
|
|
213
607
|
url: SafeThumbnailUrlSchema,
|
|
214
|
-
alt:
|
|
215
|
-
width:
|
|
216
|
-
height:
|
|
608
|
+
alt: import_zod5.z.string().optional(),
|
|
609
|
+
width: import_zod5.z.number().positive().optional(),
|
|
610
|
+
height: import_zod5.z.number().positive().optional()
|
|
217
611
|
});
|
|
218
|
-
var SafeThumbnailSchema =
|
|
612
|
+
var SafeThumbnailSchema = import_zod5.z.union([
|
|
219
613
|
AssetReferenceSchema,
|
|
220
614
|
SafeThumbnailObjectSchema,
|
|
221
615
|
SafeThumbnailUrlSchema
|
|
222
616
|
]);
|
|
223
|
-
var TemplatePackageRefSchema =
|
|
224
|
-
path:
|
|
617
|
+
var TemplatePackageRefSchema = import_zod5.z.object({
|
|
618
|
+
path: import_zod5.z.string().optional(),
|
|
225
619
|
url: SafeThumbnailUrlSchema.optional(),
|
|
226
|
-
checksum:
|
|
227
|
-
format:
|
|
620
|
+
checksum: import_zod5.z.string().optional(),
|
|
621
|
+
format: import_zod5.z.enum(["stora", "json"]).default("stora")
|
|
228
622
|
});
|
|
229
|
-
var TemplateRequirementsSchema =
|
|
230
|
-
requiredComponents:
|
|
231
|
-
requiredCapabilities:
|
|
623
|
+
var TemplateRequirementsSchema = import_zod5.z.object({
|
|
624
|
+
requiredComponents: import_zod5.z.array(import_zod5.z.string()).default([]),
|
|
625
|
+
requiredCapabilities: import_zod5.z.array(import_zod5.z.string()).default([])
|
|
232
626
|
});
|
|
233
|
-
var TemplateRecordSchema =
|
|
234
|
-
id:
|
|
235
|
-
name:
|
|
236
|
-
description:
|
|
237
|
-
category:
|
|
238
|
-
tags:
|
|
627
|
+
var TemplateRecordSchema = import_zod5.z.object({
|
|
628
|
+
id: import_zod5.z.string().min(1, "Template ID must be a non-empty string"),
|
|
629
|
+
name: import_zod5.z.string().min(1, "Template name must be a non-empty string"),
|
|
630
|
+
description: import_zod5.z.string().optional().default(""),
|
|
631
|
+
category: import_zod5.z.string().optional().default("general"),
|
|
632
|
+
tags: import_zod5.z.array(import_zod5.z.string()).optional().default([]),
|
|
239
633
|
thumbnail: SafeThumbnailSchema.optional(),
|
|
240
|
-
author:
|
|
241
|
-
version:
|
|
634
|
+
author: import_zod5.z.string().optional().default(""),
|
|
635
|
+
version: import_zod5.z.string().optional().default("1.0.0"),
|
|
242
636
|
document: PageDocumentSchema.optional(),
|
|
243
637
|
packageReference: TemplatePackageRefSchema.optional(),
|
|
244
638
|
requirements: TemplateRequirementsSchema.default({
|
|
245
639
|
requiredComponents: [],
|
|
246
640
|
requiredCapabilities: []
|
|
247
641
|
}),
|
|
248
|
-
createdAt:
|
|
249
|
-
updatedAt:
|
|
250
|
-
custom:
|
|
642
|
+
createdAt: import_zod5.z.string().optional(),
|
|
643
|
+
updatedAt: import_zod5.z.string().optional(),
|
|
644
|
+
custom: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.unknown()).optional()
|
|
251
645
|
});
|
|
252
646
|
function isTemplateRecord(value) {
|
|
253
647
|
return TemplateRecordSchema.safeParse(value).success;
|
|
@@ -524,6 +918,154 @@ var PAGE_DOCUMENT_JSON_SCHEMA_V1 = {
|
|
|
524
918
|
},
|
|
525
919
|
additionalProperties: false
|
|
526
920
|
},
|
|
921
|
+
animationConfig: {
|
|
922
|
+
type: "object",
|
|
923
|
+
properties: {
|
|
924
|
+
type: {
|
|
925
|
+
type: "string",
|
|
926
|
+
default: "none",
|
|
927
|
+
description: "Scroll entrance animation type (e.g. fade, fade-up, zoom-in, slide-left)"
|
|
928
|
+
},
|
|
929
|
+
duration: {
|
|
930
|
+
type: "number",
|
|
931
|
+
minimum: 0,
|
|
932
|
+
default: 600,
|
|
933
|
+
description: "Animation duration in milliseconds"
|
|
934
|
+
},
|
|
935
|
+
delay: {
|
|
936
|
+
type: "number",
|
|
937
|
+
minimum: 0,
|
|
938
|
+
default: 0,
|
|
939
|
+
description: "Animation delay in milliseconds"
|
|
940
|
+
},
|
|
941
|
+
easing: {
|
|
942
|
+
type: "string",
|
|
943
|
+
default: "ease-out",
|
|
944
|
+
description: "CSS animation easing / transition timing function"
|
|
945
|
+
},
|
|
946
|
+
once: {
|
|
947
|
+
type: "boolean",
|
|
948
|
+
default: true,
|
|
949
|
+
description: "Whether scroll animation plays only once when entering viewport"
|
|
950
|
+
},
|
|
951
|
+
hoverEffect: {
|
|
952
|
+
type: "string",
|
|
953
|
+
default: "none",
|
|
954
|
+
description: "Hover micro-interaction effect (e.g. lift, scale, glow, tilt)"
|
|
955
|
+
},
|
|
956
|
+
loopEffect: {
|
|
957
|
+
type: "string",
|
|
958
|
+
default: "none",
|
|
959
|
+
description: "Continuous loop animation effect (e.g. pulse, bounce, spin, float)"
|
|
960
|
+
}
|
|
961
|
+
},
|
|
962
|
+
additionalProperties: false
|
|
963
|
+
},
|
|
964
|
+
actionStep: {
|
|
965
|
+
type: "object",
|
|
966
|
+
required: ["id", "type"],
|
|
967
|
+
properties: {
|
|
968
|
+
id: {
|
|
969
|
+
type: "string",
|
|
970
|
+
minLength: 1
|
|
971
|
+
},
|
|
972
|
+
type: {
|
|
973
|
+
type: "string",
|
|
974
|
+
enum: [
|
|
975
|
+
"api_request",
|
|
976
|
+
"navigate",
|
|
977
|
+
"set_state",
|
|
978
|
+
"reset_form",
|
|
979
|
+
"show_toast",
|
|
980
|
+
"open_modal",
|
|
981
|
+
"close_modal",
|
|
982
|
+
"copy_clipboard",
|
|
983
|
+
"custom_event"
|
|
984
|
+
]
|
|
985
|
+
},
|
|
986
|
+
label: { type: "string" },
|
|
987
|
+
payload: { type: "object" },
|
|
988
|
+
condition: {
|
|
989
|
+
type: "object",
|
|
990
|
+
required: ["field", "operator"],
|
|
991
|
+
properties: {
|
|
992
|
+
field: { type: "string", minLength: 1 },
|
|
993
|
+
operator: {
|
|
994
|
+
type: "string",
|
|
995
|
+
enum: [
|
|
996
|
+
"equals",
|
|
997
|
+
"not_equals",
|
|
998
|
+
"contains",
|
|
999
|
+
"not_contains",
|
|
1000
|
+
"is_truthy",
|
|
1001
|
+
"is_falsy",
|
|
1002
|
+
"gt",
|
|
1003
|
+
"gte",
|
|
1004
|
+
"lt",
|
|
1005
|
+
"lte",
|
|
1006
|
+
"regex"
|
|
1007
|
+
]
|
|
1008
|
+
},
|
|
1009
|
+
value: {}
|
|
1010
|
+
},
|
|
1011
|
+
additionalProperties: false
|
|
1012
|
+
},
|
|
1013
|
+
timeout: { type: "number", minimum: 1 },
|
|
1014
|
+
continueOnError: { type: "boolean" },
|
|
1015
|
+
onSuccess: {
|
|
1016
|
+
type: "array",
|
|
1017
|
+
items: { $ref: "#/definitions/actionStep" }
|
|
1018
|
+
},
|
|
1019
|
+
onError: {
|
|
1020
|
+
type: "array",
|
|
1021
|
+
items: { $ref: "#/definitions/actionStep" }
|
|
1022
|
+
}
|
|
1023
|
+
},
|
|
1024
|
+
additionalProperties: false
|
|
1025
|
+
},
|
|
1026
|
+
actionPipeline: {
|
|
1027
|
+
type: "object",
|
|
1028
|
+
required: ["id", "trigger", "steps"],
|
|
1029
|
+
properties: {
|
|
1030
|
+
id: {
|
|
1031
|
+
type: "string",
|
|
1032
|
+
minLength: 1
|
|
1033
|
+
},
|
|
1034
|
+
trigger: {
|
|
1035
|
+
type: "string",
|
|
1036
|
+
enum: ["click", "submit", "change", "blur", "focus", "load"]
|
|
1037
|
+
},
|
|
1038
|
+
label: { type: "string" },
|
|
1039
|
+
debounceMs: { type: "number", minimum: 0 },
|
|
1040
|
+
preventDuplicate: { type: "boolean" },
|
|
1041
|
+
enabled: { type: "boolean", default: true },
|
|
1042
|
+
steps: {
|
|
1043
|
+
type: "array",
|
|
1044
|
+
items: { $ref: "#/definitions/actionStep" },
|
|
1045
|
+
minItems: 1
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
additionalProperties: false
|
|
1049
|
+
},
|
|
1050
|
+
formConfig: {
|
|
1051
|
+
type: "object",
|
|
1052
|
+
required: ["formId"],
|
|
1053
|
+
properties: {
|
|
1054
|
+
formId: {
|
|
1055
|
+
type: "string",
|
|
1056
|
+
minLength: 1
|
|
1057
|
+
},
|
|
1058
|
+
resetOnSubmit: { type: "boolean", default: false },
|
|
1059
|
+
scrollToFirstError: { type: "boolean", default: true },
|
|
1060
|
+
validateOn: {
|
|
1061
|
+
type: "string",
|
|
1062
|
+
enum: ["blur", "change", "submit"],
|
|
1063
|
+
default: "blur"
|
|
1064
|
+
},
|
|
1065
|
+
initialValues: { type: "object" }
|
|
1066
|
+
},
|
|
1067
|
+
additionalProperties: false
|
|
1068
|
+
},
|
|
527
1069
|
node: {
|
|
528
1070
|
type: "object",
|
|
529
1071
|
required: ["id", "type"],
|
|
@@ -546,6 +1088,20 @@ var PAGE_DOCUMENT_JSON_SCHEMA_V1 = {
|
|
|
546
1088
|
styles: {
|
|
547
1089
|
$ref: "#/definitions/responsiveStyles"
|
|
548
1090
|
},
|
|
1091
|
+
animation: {
|
|
1092
|
+
$ref: "#/definitions/animationConfig"
|
|
1093
|
+
},
|
|
1094
|
+
actions: {
|
|
1095
|
+
type: "array",
|
|
1096
|
+
items: {
|
|
1097
|
+
$ref: "#/definitions/actionPipeline"
|
|
1098
|
+
},
|
|
1099
|
+
description: "Multi-step action pipelines bound to component events"
|
|
1100
|
+
},
|
|
1101
|
+
formConfig: {
|
|
1102
|
+
$ref: "#/definitions/formConfig",
|
|
1103
|
+
description: "Form container configuration and behavior"
|
|
1104
|
+
},
|
|
549
1105
|
children: {
|
|
550
1106
|
type: "array",
|
|
551
1107
|
items: {
|
|
@@ -882,45 +1438,326 @@ var TEMPLATE_RECORD_JSON_SCHEMA_V1 = {
|
|
|
882
1438
|
function getTemplateRecordJsonSchema() {
|
|
883
1439
|
return TEMPLATE_RECORD_JSON_SCHEMA_V1;
|
|
884
1440
|
}
|
|
1441
|
+
var ACTION_PIPELINE_JSON_SCHEMA_V1 = {
|
|
1442
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
1443
|
+
$id: "https://schema.stora.page/v1/action-pipeline.json",
|
|
1444
|
+
title: "StoraActionPipeline",
|
|
1445
|
+
description: "Action Pipeline schema definition for KUBUILD event workflows",
|
|
1446
|
+
type: "object",
|
|
1447
|
+
required: ["id", "trigger", "steps"],
|
|
1448
|
+
additionalProperties: false,
|
|
1449
|
+
properties: {
|
|
1450
|
+
id: {
|
|
1451
|
+
type: "string",
|
|
1452
|
+
minLength: 1,
|
|
1453
|
+
description: "Unique pipeline identifier"
|
|
1454
|
+
},
|
|
1455
|
+
trigger: {
|
|
1456
|
+
type: "string",
|
|
1457
|
+
enum: ["click", "submit", "change", "blur", "focus", "load"],
|
|
1458
|
+
description: "DOM or component event that triggers the action pipeline"
|
|
1459
|
+
},
|
|
1460
|
+
label: {
|
|
1461
|
+
type: "string",
|
|
1462
|
+
description: "Human readable label for the action pipeline"
|
|
1463
|
+
},
|
|
1464
|
+
debounceMs: {
|
|
1465
|
+
type: "number",
|
|
1466
|
+
minimum: 0,
|
|
1467
|
+
description: "Debounce duration in milliseconds"
|
|
1468
|
+
},
|
|
1469
|
+
preventDuplicate: {
|
|
1470
|
+
type: "boolean",
|
|
1471
|
+
description: "Prevent concurrent duplicate pipeline executions"
|
|
1472
|
+
},
|
|
1473
|
+
enabled: {
|
|
1474
|
+
type: "boolean",
|
|
1475
|
+
default: true,
|
|
1476
|
+
description: "Whether the pipeline is currently active"
|
|
1477
|
+
},
|
|
1478
|
+
steps: {
|
|
1479
|
+
type: "array",
|
|
1480
|
+
items: { $ref: "#/definitions/actionStep" },
|
|
1481
|
+
minItems: 1,
|
|
1482
|
+
description: "Ordered sequence of action steps to execute"
|
|
1483
|
+
}
|
|
1484
|
+
},
|
|
1485
|
+
definitions: {
|
|
1486
|
+
actionStep: {
|
|
1487
|
+
type: "object",
|
|
1488
|
+
required: ["id", "type"],
|
|
1489
|
+
properties: {
|
|
1490
|
+
id: {
|
|
1491
|
+
type: "string",
|
|
1492
|
+
minLength: 1
|
|
1493
|
+
},
|
|
1494
|
+
type: {
|
|
1495
|
+
type: "string",
|
|
1496
|
+
enum: [
|
|
1497
|
+
"api_request",
|
|
1498
|
+
"navigate",
|
|
1499
|
+
"set_state",
|
|
1500
|
+
"reset_form",
|
|
1501
|
+
"show_toast",
|
|
1502
|
+
"open_modal",
|
|
1503
|
+
"close_modal",
|
|
1504
|
+
"copy_clipboard",
|
|
1505
|
+
"custom_event"
|
|
1506
|
+
]
|
|
1507
|
+
},
|
|
1508
|
+
label: { type: "string" },
|
|
1509
|
+
payload: { type: "object" },
|
|
1510
|
+
condition: {
|
|
1511
|
+
type: "object",
|
|
1512
|
+
required: ["field", "operator"],
|
|
1513
|
+
properties: {
|
|
1514
|
+
field: { type: "string", minLength: 1 },
|
|
1515
|
+
operator: {
|
|
1516
|
+
type: "string",
|
|
1517
|
+
enum: [
|
|
1518
|
+
"equals",
|
|
1519
|
+
"not_equals",
|
|
1520
|
+
"contains",
|
|
1521
|
+
"not_contains",
|
|
1522
|
+
"is_truthy",
|
|
1523
|
+
"is_falsy",
|
|
1524
|
+
"gt",
|
|
1525
|
+
"gte",
|
|
1526
|
+
"lt",
|
|
1527
|
+
"lte",
|
|
1528
|
+
"regex"
|
|
1529
|
+
]
|
|
1530
|
+
},
|
|
1531
|
+
value: {}
|
|
1532
|
+
},
|
|
1533
|
+
additionalProperties: false
|
|
1534
|
+
},
|
|
1535
|
+
timeout: { type: "number", minimum: 1 },
|
|
1536
|
+
continueOnError: { type: "boolean" },
|
|
1537
|
+
onSuccess: {
|
|
1538
|
+
type: "array",
|
|
1539
|
+
items: { $ref: "#/definitions/actionStep" }
|
|
1540
|
+
},
|
|
1541
|
+
onError: {
|
|
1542
|
+
type: "array",
|
|
1543
|
+
items: { $ref: "#/definitions/actionStep" }
|
|
1544
|
+
}
|
|
1545
|
+
},
|
|
1546
|
+
additionalProperties: false
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
};
|
|
1550
|
+
function getActionPipelineJsonSchema() {
|
|
1551
|
+
return ACTION_PIPELINE_JSON_SCHEMA_V1;
|
|
1552
|
+
}
|
|
1553
|
+
var FORM_CONFIG_JSON_SCHEMA_V1 = {
|
|
1554
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
1555
|
+
$id: "https://schema.stora.page/v1/form-config.json",
|
|
1556
|
+
title: "StoraFormConfig",
|
|
1557
|
+
description: "Form container configuration and behavior definition for KUBUILD",
|
|
1558
|
+
type: "object",
|
|
1559
|
+
required: ["formId"],
|
|
1560
|
+
additionalProperties: false,
|
|
1561
|
+
properties: {
|
|
1562
|
+
formId: {
|
|
1563
|
+
type: "string",
|
|
1564
|
+
minLength: 1,
|
|
1565
|
+
description: "Unique identifier for the form boundary"
|
|
1566
|
+
},
|
|
1567
|
+
resetOnSubmit: {
|
|
1568
|
+
type: "boolean",
|
|
1569
|
+
default: false,
|
|
1570
|
+
description: "Whether to reset form field values after successful submission"
|
|
1571
|
+
},
|
|
1572
|
+
scrollToFirstError: {
|
|
1573
|
+
type: "boolean",
|
|
1574
|
+
default: true,
|
|
1575
|
+
description: "Auto-scroll viewport to the first invalid input on validation failure"
|
|
1576
|
+
},
|
|
1577
|
+
validateOn: {
|
|
1578
|
+
type: "string",
|
|
1579
|
+
enum: ["blur", "change", "submit"],
|
|
1580
|
+
default: "blur",
|
|
1581
|
+
description: "Default trigger event for field validation evaluation"
|
|
1582
|
+
},
|
|
1583
|
+
initialValues: {
|
|
1584
|
+
type: "object",
|
|
1585
|
+
description: "Initial state values populated in form fields"
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
function getFormConfigJsonSchema() {
|
|
1590
|
+
return FORM_CONFIG_JSON_SCHEMA_V1;
|
|
1591
|
+
}
|
|
1592
|
+
var FORM_FIELD_BINDING_JSON_SCHEMA_V1 = {
|
|
1593
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
1594
|
+
$id: "https://schema.stora.page/v1/form-field-binding.json",
|
|
1595
|
+
title: "StoraFormFieldBinding",
|
|
1596
|
+
description: "Form field binding definition connecting input elements to form state runtime",
|
|
1597
|
+
type: "object",
|
|
1598
|
+
required: ["name"],
|
|
1599
|
+
additionalProperties: false,
|
|
1600
|
+
properties: {
|
|
1601
|
+
name: {
|
|
1602
|
+
type: "string",
|
|
1603
|
+
minLength: 1,
|
|
1604
|
+
description: "Field state property key"
|
|
1605
|
+
},
|
|
1606
|
+
label: {
|
|
1607
|
+
type: "string",
|
|
1608
|
+
description: "Display label for the field"
|
|
1609
|
+
},
|
|
1610
|
+
defaultValue: {
|
|
1611
|
+
description: "Initial default value if not overridden by form initialValues"
|
|
1612
|
+
},
|
|
1613
|
+
rules: {
|
|
1614
|
+
type: "array",
|
|
1615
|
+
items: { $ref: "#/definitions/validationRule" },
|
|
1616
|
+
default: [],
|
|
1617
|
+
description: "Validation rules applied to the field value"
|
|
1618
|
+
},
|
|
1619
|
+
validateOn: {
|
|
1620
|
+
type: "string",
|
|
1621
|
+
enum: ["blur", "change", "submit"],
|
|
1622
|
+
default: "blur",
|
|
1623
|
+
description: "Field-specific validation trigger timing"
|
|
1624
|
+
},
|
|
1625
|
+
transform: {
|
|
1626
|
+
type: "string",
|
|
1627
|
+
enum: ["trim", "lowercase", "uppercase", "number"],
|
|
1628
|
+
description: "Value transformation applied prior to validation and state storage"
|
|
1629
|
+
},
|
|
1630
|
+
disabled: {
|
|
1631
|
+
type: "boolean",
|
|
1632
|
+
description: "Whether the field is disabled"
|
|
1633
|
+
},
|
|
1634
|
+
required: {
|
|
1635
|
+
type: "boolean",
|
|
1636
|
+
description: "Whether the field is required (shorthand rule)"
|
|
1637
|
+
}
|
|
1638
|
+
},
|
|
1639
|
+
definitions: {
|
|
1640
|
+
validationRule: {
|
|
1641
|
+
type: "object",
|
|
1642
|
+
required: ["type", "message"],
|
|
1643
|
+
properties: {
|
|
1644
|
+
type: {
|
|
1645
|
+
type: "string",
|
|
1646
|
+
enum: [
|
|
1647
|
+
"required",
|
|
1648
|
+
"email",
|
|
1649
|
+
"url",
|
|
1650
|
+
"min_length",
|
|
1651
|
+
"max_length",
|
|
1652
|
+
"numeric_min",
|
|
1653
|
+
"numeric_max",
|
|
1654
|
+
"pattern",
|
|
1655
|
+
"match_field",
|
|
1656
|
+
"custom_regex"
|
|
1657
|
+
]
|
|
1658
|
+
},
|
|
1659
|
+
value: {},
|
|
1660
|
+
message: {
|
|
1661
|
+
type: "string",
|
|
1662
|
+
minLength: 1
|
|
1663
|
+
}
|
|
1664
|
+
},
|
|
1665
|
+
additionalProperties: false
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
function getFormFieldBindingJsonSchema() {
|
|
1670
|
+
return FORM_FIELD_BINDING_JSON_SCHEMA_V1;
|
|
1671
|
+
}
|
|
885
1672
|
// Annotate the CommonJS export names for ESM import in node:
|
|
886
1673
|
0 && (module.exports = {
|
|
1674
|
+
ACTION_PIPELINE_JSON_SCHEMA_V1,
|
|
887
1675
|
ActionBindingSchema,
|
|
1676
|
+
ActionPipelineSchema,
|
|
1677
|
+
ActionStepConditionSchema,
|
|
1678
|
+
ActionStepSchema,
|
|
1679
|
+
ActionStepTypeSchema,
|
|
1680
|
+
ActionTriggerSchema,
|
|
1681
|
+
ActionTriggerTypeSchema,
|
|
1682
|
+
AnimationConfigSchema,
|
|
1683
|
+
ApiRequestStepPayloadSchema,
|
|
888
1684
|
AssetReferenceSchema,
|
|
889
1685
|
CURRENT_SCHEMA_VERSION,
|
|
1686
|
+
CloseModalStepPayloadSchema,
|
|
1687
|
+
ConditionOperatorSchema,
|
|
1688
|
+
CopyClipboardStepPayloadSchema,
|
|
1689
|
+
CustomEventStepPayloadSchema,
|
|
1690
|
+
DEFAULT_ANIMATION_CONFIG,
|
|
890
1691
|
DocumentMetadataSchema,
|
|
1692
|
+
FORM_CONFIG_JSON_SCHEMA_V1,
|
|
1693
|
+
FORM_FIELD_BINDING_JSON_SCHEMA_V1,
|
|
1694
|
+
FormConfigSchema,
|
|
1695
|
+
FormFieldBindingSchema,
|
|
891
1696
|
MANIFEST_JSON_SCHEMA_V1,
|
|
892
1697
|
ManifestAssetItemSchema,
|
|
893
1698
|
ManifestSchema,
|
|
1699
|
+
NavigateStepPayloadSchema,
|
|
894
1700
|
NodeSchema,
|
|
1701
|
+
OpenModalStepPayloadSchema,
|
|
895
1702
|
PAGE_DOCUMENT_JSON_SCHEMA_V1,
|
|
896
1703
|
PageDocumentSchema,
|
|
897
1704
|
PseudoStateStylesSchema,
|
|
1705
|
+
ResetFormStepPayloadSchema,
|
|
898
1706
|
ResponsiveStylesSchema,
|
|
899
1707
|
RootPageNodeSchema,
|
|
900
1708
|
SCHEMA_NAME,
|
|
901
1709
|
SafeThumbnailObjectSchema,
|
|
902
1710
|
SafeThumbnailSchema,
|
|
903
1711
|
SafeThumbnailUrlSchema,
|
|
1712
|
+
SetStateStepPayloadSchema,
|
|
1713
|
+
ShowToastStepPayloadSchema,
|
|
1714
|
+
StepPayloadSchemas,
|
|
904
1715
|
StyleDefinitionSchema,
|
|
905
1716
|
StyleValueSchema,
|
|
906
1717
|
TEMPLATE_RECORD_JSON_SCHEMA_V1,
|
|
907
1718
|
TemplatePackageRefSchema,
|
|
908
1719
|
TemplateRecordSchema,
|
|
909
1720
|
TemplateRequirementsSchema,
|
|
1721
|
+
ValidateOnEventSchema,
|
|
1722
|
+
ValidationRuleSchema,
|
|
1723
|
+
ValidationRuleTypeSchema,
|
|
910
1724
|
VariableBindingSchema,
|
|
911
1725
|
collectNodeIds,
|
|
912
1726
|
generateDeterministicNodeId,
|
|
1727
|
+
getActionPipelineJsonSchema,
|
|
1728
|
+
getFormConfigJsonSchema,
|
|
1729
|
+
getFormFieldBindingJsonSchema,
|
|
913
1730
|
getManifestJsonSchema,
|
|
914
1731
|
getPageDocumentJsonSchema,
|
|
915
1732
|
getTemplateRecordJsonSchema,
|
|
916
1733
|
isActionBinding,
|
|
1734
|
+
isActionPipeline,
|
|
1735
|
+
isActionStep,
|
|
1736
|
+
isActionStepCondition,
|
|
1737
|
+
isActionStepType,
|
|
1738
|
+
isActionTriggerType,
|
|
1739
|
+
isAnimationConfig,
|
|
917
1740
|
isAssetReference,
|
|
1741
|
+
isConditionOperator,
|
|
1742
|
+
isFormConfig,
|
|
1743
|
+
isFormFieldBinding,
|
|
918
1744
|
isManifest,
|
|
1745
|
+
isSafeActionUrl,
|
|
919
1746
|
isSafeThumbnail,
|
|
920
1747
|
isSafeThumbnailUrl,
|
|
921
1748
|
isTemplateRecord,
|
|
1749
|
+
isValidateOnEvent,
|
|
1750
|
+
isValidationRule,
|
|
1751
|
+
isValidationRuleType,
|
|
922
1752
|
isVariableBinding,
|
|
1753
|
+
sanitizeActionPayload,
|
|
1754
|
+
sanitizeActionPipeline,
|
|
1755
|
+
sanitizeActionStep,
|
|
1756
|
+
sanitizeActionString,
|
|
1757
|
+
sanitizeActionUrl,
|
|
1758
|
+
sanitizeActionValue,
|
|
923
1759
|
starterPageFixture,
|
|
1760
|
+
validateActionStepPayload,
|
|
924
1761
|
validateNodeIdUniqueness
|
|
925
1762
|
});
|
|
926
1763
|
//# sourceMappingURL=index.cjs.map
|