@kubuild/schema 0.2.0 → 0.3.1
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 +2 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/document.d.ts +196 -8
- package/dist/document.d.ts.map +1 -1
- package/dist/index.cjs +70 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -92,7 +92,8 @@ var ShowToastStepPayloadSchema = z.object({
|
|
|
92
92
|
});
|
|
93
93
|
var OpenModalStepPayloadSchema = z.object({
|
|
94
94
|
modalId: z.string().optional(),
|
|
95
|
-
modalNodeId: z.string().optional()
|
|
95
|
+
modalNodeId: z.string().optional(),
|
|
96
|
+
toggle: z.boolean().optional()
|
|
96
97
|
}).refine((data) => Boolean(data.modalId || data.modalNodeId), {
|
|
97
98
|
message: "Modal ID or Modal Node ID cannot be empty"
|
|
98
99
|
});
|
|
@@ -411,6 +412,45 @@ var PageDocumentSchema = z3.object({
|
|
|
411
412
|
metadata: DocumentMetadataSchema.optional(),
|
|
412
413
|
document: RootPageNodeSchema
|
|
413
414
|
});
|
|
415
|
+
var PROJECT_SCHEMA_NAME = "stora.project";
|
|
416
|
+
var CURRENT_PROJECT_SCHEMA_VERSION = "1.0.0";
|
|
417
|
+
var ARTBOARD_REFERENCE_NODE_TYPE = "artboard-reference";
|
|
418
|
+
var ArtboardTypeSchema = z3.enum(["page", "component"]);
|
|
419
|
+
var ArtboardSchema = z3.object({
|
|
420
|
+
id: z3.string().min(1, "Artboard ID is required"),
|
|
421
|
+
name: z3.string().min(1, "Artboard name is required"),
|
|
422
|
+
artboardType: ArtboardTypeSchema,
|
|
423
|
+
/** Route for page artboards (e.g. "/about"). */
|
|
424
|
+
slug: z3.string().optional(),
|
|
425
|
+
/**
|
|
426
|
+
* For component artboards: the id that `open_modal` / `close_modal` actions target.
|
|
427
|
+
* Mirrors the detached node's own `props.modalId` so ModalManager keeps working unchanged.
|
|
428
|
+
*/
|
|
429
|
+
triggerId: z3.string().optional(),
|
|
430
|
+
/**
|
|
431
|
+
* Viewport/breakpoint this artboard is currently authored at. Declared inline
|
|
432
|
+
* (rather than imported) because viewport is otherwise an editor/renderer concept.
|
|
433
|
+
*/
|
|
434
|
+
viewport: z3.enum(["desktop", "tablet", "mobile"]).optional(),
|
|
435
|
+
/** Persisted artboard width in px, matching the canvas ViewportResizer's `width`. */
|
|
436
|
+
width: z3.number().positive().optional(),
|
|
437
|
+
/**
|
|
438
|
+
* Free position on the builder's infinite canvas, in unscaled canvas px. Absent means
|
|
439
|
+
* "not placed yet" — the canvas then falls back to laying the artboard out in a row.
|
|
440
|
+
*/
|
|
441
|
+
position: z3.object({
|
|
442
|
+
x: z3.number(),
|
|
443
|
+
y: z3.number()
|
|
444
|
+
}).optional(),
|
|
445
|
+
document: PageDocumentSchema
|
|
446
|
+
});
|
|
447
|
+
var ProjectDocumentSchema = z3.object({
|
|
448
|
+
schema: z3.literal(PROJECT_SCHEMA_NAME),
|
|
449
|
+
version: z3.string().min(1, "Schema version is required").default(CURRENT_PROJECT_SCHEMA_VERSION),
|
|
450
|
+
metadata: DocumentMetadataSchema.optional(),
|
|
451
|
+
artboards: z3.array(ArtboardSchema).min(1, "A project needs at least one artboard"),
|
|
452
|
+
activeArtboardId: z3.string().optional()
|
|
453
|
+
});
|
|
414
454
|
function isAssetReference(value) {
|
|
415
455
|
return AssetReferenceSchema.safeParse(value).success;
|
|
416
456
|
}
|
|
@@ -423,6 +463,17 @@ function isActionBinding(value) {
|
|
|
423
463
|
function isAnimationConfig(value) {
|
|
424
464
|
return AnimationConfigSchema.safeParse(value).success;
|
|
425
465
|
}
|
|
466
|
+
function isProjectDocument(value) {
|
|
467
|
+
return ProjectDocumentSchema.safeParse(value).success;
|
|
468
|
+
}
|
|
469
|
+
function looksLikeProjectDocument(value) {
|
|
470
|
+
if (typeof value !== "object" || value === null) return false;
|
|
471
|
+
const candidate = value;
|
|
472
|
+
return candidate.schema === PROJECT_SCHEMA_NAME || Array.isArray(candidate.artboards);
|
|
473
|
+
}
|
|
474
|
+
function isArtboardReferenceNode(node) {
|
|
475
|
+
return node.type === ARTBOARD_REFERENCE_NODE_TYPE;
|
|
476
|
+
}
|
|
426
477
|
function generateDeterministicNodeId(prefix, indexOrKey) {
|
|
427
478
|
const cleanPrefix = prefix.toLowerCase().replace(/[^a-z0-9_-]/g, "-");
|
|
428
479
|
return `${cleanPrefix}_${indexOrKey}`;
|
|
@@ -1558,6 +1609,7 @@ function getFormFieldBindingJsonSchema() {
|
|
|
1558
1609
|
}
|
|
1559
1610
|
export {
|
|
1560
1611
|
ACTION_PIPELINE_JSON_SCHEMA_V1,
|
|
1612
|
+
ARTBOARD_REFERENCE_NODE_TYPE,
|
|
1561
1613
|
ActionBindingSchema,
|
|
1562
1614
|
ActionPipelineSchema,
|
|
1563
1615
|
ActionStepConditionSchema,
|
|
@@ -1567,7 +1619,10 @@ export {
|
|
|
1567
1619
|
ActionTriggerTypeSchema,
|
|
1568
1620
|
AnimationConfigSchema,
|
|
1569
1621
|
ApiRequestStepPayloadSchema,
|
|
1622
|
+
ArtboardSchema,
|
|
1623
|
+
ArtboardTypeSchema,
|
|
1570
1624
|
AssetReferenceSchema,
|
|
1625
|
+
CURRENT_PROJECT_SCHEMA_VERSION,
|
|
1571
1626
|
CURRENT_SCHEMA_VERSION,
|
|
1572
1627
|
CloseModalStepPayloadSchema,
|
|
1573
1628
|
ConditionOperatorSchema,
|
|
@@ -1586,7 +1641,9 @@ export {
|
|
|
1586
1641
|
NodeSchema,
|
|
1587
1642
|
OpenModalStepPayloadSchema,
|
|
1588
1643
|
PAGE_DOCUMENT_JSON_SCHEMA_V1,
|
|
1644
|
+
PROJECT_SCHEMA_NAME,
|
|
1589
1645
|
PageDocumentSchema,
|
|
1646
|
+
ProjectDocumentSchema,
|
|
1590
1647
|
PseudoStateStylesSchema,
|
|
1591
1648
|
ResetFormStepPayloadSchema,
|
|
1592
1649
|
ResponsiveStylesSchema,
|
|
@@ -1623,11 +1680,13 @@ export {
|
|
|
1623
1680
|
isActionStepType,
|
|
1624
1681
|
isActionTriggerType,
|
|
1625
1682
|
isAnimationConfig,
|
|
1683
|
+
isArtboardReferenceNode,
|
|
1626
1684
|
isAssetReference,
|
|
1627
1685
|
isConditionOperator,
|
|
1628
1686
|
isFormConfig,
|
|
1629
1687
|
isFormFieldBinding,
|
|
1630
1688
|
isManifest,
|
|
1689
|
+
isProjectDocument,
|
|
1631
1690
|
isSafeActionUrl,
|
|
1632
1691
|
isSafeThumbnail,
|
|
1633
1692
|
isSafeThumbnailUrl,
|
|
@@ -1636,6 +1695,7 @@ export {
|
|
|
1636
1695
|
isValidationRule,
|
|
1637
1696
|
isValidationRuleType,
|
|
1638
1697
|
isVariableBinding,
|
|
1698
|
+
looksLikeProjectDocument,
|
|
1639
1699
|
sanitizeActionPayload,
|
|
1640
1700
|
sanitizeActionPipeline,
|
|
1641
1701
|
sanitizeActionStep,
|