@cmssy/core 11.6.0 → 11.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/internal.cjs 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 cachedWorkspaceId2;
609
+ let cachedWorkspaceId;
626
610
  let inFlight;
627
611
  function resolveWorkspaceId2(options) {
628
- if (cachedWorkspaceId2) return Promise.resolve(cachedWorkspaceId2);
612
+ if (cachedWorkspaceId) return Promise.resolve(cachedWorkspaceId);
629
613
  if (!inFlight) {
630
614
  inFlight = resolveWorkspaceId(config, options).then((id) => {
631
- cachedWorkspaceId2 = id;
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;
@@ -1,10 +1,10 @@
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-CJQ-nafm.cjs';
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-XMylB_kz.cjs';
5
- export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, d as localesFromSiteConfig, l as localizeHref, e as localizeHtmlLinks, f as resolveSiteLocales, s as splitCmssyLocale, h as splitLocaleFromPath } from './locale-XMylB_kz.cjs';
6
- import { Q as QueryScopedOptions } from './csp-0D9pcuDp.cjs';
7
- export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-0D9pcuDp.cjs';
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, type CmssyDeliveryOperation, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
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 };
@@ -1,10 +1,10 @@
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-CJQ-nafm.js';
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-Clouq4s4.js';
5
- export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, d as localesFromSiteConfig, l as localizeHref, e as localizeHtmlLinks, f as resolveSiteLocales, s as splitCmssyLocale, h as splitLocaleFromPath } from './locale-Clouq4s4.js';
6
- import { Q as QueryScopedOptions } from './csp-CpiqfM03.js';
7
- export { o as cmssyCspHeaders, q as isDevelopment, s as resolveInitialTarget, t as toCspOrigin } from './csp-CpiqfM03.js';
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, type CmssyDeliveryOperation, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
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 cachedWorkspaceId2;
607
+ let cachedWorkspaceId;
624
608
  let inFlight;
625
609
  function resolveWorkspaceId2(options) {
626
- if (cachedWorkspaceId2) return Promise.resolve(cachedWorkspaceId2);
610
+ if (cachedWorkspaceId) return Promise.resolve(cachedWorkspaceId);
627
611
  if (!inFlight) {
628
612
  inFlight = resolveWorkspaceId(config, options).then((id) => {
629
- cachedWorkspaceId2 = id;
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, 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 };
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 };
@@ -1,4 +1,4 @@
1
- import { F as FetchLike } from './content-client-CJQ-nafm.cjs';
1
+ import { F as FetchLike } from './content-client-BPpRfq0h.cjs';
2
2
  import { CmssyClientConfig } from '@cmssy/types';
3
3
 
4
4
  interface EditDiagnosticsConfig {
@@ -1,4 +1,4 @@
1
- import { F as FetchLike } from './content-client-CJQ-nafm.js';
1
+ import { F as FetchLike } from './content-client-BPpRfq0h.js';
2
2
  import { CmssyClientConfig } from '@cmssy/types';
3
3
 
4
4
  interface EditDiagnosticsConfig {