@usethrottle/builder-schema 0.1.1 → 0.1.3
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/__tests__/fixtures/parity/01-hero-boxed.json +68 -0
- package/__tests__/fixtures/parity/02-full-bleed-image-hero.json +61 -0
- package/__tests__/fixtures/parity/03-two-columns-50-50.json +66 -0
- package/__tests__/fixtures/parity/04-three-columns-phone-widths.json +87 -0
- package/__tests__/fixtures/parity/05-four-columns-tablet-two-by-two.json +108 -0
- package/__tests__/fixtures/parity/06-inner-section-in-column.json +101 -0
- package/__tests__/fixtures/parity/07-hidden-on-phone.json +47 -0
- package/__tests__/fixtures/parity/08-device-specific-text-and-size.json +46 -0
- package/__tests__/fixtures/parity/09-every-basic-widget.json +100 -0
- package/__tests__/fixtures/parity/10-header-part.json +87 -0
- package/__tests__/fixtures/parity/11-footer-part.json +105 -0
- package/__tests__/fixtures/parity/12-announcement-bar.json +34 -0
- package/__tests__/fixtures/parity/13-product-slot-context.json +69 -0
- package/__tests__/fixtures/parity/14-published-snapshot-with-assets-and-custom-widget.json +84 -0
- package/__tests__/fixtures/parity/15-empty-document.json +4 -0
- package/__tests__/fixtures/parity/16-product-grid-and-featured.json +140 -0
- package/__tests__/fixtures/parity/17-collection-shelf-and-categories.json +153 -0
- package/__tests__/fixtures/parity/18-search-switches-and-greeting.json +80 -0
- package/__tests__/fixtures/parity/19-shop-slot-context.json +42 -0
- package/dist/index.cjs +17 -2
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +17 -2
- package/package.json +3 -2
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"sections": [
|
|
4
|
+
{
|
|
5
|
+
"id": "s0000129",
|
|
6
|
+
"type": "section",
|
|
7
|
+
"props": {
|
|
8
|
+
"paddingY": "m"
|
|
9
|
+
},
|
|
10
|
+
"columns": [
|
|
11
|
+
{
|
|
12
|
+
"id": "c0000123",
|
|
13
|
+
"type": "column",
|
|
14
|
+
"props": {
|
|
15
|
+
"width": 40
|
|
16
|
+
},
|
|
17
|
+
"children": [
|
|
18
|
+
{
|
|
19
|
+
"id": "w0000122",
|
|
20
|
+
"type": "catalog.search-box",
|
|
21
|
+
"v": 1,
|
|
22
|
+
"props": {}
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "c0000126",
|
|
28
|
+
"type": "column",
|
|
29
|
+
"props": {
|
|
30
|
+
"width": 30
|
|
31
|
+
},
|
|
32
|
+
"children": [
|
|
33
|
+
{
|
|
34
|
+
"id": "w0000124",
|
|
35
|
+
"type": "catalog.locale-switch",
|
|
36
|
+
"v": 1,
|
|
37
|
+
"props": {}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": "w0000125",
|
|
41
|
+
"type": "catalog.currency-switch",
|
|
42
|
+
"v": 1,
|
|
43
|
+
"props": {}
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "c0000128",
|
|
49
|
+
"type": "column",
|
|
50
|
+
"props": {
|
|
51
|
+
"width": 30
|
|
52
|
+
},
|
|
53
|
+
"children": [
|
|
54
|
+
{
|
|
55
|
+
"id": "w0000127",
|
|
56
|
+
"type": "commerce.customer-greeting",
|
|
57
|
+
"v": 1,
|
|
58
|
+
"props": {
|
|
59
|
+
"greeting": {
|
|
60
|
+
"en": "Welcome back, {name}"
|
|
61
|
+
},
|
|
62
|
+
"guest": {
|
|
63
|
+
"en": "Welcome, guest"
|
|
64
|
+
},
|
|
65
|
+
"align": "left",
|
|
66
|
+
"size": "m"
|
|
67
|
+
},
|
|
68
|
+
"data": {
|
|
69
|
+
"customer": {
|
|
70
|
+
"source": "throttle.customer",
|
|
71
|
+
"params": {}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"sections": [
|
|
4
|
+
{
|
|
5
|
+
"id": "s0000132",
|
|
6
|
+
"type": "section",
|
|
7
|
+
"props": {
|
|
8
|
+
"paddingY": "l"
|
|
9
|
+
},
|
|
10
|
+
"columns": [
|
|
11
|
+
{
|
|
12
|
+
"id": "c0000131",
|
|
13
|
+
"type": "column",
|
|
14
|
+
"props": {
|
|
15
|
+
"width": 100
|
|
16
|
+
},
|
|
17
|
+
"children": [
|
|
18
|
+
{
|
|
19
|
+
"id": "w0000130",
|
|
20
|
+
"type": "catalog.collection-shelf",
|
|
21
|
+
"v": 1,
|
|
22
|
+
"props": {
|
|
23
|
+
"title": {
|
|
24
|
+
"en": "More from this collection"
|
|
25
|
+
},
|
|
26
|
+
"layout": "grid",
|
|
27
|
+
"columnsDesktop": 4,
|
|
28
|
+
"columnsMobile": 2,
|
|
29
|
+
"showViewAll": false
|
|
30
|
+
},
|
|
31
|
+
"data": {
|
|
32
|
+
"collection": {
|
|
33
|
+
"source": "context.listing"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1958,6 +1958,17 @@ function propIssues(def, props, path, skipNull, common2 = false) {
|
|
|
1958
1958
|
}
|
|
1959
1959
|
return out;
|
|
1960
1960
|
}
|
|
1961
|
+
function contextIssues(id, ctx, path) {
|
|
1962
|
+
if (ctx.documentKind !== "slot" || ctx.slotContext === void 0) return [];
|
|
1963
|
+
if (id === `context.${ctx.slotContext}`) return [];
|
|
1964
|
+
return [
|
|
1965
|
+
issue(
|
|
1966
|
+
path,
|
|
1967
|
+
"SOURCE_NOT_ENABLED",
|
|
1968
|
+
ctx.slotContext === "none" ? `This slot gives no context, so "${id}" is not available` : `This slot gives context.${ctx.slotContext}, so "${id}" is not available`
|
|
1969
|
+
)
|
|
1970
|
+
];
|
|
1971
|
+
}
|
|
1961
1972
|
function bindingIssues(def, name, binding, ctx, path) {
|
|
1962
1973
|
const input = def.data?.[name];
|
|
1963
1974
|
if (input === void 0) {
|
|
@@ -1967,7 +1978,7 @@ function bindingIssues(def, name, binding, ctx, path) {
|
|
|
1967
1978
|
return [issue(path, "INVALID_SHAPE", "A binding is { source, params }")];
|
|
1968
1979
|
}
|
|
1969
1980
|
const { source: id } = binding;
|
|
1970
|
-
if (id.startsWith("context.")) return [];
|
|
1981
|
+
if (id.startsWith("context.")) return contextIssues(id, ctx, [...path, "source"]);
|
|
1971
1982
|
const source = ctx.registry.source(id);
|
|
1972
1983
|
if (source === void 0 || !ctx.enabledSources.has(id)) {
|
|
1973
1984
|
return [issue([...path, "source"], "SOURCE_NOT_ENABLED", `The data source "${id}" is not enabled`)];
|
|
@@ -2756,6 +2767,8 @@ var ALLOWED_ELEMENTS = [
|
|
|
2756
2767
|
"article",
|
|
2757
2768
|
"header",
|
|
2758
2769
|
"footer",
|
|
2770
|
+
"details",
|
|
2771
|
+
"summary",
|
|
2759
2772
|
"br",
|
|
2760
2773
|
"hr"
|
|
2761
2774
|
];
|
|
@@ -3017,7 +3030,9 @@ var CLOSES_P = /* @__PURE__ */ new Set([
|
|
|
3017
3030
|
"article",
|
|
3018
3031
|
"header",
|
|
3019
3032
|
"footer",
|
|
3020
|
-
"hr"
|
|
3033
|
+
"hr",
|
|
3034
|
+
"details",
|
|
3035
|
+
"summary"
|
|
3021
3036
|
]);
|
|
3022
3037
|
var forbidden = (message, pos) => new TemplateError("TEMPLATE_FORBIDDEN", message, pos);
|
|
3023
3038
|
var syntax = (message, pos) => new TemplateError("TEMPLATE_SYNTAX", message, pos);
|
package/dist/index.d.cts
CHANGED
|
@@ -3619,9 +3619,17 @@ declare const BASIC_WIDGET_DEFINITIONS: WidgetDefinition[];
|
|
|
3619
3619
|
|
|
3620
3620
|
/** Where a document lives. A part or slot may refuse some widgets. */
|
|
3621
3621
|
type DocumentKind = 'page' | 'part:header' | 'part:footer' | 'slot';
|
|
3622
|
+
/** What a slot point hands to the widgets in its document (`SlotPoint.context` of a pack). */
|
|
3623
|
+
type SlotContext = 'product' | 'listing' | 'none';
|
|
3622
3624
|
type OpContext = {
|
|
3623
3625
|
registry: WidgetRegistry;
|
|
3624
3626
|
documentKind: DocumentKind;
|
|
3627
|
+
/**
|
|
3628
|
+
* For a slot document: the context its slot key gives (`product.below` gives
|
|
3629
|
+
* `product`, `shop.below` gives `listing`). A `context.*` binding must name it.
|
|
3630
|
+
* Left out, a context binding is not checked against the slot.
|
|
3631
|
+
*/
|
|
3632
|
+
slotContext?: SlotContext;
|
|
3625
3633
|
/** Data source ids the merchant has enabled (a source is also known to the registry). */
|
|
3626
3634
|
enabledSources: ReadonlySet<string>;
|
|
3627
3635
|
};
|
|
@@ -3873,7 +3881,7 @@ declare function safeUrl(value: unknown, kind: SafeUrlKind, ctx: {
|
|
|
3873
3881
|
*/
|
|
3874
3882
|
declare const TEMPLATE_FILTERS: readonly ["upper", "lower", "truncate", "default"];
|
|
3875
3883
|
type TemplateFilterName = (typeof TEMPLATE_FILTERS)[number];
|
|
3876
|
-
declare const ALLOWED_ELEMENTS: readonly ["div", "span", "p", "h1", "h2", "h3", "h4", "h5", "h6", "a", "img", "ul", "ol", "li", "strong", "em", "small", "figure", "figcaption", "section", "article", "header", "footer", "br", "hr"];
|
|
3884
|
+
declare const ALLOWED_ELEMENTS: readonly ["div", "span", "p", "h1", "h2", "h3", "h4", "h5", "h6", "a", "img", "ul", "ol", "li", "strong", "em", "small", "figure", "figcaption", "section", "article", "header", "footer", "details", "summary", "br", "hr"];
|
|
3877
3885
|
type AllowedElement = (typeof ALLOWED_ELEMENTS)[number];
|
|
3878
3886
|
/** Elements with no children and no closing tag. */
|
|
3879
3887
|
declare const VOID_ELEMENTS: readonly AllowedElement[];
|
|
@@ -4089,4 +4097,4 @@ type ValidateCustomWidgetResult = {
|
|
|
4089
4097
|
*/
|
|
4090
4098
|
declare function validateCustomWidget(def: unknown, registry: WidgetRegistry): ValidateCustomWidgetResult;
|
|
4091
4099
|
|
|
4092
|
-
export { AGENT_MAX_OPS, ALLOWED_ATTRS, ALLOWED_ELEMENTS, ALLOWED_ROLES, ANCHOR_RE, type AllowedElement, type AnyNode, type ApplyResult, type AttrPart, BASIC_WIDGET_DEFINITIONS, BIDI_CONTROL_RE, BREAKPOINTS, CATALOG_STRING_KEYS, CLASS_TOKEN_RE, COLOR_VALUE_RE, COMMON_SETTING_KEYS, COMMON_WIDGET_SETTINGS, CSS_CONTROLS, CURRENT_SCHEMA_VERSION, type CatalogStringKey, type ColumnNode, type ColumnProps, type CompositeDefinition, type CustomWidgetDefinition, type CustomWidgetSnapshot, DATA_ATTR_RE, DATA_RESULT_TYPES, type DataBinding, type DataInputDefinition, type DataResultType, type DataSourceDescriptor, type DocOp, type DocOpDevice, type DocumentKind, EACH_ITERATION_CAP, type EachNode, type ElementAttr, type ElementNode, type FieldSpec, type Filter, type FrozenAsset, ISSUE_CODES, type IconName, type IfNode, type InnerColumnNode, type InnerSectionNode, type Issue, type IssueCode, LIMITS, LOCALE_TAG_RE, type LocalizedText, MAX_ISSUES, MAX_TEMPLATE_WEIGHT, type MenuItem, type MenuTarget, NODE_ID_RE, type NodeId, type OpContext, type OutputNode, type Overrides, PREVIEW_WIDTHS, type PageDocument, type ParentId, type ParseTemplateResult, type PathSegment, type Placement, type PlacementCode, RESERVED_CLASS_PREFIXES, RESERVED_DATA_PREFIX, type ResponsiveDevice, SAFE_HREF, SETTING_CONTROLS, SETTING_TABS, SITE_ASSET_PATHS, SITE_FONTS, SITE_FONT_FAMILIES, SITE_SETTINGS_SCHEMA_VERSION, SITE_STRING_DEFAULTS, SITE_STRING_KEYS, SITE_STRING_NAMESPACES, SPACING_TOKENS, type SafeUrlKind, type SanitizeCssResult, type SectionNode, type SectionProps, type SettingField, type SettingValue, type SiteFont, type SiteFontCategory, type SiteFontFamily, type SitePalette, type SiteSettings, type SiteSettingsInput, type SiteStringKey, TEMPLATE_FILTERS, THROTTLE_PK_RE, type TemplateAst, type TemplateContext, type TemplateDefinition, type TemplateFilterName, type TemplateNode, type TextNode, type UnlessNode, type UpgradeResult, VOID_ELEMENTS, type ValidateCustomWidgetResult, WIDGET_GROUPS, WIDGET_TYPE_RE, type WidgetDefinition, type WidgetMigration, type WidgetNode, type WidgetRegistry, type WidgetType, agentDocOpSchema, agentDocOpsSchema, applyOps, assetIdSchema, canPlace, capIssues, checkLimits, checkTopLevel, checkWidgetPart, colorValueSchema, columnPropsSchema, createRegistry, customWidgetSnapshotSchema, dataBindingSchema, dataSourceDescriptorSchema, defaultSiteSettings, docOpSchema, emptyDocument, fieldSpecSchema, formatPath, frozenAssetSchema, innerSectionNodeSchema, invertOps, isReservedClass, isSettingValue, localeTagSchema, localizedTextSchema, makeIssue, menuItemSchema, menuTargetSchema, newNodeId, nodeIdSchema, pageDocumentSchema, parseTemplate, resolveColumnProps, resolveColumnWidths, resolveResponsive, safeUrl, sanitizeWidgetCss, sectionNodeSchema, sectionPropsSchema, settingFieldSchema, settingValueSchema, siteSettingsSchema, spacingValueSchema, templateWeight, upgradeDocument, upgradeNodes, utf8Length, validateCustomWidget, validateDocument, validateSettingValue, validateTemplate, validateWidgetProps, walkNodes, widgetDefinitionSchema, widgetNodeSchema, wrapColumnRows, zodIssues };
|
|
4100
|
+
export { AGENT_MAX_OPS, ALLOWED_ATTRS, ALLOWED_ELEMENTS, ALLOWED_ROLES, ANCHOR_RE, type AllowedElement, type AnyNode, type ApplyResult, type AttrPart, BASIC_WIDGET_DEFINITIONS, BIDI_CONTROL_RE, BREAKPOINTS, CATALOG_STRING_KEYS, CLASS_TOKEN_RE, COLOR_VALUE_RE, COMMON_SETTING_KEYS, COMMON_WIDGET_SETTINGS, CSS_CONTROLS, CURRENT_SCHEMA_VERSION, type CatalogStringKey, type ColumnNode, type ColumnProps, type CompositeDefinition, type CustomWidgetDefinition, type CustomWidgetSnapshot, DATA_ATTR_RE, DATA_RESULT_TYPES, type DataBinding, type DataInputDefinition, type DataResultType, type DataSourceDescriptor, type DocOp, type DocOpDevice, type DocumentKind, EACH_ITERATION_CAP, type EachNode, type ElementAttr, type ElementNode, type FieldSpec, type Filter, type FrozenAsset, ISSUE_CODES, type IconName, type IfNode, type InnerColumnNode, type InnerSectionNode, type Issue, type IssueCode, LIMITS, LOCALE_TAG_RE, type LocalizedText, MAX_ISSUES, MAX_TEMPLATE_WEIGHT, type MenuItem, type MenuTarget, NODE_ID_RE, type NodeId, type OpContext, type OutputNode, type Overrides, PREVIEW_WIDTHS, type PageDocument, type ParentId, type ParseTemplateResult, type PathSegment, type Placement, type PlacementCode, RESERVED_CLASS_PREFIXES, RESERVED_DATA_PREFIX, type ResponsiveDevice, SAFE_HREF, SETTING_CONTROLS, SETTING_TABS, SITE_ASSET_PATHS, SITE_FONTS, SITE_FONT_FAMILIES, SITE_SETTINGS_SCHEMA_VERSION, SITE_STRING_DEFAULTS, SITE_STRING_KEYS, SITE_STRING_NAMESPACES, SPACING_TOKENS, type SafeUrlKind, type SanitizeCssResult, type SectionNode, type SectionProps, type SettingField, type SettingValue, type SiteFont, type SiteFontCategory, type SiteFontFamily, type SitePalette, type SiteSettings, type SiteSettingsInput, type SiteStringKey, type SlotContext, TEMPLATE_FILTERS, THROTTLE_PK_RE, type TemplateAst, type TemplateContext, type TemplateDefinition, type TemplateFilterName, type TemplateNode, type TextNode, type UnlessNode, type UpgradeResult, VOID_ELEMENTS, type ValidateCustomWidgetResult, WIDGET_GROUPS, WIDGET_TYPE_RE, type WidgetDefinition, type WidgetMigration, type WidgetNode, type WidgetRegistry, type WidgetType, agentDocOpSchema, agentDocOpsSchema, applyOps, assetIdSchema, canPlace, capIssues, checkLimits, checkTopLevel, checkWidgetPart, colorValueSchema, columnPropsSchema, createRegistry, customWidgetSnapshotSchema, dataBindingSchema, dataSourceDescriptorSchema, defaultSiteSettings, docOpSchema, emptyDocument, fieldSpecSchema, formatPath, frozenAssetSchema, innerSectionNodeSchema, invertOps, isReservedClass, isSettingValue, localeTagSchema, localizedTextSchema, makeIssue, menuItemSchema, menuTargetSchema, newNodeId, nodeIdSchema, pageDocumentSchema, parseTemplate, resolveColumnProps, resolveColumnWidths, resolveResponsive, safeUrl, sanitizeWidgetCss, sectionNodeSchema, sectionPropsSchema, settingFieldSchema, settingValueSchema, siteSettingsSchema, spacingValueSchema, templateWeight, upgradeDocument, upgradeNodes, utf8Length, validateCustomWidget, validateDocument, validateSettingValue, validateTemplate, validateWidgetProps, walkNodes, widgetDefinitionSchema, widgetNodeSchema, wrapColumnRows, zodIssues };
|
package/dist/index.d.ts
CHANGED
|
@@ -3619,9 +3619,17 @@ declare const BASIC_WIDGET_DEFINITIONS: WidgetDefinition[];
|
|
|
3619
3619
|
|
|
3620
3620
|
/** Where a document lives. A part or slot may refuse some widgets. */
|
|
3621
3621
|
type DocumentKind = 'page' | 'part:header' | 'part:footer' | 'slot';
|
|
3622
|
+
/** What a slot point hands to the widgets in its document (`SlotPoint.context` of a pack). */
|
|
3623
|
+
type SlotContext = 'product' | 'listing' | 'none';
|
|
3622
3624
|
type OpContext = {
|
|
3623
3625
|
registry: WidgetRegistry;
|
|
3624
3626
|
documentKind: DocumentKind;
|
|
3627
|
+
/**
|
|
3628
|
+
* For a slot document: the context its slot key gives (`product.below` gives
|
|
3629
|
+
* `product`, `shop.below` gives `listing`). A `context.*` binding must name it.
|
|
3630
|
+
* Left out, a context binding is not checked against the slot.
|
|
3631
|
+
*/
|
|
3632
|
+
slotContext?: SlotContext;
|
|
3625
3633
|
/** Data source ids the merchant has enabled (a source is also known to the registry). */
|
|
3626
3634
|
enabledSources: ReadonlySet<string>;
|
|
3627
3635
|
};
|
|
@@ -3873,7 +3881,7 @@ declare function safeUrl(value: unknown, kind: SafeUrlKind, ctx: {
|
|
|
3873
3881
|
*/
|
|
3874
3882
|
declare const TEMPLATE_FILTERS: readonly ["upper", "lower", "truncate", "default"];
|
|
3875
3883
|
type TemplateFilterName = (typeof TEMPLATE_FILTERS)[number];
|
|
3876
|
-
declare const ALLOWED_ELEMENTS: readonly ["div", "span", "p", "h1", "h2", "h3", "h4", "h5", "h6", "a", "img", "ul", "ol", "li", "strong", "em", "small", "figure", "figcaption", "section", "article", "header", "footer", "br", "hr"];
|
|
3884
|
+
declare const ALLOWED_ELEMENTS: readonly ["div", "span", "p", "h1", "h2", "h3", "h4", "h5", "h6", "a", "img", "ul", "ol", "li", "strong", "em", "small", "figure", "figcaption", "section", "article", "header", "footer", "details", "summary", "br", "hr"];
|
|
3877
3885
|
type AllowedElement = (typeof ALLOWED_ELEMENTS)[number];
|
|
3878
3886
|
/** Elements with no children and no closing tag. */
|
|
3879
3887
|
declare const VOID_ELEMENTS: readonly AllowedElement[];
|
|
@@ -4089,4 +4097,4 @@ type ValidateCustomWidgetResult = {
|
|
|
4089
4097
|
*/
|
|
4090
4098
|
declare function validateCustomWidget(def: unknown, registry: WidgetRegistry): ValidateCustomWidgetResult;
|
|
4091
4099
|
|
|
4092
|
-
export { AGENT_MAX_OPS, ALLOWED_ATTRS, ALLOWED_ELEMENTS, ALLOWED_ROLES, ANCHOR_RE, type AllowedElement, type AnyNode, type ApplyResult, type AttrPart, BASIC_WIDGET_DEFINITIONS, BIDI_CONTROL_RE, BREAKPOINTS, CATALOG_STRING_KEYS, CLASS_TOKEN_RE, COLOR_VALUE_RE, COMMON_SETTING_KEYS, COMMON_WIDGET_SETTINGS, CSS_CONTROLS, CURRENT_SCHEMA_VERSION, type CatalogStringKey, type ColumnNode, type ColumnProps, type CompositeDefinition, type CustomWidgetDefinition, type CustomWidgetSnapshot, DATA_ATTR_RE, DATA_RESULT_TYPES, type DataBinding, type DataInputDefinition, type DataResultType, type DataSourceDescriptor, type DocOp, type DocOpDevice, type DocumentKind, EACH_ITERATION_CAP, type EachNode, type ElementAttr, type ElementNode, type FieldSpec, type Filter, type FrozenAsset, ISSUE_CODES, type IconName, type IfNode, type InnerColumnNode, type InnerSectionNode, type Issue, type IssueCode, LIMITS, LOCALE_TAG_RE, type LocalizedText, MAX_ISSUES, MAX_TEMPLATE_WEIGHT, type MenuItem, type MenuTarget, NODE_ID_RE, type NodeId, type OpContext, type OutputNode, type Overrides, PREVIEW_WIDTHS, type PageDocument, type ParentId, type ParseTemplateResult, type PathSegment, type Placement, type PlacementCode, RESERVED_CLASS_PREFIXES, RESERVED_DATA_PREFIX, type ResponsiveDevice, SAFE_HREF, SETTING_CONTROLS, SETTING_TABS, SITE_ASSET_PATHS, SITE_FONTS, SITE_FONT_FAMILIES, SITE_SETTINGS_SCHEMA_VERSION, SITE_STRING_DEFAULTS, SITE_STRING_KEYS, SITE_STRING_NAMESPACES, SPACING_TOKENS, type SafeUrlKind, type SanitizeCssResult, type SectionNode, type SectionProps, type SettingField, type SettingValue, type SiteFont, type SiteFontCategory, type SiteFontFamily, type SitePalette, type SiteSettings, type SiteSettingsInput, type SiteStringKey, TEMPLATE_FILTERS, THROTTLE_PK_RE, type TemplateAst, type TemplateContext, type TemplateDefinition, type TemplateFilterName, type TemplateNode, type TextNode, type UnlessNode, type UpgradeResult, VOID_ELEMENTS, type ValidateCustomWidgetResult, WIDGET_GROUPS, WIDGET_TYPE_RE, type WidgetDefinition, type WidgetMigration, type WidgetNode, type WidgetRegistry, type WidgetType, agentDocOpSchema, agentDocOpsSchema, applyOps, assetIdSchema, canPlace, capIssues, checkLimits, checkTopLevel, checkWidgetPart, colorValueSchema, columnPropsSchema, createRegistry, customWidgetSnapshotSchema, dataBindingSchema, dataSourceDescriptorSchema, defaultSiteSettings, docOpSchema, emptyDocument, fieldSpecSchema, formatPath, frozenAssetSchema, innerSectionNodeSchema, invertOps, isReservedClass, isSettingValue, localeTagSchema, localizedTextSchema, makeIssue, menuItemSchema, menuTargetSchema, newNodeId, nodeIdSchema, pageDocumentSchema, parseTemplate, resolveColumnProps, resolveColumnWidths, resolveResponsive, safeUrl, sanitizeWidgetCss, sectionNodeSchema, sectionPropsSchema, settingFieldSchema, settingValueSchema, siteSettingsSchema, spacingValueSchema, templateWeight, upgradeDocument, upgradeNodes, utf8Length, validateCustomWidget, validateDocument, validateSettingValue, validateTemplate, validateWidgetProps, walkNodes, widgetDefinitionSchema, widgetNodeSchema, wrapColumnRows, zodIssues };
|
|
4100
|
+
export { AGENT_MAX_OPS, ALLOWED_ATTRS, ALLOWED_ELEMENTS, ALLOWED_ROLES, ANCHOR_RE, type AllowedElement, type AnyNode, type ApplyResult, type AttrPart, BASIC_WIDGET_DEFINITIONS, BIDI_CONTROL_RE, BREAKPOINTS, CATALOG_STRING_KEYS, CLASS_TOKEN_RE, COLOR_VALUE_RE, COMMON_SETTING_KEYS, COMMON_WIDGET_SETTINGS, CSS_CONTROLS, CURRENT_SCHEMA_VERSION, type CatalogStringKey, type ColumnNode, type ColumnProps, type CompositeDefinition, type CustomWidgetDefinition, type CustomWidgetSnapshot, DATA_ATTR_RE, DATA_RESULT_TYPES, type DataBinding, type DataInputDefinition, type DataResultType, type DataSourceDescriptor, type DocOp, type DocOpDevice, type DocumentKind, EACH_ITERATION_CAP, type EachNode, type ElementAttr, type ElementNode, type FieldSpec, type Filter, type FrozenAsset, ISSUE_CODES, type IconName, type IfNode, type InnerColumnNode, type InnerSectionNode, type Issue, type IssueCode, LIMITS, LOCALE_TAG_RE, type LocalizedText, MAX_ISSUES, MAX_TEMPLATE_WEIGHT, type MenuItem, type MenuTarget, NODE_ID_RE, type NodeId, type OpContext, type OutputNode, type Overrides, PREVIEW_WIDTHS, type PageDocument, type ParentId, type ParseTemplateResult, type PathSegment, type Placement, type PlacementCode, RESERVED_CLASS_PREFIXES, RESERVED_DATA_PREFIX, type ResponsiveDevice, SAFE_HREF, SETTING_CONTROLS, SETTING_TABS, SITE_ASSET_PATHS, SITE_FONTS, SITE_FONT_FAMILIES, SITE_SETTINGS_SCHEMA_VERSION, SITE_STRING_DEFAULTS, SITE_STRING_KEYS, SITE_STRING_NAMESPACES, SPACING_TOKENS, type SafeUrlKind, type SanitizeCssResult, type SectionNode, type SectionProps, type SettingField, type SettingValue, type SiteFont, type SiteFontCategory, type SiteFontFamily, type SitePalette, type SiteSettings, type SiteSettingsInput, type SiteStringKey, type SlotContext, TEMPLATE_FILTERS, THROTTLE_PK_RE, type TemplateAst, type TemplateContext, type TemplateDefinition, type TemplateFilterName, type TemplateNode, type TextNode, type UnlessNode, type UpgradeResult, VOID_ELEMENTS, type ValidateCustomWidgetResult, WIDGET_GROUPS, WIDGET_TYPE_RE, type WidgetDefinition, type WidgetMigration, type WidgetNode, type WidgetRegistry, type WidgetType, agentDocOpSchema, agentDocOpsSchema, applyOps, assetIdSchema, canPlace, capIssues, checkLimits, checkTopLevel, checkWidgetPart, colorValueSchema, columnPropsSchema, createRegistry, customWidgetSnapshotSchema, dataBindingSchema, dataSourceDescriptorSchema, defaultSiteSettings, docOpSchema, emptyDocument, fieldSpecSchema, formatPath, frozenAssetSchema, innerSectionNodeSchema, invertOps, isReservedClass, isSettingValue, localeTagSchema, localizedTextSchema, makeIssue, menuItemSchema, menuTargetSchema, newNodeId, nodeIdSchema, pageDocumentSchema, parseTemplate, resolveColumnProps, resolveColumnWidths, resolveResponsive, safeUrl, sanitizeWidgetCss, sectionNodeSchema, sectionPropsSchema, settingFieldSchema, settingValueSchema, siteSettingsSchema, spacingValueSchema, templateWeight, upgradeDocument, upgradeNodes, utf8Length, validateCustomWidget, validateDocument, validateSettingValue, validateTemplate, validateWidgetProps, walkNodes, widgetDefinitionSchema, widgetNodeSchema, wrapColumnRows, zodIssues };
|
package/dist/index.js
CHANGED
|
@@ -1831,6 +1831,17 @@ function propIssues(def, props, path, skipNull, common2 = false) {
|
|
|
1831
1831
|
}
|
|
1832
1832
|
return out;
|
|
1833
1833
|
}
|
|
1834
|
+
function contextIssues(id, ctx, path) {
|
|
1835
|
+
if (ctx.documentKind !== "slot" || ctx.slotContext === void 0) return [];
|
|
1836
|
+
if (id === `context.${ctx.slotContext}`) return [];
|
|
1837
|
+
return [
|
|
1838
|
+
issue(
|
|
1839
|
+
path,
|
|
1840
|
+
"SOURCE_NOT_ENABLED",
|
|
1841
|
+
ctx.slotContext === "none" ? `This slot gives no context, so "${id}" is not available` : `This slot gives context.${ctx.slotContext}, so "${id}" is not available`
|
|
1842
|
+
)
|
|
1843
|
+
];
|
|
1844
|
+
}
|
|
1834
1845
|
function bindingIssues(def, name, binding, ctx, path) {
|
|
1835
1846
|
const input = def.data?.[name];
|
|
1836
1847
|
if (input === void 0) {
|
|
@@ -1840,7 +1851,7 @@ function bindingIssues(def, name, binding, ctx, path) {
|
|
|
1840
1851
|
return [issue(path, "INVALID_SHAPE", "A binding is { source, params }")];
|
|
1841
1852
|
}
|
|
1842
1853
|
const { source: id } = binding;
|
|
1843
|
-
if (id.startsWith("context.")) return [];
|
|
1854
|
+
if (id.startsWith("context.")) return contextIssues(id, ctx, [...path, "source"]);
|
|
1844
1855
|
const source = ctx.registry.source(id);
|
|
1845
1856
|
if (source === void 0 || !ctx.enabledSources.has(id)) {
|
|
1846
1857
|
return [issue([...path, "source"], "SOURCE_NOT_ENABLED", `The data source "${id}" is not enabled`)];
|
|
@@ -2629,6 +2640,8 @@ var ALLOWED_ELEMENTS = [
|
|
|
2629
2640
|
"article",
|
|
2630
2641
|
"header",
|
|
2631
2642
|
"footer",
|
|
2643
|
+
"details",
|
|
2644
|
+
"summary",
|
|
2632
2645
|
"br",
|
|
2633
2646
|
"hr"
|
|
2634
2647
|
];
|
|
@@ -2890,7 +2903,9 @@ var CLOSES_P = /* @__PURE__ */ new Set([
|
|
|
2890
2903
|
"article",
|
|
2891
2904
|
"header",
|
|
2892
2905
|
"footer",
|
|
2893
|
-
"hr"
|
|
2906
|
+
"hr",
|
|
2907
|
+
"details",
|
|
2908
|
+
"summary"
|
|
2894
2909
|
]);
|
|
2895
2910
|
var forbidden = (message, pos) => new TemplateError("TEMPLATE_FORBIDDEN", message, pos);
|
|
2896
2911
|
var syntax = (message, pos) => new TemplateError("TEMPLATE_SYNTAX", message, pos);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usethrottle/builder-schema",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Throttle Builder page document, site settings, responsive rules, limits and basic widget definitions. Pure TypeScript plus zod, no React and no I/O.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
|
-
"dist"
|
|
22
|
+
"dist",
|
|
23
|
+
"__tests__/fixtures/parity"
|
|
23
24
|
],
|
|
24
25
|
"sideEffects": [
|
|
25
26
|
"./dist/index.js",
|