@suss/contract-graphql 0.3.2 → 0.5.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/index.cjs +16 -18
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +23 -20
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
SCALAR_SHAPES: () => SCALAR_SHAPES,
|
|
33
34
|
graphqlDocumentFilesToSummaries: () => graphqlDocumentFilesToSummaries,
|
|
34
35
|
graphqlDocumentsPathToSummaries: () => graphqlDocumentsPathToSummaries,
|
|
35
36
|
graphqlDocumentsToSummaries: () => graphqlDocumentsToSummaries,
|
|
@@ -227,12 +228,10 @@ function buildOperationSummary(op, name, file, fragments, config) {
|
|
|
227
228
|
transitions: buildTransitions(name, responseShape),
|
|
228
229
|
gaps: unexpandedSpreadGaps(unexpanded, fragments),
|
|
229
230
|
confidence: { source: "declared", level: "high" },
|
|
230
|
-
metadata: {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
235
|
-
}
|
|
231
|
+
metadata: (0, import_behavioral_ir.withGraphqlMetadata)(void 0, {
|
|
232
|
+
document: documentText,
|
|
233
|
+
...unexpanded.missing.size > 0 ? { unresolvedFragments: [...unexpanded.missing].sort() } : {}
|
|
234
|
+
})
|
|
236
235
|
};
|
|
237
236
|
}
|
|
238
237
|
function buildVariableInputs(op) {
|
|
@@ -529,18 +528,16 @@ function buildResolverSummary(rootType, field, source, recognition, transport) {
|
|
|
529
528
|
transitions: buildTransitions2(ownerKey, field),
|
|
530
529
|
gaps: [],
|
|
531
530
|
confidence: { source: "derived", level: "high" },
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
}
|
|
543
|
-
}
|
|
531
|
+
// Declared contract: checker pairs against any other source
|
|
532
|
+
// declaring a contract for the same gql:Type.field key. Provenance
|
|
533
|
+
// is "derived" because both this metadata and the summary's
|
|
534
|
+
// transitions come from the same SDL field declaration;
|
|
535
|
+
// self-comparison would be tautological.
|
|
536
|
+
metadata: (0, import_behavioral_ir2.withGraphqlMetadata)(void 0, {
|
|
537
|
+
rootType,
|
|
538
|
+
fieldName,
|
|
539
|
+
declaredContract: buildDeclaredContract(field, recognition)
|
|
540
|
+
})
|
|
544
541
|
};
|
|
545
542
|
}
|
|
546
543
|
function buildDeclaredContract(field, recognition) {
|
|
@@ -606,6 +603,7 @@ function buildTransitions2(ownerKey, field) {
|
|
|
606
603
|
}
|
|
607
604
|
// Annotate the CommonJS export names for ESM import in node:
|
|
608
605
|
0 && (module.exports = {
|
|
606
|
+
SCALAR_SHAPES,
|
|
609
607
|
graphqlDocumentFilesToSummaries,
|
|
610
608
|
graphqlDocumentsPathToSummaries,
|
|
611
609
|
graphqlDocumentsToSummaries,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BehavioralSummary } from '@suss/behavioral-ir';
|
|
1
|
+
import { BehavioralSummary, TypeShape } from '@suss/behavioral-ir';
|
|
2
2
|
|
|
3
3
|
interface GraphqlDocumentsOptions {
|
|
4
4
|
/**
|
|
@@ -46,6 +46,13 @@ declare function graphqlDocumentFilesToSummaries(filepaths: string[], options?:
|
|
|
46
46
|
*/
|
|
47
47
|
declare function graphqlDocumentsPathToSummaries(specPath: string, options?: GraphqlDocumentsOptions): BehavioralSummary[];
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The five standard GraphQL scalars, mapped to the shapes they read
|
|
51
|
+
* as. Exported so packs whose library exposes the same scalars under
|
|
52
|
+
* its own spelling can build on this table instead of restating it.
|
|
53
|
+
*/
|
|
54
|
+
declare const SCALAR_SHAPES: Record<string, TypeShape>;
|
|
55
|
+
|
|
49
56
|
interface GraphqlContractOptions {
|
|
50
57
|
/**
|
|
51
58
|
* Logical source path recorded on each summary's `location.file`.
|
|
@@ -62,7 +69,7 @@ interface GraphqlContractOptions {
|
|
|
62
69
|
recognition?: string;
|
|
63
70
|
/**
|
|
64
71
|
* Transport to record on the boundary binding. Defaults to
|
|
65
|
-
* `"http-graphql"
|
|
72
|
+
* `"http-graphql"`: most GraphQL servers run over HTTPS.
|
|
66
73
|
*/
|
|
67
74
|
transport?: string;
|
|
68
75
|
}
|
|
@@ -80,7 +87,7 @@ declare function graphqlSdlFileToSummaries(filepath: string, options?: GraphqlCo
|
|
|
80
87
|
/**
|
|
81
88
|
* Read an SDL file from disk and return its text, or `null` when the
|
|
82
89
|
* file can't be read. Shared entry point for callers that need the raw
|
|
83
|
-
* SDL rather than the derived summaries
|
|
90
|
+
* SDL rather than the derived summaries, e.g. @suss/contract-appsync
|
|
84
91
|
* resolving an external schema file referenced by a CloudFormation /
|
|
85
92
|
* SAM template's `DefinitionS3Location` / `SchemaUri`. Reading fails
|
|
86
93
|
* best-effort (missing file, permission error) so the caller can record
|
|
@@ -88,4 +95,4 @@ declare function graphqlSdlFileToSummaries(filepath: string, options?: GraphqlCo
|
|
|
88
95
|
*/
|
|
89
96
|
declare function loadSdlFile(filepath: string): string | null;
|
|
90
97
|
|
|
91
|
-
export { type GraphqlContractOptions, type GraphqlDocumentsOptions, graphqlDocumentFilesToSummaries, graphqlDocumentsPathToSummaries, graphqlDocumentsToSummaries, graphqlSdlFileToSummaries, graphqlSdlToSummaries, loadSdlFile };
|
|
98
|
+
export { type GraphqlContractOptions, type GraphqlDocumentsOptions, SCALAR_SHAPES, graphqlDocumentFilesToSummaries, graphqlDocumentsPathToSummaries, graphqlDocumentsToSummaries, graphqlSdlFileToSummaries, graphqlSdlToSummaries, loadSdlFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BehavioralSummary } from '@suss/behavioral-ir';
|
|
1
|
+
import { BehavioralSummary, TypeShape } from '@suss/behavioral-ir';
|
|
2
2
|
|
|
3
3
|
interface GraphqlDocumentsOptions {
|
|
4
4
|
/**
|
|
@@ -46,6 +46,13 @@ declare function graphqlDocumentFilesToSummaries(filepaths: string[], options?:
|
|
|
46
46
|
*/
|
|
47
47
|
declare function graphqlDocumentsPathToSummaries(specPath: string, options?: GraphqlDocumentsOptions): BehavioralSummary[];
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The five standard GraphQL scalars, mapped to the shapes they read
|
|
51
|
+
* as. Exported so packs whose library exposes the same scalars under
|
|
52
|
+
* its own spelling can build on this table instead of restating it.
|
|
53
|
+
*/
|
|
54
|
+
declare const SCALAR_SHAPES: Record<string, TypeShape>;
|
|
55
|
+
|
|
49
56
|
interface GraphqlContractOptions {
|
|
50
57
|
/**
|
|
51
58
|
* Logical source path recorded on each summary's `location.file`.
|
|
@@ -62,7 +69,7 @@ interface GraphqlContractOptions {
|
|
|
62
69
|
recognition?: string;
|
|
63
70
|
/**
|
|
64
71
|
* Transport to record on the boundary binding. Defaults to
|
|
65
|
-
* `"http-graphql"
|
|
72
|
+
* `"http-graphql"`: most GraphQL servers run over HTTPS.
|
|
66
73
|
*/
|
|
67
74
|
transport?: string;
|
|
68
75
|
}
|
|
@@ -80,7 +87,7 @@ declare function graphqlSdlFileToSummaries(filepath: string, options?: GraphqlCo
|
|
|
80
87
|
/**
|
|
81
88
|
* Read an SDL file from disk and return its text, or `null` when the
|
|
82
89
|
* file can't be read. Shared entry point for callers that need the raw
|
|
83
|
-
* SDL rather than the derived summaries
|
|
90
|
+
* SDL rather than the derived summaries, e.g. @suss/contract-appsync
|
|
84
91
|
* resolving an external schema file referenced by a CloudFormation /
|
|
85
92
|
* SAM template's `DefinitionS3Location` / `SchemaUri`. Reading fails
|
|
86
93
|
* best-effort (missing file, permission error) so the caller can record
|
|
@@ -88,4 +95,4 @@ declare function graphqlSdlFileToSummaries(filepath: string, options?: GraphqlCo
|
|
|
88
95
|
*/
|
|
89
96
|
declare function loadSdlFile(filepath: string): string | null;
|
|
90
97
|
|
|
91
|
-
export { type GraphqlContractOptions, type GraphqlDocumentsOptions, graphqlDocumentFilesToSummaries, graphqlDocumentsPathToSummaries, graphqlDocumentsToSummaries, graphqlSdlFileToSummaries, graphqlSdlToSummaries, loadSdlFile };
|
|
98
|
+
export { type GraphqlContractOptions, type GraphqlDocumentsOptions, SCALAR_SHAPES, graphqlDocumentFilesToSummaries, graphqlDocumentsPathToSummaries, graphqlDocumentsToSummaries, graphqlSdlFileToSummaries, graphqlSdlToSummaries, loadSdlFile };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,10 @@ import {
|
|
|
4
4
|
Kind as Kind3,
|
|
5
5
|
parse as parse2
|
|
6
6
|
} from "graphql";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
graphqlResolverBinding,
|
|
9
|
+
withGraphqlMetadata as withGraphqlMetadata2
|
|
10
|
+
} from "@suss/behavioral-ir";
|
|
8
11
|
|
|
9
12
|
// src/typeShape.ts
|
|
10
13
|
import { Kind } from "graphql";
|
|
@@ -37,7 +40,10 @@ import {
|
|
|
37
40
|
parse,
|
|
38
41
|
print
|
|
39
42
|
} from "graphql";
|
|
40
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
graphqlOperationBinding,
|
|
45
|
+
withGraphqlMetadata
|
|
46
|
+
} from "@suss/behavioral-ir";
|
|
41
47
|
function graphqlDocumentsToSummaries(sources, options = {}) {
|
|
42
48
|
const recognition = options.recognition ?? "graphql-documents";
|
|
43
49
|
const transport = options.transport ?? "http-graphql";
|
|
@@ -195,12 +201,10 @@ function buildOperationSummary(op, name, file, fragments, config) {
|
|
|
195
201
|
transitions: buildTransitions(name, responseShape),
|
|
196
202
|
gaps: unexpandedSpreadGaps(unexpanded, fragments),
|
|
197
203
|
confidence: { source: "declared", level: "high" },
|
|
198
|
-
metadata: {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
+
metadata: withGraphqlMetadata(void 0, {
|
|
205
|
+
document: documentText,
|
|
206
|
+
...unexpanded.missing.size > 0 ? { unresolvedFragments: [...unexpanded.missing].sort() } : {}
|
|
207
|
+
})
|
|
204
208
|
};
|
|
205
209
|
}
|
|
206
210
|
function buildVariableInputs(op) {
|
|
@@ -497,18 +501,16 @@ function buildResolverSummary(rootType, field, source, recognition, transport) {
|
|
|
497
501
|
transitions: buildTransitions2(ownerKey, field),
|
|
498
502
|
gaps: [],
|
|
499
503
|
confidence: { source: "derived", level: "high" },
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
}
|
|
511
|
-
}
|
|
504
|
+
// Declared contract: checker pairs against any other source
|
|
505
|
+
// declaring a contract for the same gql:Type.field key. Provenance
|
|
506
|
+
// is "derived" because both this metadata and the summary's
|
|
507
|
+
// transitions come from the same SDL field declaration;
|
|
508
|
+
// self-comparison would be tautological.
|
|
509
|
+
metadata: withGraphqlMetadata2(void 0, {
|
|
510
|
+
rootType,
|
|
511
|
+
fieldName,
|
|
512
|
+
declaredContract: buildDeclaredContract(field, recognition)
|
|
513
|
+
})
|
|
512
514
|
};
|
|
513
515
|
}
|
|
514
516
|
function buildDeclaredContract(field, recognition) {
|
|
@@ -573,6 +575,7 @@ function buildTransitions2(ownerKey, field) {
|
|
|
573
575
|
];
|
|
574
576
|
}
|
|
575
577
|
export {
|
|
578
|
+
SCALAR_SHAPES,
|
|
576
579
|
graphqlDocumentFilesToSummaries,
|
|
577
580
|
graphqlDocumentsPathToSummaries,
|
|
578
581
|
graphqlDocumentsToSummaries,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/contract-graphql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Generate behavioral summaries from GraphQL sources: a plain SDL file (root fields become resolver-kind summaries) or committed .graphql operation documents (each operation becomes a client-kind summary).",
|
|
6
6
|
"keywords": [
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"typecheck": "tsc --noEmit"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@suss/behavioral-ir": "0.
|
|
48
|
+
"@suss/behavioral-ir": "0.5.0",
|
|
49
49
|
"graphql": "^16.8.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|