@cmssy/core 10.0.0 → 10.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-DpssAFJC.d.ts → csp-Blh6P15m.d.ts} +1 -1
- package/dist/{csp-DDVG6VAm.d.cts → csp-DlAEXYjA.d.cts} +1 -1
- package/dist/index.cjs +37 -14
- package/dist/index.d.cts +5 -7
- package/dist/index.d.ts +5 -7
- package/dist/index.js +36 -14
- package/dist/internal/locale.d.cts +4 -32
- package/dist/internal/locale.d.ts +4 -32
- package/dist/internal.cjs +44 -2
- package/dist/internal.d.cts +17 -6
- package/dist/internal.d.ts +17 -6
- package/dist/internal.js +43 -3
- package/dist/locale-XintNd0n.d.ts +52 -0
- package/dist/locale-rhYcXU5z.d.cts +52 -0
- package/package.json +2 -2
- package/dist/graphql-request-CDh6IRok.d.ts +0 -23
- package/dist/graphql-request-NQxSMt6v.d.cts +0 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
|
|
2
|
-
import { G as GraphqlRequestOptions } from './
|
|
2
|
+
import { G as GraphqlRequestOptions } from './locale-XintNd0n.js';
|
|
3
3
|
|
|
4
4
|
declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
|
|
5
5
|
declare function isDevelopment(): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
|
|
2
|
-
import { G as GraphqlRequestOptions } from './
|
|
2
|
+
import { G as GraphqlRequestOptions } from './locale-rhYcXU5z.cjs';
|
|
3
3
|
|
|
4
4
|
declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
|
|
5
5
|
declare function isDevelopment(): boolean;
|
package/dist/index.cjs
CHANGED
|
@@ -323,21 +323,43 @@ var fields = {
|
|
|
323
323
|
}
|
|
324
324
|
};
|
|
325
325
|
|
|
326
|
-
// src/
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
326
|
+
// src/data/localize-href.ts
|
|
327
|
+
var PROTOCOL_OR_RELATIVE = /^([a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
328
|
+
function isExternalHref(href) {
|
|
329
|
+
const value = href.trim();
|
|
330
|
+
if (!value) return true;
|
|
331
|
+
if (value.startsWith("#")) return true;
|
|
332
|
+
return PROTOCOL_OR_RELATIVE.test(value);
|
|
333
|
+
}
|
|
334
|
+
function stripLeadingLocale(path, locale) {
|
|
335
|
+
const segments = path.split("/");
|
|
336
|
+
const first = segments[1];
|
|
337
|
+
if (first && first !== locale.default && locale.enabled.includes(first)) {
|
|
338
|
+
segments.splice(1, 1);
|
|
339
|
+
const rest = segments.join("/");
|
|
340
|
+
return rest === "" ? "/" : rest;
|
|
341
|
+
}
|
|
342
|
+
return path;
|
|
343
|
+
}
|
|
344
|
+
function addLocalePrefix(path, target, locale) {
|
|
345
|
+
if (target === locale.default) return path;
|
|
346
|
+
if (path === "/") return `/${target}`;
|
|
347
|
+
return `/${target}${path}`;
|
|
348
|
+
}
|
|
349
|
+
function localizeHref(href, locale) {
|
|
350
|
+
const value = href.trim();
|
|
351
|
+
if (isExternalHref(value)) return href;
|
|
352
|
+
const boundary = value.search(/[?#]/);
|
|
353
|
+
const path = boundary === -1 ? value : value.slice(0, boundary);
|
|
354
|
+
const suffix = boundary === -1 ? "" : value.slice(boundary);
|
|
355
|
+
if (!path.startsWith("/")) return href;
|
|
356
|
+
const bare = stripLeadingLocale(path, locale);
|
|
357
|
+
return `${addLocalePrefix(bare, locale.current, locale)}${suffix}`;
|
|
339
358
|
}
|
|
340
359
|
|
|
360
|
+
// src/locale.ts
|
|
361
|
+
var CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
362
|
+
|
|
341
363
|
// src/bridge/protocol.ts
|
|
342
364
|
var PROTOCOL_VERSION = 2;
|
|
343
365
|
function isProtocolCompatible(version) {
|
|
@@ -596,6 +618,7 @@ Object.defineProperty(exports, "evaluateFieldConditionGroup", {
|
|
|
596
618
|
});
|
|
597
619
|
exports.CMSSY_EDIT_HEADER = CMSSY_EDIT_HEADER;
|
|
598
620
|
exports.CMSSY_EDIT_QUERY_PARAM = CMSSY_EDIT_QUERY_PARAM;
|
|
621
|
+
exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
|
|
599
622
|
exports.CMSSY_SECRET_QUERY_PARAM = CMSSY_SECRET_QUERY_PARAM;
|
|
600
623
|
exports.CmssyRequestError = CmssyRequestError;
|
|
601
624
|
exports.CmssyWebhookError = CmssyWebhookError;
|
|
@@ -603,13 +626,13 @@ exports.DEFAULT_CMSSY_API_URL = DEFAULT_CMSSY_API_URL;
|
|
|
603
626
|
exports.DEFAULT_CMSSY_EDITOR_ORIGINS = DEFAULT_CMSSY_EDITOR_ORIGINS;
|
|
604
627
|
exports.PROTOCOL_VERSION = PROTOCOL_VERSION;
|
|
605
628
|
exports.applyCmssyCsp = applyCmssyCsp;
|
|
606
|
-
exports.buildBlockContext = buildBlockContext;
|
|
607
629
|
exports.createCmssyClient = createCmssyClient;
|
|
608
630
|
exports.defineCmssyConfig = defineCmssyConfig;
|
|
609
631
|
exports.fields = fields;
|
|
610
632
|
exports.graphqlRequest = graphqlRequest;
|
|
611
633
|
exports.isProtocolCompatible = isProtocolCompatible;
|
|
612
634
|
exports.isVerifiedEditUrl = isVerifiedEditUrl;
|
|
635
|
+
exports.localizeHref = localizeHref;
|
|
613
636
|
exports.normalizeOrigin = normalizeOrigin;
|
|
614
637
|
exports.parseEditorMessage = parseEditorMessage;
|
|
615
638
|
exports.postToEditor = postToEditor;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, e as ParentReadyMessage, f as PatchMessage, g as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, h as applyCmssyCsp, i as createCmssyClient, j as defineCmssyConfig, k as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, l as postToEditor, r as resolveEditorOrigin } from './csp-
|
|
2
|
-
export { G as GraphqlRequestOptions, g as graphqlRequest } from './
|
|
1
|
+
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, e as ParentReadyMessage, f as PatchMessage, g as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, h as applyCmssyCsp, i as createCmssyClient, j as defineCmssyConfig, k as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, l as postToEditor, r as resolveEditorOrigin } from './csp-DlAEXYjA.cjs';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref } from './locale-rhYcXU5z.cjs';
|
|
3
3
|
export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, F as FetchLike, a as FetchLikeResponse, b as FetchPageOptions, R as RetryPolicy } from './content-client-D0EdiqbQ.cjs';
|
|
4
4
|
import * as _cmssy_types from '@cmssy/types';
|
|
5
|
-
import { FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord,
|
|
6
|
-
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
5
|
+
import { FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
6
|
+
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
7
7
|
|
|
8
8
|
type Declared<O> = O extends {
|
|
9
9
|
required: true;
|
|
@@ -66,8 +66,6 @@ declare const fields: {
|
|
|
66
66
|
relation: <const O extends RelationFieldOptions>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
70
|
-
|
|
71
69
|
declare const CMSSY_EDIT_HEADER = "x-cmssy-edit";
|
|
72
70
|
declare const CMSSY_EDIT_QUERY_PARAM = "cmssyEdit";
|
|
73
71
|
declare const CMSSY_SECRET_QUERY_PARAM = "cmssySecret";
|
|
@@ -103,4 +101,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
103
101
|
*/
|
|
104
102
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
105
103
|
|
|
106
|
-
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyWebhookError,
|
|
104
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyWebhookError, fields, isVerifiedEditUrl, verifyCmssyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, e as ParentReadyMessage, f as PatchMessage, g as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, h as applyCmssyCsp, i as createCmssyClient, j as defineCmssyConfig, k as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, l as postToEditor, r as resolveEditorOrigin } from './csp-
|
|
2
|
-
export { G as GraphqlRequestOptions, g as graphqlRequest } from './
|
|
1
|
+
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, e as ParentReadyMessage, f as PatchMessage, g as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, h as applyCmssyCsp, i as createCmssyClient, j as defineCmssyConfig, k as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, l as postToEditor, r as resolveEditorOrigin } from './csp-Blh6P15m.js';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref } from './locale-XintNd0n.js';
|
|
3
3
|
export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, F as FetchLike, a as FetchLikeResponse, b as FetchPageOptions, R as RetryPolicy } from './content-client-D0EdiqbQ.js';
|
|
4
4
|
import * as _cmssy_types from '@cmssy/types';
|
|
5
|
-
import { FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord,
|
|
6
|
-
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
5
|
+
import { FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
6
|
+
export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockPage, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
|
|
7
7
|
|
|
8
8
|
type Declared<O> = O extends {
|
|
9
9
|
required: true;
|
|
@@ -66,8 +66,6 @@ declare const fields: {
|
|
|
66
66
|
relation: <const O extends RelationFieldOptions>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
70
|
-
|
|
71
69
|
declare const CMSSY_EDIT_HEADER = "x-cmssy-edit";
|
|
72
70
|
declare const CMSSY_EDIT_QUERY_PARAM = "cmssyEdit";
|
|
73
71
|
declare const CMSSY_SECRET_QUERY_PARAM = "cmssySecret";
|
|
@@ -103,4 +101,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
103
101
|
*/
|
|
104
102
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
105
103
|
|
|
106
|
-
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyWebhookError,
|
|
104
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyWebhookError, fields, isVerifiedEditUrl, verifyCmssyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -321,21 +321,43 @@ var fields = {
|
|
|
321
321
|
}
|
|
322
322
|
};
|
|
323
323
|
|
|
324
|
-
// src/
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
324
|
+
// src/data/localize-href.ts
|
|
325
|
+
var PROTOCOL_OR_RELATIVE = /^([a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
326
|
+
function isExternalHref(href) {
|
|
327
|
+
const value = href.trim();
|
|
328
|
+
if (!value) return true;
|
|
329
|
+
if (value.startsWith("#")) return true;
|
|
330
|
+
return PROTOCOL_OR_RELATIVE.test(value);
|
|
331
|
+
}
|
|
332
|
+
function stripLeadingLocale(path, locale) {
|
|
333
|
+
const segments = path.split("/");
|
|
334
|
+
const first = segments[1];
|
|
335
|
+
if (first && first !== locale.default && locale.enabled.includes(first)) {
|
|
336
|
+
segments.splice(1, 1);
|
|
337
|
+
const rest = segments.join("/");
|
|
338
|
+
return rest === "" ? "/" : rest;
|
|
339
|
+
}
|
|
340
|
+
return path;
|
|
341
|
+
}
|
|
342
|
+
function addLocalePrefix(path, target, locale) {
|
|
343
|
+
if (target === locale.default) return path;
|
|
344
|
+
if (path === "/") return `/${target}`;
|
|
345
|
+
return `/${target}${path}`;
|
|
346
|
+
}
|
|
347
|
+
function localizeHref(href, locale) {
|
|
348
|
+
const value = href.trim();
|
|
349
|
+
if (isExternalHref(value)) return href;
|
|
350
|
+
const boundary = value.search(/[?#]/);
|
|
351
|
+
const path = boundary === -1 ? value : value.slice(0, boundary);
|
|
352
|
+
const suffix = boundary === -1 ? "" : value.slice(boundary);
|
|
353
|
+
if (!path.startsWith("/")) return href;
|
|
354
|
+
const bare = stripLeadingLocale(path, locale);
|
|
355
|
+
return `${addLocalePrefix(bare, locale.current, locale)}${suffix}`;
|
|
337
356
|
}
|
|
338
357
|
|
|
358
|
+
// src/locale.ts
|
|
359
|
+
var CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
360
|
+
|
|
339
361
|
// src/bridge/protocol.ts
|
|
340
362
|
var PROTOCOL_VERSION = 2;
|
|
341
363
|
function isProtocolCompatible(version) {
|
|
@@ -588,4 +610,4 @@ async function verifyCmssyWebhook(options) {
|
|
|
588
610
|
return parsed;
|
|
589
611
|
}
|
|
590
612
|
|
|
591
|
-
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, applyCmssyCsp,
|
|
613
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, applyCmssyCsp, createCmssyClient, defineCmssyConfig, fields, graphqlRequest, isProtocolCompatible, isVerifiedEditUrl, localizeHref, normalizeOrigin, parseEditorMessage, postToEditor, resolveEditorOrigin, verifyCmssyWebhook };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as GraphqlRequestOptions } from '../locale-rhYcXU5z.cjs';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from '../locale-rhYcXU5z.cjs';
|
|
3
|
+
import { CmssySiteLocales, CmssyClientConfig } from '@cmssy/types';
|
|
2
4
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
3
|
-
import { G as GraphqlRequestOptions } from '../graphql-request-NQxSMt6v.cjs';
|
|
4
5
|
import '../content-client-D0EdiqbQ.cjs';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -18,39 +19,10 @@ declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: Cm
|
|
|
18
19
|
path: string[] | undefined;
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
/**
|
|
22
|
-
* Rewrites an internal href to carry the active locale as a path prefix.
|
|
23
|
-
* External hrefs, fragments and relative paths are returned untouched. Already
|
|
24
|
-
* prefixed hrefs are normalized so the prefix never doubles.
|
|
25
|
-
*/
|
|
26
|
-
declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
|
|
27
|
-
/**
|
|
28
|
-
* Builds the href that switches the current `pathname` to `target` locale,
|
|
29
|
-
* preserving the rest of the path. Used by a language switcher.
|
|
30
|
-
*/
|
|
31
|
-
declare function buildLocaleSwitchHref(target: string, pathname: string, locale: CmssyLocaleContext): string;
|
|
32
|
-
/**
|
|
33
|
-
* Rewrites every `<a href>` inside an HTML string with {@link localizeHref}.
|
|
34
|
-
* For rich-text content stored in CMS blocks where links are raw markup.
|
|
35
|
-
*/
|
|
36
|
-
declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
|
|
37
|
-
|
|
38
|
-
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
39
|
-
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
40
|
-
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
41
|
-
locale: string;
|
|
42
|
-
path: string[] | undefined;
|
|
43
|
-
}>;
|
|
44
|
-
/**
|
|
45
|
-
* Resolve the locale a path asks for. The prefix IS the language, so a routed
|
|
46
|
-
* path is all it takes - no request, no headers, static-safe.
|
|
47
|
-
*/
|
|
48
|
-
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
49
|
-
|
|
50
22
|
/**
|
|
51
23
|
* Maps a page slug to its path for a locale: the default locale gets no
|
|
52
24
|
* prefix, others get `/${locale}`. The homepage ("/") stays "/" (or "/${locale}").
|
|
53
25
|
*/
|
|
54
26
|
declare function localizedPath(slug: string, locale: string, defaultLocale: string): string;
|
|
55
27
|
|
|
56
|
-
export {
|
|
28
|
+
export { localesFromSiteConfig, localizedPath, resolveSiteLocales, splitLocaleFromPath };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as GraphqlRequestOptions } from '../locale-XintNd0n.js';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from '../locale-XintNd0n.js';
|
|
3
|
+
import { CmssySiteLocales, CmssyClientConfig } from '@cmssy/types';
|
|
2
4
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
3
|
-
import { G as GraphqlRequestOptions } from '../graphql-request-CDh6IRok.js';
|
|
4
5
|
import '../content-client-D0EdiqbQ.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -18,39 +19,10 @@ declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: Cm
|
|
|
18
19
|
path: string[] | undefined;
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
/**
|
|
22
|
-
* Rewrites an internal href to carry the active locale as a path prefix.
|
|
23
|
-
* External hrefs, fragments and relative paths are returned untouched. Already
|
|
24
|
-
* prefixed hrefs are normalized so the prefix never doubles.
|
|
25
|
-
*/
|
|
26
|
-
declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
|
|
27
|
-
/**
|
|
28
|
-
* Builds the href that switches the current `pathname` to `target` locale,
|
|
29
|
-
* preserving the rest of the path. Used by a language switcher.
|
|
30
|
-
*/
|
|
31
|
-
declare function buildLocaleSwitchHref(target: string, pathname: string, locale: CmssyLocaleContext): string;
|
|
32
|
-
/**
|
|
33
|
-
* Rewrites every `<a href>` inside an HTML string with {@link localizeHref}.
|
|
34
|
-
* For rich-text content stored in CMS blocks where links are raw markup.
|
|
35
|
-
*/
|
|
36
|
-
declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
|
|
37
|
-
|
|
38
|
-
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
39
|
-
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
40
|
-
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
41
|
-
locale: string;
|
|
42
|
-
path: string[] | undefined;
|
|
43
|
-
}>;
|
|
44
|
-
/**
|
|
45
|
-
* Resolve the locale a path asks for. The prefix IS the language, so a routed
|
|
46
|
-
* path is all it takes - no request, no headers, static-safe.
|
|
47
|
-
*/
|
|
48
|
-
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
49
|
-
|
|
50
22
|
/**
|
|
51
23
|
* Maps a page slug to its path for a locale: the default locale gets no
|
|
52
24
|
* prefix, others get `/${locale}`. The homepage ("/") stays "/" (or "/${locale}").
|
|
53
25
|
*/
|
|
54
26
|
declare function localizedPath(slug: string, locale: string, defaultLocale: string): string;
|
|
55
27
|
|
|
56
|
-
export {
|
|
28
|
+
export { localesFromSiteConfig, localizedPath, resolveSiteLocales, splitLocaleFromPath };
|
package/dist/internal.cjs
CHANGED
|
@@ -120,6 +120,8 @@ var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String
|
|
|
120
120
|
page {
|
|
121
121
|
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret) {
|
|
122
122
|
id
|
|
123
|
+
slug
|
|
124
|
+
pageType
|
|
123
125
|
blocks { id type content style advanced }
|
|
124
126
|
publishedBlocks { id type content style advanced }
|
|
125
127
|
}
|
|
@@ -131,6 +133,8 @@ var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: St
|
|
|
131
133
|
page {
|
|
132
134
|
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret, devPreview: $devPreview) {
|
|
133
135
|
id
|
|
136
|
+
slug
|
|
137
|
+
pageType
|
|
134
138
|
blocks { id type content style advanced }
|
|
135
139
|
publishedBlocks { id type content style advanced }
|
|
136
140
|
}
|
|
@@ -142,6 +146,8 @@ var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pa
|
|
|
142
146
|
page {
|
|
143
147
|
getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
|
|
144
148
|
id
|
|
149
|
+
slug
|
|
150
|
+
pageType
|
|
145
151
|
publishedBlocks { id type content style advanced }
|
|
146
152
|
}
|
|
147
153
|
}
|
|
@@ -225,7 +231,12 @@ async function fetchPage(config, path, options = {}) {
|
|
|
225
231
|
if (!page) return null;
|
|
226
232
|
const draft = previewSecret !== null || devPreview;
|
|
227
233
|
const blocks = (draft ? page.blocks : page.publishedBlocks) ?? [];
|
|
228
|
-
return {
|
|
234
|
+
return {
|
|
235
|
+
id: page.id,
|
|
236
|
+
blocks,
|
|
237
|
+
slug: page.slug ?? slug,
|
|
238
|
+
pageType: page.pageType ?? null
|
|
239
|
+
};
|
|
229
240
|
}
|
|
230
241
|
async function fetchPageById(config, pageId, options = {}) {
|
|
231
242
|
const data = await postGraphql(
|
|
@@ -241,7 +252,12 @@ async function fetchPageById(config, pageId, options = {}) {
|
|
|
241
252
|
);
|
|
242
253
|
const page = data?.public?.page?.getById;
|
|
243
254
|
if (!page) return null;
|
|
244
|
-
return {
|
|
255
|
+
return {
|
|
256
|
+
id: page.id,
|
|
257
|
+
blocks: page.publishedBlocks ?? [],
|
|
258
|
+
...page.slug ? { slug: page.slug } : {},
|
|
259
|
+
pageType: page.pageType ?? null
|
|
260
|
+
};
|
|
245
261
|
}
|
|
246
262
|
async function fetchPages(config, options = {}) {
|
|
247
263
|
const data = await postGraphql(
|
|
@@ -802,6 +818,30 @@ function localizedPath(slug, locale, defaultLocale) {
|
|
|
802
818
|
return locale === defaultLocale ? base || "/" : `/${locale}${base}`;
|
|
803
819
|
}
|
|
804
820
|
|
|
821
|
+
// src/block-context.ts
|
|
822
|
+
function blockPageOf(page) {
|
|
823
|
+
if (!page?.slug) return void 0;
|
|
824
|
+
return {
|
|
825
|
+
id: page.id,
|
|
826
|
+
slug: page.slug,
|
|
827
|
+
pageType: page.pageType ?? null
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
|
|
831
|
+
return {
|
|
832
|
+
locale: {
|
|
833
|
+
current: locale,
|
|
834
|
+
default: defaultLocale,
|
|
835
|
+
enabled: enabledLocales && enabledLocales.length > 0 ? enabledLocales : Array.from(/* @__PURE__ */ new Set([defaultLocale, locale]))
|
|
836
|
+
},
|
|
837
|
+
isPreview: isPreview ?? false,
|
|
838
|
+
forms,
|
|
839
|
+
...extra?.auth ? { auth: extra.auth } : {},
|
|
840
|
+
...extra?.workspace ? { workspace: extra.workspace } : {},
|
|
841
|
+
...extra?.page ? { page: extra.page } : {}
|
|
842
|
+
};
|
|
843
|
+
}
|
|
844
|
+
|
|
805
845
|
// src/bridge/messages.ts
|
|
806
846
|
function normalizeOrigin(origin) {
|
|
807
847
|
const trimmed = origin.trim();
|
|
@@ -905,6 +945,8 @@ exports.RECORDS_BY_IDS_QUERY = RECORDS_BY_IDS_QUERY;
|
|
|
905
945
|
exports.SITE_CONFIG_QUERY = SITE_CONFIG_QUERY;
|
|
906
946
|
exports.SUBMIT_FORM_MUTATION = SUBMIT_FORM_MUTATION;
|
|
907
947
|
exports.asBucket = asBucket;
|
|
948
|
+
exports.blockPageOf = blockPageOf;
|
|
949
|
+
exports.buildBlockContext = buildBlockContext;
|
|
908
950
|
exports.buildLocaleSwitchHref = buildLocaleSwitchHref;
|
|
909
951
|
exports.cachedWorkspaceId = cachedWorkspaceId;
|
|
910
952
|
exports.clearWorkspaceIdCache = clearWorkspaceIdCache;
|
package/dist/internal.d.cts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, n as normalizeSlug, r as resolveApiUrl, h as resolvePublicUrl } from './content-client-D0EdiqbQ.cjs';
|
|
2
|
-
import { CmssyClientConfig, CmssySiteConfig, RawBlock,
|
|
2
|
+
import { CmssyPageData, CmssyBlockPage, CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, CmssySiteConfig, RawBlock, FieldDefinition } from '@cmssy/types';
|
|
3
3
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
4
|
-
import { G as GraphqlRequestOptions } from './
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
4
|
+
import { G as GraphqlRequestOptions } from './locale-rhYcXU5z.cjs';
|
|
5
|
+
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-rhYcXU5z.cjs';
|
|
6
|
+
import { Q as QueryScopedOptions } from './csp-DlAEXYjA.cjs';
|
|
7
|
+
export { m as cmssyCspHeaders, o as isDevelopment, q as resolveInitialTarget, t as toCspOrigin } from './csp-DlAEXYjA.cjs';
|
|
8
|
+
export { localesFromSiteConfig, localizedPath, resolveSiteLocales, splitLocaleFromPath } from './internal/locale.cjs';
|
|
8
9
|
|
|
9
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 faviconUrl\n ogImageUrl\n }\n }\n }\n}";
|
|
10
11
|
declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n public {\n model {\n definitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n }\n }\n}";
|
|
@@ -12,6 +13,16 @@ declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: Stri
|
|
|
12
13
|
declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin enableCaptcha\n }\n }\n }\n }\n}";
|
|
13
14
|
declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n }\n }\n}";
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The identity half of a fetched page, for `context.page`.
|
|
18
|
+
*
|
|
19
|
+
* A page fetched by an older SDK - or by a consumer that builds `CmssyPageData`
|
|
20
|
+
* itself - has no slug, and then a block gets no `page` at all rather than one
|
|
21
|
+
* with a hole in it: `context.page ? … : …` is a question a block can answer.
|
|
22
|
+
*/
|
|
23
|
+
declare function blockPageOf(page: CmssyPageData | null | undefined): CmssyBlockPage | undefined;
|
|
24
|
+
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
25
|
+
|
|
15
26
|
declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
|
|
16
27
|
/**
|
|
17
28
|
* Coerce a block bucket (`style` / `advanced`) to a plain object. These buckets
|
|
@@ -59,4 +70,4 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
|
|
|
59
70
|
|
|
60
71
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
61
72
|
|
|
62
|
-
export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
|
73
|
+
export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, blockPageOf, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, n as normalizeSlug, r as resolveApiUrl, h as resolvePublicUrl } from './content-client-D0EdiqbQ.js';
|
|
2
|
-
import { CmssyClientConfig, CmssySiteConfig, RawBlock,
|
|
2
|
+
import { CmssyPageData, CmssyBlockPage, CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, CmssySiteConfig, RawBlock, FieldDefinition } from '@cmssy/types';
|
|
3
3
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
4
|
-
import { G as GraphqlRequestOptions } from './
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
4
|
+
import { G as GraphqlRequestOptions } from './locale-XintNd0n.js';
|
|
5
|
+
export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-XintNd0n.js';
|
|
6
|
+
import { Q as QueryScopedOptions } from './csp-Blh6P15m.js';
|
|
7
|
+
export { m as cmssyCspHeaders, o as isDevelopment, q as resolveInitialTarget, t as toCspOrigin } from './csp-Blh6P15m.js';
|
|
8
|
+
export { localesFromSiteConfig, localizedPath, resolveSiteLocales, splitLocaleFromPath } from './internal/locale.js';
|
|
8
9
|
|
|
9
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 faviconUrl\n ogImageUrl\n }\n }\n }\n}";
|
|
10
11
|
declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n public {\n model {\n definitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n }\n }\n}";
|
|
@@ -12,6 +13,16 @@ declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: Stri
|
|
|
12
13
|
declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin enableCaptcha\n }\n }\n }\n }\n}";
|
|
13
14
|
declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n }\n }\n}";
|
|
14
15
|
|
|
16
|
+
/**
|
|
17
|
+
* The identity half of a fetched page, for `context.page`.
|
|
18
|
+
*
|
|
19
|
+
* A page fetched by an older SDK - or by a consumer that builds `CmssyPageData`
|
|
20
|
+
* itself - has no slug, and then a block gets no `page` at all rather than one
|
|
21
|
+
* with a hole in it: `context.page ? … : …` is a question a block can answer.
|
|
22
|
+
*/
|
|
23
|
+
declare function blockPageOf(page: CmssyPageData | null | undefined): CmssyBlockPage | undefined;
|
|
24
|
+
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
25
|
+
|
|
15
26
|
declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
|
|
16
27
|
/**
|
|
17
28
|
* Coerce a block bucket (`style` / `advanced`) to a plain object. These buckets
|
|
@@ -59,4 +70,4 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
|
|
|
59
70
|
|
|
60
71
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
61
72
|
|
|
62
|
-
export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
|
73
|
+
export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, blockPageOf, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
package/dist/internal.js
CHANGED
|
@@ -118,6 +118,8 @@ var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String
|
|
|
118
118
|
page {
|
|
119
119
|
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret) {
|
|
120
120
|
id
|
|
121
|
+
slug
|
|
122
|
+
pageType
|
|
121
123
|
blocks { id type content style advanced }
|
|
122
124
|
publishedBlocks { id type content style advanced }
|
|
123
125
|
}
|
|
@@ -129,6 +131,8 @@ var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: St
|
|
|
129
131
|
page {
|
|
130
132
|
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret, devPreview: $devPreview) {
|
|
131
133
|
id
|
|
134
|
+
slug
|
|
135
|
+
pageType
|
|
132
136
|
blocks { id type content style advanced }
|
|
133
137
|
publishedBlocks { id type content style advanced }
|
|
134
138
|
}
|
|
@@ -140,6 +144,8 @@ var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pa
|
|
|
140
144
|
page {
|
|
141
145
|
getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
|
|
142
146
|
id
|
|
147
|
+
slug
|
|
148
|
+
pageType
|
|
143
149
|
publishedBlocks { id type content style advanced }
|
|
144
150
|
}
|
|
145
151
|
}
|
|
@@ -223,7 +229,12 @@ async function fetchPage(config, path, options = {}) {
|
|
|
223
229
|
if (!page) return null;
|
|
224
230
|
const draft = previewSecret !== null || devPreview;
|
|
225
231
|
const blocks = (draft ? page.blocks : page.publishedBlocks) ?? [];
|
|
226
|
-
return {
|
|
232
|
+
return {
|
|
233
|
+
id: page.id,
|
|
234
|
+
blocks,
|
|
235
|
+
slug: page.slug ?? slug,
|
|
236
|
+
pageType: page.pageType ?? null
|
|
237
|
+
};
|
|
227
238
|
}
|
|
228
239
|
async function fetchPageById(config, pageId, options = {}) {
|
|
229
240
|
const data = await postGraphql(
|
|
@@ -239,7 +250,12 @@ async function fetchPageById(config, pageId, options = {}) {
|
|
|
239
250
|
);
|
|
240
251
|
const page = data?.public?.page?.getById;
|
|
241
252
|
if (!page) return null;
|
|
242
|
-
return {
|
|
253
|
+
return {
|
|
254
|
+
id: page.id,
|
|
255
|
+
blocks: page.publishedBlocks ?? [],
|
|
256
|
+
...page.slug ? { slug: page.slug } : {},
|
|
257
|
+
pageType: page.pageType ?? null
|
|
258
|
+
};
|
|
243
259
|
}
|
|
244
260
|
async function fetchPages(config, options = {}) {
|
|
245
261
|
const data = await postGraphql(
|
|
@@ -800,6 +816,30 @@ function localizedPath(slug, locale, defaultLocale) {
|
|
|
800
816
|
return locale === defaultLocale ? base || "/" : `/${locale}${base}`;
|
|
801
817
|
}
|
|
802
818
|
|
|
819
|
+
// src/block-context.ts
|
|
820
|
+
function blockPageOf(page) {
|
|
821
|
+
if (!page?.slug) return void 0;
|
|
822
|
+
return {
|
|
823
|
+
id: page.id,
|
|
824
|
+
slug: page.slug,
|
|
825
|
+
pageType: page.pageType ?? null
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
|
|
829
|
+
return {
|
|
830
|
+
locale: {
|
|
831
|
+
current: locale,
|
|
832
|
+
default: defaultLocale,
|
|
833
|
+
enabled: enabledLocales && enabledLocales.length > 0 ? enabledLocales : Array.from(/* @__PURE__ */ new Set([defaultLocale, locale]))
|
|
834
|
+
},
|
|
835
|
+
isPreview: isPreview ?? false,
|
|
836
|
+
forms,
|
|
837
|
+
...extra?.auth ? { auth: extra.auth } : {},
|
|
838
|
+
...extra?.workspace ? { workspace: extra.workspace } : {},
|
|
839
|
+
...extra?.page ? { page: extra.page } : {}
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
|
|
803
843
|
// src/bridge/messages.ts
|
|
804
844
|
function normalizeOrigin(origin) {
|
|
805
845
|
const trimmed = origin.trim();
|
|
@@ -895,4 +935,4 @@ function cmssyCspHeaders(options) {
|
|
|
895
935
|
};
|
|
896
936
|
}
|
|
897
937
|
|
|
898
|
-
export { CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, 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 };
|
|
938
|
+
export { CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, blockPageOf, 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 };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { F as FetchLike, R as RetryPolicy } from './content-client-D0EdiqbQ.js';
|
|
2
|
+
import { CmssyClientConfig, CmssyLocaleContext } from '@cmssy/types';
|
|
3
|
+
|
|
4
|
+
interface GraphqlRequestOptions {
|
|
5
|
+
fetch?: FetchLike;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Route through the org-scoped public delivery path instead of the base
|
|
10
|
+
* `/graphql` endpoint. Set for unauthenticated public queries so the backend
|
|
11
|
+
* resolves the workspace from the URL rather than a global slug lookup.
|
|
12
|
+
*/
|
|
13
|
+
public?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Retry transient HTTP failures (429/503, honoring Retry-After). Off by
|
|
16
|
+
* default: this function also carries mutations (auth, cart, checkout),
|
|
17
|
+
* which must never be blind-retried. Read-only callers opt in with `{}`.
|
|
18
|
+
*/
|
|
19
|
+
retry?: RetryPolicy | false;
|
|
20
|
+
}
|
|
21
|
+
declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Rewrites an internal href to carry the active locale as a path prefix.
|
|
25
|
+
* External hrefs, fragments and relative paths are returned untouched. Already
|
|
26
|
+
* prefixed hrefs are normalized so the prefix never doubles.
|
|
27
|
+
*/
|
|
28
|
+
declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
|
|
29
|
+
/**
|
|
30
|
+
* Builds the href that switches the current `pathname` to `target` locale,
|
|
31
|
+
* preserving the rest of the path. Used by a language switcher.
|
|
32
|
+
*/
|
|
33
|
+
declare function buildLocaleSwitchHref(target: string, pathname: string, locale: CmssyLocaleContext): string;
|
|
34
|
+
/**
|
|
35
|
+
* Rewrites every `<a href>` inside an HTML string with {@link localizeHref}.
|
|
36
|
+
* For rich-text content stored in CMS blocks where links are raw markup.
|
|
37
|
+
*/
|
|
38
|
+
declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
|
|
39
|
+
|
|
40
|
+
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
41
|
+
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
42
|
+
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
43
|
+
locale: string;
|
|
44
|
+
path: string[] | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the locale a path asks for. The prefix IS the language, so a routed
|
|
48
|
+
* path is all it takes - no request, no headers, static-safe.
|
|
49
|
+
*/
|
|
50
|
+
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
51
|
+
|
|
52
|
+
export { CMSSY_LOCALE_HEADER as C, type GraphqlRequestOptions as G, localeForPath as a, buildLocaleSwitchHref as b, localeForPathname as c, localizeHtmlLinks as d, graphqlRequest as g, localizeHref as l, splitCmssyLocale as s };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { F as FetchLike, R as RetryPolicy } from './content-client-D0EdiqbQ.cjs';
|
|
2
|
+
import { CmssyClientConfig, CmssyLocaleContext } from '@cmssy/types';
|
|
3
|
+
|
|
4
|
+
interface GraphqlRequestOptions {
|
|
5
|
+
fetch?: FetchLike;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Route through the org-scoped public delivery path instead of the base
|
|
10
|
+
* `/graphql` endpoint. Set for unauthenticated public queries so the backend
|
|
11
|
+
* resolves the workspace from the URL rather than a global slug lookup.
|
|
12
|
+
*/
|
|
13
|
+
public?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Retry transient HTTP failures (429/503, honoring Retry-After). Off by
|
|
16
|
+
* default: this function also carries mutations (auth, cart, checkout),
|
|
17
|
+
* which must never be blind-retried. Read-only callers opt in with `{}`.
|
|
18
|
+
*/
|
|
19
|
+
retry?: RetryPolicy | false;
|
|
20
|
+
}
|
|
21
|
+
declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Rewrites an internal href to carry the active locale as a path prefix.
|
|
25
|
+
* External hrefs, fragments and relative paths are returned untouched. Already
|
|
26
|
+
* prefixed hrefs are normalized so the prefix never doubles.
|
|
27
|
+
*/
|
|
28
|
+
declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
|
|
29
|
+
/**
|
|
30
|
+
* Builds the href that switches the current `pathname` to `target` locale,
|
|
31
|
+
* preserving the rest of the path. Used by a language switcher.
|
|
32
|
+
*/
|
|
33
|
+
declare function buildLocaleSwitchHref(target: string, pathname: string, locale: CmssyLocaleContext): string;
|
|
34
|
+
/**
|
|
35
|
+
* Rewrites every `<a href>` inside an HTML string with {@link localizeHref}.
|
|
36
|
+
* For rich-text content stored in CMS blocks where links are raw markup.
|
|
37
|
+
*/
|
|
38
|
+
declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
|
|
39
|
+
|
|
40
|
+
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
41
|
+
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
42
|
+
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
43
|
+
locale: string;
|
|
44
|
+
path: string[] | undefined;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the locale a path asks for. The prefix IS the language, so a routed
|
|
48
|
+
* path is all it takes - no request, no headers, static-safe.
|
|
49
|
+
*/
|
|
50
|
+
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
51
|
+
|
|
52
|
+
export { CMSSY_LOCALE_HEADER as C, type GraphqlRequestOptions as G, localeForPath as a, buildLocaleSwitchHref as b, localeForPathname as c, localizeHtmlLinks as d, graphqlRequest as g, localizeHref as l, splitCmssyLocale as s };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/core",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.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",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vitest": "^2.1.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@cmssy/types": "0.
|
|
65
|
+
"@cmssy/types": "0.30.0",
|
|
66
66
|
"jose": "^6.2.3"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { F as FetchLike, R as RetryPolicy } from './content-client-D0EdiqbQ.js';
|
|
2
|
-
import { CmssyClientConfig } from '@cmssy/types';
|
|
3
|
-
|
|
4
|
-
interface GraphqlRequestOptions {
|
|
5
|
-
fetch?: FetchLike;
|
|
6
|
-
signal?: AbortSignal;
|
|
7
|
-
headers?: Record<string, string>;
|
|
8
|
-
/**
|
|
9
|
-
* Route through the org-scoped public delivery path instead of the base
|
|
10
|
-
* `/graphql` endpoint. Set for unauthenticated public queries so the backend
|
|
11
|
-
* resolves the workspace from the URL rather than a global slug lookup.
|
|
12
|
-
*/
|
|
13
|
-
public?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Retry transient HTTP failures (429/503, honoring Retry-After). Off by
|
|
16
|
-
* default: this function also carries mutations (auth, cart, checkout),
|
|
17
|
-
* which must never be blind-retried. Read-only callers opt in with `{}`.
|
|
18
|
-
*/
|
|
19
|
-
retry?: RetryPolicy | false;
|
|
20
|
-
}
|
|
21
|
-
declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
|
|
22
|
-
|
|
23
|
-
export { type GraphqlRequestOptions as G, graphqlRequest as g };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { F as FetchLike, R as RetryPolicy } from './content-client-D0EdiqbQ.cjs';
|
|
2
|
-
import { CmssyClientConfig } from '@cmssy/types';
|
|
3
|
-
|
|
4
|
-
interface GraphqlRequestOptions {
|
|
5
|
-
fetch?: FetchLike;
|
|
6
|
-
signal?: AbortSignal;
|
|
7
|
-
headers?: Record<string, string>;
|
|
8
|
-
/**
|
|
9
|
-
* Route through the org-scoped public delivery path instead of the base
|
|
10
|
-
* `/graphql` endpoint. Set for unauthenticated public queries so the backend
|
|
11
|
-
* resolves the workspace from the URL rather than a global slug lookup.
|
|
12
|
-
*/
|
|
13
|
-
public?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Retry transient HTTP failures (429/503, honoring Retry-After). Off by
|
|
16
|
-
* default: this function also carries mutations (auth, cart, checkout),
|
|
17
|
-
* which must never be blind-retried. Read-only callers opt in with `{}`.
|
|
18
|
-
*/
|
|
19
|
-
retry?: RetryPolicy | false;
|
|
20
|
-
}
|
|
21
|
-
declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
|
|
22
|
-
|
|
23
|
-
export { type GraphqlRequestOptions as G, graphqlRequest as g };
|