@glubean/graphql 0.1.7 → 0.2.1
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/README.md +433 -0
- package/dist/contract/adapter.d.ts +27 -0
- package/dist/contract/adapter.d.ts.map +1 -0
- package/dist/contract/adapter.js +543 -0
- package/dist/contract/adapter.js.map +1 -0
- package/dist/contract/factory.d.ts +34 -0
- package/dist/contract/factory.d.ts.map +1 -0
- package/dist/contract/factory.js +90 -0
- package/dist/contract/factory.js.map +1 -0
- package/dist/contract/index.d.ts +37 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +55 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/matchers.d.ts +95 -0
- package/dist/contract/matchers.d.ts.map +1 -0
- package/dist/contract/matchers.js +246 -0
- package/dist/contract/matchers.js.map +1 -0
- package/dist/contract/types.d.ts +369 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/contract/types.js +41 -0
- package/dist/contract/types.js.map +1 -0
- package/dist/index.d.ts +24 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -7
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in GraphQL contract adapter for @glubean/graphql 0.2.0.
|
|
3
|
+
*
|
|
4
|
+
* Shipped alongside the transport plugin in @glubean/graphql (single-package
|
|
5
|
+
* model — "contract is a first-class citizen"). Registered via
|
|
6
|
+
* `contract.register("graphql", graphqlAdapter)` on import — see ./index.ts.
|
|
7
|
+
*
|
|
8
|
+
* Responsibilities (same interface as HTTP / gRPC adapters):
|
|
9
|
+
* - execute: setup → call → expect → verify → teardown
|
|
10
|
+
* - executeCaseInFlow: deep-merge resolvedInputs, run case in flow mode
|
|
11
|
+
* - validateCaseForFlow: reject function-valued variables / headers
|
|
12
|
+
* - project: runtime ContractProjection<GraphqlPayloadSchemas>
|
|
13
|
+
* - normalize: runtime → JSON-safe ExtractedContractProjection
|
|
14
|
+
* - classifyFailure: 3-layer (transport / payload errors / data shape)
|
|
15
|
+
* - renderTarget: operationName (parsed from query if needed)
|
|
16
|
+
* - toMarkdown: case list with operation + query snippet
|
|
17
|
+
* - describePayload: high-level summary for index views
|
|
18
|
+
*
|
|
19
|
+
* Phase 1 scope: query + mutation only. Subscription deferred to Phase 2.
|
|
20
|
+
*/
|
|
21
|
+
import { parseOperationName } from "../index.js";
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// Helpers
|
|
24
|
+
// =============================================================================
|
|
25
|
+
/** Convert a SchemaLike to a JSON Schema fragment if possible (best-effort). */
|
|
26
|
+
export function schemaToJsonSchema(schema) {
|
|
27
|
+
if (!schema || typeof schema !== "object")
|
|
28
|
+
return null;
|
|
29
|
+
const maybe = schema.toJSONSchema;
|
|
30
|
+
if (typeof maybe === "function") {
|
|
31
|
+
try {
|
|
32
|
+
const out = maybe.call(schema);
|
|
33
|
+
if (out && typeof out === "object")
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
/** Deep-merge two plain objects (right wins). Handles nested objects; skips arrays. */
|
|
43
|
+
function deepMerge(base, override) {
|
|
44
|
+
if (!base && !override)
|
|
45
|
+
return {};
|
|
46
|
+
if (!base)
|
|
47
|
+
return { ...override };
|
|
48
|
+
if (!override)
|
|
49
|
+
return { ...base };
|
|
50
|
+
const out = { ...base };
|
|
51
|
+
for (const [k, v] of Object.entries(override)) {
|
|
52
|
+
const baseVal = base[k];
|
|
53
|
+
if (v != null &&
|
|
54
|
+
typeof v === "object" &&
|
|
55
|
+
!Array.isArray(v) &&
|
|
56
|
+
baseVal != null &&
|
|
57
|
+
typeof baseVal === "object" &&
|
|
58
|
+
!Array.isArray(baseVal)) {
|
|
59
|
+
out[k] = deepMerge(baseVal, v);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
out[k] = v;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/** Resolve the effective GraphQL client with case > spec fallback. */
|
|
68
|
+
function resolveClient(caseSpec, spec) {
|
|
69
|
+
const client = caseSpec.client ?? spec.client;
|
|
70
|
+
if (!client) {
|
|
71
|
+
throw new Error(`No GraphQL client provided for case. Set "client" on the case or contract spec (e.g. via contract.graphql.with("name", { client: gqlPlugin })).`);
|
|
72
|
+
}
|
|
73
|
+
return client;
|
|
74
|
+
}
|
|
75
|
+
/** Merge headers: contract defaults < case. */
|
|
76
|
+
function resolveHeaders(spec, caseSpec, state) {
|
|
77
|
+
const caseHeaders = typeof caseSpec.headers === "function"
|
|
78
|
+
? caseSpec.headers(state)
|
|
79
|
+
: caseSpec.headers;
|
|
80
|
+
const specHeaders = spec.defaultHeaders;
|
|
81
|
+
if (!caseHeaders && !specHeaders)
|
|
82
|
+
return undefined;
|
|
83
|
+
return { ...(specHeaders ?? {}), ...(caseHeaders ?? {}) };
|
|
84
|
+
}
|
|
85
|
+
/** Resolve variables with deep-merge: spec.defaultVariables < case.variables. */
|
|
86
|
+
function resolveVariables(spec, caseSpec, state) {
|
|
87
|
+
const caseVars = typeof caseSpec.variables === "function"
|
|
88
|
+
? caseSpec.variables(state)
|
|
89
|
+
: caseSpec.variables;
|
|
90
|
+
return deepMerge(spec.defaultVariables, caseVars);
|
|
91
|
+
}
|
|
92
|
+
/** Resolve effective operation type: case > spec default > "query". */
|
|
93
|
+
function resolveOperation(spec, caseSpec) {
|
|
94
|
+
return caseSpec.operation ?? spec.defaultOperation ?? "query";
|
|
95
|
+
}
|
|
96
|
+
/** Resolve display operationName: case.operationName > parsed from query > "anonymous". */
|
|
97
|
+
function resolveOperationName(caseSpec) {
|
|
98
|
+
return (caseSpec.operationName ?? parseOperationName(caseSpec.query) ?? "anonymous");
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Call the GraphQL client for a case. Returns the full GraphQLResult envelope
|
|
102
|
+
* plus the resolved operation + operationName + duration.
|
|
103
|
+
*/
|
|
104
|
+
async function callGraphql(client, caseSpec, spec, variables, headers) {
|
|
105
|
+
const operation = resolveOperation(spec, caseSpec);
|
|
106
|
+
const operationName = resolveOperationName(caseSpec);
|
|
107
|
+
const start = Date.now();
|
|
108
|
+
const callFn = operation === "mutation" ? client.mutate : client.query;
|
|
109
|
+
const res = await callFn.call(client, caseSpec.query, {
|
|
110
|
+
variables,
|
|
111
|
+
...(headers ? { headers } : {}),
|
|
112
|
+
operationName: operationName !== "anonymous" ? operationName : undefined,
|
|
113
|
+
});
|
|
114
|
+
const duration = Date.now() - start;
|
|
115
|
+
return {
|
|
116
|
+
data: res.data,
|
|
117
|
+
errors: res.errors,
|
|
118
|
+
extensions: res.extensions,
|
|
119
|
+
httpStatus: res.httpStatus,
|
|
120
|
+
headers: res.headers,
|
|
121
|
+
rawBody: res.rawBody,
|
|
122
|
+
operationName,
|
|
123
|
+
duration,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* 3-layer assertion: transport → payload errors → data shape.
|
|
128
|
+
* Uses `ctx.assert` / `ctx.expect` / `ctx.validate` for structured failures.
|
|
129
|
+
*/
|
|
130
|
+
function assertResult(ctx, result, caseSpec) {
|
|
131
|
+
const expect = caseSpec.expect ?? {};
|
|
132
|
+
const expectedStatus = expect.httpStatus ?? 200;
|
|
133
|
+
// Layer 1: transport (HTTP status)
|
|
134
|
+
if (result.httpStatus !== expectedStatus) {
|
|
135
|
+
ctx.assert(false, `Expected HTTP status ${expectedStatus} but got ${result.httpStatus}`, { actual: result.httpStatus, expected: expectedStatus });
|
|
136
|
+
}
|
|
137
|
+
// Layer 2: payload errors (GraphQL `errors` array)
|
|
138
|
+
assertErrors(ctx, result.errors, expect.errors ?? "absent");
|
|
139
|
+
// Layer 3: data shape (only when transport succeeded and errors absent OR
|
|
140
|
+
// `data` partial expect is declared — schema always runs if provided)
|
|
141
|
+
if (expect.schema) {
|
|
142
|
+
ctx.validate(result.data, expect.schema, `response data`);
|
|
143
|
+
}
|
|
144
|
+
if (expect.data) {
|
|
145
|
+
if (result.data == null) {
|
|
146
|
+
ctx.assert(false, `Expected data shape to match but response.data was null`, { actual: null, expected: expect.data });
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
ctx.expect(result.data).toMatchObject(expect.data);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Response headers assertions
|
|
153
|
+
if (expect.headersMatch) {
|
|
154
|
+
ctx.expect(result.headers).toMatchObject(expect.headersMatch);
|
|
155
|
+
}
|
|
156
|
+
if (expect.headers) {
|
|
157
|
+
ctx.validate(result.headers, expect.headers, `response headers`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Assert the `errors` layer against a sentinel or partial array.
|
|
162
|
+
*/
|
|
163
|
+
function assertErrors(ctx, actual, expected) {
|
|
164
|
+
const errs = actual ?? [];
|
|
165
|
+
if (expected === "absent") {
|
|
166
|
+
if (errs.length > 0) {
|
|
167
|
+
ctx.assert(false, `Expected no GraphQL errors but got ${errs.length}: ${errs.map((e) => e.message).join("; ")}`, { actual: errs, expected: [] });
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (expected === "any") {
|
|
172
|
+
return; // accept whatever shows up
|
|
173
|
+
}
|
|
174
|
+
// Array of partial GraphQLError — match by position (each entry partial-matches)
|
|
175
|
+
if (errs.length < expected.length) {
|
|
176
|
+
ctx.assert(false, `Expected ${expected.length} GraphQL errors but got ${errs.length}`, { actual: errs, expected });
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
for (let i = 0; i < expected.length; i++) {
|
|
180
|
+
const want = expected[i];
|
|
181
|
+
const got = errs[i];
|
|
182
|
+
// Partial match on top-level keys (message, extensions.code, etc.)
|
|
183
|
+
for (const [k, v] of Object.entries(want)) {
|
|
184
|
+
if (k === "extensions" && v && typeof v === "object") {
|
|
185
|
+
ctx.expect((got.extensions ?? {})).toMatchObject(v);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
ctx.expect(got[k]).toEqual(v);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// =============================================================================
|
|
194
|
+
// executeCase — standard (non-flow) case execution
|
|
195
|
+
// =============================================================================
|
|
196
|
+
async function executeCase(ctx, caseSpec, spec) {
|
|
197
|
+
if (!caseSpec.query || typeof caseSpec.query !== "string") {
|
|
198
|
+
throw new Error(`GraphQL contract case: "query" is required and must be a string.`);
|
|
199
|
+
}
|
|
200
|
+
const state = caseSpec.setup
|
|
201
|
+
? await caseSpec.setup(ctx)
|
|
202
|
+
: undefined;
|
|
203
|
+
try {
|
|
204
|
+
const client = resolveClient(caseSpec, spec);
|
|
205
|
+
const variables = resolveVariables(spec, caseSpec, state);
|
|
206
|
+
const headers = resolveHeaders(spec, caseSpec, state);
|
|
207
|
+
const result = await callGraphql(client, caseSpec, spec, variables, headers);
|
|
208
|
+
assertResult(ctx, result, caseSpec);
|
|
209
|
+
if (caseSpec.verify) {
|
|
210
|
+
await caseSpec.verify(ctx, result);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
if (caseSpec.teardown) {
|
|
215
|
+
await caseSpec.teardown(ctx, state);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// =============================================================================
|
|
220
|
+
// project — runtime ContractProjection
|
|
221
|
+
// =============================================================================
|
|
222
|
+
function projectGraphql(spec) {
|
|
223
|
+
const meta = {
|
|
224
|
+
endpoint: spec.endpoint,
|
|
225
|
+
defaultOperation: spec.defaultOperation,
|
|
226
|
+
defaultHeaders: spec.defaultHeaders,
|
|
227
|
+
types: spec.types,
|
|
228
|
+
};
|
|
229
|
+
const cases = Object.entries(spec.cases).map(([key, c]) => {
|
|
230
|
+
const casted = c;
|
|
231
|
+
const lifecycle = casted.deprecated
|
|
232
|
+
? "deprecated"
|
|
233
|
+
: casted.deferred
|
|
234
|
+
? "deferred"
|
|
235
|
+
: "active";
|
|
236
|
+
const operation = resolveOperation(spec, casted);
|
|
237
|
+
const operationName = resolveOperationName(casted);
|
|
238
|
+
const schemas = {
|
|
239
|
+
query: casted.query,
|
|
240
|
+
operation,
|
|
241
|
+
operationName,
|
|
242
|
+
variables: spec.variablesSchema,
|
|
243
|
+
response: casted.expect?.schema ?? spec.responseSchema,
|
|
244
|
+
headers: casted.expect?.headers,
|
|
245
|
+
};
|
|
246
|
+
return {
|
|
247
|
+
key,
|
|
248
|
+
description: casted.description,
|
|
249
|
+
lifecycle,
|
|
250
|
+
severity: casted.severity ?? "warning",
|
|
251
|
+
deferredReason: casted.deferred,
|
|
252
|
+
deprecatedReason: casted.deprecated,
|
|
253
|
+
schemas,
|
|
254
|
+
tags: casted.tags,
|
|
255
|
+
extensions: casted.extensions,
|
|
256
|
+
requires: casted.requires,
|
|
257
|
+
defaultRun: casted.defaultRun,
|
|
258
|
+
};
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
protocol: "graphql",
|
|
262
|
+
target: spec.endpoint ?? "",
|
|
263
|
+
description: spec.description,
|
|
264
|
+
feature: spec.feature,
|
|
265
|
+
tags: spec.tags,
|
|
266
|
+
extensions: spec.extensions,
|
|
267
|
+
deprecated: spec.deprecated,
|
|
268
|
+
cases,
|
|
269
|
+
schemas: {},
|
|
270
|
+
meta,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
// =============================================================================
|
|
274
|
+
// normalize — runtime → JSON-safe Extracted
|
|
275
|
+
// =============================================================================
|
|
276
|
+
function normalizeGraphql(projection) {
|
|
277
|
+
const safeCases = projection.cases.map((c) => {
|
|
278
|
+
const s = c.schemas ?? {};
|
|
279
|
+
const safe = {
|
|
280
|
+
query: s.query,
|
|
281
|
+
operation: s.operation,
|
|
282
|
+
operationName: s.operationName,
|
|
283
|
+
variables: schemaToJsonSchema(s.variables) ?? undefined,
|
|
284
|
+
response: schemaToJsonSchema(s.response) ?? undefined,
|
|
285
|
+
headers: schemaToJsonSchema(s.headers) ?? undefined,
|
|
286
|
+
variablesExample: s.variablesExample,
|
|
287
|
+
variablesExamples: s.variablesExamples,
|
|
288
|
+
};
|
|
289
|
+
return { ...c, schemas: safe };
|
|
290
|
+
});
|
|
291
|
+
return {
|
|
292
|
+
id: projection.id,
|
|
293
|
+
protocol: projection.protocol,
|
|
294
|
+
target: projection.target,
|
|
295
|
+
description: projection.description,
|
|
296
|
+
feature: projection.feature,
|
|
297
|
+
instanceName: projection.instanceName,
|
|
298
|
+
tags: projection.tags,
|
|
299
|
+
extensions: projection.extensions,
|
|
300
|
+
deprecated: projection.deprecated,
|
|
301
|
+
cases: safeCases,
|
|
302
|
+
schemas: {},
|
|
303
|
+
meta: projection.meta,
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
// =============================================================================
|
|
307
|
+
// executeCaseInFlow — flow-mode execution
|
|
308
|
+
// =============================================================================
|
|
309
|
+
async function executeCaseInFlowGraphql(input) {
|
|
310
|
+
const { ctx, contract: c, caseKey, resolvedInputs } = input;
|
|
311
|
+
const spec = c._spec;
|
|
312
|
+
const caseSpec = spec.cases[caseKey];
|
|
313
|
+
if (!caseSpec) {
|
|
314
|
+
throw new Error(`GraphQL contract: unknown case key "${caseKey}".`);
|
|
315
|
+
}
|
|
316
|
+
if (!caseSpec.query || typeof caseSpec.query !== "string") {
|
|
317
|
+
throw new Error(`GraphQL contract case "${caseKey}": "query" is required and must be a string.`);
|
|
318
|
+
}
|
|
319
|
+
const state = caseSpec.setup
|
|
320
|
+
? (await caseSpec.setup(ctx))
|
|
321
|
+
: undefined;
|
|
322
|
+
try {
|
|
323
|
+
const client = resolveClient(caseSpec, spec);
|
|
324
|
+
const staticVars = typeof caseSpec.variables === "function"
|
|
325
|
+
? undefined
|
|
326
|
+
: caseSpec.variables;
|
|
327
|
+
const staticHeaders = typeof caseSpec.headers === "function"
|
|
328
|
+
? undefined
|
|
329
|
+
: caseSpec.headers;
|
|
330
|
+
const lensInput = (resolvedInputs ?? {});
|
|
331
|
+
// Deep-merge lens variables over case static + spec default
|
|
332
|
+
const mergedVariables = deepMerge(deepMerge(spec.defaultVariables, staticVars), lensInput.variables);
|
|
333
|
+
const mergedHeaders = {
|
|
334
|
+
...(spec.defaultHeaders ?? {}),
|
|
335
|
+
...(staticHeaders ?? {}),
|
|
336
|
+
...(lensInput.headers ?? {}),
|
|
337
|
+
};
|
|
338
|
+
const result = await callGraphql(client, caseSpec, spec, mergedVariables, Object.keys(mergedHeaders).length > 0 ? mergedHeaders : undefined);
|
|
339
|
+
assertResult(ctx, result, caseSpec);
|
|
340
|
+
if (caseSpec.verify) {
|
|
341
|
+
await caseSpec.verify(ctx, result);
|
|
342
|
+
}
|
|
343
|
+
return result;
|
|
344
|
+
}
|
|
345
|
+
finally {
|
|
346
|
+
if (caseSpec.teardown) {
|
|
347
|
+
await caseSpec.teardown(ctx, state);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// =============================================================================
|
|
352
|
+
// validateCaseForFlow — reject function-valued fields in flow mode
|
|
353
|
+
// =============================================================================
|
|
354
|
+
export function validateGraphqlCaseForFlow(spec, caseKey, contractId) {
|
|
355
|
+
const caseSpec = spec.cases[caseKey];
|
|
356
|
+
if (!caseSpec) {
|
|
357
|
+
throw new Error(`contract.graphql(${JSON.stringify(contractId)}).case(${JSON.stringify(caseKey)}): case not found.`);
|
|
358
|
+
}
|
|
359
|
+
const functionFields = [];
|
|
360
|
+
if (typeof caseSpec.variables === "function")
|
|
361
|
+
functionFields.push("variables");
|
|
362
|
+
if (typeof caseSpec.headers === "function")
|
|
363
|
+
functionFields.push("headers");
|
|
364
|
+
if (functionFields.length > 0) {
|
|
365
|
+
throw new Error(`contract.graphql(${JSON.stringify(contractId)}).case(${JSON.stringify(caseKey)}): ` +
|
|
366
|
+
`cannot use function-valued ${functionFields.join(" / ")} in a flow step — ` +
|
|
367
|
+
`these fields depend on case-local setup state which isn't available in flow mode. ` +
|
|
368
|
+
`Move the value into flow state and use step.in lens instead.`);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// =============================================================================
|
|
372
|
+
// classifyFailure — 3-layer (transport / payload / data shape)
|
|
373
|
+
// =============================================================================
|
|
374
|
+
/**
|
|
375
|
+
* Classify failures based on:
|
|
376
|
+
* 1. Transport: HTTP status from the underlying POST
|
|
377
|
+
* 2. Payload: GraphQL `errors` array with optional `extensions.code`
|
|
378
|
+
* 3. Error shape (network / timeout) when no response was parsed
|
|
379
|
+
*
|
|
380
|
+
* Emitted events inspected: `graphql_response` (if adapter/transport emits
|
|
381
|
+
* it), else falls back to generic error shape.
|
|
382
|
+
*/
|
|
383
|
+
function classifyGraphqlFailure(input) {
|
|
384
|
+
const gqlEvent = input.events.find((e) => e.type === "graphql_response");
|
|
385
|
+
if (gqlEvent) {
|
|
386
|
+
const httpStatus = typeof gqlEvent.data?.httpStatus === "number"
|
|
387
|
+
? gqlEvent.data.httpStatus
|
|
388
|
+
: undefined;
|
|
389
|
+
const errors = Array.isArray(gqlEvent.data?.errors)
|
|
390
|
+
? gqlEvent.data.errors
|
|
391
|
+
: undefined;
|
|
392
|
+
const transport = statusToClassification(httpStatus);
|
|
393
|
+
if (transport)
|
|
394
|
+
return transport;
|
|
395
|
+
const payload = payloadErrorsToClassification(errors);
|
|
396
|
+
if (payload)
|
|
397
|
+
return payload;
|
|
398
|
+
return undefined;
|
|
399
|
+
}
|
|
400
|
+
// Fall back to HTTP event emitted by the underlying transport
|
|
401
|
+
const httpEvent = input.events.find((e) => e.type === "http_response");
|
|
402
|
+
if (httpEvent) {
|
|
403
|
+
const status = typeof httpEvent.data?.status === "number"
|
|
404
|
+
? httpEvent.data.status
|
|
405
|
+
: undefined;
|
|
406
|
+
const transport = statusToClassification(status);
|
|
407
|
+
if (transport)
|
|
408
|
+
return transport;
|
|
409
|
+
}
|
|
410
|
+
// Error shape fallback
|
|
411
|
+
if (input.error instanceof Error) {
|
|
412
|
+
const name = input.error.name;
|
|
413
|
+
if (name === "TimeoutError" || name === "AbortError") {
|
|
414
|
+
return { kind: "transient", source: "trace", retryable: true, message: input.error.message };
|
|
415
|
+
}
|
|
416
|
+
if (name === "GraphQLResponseError") {
|
|
417
|
+
return { kind: "semantic", source: "trace", message: input.error.message };
|
|
418
|
+
}
|
|
419
|
+
return { kind: "server", source: "trace", message: input.error.message };
|
|
420
|
+
}
|
|
421
|
+
return undefined;
|
|
422
|
+
}
|
|
423
|
+
function statusToClassification(status) {
|
|
424
|
+
if (status === undefined)
|
|
425
|
+
return undefined;
|
|
426
|
+
if (status >= 200 && status < 300)
|
|
427
|
+
return undefined;
|
|
428
|
+
if (status === 401 || status === 403) {
|
|
429
|
+
return { kind: "auth", source: "trace", message: `HTTP ${status}` };
|
|
430
|
+
}
|
|
431
|
+
if (status === 408 || status === 429) {
|
|
432
|
+
return { kind: "transient", source: "trace", retryable: true, message: `HTTP ${status}` };
|
|
433
|
+
}
|
|
434
|
+
if (status >= 400 && status < 500) {
|
|
435
|
+
return { kind: "client", source: "trace", message: `HTTP ${status}` };
|
|
436
|
+
}
|
|
437
|
+
if (status === 502 || status === 503 || status === 504) {
|
|
438
|
+
return { kind: "transient", source: "trace", retryable: true, message: `HTTP ${status}` };
|
|
439
|
+
}
|
|
440
|
+
if (status >= 500) {
|
|
441
|
+
return { kind: "server", source: "trace", message: `HTTP ${status}` };
|
|
442
|
+
}
|
|
443
|
+
return undefined;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Interpret GraphQL `errors[].extensions.code` when present.
|
|
447
|
+
*
|
|
448
|
+
* Common codes: UNAUTHENTICATED, FORBIDDEN, BAD_USER_INPUT, NOT_FOUND,
|
|
449
|
+
* INTERNAL_SERVER_ERROR. Unknown or missing codes → semantic.
|
|
450
|
+
*/
|
|
451
|
+
function payloadErrorsToClassification(errors) {
|
|
452
|
+
if (!errors || errors.length === 0)
|
|
453
|
+
return undefined;
|
|
454
|
+
const first = errors[0];
|
|
455
|
+
const code = first.extensions?.code;
|
|
456
|
+
const codeStr = typeof code === "string" ? code.toUpperCase() : "";
|
|
457
|
+
if (codeStr === "UNAUTHENTICATED" || codeStr === "FORBIDDEN") {
|
|
458
|
+
return { kind: "auth", source: "trace", message: first.message };
|
|
459
|
+
}
|
|
460
|
+
if (codeStr === "BAD_USER_INPUT" || codeStr === "GRAPHQL_VALIDATION_FAILED" || codeStr === "GRAPHQL_PARSE_FAILED") {
|
|
461
|
+
return { kind: "client", source: "trace", message: first.message };
|
|
462
|
+
}
|
|
463
|
+
if (codeStr === "INTERNAL_SERVER_ERROR") {
|
|
464
|
+
return { kind: "server", source: "trace", message: first.message };
|
|
465
|
+
}
|
|
466
|
+
return { kind: "semantic", source: "trace", message: first.message };
|
|
467
|
+
}
|
|
468
|
+
// =============================================================================
|
|
469
|
+
// renderTarget — display operationName (or endpoint if none)
|
|
470
|
+
// =============================================================================
|
|
471
|
+
function renderGraphqlTarget(target) {
|
|
472
|
+
// `target` here is `spec.endpoint` per projectGraphql. Display as-is;
|
|
473
|
+
// per-case operationName is surfaced in toMarkdown, not here.
|
|
474
|
+
return target || "(graphql)";
|
|
475
|
+
}
|
|
476
|
+
// =============================================================================
|
|
477
|
+
// toMarkdown — case list with operation + short query snippet
|
|
478
|
+
// =============================================================================
|
|
479
|
+
function summarizeQuery(query, limit = 80) {
|
|
480
|
+
const flat = query.replace(/\s+/g, " ").trim();
|
|
481
|
+
return flat.length <= limit ? flat : `${flat.slice(0, limit - 1)}…`;
|
|
482
|
+
}
|
|
483
|
+
function toMarkdownGraphql(projection) {
|
|
484
|
+
const lines = [];
|
|
485
|
+
const endpoint = projection.target || "(no endpoint)";
|
|
486
|
+
lines.push(`### ${projection.id} — GraphQL \`${endpoint}\``);
|
|
487
|
+
if (projection.description)
|
|
488
|
+
lines.push(`\n${projection.description}`);
|
|
489
|
+
if (projection.deprecated)
|
|
490
|
+
lines.push(`\n**Deprecated:** ${projection.deprecated}`);
|
|
491
|
+
if (projection.cases.length === 0) {
|
|
492
|
+
lines.push("\n_(no cases)_");
|
|
493
|
+
return lines.join("\n");
|
|
494
|
+
}
|
|
495
|
+
lines.push("\n**Cases:**\n");
|
|
496
|
+
for (const c of projection.cases) {
|
|
497
|
+
const marker = c.lifecycle === "deprecated"
|
|
498
|
+
? " ⚠ deprecated"
|
|
499
|
+
: c.lifecycle === "deferred"
|
|
500
|
+
? " ⏸ deferred"
|
|
501
|
+
: "";
|
|
502
|
+
const op = c.schemas?.operation ?? "query";
|
|
503
|
+
const opName = c.schemas?.operationName ?? "anonymous";
|
|
504
|
+
lines.push(`- \`${c.key}\`${marker} — ${op} \`${opName}\` — ${c.description ?? ""}`);
|
|
505
|
+
if (c.schemas?.query) {
|
|
506
|
+
lines.push(` - \`${summarizeQuery(c.schemas.query)}\``);
|
|
507
|
+
}
|
|
508
|
+
if (c.deprecatedReason)
|
|
509
|
+
lines.push(` - deprecated: ${c.deprecatedReason}`);
|
|
510
|
+
if (c.deferredReason)
|
|
511
|
+
lines.push(` - deferred: ${c.deferredReason}`);
|
|
512
|
+
}
|
|
513
|
+
return lines.join("\n");
|
|
514
|
+
}
|
|
515
|
+
// =============================================================================
|
|
516
|
+
// describePayload — high-level summary for index views
|
|
517
|
+
// =============================================================================
|
|
518
|
+
function describeGraphqlPayload(schemas) {
|
|
519
|
+
const hasRequest = schemas.query !== undefined || schemas.variables !== undefined;
|
|
520
|
+
const hasResponse = schemas.response !== undefined;
|
|
521
|
+
return {
|
|
522
|
+
hasRequest,
|
|
523
|
+
hasResponse,
|
|
524
|
+
protocol: "graphql",
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
// =============================================================================
|
|
528
|
+
// Exported adapter
|
|
529
|
+
// =============================================================================
|
|
530
|
+
export const graphqlAdapter = {
|
|
531
|
+
async execute(ctx, caseSpec, contractSpec) {
|
|
532
|
+
await executeCase(ctx, caseSpec, contractSpec);
|
|
533
|
+
},
|
|
534
|
+
project: projectGraphql,
|
|
535
|
+
normalize: normalizeGraphql,
|
|
536
|
+
executeCaseInFlow: executeCaseInFlowGraphql,
|
|
537
|
+
validateCaseForFlow: validateGraphqlCaseForFlow,
|
|
538
|
+
classifyFailure: classifyGraphqlFailure,
|
|
539
|
+
renderTarget: renderGraphqlTarget,
|
|
540
|
+
toMarkdown: toMarkdownGraphql,
|
|
541
|
+
describePayload: describeGraphqlPayload,
|
|
542
|
+
};
|
|
543
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/contract/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAcH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAYjD,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAChD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACvD,MAAM,KAAK,GAAI,MAA2C,CAAC,YAAY,CAAC;IACxE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC/B,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;gBAAE,OAAO,GAA8B,CAAC;QAC5E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uFAAuF;AACvF,SAAS,SAAS,CAChB,IAAmB,EACnB,QAAgC;IAEhC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ;QAAE,OAAO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O,CAAC,SAAS,KAAK,SAAS,CAAC;IAClF,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC;IACnD,OAAO;QACL,UAAU;QACV,WAAW;QACX,QAAQ,EAAE,SAAS;KACpB,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF,MAAM,CAAC,MAAM,cAAc,GAMvB;IACF,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,YAAY;QACvC,MAAM,WAAW,CACf,GAAG,EACH,QAA+B,EAC/B,YAAmC,CACpC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,cAAc;IACvB,SAAS,EAAE,gBAAgB;IAC3B,iBAAiB,EAAE,wBAEG;IACtB,mBAAmB,EAAE,0BAA0B;IAC/C,eAAe,EAAE,sBAAsB;IACvC,YAAY,EAAE,mBAAmB;IACjC,UAAU,EAAE,iBAAiB;IAC7B,eAAe,EAAE,sBAAsB;CACxC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* contract.graphql factory — scoped-defaults pattern.
|
|
3
|
+
*
|
|
4
|
+
* Root `contract.graphql` exposes only `.with(name, defaults)`. Calling
|
|
5
|
+
* `contract.graphql("id", spec)` directly is forbidden — client injection
|
|
6
|
+
* via scoped instances is the canonical authoring pattern (same as HTTP
|
|
7
|
+
* and gRPC).
|
|
8
|
+
*
|
|
9
|
+
* The factory wraps the generic dispatcher attached to `contract.graphql`
|
|
10
|
+
* by `contract.register("graphql", graphqlAdapter)`. Calls flow through:
|
|
11
|
+
* user code
|
|
12
|
+
* → scoped factory(id, spec)
|
|
13
|
+
* → merge instance defaults into spec
|
|
14
|
+
* → dispatcher(id, mergedSpec) [generic register() output]
|
|
15
|
+
* → adapter.project + per-case registerTest + Test[] with
|
|
16
|
+
* _projection/_spec
|
|
17
|
+
*/
|
|
18
|
+
import type { ProtocolContract } from "@glubean/sdk";
|
|
19
|
+
import type { GraphqlContractCase, GraphqlContractDefaults, GraphqlContractFactory, GraphqlContractMeta, GraphqlContractRoot, GraphqlContractSpec, GraphqlPayloadSchemas } from "./types.js";
|
|
20
|
+
type InternalDefaults = GraphqlContractDefaults & {
|
|
21
|
+
_name?: string;
|
|
22
|
+
};
|
|
23
|
+
type GraphqlDispatch = <Vars extends Record<string, unknown>, Res, Cases extends Record<string, GraphqlContractCase<Vars, Res, any>>>(id: string, spec: GraphqlContractSpec<Vars, Res, Cases>) => ProtocolContract<GraphqlContractSpec, GraphqlPayloadSchemas, GraphqlContractMeta>;
|
|
24
|
+
/**
|
|
25
|
+
* Build a scoped GraphQL factory. `dispatch` is `contract.graphql` attached
|
|
26
|
+
* by the core's register() call — we wrap it to inject instance defaults.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createGraphqlFactory(dispatch: GraphqlDispatch, defaults?: InternalDefaults): GraphqlContractFactory;
|
|
29
|
+
/**
|
|
30
|
+
* Root factory — `.with()` only, direct call throws.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createGraphqlRoot(dispatch: GraphqlDispatch): GraphqlContractRoot;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/contract/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAc,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,KAAK,gBAAgB,GAAG,uBAAuB,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE,KAAK,eAAe,GAAG,CACrB,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,GAAG,EACH,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAEjE,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,KACxC,gBAAgB,CAAC,mBAAmB,EAAE,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;AA+CvF;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,EACzB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,sBAAsB,CA4CxB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,eAAe,GAAG,mBAAmB,CAEhF"}
|