@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/preflight.cjs
CHANGED
|
@@ -1,5 +1,156 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// src/data/document.ts
|
|
4
|
+
function typedOperation(text) {
|
|
5
|
+
return text;
|
|
6
|
+
}
|
|
7
|
+
function isNode(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && typeof value.kind === "string";
|
|
9
|
+
}
|
|
10
|
+
function name(node) {
|
|
11
|
+
return isNode(node) ? String(node.value ?? "") : "";
|
|
12
|
+
}
|
|
13
|
+
function printValue(node) {
|
|
14
|
+
if (!isNode(node)) return "null";
|
|
15
|
+
const value = node.value;
|
|
16
|
+
switch (node.kind) {
|
|
17
|
+
case "Variable":
|
|
18
|
+
return `$${name(node.name)}`;
|
|
19
|
+
case "IntValue":
|
|
20
|
+
case "FloatValue":
|
|
21
|
+
case "BooleanValue":
|
|
22
|
+
return String(value);
|
|
23
|
+
case "StringValue":
|
|
24
|
+
return node.block ? `"""
|
|
25
|
+
${String(value)}
|
|
26
|
+
"""` : JSON.stringify(String(value));
|
|
27
|
+
case "EnumValue":
|
|
28
|
+
return String(value);
|
|
29
|
+
case "NullValue":
|
|
30
|
+
return "null";
|
|
31
|
+
case "ListValue":
|
|
32
|
+
return `[${(node.values ?? []).map(printValue).join(", ")}]`;
|
|
33
|
+
case "ObjectValue":
|
|
34
|
+
return `{${(node.fields ?? []).map(
|
|
35
|
+
(field) => `${name(field.name)}: ${printValue(
|
|
36
|
+
field.value
|
|
37
|
+
)}`
|
|
38
|
+
).join(", ")}}`;
|
|
39
|
+
default:
|
|
40
|
+
return "null";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function printType(node) {
|
|
44
|
+
if (!isNode(node)) return "";
|
|
45
|
+
switch (node.kind) {
|
|
46
|
+
case "NonNullType":
|
|
47
|
+
return `${printType(node.type)}!`;
|
|
48
|
+
case "ListType":
|
|
49
|
+
return `[${printType(node.type)}]`;
|
|
50
|
+
default:
|
|
51
|
+
return name(node.name);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function printArguments(node) {
|
|
55
|
+
const args = node.arguments ?? [];
|
|
56
|
+
if (args.length === 0) return "";
|
|
57
|
+
return `(${args.map(
|
|
58
|
+
(arg) => `${name(arg.name)}: ${printValue(
|
|
59
|
+
arg.value
|
|
60
|
+
)}`
|
|
61
|
+
).join(", ")})`;
|
|
62
|
+
}
|
|
63
|
+
function printDirectives(node) {
|
|
64
|
+
const directives = node.directives ?? [];
|
|
65
|
+
if (directives.length === 0) return "";
|
|
66
|
+
return ` ${directives.map(
|
|
67
|
+
(directive) => `@${name(directive.name)}${printArguments(directive)}`
|
|
68
|
+
).join(" ")}`;
|
|
69
|
+
}
|
|
70
|
+
function printSelectionSet(node, depth) {
|
|
71
|
+
if (!isNode(node)) return "";
|
|
72
|
+
const selections = node.selections ?? [];
|
|
73
|
+
if (selections.length === 0) return "";
|
|
74
|
+
const pad = " ".repeat(depth + 1);
|
|
75
|
+
const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
|
|
76
|
+
return ` {
|
|
77
|
+
${body}
|
|
78
|
+
${" ".repeat(depth)}}`;
|
|
79
|
+
}
|
|
80
|
+
function printSelection(node, depth) {
|
|
81
|
+
if (node.kind === "FragmentSpread") {
|
|
82
|
+
return `...${name(node.name)}${printDirectives(node)}`;
|
|
83
|
+
}
|
|
84
|
+
if (node.kind === "InlineFragment") {
|
|
85
|
+
const condition = node.typeCondition;
|
|
86
|
+
const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
|
|
87
|
+
return `...${on}${printDirectives(node)}${printSelectionSet(
|
|
88
|
+
node.selectionSet,
|
|
89
|
+
depth
|
|
90
|
+
)}`;
|
|
91
|
+
}
|
|
92
|
+
const alias = node.alias;
|
|
93
|
+
const prefix = isNode(alias) ? `${name(alias)}: ` : "";
|
|
94
|
+
return `${prefix}${name(node.name)}${printArguments(
|
|
95
|
+
node
|
|
96
|
+
)}${printDirectives(node)}${printSelectionSet(
|
|
97
|
+
node.selectionSet,
|
|
98
|
+
depth
|
|
99
|
+
)}`;
|
|
100
|
+
}
|
|
101
|
+
function printVariableDefinitions(node) {
|
|
102
|
+
const definitions = node.variableDefinitions ?? [];
|
|
103
|
+
if (definitions.length === 0) return "";
|
|
104
|
+
return `(${definitions.map((definition) => {
|
|
105
|
+
const variable = definition.variable;
|
|
106
|
+
const declared = `$${name(
|
|
107
|
+
isNode(variable) ? variable.name : void 0
|
|
108
|
+
)}: ${printType(definition.type)}`;
|
|
109
|
+
const defaultValue = definition.defaultValue;
|
|
110
|
+
return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
|
|
111
|
+
}).join(", ")})`;
|
|
112
|
+
}
|
|
113
|
+
function printDefinition(node) {
|
|
114
|
+
if (node.kind === "FragmentDefinition") {
|
|
115
|
+
const condition = node.typeCondition;
|
|
116
|
+
const on = isNode(condition) ? name(condition.name) : "";
|
|
117
|
+
return `fragment ${name(node.name)} on ${on}${printDirectives(
|
|
118
|
+
node
|
|
119
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
120
|
+
}
|
|
121
|
+
const operation = String(
|
|
122
|
+
node.operation ?? "query"
|
|
123
|
+
);
|
|
124
|
+
const operationName = name(node.name);
|
|
125
|
+
const head = operationName ? `${operation} ${operationName}` : operation;
|
|
126
|
+
return `${head}${printVariableDefinitions(node)}${printDirectives(
|
|
127
|
+
node
|
|
128
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
129
|
+
}
|
|
130
|
+
function printDocumentNode(node) {
|
|
131
|
+
const definitions = node.definitions ?? [];
|
|
132
|
+
return definitions.map(printDefinition).join("\n\n");
|
|
133
|
+
}
|
|
134
|
+
function documentText(document) {
|
|
135
|
+
if (typeof document === "string") return document;
|
|
136
|
+
if (!document || typeof document !== "object") {
|
|
137
|
+
throw new TypeError(
|
|
138
|
+
"cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
const loc = document.loc;
|
|
142
|
+
if (typeof loc?.source?.body === "string") return loc.source.body;
|
|
143
|
+
if (document.kind === "Document") {
|
|
144
|
+
const printed = printDocumentNode(document);
|
|
145
|
+
if (printed.trim()) return printed;
|
|
146
|
+
}
|
|
147
|
+
const asString = String(document);
|
|
148
|
+
if (asString && asString !== "[object Object]") return asString;
|
|
149
|
+
throw new TypeError(
|
|
150
|
+
"cmssy: could not read the query text off the given document"
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
3
154
|
// src/content/content-client.ts
|
|
4
155
|
var DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
|
|
5
156
|
function resolveApiUrl(apiUrl) {
|
|
@@ -95,10 +246,10 @@ async function collectEditDiagnostics(input) {
|
|
|
95
246
|
return { workspace, checks };
|
|
96
247
|
}
|
|
97
248
|
async function diagnoseSecret(preflight, providedSecret) {
|
|
98
|
-
const
|
|
249
|
+
const name2 = "draft secret";
|
|
99
250
|
if (!providedSecret?.trim()) {
|
|
100
251
|
return {
|
|
101
|
-
name,
|
|
252
|
+
name: name2,
|
|
102
253
|
status: "fail",
|
|
103
254
|
message: "the request carried no cmssySecret - a bare cmssyEdit=1 is never trusted",
|
|
104
255
|
fix: "open the page from the cmssy editor, which appends the cmssySecret itself"
|
|
@@ -107,7 +258,7 @@ async function diagnoseSecret(preflight, providedSecret) {
|
|
|
107
258
|
const platform = await checkDraftSecret(preflight);
|
|
108
259
|
if (platform.status === "fail") {
|
|
109
260
|
return {
|
|
110
|
-
name,
|
|
261
|
+
name: name2,
|
|
111
262
|
status: "fail",
|
|
112
263
|
message: `the provided cmssySecret does not match CMSSY_DRAFT_SECRET, and ${platform.message}`,
|
|
113
264
|
...platform.fix ? { fix: platform.fix } : {}
|
|
@@ -115,14 +266,14 @@ async function diagnoseSecret(preflight, providedSecret) {
|
|
|
115
266
|
}
|
|
116
267
|
if (platform.status === "ok") {
|
|
117
268
|
return {
|
|
118
|
-
name,
|
|
269
|
+
name: name2,
|
|
119
270
|
status: "fail",
|
|
120
271
|
message: "CMSSY_DRAFT_SECRET matches this workspace, but the cmssySecret sent with the request does not match it",
|
|
121
272
|
fix: "reload the editor so it opens the preview with the current secret"
|
|
122
273
|
};
|
|
123
274
|
}
|
|
124
275
|
return {
|
|
125
|
-
name,
|
|
276
|
+
name: name2,
|
|
126
277
|
status: "unknown",
|
|
127
278
|
message: `could not verify against the platform (${platform.message}); the provided cmssySecret failed local verification against CMSSY_DRAFT_SECRET`,
|
|
128
279
|
fix: `make sure CMSSY_DRAFT_SECRET matches Settings \u2192 Headless, then reload the editor`
|
|
@@ -171,19 +322,19 @@ function renderEditDiagnosticsDocument(diagnostics) {
|
|
|
171
322
|
var CMSSY_ADMIN_ORIGIN = "https://www.cmssy.io";
|
|
172
323
|
var ALLOWED_FRAME_HOSTS = ["cmssy.io", "www.cmssy.io"];
|
|
173
324
|
var SETTINGS_PATH = "Settings \u2192 Headless";
|
|
174
|
-
var PREFLIGHT_SITE_CONFIG_QUERY = `query PreflightSiteConfig($workspaceSlug: String!) {
|
|
325
|
+
var PREFLIGHT_SITE_CONFIG_QUERY = typedOperation(`query PreflightSiteConfig($workspaceSlug: String!) {
|
|
175
326
|
public {
|
|
176
327
|
siteConfig(workspaceSlug: $workspaceSlug) {
|
|
177
328
|
previewUrl
|
|
178
329
|
publicSiteUrl
|
|
179
330
|
}
|
|
180
331
|
}
|
|
181
|
-
}
|
|
182
|
-
var DRAFT_SECRET_VALID_QUERY = `query PreflightDraftSecretValid($workspaceSlug: String!, $secret: String!) {
|
|
332
|
+
}`);
|
|
333
|
+
var DRAFT_SECRET_VALID_QUERY = typedOperation(`query PreflightDraftSecretValid($workspaceSlug: String!, $secret: String!) {
|
|
183
334
|
public {
|
|
184
335
|
draftSecretValid(workspaceSlug: $workspaceSlug, secret: $secret)
|
|
185
336
|
}
|
|
186
|
-
}
|
|
337
|
+
}`);
|
|
187
338
|
async function postPreflightQuery(config, query, variables) {
|
|
188
339
|
const doFetch = config.fetch ?? globalThis.fetch;
|
|
189
340
|
if (typeof doFetch !== "function") {
|
|
@@ -198,7 +349,7 @@ async function postPreflightQuery(config, query, variables) {
|
|
|
198
349
|
response = await doFetch(url, {
|
|
199
350
|
method: "POST",
|
|
200
351
|
headers: { "content-type": "application/json" },
|
|
201
|
-
body: JSON.stringify({ query, variables })
|
|
352
|
+
body: JSON.stringify({ query: documentText(query), variables })
|
|
202
353
|
});
|
|
203
354
|
} catch (error) {
|
|
204
355
|
return { kind: "network", error };
|
|
@@ -234,9 +385,11 @@ function isNotFound(errors, httpStatus) {
|
|
|
234
385
|
}
|
|
235
386
|
async function checkWorkspaceReachable(config) {
|
|
236
387
|
const workspace = `${config.org}/${config.workspaceSlug}`;
|
|
237
|
-
const outcome = await postPreflightQuery(
|
|
238
|
-
|
|
239
|
-
|
|
388
|
+
const outcome = await postPreflightQuery(
|
|
389
|
+
config,
|
|
390
|
+
PREFLIGHT_SITE_CONFIG_QUERY,
|
|
391
|
+
{ workspaceSlug: config.workspaceSlug }
|
|
392
|
+
);
|
|
240
393
|
if (outcome.kind === "network") {
|
|
241
394
|
return {
|
|
242
395
|
status: "fail",
|
|
@@ -301,10 +454,11 @@ async function checkDraftSecret(config) {
|
|
|
301
454
|
fix: `copy the draft secret from ${SETTINGS_PATH}`
|
|
302
455
|
};
|
|
303
456
|
}
|
|
304
|
-
const outcome = await postPreflightQuery(
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
457
|
+
const outcome = await postPreflightQuery(
|
|
458
|
+
config,
|
|
459
|
+
DRAFT_SECRET_VALID_QUERY,
|
|
460
|
+
{ workspaceSlug: config.workspaceSlug, secret }
|
|
461
|
+
);
|
|
308
462
|
if (outcome.kind === "network") {
|
|
309
463
|
return {
|
|
310
464
|
status: "unknown",
|
package/dist/preflight.js
CHANGED
|
@@ -1,3 +1,154 @@
|
|
|
1
|
+
// src/data/document.ts
|
|
2
|
+
function typedOperation(text) {
|
|
3
|
+
return text;
|
|
4
|
+
}
|
|
5
|
+
function isNode(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && typeof value.kind === "string";
|
|
7
|
+
}
|
|
8
|
+
function name(node) {
|
|
9
|
+
return isNode(node) ? String(node.value ?? "") : "";
|
|
10
|
+
}
|
|
11
|
+
function printValue(node) {
|
|
12
|
+
if (!isNode(node)) return "null";
|
|
13
|
+
const value = node.value;
|
|
14
|
+
switch (node.kind) {
|
|
15
|
+
case "Variable":
|
|
16
|
+
return `$${name(node.name)}`;
|
|
17
|
+
case "IntValue":
|
|
18
|
+
case "FloatValue":
|
|
19
|
+
case "BooleanValue":
|
|
20
|
+
return String(value);
|
|
21
|
+
case "StringValue":
|
|
22
|
+
return node.block ? `"""
|
|
23
|
+
${String(value)}
|
|
24
|
+
"""` : JSON.stringify(String(value));
|
|
25
|
+
case "EnumValue":
|
|
26
|
+
return String(value);
|
|
27
|
+
case "NullValue":
|
|
28
|
+
return "null";
|
|
29
|
+
case "ListValue":
|
|
30
|
+
return `[${(node.values ?? []).map(printValue).join(", ")}]`;
|
|
31
|
+
case "ObjectValue":
|
|
32
|
+
return `{${(node.fields ?? []).map(
|
|
33
|
+
(field) => `${name(field.name)}: ${printValue(
|
|
34
|
+
field.value
|
|
35
|
+
)}`
|
|
36
|
+
).join(", ")}}`;
|
|
37
|
+
default:
|
|
38
|
+
return "null";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function printType(node) {
|
|
42
|
+
if (!isNode(node)) return "";
|
|
43
|
+
switch (node.kind) {
|
|
44
|
+
case "NonNullType":
|
|
45
|
+
return `${printType(node.type)}!`;
|
|
46
|
+
case "ListType":
|
|
47
|
+
return `[${printType(node.type)}]`;
|
|
48
|
+
default:
|
|
49
|
+
return name(node.name);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function printArguments(node) {
|
|
53
|
+
const args = node.arguments ?? [];
|
|
54
|
+
if (args.length === 0) return "";
|
|
55
|
+
return `(${args.map(
|
|
56
|
+
(arg) => `${name(arg.name)}: ${printValue(
|
|
57
|
+
arg.value
|
|
58
|
+
)}`
|
|
59
|
+
).join(", ")})`;
|
|
60
|
+
}
|
|
61
|
+
function printDirectives(node) {
|
|
62
|
+
const directives = node.directives ?? [];
|
|
63
|
+
if (directives.length === 0) return "";
|
|
64
|
+
return ` ${directives.map(
|
|
65
|
+
(directive) => `@${name(directive.name)}${printArguments(directive)}`
|
|
66
|
+
).join(" ")}`;
|
|
67
|
+
}
|
|
68
|
+
function printSelectionSet(node, depth) {
|
|
69
|
+
if (!isNode(node)) return "";
|
|
70
|
+
const selections = node.selections ?? [];
|
|
71
|
+
if (selections.length === 0) return "";
|
|
72
|
+
const pad = " ".repeat(depth + 1);
|
|
73
|
+
const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
|
|
74
|
+
return ` {
|
|
75
|
+
${body}
|
|
76
|
+
${" ".repeat(depth)}}`;
|
|
77
|
+
}
|
|
78
|
+
function printSelection(node, depth) {
|
|
79
|
+
if (node.kind === "FragmentSpread") {
|
|
80
|
+
return `...${name(node.name)}${printDirectives(node)}`;
|
|
81
|
+
}
|
|
82
|
+
if (node.kind === "InlineFragment") {
|
|
83
|
+
const condition = node.typeCondition;
|
|
84
|
+
const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
|
|
85
|
+
return `...${on}${printDirectives(node)}${printSelectionSet(
|
|
86
|
+
node.selectionSet,
|
|
87
|
+
depth
|
|
88
|
+
)}`;
|
|
89
|
+
}
|
|
90
|
+
const alias = node.alias;
|
|
91
|
+
const prefix = isNode(alias) ? `${name(alias)}: ` : "";
|
|
92
|
+
return `${prefix}${name(node.name)}${printArguments(
|
|
93
|
+
node
|
|
94
|
+
)}${printDirectives(node)}${printSelectionSet(
|
|
95
|
+
node.selectionSet,
|
|
96
|
+
depth
|
|
97
|
+
)}`;
|
|
98
|
+
}
|
|
99
|
+
function printVariableDefinitions(node) {
|
|
100
|
+
const definitions = node.variableDefinitions ?? [];
|
|
101
|
+
if (definitions.length === 0) return "";
|
|
102
|
+
return `(${definitions.map((definition) => {
|
|
103
|
+
const variable = definition.variable;
|
|
104
|
+
const declared = `$${name(
|
|
105
|
+
isNode(variable) ? variable.name : void 0
|
|
106
|
+
)}: ${printType(definition.type)}`;
|
|
107
|
+
const defaultValue = definition.defaultValue;
|
|
108
|
+
return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
|
|
109
|
+
}).join(", ")})`;
|
|
110
|
+
}
|
|
111
|
+
function printDefinition(node) {
|
|
112
|
+
if (node.kind === "FragmentDefinition") {
|
|
113
|
+
const condition = node.typeCondition;
|
|
114
|
+
const on = isNode(condition) ? name(condition.name) : "";
|
|
115
|
+
return `fragment ${name(node.name)} on ${on}${printDirectives(
|
|
116
|
+
node
|
|
117
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
118
|
+
}
|
|
119
|
+
const operation = String(
|
|
120
|
+
node.operation ?? "query"
|
|
121
|
+
);
|
|
122
|
+
const operationName = name(node.name);
|
|
123
|
+
const head = operationName ? `${operation} ${operationName}` : operation;
|
|
124
|
+
return `${head}${printVariableDefinitions(node)}${printDirectives(
|
|
125
|
+
node
|
|
126
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
127
|
+
}
|
|
128
|
+
function printDocumentNode(node) {
|
|
129
|
+
const definitions = node.definitions ?? [];
|
|
130
|
+
return definitions.map(printDefinition).join("\n\n");
|
|
131
|
+
}
|
|
132
|
+
function documentText(document) {
|
|
133
|
+
if (typeof document === "string") return document;
|
|
134
|
+
if (!document || typeof document !== "object") {
|
|
135
|
+
throw new TypeError(
|
|
136
|
+
"cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
const loc = document.loc;
|
|
140
|
+
if (typeof loc?.source?.body === "string") return loc.source.body;
|
|
141
|
+
if (document.kind === "Document") {
|
|
142
|
+
const printed = printDocumentNode(document);
|
|
143
|
+
if (printed.trim()) return printed;
|
|
144
|
+
}
|
|
145
|
+
const asString = String(document);
|
|
146
|
+
if (asString && asString !== "[object Object]") return asString;
|
|
147
|
+
throw new TypeError(
|
|
148
|
+
"cmssy: could not read the query text off the given document"
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
1
152
|
// src/content/content-client.ts
|
|
2
153
|
var DEFAULT_CMSSY_API_URL = "https://api.cmssy.io/graphql";
|
|
3
154
|
function resolveApiUrl(apiUrl) {
|
|
@@ -93,10 +244,10 @@ async function collectEditDiagnostics(input) {
|
|
|
93
244
|
return { workspace, checks };
|
|
94
245
|
}
|
|
95
246
|
async function diagnoseSecret(preflight, providedSecret) {
|
|
96
|
-
const
|
|
247
|
+
const name2 = "draft secret";
|
|
97
248
|
if (!providedSecret?.trim()) {
|
|
98
249
|
return {
|
|
99
|
-
name,
|
|
250
|
+
name: name2,
|
|
100
251
|
status: "fail",
|
|
101
252
|
message: "the request carried no cmssySecret - a bare cmssyEdit=1 is never trusted",
|
|
102
253
|
fix: "open the page from the cmssy editor, which appends the cmssySecret itself"
|
|
@@ -105,7 +256,7 @@ async function diagnoseSecret(preflight, providedSecret) {
|
|
|
105
256
|
const platform = await checkDraftSecret(preflight);
|
|
106
257
|
if (platform.status === "fail") {
|
|
107
258
|
return {
|
|
108
|
-
name,
|
|
259
|
+
name: name2,
|
|
109
260
|
status: "fail",
|
|
110
261
|
message: `the provided cmssySecret does not match CMSSY_DRAFT_SECRET, and ${platform.message}`,
|
|
111
262
|
...platform.fix ? { fix: platform.fix } : {}
|
|
@@ -113,14 +264,14 @@ async function diagnoseSecret(preflight, providedSecret) {
|
|
|
113
264
|
}
|
|
114
265
|
if (platform.status === "ok") {
|
|
115
266
|
return {
|
|
116
|
-
name,
|
|
267
|
+
name: name2,
|
|
117
268
|
status: "fail",
|
|
118
269
|
message: "CMSSY_DRAFT_SECRET matches this workspace, but the cmssySecret sent with the request does not match it",
|
|
119
270
|
fix: "reload the editor so it opens the preview with the current secret"
|
|
120
271
|
};
|
|
121
272
|
}
|
|
122
273
|
return {
|
|
123
|
-
name,
|
|
274
|
+
name: name2,
|
|
124
275
|
status: "unknown",
|
|
125
276
|
message: `could not verify against the platform (${platform.message}); the provided cmssySecret failed local verification against CMSSY_DRAFT_SECRET`,
|
|
126
277
|
fix: `make sure CMSSY_DRAFT_SECRET matches Settings \u2192 Headless, then reload the editor`
|
|
@@ -169,19 +320,19 @@ function renderEditDiagnosticsDocument(diagnostics) {
|
|
|
169
320
|
var CMSSY_ADMIN_ORIGIN = "https://www.cmssy.io";
|
|
170
321
|
var ALLOWED_FRAME_HOSTS = ["cmssy.io", "www.cmssy.io"];
|
|
171
322
|
var SETTINGS_PATH = "Settings \u2192 Headless";
|
|
172
|
-
var PREFLIGHT_SITE_CONFIG_QUERY = `query PreflightSiteConfig($workspaceSlug: String!) {
|
|
323
|
+
var PREFLIGHT_SITE_CONFIG_QUERY = typedOperation(`query PreflightSiteConfig($workspaceSlug: String!) {
|
|
173
324
|
public {
|
|
174
325
|
siteConfig(workspaceSlug: $workspaceSlug) {
|
|
175
326
|
previewUrl
|
|
176
327
|
publicSiteUrl
|
|
177
328
|
}
|
|
178
329
|
}
|
|
179
|
-
}
|
|
180
|
-
var DRAFT_SECRET_VALID_QUERY = `query PreflightDraftSecretValid($workspaceSlug: String!, $secret: String!) {
|
|
330
|
+
}`);
|
|
331
|
+
var DRAFT_SECRET_VALID_QUERY = typedOperation(`query PreflightDraftSecretValid($workspaceSlug: String!, $secret: String!) {
|
|
181
332
|
public {
|
|
182
333
|
draftSecretValid(workspaceSlug: $workspaceSlug, secret: $secret)
|
|
183
334
|
}
|
|
184
|
-
}
|
|
335
|
+
}`);
|
|
185
336
|
async function postPreflightQuery(config, query, variables) {
|
|
186
337
|
const doFetch = config.fetch ?? globalThis.fetch;
|
|
187
338
|
if (typeof doFetch !== "function") {
|
|
@@ -196,7 +347,7 @@ async function postPreflightQuery(config, query, variables) {
|
|
|
196
347
|
response = await doFetch(url, {
|
|
197
348
|
method: "POST",
|
|
198
349
|
headers: { "content-type": "application/json" },
|
|
199
|
-
body: JSON.stringify({ query, variables })
|
|
350
|
+
body: JSON.stringify({ query: documentText(query), variables })
|
|
200
351
|
});
|
|
201
352
|
} catch (error) {
|
|
202
353
|
return { kind: "network", error };
|
|
@@ -232,9 +383,11 @@ function isNotFound(errors, httpStatus) {
|
|
|
232
383
|
}
|
|
233
384
|
async function checkWorkspaceReachable(config) {
|
|
234
385
|
const workspace = `${config.org}/${config.workspaceSlug}`;
|
|
235
|
-
const outcome = await postPreflightQuery(
|
|
236
|
-
|
|
237
|
-
|
|
386
|
+
const outcome = await postPreflightQuery(
|
|
387
|
+
config,
|
|
388
|
+
PREFLIGHT_SITE_CONFIG_QUERY,
|
|
389
|
+
{ workspaceSlug: config.workspaceSlug }
|
|
390
|
+
);
|
|
238
391
|
if (outcome.kind === "network") {
|
|
239
392
|
return {
|
|
240
393
|
status: "fail",
|
|
@@ -299,10 +452,11 @@ async function checkDraftSecret(config) {
|
|
|
299
452
|
fix: `copy the draft secret from ${SETTINGS_PATH}`
|
|
300
453
|
};
|
|
301
454
|
}
|
|
302
|
-
const outcome = await postPreflightQuery(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
455
|
+
const outcome = await postPreflightQuery(
|
|
456
|
+
config,
|
|
457
|
+
DRAFT_SECRET_VALID_QUERY,
|
|
458
|
+
{ workspaceSlug: config.workspaceSlug, secret }
|
|
459
|
+
);
|
|
306
460
|
if (outcome.kind === "network") {
|
|
307
461
|
return {
|
|
308
462
|
status: "unknown",
|
package/dist/testing.cjs
CHANGED
package/dist/testing.js
CHANGED