@cmssy/core 11.5.1 → 11.7.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/{content-client-CJQ-nafm.d.cts → content-client-BPpRfq0h.d.cts} +1 -30
- package/dist/{content-client-CJQ-nafm.d.ts → content-client-BPpRfq0h.d.ts} +1 -30
- package/dist/{csp-CpiqfM03.d.ts → csp-DjFT5SmH.d.ts} +1 -65
- package/dist/{csp-0D9pcuDp.d.cts → csp-ZchQ-sC7.d.cts} +1 -65
- package/dist/index.cjs +24 -16
- package/dist/index.d.cts +3 -32
- package/dist/index.d.ts +3 -32
- package/dist/index.js +24 -16
- package/dist/internal/locale.cjs +0 -20
- package/dist/internal/locale.d.cts +2 -6
- package/dist/internal/locale.d.ts +2 -6
- package/dist/internal/locale.js +1 -18
- package/dist/internal.cjs +3 -44
- package/dist/internal.d.cts +6 -53
- package/dist/internal.d.ts +6 -53
- package/dist/internal.js +4 -38
- package/dist/locale-BS61R-fF.d.cts +30 -0
- package/dist/locale-DQZ80cew.d.ts +30 -0
- package/dist/preflight.d.cts +1 -1
- package/dist/preflight.d.ts +1 -1
- package/dist/testing.cjs +25 -173
- package/dist/testing.d.cts +2 -50
- package/dist/testing.d.ts +2 -50
- package/dist/testing.js +25 -173
- package/package.json +42 -17
- package/dist/locale-Clouq4s4.d.ts +0 -68
- package/dist/locale-XMylB_kz.d.cts +0 -68
package/dist/internal/locale.cjs
CHANGED
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
// src/data/http.ts
|
|
4
4
|
var CmssyRequestError = class extends Error {
|
|
5
5
|
status;
|
|
6
|
-
/**
|
|
7
|
-
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
8
|
-
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
9
|
-
* long instead of guessing.
|
|
10
|
-
*/
|
|
11
6
|
retryAfterMs;
|
|
12
7
|
constructor(message, status, retryAfterMs2) {
|
|
13
8
|
super(message);
|
|
@@ -266,18 +261,6 @@ function localizeHref(href, locale) {
|
|
|
266
261
|
const bare = stripLeadingLocale(path, locale);
|
|
267
262
|
return `${addLocalePrefix(bare, locale.current, locale)}${suffix}`;
|
|
268
263
|
}
|
|
269
|
-
function buildLocaleSwitchHref(target, pathname, locale) {
|
|
270
|
-
const path = pathname && pathname.startsWith("/") ? pathname : "/";
|
|
271
|
-
const bare = stripLeadingLocale(path, locale);
|
|
272
|
-
return addLocalePrefix(bare, target, locale);
|
|
273
|
-
}
|
|
274
|
-
var ANCHOR_HREF = /(<a\b(?:"[^"]*"|'[^']*'|[^>])*?\shref=)(["'])(.*?)\2/gi;
|
|
275
|
-
function localizeHtmlLinks(html, locale) {
|
|
276
|
-
return html.replace(
|
|
277
|
-
ANCHOR_HREF,
|
|
278
|
-
(_match, prefix, quote, url) => `${prefix}${quote}${localizeHref(url, locale)}${quote}`
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
264
|
|
|
282
265
|
// src/seo-paths.ts
|
|
283
266
|
function normalizeSlug(slug) {
|
|
@@ -291,12 +274,9 @@ function localizedPath(slug, locale, defaultLocale) {
|
|
|
291
274
|
}
|
|
292
275
|
|
|
293
276
|
exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
|
|
294
|
-
exports.buildLocaleSwitchHref = buildLocaleSwitchHref;
|
|
295
277
|
exports.localeForPath = localeForPath;
|
|
296
278
|
exports.localeForPathname = localeForPathname;
|
|
297
|
-
exports.localesFromSiteConfig = localesFromSiteConfig;
|
|
298
279
|
exports.localizeHref = localizeHref;
|
|
299
|
-
exports.localizeHtmlLinks = localizeHtmlLinks;
|
|
300
280
|
exports.localizedPath = localizedPath;
|
|
301
281
|
exports.resolveSiteLocales = resolveSiteLocales;
|
|
302
282
|
exports.splitCmssyLocale = splitCmssyLocale;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
export { C as CMSSY_LOCALE_HEADER,
|
|
1
|
+
export { C as CMSSY_LOCALE_HEADER, a as localeForPath, b as localeForPathname, l as localizeHref, c as resolveSiteLocales, s as splitCmssyLocale, d as splitLocaleFromPath } from '../locale-BS61R-fF.cjs';
|
|
2
2
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
3
|
-
import '../content-client-
|
|
3
|
+
import '../content-client-BPpRfq0h.cjs';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Maps a page slug to its path for a locale: the default locale gets no
|
|
7
|
-
* prefix, others get `/${locale}`. The homepage ("/") stays "/" (or "/${locale}").
|
|
8
|
-
*/
|
|
9
5
|
declare function localizedPath(slug: string, locale: string, defaultLocale: string): string;
|
|
10
6
|
|
|
11
7
|
export { localizedPath };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
export { C as CMSSY_LOCALE_HEADER,
|
|
1
|
+
export { C as CMSSY_LOCALE_HEADER, a as localeForPath, b as localeForPathname, l as localizeHref, c as resolveSiteLocales, s as splitCmssyLocale, d as splitLocaleFromPath } from '../locale-DQZ80cew.js';
|
|
2
2
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
3
|
-
import '../content-client-
|
|
3
|
+
import '../content-client-BPpRfq0h.js';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Maps a page slug to its path for a locale: the default locale gets no
|
|
7
|
-
* prefix, others get `/${locale}`. The homepage ("/") stays "/" (or "/${locale}").
|
|
8
|
-
*/
|
|
9
5
|
declare function localizedPath(slug: string, locale: string, defaultLocale: string): string;
|
|
10
6
|
|
|
11
7
|
export { localizedPath };
|
package/dist/internal/locale.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
// src/data/http.ts
|
|
2
2
|
var CmssyRequestError = class extends Error {
|
|
3
3
|
status;
|
|
4
|
-
/**
|
|
5
|
-
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
6
|
-
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
7
|
-
* long instead of guessing.
|
|
8
|
-
*/
|
|
9
4
|
retryAfterMs;
|
|
10
5
|
constructor(message, status, retryAfterMs2) {
|
|
11
6
|
super(message);
|
|
@@ -264,18 +259,6 @@ function localizeHref(href, locale) {
|
|
|
264
259
|
const bare = stripLeadingLocale(path, locale);
|
|
265
260
|
return `${addLocalePrefix(bare, locale.current, locale)}${suffix}`;
|
|
266
261
|
}
|
|
267
|
-
function buildLocaleSwitchHref(target, pathname, locale) {
|
|
268
|
-
const path = pathname && pathname.startsWith("/") ? pathname : "/";
|
|
269
|
-
const bare = stripLeadingLocale(path, locale);
|
|
270
|
-
return addLocalePrefix(bare, target, locale);
|
|
271
|
-
}
|
|
272
|
-
var ANCHOR_HREF = /(<a\b(?:"[^"]*"|'[^']*'|[^>])*?\shref=)(["'])(.*?)\2/gi;
|
|
273
|
-
function localizeHtmlLinks(html, locale) {
|
|
274
|
-
return html.replace(
|
|
275
|
-
ANCHOR_HREF,
|
|
276
|
-
(_match, prefix, quote, url) => `${prefix}${quote}${localizeHref(url, locale)}${quote}`
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
262
|
|
|
280
263
|
// src/seo-paths.ts
|
|
281
264
|
function normalizeSlug(slug) {
|
|
@@ -288,4 +271,4 @@ function localizedPath(slug, locale, defaultLocale) {
|
|
|
288
271
|
return locale === defaultLocale ? base || "/" : `/${locale}${base}`;
|
|
289
272
|
}
|
|
290
273
|
|
|
291
|
-
export { CMSSY_LOCALE_HEADER,
|
|
274
|
+
export { CMSSY_LOCALE_HEADER, localeForPath, localeForPathname, localizeHref, localizedPath, resolveSiteLocales, splitCmssyLocale, splitLocaleFromPath };
|
package/dist/internal.cjs
CHANGED
|
@@ -3,11 +3,6 @@
|
|
|
3
3
|
// src/data/http.ts
|
|
4
4
|
var CmssyRequestError = class extends Error {
|
|
5
5
|
status;
|
|
6
|
-
/**
|
|
7
|
-
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
8
|
-
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
9
|
-
* long instead of guessing.
|
|
10
|
-
*/
|
|
11
6
|
retryAfterMs;
|
|
12
7
|
constructor(message, status, retryAfterMs2) {
|
|
13
8
|
super(message);
|
|
@@ -453,17 +448,6 @@ async function resolveWorkspaceId(config, options = {}) {
|
|
|
453
448
|
return siteConfig.workspaceId;
|
|
454
449
|
}
|
|
455
450
|
var workspaceIdCache = /* @__PURE__ */ new Map();
|
|
456
|
-
function cachedWorkspaceId(config) {
|
|
457
|
-
const key = `${resolveApiUrl(config.apiUrl)}::${config.workspaceSlug}`;
|
|
458
|
-
const existing = workspaceIdCache.get(key);
|
|
459
|
-
if (existing) return existing;
|
|
460
|
-
const fresh = resolveWorkspaceId(config).catch((err) => {
|
|
461
|
-
workspaceIdCache.delete(key);
|
|
462
|
-
throw err;
|
|
463
|
-
});
|
|
464
|
-
workspaceIdCache.set(key, fresh);
|
|
465
|
-
return fresh;
|
|
466
|
-
}
|
|
467
451
|
function clearWorkspaceIdCache() {
|
|
468
452
|
workspaceIdCache.clear();
|
|
469
453
|
}
|
|
@@ -622,13 +606,13 @@ function createCmssyClient(input) {
|
|
|
622
606
|
...input,
|
|
623
607
|
apiUrl: resolveApiUrl(input.apiUrl)
|
|
624
608
|
};
|
|
625
|
-
let
|
|
609
|
+
let cachedWorkspaceId;
|
|
626
610
|
let inFlight;
|
|
627
611
|
function resolveWorkspaceId2(options) {
|
|
628
|
-
if (
|
|
612
|
+
if (cachedWorkspaceId) return Promise.resolve(cachedWorkspaceId);
|
|
629
613
|
if (!inFlight) {
|
|
630
614
|
inFlight = resolveWorkspaceId(config, options).then((id) => {
|
|
631
|
-
|
|
615
|
+
cachedWorkspaceId = id;
|
|
632
616
|
return id;
|
|
633
617
|
}).finally(() => {
|
|
634
618
|
inFlight = void 0;
|
|
@@ -661,8 +645,6 @@ function createCmssyClient(input) {
|
|
|
661
645
|
const client = {
|
|
662
646
|
config,
|
|
663
647
|
resolveWorkspaceId: resolveWorkspaceId2,
|
|
664
|
-
// One implementation behind both overloads: a string passes through
|
|
665
|
-
// documentText untouched, a typed document gives up its query text.
|
|
666
648
|
query: ((document2, variables = {}, options) => query(documentText(document2), variables, options)),
|
|
667
649
|
queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
|
|
668
650
|
documentText(document2),
|
|
@@ -796,18 +778,6 @@ function localizeHref(href, locale) {
|
|
|
796
778
|
const bare = stripLeadingLocale(path, locale);
|
|
797
779
|
return `${addLocalePrefix(bare, locale.current, locale)}${suffix}`;
|
|
798
780
|
}
|
|
799
|
-
function buildLocaleSwitchHref(target, pathname, locale) {
|
|
800
|
-
const path = pathname && pathname.startsWith("/") ? pathname : "/";
|
|
801
|
-
const bare = stripLeadingLocale(path, locale);
|
|
802
|
-
return addLocalePrefix(bare, target, locale);
|
|
803
|
-
}
|
|
804
|
-
var ANCHOR_HREF = /(<a\b(?:"[^"]*"|'[^']*'|[^>])*?\shref=)(["'])(.*?)\2/gi;
|
|
805
|
-
function localizeHtmlLinks(html, locale) {
|
|
806
|
-
return html.replace(
|
|
807
|
-
ANCHOR_HREF,
|
|
808
|
-
(_match, prefix, quote, url) => `${prefix}${quote}${localizeHref(url, locale)}${quote}`
|
|
809
|
-
);
|
|
810
|
-
}
|
|
811
781
|
|
|
812
782
|
// src/data/relation-resolver.ts
|
|
813
783
|
var RECORDS_BY_IDS_QUERY = `query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {
|
|
@@ -1011,10 +981,6 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
|
|
|
1011
981
|
forms,
|
|
1012
982
|
...extra?.auth ? { auth: extra.auth } : {},
|
|
1013
983
|
...extra?.workspace ? { workspace: extra.workspace } : {},
|
|
1014
|
-
// Identity only, and only when the page has one. A page fetched by an older
|
|
1015
|
-
// SDK has no slug, and then a block gets no `page` at all rather than one
|
|
1016
|
-
// with a hole in it: "I don't know where I am" has to stay distinguishable
|
|
1017
|
-
// from "I am at /".
|
|
1018
984
|
...extra?.page?.slug ? {
|
|
1019
985
|
page: {
|
|
1020
986
|
id: extra.page.id,
|
|
@@ -1182,13 +1148,10 @@ exports.CMSSY_LOCALE_HEADER = CMSSY_LOCALE_HEADER;
|
|
|
1182
1148
|
exports.FORM_QUERY = FORM_QUERY;
|
|
1183
1149
|
exports.MODEL_DEFINITIONS_QUERY = MODEL_DEFINITIONS_QUERY;
|
|
1184
1150
|
exports.MODEL_RECORDS_QUERY = MODEL_RECORDS_QUERY;
|
|
1185
|
-
exports.RECORDS_BY_IDS_QUERY = RECORDS_BY_IDS_QUERY;
|
|
1186
1151
|
exports.SITE_CONFIG_QUERY = SITE_CONFIG_QUERY;
|
|
1187
1152
|
exports.SUBMIT_FORM_MUTATION = SUBMIT_FORM_MUTATION;
|
|
1188
1153
|
exports.asBucket = asBucket;
|
|
1189
1154
|
exports.buildBlockContext = buildBlockContext;
|
|
1190
|
-
exports.buildLocaleSwitchHref = buildLocaleSwitchHref;
|
|
1191
|
-
exports.cachedWorkspaceId = cachedWorkspaceId;
|
|
1192
1155
|
exports.clearWorkspaceIdCache = clearWorkspaceIdCache;
|
|
1193
1156
|
exports.cmssyCspHeaders = cmssyCspHeaders;
|
|
1194
1157
|
exports.cmssySecretsMatch = cmssySecretsMatch;
|
|
@@ -1203,16 +1166,12 @@ exports.getBlockContentForLanguage = getBlockContentForLanguage;
|
|
|
1203
1166
|
exports.isDevelopment = isDevelopment;
|
|
1204
1167
|
exports.localeForPath = localeForPath;
|
|
1205
1168
|
exports.localeForPathname = localeForPathname;
|
|
1206
|
-
exports.localesFromSiteConfig = localesFromSiteConfig;
|
|
1207
1169
|
exports.localizeHref = localizeHref;
|
|
1208
|
-
exports.localizeHtmlLinks = localizeHtmlLinks;
|
|
1209
1170
|
exports.localizedPath = localizedPath;
|
|
1210
1171
|
exports.normalizeRelationContent = normalizeRelationContent;
|
|
1211
|
-
exports.normalizeSlug = normalizeSlug;
|
|
1212
1172
|
exports.resolveApiUrl = resolveApiUrl;
|
|
1213
1173
|
exports.resolveForms = resolveForms;
|
|
1214
1174
|
exports.resolveInitialTarget = resolveInitialTarget;
|
|
1215
|
-
exports.resolvePublicUrl = resolvePublicUrl;
|
|
1216
1175
|
exports.resolveRelationContent = resolveRelationContent;
|
|
1217
1176
|
exports.resolveSiteLocales = resolveSiteLocales;
|
|
1218
1177
|
exports.resolveWorkspaceId = resolveWorkspaceId;
|
package/dist/internal.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages,
|
|
1
|
+
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, r as resolveApiUrl } from './content-client-BPpRfq0h.cjs';
|
|
2
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 './locale-
|
|
5
|
-
export { C as CMSSY_LOCALE_HEADER,
|
|
6
|
-
import { Q as QueryScopedOptions } from './csp-
|
|
7
|
-
export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-
|
|
4
|
+
import { G as GraphqlRequestOptions } from './locale-BS61R-fF.cjs';
|
|
5
|
+
export { C as CMSSY_LOCALE_HEADER, a as localeForPath, b as localeForPathname, l as localizeHref, c as resolveSiteLocales, s as splitCmssyLocale, d as splitLocaleFromPath } from './locale-BS61R-fF.cjs';
|
|
6
|
+
import { Q as QueryScopedOptions } from './csp-ZchQ-sC7.cjs';
|
|
7
|
+
export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-ZchQ-sC7.cjs';
|
|
8
8
|
export { localizedPath } from './internal/locale.cjs';
|
|
9
9
|
|
|
10
10
|
declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n logoDarkUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
|
|
@@ -16,76 +16,29 @@ declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input:
|
|
|
16
16
|
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
17
17
|
|
|
18
18
|
declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
|
|
19
|
-
/**
|
|
20
|
-
* Coerce a block bucket (`style` / `advanced`) to a plain object. These buckets
|
|
21
|
-
* are flat (not locale-keyed) and free-form; a missing/invalid bucket becomes
|
|
22
|
-
* an empty object so components can destructure it safely.
|
|
23
|
-
*/
|
|
24
19
|
declare function asBucket(value: unknown): Record<string, unknown>;
|
|
25
20
|
|
|
26
21
|
declare function fetchSiteConfig(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteConfig | null>;
|
|
27
22
|
declare function resolveWorkspaceId(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<string>;
|
|
28
|
-
/**
|
|
29
|
-
* Every authenticated operation needs the workspace id, and it never changes for
|
|
30
|
-
* a given (endpoint, workspace) pair - so it is resolved once and shared. A
|
|
31
|
-
* failed lookup is evicted, otherwise one bad request would be cached forever.
|
|
32
|
-
*/
|
|
33
|
-
declare function cachedWorkspaceId(config: CmssyClientConfig): Promise<string>;
|
|
34
23
|
declare function clearWorkspaceIdCache(): void;
|
|
35
24
|
|
|
36
25
|
declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
|
|
37
26
|
declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
|
|
38
27
|
|
|
39
|
-
declare const RECORDS_BY_IDS_QUERY = "query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {\n public {\n model {\n recordsByIds(workspaceId: $workspaceId, ids: $ids, locale: $locale) {\n id modelId data status createdAt updatedAt\n }\n }\n }\n}";
|
|
40
28
|
interface RelationContentEntry {
|
|
41
29
|
type: string;
|
|
42
30
|
content: Record<string, unknown>;
|
|
43
31
|
}
|
|
44
32
|
type BlockSchemaMap = Record<string, Record<string, FieldDefinition>>;
|
|
45
|
-
/**
|
|
46
|
-
* The editor canvas renders stored content without the server-side resolve, so
|
|
47
|
-
* a relation field there holds raw ids - or the "" a freshly inserted block is
|
|
48
|
-
* seeded with. A component is typed against resolved records, so anything that
|
|
49
|
-
* is not one falls back to the server-resolved value for that key (the admin
|
|
50
|
-
* hydrates the canvas with raw stored content, clobbering it), and only then
|
|
51
|
-
* to the safe empty shape.
|
|
52
|
-
*/
|
|
53
33
|
declare function normalizeRelationContent(content: Record<string, unknown>, schema: Record<string, FieldDefinition>, resolved?: Record<string, unknown>): void;
|
|
54
|
-
/**
|
|
55
|
-
* Resolves every `fields.relation` value on the given block contents in place:
|
|
56
|
-
* stored record ids become full records (one batched read for the whole page),
|
|
57
|
-
* and a `mode: "all"` field becomes the model's record list. A dangling id and
|
|
58
|
-
* a failed fetch both degrade to "no value" - a relation must never break a
|
|
59
|
-
* render.
|
|
60
|
-
*/
|
|
61
34
|
declare function resolveRelationContent(config: CmssyClientConfig, entries: RelationContentEntry[], schemas: BlockSchemaMap, locale?: string, requestOptions?: QueryScopedOptions): Promise<void>;
|
|
62
35
|
|
|
63
36
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
64
37
|
|
|
65
38
|
interface CmssyDeliveryOperation {
|
|
66
|
-
/** One line, for the generated file - why an app would want this one. */
|
|
67
39
|
purpose: string;
|
|
68
40
|
document: string;
|
|
69
41
|
}
|
|
70
|
-
/**
|
|
71
|
-
* The delivery operations the SDK itself performs, for `cmssy types` to vendor
|
|
72
|
-
* into an app.
|
|
73
|
-
*
|
|
74
|
-
* These reference the runtime constants rather than restating them: a second
|
|
75
|
-
* copy here would be free to drift from the client that actually sends them,
|
|
76
|
-
* which is the problem this list exists to remove. Keep it that way - a literal
|
|
77
|
-
* moved into this file also drops out of `sdl-operations.test.ts`, which
|
|
78
|
-
* validates exported document *strings* in their home modules.
|
|
79
|
-
*
|
|
80
|
-
* Deliberately absent, and why:
|
|
81
|
-
*
|
|
82
|
-
* - `PUBLIC_PAGE_DEV_QUERY` - a second document named `PublicPage`. Two
|
|
83
|
-
* documents cannot share an operation name in graphql-codegen's client
|
|
84
|
-
* preset, so including it would emit a file every consumer's codegen
|
|
85
|
-
* rejects. It is also a dev-preview path an app never calls itself.
|
|
86
|
-
* - `MODEL_DEFINITIONS_QUERY` - `cmssy types` already turns definitions into
|
|
87
|
-
* TypeScript; fetching them at runtime is not something an app does.
|
|
88
|
-
*/
|
|
89
42
|
declare const CMSSY_DELIVERY_OPERATIONS: readonly CmssyDeliveryOperation[];
|
|
90
43
|
|
|
91
|
-
export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS,
|
|
44
|
+
export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages,
|
|
1
|
+
export { f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, r as resolveApiUrl } from './content-client-BPpRfq0h.js';
|
|
2
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 './locale-
|
|
5
|
-
export { C as CMSSY_LOCALE_HEADER,
|
|
6
|
-
import { Q as QueryScopedOptions } from './csp-
|
|
7
|
-
export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-
|
|
4
|
+
import { G as GraphqlRequestOptions } from './locale-DQZ80cew.js';
|
|
5
|
+
export { C as CMSSY_LOCALE_HEADER, a as localeForPath, b as localeForPathname, l as localizeHref, c as resolveSiteLocales, s as splitCmssyLocale, d as splitLocaleFromPath } from './locale-DQZ80cew.js';
|
|
6
|
+
import { Q as QueryScopedOptions } from './csp-DjFT5SmH.js';
|
|
7
|
+
export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-DjFT5SmH.js';
|
|
8
8
|
export { localizedPath } from './internal/locale.js';
|
|
9
9
|
|
|
10
10
|
declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n logoDarkUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
|
|
@@ -16,76 +16,29 @@ declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input:
|
|
|
16
16
|
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
17
17
|
|
|
18
18
|
declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
|
|
19
|
-
/**
|
|
20
|
-
* Coerce a block bucket (`style` / `advanced`) to a plain object. These buckets
|
|
21
|
-
* are flat (not locale-keyed) and free-form; a missing/invalid bucket becomes
|
|
22
|
-
* an empty object so components can destructure it safely.
|
|
23
|
-
*/
|
|
24
19
|
declare function asBucket(value: unknown): Record<string, unknown>;
|
|
25
20
|
|
|
26
21
|
declare function fetchSiteConfig(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteConfig | null>;
|
|
27
22
|
declare function resolveWorkspaceId(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<string>;
|
|
28
|
-
/**
|
|
29
|
-
* Every authenticated operation needs the workspace id, and it never changes for
|
|
30
|
-
* a given (endpoint, workspace) pair - so it is resolved once and shared. A
|
|
31
|
-
* failed lookup is evicted, otherwise one bad request would be cached forever.
|
|
32
|
-
*/
|
|
33
|
-
declare function cachedWorkspaceId(config: CmssyClientConfig): Promise<string>;
|
|
34
23
|
declare function clearWorkspaceIdCache(): void;
|
|
35
24
|
|
|
36
25
|
declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
|
|
37
26
|
declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
|
|
38
27
|
|
|
39
|
-
declare const RECORDS_BY_IDS_QUERY = "query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {\n public {\n model {\n recordsByIds(workspaceId: $workspaceId, ids: $ids, locale: $locale) {\n id modelId data status createdAt updatedAt\n }\n }\n }\n}";
|
|
40
28
|
interface RelationContentEntry {
|
|
41
29
|
type: string;
|
|
42
30
|
content: Record<string, unknown>;
|
|
43
31
|
}
|
|
44
32
|
type BlockSchemaMap = Record<string, Record<string, FieldDefinition>>;
|
|
45
|
-
/**
|
|
46
|
-
* The editor canvas renders stored content without the server-side resolve, so
|
|
47
|
-
* a relation field there holds raw ids - or the "" a freshly inserted block is
|
|
48
|
-
* seeded with. A component is typed against resolved records, so anything that
|
|
49
|
-
* is not one falls back to the server-resolved value for that key (the admin
|
|
50
|
-
* hydrates the canvas with raw stored content, clobbering it), and only then
|
|
51
|
-
* to the safe empty shape.
|
|
52
|
-
*/
|
|
53
33
|
declare function normalizeRelationContent(content: Record<string, unknown>, schema: Record<string, FieldDefinition>, resolved?: Record<string, unknown>): void;
|
|
54
|
-
/**
|
|
55
|
-
* Resolves every `fields.relation` value on the given block contents in place:
|
|
56
|
-
* stored record ids become full records (one batched read for the whole page),
|
|
57
|
-
* and a `mode: "all"` field becomes the model's record list. A dangling id and
|
|
58
|
-
* a failed fetch both degrade to "no value" - a relation must never break a
|
|
59
|
-
* render.
|
|
60
|
-
*/
|
|
61
34
|
declare function resolveRelationContent(config: CmssyClientConfig, entries: RelationContentEntry[], schemas: BlockSchemaMap, locale?: string, requestOptions?: QueryScopedOptions): Promise<void>;
|
|
62
35
|
|
|
63
36
|
declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
|
|
64
37
|
|
|
65
38
|
interface CmssyDeliveryOperation {
|
|
66
|
-
/** One line, for the generated file - why an app would want this one. */
|
|
67
39
|
purpose: string;
|
|
68
40
|
document: string;
|
|
69
41
|
}
|
|
70
|
-
/**
|
|
71
|
-
* The delivery operations the SDK itself performs, for `cmssy types` to vendor
|
|
72
|
-
* into an app.
|
|
73
|
-
*
|
|
74
|
-
* These reference the runtime constants rather than restating them: a second
|
|
75
|
-
* copy here would be free to drift from the client that actually sends them,
|
|
76
|
-
* which is the problem this list exists to remove. Keep it that way - a literal
|
|
77
|
-
* moved into this file also drops out of `sdl-operations.test.ts`, which
|
|
78
|
-
* validates exported document *strings* in their home modules.
|
|
79
|
-
*
|
|
80
|
-
* Deliberately absent, and why:
|
|
81
|
-
*
|
|
82
|
-
* - `PUBLIC_PAGE_DEV_QUERY` - a second document named `PublicPage`. Two
|
|
83
|
-
* documents cannot share an operation name in graphql-codegen's client
|
|
84
|
-
* preset, so including it would emit a file every consumer's codegen
|
|
85
|
-
* rejects. It is also a dev-preview path an app never calls itself.
|
|
86
|
-
* - `MODEL_DEFINITIONS_QUERY` - `cmssy types` already turns definitions into
|
|
87
|
-
* TypeScript; fetching them at runtime is not something an app does.
|
|
88
|
-
*/
|
|
89
42
|
declare const CMSSY_DELIVERY_OPERATIONS: readonly CmssyDeliveryOperation[];
|
|
90
43
|
|
|
91
|
-
export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS,
|
|
44
|
+
export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
|
package/dist/internal.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
// src/data/http.ts
|
|
2
2
|
var CmssyRequestError = class extends Error {
|
|
3
3
|
status;
|
|
4
|
-
/**
|
|
5
|
-
* How long the server asked us to wait, in ms, when it said so. Present on a
|
|
6
|
-
* 429 that carried `Retry-After`; a caller can serve stale content for that
|
|
7
|
-
* long instead of guessing.
|
|
8
|
-
*/
|
|
9
4
|
retryAfterMs;
|
|
10
5
|
constructor(message, status, retryAfterMs2) {
|
|
11
6
|
super(message);
|
|
@@ -451,17 +446,6 @@ async function resolveWorkspaceId(config, options = {}) {
|
|
|
451
446
|
return siteConfig.workspaceId;
|
|
452
447
|
}
|
|
453
448
|
var workspaceIdCache = /* @__PURE__ */ new Map();
|
|
454
|
-
function cachedWorkspaceId(config) {
|
|
455
|
-
const key = `${resolveApiUrl(config.apiUrl)}::${config.workspaceSlug}`;
|
|
456
|
-
const existing = workspaceIdCache.get(key);
|
|
457
|
-
if (existing) return existing;
|
|
458
|
-
const fresh = resolveWorkspaceId(config).catch((err) => {
|
|
459
|
-
workspaceIdCache.delete(key);
|
|
460
|
-
throw err;
|
|
461
|
-
});
|
|
462
|
-
workspaceIdCache.set(key, fresh);
|
|
463
|
-
return fresh;
|
|
464
|
-
}
|
|
465
449
|
function clearWorkspaceIdCache() {
|
|
466
450
|
workspaceIdCache.clear();
|
|
467
451
|
}
|
|
@@ -620,13 +604,13 @@ function createCmssyClient(input) {
|
|
|
620
604
|
...input,
|
|
621
605
|
apiUrl: resolveApiUrl(input.apiUrl)
|
|
622
606
|
};
|
|
623
|
-
let
|
|
607
|
+
let cachedWorkspaceId;
|
|
624
608
|
let inFlight;
|
|
625
609
|
function resolveWorkspaceId2(options) {
|
|
626
|
-
if (
|
|
610
|
+
if (cachedWorkspaceId) return Promise.resolve(cachedWorkspaceId);
|
|
627
611
|
if (!inFlight) {
|
|
628
612
|
inFlight = resolveWorkspaceId(config, options).then((id) => {
|
|
629
|
-
|
|
613
|
+
cachedWorkspaceId = id;
|
|
630
614
|
return id;
|
|
631
615
|
}).finally(() => {
|
|
632
616
|
inFlight = void 0;
|
|
@@ -659,8 +643,6 @@ function createCmssyClient(input) {
|
|
|
659
643
|
const client = {
|
|
660
644
|
config,
|
|
661
645
|
resolveWorkspaceId: resolveWorkspaceId2,
|
|
662
|
-
// One implementation behind both overloads: a string passes through
|
|
663
|
-
// documentText untouched, a typed document gives up its query text.
|
|
664
646
|
query: ((document2, variables = {}, options) => query(documentText(document2), variables, options)),
|
|
665
647
|
queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
|
|
666
648
|
documentText(document2),
|
|
@@ -794,18 +776,6 @@ function localizeHref(href, locale) {
|
|
|
794
776
|
const bare = stripLeadingLocale(path, locale);
|
|
795
777
|
return `${addLocalePrefix(bare, locale.current, locale)}${suffix}`;
|
|
796
778
|
}
|
|
797
|
-
function buildLocaleSwitchHref(target, pathname, locale) {
|
|
798
|
-
const path = pathname && pathname.startsWith("/") ? pathname : "/";
|
|
799
|
-
const bare = stripLeadingLocale(path, locale);
|
|
800
|
-
return addLocalePrefix(bare, target, locale);
|
|
801
|
-
}
|
|
802
|
-
var ANCHOR_HREF = /(<a\b(?:"[^"]*"|'[^']*'|[^>])*?\shref=)(["'])(.*?)\2/gi;
|
|
803
|
-
function localizeHtmlLinks(html, locale) {
|
|
804
|
-
return html.replace(
|
|
805
|
-
ANCHOR_HREF,
|
|
806
|
-
(_match, prefix, quote, url) => `${prefix}${quote}${localizeHref(url, locale)}${quote}`
|
|
807
|
-
);
|
|
808
|
-
}
|
|
809
779
|
|
|
810
780
|
// src/data/relation-resolver.ts
|
|
811
781
|
var RECORDS_BY_IDS_QUERY = `query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {
|
|
@@ -1009,10 +979,6 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
|
|
|
1009
979
|
forms,
|
|
1010
980
|
...extra?.auth ? { auth: extra.auth } : {},
|
|
1011
981
|
...extra?.workspace ? { workspace: extra.workspace } : {},
|
|
1012
|
-
// Identity only, and only when the page has one. A page fetched by an older
|
|
1013
|
-
// SDK has no slug, and then a block gets no `page` at all rather than one
|
|
1014
|
-
// with a hole in it: "I don't know where I am" has to stay distinguishable
|
|
1015
|
-
// from "I am at /".
|
|
1016
982
|
...extra?.page?.slug ? {
|
|
1017
983
|
page: {
|
|
1018
984
|
id: extra.page.id,
|
|
@@ -1175,4 +1141,4 @@ var CMSSY_DELIVERY_OPERATIONS = [
|
|
|
1175
1141
|
}
|
|
1176
1142
|
];
|
|
1177
1143
|
|
|
1178
|
-
export { CMSSY_DELIVERY_OPERATIONS, CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY,
|
|
1144
|
+
export { CMSSY_DELIVERY_OPERATIONS, CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, getBlockContentForLanguage, isDevelopment, localeForPath, localeForPathname, localizeHref, localizedPath, normalizeRelationContent, resolveApiUrl, resolveForms, resolveInitialTarget, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, splitCmssyLocale, splitLocaleFromPath, toCspOrigin };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CmssyClientConfig, CmssyLocaleContext, CmssySiteLocales } from '@cmssy/types';
|
|
2
|
+
import { F as FetchLike, R as RetryPolicy } from './content-client-BPpRfq0h.cjs';
|
|
3
|
+
|
|
4
|
+
interface GraphqlRequestOptions {
|
|
5
|
+
fetch?: FetchLike;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
public?: boolean;
|
|
9
|
+
retry?: RetryPolicy | false;
|
|
10
|
+
}
|
|
11
|
+
declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
|
|
12
|
+
|
|
13
|
+
declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
|
|
14
|
+
|
|
15
|
+
declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
|
|
16
|
+
declare function resolveCmssyLocale(config: CmssyClientConfig, path: string[] | undefined, options?: GraphqlRequestOptions): Promise<string | undefined>;
|
|
17
|
+
declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
|
|
18
|
+
locale: string;
|
|
19
|
+
path: string[] | undefined;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
23
|
+
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
24
|
+
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
25
|
+
locale: string;
|
|
26
|
+
path: string[] | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
29
|
+
|
|
30
|
+
export { CMSSY_LOCALE_HEADER as C, type GraphqlRequestOptions as G, localeForPath as a, localeForPathname as b, resolveSiteLocales as c, splitLocaleFromPath as d, graphqlRequest as g, localizeHref as l, resolveCmssyLocale as r, splitCmssyLocale as s };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CmssyClientConfig, CmssyLocaleContext, CmssySiteLocales } from '@cmssy/types';
|
|
2
|
+
import { F as FetchLike, R as RetryPolicy } from './content-client-BPpRfq0h.js';
|
|
3
|
+
|
|
4
|
+
interface GraphqlRequestOptions {
|
|
5
|
+
fetch?: FetchLike;
|
|
6
|
+
signal?: AbortSignal;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
public?: boolean;
|
|
9
|
+
retry?: RetryPolicy | false;
|
|
10
|
+
}
|
|
11
|
+
declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
|
|
12
|
+
|
|
13
|
+
declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
|
|
14
|
+
|
|
15
|
+
declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
|
|
16
|
+
declare function resolveCmssyLocale(config: CmssyClientConfig, path: string[] | undefined, options?: GraphqlRequestOptions): Promise<string | undefined>;
|
|
17
|
+
declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
|
|
18
|
+
locale: string;
|
|
19
|
+
path: string[] | undefined;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
|
|
23
|
+
declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
|
|
24
|
+
declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
|
|
25
|
+
locale: string;
|
|
26
|
+
path: string[] | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
|
|
29
|
+
|
|
30
|
+
export { CMSSY_LOCALE_HEADER as C, type GraphqlRequestOptions as G, localeForPath as a, localeForPathname as b, resolveSiteLocales as c, splitLocaleFromPath as d, graphqlRequest as g, localizeHref as l, resolveCmssyLocale as r, splitCmssyLocale as s };
|
package/dist/preflight.d.cts
CHANGED
package/dist/preflight.d.ts
CHANGED