@aws/nx-plugin 0.33.0 → 0.34.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/open-api/ts-hooks/generator.spec.tsx +1 -4
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/py/fast-api/generator.js +5 -13
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/lambda-function/generator.js +5 -13
- package/src/py/lambda-function/generator.js.map +1 -1
- 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/utils/bundle.d.ts +19 -0
- package/src/utils/bundle.js +26 -0
- package/src/utils/bundle.js.map +1 -0
- package/src/utils/versions.d.ts +3 -1
- package/src/utils/versions.js +2 -0
- package/src/utils/versions.js.map +1 -1
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
|
@@ -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
|
|
@@ -22,6 +22,7 @@ const api_constructs_1 = require("../../utils/api-constructs/api-constructs");
|
|
|
22
22
|
const open_api_1 = require("./react/open-api");
|
|
23
23
|
const git_1 = require("../../utils/git");
|
|
24
24
|
const port_1 = require("../../utils/port");
|
|
25
|
+
const bundle_1 = require("../../utils/bundle");
|
|
25
26
|
exports.FAST_API_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
26
27
|
/**
|
|
27
28
|
* Generates a Python FastAPI project
|
|
@@ -45,19 +46,10 @@ const pyFastApiProjectGenerator = (tree, schema) => tslib_1.__awaiter(void 0, vo
|
|
|
45
46
|
projectType: 'application',
|
|
46
47
|
});
|
|
47
48
|
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, fullyQualifiedName);
|
|
48
|
-
projectConfig.targets.bundle = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
options: {
|
|
53
|
-
commands: [
|
|
54
|
-
`uv export --frozen --no-dev --no-editable --project ${dir} -o dist/${dir}/bundle/requirements.txt`,
|
|
55
|
-
`uv pip install -n --no-installer-metadata --no-compile-bytecode --python-platform x86_64-manylinux2014 --target dist/${dir}/bundle -r dist/${dir}/bundle/requirements.txt`,
|
|
56
|
-
],
|
|
57
|
-
parallel: false,
|
|
58
|
-
},
|
|
59
|
-
dependsOn: ['compile'],
|
|
60
|
-
};
|
|
49
|
+
projectConfig.targets.bundle = Object.assign(Object.assign({}, (0, bundle_1.createPythonBundleTarget)({
|
|
50
|
+
projectDir: dir,
|
|
51
|
+
packageName: fullyQualifiedName,
|
|
52
|
+
})), { dependsOn: ['compile'] });
|
|
61
53
|
projectConfig.targets.build.dependsOn = [
|
|
62
54
|
...((_a = projectConfig.targets.build.dependsOn) !== null && _a !== void 0 ? _a : []),
|
|
63
55
|
'bundle',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/py/fast-api/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAWoB;AAEpB,oEAAmE;AACnE,oEAAiE;AACjE,0EAA+E;AAC/E,sCAA+C;AAE/C,qEAA0E;AAC1E,yFAGiD;AACjD,6CAA0E;AAC1E,+CAA0D;AAC1D,+CAAoD;AACpD,uCAIwB;AACxB,iDAAsE;AACtE,8EAAmF;AACnF,+CAAwD;AACxD,yCAAkD;AAClD,2CAA4D;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/py/fast-api/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAWoB;AAEpB,oEAAmE;AACnE,oEAAiE;AACjE,0EAA+E;AAC/E,sCAA+C;AAE/C,qEAA0E;AAC1E,yFAGiD;AACjD,6CAA0E;AAC1E,+CAA0D;AAC1D,+CAAoD;AACpD,uCAIwB;AACxB,iDAAsE;AACtE,8EAAmF;AACnF,+CAAwD;AACxD,yCAAkD;AAClD,2CAA4D;AAC5D,+CAA8D;AAEjD,QAAA,uBAAuB,GAClC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAE/B;;GAEG;AACI,MAAM,yBAAyB,GAAG,CACvC,IAAU,EACV,MAAuC,EACX,EAAE;;IAC9B,MAAM,IAAA,6CAAyB,EAAC,IAAI,CAAC,CAAC;IAEtC,MAAM,EAAE,GAAG,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,GAAG,IAAA,+BAAmB,EAC3E,IAAI,EACJ;QACE,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CACF,CAAC;IACF,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAElD,MAAM,IAAI,GAAG,IAAA,+BAAwB,EAAC,IAAI,EAAE,+BAAuB,EAAE,IAAI,CAAC,CAAC;IAE3E,MAAM,IAAA,mBAAkB,EAAC,IAAI,EAAE;QAC7B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,UAAU,EAAE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@ const npm_scope_1 = require("../../utils/npm-scope");
|
|
|
19
19
|
const object_1 = require("../../utils/object");
|
|
20
20
|
const nx_1 = require("../../utils/nx");
|
|
21
21
|
const metrics_1 = require("../../utils/metrics");
|
|
22
|
+
const bundle_1 = require("../../utils/bundle");
|
|
22
23
|
exports.LAMBDA_FUNCTION_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
23
24
|
const getLambdaFunctionDetails = (tree, schema) => {
|
|
24
25
|
const scope = (0, names_1.toSnakeCase)((0, npm_scope_1.getNpmScope)(tree));
|
|
@@ -71,19 +72,10 @@ const pyLambdaFunctionGenerator = (tree, schema) => tslib_1.__awaiter(void 0, vo
|
|
|
71
72
|
constructFunctionKebabCase, constructHandlerFilePath: normalizedFunctionPath, lambdaFunctionClassName, lambdaFunctionSnakeCase: normalizedFunctionName });
|
|
72
73
|
// Check if the project has a bundle target and if not add it
|
|
73
74
|
if (!((_b = projectConfig.targets) === null || _b === void 0 ? void 0 : _b.bundle)) {
|
|
74
|
-
projectConfig.targets.bundle = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
options: {
|
|
79
|
-
commands: [
|
|
80
|
-
`uv export --frozen --no-dev --no-editable --project ${dir} -o dist/${dir}/bundle/requirements.txt`,
|
|
81
|
-
`uv pip install -n --no-installer-metadata --no-compile-bytecode --python-platform x86_64-manylinux2014 --target dist/${dir}/bundle -r dist/${dir}/bundle/requirements.txt`,
|
|
82
|
-
],
|
|
83
|
-
parallel: false,
|
|
84
|
-
},
|
|
85
|
-
dependsOn: ['compile'],
|
|
86
|
-
};
|
|
75
|
+
projectConfig.targets.bundle = Object.assign(Object.assign({}, (0, bundle_1.createPythonBundleTarget)({
|
|
76
|
+
projectDir: dir,
|
|
77
|
+
packageName: projectConfig.name,
|
|
78
|
+
})), { dependsOn: ['compile'] });
|
|
87
79
|
}
|
|
88
80
|
if ((_c = projectConfig.targets) === null || _c === void 0 ? void 0 : _c.build) {
|
|
89
81
|
projectConfig.targets.build.dependsOn = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/py/lambda-function/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAUoB;AAEpB,oEAAmE;AACnE,oEAAiE;AACjE,sCAA+C;AAE/C,qEAA0E;AAC1E,yFAGiD;AACjD,6CAK2B;AAC3B,yCAAgD;AAChD,+CAA0D;AAC1D,qDAAoD;AACpD,+CAAoD;AACpD,uCAIwB;AACxB,iDAAsE;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/py/lambda-function/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAUoB;AAEpB,oEAAmE;AACnE,oEAAiE;AACjE,sCAA+C;AAE/C,qEAA0E;AAC1E,yFAGiD;AACjD,6CAK2B;AAC3B,yCAAgD;AAChD,+CAA0D;AAC1D,qDAAoD;AACpD,+CAAoD;AACpD,uCAIwB;AACxB,iDAAsE;AACtE,+CAA8D;AAEjD,QAAA,8BAA8B,GACzC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAiB/B,MAAM,wBAAwB,GAAG,CAC/B,IAAU,EACV,MAA2E,EACpD,EAAE;IACzB,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,IAAA,uBAAW,EAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,MAAM,sBAAsB,GAAG,IAAA,mBAAW,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAChE,MAAM,0BAA0B,GAAG,GAAG,KAAK,IAAI,sBAAsB,EAAE,CAAC;IACxE,MAAM,sBAAsB,GAAG,GAAG,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAA,qBAAa,EAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,iBAA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AAI,EAAE,CAAC;IAE7D,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;QACpD,YAAY,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAAE,CAAC;QAC5D,YAAY,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAAE,CAAC;QAC5D,YAAY,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,IAAA,0BAAiB,EAAC,GAAG,EAAE,gBAAgB,CAAC,EAAE,IAAA,gBAAS,EAAC,WAAW,CAAC,CAAC,CAAC;IAE7E,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE,CAAC,sCAA8B,CAAC,CAAC,CAAC;IAE9E,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;IAEjC,OAAO,GAAS,EAAE;QAChB,MAAM,IAAI,qBAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,eAAM,EAAE,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;QAC9D,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAA,CAAC;AACJ,CAAC,CAAA,CAAC;AArNW,QAAA,yBAAyB,6BAqNpC;AACF,kBAAe,iCAAyB,CAAC"}
|
|
@@ -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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@@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TS_HANDLER_RETURN_TYPES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Mapping of EventSource to the corresponding return type from @types/aws-lambda
|
|
6
|
+
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/aws-lambda/trigger
|
|
7
|
+
*/
|
|
8
|
+
exports.TS_HANDLER_RETURN_TYPES = {
|
|
9
|
+
Any: {
|
|
10
|
+
type: 'any',
|
|
11
|
+
imports: [],
|
|
12
|
+
},
|
|
13
|
+
AlbSchema: {
|
|
14
|
+
type: 'ALBResult',
|
|
15
|
+
imports: ['ALBResult'],
|
|
16
|
+
},
|
|
17
|
+
APIGatewayProxyEventSchema: {
|
|
18
|
+
type: 'APIGatewayProxyResult',
|
|
19
|
+
imports: ['APIGatewayProxyResult'],
|
|
20
|
+
},
|
|
21
|
+
APIGatewayRequestAuthorizerEventSchema: {
|
|
22
|
+
type: 'APIGatewayAuthorizerResult',
|
|
23
|
+
imports: ['APIGatewayAuthorizerResult'],
|
|
24
|
+
},
|
|
25
|
+
APIGatewayTokenAuthorizerEventSchema: {
|
|
26
|
+
type: 'APIGatewayAuthorizerResult',
|
|
27
|
+
imports: ['APIGatewayAuthorizerResult'],
|
|
28
|
+
},
|
|
29
|
+
APIGatewayProxyEventV2Schema: {
|
|
30
|
+
type: 'APIGatewayProxyResultV2',
|
|
31
|
+
imports: ['APIGatewayProxyResultV2'],
|
|
32
|
+
},
|
|
33
|
+
APIGatewayProxyWebsocketEventSchema: {
|
|
34
|
+
type: 'APIGatewayProxyResultV2',
|
|
35
|
+
imports: ['APIGatewayProxyResultV2'],
|
|
36
|
+
},
|
|
37
|
+
APIGatewayRequestAuthorizerEventV2Schema: {
|
|
38
|
+
type: 'APIGatewayAuthorizerResult',
|
|
39
|
+
imports: ['APIGatewayAuthorizerResult'],
|
|
40
|
+
},
|
|
41
|
+
CloudFormationCustomResourceCreateSchema: {
|
|
42
|
+
type: 'void',
|
|
43
|
+
imports: [],
|
|
44
|
+
},
|
|
45
|
+
CloudFormationCustomResourceUpdateSchema: {
|
|
46
|
+
type: 'void',
|
|
47
|
+
imports: [],
|
|
48
|
+
},
|
|
49
|
+
CloudFormationCustomResourceDeleteSchema: {
|
|
50
|
+
type: 'void',
|
|
51
|
+
imports: [],
|
|
52
|
+
},
|
|
53
|
+
CloudWatchLogsSchema: {
|
|
54
|
+
type: 'void',
|
|
55
|
+
imports: [],
|
|
56
|
+
},
|
|
57
|
+
DynamoDBStreamSchema: {
|
|
58
|
+
type: 'DynamoDBBatchResponse | void',
|
|
59
|
+
imports: ['DynamoDBBatchResponse'],
|
|
60
|
+
},
|
|
61
|
+
EventBridgeSchema: {
|
|
62
|
+
type: 'void',
|
|
63
|
+
imports: [],
|
|
64
|
+
},
|
|
65
|
+
KafkaMskEventSchema: {
|
|
66
|
+
type: 'void',
|
|
67
|
+
imports: [],
|
|
68
|
+
},
|
|
69
|
+
KafkaSelfManagedEventSchema: {
|
|
70
|
+
type: 'void',
|
|
71
|
+
imports: [],
|
|
72
|
+
},
|
|
73
|
+
KinesisDataStreamSchema: {
|
|
74
|
+
type: 'KinesisStreamBatchResponse | void',
|
|
75
|
+
imports: ['KinesisStreamBatchResponse'],
|
|
76
|
+
},
|
|
77
|
+
KinesisFirehoseSchema: {
|
|
78
|
+
type: 'FirehoseTransformationResult',
|
|
79
|
+
imports: ['FirehoseTransformationResult'],
|
|
80
|
+
},
|
|
81
|
+
KinesisDynamoDBStreamSchema: {
|
|
82
|
+
type: 'KinesisStreamBatchResponse | void',
|
|
83
|
+
imports: ['KinesisStreamBatchResponse'],
|
|
84
|
+
},
|
|
85
|
+
KinesisFirehoseSqsSchema: {
|
|
86
|
+
type: 'FirehoseTransformationResult',
|
|
87
|
+
imports: ['FirehoseTransformationResult'],
|
|
88
|
+
},
|
|
89
|
+
LambdaFunctionUrlSchema: {
|
|
90
|
+
type: 'LambdaFunctionURLResult',
|
|
91
|
+
imports: ['LambdaFunctionURLResult'],
|
|
92
|
+
},
|
|
93
|
+
S3EventNotificationEventBridgeSchema: {
|
|
94
|
+
type: 'void',
|
|
95
|
+
imports: [],
|
|
96
|
+
},
|
|
97
|
+
S3Schema: {
|
|
98
|
+
type: 'void',
|
|
99
|
+
imports: [],
|
|
100
|
+
},
|
|
101
|
+
S3ObjectLambdaEventSchema: {
|
|
102
|
+
type: 'void',
|
|
103
|
+
imports: [],
|
|
104
|
+
},
|
|
105
|
+
S3SqsEventNotificationSchema: {
|
|
106
|
+
type: 'SQSBatchResponse | void',
|
|
107
|
+
imports: ['SQSBatchResponse'],
|
|
108
|
+
},
|
|
109
|
+
SesSchema: {
|
|
110
|
+
type: 'void',
|
|
111
|
+
imports: [],
|
|
112
|
+
},
|
|
113
|
+
SnsSchema: {
|
|
114
|
+
type: 'void',
|
|
115
|
+
imports: [],
|
|
116
|
+
},
|
|
117
|
+
SqsSchema: {
|
|
118
|
+
type: 'SQSBatchResponse | void',
|
|
119
|
+
imports: ['SQSBatchResponse'],
|
|
120
|
+
},
|
|
121
|
+
TransferFamilySchema: {
|
|
122
|
+
type: 'TransferFamilyAuthorizerResult',
|
|
123
|
+
imports: ['TransferFamilyAuthorizerResult'],
|
|
124
|
+
},
|
|
125
|
+
VpcLatticeSchema: {
|
|
126
|
+
type: 'void',
|
|
127
|
+
imports: [],
|
|
128
|
+
},
|
|
129
|
+
VpcLatticeV2Schema: {
|
|
130
|
+
type: 'void',
|
|
131
|
+
imports: [],
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* The below Cognito triggers must return the same type as the input event.
|
|
135
|
+
* Due to mismatches between @types/aws-lambda and powertools schemas, we choose the zod input type.
|
|
136
|
+
*/
|
|
137
|
+
PreSignupTriggerSchema: {
|
|
138
|
+
type: 'z.infer<typeof PreSignupTriggerSchema>',
|
|
139
|
+
imports: [],
|
|
140
|
+
},
|
|
141
|
+
PostConfirmationTriggerSchema: {
|
|
142
|
+
type: 'z.infer<typeof PostConfirmationTriggerSchema>',
|
|
143
|
+
imports: [],
|
|
144
|
+
},
|
|
145
|
+
CustomMessageTriggerSchema: {
|
|
146
|
+
type: 'z.infer<typeof CustomMessageTriggerSchema>',
|
|
147
|
+
imports: [],
|
|
148
|
+
},
|
|
149
|
+
MigrateUserTriggerSchema: {
|
|
150
|
+
type: 'z.infer<typeof MigrateUserTriggerSchema>',
|
|
151
|
+
imports: [],
|
|
152
|
+
},
|
|
153
|
+
CustomSMSSenderTriggerSchema: {
|
|
154
|
+
type: 'z.infer<typeof CustomSMSSenderTriggerSchema>',
|
|
155
|
+
imports: [],
|
|
156
|
+
},
|
|
157
|
+
CustomEmailSenderTriggerSchema: {
|
|
158
|
+
type: 'z.infer<typeof CustomEmailSenderTriggerSchema>',
|
|
159
|
+
imports: [],
|
|
160
|
+
},
|
|
161
|
+
DefineAuthChallengeTriggerSchema: {
|
|
162
|
+
type: 'z.infer<typeof DefineAuthChallengeTriggerSchema>',
|
|
163
|
+
imports: [],
|
|
164
|
+
},
|
|
165
|
+
CreateAuthChallengeTriggerSchema: {
|
|
166
|
+
type: 'z.infer<typeof CreateAuthChallengeTriggerSchema>',
|
|
167
|
+
imports: [],
|
|
168
|
+
},
|
|
169
|
+
VerifyAuthChallengeTriggerSchema: {
|
|
170
|
+
type: 'z.infer<typeof VerifyAuthChallengeTriggerSchema>',
|
|
171
|
+
imports: [],
|
|
172
|
+
},
|
|
173
|
+
PreTokenGenerationTriggerSchemaV1: {
|
|
174
|
+
type: 'z.infer<typeof PreTokenGenerationTriggerSchemaV1>',
|
|
175
|
+
imports: [],
|
|
176
|
+
},
|
|
177
|
+
PreTokenGenerationTriggerSchemaV2AndV3: {
|
|
178
|
+
type: 'z.infer<typeof PreTokenGenerationTriggerSchemaV2AndV3>',
|
|
179
|
+
imports: [],
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"io.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lambda-function/io.ts"],"names":[],"mappings":";;;AAMA;;;GAGG;AACU,QAAA,uBAAuB,GAAG;IACrC,GAAG,EAAE;QACH,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,EAAE;KACZ;IACD,SAAS,EAAE;QACT,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,CAAC,WAAW,CAAC;KACvB;IACD,0BAA0B,EAAE;QAC1B,IAAI,EAAE,uBAAuB;QAC7B,OAAO,EAAE,CAAC,uBAAuB,CAAC;KACnC;IACD,sCAAsC,EAAE;QACtC,IAAI,EAAE,4BAA4B;QAClC,OAAO,EAAE,CAAC,4BAA4B,CAAC;KACxC;IACD,oCAAoC,EAAE;QACpC,IAAI,EAAE,4BAA4B;QAClC,OAAO,EAAE,CAAC,4BAA4B,CAAC;KACxC;IACD,4BAA4B,EAAE;QAC5B,IAAI,EAAE,yBAAyB;QAC/B,OAAO,EAAE,CAAC,yBAAyB,CAAC;KACrC;IACD,mCAAmC,EAAE;QACnC,IAAI,EAAE,yBAAyB;QAC/B,OAAO,EAAE,CAAC,yBAAyB,CAAC;KACrC;IACD,wCAAwC,EAAE;QACxC,IAAI,EAAE,4BAA4B;QAClC,OAAO,EAAE,CAAC,4BAA4B,CAAC;KACxC;IACD,wCAAwC,EAAE;QACxC,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,EAAE;KACZ;IACD,wCAAwC,EAAE;QACxC,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,EAAE;KACZ;IACD,wCAAw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sCAAsC,EAAE;QACtC,IAAI,EAAE,wDAAwD;QAC9D,OAAO,EAAE,EAAE;KACZ;CACiE,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type EventSource =
|
|
7
|
+
| 'Any'
|
|
8
|
+
| 'AlbSchema'
|
|
9
|
+
| 'APIGatewayProxyEventSchema'
|
|
10
|
+
| 'APIGatewayRequestAuthorizerEventSchema'
|
|
11
|
+
| 'APIGatewayTokenAuthorizerEventSchema'
|
|
12
|
+
| 'APIGatewayProxyEventV2Schema'
|
|
13
|
+
| 'APIGatewayProxyWebsocketEventSchema'
|
|
14
|
+
| 'APIGatewayRequestAuthorizerEventV2Schema'
|
|
15
|
+
| 'CloudFormationCustomResourceCreateSchema'
|
|
16
|
+
| 'CloudFormationCustomResourceUpdateSchema'
|
|
17
|
+
| 'CloudFormationCustomResourceDeleteSchema'
|
|
18
|
+
| 'CloudWatchLogsSchema'
|
|
19
|
+
| 'PreSignupTriggerSchema'
|
|
20
|
+
| 'PostConfirmationTriggerSchema'
|
|
21
|
+
| 'CustomMessageTriggerSchema'
|
|
22
|
+
| 'MigrateUserTriggerSchema'
|
|
23
|
+
| 'CustomSMSSenderTriggerSchema'
|
|
24
|
+
| 'CustomEmailSenderTriggerSchema'
|
|
25
|
+
| 'DefineAuthChallengeTriggerSchema'
|
|
26
|
+
| 'CreateAuthChallengeTriggerSchema'
|
|
27
|
+
| 'VerifyAuthChallengeTriggerSchema'
|
|
28
|
+
| 'PreTokenGenerationTriggerSchemaV1'
|
|
29
|
+
| 'PreTokenGenerationTriggerSchemaV2AndV3'
|
|
30
|
+
| 'DynamoDBStreamSchema'
|
|
31
|
+
| 'EventBridgeSchema'
|
|
32
|
+
| 'KafkaMskEventSchema'
|
|
33
|
+
| 'KafkaSelfManagedEventSchema'
|
|
34
|
+
| 'KinesisDataStreamSchema'
|
|
35
|
+
| 'KinesisFirehoseSchema'
|
|
36
|
+
| 'KinesisDynamoDBStreamSchema'
|
|
37
|
+
| 'KinesisFirehoseSqsSchema'
|
|
38
|
+
| 'LambdaFunctionUrlSchema'
|
|
39
|
+
| 'S3EventNotificationEventBridgeSchema'
|
|
40
|
+
| 'S3Schema'
|
|
41
|
+
| 'S3ObjectLambdaEventSchema'
|
|
42
|
+
| 'S3SqsEventNotificationSchema'
|
|
43
|
+
| 'SesSchema'
|
|
44
|
+
| 'SnsSchema'
|
|
45
|
+
| 'SqsSchema'
|
|
46
|
+
| 'TransferFamilySchema'
|
|
47
|
+
| 'VpcLatticeSchema'
|
|
48
|
+
| 'VpcLatticeV2Schema';
|
|
49
|
+
|
|
50
|
+
export interface TsLambdaFunctionGeneratorSchema {
|
|
51
|
+
readonly project: string;
|
|
52
|
+
readonly functionName: string;
|
|
53
|
+
readonly functionPath?: string;
|
|
54
|
+
readonly eventSource?: EventSource;
|
|
55
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "ts#lambda-function",
|
|
4
|
+
"title": "Add a TypeScript Lambda Function to a project",
|
|
5
|
+
"description": "Add a TypeScript Lambda Function to a project",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"project": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The project to add the lambda function to",
|
|
11
|
+
"x-prompt": "Select the project to add the lambda function to",
|
|
12
|
+
"x-dropdown": "projects"
|
|
13
|
+
},
|
|
14
|
+
"functionName": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The name of the function to add",
|
|
17
|
+
"$default": {
|
|
18
|
+
"$source": "argv",
|
|
19
|
+
"index": 0
|
|
20
|
+
},
|
|
21
|
+
"x-priority": "important",
|
|
22
|
+
"x-prompt": "What name would you like your Lambda Function to have? i.e: MyFunction"
|
|
23
|
+
},
|
|
24
|
+
"functionPath": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Optional subdirectory within the project source directory to add the function to",
|
|
27
|
+
"x-prompt": "Enter the path within the project source directory to add the function to (e.g. 'lambda-functions/')"
|
|
28
|
+
},
|
|
29
|
+
"eventSource": {
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "Optional event source schema to use for the lambda function",
|
|
32
|
+
"x-priority": "important",
|
|
33
|
+
"enum": [
|
|
34
|
+
"Any",
|
|
35
|
+
"AlbSchema",
|
|
36
|
+
"APIGatewayProxyEventSchema",
|
|
37
|
+
"APIGatewayRequestAuthorizerEventSchema",
|
|
38
|
+
"APIGatewayTokenAuthorizerEventSchema",
|
|
39
|
+
"APIGatewayProxyEventV2Schema",
|
|
40
|
+
"APIGatewayProxyWebsocketEventSchema",
|
|
41
|
+
"APIGatewayRequestAuthorizerEventV2Schema",
|
|
42
|
+
"CloudFormationCustomResourceCreateSchema",
|
|
43
|
+
"CloudFormationCustomResourceUpdateSchema",
|
|
44
|
+
"CloudFormationCustomResourceDeleteSchema",
|
|
45
|
+
"CloudWatchLogsSchema",
|
|
46
|
+
"PreSignupTriggerSchema",
|
|
47
|
+
"PostConfirmationTriggerSchema",
|
|
48
|
+
"CustomMessageTriggerSchema",
|
|
49
|
+
"MigrateUserTriggerSchema",
|
|
50
|
+
"CustomSMSSenderTriggerSchema",
|
|
51
|
+
"CustomEmailSenderTriggerSchema",
|
|
52
|
+
"DefineAuthChallengeTriggerSchema",
|
|
53
|
+
"CreateAuthChallengeTriggerSchema",
|
|
54
|
+
"VerifyAuthChallengeTriggerSchema",
|
|
55
|
+
"PreTokenGenerationTriggerSchemaV1",
|
|
56
|
+
"PreTokenGenerationTriggerSchemaV2AndV3",
|
|
57
|
+
"DynamoDBStreamSchema",
|
|
58
|
+
"EventBridgeSchema",
|
|
59
|
+
"KafkaMskEventSchema",
|
|
60
|
+
"KafkaSelfManagedEventSchema",
|
|
61
|
+
"KinesisDataStreamSchema",
|
|
62
|
+
"KinesisFirehoseSchema",
|
|
63
|
+
"KinesisDynamoDBStreamSchema",
|
|
64
|
+
"KinesisFirehoseSqsSchema",
|
|
65
|
+
"LambdaFunctionUrlSchema",
|
|
66
|
+
"S3EventNotificationEventBridgeSchema",
|
|
67
|
+
"S3Schema",
|
|
68
|
+
"S3ObjectLambdaEventSchema",
|
|
69
|
+
"S3SqsEventNotificationSchema",
|
|
70
|
+
"SesSchema",
|
|
71
|
+
"SnsSchema",
|
|
72
|
+
"SqsSchema",
|
|
73
|
+
"TransferFamilySchema",
|
|
74
|
+
"VpcLatticeSchema",
|
|
75
|
+
"VpcLatticeV2Schema"
|
|
76
|
+
],
|
|
77
|
+
"default": "Any",
|
|
78
|
+
"x-prompt": "Enter the event source schema to use for the lambda function"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"required": ["project", "functionName"]
|
|
82
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { TargetConfiguration } from '@nx/devkit';
|
|
6
|
+
export interface CreatePythonBundleTargetOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Directory of the python project from the monorepo root
|
|
9
|
+
*/
|
|
10
|
+
projectDir: string;
|
|
11
|
+
/**
|
|
12
|
+
* Python package name
|
|
13
|
+
*/
|
|
14
|
+
packageName: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Create a target for bundling a python project
|
|
18
|
+
*/
|
|
19
|
+
export declare const createPythonBundleTarget: ({ projectDir, packageName, }: CreatePythonBundleTargetOptions) => TargetConfiguration;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createPythonBundleTarget = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Create a target for bundling a python project
|
|
10
|
+
*/
|
|
11
|
+
const createPythonBundleTarget = ({ projectDir, packageName, }) => {
|
|
12
|
+
return {
|
|
13
|
+
cache: true,
|
|
14
|
+
executor: 'nx:run-commands',
|
|
15
|
+
outputs: [`{workspaceRoot}/dist/${projectDir}/bundle`],
|
|
16
|
+
options: {
|
|
17
|
+
commands: [
|
|
18
|
+
`uv export --frozen --no-dev --no-editable --project ${projectDir} --package ${packageName} -o dist/${projectDir}/bundle/requirements.txt`,
|
|
19
|
+
`uv pip install -n --no-installer-metadata --no-compile-bytecode --python-platform x86_64-manylinux2014 --target dist/${projectDir}/bundle -r dist/${projectDir}/bundle/requirements.txt`,
|
|
20
|
+
],
|
|
21
|
+
parallel: false,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.createPythonBundleTarget = createPythonBundleTarget;
|
|
26
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/bundle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH;;GAEG;AACI,MAAM,wBAAwB,GAAG,CAAC,EACvC,UAAU,EACV,WAAW,GACqB,EAAuB,EAAE;IACzD,OAAO;QACL,KAAK,EAAE,IAAI;QACX,QAAQ,EAAE,iBAAiB;QAC3B,OAAO,EAAE,CAAC,wBAAwB,UAAU,SAAS,CAAC;QACtD,OAAO,EAAE;YACP,QAAQ,EAAE;gBACR,uDAAuD,UAAU,cAAc,WAAW,YAAY,UAAU,0BAA0B;gBAC1I,wHAAwH,UAAU,mBAAmB,UAAU,0BAA0B;aAC1L;YACD,QAAQ,EAAE,KAAK;SAChB;KACF,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,wBAAwB,4BAgBnC"}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare const VERSIONS: {
|
|
|
10
10
|
readonly '@aws-lambda-powertools/logger': "^2.17.0";
|
|
11
11
|
readonly '@aws-lambda-powertools/metrics': "^2.17.0";
|
|
12
12
|
readonly '@aws-lambda-powertools/tracer': "^2.17.0";
|
|
13
|
+
readonly '@aws-lambda-powertools/parser': "^2.17.0";
|
|
14
|
+
readonly '@middy/core': "^6.0.0";
|
|
13
15
|
readonly '@nxlv/python': "^21.0.0";
|
|
14
16
|
readonly '@nx/devkit': "~21.0.3";
|
|
15
17
|
readonly '@modelcontextprotocol/sdk': "^1.11.3";
|
|
@@ -50,5 +52,5 @@ export declare const VERSIONS: {
|
|
|
50
52
|
* Add versions to the given dependencies
|
|
51
53
|
*/
|
|
52
54
|
export declare const withVersions: (deps: (keyof typeof VERSIONS)[]) => {
|
|
53
|
-
[k: string]: "^0.0.60" | "^3.775.0" | "^2.17.0" | "^21.0.0" | "~21.0.3" | "^1.11.3" | "^1.121.16" | "^1.120.17" | "^1.121.0" | "^3.0.94" | "^3.0.928" | "^1.0.38" | "^5.74.3" | "11.0.0" | "^22.13.13" | "^8.10.148" | "^2.8.18" | "^4.2.0" | "^1.0.20" | "^2.1006.0" | "^2.200.0" | "^3.10.3" | "^10.4.2" | "^2.8.5" | "^0.25.1" | "^5.2.5" | "^2.4.0" | "^3.2.0" | "^3.5.3" | "^0.5.21" | "4.20.1" | "^5.1.4" | "^3.25.50";
|
|
55
|
+
[k: string]: "^0.0.60" | "^3.775.0" | "^2.17.0" | "^6.0.0" | "^21.0.0" | "~21.0.3" | "^1.11.3" | "^1.121.16" | "^1.120.17" | "^1.121.0" | "^3.0.94" | "^3.0.928" | "^1.0.38" | "^5.74.3" | "11.0.0" | "^22.13.13" | "^8.10.148" | "^2.8.18" | "^4.2.0" | "^1.0.20" | "^2.1006.0" | "^2.200.0" | "^3.10.3" | "^10.4.2" | "^2.8.5" | "^0.25.1" | "^5.2.5" | "^2.4.0" | "^3.2.0" | "^3.5.3" | "^0.5.21" | "4.20.1" | "^5.1.4" | "^3.25.50";
|
|
54
56
|
};
|
package/src/utils/versions.js
CHANGED
|
@@ -13,6 +13,8 @@ exports.VERSIONS = {
|
|
|
13
13
|
'@aws-lambda-powertools/logger': '^2.17.0',
|
|
14
14
|
'@aws-lambda-powertools/metrics': '^2.17.0',
|
|
15
15
|
'@aws-lambda-powertools/tracer': '^2.17.0',
|
|
16
|
+
'@aws-lambda-powertools/parser': '^2.17.0',
|
|
17
|
+
'@middy/core': '^6.0.0',
|
|
16
18
|
'@nxlv/python': '^21.0.0',
|
|
17
19
|
'@nx/devkit': '~21.0.3',
|
|
18
20
|
'@modelcontextprotocol/sdk': '^1.11.3',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/utils/versions.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,QAAQ,GAAG;IACtB,iCAAiC,EAAE,SAAS;IAC5C,kCAAkC,EAAE,UAAU;IAC9C,+BAA+B,EAAE,UAAU;IAC3C,+CAA+C,EAAE,UAAU;IAC3D,+BAA+B,EAAE,SAAS;IAC1C,gCAAgC,EAAE,SAAS;IAC3C,+BAA+B,EAAE,SAAS;IAC1C,cAAc,EAAE,SAAS;IACzB,YAAY,EAAE,SAAS;IACvB,2BAA2B,EAAE,SAAS;IACtC,wBAAwB,EAAE,WAAW;IACrC,yBAAyB,EAAE,WAAW;IACtC,4BAA4B,EAAE,WAAW;IACzC,+BAA+B,EAAE,WAAW;IAC5C,wBAAwB,EAAE,UAAU;IACpC,qCAAqC,EAAE,SAAS;IAChD,+BAA+B,EAAE,UAAU;IAC3C,kCAAkC,EAAE,SAAS;IAC7C,uBAAuB,EAAE,SAAS;IAClC,4BAA4B,EAAE,QA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