@cmssy/core 10.0.0 → 10.1.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 +4 -6
- package/dist/index.d.ts +4 -6
- 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 +16 -0
- package/dist/internal.d.cts +9 -6
- package/dist/internal.d.ts +9 -6
- package/dist/internal.js +16 -1
- package/dist/locale-XintNd0n.d.ts +52 -0
- package/dist/locale-rhYcXU5z.d.cts +52 -0
- package/package.json +1 -1
- 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,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, 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,
|
|
5
|
+
import { FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
6
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';
|
|
7
7
|
|
|
8
8
|
type Declared<O> = O extends {
|
|
@@ -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,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, 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,
|
|
5
|
+
import { FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
|
6
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';
|
|
7
7
|
|
|
8
8
|
type Declared<O> = O extends {
|
|
@@ -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
|
@@ -802,6 +802,21 @@ function localizedPath(slug, locale, defaultLocale) {
|
|
|
802
802
|
return locale === defaultLocale ? base || "/" : `/${locale}${base}`;
|
|
803
803
|
}
|
|
804
804
|
|
|
805
|
+
// src/block-context.ts
|
|
806
|
+
function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
|
|
807
|
+
return {
|
|
808
|
+
locale: {
|
|
809
|
+
current: locale,
|
|
810
|
+
default: defaultLocale,
|
|
811
|
+
enabled: enabledLocales && enabledLocales.length > 0 ? enabledLocales : Array.from(/* @__PURE__ */ new Set([defaultLocale, locale]))
|
|
812
|
+
},
|
|
813
|
+
isPreview: isPreview ?? false,
|
|
814
|
+
forms,
|
|
815
|
+
...extra?.auth ? { auth: extra.auth } : {},
|
|
816
|
+
...extra?.workspace ? { workspace: extra.workspace } : {}
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
|
|
805
820
|
// src/bridge/messages.ts
|
|
806
821
|
function normalizeOrigin(origin) {
|
|
807
822
|
const trimmed = origin.trim();
|
|
@@ -905,6 +920,7 @@ exports.RECORDS_BY_IDS_QUERY = RECORDS_BY_IDS_QUERY;
|
|
|
905
920
|
exports.SITE_CONFIG_QUERY = SITE_CONFIG_QUERY;
|
|
906
921
|
exports.SUBMIT_FORM_MUTATION = SUBMIT_FORM_MUTATION;
|
|
907
922
|
exports.asBucket = asBucket;
|
|
923
|
+
exports.buildBlockContext = buildBlockContext;
|
|
908
924
|
exports.buildLocaleSwitchHref = buildLocaleSwitchHref;
|
|
909
925
|
exports.cachedWorkspaceId = cachedWorkspaceId;
|
|
910
926
|
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 { 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,8 @@ 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
|
+
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
17
|
+
|
|
15
18
|
declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
|
|
16
19
|
/**
|
|
17
20
|
* Coerce a block bucket (`style` / `advanced`) to a plain object. These buckets
|
|
@@ -59,4 +62,4 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
|
|
|
59
62
|
|
|
60
63
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
61
64
|
|
|
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 };
|
|
65
|
+
export { type BlockSchemaMap, 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
|
@@ -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 { 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,8 @@ 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
|
+
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
17
|
+
|
|
15
18
|
declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
|
|
16
19
|
/**
|
|
17
20
|
* Coerce a block bucket (`style` / `advanced`) to a plain object. These buckets
|
|
@@ -59,4 +62,4 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
|
|
|
59
62
|
|
|
60
63
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
61
64
|
|
|
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 };
|
|
65
|
+
export { type BlockSchemaMap, 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
|
@@ -800,6 +800,21 @@ function localizedPath(slug, locale, defaultLocale) {
|
|
|
800
800
|
return locale === defaultLocale ? base || "/" : `/${locale}${base}`;
|
|
801
801
|
}
|
|
802
802
|
|
|
803
|
+
// src/block-context.ts
|
|
804
|
+
function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
|
|
805
|
+
return {
|
|
806
|
+
locale: {
|
|
807
|
+
current: locale,
|
|
808
|
+
default: defaultLocale,
|
|
809
|
+
enabled: enabledLocales && enabledLocales.length > 0 ? enabledLocales : Array.from(/* @__PURE__ */ new Set([defaultLocale, locale]))
|
|
810
|
+
},
|
|
811
|
+
isPreview: isPreview ?? false,
|
|
812
|
+
forms,
|
|
813
|
+
...extra?.auth ? { auth: extra.auth } : {},
|
|
814
|
+
...extra?.workspace ? { workspace: extra.workspace } : {}
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
|
|
803
818
|
// src/bridge/messages.ts
|
|
804
819
|
function normalizeOrigin(origin) {
|
|
805
820
|
const trimmed = origin.trim();
|
|
@@ -895,4 +910,4 @@ function cmssyCspHeaders(options) {
|
|
|
895
910
|
};
|
|
896
911
|
}
|
|
897
912
|
|
|
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 };
|
|
913
|
+
export { 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 };
|
|
@@ -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,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 };
|