@aws/nx-plugin 0.33.1 → 0.35.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/generators.json +6 -0
- package/package.json +1 -1
- package/src/mcp-server/tools/create-workspace-command.js +1 -8
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/open-api/ts-hooks/generator.spec.tsx +1 -4
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/py/lambda-function/schema.json +2 -5
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +134 -0
- package/src/ts/lambda-function/files/common/constructs/src/app/lambda-functions/__constructFunctionNameKebabCase__.ts.template +24 -0
- package/src/ts/lambda-function/files/handler/__lambdaFunctionKebabCase__.ts.template +72 -0
- package/src/ts/lambda-function/generator.d.ts +13 -0
- package/src/ts/lambda-function/generator.js +133 -0
- package/src/ts/lambda-function/generator.js.map +1 -0
- package/src/ts/lambda-function/io.d.ts +178 -0
- package/src/ts/lambda-function/io.js +182 -0
- package/src/ts/lambda-function/io.js.map +1 -0
- package/src/ts/lambda-function/schema.d.ts +55 -0
- package/src/ts/lambda-function/schema.json +82 -0
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +41 -314
- package/src/ts/mcp-server/files/index.ts.template +17 -0
- package/src/ts/mcp-server/files/resources/sample-guidance.ts.template +9 -0
- package/src/ts/mcp-server/files/server.ts.template +18 -0
- package/src/ts/mcp-server/files/tools/add.ts.template +11 -0
- package/src/ts/mcp-server/generator.js +42 -31
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.ts +4 -2
- package/src/ts/mcp-server/schema.json +9 -16
- package/src/utils/versions.d.ts +3 -1
- package/src/utils/versions.js +2 -0
- package/src/utils/versions.js.map +1 -1
- package/src/ts/mcp-server/files/README.md.template +0 -108
- package/src/ts/mcp-server/files/src/global.d.ts.template +0 -4
- package/src/ts/mcp-server/files/src/index.ts.template +0 -6
- package/src/ts/mcp-server/files/src/resources/example-context.md +0 -3
- package/src/ts/mcp-server/files/src/server.ts.template +0 -28
package/generators.json
CHANGED
|
@@ -59,6 +59,12 @@
|
|
|
59
59
|
"metric": "g8",
|
|
60
60
|
"guidePages": ["typescript-infrastructure"]
|
|
61
61
|
},
|
|
62
|
+
"ts#lambda-function": {
|
|
63
|
+
"factory": "./src/ts/lambda-function/generator",
|
|
64
|
+
"schema": "./src/ts/lambda-function/schema.json",
|
|
65
|
+
"description": "Generate a TypeScript lambda function",
|
|
66
|
+
"metric": "g21"
|
|
67
|
+
},
|
|
62
68
|
"ts#trpc-api": {
|
|
63
69
|
"factory": "./src/trpc/backend/generator",
|
|
64
70
|
"schema": "./src/trpc/backend/schema.json",
|
package/package.json
CHANGED
|
@@ -17,14 +17,7 @@ const addCreateWorkspaceCommandTool = (server) => {
|
|
|
17
17
|
npx create-nx-workspace@~21.0.3 ${workspaceName} --pm=${packageManager} --preset=@aws/nx-plugin --ci=skip
|
|
18
18
|
\`\`\`
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
you would like for your workspace, you can move all the files up one level and delete the empty directory afterwards, eg:
|
|
22
|
-
|
|
23
|
-
\`\`\`bash
|
|
24
|
-
mv ${workspaceName}/{*,.*} ./ && rm -rf ${workspaceName}
|
|
25
|
-
\`\`\`
|
|
26
|
-
|
|
27
|
-
(Note that the above command will complain about moving . and .. but that is expected and ok!)
|
|
20
|
+
This will create a new workspace within the ${workspaceName} directory.
|
|
28
21
|
`,
|
|
29
22
|
},
|
|
30
23
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-workspace-command.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/create-workspace-command.ts"],"names":[],"mappings":";;;AAKA,6BAAwB;AACxB,sCAAiD;AAEjD;;GAEG;AACI,MAAM,6BAA6B,GAAG,CAAC,MAAiB,EAAE,EAAE;IACjE,MAAM,CAAC,IAAI,CACT,0BAA0B,EAC1B,oEAAoE,EACpE,EAAE,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,6BAAoB,EAAE,EACnE,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;QACtC,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE;;;kCAGkB,aAAa,SAAS,cAAc;;;
|
|
1
|
+
{"version":3,"file":"create-workspace-command.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/create-workspace-command.ts"],"names":[],"mappings":";;;AAKA,6BAAwB;AACxB,sCAAiD;AAEjD;;GAEG;AACI,MAAM,6BAA6B,GAAG,CAAC,MAAiB,EAAE,EAAE;IACjE,MAAM,CAAC,IAAI,CACT,0BAA0B,EAC1B,oEAAoE,EACpE,EAAE,aAAa,EAAE,OAAC,CAAC,MAAM,EAAE,EAAE,cAAc,EAAE,6BAAoB,EAAE,EACnE,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC,CAAC;QACtC,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE;;;kCAGkB,aAAa,SAAS,cAAc;;;8CAGxB,aAAa;GACxD;aACM;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,6BAA6B,iCAqBxC"}
|
|
@@ -6,10 +6,6 @@ import { Tree } from '@nx/devkit';
|
|
|
6
6
|
import { createTreeUsingTsSolutionSetup } from '../../utils/test';
|
|
7
7
|
import { Spec } from '../utils/types';
|
|
8
8
|
import { openApiTsHooksGenerator } from './generator';
|
|
9
|
-
import {
|
|
10
|
-
expectTypeScriptToCompile,
|
|
11
|
-
TypeScriptVerifier,
|
|
12
|
-
} from '../ts-client/generator.utils.spec';
|
|
13
9
|
import { importTypeScriptModule } from '../../utils/js';
|
|
14
10
|
import { waitFor, render, fireEvent } from '@testing-library/react';
|
|
15
11
|
import {
|
|
@@ -25,6 +21,7 @@ import {
|
|
|
25
21
|
import React from 'react';
|
|
26
22
|
import { Mock } from 'vitest';
|
|
27
23
|
import { PET_STORE_SPEC } from '../ts-client/generator.petstore.spec';
|
|
24
|
+
import { TypeScriptVerifier } from '../../utils/test/ts.spec';
|
|
28
25
|
|
|
29
26
|
describe('openApiTsHooksGenerator', () => {
|
|
30
27
|
let tree: Tree;
|
|
@@ -42,6 +42,8 @@ The following list of generators are what is currently available in the \`@aws/n
|
|
|
42
42
|
|
|
43
43
|
- **ts#infra**: Generates a cdk application
|
|
44
44
|
|
|
45
|
+
- **ts#lambda-function**: Generate a TypeScript lambda function
|
|
46
|
+
|
|
45
47
|
- **ts#trpc-api**: creates a trpc backend
|
|
46
48
|
|
|
47
49
|
- **api-connection**: Integrates a source project with a target API project
|
|
@@ -8,10 +8,6 @@
|
|
|
8
8
|
"project": {
|
|
9
9
|
"type": "string",
|
|
10
10
|
"description": "The project to add the lambda function to",
|
|
11
|
-
"$default": {
|
|
12
|
-
"$source": "argv",
|
|
13
|
-
"index": 0
|
|
14
|
-
},
|
|
15
11
|
"x-prompt": "Select the project to add the lambda function to",
|
|
16
12
|
"x-dropdown": "projects"
|
|
17
13
|
},
|
|
@@ -33,6 +29,7 @@
|
|
|
33
29
|
"eventSource": {
|
|
34
30
|
"type": "string",
|
|
35
31
|
"description": "Optional event source model to use for the lambda function",
|
|
32
|
+
"x-priority": "important",
|
|
36
33
|
"enum": [
|
|
37
34
|
"Any",
|
|
38
35
|
"AlbModel",
|
|
@@ -79,5 +76,5 @@
|
|
|
79
76
|
"x-prompt": "Enter the event source model to use for the lambda function"
|
|
80
77
|
}
|
|
81
78
|
},
|
|
82
|
-
"required": ["project", "functionName"
|
|
79
|
+
"required": ["project", "functionName"]
|
|
83
80
|
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`ts-lambda-function generator > should create CDK construct > cdk-construct.ts 1`] = `
|
|
4
|
+
"import { Construct } from 'constructs';
|
|
5
|
+
import * as url from 'url';
|
|
6
|
+
import { Code, Function, Runtime, Tracing } from 'aws-cdk-lib/aws-lambda';
|
|
7
|
+
import { Duration } from 'aws-cdk-lib';
|
|
8
|
+
|
|
9
|
+
export class TestProjectTestFunction extends Function {
|
|
10
|
+
constructor(scope: Construct, id: string) {
|
|
11
|
+
super(scope, id, {
|
|
12
|
+
timeout: Duration.seconds(30),
|
|
13
|
+
runtime: Runtime.NODEJS_LATEST,
|
|
14
|
+
handler: 'index.handler',
|
|
15
|
+
code: Code.fromAsset(
|
|
16
|
+
url.fileURLToPath(
|
|
17
|
+
new URL(
|
|
18
|
+
'../../../../../../dist/packages/test-project/bundle-test-function',
|
|
19
|
+
import.meta.url,
|
|
20
|
+
),
|
|
21
|
+
),
|
|
22
|
+
),
|
|
23
|
+
tracing: Tracing.ACTIVE,
|
|
24
|
+
environment: {
|
|
25
|
+
AWS_CONNECTION_REUSE_ENABLED: '1',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
"
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
exports[`ts-lambda-function generator > should create lambda function file with Any event source > lambda-handler-any.ts 1`] = `
|
|
34
|
+
"import middy from '@middy/core';
|
|
35
|
+
import { Tracer } from '@aws-lambda-powertools/tracer';
|
|
36
|
+
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';
|
|
37
|
+
import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware';
|
|
38
|
+
import { Logger } from '@aws-lambda-powertools/logger';
|
|
39
|
+
import { Metrics } from '@aws-lambda-powertools/metrics';
|
|
40
|
+
import { logMetrics } from '@aws-lambda-powertools/metrics/middleware';
|
|
41
|
+
|
|
42
|
+
process.env.POWERTOOLS_METRICS_NAMESPACE = 'TestFunction';
|
|
43
|
+
process.env.POWERTOOLS_SERVICE_NAME = 'TestFunction';
|
|
44
|
+
|
|
45
|
+
const tracer = new Tracer();
|
|
46
|
+
const logger = new Logger();
|
|
47
|
+
const metrics = new Metrics();
|
|
48
|
+
|
|
49
|
+
export const testFunction = async (event: any): Promise<any> => {
|
|
50
|
+
logger.info('Received event', event);
|
|
51
|
+
|
|
52
|
+
// TODO: implement
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const handler = middy()
|
|
56
|
+
.use(captureLambdaHandler(tracer))
|
|
57
|
+
.use(injectLambdaContext(logger))
|
|
58
|
+
.use(logMetrics(metrics))
|
|
59
|
+
.handler(testFunction);
|
|
60
|
+
"
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
exports[`ts-lambda-function generator > should create lambda function file with EventBridge schema > lambda-handler-eventbridge.ts 1`] = `
|
|
64
|
+
"import { parser } from '@aws-lambda-powertools/parser/middleware';
|
|
65
|
+
import { EventBridgeSchema } from '@aws-lambda-powertools/parser/schemas';
|
|
66
|
+
import { z } from 'zod';
|
|
67
|
+
import middy from '@middy/core';
|
|
68
|
+
import { Tracer } from '@aws-lambda-powertools/tracer';
|
|
69
|
+
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';
|
|
70
|
+
import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware';
|
|
71
|
+
import { Logger } from '@aws-lambda-powertools/logger';
|
|
72
|
+
import { Metrics } from '@aws-lambda-powertools/metrics';
|
|
73
|
+
import { logMetrics } from '@aws-lambda-powertools/metrics/middleware';
|
|
74
|
+
|
|
75
|
+
process.env.POWERTOOLS_METRICS_NAMESPACE = 'TestFunction';
|
|
76
|
+
process.env.POWERTOOLS_SERVICE_NAME = 'TestFunction';
|
|
77
|
+
|
|
78
|
+
const tracer = new Tracer();
|
|
79
|
+
const logger = new Logger();
|
|
80
|
+
const metrics = new Metrics();
|
|
81
|
+
|
|
82
|
+
export const testFunction = async (
|
|
83
|
+
event: z.infer<typeof EventBridgeSchema>,
|
|
84
|
+
): Promise<void> => {
|
|
85
|
+
logger.info('Received event', event);
|
|
86
|
+
|
|
87
|
+
// TODO: implement
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export const handler = middy()
|
|
91
|
+
.use(captureLambdaHandler(tracer))
|
|
92
|
+
.use(injectLambdaContext(logger))
|
|
93
|
+
.use(logMetrics(metrics))
|
|
94
|
+
.use(parser({ schema: EventBridgeSchema }))
|
|
95
|
+
.handler(testFunction);
|
|
96
|
+
"
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
exports[`ts-lambda-function generator > should create lambda function file with SQS schema > lambda-handler-sqs.ts 1`] = `
|
|
100
|
+
"import { parser } from '@aws-lambda-powertools/parser/middleware';
|
|
101
|
+
import { SqsSchema } from '@aws-lambda-powertools/parser/schemas';
|
|
102
|
+
import { z } from 'zod';
|
|
103
|
+
import middy from '@middy/core';
|
|
104
|
+
import { Tracer } from '@aws-lambda-powertools/tracer';
|
|
105
|
+
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';
|
|
106
|
+
import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware';
|
|
107
|
+
import { Logger } from '@aws-lambda-powertools/logger';
|
|
108
|
+
import { Metrics } from '@aws-lambda-powertools/metrics';
|
|
109
|
+
import { logMetrics } from '@aws-lambda-powertools/metrics/middleware';
|
|
110
|
+
import type { SQSBatchResponse } from 'aws-lambda';
|
|
111
|
+
|
|
112
|
+
process.env.POWERTOOLS_METRICS_NAMESPACE = 'TestFunction';
|
|
113
|
+
process.env.POWERTOOLS_SERVICE_NAME = 'TestFunction';
|
|
114
|
+
|
|
115
|
+
const tracer = new Tracer();
|
|
116
|
+
const logger = new Logger();
|
|
117
|
+
const metrics = new Metrics();
|
|
118
|
+
|
|
119
|
+
export const testFunction = async (
|
|
120
|
+
event: z.infer<typeof SqsSchema>,
|
|
121
|
+
): Promise<SQSBatchResponse | void> => {
|
|
122
|
+
logger.info('Received event', event);
|
|
123
|
+
|
|
124
|
+
// TODO: implement
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const handler = middy()
|
|
128
|
+
.use(captureLambdaHandler(tracer))
|
|
129
|
+
.use(injectLambdaContext(logger))
|
|
130
|
+
.use(logMetrics(metrics))
|
|
131
|
+
.use(parser({ schema: SqsSchema }))
|
|
132
|
+
.handler(testFunction);
|
|
133
|
+
"
|
|
134
|
+
`;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Construct } from 'constructs';
|
|
2
|
+
import * as url from 'url';
|
|
3
|
+
import { Code, Function, Runtime, Tracing } from 'aws-cdk-lib/aws-lambda';
|
|
4
|
+
import { Duration } from 'aws-cdk-lib';
|
|
5
|
+
|
|
6
|
+
export class <%= constructFunctionClassName %> extends Function {
|
|
7
|
+
constructor(scope: Construct, id: string) {
|
|
8
|
+
super(scope, id, {
|
|
9
|
+
timeout: Duration.seconds(30),
|
|
10
|
+
runtime: Runtime.NODEJS_LATEST,
|
|
11
|
+
handler: 'index.handler',
|
|
12
|
+
code: Code.fromAsset(url.fileURLToPath(
|
|
13
|
+
new URL(
|
|
14
|
+
'../../../../../../dist/<%= dir %>/<%= bundleTargetName %>',
|
|
15
|
+
import.meta.url
|
|
16
|
+
)
|
|
17
|
+
)),
|
|
18
|
+
tracing: Tracing.ACTIVE,
|
|
19
|
+
environment: {
|
|
20
|
+
AWS_CONNECTION_REUSE_ENABLED: '1',
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<%_ if (eventSource !== 'Any') { _%>
|
|
2
|
+
import { parser } from '@aws-lambda-powertools/parser/middleware';
|
|
3
|
+
import { <%= eventSource %> } from '@aws-lambda-powertools/parser/schemas';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
<%_ } _%>
|
|
6
|
+
import middy from '@middy/core';
|
|
7
|
+
import { Tracer } from '@aws-lambda-powertools/tracer';
|
|
8
|
+
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';
|
|
9
|
+
import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware';
|
|
10
|
+
import { Logger } from '@aws-lambda-powertools/logger';
|
|
11
|
+
import { Metrics } from '@aws-lambda-powertools/metrics';
|
|
12
|
+
import { logMetrics } from '@aws-lambda-powertools/metrics/middleware';
|
|
13
|
+
<%_ if (returnType.imports.length > 0) { _%>
|
|
14
|
+
import type { <%= returnType.imports.join(', ') %> } from 'aws-lambda';
|
|
15
|
+
<%_ } _%>
|
|
16
|
+
|
|
17
|
+
process.env.POWERTOOLS_METRICS_NAMESPACE = "<%= lambdaFunctionClassName %>";
|
|
18
|
+
process.env.POWERTOOLS_SERVICE_NAME = "<%= lambdaFunctionClassName %>";
|
|
19
|
+
|
|
20
|
+
const tracer = new Tracer();
|
|
21
|
+
const logger = new Logger();
|
|
22
|
+
const metrics = new Metrics();
|
|
23
|
+
<%_ const inputType = eventSource === 'Any' ? 'any' : `z.infer<typeof ${eventSource}>`; _%>
|
|
24
|
+
<%_ const outputType = `Promise<${returnType.type}>`; %>
|
|
25
|
+
|
|
26
|
+
export const <%= lambdaFunctionCamelCase %> = async (event: <%- inputType %>): <%- outputType %> => {
|
|
27
|
+
logger.info("Received event", event);
|
|
28
|
+
|
|
29
|
+
// TODO: implement
|
|
30
|
+
<%_ if (['APIGatewayProxyEventSchema', 'APIGatewayProxyEventV2Schema', 'APIGatewayProxyWebsocketEventSchema', 'AlbSchema', 'LambdaFunctionUrlSchema'].includes(eventSource)) { _%>
|
|
31
|
+
return {
|
|
32
|
+
statusCode: 200,
|
|
33
|
+
body: ''
|
|
34
|
+
};
|
|
35
|
+
<%_ } else if (['APIGatewayRequestAuthorizerEventSchema', 'APIGatewayTokenAuthorizerEventSchema', 'APIGatewayRequestAuthorizerEventV2Schema'].includes(eventSource)) { _%>
|
|
36
|
+
return {
|
|
37
|
+
principalId: 'user',
|
|
38
|
+
policyDocument: {
|
|
39
|
+
Version: '2012-10-17',
|
|
40
|
+
Statement: [
|
|
41
|
+
{
|
|
42
|
+
Action: 'execute-api:Invoke',
|
|
43
|
+
Effect: 'Allow',
|
|
44
|
+
Resource: '*'
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
<%_ } else if (['KinesisFirehoseSchema', 'KinesisFirehoseSqsSchema'].includes(eventSource)) { _%>
|
|
50
|
+
return {
|
|
51
|
+
records: []
|
|
52
|
+
};
|
|
53
|
+
<%_ } else if (eventSource === 'TransferFamilySchema') { _%>
|
|
54
|
+
return {
|
|
55
|
+
Role: '',
|
|
56
|
+
Policy: '',
|
|
57
|
+
HomeDirectory: '/'
|
|
58
|
+
};
|
|
59
|
+
<%_ } else if (['PreSignupTriggerSchema', 'PostConfirmationTriggerSchema', 'CustomMessageTriggerSchema', 'MigrateUserTriggerSchema', 'CustomSMSSenderTriggerSchema', 'CustomEmailSenderTriggerSchema', 'DefineAuthChallengeTriggerSchema', 'CreateAuthChallengeTriggerSchema', 'VerifyAuthChallengeTriggerSchema', 'PreTokenGenerationTriggerSchemaV1', 'PreTokenGenerationTriggerSchemaV2AndV3'].includes(eventSource)) { _%>
|
|
60
|
+
return event;
|
|
61
|
+
<%_ } else { /* Event sources which don't need to return a response */ _%>
|
|
62
|
+
<%_ } _%>
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const handler = middy()
|
|
66
|
+
.use(captureLambdaHandler(tracer))
|
|
67
|
+
.use(injectLambdaContext(logger))
|
|
68
|
+
.use(logMetrics(metrics))
|
|
69
|
+
<%_ if (eventSource !== 'Any') { _%>
|
|
70
|
+
.use(parser({ schema: <%= eventSource %> }))
|
|
71
|
+
<%_ } _%>
|
|
72
|
+
.handler(<%= lambdaFunctionCamelCase %>);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
6
|
+
import { TsLambdaFunctionGeneratorSchema } from './schema';
|
|
7
|
+
import { NxGeneratorInfo } from '../../utils/nx';
|
|
8
|
+
export declare const TS_LAMBDA_FUNCTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
/**
|
|
10
|
+
* Generates a TypeScript Lambda Function to add to a TypeScript project
|
|
11
|
+
*/
|
|
12
|
+
export declare const tsLambdaFunctionGenerator: (tree: Tree, schema: TsLambdaFunctionGeneratorSchema) => Promise<GeneratorCallback>;
|
|
13
|
+
export default tsLambdaFunctionGenerator;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tsLambdaFunctionGenerator = exports.TS_LAMBDA_FUNCTION_GENERATOR_INFO = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
10
|
+
const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
11
|
+
const shared_constructs_constants_1 = require("../../utils/shared-constructs-constants");
|
|
12
|
+
const names_1 = require("../../utils/names");
|
|
13
|
+
const ast_1 = require("../../utils/ast");
|
|
14
|
+
const format_1 = require("../../utils/format");
|
|
15
|
+
const object_1 = require("../../utils/object");
|
|
16
|
+
const nx_1 = require("../../utils/nx");
|
|
17
|
+
const metrics_1 = require("../../utils/metrics");
|
|
18
|
+
const versions_1 = require("../../utils/versions");
|
|
19
|
+
const lodash_camelcase_1 = tslib_1.__importDefault(require("lodash.camelcase"));
|
|
20
|
+
const io_1 = require("./io");
|
|
21
|
+
exports.TS_LAMBDA_FUNCTION_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
22
|
+
/**
|
|
23
|
+
* Generates a TypeScript Lambda Function to add to a TypeScript project
|
|
24
|
+
*/
|
|
25
|
+
const tsLambdaFunctionGenerator = (tree, schema) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
|
+
const projectConfig = (0, nx_1.readProjectConfigurationUnqualified)(tree, schema.project);
|
|
28
|
+
const tsconfigPath = (0, devkit_1.joinPathFragments)(projectConfig.root, 'tsconfig.json');
|
|
29
|
+
// Check if the project has a tsconfig.json file
|
|
30
|
+
if (!tree.exists(tsconfigPath)) {
|
|
31
|
+
throw new Error(`This generator does not support selected project ${schema.project}. The project must be a typescript project (ie contain a tsconfig.json)`);
|
|
32
|
+
}
|
|
33
|
+
if (!projectConfig.sourceRoot) {
|
|
34
|
+
throw new Error(`This project does not have a source root. Please add a source root to the project configuration before running this generator.`);
|
|
35
|
+
}
|
|
36
|
+
const dir = projectConfig.root;
|
|
37
|
+
const projectNameWithOutScope = projectConfig.name.split('/').pop();
|
|
38
|
+
const projectNameKebabCase = (0, names_1.toKebabCase)(projectNameWithOutScope);
|
|
39
|
+
const functionNameKebabCase = (0, names_1.toKebabCase)(schema.functionName);
|
|
40
|
+
const constructFunctionNameKebabCase = `${projectNameKebabCase}-${functionNameKebabCase}`;
|
|
41
|
+
const constructFunctionClassName = (0, names_1.toClassName)(constructFunctionNameKebabCase);
|
|
42
|
+
const lambdaFunctionCamelCase = (0, lodash_camelcase_1.default)(schema.functionName);
|
|
43
|
+
const lambdaFunctionClassName = (0, names_1.pascalCase)(schema.functionName);
|
|
44
|
+
const lambdaFunctionKebabCase = (0, names_1.toKebabCase)(schema.functionName);
|
|
45
|
+
const functionPath = (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, (_a = schema.functionPath) !== null && _a !== void 0 ? _a : '', `${lambdaFunctionKebabCase}.ts`);
|
|
46
|
+
// Check that the project does not already have a lambda handler
|
|
47
|
+
if (tree.exists(functionPath)) {
|
|
48
|
+
throw new Error(`This project already has a lambda function with the name ${functionNameKebabCase}. Please remove the lambda function before running this generator or use a different name.`);
|
|
49
|
+
}
|
|
50
|
+
yield (0, shared_constructs_1.sharedConstructsGenerator)(tree);
|
|
51
|
+
// Add bundle-<name> target for this specific lambda function
|
|
52
|
+
const bundleTargetName = `bundle-${lambdaFunctionKebabCase}`;
|
|
53
|
+
const enhancedOptions = Object.assign(Object.assign({}, schema), { dir,
|
|
54
|
+
constructFunctionClassName,
|
|
55
|
+
constructFunctionNameKebabCase,
|
|
56
|
+
lambdaFunctionCamelCase,
|
|
57
|
+
lambdaFunctionClassName,
|
|
58
|
+
lambdaFunctionKebabCase,
|
|
59
|
+
bundleTargetName, returnType: io_1.TS_HANDLER_RETURN_TYPES[schema.eventSource] });
|
|
60
|
+
if (!projectConfig.targets) {
|
|
61
|
+
projectConfig.targets = {};
|
|
62
|
+
}
|
|
63
|
+
// Add the specific bundle target for this lambda function
|
|
64
|
+
projectConfig.targets[bundleTargetName] = {
|
|
65
|
+
cache: true,
|
|
66
|
+
executor: 'nx:run-commands',
|
|
67
|
+
outputs: [`{workspaceRoot}/dist/${dir}/${bundleTargetName}`],
|
|
68
|
+
options: {
|
|
69
|
+
commands: [
|
|
70
|
+
`esbuild ${functionPath} --bundle --platform=node --target=node22 --format=cjs --outfile=dist/${dir}/${bundleTargetName}/index.js --external:@aws-sdk/*`,
|
|
71
|
+
],
|
|
72
|
+
parallel: false,
|
|
73
|
+
},
|
|
74
|
+
dependsOn: ['compile'],
|
|
75
|
+
};
|
|
76
|
+
// Add the bundle target if it doesn't exist
|
|
77
|
+
projectConfig.targets.bundle = (_b = projectConfig.targets.bundle) !== null && _b !== void 0 ? _b : {
|
|
78
|
+
cache: true,
|
|
79
|
+
dependsOn: [],
|
|
80
|
+
};
|
|
81
|
+
// Add the lambda's bundle target to the main bundle target's dependsOn
|
|
82
|
+
projectConfig.targets.bundle.dependsOn = [
|
|
83
|
+
...((_c = projectConfig.targets.bundle.dependsOn) !== null && _c !== void 0 ? _c : []).filter((d) => d !== bundleTargetName),
|
|
84
|
+
bundleTargetName,
|
|
85
|
+
];
|
|
86
|
+
if (!((_d = projectConfig.targets) === null || _d === void 0 ? void 0 : _d.build)) {
|
|
87
|
+
projectConfig.targets.build = {};
|
|
88
|
+
}
|
|
89
|
+
projectConfig.targets.build.dependsOn = [
|
|
90
|
+
...((_e = projectConfig.targets.build.dependsOn) !== null && _e !== void 0 ? _e : []).filter((t) => t !== 'bundle'),
|
|
91
|
+
'bundle',
|
|
92
|
+
];
|
|
93
|
+
projectConfig.targets = (0, object_1.sortObjectKeys)(projectConfig.targets);
|
|
94
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectConfig.name, projectConfig);
|
|
95
|
+
// Generate the lambda handler file
|
|
96
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'handler'), (0, devkit_1.joinPathFragments)(projectConfig.sourceRoot, (_f = schema.functionPath) !== null && _f !== void 0 ? _f : ''), enhancedOptions, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
97
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', shared_constructs_constants_1.SHARED_CONSTRUCTS_DIR, 'src', 'app'), (0, devkit_1.joinPathFragments)(shared_constructs_constants_1.PACKAGES_DIR, shared_constructs_constants_1.SHARED_CONSTRUCTS_DIR, 'src', 'app'), enhancedOptions, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
98
|
+
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_constants_1.PACKAGES_DIR, shared_constructs_constants_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'index.ts'), './lambda-functions/index.js');
|
|
99
|
+
(0, ast_1.addStarExport)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_constants_1.PACKAGES_DIR, shared_constructs_constants_1.SHARED_CONSTRUCTS_DIR, 'src', 'app', 'lambda-functions', 'index.ts'), `./${constructFunctionNameKebabCase}.js`);
|
|
100
|
+
// Ensure common constructs builds after our lambda function project
|
|
101
|
+
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(shared_constructs_constants_1.PACKAGES_DIR, shared_constructs_constants_1.SHARED_CONSTRUCTS_DIR, 'project.json'), (config) => {
|
|
102
|
+
var _a;
|
|
103
|
+
if (!config.targets) {
|
|
104
|
+
config.targets = {};
|
|
105
|
+
}
|
|
106
|
+
if (!config.targets.build) {
|
|
107
|
+
config.targets.build = {};
|
|
108
|
+
}
|
|
109
|
+
config.targets.build.dependsOn = [
|
|
110
|
+
...((_a = config.targets.build.dependsOn) !== null && _a !== void 0 ? _a : []).filter((t) => t !== `${projectConfig.name}:build`),
|
|
111
|
+
`${projectConfig.name}:build`,
|
|
112
|
+
];
|
|
113
|
+
return config;
|
|
114
|
+
});
|
|
115
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)([
|
|
116
|
+
'@aws-lambda-powertools/tracer',
|
|
117
|
+
'@aws-lambda-powertools/logger',
|
|
118
|
+
'@aws-lambda-powertools/metrics',
|
|
119
|
+
'@aws-lambda-powertools/parser',
|
|
120
|
+
'@middy/core',
|
|
121
|
+
'zod',
|
|
122
|
+
]), (0, versions_1.withVersions)(['esbuild', '@types/aws-lambda']));
|
|
123
|
+
yield (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
|
|
124
|
+
exports.TS_LAMBDA_FUNCTION_GENERATOR_INFO,
|
|
125
|
+
]);
|
|
126
|
+
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
127
|
+
return () => {
|
|
128
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
exports.tsLambdaFunctionGenerator = tsLambdaFunctionGenerator;
|
|
132
|
+
exports.default = exports.tsLambdaFunctionGenerator;
|
|
133
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lambda-function/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAWoB;AAEpB,qEAA0E;AAC1E,yFAGiD;AACjD,6CAAyE;AACzE,yCAAgD;AAChD,+CAA0D;AAC1D,+CAAoD;AACpD,uCAIwB;AACxB,iDAAsE;AACtE,mDAAoD;AACpD,gFAAyC;AACzC,6BAA+C;AAElC,QAAA,iCAAiC,GAC5C,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAE/B;;GAEG;AACI,MAAM,yBAAyB,GAAG,CACvC,IAAU,EACV,MAAuC,EACX,EAAE;;IAC9B,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,MAAM,CAAC,OAAO,CACf,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,0BAAiB,EAAC,aAAa,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IAE5E,gDAAgD;IAChD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,oDAAoD,MAAM,CAAC,OAAO,yEAAyE,CAC5I,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,gIAAgI,CACjI,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC;IAC/B,MAAM,uBAAuB,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACpE,MAAM,oBAAoB,GAAG,IAAA,mBAAW,EAAC,uBAAuB,CAAC,CAAC;IAClE,MAAM,qBAAqB,GAAG,IAAA,mBAAW,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAE/D,MAAM,8BAA8B,GAAG,GAAG,oBAAoB,IAAI,qBAAqB,EAAE,CAAC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I,EAAE,CAAC,CAAC,MAAM,CAC9C,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,aAAa,CAAC,IAAI,QAAQ,CAC3C;YACD,GAAG,aAAa,CAAC,IAAI,QAAQ;SAC9B,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC,CACF,CAAC;IAEF,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,uBAAY,EAAC;QACX,+BAA+B;QAC/B,+BAA+B;QAC/B,gCAAgC;QAChC,+BAA+B;QAC/B,aAAa;QACb,KAAK;KACN,CAAC,EACF,IAAA,uBAAY,EAAC,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAC/C,CAAC;IAEF,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE;QAC1C,yCAAiC;KAClC,CAAC,CAAC;IAEH,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;IAEjC,OAAO,GAAG,EAAE;QACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC,CAAA,CAAC;AApMW,QAAA,yBAAyB,6BAoMpC;AAEF,kBAAe,iCAAyB,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mapping of EventSource to the corresponding return type from @types/aws-lambda
|
|
3
|
+
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/aws-lambda/trigger
|
|
4
|
+
*/
|
|
5
|
+
export declare const TS_HANDLER_RETURN_TYPES: {
|
|
6
|
+
Any: {
|
|
7
|
+
type: string;
|
|
8
|
+
imports: any[];
|
|
9
|
+
};
|
|
10
|
+
AlbSchema: {
|
|
11
|
+
type: string;
|
|
12
|
+
imports: string[];
|
|
13
|
+
};
|
|
14
|
+
APIGatewayProxyEventSchema: {
|
|
15
|
+
type: string;
|
|
16
|
+
imports: string[];
|
|
17
|
+
};
|
|
18
|
+
APIGatewayRequestAuthorizerEventSchema: {
|
|
19
|
+
type: string;
|
|
20
|
+
imports: string[];
|
|
21
|
+
};
|
|
22
|
+
APIGatewayTokenAuthorizerEventSchema: {
|
|
23
|
+
type: string;
|
|
24
|
+
imports: string[];
|
|
25
|
+
};
|
|
26
|
+
APIGatewayProxyEventV2Schema: {
|
|
27
|
+
type: string;
|
|
28
|
+
imports: string[];
|
|
29
|
+
};
|
|
30
|
+
APIGatewayProxyWebsocketEventSchema: {
|
|
31
|
+
type: string;
|
|
32
|
+
imports: string[];
|
|
33
|
+
};
|
|
34
|
+
APIGatewayRequestAuthorizerEventV2Schema: {
|
|
35
|
+
type: string;
|
|
36
|
+
imports: string[];
|
|
37
|
+
};
|
|
38
|
+
CloudFormationCustomResourceCreateSchema: {
|
|
39
|
+
type: string;
|
|
40
|
+
imports: any[];
|
|
41
|
+
};
|
|
42
|
+
CloudFormationCustomResourceUpdateSchema: {
|
|
43
|
+
type: string;
|
|
44
|
+
imports: any[];
|
|
45
|
+
};
|
|
46
|
+
CloudFormationCustomResourceDeleteSchema: {
|
|
47
|
+
type: string;
|
|
48
|
+
imports: any[];
|
|
49
|
+
};
|
|
50
|
+
CloudWatchLogsSchema: {
|
|
51
|
+
type: string;
|
|
52
|
+
imports: any[];
|
|
53
|
+
};
|
|
54
|
+
DynamoDBStreamSchema: {
|
|
55
|
+
type: string;
|
|
56
|
+
imports: string[];
|
|
57
|
+
};
|
|
58
|
+
EventBridgeSchema: {
|
|
59
|
+
type: string;
|
|
60
|
+
imports: any[];
|
|
61
|
+
};
|
|
62
|
+
KafkaMskEventSchema: {
|
|
63
|
+
type: string;
|
|
64
|
+
imports: any[];
|
|
65
|
+
};
|
|
66
|
+
KafkaSelfManagedEventSchema: {
|
|
67
|
+
type: string;
|
|
68
|
+
imports: any[];
|
|
69
|
+
};
|
|
70
|
+
KinesisDataStreamSchema: {
|
|
71
|
+
type: string;
|
|
72
|
+
imports: string[];
|
|
73
|
+
};
|
|
74
|
+
KinesisFirehoseSchema: {
|
|
75
|
+
type: string;
|
|
76
|
+
imports: string[];
|
|
77
|
+
};
|
|
78
|
+
KinesisDynamoDBStreamSchema: {
|
|
79
|
+
type: string;
|
|
80
|
+
imports: string[];
|
|
81
|
+
};
|
|
82
|
+
KinesisFirehoseSqsSchema: {
|
|
83
|
+
type: string;
|
|
84
|
+
imports: string[];
|
|
85
|
+
};
|
|
86
|
+
LambdaFunctionUrlSchema: {
|
|
87
|
+
type: string;
|
|
88
|
+
imports: string[];
|
|
89
|
+
};
|
|
90
|
+
S3EventNotificationEventBridgeSchema: {
|
|
91
|
+
type: string;
|
|
92
|
+
imports: any[];
|
|
93
|
+
};
|
|
94
|
+
S3Schema: {
|
|
95
|
+
type: string;
|
|
96
|
+
imports: any[];
|
|
97
|
+
};
|
|
98
|
+
S3ObjectLambdaEventSchema: {
|
|
99
|
+
type: string;
|
|
100
|
+
imports: any[];
|
|
101
|
+
};
|
|
102
|
+
S3SqsEventNotificationSchema: {
|
|
103
|
+
type: string;
|
|
104
|
+
imports: string[];
|
|
105
|
+
};
|
|
106
|
+
SesSchema: {
|
|
107
|
+
type: string;
|
|
108
|
+
imports: any[];
|
|
109
|
+
};
|
|
110
|
+
SnsSchema: {
|
|
111
|
+
type: string;
|
|
112
|
+
imports: any[];
|
|
113
|
+
};
|
|
114
|
+
SqsSchema: {
|
|
115
|
+
type: string;
|
|
116
|
+
imports: string[];
|
|
117
|
+
};
|
|
118
|
+
TransferFamilySchema: {
|
|
119
|
+
type: string;
|
|
120
|
+
imports: string[];
|
|
121
|
+
};
|
|
122
|
+
VpcLatticeSchema: {
|
|
123
|
+
type: string;
|
|
124
|
+
imports: any[];
|
|
125
|
+
};
|
|
126
|
+
VpcLatticeV2Schema: {
|
|
127
|
+
type: string;
|
|
128
|
+
imports: any[];
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The below Cognito triggers must return the same type as the input event.
|
|
132
|
+
* Due to mismatches between @types/aws-lambda and powertools schemas, we choose the zod input type.
|
|
133
|
+
*/
|
|
134
|
+
PreSignupTriggerSchema: {
|
|
135
|
+
type: string;
|
|
136
|
+
imports: any[];
|
|
137
|
+
};
|
|
138
|
+
PostConfirmationTriggerSchema: {
|
|
139
|
+
type: string;
|
|
140
|
+
imports: any[];
|
|
141
|
+
};
|
|
142
|
+
CustomMessageTriggerSchema: {
|
|
143
|
+
type: string;
|
|
144
|
+
imports: any[];
|
|
145
|
+
};
|
|
146
|
+
MigrateUserTriggerSchema: {
|
|
147
|
+
type: string;
|
|
148
|
+
imports: any[];
|
|
149
|
+
};
|
|
150
|
+
CustomSMSSenderTriggerSchema: {
|
|
151
|
+
type: string;
|
|
152
|
+
imports: any[];
|
|
153
|
+
};
|
|
154
|
+
CustomEmailSenderTriggerSchema: {
|
|
155
|
+
type: string;
|
|
156
|
+
imports: any[];
|
|
157
|
+
};
|
|
158
|
+
DefineAuthChallengeTriggerSchema: {
|
|
159
|
+
type: string;
|
|
160
|
+
imports: any[];
|
|
161
|
+
};
|
|
162
|
+
CreateAuthChallengeTriggerSchema: {
|
|
163
|
+
type: string;
|
|
164
|
+
imports: any[];
|
|
165
|
+
};
|
|
166
|
+
VerifyAuthChallengeTriggerSchema: {
|
|
167
|
+
type: string;
|
|
168
|
+
imports: any[];
|
|
169
|
+
};
|
|
170
|
+
PreTokenGenerationTriggerSchemaV1: {
|
|
171
|
+
type: string;
|
|
172
|
+
imports: any[];
|
|
173
|
+
};
|
|
174
|
+
PreTokenGenerationTriggerSchemaV2AndV3: {
|
|
175
|
+
type: string;
|
|
176
|
+
imports: any[];
|
|
177
|
+
};
|
|
178
|
+
};
|