@cmssy/core 19.1.0 → 19.2.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/{csp-AuptG-R-.d.ts → csp-BdigosQo.d.ts} +8 -10
- package/dist/{csp-Dtp9S9TS.d.cts → csp-GwcubV3k.d.cts} +8 -10
- package/dist/index.cjs +156 -152
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +156 -153
- package/dist/internal/locale.cjs +156 -5
- package/dist/internal/locale.d.cts +1 -1
- package/dist/internal/locale.d.ts +1 -1
- package/dist/internal/locale.js +156 -5
- package/dist/internal.cjs +202 -186
- package/dist/internal.d.cts +66 -10
- package/dist/internal.d.ts +66 -10
- package/dist/internal.js +202 -186
- package/dist/{locale-BCguiP54.d.ts → locale-BGUsgy8p.d.ts} +11 -2
- package/dist/{locale-CsDPiYGF.d.cts → locale-DLGQgiu5.d.cts} +11 -2
- package/dist/preflight.cjs +171 -17
- package/dist/preflight.js +171 -17
- package/dist/testing.cjs +2 -0
- package/dist/testing.js +2 -0
- package/package.json +1 -1
package/dist/internal.cjs
CHANGED
|
@@ -2,8 +2,159 @@
|
|
|
2
2
|
|
|
3
3
|
var types = require('@cmssy/types');
|
|
4
4
|
|
|
5
|
+
// src/data/document.ts
|
|
6
|
+
function typedOperation(text) {
|
|
7
|
+
return text;
|
|
8
|
+
}
|
|
9
|
+
function isNode(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && typeof value.kind === "string";
|
|
11
|
+
}
|
|
12
|
+
function name(node) {
|
|
13
|
+
return isNode(node) ? String(node.value ?? "") : "";
|
|
14
|
+
}
|
|
15
|
+
function printValue(node) {
|
|
16
|
+
if (!isNode(node)) return "null";
|
|
17
|
+
const value = node.value;
|
|
18
|
+
switch (node.kind) {
|
|
19
|
+
case "Variable":
|
|
20
|
+
return `$${name(node.name)}`;
|
|
21
|
+
case "IntValue":
|
|
22
|
+
case "FloatValue":
|
|
23
|
+
case "BooleanValue":
|
|
24
|
+
return String(value);
|
|
25
|
+
case "StringValue":
|
|
26
|
+
return node.block ? `"""
|
|
27
|
+
${String(value)}
|
|
28
|
+
"""` : JSON.stringify(String(value));
|
|
29
|
+
case "EnumValue":
|
|
30
|
+
return String(value);
|
|
31
|
+
case "NullValue":
|
|
32
|
+
return "null";
|
|
33
|
+
case "ListValue":
|
|
34
|
+
return `[${(node.values ?? []).map(printValue).join(", ")}]`;
|
|
35
|
+
case "ObjectValue":
|
|
36
|
+
return `{${(node.fields ?? []).map(
|
|
37
|
+
(field) => `${name(field.name)}: ${printValue(
|
|
38
|
+
field.value
|
|
39
|
+
)}`
|
|
40
|
+
).join(", ")}}`;
|
|
41
|
+
default:
|
|
42
|
+
return "null";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function printType(node) {
|
|
46
|
+
if (!isNode(node)) return "";
|
|
47
|
+
switch (node.kind) {
|
|
48
|
+
case "NonNullType":
|
|
49
|
+
return `${printType(node.type)}!`;
|
|
50
|
+
case "ListType":
|
|
51
|
+
return `[${printType(node.type)}]`;
|
|
52
|
+
default:
|
|
53
|
+
return name(node.name);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function printArguments(node) {
|
|
57
|
+
const args = node.arguments ?? [];
|
|
58
|
+
if (args.length === 0) return "";
|
|
59
|
+
return `(${args.map(
|
|
60
|
+
(arg) => `${name(arg.name)}: ${printValue(
|
|
61
|
+
arg.value
|
|
62
|
+
)}`
|
|
63
|
+
).join(", ")})`;
|
|
64
|
+
}
|
|
65
|
+
function printDirectives(node) {
|
|
66
|
+
const directives = node.directives ?? [];
|
|
67
|
+
if (directives.length === 0) return "";
|
|
68
|
+
return ` ${directives.map(
|
|
69
|
+
(directive) => `@${name(directive.name)}${printArguments(directive)}`
|
|
70
|
+
).join(" ")}`;
|
|
71
|
+
}
|
|
72
|
+
function printSelectionSet(node, depth) {
|
|
73
|
+
if (!isNode(node)) return "";
|
|
74
|
+
const selections = node.selections ?? [];
|
|
75
|
+
if (selections.length === 0) return "";
|
|
76
|
+
const pad = " ".repeat(depth + 1);
|
|
77
|
+
const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
|
|
78
|
+
return ` {
|
|
79
|
+
${body}
|
|
80
|
+
${" ".repeat(depth)}}`;
|
|
81
|
+
}
|
|
82
|
+
function printSelection(node, depth) {
|
|
83
|
+
if (node.kind === "FragmentSpread") {
|
|
84
|
+
return `...${name(node.name)}${printDirectives(node)}`;
|
|
85
|
+
}
|
|
86
|
+
if (node.kind === "InlineFragment") {
|
|
87
|
+
const condition = node.typeCondition;
|
|
88
|
+
const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
|
|
89
|
+
return `...${on}${printDirectives(node)}${printSelectionSet(
|
|
90
|
+
node.selectionSet,
|
|
91
|
+
depth
|
|
92
|
+
)}`;
|
|
93
|
+
}
|
|
94
|
+
const alias = node.alias;
|
|
95
|
+
const prefix = isNode(alias) ? `${name(alias)}: ` : "";
|
|
96
|
+
return `${prefix}${name(node.name)}${printArguments(
|
|
97
|
+
node
|
|
98
|
+
)}${printDirectives(node)}${printSelectionSet(
|
|
99
|
+
node.selectionSet,
|
|
100
|
+
depth
|
|
101
|
+
)}`;
|
|
102
|
+
}
|
|
103
|
+
function printVariableDefinitions(node) {
|
|
104
|
+
const definitions = node.variableDefinitions ?? [];
|
|
105
|
+
if (definitions.length === 0) return "";
|
|
106
|
+
return `(${definitions.map((definition) => {
|
|
107
|
+
const variable = definition.variable;
|
|
108
|
+
const declared = `$${name(
|
|
109
|
+
isNode(variable) ? variable.name : void 0
|
|
110
|
+
)}: ${printType(definition.type)}`;
|
|
111
|
+
const defaultValue = definition.defaultValue;
|
|
112
|
+
return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
|
|
113
|
+
}).join(", ")})`;
|
|
114
|
+
}
|
|
115
|
+
function printDefinition(node) {
|
|
116
|
+
if (node.kind === "FragmentDefinition") {
|
|
117
|
+
const condition = node.typeCondition;
|
|
118
|
+
const on = isNode(condition) ? name(condition.name) : "";
|
|
119
|
+
return `fragment ${name(node.name)} on ${on}${printDirectives(
|
|
120
|
+
node
|
|
121
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
122
|
+
}
|
|
123
|
+
const operation = String(
|
|
124
|
+
node.operation ?? "query"
|
|
125
|
+
);
|
|
126
|
+
const operationName = name(node.name);
|
|
127
|
+
const head = operationName ? `${operation} ${operationName}` : operation;
|
|
128
|
+
return `${head}${printVariableDefinitions(node)}${printDirectives(
|
|
129
|
+
node
|
|
130
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
131
|
+
}
|
|
132
|
+
function printDocumentNode(node) {
|
|
133
|
+
const definitions = node.definitions ?? [];
|
|
134
|
+
return definitions.map(printDefinition).join("\n\n");
|
|
135
|
+
}
|
|
136
|
+
function documentText(document2) {
|
|
137
|
+
if (typeof document2 === "string") return document2;
|
|
138
|
+
if (!document2 || typeof document2 !== "object") {
|
|
139
|
+
throw new TypeError(
|
|
140
|
+
"cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
const loc = document2.loc;
|
|
144
|
+
if (typeof loc?.source?.body === "string") return loc.source.body;
|
|
145
|
+
if (document2.kind === "Document") {
|
|
146
|
+
const printed = printDocumentNode(document2);
|
|
147
|
+
if (printed.trim()) return printed;
|
|
148
|
+
}
|
|
149
|
+
const asString = String(document2);
|
|
150
|
+
if (asString && asString !== "[object Object]") return asString;
|
|
151
|
+
throw new TypeError(
|
|
152
|
+
"cmssy: could not read the query text off the given document"
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
5
156
|
// src/version.ts
|
|
6
|
-
var CMSSY_CORE_VERSION = "19.
|
|
157
|
+
var CMSSY_CORE_VERSION = "19.2.0" ;
|
|
7
158
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
8
159
|
|
|
9
160
|
// src/data/http.ts
|
|
@@ -146,7 +297,7 @@ async function postGraphql(url, query, variables, options) {
|
|
|
146
297
|
"user-agent": CMSSY_USER_AGENT,
|
|
147
298
|
...options.headers
|
|
148
299
|
},
|
|
149
|
-
body: JSON.stringify({ query, variables }),
|
|
300
|
+
body: JSON.stringify({ query: documentText(query), variables }),
|
|
150
301
|
signal: options.signal
|
|
151
302
|
},
|
|
152
303
|
options.retry,
|
|
@@ -198,7 +349,7 @@ function resolvePublicUrl(config) {
|
|
|
198
349
|
const base = resolveApiUrl(config.apiUrl).replace(/\/graphql\/?$/, "");
|
|
199
350
|
return `${base}/public/${config.org}/${config.workspaceSlug}/graphql`;
|
|
200
351
|
}
|
|
201
|
-
var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String) {
|
|
352
|
+
var PUBLIC_PAGE_QUERY = typedOperation(`query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String) {
|
|
202
353
|
public {
|
|
203
354
|
page {
|
|
204
355
|
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret) {
|
|
@@ -210,8 +361,8 @@ var PUBLIC_PAGE_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String
|
|
|
210
361
|
}
|
|
211
362
|
}
|
|
212
363
|
}
|
|
213
|
-
}
|
|
214
|
-
var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String, $devPreview: Boolean) {
|
|
364
|
+
}`);
|
|
365
|
+
var PUBLIC_PAGE_DEV_QUERY = typedOperation(`query PublicPage($workspaceSlug: String!, $slug: String!, $previewSecret: String, $devPreview: Boolean) {
|
|
215
366
|
public {
|
|
216
367
|
page {
|
|
217
368
|
get(workspaceSlug: $workspaceSlug, slug: $slug, previewSecret: $previewSecret, devPreview: $devPreview) {
|
|
@@ -223,8 +374,8 @@ var PUBLIC_PAGE_DEV_QUERY = `query PublicPage($workspaceSlug: String!, $slug: St
|
|
|
223
374
|
}
|
|
224
375
|
}
|
|
225
376
|
}
|
|
226
|
-
}
|
|
227
|
-
var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pageId: ID!) {
|
|
377
|
+
}`);
|
|
378
|
+
var PUBLIC_PAGE_BY_ID_QUERY = typedOperation(`query PublicPageById($workspaceSlug: String!, $pageId: ID!) {
|
|
228
379
|
public {
|
|
229
380
|
page {
|
|
230
381
|
getById(workspaceSlug: $workspaceSlug, pageId: $pageId) {
|
|
@@ -235,8 +386,8 @@ var PUBLIC_PAGE_BY_ID_QUERY = `query PublicPageById($workspaceSlug: String!, $pa
|
|
|
235
386
|
}
|
|
236
387
|
}
|
|
237
388
|
}
|
|
238
|
-
}
|
|
239
|
-
var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
|
|
389
|
+
}`);
|
|
390
|
+
var PUBLIC_PAGES_QUERY = typedOperation(`query PublicPages($workspaceSlug: String!) {
|
|
240
391
|
public {
|
|
241
392
|
page {
|
|
242
393
|
list(workspaceSlug: $workspaceSlug) {
|
|
@@ -247,8 +398,8 @@ var PUBLIC_PAGES_QUERY = `query PublicPages($workspaceSlug: String!) {
|
|
|
247
398
|
}
|
|
248
399
|
}
|
|
249
400
|
}
|
|
250
|
-
}
|
|
251
|
-
var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
|
|
401
|
+
}`);
|
|
402
|
+
var PUBLIC_PAGE_META_QUERY = typedOperation(`query PublicPageMeta($workspaceSlug: String!, $slug: String!) {
|
|
252
403
|
public {
|
|
253
404
|
page {
|
|
254
405
|
get(workspaceSlug: $workspaceSlug, slug: $slug) {
|
|
@@ -260,8 +411,8 @@ var PUBLIC_PAGE_META_QUERY = `query PublicPageMeta($workspaceSlug: String!, $slu
|
|
|
260
411
|
}
|
|
261
412
|
}
|
|
262
413
|
}
|
|
263
|
-
}
|
|
264
|
-
var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
|
|
414
|
+
}`);
|
|
415
|
+
var PUBLIC_PAGE_LAYOUTS_QUERY = typedOperation(`query PublicPageLayouts($workspaceSlug: String!, $pageSlug: String!, $previewSecret: String) {
|
|
265
416
|
public {
|
|
266
417
|
page {
|
|
267
418
|
layouts(workspaceSlug: $workspaceSlug, pageSlug: $pageSlug, previewSecret: $previewSecret) {
|
|
@@ -271,7 +422,7 @@ var PUBLIC_PAGE_LAYOUTS_QUERY = `query PublicPageLayouts($workspaceSlug: String!
|
|
|
271
422
|
}
|
|
272
423
|
}
|
|
273
424
|
}
|
|
274
|
-
}
|
|
425
|
+
}`);
|
|
275
426
|
function normalizeSlug(path) {
|
|
276
427
|
if (Array.isArray(path)) {
|
|
277
428
|
const joined = path.filter(Boolean).join("/");
|
|
@@ -293,22 +444,29 @@ async function fetchPage(config, path, options = {}) {
|
|
|
293
444
|
headers["x-workspace-id"] = options.workspaceId;
|
|
294
445
|
}
|
|
295
446
|
}
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
|
|
447
|
+
const requestOptions = {
|
|
448
|
+
fetch: options.fetch,
|
|
449
|
+
signal: options.signal,
|
|
450
|
+
headers,
|
|
451
|
+
retry: options.retry ?? "build",
|
|
452
|
+
label: "page fetch"
|
|
453
|
+
};
|
|
454
|
+
const url = resolvePublicUrl(config);
|
|
455
|
+
const data = devPreview ? await postGraphql(
|
|
456
|
+
url,
|
|
457
|
+
PUBLIC_PAGE_DEV_QUERY,
|
|
299
458
|
{
|
|
300
459
|
workspaceSlug: config.workspaceSlug,
|
|
301
460
|
slug,
|
|
302
461
|
previewSecret,
|
|
303
|
-
|
|
462
|
+
devPreview: true
|
|
304
463
|
},
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
464
|
+
requestOptions
|
|
465
|
+
) : await postGraphql(
|
|
466
|
+
url,
|
|
467
|
+
PUBLIC_PAGE_QUERY,
|
|
468
|
+
{ workspaceSlug: config.workspaceSlug, slug, previewSecret },
|
|
469
|
+
requestOptions
|
|
312
470
|
);
|
|
313
471
|
const page = data?.public?.page?.get;
|
|
314
472
|
if (!page) return null;
|
|
@@ -427,7 +585,7 @@ async function graphqlRequest(config, query, variables, options = {}, label = "r
|
|
|
427
585
|
label
|
|
428
586
|
});
|
|
429
587
|
}
|
|
430
|
-
var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
588
|
+
var SITE_CONFIG_QUERY = typedOperation(`query PublicSiteConfig($workspaceSlug: String!) {
|
|
431
589
|
public {
|
|
432
590
|
siteConfig(workspaceSlug: $workspaceSlug) {
|
|
433
591
|
id
|
|
@@ -443,8 +601,8 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
|
443
601
|
}
|
|
444
602
|
}
|
|
445
603
|
}
|
|
446
|
-
}
|
|
447
|
-
var MODEL_DEFINITIONS_QUERY = `query PublicModelDefinitions($workspaceId: String!) {
|
|
604
|
+
}`);
|
|
605
|
+
var MODEL_DEFINITIONS_QUERY = typedOperation(`query PublicModelDefinitions($workspaceId: String!) {
|
|
448
606
|
public {
|
|
449
607
|
model {
|
|
450
608
|
definitions(workspaceId: $workspaceId) {
|
|
@@ -452,8 +610,8 @@ var MODEL_DEFINITIONS_QUERY = `query PublicModelDefinitions($workspaceId: String
|
|
|
452
610
|
}
|
|
453
611
|
}
|
|
454
612
|
}
|
|
455
|
-
}
|
|
456
|
-
var MODEL_RECORDS_QUERY = `query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $locale: String, $limit: Int, $offset: Int, $populate: [String!]) {
|
|
613
|
+
}`);
|
|
614
|
+
var MODEL_RECORDS_QUERY = typedOperation(`query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $locale: String, $limit: Int, $offset: Int, $populate: [String!]) {
|
|
457
615
|
public {
|
|
458
616
|
model {
|
|
459
617
|
records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, locale: $locale, limit: $limit, offset: $offset, populate: $populate) {
|
|
@@ -463,8 +621,9 @@ var MODEL_RECORDS_QUERY = `query PublicModelRecords($workspaceId: String!, $mode
|
|
|
463
621
|
}
|
|
464
622
|
}
|
|
465
623
|
}
|
|
466
|
-
}
|
|
467
|
-
var FORM_QUERY =
|
|
624
|
+
}`);
|
|
625
|
+
var FORM_QUERY = typedOperation(
|
|
626
|
+
`query PublicForm($formId: ID!) {
|
|
468
627
|
public {
|
|
469
628
|
form {
|
|
470
629
|
get(formId: $formId) {
|
|
@@ -485,8 +644,9 @@ var FORM_QUERY = `query PublicForm($formId: ID!) {
|
|
|
485
644
|
}
|
|
486
645
|
}
|
|
487
646
|
}
|
|
488
|
-
}
|
|
489
|
-
|
|
647
|
+
}`
|
|
648
|
+
);
|
|
649
|
+
var SUBMIT_FORM_MUTATION = typedOperation(`mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {
|
|
490
650
|
public {
|
|
491
651
|
form {
|
|
492
652
|
submit(formId: $formId, input: $input) {
|
|
@@ -494,7 +654,7 @@ var SUBMIT_FORM_MUTATION = `mutation SubmitForm($formId: ID!, $input: SubmitForm
|
|
|
494
654
|
}
|
|
495
655
|
}
|
|
496
656
|
}
|
|
497
|
-
}
|
|
657
|
+
}`);
|
|
498
658
|
|
|
499
659
|
// src/data/settings-client.ts
|
|
500
660
|
async function fetchSiteConfig(config, options = {}) {
|
|
@@ -540,154 +700,6 @@ function clearWorkspaceIdCache() {
|
|
|
540
700
|
workspaceIdCache.clear();
|
|
541
701
|
}
|
|
542
702
|
|
|
543
|
-
// src/data/document.ts
|
|
544
|
-
function isNode(value) {
|
|
545
|
-
return typeof value === "object" && value !== null && typeof value.kind === "string";
|
|
546
|
-
}
|
|
547
|
-
function name(node) {
|
|
548
|
-
return isNode(node) ? String(node.value ?? "") : "";
|
|
549
|
-
}
|
|
550
|
-
function printValue(node) {
|
|
551
|
-
if (!isNode(node)) return "null";
|
|
552
|
-
const value = node.value;
|
|
553
|
-
switch (node.kind) {
|
|
554
|
-
case "Variable":
|
|
555
|
-
return `$${name(node.name)}`;
|
|
556
|
-
case "IntValue":
|
|
557
|
-
case "FloatValue":
|
|
558
|
-
case "BooleanValue":
|
|
559
|
-
return String(value);
|
|
560
|
-
case "StringValue":
|
|
561
|
-
return node.block ? `"""
|
|
562
|
-
${String(value)}
|
|
563
|
-
"""` : JSON.stringify(String(value));
|
|
564
|
-
case "EnumValue":
|
|
565
|
-
return String(value);
|
|
566
|
-
case "NullValue":
|
|
567
|
-
return "null";
|
|
568
|
-
case "ListValue":
|
|
569
|
-
return `[${(node.values ?? []).map(printValue).join(", ")}]`;
|
|
570
|
-
case "ObjectValue":
|
|
571
|
-
return `{${(node.fields ?? []).map(
|
|
572
|
-
(field) => `${name(field.name)}: ${printValue(
|
|
573
|
-
field.value
|
|
574
|
-
)}`
|
|
575
|
-
).join(", ")}}`;
|
|
576
|
-
default:
|
|
577
|
-
return "null";
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
function printType(node) {
|
|
581
|
-
if (!isNode(node)) return "";
|
|
582
|
-
switch (node.kind) {
|
|
583
|
-
case "NonNullType":
|
|
584
|
-
return `${printType(node.type)}!`;
|
|
585
|
-
case "ListType":
|
|
586
|
-
return `[${printType(node.type)}]`;
|
|
587
|
-
default:
|
|
588
|
-
return name(node.name);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
function printArguments(node) {
|
|
592
|
-
const args = node.arguments ?? [];
|
|
593
|
-
if (args.length === 0) return "";
|
|
594
|
-
return `(${args.map(
|
|
595
|
-
(arg) => `${name(arg.name)}: ${printValue(
|
|
596
|
-
arg.value
|
|
597
|
-
)}`
|
|
598
|
-
).join(", ")})`;
|
|
599
|
-
}
|
|
600
|
-
function printDirectives(node) {
|
|
601
|
-
const directives = node.directives ?? [];
|
|
602
|
-
if (directives.length === 0) return "";
|
|
603
|
-
return ` ${directives.map(
|
|
604
|
-
(directive) => `@${name(directive.name)}${printArguments(directive)}`
|
|
605
|
-
).join(" ")}`;
|
|
606
|
-
}
|
|
607
|
-
function printSelectionSet(node, depth) {
|
|
608
|
-
if (!isNode(node)) return "";
|
|
609
|
-
const selections = node.selections ?? [];
|
|
610
|
-
if (selections.length === 0) return "";
|
|
611
|
-
const pad = " ".repeat(depth + 1);
|
|
612
|
-
const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
|
|
613
|
-
return ` {
|
|
614
|
-
${body}
|
|
615
|
-
${" ".repeat(depth)}}`;
|
|
616
|
-
}
|
|
617
|
-
function printSelection(node, depth) {
|
|
618
|
-
if (node.kind === "FragmentSpread") {
|
|
619
|
-
return `...${name(node.name)}${printDirectives(node)}`;
|
|
620
|
-
}
|
|
621
|
-
if (node.kind === "InlineFragment") {
|
|
622
|
-
const condition = node.typeCondition;
|
|
623
|
-
const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
|
|
624
|
-
return `...${on}${printDirectives(node)}${printSelectionSet(
|
|
625
|
-
node.selectionSet,
|
|
626
|
-
depth
|
|
627
|
-
)}`;
|
|
628
|
-
}
|
|
629
|
-
const alias = node.alias;
|
|
630
|
-
const prefix = isNode(alias) ? `${name(alias)}: ` : "";
|
|
631
|
-
return `${prefix}${name(node.name)}${printArguments(
|
|
632
|
-
node
|
|
633
|
-
)}${printDirectives(node)}${printSelectionSet(
|
|
634
|
-
node.selectionSet,
|
|
635
|
-
depth
|
|
636
|
-
)}`;
|
|
637
|
-
}
|
|
638
|
-
function printVariableDefinitions(node) {
|
|
639
|
-
const definitions = node.variableDefinitions ?? [];
|
|
640
|
-
if (definitions.length === 0) return "";
|
|
641
|
-
return `(${definitions.map((definition) => {
|
|
642
|
-
const variable = definition.variable;
|
|
643
|
-
const declared = `$${name(
|
|
644
|
-
isNode(variable) ? variable.name : void 0
|
|
645
|
-
)}: ${printType(definition.type)}`;
|
|
646
|
-
const defaultValue = definition.defaultValue;
|
|
647
|
-
return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
|
|
648
|
-
}).join(", ")})`;
|
|
649
|
-
}
|
|
650
|
-
function printDefinition(node) {
|
|
651
|
-
if (node.kind === "FragmentDefinition") {
|
|
652
|
-
const condition = node.typeCondition;
|
|
653
|
-
const on = isNode(condition) ? name(condition.name) : "";
|
|
654
|
-
return `fragment ${name(node.name)} on ${on}${printDirectives(
|
|
655
|
-
node
|
|
656
|
-
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
657
|
-
}
|
|
658
|
-
const operation = String(
|
|
659
|
-
node.operation ?? "query"
|
|
660
|
-
);
|
|
661
|
-
const operationName = name(node.name);
|
|
662
|
-
const head = operationName ? `${operation} ${operationName}` : operation;
|
|
663
|
-
return `${head}${printVariableDefinitions(node)}${printDirectives(
|
|
664
|
-
node
|
|
665
|
-
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
666
|
-
}
|
|
667
|
-
function printDocumentNode(node) {
|
|
668
|
-
const definitions = node.definitions ?? [];
|
|
669
|
-
return definitions.map(printDefinition).join("\n\n");
|
|
670
|
-
}
|
|
671
|
-
function documentText(document2) {
|
|
672
|
-
if (typeof document2 === "string") return document2;
|
|
673
|
-
if (!document2 || typeof document2 !== "object") {
|
|
674
|
-
throw new TypeError(
|
|
675
|
-
"cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
|
|
676
|
-
);
|
|
677
|
-
}
|
|
678
|
-
const loc = document2.loc;
|
|
679
|
-
if (typeof loc?.source?.body === "string") return loc.source.body;
|
|
680
|
-
if (document2.kind === "Document") {
|
|
681
|
-
const printed = printDocumentNode(document2);
|
|
682
|
-
if (printed.trim()) return printed;
|
|
683
|
-
}
|
|
684
|
-
const asString = String(document2);
|
|
685
|
-
if (asString && asString !== "[object Object]") return asString;
|
|
686
|
-
throw new TypeError(
|
|
687
|
-
"cmssy: could not read the query text off the given document"
|
|
688
|
-
);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
703
|
// src/data/client.ts
|
|
692
704
|
function createCmssyClient(input) {
|
|
693
705
|
const config = {
|
|
@@ -741,7 +753,7 @@ function createCmssyClient(input) {
|
|
|
741
753
|
}
|
|
742
754
|
|
|
743
755
|
// src/data/block-content.ts
|
|
744
|
-
var RECORDS_BY_IDS_QUERY = `query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {
|
|
756
|
+
var RECORDS_BY_IDS_QUERY = typedOperation(`query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {
|
|
745
757
|
public {
|
|
746
758
|
model {
|
|
747
759
|
recordsByIds(workspaceId: $workspaceId, ids: $ids, locale: $locale) {
|
|
@@ -749,7 +761,7 @@ var RECORDS_BY_IDS_QUERY = `query PublicRecordsByIds($workspaceId: String!, $ids
|
|
|
749
761
|
}
|
|
750
762
|
}
|
|
751
763
|
}
|
|
752
|
-
}
|
|
764
|
+
}`);
|
|
753
765
|
var BY_IDS_CHUNK = 50;
|
|
754
766
|
var COLLECTION_DEFAULT_LIMIT = 50;
|
|
755
767
|
function relationModel(field) {
|
|
@@ -1016,7 +1028,11 @@ async function resolveForms(config, blocks, schemas, locale, defaultLocale, opti
|
|
|
1016
1028
|
const entries = await Promise.all(
|
|
1017
1029
|
ids.map(async (id) => {
|
|
1018
1030
|
try {
|
|
1019
|
-
const data = await client.queryScoped(
|
|
1031
|
+
const data = await client.queryScoped(
|
|
1032
|
+
FORM_QUERY,
|
|
1033
|
+
{ formId: id },
|
|
1034
|
+
options
|
|
1035
|
+
);
|
|
1020
1036
|
return [id, data.public.form.get];
|
|
1021
1037
|
} catch (err) {
|
|
1022
1038
|
if (typeof console !== "undefined") {
|
package/dist/internal.d.cts
CHANGED
|
@@ -1,17 +1,73 @@
|
|
|
1
1
|
export { g as fetchLayouts, h as fetchPage, j as fetchPageById, k as fetchPageMeta, l as fetchPages, r as resolveApiUrl } from './content-client-DhcHP8ln.cjs';
|
|
2
|
-
import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig,
|
|
2
|
+
import { CmssyFormDefinition, CmssyModelDefinition, CmssyRecordList, CmssySiteConfig, CmssyFormSubmitResponse, SubmitFormInput, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, FieldDefinition, RawBlock, CmssyLayoutGroup } 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 {
|
|
4
|
+
import { a as CmssyOperation, G as GraphqlRequestOptions } from './locale-DLGQgiu5.cjs';
|
|
5
|
+
export { C as CMSSY_LOCALE_HEADER, d as localeForPath, e as localeForPathname, l as localizeHref, f as resolveSiteLocales, s as splitCmssyLocale, h as splitLocaleFromPath } from './locale-DLGQgiu5.cjs';
|
|
6
|
+
import { Q as QueryScopedOptions } from './csp-GwcubV3k.cjs';
|
|
7
|
+
export { G as cmssyCspHeaders, H as isDevelopment, J as layoutRegionIds, K as resolveInitialTarget, L as toCspOrigin } from './csp-GwcubV3k.cjs';
|
|
8
8
|
export { localizedPath } from './internal/locale.cjs';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
interface SiteConfigVariables {
|
|
11
|
+
workspaceSlug: string;
|
|
12
|
+
}
|
|
13
|
+
interface SiteConfigResult {
|
|
14
|
+
public: {
|
|
15
|
+
siteConfig: CmssySiteConfig | null;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
declare const SITE_CONFIG_QUERY: CmssyOperation<SiteConfigResult, SiteConfigVariables>;
|
|
19
|
+
interface ModelDefinitionsVariables {
|
|
20
|
+
workspaceId: string;
|
|
21
|
+
}
|
|
22
|
+
interface ModelDefinitionsResult {
|
|
23
|
+
public: {
|
|
24
|
+
model: {
|
|
25
|
+
definitions: CmssyModelDefinition[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
declare const MODEL_DEFINITIONS_QUERY: CmssyOperation<ModelDefinitionsResult, ModelDefinitionsVariables>;
|
|
30
|
+
interface ModelRecordsVariables {
|
|
31
|
+
workspaceId: string;
|
|
32
|
+
modelSlug: string;
|
|
33
|
+
filter?: Record<string, unknown> | null;
|
|
34
|
+
sort?: string | null;
|
|
35
|
+
locale?: string | null;
|
|
36
|
+
limit?: number | null;
|
|
37
|
+
offset?: number | null;
|
|
38
|
+
populate?: string[] | null;
|
|
39
|
+
}
|
|
40
|
+
interface ModelRecordsResult {
|
|
41
|
+
public: {
|
|
42
|
+
model: {
|
|
43
|
+
records: CmssyRecordList;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
declare const MODEL_RECORDS_QUERY: CmssyOperation<ModelRecordsResult, ModelRecordsVariables>;
|
|
48
|
+
interface FormVariables {
|
|
49
|
+
formId: string;
|
|
50
|
+
}
|
|
51
|
+
interface FormResult {
|
|
52
|
+
public: {
|
|
53
|
+
form: {
|
|
54
|
+
get: CmssyFormDefinition | null;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
declare const FORM_QUERY: CmssyOperation<FormResult, FormVariables>;
|
|
59
|
+
interface SubmitFormVariables {
|
|
60
|
+
formId: string;
|
|
61
|
+
input: SubmitFormInput;
|
|
62
|
+
}
|
|
63
|
+
interface SubmitFormResult {
|
|
64
|
+
public: {
|
|
65
|
+
form: {
|
|
66
|
+
submit: CmssyFormSubmitResponse;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
declare const SUBMIT_FORM_MUTATION: CmssyOperation<SubmitFormResult, SubmitFormVariables>;
|
|
15
71
|
|
|
16
72
|
declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
|
|
17
73
|
|