@ttoss/appsync-api 0.21.1 → 0.22.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/esm/index.js CHANGED
@@ -169,11 +169,14 @@ var createApiTemplate = ({
169
169
  const apiKey = additionalAuthenticationProviders?.includes("API_KEY") || authenticationType === "API_KEY";
170
170
  const cognitoUserPoolAuth = additionalAuthenticationProviders?.includes("AMAZON_COGNITO_USER_POOLS") || authenticationType === "AMAZON_COGNITO_USER_POOLS";
171
171
  if (additionalAuthenticationProviders) {
172
- template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProviders = additionalAuthenticationProviders?.map(provider => {
173
- return {
174
- AuthenticationType: provider
175
- };
176
- });
172
+ template.Resources[AppSyncGraphQLApiLogicalId].Properties = {
173
+ ...template.Resources[AppSyncGraphQLApiLogicalId].Properties,
174
+ AdditionalAuthenticationProviders: additionalAuthenticationProviders?.map(provider => {
175
+ return {
176
+ AuthenticationType: provider
177
+ };
178
+ })
179
+ };
177
180
  }
178
181
  if (apiKey) {
179
182
  template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
@@ -197,16 +200,22 @@ var createApiTemplate = ({
197
200
  if (!userPoolConfig) {
198
201
  throw new Error("userPoolConfig is required when using AMAZON_COGNITO_USER_POOLS authentication.");
199
202
  }
200
- template.Resources[AppSyncGraphQLApiLogicalId].Properties.UserPoolConfig = {
201
- AppIdClientRegex: userPoolConfig.appIdClientRegex,
202
- AwsRegion: userPoolConfig.awsRegion,
203
- DefaultAction: userPoolConfig.defaultAction,
204
- UserPoolId: userPoolConfig.userPoolId
203
+ template.Resources[AppSyncGraphQLApiLogicalId].Properties = {
204
+ ...template.Resources[AppSyncGraphQLApiLogicalId].Properties,
205
+ UserPoolConfig: {
206
+ AppIdClientRegex: userPoolConfig.appIdClientRegex,
207
+ AwsRegion: userPoolConfig.awsRegion,
208
+ DefaultAction: userPoolConfig.defaultAction,
209
+ UserPoolId: userPoolConfig.userPoolId
210
+ }
205
211
  };
206
212
  }
207
213
  if (lambdaFunction.environment?.variables) {
208
- template.Resources[AppSyncLambdaFunctionLogicalId].Properties.Environment = {
209
- Variables: lambdaFunction.environment.variables
214
+ template.Resources[AppSyncLambdaFunctionLogicalId].Properties = {
215
+ ...template.Resources[AppSyncLambdaFunctionLogicalId].Properties,
216
+ Environment: {
217
+ Variables: lambdaFunction.environment.variables
218
+ }
210
219
  };
211
220
  }
212
221
  if (customDomain) {
package/dist/index.d.mts CHANGED
@@ -2,79 +2,73 @@ import { SchemaComposer, BuildSchemaInput } from '@ttoss/graphql-api';
2
2
  import { AppSyncResolverHandler as AppSyncResolverHandler$1 } from 'aws-lambda';
3
3
  export { AppSyncIdentityCognito } from 'aws-lambda';
4
4
 
5
+ type CloudFormationRef = {
6
+ Ref: string;
7
+ };
8
+ type CloudFormationGetAtt = {
9
+ 'Fn::GetAtt': [string, string];
10
+ };
11
+ type CloudFormationJoin = {
12
+ 'Fn::Join': [string, (string | CloudFormationRef)[]];
13
+ };
14
+ type CloudFormationSub = {
15
+ 'Fn::Sub': string | [string, Record<string, any>];
16
+ };
17
+ type CloudFormationSelect = {
18
+ 'Fn::Select': [number, string[]];
19
+ };
20
+ type CloudFormationSplit = {
21
+ 'Fn::Split': [string, string];
22
+ };
23
+ type CloudFormationIntrinsic = CloudFormationRef | CloudFormationGetAtt | CloudFormationJoin | CloudFormationSub | CloudFormationSelect | CloudFormationSplit;
24
+ type CloudFormationValue<T = any> = T | CloudFormationIntrinsic;
5
25
  type Parameter = {
6
26
  AllowedValues?: string[];
7
- Default?: string | number;
27
+ Default?: string | number | boolean;
8
28
  Description?: string;
9
- Type: string;
29
+ Type: 'String' | 'Number' | 'List<Number>' | 'CommaDelimitedList' | 'AWS::EC2::KeyPair::KeyName' | 'AWS::EC2::SecurityGroup::Id' | 'AWS::EC2::Subnet::Id' | 'AWS::EC2::VPC::Id' | 'List<AWS::EC2::VPC::Id>' | 'List<AWS::EC2::SecurityGroup::Id>' | 'List<AWS::EC2::Subnet::Id>';
10
30
  NoEcho?: boolean;
31
+ MinLength?: number;
32
+ MaxLength?: number;
33
+ MinValue?: number;
34
+ MaxValue?: number;
35
+ AllowedPattern?: string;
36
+ ConstraintDescription?: string;
11
37
  };
12
- type Parameters = {
13
- [key: string]: Parameter;
14
- };
15
- type Resource = {
38
+ type Parameters = Record<string, Parameter>;
39
+ type Condition = Record<string, any>;
40
+ type Conditions = Record<string, Condition>;
41
+ type BaseResource = {
16
42
  Type: string;
17
- DeletionPolicy?: 'Delete' | 'Retain';
43
+ DeletionPolicy?: 'Delete' | 'Retain' | 'Snapshot';
44
+ UpdateReplacePolicy?: 'Delete' | 'Retain' | 'Snapshot';
18
45
  Description?: string;
19
- DependsOn?: string[] | string;
46
+ DependsOn?: string | string[];
20
47
  Condition?: string;
21
- Properties: any;
48
+ Metadata?: Record<string, any>;
49
+ CreationPolicy?: Record<string, any>;
50
+ UpdatePolicy?: Record<string, any>;
22
51
  };
23
- type Policy = {
24
- PolicyName: string;
25
- PolicyDocument: {
26
- Version: '2012-10-17';
27
- Statement: {
28
- Sid?: string;
29
- Effect: 'Allow' | 'Deny';
30
- Action: string | string[];
31
- Resource: string | string[] | {
32
- [key: string]: any;
33
- } | {
34
- [key: string]: any;
35
- }[];
36
- }[];
37
- };
38
- };
39
- type IAMRoleResource = Resource & {
40
- Type: 'AWS::IAM::Role';
41
- Properties: {
42
- AssumeRolePolicyDocument: {
43
- Version: '2012-10-17';
44
- Statement: {
45
- Effect: 'Allow' | 'Deny';
46
- Action: string;
47
- Principal: any;
48
- Condition?: {
49
- [key: string]: any;
50
- };
51
- }[];
52
- };
53
- ManagedPolicyArns?: string[];
54
- Path?: string;
55
- Policies?: Policy[];
56
- };
57
- };
58
- type Resources = {
59
- [key: string]: IAMRoleResource | Resource;
52
+ type Resource = BaseResource & {
53
+ Properties?: Record<string, any>;
60
54
  };
55
+ type Resources = Record<string, Resource>;
61
56
  type Output = {
62
57
  Description?: string;
63
- Value: string | any;
58
+ Value: CloudFormationValue;
64
59
  Export?: {
65
- Name: string | any;
60
+ Name: CloudFormationValue<string>;
66
61
  };
62
+ Condition?: string;
67
63
  };
68
- type Outputs = {
69
- [key: string]: Output;
70
- };
64
+ type Outputs = Record<string, Output>;
71
65
  type CloudFormationTemplate = {
72
66
  AWSTemplateFormatVersion: '2010-09-09';
73
- Metadata?: any;
67
+ Metadata?: Record<string, any>;
74
68
  Description?: string;
75
- Transform?: 'AWS::Serverless-2016-10-31';
76
- Mappings?: any;
77
- Conditions?: any;
69
+ Transform?: 'AWS::Serverless-2016-10-31' | string[];
70
+ Mappings?: Record<string, Record<string, Record<string, string | number>>>;
71
+ Conditions?: Conditions;
78
72
  Parameters?: Parameters;
79
73
  Resources: Resources;
80
74
  Outputs?: Outputs;
package/dist/index.d.ts CHANGED
@@ -2,79 +2,73 @@ import { SchemaComposer, BuildSchemaInput } from '@ttoss/graphql-api';
2
2
  import { AppSyncResolverHandler as AppSyncResolverHandler$1 } from 'aws-lambda';
3
3
  export { AppSyncIdentityCognito } from 'aws-lambda';
4
4
 
5
+ type CloudFormationRef = {
6
+ Ref: string;
7
+ };
8
+ type CloudFormationGetAtt = {
9
+ 'Fn::GetAtt': [string, string];
10
+ };
11
+ type CloudFormationJoin = {
12
+ 'Fn::Join': [string, (string | CloudFormationRef)[]];
13
+ };
14
+ type CloudFormationSub = {
15
+ 'Fn::Sub': string | [string, Record<string, any>];
16
+ };
17
+ type CloudFormationSelect = {
18
+ 'Fn::Select': [number, string[]];
19
+ };
20
+ type CloudFormationSplit = {
21
+ 'Fn::Split': [string, string];
22
+ };
23
+ type CloudFormationIntrinsic = CloudFormationRef | CloudFormationGetAtt | CloudFormationJoin | CloudFormationSub | CloudFormationSelect | CloudFormationSplit;
24
+ type CloudFormationValue<T = any> = T | CloudFormationIntrinsic;
5
25
  type Parameter = {
6
26
  AllowedValues?: string[];
7
- Default?: string | number;
27
+ Default?: string | number | boolean;
8
28
  Description?: string;
9
- Type: string;
29
+ Type: 'String' | 'Number' | 'List<Number>' | 'CommaDelimitedList' | 'AWS::EC2::KeyPair::KeyName' | 'AWS::EC2::SecurityGroup::Id' | 'AWS::EC2::Subnet::Id' | 'AWS::EC2::VPC::Id' | 'List<AWS::EC2::VPC::Id>' | 'List<AWS::EC2::SecurityGroup::Id>' | 'List<AWS::EC2::Subnet::Id>';
10
30
  NoEcho?: boolean;
31
+ MinLength?: number;
32
+ MaxLength?: number;
33
+ MinValue?: number;
34
+ MaxValue?: number;
35
+ AllowedPattern?: string;
36
+ ConstraintDescription?: string;
11
37
  };
12
- type Parameters = {
13
- [key: string]: Parameter;
14
- };
15
- type Resource = {
38
+ type Parameters = Record<string, Parameter>;
39
+ type Condition = Record<string, any>;
40
+ type Conditions = Record<string, Condition>;
41
+ type BaseResource = {
16
42
  Type: string;
17
- DeletionPolicy?: 'Delete' | 'Retain';
43
+ DeletionPolicy?: 'Delete' | 'Retain' | 'Snapshot';
44
+ UpdateReplacePolicy?: 'Delete' | 'Retain' | 'Snapshot';
18
45
  Description?: string;
19
- DependsOn?: string[] | string;
46
+ DependsOn?: string | string[];
20
47
  Condition?: string;
21
- Properties: any;
48
+ Metadata?: Record<string, any>;
49
+ CreationPolicy?: Record<string, any>;
50
+ UpdatePolicy?: Record<string, any>;
22
51
  };
23
- type Policy = {
24
- PolicyName: string;
25
- PolicyDocument: {
26
- Version: '2012-10-17';
27
- Statement: {
28
- Sid?: string;
29
- Effect: 'Allow' | 'Deny';
30
- Action: string | string[];
31
- Resource: string | string[] | {
32
- [key: string]: any;
33
- } | {
34
- [key: string]: any;
35
- }[];
36
- }[];
37
- };
38
- };
39
- type IAMRoleResource = Resource & {
40
- Type: 'AWS::IAM::Role';
41
- Properties: {
42
- AssumeRolePolicyDocument: {
43
- Version: '2012-10-17';
44
- Statement: {
45
- Effect: 'Allow' | 'Deny';
46
- Action: string;
47
- Principal: any;
48
- Condition?: {
49
- [key: string]: any;
50
- };
51
- }[];
52
- };
53
- ManagedPolicyArns?: string[];
54
- Path?: string;
55
- Policies?: Policy[];
56
- };
57
- };
58
- type Resources = {
59
- [key: string]: IAMRoleResource | Resource;
52
+ type Resource = BaseResource & {
53
+ Properties?: Record<string, any>;
60
54
  };
55
+ type Resources = Record<string, Resource>;
61
56
  type Output = {
62
57
  Description?: string;
63
- Value: string | any;
58
+ Value: CloudFormationValue;
64
59
  Export?: {
65
- Name: string | any;
60
+ Name: CloudFormationValue<string>;
66
61
  };
62
+ Condition?: string;
67
63
  };
68
- type Outputs = {
69
- [key: string]: Output;
70
- };
64
+ type Outputs = Record<string, Output>;
71
65
  type CloudFormationTemplate = {
72
66
  AWSTemplateFormatVersion: '2010-09-09';
73
- Metadata?: any;
67
+ Metadata?: Record<string, any>;
74
68
  Description?: string;
75
- Transform?: 'AWS::Serverless-2016-10-31';
76
- Mappings?: any;
77
- Conditions?: any;
69
+ Transform?: 'AWS::Serverless-2016-10-31' | string[];
70
+ Mappings?: Record<string, Record<string, Record<string, string | number>>>;
71
+ Conditions?: Conditions;
78
72
  Parameters?: Parameters;
79
73
  Resources: Resources;
80
74
  Outputs?: Outputs;
package/dist/index.js CHANGED
@@ -201,11 +201,14 @@ var createApiTemplate = ({
201
201
  const apiKey = additionalAuthenticationProviders?.includes("API_KEY") || authenticationType === "API_KEY";
202
202
  const cognitoUserPoolAuth = additionalAuthenticationProviders?.includes("AMAZON_COGNITO_USER_POOLS") || authenticationType === "AMAZON_COGNITO_USER_POOLS";
203
203
  if (additionalAuthenticationProviders) {
204
- template.Resources[AppSyncGraphQLApiLogicalId].Properties.AdditionalAuthenticationProviders = additionalAuthenticationProviders?.map(provider => {
205
- return {
206
- AuthenticationType: provider
207
- };
208
- });
204
+ template.Resources[AppSyncGraphQLApiLogicalId].Properties = {
205
+ ...template.Resources[AppSyncGraphQLApiLogicalId].Properties,
206
+ AdditionalAuthenticationProviders: additionalAuthenticationProviders?.map(provider => {
207
+ return {
208
+ AuthenticationType: provider
209
+ };
210
+ })
211
+ };
209
212
  }
210
213
  if (apiKey) {
211
214
  template.Resources[AppSyncGraphQLApiKeyLogicalId] = {
@@ -229,16 +232,22 @@ var createApiTemplate = ({
229
232
  if (!userPoolConfig) {
230
233
  throw new Error("userPoolConfig is required when using AMAZON_COGNITO_USER_POOLS authentication.");
231
234
  }
232
- template.Resources[AppSyncGraphQLApiLogicalId].Properties.UserPoolConfig = {
233
- AppIdClientRegex: userPoolConfig.appIdClientRegex,
234
- AwsRegion: userPoolConfig.awsRegion,
235
- DefaultAction: userPoolConfig.defaultAction,
236
- UserPoolId: userPoolConfig.userPoolId
235
+ template.Resources[AppSyncGraphQLApiLogicalId].Properties = {
236
+ ...template.Resources[AppSyncGraphQLApiLogicalId].Properties,
237
+ UserPoolConfig: {
238
+ AppIdClientRegex: userPoolConfig.appIdClientRegex,
239
+ AwsRegion: userPoolConfig.awsRegion,
240
+ DefaultAction: userPoolConfig.defaultAction,
241
+ UserPoolId: userPoolConfig.userPoolId
242
+ }
237
243
  };
238
244
  }
239
245
  if (lambdaFunction.environment?.variables) {
240
- template.Resources[AppSyncLambdaFunctionLogicalId].Properties.Environment = {
241
- Variables: lambdaFunction.environment.variables
246
+ template.Resources[AppSyncLambdaFunctionLogicalId].Properties = {
247
+ ...template.Resources[AppSyncLambdaFunctionLogicalId].Properties,
248
+ Environment: {
249
+ Variables: lambdaFunction.environment.variables
250
+ }
242
251
  };
243
252
  }
244
253
  if (customDomain) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/appsync-api",
3
- "version": "0.21.1",
3
+ "version": "0.22.0",
4
4
  "description": "A library for building GraphQL APIs for AWS AppSync.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -24,21 +24,21 @@
24
24
  ],
25
25
  "sideEffects": false,
26
26
  "dependencies": {
27
- "@ttoss/cloudformation": "^0.10.19"
27
+ "@ttoss/cloudformation": "^0.11.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "graphql": "^16.6.0",
31
- "@ttoss/graphql-api": "^0.8.6"
31
+ "@ttoss/graphql-api": "^0.8.7"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/aws-lambda": "^8.10.146",
35
- "graphql": "^16.9.0",
34
+ "@types/aws-lambda": "^8.10.152",
35
+ "graphql": "^16.11.0",
36
36
  "graphql-shield": "^7.6.5",
37
37
  "jest": "^30.0.4",
38
38
  "tsup": "^8.5.0",
39
- "@ttoss/config": "^1.35.5",
40
- "@ttoss/graphql-api": "^0.8.6",
41
- "@ttoss/ids": "^0.3.5"
39
+ "@ttoss/ids": "^0.3.6",
40
+ "@ttoss/config": "^1.35.6",
41
+ "@ttoss/graphql-api": "^0.8.7"
42
42
  },
43
43
  "keywords": [
44
44
  "api",