@suss/contract-appsync 0.9.0 → 0.10.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 CHANGED
@@ -494,8 +494,53 @@ function buildResolverSummaries(config, resolvedByApi, schemasByApi, options = {
494
494
  functionById: byLogicalId(config.functions),
495
495
  dataSourceById: byLogicalId(config.dataSources)
496
496
  };
497
- return config.resolvers.map(
498
- (resolver) => buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile)
497
+ const resolverApis = new Set(
498
+ config.resolvers.map((resolver) => resolver.apiLogicalId)
499
+ );
500
+ return [
501
+ ...schemaDocumentSummaries(
502
+ resolvedByApi,
503
+ resolverApis,
504
+ indexes,
505
+ sourceFile
506
+ ),
507
+ ...config.resolvers.map(
508
+ (resolver) => buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile)
509
+ )
510
+ ];
511
+ }
512
+ function schemaDocumentSummaries(resolvedByApi, resolverApis, indexes, sourceFile) {
513
+ const out = [];
514
+ for (const [apiLogicalId, resolved] of resolvedByApi) {
515
+ const sdl = resolvedSdl(resolved);
516
+ if (sdl === null || !resolverApis.has(apiLogicalId)) {
517
+ continue;
518
+ }
519
+ const label = schemaDocumentLabel(sourceFile, apiLogicalId);
520
+ out.push({
521
+ kind: "library",
522
+ location: { file: label, range: { start: 0, end: 0 }, exportName: null },
523
+ identity: {
524
+ name: indexes.apiById.get(apiLogicalId)?.name ?? apiLogicalId,
525
+ exportPath: null,
526
+ boundaryBinding: null
527
+ },
528
+ inputs: [],
529
+ transitions: [],
530
+ gaps: [],
531
+ confidence: { source: "derived", level: "high" },
532
+ metadata: (0, import_behavioral_ir.withGraphqlMetadata)(
533
+ (0, import_behavioral_ir.withSourceDocumentMetadata)(void 0, { label }),
534
+ { schemaSdl: sdl }
535
+ )
536
+ });
537
+ }
538
+ return out;
539
+ }
540
+ function schemaDocumentLabel(sourceFile, apiLogicalId) {
541
+ return (0, import_behavioral_ir.nestedDocumentLabel)(
542
+ sourceFile,
543
+ apiLogicalId === null ? [] : [apiLogicalId]
499
544
  );
500
545
  }
