@mbc-cqrs-serverless/cli 0.1.4-beta.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.
Files changed (65) hide show
  1. package/package.json +39 -0
  2. package/templates/.env.local +54 -0
  3. package/templates/.envrc +3 -0
  4. package/templates/.eslintrc.js +50 -0
  5. package/templates/.prettierrc +8 -0
  6. package/templates/README.md +168 -0
  7. package/templates/gitignore +46 -0
  8. package/templates/infra-local/appsync-simulator/.dockerignore +1 -0
  9. package/templates/infra-local/appsync-simulator/Dockerfile +8 -0
  10. package/templates/infra-local/appsync-simulator/package-lock.json +7179 -0
  11. package/templates/infra-local/appsync-simulator/package.json +30 -0
  12. package/templates/infra-local/appsync-simulator/src/main.ts +61 -0
  13. package/templates/infra-local/appsync-simulator/src/resolversConfig.ts +19 -0
  14. package/templates/infra-local/appsync-simulator/src/schema.graphql +28 -0
  15. package/templates/infra-local/appsync-simulator/src/schema.ts +7 -0
  16. package/templates/infra-local/appsync-simulator/src/vtl/readVTL.ts +6 -0
  17. package/templates/infra-local/appsync-simulator/src/vtl/sendMessage.req.vtl +4 -0
  18. package/templates/infra-local/appsync-simulator/src/vtl/sendMessage.res.vtl +1 -0
  19. package/templates/infra-local/cognito-local/.dockerignore +1 -0
  20. package/templates/infra-local/cognito-local/Dockerfile +9 -0
  21. package/templates/infra-local/cognito-local/db/clients.json +17 -0
  22. package/templates/infra-local/cognito-local/db/local_2G7noHgW.json +282 -0
  23. package/templates/infra-local/cognito-local/package-lock.json +2321 -0
  24. package/templates/infra-local/cognito-local/package.json +17 -0
  25. package/templates/infra-local/cognito-local/patches/cognito-local+3.23.2.patch +57 -0
  26. package/templates/infra-local/docker-compose.yml +91 -0
  27. package/templates/infra-local/elasticmq.conf +23 -0
  28. package/templates/infra-local/resources.sh +11 -0
  29. package/templates/infra-local/scripts/trigger_ddb_stream.sh +69 -0
  30. package/templates/infra-local/serverless.yml +306 -0
  31. package/templates/jest.config.js +4 -0
  32. package/templates/nest-cli.json +16 -0
  33. package/templates/package.json +118 -0
  34. package/templates/prisma/ddb.ts +232 -0
  35. package/templates/prisma/dynamodbs/cqrs.json +1 -0
  36. package/templates/prisma/dynamodbs/cqrs_desc.json +18 -0
  37. package/templates/prisma/dynamodbs/sequences.json +14 -0
  38. package/templates/prisma/dynamodbs/tasks.json +18 -0
  39. package/templates/prisma/schema.prisma +45 -0
  40. package/templates/src/event-factory.ts +7 -0
  41. package/templates/src/helpers/get-order.ts +19 -0
  42. package/templates/src/helpers/index.ts +1 -0
  43. package/templates/src/main.module.ts +26 -0
  44. package/templates/src/main.ts +7 -0
  45. package/templates/src/master/dto/master-attributes.dto.ts +6 -0
  46. package/templates/src/master/dto/master-command.dto.ts +12 -0
  47. package/templates/src/master/entity/master-command.entity.ts +13 -0
  48. package/templates/src/master/entity/master-data-list.entity.ts +13 -0
  49. package/templates/src/master/entity/master-data.entity.ts +13 -0
  50. package/templates/src/master/handler/master-rds.handler.ts +59 -0
  51. package/templates/src/master/master.controller.ts +83 -0
  52. package/templates/src/master/master.module.ts +19 -0
  53. package/templates/src/master/master.service.ts +58 -0
  54. package/templates/src/prisma/index.ts +5 -0
  55. package/templates/src/prisma/interfaces/index.ts +1 -0
  56. package/templates/src/prisma/interfaces/prisma-module-options.interface.ts +50 -0
  57. package/templates/src/prisma/prisma.constants.ts +2 -0
  58. package/templates/src/prisma/prisma.logging.middleware.ts +20 -0
  59. package/templates/src/prisma/prisma.module.ts +75 -0
  60. package/templates/src/prisma/prisma.service.ts +45 -0
  61. package/templates/src/repl.ts +21 -0
  62. package/templates/test/api.http +42 -0
  63. package/templates/test/jest-e2e.json +9 -0
  64. package/templates/tsconfig.build.json +4 -0
  65. package/templates/tsconfig.json +25 -0
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "appsync-simulator-starter-kit",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "serve": "ts-node src/main.ts"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/Cox65/appsync-simulator-starter-kit.git"
12
+ },
13
+ "keywords": [],
14
+ "author": "",
15
+ "license": "ISC",
16
+ "bugs": {
17
+ "url": "https://github.com/Cox65/appsync-simulator-starter-kit/issues"
18
+ },
19
+ "homepage": "https://github.com/Cox65/appsync-simulator-starter-kit#readme",
20
+ "devDependencies": {
21
+ "@types/aws-lambda": "^8.10.109",
22
+ "@types/node": "^18.11.18",
23
+ "ts-node": "^10.9.1",
24
+ "ts-node-dev": "^2.0.0",
25
+ "typescript": "^4.9.4"
26
+ },
27
+ "dependencies": {
28
+ "amplify-appsync-simulator": "https://github.com/tabk30/amplify-appsync-simulator.git"
29
+ }
30
+ }
@@ -0,0 +1,61 @@
1
+ import {
2
+ AmplifyAppSyncSimulator,
3
+ AmplifyAppSyncSimulatorAuthenticationType,
4
+ AmplifyAppSyncSimulatorConfig,
5
+ } from 'amplify-appsync-simulator';
6
+
7
+ import { schema } from './schema';
8
+ import { readVTL } from './vtl/readVTL';
9
+ import { resolversConfig } from './resolversConfig';
10
+
11
+ class AppSyncSimulator {
12
+ httpPort: number;
13
+
14
+ constructor(httpPort: number) {
15
+ this.httpPort = httpPort;
16
+ }
17
+
18
+ async start() {
19
+ const simulatorConfig: AmplifyAppSyncSimulatorConfig = {
20
+ appSync: {
21
+ defaultAuthenticationType: {
22
+ authenticationType: AmplifyAppSyncSimulatorAuthenticationType.API_KEY,
23
+ },
24
+ name: 'api-local',
25
+ additionalAuthenticationProviders: [],
26
+ apiKey: process.env.API_KEY || 'api_key',
27
+ },
28
+ schema: { content: schema },
29
+ mappingTemplates: [
30
+ {
31
+ path: 'sendMessage.req.vtl',
32
+ content: readVTL('sendMessage.req.vtl'),
33
+ },
34
+ {
35
+ path: 'sendMessage.res.vtl',
36
+ content: readVTL('sendMessage.res.vtl'),
37
+ },
38
+ ],
39
+ dataSources: [
40
+ {
41
+ type: 'NONE',
42
+ name: 'NoneDS',
43
+ },
44
+ ],
45
+ resolvers: resolversConfig,
46
+ };
47
+ const amplifySimulator = new AmplifyAppSyncSimulator({
48
+ port: this.httpPort,
49
+ });
50
+ await amplifySimulator.start();
51
+ await amplifySimulator.init(simulatorConfig);
52
+ }
53
+ }
54
+
55
+ const httpPort = Number(process.env.PORT) || 4000;
56
+ const simulator = new AppSyncSimulator(httpPort);
57
+ simulator.start().then(() => {
58
+ console.log(
59
+ `🚀 App Sync Simulator started at http://localhost:${httpPort}/graphql`,
60
+ );
61
+ });
@@ -0,0 +1,19 @@
1
+ import {
2
+ AppSyncSimulatorPipelineResolverConfig,
3
+ AppSyncSimulatorUnitResolverConfig,
4
+ RESOLVER_KIND,
5
+ } from 'amplify-appsync-simulator';
6
+
7
+ export const resolversConfig: (
8
+ | AppSyncSimulatorPipelineResolverConfig
9
+ | AppSyncSimulatorUnitResolverConfig
10
+ )[] = [
11
+ {
12
+ kind: RESOLVER_KIND.UNIT,
13
+ typeName: 'Mutation',
14
+ fieldName: 'sendMessage',
15
+ dataSourceName: 'NoneDS',
16
+ requestMappingTemplateLocation: 'sendMessage.req.vtl',
17
+ responseMappingTemplateLocation: 'sendMessage.res.vtl',
18
+ },
19
+ ];
@@ -0,0 +1,28 @@
1
+ type Message {
2
+ id: String!
3
+ table: String!
4
+ pk: String!
5
+ sk: String!
6
+ tenantCode: String!
7
+ action: String!
8
+ content: AWSJSON!
9
+ }
10
+
11
+ type Query {
12
+ getMessage(id: String!): Message
13
+ }
14
+
15
+ type Mutation {
16
+ sendMessage(message: AWSJSON!): Message!
17
+ }
18
+
19
+ type Subscription {
20
+ onMessage(tenantCode: String!, action: String, id: String): Message
21
+ @aws_subscribe(mutations: ["sendMessage"])
22
+ }
23
+
24
+ schema {
25
+ query: Query
26
+ mutation: Mutation
27
+ subscription: Subscription
28
+ }
@@ -0,0 +1,7 @@
1
+ import { readFileSync } from 'fs';
2
+ import { resolve } from 'path';
3
+
4
+ export const schema = readFileSync(
5
+ resolve(__dirname, 'schema.graphql'),
6
+ 'utf8',
7
+ );
@@ -0,0 +1,6 @@
1
+ import { readFileSync } from 'fs'
2
+ import { resolve } from 'path'
3
+
4
+ export const readVTL = (filename: string) => {
5
+ return readFileSync(resolve(__dirname, filename), 'utf8')
6
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "version": "2018-05-29",
3
+ "payload": $util.toJson($context.arguments.message)
4
+ }
@@ -0,0 +1 @@
1
+ $util.toJson($context.result)
@@ -0,0 +1 @@
1
+ node_modules
@@ -0,0 +1,9 @@
1
+ FROM node:18-alpine
2
+ WORKDIR /app
3
+
4
+ COPY ./package.json ./
5
+ COPY ./package-lock.json ./
6
+ RUN npm install --legacy-peer-deps
7
+ COPY . .
8
+ EXPOSE 9229
9
+ CMD ["npm", "run", "dev"]
@@ -0,0 +1,17 @@
1
+ {
2
+ "Clients": {
3
+ "dnk8y7ii3wled35p3lw0l2cd7": {
4
+ "AccessTokenValidity": 30,
5
+ "ClientId": "dnk8y7ii3wled35p3lw0l2cd7",
6
+ "ClientName": "local_cognito_fw",
7
+ "CreationDate": "2023-11-14T01:22:54.529Z",
8
+ "LastModifiedDate": "2023-11-14T01:22:54.529Z",
9
+ "TokenValidityUnits": {
10
+ "AccessToken": "hours",
11
+ "IdToken": "minutes",
12
+ "RefreshToken": "days"
13
+ },
14
+ "UserPoolId": "local_2G7noHgW"
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,282 @@
1
+ {
2
+ "Users": {
3
+ "admin2": {
4
+ "Attributes": [
5
+ {
6
+ "Name": "sub",
7
+ "Value": "92ca4f68-9ac6-4080-9ae2-2f02a86206a4"
8
+ },
9
+ {
10
+ "Name": "email",
11
+ "Value": "admin@test.com"
12
+ },
13
+ {
14
+ "Name": "custom:roles",
15
+ "Value": "[{\"role\":\"system_admin\"}]"
16
+ }
17
+ ],
18
+ "Enabled": true,
19
+ "Password": "admin1234",
20
+ "RefreshTokens": [],
21
+ "UserCreateDate": "2023-11-14T01:26:22.636Z",
22
+ "UserLastModifiedDate": "2023-11-14T01:27:48.505Z",
23
+ "Username": "admin2",
24
+ "UserStatus": "CONFIRMED"
25
+ }
26
+ },
27
+ "Options": {
28
+ "Policies": {
29
+ "PasswordPolicy": {
30
+ "MinimumLength": 8,
31
+ "RequireUppercase": true,
32
+ "RequireLowercase": true,
33
+ "RequireNumbers": true,
34
+ "RequireSymbols": true,
35
+ "TemporaryPasswordValidityDays": 7
36
+ }
37
+ },
38
+ "LambdaConfig": {},
39
+ "SchemaAttributes": [
40
+ {
41
+ "Name": "sub",
42
+ "AttributeDataType": "String",
43
+ "DeveloperOnlyAttribute": false,
44
+ "Mutable": false,
45
+ "Required": true,
46
+ "StringAttributeConstraints": {
47
+ "MinLength": "1",
48
+ "MaxLength": "2048"
49
+ }
50
+ },
51
+ {
52
+ "Name": "name",
53
+ "AttributeDataType": "String",
54
+ "DeveloperOnlyAttribute": false,
55
+ "Mutable": true,
56
+ "Required": false,
57
+ "StringAttributeConstraints": {
58
+ "MinLength": "0",
59
+ "MaxLength": "2048"
60
+ }
61
+ },
62
+ {
63
+ "Name": "given_name",
64
+ "AttributeDataType": "String",
65
+ "DeveloperOnlyAttribute": false,
66
+ "Mutable": true,
67
+ "Required": false,
68
+ "StringAttributeConstraints": {
69
+ "MinLength": "0",
70
+ "MaxLength": "2048"
71
+ }
72
+ },
73
+ {
74
+ "Name": "family_name",
75
+ "AttributeDataType": "String",
76
+ "DeveloperOnlyAttribute": false,
77
+ "Mutable": true,
78
+ "Required": false,
79
+ "StringAttributeConstraints": {
80
+ "MinLength": "0",
81
+ "MaxLength": "2048"
82
+ }
83
+ },
84
+ {
85
+ "Name": "middle_name",
86
+ "AttributeDataType": "String",
87
+ "DeveloperOnlyAttribute": false,
88
+ "Mutable": true,
89
+ "Required": false,
90
+ "StringAttributeConstraints": {
91
+ "MinLength": "0",
92
+ "MaxLength": "2048"
93
+ }
94
+ },
95
+ {
96
+ "Name": "nickname",
97
+ "AttributeDataType": "String",
98
+ "DeveloperOnlyAttribute": false,
99
+ "Mutable": true,
100
+ "Required": false,
101
+ "StringAttributeConstraints": {
102
+ "MinLength": "0",
103
+ "MaxLength": "2048"
104
+ }
105
+ },
106
+ {
107
+ "Name": "preferred_username",
108
+ "AttributeDataType": "String",
109
+ "DeveloperOnlyAttribute": false,
110
+ "Mutable": true,
111
+ "Required": false,
112
+ "StringAttributeConstraints": {
113
+ "MinLength": "0",
114
+ "MaxLength": "2048"
115
+ }
116
+ },
117
+ {
118
+ "Name": "profile",
119
+ "AttributeDataType": "String",
120
+ "DeveloperOnlyAttribute": false,
121
+ "Mutable": true,
122
+ "Required": false,
123
+ "StringAttributeConstraints": {
124
+ "MinLength": "0",
125
+ "MaxLength": "2048"
126
+ }
127
+ },
128
+ {
129
+ "Name": "picture",
130
+ "AttributeDataType": "String",
131
+ "DeveloperOnlyAttribute": false,
132
+ "Mutable": true,
133
+ "Required": false,
134
+ "StringAttributeConstraints": {
135
+ "MinLength": "0",
136
+ "MaxLength": "2048"
137
+ }
138
+ },
139
+ {
140
+ "Name": "website",
141
+ "AttributeDataType": "String",
142
+ "DeveloperOnlyAttribute": false,
143
+ "Mutable": true,
144
+ "Required": false,
145
+ "StringAttributeConstraints": {
146
+ "MinLength": "0",
147
+ "MaxLength": "2048"
148
+ }
149
+ },
150
+ {
151
+ "Name": "email",
152
+ "AttributeDataType": "String",
153
+ "DeveloperOnlyAttribute": false,
154
+ "Mutable": true,
155
+ "Required": false,
156
+ "StringAttributeConstraints": {
157
+ "MinLength": "0",
158
+ "MaxLength": "2048"
159
+ }
160
+ },
161
+ {
162
+ "Name": "email_verified",
163
+ "AttributeDataType": "Boolean",
164
+ "DeveloperOnlyAttribute": false,
165
+ "Mutable": true,
166
+ "Required": false
167
+ },
168
+ {
169
+ "Name": "gender",
170
+ "AttributeDataType": "String",
171
+ "DeveloperOnlyAttribute": false,
172
+ "Mutable": true,
173
+ "Required": false,
174
+ "StringAttributeConstraints": {
175
+ "MinLength": "0",
176
+ "MaxLength": "2048"
177
+ }
178
+ },
179
+ {
180
+ "Name": "birthdate",
181
+ "AttributeDataType": "String",
182
+ "DeveloperOnlyAttribute": false,
183
+ "Mutable": true,
184
+ "Required": false,
185
+ "StringAttributeConstraints": {
186
+ "MinLength": "10",
187
+ "MaxLength": "10"
188
+ }
189
+ },
190
+ {
191
+ "Name": "zoneinfo",
192
+ "AttributeDataType": "String",
193
+ "DeveloperOnlyAttribute": false,
194
+ "Mutable": true,
195
+ "Required": false,
196
+ "StringAttributeConstraints": {
197
+ "MinLength": "0",
198
+ "MaxLength": "2048"
199
+ }
200
+ },
201
+ {
202
+ "Name": "locale",
203
+ "AttributeDataType": "String",
204
+ "DeveloperOnlyAttribute": false,
205
+ "Mutable": true,
206
+ "Required": false,
207
+ "StringAttributeConstraints": {
208
+ "MinLength": "0",
209
+ "MaxLength": "2048"
210
+ }
211
+ },
212
+ {
213
+ "Name": "phone_number",
214
+ "AttributeDataType": "String",
215
+ "DeveloperOnlyAttribute": false,
216
+ "Mutable": true,
217
+ "Required": false,
218
+ "StringAttributeConstraints": {
219
+ "MinLength": "0",
220
+ "MaxLength": "2048"
221
+ }
222
+ },
223
+ {
224
+ "Name": "phone_number_verified",
225
+ "AttributeDataType": "Boolean",
226
+ "DeveloperOnlyAttribute": false,
227
+ "Mutable": true,
228
+ "Required": false
229
+ },
230
+ {
231
+ "Name": "address",
232
+ "AttributeDataType": "String",
233
+ "DeveloperOnlyAttribute": false,
234
+ "Mutable": true,
235
+ "Required": false,
236
+ "StringAttributeConstraints": {
237
+ "MinLength": "0",
238
+ "MaxLength": "2048"
239
+ }
240
+ },
241
+ {
242
+ "Name": "updated_at",
243
+ "AttributeDataType": "Number",
244
+ "DeveloperOnlyAttribute": false,
245
+ "Mutable": true,
246
+ "Required": false,
247
+ "NumberAttributeConstraints": {
248
+ "MinValue": "0"
249
+ }
250
+ },
251
+ {
252
+ "Name": "custom:roles",
253
+ "AttributeDataType": "String",
254
+ "DeveloperOnlyAttribute": false,
255
+ "Mutable": true,
256
+ "Required": false,
257
+ "StringAttributeConstraints": {
258
+ "MinLength": "1",
259
+ "MaxLength": "10"
260
+ }
261
+ }
262
+ ],
263
+ "VerificationMessageTemplate": {
264
+ "DefaultEmailOption": "CONFIRM_WITH_CODE"
265
+ },
266
+ "MfaConfiguration": "OFF",
267
+ "EstimatedNumberOfUsers": 0,
268
+ "EmailConfiguration": {
269
+ "EmailSendingAccount": "COGNITO_DEFAULT"
270
+ },
271
+ "AdminCreateUserConfig": {
272
+ "AllowAdminCreateUserOnly": false,
273
+ "UnusedAccountValidityDays": 7
274
+ },
275
+ "UsernameAttributes": ["email"],
276
+ "Arn": "arn:aws:cognito-idp:local:local:userpool/local_2G7noHgW",
277
+ "CreationDate": "2023-11-14T01:22:17.775Z",
278
+ "Id": "local_2G7noHgW",
279
+ "LastModifiedDate": "2023-11-14T01:22:17.775Z",
280
+ "Name": "user_pool_name"
281
+ }
282
+ }