@suss/contract-appsync 0.3.2 → 0.4.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 +14 -63
- package/dist/index.js +18 -64
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -34,28 +34,13 @@ __export(index_exports, {
|
|
|
34
34
|
appsyncToSummaries: () => appsyncToSummaries
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(index_exports);
|
|
37
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
38
37
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
39
|
-
var
|
|
38
|
+
var import_manifest_aws2 = require("@suss/manifest-aws");
|
|
40
39
|
|
|
41
40
|
// src/refs.ts
|
|
41
|
+
var import_manifest_aws = require("@suss/manifest-aws");
|
|
42
42
|
function resolveLogicalRef(value) {
|
|
43
|
-
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
if (value === null || typeof value !== "object") {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
const obj = value;
|
|
50
|
-
const ref = obj.Ref;
|
|
51
|
-
if (typeof ref === "string") {
|
|
52
|
-
return ref;
|
|
53
|
-
}
|
|
54
|
-
const getAtt = obj["Fn::GetAtt"];
|
|
55
|
-
if (Array.isArray(getAtt) && getAtt.length > 0 && typeof getAtt[0] === "string") {
|
|
56
|
-
return getAtt[0];
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
43
|
+
return (0, import_manifest_aws.refTarget)(value);
|
|
59
44
|
}
|
|
60
45
|
function stringField(value) {
|
|
61
46
|
return typeof value === "string" ? value : null;
|
|
@@ -542,17 +527,17 @@ function buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile) {
|
|
|
542
527
|
transitions: buildTransitions(ownerKey, resolver, field),
|
|
543
528
|
gaps: [],
|
|
544
529
|
confidence: { source: "derived", level: "high" },
|
|
545
|
-
metadata:
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
// cross-summary schema lookup, and the checker caches parses
|
|
552
|
-
// per-SDL.
|
|
553
|
-
...schemaSdl !== null ? { graphql: { schemaSdl } } : {}
|
|
554
|
-
}
|
|
530
|
+
metadata: buildMetadata(resolver, api, resolved, field, indexes, schemaSdl)
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
function buildMetadata(resolver, api, resolved, field, indexes, schemaSdl) {
|
|
534
|
+
const metadata = {
|
|
535
|
+
appsync: buildAppsyncMetadata(resolver, api, resolved, field, indexes)
|
|
555
536
|
};
|
|
537
|
+
if (schemaSdl === null) {
|
|
538
|
+
return metadata;
|
|
539
|
+
}
|
|
540
|
+
return (0, import_behavioral_ir.withGraphqlMetadata)(metadata, { schemaSdl });
|
|
556
541
|
}
|
|
557
542
|
function buildAppsyncMetadata(resolver, api, resolved, field, indexes) {
|
|
558
543
|
const pipelineFunctions = resolver.pipelineFunctionLogicalIds.map(
|
|
@@ -704,46 +689,12 @@ function indexSchemas(resolvedByApi) {
|
|
|
704
689
|
return out;
|
|
705
690
|
}
|
|
706
691
|
function appsyncFileToSummaries(filePath, options = {}) {
|
|
707
|
-
const
|
|
708
|
-
const template = parseTemplate(filePath, raw);
|
|
692
|
+
const template = (0, import_manifest_aws2.loadCloudFormationTemplate)(filePath);
|
|
709
693
|
return appsyncToSummaries(template, {
|
|
710
694
|
source: options.source ?? import_node_path2.default.relative(process.cwd(), filePath),
|
|
711
695
|
baseDir: options.baseDir ?? import_node_path2.default.dirname(filePath)
|
|
712
696
|
});
|
|
713
697
|
}
|
|
714
|
-
var CLOUDFORMATION_YAML_TAGS = [
|
|
715
|
-
{ tag: "!Ref", resolve: (value) => ({ Ref: value }) },
|
|
716
|
-
{
|
|
717
|
-
tag: "!GetAtt",
|
|
718
|
-
resolve: (value) => ({
|
|
719
|
-
"Fn::GetAtt": value.includes(".") ? value.split(".") : [value]
|
|
720
|
-
})
|
|
721
|
-
},
|
|
722
|
-
...[
|
|
723
|
-
"!Sub",
|
|
724
|
-
"!Join",
|
|
725
|
-
"!Select",
|
|
726
|
-
"!Split",
|
|
727
|
-
"!FindInMap",
|
|
728
|
-
"!ImportValue",
|
|
729
|
-
"!Base64",
|
|
730
|
-
"!Cidr",
|
|
731
|
-
"!If",
|
|
732
|
-
"!Not",
|
|
733
|
-
"!And",
|
|
734
|
-
"!Or",
|
|
735
|
-
"!Equals"
|
|
736
|
-
].map((tag) => ({ tag, resolve: (value) => value }))
|
|
737
|
-
];
|
|
738
|
-
function parseTemplate(filePath, raw) {
|
|
739
|
-
const ext = import_node_path2.default.extname(filePath).toLowerCase();
|
|
740
|
-
if (ext === ".json") {
|
|
741
|
-
return JSON.parse(raw);
|
|
742
|
-
}
|
|
743
|
-
return import_yaml.default.parse(raw, {
|
|
744
|
-
customTags: CLOUDFORMATION_YAML_TAGS
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
698
|
// Annotate the CommonJS export names for ESM import in node:
|
|
748
699
|
0 && (module.exports = {
|
|
749
700
|
appsyncFileToSummaries,
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import fs from "fs";
|
|
3
2
|
import path2 from "path";
|
|
4
|
-
import
|
|
3
|
+
import { loadCloudFormationTemplate } from "@suss/manifest-aws";
|
|
5
4
|
|
|
6
5
|
// src/refs.ts
|
|
6
|
+
import { refTarget } from "@suss/manifest-aws";
|
|
7
7
|
function resolveLogicalRef(value) {
|
|
8
|
-
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
if (value === null || typeof value !== "object") {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
const obj = value;
|
|
15
|
-
const ref = obj.Ref;
|
|
16
|
-
if (typeof ref === "string") {
|
|
17
|
-
return ref;
|
|
18
|
-
}
|
|
19
|
-
const getAtt = obj["Fn::GetAtt"];
|
|
20
|
-
if (Array.isArray(getAtt) && getAtt.length > 0 && typeof getAtt[0] === "string") {
|
|
21
|
-
return getAtt[0];
|
|
22
|
-
}
|
|
23
|
-
return null;
|
|
8
|
+
return refTarget(value);
|
|
24
9
|
}
|
|
25
10
|
function stringField(value) {
|
|
26
11
|
return typeof value === "string" ? value : null;
|
|
@@ -459,7 +444,10 @@ function resolvedSdl(resolved) {
|
|
|
459
444
|
}
|
|
460
445
|
|
|
461
446
|
// src/summaryBuilder.ts
|
|
462
|
-
import {
|
|
447
|
+
import {
|
|
448
|
+
graphqlResolverBinding,
|
|
449
|
+
withGraphqlMetadata
|
|
450
|
+
} from "@suss/behavioral-ir";
|
|
463
451
|
function buildResolverSummaries(config, resolvedByApi, schemasByApi, options = {}) {
|
|
464
452
|
const sourceFile = options.source ?? "appsync";
|
|
465
453
|
const indexes = {
|
|
@@ -510,17 +498,17 @@ function buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile) {
|
|
|
510
498
|
transitions: buildTransitions(ownerKey, resolver, field),
|
|
511
499
|
gaps: [],
|
|
512
500
|
confidence: { source: "derived", level: "high" },
|
|
513
|
-
metadata:
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
// cross-summary schema lookup, and the checker caches parses
|
|
520
|
-
// per-SDL.
|
|
521
|
-
...schemaSdl !== null ? { graphql: { schemaSdl } } : {}
|
|
522
|
-
}
|
|
501
|
+
metadata: buildMetadata(resolver, api, resolved, field, indexes, schemaSdl)
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
function buildMetadata(resolver, api, resolved, field, indexes, schemaSdl) {
|
|
505
|
+
const metadata = {
|
|
506
|
+
appsync: buildAppsyncMetadata(resolver, api, resolved, field, indexes)
|
|
523
507
|
};
|
|
508
|
+
if (schemaSdl === null) {
|
|
509
|
+
return metadata;
|
|
510
|
+
}
|
|
511
|
+
return withGraphqlMetadata(metadata, { schemaSdl });
|
|
524
512
|
}
|
|
525
513
|
function buildAppsyncMetadata(resolver, api, resolved, field, indexes) {
|
|
526
514
|
const pipelineFunctions = resolver.pipelineFunctionLogicalIds.map(
|
|
@@ -672,46 +660,12 @@ function indexSchemas(resolvedByApi) {
|
|
|
672
660
|
return out;
|
|
673
661
|
}
|
|
674
662
|
function appsyncFileToSummaries(filePath, options = {}) {
|
|
675
|
-
const
|
|
676
|
-
const template = parseTemplate(filePath, raw);
|
|
663
|
+
const template = loadCloudFormationTemplate(filePath);
|
|
677
664
|
return appsyncToSummaries(template, {
|
|
678
665
|
source: options.source ?? path2.relative(process.cwd(), filePath),
|
|
679
666
|
baseDir: options.baseDir ?? path2.dirname(filePath)
|
|
680
667
|
});
|
|
681
668
|
}
|
|
682
|
-
var CLOUDFORMATION_YAML_TAGS = [
|
|
683
|
-
{ tag: "!Ref", resolve: (value) => ({ Ref: value }) },
|
|
684
|
-
{
|
|
685
|
-
tag: "!GetAtt",
|
|
686
|
-
resolve: (value) => ({
|
|
687
|
-
"Fn::GetAtt": value.includes(".") ? value.split(".") : [value]
|
|
688
|
-
})
|
|
689
|
-
},
|
|
690
|
-
...[
|
|
691
|
-
"!Sub",
|
|
692
|
-
"!Join",
|
|
693
|
-
"!Select",
|
|
694
|
-
"!Split",
|
|
695
|
-
"!FindInMap",
|
|
696
|
-
"!ImportValue",
|
|
697
|
-
"!Base64",
|
|
698
|
-
"!Cidr",
|
|
699
|
-
"!If",
|
|
700
|
-
"!Not",
|
|
701
|
-
"!And",
|
|
702
|
-
"!Or",
|
|
703
|
-
"!Equals"
|
|
704
|
-
].map((tag) => ({ tag, resolve: (value) => value }))
|
|
705
|
-
];
|
|
706
|
-
function parseTemplate(filePath, raw) {
|
|
707
|
-
const ext = path2.extname(filePath).toLowerCase();
|
|
708
|
-
if (ext === ".json") {
|
|
709
|
-
return JSON.parse(raw);
|
|
710
|
-
}
|
|
711
|
-
return YAML.parse(raw, {
|
|
712
|
-
customTags: CLOUDFORMATION_YAML_TAGS
|
|
713
|
-
});
|
|
714
|
-
}
|
|
715
669
|
export {
|
|
716
670
|
appsyncFileToSummaries,
|
|
717
671
|
appsyncToSummaries
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suss/contract-appsync",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Generate suss behavioral summaries from AWS AppSync in CloudFormation (AWS::AppSync::*) and SAM (AWS::Serverless::GraphQLApi) templates, including external .graphql schema files (GraphQL schema-first).",
|
|
6
6
|
"keywords": [
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"typecheck": "tsc --noEmit"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@suss/behavioral-ir": "0.
|
|
50
|
-
"@suss/contract-graphql": "0.
|
|
51
|
-
"
|
|
52
|
-
"
|
|
49
|
+
"@suss/behavioral-ir": "0.4.0",
|
|
50
|
+
"@suss/contract-graphql": "0.4.0",
|
|
51
|
+
"@suss/manifest-aws": "0.4.0",
|
|
52
|
+
"graphql": "^16.8.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"tsup": "*",
|