@cmssy/core 11.1.1 → 11.3.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/internal.cjs +45 -0
- package/dist/internal.d.cts +27 -1
- package/dist/internal.d.ts +27 -1
- package/dist/internal.js +45 -1
- package/dist/testing.cjs +16 -0
- package/dist/testing.js +16 -0
- package/package.json +1 -1
package/dist/internal.cjs
CHANGED
|
@@ -1111,6 +1111,51 @@ function cmssyCspHeaders(options) {
|
|
|
1111
1111
|
};
|
|
1112
1112
|
}
|
|
1113
1113
|
|
|
1114
|
+
// src/data/delivery-operations.ts
|
|
1115
|
+
var CMSSY_DELIVERY_OPERATIONS = [
|
|
1116
|
+
{
|
|
1117
|
+
purpose: "Languages, branding and the 404 page - the workspace's settings.",
|
|
1118
|
+
document: SITE_CONFIG_QUERY
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
purpose: "One page with its blocks. `previewSecret` returns the draft.",
|
|
1122
|
+
document: PUBLIC_PAGE_QUERY
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
purpose: "One page by id - what the workspace's 404 page setting stores.",
|
|
1126
|
+
document: PUBLIC_PAGE_BY_ID_QUERY
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
purpose: "The published page list - sitemaps, and static params.",
|
|
1130
|
+
document: PUBLIC_PAGES_QUERY
|
|
1131
|
+
},
|
|
1132
|
+
{
|
|
1133
|
+
purpose: "SEO fields for one page, without fetching its blocks.",
|
|
1134
|
+
document: PUBLIC_PAGE_META_QUERY
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
purpose: "Header, footer and the other layout positions for a page.",
|
|
1138
|
+
document: PUBLIC_PAGE_LAYOUTS_QUERY
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
purpose: "Records of one model - the typed half of `cmssy types`.",
|
|
1142
|
+
document: MODEL_RECORDS_QUERY
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
purpose: "Records by id - how a relation field resolves to records.",
|
|
1146
|
+
document: RECORDS_BY_IDS_QUERY
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
purpose: "A form definition, for rendering and validating it.",
|
|
1150
|
+
document: FORM_QUERY
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
purpose: "Submitting that form - rendering one without this is half a feature.",
|
|
1154
|
+
document: SUBMIT_FORM_MUTATION
|
|
1155
|
+
}
|
|
1156
|
+
];
|
|
1157
|
+
|
|
1158
|
+
exports.CMSSY_DELIVERY_OPERATIONS = CMSSY_DELIVERY_OPERATIONS;
|
|
1114
1159
|
exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
|
|
1115
1160
|
exports.FORM_QUERY = FORM_QUERY;
|
|
1116
1161
|
exports.MODEL_DEFINITIONS_QUERY = MODEL_DEFINITIONS_QUERY;
|
package/dist/internal.d.cts
CHANGED
|
@@ -62,4 +62,30 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
|
|
|
62
62
|
|
|
63
63
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
interface CmssyDeliveryOperation {
|
|
66
|
+
/** One line, for the generated file - why an app would want this one. */
|
|
67
|
+
purpose: string;
|
|
68
|
+
document: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The delivery operations the SDK itself performs, for `cmssy types` to vendor
|
|
72
|
+
* into an app.
|
|
73
|
+
*
|
|
74
|
+
* These reference the runtime constants rather than restating them: a second
|
|
75
|
+
* copy here would be free to drift from the client that actually sends them,
|
|
76
|
+
* which is the problem this list exists to remove. Keep it that way - a literal
|
|
77
|
+
* moved into this file also drops out of `sdl-operations.test.ts`, which
|
|
78
|
+
* validates exported document *strings* in their home modules.
|
|
79
|
+
*
|
|
80
|
+
* Deliberately absent, and why:
|
|
81
|
+
*
|
|
82
|
+
* - `PUBLIC_PAGE_DEV_QUERY` - a second document named `PublicPage`. Two
|
|
83
|
+
* documents cannot share an operation name in graphql-codegen's client
|
|
84
|
+
* preset, so including it would emit a file every consumer's codegen
|
|
85
|
+
* rejects. It is also a dev-preview path an app never calls itself.
|
|
86
|
+
* - `MODEL_DEFINITIONS_QUERY` - `cmssy types` already turns definitions into
|
|
87
|
+
* TypeScript; fetching them at runtime is not something an app does.
|
|
88
|
+
*/
|
|
89
|
+
declare const CMSSY_DELIVERY_OPERATIONS: readonly CmssyDeliveryOperation[];
|
|
90
|
+
|
|
91
|
+
export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS, type CmssyDeliveryOperation, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
package/dist/internal.d.ts
CHANGED
|
@@ -62,4 +62,30 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
|
|
|
62
62
|
|
|
63
63
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
interface CmssyDeliveryOperation {
|
|
66
|
+
/** One line, for the generated file - why an app would want this one. */
|
|
67
|
+
purpose: string;
|
|
68
|
+
document: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The delivery operations the SDK itself performs, for `cmssy types` to vendor
|
|
72
|
+
* into an app.
|
|
73
|
+
*
|
|
74
|
+
* These reference the runtime constants rather than restating them: a second
|
|
75
|
+
* copy here would be free to drift from the client that actually sends them,
|
|
76
|
+
* which is the problem this list exists to remove. Keep it that way - a literal
|
|
77
|
+
* moved into this file also drops out of `sdl-operations.test.ts`, which
|
|
78
|
+
* validates exported document *strings* in their home modules.
|
|
79
|
+
*
|
|
80
|
+
* Deliberately absent, and why:
|
|
81
|
+
*
|
|
82
|
+
* - `PUBLIC_PAGE_DEV_QUERY` - a second document named `PublicPage`. Two
|
|
83
|
+
* documents cannot share an operation name in graphql-codegen's client
|
|
84
|
+
* preset, so including it would emit a file every consumer's codegen
|
|
85
|
+
* rejects. It is also a dev-preview path an app never calls itself.
|
|
86
|
+
* - `MODEL_DEFINITIONS_QUERY` - `cmssy types` already turns definitions into
|
|
87
|
+
* TypeScript; fetching them at runtime is not something an app does.
|
|
88
|
+
*/
|
|
89
|
+
declare const CMSSY_DELIVERY_OPERATIONS: readonly CmssyDeliveryOperation[];
|
|
90
|
+
|
|
91
|
+
export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS, type CmssyDeliveryOperation, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
package/dist/internal.js
CHANGED
|
@@ -1109,4 +1109,48 @@ function cmssyCspHeaders(options) {
|
|
|
1109
1109
|
};
|
|
1110
1110
|
}
|
|
1111
1111
|
|
|
1112
|
-
|
|
1112
|
+
// src/data/delivery-operations.ts
|
|
1113
|
+
var CMSSY_DELIVERY_OPERATIONS = [
|
|
1114
|
+
{
|
|
1115
|
+
purpose: "Languages, branding and the 404 page - the workspace's settings.",
|
|
1116
|
+
document: SITE_CONFIG_QUERY
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
purpose: "One page with its blocks. `previewSecret` returns the draft.",
|
|
1120
|
+
document: PUBLIC_PAGE_QUERY
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
purpose: "One page by id - what the workspace's 404 page setting stores.",
|
|
1124
|
+
document: PUBLIC_PAGE_BY_ID_QUERY
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
purpose: "The published page list - sitemaps, and static params.",
|
|
1128
|
+
document: PUBLIC_PAGES_QUERY
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
purpose: "SEO fields for one page, without fetching its blocks.",
|
|
1132
|
+
document: PUBLIC_PAGE_META_QUERY
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
purpose: "Header, footer and the other layout positions for a page.",
|
|
1136
|
+
document: PUBLIC_PAGE_LAYOUTS_QUERY
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
purpose: "Records of one model - the typed half of `cmssy types`.",
|
|
1140
|
+
document: MODEL_RECORDS_QUERY
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
purpose: "Records by id - how a relation field resolves to records.",
|
|
1144
|
+
document: RECORDS_BY_IDS_QUERY
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
purpose: "A form definition, for rendering and validating it.",
|
|
1148
|
+
document: FORM_QUERY
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
purpose: "Submitting that form - rendering one without this is half a feature.",
|
|
1152
|
+
document: SUBMIT_FORM_MUTATION
|
|
1153
|
+
}
|
|
1154
|
+
];
|
|
1155
|
+
|
|
1156
|
+
export { CMSSY_DELIVERY_OPERATIONS, CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, getBlockContentForLanguage, isDevelopment, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeRelationContent, normalizeSlug, resolveApiUrl, resolveForms, resolveInitialTarget, resolvePublicUrl, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, splitCmssyLocale, splitLocaleFromPath, toCspOrigin };
|
package/dist/testing.cjs
CHANGED
|
@@ -145,6 +145,10 @@ async function graphqlRequest(config, query, variables, options = {}, label = "r
|
|
|
145
145
|
var EDITOR_MARKER = /data-cmssy-editor/;
|
|
146
146
|
var SERVER_LAYOUT_BLOCKS = /<header|<footer/;
|
|
147
147
|
var EDITABLE_LAYOUT_SLOT = /data-cmssy-layout-slot/;
|
|
148
|
+
var EDITOR_CONTENT_COUNT = /data-cmssy-editor-content="(\d+)"/g;
|
|
149
|
+
function resolvedContentCounts(body) {
|
|
150
|
+
return [...body.matchAll(EDITOR_CONTENT_COUNT)].map((m) => Number(m[1]));
|
|
151
|
+
}
|
|
148
152
|
async function html(url) {
|
|
149
153
|
const response = await fetch(url, { redirect: "manual" });
|
|
150
154
|
return { status: response.status, body: await response.text() };
|
|
@@ -216,6 +220,18 @@ async function checkCmssyEditMode(options) {
|
|
|
216
220
|
`edit ${path}: the workspace defines layout blocks and no editable layout slot is mounted - the header and footer cannot be edited (10.0 removed CmssyLayoutSlot; see docs/wiring.md \xA75)`
|
|
217
221
|
);
|
|
218
222
|
}
|
|
223
|
+
if (configured === true && EDITABLE_LAYOUT_SLOT.test(verified.body)) {
|
|
224
|
+
const counts = resolvedContentCounts(verified.body);
|
|
225
|
+
if (counts.length === 0) {
|
|
226
|
+
failures.push(
|
|
227
|
+
`edit ${path}: the layout slot reports no editor-content marker - @cmssy/react is older than 11.2.0, or the slot is not CmssyLazyLayout`
|
|
228
|
+
);
|
|
229
|
+
} else if (counts.every((count) => count === 0)) {
|
|
230
|
+
failures.push(
|
|
231
|
+
`edit ${path}: every layout slot resolved 0 blocks for the editor. The slot is mounted but was not rendered in edit mode - the canvas gets nothing and the fetch ran without the preview secret, so you are editing the published page. Check that the verified request reaches the edit route with its edit signal intact.`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
219
235
|
const { localizedPath } = options;
|
|
220
236
|
if (localizedPath) {
|
|
221
237
|
const locale = options.localizedLocale ?? localizedPath.split("/").filter(Boolean)[0];
|
package/dist/testing.js
CHANGED
|
@@ -143,6 +143,10 @@ async function graphqlRequest(config, query, variables, options = {}, label = "r
|
|
|
143
143
|
var EDITOR_MARKER = /data-cmssy-editor/;
|
|
144
144
|
var SERVER_LAYOUT_BLOCKS = /<header|<footer/;
|
|
145
145
|
var EDITABLE_LAYOUT_SLOT = /data-cmssy-layout-slot/;
|
|
146
|
+
var EDITOR_CONTENT_COUNT = /data-cmssy-editor-content="(\d+)"/g;
|
|
147
|
+
function resolvedContentCounts(body) {
|
|
148
|
+
return [...body.matchAll(EDITOR_CONTENT_COUNT)].map((m) => Number(m[1]));
|
|
149
|
+
}
|
|
146
150
|
async function html(url) {
|
|
147
151
|
const response = await fetch(url, { redirect: "manual" });
|
|
148
152
|
return { status: response.status, body: await response.text() };
|
|
@@ -214,6 +218,18 @@ async function checkCmssyEditMode(options) {
|
|
|
214
218
|
`edit ${path}: the workspace defines layout blocks and no editable layout slot is mounted - the header and footer cannot be edited (10.0 removed CmssyLayoutSlot; see docs/wiring.md \xA75)`
|
|
215
219
|
);
|
|
216
220
|
}
|
|
221
|
+
if (configured === true && EDITABLE_LAYOUT_SLOT.test(verified.body)) {
|
|
222
|
+
const counts = resolvedContentCounts(verified.body);
|
|
223
|
+
if (counts.length === 0) {
|
|
224
|
+
failures.push(
|
|
225
|
+
`edit ${path}: the layout slot reports no editor-content marker - @cmssy/react is older than 11.2.0, or the slot is not CmssyLazyLayout`
|
|
226
|
+
);
|
|
227
|
+
} else if (counts.every((count) => count === 0)) {
|
|
228
|
+
failures.push(
|
|
229
|
+
`edit ${path}: every layout slot resolved 0 blocks for the editor. The slot is mounted but was not rendered in edit mode - the canvas gets nothing and the fetch ran without the preview secret, so you are editing the published page. Check that the verified request reaches the edit route with its edit signal intact.`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
217
233
|
const { localizedPath } = options;
|
|
218
234
|
if (localizedPath) {
|
|
219
235
|
const locale = options.localizedLocale ?? localizedPath.split("/").filter(Boolean)[0];
|