501
546
  function byLogicalId(items) {
@@ -511,7 +556,7 @@ function buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile) {
511
556
  const schema = resolver.apiLogicalId === null ? null : schemasByApi.get(resolver.apiLogicalId) ?? null;
512
557
  const field = schema?.get(schemaKey(resolver.typeName, resolver.fieldName)) ?? null;
513
558
  const ownerKey = `${resolver.typeName}.${resolver.fieldName}`;
514
- const schemaSdl = resolved === null ? null : resolvedSdl(resolved);
559
+ const schemaDocument = resolved === null || resolvedSdl(resolved) === null ? null : schemaDocumentLabel(sourceFile, resolver.apiLogicalId);
515
560
  return {
516
561
  kind: "resolver",
517
562
  location: {
@@ -537,17 +582,24 @@ function buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile) {
537
582
  transitions: buildTransitions(ownerKey, resolver, field),
538
583
  gaps: [],
539
584
  confidence: { source: "derived", level: "high" },
540
- metadata: buildMetadata(resolver, api, resolved, field, indexes, schemaSdl)
585
+ metadata: buildMetadata(
586
+ resolver,
587
+ api,
588
+ resolved,
589
+ field,
590
+ indexes,
591
+ schemaDocument
592
+ )
541
593
  };
542
594
  }
543
- function buildMetadata(resolver, api, resolved, field, indexes, schemaSdl) {
595
+ function buildMetadata(resolver, api, resolved, field, indexes, schemaDocument) {
544
596
  const metadata = {
545
597
  appsync: buildAppsyncMetadata(resolver, api, resolved, field, indexes)
546
598
  };
547
- if (schemaSdl === null) {
599
+ if (schemaDocument === null) {
548
600
  return metadata;
549
601
  }
550
- return (0, import_behavioral_ir.withGraphqlMetadata)(metadata, { schemaSdl });
602
+ return (0, import_behavioral_ir.withSourceDocumentMetadata)(metadata, { label: schemaDocument });
551
603
  }
552
604
  function buildAppsyncMetadata(resolver, api, resolved, field, indexes) {
553
605
  const pipelineFunctions = resolver.pipelineFunctionLogicalIds.map(
package/dist/index.js CHANGED
@@ -456,7 +456,9 @@ function resolvedSdl(resolved) {
456
456
  // src/summaryBuilder.ts
457
457
  import {
458
458
  graphqlResolverBinding,
459
- withGraphqlMetadata
459
+ nestedDocumentLabel,
460
+ withGraphqlMetadata,
461
+ withSourceDocumentMetadata
460
462
  } from "@suss/behavioral-ir";
461
463
  function buildResolverSummaries(config, resolvedByApi, schemasByApi, options = {}) {
462
464
  const sourceFile = options.source ?? "appsync";
@@ -465,8 +467,53 @@ function buildResolverSummaries(config, resolvedByApi, schemasByApi, options = {
465
467
  functionById: byLogicalId(config.functions),
466
468
  dataSourceById: byLogicalId(config.dataSources)
467
469
  };
468
- return config.resolvers.map(
469
- (resolver) => buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile)
470
+ const resolverApis = new Set(
471
+ config.resolvers.map((resolver) => resolver.apiLogicalId)
472
+ );
473
+ return [
474
+ ...schemaDocumentSummaries(
475
+ resolvedByApi,
476
+ resolverApis,
477
+ indexes,
478
+ sourceFile
479
+ ),
480
+ ...config.resolvers.map(
481
+ (resolver) => buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile)
482
+ )
483
+ ];
484
+ }
485
+ function schemaDocumentSummaries(resolvedByApi, resolverApis, indexes, sourceFile) {
486
+ const out = [];
487
+ for (const [apiLogicalId, resolved] of resolvedByApi) {
488
+ const sdl = resolvedSdl(resolved);
489
+ if (sdl === null || !resolverApis.has(apiLogicalId)) {
490
+ continue;
491
+ }
492
+ const label = schemaDocumentLabel(sourceFile, apiLogicalId);
493
+ out.push({
494
+ kind: "library",
495
+ location: { file: label, range: { start: 0, end: 0 }, exportName: null },
496
+ identity: {
497
+ name: indexes.apiById.get(apiLogicalId)?.name ?? apiLogicalId,
498
+ exportPath: null,
499
+ boundaryBinding: null
500
+ },
501
+ inputs: [],
502
+ transitions: [],
503
+ gaps: [],
504
+ confidence: { source: "derived", level: "high" },
505
+ metadata: withGraphqlMetadata(
506
+ withSourceDocumentMetadata(void 0, { label }),
507
+ { schemaSdl: sdl }
508
+ )
509
+ });
510
+ }
511
+ return out;
512
+ }
513
+ function schemaDocumentLabel(sourceFile, apiLogicalId) {
514
+ return nestedDocumentLabel(
515
+ sourceFile,
516
+ apiLogicalId === null ? [] : [apiLogicalId]
470
517
  );
471
518
  }
472
519
  function byLogicalId(items) {
@@ -482,7 +529,7 @@ function buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile) {
482
529
  const schema = resolver.apiLogicalId === null ? null : schemasByApi.get(resolver.apiLogicalId) ?? null;
483
530
  const field = schema?.get(schemaKey(resolver.typeName, resolver.fieldName)) ?? null;
484
531
  const ownerKey = `${resolver.typeName}.${resolver.fieldName}`;
485
- const schemaSdl = resolved === null ? null : resolvedSdl(resolved);
532
+ const schemaDocument = resolved === null || resolvedSdl(resolved) === null ? null : schemaDocumentLabel(sourceFile, resolver.apiLogicalId);
486
533
  return {
487
534
  kind: "resolver",
488
535
  location: {
@@ -508,17 +555,24 @@ function buildOne(resolver, indexes, resolvedByApi, schemasByApi, sourceFile) {
508
555
  transitions: buildTransitions(ownerKey, resolver, field),
509
556
  gaps: [],
510
557
  confidence: { source: "derived", level: "high" },
511
- metadata: buildMetadata(resolver, api, resolved, field, indexes, schemaSdl)
558
+ metadata: buildMetadata(
559
+ resolver,
560
+ api,
561
+ resolved,
562
+ field,
563
+ indexes,
564
+ schemaDocument
565
+ )
512
566
  };
513
567
  }
514
- function buildMetadata(resolver, api, resolved, field, indexes, schemaSdl) {
568
+ function buildMetadata(resolver, api, resolved, field, indexes, schemaDocument) {
515
569
  const metadata = {
516
570
  appsync: buildAppsyncMetadata(resolver, api, resolved, field, indexes)
517
571
  };
518
- if (schemaSdl === null) {
572
+ if (schemaDocument === null) {
519
573
  return metadata;
520
574
  }
521
- return withGraphqlMetadata(metadata, { schemaSdl });
575
+ return withSourceDocumentMetadata(metadata, { label: schemaDocument });
522
576
  }
523
577
  function buildAppsyncMetadata(resolver, api, resolved, field, indexes) {
524
578
  const pipelineFunctions = resolver.pipelineFunctionLogicalIds.map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suss/contract-appsync",
3
- "version": "0.9.0",
3
+ "version": "0.10.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,9 +46,9 @@
46
46
  "typecheck": "tsc --noEmit"
47
47
  },
48
48
  "dependencies": {
49
- "@suss/behavioral-ir": "0.9.0",
50
- "@suss/contract-graphql": "0.9.0",
51
- "@suss/manifest-aws": "0.9.0",
49
+ "@suss/behavioral-ir": "0.10.0",
50
+ "@suss/contract-graphql": "0.10.0",
51
+ "@suss/manifest-aws": "0.10.0",
52
52
  "graphql": "^16.8.0"
53
53
  },
54
54
  "devDependencies": {