@cmssy/core 14.0.0 → 14.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{csp-BSWMb5Du.d.cts → csp-CY7ssZsh.d.cts} +4 -1
- package/dist/{csp-P-acJQaJ.d.ts → csp-DLCKZAyi.d.ts} +4 -1
- package/dist/index.cjs +62 -0
- package/dist/index.d.cts +37 -3
- package/dist/index.d.ts +37 -3
- package/dist/index.js +57 -1
- package/dist/internal.cjs +2 -1
- package/dist/internal.d.cts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +2 -1
- package/package.json +2 -2
|
@@ -13,6 +13,9 @@ type RegionSettingsOf<Region> = [Region] extends [
|
|
|
13
13
|
type CmssyRegionSettings<L extends CmssyLayout, R extends CmssyRegion<L>> = string extends CmssyRegion<L> ? Record<string, never> : RegionSettingsOf<Extract<L["regions"][number], {
|
|
14
14
|
id: R;
|
|
15
15
|
}>>;
|
|
16
|
+
type CmssyRegionSettingsOf<C extends {
|
|
17
|
+
layout?: CmssyLayout;
|
|
18
|
+
}, R extends string> = string extends CmssyRegion<NonNullable<C["layout"]>> ? Record<string, unknown> : R extends CmssyRegion<NonNullable<C["layout"]>> ? CmssyRegionSettings<NonNullable<C["layout"]>, R> : Record<string, never>;
|
|
16
19
|
declare function defineCmssyLayout<const R extends readonly LayoutRegion[]>(layout: CmssyLayout<R>): CmssyLayout<R>;
|
|
17
20
|
declare function layoutRegionIds(layout: CmssyLayout | undefined): string[];
|
|
18
21
|
|
|
@@ -191,4 +194,4 @@ declare function toCspOrigin(origin: string): string;
|
|
|
191
194
|
declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
|
|
192
195
|
declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
|
|
193
196
|
|
|
194
|
-
export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E,
|
|
197
|
+
export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E, cmssyCspHeaders as F, isDevelopment as G, layoutRegionIds as H, type InvisibleBlock as I, resolveInitialTarget as J, toCspOrigin as K, PROTOCOL_VERSION as P, type QueryScopedOptions as Q, type ReadyMessage as R, SHORTCUT_ACTIONS as S, type ViewportMessage as V, type CmssyClient as a, type CmssyConfig as b, type CmssyCspOptions as c, type CmssyEnvConfig as d, type CmssyLayout as e, type CmssyRegion as f, type CmssyRegionOf as g, type CmssyRegionSettings as h, type CmssyRegionSettingsOf as i, type CmssyTypedDocument as j, type InvisibleBlocksMessage as k, type ParentReadyMessage as l, type PatchMessage as m, type PostTarget as n, type SelectMessage as o, type ShortcutAction as p, type ShortcutMessage as q, applyCmssyCsp as r, createCmssyClient as s, defineCmssyConfig as t, defineCmssyLayout as u, isProtocolCompatible as v, normalizeOrigin as w, parseEditorMessage as x, postToEditor as y, resolveEditorOrigin as z };
|
|
@@ -13,6 +13,9 @@ type RegionSettingsOf<Region> = [Region] extends [
|
|
|
13
13
|
type CmssyRegionSettings<L extends CmssyLayout, R extends CmssyRegion<L>> = string extends CmssyRegion<L> ? Record<string, never> : RegionSettingsOf<Extract<L["regions"][number], {
|
|
14
14
|
id: R;
|
|
15
15
|
}>>;
|
|
16
|
+
type CmssyRegionSettingsOf<C extends {
|
|
17
|
+
layout?: CmssyLayout;
|
|
18
|
+
}, R extends string> = string extends CmssyRegion<NonNullable<C["layout"]>> ? Record<string, unknown> : R extends CmssyRegion<NonNullable<C["layout"]>> ? CmssyRegionSettings<NonNullable<C["layout"]>, R> : Record<string, never>;
|
|
16
19
|
declare function defineCmssyLayout<const R extends readonly LayoutRegion[]>(layout: CmssyLayout<R>): CmssyLayout<R>;
|
|
17
20
|
declare function layoutRegionIds(layout: CmssyLayout | undefined): string[];
|
|
18
21
|
|
|
@@ -191,4 +194,4 @@ declare function toCspOrigin(origin: string): string;
|
|
|
191
194
|
declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
|
|
192
195
|
declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
|
|
193
196
|
|
|
194
|
-
export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E,
|
|
197
|
+
export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E, cmssyCspHeaders as F, isDevelopment as G, layoutRegionIds as H, type InvisibleBlock as I, resolveInitialTarget as J, toCspOrigin as K, PROTOCOL_VERSION as P, type QueryScopedOptions as Q, type ReadyMessage as R, SHORTCUT_ACTIONS as S, type ViewportMessage as V, type CmssyClient as a, type CmssyConfig as b, type CmssyCspOptions as c, type CmssyEnvConfig as d, type CmssyLayout as e, type CmssyRegion as f, type CmssyRegionOf as g, type CmssyRegionSettings as h, type CmssyRegionSettingsOf as i, type CmssyTypedDocument as j, type InvisibleBlocksMessage as k, type ParentReadyMessage as l, type PatchMessage as m, type PostTarget as n, type SelectMessage as o, type ShortcutAction as p, type ShortcutMessage as q, applyCmssyCsp as r, createCmssyClient as s, defineCmssyConfig as t, defineCmssyLayout as u, isProtocolCompatible as v, normalizeOrigin as w, parseEditorMessage as x, postToEditor as y, resolveEditorOrigin as z };
|
package/dist/index.cjs
CHANGED
|
@@ -619,6 +619,62 @@ function defineCmssyLayout(layout) {
|
|
|
619
619
|
return { regions };
|
|
620
620
|
}
|
|
621
621
|
|
|
622
|
+
// src/manifest.ts
|
|
623
|
+
function propsToSchema(props) {
|
|
624
|
+
const schema = {};
|
|
625
|
+
for (const [key, def] of Object.entries(props)) {
|
|
626
|
+
schema[key] = { ...def, label: def.label || key };
|
|
627
|
+
}
|
|
628
|
+
return schema;
|
|
629
|
+
}
|
|
630
|
+
function blocksToSchemas(blocks) {
|
|
631
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
632
|
+
for (const block of blocks) out[block.type] = propsToSchema(block.props);
|
|
633
|
+
return out;
|
|
634
|
+
}
|
|
635
|
+
function blocksToMeta(blocks, defaults = {}) {
|
|
636
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
637
|
+
for (const block of blocks) {
|
|
638
|
+
const category = block.category ?? defaults.category;
|
|
639
|
+
out[block.type] = {
|
|
640
|
+
label: block.label ?? block.type,
|
|
641
|
+
...category ? { category } : {},
|
|
642
|
+
...block.icon ? { icon: block.icon } : {},
|
|
643
|
+
...block.layoutPositions ? { layoutPositions: block.layoutPositions } : {},
|
|
644
|
+
...block.description ? { description: block.description } : {}
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
return out;
|
|
648
|
+
}
|
|
649
|
+
function layoutRegionsToBridge(regions) {
|
|
650
|
+
return regions.map(
|
|
651
|
+
(region) => region.settings ? { ...region, settings: propsToSchema(region.settings) } : { ...region }
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
function registryToManifestBlocks(schemas, blockMeta) {
|
|
655
|
+
return Object.entries(schemas).sort(([a], [b]) => a.localeCompare(b)).map(([type, schema]) => {
|
|
656
|
+
const meta = blockMeta?.[type];
|
|
657
|
+
return {
|
|
658
|
+
type,
|
|
659
|
+
label: meta?.label || type,
|
|
660
|
+
...meta?.category ? { category: meta.category } : {},
|
|
661
|
+
...meta?.icon ? { icon: meta.icon } : {},
|
|
662
|
+
...meta?.description ? { description: meta.description } : {},
|
|
663
|
+
...meta?.layoutPositions?.length ? { layoutPositions: meta.layoutPositions } : {},
|
|
664
|
+
schema
|
|
665
|
+
};
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
function buildBlockManifest(blocks, options = {}) {
|
|
669
|
+
return {
|
|
670
|
+
blocks: registryToManifestBlocks(
|
|
671
|
+
blocksToSchemas(blocks),
|
|
672
|
+
blocksToMeta(blocks, { category: options.category })
|
|
673
|
+
),
|
|
674
|
+
regions: options.regions ? layoutRegionsToBridge(options.regions) : null
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
|
|
622
678
|
// src/data/localize-href.ts
|
|
623
679
|
var PROTOCOL_OR_RELATIVE = /^([a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
624
680
|
function isExternalHref(href) {
|
|
@@ -1009,6 +1065,9 @@ exports.DEFAULT_CMSSY_EDITOR_ORIGINS = DEFAULT_CMSSY_EDITOR_ORIGINS;
|
|
|
1009
1065
|
exports.PROTOCOL_VERSION = PROTOCOL_VERSION;
|
|
1010
1066
|
exports.SHORTCUT_ACTIONS = SHORTCUT_ACTIONS;
|
|
1011
1067
|
exports.applyCmssyCsp = applyCmssyCsp;
|
|
1068
|
+
exports.blocksToMeta = blocksToMeta;
|
|
1069
|
+
exports.blocksToSchemas = blocksToSchemas;
|
|
1070
|
+
exports.buildBlockManifest = buildBlockManifest;
|
|
1012
1071
|
exports.createCmssyClient = createCmssyClient;
|
|
1013
1072
|
exports.defineCmssyConfig = defineCmssyConfig;
|
|
1014
1073
|
exports.defineCmssyLayout = defineCmssyLayout;
|
|
@@ -1016,6 +1075,7 @@ exports.fields = fields;
|
|
|
1016
1075
|
exports.graphqlRequest = graphqlRequest;
|
|
1017
1076
|
exports.isProtocolCompatible = isProtocolCompatible;
|
|
1018
1077
|
exports.isVerifiedEditUrl = isVerifiedEditUrl;
|
|
1078
|
+
exports.layoutRegionsToBridge = layoutRegionsToBridge;
|
|
1019
1079
|
exports.localizeHref = localizeHref;
|
|
1020
1080
|
exports.mediaAlt = mediaAlt;
|
|
1021
1081
|
exports.mediaUrl = mediaUrl;
|
|
@@ -1023,6 +1083,8 @@ exports.mediaUrls = mediaUrls;
|
|
|
1023
1083
|
exports.normalizeOrigin = normalizeOrigin;
|
|
1024
1084
|
exports.parseEditorMessage = parseEditorMessage;
|
|
1025
1085
|
exports.postToEditor = postToEditor;
|
|
1086
|
+
exports.propsToSchema = propsToSchema;
|
|
1087
|
+
exports.registryToManifestBlocks = registryToManifestBlocks;
|
|
1026
1088
|
exports.resolveCmssyLocale = resolveCmssyLocale;
|
|
1027
1089
|
exports.resolveEditorOrigin = resolveEditorOrigin;
|
|
1028
1090
|
exports.verifyCmssyWebhook = verifyCmssyWebhook;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyRegionSettings, i as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock,
|
|
1
|
+
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyRegionSettings, i as CmssyRegionSettingsOf, j as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock, k as InvisibleBlocksMessage, P as PROTOCOL_VERSION, l as ParentReadyMessage, m as PatchMessage, n as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SHORTCUT_ACTIONS, o as SelectMessage, p as ShortcutAction, q as ShortcutMessage, V as ViewportMessage, r as applyCmssyCsp, s as createCmssyClient, t as defineCmssyConfig, u as defineCmssyLayout, v as isProtocolCompatible, w as normalizeOrigin, x as parseEditorMessage, y as postToEditor, z as resolveEditorOrigin } from './csp-CY7ssZsh.cjs';
|
|
2
2
|
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref, r as resolveCmssyLocale } from './locale-JyBHqpAQ.cjs';
|
|
3
3
|
export { C as CMSSY_RATE_LIMIT_WINDOW_MS, a as CMSSY_RETRY_MODES, b as CmssyRequestError, c as CmssyRetryMode, D as DEFAULT_CMSSY_API_URL, F as FetchLike, d as FetchLikeResponse, e as FetchPageOptions, R as RetryOption, f as RetryPolicy } from './content-client-65N8ZRq9.cjs';
|
|
4
4
|
import * as _cmssy_types from '@cmssy/types';
|
|
5
|
-
import { FieldOptions, TypedField, ResolvedMediaValue, PageRef, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, ResolvedMedia, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
5
|
+
import { FieldOptions, TypedField, ResolvedMediaValue, PageRef, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, ResolvedMedia, BlockSchema, LayoutRegion, FieldDefinition, BlockMeta, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
6
6
|
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, LayoutPosition, LayoutRegion, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -79,6 +79,40 @@ declare function mediaUrl(value: MediaLike): string | null;
|
|
|
79
79
|
declare function mediaUrls(value: readonly MediaLike[] | null | undefined): string[];
|
|
80
80
|
declare function mediaAlt(value: MediaLike): string | undefined;
|
|
81
81
|
|
|
82
|
+
interface BlockManifestSource {
|
|
83
|
+
type: string;
|
|
84
|
+
label?: string;
|
|
85
|
+
category?: string;
|
|
86
|
+
icon?: string;
|
|
87
|
+
layoutPositions?: string[];
|
|
88
|
+
description?: string;
|
|
89
|
+
props: Record<string, FieldDefinition>;
|
|
90
|
+
}
|
|
91
|
+
interface BlockManifestBlock {
|
|
92
|
+
type: string;
|
|
93
|
+
label: string;
|
|
94
|
+
category?: string;
|
|
95
|
+
icon?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
layoutPositions?: string[];
|
|
98
|
+
schema: BlockSchema;
|
|
99
|
+
}
|
|
100
|
+
interface BlockManifest {
|
|
101
|
+
blocks: BlockManifestBlock[];
|
|
102
|
+
regions: LayoutRegion[] | null;
|
|
103
|
+
}
|
|
104
|
+
declare function propsToSchema(props: BlockPropsSchema): BlockSchema;
|
|
105
|
+
declare function blocksToSchemas(blocks: readonly BlockManifestSource[]): Record<string, BlockSchema>;
|
|
106
|
+
declare function blocksToMeta(blocks: readonly BlockManifestSource[], defaults?: {
|
|
107
|
+
category?: string;
|
|
108
|
+
}): Record<string, BlockMeta>;
|
|
109
|
+
declare function layoutRegionsToBridge(regions: readonly LayoutRegion[]): LayoutRegion[];
|
|
110
|
+
declare function registryToManifestBlocks(schemas: Record<string, BlockSchema>, blockMeta: Record<string, BlockMeta> | null): BlockManifestBlock[];
|
|
111
|
+
declare function buildBlockManifest(blocks: readonly BlockManifestSource[], options?: {
|
|
112
|
+
category?: string;
|
|
113
|
+
regions?: readonly LayoutRegion[] | null;
|
|
114
|
+
}): BlockManifest;
|
|
115
|
+
|
|
82
116
|
declare const CMSSY_EDIT_HEADER = "x-cmssy-edit";
|
|
83
117
|
declare const CMSSY_EDIT_QUERY_PARAM = "cmssyEdit";
|
|
84
118
|
declare const CMSSY_SECRET_QUERY_PARAM = "cmssySecret";
|
|
@@ -97,4 +131,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
97
131
|
}
|
|
98
132
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
99
133
|
|
|
100
|
-
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyWebhookError, type MediaLike, fields, isVerifiedEditUrl, mediaAlt, mediaUrl, mediaUrls, verifyCmssyWebhook };
|
|
134
|
+
export { type BlockManifest, type BlockManifestBlock, type BlockManifestSource, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyWebhookError, type MediaLike, blocksToMeta, blocksToSchemas, buildBlockManifest, fields, isVerifiedEditUrl, layoutRegionsToBridge, mediaAlt, mediaUrl, mediaUrls, propsToSchema, registryToManifestBlocks, verifyCmssyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyRegionSettings, i as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock,
|
|
1
|
+
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyRegionSettings, i as CmssyRegionSettingsOf, j as CmssyTypedDocument, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock, k as InvisibleBlocksMessage, P as PROTOCOL_VERSION, l as ParentReadyMessage, m as PatchMessage, n as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SHORTCUT_ACTIONS, o as SelectMessage, p as ShortcutAction, q as ShortcutMessage, V as ViewportMessage, r as applyCmssyCsp, s as createCmssyClient, t as defineCmssyConfig, u as defineCmssyLayout, v as isProtocolCompatible, w as normalizeOrigin, x as parseEditorMessage, y as postToEditor, z as resolveEditorOrigin } from './csp-DLCKZAyi.js';
|
|
2
2
|
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref, r as resolveCmssyLocale } from './locale-D9KI4bND.js';
|
|
3
3
|
export { C as CMSSY_RATE_LIMIT_WINDOW_MS, a as CMSSY_RETRY_MODES, b as CmssyRequestError, c as CmssyRetryMode, D as DEFAULT_CMSSY_API_URL, F as FetchLike, d as FetchLikeResponse, e as FetchPageOptions, R as RetryOption, f as RetryPolicy } from './content-client-65N8ZRq9.js';
|
|
4
4
|
import * as _cmssy_types from '@cmssy/types';
|
|
5
|
-
import { FieldOptions, TypedField, ResolvedMediaValue, PageRef, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, ResolvedMedia, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
5
|
+
import { FieldOptions, TypedField, ResolvedMediaValue, PageRef, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, ResolvedMedia, BlockSchema, LayoutRegion, FieldDefinition, BlockMeta, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
6
6
|
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, LayoutPosition, LayoutRegion, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -79,6 +79,40 @@ declare function mediaUrl(value: MediaLike): string | null;
|
|
|
79
79
|
declare function mediaUrls(value: readonly MediaLike[] | null | undefined): string[];
|
|
80
80
|
declare function mediaAlt(value: MediaLike): string | undefined;
|
|
81
81
|
|
|
82
|
+
interface BlockManifestSource {
|
|
83
|
+
type: string;
|
|
84
|
+
label?: string;
|
|
85
|
+
category?: string;
|
|
86
|
+
icon?: string;
|
|
87
|
+
layoutPositions?: string[];
|
|
88
|
+
description?: string;
|
|
89
|
+
props: Record<string, FieldDefinition>;
|
|
90
|
+
}
|
|
91
|
+
interface BlockManifestBlock {
|
|
92
|
+
type: string;
|
|
93
|
+
label: string;
|
|
94
|
+
category?: string;
|
|
95
|
+
icon?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
layoutPositions?: string[];
|
|
98
|
+
schema: BlockSchema;
|
|
99
|
+
}
|
|
100
|
+
interface BlockManifest {
|
|
101
|
+
blocks: BlockManifestBlock[];
|
|
102
|
+
regions: LayoutRegion[] | null;
|
|
103
|
+
}
|
|
104
|
+
declare function propsToSchema(props: BlockPropsSchema): BlockSchema;
|
|
105
|
+
declare function blocksToSchemas(blocks: readonly BlockManifestSource[]): Record<string, BlockSchema>;
|
|
106
|
+
declare function blocksToMeta(blocks: readonly BlockManifestSource[], defaults?: {
|
|
107
|
+
category?: string;
|
|
108
|
+
}): Record<string, BlockMeta>;
|
|
109
|
+
declare function layoutRegionsToBridge(regions: readonly LayoutRegion[]): LayoutRegion[];
|
|
110
|
+
declare function registryToManifestBlocks(schemas: Record<string, BlockSchema>, blockMeta: Record<string, BlockMeta> | null): BlockManifestBlock[];
|
|
111
|
+
declare function buildBlockManifest(blocks: readonly BlockManifestSource[], options?: {
|
|
112
|
+
category?: string;
|
|
113
|
+
regions?: readonly LayoutRegion[] | null;
|
|
114
|
+
}): BlockManifest;
|
|
115
|
+
|
|
82
116
|
declare const CMSSY_EDIT_HEADER = "x-cmssy-edit";
|
|
83
117
|
declare const CMSSY_EDIT_QUERY_PARAM = "cmssyEdit";
|
|
84
118
|
declare const CMSSY_SECRET_QUERY_PARAM = "cmssySecret";
|
|
@@ -97,4 +131,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
97
131
|
}
|
|
98
132
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
99
133
|
|
|
100
|
-
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyWebhookError, type MediaLike, fields, isVerifiedEditUrl, mediaAlt, mediaUrl, mediaUrls, verifyCmssyWebhook };
|
|
134
|
+
export { type BlockManifest, type BlockManifestBlock, type BlockManifestSource, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyWebhookError, type MediaLike, blocksToMeta, blocksToSchemas, buildBlockManifest, fields, isVerifiedEditUrl, layoutRegionsToBridge, mediaAlt, mediaUrl, mediaUrls, propsToSchema, registryToManifestBlocks, verifyCmssyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -618,6 +618,62 @@ function defineCmssyLayout(layout) {
|
|
|
618
618
|
return { regions };
|
|
619
619
|
}
|
|
620
620
|
|
|
621
|
+
// src/manifest.ts
|
|
622
|
+
function propsToSchema(props) {
|
|
623
|
+
const schema = {};
|
|
624
|
+
for (const [key, def] of Object.entries(props)) {
|
|
625
|
+
schema[key] = { ...def, label: def.label || key };
|
|
626
|
+
}
|
|
627
|
+
return schema;
|
|
628
|
+
}
|
|
629
|
+
function blocksToSchemas(blocks) {
|
|
630
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
631
|
+
for (const block of blocks) out[block.type] = propsToSchema(block.props);
|
|
632
|
+
return out;
|
|
633
|
+
}
|
|
634
|
+
function blocksToMeta(blocks, defaults = {}) {
|
|
635
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
636
|
+
for (const block of blocks) {
|
|
637
|
+
const category = block.category ?? defaults.category;
|
|
638
|
+
out[block.type] = {
|
|
639
|
+
label: block.label ?? block.type,
|
|
640
|
+
...category ? { category } : {},
|
|
641
|
+
...block.icon ? { icon: block.icon } : {},
|
|
642
|
+
...block.layoutPositions ? { layoutPositions: block.layoutPositions } : {},
|
|
643
|
+
...block.description ? { description: block.description } : {}
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
return out;
|
|
647
|
+
}
|
|
648
|
+
function layoutRegionsToBridge(regions) {
|
|
649
|
+
return regions.map(
|
|
650
|
+
(region) => region.settings ? { ...region, settings: propsToSchema(region.settings) } : { ...region }
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
function registryToManifestBlocks(schemas, blockMeta) {
|
|
654
|
+
return Object.entries(schemas).sort(([a], [b]) => a.localeCompare(b)).map(([type, schema]) => {
|
|
655
|
+
const meta = blockMeta?.[type];
|
|
656
|
+
return {
|
|
657
|
+
type,
|
|
658
|
+
label: meta?.label || type,
|
|
659
|
+
...meta?.category ? { category: meta.category } : {},
|
|
660
|
+
...meta?.icon ? { icon: meta.icon } : {},
|
|
661
|
+
...meta?.description ? { description: meta.description } : {},
|
|
662
|
+
...meta?.layoutPositions?.length ? { layoutPositions: meta.layoutPositions } : {},
|
|
663
|
+
schema
|
|
664
|
+
};
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
function buildBlockManifest(blocks, options = {}) {
|
|
668
|
+
return {
|
|
669
|
+
blocks: registryToManifestBlocks(
|
|
670
|
+
blocksToSchemas(blocks),
|
|
671
|
+
blocksToMeta(blocks, { category: options.category })
|
|
672
|
+
),
|
|
673
|
+
regions: options.regions ? layoutRegionsToBridge(options.regions) : null
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
621
677
|
// src/data/localize-href.ts
|
|
622
678
|
var PROTOCOL_OR_RELATIVE = /^([a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
623
679
|
function isExternalHref(href) {
|
|
@@ -991,4 +1047,4 @@ async function verifyCmssyWebhook(options) {
|
|
|
991
1047
|
return parsed;
|
|
992
1048
|
}
|
|
993
1049
|
|
|
994
|
-
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_RATE_LIMIT_WINDOW_MS, CMSSY_RETRY_MODES, CMSSY_SECRET_QUERY_PARAM, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, SHORTCUT_ACTIONS, applyCmssyCsp, createCmssyClient, defineCmssyConfig, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, isVerifiedEditUrl, localizeHref, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor, resolveCmssyLocale, resolveEditorOrigin, verifyCmssyWebhook };
|
|
1050
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_RATE_LIMIT_WINDOW_MS, CMSSY_RETRY_MODES, CMSSY_SECRET_QUERY_PARAM, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, SHORTCUT_ACTIONS, applyCmssyCsp, blocksToMeta, blocksToSchemas, buildBlockManifest, createCmssyClient, defineCmssyConfig, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, isVerifiedEditUrl, layoutRegionsToBridge, localizeHref, mediaAlt, mediaUrl, mediaUrls, normalizeOrigin, parseEditorMessage, postToEditor, propsToSchema, registryToManifestBlocks, resolveCmssyLocale, resolveEditorOrigin, verifyCmssyWebhook };
|
package/dist/internal.cjs
CHANGED
|
@@ -1142,8 +1142,9 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
|
|
|
1142
1142
|
...extra?.workspace ? { workspace: extra.workspace } : {},
|
|
1143
1143
|
...extra?.page?.slug ? {
|
|
1144
1144
|
page: {
|
|
1145
|
-
id: extra.page.id,
|
|
1145
|
+
...extra.page.id !== void 0 ? { id: extra.page.id } : {},
|
|
1146
1146
|
slug: extra.page.slug,
|
|
1147
|
+
path: extra.page.slug.split("/").filter(Boolean),
|
|
1147
1148
|
pageType: extra.page.pageType ?? null
|
|
1148
1149
|
}
|
|
1149
1150
|
} : {},
|
package/dist/internal.d.cts
CHANGED
|
@@ -3,8 +3,8 @@ import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyCl
|
|
|
3
3
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
4
4
|
import { G as GraphqlRequestOptions } from './locale-JyBHqpAQ.cjs';
|
|
5
5
|
export { C as CMSSY_LOCALE_HEADER, a as localeForPath, b as localeForPathname, l as localizeHref, c as resolveSiteLocales, s as splitCmssyLocale, d as splitLocaleFromPath } from './locale-JyBHqpAQ.cjs';
|
|
6
|
-
import { Q as QueryScopedOptions } from './csp-
|
|
7
|
-
export {
|
|
6
|
+
import { Q as QueryScopedOptions } from './csp-CY7ssZsh.cjs';
|
|
7
|
+
export { F as cmssyCspHeaders, G as isDevelopment, H as layoutRegionIds, J as resolveInitialTarget, K as toCspOrigin } from './csp-CY7ssZsh.cjs';
|
|
8
8
|
export { localizedPath } from './internal/locale.cjs';
|
|
9
9
|
|
|
10
10
|
declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n logoDarkUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
|
package/dist/internal.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyCl
|
|
|
3
3
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
4
4
|
import { G as GraphqlRequestOptions } from './locale-D9KI4bND.js';
|
|
5
5
|
export { C as CMSSY_LOCALE_HEADER, a as localeForPath, b as localeForPathname, l as localizeHref, c as resolveSiteLocales, s as splitCmssyLocale, d as splitLocaleFromPath } from './locale-D9KI4bND.js';
|
|
6
|
-
import { Q as QueryScopedOptions } from './csp-
|
|
7
|
-
export {
|
|
6
|
+
import { Q as QueryScopedOptions } from './csp-DLCKZAyi.js';
|
|
7
|
+
export { F as cmssyCspHeaders, G as isDevelopment, H as layoutRegionIds, J as resolveInitialTarget, K as toCspOrigin } from './csp-DLCKZAyi.js';
|
|
8
8
|
export { localizedPath } from './internal/locale.js';
|
|
9
9
|
|
|
10
10
|
declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n logoDarkUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
|
package/dist/internal.js
CHANGED
|
@@ -1140,8 +1140,9 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
|
|
|
1140
1140
|
...extra?.workspace ? { workspace: extra.workspace } : {},
|
|
1141
1141
|
...extra?.page?.slug ? {
|
|
1142
1142
|
page: {
|
|
1143
|
-
id: extra.page.id,
|
|
1143
|
+
...extra.page.id !== void 0 ? { id: extra.page.id } : {},
|
|
1144
1144
|
slug: extra.page.slug,
|
|
1145
|
+
path: extra.page.slug.split("/").filter(Boolean),
|
|
1145
1146
|
pageType: extra.page.pageType ?? null
|
|
1146
1147
|
}
|
|
1147
1148
|
} : {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/core",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.2.0",
|
|
4
4
|
"description": "Framework-agnostic cmssy gateway: GraphQL client, block/field system, editor protocol. No React, no Next.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"vitest": "^2.1.0"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@cmssy/types": "0.
|
|
90
|
+
"@cmssy/types": "0.39.0",
|
|
91
91
|
"jose": "^6.2.3"
|
|
92
92
|
},
|
|
93
93
|
"scripts": {
|