@ttoss/appsync-api 0.5.0 → 0.6.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.
@@ -539,7 +539,7 @@ var getPackageLambdaLayerStackName = (packageName) => {
539
539
  // package.json
540
540
  var package_default = {
541
541
  name: "@ttoss/appsync-api",
542
- version: "0.5.0",
542
+ version: "0.6.0",
543
543
  description: "A library for building GraphQL APIs for AWS AppSync.",
544
544
  license: "UNLICENSED",
545
545
  author: "ttoss",
@@ -572,7 +572,7 @@ var package_default = {
572
572
  sideEffects: false,
573
573
  typings: "dist/index.d.ts",
574
574
  dependencies: {
575
- "@ttoss/cloudformation": "^0.3.0",
575
+ "@ttoss/cloudformation": "^0.4.0",
576
576
  express: "^4.18.2",
577
577
  "graphql-helix": "^1.13.0",
578
578
  minimist: "^1.2.7"
@@ -582,9 +582,9 @@ var package_default = {
582
582
  "graphql-compose": "^9.0.10"
583
583
  },
584
584
  devDependencies: {
585
- "@ttoss/config": "^1.26.0",
585
+ "@ttoss/config": "^1.27.0",
586
586
  "@types/aws-lambda": "^8.10.109",
587
- carlin: "^1.21.4",
587
+ carlin: "^1.22.0",
588
588
  graphql: "^16.6.0",
589
589
  "graphql-compose": "^9.0.10"
590
590
  },
@@ -614,7 +614,9 @@ var AppSyncGraphQLApiLogicalId = "AppSyncGraphQLApi";
614
614
  var AppSyncGraphQLSchemaLogicalId = "AppSyncGraphQLSchema";
615
615
  var AppSyncLambdaFunctionLogicalId = "AppSyncLambdaFunction";
616
616
  var AppSyncLambdaFunctionAppSyncDataSourceLogicalId = "AppSyncLambdaFunctionAppSyncDataSource";
617
+ var AppSyncGraphQLApiKeyLogicalId = "AppSyncGraphQLApiKey";
617
618
  var createApiTemplate = ({
619
+ apiKey,
618
620
  schemaComposer,
619
621
  dataSource,
620
622
  lambdaFunction
@@ -669,7 +671,7 @@ var createApiTemplate = ({
669
671
  [AppSyncGraphQLApiLogicalId]: {
670
672
  Type: "AWS::AppSync::GraphQLApi",
671
673
  Properties: {
672
- AuthenticationType: "API_KEY",
674
+ AuthenticationType: "AWS_IAM",
673
675
  Name: {
674
676
  "Fn::Join": [
675
677
  ":",
@@ -741,6 +743,27 @@ var createApiTemplate = ({
741
743
  }
742
744
  };
743
745
  });
746
+ if (apiKey) {
747
+ template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProvider = [
748
+ {
749
+ AuthenticationType: "API_KEY"
750
+ }
751
+ ];
752
+ template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
753
+ Type: "AWS::AppSync::ApiKey",
754
+ Properties: {
755
+ ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] }
756
+ }
757
+ };
758
+ if (!template.Outputs) {
759
+ template.Outputs = {};
760
+ }
761
+ template.Outputs[AppSyncGraphQLApiKeyLogicalId] = {
762
+ Value: {
763
+ "Fn::GetAtt": [AppSyncGraphQLApiKeyLogicalId, "ApiKey"]
764
+ }
765
+ };
766
+ }
744
767
  return template;
745
768
  };
746
769
 
package/dist/esm/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
  import {
3
3
  AppSyncGraphQLSchemaLogicalId
4
- } from "./chunk-5MBGDEAO.js";
4
+ } from "./chunk-MENSBKNQ.js";
5
5
  import "./chunk-NQOARNEJ.js";
6
6
 
7
7
  // src/cli.ts
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
  import {
3
3
  createApiTemplate
4
- } from "./chunk-5MBGDEAO.js";
4
+ } from "./chunk-MENSBKNQ.js";
5
5
  import "./chunk-NQOARNEJ.js";
6
6
 
7
7
  // src/index.ts
package/dist/index.d.ts CHANGED
@@ -6,7 +6,8 @@ import { AppSyncResolverHandler as AppSyncResolverHandler$1 } from 'aws-lambda';
6
6
  type Role = string | {
7
7
  'Fn::ImportValue': string;
8
8
  };
9
- declare const createApiTemplate: ({ schemaComposer, dataSource, lambdaFunction, }: {
9
+ declare const createApiTemplate: ({ apiKey, schemaComposer, dataSource, lambdaFunction, }: {
10
+ apiKey?: boolean | undefined;
10
11
  schemaComposer: SchemaComposer<any>;
11
12
  dataSource: {
12
13
  roleArn: Role;
package/dist/index.js CHANGED
@@ -572,7 +572,7 @@ var getPackageLambdaLayerStackName = (packageName) => {
572
572
  // package.json
573
573
  var package_default = {
574
574
  name: "@ttoss/appsync-api",
575
- version: "0.5.0",
575
+ version: "0.6.0",
576
576
  description: "A library for building GraphQL APIs for AWS AppSync.",
577
577
  license: "UNLICENSED",
578
578
  author: "ttoss",
@@ -605,7 +605,7 @@ var package_default = {
605
605
  sideEffects: false,
606
606
  typings: "dist/index.d.ts",
607
607
  dependencies: {
608
- "@ttoss/cloudformation": "^0.3.0",
608
+ "@ttoss/cloudformation": "^0.4.0",
609
609
  express: "^4.18.2",
610
610
  "graphql-helix": "^1.13.0",
611
611
  minimist: "^1.2.7"
@@ -615,9 +615,9 @@ var package_default = {
615
615
  "graphql-compose": "^9.0.10"
616
616
  },
617
617
  devDependencies: {
618
- "@ttoss/config": "^1.26.0",
618
+ "@ttoss/config": "^1.27.0",
619
619
  "@types/aws-lambda": "^8.10.109",
620
- carlin: "^1.21.4",
620
+ carlin: "^1.22.0",
621
621
  graphql: "^16.6.0",
622
622
  "graphql-compose": "^9.0.10"
623
623
  },
@@ -647,7 +647,9 @@ var AppSyncGraphQLApiLogicalId = "AppSyncGraphQLApi";
647
647
  var AppSyncGraphQLSchemaLogicalId = "AppSyncGraphQLSchema";
648
648
  var AppSyncLambdaFunctionLogicalId = "AppSyncLambdaFunction";
649
649
  var AppSyncLambdaFunctionAppSyncDataSourceLogicalId = "AppSyncLambdaFunctionAppSyncDataSource";
650
+ var AppSyncGraphQLApiKeyLogicalId = "AppSyncGraphQLApiKey";
650
651
  var createApiTemplate = ({
652
+ apiKey,
651
653
  schemaComposer: schemaComposer2,
652
654
  dataSource,
653
655
  lambdaFunction
@@ -702,7 +704,7 @@ var createApiTemplate = ({
702
704
  [AppSyncGraphQLApiLogicalId]: {
703
705
  Type: "AWS::AppSync::GraphQLApi",
704
706
  Properties: {
705
- AuthenticationType: "API_KEY",
707
+ AuthenticationType: "AWS_IAM",
706
708
  Name: {
707
709
  "Fn::Join": [
708
710
  ":",
@@ -774,6 +776,27 @@ var createApiTemplate = ({
774
776
  }
775
777
  };
776
778
  });
779
+ if (apiKey) {
780
+ template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProvider = [
781
+ {
782
+ AuthenticationType: "API_KEY"
783
+ }
784
+ ];
785
+ template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
786
+ Type: "AWS::AppSync::ApiKey",
787
+ Properties: {
788
+ ApiId: { "Fn::GetAtt": [AppSyncGraphQLApiLogicalId, "ApiId"] }
789
+ }
790
+ };
791
+ if (!template.Outputs) {
792
+ template.Outputs = {};
793
+ }
794
+ template.Outputs[AppSyncGraphQLApiKeyLogicalId] = {
795
+ Value: {
796
+ "Fn::GetAtt": [AppSyncGraphQLApiKeyLogicalId, "ApiKey"]
797
+ }
798
+ };
799
+ }
777
800
  return template;
778
801
  };
779
802
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/appsync-api",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "A library for building GraphQL APIs for AWS AppSync.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ttoss",
@@ -33,7 +33,7 @@
33
33
  "sideEffects": false,
34
34
  "typings": "dist/index.d.ts",
35
35
  "dependencies": {
36
- "@ttoss/cloudformation": "^0.3.0",
36
+ "@ttoss/cloudformation": "^0.4.0",
37
37
  "express": "^4.18.2",
38
38
  "graphql-helix": "^1.13.0",
39
39
  "minimist": "^1.2.7"
@@ -43,9 +43,9 @@
43
43
  "graphql-compose": "^9.0.10"
44
44
  },
45
45
  "devDependencies": {
46
- "@ttoss/config": "^1.26.0",
46
+ "@ttoss/config": "^1.27.0",
47
47
  "@types/aws-lambda": "^8.10.109",
48
- "carlin": "^1.21.4",
48
+ "carlin": "^1.22.0",
49
49
  "graphql": "^16.6.0",
50
50
  "graphql-compose": "^9.0.10"
51
51
  },
@@ -68,5 +68,5 @@
68
68
  ]
69
69
  }
70
70
  },
71
- "gitHead": "702cb6f1dd3411f53c5172eb50ce9d5e3fa5c3cc"
71
+ "gitHead": "6c5898425e2847fed46511ae1e573ff8dc3eb1d4"
72
72
  }
@@ -3,7 +3,7 @@ import { getPackageLambdaLayerStackName } from 'carlin/src/deploy/lambdaLayer/ge
3
3
  import packageJson from '../package.json';
4
4
  import type { CloudFormationTemplate } from '@ttoss/cloudformation';
5
5
 
6
- const AppSyncGraphQLApiLogicalId = 'AppSyncGraphQLApi';
6
+ export const AppSyncGraphQLApiLogicalId = 'AppSyncGraphQLApi';
7
7
 
8
8
  export const AppSyncGraphQLSchemaLogicalId = 'AppSyncGraphQLSchema';
9
9
 
@@ -12,6 +12,8 @@ export const AppSyncLambdaFunctionLogicalId = 'AppSyncLambdaFunction';
12
12
  const AppSyncLambdaFunctionAppSyncDataSourceLogicalId =
13
13
  'AppSyncLambdaFunctionAppSyncDataSource';
14
14
 
15
+ export const AppSyncGraphQLApiKeyLogicalId = 'AppSyncGraphQLApiKey';
16
+
15
17
  type Role =
16
18
  | string
17
19
  | {
@@ -19,10 +21,12 @@ type Role =
19
21
  };
20
22
 
21
23
  export const createApiTemplate = ({
24
+ apiKey,
22
25
  schemaComposer,
23
26
  dataSource,
24
27
  lambdaFunction,
25
28
  }: {
29
+ apiKey?: boolean;
26
30
  schemaComposer: SchemaComposer<any>;
27
31
  dataSource: {
28
32
  roleArn: Role;
@@ -96,7 +100,7 @@ export const createApiTemplate = ({
96
100
  [AppSyncGraphQLApiLogicalId]: {
97
101
  Type: 'AWS::AppSync::GraphQLApi',
98
102
  Properties: {
99
- AuthenticationType: 'API_KEY',
103
+ AuthenticationType: 'AWS_IAM',
100
104
  Name: {
101
105
  'Fn::Join': [
102
106
  ':',
@@ -174,5 +178,32 @@ export const createApiTemplate = ({
174
178
  };
175
179
  });
176
180
 
181
+ if (apiKey) {
182
+ template.Resources[
183
+ AppSyncGraphQLApiLogicalId
184
+ ].Properties.AdditionalAuthenticationProvider = [
185
+ {
186
+ AuthenticationType: 'API_KEY',
187
+ },
188
+ ];
189
+
190
+ template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
191
+ Type: 'AWS::AppSync::ApiKey',
192
+ Properties: {
193
+ ApiId: { 'Fn::GetAtt': [AppSyncGraphQLApiLogicalId, 'ApiId'] },
194
+ },
195
+ };
196
+
197
+ if (!template.Outputs) {
198
+ template.Outputs = {};
199
+ }
200
+
201
+ template.Outputs[AppSyncGraphQLApiKeyLogicalId] = {
202
+ Value: {
203
+ 'Fn::GetAtt': [AppSyncGraphQLApiKeyLogicalId, 'ApiKey'],
204
+ },
205
+ };
206
+ }
207
+
177
208
  return template;
178
209
  };