@cmssy/core 19.1.1 → 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/index.js
CHANGED
|
@@ -72,8 +72,159 @@ 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/data/document.ts
|
|
76
|
+
function typedOperation(text) {
|
|
77
|
+
return text;
|
|
78
|
+
}
|
|
79
|
+
function isNode(value) {
|
|
80
|
+
return typeof value === "object" && value !== null && typeof value.kind === "string";
|
|
81
|
+
}
|
|
82
|
+
function name(node) {
|
|
83
|
+
return isNode(node) ? String(node.value ?? "") : "";
|
|
84
|
+
}
|
|
85
|
+
function printValue(node) {
|
|
86
|
+
if (!isNode(node)) return "null";
|
|
87
|
+
const value = node.value;
|
|
88
|
+
switch (node.kind) {
|
|
89
|
+
case "Variable":
|
|
90
|
+
return `$${name(node.name)}`;
|
|
91
|
+
case "IntValue":
|
|
92
|
+
case "FloatValue":
|
|
93
|
+
case "BooleanValue":
|
|
94
|
+
return String(value);
|
|
95
|
+
case "StringValue":
|
|
96
|
+
return node.block ? `"""
|
|
97
|
+
${String(value)}
|
|
98
|
+
"""` : JSON.stringify(String(value));
|
|
99
|
+
case "EnumValue":
|
|
100
|
+
return String(value);
|
|
101
|
+
case "NullValue":
|
|
102
|
+
return "null";
|
|
103
|
+
case "ListValue":
|
|
104
|
+
return `[${(node.values ?? []).map(printValue).join(", ")}]`;
|
|
105
|
+
case "ObjectValue":
|
|
106
|
+
return `{${(node.fields ?? []).map(
|
|
107
|
+
(field) => `${name(field.name)}: ${printValue(
|
|
108
|
+
field.value
|
|
109
|
+
)}`
|
|
110
|
+
).join(", ")}}`;
|
|
111
|
+
default:
|
|
112
|
+
return "null";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function printType(node) {
|
|
116
|
+
if (!isNode(node)) return "";
|
|
117
|
+
switch (node.kind) {
|
|
118
|
+
case "NonNullType":
|
|
119
|
+
return `${printType(node.type)}!`;
|
|
120
|
+
case "ListType":
|
|
121
|
+
return `[${printType(node.type)}]`;
|
|
122
|
+
default:
|
|
123
|
+
return name(node.name);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function printArguments(node) {
|
|
127
|
+
const args = node.arguments ?? [];
|
|
128
|
+
if (args.length === 0) return "";
|
|
129
|
+
return `(${args.map(
|
|
130
|
+
(arg) => `${name(arg.name)}: ${printValue(
|
|
131
|
+
arg.value
|
|
132
|
+
)}`
|
|
133
|
+
).join(", ")})`;
|
|
134
|
+
}
|
|
135
|
+
function printDirectives(node) {
|
|
136
|
+
const directives = node.directives ?? [];
|
|
137
|
+
if (directives.length === 0) return "";
|
|
138
|
+
return ` ${directives.map(
|
|
139
|
+
(directive) => `@${name(directive.name)}${printArguments(directive)}`
|
|
140
|
+
).join(" ")}`;
|
|
141
|
+
}
|
|
142
|
+
function printSelectionSet(node, depth) {
|
|
143
|
+
if (!isNode(node)) return "";
|
|
144
|
+
const selections = node.selections ?? [];
|
|
145
|
+
if (selections.length === 0) return "";
|
|
146
|
+
const pad = " ".repeat(depth + 1);
|
|
147
|
+
const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
|
|
148
|
+
return ` {
|
|
149
|
+
${body}
|
|
150
|
+
${" ".repeat(depth)}}`;
|
|
151
|
+
}
|
|
152
|
+
function printSelection(node, depth) {
|
|
153
|
+
if (node.kind === "FragmentSpread") {
|
|
154
|
+
return `...${name(node.name)}${printDirectives(node)}`;
|
|
155
|
+
}
|
|
156
|
+
if (node.kind === "InlineFragment") {
|
|
157
|
+
const condition = node.typeCondition;
|
|
158
|
+
const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
|
|
159
|
+
return `...${on}${printDirectives(node)}${printSelectionSet(
|
|
160
|
+
node.selectionSet,
|
|
161
|
+
depth
|
|
162
|
+
)}`;
|
|
163
|
+
}
|
|
164
|
+
const alias = node.alias;
|
|
165
|
+
const prefix = isNode(alias) ? `${name(alias)}: ` : "";
|
|
166
|
+
return `${prefix}${name(node.name)}${printArguments(
|
|
167
|
+
node
|
|
168
|
+
)}${printDirectives(node)}${printSelectionSet(
|
|
169
|
+
node.selectionSet,
|
|
170
|
+
depth
|
|
171
|
+
)}`;
|
|
172
|
+
}
|
|
173
|
+
function printVariableDefinitions(node) {
|
|
174
|
+
const definitions = node.variableDefinitions ?? [];
|
|
175
|
+
if (definitions.length === 0) return "";
|
|
176
|
+
return `(${definitions.map((definition) => {
|
|
177
|
+
const variable = definition.variable;
|
|
178
|
+
const declared = `$${name(
|
|
179
|
+
isNode(variable) ? variable.name : void 0
|
|
180
|
+
)}: ${printType(definition.type)}`;
|
|
181
|
+
const defaultValue = definition.defaultValue;
|
|
182
|
+
return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
|
|
183
|
+
}).join(", ")})`;
|
|
184
|
+
}
|
|
185
|
+
function printDefinition(node) {
|
|
186
|
+
if (node.kind === "FragmentDefinition") {
|
|
187
|
+
const condition = node.typeCondition;
|
|
188
|
+
const on = isNode(condition) ? name(condition.name) : "";
|
|
189
|
+
return `fragment ${name(node.name)} on ${on}${printDirectives(
|
|
190
|
+
node
|
|
191
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
192
|
+
}
|
|
193
|
+
const operation = String(
|
|
194
|
+
node.operation ?? "query"
|
|
195
|
+
);
|
|
196
|
+
const operationName = name(node.name);
|
|
197
|
+
const head = operationName ? `${operation} ${operationName}` : operation;
|
|
198
|
+
return `${head}${printVariableDefinitions(node)}${printDirectives(
|
|
199
|
+
node
|
|
200
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
201
|
+
}
|
|
202
|
+
function printDocumentNode(node) {
|
|
203
|
+
const definitions = node.definitions ?? [];
|
|
204
|
+
return definitions.map(printDefinition).join("\n\n");
|
|
205
|
+
}
|
|
206
|
+
function documentText(document2) {
|
|
207
|
+
if (typeof document2 === "string") return document2;
|
|
208
|
+
if (!document2 || typeof document2 !== "object") {
|
|
209
|
+
throw new TypeError(
|
|
210
|
+
"cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
const loc = document2.loc;
|
|
214
|
+
if (typeof loc?.source?.body === "string") return loc.source.body;
|
|
215
|
+
if (document2.kind === "Document") {
|
|
216
|
+
const printed = printDocumentNode(document2);
|
|
217
|
+
if (printed.trim()) return printed;
|
|
218
|
+
}
|
|
219
|
+
const asString = String(document2);
|
|
220
|
+
if (asString && asString !== "[object Object]") return asString;
|
|
221
|
+
throw new TypeError(
|
|
222
|
+
"cmssy: could not read the query text off the given document"
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
75
226
|
// src/version.ts
|
|
76
|
-
var CMSSY_CORE_VERSION = "19.
|
|
227
|
+
var CMSSY_CORE_VERSION = "19.2.0" ;
|
|
77
228
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
78
229
|
|
|
79
230
|
// src/data/http.ts
|
|
@@ -219,7 +370,7 @@ async function postGraphql(url, query, variables, options) {
|
|
|
219
370
|
"user-agent": CMSSY_USER_AGENT,
|
|
220
371
|
...options.headers
|
|
221
372
|
},
|
|
222
|
-
body: JSON.stringify({ query, variables }),
|
|
373
|
+
body: JSON.stringify({ query: documentText(query), variables }),
|
|
223
374
|
signal: options.signal
|
|
224
375
|
},
|
|
225
376
|
options.retry,
|
|
@@ -283,155 +434,7 @@ async function graphqlRequest(config, query, variables, options = {}, label = "r
|
|
|
283
434
|
label
|
|
284
435
|
});
|
|
285
436
|
}
|
|
286
|
-
|
|
287
|
-
// src/data/document.ts
|
|
288
|
-
function isNode(value) {
|
|
289
|
-
return typeof value === "object" && value !== null && typeof value.kind === "string";
|
|
290
|
-
}
|
|
291
|
-
function name(node) {
|
|
292
|
-
return isNode(node) ? String(node.value ?? "") : "";
|
|
293
|
-
}
|
|
294
|
-
function printValue(node) {
|
|
295
|
-
if (!isNode(node)) return "null";
|
|
296
|
-
const value = node.value;
|
|
297
|
-
switch (node.kind) {
|
|
298
|
-
case "Variable":
|
|
299
|
-
return `$${name(node.name)}`;
|
|
300
|
-
case "IntValue":
|
|
301
|
-
case "FloatValue":
|
|
302
|
-
case "BooleanValue":
|
|
303
|
-
return String(value);
|
|
304
|
-
case "StringValue":
|
|
305
|
-
return node.block ? `"""
|
|
306
|
-
${String(value)}
|
|
307
|
-
"""` : JSON.stringify(String(value));
|
|
308
|
-
case "EnumValue":
|
|
309
|
-
return String(value);
|
|
310
|
-
case "NullValue":
|
|
311
|
-
return "null";
|
|
312
|
-
case "ListValue":
|
|
313
|
-
return `[${(node.values ?? []).map(printValue).join(", ")}]`;
|
|
314
|
-
case "ObjectValue":
|
|
315
|
-
return `{${(node.fields ?? []).map(
|
|
316
|
-
(field) => `${name(field.name)}: ${printValue(
|
|
317
|
-
field.value
|
|
318
|
-
)}`
|
|
319
|
-
).join(", ")}}`;
|
|
320
|
-
default:
|
|
321
|
-
return "null";
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
function printType(node) {
|
|
325
|
-
if (!isNode(node)) return "";
|
|
326
|
-
switch (node.kind) {
|
|
327
|
-
case "NonNullType":
|
|
328
|
-
return `${printType(node.type)}!`;
|
|
329
|
-
case "ListType":
|
|
330
|
-
return `[${printType(node.type)}]`;
|
|
331
|
-
default:
|
|
332
|
-
return name(node.name);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
function printArguments(node) {
|
|
336
|
-
const args = node.arguments ?? [];
|
|
337
|
-
if (args.length === 0) return "";
|
|
338
|
-
return `(${args.map(
|
|
339
|
-
(arg) => `${name(arg.name)}: ${printValue(
|
|
340
|
-
arg.value
|
|
341
|
-
)}`
|
|
342
|
-
).join(", ")})`;
|
|
343
|
-
}
|
|
344
|
-
function printDirectives(node) {
|
|
345
|
-
const directives = node.directives ?? [];
|
|
346
|
-
if (directives.length === 0) return "";
|
|
347
|
-
return ` ${directives.map(
|
|
348
|
-
(directive) => `@${name(directive.name)}${printArguments(directive)}`
|
|
349
|
-
).join(" ")}`;
|
|
350
|
-
}
|
|
351
|
-
function printSelectionSet(node, depth) {
|
|
352
|
-
if (!isNode(node)) return "";
|
|
353
|
-
const selections = node.selections ?? [];
|
|
354
|
-
if (selections.length === 0) return "";
|
|
355
|
-
const pad = " ".repeat(depth + 1);
|
|
356
|
-
const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
|
|
357
|
-
return ` {
|
|
358
|
-
${body}
|
|
359
|
-
${" ".repeat(depth)}}`;
|
|
360
|
-
}
|
|
361
|
-
function printSelection(node, depth) {
|
|
362
|
-
if (node.kind === "FragmentSpread") {
|
|
363
|
-
return `...${name(node.name)}${printDirectives(node)}`;
|
|
364
|
-
}
|
|
365
|
-
if (node.kind === "InlineFragment") {
|
|
366
|
-
const condition = node.typeCondition;
|
|
367
|
-
const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
|
|
368
|
-
return `...${on}${printDirectives(node)}${printSelectionSet(
|
|
369
|
-
node.selectionSet,
|
|
370
|
-
depth
|
|
371
|
-
)}`;
|
|
372
|
-
}
|
|
373
|
-
const alias = node.alias;
|
|
374
|
-
const prefix = isNode(alias) ? `${name(alias)}: ` : "";
|
|
375
|
-
return `${prefix}${name(node.name)}${printArguments(
|
|
376
|
-
node
|
|
377
|
-
)}${printDirectives(node)}${printSelectionSet(
|
|
378
|
-
node.selectionSet,
|
|
379
|
-
depth
|
|
380
|
-
)}`;
|
|
381
|
-
}
|
|
382
|
-
function printVariableDefinitions(node) {
|
|
383
|
-
const definitions = node.variableDefinitions ?? [];
|
|
384
|
-
if (definitions.length === 0) return "";
|
|
385
|
-
return `(${definitions.map((definition) => {
|
|
386
|
-
const variable = definition.variable;
|
|
387
|
-
const declared = `$${name(
|
|
388
|
-
isNode(variable) ? variable.name : void 0
|
|
389
|
-
)}: ${printType(definition.type)}`;
|
|
390
|
-
const defaultValue = definition.defaultValue;
|
|
391
|
-
return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
|
|
392
|
-
}).join(", ")})`;
|
|
393
|
-
}
|
|
394
|
-
function printDefinition(node) {
|
|
395
|
-
if (node.kind === "FragmentDefinition") {
|
|
396
|
-
const condition = node.typeCondition;
|
|
397
|
-
const on = isNode(condition) ? name(condition.name) : "";
|
|
398
|
-
return `fragment ${name(node.name)} on ${on}${printDirectives(
|
|
399
|
-
node
|
|
400
|
-
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
401
|
-
}
|
|
402
|
-
const operation = String(
|
|
403
|
-
node.operation ?? "query"
|
|
404
|
-
);
|
|
405
|
-
const operationName = name(node.name);
|
|
406
|
-
const head = operationName ? `${operation} ${operationName}` : operation;
|
|
407
|
-
return `${head}${printVariableDefinitions(node)}${printDirectives(
|
|
408
|
-
node
|
|
409
|
-
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
410
|
-
}
|
|
411
|
-
function printDocumentNode(node) {
|
|
412
|
-
const definitions = node.definitions ?? [];
|
|
413
|
-
return definitions.map(printDefinition).join("\n\n");
|
|
414
|
-
}
|
|
415
|
-
function documentText(document2) {
|
|
416
|
-
if (typeof document2 === "string") return document2;
|
|
417
|
-
if (!document2 || typeof document2 !== "object") {
|
|
418
|
-
throw new TypeError(
|
|
419
|
-
"cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
const loc = document2.loc;
|
|
423
|
-
if (typeof loc?.source?.body === "string") return loc.source.body;
|
|
424
|
-
if (document2.kind === "Document") {
|
|
425
|
-
const printed = printDocumentNode(document2);
|
|
426
|
-
if (printed.trim()) return printed;
|
|
427
|
-
}
|
|
428
|
-
const asString = String(document2);
|
|
429
|
-
if (asString && asString !== "[object Object]") return asString;
|
|
430
|
-
throw new TypeError(
|
|
431
|
-
"cmssy: could not read the query text off the given document"
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
437
|
+
var SITE_CONFIG_QUERY = typedOperation(`query PublicSiteConfig($workspaceSlug: String!) {
|
|
435
438
|
public {
|
|
436
439
|
siteConfig(workspaceSlug: $workspaceSlug) {
|
|
437
440
|
id
|
|
@@ -447,7 +450,7 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
|
447
450
|
}
|
|
448
451
|
}
|
|
449
452
|
}
|
|
450
|
-
}
|
|
453
|
+
}`);
|
|
451
454
|
|
|
452
455
|
// src/data/settings-client.ts
|
|
453
456
|
async function fetchSiteConfig(config, options = {}) {
|
|
@@ -1111,4 +1114,4 @@ async function verifyCmssyWebhook(options) {
|
|
|
1111
1114
|
return parsed;
|
|
1112
1115
|
}
|
|
1113
1116
|
|
|
1114
|
-
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_EDIT_TOKEN_HEADER, CMSSY_LOCALE_HEADER, CMSSY_RATE_LIMIT_WINDOW_MS, CMSSY_RETRY_MODES, CMSSY_SECRET_QUERY_PARAM, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, SHORTCUT_ACTIONS, applyCmssyCsp, blocksToMeta, blocksToSchemas, buildBlockManifest, createCmssyClient, defineCmssyConfig, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, isTransientRequestError, isVerifiedEditUrl, layoutRegionsToBridge, localizeHref, mediaAlt, mediaDuration, mediaType, mediaUrl, mediaUrls, mintCmssyEditToken, normalizeOrigin, parseEditorMessage, postToEditor, propsToSchema, registryToManifestBlocks, resolveCmssyLocale, resolveEditorOrigin, verifyCmssyEditToken, verifyCmssyWebhook };
|
|
1117
|
+
export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_EDIT_TOKEN_HEADER, CMSSY_LOCALE_HEADER, CMSSY_RATE_LIMIT_WINDOW_MS, CMSSY_RETRY_MODES, CMSSY_SECRET_QUERY_PARAM, CmssyRequestError, CmssyWebhookError, DEFAULT_CMSSY_API_URL, DEFAULT_CMSSY_EDITOR_ORIGINS, PROTOCOL_VERSION, SHORTCUT_ACTIONS, applyCmssyCsp, blocksToMeta, blocksToSchemas, buildBlockManifest, createCmssyClient, defineCmssyConfig, defineCmssyLayout, fields, graphqlRequest, isProtocolCompatible, isTransientRequestError, isVerifiedEditUrl, layoutRegionsToBridge, localizeHref, mediaAlt, mediaDuration, mediaType, mediaUrl, mediaUrls, mintCmssyEditToken, normalizeOrigin, parseEditorMessage, postToEditor, propsToSchema, registryToManifestBlocks, resolveCmssyLocale, resolveEditorOrigin, typedOperation, verifyCmssyEditToken, verifyCmssyWebhook };
|
package/dist/internal/locale.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(document) {
|
|
137
|
+
if (typeof document === "string") return document;
|
|
138
|
+
if (!document || typeof document !== "object") {
|
|
139
|
+
throw new TypeError(
|
|
140
|
+
"cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
const loc = document.loc;
|
|
144
|
+
if (typeof loc?.source?.body === "string") return loc.source.body;
|
|
145
|
+
if (document.kind === "Document") {
|
|
146
|
+
const printed = printDocumentNode(document);
|
|
147
|
+
if (printed.trim()) return printed;
|
|
148
|
+
}
|
|
149
|
+
const asString = String(document);
|
|
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
|
|
@@ -52,7 +203,7 @@ function resolveRetryPolicy(retry) {
|
|
|
52
203
|
throw new Error(
|
|
53
204
|
`cmssy: unknown retry mode "${retry}" - use ${Object.keys(
|
|
54
205
|
CMSSY_RETRY_MODES
|
|
55
|
-
).map((
|
|
206
|
+
).map((name2) => `"${name2}"`).join(" or ")}, false, or a retry policy object`
|
|
56
207
|
);
|
|
57
208
|
}
|
|
58
209
|
return mode;
|
|
@@ -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,
|
|
@@ -210,7 +361,7 @@ async function graphqlRequest(config, query, variables, options = {}, label = "r
|
|
|
210
361
|
label
|
|
211
362
|
});
|
|
212
363
|
}
|
|
213
|
-
var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
364
|
+
var SITE_CONFIG_QUERY = typedOperation(`query PublicSiteConfig($workspaceSlug: String!) {
|
|
214
365
|
public {
|
|
215
366
|
siteConfig(workspaceSlug: $workspaceSlug) {
|
|
216
367
|
id
|
|
@@ -226,7 +377,7 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
|
226
377
|
}
|
|
227
378
|
}
|
|
228
379
|
}
|
|
229
|
-
}
|
|
380
|
+
}`);
|
|
230
381
|
|
|
231
382
|
// src/data/settings-client.ts
|
|
232
383
|
var workspaceIdCache = /* @__PURE__ */ new Map();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CMSSY_LOCALE_HEADER,
|
|
1
|
+
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';
|
|
2
2
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
3
3
|
import '../content-client-DhcHP8ln.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { C as CMSSY_LOCALE_HEADER,
|
|
1
|
+
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-BGUsgy8p.js';
|
|
2
2
|
export { CmssySiteLocales } from '@cmssy/types';
|
|
3
3
|
import '../content-client-DhcHP8ln.js';
|
|
4
4
|
|