@cmssy/core 16.2.0 → 16.3.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 +41 -17
- package/dist/index.js +41 -17
- package/dist/internal/locale.cjs +22 -2
- package/dist/internal/locale.js +22 -2
- package/dist/internal.cjs +40 -17
- package/dist/internal.js +40 -17
- package/dist/preflight.cjs +16 -3
- package/dist/preflight.js +16 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -73,6 +73,10 @@ Set the listed environment variables (e.g. in .env.local) and restart the dev se
|
|
|
73
73
|
return resolved;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// src/version.ts
|
|
77
|
+
var CMSSY_CORE_VERSION = "16.3.0" ;
|
|
78
|
+
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
79
|
+
|
|
76
80
|
// src/data/http.ts
|
|
77
81
|
var CmssyRequestError = class extends Error {
|
|
78
82
|
status;
|
|
@@ -208,7 +212,11 @@ async function postGraphql(url, query, variables, options) {
|
|
|
208
212
|
url,
|
|
209
213
|
{
|
|
210
214
|
method: "POST",
|
|
211
|
-
headers: {
|
|
215
|
+
headers: {
|
|
216
|
+
"content-type": "application/json",
|
|
217
|
+
"user-agent": CMSSY_USER_AGENT,
|
|
218
|
+
...options.headers
|
|
219
|
+
},
|
|
212
220
|
body: JSON.stringify({ query, variables }),
|
|
213
221
|
signal: options.signal
|
|
214
222
|
},
|
|
@@ -465,6 +473,26 @@ async function resolveWorkspaceId(config, options = {}) {
|
|
|
465
473
|
}
|
|
466
474
|
return siteConfig.workspaceId;
|
|
467
475
|
}
|
|
476
|
+
var MAX_ENTRIES = 64;
|
|
477
|
+
var workspaceIdCache = /* @__PURE__ */ new Map();
|
|
478
|
+
function cacheKey(config) {
|
|
479
|
+
return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
|
|
480
|
+
}
|
|
481
|
+
function cachedWorkspaceId(config, options = {}) {
|
|
482
|
+
const key = cacheKey(config);
|
|
483
|
+
const existing = workspaceIdCache.get(key);
|
|
484
|
+
if (existing) return existing;
|
|
485
|
+
const fresh = resolveWorkspaceId(config, options).catch((err) => {
|
|
486
|
+
workspaceIdCache.delete(key);
|
|
487
|
+
throw err;
|
|
488
|
+
});
|
|
489
|
+
if (workspaceIdCache.size >= MAX_ENTRIES) workspaceIdCache.clear();
|
|
490
|
+
workspaceIdCache.set(key, fresh);
|
|
491
|
+
return fresh;
|
|
492
|
+
}
|
|
493
|
+
function primeWorkspaceId(config, workspaceId) {
|
|
494
|
+
workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
|
|
495
|
+
}
|
|
468
496
|
|
|
469
497
|
// src/data/client.ts
|
|
470
498
|
function createCmssyClient(input) {
|
|
@@ -472,19 +500,8 @@ function createCmssyClient(input) {
|
|
|
472
500
|
...input,
|
|
473
501
|
apiUrl: resolveApiUrl(input.apiUrl)
|
|
474
502
|
};
|
|
475
|
-
let cachedWorkspaceId;
|
|
476
|
-
let inFlight;
|
|
477
503
|
function resolveWorkspaceId2(options) {
|
|
478
|
-
|
|
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;
|
|
504
|
+
return cachedWorkspaceId(config, options);
|
|
488
505
|
}
|
|
489
506
|
function query(document2, variables, options) {
|
|
490
507
|
return graphqlRequest(
|
|
@@ -515,7 +532,11 @@ function createCmssyClient(input) {
|
|
|
515
532
|
const client = {
|
|
516
533
|
config,
|
|
517
534
|
resolveWorkspaceId: resolveWorkspaceId2,
|
|
518
|
-
query: ((document2, variables = {}, options) => query(
|
|
535
|
+
query: ((document2, variables = {}, options) => query(
|
|
536
|
+
documentText(document2),
|
|
537
|
+
variables,
|
|
538
|
+
options
|
|
539
|
+
)),
|
|
519
540
|
queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
|
|
520
541
|
documentText(document2),
|
|
521
542
|
variables,
|
|
@@ -712,7 +733,7 @@ function localizeHref(href, locale) {
|
|
|
712
733
|
// src/data/site-locales.ts
|
|
713
734
|
var TTL_MS = 6e4;
|
|
714
735
|
var FAILURE_TTL_MS = 5e3;
|
|
715
|
-
var
|
|
736
|
+
var MAX_ENTRIES2 = 64;
|
|
716
737
|
var cache = /* @__PURE__ */ new Map();
|
|
717
738
|
function localesFromSiteConfig(siteConfig) {
|
|
718
739
|
const defaultLocale = siteConfig?.defaultLanguage || "en";
|
|
@@ -736,11 +757,14 @@ async function loadSiteLocales(config, options) {
|
|
|
736
757
|
{ ...options, public: true, retry: options?.retry ?? "build" },
|
|
737
758
|
"site config"
|
|
738
759
|
);
|
|
739
|
-
|
|
760
|
+
const siteConfig = data.public?.siteConfig ?? null;
|
|
761
|
+
if (siteConfig?.workspaceId)
|
|
762
|
+
primeWorkspaceId(config, siteConfig.workspaceId);
|
|
763
|
+
value = localesFromSiteConfig(siteConfig);
|
|
740
764
|
} catch {
|
|
741
765
|
value = null;
|
|
742
766
|
}
|
|
743
|
-
if (cache.size >=
|
|
767
|
+
if (cache.size >= MAX_ENTRIES2) cache.clear();
|
|
744
768
|
cache.set(key, {
|
|
745
769
|
value,
|
|
746
770
|
expires: Date.now() + (value ? TTL_MS : FAILURE_TTL_MS)
|
package/dist/index.js
CHANGED
|
@@ -72,6 +72,10 @@ Set the listed environment variables (e.g. in .env.local) and restart the dev se
|
|
|
72
72
|
return resolved;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// src/version.ts
|
|
76
|
+
var CMSSY_CORE_VERSION = "16.3.0" ;
|
|
77
|
+
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
78
|
+
|
|
75
79
|
// src/data/http.ts
|
|
76
80
|
var CmssyRequestError = class extends Error {
|
|
77
81
|
status;
|
|
@@ -207,7 +211,11 @@ async function postGraphql(url, query, variables, options) {
|
|
|
207
211
|
url,
|
|
208
212
|
{
|
|
209
213
|
method: "POST",
|
|
210
|
-
headers: {
|
|
214
|
+
headers: {
|
|
215
|
+
"content-type": "application/json",
|
|
216
|
+
"user-agent": CMSSY_USER_AGENT,
|
|
217
|
+
...options.headers
|
|
218
|
+
},
|
|
211
219
|
body: JSON.stringify({ query, variables }),
|
|
212
220
|
signal: options.signal
|
|
213
221
|
},
|
|
@@ -464,6 +472,26 @@ async function resolveWorkspaceId(config, options = {}) {
|
|
|
464
472
|
}
|
|
465
473
|
return siteConfig.workspaceId;
|
|
466
474
|
}
|
|
475
|
+
var MAX_ENTRIES = 64;
|
|
476
|
+
var workspaceIdCache = /* @__PURE__ */ new Map();
|
|
477
|
+
function cacheKey(config) {
|
|
478
|
+
return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
|
|
479
|
+
}
|
|
480
|
+
function cachedWorkspaceId(config, options = {}) {
|
|
481
|
+
const key = cacheKey(config);
|
|
482
|
+
const existing = workspaceIdCache.get(key);
|
|
483
|
+
if (existing) return existing;
|
|
484
|
+
const fresh = resolveWorkspaceId(config, options).catch((err) => {
|
|
485
|
+
workspaceIdCache.delete(key);
|
|
486
|
+
throw err;
|
|
487
|
+
});
|
|
488
|
+
if (workspaceIdCache.size >= MAX_ENTRIES) workspaceIdCache.clear();
|
|
489
|
+
workspaceIdCache.set(key, fresh);
|
|
490
|
+
return fresh;
|
|
491
|
+
}
|
|
492
|
+
function primeWorkspaceId(config, workspaceId) {
|
|
493
|
+
workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
|
|
494
|
+
}
|
|
467
495
|
|
|
468
496
|
// src/data/client.ts
|
|
469
497
|
function createCmssyClient(input) {
|
|
@@ -471,19 +499,8 @@ function createCmssyClient(input) {
|
|
|
471
499
|
...input,
|
|
472
500
|
apiUrl: resolveApiUrl(input.apiUrl)
|
|
473
501
|
};
|
|
474
|
-
let cachedWorkspaceId;
|
|
475
|
-
let inFlight;
|
|
476
502
|
function resolveWorkspaceId2(options) {
|
|
477
|
-
|
|
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;
|
|
503
|
+
return cachedWorkspaceId(config, options);
|
|
487
504
|
}
|
|
488
505
|
function query(document2, variables, options) {
|
|
489
506
|
return graphqlRequest(
|
|
@@ -514,7 +531,11 @@ function createCmssyClient(input) {
|
|
|
514
531
|
const client = {
|
|
515
532
|
config,
|
|
516
533
|
resolveWorkspaceId: resolveWorkspaceId2,
|
|
517
|
-
query: ((document2, variables = {}, options) => query(
|
|
534
|
+
query: ((document2, variables = {}, options) => query(
|
|
535
|
+
documentText(document2),
|
|
536
|
+
variables,
|
|
537
|
+
options
|
|
538
|
+
)),
|
|
518
539
|
queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
|
|
519
540
|
documentText(document2),
|
|
520
541
|
variables,
|
|
@@ -711,7 +732,7 @@ function localizeHref(href, locale) {
|
|
|
711
732
|
// src/data/site-locales.ts
|
|
712
733
|
var TTL_MS = 6e4;
|
|
713
734
|
var FAILURE_TTL_MS = 5e3;
|
|
714
|
-
var
|
|
735
|
+
var MAX_ENTRIES2 = 64;
|
|
715
736
|
var cache = /* @__PURE__ */ new Map();
|
|
716
737
|
function localesFromSiteConfig(siteConfig) {
|
|
717
738
|
const defaultLocale = siteConfig?.defaultLanguage || "en";
|
|
@@ -735,11 +756,14 @@ async function loadSiteLocales(config, options) {
|
|
|
735
756
|
{ ...options, public: true, retry: options?.retry ?? "build" },
|
|
736
757
|
"site config"
|
|
737
758
|
);
|
|
738
|
-
|
|
759
|
+
const siteConfig = data.public?.siteConfig ?? null;
|
|
760
|
+
if (siteConfig?.workspaceId)
|
|
761
|
+
primeWorkspaceId(config, siteConfig.workspaceId);
|
|
762
|
+
value = localesFromSiteConfig(siteConfig);
|
|
739
763
|
} catch {
|
|
740
764
|
value = null;
|
|
741
765
|
}
|
|
742
|
-
if (cache.size >=
|
|
766
|
+
if (cache.size >= MAX_ENTRIES2) cache.clear();
|
|
743
767
|
cache.set(key, {
|
|
744
768
|
value,
|
|
745
769
|
expires: Date.now() + (value ? TTL_MS : FAILURE_TTL_MS)
|
package/dist/internal/locale.cjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/version.ts
|
|
4
|
+
var CMSSY_CORE_VERSION = "16.3.0" ;
|
|
5
|
+
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
6
|
+
|
|
3
7
|
// src/data/http.ts
|
|
4
8
|
var CmssyRequestError = class extends Error {
|
|
5
9
|
status;
|
|
@@ -135,7 +139,11 @@ async function postGraphql(url, query, variables, options) {
|
|
|
135
139
|
url,
|
|
136
140
|
{
|
|
137
141
|
method: "POST",
|
|
138
|
-
headers: {
|
|
142
|
+
headers: {
|
|
143
|
+
"content-type": "application/json",
|
|
144
|
+
"user-agent": CMSSY_USER_AGENT,
|
|
145
|
+
...options.headers
|
|
146
|
+
},
|
|
139
147
|
body: JSON.stringify({ query, variables }),
|
|
140
148
|
signal: options.signal
|
|
141
149
|
},
|
|
@@ -224,6 +232,15 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
|
224
232
|
}
|
|
225
233
|
}`;
|
|
226
234
|
|
|
235
|
+
// src/data/settings-client.ts
|
|
236
|
+
var workspaceIdCache = /* @__PURE__ */ new Map();
|
|
237
|
+
function cacheKey(config) {
|
|
238
|
+
return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
|
|
239
|
+
}
|
|
240
|
+
function primeWorkspaceId(config, workspaceId) {
|
|
241
|
+
workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
|
|
242
|
+
}
|
|
243
|
+
|
|
227
244
|
// src/data/site-locales.ts
|
|
228
245
|
var TTL_MS = 6e4;
|
|
229
246
|
var FAILURE_TTL_MS = 5e3;
|
|
@@ -251,7 +268,10 @@ async function loadSiteLocales(config, options) {
|
|
|
251
268
|
{ ...options, public: true, retry: options?.retry ?? "build" },
|
|
252
269
|
"site config"
|
|
253
270
|
);
|
|
254
|
-
|
|
271
|
+
const siteConfig = data.public?.siteConfig ?? null;
|
|
272
|
+
if (siteConfig?.workspaceId)
|
|
273
|
+
primeWorkspaceId(config, siteConfig.workspaceId);
|
|
274
|
+
value = localesFromSiteConfig(siteConfig);
|
|
255
275
|
} catch {
|
|
256
276
|
value = null;
|
|
257
277
|
}
|
package/dist/internal/locale.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// src/version.ts
|
|
2
|
+
var CMSSY_CORE_VERSION = "16.3.0" ;
|
|
3
|
+
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
4
|
+
|
|
1
5
|
// src/data/http.ts
|
|
2
6
|
var CmssyRequestError = class extends Error {
|
|
3
7
|
status;
|
|
@@ -133,7 +137,11 @@ async function postGraphql(url, query, variables, options) {
|
|
|
133
137
|
url,
|
|
134
138
|
{
|
|
135
139
|
method: "POST",
|
|
136
|
-
headers: {
|
|
140
|
+
headers: {
|
|
141
|
+
"content-type": "application/json",
|
|
142
|
+
"user-agent": CMSSY_USER_AGENT,
|
|
143
|
+
...options.headers
|
|
144
|
+
},
|
|
137
145
|
body: JSON.stringify({ query, variables }),
|
|
138
146
|
signal: options.signal
|
|
139
147
|
},
|
|
@@ -222,6 +230,15 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
|
222
230
|
}
|
|
223
231
|
}`;
|
|
224
232
|
|
|
233
|
+
// src/data/settings-client.ts
|
|
234
|
+
var workspaceIdCache = /* @__PURE__ */ new Map();
|
|
235
|
+
function cacheKey(config) {
|
|
236
|
+
return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
|
|
237
|
+
}
|
|
238
|
+
function primeWorkspaceId(config, workspaceId) {
|
|
239
|
+
workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
|
|
240
|
+
}
|
|
241
|
+
|
|
225
242
|
// src/data/site-locales.ts
|
|
226
243
|
var TTL_MS = 6e4;
|
|
227
244
|
var FAILURE_TTL_MS = 5e3;
|
|
@@ -249,7 +266,10 @@ async function loadSiteLocales(config, options) {
|
|
|
249
266
|
{ ...options, public: true, retry: options?.retry ?? "build" },
|
|
250
267
|
"site config"
|
|
251
268
|
);
|
|
252
|
-
|
|
269
|
+
const siteConfig = data.public?.siteConfig ?? null;
|
|
270
|
+
if (siteConfig?.workspaceId)
|
|
271
|
+
primeWorkspaceId(config, siteConfig.workspaceId);
|
|
272
|
+
value = localesFromSiteConfig(siteConfig);
|
|
253
273
|
} catch {
|
|
254
274
|
value = null;
|
|
255
275
|
}
|
package/dist/internal.cjs
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var types = require('@cmssy/types');
|
|
4
4
|
|
|
5
|
+
// src/version.ts
|
|
6
|
+
var CMSSY_CORE_VERSION = "16.3.0" ;
|
|
7
|
+
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
8
|
+
|
|
5
9
|
// src/data/http.ts
|
|
6
10
|
var CmssyRequestError = class extends Error {
|
|
7
11
|
status;
|
|
@@ -137,7 +141,11 @@ async function postGraphql(url, query, variables, options) {
|
|
|
137
141
|
url,
|
|
138
142
|
{
|
|
139
143
|
method: "POST",
|
|
140
|
-
headers: {
|
|
144
|
+
headers: {
|
|
145
|
+
"content-type": "application/json",
|
|
146
|
+
"user-agent": CMSSY_USER_AGENT,
|
|
147
|
+
...options.headers
|
|
148
|
+
},
|
|
141
149
|
body: JSON.stringify({ query, variables }),
|
|
142
150
|
signal: options.signal
|
|
143
151
|
},
|
|
@@ -514,7 +522,26 @@ async function resolveWorkspaceId(config, options = {}) {
|
|
|
514
522
|
}
|
|
515
523
|
return siteConfig.workspaceId;
|
|
516
524
|
}
|
|
525
|
+
var MAX_ENTRIES = 64;
|
|
517
526
|
var workspaceIdCache = /* @__PURE__ */ new Map();
|
|
527
|
+
function cacheKey(config) {
|
|
528
|
+
return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
|
|
529
|
+
}
|
|
530
|
+
function cachedWorkspaceId(config, options = {}) {
|
|
531
|
+
const key = cacheKey(config);
|
|
532
|
+
const existing = workspaceIdCache.get(key);
|
|
533
|
+
if (existing) return existing;
|
|
534
|
+
const fresh = resolveWorkspaceId(config, options).catch((err) => {
|
|
535
|
+
workspaceIdCache.delete(key);
|
|
536
|
+
throw err;
|
|
537
|
+
});
|
|
538
|
+
if (workspaceIdCache.size >= MAX_ENTRIES) workspaceIdCache.clear();
|
|
539
|
+
workspaceIdCache.set(key, fresh);
|
|
540
|
+
return fresh;
|
|
541
|
+
}
|
|
542
|
+
function primeWorkspaceId(config, workspaceId) {
|
|
543
|
+
workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
|
|
544
|
+
}
|
|
518
545
|
function clearWorkspaceIdCache() {
|
|
519
546
|
workspaceIdCache.clear();
|
|
520
547
|
}
|
|
@@ -673,19 +700,8 @@ function createCmssyClient(input) {
|
|
|
673
700
|
...input,
|
|
674
701
|
apiUrl: resolveApiUrl(input.apiUrl)
|
|
675
702
|
};
|
|
676
|
-
let cachedWorkspaceId;
|
|
677
|
-
let inFlight;
|
|
678
703
|
function resolveWorkspaceId2(options) {
|
|
679
|
-
|
|
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;
|
|
704
|
+
return cachedWorkspaceId(config, options);
|
|
689
705
|
}
|
|
690
706
|
function query(document2, variables, options) {
|
|
691
707
|
return graphqlRequest(
|
|
@@ -716,7 +732,11 @@ function createCmssyClient(input) {
|
|
|
716
732
|
const client = {
|
|
717
733
|
config,
|
|
718
734
|
resolveWorkspaceId: resolveWorkspaceId2,
|
|
719
|
-
query: ((document2, variables = {}, options) => query(
|
|
735
|
+
query: ((document2, variables = {}, options) => query(
|
|
736
|
+
documentText(document2),
|
|
737
|
+
variables,
|
|
738
|
+
options
|
|
739
|
+
)),
|
|
720
740
|
queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
|
|
721
741
|
documentText(document2),
|
|
722
742
|
variables,
|
|
@@ -1017,7 +1037,7 @@ async function resolveForms(config, blocks, schemas, locale, defaultLocale, opti
|
|
|
1017
1037
|
// src/data/site-locales.ts
|
|
1018
1038
|
var TTL_MS = 6e4;
|
|
1019
1039
|
var FAILURE_TTL_MS = 5e3;
|
|
1020
|
-
var
|
|
1040
|
+
var MAX_ENTRIES2 = 64;
|
|
1021
1041
|
var cache = /* @__PURE__ */ new Map();
|
|
1022
1042
|
function localesFromSiteConfig(siteConfig) {
|
|
1023
1043
|
const defaultLocale = siteConfig?.defaultLanguage || "en";
|
|
@@ -1041,11 +1061,14 @@ async function loadSiteLocales(config, options) {
|
|
|
1041
1061
|
{ ...options, public: true, retry: options?.retry ?? "build" },
|
|
1042
1062
|
"site config"
|
|
1043
1063
|
);
|
|
1044
|
-
|
|
1064
|
+
const siteConfig = data.public?.siteConfig ?? null;
|
|
1065
|
+
if (siteConfig?.workspaceId)
|
|
1066
|
+
primeWorkspaceId(config, siteConfig.workspaceId);
|
|
1067
|
+
value = localesFromSiteConfig(siteConfig);
|
|
1045
1068
|
} catch {
|
|
1046
1069
|
value = null;
|
|
1047
1070
|
}
|
|
1048
|
-
if (cache.size >=
|
|
1071
|
+
if (cache.size >= MAX_ENTRIES2) cache.clear();
|
|
1049
1072
|
cache.set(key, {
|
|
1050
1073
|
value,
|
|
1051
1074
|
expires: Date.now() + (value ? TTL_MS : FAILURE_TTL_MS)
|
package/dist/internal.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_LAYOUT_REGIONS } from '@cmssy/types';
|
|
2
2
|
|
|
3
|
+
// src/version.ts
|
|
4
|
+
var CMSSY_CORE_VERSION = "16.3.0" ;
|
|
5
|
+
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
6
|
+
|
|
3
7
|
// src/data/http.ts
|
|
4
8
|
var CmssyRequestError = class extends Error {
|
|
5
9
|
status;
|
|
@@ -135,7 +139,11 @@ async function postGraphql(url, query, variables, options) {
|
|
|
135
139
|
url,
|
|
136
140
|
{
|
|
137
141
|
method: "POST",
|
|
138
|
-
headers: {
|
|
142
|
+
headers: {
|
|
143
|
+
"content-type": "application/json",
|
|
144
|
+
"user-agent": CMSSY_USER_AGENT,
|
|
145
|
+
...options.headers
|
|
146
|
+
},
|
|
139
147
|
body: JSON.stringify({ query, variables }),
|
|
140
148
|
signal: options.signal
|
|
141
149
|
},
|
|
@@ -512,7 +520,26 @@ async function resolveWorkspaceId(config, options = {}) {
|
|
|
512
520
|
}
|
|
513
521
|
return siteConfig.workspaceId;
|
|
514
522
|
}
|
|
523
|
+
var MAX_ENTRIES = 64;
|
|
515
524
|
var workspaceIdCache = /* @__PURE__ */ new Map();
|
|
525
|
+
function cacheKey(config) {
|
|
526
|
+
return `${resolveApiUrl(config.apiUrl)}::${config.org}::${config.workspaceSlug}`;
|
|
527
|
+
}
|
|
528
|
+
function cachedWorkspaceId(config, options = {}) {
|
|
529
|
+
const key = cacheKey(config);
|
|
530
|
+
const existing = workspaceIdCache.get(key);
|
|
531
|
+
if (existing) return existing;
|
|
532
|
+
const fresh = resolveWorkspaceId(config, options).catch((err) => {
|
|
533
|
+
workspaceIdCache.delete(key);
|
|
534
|
+
throw err;
|
|
535
|
+
});
|
|
536
|
+
if (workspaceIdCache.size >= MAX_ENTRIES) workspaceIdCache.clear();
|
|
537
|
+
workspaceIdCache.set(key, fresh);
|
|
538
|
+
return fresh;
|
|
539
|
+
}
|
|
540
|
+
function primeWorkspaceId(config, workspaceId) {
|
|
541
|
+
workspaceIdCache.set(cacheKey(config), Promise.resolve(workspaceId));
|
|
542
|
+
}
|
|
516
543
|
function clearWorkspaceIdCache() {
|
|
517
544
|
workspaceIdCache.clear();
|
|
518
545
|
}
|
|
@@ -671,19 +698,8 @@ function createCmssyClient(input) {
|
|
|
671
698
|
...input,
|
|
672
699
|
apiUrl: resolveApiUrl(input.apiUrl)
|
|
673
700
|
};
|
|
674
|
-
let cachedWorkspaceId;
|
|
675
|
-
let inFlight;
|
|
676
701
|
function resolveWorkspaceId2(options) {
|
|
677
|
-
|
|
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;
|
|
702
|
+
return cachedWorkspaceId(config, options);
|
|
687
703
|
}
|
|
688
704
|
function query(document2, variables, options) {
|
|
689
705
|
return graphqlRequest(
|
|
@@ -714,7 +730,11 @@ function createCmssyClient(input) {
|
|
|
714
730
|
const client = {
|
|
715
731
|
config,
|
|
716
732
|
resolveWorkspaceId: resolveWorkspaceId2,
|
|
717
|
-
query: ((document2, variables = {}, options) => query(
|
|
733
|
+
query: ((document2, variables = {}, options) => query(
|
|
734
|
+
documentText(document2),
|
|
735
|
+
variables,
|
|
736
|
+
options
|
|
737
|
+
)),
|
|
718
738
|
queryScoped: ((document2, variables = {}, options = {}) => queryScoped(
|
|
719
739
|
documentText(document2),
|
|
720
740
|
variables,
|
|
@@ -1015,7 +1035,7 @@ async function resolveForms(config, blocks, schemas, locale, defaultLocale, opti
|
|
|
1015
1035
|
// src/data/site-locales.ts
|
|
1016
1036
|
var TTL_MS = 6e4;
|
|
1017
1037
|
var FAILURE_TTL_MS = 5e3;
|
|
1018
|
-
var
|
|
1038
|
+
var MAX_ENTRIES2 = 64;
|
|
1019
1039
|
var cache = /* @__PURE__ */ new Map();
|
|
1020
1040
|
function localesFromSiteConfig(siteConfig) {
|
|
1021
1041
|
const defaultLocale = siteConfig?.defaultLanguage || "en";
|
|
@@ -1039,11 +1059,14 @@ async function loadSiteLocales(config, options) {
|
|
|
1039
1059
|
{ ...options, public: true, retry: options?.retry ?? "build" },
|
|
1040
1060
|
"site config"
|
|
1041
1061
|
);
|
|
1042
|
-
|
|
1062
|
+
const siteConfig = data.public?.siteConfig ?? null;
|
|
1063
|
+
if (siteConfig?.workspaceId)
|
|
1064
|
+
primeWorkspaceId(config, siteConfig.workspaceId);
|
|
1065
|
+
value = localesFromSiteConfig(siteConfig);
|
|
1043
1066
|
} catch {
|
|
1044
1067
|
value = null;
|
|
1045
1068
|
}
|
|
1046
|
-
if (cache.size >=
|
|
1069
|
+
if (cache.size >= MAX_ENTRIES2) cache.clear();
|
|
1047
1070
|
cache.set(key, {
|
|
1048
1071
|
value,
|
|
1049
1072
|
expires: Date.now() + (value ? TTL_MS : FAILURE_TTL_MS)
|
package/dist/preflight.cjs
CHANGED
|
@@ -346,13 +346,26 @@ function parseOrigin(value) {
|
|
|
346
346
|
return null;
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
|
+
var LOCAL_HOSTNAMES = ["localhost", "127.0.0.1"];
|
|
350
|
+
function previewUrlFix(devOrigin) {
|
|
351
|
+
let hostname = null;
|
|
352
|
+
try {
|
|
353
|
+
hostname = new URL(devOrigin).hostname;
|
|
354
|
+
} catch {
|
|
355
|
+
hostname = null;
|
|
356
|
+
}
|
|
357
|
+
if (hostname && LOCAL_HOSTNAMES.includes(hostname)) {
|
|
358
|
+
return `toggle dev mode in the editor and enter ${devOrigin} there - ${SETTINGS_PATH} holds the shared preview URL of the DEPLOYED site, not your machine`;
|
|
359
|
+
}
|
|
360
|
+
return `paste ${devOrigin} into the preview URL field in ${SETTINGS_PATH}`;
|
|
361
|
+
}
|
|
349
362
|
function checkPreviewUrl(previewUrl, devOrigin) {
|
|
350
363
|
const trimmed = previewUrl?.trim();
|
|
351
364
|
if (!trimmed) {
|
|
352
365
|
return {
|
|
353
366
|
status: "fail",
|
|
354
367
|
message: "no preview URL is set for this workspace",
|
|
355
|
-
fix:
|
|
368
|
+
fix: previewUrlFix(devOrigin)
|
|
356
369
|
};
|
|
357
370
|
}
|
|
358
371
|
const previewOrigin = parseOrigin(trimmed);
|
|
@@ -360,7 +373,7 @@ function checkPreviewUrl(previewUrl, devOrigin) {
|
|
|
360
373
|
return {
|
|
361
374
|
status: "fail",
|
|
362
375
|
message: `the workspace preview URL "${trimmed}" is not a valid URL`,
|
|
363
|
-
fix:
|
|
376
|
+
fix: previewUrlFix(devOrigin)
|
|
364
377
|
};
|
|
365
378
|
}
|
|
366
379
|
const localOrigin = parseOrigin(devOrigin);
|
|
@@ -373,7 +386,7 @@ function checkPreviewUrl(previewUrl, devOrigin) {
|
|
|
373
386
|
return {
|
|
374
387
|
status: "fail",
|
|
375
388
|
message: `the workspace preview URL is ${previewOrigin} but your dev server runs at ${devOrigin}`,
|
|
376
|
-
fix:
|
|
389
|
+
fix: previewUrlFix(devOrigin)
|
|
377
390
|
};
|
|
378
391
|
}
|
|
379
392
|
function frameAncestorSources(cspHeaderValue) {
|
package/dist/preflight.js
CHANGED
|
@@ -344,13 +344,26 @@ function parseOrigin(value) {
|
|
|
344
344
|
return null;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
+
var LOCAL_HOSTNAMES = ["localhost", "127.0.0.1"];
|
|
348
|
+
function previewUrlFix(devOrigin) {
|
|
349
|
+
let hostname = null;
|
|
350
|
+
try {
|
|
351
|
+
hostname = new URL(devOrigin).hostname;
|
|
352
|
+
} catch {
|
|
353
|
+
hostname = null;
|
|
354
|
+
}
|
|
355
|
+
if (hostname && LOCAL_HOSTNAMES.includes(hostname)) {
|
|
356
|
+
return `toggle dev mode in the editor and enter ${devOrigin} there - ${SETTINGS_PATH} holds the shared preview URL of the DEPLOYED site, not your machine`;
|
|
357
|
+
}
|
|
358
|
+
return `paste ${devOrigin} into the preview URL field in ${SETTINGS_PATH}`;
|
|
359
|
+
}
|
|
347
360
|
function checkPreviewUrl(previewUrl, devOrigin) {
|
|
348
361
|
const trimmed = previewUrl?.trim();
|
|
349
362
|
if (!trimmed) {
|
|
350
363
|
return {
|
|
351
364
|
status: "fail",
|
|
352
365
|
message: "no preview URL is set for this workspace",
|
|
353
|
-
fix:
|
|
366
|
+
fix: previewUrlFix(devOrigin)
|
|
354
367
|
};
|
|
355
368
|
}
|
|
356
369
|
const previewOrigin = parseOrigin(trimmed);
|
|
@@ -358,7 +371,7 @@ function checkPreviewUrl(previewUrl, devOrigin) {
|
|
|
358
371
|
return {
|
|
359
372
|
status: "fail",
|
|
360
373
|
message: `the workspace preview URL "${trimmed}" is not a valid URL`,
|
|
361
|
-
fix:
|
|
374
|
+
fix: previewUrlFix(devOrigin)
|
|
362
375
|
};
|
|
363
376
|
}
|
|
364
377
|
const localOrigin = parseOrigin(devOrigin);
|
|
@@ -371,7 +384,7 @@ function checkPreviewUrl(previewUrl, devOrigin) {
|
|
|
371
384
|
return {
|
|
372
385
|
status: "fail",
|
|
373
386
|
message: `the workspace preview URL is ${previewOrigin} but your dev server runs at ${devOrigin}`,
|
|
374
|
-
fix:
|
|
387
|
+
fix: previewUrlFix(devOrigin)
|
|
375
388
|
};
|
|
376
389
|
}
|
|
377
390
|
function frameAncestorSources(cspHeaderValue) {
|