@kubuild/schema 0.7.0 → 0.8.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/README.md +24 -0
- package/dist/actions.d.ts +5 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/breakpoints.d.ts +35 -0
- package/dist/breakpoints.d.ts.map +1 -0
- package/dist/builtin-components.d.ts +17 -0
- package/dist/builtin-components.d.ts.map +1 -0
- package/dist/canonical-props.d.ts +39 -0
- package/dist/canonical-props.d.ts.map +1 -0
- package/dist/chunk-MT3M7D67.js +1041 -0
- package/dist/chunk-MT3M7D67.js.map +1 -0
- package/dist/chunk-PECTZDCI.js +1038 -0
- package/dist/chunk-PECTZDCI.js.map +1 -0
- package/dist/document.d.ts +21 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/index.cjs +437 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +316 -819
- package/dist/index.js.map +1 -1
- package/dist/json-schema.d.ts +74 -6
- package/dist/json-schema.d.ts.map +1 -1
- package/dist/template.d.ts +6 -0
- package/dist/template.d.ts.map +1 -1
- package/dist/theme.d.ts +80 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/types.cjs +19 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +331 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/validate.cjs +715 -0
- package/dist/validate.cjs.map +1 -0
- package/dist/validate.d.ts +16 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +53 -0
- package/dist/validate.js.map +1 -0
- package/package.json +22 -2
package/dist/json-schema.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare const PAGE_DOCUMENT_JSON_SCHEMA_V1: {
|
|
|
20
20
|
readonly type: "string";
|
|
21
21
|
readonly pattern: "^\\d+(\\.\\d+)*$";
|
|
22
22
|
readonly description: "Schema version of the document";
|
|
23
|
-
readonly default: "1.
|
|
23
|
+
readonly default: "1.2.0";
|
|
24
24
|
};
|
|
25
25
|
readonly metadata: {
|
|
26
26
|
readonly $ref: "#/definitions/documentMetadata";
|
|
@@ -31,8 +31,42 @@ export declare const PAGE_DOCUMENT_JSON_SCHEMA_V1: {
|
|
|
31
31
|
readonly tracking: {
|
|
32
32
|
readonly $ref: "#/definitions/trackingConfig";
|
|
33
33
|
};
|
|
34
|
+
readonly theme: {
|
|
35
|
+
readonly $ref: "#/definitions/theme";
|
|
36
|
+
};
|
|
34
37
|
};
|
|
35
38
|
readonly definitions: {
|
|
39
|
+
readonly themeTokenMap: {
|
|
40
|
+
readonly type: "object";
|
|
41
|
+
readonly propertyNames: {
|
|
42
|
+
readonly pattern: "^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$";
|
|
43
|
+
};
|
|
44
|
+
readonly additionalProperties: {
|
|
45
|
+
readonly type: readonly ["string", "number"];
|
|
46
|
+
readonly maxLength: 512;
|
|
47
|
+
readonly pattern: "^[^;{}<>\\\\]*$";
|
|
48
|
+
};
|
|
49
|
+
readonly description: "Design tokens keyed by name. Values must not contain ; { } < > or backslashes.";
|
|
50
|
+
};
|
|
51
|
+
readonly theme: {
|
|
52
|
+
readonly type: "object";
|
|
53
|
+
readonly description: "Document design tokens, emitted as CSS custom properties (--kb-color-*, --kb-font-*, --kb-radius-*, --kb-space-*) and referenced from styles as var(--kb-color-<key>).";
|
|
54
|
+
readonly properties: {
|
|
55
|
+
readonly colors: {
|
|
56
|
+
readonly $ref: "#/definitions/themeTokenMap";
|
|
57
|
+
};
|
|
58
|
+
readonly fonts: {
|
|
59
|
+
readonly $ref: "#/definitions/themeTokenMap";
|
|
60
|
+
};
|
|
61
|
+
readonly radii: {
|
|
62
|
+
readonly $ref: "#/definitions/themeTokenMap";
|
|
63
|
+
};
|
|
64
|
+
readonly spacing: {
|
|
65
|
+
readonly $ref: "#/definitions/themeTokenMap";
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
readonly additionalProperties: false;
|
|
69
|
+
};
|
|
36
70
|
readonly trackingConfig: {
|
|
37
71
|
readonly type: "object";
|
|
38
72
|
readonly description: "Tracking configuration. Contains only public ids, flags and opaque credential ids — secrets are host-owned.";
|
|
@@ -342,7 +376,7 @@ export declare const PAGE_DOCUMENT_JSON_SCHEMA_V1: {
|
|
|
342
376
|
};
|
|
343
377
|
readonly trigger: {
|
|
344
378
|
readonly type: "string";
|
|
345
|
-
readonly enum: readonly ["click", "submit", "change", "blur", "focus", "load"];
|
|
379
|
+
readonly enum: readonly ["click", "submit", "change", "blur", "focus", "load", "expire"];
|
|
346
380
|
};
|
|
347
381
|
readonly label: {
|
|
348
382
|
readonly type: "string";
|
|
@@ -521,7 +555,7 @@ export declare function getPageDocumentJsonSchema(): {
|
|
|
521
555
|
readonly type: "string";
|
|
522
556
|
readonly pattern: "^\\d+(\\.\\d+)*$";
|
|
523
557
|
readonly description: "Schema version of the document";
|
|
524
|
-
readonly default: "1.
|
|
558
|
+
readonly default: "1.2.0";
|
|
525
559
|
};
|
|
526
560
|
readonly metadata: {
|
|
527
561
|
readonly $ref: "#/definitions/documentMetadata";
|
|
@@ -532,8 +566,42 @@ export declare function getPageDocumentJsonSchema(): {
|
|
|
532
566
|
readonly tracking: {
|
|
533
567
|
readonly $ref: "#/definitions/trackingConfig";
|
|
534
568
|
};
|
|
569
|
+
readonly theme: {
|
|
570
|
+
readonly $ref: "#/definitions/theme";
|
|
571
|
+
};
|
|
535
572
|
};
|
|
536
573
|
readonly definitions: {
|
|
574
|
+
readonly themeTokenMap: {
|
|
575
|
+
readonly type: "object";
|
|
576
|
+
readonly propertyNames: {
|
|
577
|
+
readonly pattern: "^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$";
|
|
578
|
+
};
|
|
579
|
+
readonly additionalProperties: {
|
|
580
|
+
readonly type: readonly ["string", "number"];
|
|
581
|
+
readonly maxLength: 512;
|
|
582
|
+
readonly pattern: "^[^;{}<>\\\\]*$";
|
|
583
|
+
};
|
|
584
|
+
readonly description: "Design tokens keyed by name. Values must not contain ; { } < > or backslashes.";
|
|
585
|
+
};
|
|
586
|
+
readonly theme: {
|
|
587
|
+
readonly type: "object";
|
|
588
|
+
readonly description: "Document design tokens, emitted as CSS custom properties (--kb-color-*, --kb-font-*, --kb-radius-*, --kb-space-*) and referenced from styles as var(--kb-color-<key>).";
|
|
589
|
+
readonly properties: {
|
|
590
|
+
readonly colors: {
|
|
591
|
+
readonly $ref: "#/definitions/themeTokenMap";
|
|
592
|
+
};
|
|
593
|
+
readonly fonts: {
|
|
594
|
+
readonly $ref: "#/definitions/themeTokenMap";
|
|
595
|
+
};
|
|
596
|
+
readonly radii: {
|
|
597
|
+
readonly $ref: "#/definitions/themeTokenMap";
|
|
598
|
+
};
|
|
599
|
+
readonly spacing: {
|
|
600
|
+
readonly $ref: "#/definitions/themeTokenMap";
|
|
601
|
+
};
|
|
602
|
+
};
|
|
603
|
+
readonly additionalProperties: false;
|
|
604
|
+
};
|
|
537
605
|
readonly trackingConfig: {
|
|
538
606
|
readonly type: "object";
|
|
539
607
|
readonly description: "Tracking configuration. Contains only public ids, flags and opaque credential ids — secrets are host-owned.";
|
|
@@ -843,7 +911,7 @@ export declare function getPageDocumentJsonSchema(): {
|
|
|
843
911
|
};
|
|
844
912
|
readonly trigger: {
|
|
845
913
|
readonly type: "string";
|
|
846
|
-
readonly enum: readonly ["click", "submit", "change", "blur", "focus", "load"];
|
|
914
|
+
readonly enum: readonly ["click", "submit", "change", "blur", "focus", "load", "expire"];
|
|
847
915
|
};
|
|
848
916
|
readonly label: {
|
|
849
917
|
readonly type: "string";
|
|
@@ -1574,7 +1642,7 @@ export declare const ACTION_PIPELINE_JSON_SCHEMA_V1: {
|
|
|
1574
1642
|
};
|
|
1575
1643
|
readonly trigger: {
|
|
1576
1644
|
readonly type: "string";
|
|
1577
|
-
readonly enum: readonly ["click", "submit", "change", "blur", "focus", "load"];
|
|
1645
|
+
readonly enum: readonly ["click", "submit", "change", "blur", "focus", "load", "expire"];
|
|
1578
1646
|
readonly description: "DOM or component event that triggers the action pipeline";
|
|
1579
1647
|
};
|
|
1580
1648
|
readonly label: {
|
|
@@ -1679,7 +1747,7 @@ export declare function getActionPipelineJsonSchema(): {
|
|
|
1679
1747
|
};
|
|
1680
1748
|
readonly trigger: {
|
|
1681
1749
|
readonly type: "string";
|
|
1682
|
-
readonly enum: readonly ["click", "submit", "change", "blur", "focus", "load"];
|
|
1750
|
+
readonly enum: readonly ["click", "submit", "change", "blur", "focus", "load", "expire"];
|
|
1683
1751
|
readonly description: "DOM or component event that triggers the action pipeline";
|
|
1684
1752
|
};
|
|
1685
1753
|
readonly label: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,4BAA4B
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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gBAAgB,CAQpE;AAED,yGAAyG;AACzG,wBAAgB,kCAAkC,IAAI,gBAAgB,CAQrE;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,IAAI,gBAAgB,CAavE"}
|
package/dist/template.d.ts
CHANGED
|
@@ -176,6 +176,12 @@ export declare const TemplateRecordSchema: z.ZodObject<{
|
|
|
176
176
|
}, z.core.$strip>>;
|
|
177
177
|
}, z.core.$strip>>>;
|
|
178
178
|
}, z.core.$strip>>;
|
|
179
|
+
theme: z.ZodOptional<z.ZodObject<{
|
|
180
|
+
colors: z.ZodOptional<z.ZodRecord<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
181
|
+
fonts: z.ZodOptional<z.ZodRecord<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
182
|
+
radii: z.ZodOptional<z.ZodRecord<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
183
|
+
spacing: z.ZodOptional<z.ZodRecord<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
184
|
+
}, z.core.$strip>>;
|
|
179
185
|
document: z.ZodType<import("./document").RootPageNode, unknown, z.core.$ZodTypeInternals<import("./document").RootPageNode, unknown>>;
|
|
180
186
|
}, z.core.$strip>>;
|
|
181
187
|
packageReference: z.ZodOptional<z.ZodObject<{
|
package/dist/template.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAA4C,KAAK,cAAc,EAAqB,MAAM,YAAY,C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;;;;;;gCAI9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,mBAAmB,GAAG,MAAM,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;iBAKnC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;iBAGrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkB/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAExE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE"}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Document Theme / Design Tokens (STORA-551)
|
|
4
|
+
*
|
|
5
|
+
* A theme is a small, portable set of named design tokens stored on the document
|
|
6
|
+
* (`PageDocument.theme`). The renderer emits every token as a CSS custom property on
|
|
7
|
+
* the page root, and node styles reference tokens with a plain CSS `var()` string:
|
|
8
|
+
*
|
|
9
|
+
* styles.base.backgroundColor = 'var(--kb-color-primary)'
|
|
10
|
+
*
|
|
11
|
+
* Because the reference is an ordinary CSS value it passes the existing style
|
|
12
|
+
* validation, renders unchanged in inline styles, generated CSS and exported HTML,
|
|
13
|
+
* and falls back gracefully (to the property's initial value) when a token is absent.
|
|
14
|
+
*
|
|
15
|
+
* Token groups map to custom-property prefixes:
|
|
16
|
+
* colors -> --kb-color-<key>
|
|
17
|
+
* fonts -> --kb-font-<key>
|
|
18
|
+
* radii -> --kb-radius-<key>
|
|
19
|
+
* spacing -> --kb-space-<key>
|
|
20
|
+
*
|
|
21
|
+
* Security: token keys are restricted to a safe identifier alphabet and token values
|
|
22
|
+
* are screened like style values, and additionally may not contain characters that can
|
|
23
|
+
* terminate a CSS declaration/rule or open markup (`; { } < > \`), since values end up
|
|
24
|
+
* inside a `<style>` block in generated HTML.
|
|
25
|
+
*/
|
|
26
|
+
export declare const THEME_TOKEN_GROUPS: readonly ["colors", "fonts", "radii", "spacing"];
|
|
27
|
+
export type ThemeTokenGroup = (typeof THEME_TOKEN_GROUPS)[number];
|
|
28
|
+
/** CSS custom-property prefix per token group. */
|
|
29
|
+
export declare const THEME_TOKEN_CSS_PREFIX: Readonly<Record<ThemeTokenGroup, string>>;
|
|
30
|
+
/** True when `key` can be used as a theme token key (and custom-property suffix). */
|
|
31
|
+
export declare function isSafeThemeTokenKey(key: unknown): key is string;
|
|
32
|
+
/**
|
|
33
|
+
* True when `value` is safe to emit as a CSS custom-property value. Numbers are allowed
|
|
34
|
+
* (finite only); strings must be short and free of injection vectors.
|
|
35
|
+
*/
|
|
36
|
+
export declare function isSafeThemeTokenValue(value: unknown): value is string | number;
|
|
37
|
+
export declare const ThemeTokenKeySchema: z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
|
|
38
|
+
export declare const ThemeTokenValueSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
39
|
+
export type ThemeTokenValue = z.infer<typeof ThemeTokenValueSchema>;
|
|
40
|
+
export declare const ThemeTokenMapSchema: z.ZodRecord<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
41
|
+
export type ThemeTokenMap = Record<string, ThemeTokenValue>;
|
|
42
|
+
export declare const ThemeSchema: z.ZodObject<{
|
|
43
|
+
colors: z.ZodOptional<z.ZodRecord<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
44
|
+
fonts: z.ZodOptional<z.ZodRecord<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
45
|
+
radii: z.ZodOptional<z.ZodRecord<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
46
|
+
spacing: z.ZodOptional<z.ZodRecord<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type Theme = z.infer<typeof ThemeSchema>;
|
|
49
|
+
/**
|
|
50
|
+
* Builds the custom-property name for a token, e.g. `('colors', 'primary')` ->
|
|
51
|
+
* `--kb-color-primary`. Returns `null` for unsafe keys.
|
|
52
|
+
*/
|
|
53
|
+
export declare function themeTokenCssVarName(group: ThemeTokenGroup, key: string): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Builds the style value that references a token, e.g. `var(--kb-color-primary)`.
|
|
56
|
+
* This is the canonical token reference format stored in node styles.
|
|
57
|
+
*/
|
|
58
|
+
export declare function themeTokenRef(group: ThemeTokenGroup, key: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Parses a token reference style value back into `{ group, key }`, or `null` when the
|
|
61
|
+
* value is not a theme token reference.
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseThemeTokenRef(value: unknown): {
|
|
64
|
+
group: ThemeTokenGroup;
|
|
65
|
+
key: string;
|
|
66
|
+
} | null;
|
|
67
|
+
/**
|
|
68
|
+
* Merges theme layers left-to-right (later layers win per token). Used to apply a host
|
|
69
|
+
* runtime override on top of the document theme without mutating either. Unsafe tokens in
|
|
70
|
+
* any layer are skipped, so an invalid override never clobbers a valid lower-layer value.
|
|
71
|
+
*/
|
|
72
|
+
export declare function mergeThemes(...layers: Array<Partial<Theme> | undefined | null>): Theme;
|
|
73
|
+
/**
|
|
74
|
+
* Flattens a theme into `[customPropertyName, value]` pairs, silently dropping any
|
|
75
|
+
* token whose key or value is unsafe. Safe to call on unvalidated input (e.g. a host
|
|
76
|
+
* runtime override), which is why it re-checks every entry.
|
|
77
|
+
*/
|
|
78
|
+
export declare function themeToCssVariables(theme: Partial<Theme> | undefined | null): Array<[string, string]>;
|
|
79
|
+
export declare function isTheme(value: unknown): value is Theme;
|
|
80
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,eAAO,MAAM,kBAAkB,kDAAmD,CAAC;AAEnF,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,kDAAkD;AAClD,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAK3E,CAAC;AAQH,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,CAE/D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,GAAG,MAAM,CAO9E;AAED,eAAO,MAAM,mBAAmB,mFAG9B,CA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esc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/types.ts
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * `@kubuild/schema/types` — pure TypeScript interfaces for the portable document format\n * (STORA-552).\n *\n * This module MUST NOT import zod (or any module that does). Its emitted `.d.ts` is what\n * hosts on a different zod major (e.g. a zod v3 backend) import to type `PageDocument`,\n * `Node`, etc. without pulling zod v4's core namespace into their compilation.\n *\n * Every type here mirrors the *parsed output* (`z.infer<...>`) of the matching schema in\n * the main entry, i.e. fields with a schema default are required. The equality is\n * enforced by `tests/types.test.ts` (`expectTypeOf(...).toEqualTypeOf(...)`), so a schema\n * change that is not reflected here fails `pnpm run typecheck`.\n */\n\n/* ----------------------------------------------------------------------------------------\n * Bindings & styles\n * -------------------------------------------------------------------------------------- */\n\nexport interface AssetReference {\n type: 'asset';\n assetId: string;\n filename?: string;\n mimeType?: string;\n fallbackUrl?: string;\n}\n\nexport interface VariableBinding {\n type: 'variable';\n key: string;\n fallback?: unknown;\n}\n\nexport interface ActionBinding {\n type: string;\n payload?: Record<string, unknown>;\n}\n\nexport type StyleValue = string | number | boolean | null | undefined;\n\n/**\n * Standard CSS style definition supporting Flexbox, sizing constraints, effects,\n * CSS Grid, and arbitrary CSS properties / design-token references.\n */\nexport interface StyleDefinition extends Record<string, StyleValue> {\n display?: string;\n flexDirection?: 'row' | 'row-reverse' | 'column' | 'column-reverse' | (string & {});\n flexWrap?: 'nowrap' | 'wrap' | 'wrap-reverse' | (string & {});\n justifyContent?:\n | 'flex-start'\n | 'flex-end'\n | 'center'\n | 'space-between'\n | 'space-around'\n | 'space-evenly'\n | 'start'\n | 'end'\n | 'left'\n | 'right'\n | (string & {});\n alignItems?:\n | 'stretch'\n | 'flex-start'\n | 'flex-end'\n | 'center'\n | 'baseline'\n | 'start'\n | 'end'\n | 'self-start'\n | 'self-end'\n | (string & {});\n alignContent?:\n | 'flex-start'\n | 'flex-end'\n | 'center'\n | 'space-between'\n | 'space-around'\n | 'space-evenly'\n | 'stretch'\n | 'start'\n | 'end'\n | (string & {});\n gap?: string | number;\n rowGap?: string | number;\n columnGap?: string | number;\n flexGrow?: number | string;\n flexShrink?: number | string;\n flexBasis?: string | number;\n alignSelf?:\n 'auto' | 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch' | (string & {});\n width?: string | number;\n height?: string | number;\n minWidth?: string | number;\n maxWidth?: string | number;\n minHeight?: string | number;\n maxHeight?: string | number;\n objectFit?: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down' | (string & {});\n objectPosition?: string;\n borderRadius?: string | number;\n borderTopLeftRadius?: string | number;\n borderTopRightRadius?: string | number;\n borderBottomRightRadius?: string | number;\n borderBottomLeftRadius?: string | number;\n backdropFilter?: string;\n filter?: string;\n boxShadow?: string;\n backgroundColor?: string;\n backgroundImage?: string;\n backgroundSize?: 'cover' | 'contain' | 'auto' | (string & {});\n backgroundPosition?: string;\n backgroundRepeat?: 'no-repeat' | 'repeat' | 'repeat-x' | 'repeat-y' | (string & {});\n backgroundAttachment?: 'scroll' | 'fixed' | 'local' | (string & {});\n gridTemplateColumns?: string;\n gridTemplateRows?: string;\n gridAutoFlow?: string;\n gridAutoColumns?: string;\n gridAutoRows?: string;\n gridColumn?: string | number;\n gridRow?: string | number;\n gridColumnStart?: string | number;\n gridColumnEnd?: string | number;\n gridRowStart?: string | number;\n gridRowEnd?: string | number;\n colSpan?: number | string;\n rowSpan?: number | string;\n justifySelf?: string;\n}\n\nexport type PseudoStateStyles = Record<string, StyleDefinition>;\n\n/** Breakpoint style layers (`base` applies to every viewport) plus pseudo-state layers. */\nexport interface ResponsiveStyles {\n [key: string]: unknown;\n base?: StyleDefinition;\n desktop?: StyleDefinition;\n tablet?: StyleDefinition;\n mobile?: StyleDefinition;\n states?: Record<string, StyleDefinition>;\n}\n\nexport interface AnimationConfig {\n type: string;\n duration: number;\n delay: number;\n easing: string;\n once: boolean;\n hoverEffect: string;\n loopEffect: string;\n}\n\n/* ----------------------------------------------------------------------------------------\n * Theme (STORA-551)\n * -------------------------------------------------------------------------------------- */\n\nexport type ThemeTokenValue = string | number;\n\n/** Design tokens; referenced from styles as `var(--kb-color-<key>)` etc. */\nexport interface Theme {\n colors?: Record<string, ThemeTokenValue>;\n fonts?: Record<string, ThemeTokenValue>;\n radii?: Record<string, ThemeTokenValue>;\n spacing?: Record<string, ThemeTokenValue>;\n}\n\n/* ----------------------------------------------------------------------------------------\n * Forms\n * -------------------------------------------------------------------------------------- */\n\nexport type ValidationRuleType =\n | 'required'\n | 'email'\n | 'url'\n | 'min_length'\n | 'max_length'\n | 'numeric_min'\n | 'numeric_max'\n | 'pattern'\n | 'match_field'\n | 'custom_regex';\n\nexport type ValidateOnEvent = 'blur' | 'change' | 'submit';\n\nexport interface ValidationRule {\n type: ValidationRuleType;\n value?: unknown;\n message: string;\n}\n\nexport interface FormFieldBinding {\n name: string;\n label?: string;\n defaultValue?: unknown;\n rules: ValidationRule[];\n validateOn: ValidateOnEvent;\n transform?: 'trim' | 'lowercase' | 'uppercase' | 'number';\n disabled?: boolean;\n required?: boolean;\n}\n\nexport interface FormConfig {\n formId: string;\n resetOnSubmit: boolean;\n scrollToFirstError: boolean;\n validateOn: ValidateOnEvent;\n initialValues?: Record<string, unknown>;\n rules?: ValidationRule[];\n}\n\n/* ----------------------------------------------------------------------------------------\n * Actions\n * -------------------------------------------------------------------------------------- */\n\nexport type ActionTriggerType =\n 'click' | 'submit' | 'change' | 'blur' | 'focus' | 'load' | 'expire';\n\nexport type ActionStepType =\n | 'api_request'\n | 'navigate'\n | 'set_state'\n | 'reset_form'\n | 'show_toast'\n | 'open_modal'\n | 'close_modal'\n | 'toggle_modal'\n | 'copy_clipboard'\n | 'custom_event'\n | 'track_event';\n\nexport type ConditionOperator =\n | 'equals'\n | 'not_equals'\n | 'contains'\n | 'not_contains'\n | 'is_truthy'\n | 'is_falsy'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte'\n | 'regex';\n\nexport interface ActionStepCondition {\n field: string;\n operator: ConditionOperator;\n value?: unknown;\n}\n\nexport interface ActionStep {\n id: string;\n type: ActionStepType;\n label?: string;\n payload?: Record<string, unknown>;\n condition?: ActionStepCondition;\n timeout?: number;\n continueOnError?: boolean;\n onSuccess?: ActionStep[];\n onError?: ActionStep[];\n}\n\nexport interface ActionPipeline {\n id: string;\n trigger: ActionTriggerType;\n label?: string;\n debounceMs?: number;\n preventDuplicate?: boolean;\n enabled: boolean;\n steps: ActionStep[];\n}\n\n/* ----------------------------------------------------------------------------------------\n * Tracking (public ids only — secrets are host-owned)\n * -------------------------------------------------------------------------------------- */\n\nexport type TrackingProviderType = 'meta' | 'google' | 'gtm' | 'tiktok' | 'custom';\n\nexport type TrackingDelivery = 'both' | 'client_only' | 'server_only';\n\nexport interface MetaTrackingProviderConfig {\n enabled: boolean;\n credentialId?: string;\n pixelId: string;\n capiEnabled: boolean;\n testEventCode: string;\n}\n\nexport interface GoogleTrackingProviderConfig {\n enabled: boolean;\n credentialId?: string;\n measurementId: string;\n}\n\nexport interface GtmTrackingProviderConfig {\n enabled: boolean;\n credentialId?: string;\n containerId: string;\n}\n\nexport interface TikTokTrackingProviderConfig {\n enabled: boolean;\n credentialId?: string;\n pixelId: string;\n eventsApiEnabled: boolean;\n testEventCode: string;\n}\n\nexport interface CustomTrackingProviderConfig {\n enabled: boolean;\n credentialId?: string;\n}\n\nexport interface TrackingConfig {\n enabled: boolean;\n debugMode: boolean;\n autoPageView: boolean;\n defaultDelivery: TrackingDelivery;\n providers: {\n meta?: MetaTrackingProviderConfig;\n google?: GoogleTrackingProviderConfig;\n gtm?: GtmTrackingProviderConfig;\n tiktok?: TikTokTrackingProviderConfig;\n custom?: CustomTrackingProviderConfig;\n };\n}\n\n/* ----------------------------------------------------------------------------------------\n * Document\n * -------------------------------------------------------------------------------------- */\n\nexport interface Node {\n id: string;\n type: string;\n props?: Record<string, unknown>;\n styles?: ResponsiveStyles;\n animation?: AnimationConfig;\n actions?: ActionPipeline[];\n formConfig?: FormConfig;\n children?: Node[];\n}\n\nexport type RootPageNode = Node & { type: 'page' };\n\nexport interface DocumentMetadata {\n title: string;\n description: string;\n author: string;\n createdAt?: string;\n updatedAt?: string;\n tags: string[];\n category: string;\n version: string;\n custom?: Record<string, unknown>;\n tracking?: TrackingConfig;\n}\n\nexport interface PageDocument {\n schema: 'stora.page';\n version: string;\n metadata?: DocumentMetadata;\n tracking?: TrackingConfig;\n theme?: Theme;\n document: RootPageNode;\n}\n\nexport type ArtboardType = 'page' | 'component';\n\nexport interface Artboard {\n id: string;\n name: string;\n artboardType: ArtboardType;\n slug?: string;\n triggerId?: string;\n viewport?: 'desktop' | 'tablet' | 'mobile';\n width?: number;\n position?: { x: number; y: number };\n document: PageDocument;\n}\n\nexport interface ProjectDocument {\n schema: 'stora.project';\n version: string;\n metadata?: DocumentMetadata;\n tracking?: TrackingConfig;\n artboards: Artboard[];\n activeArtboardId?: string;\n}\n\n/* ----------------------------------------------------------------------------------------\n * Package manifest & templates\n * -------------------------------------------------------------------------------------- */\n\nexport interface ManifestAssetItem {\n id: string;\n path: string;\n mimeType: string;\n size: number;\n checksum?: string;\n}\n\nexport interface Manifest {\n schema: 'stora.page';\n schemaVersion: string;\n packageVersion: string;\n builderCompatibility: string;\n requiredComponents: string[];\n requiredCapabilities: string[];\n assets: ManifestAssetItem[];\n createdAt?: string;\n}\n\nexport interface SafeThumbnailObject {\n url: string;\n alt?: string;\n width?: number;\n height?: number;\n}\n\nexport type SafeThumbnail = AssetReference | SafeThumbnailObject | string;\n\nexport interface TemplatePackageRef {\n path?: string;\n url?: string;\n checksum?: string;\n format: 'stora' | 'json';\n}\n\nexport interface TemplateRequirements {\n requiredComponents: string[];\n requiredCapabilities: string[];\n}\n\nexport interface TemplateRecord {\n id: string;\n name: string;\n description: string;\n category: string;\n tags: string[];\n thumbnail?: SafeThumbnail;\n author: string;\n version: string;\n document?: PageDocument;\n packageReference?: TemplatePackageRef;\n requirements: TemplateRequirements;\n createdAt?: string;\n updatedAt?: string;\n custom?: Record<string, unknown>;\n}\n\n/* ----------------------------------------------------------------------------------------\n * Zod-free validation results (see `@kubuild/schema/validate`)\n * -------------------------------------------------------------------------------------- */\n\nexport interface SchemaValidationIssue {\n /** Dotted path to the offending value, e.g. `document.children.0.id` (empty for root). */\n path: string;\n message: string;\n /** Validator issue code (e.g. `invalid_type`, `custom`). */\n code: string;\n}\n\nexport type SchemaValidationResult<T> =\n | { success: true; data: T; issues: [] }\n | { success: false; data?: undefined; issues: SchemaValidationIssue[] };\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@kubuild/schema/types` — pure TypeScript interfaces for the portable document format
|
|
3
|
+
* (STORA-552).
|
|
4
|
+
*
|
|
5
|
+
* This module MUST NOT import zod (or any module that does). Its emitted `.d.ts` is what
|
|
6
|
+
* hosts on a different zod major (e.g. a zod v3 backend) import to type `PageDocument`,
|
|
7
|
+
* `Node`, etc. without pulling zod v4's core namespace into their compilation.
|
|
8
|
+
*
|
|
9
|
+
* Every type here mirrors the *parsed output* (`z.infer<...>`) of the matching schema in
|
|
10
|
+
* the main entry, i.e. fields with a schema default are required. The equality is
|
|
11
|
+
* enforced by `tests/types.test.ts` (`expectTypeOf(...).toEqualTypeOf(...)`), so a schema
|
|
12
|
+
* change that is not reflected here fails `pnpm run typecheck`.
|
|
13
|
+
*/
|
|
14
|
+
export interface AssetReference {
|
|
15
|
+
type: 'asset';
|
|
16
|
+
assetId: string;
|
|
17
|
+
filename?: string;
|
|
18
|
+
mimeType?: string;
|
|
19
|
+
fallbackUrl?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface VariableBinding {
|
|
22
|
+
type: 'variable';
|
|
23
|
+
key: string;
|
|
24
|
+
fallback?: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface ActionBinding {
|
|
27
|
+
type: string;
|
|
28
|
+
payload?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
export type StyleValue = string | number | boolean | null | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Standard CSS style definition supporting Flexbox, sizing constraints, effects,
|
|
33
|
+
* CSS Grid, and arbitrary CSS properties / design-token references.
|
|
34
|
+
*/
|
|
35
|
+
export interface StyleDefinition extends Record<string, StyleValue> {
|
|
36
|
+
display?: string;
|
|
37
|
+
flexDirection?: 'row' | 'row-reverse' | 'column' | 'column-reverse' | (string & {});
|
|
38
|
+
flexWrap?: 'nowrap' | 'wrap' | 'wrap-reverse' | (string & {});
|
|
39
|
+
justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly' | 'start' | 'end' | 'left' | 'right' | (string & {});
|
|
40
|
+
alignItems?: 'stretch' | 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'start' | 'end' | 'self-start' | 'self-end' | (string & {});
|
|
41
|
+
alignContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch' | 'start' | 'end' | (string & {});
|
|
42
|
+
gap?: string | number;
|
|
43
|
+
rowGap?: string | number;
|
|
44
|
+
columnGap?: string | number;
|
|
45
|
+
flexGrow?: number | string;
|
|
46
|
+
flexShrink?: number | string;
|
|
47
|
+
flexBasis?: string | number;
|
|
48
|
+
alignSelf?: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'baseline' | 'stretch' | (string & {});
|
|
49
|
+
width?: string | number;
|
|
50
|
+
height?: string | number;
|
|
51
|
+
minWidth?: string | number;
|
|
52
|
+
maxWidth?: string | number;
|
|
53
|
+
minHeight?: string | number;
|
|
54
|
+
maxHeight?: string | number;
|
|
55
|
+
objectFit?: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down' | (string & {});
|
|
56
|
+
objectPosition?: string;
|
|
57
|
+
borderRadius?: string | number;
|
|
58
|
+
borderTopLeftRadius?: string | number;
|
|
59
|
+
borderTopRightRadius?: string | number;
|
|
60
|
+
borderBottomRightRadius?: string | number;
|
|
61
|
+
borderBottomLeftRadius?: string | number;
|
|
62
|
+
backdropFilter?: string;
|
|
63
|
+
filter?: string;
|
|
64
|
+
boxShadow?: string;
|
|
65
|
+
backgroundColor?: string;
|
|
66
|
+
backgroundImage?: string;
|
|
67
|
+
backgroundSize?: 'cover' | 'contain' | 'auto' | (string & {});
|
|
68
|
+
backgroundPosition?: string;
|
|
69
|
+
backgroundRepeat?: 'no-repeat' | 'repeat' | 'repeat-x' | 'repeat-y' | (string & {});
|
|
70
|
+
backgroundAttachment?: 'scroll' | 'fixed' | 'local' | (string & {});
|
|
71
|
+
gridTemplateColumns?: string;
|
|
72
|
+
gridTemplateRows?: string;
|
|
73
|
+
gridAutoFlow?: string;
|
|
74
|
+
gridAutoColumns?: string;
|
|
75
|
+
gridAutoRows?: string;
|
|
76
|
+
gridColumn?: string | number;
|
|
77
|
+
gridRow?: string | number;
|
|
78
|
+
gridColumnStart?: string | number;
|
|
79
|
+
gridColumnEnd?: string | number;
|
|
80
|
+
gridRowStart?: string | number;
|
|
81
|
+
gridRowEnd?: string | number;
|
|
82
|
+
colSpan?: number | string;
|
|
83
|
+
rowSpan?: number | string;
|
|
84
|
+
justifySelf?: string;
|
|
85
|
+
}
|
|
86
|
+
export type PseudoStateStyles = Record<string, StyleDefinition>;
|
|
87
|
+
/** Breakpoint style layers (`base` applies to every viewport) plus pseudo-state layers. */
|
|
88
|
+
export interface ResponsiveStyles {
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
base?: StyleDefinition;
|
|
91
|
+
desktop?: StyleDefinition;
|
|
92
|
+
tablet?: StyleDefinition;
|
|
93
|
+
mobile?: StyleDefinition;
|
|
94
|
+
states?: Record<string, StyleDefinition>;
|
|
95
|
+
}
|
|
96
|
+
export interface AnimationConfig {
|
|
97
|
+
type: string;
|
|
98
|
+
duration: number;
|
|
99
|
+
delay: number;
|
|
100
|
+
easing: string;
|
|
101
|
+
once: boolean;
|
|
102
|
+
hoverEffect: string;
|
|
103
|
+
loopEffect: string;
|
|
104
|
+
}
|
|
105
|
+
export type ThemeTokenValue = string | number;
|
|
106
|
+
/** Design tokens; referenced from styles as `var(--kb-color-<key>)` etc. */
|
|
107
|
+
export interface Theme {
|
|
108
|
+
colors?: Record<string, ThemeTokenValue>;
|
|
109
|
+
fonts?: Record<string, ThemeTokenValue>;
|
|
110
|
+
radii?: Record<string, ThemeTokenValue>;
|
|
111
|
+
spacing?: Record<string, ThemeTokenValue>;
|
|
112
|
+
}
|
|
113
|
+
export type ValidationRuleType = 'required' | 'email' | 'url' | 'min_length' | 'max_length' | 'numeric_min' | 'numeric_max' | 'pattern' | 'match_field' | 'custom_regex';
|
|
114
|
+
export type ValidateOnEvent = 'blur' | 'change' | 'submit';
|
|
115
|
+
export interface ValidationRule {
|
|
116
|
+
type: ValidationRuleType;
|
|
117
|
+
value?: unknown;
|
|
118
|
+
message: string;
|
|
119
|
+
}
|
|
120
|
+
export interface FormFieldBinding {
|
|
121
|
+
name: string;
|
|
122
|
+
label?: string;
|
|
123
|
+
defaultValue?: unknown;
|
|
124
|
+
rules: ValidationRule[];
|
|
125
|
+
validateOn: ValidateOnEvent;
|
|
126
|
+
transform?: 'trim' | 'lowercase' | 'uppercase' | 'number';
|
|
127
|
+
disabled?: boolean;
|
|
128
|
+
required?: boolean;
|
|
129
|
+
}
|
|
130
|
+
export interface FormConfig {
|
|
131
|
+
formId: string;
|
|
132
|
+
resetOnSubmit: boolean;
|
|
133
|
+
scrollToFirstError: boolean;
|
|
134
|
+
validateOn: ValidateOnEvent;
|
|
135
|
+
initialValues?: Record<string, unknown>;
|
|
136
|
+
rules?: ValidationRule[];
|
|
137
|
+
}
|
|
138
|
+
export type ActionTriggerType = 'click' | 'submit' | 'change' | 'blur' | 'focus' | 'load' | 'expire';
|
|
139
|
+
export type ActionStepType = 'api_request' | 'navigate' | 'set_state' | 'reset_form' | 'show_toast' | 'open_modal' | 'close_modal' | 'toggle_modal' | 'copy_clipboard' | 'custom_event' | 'track_event';
|
|
140
|
+
export type ConditionOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'is_truthy' | 'is_falsy' | 'gt' | 'gte' | 'lt' | 'lte' | 'regex';
|
|
141
|
+
export interface ActionStepCondition {
|
|
142
|
+
field: string;
|
|
143
|
+
operator: ConditionOperator;
|
|
144
|
+
value?: unknown;
|
|
145
|
+
}
|
|
146
|
+
export interface ActionStep {
|
|
147
|
+
id: string;
|
|
148
|
+
type: ActionStepType;
|
|
149
|
+
label?: string;
|
|
150
|
+
payload?: Record<string, unknown>;
|
|
151
|
+
condition?: ActionStepCondition;
|
|
152
|
+
timeout?: number;
|
|
153
|
+
continueOnError?: boolean;
|
|
154
|
+
onSuccess?: ActionStep[];
|
|
155
|
+
onError?: ActionStep[];
|
|
156
|
+
}
|
|
157
|
+
export interface ActionPipeline {
|
|
158
|
+
id: string;
|
|
159
|
+
trigger: ActionTriggerType;
|
|
160
|
+
label?: string;
|
|
161
|
+
debounceMs?: number;
|
|
162
|
+
preventDuplicate?: boolean;
|
|
163
|
+
enabled: boolean;
|
|
164
|
+
steps: ActionStep[];
|
|
165
|
+
}
|
|
166
|
+
export type TrackingProviderType = 'meta' | 'google' | 'gtm' | 'tiktok' | 'custom';
|
|
167
|
+
export type TrackingDelivery = 'both' | 'client_only' | 'server_only';
|
|
168
|
+
export interface MetaTrackingProviderConfig {
|
|
169
|
+
enabled: boolean;
|
|
170
|
+
credentialId?: string;
|
|
171
|
+
pixelId: string;
|
|
172
|
+
capiEnabled: boolean;
|
|
173
|
+
testEventCode: string;
|
|
174
|
+
}
|
|
175
|
+
export interface GoogleTrackingProviderConfig {
|
|
176
|
+
enabled: boolean;
|
|
177
|
+
credentialId?: string;
|
|
178
|
+
measurementId: string;
|
|
179
|
+
}
|
|
180
|
+
export interface GtmTrackingProviderConfig {
|
|
181
|
+
enabled: boolean;
|
|
182
|
+
credentialId?: string;
|
|
183
|
+
containerId: string;
|
|
184
|
+
}
|
|
185
|
+
export interface TikTokTrackingProviderConfig {
|
|
186
|
+
enabled: boolean;
|
|
187
|
+
credentialId?: string;
|
|
188
|
+
pixelId: string;
|
|
189
|
+
eventsApiEnabled: boolean;
|
|
190
|
+
testEventCode: string;
|
|
191
|
+
}
|
|
192
|
+
export interface CustomTrackingProviderConfig {
|
|
193
|
+
enabled: boolean;
|
|
194
|
+
credentialId?: string;
|
|
195
|
+
}
|
|
196
|
+
export interface TrackingConfig {
|
|
197
|
+
enabled: boolean;
|
|
198
|
+
debugMode: boolean;
|
|
199
|
+
autoPageView: boolean;
|
|
200
|
+
defaultDelivery: TrackingDelivery;
|
|
201
|
+
providers: {
|
|
202
|
+
meta?: MetaTrackingProviderConfig;
|
|
203
|
+
google?: GoogleTrackingProviderConfig;
|
|
204
|
+
gtm?: GtmTrackingProviderConfig;
|
|
205
|
+
tiktok?: TikTokTrackingProviderConfig;
|
|
206
|
+
custom?: CustomTrackingProviderConfig;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
export interface Node {
|
|
210
|
+
id: string;
|
|
211
|
+
type: string;
|
|
212
|
+
props?: Record<string, unknown>;
|
|
213
|
+
styles?: ResponsiveStyles;
|
|
214
|
+
animation?: AnimationConfig;
|
|
215
|
+
actions?: ActionPipeline[];
|
|
216
|
+
formConfig?: FormConfig;
|
|
217
|
+
children?: Node[];
|
|
218
|
+
}
|
|
219
|
+
export type RootPageNode = Node & {
|
|
220
|
+
type: 'page';
|
|
221
|
+
};
|
|
222
|
+
export interface DocumentMetadata {
|
|
223
|
+
title: string;
|
|
224
|
+
description: string;
|
|
225
|
+
author: string;
|
|
226
|
+
createdAt?: string;
|
|
227
|
+
updatedAt?: string;
|
|
228
|
+
tags: string[];
|
|
229
|
+
category: string;
|
|
230
|
+
version: string;
|
|
231
|
+
custom?: Record<string, unknown>;
|
|
232
|
+
tracking?: TrackingConfig;
|
|
233
|
+
}
|
|
234
|
+
export interface PageDocument {
|
|
235
|
+
schema: 'stora.page';
|
|
236
|
+
version: string;
|
|
237
|
+
metadata?: DocumentMetadata;
|
|
238
|
+
tracking?: TrackingConfig;
|
|
239
|
+
theme?: Theme;
|
|
240
|
+
document: RootPageNode;
|
|
241
|
+
}
|
|
242
|
+
export type ArtboardType = 'page' | 'component';
|
|
243
|
+
export interface Artboard {
|
|
244
|
+
id: string;
|
|
245
|
+
name: string;
|
|
246
|
+
artboardType: ArtboardType;
|
|
247
|
+
slug?: string;
|
|
248
|
+
triggerId?: string;
|
|
249
|
+
viewport?: 'desktop' | 'tablet' | 'mobile';
|
|
250
|
+
width?: number;
|
|
251
|
+
position?: {
|
|
252
|
+
x: number;
|
|
253
|
+
y: number;
|
|
254
|
+
};
|
|
255
|
+
document: PageDocument;
|
|
256
|
+
}
|
|
257
|
+
export interface ProjectDocument {
|
|
258
|
+
schema: 'stora.project';
|
|
259
|
+
version: string;
|
|
260
|
+
metadata?: DocumentMetadata;
|
|
261
|
+
tracking?: TrackingConfig;
|
|
262
|
+
artboards: Artboard[];
|
|
263
|
+
activeArtboardId?: string;
|
|
264
|
+
}
|
|
265
|
+
export interface ManifestAssetItem {
|
|
266
|
+
id: string;
|
|
267
|
+
path: string;
|
|
268
|
+
mimeType: string;
|
|
269
|
+
size: number;
|
|
270
|
+
checksum?: string;
|
|
271
|
+
}
|
|
272
|
+
export interface Manifest {
|
|
273
|
+
schema: 'stora.page';
|
|
274
|
+
schemaVersion: string;
|
|
275
|
+
packageVersion: string;
|
|
276
|
+
builderCompatibility: string;
|
|
277
|
+
requiredComponents: string[];
|
|
278
|
+
requiredCapabilities: string[];
|
|
279
|
+
assets: ManifestAssetItem[];
|
|
280
|
+
createdAt?: string;
|
|
281
|
+
}
|
|
282
|
+
export interface SafeThumbnailObject {
|
|
283
|
+
url: string;
|
|
284
|
+
alt?: string;
|
|
285
|
+
width?: number;
|
|
286
|
+
height?: number;
|
|
287
|
+
}
|
|
288
|
+
export type SafeThumbnail = AssetReference | SafeThumbnailObject | string;
|
|
289
|
+
export interface TemplatePackageRef {
|
|
290
|
+
path?: string;
|
|
291
|
+
url?: string;
|
|
292
|
+
checksum?: string;
|
|
293
|
+
format: 'stora' | 'json';
|
|
294
|
+
}
|
|
295
|
+
export interface TemplateRequirements {
|
|
296
|
+
requiredComponents: string[];
|
|
297
|
+
requiredCapabilities: string[];
|
|
298
|
+
}
|
|
299
|
+
export interface TemplateRecord {
|
|
300
|
+
id: string;
|
|
301
|
+
name: string;
|
|
302
|
+
description: string;
|
|
303
|
+
category: string;
|
|
304
|
+
tags: string[];
|
|
305
|
+
thumbnail?: SafeThumbnail;
|
|
306
|
+
author: string;
|
|
307
|
+
version: string;
|
|
308
|
+
document?: PageDocument;
|
|
309
|
+
packageReference?: TemplatePackageRef;
|
|
310
|
+
requirements: TemplateRequirements;
|
|
311
|
+
createdAt?: string;
|
|
312
|
+
updatedAt?: string;
|
|
313
|
+
custom?: Record<string, unknown>;
|
|
314
|
+
}
|
|
315
|
+
export interface SchemaValidationIssue {
|
|
316
|
+
/** Dotted path to the offending value, e.g. `document.children.0.id` (empty for root). */
|
|
317
|
+
path: string;
|
|
318
|
+
message: string;
|
|
319
|
+
/** Validator issue code (e.g. `invalid_type`, `custom`). */
|
|
320
|
+
code: string;
|
|
321
|
+
}
|
|
322
|
+
export type SchemaValidationResult<T> = {
|
|
323
|
+
success: true;
|
|
324
|
+
data: T;
|
|
325
|
+
issues: [];
|
|
326
|
+
} | {
|
|
327
|
+
success: false;
|
|
328
|
+
data?: undefined;
|
|
329
|
+
issues: SchemaValidationIssue[];
|
|
330
|
+
};
|
|
331
|
+
//# sourceMappingURL=types.d.ts.map
|