@cmssy/core 19.1.1 → 19.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/{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 +205 -188
- package/dist/internal.d.cts +66 -10
- package/dist/internal.d.ts +66 -10
- package/dist/internal.js +205 -188
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LayoutRegion, BlockPropsSchema, InferBlockContent, CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
|
|
2
|
-
import { G as GraphqlRequestOptions } from './locale-
|
|
2
|
+
import { b as CmssyOperationInput, G as GraphqlRequestOptions } from './locale-BGUsgy8p.js';
|
|
3
3
|
|
|
4
4
|
interface CmssyLayout<R extends readonly LayoutRegion[] = readonly LayoutRegion[]> {
|
|
5
5
|
readonly regions: R;
|
|
@@ -41,19 +41,17 @@ type CmssyEnvConfig<L extends CmssyLayout = CmssyLayout> = Omit<CmssyConfig<L>,
|
|
|
41
41
|
};
|
|
42
42
|
declare function defineCmssyConfig<L extends CmssyLayout = CmssyLayout>(config: CmssyEnvConfig<L>): CmssyConfig<L>;
|
|
43
43
|
|
|
44
|
-
interface CmssyTypedDocument<Result, Variables> {
|
|
45
|
-
__apiType?: (variables: Variables) => Result;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
44
|
interface QueryScopedOptions extends Omit<GraphqlRequestOptions, "public"> {
|
|
49
45
|
workspaceId?: string;
|
|
50
46
|
}
|
|
47
|
+
type ScopedVariables<Variables> = "workspaceId" extends keyof Variables ? Omit<Variables, "workspaceId"> & {
|
|
48
|
+
workspaceId?: string | null;
|
|
49
|
+
} : Variables;
|
|
50
|
+
type VariablesParameter<Variables, Options> = Record<string, never> extends Variables ? [variables?: Variables, options?: Options] : [variables: Variables, options?: Options];
|
|
51
51
|
interface CmssyClient {
|
|
52
52
|
readonly config: CmssyClientConfig;
|
|
53
|
-
query<Result, Variables
|
|
54
|
-
|
|
55
|
-
queryScoped<Result, Variables>(document: CmssyTypedDocument<Result, Variables>, variables: Omit<Variables, "workspaceId">, options?: QueryScopedOptions): Promise<Result>;
|
|
56
|
-
queryScoped<T = unknown>(document: string, variables?: Record<string, unknown>, options?: QueryScopedOptions): Promise<T>;
|
|
53
|
+
query<Result = unknown, Variables = Record<string, unknown>>(document: CmssyOperationInput<Result, Variables>, ...rest: VariablesParameter<Variables, GraphqlRequestOptions>): Promise<Result>;
|
|
54
|
+
queryScoped<Result = unknown, Variables = Record<string, unknown>>(document: CmssyOperationInput<Result, Variables>, ...rest: VariablesParameter<ScopedVariables<Variables>, QueryScopedOptions>): Promise<Result>;
|
|
57
55
|
resolveWorkspaceId(options?: GraphqlRequestOptions): Promise<string>;
|
|
58
56
|
}
|
|
59
57
|
declare function createCmssyClient(input: CmssyClientConfig): CmssyClient;
|
|
@@ -194,4 +192,4 @@ declare function toCspOrigin(origin: string): string;
|
|
|
194
192
|
declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
|
|
195
193
|
declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
|
|
196
194
|
|
|
197
|
-
export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E,
|
|
195
|
+
export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E, resolveEditorOrigin as F, cmssyCspHeaders as G, isDevelopment as H, type InvisibleBlock as I, layoutRegionIds as J, resolveInitialTarget as K, toCspOrigin as L, PROTOCOL_VERSION as P, type QueryScopedOptions as Q, type ReadyMessage as R, SHORTCUT_ACTIONS as S, type VariablesParameter as V, type CmssyClient as a, type CmssyConfig as b, type CmssyCspOptions as c, type CmssyEnvConfig as d, type CmssyLayout as e, type CmssyRegion as f, type CmssyRegionOf as g, type CmssyRegionSettings as h, type CmssyRegionSettingsOf as i, type InvisibleBlocksMessage as j, type ParentReadyMessage as k, type PatchMessage as l, type PostTarget as m, type ScopedVariables as n, type SelectMessage as o, type ShortcutAction as p, type ShortcutMessage as q, type ViewportMessage as r, applyCmssyCsp as s, createCmssyClient as t, defineCmssyConfig as u, defineCmssyLayout as v, isProtocolCompatible as w, normalizeOrigin as x, parseEditorMessage as y, postToEditor as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LayoutRegion, BlockPropsSchema, InferBlockContent, CmssyClientConfig, BlockRect, BlockSchema, BlockMeta } from '@cmssy/types';
|
|
2
|
-
import { G as GraphqlRequestOptions } from './locale-
|
|
2
|
+
import { b as CmssyOperationInput, G as GraphqlRequestOptions } from './locale-DLGQgiu5.cjs';
|
|
3
3
|
|
|
4
4
|
interface CmssyLayout<R extends readonly LayoutRegion[] = readonly LayoutRegion[]> {
|
|
5
5
|
readonly regions: R;
|
|
@@ -41,19 +41,17 @@ type CmssyEnvConfig<L extends CmssyLayout = CmssyLayout> = Omit<CmssyConfig<L>,
|
|
|
41
41
|
};
|
|
42
42
|
declare function defineCmssyConfig<L extends CmssyLayout = CmssyLayout>(config: CmssyEnvConfig<L>): CmssyConfig<L>;
|
|
43
43
|
|
|
44
|
-
interface CmssyTypedDocument<Result, Variables> {
|
|
45
|
-
__apiType?: (variables: Variables) => Result;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
44
|
interface QueryScopedOptions extends Omit<GraphqlRequestOptions, "public"> {
|
|
49
45
|
workspaceId?: string;
|
|
50
46
|
}
|
|
47
|
+
type ScopedVariables<Variables> = "workspaceId" extends keyof Variables ? Omit<Variables, "workspaceId"> & {
|
|
48
|
+
workspaceId?: string | null;
|
|
49
|
+
} : Variables;
|
|
50
|
+
type VariablesParameter<Variables, Options> = Record<string, never> extends Variables ? [variables?: Variables, options?: Options] : [variables: Variables, options?: Options];
|
|
51
51
|
interface CmssyClient {
|
|
52
52
|
readonly config: CmssyClientConfig;
|
|
53
|
-
query<Result, Variables
|
|
54
|
-
|
|
55
|
-
queryScoped<Result, Variables>(document: CmssyTypedDocument<Result, Variables>, variables: Omit<Variables, "workspaceId">, options?: QueryScopedOptions): Promise<Result>;
|
|
56
|
-
queryScoped<T = unknown>(document: string, variables?: Record<string, unknown>, options?: QueryScopedOptions): Promise<T>;
|
|
53
|
+
query<Result = unknown, Variables = Record<string, unknown>>(document: CmssyOperationInput<Result, Variables>, ...rest: VariablesParameter<Variables, GraphqlRequestOptions>): Promise<Result>;
|
|
54
|
+
queryScoped<Result = unknown, Variables = Record<string, unknown>>(document: CmssyOperationInput<Result, Variables>, ...rest: VariablesParameter<ScopedVariables<Variables>, QueryScopedOptions>): Promise<Result>;
|
|
57
55
|
resolveWorkspaceId(options?: GraphqlRequestOptions): Promise<string>;
|
|
58
56
|
}
|
|
59
57
|
declare function createCmssyClient(input: CmssyClientConfig): CmssyClient;
|
|
@@ -194,4 +192,4 @@ declare function toCspOrigin(origin: string): string;
|
|
|
194
192
|
declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
|
|
195
193
|
declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
|
|
196
194
|
|
|
197
|
-
export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E,
|
|
195
|
+
export { type AppToEditorMessage as A, type BoundsMessage as B, type ClickMessage as C, DEFAULT_CMSSY_EDITOR_ORIGINS as D, type EditorToAppMessage as E, resolveEditorOrigin as F, cmssyCspHeaders as G, isDevelopment as H, type InvisibleBlock as I, layoutRegionIds as J, resolveInitialTarget as K, toCspOrigin as L, PROTOCOL_VERSION as P, type QueryScopedOptions as Q, type ReadyMessage as R, SHORTCUT_ACTIONS as S, type VariablesParameter as V, type CmssyClient as a, type CmssyConfig as b, type CmssyCspOptions as c, type CmssyEnvConfig as d, type CmssyLayout as e, type CmssyRegion as f, type CmssyRegionOf as g, type CmssyRegionSettings as h, type CmssyRegionSettingsOf as i, type InvisibleBlocksMessage as j, type ParentReadyMessage as k, type PatchMessage as l, type PostTarget as m, type ScopedVariables as n, type SelectMessage as o, type ShortcutAction as p, type ShortcutMessage as q, type ViewportMessage as r, applyCmssyCsp as s, createCmssyClient as t, defineCmssyConfig as u, defineCmssyLayout as v, isProtocolCompatible as w, normalizeOrigin as x, parseEditorMessage as y, postToEditor as z };
|
package/dist/index.cjs
CHANGED
|
@@ -73,8 +73,159 @@ 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/data/document.ts
|
|
77
|
+
function typedOperation(text) {
|
|
78
|
+
return text;
|
|
79
|
+
}
|
|
80
|
+
function isNode(value) {
|
|
81
|
+
return typeof value === "object" && value !== null && typeof value.kind === "string";
|
|
82
|
+
}
|
|
83
|
+
function name(node) {
|
|
84
|
+
return isNode(node) ? String(node.value ?? "") : "";
|
|
85
|
+
}
|
|
86
|
+
function printValue(node) {
|
|
87
|
+
if (!isNode(node)) return "null";
|
|
88
|
+
const value = node.value;
|
|
89
|
+
switch (node.kind) {
|
|
90
|
+
case "Variable":
|
|
91
|
+
return `$${name(node.name)}`;
|
|
92
|
+
case "IntValue":
|
|
93
|
+
case "FloatValue":
|
|
94
|
+
case "BooleanValue":
|
|
95
|
+
return String(value);
|
|
96
|
+
case "StringValue":
|
|
97
|
+
return node.block ? `"""
|
|
98
|
+
${String(value)}
|
|
99
|
+
"""` : JSON.stringify(String(value));
|
|
100
|
+
case "EnumValue":
|
|
101
|
+
return String(value);
|
|
102
|
+
case "NullValue":
|
|
103
|
+
return "null";
|
|
104
|
+
case "ListValue":
|
|
105
|
+
return `[${(node.values ?? []).map(printValue).join(", ")}]`;
|
|
106
|
+
case "ObjectValue":
|
|
107
|
+
return `{${(node.fields ?? []).map(
|
|
108
|
+
(field) => `${name(field.name)}: ${printValue(
|
|
109
|
+
field.value
|
|
110
|
+
)}`
|
|
111
|
+
).join(", ")}}`;
|
|
112
|
+
default:
|
|
113
|
+
return "null";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function printType(node) {
|
|
117
|
+
if (!isNode(node)) return "";
|
|
118
|
+
switch (node.kind) {
|
|
119
|
+
case "NonNullType":
|
|
120
|
+
return `${printType(node.type)}!`;
|
|
121
|
+
case "ListType":
|
|
122
|
+
return `[${printType(node.type)}]`;
|
|
123
|
+
default:
|
|
124
|
+
return name(node.name);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function printArguments(node) {
|
|
128
|
+
const args = node.arguments ?? [];
|
|
129
|
+
if (args.length === 0) return "";
|
|
130
|
+
return `(${args.map(
|
|
131
|
+
(arg) => `${name(arg.name)}: ${printValue(
|
|
132
|
+
arg.value
|
|
133
|
+
)}`
|
|
134
|
+
).join(", ")})`;
|
|
135
|
+
}
|
|
136
|
+
function printDirectives(node) {
|
|
137
|
+
const directives = node.directives ?? [];
|
|
138
|
+
if (directives.length === 0) return "";
|
|
139
|
+
return ` ${directives.map(
|
|
140
|
+
(directive) => `@${name(directive.name)}${printArguments(directive)}`
|
|
141
|
+
).join(" ")}`;
|
|
142
|
+
}
|
|
143
|
+
function printSelectionSet(node, depth) {
|
|
144
|
+
if (!isNode(node)) return "";
|
|
145
|
+
const selections = node.selections ?? [];
|
|
146
|
+
if (selections.length === 0) return "";
|
|
147
|
+
const pad = " ".repeat(depth + 1);
|
|
148
|
+
const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
|
|
149
|
+
return ` {
|
|
150
|
+
${body}
|
|
151
|
+
${" ".repeat(depth)}}`;
|
|
152
|
+
}
|
|
153
|
+
function printSelection(node, depth) {
|
|
154
|
+
if (node.kind === "FragmentSpread") {
|
|
155
|
+
return `...${name(node.name)}${printDirectives(node)}`;
|
|
156
|
+
}
|
|
157
|
+
if (node.kind === "InlineFragment") {
|
|
158
|
+
const condition = node.typeCondition;
|
|
159
|
+
const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
|
|
160
|
+
return `...${on}${printDirectives(node)}${printSelectionSet(
|
|
161
|
+
node.selectionSet,
|
|
162
|
+
depth
|
|
163
|
+
)}`;
|
|
164
|
+
}
|
|
165
|
+
const alias = node.alias;
|
|
166
|
+
const prefix = isNode(alias) ? `${name(alias)}: ` : "";
|
|
167
|
+
return `${prefix}${name(node.name)}${printArguments(
|
|
168
|
+
node
|
|
169
|
+
)}${printDirectives(node)}${printSelectionSet(
|
|
170
|
+
node.selectionSet,
|
|
171
|
+
depth
|
|
172
|
+
)}`;
|
|
173
|
+
}
|
|
174
|
+
function printVariableDefinitions(node) {
|
|
175
|
+
const definitions = node.variableDefinitions ?? [];
|
|
176
|
+
if (definitions.length === 0) return "";
|
|
177
|
+
return `(${definitions.map((definition) => {
|
|
178
|
+
const variable = definition.variable;
|
|
179
|
+
const declared = `$${name(
|
|
180
|
+
isNode(variable) ? variable.name : void 0
|
|
181
|
+
)}: ${printType(definition.type)}`;
|
|
182
|
+
const defaultValue = definition.defaultValue;
|
|
183
|
+
return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
|
|
184
|
+
}).join(", ")})`;
|
|
185
|
+
}
|
|
186
|
+
function printDefinition(node) {
|
|
187
|
+
if (node.kind === "FragmentDefinition") {
|
|
188
|
+
const condition = node.typeCondition;
|
|
189
|
+
const on = isNode(condition) ? name(condition.name) : "";
|
|
190
|
+
return `fragment ${name(node.name)} on ${on}${printDirectives(
|
|
191
|
+
node
|
|
192
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
193
|
+
}
|
|
194
|
+
const operation = String(
|
|
195
|
+
node.operation ?? "query"
|
|
196
|
+
);
|
|
197
|
+
const operationName = name(node.name);
|
|
198
|
+
const head = operationName ? `${operation} ${operationName}` : operation;
|
|
199
|
+
return `${head}${printVariableDefinitions(node)}${printDirectives(
|
|
200
|
+
node
|
|
201
|
+
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
202
|
+
}
|
|
203
|
+
function printDocumentNode(node) {
|
|
204
|
+
const definitions = node.definitions ?? [];
|
|
205
|
+
return definitions.map(printDefinition).join("\n\n");
|
|
206
|
+
}
|
|
207
|
+
function documentText(document2) {
|
|
208
|
+
if (typeof document2 === "string") return document2;
|
|
209
|
+
if (!document2 || typeof document2 !== "object") {
|
|
210
|
+
throw new TypeError(
|
|
211
|
+
"cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
const loc = document2.loc;
|
|
215
|
+
if (typeof loc?.source?.body === "string") return loc.source.body;
|
|
216
|
+
if (document2.kind === "Document") {
|
|
217
|
+
const printed = printDocumentNode(document2);
|
|
218
|
+
if (printed.trim()) return printed;
|
|
219
|
+
}
|
|
220
|
+
const asString = String(document2);
|
|
221
|
+
if (asString && asString !== "[object Object]") return asString;
|
|
222
|
+
throw new TypeError(
|
|
223
|
+
"cmssy: could not read the query text off the given document"
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
76
227
|
// src/version.ts
|
|
77
|
-
var CMSSY_CORE_VERSION = "19.
|
|
228
|
+
var CMSSY_CORE_VERSION = "19.3.0" ;
|
|
78
229
|
var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
|
|
79
230
|
|
|
80
231
|
// src/data/http.ts
|
|
@@ -220,7 +371,7 @@ async function postGraphql(url, query, variables, options) {
|
|
|
220
371
|
"user-agent": CMSSY_USER_AGENT,
|
|
221
372
|
...options.headers
|
|
222
373
|
},
|
|
223
|
-
body: JSON.stringify({ query, variables }),
|
|
374
|
+
body: JSON.stringify({ query: documentText(query), variables }),
|
|
224
375
|
signal: options.signal
|
|
225
376
|
},
|
|
226
377
|
options.retry,
|
|
@@ -284,155 +435,7 @@ async function graphqlRequest(config, query, variables, options = {}, label = "r
|
|
|
284
435
|
label
|
|
285
436
|
});
|
|
286
437
|
}
|
|
287
|
-
|
|
288
|
-
// src/data/document.ts
|
|
289
|
-
function isNode(value) {
|
|
290
|
-
return typeof value === "object" && value !== null && typeof value.kind === "string";
|
|
291
|
-
}
|
|
292
|
-
function name(node) {
|
|
293
|
-
return isNode(node) ? String(node.value ?? "") : "";
|
|
294
|
-
}
|
|
295
|
-
function printValue(node) {
|
|
296
|
-
if (!isNode(node)) return "null";
|
|
297
|
-
const value = node.value;
|
|
298
|
-
switch (node.kind) {
|
|
299
|
-
case "Variable":
|
|
300
|
-
return `$${name(node.name)}`;
|
|
301
|
-
case "IntValue":
|
|
302
|
-
case "FloatValue":
|
|
303
|
-
case "BooleanValue":
|
|
304
|
-
return String(value);
|
|
305
|
-
case "StringValue":
|
|
306
|
-
return node.block ? `"""
|
|
307
|
-
${String(value)}
|
|
308
|
-
"""` : JSON.stringify(String(value));
|
|
309
|
-
case "EnumValue":
|
|
310
|
-
return String(value);
|
|
311
|
-
case "NullValue":
|
|
312
|
-
return "null";
|
|
313
|
-
case "ListValue":
|
|
314
|
-
return `[${(node.values ?? []).map(printValue).join(", ")}]`;
|
|
315
|
-
case "ObjectValue":
|
|
316
|
-
return `{${(node.fields ?? []).map(
|
|
317
|
-
(field) => `${name(field.name)}: ${printValue(
|
|
318
|
-
field.value
|
|
319
|
-
)}`
|
|
320
|
-
).join(", ")}}`;
|
|
321
|
-
default:
|
|
322
|
-
return "null";
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
function printType(node) {
|
|
326
|
-
if (!isNode(node)) return "";
|
|
327
|
-
switch (node.kind) {
|
|
328
|
-
case "NonNullType":
|
|
329
|
-
return `${printType(node.type)}!`;
|
|
330
|
-
case "ListType":
|
|
331
|
-
return `[${printType(node.type)}]`;
|
|
332
|
-
default:
|
|
333
|
-
return name(node.name);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
function printArguments(node) {
|
|
337
|
-
const args = node.arguments ?? [];
|
|
338
|
-
if (args.length === 0) return "";
|
|
339
|
-
return `(${args.map(
|
|
340
|
-
(arg) => `${name(arg.name)}: ${printValue(
|
|
341
|
-
arg.value
|
|
342
|
-
)}`
|
|
343
|
-
).join(", ")})`;
|
|
344
|
-
}
|
|
345
|
-
function printDirectives(node) {
|
|
346
|
-
const directives = node.directives ?? [];
|
|
347
|
-
if (directives.length === 0) return "";
|
|
348
|
-
return ` ${directives.map(
|
|
349
|
-
(directive) => `@${name(directive.name)}${printArguments(directive)}`
|
|
350
|
-
).join(" ")}`;
|
|
351
|
-
}
|
|
352
|
-
function printSelectionSet(node, depth) {
|
|
353
|
-
if (!isNode(node)) return "";
|
|
354
|
-
const selections = node.selections ?? [];
|
|
355
|
-
if (selections.length === 0) return "";
|
|
356
|
-
const pad = " ".repeat(depth + 1);
|
|
357
|
-
const body = selections.map((selection) => `${pad}${printSelection(selection, depth + 1)}`).join("\n");
|
|
358
|
-
return ` {
|
|
359
|
-
${body}
|
|
360
|
-
${" ".repeat(depth)}}`;
|
|
361
|
-
}
|
|
362
|
-
function printSelection(node, depth) {
|
|
363
|
-
if (node.kind === "FragmentSpread") {
|
|
364
|
-
return `...${name(node.name)}${printDirectives(node)}`;
|
|
365
|
-
}
|
|
366
|
-
if (node.kind === "InlineFragment") {
|
|
367
|
-
const condition = node.typeCondition;
|
|
368
|
-
const on = isNode(condition) ? ` on ${name(condition.name)}` : "";
|
|
369
|
-
return `...${on}${printDirectives(node)}${printSelectionSet(
|
|
370
|
-
node.selectionSet,
|
|
371
|
-
depth
|
|
372
|
-
)}`;
|
|
373
|
-
}
|
|
374
|
-
const alias = node.alias;
|
|
375
|
-
const prefix = isNode(alias) ? `${name(alias)}: ` : "";
|
|
376
|
-
return `${prefix}${name(node.name)}${printArguments(
|
|
377
|
-
node
|
|
378
|
-
)}${printDirectives(node)}${printSelectionSet(
|
|
379
|
-
node.selectionSet,
|
|
380
|
-
depth
|
|
381
|
-
)}`;
|
|
382
|
-
}
|
|
383
|
-
function printVariableDefinitions(node) {
|
|
384
|
-
const definitions = node.variableDefinitions ?? [];
|
|
385
|
-
if (definitions.length === 0) return "";
|
|
386
|
-
return `(${definitions.map((definition) => {
|
|
387
|
-
const variable = definition.variable;
|
|
388
|
-
const declared = `$${name(
|
|
389
|
-
isNode(variable) ? variable.name : void 0
|
|
390
|
-
)}: ${printType(definition.type)}`;
|
|
391
|
-
const defaultValue = definition.defaultValue;
|
|
392
|
-
return isNode(defaultValue) ? `${declared} = ${printValue(defaultValue)}` : declared;
|
|
393
|
-
}).join(", ")})`;
|
|
394
|
-
}
|
|
395
|
-
function printDefinition(node) {
|
|
396
|
-
if (node.kind === "FragmentDefinition") {
|
|
397
|
-
const condition = node.typeCondition;
|
|
398
|
-
const on = isNode(condition) ? name(condition.name) : "";
|
|
399
|
-
return `fragment ${name(node.name)} on ${on}${printDirectives(
|
|
400
|
-
node
|
|
401
|
-
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
402
|
-
}
|
|
403
|
-
const operation = String(
|
|
404
|
-
node.operation ?? "query"
|
|
405
|
-
);
|
|
406
|
-
const operationName = name(node.name);
|
|
407
|
-
const head = operationName ? `${operation} ${operationName}` : operation;
|
|
408
|
-
return `${head}${printVariableDefinitions(node)}${printDirectives(
|
|
409
|
-
node
|
|
410
|
-
)}${printSelectionSet(node.selectionSet, 0)}`;
|
|
411
|
-
}
|
|
412
|
-
function printDocumentNode(node) {
|
|
413
|
-
const definitions = node.definitions ?? [];
|
|
414
|
-
return definitions.map(printDefinition).join("\n\n");
|
|
415
|
-
}
|
|
416
|
-
function documentText(document2) {
|
|
417
|
-
if (typeof document2 === "string") return document2;
|
|
418
|
-
if (!document2 || typeof document2 !== "object") {
|
|
419
|
-
throw new TypeError(
|
|
420
|
-
"cmssy: expected a GraphQL document - a query string, a TypedDocumentString, or a TypedDocumentNode"
|
|
421
|
-
);
|
|
422
|
-
}
|
|
423
|
-
const loc = document2.loc;
|
|
424
|
-
if (typeof loc?.source?.body === "string") return loc.source.body;
|
|
425
|
-
if (document2.kind === "Document") {
|
|
426
|
-
const printed = printDocumentNode(document2);
|
|
427
|
-
if (printed.trim()) return printed;
|
|
428
|
-
}
|
|
429
|
-
const asString = String(document2);
|
|
430
|
-
if (asString && asString !== "[object Object]") return asString;
|
|
431
|
-
throw new TypeError(
|
|
432
|
-
"cmssy: could not read the query text off the given document"
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
|
-
var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
438
|
+
var SITE_CONFIG_QUERY = typedOperation(`query PublicSiteConfig($workspaceSlug: String!) {
|
|
436
439
|
public {
|
|
437
440
|
siteConfig(workspaceSlug: $workspaceSlug) {
|
|
438
441
|
id
|
|
@@ -448,7 +451,7 @@ var SITE_CONFIG_QUERY = `query PublicSiteConfig($workspaceSlug: String!) {
|
|
|
448
451
|
}
|
|
449
452
|
}
|
|
450
453
|
}
|
|
451
|
-
}
|
|
454
|
+
}`);
|
|
452
455
|
|
|
453
456
|
// src/data/settings-client.ts
|
|
454
457
|
async function fetchSiteConfig(config, options = {}) {
|
|
@@ -1164,5 +1167,6 @@ exports.propsToSchema = propsToSchema;
|
|
|
1164
1167
|
exports.registryToManifestBlocks = registryToManifestBlocks;
|
|
1165
1168
|
exports.resolveCmssyLocale = resolveCmssyLocale;
|
|
1166
1169
|
exports.resolveEditorOrigin = resolveEditorOrigin;
|
|
1170
|
+
exports.typedOperation = typedOperation;
|
|
1167
1171
|
exports.verifyCmssyEditToken = verifyCmssyEditToken;
|
|
1168
1172
|
exports.verifyCmssyWebhook = verifyCmssyWebhook;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyRegionSettings, i as CmssyRegionSettingsOf,
|
|
2
|
-
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref, r as resolveCmssyLocale } from './locale-
|
|
1
|
+
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyRegionSettings, i as CmssyRegionSettingsOf, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock, j as InvisibleBlocksMessage, P as PROTOCOL_VERSION, k as ParentReadyMessage, l as PatchMessage, m as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SHORTCUT_ACTIONS, n as ScopedVariables, o as SelectMessage, p as ShortcutAction, q as ShortcutMessage, V as VariablesParameter, r as ViewportMessage, s as applyCmssyCsp, t as createCmssyClient, u as defineCmssyConfig, v as defineCmssyLayout, w as isProtocolCompatible, x as normalizeOrigin, y as parseEditorMessage, z as postToEditor, F as resolveEditorOrigin } from './csp-GwcubV3k.cjs';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, a as CmssyOperation, b as CmssyOperationInput, c as CmssyTypedDocument, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref, r as resolveCmssyLocale, t as typedOperation } from './locale-DLGQgiu5.cjs';
|
|
3
3
|
export { C as CMSSY_RATE_LIMIT_WINDOW_MS, a as CMSSY_RETRY_MODES, b as CmssyRequestError, c as CmssyRetryMode, D as DEFAULT_CMSSY_API_URL, F as FetchLike, d as FetchLikeResponse, e as FetchPageOptions, R as RetryOption, f as RetryPolicy, i as isTransientRequestError } from './content-client-DhcHP8ln.cjs';
|
|
4
4
|
import * as _cmssy_types from '@cmssy/types';
|
|
5
5
|
import { FieldOptions, TypedField, FieldTypeValueMap, ResolvedMediaValue, PageRef, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, ResolvedMedia, MediaType, BlockSchema, LayoutRegion, FieldDefinition, BlockMeta, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyRegionSettings, i as CmssyRegionSettingsOf,
|
|
2
|
-
export { C as CMSSY_LOCALE_HEADER, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref, r as resolveCmssyLocale } from './locale-
|
|
1
|
+
export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, e as CmssyLayout, f as CmssyRegion, g as CmssyRegionOf, h as CmssyRegionSettings, i as CmssyRegionSettingsOf, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, I as InvisibleBlock, j as InvisibleBlocksMessage, P as PROTOCOL_VERSION, k as ParentReadyMessage, l as PatchMessage, m as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SHORTCUT_ACTIONS, n as ScopedVariables, o as SelectMessage, p as ShortcutAction, q as ShortcutMessage, V as VariablesParameter, r as ViewportMessage, s as applyCmssyCsp, t as createCmssyClient, u as defineCmssyConfig, v as defineCmssyLayout, w as isProtocolCompatible, x as normalizeOrigin, y as parseEditorMessage, z as postToEditor, F as resolveEditorOrigin } from './csp-BdigosQo.js';
|
|
2
|
+
export { C as CMSSY_LOCALE_HEADER, a as CmssyOperation, b as CmssyOperationInput, c as CmssyTypedDocument, G as GraphqlRequestOptions, g as graphqlRequest, l as localizeHref, r as resolveCmssyLocale, t as typedOperation } from './locale-BGUsgy8p.js';
|
|
3
3
|
export { C as CMSSY_RATE_LIMIT_WINDOW_MS, a as CMSSY_RETRY_MODES, b as CmssyRequestError, c as CmssyRetryMode, D as DEFAULT_CMSSY_API_URL, F as FetchLike, d as FetchLikeResponse, e as FetchPageOptions, R as RetryOption, f as RetryPolicy, i as isTransientRequestError } from './content-client-DhcHP8ln.js';
|
|
4
4
|
import * as _cmssy_types from '@cmssy/types';
|
|
5
5
|
import { FieldOptions, TypedField, FieldTypeValueMap, ResolvedMediaValue, PageRef, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, ResolvedMedia, MediaType, BlockSchema, LayoutRegion, FieldDefinition, BlockMeta, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
|