@kubuild/schema 0.5.0 → 0.7.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/actions.d.ts +45 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/document.d.ts +362 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/index.cjs +598 -204
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +569 -204
- package/dist/index.js.map +1 -1
- package/dist/json-schema.d.ts +251 -6
- package/dist/json-schema.d.ts.map +1 -1
- package/dist/template.d.ts +80 -0
- package/dist/template.d.ts.map +1 -1
- package/dist/tracking.d.ts +348 -0
- package/dist/tracking.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,210 @@
|
|
|
1
1
|
// src/document.ts
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as z4 } from "zod";
|
|
3
3
|
|
|
4
4
|
// src/actions.ts
|
|
5
|
+
import { z as z2 } from "zod";
|
|
6
|
+
|
|
7
|
+
// src/tracking.ts
|
|
5
8
|
import { z } from "zod";
|
|
6
|
-
var
|
|
9
|
+
var TrackingProviderTypeSchema = z.enum([
|
|
10
|
+
"meta",
|
|
11
|
+
"google",
|
|
12
|
+
"gtm",
|
|
13
|
+
"tiktok",
|
|
14
|
+
"custom"
|
|
15
|
+
]);
|
|
16
|
+
var TrackingDeliverySchema = z.enum(["both", "client_only", "server_only"]);
|
|
17
|
+
var MetaTrackingProviderConfigSchema = z.object({
|
|
18
|
+
enabled: z.boolean().default(true),
|
|
19
|
+
/** Host credential id; the server resolves the CAPI access token from it. */
|
|
20
|
+
credentialId: z.string().optional(),
|
|
21
|
+
/** Meta Pixel ID (e.g. 123456789012345) — public */
|
|
22
|
+
pixelId: z.string().optional().default(""),
|
|
23
|
+
/** Enable Server-Side Conversions API (delivered through the host relay) */
|
|
24
|
+
capiEnabled: z.boolean().optional().default(false),
|
|
25
|
+
/** Test Event Code from Meta Events Manager (e.g. "TEST12345") — not a secret */
|
|
26
|
+
testEventCode: z.string().optional().default("")
|
|
27
|
+
});
|
|
28
|
+
var GoogleTrackingProviderConfigSchema = z.object({
|
|
29
|
+
enabled: z.boolean().default(true),
|
|
30
|
+
/** Host credential id; the server resolves the Measurement Protocol API secret from it. */
|
|
31
|
+
credentialId: z.string().optional(),
|
|
32
|
+
/** GA4 Measurement ID (e.g. "G-XXXXXXXXXX") — public */
|
|
33
|
+
measurementId: z.string().optional().default("")
|
|
34
|
+
});
|
|
35
|
+
var GtmTrackingProviderConfigSchema = z.object({
|
|
36
|
+
enabled: z.boolean().default(true),
|
|
37
|
+
/** Optional linked account/workspace credential ID */
|
|
38
|
+
credentialId: z.string().optional(),
|
|
39
|
+
/** GTM Container ID (e.g. "GTM-XXXXXXX") — public */
|
|
40
|
+
containerId: z.string().optional().default("")
|
|
41
|
+
});
|
|
42
|
+
var TikTokTrackingProviderConfigSchema = z.object({
|
|
43
|
+
enabled: z.boolean().default(true),
|
|
44
|
+
/** Host credential id; the server resolves the Events API access token from it. */
|
|
45
|
+
credentialId: z.string().optional(),
|
|
46
|
+
/** TikTok Pixel ID (e.g. "C1234567890") — public */
|
|
47
|
+
pixelId: z.string().optional().default(""),
|
|
48
|
+
/** Enable TikTok Events API (server-side, delivered through the host relay) */
|
|
49
|
+
eventsApiEnabled: z.boolean().optional().default(false),
|
|
50
|
+
/** Test Event Code from TikTok Event Manager — not a secret */
|
|
51
|
+
testEventCode: z.string().optional().default("")
|
|
52
|
+
});
|
|
53
|
+
var CustomTrackingProviderConfigSchema = z.object({
|
|
54
|
+
enabled: z.boolean().default(true),
|
|
55
|
+
/** Host credential id; the server resolves the webhook `endpointUrl` + `headers` from it. */
|
|
56
|
+
credentialId: z.string().optional()
|
|
57
|
+
});
|
|
58
|
+
var LEGACY_TRACKING_SECRET_KEYS = Object.freeze({
|
|
59
|
+
meta: ["capiAccessToken", "serverRelayUrl"],
|
|
60
|
+
google: ["measurementProtocolSecret", "serverRelayUrl"],
|
|
61
|
+
gtm: ["serverRelayUrl"],
|
|
62
|
+
tiktok: ["accessToken", "serverRelayUrl"],
|
|
63
|
+
custom: ["endpointUrl", "headers"]
|
|
64
|
+
});
|
|
65
|
+
var TrackingConfigSchema = z.object({
|
|
66
|
+
/** Master toggle: dynamically enables or disables all tracking operations */
|
|
67
|
+
enabled: z.boolean().default(true),
|
|
68
|
+
/** When enabled, events are logged to console and can bypass live API calls for safe debugging */
|
|
69
|
+
debugMode: z.boolean().optional().default(false),
|
|
70
|
+
/** Automatically trigger PageView event upon page load */
|
|
71
|
+
autoPageView: z.boolean().optional().default(true),
|
|
72
|
+
/** Default delivery method when not explicitly overridden in an action step */
|
|
73
|
+
defaultDelivery: TrackingDeliverySchema.optional().default("both"),
|
|
74
|
+
/** Provider-specific settings */
|
|
75
|
+
providers: z.object({
|
|
76
|
+
meta: MetaTrackingProviderConfigSchema.optional(),
|
|
77
|
+
google: GoogleTrackingProviderConfigSchema.optional(),
|
|
78
|
+
gtm: GtmTrackingProviderConfigSchema.optional(),
|
|
79
|
+
tiktok: TikTokTrackingProviderConfigSchema.optional(),
|
|
80
|
+
custom: CustomTrackingProviderConfigSchema.optional()
|
|
81
|
+
}).optional().default({})
|
|
82
|
+
});
|
|
83
|
+
var MetaTrackingSecretsSchema = z.object({
|
|
84
|
+
/** System User access token for the Meta Graph API. */
|
|
85
|
+
capiAccessToken: z.string().min(1)
|
|
86
|
+
});
|
|
87
|
+
var GoogleTrackingSecretsSchema = z.object({
|
|
88
|
+
/** Measurement Protocol `api_secret`. */
|
|
89
|
+
measurementProtocolSecret: z.string().min(1)
|
|
90
|
+
});
|
|
91
|
+
var TikTokTrackingSecretsSchema = z.object({
|
|
92
|
+
/** Long-term Events API access token. */
|
|
93
|
+
accessToken: z.string().min(1)
|
|
94
|
+
});
|
|
95
|
+
var CustomTrackingSecretsSchema = z.object({
|
|
96
|
+
endpointUrl: z.string().url(),
|
|
97
|
+
headers: z.record(z.string(), z.string()).optional()
|
|
98
|
+
});
|
|
99
|
+
var StandardTrackingEventSchema = z.enum([
|
|
100
|
+
"PageView",
|
|
101
|
+
"ViewContent",
|
|
102
|
+
"AddToCart",
|
|
103
|
+
"InitiateCheckout",
|
|
104
|
+
"Purchase",
|
|
105
|
+
"Lead",
|
|
106
|
+
"Contact",
|
|
107
|
+
"CompleteRegistration",
|
|
108
|
+
"Subscribe",
|
|
109
|
+
"Search",
|
|
110
|
+
"SubmitApplication",
|
|
111
|
+
"Schedule"
|
|
112
|
+
]);
|
|
113
|
+
var TrackEventProviderSchema = z.enum(["all", "meta", "google", "gtm", "tiktok", "custom"]);
|
|
114
|
+
var TrackEventStepPayloadSchema = z.object({
|
|
115
|
+
/** Event name: e.g. "Purchase", "Lead", or custom string */
|
|
116
|
+
eventName: z.string().min(1, "Event name cannot be empty"),
|
|
117
|
+
/** Standard event vs custom event identifier */
|
|
118
|
+
eventType: z.enum(["standard", "custom"]).optional().default("standard"),
|
|
119
|
+
/**
|
|
120
|
+
* Target provider: 'all' or a specific provider.
|
|
121
|
+
* 'gtm' pushes the event to `window.dataLayer` (client-side only).
|
|
122
|
+
*/
|
|
123
|
+
provider: TrackEventProviderSchema.optional().default("all"),
|
|
124
|
+
/** Delivery channel: 'both', 'client_only', or 'server_only' */
|
|
125
|
+
delivery: TrackingDeliverySchema.optional().default("both"),
|
|
126
|
+
/**
|
|
127
|
+
* Deduplication Event ID.
|
|
128
|
+
* If omitted, a unique ID is automatically generated so Meta/TikTok CAPI
|
|
129
|
+
* deduplicates cleanly with the browser pixel.
|
|
130
|
+
*/
|
|
131
|
+
eventId: z.string().optional(),
|
|
132
|
+
/**
|
|
133
|
+
* Event parameters/properties (e.g. currency, value, content_name, order_id).
|
|
134
|
+
* Supports runtime variable interpolation (e.g. {{ form.price }} or {{ variables.currency }}).
|
|
135
|
+
*/
|
|
136
|
+
params: z.record(z.string(), z.unknown()).optional().default({}),
|
|
137
|
+
/**
|
|
138
|
+
* User Data for advanced matching and server CAPI (e.g. email, phone, firstName, lastName).
|
|
139
|
+
* Supports runtime variable interpolation (e.g. {{ form.email }}).
|
|
140
|
+
*/
|
|
141
|
+
userData: z.record(z.string(), z.unknown()).optional().default({}),
|
|
142
|
+
/** Step-level active toggle */
|
|
143
|
+
enabled: z.boolean().optional().default(true)
|
|
144
|
+
});
|
|
145
|
+
var TRACKING_RELAY_PROTOCOL_VERSION = 1;
|
|
146
|
+
var ServerTrackingEventSchema = z.object({
|
|
147
|
+
eventName: z.string().min(1).max(256),
|
|
148
|
+
eventType: z.enum(["standard", "custom"]).optional(),
|
|
149
|
+
eventId: z.string().max(256).optional(),
|
|
150
|
+
/** Unix epoch seconds. */
|
|
151
|
+
eventTime: z.number().int().nonnegative().optional(),
|
|
152
|
+
eventSourceUrl: z.string().max(4096).optional(),
|
|
153
|
+
actionSource: z.enum(["website", "app", "system_generated"]).optional(),
|
|
154
|
+
params: z.record(z.string(), z.unknown()).optional(),
|
|
155
|
+
/** Raw (unhashed) user data; the relay hashes PII per provider spec before forwarding. */
|
|
156
|
+
userData: z.record(z.string(), z.unknown()).optional(),
|
|
157
|
+
customData: z.record(z.string(), z.unknown()).optional()
|
|
158
|
+
});
|
|
159
|
+
var TrackingRelayRequestSchema = z.object({
|
|
160
|
+
version: z.literal(TRACKING_RELAY_PROTOCOL_VERSION),
|
|
161
|
+
event: ServerTrackingEventSchema,
|
|
162
|
+
provider: TrackEventProviderSchema.optional().default("all"),
|
|
163
|
+
/** Optional hint only; the relay uses the credentialId from its trusted config. */
|
|
164
|
+
credentialId: z.string().max(256).optional(),
|
|
165
|
+
/** Host document/page id so the relay can look up the trusted tracking config. */
|
|
166
|
+
documentId: z.string().max(256).optional()
|
|
167
|
+
});
|
|
168
|
+
var TrackingRelayProviderResultSchema = z.object({
|
|
169
|
+
provider: z.string(),
|
|
170
|
+
success: z.boolean(),
|
|
171
|
+
status: z.number().int().optional(),
|
|
172
|
+
skipped: z.boolean().optional(),
|
|
173
|
+
reason: z.string().optional(),
|
|
174
|
+
error: z.string().optional()
|
|
175
|
+
});
|
|
176
|
+
var TrackingRelayErrorCodeSchema = z.enum([
|
|
177
|
+
"INVALID_REQUEST",
|
|
178
|
+
"UNSUPPORTED_VERSION",
|
|
179
|
+
"FORBIDDEN_ORIGIN",
|
|
180
|
+
"METHOD_NOT_ALLOWED",
|
|
181
|
+
"CONFIG_NOT_FOUND",
|
|
182
|
+
"INTERNAL_ERROR"
|
|
183
|
+
]);
|
|
184
|
+
var TrackingRelayResponseSchema = z.object({
|
|
185
|
+
version: z.literal(TRACKING_RELAY_PROTOCOL_VERSION),
|
|
186
|
+
success: z.boolean(),
|
|
187
|
+
eventId: z.string().optional(),
|
|
188
|
+
skipped: z.boolean().optional(),
|
|
189
|
+
reason: z.string().optional(),
|
|
190
|
+
results: z.record(z.string(), TrackingRelayProviderResultSchema).optional(),
|
|
191
|
+
error: z.object({
|
|
192
|
+
code: TrackingRelayErrorCodeSchema,
|
|
193
|
+
message: z.string()
|
|
194
|
+
}).optional()
|
|
195
|
+
});
|
|
196
|
+
function isTrackingConfig(value) {
|
|
197
|
+
return TrackingConfigSchema.safeParse(value).success;
|
|
198
|
+
}
|
|
199
|
+
function isTrackEventStepPayload(value) {
|
|
200
|
+
return TrackEventStepPayloadSchema.safeParse(value).success;
|
|
201
|
+
}
|
|
202
|
+
function isTrackingRelayRequest(value) {
|
|
203
|
+
return TrackingRelayRequestSchema.safeParse(value).success;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/actions.ts
|
|
207
|
+
var ActionTriggerTypeSchema = z2.enum([
|
|
7
208
|
"click",
|
|
8
209
|
"submit",
|
|
9
210
|
"change",
|
|
@@ -12,7 +213,7 @@ var ActionTriggerTypeSchema = z.enum([
|
|
|
12
213
|
"load"
|
|
13
214
|
]);
|
|
14
215
|
var ActionTriggerSchema = ActionTriggerTypeSchema;
|
|
15
|
-
var ActionStepTypeSchema =
|
|
216
|
+
var ActionStepTypeSchema = z2.enum([
|
|
16
217
|
"api_request",
|
|
17
218
|
"navigate",
|
|
18
219
|
"set_state",
|
|
@@ -20,10 +221,12 @@ var ActionStepTypeSchema = z.enum([
|
|
|
20
221
|
"show_toast",
|
|
21
222
|
"open_modal",
|
|
22
223
|
"close_modal",
|
|
224
|
+
"toggle_modal",
|
|
23
225
|
"copy_clipboard",
|
|
24
|
-
"custom_event"
|
|
226
|
+
"custom_event",
|
|
227
|
+
"track_event"
|
|
25
228
|
]);
|
|
26
|
-
var ConditionOperatorSchema =
|
|
229
|
+
var ConditionOperatorSchema = z2.enum([
|
|
27
230
|
"equals",
|
|
28
231
|
"not_equals",
|
|
29
232
|
"contains",
|
|
@@ -36,10 +239,10 @@ var ConditionOperatorSchema = z.enum([
|
|
|
36
239
|
"lte",
|
|
37
240
|
"regex"
|
|
38
241
|
]);
|
|
39
|
-
var ActionStepConditionSchema =
|
|
40
|
-
field:
|
|
242
|
+
var ActionStepConditionSchema = z2.object({
|
|
243
|
+
field: z2.string().min(1, "Condition field cannot be empty"),
|
|
41
244
|
operator: ConditionOperatorSchema,
|
|
42
|
-
value:
|
|
245
|
+
value: z2.unknown().optional()
|
|
43
246
|
});
|
|
44
247
|
var DANGEROUS_URL_PATTERN = /(javascript:|vbscript:|data:text\/html)/i;
|
|
45
248
|
var DANGEROUS_SCRIPT_PATTERN = /<\s*script/i;
|
|
@@ -50,68 +253,81 @@ function isSafeActionUrl(url) {
|
|
|
50
253
|
if (DANGEROUS_SCRIPT_PATTERN.test(trimmed)) return false;
|
|
51
254
|
return true;
|
|
52
255
|
}
|
|
53
|
-
var SafeUrlStringSchema =
|
|
256
|
+
var SafeUrlStringSchema = z2.string().min(1, "URL cannot be empty").refine(isSafeActionUrl, {
|
|
54
257
|
message: "URL contains disallowed or unsafe protocol/script pattern"
|
|
55
258
|
});
|
|
56
|
-
var SafeEventNameSchema =
|
|
259
|
+
var SafeEventNameSchema = z2.string().min(1, "Event name cannot be empty").regex(/^[a-zA-Z0-9_\-:]+$/, {
|
|
57
260
|
message: "Event name must contain only alphanumeric characters, dashes, colons, or underscores"
|
|
58
261
|
});
|
|
59
|
-
var ApiRequestStepPayloadSchema =
|
|
262
|
+
var ApiRequestStepPayloadSchema = z2.object({
|
|
60
263
|
url: SafeUrlStringSchema,
|
|
61
|
-
method:
|
|
62
|
-
headers:
|
|
63
|
-
queryParams:
|
|
64
|
-
body:
|
|
65
|
-
bodyFormat:
|
|
66
|
-
bodyType:
|
|
67
|
-
timeout:
|
|
68
|
-
responseMapping:
|
|
264
|
+
method: z2.enum(["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]).default("GET"),
|
|
265
|
+
headers: z2.record(z2.string(), z2.string()).optional(),
|
|
266
|
+
queryParams: z2.record(z2.string(), z2.union([z2.string(), z2.number(), z2.boolean()])).optional(),
|
|
267
|
+
body: z2.union([z2.string(), z2.record(z2.string(), z2.unknown()), z2.array(z2.unknown())]).optional(),
|
|
268
|
+
bodyFormat: z2.enum(["json", "form-data", "formData", "urlencoded", "url-encoded", "raw", "text"]).optional(),
|
|
269
|
+
bodyType: z2.enum(["json", "form-data", "formData", "urlencoded", "url-encoded", "raw", "text"]).optional(),
|
|
270
|
+
timeout: z2.number().positive("Timeout must be greater than 0 ms").optional(),
|
|
271
|
+
responseMapping: z2.record(z2.string(), z2.string()).optional()
|
|
69
272
|
});
|
|
70
|
-
var NavigateStepPayloadSchema =
|
|
273
|
+
var NavigateStepPayloadSchema = z2.object({
|
|
71
274
|
url: SafeUrlStringSchema,
|
|
72
|
-
target:
|
|
73
|
-
replace:
|
|
74
|
-
scroll:
|
|
75
|
-
behavior:
|
|
275
|
+
target: z2.enum(["_self", "_blank", "_parent", "_top"]).optional().default("_self"),
|
|
276
|
+
replace: z2.boolean().optional(),
|
|
277
|
+
scroll: z2.boolean().optional(),
|
|
278
|
+
behavior: z2.enum(["smooth", "auto"]).optional()
|
|
76
279
|
});
|
|
77
|
-
var SetStateStepPayloadSchema =
|
|
78
|
-
key:
|
|
79
|
-
value:
|
|
80
|
-
scope:
|
|
280
|
+
var SetStateStepPayloadSchema = z2.object({
|
|
281
|
+
key: z2.string().min(1, "State key cannot be empty"),
|
|
282
|
+
value: z2.unknown(),
|
|
283
|
+
scope: z2.enum(["runtime", "document", "session", "local"]).optional().default("runtime")
|
|
81
284
|
});
|
|
82
|
-
var ResetFormStepPayloadSchema =
|
|
83
|
-
formId:
|
|
285
|
+
var ResetFormStepPayloadSchema = z2.object({
|
|
286
|
+
formId: z2.string().optional()
|
|
84
287
|
});
|
|
85
|
-
var ShowToastStepPayloadSchema =
|
|
86
|
-
message:
|
|
87
|
-
type:
|
|
88
|
-
variant:
|
|
89
|
-
title:
|
|
90
|
-
duration:
|
|
91
|
-
position:
|
|
288
|
+
var ShowToastStepPayloadSchema = z2.object({
|
|
289
|
+
message: z2.string().min(1, "Toast message cannot be empty"),
|
|
290
|
+
type: z2.enum(["success", "error", "warning", "info"]).optional().default("info"),
|
|
291
|
+
variant: z2.enum(["success", "error", "warning", "info"]).optional(),
|
|
292
|
+
title: z2.string().optional(),
|
|
293
|
+
duration: z2.number().nonnegative("Duration must be >= 0 ms").optional(),
|
|
294
|
+
position: z2.enum(["top-right", "top-left", "bottom-right", "bottom-left", "top-center", "bottom-center"]).optional()
|
|
92
295
|
});
|
|
93
|
-
var OpenModalStepPayloadSchema =
|
|
94
|
-
modalId:
|
|
95
|
-
modalNodeId:
|
|
96
|
-
toggle:
|
|
296
|
+
var OpenModalStepPayloadSchema = z2.object({
|
|
297
|
+
modalId: z2.string().optional(),
|
|
298
|
+
modalNodeId: z2.string().optional(),
|
|
299
|
+
toggle: z2.boolean().optional()
|
|
97
300
|
}).refine((data) => Boolean(data.modalId || data.modalNodeId), {
|
|
98
301
|
message: "Modal ID or Modal Node ID cannot be empty"
|
|
99
302
|
});
|
|
100
|
-
var CloseModalStepPayloadSchema =
|
|
101
|
-
modalId:
|
|
102
|
-
modalNodeId:
|
|
303
|
+
var CloseModalStepPayloadSchema = z2.object({
|
|
304
|
+
modalId: z2.string().optional(),
|
|
305
|
+
modalNodeId: z2.string().optional()
|
|
103
306
|
});
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
307
|
+
var ToggleModalStepPayloadSchema = z2.object({
|
|
308
|
+
modalId: z2.string().optional(),
|
|
309
|
+
modalNodeId: z2.string().optional(),
|
|
310
|
+
targetNodeId: z2.string().optional(),
|
|
311
|
+
nodeId: z2.string().optional()
|
|
312
|
+
}).refine(
|
|
313
|
+
(data) => [data.modalId, data.modalNodeId, data.targetNodeId, data.nodeId].some(
|
|
314
|
+
(id) => typeof id === "string" && id.trim().length > 0
|
|
315
|
+
),
|
|
316
|
+
{
|
|
317
|
+
message: "Modal ID or Modal Node ID cannot be empty"
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
var CopyClipboardStepPayloadSchema = z2.object({
|
|
321
|
+
text: z2.string().optional(),
|
|
322
|
+
value: z2.unknown().optional(),
|
|
323
|
+
notify: z2.boolean().optional(),
|
|
324
|
+
toastMessage: z2.string().optional()
|
|
109
325
|
});
|
|
110
|
-
var CustomEventStepPayloadSchema =
|
|
326
|
+
var CustomEventStepPayloadSchema = z2.object({
|
|
111
327
|
eventName: SafeEventNameSchema,
|
|
112
|
-
detail:
|
|
113
|
-
bubbles:
|
|
114
|
-
cancelable:
|
|
328
|
+
detail: z2.record(z2.string(), z2.unknown()).optional(),
|
|
329
|
+
bubbles: z2.boolean().optional().default(true),
|
|
330
|
+
cancelable: z2.boolean().optional().default(true)
|
|
115
331
|
});
|
|
116
332
|
var StepPayloadSchemas = {
|
|
117
333
|
api_request: ApiRequestStepPayloadSchema,
|
|
@@ -121,30 +337,32 @@ var StepPayloadSchemas = {
|
|
|
121
337
|
show_toast: ShowToastStepPayloadSchema,
|
|
122
338
|
open_modal: OpenModalStepPayloadSchema,
|
|
123
339
|
close_modal: CloseModalStepPayloadSchema,
|
|
340
|
+
toggle_modal: ToggleModalStepPayloadSchema,
|
|
124
341
|
copy_clipboard: CopyClipboardStepPayloadSchema,
|
|
125
|
-
custom_event: CustomEventStepPayloadSchema
|
|
342
|
+
custom_event: CustomEventStepPayloadSchema,
|
|
343
|
+
track_event: TrackEventStepPayloadSchema
|
|
126
344
|
};
|
|
127
|
-
var ActionStepSchema =
|
|
128
|
-
() =>
|
|
129
|
-
id:
|
|
345
|
+
var ActionStepSchema = z2.lazy(
|
|
346
|
+
() => z2.object({
|
|
347
|
+
id: z2.string().min(1, "Step ID cannot be empty"),
|
|
130
348
|
type: ActionStepTypeSchema,
|
|
131
|
-
label:
|
|
132
|
-
payload:
|
|
349
|
+
label: z2.string().optional(),
|
|
350
|
+
payload: z2.record(z2.string(), z2.unknown()).optional().default({}),
|
|
133
351
|
condition: ActionStepConditionSchema.optional(),
|
|
134
|
-
timeout:
|
|
135
|
-
continueOnError:
|
|
136
|
-
onSuccess:
|
|
137
|
-
onError:
|
|
352
|
+
timeout: z2.number().positive().optional(),
|
|
353
|
+
continueOnError: z2.boolean().optional(),
|
|
354
|
+
onSuccess: z2.array(ActionStepSchema).optional(),
|
|
355
|
+
onError: z2.array(ActionStepSchema).optional()
|
|
138
356
|
})
|
|
139
357
|
);
|
|
140
|
-
var ActionPipelineSchema =
|
|
141
|
-
id:
|
|
358
|
+
var ActionPipelineSchema = z2.object({
|
|
359
|
+
id: z2.string().min(1, "Pipeline ID cannot be empty"),
|
|
142
360
|
trigger: ActionTriggerTypeSchema,
|
|
143
|
-
label:
|
|
144
|
-
debounceMs:
|
|
145
|
-
preventDuplicate:
|
|
146
|
-
enabled:
|
|
147
|
-
steps:
|
|
361
|
+
label: z2.string().optional(),
|
|
362
|
+
debounceMs: z2.number().nonnegative("Debounce ms must be >= 0").optional(),
|
|
363
|
+
preventDuplicate: z2.boolean().optional(),
|
|
364
|
+
enabled: z2.boolean().optional().default(true),
|
|
365
|
+
steps: z2.array(ActionStepSchema).min(1, "Action pipeline must contain at least one step")
|
|
148
366
|
});
|
|
149
367
|
function isActionTriggerType(value) {
|
|
150
368
|
return ActionTriggerTypeSchema.safeParse(value).success;
|
|
@@ -169,9 +387,9 @@ function validateActionStepPayload(type, payload) {
|
|
|
169
387
|
if (!schema) {
|
|
170
388
|
return {
|
|
171
389
|
success: false,
|
|
172
|
-
error: new
|
|
390
|
+
error: new z2.ZodError([
|
|
173
391
|
{
|
|
174
|
-
code:
|
|
392
|
+
code: z2.ZodIssueCode.custom,
|
|
175
393
|
message: `Unknown step type: ${type}`,
|
|
176
394
|
path: ["type"]
|
|
177
395
|
}
|
|
@@ -259,8 +477,8 @@ function sanitizeActionPipeline(pipeline) {
|
|
|
259
477
|
}
|
|
260
478
|
|
|
261
479
|
// src/form.ts
|
|
262
|
-
import { z as
|
|
263
|
-
var ValidationRuleTypeSchema =
|
|
480
|
+
import { z as z3 } from "zod";
|
|
481
|
+
var ValidationRuleTypeSchema = z3.enum([
|
|
264
482
|
"required",
|
|
265
483
|
"email",
|
|
266
484
|
"url",
|
|
@@ -272,29 +490,29 @@ var ValidationRuleTypeSchema = z2.enum([
|
|
|
272
490
|
"match_field",
|
|
273
491
|
"custom_regex"
|
|
274
492
|
]);
|
|
275
|
-
var ValidateOnEventSchema =
|
|
276
|
-
var ValidationRuleSchema =
|
|
493
|
+
var ValidateOnEventSchema = z3.enum(["blur", "change", "submit"]);
|
|
494
|
+
var ValidationRuleSchema = z3.object({
|
|
277
495
|
type: ValidationRuleTypeSchema,
|
|
278
|
-
value:
|
|
279
|
-
message:
|
|
496
|
+
value: z3.unknown().optional(),
|
|
497
|
+
message: z3.string().min(1, "Validation error message cannot be empty")
|
|
280
498
|
});
|
|
281
|
-
var FormFieldBindingSchema =
|
|
282
|
-
name:
|
|
283
|
-
label:
|
|
284
|
-
defaultValue:
|
|
285
|
-
rules:
|
|
499
|
+
var FormFieldBindingSchema = z3.object({
|
|
500
|
+
name: z3.string().min(1, "Field name cannot be empty"),
|
|
501
|
+
label: z3.string().optional(),
|
|
502
|
+
defaultValue: z3.unknown().optional(),
|
|
503
|
+
rules: z3.array(ValidationRuleSchema).optional().default([]),
|
|
286
504
|
validateOn: ValidateOnEventSchema.optional().default("blur"),
|
|
287
|
-
transform:
|
|
288
|
-
disabled:
|
|
289
|
-
required:
|
|
505
|
+
transform: z3.enum(["trim", "lowercase", "uppercase", "number"]).optional(),
|
|
506
|
+
disabled: z3.boolean().optional(),
|
|
507
|
+
required: z3.boolean().optional()
|
|
290
508
|
});
|
|
291
|
-
var FormConfigSchema =
|
|
292
|
-
formId:
|
|
293
|
-
resetOnSubmit:
|
|
294
|
-
scrollToFirstError:
|
|
509
|
+
var FormConfigSchema = z3.object({
|
|
510
|
+
formId: z3.string().min(1, "Form ID cannot be empty"),
|
|
511
|
+
resetOnSubmit: z3.boolean().optional().default(false),
|
|
512
|
+
scrollToFirstError: z3.boolean().optional().default(true),
|
|
295
513
|
validateOn: ValidateOnEventSchema.optional().default("blur"),
|
|
296
|
-
initialValues:
|
|
297
|
-
rules:
|
|
514
|
+
initialValues: z3.record(z3.string(), z3.unknown()).optional(),
|
|
515
|
+
rules: z3.array(ValidationRuleSchema).optional()
|
|
298
516
|
});
|
|
299
517
|
function isValidationRuleType(value) {
|
|
300
518
|
return ValidationRuleTypeSchema.safeParse(value).success;
|
|
@@ -314,56 +532,56 @@ function isFormConfig(value) {
|
|
|
314
532
|
|
|
315
533
|
// src/document.ts
|
|
316
534
|
var SCHEMA_NAME = "stora.page";
|
|
317
|
-
var CURRENT_SCHEMA_VERSION = "1.
|
|
318
|
-
var AssetReferenceSchema =
|
|
319
|
-
type:
|
|
320
|
-
assetId:
|
|
321
|
-
filename:
|
|
322
|
-
mimeType:
|
|
323
|
-
fallbackUrl:
|
|
535
|
+
var CURRENT_SCHEMA_VERSION = "1.1.0";
|
|
536
|
+
var AssetReferenceSchema = z4.object({
|
|
537
|
+
type: z4.literal("asset"),
|
|
538
|
+
assetId: z4.string().min(1, "Asset ID cannot be empty"),
|
|
539
|
+
filename: z4.string().optional(),
|
|
540
|
+
mimeType: z4.string().optional(),
|
|
541
|
+
fallbackUrl: z4.string().url().optional()
|
|
324
542
|
});
|
|
325
|
-
var VariableBindingSchema =
|
|
326
|
-
type:
|
|
327
|
-
key:
|
|
328
|
-
fallback:
|
|
543
|
+
var VariableBindingSchema = z4.object({
|
|
544
|
+
type: z4.literal("variable"),
|
|
545
|
+
key: z4.string().min(1, "Variable key cannot be empty"),
|
|
546
|
+
fallback: z4.unknown().optional()
|
|
329
547
|
});
|
|
330
|
-
var ActionBindingSchema =
|
|
331
|
-
type:
|
|
332
|
-
payload:
|
|
548
|
+
var ActionBindingSchema = z4.object({
|
|
549
|
+
type: z4.string().min(1, "Action type cannot be empty"),
|
|
550
|
+
payload: z4.record(z4.string(), z4.unknown()).optional()
|
|
333
551
|
});
|
|
334
552
|
var DANGEROUS_STYLE_VALUE_PATTERN = /javascript:|expression\(|@import|<script|vbscript:|data:text\/html/i;
|
|
335
|
-
var StyleValueSchema =
|
|
336
|
-
|
|
553
|
+
var StyleValueSchema = z4.union([
|
|
554
|
+
z4.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
337
555
|
message: "Style value contains a disallowed or unsafe pattern"
|
|
338
556
|
}),
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
557
|
+
z4.number(),
|
|
558
|
+
z4.boolean(),
|
|
559
|
+
z4.null(),
|
|
560
|
+
z4.undefined()
|
|
343
561
|
]);
|
|
344
|
-
var StyleDefinitionSchema =
|
|
345
|
-
var PseudoStateStylesSchema =
|
|
346
|
-
var ResponsiveStylesSchema =
|
|
562
|
+
var StyleDefinitionSchema = z4.record(z4.string(), StyleValueSchema);
|
|
563
|
+
var PseudoStateStylesSchema = z4.record(z4.string(), StyleDefinitionSchema);
|
|
564
|
+
var ResponsiveStylesSchema = z4.object({
|
|
347
565
|
base: StyleDefinitionSchema.optional(),
|
|
348
566
|
desktop: StyleDefinitionSchema.optional(),
|
|
349
567
|
tablet: StyleDefinitionSchema.optional(),
|
|
350
568
|
mobile: StyleDefinitionSchema.optional(),
|
|
351
569
|
states: PseudoStateStylesSchema.optional()
|
|
352
570
|
}).passthrough().default({});
|
|
353
|
-
var AnimationConfigSchema =
|
|
354
|
-
type:
|
|
571
|
+
var AnimationConfigSchema = z4.object({
|
|
572
|
+
type: z4.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
355
573
|
message: "Animation type contains a disallowed or unsafe pattern"
|
|
356
574
|
}).optional().default("none"),
|
|
357
|
-
duration:
|
|
358
|
-
delay:
|
|
359
|
-
easing:
|
|
575
|
+
duration: z4.number().min(0, "Duration must be non-negative").optional().default(600),
|
|
576
|
+
delay: z4.number().min(0, "Delay must be non-negative").optional().default(0),
|
|
577
|
+
easing: z4.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
360
578
|
message: "Animation easing contains a disallowed or unsafe pattern"
|
|
361
579
|
}).optional().default("ease-out"),
|
|
362
|
-
once:
|
|
363
|
-
hoverEffect:
|
|
580
|
+
once: z4.boolean().optional().default(true),
|
|
581
|
+
hoverEffect: z4.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
364
582
|
message: "Hover effect contains a disallowed or unsafe pattern"
|
|
365
583
|
}).optional().default("none"),
|
|
366
|
-
loopEffect:
|
|
584
|
+
loopEffect: z4.string().refine((value) => !DANGEROUS_STYLE_VALUE_PATTERN.test(value), {
|
|
367
585
|
message: "Loop effect contains a disallowed or unsafe pattern"
|
|
368
586
|
}).optional().default("none")
|
|
369
587
|
});
|
|
@@ -376,16 +594,16 @@ var DEFAULT_ANIMATION_CONFIG = {
|
|
|
376
594
|
hoverEffect: "none",
|
|
377
595
|
loopEffect: "none"
|
|
378
596
|
};
|
|
379
|
-
var NodeSchema =
|
|
380
|
-
() =>
|
|
381
|
-
id:
|
|
382
|
-
type:
|
|
383
|
-
props:
|
|
597
|
+
var NodeSchema = z4.lazy(
|
|
598
|
+
() => z4.object({
|
|
599
|
+
id: z4.string().min(1, "Node ID must be a non-empty string"),
|
|
600
|
+
type: z4.string().min(1, "Node type must be a non-empty string"),
|
|
601
|
+
props: z4.record(z4.string(), z4.unknown()).optional().default({}),
|
|
384
602
|
styles: ResponsiveStylesSchema.optional().default({}),
|
|
385
603
|
animation: AnimationConfigSchema.optional(),
|
|
386
|
-
actions:
|
|
604
|
+
actions: z4.array(ActionPipelineSchema).optional(),
|
|
387
605
|
formConfig: FormConfigSchema.optional(),
|
|
388
|
-
children:
|
|
606
|
+
children: z4.array(NodeSchema).optional().default([])
|
|
389
607
|
})
|
|
390
608
|
);
|
|
391
609
|
var RootPageNodeSchema = NodeSchema.refine(
|
|
@@ -395,61 +613,64 @@ var RootPageNodeSchema = NodeSchema.refine(
|
|
|
395
613
|
path: ["type"]
|
|
396
614
|
}
|
|
397
615
|
);
|
|
398
|
-
var DocumentMetadataSchema =
|
|
399
|
-
title:
|
|
400
|
-
description:
|
|
401
|
-
author:
|
|
402
|
-
createdAt:
|
|
403
|
-
updatedAt:
|
|
404
|
-
tags:
|
|
405
|
-
category:
|
|
406
|
-
version:
|
|
407
|
-
custom:
|
|
616
|
+
var DocumentMetadataSchema = z4.object({
|
|
617
|
+
title: z4.string().min(1, "Title is required").default("Untitled Page"),
|
|
618
|
+
description: z4.string().optional().default(""),
|
|
619
|
+
author: z4.string().optional().default(""),
|
|
620
|
+
createdAt: z4.string().optional(),
|
|
621
|
+
updatedAt: z4.string().optional(),
|
|
622
|
+
tags: z4.array(z4.string()).optional().default([]),
|
|
623
|
+
category: z4.string().optional().default("general"),
|
|
624
|
+
version: z4.string().optional().default("1.0.0"),
|
|
625
|
+
custom: z4.record(z4.string(), z4.unknown()).optional(),
|
|
626
|
+
tracking: TrackingConfigSchema.optional()
|
|
408
627
|
});
|
|
409
|
-
var PageDocumentSchema =
|
|
410
|
-
schema:
|
|
411
|
-
version:
|
|
628
|
+
var PageDocumentSchema = z4.object({
|
|
629
|
+
schema: z4.literal(SCHEMA_NAME),
|
|
630
|
+
version: z4.string().min(1, "Schema version is required").default(CURRENT_SCHEMA_VERSION),
|
|
412
631
|
metadata: DocumentMetadataSchema.optional(),
|
|
632
|
+
tracking: TrackingConfigSchema.optional(),
|
|
413
633
|
document: RootPageNodeSchema
|
|
414
634
|
});
|
|
415
635
|
var PROJECT_SCHEMA_NAME = "stora.project";
|
|
416
636
|
var CURRENT_PROJECT_SCHEMA_VERSION = "1.0.0";
|
|
417
637
|
var ARTBOARD_REFERENCE_NODE_TYPE = "artboard-reference";
|
|
418
|
-
var ArtboardTypeSchema =
|
|
419
|
-
var ArtboardSchema =
|
|
420
|
-
id:
|
|
421
|
-
name:
|
|
638
|
+
var ArtboardTypeSchema = z4.enum(["page", "component"]);
|
|
639
|
+
var ArtboardSchema = z4.object({
|
|
640
|
+
id: z4.string().min(1, "Artboard ID is required"),
|
|
641
|
+
name: z4.string().min(1, "Artboard name is required"),
|
|
422
642
|
artboardType: ArtboardTypeSchema,
|
|
423
643
|
/** Route for page artboards (e.g. "/about"). */
|
|
424
|
-
slug:
|
|
644
|
+
slug: z4.string().optional(),
|
|
425
645
|
/**
|
|
426
646
|
* For component artboards: the id that `open_modal` / `close_modal` actions target.
|
|
427
647
|
* Mirrors the detached node's own `props.modalId` so ModalManager keeps working unchanged.
|
|
428
648
|
*/
|
|
429
|
-
triggerId:
|
|
649
|
+
triggerId: z4.string().optional(),
|
|
430
650
|
/**
|
|
431
651
|
* Viewport/breakpoint this artboard is currently authored at. Declared inline
|
|
432
652
|
* (rather than imported) because viewport is otherwise an editor/renderer concept.
|
|
433
653
|
*/
|
|
434
|
-
viewport:
|
|
654
|
+
viewport: z4.enum(["desktop", "tablet", "mobile"]).optional(),
|
|
435
655
|
/** Persisted artboard width in px, matching the canvas ViewportResizer's `width`. */
|
|
436
|
-
width:
|
|
656
|
+
width: z4.number().positive().optional(),
|
|
437
657
|
/**
|
|
438
658
|
* Free position on the builder's infinite canvas, in unscaled canvas px. Absent means
|
|
439
659
|
* "not placed yet" — the canvas then falls back to laying the artboard out in a row.
|
|
440
660
|
*/
|
|
441
|
-
position:
|
|
442
|
-
x:
|
|
443
|
-
y:
|
|
661
|
+
position: z4.object({
|
|
662
|
+
x: z4.number(),
|
|
663
|
+
y: z4.number()
|
|
444
664
|
}).optional(),
|
|
445
665
|
document: PageDocumentSchema
|
|
446
666
|
});
|
|
447
|
-
var ProjectDocumentSchema =
|
|
448
|
-
schema:
|
|
449
|
-
version:
|
|
667
|
+
var ProjectDocumentSchema = z4.object({
|
|
668
|
+
schema: z4.literal(PROJECT_SCHEMA_NAME),
|
|
669
|
+
version: z4.string().min(1, "Schema version is required").default(CURRENT_PROJECT_SCHEMA_VERSION),
|
|
450
670
|
metadata: DocumentMetadataSchema.optional(),
|
|
451
|
-
|
|
452
|
-
|
|
671
|
+
tracking: TrackingConfigSchema.optional(),
|
|
672
|
+
artboards: z4.array(ArtboardSchema).min(1, "A project needs at least one artboard"),
|
|
673
|
+
activeArtboardId: z4.string().optional()
|
|
453
674
|
});
|
|
454
675
|
function isAssetReference(value) {
|
|
455
676
|
return AssetReferenceSchema.safeParse(value).success;
|
|
@@ -505,30 +726,30 @@ function validateNodeIdUniqueness(node) {
|
|
|
505
726
|
}
|
|
506
727
|
|
|
507
728
|
// src/manifest.ts
|
|
508
|
-
import { z as
|
|
509
|
-
var ManifestAssetItemSchema =
|
|
510
|
-
id:
|
|
511
|
-
path:
|
|
512
|
-
mimeType:
|
|
513
|
-
size:
|
|
514
|
-
checksum:
|
|
729
|
+
import { z as z5 } from "zod";
|
|
730
|
+
var ManifestAssetItemSchema = z5.object({
|
|
731
|
+
id: z5.string().min(1, "Asset ID cannot be empty"),
|
|
732
|
+
path: z5.string().min(1, "Asset archive path cannot be empty"),
|
|
733
|
+
mimeType: z5.string().min(1, "MIME type cannot be empty"),
|
|
734
|
+
size: z5.number().nonnegative("Asset size must be non-negative"),
|
|
735
|
+
checksum: z5.string().optional()
|
|
515
736
|
});
|
|
516
|
-
var ManifestSchema =
|
|
517
|
-
schema:
|
|
518
|
-
schemaVersion:
|
|
519
|
-
packageVersion:
|
|
520
|
-
builderCompatibility:
|
|
521
|
-
requiredComponents:
|
|
522
|
-
requiredCapabilities:
|
|
523
|
-
assets:
|
|
524
|
-
createdAt:
|
|
737
|
+
var ManifestSchema = z5.object({
|
|
738
|
+
schema: z5.literal(SCHEMA_NAME).default(SCHEMA_NAME),
|
|
739
|
+
schemaVersion: z5.string().min(1, "Schema version cannot be empty").default("1.0.0"),
|
|
740
|
+
packageVersion: z5.string().min(1, "Package version cannot be empty").default("1.0.0"),
|
|
741
|
+
builderCompatibility: z5.string().default(">=0.1.0"),
|
|
742
|
+
requiredComponents: z5.array(z5.string()).default([]),
|
|
743
|
+
requiredCapabilities: z5.array(z5.string()).default([]),
|
|
744
|
+
assets: z5.array(ManifestAssetItemSchema).default([]),
|
|
745
|
+
createdAt: z5.string().optional()
|
|
525
746
|
});
|
|
526
747
|
function isManifest(value) {
|
|
527
748
|
return ManifestSchema.safeParse(value).success;
|
|
528
749
|
}
|
|
529
750
|
|
|
530
751
|
// src/template.ts
|
|
531
|
-
import { z as
|
|
752
|
+
import { z as z6 } from "zod";
|
|
532
753
|
var DANGEROUS_URI_PATTERN = /^(javascript:|vbscript:|data:(?!image\/))|<script/i;
|
|
533
754
|
function isSafeThumbnailUrl(url) {
|
|
534
755
|
if (!url || typeof url !== "string") return false;
|
|
@@ -537,49 +758,49 @@ function isSafeThumbnailUrl(url) {
|
|
|
537
758
|
if (DANGEROUS_URI_PATTERN.test(trimmed)) return false;
|
|
538
759
|
return true;
|
|
539
760
|
}
|
|
540
|
-
var SafeThumbnailUrlSchema =
|
|
761
|
+
var SafeThumbnailUrlSchema = z6.string().min(1, "Thumbnail URL cannot be empty").refine(
|
|
541
762
|
(url) => isSafeThumbnailUrl(url),
|
|
542
763
|
{ message: "Thumbnail URL contains an unsafe protocol or payload" }
|
|
543
764
|
);
|
|
544
|
-
var SafeThumbnailObjectSchema =
|
|
765
|
+
var SafeThumbnailObjectSchema = z6.object({
|
|
545
766
|
url: SafeThumbnailUrlSchema,
|
|
546
|
-
alt:
|
|
547
|
-
width:
|
|
548
|
-
height:
|
|
767
|
+
alt: z6.string().optional(),
|
|
768
|
+
width: z6.number().positive().optional(),
|
|
769
|
+
height: z6.number().positive().optional()
|
|
549
770
|
});
|
|
550
|
-
var SafeThumbnailSchema =
|
|
771
|
+
var SafeThumbnailSchema = z6.union([
|
|
551
772
|
AssetReferenceSchema,
|
|
552
773
|
SafeThumbnailObjectSchema,
|
|
553
774
|
SafeThumbnailUrlSchema
|
|
554
775
|
]);
|
|
555
|
-
var TemplatePackageRefSchema =
|
|
556
|
-
path:
|
|
776
|
+
var TemplatePackageRefSchema = z6.object({
|
|
777
|
+
path: z6.string().optional(),
|
|
557
778
|
url: SafeThumbnailUrlSchema.optional(),
|
|
558
|
-
checksum:
|
|
559
|
-
format:
|
|
779
|
+
checksum: z6.string().optional(),
|
|
780
|
+
format: z6.enum(["stora", "json"]).default("stora")
|
|
560
781
|
});
|
|
561
|
-
var TemplateRequirementsSchema =
|
|
562
|
-
requiredComponents:
|
|
563
|
-
requiredCapabilities:
|
|
782
|
+
var TemplateRequirementsSchema = z6.object({
|
|
783
|
+
requiredComponents: z6.array(z6.string()).default([]),
|
|
784
|
+
requiredCapabilities: z6.array(z6.string()).default([])
|
|
564
785
|
});
|
|
565
|
-
var TemplateRecordSchema =
|
|
566
|
-
id:
|
|
567
|
-
name:
|
|
568
|
-
description:
|
|
569
|
-
category:
|
|
570
|
-
tags:
|
|
786
|
+
var TemplateRecordSchema = z6.object({
|
|
787
|
+
id: z6.string().min(1, "Template ID must be a non-empty string"),
|
|
788
|
+
name: z6.string().min(1, "Template name must be a non-empty string"),
|
|
789
|
+
description: z6.string().optional().default(""),
|
|
790
|
+
category: z6.string().optional().default("general"),
|
|
791
|
+
tags: z6.array(z6.string()).optional().default([]),
|
|
571
792
|
thumbnail: SafeThumbnailSchema.optional(),
|
|
572
|
-
author:
|
|
573
|
-
version:
|
|
793
|
+
author: z6.string().optional().default(""),
|
|
794
|
+
version: z6.string().optional().default("1.0.0"),
|
|
574
795
|
document: PageDocumentSchema.optional(),
|
|
575
796
|
packageReference: TemplatePackageRefSchema.optional(),
|
|
576
797
|
requirements: TemplateRequirementsSchema.default({
|
|
577
798
|
requiredComponents: [],
|
|
578
799
|
requiredCapabilities: []
|
|
579
800
|
}),
|
|
580
|
-
createdAt:
|
|
581
|
-
updatedAt:
|
|
582
|
-
custom:
|
|
801
|
+
createdAt: z6.string().optional(),
|
|
802
|
+
updatedAt: z6.string().optional(),
|
|
803
|
+
custom: z6.record(z6.string(), z6.unknown()).optional()
|
|
583
804
|
});
|
|
584
805
|
function isTemplateRecord(value) {
|
|
585
806
|
return TemplateRecordSchema.safeParse(value).success;
|
|
@@ -591,7 +812,7 @@ function isSafeThumbnail(value) {
|
|
|
591
812
|
// src/fixtures/starter-page.json
|
|
592
813
|
var starter_page_default = {
|
|
593
814
|
schema: "stora.page",
|
|
594
|
-
version: "1.
|
|
815
|
+
version: "1.1.0",
|
|
595
816
|
metadata: {
|
|
596
817
|
title: "Welcome to KUBUILD",
|
|
597
818
|
description: "A starter template built with KUBUILD portable web builder",
|
|
@@ -750,6 +971,7 @@ var starter_page_default = {
|
|
|
750
971
|
var starterPageFixture = starter_page_default;
|
|
751
972
|
|
|
752
973
|
// src/json-schema.ts
|
|
974
|
+
import { z as z7 } from "zod";
|
|
753
975
|
var PAGE_DOCUMENT_JSON_SCHEMA_V1 = {
|
|
754
976
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
755
977
|
$id: "https://schema.stora.page/v1/page.json",
|
|
@@ -768,16 +990,84 @@ var PAGE_DOCUMENT_JSON_SCHEMA_V1 = {
|
|
|
768
990
|
type: "string",
|
|
769
991
|
pattern: "^\\d+(\\.\\d+)*$",
|
|
770
992
|
description: "Schema version of the document",
|
|
771
|
-
default: "1.
|
|
993
|
+
default: "1.1.0"
|
|
772
994
|
},
|
|
773
995
|
metadata: {
|
|
774
996
|
$ref: "#/definitions/documentMetadata"
|
|
775
997
|
},
|
|
776
998
|
document: {
|
|
777
999
|
$ref: "#/definitions/rootPageNode"
|
|
1000
|
+
},
|
|
1001
|
+
tracking: {
|
|
1002
|
+
$ref: "#/definitions/trackingConfig"
|
|
778
1003
|
}
|
|
779
1004
|
},
|
|
780
1005
|
definitions: {
|
|
1006
|
+
trackingConfig: {
|
|
1007
|
+
type: "object",
|
|
1008
|
+
description: "Tracking configuration. Contains only public ids, flags and opaque credential ids \u2014 secrets are host-owned.",
|
|
1009
|
+
properties: {
|
|
1010
|
+
enabled: { type: "boolean", default: true },
|
|
1011
|
+
debugMode: { type: "boolean", default: false },
|
|
1012
|
+
autoPageView: { type: "boolean", default: true },
|
|
1013
|
+
defaultDelivery: { type: "string", enum: ["both", "client_only", "server_only"], default: "both" },
|
|
1014
|
+
providers: {
|
|
1015
|
+
type: "object",
|
|
1016
|
+
properties: {
|
|
1017
|
+
meta: {
|
|
1018
|
+
type: "object",
|
|
1019
|
+
properties: {
|
|
1020
|
+
enabled: { type: "boolean" },
|
|
1021
|
+
credentialId: { type: "string" },
|
|
1022
|
+
pixelId: { type: "string" },
|
|
1023
|
+
capiEnabled: { type: "boolean" },
|
|
1024
|
+
testEventCode: { type: "string" }
|
|
1025
|
+
},
|
|
1026
|
+
additionalProperties: false
|
|
1027
|
+
},
|
|
1028
|
+
google: {
|
|
1029
|
+
type: "object",
|
|
1030
|
+
properties: {
|
|
1031
|
+
enabled: { type: "boolean" },
|
|
1032
|
+
credentialId: { type: "string" },
|
|
1033
|
+
measurementId: { type: "string" }
|
|
1034
|
+
},
|
|
1035
|
+
additionalProperties: false
|
|
1036
|
+
},
|
|
1037
|
+
gtm: {
|
|
1038
|
+
type: "object",
|
|
1039
|
+
properties: {
|
|
1040
|
+
enabled: { type: "boolean" },
|
|
1041
|
+
credentialId: { type: "string" },
|
|
1042
|
+
containerId: { type: "string" }
|
|
1043
|
+
},
|
|
1044
|
+
additionalProperties: false
|
|
1045
|
+
},
|
|
1046
|
+
tiktok: {
|
|
1047
|
+
type: "object",
|
|
1048
|
+
properties: {
|
|
1049
|
+
enabled: { type: "boolean" },
|
|
1050
|
+
credentialId: { type: "string" },
|
|
1051
|
+
pixelId: { type: "string" },
|
|
1052
|
+
eventsApiEnabled: { type: "boolean" },
|
|
1053
|
+
testEventCode: { type: "string" }
|
|
1054
|
+
},
|
|
1055
|
+
additionalProperties: false
|
|
1056
|
+
},
|
|
1057
|
+
custom: {
|
|
1058
|
+
type: "object",
|
|
1059
|
+
properties: {
|
|
1060
|
+
enabled: { type: "boolean" },
|
|
1061
|
+
credentialId: { type: "string" }
|
|
1062
|
+
},
|
|
1063
|
+
additionalProperties: false
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
additionalProperties: false
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
additionalProperties: false
|
|
1070
|
+
},
|
|
781
1071
|
styleValue: {
|
|
782
1072
|
type: ["string", "number", "boolean", "null"],
|
|
783
1073
|
description: "A CSS property or design token value"
|
|
@@ -917,8 +1207,10 @@ var PAGE_DOCUMENT_JSON_SCHEMA_V1 = {
|
|
|
917
1207
|
"show_toast",
|
|
918
1208
|
"open_modal",
|
|
919
1209
|
"close_modal",
|
|
1210
|
+
"toggle_modal",
|
|
920
1211
|
"copy_clipboard",
|
|
921
|
-
"custom_event"
|
|
1212
|
+
"custom_event",
|
|
1213
|
+
"track_event"
|
|
922
1214
|
]
|
|
923
1215
|
},
|
|
924
1216
|
label: { type: "string" },
|
|
@@ -1439,8 +1731,10 @@ var ACTION_PIPELINE_JSON_SCHEMA_V1 = {
|
|
|
1439
1731
|
"show_toast",
|
|
1440
1732
|
"open_modal",
|
|
1441
1733
|
"close_modal",
|
|
1734
|
+
"toggle_modal",
|
|
1442
1735
|
"copy_clipboard",
|
|
1443
|
-
"custom_event"
|
|
1736
|
+
"custom_event",
|
|
1737
|
+
"track_event"
|
|
1444
1738
|
]
|
|
1445
1739
|
},
|
|
1446
1740
|
label: { type: "string" },
|
|
@@ -1607,6 +1901,48 @@ var FORM_FIELD_BINDING_JSON_SCHEMA_V1 = {
|
|
|
1607
1901
|
function getFormFieldBindingJsonSchema() {
|
|
1608
1902
|
return FORM_FIELD_BINDING_JSON_SCHEMA_V1;
|
|
1609
1903
|
}
|
|
1904
|
+
function toDraft7(schema, id, title, io) {
|
|
1905
|
+
return {
|
|
1906
|
+
...z7.toJSONSchema(schema, { target: "draft-7", io }),
|
|
1907
|
+
$id: id,
|
|
1908
|
+
title
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
var trackingRelayRequestJsonSchema;
|
|
1912
|
+
var trackingRelayResponseJsonSchema;
|
|
1913
|
+
var trackingProviderSecretsJsonSchema;
|
|
1914
|
+
function getTrackingRelayRequestJsonSchema() {
|
|
1915
|
+
trackingRelayRequestJsonSchema ??= toDraft7(
|
|
1916
|
+
TrackingRelayRequestSchema,
|
|
1917
|
+
"https://schema.stora.page/v1/tracking-relay-request.json",
|
|
1918
|
+
"StoraTrackingRelayRequest",
|
|
1919
|
+
"input"
|
|
1920
|
+
);
|
|
1921
|
+
return trackingRelayRequestJsonSchema;
|
|
1922
|
+
}
|
|
1923
|
+
function getTrackingRelayResponseJsonSchema() {
|
|
1924
|
+
trackingRelayResponseJsonSchema ??= toDraft7(
|
|
1925
|
+
TrackingRelayResponseSchema,
|
|
1926
|
+
"https://schema.stora.page/v1/tracking-relay-response.json",
|
|
1927
|
+
"StoraTrackingRelayResponse",
|
|
1928
|
+
"output"
|
|
1929
|
+
);
|
|
1930
|
+
return trackingRelayResponseJsonSchema;
|
|
1931
|
+
}
|
|
1932
|
+
function getTrackingProviderSecretsJsonSchema() {
|
|
1933
|
+
trackingProviderSecretsJsonSchema ??= toDraft7(
|
|
1934
|
+
z7.object({
|
|
1935
|
+
meta: MetaTrackingSecretsSchema.optional(),
|
|
1936
|
+
google: GoogleTrackingSecretsSchema.optional(),
|
|
1937
|
+
tiktok: TikTokTrackingSecretsSchema.optional(),
|
|
1938
|
+
custom: CustomTrackingSecretsSchema.optional()
|
|
1939
|
+
}),
|
|
1940
|
+
"https://schema.stora.page/v1/tracking-provider-secrets.json",
|
|
1941
|
+
"StoraTrackingProviderSecrets",
|
|
1942
|
+
"input"
|
|
1943
|
+
);
|
|
1944
|
+
return trackingProviderSecretsJsonSchema;
|
|
1945
|
+
}
|
|
1610
1946
|
export {
|
|
1611
1947
|
ACTION_PIPELINE_JSON_SCHEMA_V1,
|
|
1612
1948
|
ARTBOARD_REFERENCE_NODE_TYPE,
|
|
@@ -1628,15 +1964,23 @@ export {
|
|
|
1628
1964
|
ConditionOperatorSchema,
|
|
1629
1965
|
CopyClipboardStepPayloadSchema,
|
|
1630
1966
|
CustomEventStepPayloadSchema,
|
|
1967
|
+
CustomTrackingProviderConfigSchema,
|
|
1968
|
+
CustomTrackingSecretsSchema,
|
|
1631
1969
|
DEFAULT_ANIMATION_CONFIG,
|
|
1632
1970
|
DocumentMetadataSchema,
|
|
1633
1971
|
FORM_CONFIG_JSON_SCHEMA_V1,
|
|
1634
1972
|
FORM_FIELD_BINDING_JSON_SCHEMA_V1,
|
|
1635
1973
|
FormConfigSchema,
|
|
1636
1974
|
FormFieldBindingSchema,
|
|
1975
|
+
GoogleTrackingProviderConfigSchema,
|
|
1976
|
+
GoogleTrackingSecretsSchema,
|
|
1977
|
+
GtmTrackingProviderConfigSchema,
|
|
1978
|
+
LEGACY_TRACKING_SECRET_KEYS,
|
|
1637
1979
|
MANIFEST_JSON_SCHEMA_V1,
|
|
1638
1980
|
ManifestAssetItemSchema,
|
|
1639
1981
|
ManifestSchema,
|
|
1982
|
+
MetaTrackingProviderConfigSchema,
|
|
1983
|
+
MetaTrackingSecretsSchema,
|
|
1640
1984
|
NavigateStepPayloadSchema,
|
|
1641
1985
|
NodeSchema,
|
|
1642
1986
|
OpenModalStepPayloadSchema,
|
|
@@ -1652,15 +1996,30 @@ export {
|
|
|
1652
1996
|
SafeThumbnailObjectSchema,
|
|
1653
1997
|
SafeThumbnailSchema,
|
|
1654
1998
|
SafeThumbnailUrlSchema,
|
|
1999
|
+
ServerTrackingEventSchema,
|
|
1655
2000
|
SetStateStepPayloadSchema,
|
|
1656
2001
|
ShowToastStepPayloadSchema,
|
|
2002
|
+
StandardTrackingEventSchema,
|
|
1657
2003
|
StepPayloadSchemas,
|
|
1658
2004
|
StyleDefinitionSchema,
|
|
1659
2005
|
StyleValueSchema,
|
|
1660
2006
|
TEMPLATE_RECORD_JSON_SCHEMA_V1,
|
|
2007
|
+
TRACKING_RELAY_PROTOCOL_VERSION,
|
|
1661
2008
|
TemplatePackageRefSchema,
|
|
1662
2009
|
TemplateRecordSchema,
|
|
1663
2010
|
TemplateRequirementsSchema,
|
|
2011
|
+
TikTokTrackingProviderConfigSchema,
|
|
2012
|
+
TikTokTrackingSecretsSchema,
|
|
2013
|
+
ToggleModalStepPayloadSchema,
|
|
2014
|
+
TrackEventProviderSchema,
|
|
2015
|
+
TrackEventStepPayloadSchema,
|
|
2016
|
+
TrackingConfigSchema,
|
|
2017
|
+
TrackingDeliverySchema,
|
|
2018
|
+
TrackingProviderTypeSchema,
|
|
2019
|
+
TrackingRelayErrorCodeSchema,
|
|
2020
|
+
TrackingRelayProviderResultSchema,
|
|
2021
|
+
TrackingRelayRequestSchema,
|
|
2022
|
+
TrackingRelayResponseSchema,
|
|
1664
2023
|
ValidateOnEventSchema,
|
|
1665
2024
|
ValidationRuleSchema,
|
|
1666
2025
|
ValidationRuleTypeSchema,
|
|
@@ -1673,6 +2032,9 @@ export {
|
|
|
1673
2032
|
getManifestJsonSchema,
|
|
1674
2033
|
getPageDocumentJsonSchema,
|
|
1675
2034
|
getTemplateRecordJsonSchema,
|
|
2035
|
+
getTrackingProviderSecretsJsonSchema,
|
|
2036
|
+
getTrackingRelayRequestJsonSchema,
|
|
2037
|
+
getTrackingRelayResponseJsonSchema,
|
|
1676
2038
|
isActionBinding,
|
|
1677
2039
|
isActionPipeline,
|
|
1678
2040
|
isActionStep,
|
|
@@ -1691,6 +2053,9 @@ export {
|
|
|
1691
2053
|
isSafeThumbnail,
|
|
1692
2054
|
isSafeThumbnailUrl,
|
|
1693
2055
|
isTemplateRecord,
|
|
2056
|
+
isTrackEventStepPayload,
|
|
2057
|
+
isTrackingConfig,
|
|
2058
|
+
isTrackingRelayRequest,
|
|
1694
2059
|
isValidateOnEvent,
|
|
1695
2060
|
isValidationRule,
|
|
1696
2061
|
isValidationRuleType,
|