@cmssy/core 8.0.4 → 9.0.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/index.cjs +10 -13
- package/dist/index.d.cts +15 -19
- package/dist/index.d.ts +15 -19
- package/dist/index.js +10 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -663,6 +663,14 @@ async function resolveForms(config, blocks, locale, defaultLocale, options) {
|
|
|
663
663
|
var TTL_MS = 6e4;
|
|
664
664
|
var MAX_ENTRIES = 64;
|
|
665
665
|
var cache = /* @__PURE__ */ new Map();
|
|
666
|
+
function localesFromSiteConfig(siteConfig) {
|
|
667
|
+
const defaultLocale = siteConfig?.defaultLanguage || "en";
|
|
668
|
+
const enabled = siteConfig?.enabledLanguages ?? [];
|
|
669
|
+
return {
|
|
670
|
+
defaultLocale,
|
|
671
|
+
locales: enabled.length > 0 ? enabled : [defaultLocale]
|
|
672
|
+
};
|
|
673
|
+
}
|
|
666
674
|
async function resolveSiteLocales(config, options) {
|
|
667
675
|
const key = `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
|
|
668
676
|
const cached = cache.get(key);
|
|
@@ -677,13 +685,7 @@ async function resolveSiteLocales(config, options) {
|
|
|
677
685
|
{ ...options, public: true, retry: options?.retry ?? {} },
|
|
678
686
|
"site config"
|
|
679
687
|
);
|
|
680
|
-
|
|
681
|
-
const defaultLocale = siteConfig?.defaultLanguage || "en";
|
|
682
|
-
const enabled = siteConfig?.enabledLanguages ?? [];
|
|
683
|
-
value = {
|
|
684
|
-
defaultLocale,
|
|
685
|
-
locales: enabled.length > 0 ? enabled : [defaultLocale]
|
|
686
|
-
};
|
|
688
|
+
value = localesFromSiteConfig(data.public?.siteConfig ?? null);
|
|
687
689
|
} catch {
|
|
688
690
|
value = { defaultLocale: "en", locales: ["en"] };
|
|
689
691
|
}
|
|
@@ -986,11 +988,6 @@ function applyCmssyCsp(response, options) {
|
|
|
986
988
|
}
|
|
987
989
|
|
|
988
990
|
// src/seo-paths.ts
|
|
989
|
-
function resolveSeoLocales(config, siteConfig) {
|
|
990
|
-
const defaultLocale = config.defaultLocale ?? siteConfig?.defaultLanguage ?? "en";
|
|
991
|
-
const locales = config.enabledLocales && config.enabledLocales.length > 0 ? config.enabledLocales : siteConfig?.enabledLanguages && siteConfig.enabledLanguages.length > 0 ? siteConfig.enabledLanguages : [defaultLocale];
|
|
992
|
-
return { defaultLocale, locales };
|
|
993
|
-
}
|
|
994
991
|
function normalizeSlug2(slug) {
|
|
995
992
|
if (slug === "/" || slug === "") return "/";
|
|
996
993
|
return slug.startsWith("/") ? slug : `/${slug}`;
|
|
@@ -1809,6 +1806,7 @@ exports.isProtocolCompatible = isProtocolCompatible;
|
|
|
1809
1806
|
exports.isVerifiedEditUrl = isVerifiedEditUrl;
|
|
1810
1807
|
exports.localeForPath = localeForPath;
|
|
1811
1808
|
exports.localeForPathname = localeForPathname;
|
|
1809
|
+
exports.localesFromSiteConfig = localesFromSiteConfig;
|
|
1812
1810
|
exports.localizeHref = localizeHref;
|
|
1813
1811
|
exports.localizeHtmlLinks = localizeHtmlLinks;
|
|
1814
1812
|
exports.localizedPath = localizedPath;
|
|
@@ -1822,7 +1820,6 @@ exports.resolveEditorOrigin = resolveEditorOrigin;
|
|
|
1822
1820
|
exports.resolveForms = resolveForms;
|
|
1823
1821
|
exports.resolveInitialTarget = resolveInitialTarget;
|
|
1824
1822
|
exports.resolvePublicUrl = resolvePublicUrl;
|
|
1825
|
-
exports.resolveSeoLocales = resolveSeoLocales;
|
|
1826
1823
|
exports.resolveSiteLocales = resolveSiteLocales;
|
|
1827
1824
|
exports.resolveWorkspaceId = resolveWorkspaceId;
|
|
1828
1825
|
exports.sealSession = sealSession;
|
package/dist/index.d.cts
CHANGED
|
@@ -37,9 +37,11 @@ interface CmssyConfig {
|
|
|
37
37
|
*/
|
|
38
38
|
siteUrl?: string;
|
|
39
39
|
auth?: CmssyAuthConfig;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Fallback locale resolver for a site whose URLs carry no language (e.g. a
|
|
42
|
+
* cookie or Accept-Language strategy). The workspace site config remains the
|
|
43
|
+
* source of truth for the default and enabled languages.
|
|
44
|
+
*/
|
|
43
45
|
resolveLocale?: () => string | Promise<string>;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
@@ -180,6 +182,15 @@ declare function clearWorkspaceIdCache(): void;
|
|
|
180
182
|
declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
|
|
181
183
|
declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
|
|
182
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Maps a workspace site config to its locale set. The single place that
|
|
187
|
+
* decides the default and enabled languages - the router and the SEO helpers
|
|
188
|
+
* must agree, so both go through here.
|
|
189
|
+
*/
|
|
190
|
+
declare function localesFromSiteConfig(siteConfig: {
|
|
191
|
+
defaultLanguage?: string | null;
|
|
192
|
+
enabledLanguages?: string[];
|
|
193
|
+
} | null): CmssySiteLocales;
|
|
183
194
|
declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
|
|
184
195
|
declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
|
|
185
196
|
locale: string;
|
|
@@ -378,21 +389,6 @@ declare function toCspOrigin(origin: string): string;
|
|
|
378
389
|
declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
|
|
379
390
|
declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
|
|
380
391
|
|
|
381
|
-
/**
|
|
382
|
-
* Resolve the default locale and the full locale list from the SDK config,
|
|
383
|
-
* falling back to the workspace site config (defaultLanguage / enabledLanguages)
|
|
384
|
-
* then "en". Shared by sitemap + metadata so their hreflang/canonical agree.
|
|
385
|
-
*/
|
|
386
|
-
declare function resolveSeoLocales(config: {
|
|
387
|
-
defaultLocale?: string;
|
|
388
|
-
enabledLocales?: string[];
|
|
389
|
-
}, siteConfig: {
|
|
390
|
-
defaultLanguage?: string | null;
|
|
391
|
-
enabledLanguages?: string[];
|
|
392
|
-
} | null): {
|
|
393
|
-
defaultLocale: string;
|
|
394
|
-
locales: string[];
|
|
395
|
-
};
|
|
396
392
|
/**
|
|
397
393
|
* Maps a page slug to its path for a locale: the default locale gets no
|
|
398
394
|
* prefix, others get `/${locale}`. The homepage ("/") stays "/" (or "/${locale}").
|
|
@@ -506,4 +502,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
506
502
|
*/
|
|
507
503
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
508
504
|
|
|
509
|
-
export { type AppToEditorMessage, type AuthMutationResult, type AuthTokenResult, type BoundsMessage, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CartRequestContext, type CheckoutInput, type ClickMessage, type CmssyClient, type CmssyConfig, type CmssyCspOptions, type CmssyEnvConfig, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, type EditorToAppMessage, FORM_QUERY, type FetchLike, type FetchLikeResponse, type FetchPageOptions, type GraphqlRequestOptions, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, type RetryPolicy, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchLayouts, fetchOrderByToken, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, normalizeSlug, openSession, parseEditorMessage, postToEditor, resolveApiUrl, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolvePublicUrl,
|
|
505
|
+
export { type AppToEditorMessage, type AuthMutationResult, type AuthTokenResult, type BoundsMessage, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CartRequestContext, type CheckoutInput, type ClickMessage, type CmssyClient, type CmssyConfig, type CmssyCspOptions, type CmssyEnvConfig, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, type EditorToAppMessage, FORM_QUERY, type FetchLike, type FetchLikeResponse, type FetchPageOptions, type GraphqlRequestOptions, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, type RetryPolicy, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchLayouts, fetchOrderByToken, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, normalizeSlug, openSession, parseEditorMessage, postToEditor, resolveApiUrl, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolvePublicUrl, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
|
package/dist/index.d.ts
CHANGED
|
@@ -37,9 +37,11 @@ interface CmssyConfig {
|
|
|
37
37
|
*/
|
|
38
38
|
siteUrl?: string;
|
|
39
39
|
auth?: CmssyAuthConfig;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Fallback locale resolver for a site whose URLs carry no language (e.g. a
|
|
42
|
+
* cookie or Accept-Language strategy). The workspace site config remains the
|
|
43
|
+
* source of truth for the default and enabled languages.
|
|
44
|
+
*/
|
|
43
45
|
resolveLocale?: () => string | Promise<string>;
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
@@ -180,6 +182,15 @@ declare function clearWorkspaceIdCache(): void;
|
|
|
180
182
|
declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
|
|
181
183
|
declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
|
|
182
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Maps a workspace site config to its locale set. The single place that
|
|
187
|
+
* decides the default and enabled languages - the router and the SEO helpers
|
|
188
|
+
* must agree, so both go through here.
|
|
189
|
+
*/
|
|
190
|
+
declare function localesFromSiteConfig(siteConfig: {
|
|
191
|
+
defaultLanguage?: string | null;
|
|
192
|
+
enabledLanguages?: string[];
|
|
193
|
+
} | null): CmssySiteLocales;
|
|
183
194
|
declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
|
|
184
195
|
declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
|
|
185
196
|
locale: string;
|
|
@@ -378,21 +389,6 @@ declare function toCspOrigin(origin: string): string;
|
|
|
378
389
|
declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
|
|
379
390
|
declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
|
|
380
391
|
|
|
381
|
-
/**
|
|
382
|
-
* Resolve the default locale and the full locale list from the SDK config,
|
|
383
|
-
* falling back to the workspace site config (defaultLanguage / enabledLanguages)
|
|
384
|
-
* then "en". Shared by sitemap + metadata so their hreflang/canonical agree.
|
|
385
|
-
*/
|
|
386
|
-
declare function resolveSeoLocales(config: {
|
|
387
|
-
defaultLocale?: string;
|
|
388
|
-
enabledLocales?: string[];
|
|
389
|
-
}, siteConfig: {
|
|
390
|
-
defaultLanguage?: string | null;
|
|
391
|
-
enabledLanguages?: string[];
|
|
392
|
-
} | null): {
|
|
393
|
-
defaultLocale: string;
|
|
394
|
-
locales: string[];
|
|
395
|
-
};
|
|
396
392
|
/**
|
|
397
393
|
* Maps a page slug to its path for a locale: the default locale gets no
|
|
398
394
|
* prefix, others get `/${locale}`. The homepage ("/") stays "/" (or "/${locale}").
|
|
@@ -506,4 +502,4 @@ declare class CmssyWebhookError extends Error {
|
|
|
506
502
|
*/
|
|
507
503
|
declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
|
|
508
504
|
|
|
509
|
-
export { type AppToEditorMessage, type AuthMutationResult, type AuthTokenResult, type BoundsMessage, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CartRequestContext, type CheckoutInput, type ClickMessage, type CmssyClient, type CmssyConfig, type CmssyCspOptions, type CmssyEnvConfig, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, type EditorToAppMessage, FORM_QUERY, type FetchLike, type FetchLikeResponse, type FetchPageOptions, type GraphqlRequestOptions, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, type RetryPolicy, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchLayouts, fetchOrderByToken, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, normalizeSlug, openSession, parseEditorMessage, postToEditor, resolveApiUrl, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolvePublicUrl,
|
|
505
|
+
export { type AppToEditorMessage, type AuthMutationResult, type AuthTokenResult, type BoundsMessage, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CartRequestContext, type CheckoutInput, type ClickMessage, type CmssyClient, type CmssyConfig, type CmssyCspOptions, type CmssyEnvConfig, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, type EditorToAppMessage, FORM_QUERY, type FetchLike, type FetchLikeResponse, type FetchPageOptions, type GraphqlRequestOptions, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, type ReadyMessage, type RetryPolicy, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchLayouts, fetchOrderByToken, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, normalizeSlug, openSession, parseEditorMessage, postToEditor, resolveApiUrl, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolvePublicUrl, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -661,6 +661,14 @@ async function resolveForms(config, blocks, locale, defaultLocale, options) {
|
|
|
661
661
|
var TTL_MS = 6e4;
|
|
662
662
|
var MAX_ENTRIES = 64;
|
|
663
663
|
var cache = /* @__PURE__ */ new Map();
|
|
664
|
+
function localesFromSiteConfig(siteConfig) {
|
|
665
|
+
const defaultLocale = siteConfig?.defaultLanguage || "en";
|
|
666
|
+
const enabled = siteConfig?.enabledLanguages ?? [];
|
|
667
|
+
return {
|
|
668
|
+
defaultLocale,
|
|
669
|
+
locales: enabled.length > 0 ? enabled : [defaultLocale]
|
|
670
|
+
};
|
|
671
|
+
}
|
|
664
672
|
async function resolveSiteLocales(config, options) {
|
|
665
673
|
const key = `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
|
|
666
674
|
const cached = cache.get(key);
|
|
@@ -675,13 +683,7 @@ async function resolveSiteLocales(config, options) {
|
|
|
675
683
|
{ ...options, public: true, retry: options?.retry ?? {} },
|
|
676
684
|
"site config"
|
|
677
685
|
);
|
|
678
|
-
|
|
679
|
-
const defaultLocale = siteConfig?.defaultLanguage || "en";
|
|
680
|
-
const enabled = siteConfig?.enabledLanguages ?? [];
|
|
681
|
-
value = {
|
|
682
|
-
defaultLocale,
|
|
683
|
-
locales: enabled.length > 0 ? enabled : [defaultLocale]
|
|
684
|
-
};
|
|
686
|
+
value = localesFromSiteConfig(data.public?.siteConfig ?? null);
|
|
685
687
|
} catch {
|
|
686
688
|
value = { defaultLocale: "en", locales: ["en"] };
|
|
687
689
|
}
|
|
@@ -984,11 +986,6 @@ function applyCmssyCsp(response, options) {
|
|
|
984
986
|
}
|
|
985
987
|
|
|
986
988
|
// src/seo-paths.ts
|
|
987
|
-
function resolveSeoLocales(config, siteConfig) {
|
|
988
|
-
const defaultLocale = config.defaultLocale ?? siteConfig?.defaultLanguage ?? "en";
|
|
989
|
-
const locales = config.enabledLocales && config.enabledLocales.length > 0 ? config.enabledLocales : siteConfig?.enabledLanguages && siteConfig.enabledLanguages.length > 0 ? siteConfig.enabledLanguages : [defaultLocale];
|
|
990
|
-
return { defaultLocale, locales };
|
|
991
|
-
}
|
|
992
989
|
function normalizeSlug2(slug) {
|
|
993
990
|
if (slug === "/" || slug === "") return "/";
|
|
994
991
|
return slug.startsWith("/") ? slug : `/${slug}`;
|
|
@@ -1729,4 +1726,4 @@ async function verifyCmssyWebhook(options) {
|
|
|
1729
1726
|
return parsed;
|
|
1730
1727
|
}
|
|
1731
1728
|
|
|
1732
|
-
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, FORM_QUERY, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchLayouts, fetchOrderByToken, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, normalizeSlug, openSession, parseEditorMessage, postToEditor, resolveApiUrl, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolvePublicUrl,
|
|
1729
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, FORM_QUERY, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchLayouts, fetchOrderByToken, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, normalizeSlug, openSession, parseEditorMessage, postToEditor, resolveApiUrl, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolvePublicUrl, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
|