@cmssy/core 16.1.1 → 16.2.1

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 CHANGED
@@ -465,6 +465,26 @@ async function resolveWorkspaceId(config, options = {}) {
465
465
  }
466
466
  return siteConfig.workspaceId;
467
467
  }
468
+ var MAX_ENTRIES = 64;
469
+ var workspaceIdCache = /* @__PURE__ */ new Map();
470
+ function cacheKey(config) {
471
+ return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
472
+ }
473
+ function cachedWorkspaceId(config, options = {}) {
474
+ const key = cacheKey(config);
475
+ const existing = workspaceIdCache.get(key);
476
+ if (existing) return existing;
477
+ const fresh = resolveWorkspaceId(config, options).catch((err) => {
478
+ workspaceIdCache.delete(key);
479
+ throw err;
480
+ });
481
+ if (workspaceIdCache.size >= MAX_ENTRIES) workspaceIdCache.clear();
482
+ workspaceIdCache.set(key, fresh);
483
+ return fresh;
484
+ }
485
+ function primeWorkspaceId(config, workspaceId) {
486
+ workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
487
+ }
468
488
 
469
489
  // src/data/client.ts
470
490
  function createCmssyClient(input) {
@@ -472,19 +492,8 @@ function createCmssyClient(input) {
472
492
  ...input,
473
493
  apiUrl: resolveApiUrl(input.apiUrl)
474
494
  };
475
- let cachedWorkspaceId;
476
- let inFlight;
477
495
  function resolveWorkspaceId2(options) {
478
- if (cachedWorkspaceId) return Promise.resolve(cachedWorkspaceId);
479
- if (!inFlight) {
480
- inFlight = resolveWorkspaceId(config, options).then((id) => {
481
- cachedWorkspaceId = id;
482
- return id;
483
- }).finally(() => {
484
- inFlight = void 0;
485
- });
486
- }
487
- return inFlight;
496
+ return cachedWorkspaceId(config, options);
488
497
  }
489
498
  function query(document2, variables, options) {
490
499
  return graphqlRequest(
@@ -515,7 +524,11 @@ function createCmssyClient(input) {
515
524
  const client = {
516
525
  config,
517
526
  resolveWorkspaceId: resolveWorkspaceId2,
518
- query: ((document2, variables = {}, options) => query(documentText(document2), variables, options)),
527
+ query: ((document2, variables = {}, options) => query(
528
+ documentText(document2),
529
+ variables,
530
+ options
531
+ )),
519
532
  queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
520
533
  documentText(document2),
521
534
  variables,
@@ -712,7 +725,7 @@ function localizeHref(href, locale) {
712
725
  // src/data/site-locales.ts
713
726
  var TTL_MS = 6e4;
714
727
  var FAILURE_TTL_MS = 5e3;
715
- var MAX_ENTRIES = 64;
728
+ var MAX_ENTRIES2 = 64;
716
729
  var cache = /* @__PURE__ */ new Map();
717
730
  function localesFromSiteConfig(siteConfig) {
718
731
  const defaultLocale = siteConfig?.defaultLanguage || "en";
@@ -736,11 +749,14 @@ async function loadSiteLocales(config, options) {
736
749
  { ...options, public: true, retry: options?.retry ?? "build" },
737
750
  "site config"
738
751
  );
739
- value = localesFromSiteConfig(data.public?.siteConfig ?? null);
752
+ const siteConfig = data.public?.siteConfig ?? null;
753
+ if (siteConfig?.workspaceId)
754
+ primeWorkspaceId(config, siteConfig.workspaceId);
755
+ value = localesFromSiteConfig(siteConfig);
740
756
  } catch {
741
757
  value = null;
742
758
  }
743
- if (cache.size >= MAX_ENTRIES) cache.clear();
759
+ if (cache.size >= MAX_ENTRIES2) cache.clear();
744
760
  cache.set(key, {
745
761
  value,
746
762
  expires: Date.now() + (value ? TTL_MS : FAILURE_TTL_MS)
package/dist/index.js CHANGED
@@ -464,6 +464,26 @@ async function resolveWorkspaceId(config, options = {}) {
464
464
  }
465
465
  return siteConfig.workspaceId;
466
466
  }
467
+ var MAX_ENTRIES = 64;
468
+ var workspaceIdCache = /* @__PURE__ */ new Map();
469
+ function cacheKey(config) {
470
+ return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
471
+ }
472
+ function cachedWorkspaceId(config, options = {}) {
473
+ const key = cacheKey(config);
474
+ const existing = workspaceIdCache.get(key);
475
+ if (existing) return existing;
476
+ const fresh = resolveWorkspaceId(config, options).catch((err) => {
477
+ workspaceIdCache.delete(key);
478
+ throw err;
479
+ });
480
+ if (workspaceIdCache.size >= MAX_ENTRIES) workspaceIdCache.clear();
481
+ workspaceIdCache.set(key, fresh);
482
+ return fresh;
483
+ }
484
+ function primeWorkspaceId(config, workspaceId) {
485
+ workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
486
+ }
467
487
 
468
488
  // src/data/client.ts
469
489
  function createCmssyClient(input) {
@@ -471,19 +491,8 @@ function createCmssyClient(input) {
471
491
  ...input,
472
492
  apiUrl: resolveApiUrl(input.apiUrl)
473
493
  };
474
- let cachedWorkspaceId;
475
- let inFlight;
476
494
  function resolveWorkspaceId2(options) {
477
- if (cachedWorkspaceId) return Promise.resolve(cachedWorkspaceId);
478
- if (!inFlight) {
479
- inFlight = resolveWorkspaceId(config, options).then((id) => {
480
- cachedWorkspaceId = id;
481
- return id;
482
- }).finally(() => {
483
- inFlight = void 0;
484
- });
485
- }
486
- return inFlight;
495
+ return cachedWorkspaceId(config, options);
487
496
  }
488
497
  function query(document2, variables, options) {
489
498
  return graphqlRequest(
@@ -514,7 +523,11 @@ function createCmssyClient(input) {
514
523
  const client = {
515
524
  config,
516
525
  resolveWorkspaceId: resolveWorkspaceId2,
517
- query: ((document2, variables = {}, options) => query(documentText(document2), variables, options)),
526
+ query: ((document2, variables = {}, options) => query(
527
+ documentText(document2),
528
+ variables,
529
+ options
530
+ )),
518
531
  queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
519
532
  documentText(document2),
520
533
  variables,
@@ -711,7 +724,7 @@ function localizeHref(href, locale) {
711
724
  // src/data/site-locales.ts
712
725
  var TTL_MS = 6e4;
713
726
  var FAILURE_TTL_MS = 5e3;
714
- var MAX_ENTRIES = 64;
727
+ var MAX_ENTRIES2 = 64;
715
728
  var cache = /* @__PURE__ */ new Map();
716
729
  function localesFromSiteConfig(siteConfig) {
717
730
  const defaultLocale = siteConfig?.defaultLanguage || "en";
@@ -735,11 +748,14 @@ async function loadSiteLocales(config, options) {
735
748
  { ...options, public: true, retry: options?.retry ?? "build" },
736
749
  "site config"
737
750
  );
738
- value = localesFromSiteConfig(data.public?.siteConfig ?? null);
751
+ const siteConfig = data.public?.siteConfig ?? null;
752
+ if (siteConfig?.workspaceId)
753
+ primeWorkspaceId(config, siteConfig.workspaceId);
754
+ value = localesFromSiteConfig(siteConfig);
739
755
  } catch {
740
756
  value = null;
741
757
  }
742
- if (cache.size >= MAX_ENTRIES) cache.clear();
758
+ if (cache.size >= MAX_ENTRIES2) cache.clear();
743
759
  cache.set(key, {
744
760
  value,
745
761
  expires: Date.now() + (value ? TTL_MS : FAILURE_TTL_MS)
@@ -224,6 +224,15 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
224
224
  }
225
225
  }`;
226
226
 
227
+ // src/data/settings-client.ts
228
+ var workspaceIdCache = /* @__PURE__ */ new Map();
229
+ function cacheKey(config) {
230
+ return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
231
+ }
232
+ function primeWorkspaceId(config, workspaceId) {
233
+ workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
234
+ }
235
+
227
236
  // src/data/site-locales.ts
228
237
  var TTL_MS = 6e4;
229
238
  var FAILURE_TTL_MS = 5e3;
@@ -251,7 +260,10 @@ async function loadSiteLocales(config, options) {
251
260
  { ...options, public: true, retry: options?.retry ?? "build" },
252
261
  "site config"
253
262
  );
254
- value = localesFromSiteConfig(data.public?.siteConfig ?? null);
263
+ const siteConfig = data.public?.siteConfig ?? null;
264
+ if (siteConfig?.workspaceId)
265
+ primeWorkspaceId(config, siteConfig.workspaceId);
266
+ value = localesFromSiteConfig(siteConfig);
255
267
  } catch {
256
268
  value = null;
257
269
  }
@@ -222,6 +222,15 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
222
222
  }
223
223
  }`;
224
224
 
225
+ // src/data/settings-client.ts
226
+ var workspaceIdCache = /* @__PURE__ */ new Map();
227
+ function cacheKey(config) {
228
+ return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
229
+ }
230
+ function primeWorkspaceId(config, workspaceId) {
231
+ workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
232
+ }
233
+
225
234
  // src/data/site-locales.ts
226
235
  var TTL_MS = 6e4;
227
236
  var FAILURE_TTL_MS = 5e3;
@@ -249,7 +258,10 @@ async function loadSiteLocales(config, options) {
249
258
  { ...options, public: true, retry: options?.retry ?? "build" },
250
259
  "site config"
251
260
  );
252
- value = localesFromSiteConfig(data.public?.siteConfig ?? null);
261
+ const siteConfig = data.public?.siteConfig ?? null;
262
+ if (siteConfig?.workspaceId)
263
+ primeWorkspaceId(config, siteConfig.workspaceId);
264
+ value = localesFromSiteConfig(siteConfig);
253
265
  } catch {
254
266
  value = null;
255
267
  }
package/dist/internal.cjs CHANGED
@@ -514,7 +514,26 @@ async function resolveWorkspaceId(config, options = {}) {
514
514
  }
515
515
  return siteConfig.workspaceId;
516
516
  }
517
+ var MAX_ENTRIES = 64;
517
518
  var workspaceIdCache = /* @__PURE__ */ new Map();
519
+ function cacheKey(config) {
520
+ return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
521
+ }
522
+ function cachedWorkspaceId(config, options = {}) {
523
+ const key = cacheKey(config);
524
+ const existing = workspaceIdCache.get(key);
525
+ if (existing) return existing;
526
+ const fresh = resolveWorkspaceId(config, options).catch((err) => {
527
+ workspaceIdCache.delete(key);
528
+ throw err;
529
+ });
530
+ if (workspaceIdCache.size >= MAX_ENTRIES) workspaceIdCache.clear();
531
+ workspaceIdCache.set(key, fresh);
532
+ return fresh;
533
+ }
534
+ function primeWorkspaceId(config, workspaceId) {
535
+ workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
536
+ }
518
537
  function clearWorkspaceIdCache() {
519
538
  workspaceIdCache.clear();
520
539
  }
@@ -673,19 +692,8 @@ function createCmssyClient(input) {
673
692
  ...input,
674
693
  apiUrl: resolveApiUrl(input.apiUrl)
675
694
  };
676
- let cachedWorkspaceId;
677
- let inFlight;
678
695
  function resolveWorkspaceId2(options) {
679
- if (cachedWorkspaceId) return Promise.resolve(cachedWorkspaceId);
680
- if (!inFlight) {
681
- inFlight = resolveWorkspaceId(config, options).then((id) => {
682
- cachedWorkspaceId = id;
683
- return id;
684
- }).finally(() => {
685
- inFlight = void 0;
686
- });
687
- }
688
- return inFlight;
696
+ return cachedWorkspaceId(config, options);
689
697
  }
690
698
  function query(document2, variables, options) {
691
699
  return graphqlRequest(
@@ -716,7 +724,11 @@ function createCmssyClient(input) {
716
724
  const client = {
717
725
  config,
718
726
  resolveWorkspaceId: resolveWorkspaceId2,
719
- query: ((document2, variables = {}, options) => query(documentText(document2), variables, options)),
727
+ query: ((document2, variables = {}, options) => query(
728
+ documentText(document2),
729
+ variables,
730
+ options
731
+ )),
720
732
  queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
721
733
  documentText(document2),
722
734
  variables,
@@ -1017,7 +1029,7 @@ async function resolveForms(config, blocks, schemas, locale, defaultLocale, opti
1017
1029
  // src/data/site-locales.ts
1018
1030
  var TTL_MS = 6e4;
1019
1031
  var FAILURE_TTL_MS = 5e3;
1020
- var MAX_ENTRIES = 64;
1032
+ var MAX_ENTRIES2 = 64;
1021
1033
  var cache = /* @__PURE__ */ new Map();
1022
1034
  function localesFromSiteConfig(siteConfig) {
1023
1035
  const defaultLocale = siteConfig?.defaultLanguage || "en";
@@ -1041,11 +1053,14 @@ async function loadSiteLocales(config, options) {
1041
1053
  { ...options, public: true, retry: options?.retry ?? "build" },
1042
1054
  "site config"
1043
1055
  );
1044
- value = localesFromSiteConfig(data.public?.siteConfig ?? null);
1056
+ const siteConfig = data.public?.siteConfig ?? null;
1057
+ if (siteConfig?.workspaceId)
1058
+ primeWorkspaceId(config, siteConfig.workspaceId);
1059
+ value = localesFromSiteConfig(siteConfig);
1045
1060
  } catch {
1046
1061
  value = null;
1047
1062
  }
1048
- if (cache.size >= MAX_ENTRIES) cache.clear();
1063
+ if (cache.size >= MAX_ENTRIES2) cache.clear();
1049
1064
  cache.set(key, {
1050
1065
  value,
1051
1066
  expires: Date.now() + (value ? TTL_MS : FAILURE_TTL_MS)
package/dist/internal.js CHANGED
@@ -512,7 +512,26 @@ async function resolveWorkspaceId(config, options = {}) {
512
512
  }
513
513
  return siteConfig.workspaceId;
514
514
  }
515
+ var MAX_ENTRIES = 64;
515
516
  var workspaceIdCache = /* @__PURE__ */ new Map();
517
+ function cacheKey(config) {
518
+ return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
519
+ }
520
+ function cachedWorkspaceId(config, options = {}) {
521
+ const key = cacheKey(config);
522
+ const existing = workspaceIdCache.get(key);
523
+ if (existing) return existing;
524
+ const fresh = resolveWorkspaceId(config, options).catch((err) => {
525
+ workspaceIdCache.delete(key);
526
+ throw err;
527
+ });
528
+ if (workspaceIdCache.size >= MAX_ENTRIES) workspaceIdCache.clear();
529
+ workspaceIdCache.set(key, fresh);
530
+ return fresh;
531
+ }
532
+ function primeWorkspaceId(config, workspaceId) {
533
+ workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
534
+ }
516
535
  function clearWorkspaceIdCache() {
517
536
  workspaceIdCache.clear();
518
537
  }
@@ -671,19 +690,8 @@ function createCmssyClient(input) {
671
690
  ...input,
672
691
  apiUrl: resolveApiUrl(input.apiUrl)
673
692
  };
674
- let cachedWorkspaceId;
675
- let inFlight;
676
693
  function resolveWorkspaceId2(options) {
677
- if (cachedWorkspaceId) return Promise.resolve(cachedWorkspaceId);
678
- if (!inFlight) {
679
- inFlight = resolveWorkspaceId(config, options).then((id) => {
680
- cachedWorkspaceId = id;
681
- return id;
682
- }).finally(() => {
683
- inFlight = void 0;
684
- });
685
- }
686
- return inFlight;
694
+ return cachedWorkspaceId(config, options);
687
695
  }
688
696
  function query(document2, variables, options) {
689
697
  return graphqlRequest(
@@ -714,7 +722,11 @@ function createCmssyClient(input) {
714
722
  const client = {
715
723
  config,
716
724
  resolveWorkspaceId: resolveWorkspaceId2,
717
- query: ((document2, variables = {}, options) => query(documentText(document2), variables, options)),
725
+ query: ((document2, variables = {}, options) => query(
726
+ documentText(document2),
727
+ variables,
728
+ options
729
+ )),
718
730
  queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
719
731
  documentText(document2),
720
732
  variables,
@@ -1015,7 +1027,7 @@ async function resolveForms(config, blocks, schemas, locale, defaultLocale, opti
1015
1027
  // src/data/site-locales.ts
1016
1028
  var TTL_MS = 6e4;
1017
1029
  var FAILURE_TTL_MS = 5e3;
1018
- var MAX_ENTRIES = 64;
1030
+ var MAX_ENTRIES2 = 64;
1019
1031
  var cache = /* @__PURE__ */ new Map();
1020
1032
  function localesFromSiteConfig(siteConfig) {
1021
1033
  const defaultLocale = siteConfig?.defaultLanguage || "en";
@@ -1039,11 +1051,14 @@ async function loadSiteLocales(config, options) {
1039
1051
  { ...options, public: true, retry: options?.retry ?? "build" },
1040
1052
  "site config"
1041
1053
  );
1042
- value = localesFromSiteConfig(data.public?.siteConfig ?? null);
1054
+ const siteConfig = data.public?.siteConfig ?? null;
1055
+ if (siteConfig?.workspaceId)
1056
+ primeWorkspaceId(config, siteConfig.workspaceId);
1057
+ value = localesFromSiteConfig(siteConfig);
1043
1058
  } catch {
1044
1059
  value = null;
1045
1060
  }
1046
- if (cache.size >= MAX_ENTRIES) cache.clear();
1061
+ if (cache.size >= MAX_ENTRIES2) cache.clear();
1047
1062
  cache.set(key, {
1048
1063
  value,
1049
1064
  expires: Date.now() + (value ? TTL_MS : FAILURE_TTL_MS)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/core",
3
- "version": "16.1.1",
3
+ "version": "16.2.1",
4
4
  "description": "Framework-agnostic cmssy gateway: GraphQL client, block/field system, editor protocol. No React, no Next.",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -87,7 +87,7 @@
87
87
  "vitest": "^2.1.0"
88
88
  },
89
89
  "dependencies": {
90
- "@cmssy/types": "0.41.0",
90
+ "@cmssy/types": "0.43.0",
91
91
  "jose": "^6.2.3"
92
92
  },
93
93
  "scripts": {