@shapio/schema 0.5.9 → 0.5.10
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/index.d.ts +11 -11
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/{resolve-viddCEYd.js → resolve-Csjpkpue.js} +2 -2
- package/dist/{resolve-viddCEYd.js.map → resolve-Csjpkpue.js.map} +1 -1
- package/dist/{resolve-7-z9VQqw.d.ts → resolve-DlXILdG3.d.ts} +2 -2
- package/dist/seoResolve.d.ts +1 -1
- package/dist/seoResolve.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as isEmptyRichText, i as RichTextResult, n as RichTextNode, o as richTextMediaIds, r as RichTextProblem, s as validateRichText, t as RichTextDocument } from "./validate-Oyo0GJ9j.js";
|
|
2
|
-
import { S as SeoFieldKey, _ as SEO_FIELD_IDS, a as EMPTY_SEO_DEFAULTS, b as SEO_TITLE_TEMPLATE_PATTERN, c as seoDefaultsForLocale, d as SeoLocaleDefaults, f as SeoLocaleDefaultsSchema, g as SEO_EDITOR_ID, h as SEO_DESCRIPTION_SOFT_MAX, i as resolveSeo, l as SeoDefaults, m as SEO_COMPONENT_ID, n as ResolveSeoContext, o as applyTitleTemplate, p as SEO_COMPONENT_API_KEY, r as SeoKeys, s as isValidTitleTemplate, t as DEFAULT_SEO_KEYS, u as SeoDefaultsSchema, v as SEO_TITLE_PLACEHOLDER, x as SEO_TWITTER_HANDLE_PATTERN, y as SEO_TITLE_SOFT_MAX } from "./resolve-
|
|
2
|
+
import { S as SeoFieldKey, _ as SEO_FIELD_IDS, a as EMPTY_SEO_DEFAULTS, b as SEO_TITLE_TEMPLATE_PATTERN, c as seoDefaultsForLocale, d as SeoLocaleDefaults, f as SeoLocaleDefaultsSchema, g as SEO_EDITOR_ID, h as SEO_DESCRIPTION_SOFT_MAX, i as resolveSeo, l as SeoDefaults, m as SEO_COMPONENT_ID, n as ResolveSeoContext, o as applyTitleTemplate, p as SEO_COMPONENT_API_KEY, r as SeoKeys, s as isValidTitleTemplate, t as DEFAULT_SEO_KEYS, u as SeoDefaultsSchema, v as SEO_TITLE_PLACEHOLDER, x as SEO_TWITTER_HANDLE_PATTERN, y as SEO_TITLE_SOFT_MAX } from "./resolve-DlXILdG3.js";
|
|
3
3
|
import { Static, TSchema, Type } from "typebox";
|
|
4
4
|
//#region src/ids.d.ts
|
|
5
5
|
/**
|
|
@@ -660,28 +660,28 @@ export declare const UID_PATTERN: RegExp;
|
|
|
660
660
|
export declare const RICHTEXT_FORMAT = "shapio-richtext";
|
|
661
661
|
export declare const RICHTEXT_FORMAT_VERSION = 1;
|
|
662
662
|
//#endregion
|
|
663
|
-
//#region src/editors/
|
|
663
|
+
//#region src/editors/catalog.d.ts
|
|
664
664
|
/**
|
|
665
665
|
* Built-in editors (ADR 0009): which data types each can edit and the schema of its options. The server
|
|
666
|
-
* validates every field's editor choice against this
|
|
666
|
+
* validates every field's editor choice against this catalog, so selecting and configuring an editor is
|
|
667
667
|
* runtime metadata. Custom editors (loaded at runtime from the project) use namespaced IDs containing a dot,
|
|
668
668
|
* e.g. `acme.colorWheel`; their options are free-form JSON here because their schema lives in the project.
|
|
669
669
|
*/
|
|
670
|
-
export type
|
|
670
|
+
export type EditorCatalogEntry = {
|
|
671
671
|
id: string;
|
|
672
672
|
dataTypes: readonly DataType[];
|
|
673
673
|
optionsSchema: TSchema;
|
|
674
674
|
/** Extra compatibility rule beyond the data type (e.g. radio buttons only for single-value enums). */
|
|
675
675
|
supports?: (field: FieldDefinition) => boolean;
|
|
676
676
|
};
|
|
677
|
-
export declare const
|
|
677
|
+
export declare const EDITOR_CATALOG: ReadonlyMap<string, EditorCatalogEntry>;
|
|
678
678
|
/** The editor a field gets when its definition names none. */
|
|
679
679
|
export declare const DEFAULT_EDITORS: Readonly<Record<DataType, string>>;
|
|
680
680
|
/** `vendor.name` (letters, digits, `_`, `-`), e.g. `acme.colorWheel`. Built-in IDs never contain a dot. */
|
|
681
681
|
export declare const CUSTOM_EDITOR_ID_PATTERN: RegExp;
|
|
682
682
|
export declare const isCustomEditorId: (id: string) => boolean;
|
|
683
683
|
/** Built-in editors that can edit this field (for the admin's editor picker). */
|
|
684
|
-
export declare const listCompatibleEditors: (field: FieldDefinition) =>
|
|
684
|
+
export declare const listCompatibleEditors: (field: FieldDefinition) => EditorCatalogEntry[];
|
|
685
685
|
//#endregion
|
|
686
686
|
//#region src/display/layout.d.ts
|
|
687
687
|
/**
|
|
@@ -762,7 +762,7 @@ export type FormLayout = {
|
|
|
762
762
|
/**
|
|
763
763
|
* The entry form's layout (`display.layout: 'form'`): every live field, the title included, in sections.
|
|
764
764
|
* Field order decides everything: a group's section sits where its first field appears, with its fields in
|
|
765
|
-
* field order, and every run of consecutive ungrouped fields is an
|
|
765
|
+
* field order, and every run of consecutive ungrouped fields is an unlabeled section of its own at its
|
|
766
766
|
* place. So name, price, sku, description with a Pricing group (price, sku) reads [name], Pricing [price,
|
|
767
767
|
* sku], [description]. Unknown and deprecated ids are skipped. Pure: no values, no I/O.
|
|
768
768
|
*/
|
|
@@ -1476,11 +1476,11 @@ export declare const THEME_KEY_PATTERN: RegExp;
|
|
|
1476
1476
|
export declare const BUILT_IN_THEME_KEYS: readonly ["shapio", "classic", "murdered-out", "forest", "snowed", "butter"];
|
|
1477
1477
|
export type BuiltInThemeKey = (typeof BUILT_IN_THEME_KEYS)[number];
|
|
1478
1478
|
/**
|
|
1479
|
-
* A token value an extension may use: a hex
|
|
1479
|
+
* A token value an extension may use: a hex color or a color function whose arguments are numbers, units
|
|
1480
1480
|
* and separators only (no `;`, quotes, braces or nested functions such as `url()` or `var()`), so a value
|
|
1481
1481
|
* can never escape its declaration.
|
|
1482
1482
|
*/
|
|
1483
|
-
export declare const
|
|
1483
|
+
export declare const THEME_COLOR_PATTERN: RegExp;
|
|
1484
1484
|
//#endregion
|
|
1485
1485
|
//#region src/themes/contrast.d.ts
|
|
1486
1486
|
/**
|
|
@@ -1497,14 +1497,14 @@ export declare const THEME_UI_PAIRS: readonly ContrastPair[];
|
|
|
1497
1497
|
* passes, and other selected surfaces hold no controls.
|
|
1498
1498
|
*/
|
|
1499
1499
|
export declare const THEME_DARK_UI_PAIRS: readonly ContrastPair[];
|
|
1500
|
-
/** The WCAG contrast ratio of two `#rrggbb`
|
|
1500
|
+
/** The WCAG contrast ratio of two `#rrggbb` colors. */
|
|
1501
1501
|
export declare const contrastRatio: (a: string, b: string) => number;
|
|
1502
1502
|
export type ContrastCheck = {
|
|
1503
1503
|
foreground: string;
|
|
1504
1504
|
background: string;
|
|
1505
1505
|
/** 4.5 for text, 3 for controls. */
|
|
1506
1506
|
required: number;
|
|
1507
|
-
/** Undefined when a value is not a `#rrggbb`
|
|
1507
|
+
/** Undefined when a value is not a `#rrggbb` color (functions such as `oklch()` are not checked). */
|
|
1508
1508
|
ratio: number | undefined;
|
|
1509
1509
|
};
|
|
1510
1510
|
/** Every pair the variant must meet, with its ratio. Missing tokens report an undefined ratio. */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as STABLE_ID_PATTERN, a as MAX_RICHTEXT_DEPTH, c as BIGINTEGER_PATTERN, d as DECIMAL_PATTERN, f as RICHTEXT_FORMAT, g as UID_PATTERN, h as TIME_PATTERN, i as MARK_RULES, l as DATETIME_PATTERN, m as SLUG_PATTERN, n as richTextMediaIds, o as NODE_RULES, p as RICHTEXT_FORMAT_VERSION, r as validateRichText, s as SAFE_LINK_PATTERN, t as isEmptyRichText, u as DATE_PATTERN, v as createStableId, y as isStableId } from "./validate-BQGutaBo.js";
|
|
2
|
-
import { a as isValidTitleTemplate, c as SEO_COMPONENT_ID, d as SEO_FIELD_IDS, f as SEO_TITLE_PLACEHOLDER, h as SEO_TWITTER_HANDLE_PATTERN, i as applyTitleTemplate, l as SEO_DESCRIPTION_SOFT_MAX, m as SEO_TITLE_TEMPLATE_PATTERN, n as resolveSeo, o as seoDefaultsForLocale, p as SEO_TITLE_SOFT_MAX, r as EMPTY_SEO_DEFAULTS, s as SEO_COMPONENT_API_KEY, t as DEFAULT_SEO_KEYS, u as SEO_EDITOR_ID } from "./resolve-
|
|
2
|
+
import { a as isValidTitleTemplate, c as SEO_COMPONENT_ID, d as SEO_FIELD_IDS, f as SEO_TITLE_PLACEHOLDER, h as SEO_TWITTER_HANDLE_PATTERN, i as applyTitleTemplate, l as SEO_DESCRIPTION_SOFT_MAX, m as SEO_TITLE_TEMPLATE_PATTERN, n as resolveSeo, o as seoDefaultsForLocale, p as SEO_TITLE_SOFT_MAX, r as EMPTY_SEO_DEFAULTS, s as SEO_COMPONENT_API_KEY, t as DEFAULT_SEO_KEYS, u as SEO_EDITOR_ID } from "./resolve-Csjpkpue.js";
|
|
3
3
|
import { Type } from "typebox";
|
|
4
4
|
import pluralize from "pluralize";
|
|
5
5
|
import { Value } from "typebox/value";
|
|
@@ -414,7 +414,7 @@ const SETTINGS_SCHEMAS = {
|
|
|
414
414
|
/** Whether a field holds the built-in SEO component (by stable ID, whatever its API ID or editor). */
|
|
415
415
|
const isSeoField = (field) => field.type === "component" && field.settings.component === "f3905a00-d2a3-4c62-899a-c894bfd6cb9b" && !field.settings.repeatable;
|
|
416
416
|
//#endregion
|
|
417
|
-
//#region src/editors/
|
|
417
|
+
//#region src/editors/catalog.ts
|
|
418
418
|
const closed$1 = { additionalProperties: false };
|
|
419
419
|
const Placeholder = Type.Optional(Type.String({ maxLength: 200 }));
|
|
420
420
|
const isMultipleEnum = (field) => field.type === "enum" && field.settings.multiple;
|
|
@@ -568,7 +568,7 @@ const entries = [
|
|
|
568
568
|
optionsSchema: Type.Object({ collapsed: Type.Optional(Type.Boolean()) }, closed$1)
|
|
569
569
|
}
|
|
570
570
|
];
|
|
571
|
-
const
|
|
571
|
+
const EDITOR_CATALOG = new Map(entries.map((entry) => [entry.id, entry]));
|
|
572
572
|
/** The editor a field gets when its definition names none. */
|
|
573
573
|
const DEFAULT_EDITORS = {
|
|
574
574
|
string: "textInput",
|
|
@@ -736,7 +736,7 @@ const ungroupedSectionId = (first, groupIds) => {
|
|
|
736
736
|
/**
|
|
737
737
|
* The entry form's layout (`display.layout: 'form'`): every live field, the title included, in sections.
|
|
738
738
|
* Field order decides everything: a group's section sits where its first field appears, with its fields in
|
|
739
|
-
* field order, and every run of consecutive ungrouped fields is an
|
|
739
|
+
* field order, and every run of consecutive ungrouped fields is an unlabeled section of its own at its
|
|
740
740
|
* place. So name, price, sku, description with a Pricing group (price, sku) reads [name], Pricing [price,
|
|
741
741
|
* sku], [description]. Unknown and deprecated ids are skipped. Pure: no values, no I/O.
|
|
742
742
|
*/
|
|
@@ -1555,7 +1555,7 @@ const checkFlags = (field, path, isComponent) => {
|
|
|
1555
1555
|
const checkEditor = (field, path) => {
|
|
1556
1556
|
const { id, options } = field.editor;
|
|
1557
1557
|
if (isCustomEditorId(id)) return [];
|
|
1558
|
-
const entry =
|
|
1558
|
+
const entry = EDITOR_CATALOG.get(id);
|
|
1559
1559
|
if (!entry) return [issue(`${path}/editor/id`, "UNKNOWN_EDITOR", `"${id}" is not a built-in editor (custom editors use a vendor.name ID)`)];
|
|
1560
1560
|
if (!entry.dataTypes.includes(field.type) || !(entry.supports?.(field) ?? true)) return [issue(`${path}/editor/id`, "INCOMPATIBLE_EDITOR", `the ${id} editor cannot edit this ${field.type} field`)];
|
|
1561
1561
|
return collectSchemaErrors(entry.optionsSchema, options, `${path}/editor/options`).map((error) => issue(error.path, "INVALID_EDITOR_OPTIONS", error.message));
|
|
@@ -2996,11 +2996,11 @@ const BUILT_IN_THEME_KEYS = [
|
|
|
2996
2996
|
"butter"
|
|
2997
2997
|
];
|
|
2998
2998
|
/**
|
|
2999
|
-
* A token value an extension may use: a hex
|
|
2999
|
+
* A token value an extension may use: a hex color or a color function whose arguments are numbers, units
|
|
3000
3000
|
* and separators only (no `;`, quotes, braces or nested functions such as `url()` or `var()`), so a value
|
|
3001
3001
|
* can never escape its declaration.
|
|
3002
3002
|
*/
|
|
3003
|
-
const
|
|
3003
|
+
const THEME_COLOR_PATTERN = /^(?:#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})|(?:rgba?|hsla?|oklch|oklab)\([0-9a-z.,%\s/+-]{1,80}\))$/;
|
|
3004
3004
|
//#endregion
|
|
3005
3005
|
//#region src/themes/contrast.ts
|
|
3006
3006
|
const SURFACES = [
|
|
@@ -3085,7 +3085,7 @@ const luminance = (hex) => {
|
|
|
3085
3085
|
].map((index) => channel(parseInt(hex.slice(index, index + 2), 16)));
|
|
3086
3086
|
return .2126 * (r ?? 0) + .7152 * (g ?? 0) + .0722 * (b ?? 0);
|
|
3087
3087
|
};
|
|
3088
|
-
/** The WCAG contrast ratio of two `#rrggbb`
|
|
3088
|
+
/** The WCAG contrast ratio of two `#rrggbb` colors. */
|
|
3089
3089
|
const contrastRatio = (a, b) => {
|
|
3090
3090
|
const [high = 0, low = 0] = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
|
3091
3091
|
return (high + .05) / (low + .05);
|
|
@@ -3189,6 +3189,6 @@ const SeoDefaultsSchema = Type.Object({
|
|
|
3189
3189
|
twitterHandle: Type.Union([Type.String({ pattern: SEO_TWITTER_HANDLE_PATTERN.source }), Type.Null()])
|
|
3190
3190
|
}, closed);
|
|
3191
3191
|
//#endregion
|
|
3192
|
-
export { API_KEY_PATTERN, BIGINTEGER_PATTERN, BUILT_IN_THEME_KEYS, CANVAS_ELIGIBLE, CHANGE_KINDS, CODE_LANGUAGES, COMPONENT_TYPE_SUFFIXES, CUSTOM_EDITOR_ID_PATTERN, ComponentDefinitionInputSchema, ComponentDisplayInputSchema, DATA_TYPES, DATETIME_PATTERN, DATE_PATTERN, DECIMAL_PATTERN, DEFAULT_EDITORS, DEFAULT_SEO_KEYS, DEFINITION_KINDS, DefinitionInputSchema,
|
|
3192
|
+
export { API_KEY_PATTERN, BIGINTEGER_PATTERN, BUILT_IN_THEME_KEYS, CANVAS_ELIGIBLE, CHANGE_KINDS, CODE_LANGUAGES, COMPONENT_TYPE_SUFFIXES, CUSTOM_EDITOR_ID_PATTERN, ComponentDefinitionInputSchema, ComponentDisplayInputSchema, DATA_TYPES, DATETIME_PATTERN, DATE_PATTERN, DECIMAL_PATTERN, DEFAULT_EDITORS, DEFAULT_SEO_KEYS, DEFINITION_KINDS, DefinitionInputSchema, EDITOR_CATALOG, EMPTY_SEO_DEFAULTS, ENTRY_LAYOUTS, EditorChoiceInputSchema, EnumValueSchema, FIELD_WIDTHS, FieldInputSchema, INLINE_TITLE_TYPES, INTERFACE_TYPE_SUFFIX, INVALID_TEXT_MESSAGE, LOCALE_CODE_PATTERN, LOCK_FILE_FORMAT_VERSION, LOCK_FILE_PATH, LocaleInputSchema, LockEntrySchema, LockFileError, LockFileSchema, MARK_RULES, MAX_API_KEY_LENGTH, MAX_COMPONENT_DEPTH, MAX_DESCRIPTION_LENGTH, MAX_FALLBACK_CHAIN, MAX_FIELDS_PER_DEFINITION, MAX_INHERITANCE_DEPTH, MAX_LABEL_LENGTH, MAX_RICHTEXT_DEPTH, MAX_ROUTE_KEY_LENGTH, MEDIA_KINDS, MODEL_KINDS, MODEL_TYPE_SUFFIXES, MUTATION_PREFIXES, ModelDefinitionInputSchema, ModelDisplayInputSchema, NODE_RULES, PLURAL_FALLBACK_SUFFIX, REFERENCE_DATA_TYPES, RELATION_CARDINALITIES, RESERVED_DEFINITION_API_KEYS, RESERVED_FIELD_API_KEYS, RESERVED_QUERY_NAMES, RESERVED_TYPE_NAMES, RICHTEXT_FORMAT, RICHTEXT_FORMAT_VERSION, ROUTE_KEY_PATTERN, SAFE_LINK_PATTERN, SCALAR_DATA_TYPES, SCHEMA_KIND_DIRECTORIES, SEO_COMPONENT_API_KEY, SEO_COMPONENT_ID, SEO_DESCRIPTION_SOFT_MAX, SEO_EDITOR_ID, SEO_FIELD_IDS, SEO_TITLE_PLACEHOLDER, SEO_TITLE_SOFT_MAX, SEO_TITLE_TEMPLATE_PATTERN, SEO_TWITTER_HANDLE_PATTERN, SETTINGS_SCHEMAS, SITES_DIRECTORY, SLUG_PATTERN, SORT_DIRECTIONS, STABLE_ID_PATTERN, STORAGE_FAMILY, STRIP_DEFAULT_COUNT, SchemaValidationError, SeoDefaultsSchema, SeoLocaleDefaultsSchema, TEXT_TITLE_FIELD_TYPES, THEME_BRAND_TOKENS, THEME_COLOR_PATTERN, THEME_DARK_UI_PAIRS, THEME_KEY_PATTERN, THEME_SEMANTIC_TOKENS, THEME_TEXT_PAIRS, THEME_TOKENS, THEME_UI_PAIRS, THEME_VARIANTS, TIME_PATTERN, TITLE_FIELD_TYPES, UID_PATTERN, UNIQUE_CAPABLE_DATA_TYPES, ancestorChain, applyTitleTemplate, assignIds, canonicalJson, changeDropsValues, checkApiKeySyntax, checkDefaultValue, checkDisplay, checkInheritance, checkThemeContrast, classifyChange, classifyChanges, classifyLocaleChange, collectionQueryName, contrastRatio, createDefinitionIndex, createStableId, decideSync, diffDefinitions, effectiveFormLayout, effectiveLayout, effectiveTitleField, embeddedComponentIds, entryLayoutOf, escapeHtml, findChildDefinitions, findDependentModels, findInvalidText, findReferencingDefinitions, foldApiKey, generatedNames, hashDefinition, isApiKeySyntaxValid, isCanvasEligible, isComponentDefinition, isCoverEligible, isCustomEditorId, isDataType, isDocumentPlaceable, isEmptyRichText, isModelDefinition, isSeoField, isStableId, isValidText, isValidTitleTemplate, issue, listCompatibleEditors, lockCoversSite, lockEntriesForSite, mergeDisplay, mergePulledLock, normalizeDefinition, ownFields, parseDefinition, parseLockFile, plainTextToRichText, renderRichTextHtml, renormalizeDefinition, resolveModelDefinition, resolveSeo, richTextBodyOf, richTextMediaIds, richTextPlainText, richTextToPlainText, routeKeyOf, routePathOf, schemaFilePath, scopeDirectory, scopeOfSchemaFilePath, seoComponentDefinition, seoDefaultsForLocale, serializeDefinition, serializeLockFile, sha256, splitRoutePath, storageFamilyOf, stripFieldsOf, suggestPlural, summarizeChanges, toTypeName, typeChangeDropsValues, uniqueFieldsChangingLocalization, upgradeLockFile, validateDefinition, validateRichText, validateSchema, withDerivedPlural, withSiteCovered };
|
|
3193
3193
|
|
|
3194
3194
|
//# sourceMappingURL=index.js.map
|