@aws/nx-plugin 0.121.0 → 1.0.0-rc.1
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 +47 -6
- package/package.json +1 -1
- package/src/connection/generator.js +2 -2
- package/src/connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +11 -11
- package/src/infra/app/files/app/src/main.ts.template +2 -2
- package/src/infra/app/generator.js +9 -9
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.ts +1 -1
- package/src/infra/app/schema.json +1 -1
- package/src/mcp-server/guide-pipeline.js +8 -10
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/tools/create-workspace-command.js +1 -1
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/mcp-server/tools/generator-guide.js +2 -2
- package/src/mcp-server/tools/generator-guide.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +6 -8
- package/src/preset/generator.d.ts +1 -1
- package/src/preset/generator.js +4 -6
- package/src/preset/generator.js.map +1 -1
- package/src/preset/schema.d.ts +5 -5
- package/src/preset/schema.json +4 -4
- package/src/py/agent/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/py/agent/a2a-connection/generator.js +4 -3
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/files/deploy/Dockerfile.template +3 -3
- package/src/py/agent/generator.js +23 -23
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.js +1 -1
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/py/agent/react-connection/generator.js +4 -4
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/agent/schema.d.ts +8 -8
- package/src/py/agent/schema.json +18 -18
- package/src/py/api/generator.d.ts +10 -0
- package/src/py/api/generator.js +25 -0
- package/src/py/api/generator.js.map +1 -0
- package/src/py/api/schema.d.ts +17 -0
- package/src/py/api/schema.json +100 -0
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/py/fast-api/generator.js +10 -10
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.js +1 -1
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/fast-api/schema.d.ts +4 -6
- package/src/py/fast-api/schema.json +15 -15
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/lambda-function/files/handler/__lambdaFunctionSnakeCase__.py.template +6 -6
- package/src/py/lambda-function/generator.js +9 -9
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/lambda-function/schema.d.ts +4 -4
- package/src/py/lambda-function/schema.json +7 -7
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/py/mcp-server/generator.js +11 -11
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/mcp-server/schema.d.ts +5 -9
- package/src/py/mcp-server/schema.json +15 -15
- package/src/py/project/generator.js +1 -1
- package/src/py/project/generator.js.map +1 -1
- package/src/py/project/schema.d.ts +1 -1
- package/src/py/project/schema.json +2 -2
- package/src/smithy/project/generator.js +2 -2
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.js +1 -1
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/smithy/ts/api/generator.js +8 -8
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/smithy/ts/api/schema.d.ts +4 -6
- package/src/smithy/ts/api/schema.json +15 -15
- package/src/terraform/project/generator.js +1 -1
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/trpc/backend/files/src/client/index.ts.template +5 -5
- package/src/trpc/backend/files/src/handler.ts.template +2 -2
- package/src/trpc/backend/generator.js +22 -22
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +4 -4
- package/src/trpc/backend/schema.json +15 -15
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/trpc/react/files/src/components/__apiNameClassName__ClientProvider.tsx.template +14 -14
- package/src/trpc/react/generator.js +6 -5
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/agent/a2a-connection/generator.js +4 -3
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/files/deploy/Dockerfile.template +1 -1
- package/src/ts/agent/generator.js +22 -22
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.js +1 -1
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/files/src/components/__agentNameClassName__AgentClientProvider.tsx.template +8 -8
- package/src/ts/agent/react-connection/generator.js +6 -6
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/serve-local.js +2 -2
- package/src/ts/agent/schema.d.ts +8 -8
- package/src/ts/agent/schema.json +18 -18
- package/src/ts/api/generator.d.ts +10 -0
- package/src/ts/api/generator.js +36 -0
- package/src/ts/api/generator.js.map +1 -0
- package/src/ts/api/schema.d.ts +18 -0
- package/src/ts/api/schema.json +105 -0
- package/src/ts/astro-docs/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/astro-docs/generator.js +1 -0
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/docs/generator.d.ts +10 -0
- package/src/ts/docs/generator.js +13 -0
- package/src/ts/docs/generator.js.map +1 -0
- package/src/ts/docs/schema.d.ts +34 -0
- package/src/ts/docs/schema.json +70 -0
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/lambda-function/files/handler/__lambdaFunctionKebabCase__.ts.template +10 -10
- package/src/ts/lambda-function/generator.js +12 -12
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lambda-function/schema.d.ts +4 -4
- package/src/ts/lambda-function/schema.json +7 -7
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/mcp-server/generator.js +12 -12
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.ts +5 -9
- package/src/ts/mcp-server/schema.json +15 -15
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.spec.ts.template +1 -1
- package/src/ts/nx-plugin/generator.js +2 -2
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/rdb/files/prisma.config.ts.template +1 -1
- package/src/ts/rdb/files/scripts/docker-pull.ts.template +1 -1
- package/src/ts/rdb/files/scripts/docker-start.ts.template +3 -3
- package/src/ts/rdb/files/scripts/wait-for-db.ts.template +3 -3
- package/src/ts/rdb/files/src/create-db-user-handler.ts.template +2 -2
- package/src/ts/rdb/files/src/migration-handler.ts.template +2 -2
- package/src/ts/rdb/files/src/prisma.ts.template +2 -2
- package/src/ts/rdb/generator.js +18 -18
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/schema.d.ts +5 -5
- package/src/ts/rdb/schema.json +13 -13
- package/src/ts/rdb/trpc-connection/files/src/middleware/__rdbNameKebab__.ts.template +1 -1
- package/src/ts/react-website/agui/files/common/src/hooks/useAgui__agentNameClassName__.tsx.template +9 -9
- package/src/ts/react-website/agui/generator.d.ts +2 -2
- package/src/ts/react-website/agui/generator.js +9 -9
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +25 -23
- package/src/ts/react-website/app/files/app/cloudscape/src/components/AppLayout/index.tsx.template +5 -5
- package/src/ts/react-website/app/files/app/cloudscape/src/main.tsx.template +1 -1
- package/src/ts/react-website/app/files/app/cloudscape/src/styles.css.template +1 -1
- package/src/ts/react-website/app/files/app/none/src/components/AppLayout/index.tsx.template +5 -5
- package/src/ts/react-website/app/files/app/none/src/main.tsx.template +1 -1
- package/src/ts/react-website/app/files/app/none/src/styles.css.template +2 -2
- package/src/ts/react-website/app/files/app/shadcn/src/components/AppLayout/index.tsx.template +6 -6
- package/src/ts/react-website/app/files/app/shadcn/src/main.tsx.template +1 -1
- package/src/ts/react-website/app/generator.d.ts +3 -3
- package/src/ts/react-website/app/generator.js +28 -27
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/app/schema.d.ts +6 -6
- package/src/ts/react-website/app/schema.json +13 -13
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +3 -3
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.ux-provider.spec.ts.snap +3 -3
- package/src/ts/react-website/cognito-auth/generator.js +9 -9
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.ts +2 -2
- package/src/ts/react-website/cognito-auth/schema.json +4 -4
- package/src/ts/website/app/generator.d.ts +10 -0
- package/src/ts/website/app/generator.js +13 -0
- package/src/ts/website/app/generator.js.map +1 -0
- package/src/ts/website/app/schema.d.ts +20 -0
- package/src/ts/website/app/schema.json +97 -0
- package/src/ts/website/auth/generator.d.ts +10 -0
- package/src/ts/website/auth/generator.js +17 -0
- package/src/ts/website/auth/generator.js.map +1 -0
- package/src/ts/website/auth/schema.d.ts +12 -0
- package/src/ts/website/auth/schema.json +46 -0
- package/src/utils/agent-connection/agent-connection.js +1 -1
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +9 -9
- package/src/utils/agent-core-constructs/agent-core-constructs.js +11 -13
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +13 -13
- package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +4 -4
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +5 -5
- package/src/utils/api-constructs/api-constructs.d.ts +3 -3
- package/src/utils/api-constructs/api-constructs.js +4 -6
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +12 -12
- package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +12 -12
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +7 -7
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +10 -10
- package/src/utils/api-constructs/open-api-metadata.d.ts +3 -3
- package/src/utils/api-constructs/open-api-metadata.js +2 -2
- package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
- package/src/utils/commands.d.ts +1 -1
- package/src/utils/commands.js +2 -2
- package/src/utils/commands.js.map +1 -1
- package/src/utils/config/__snapshots__/utils.spec.ts.snap +6 -6
- package/src/utils/config/index.d.ts +2 -2
- package/src/utils/connection/open-api/files/components/__apiNameClassName__Provider.tsx.template +7 -7
- package/src/utils/connection/open-api/react.d.ts +1 -1
- package/src/utils/connection/open-api/react.js +3 -3
- package/src/utils/containers.d.ts +5 -5
- package/src/utils/containers.js +6 -6
- package/src/utils/containers.js.map +1 -1
- package/src/utils/function-constructs/files/cdk/app/lambda-functions/{__functionNameKebabCase__.ts.template → __nameKebabCase__.ts.template} +1 -1
- package/src/utils/function-constructs/files/terraform/app/lambda-functions/{__functionNameKebabCase__/__functionNameKebabCase__.tf.template → __nameKebabCase__/__nameKebabCase__.tf.template} +7 -7
- package/src/utils/function-constructs/function-constructs.d.ts +4 -4
- package/src/utils/function-constructs/function-constructs.js +5 -7
- package/src/utils/function-constructs/function-constructs.js.map +1 -1
- package/src/utils/iac-providers.d.ts +3 -3
- package/src/utils/iac-providers.js +1 -1
- package/src/utils/iac.d.ts +2 -2
- package/src/utils/iac.js +6 -6
- package/src/utils/iac.js.map +1 -1
- package/src/utils/identity-constructs/identity-constructs.d.ts +2 -2
- package/src/utils/identity-constructs/identity-constructs.js +3 -3
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +4 -4
- package/src/utils/rdb-constructs/rdb-constructs.d.ts +4 -4
- package/src/utils/rdb-constructs/rdb-constructs.js +4 -6
- package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +2 -2
- package/src/utils/shared-constructs.js +3 -3
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/website-constructs/website-constructs.d.ts +2 -2
- package/src/utils/website-constructs/website-constructs.js +4 -6
- package/src/utils/website-constructs/website-constructs.js.map +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<%_ if (
|
|
1
|
+
<%_ if (event !== 'Any') { _%>
|
|
2
2
|
import { parser } from '@aws-lambda-powertools/parser/middleware';
|
|
3
|
-
import { <%=
|
|
3
|
+
import { <%= event %> } from '@aws-lambda-powertools/parser/schemas';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
<%_ } _%>
|
|
6
6
|
import middy from '@middy/core';
|
|
@@ -22,19 +22,19 @@ process.env.POWERTOOLS_SERVICE_NAME = "<%= lambdaFunctionClassName %>";
|
|
|
22
22
|
const tracer = new Tracer();
|
|
23
23
|
const logger = new Logger();
|
|
24
24
|
const metrics = new Metrics();
|
|
25
|
-
<%_ const inputType =
|
|
25
|
+
<%_ const inputType = event === 'Any' ? 'any' : `z.infer<typeof ${event}>`; _%>
|
|
26
26
|
<%_ const outputType = `Promise<${returnType.type}>`; %>
|
|
27
27
|
|
|
28
28
|
export const <%= lambdaFunctionCamelCase %> = async (event: <%- inputType %>): <%- outputType %> => {
|
|
29
29
|
logger.info("Received event", event);
|
|
30
30
|
|
|
31
31
|
// TODO: implement
|
|
32
|
-
<%_ if (['APIGatewayProxyEventSchema', 'APIGatewayProxyEventV2Schema', 'APIGatewayProxyWebsocketEventSchema', 'AlbSchema', 'LambdaFunctionUrlSchema'].includes(
|
|
32
|
+
<%_ if (['APIGatewayProxyEventSchema', 'APIGatewayProxyEventV2Schema', 'APIGatewayProxyWebsocketEventSchema', 'AlbSchema', 'LambdaFunctionUrlSchema'].includes(event)) { _%>
|
|
33
33
|
return {
|
|
34
34
|
statusCode: 200,
|
|
35
35
|
body: ''
|
|
36
36
|
};
|
|
37
|
-
<%_ } else if (['APIGatewayRequestAuthorizerEventSchema', 'APIGatewayTokenAuthorizerEventSchema', 'APIGatewayRequestAuthorizerEventV2Schema'].includes(
|
|
37
|
+
<%_ } else if (['APIGatewayRequestAuthorizerEventSchema', 'APIGatewayTokenAuthorizerEventSchema', 'APIGatewayRequestAuthorizerEventV2Schema'].includes(event)) { _%>
|
|
38
38
|
return {
|
|
39
39
|
principalId: 'user',
|
|
40
40
|
policyDocument: {
|
|
@@ -48,17 +48,17 @@ export const <%= lambdaFunctionCamelCase %> = async (event: <%- inputType %>): <
|
|
|
48
48
|
]
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
<%_ } else if (['KinesisFirehoseSchema', 'KinesisFirehoseSqsSchema'].includes(
|
|
51
|
+
<%_ } else if (['KinesisFirehoseSchema', 'KinesisFirehoseSqsSchema'].includes(event)) { _%>
|
|
52
52
|
return {
|
|
53
53
|
records: []
|
|
54
54
|
};
|
|
55
|
-
<%_ } else if (
|
|
55
|
+
<%_ } else if (event === 'TransferFamilySchema') { _%>
|
|
56
56
|
return {
|
|
57
57
|
Role: '',
|
|
58
58
|
Policy: '',
|
|
59
59
|
HomeDirectory: '/'
|
|
60
60
|
};
|
|
61
|
-
<%_ } else if (['PreSignupTriggerSchema', 'PostConfirmationTriggerSchema', 'CustomMessageTriggerSchema', 'MigrateUserTriggerSchema', 'CustomSMSSenderTriggerSchema', 'CustomEmailSenderTriggerSchema', 'DefineAuthChallengeTriggerSchema', 'CreateAuthChallengeTriggerSchema', 'VerifyAuthChallengeTriggerSchema', 'PreTokenGenerationTriggerSchemaV1', 'PreTokenGenerationTriggerSchemaV2AndV3'].includes(
|
|
61
|
+
<%_ } else if (['PreSignupTriggerSchema', 'PostConfirmationTriggerSchema', 'CustomMessageTriggerSchema', 'MigrateUserTriggerSchema', 'CustomSMSSenderTriggerSchema', 'CustomEmailSenderTriggerSchema', 'DefineAuthChallengeTriggerSchema', 'CreateAuthChallengeTriggerSchema', 'VerifyAuthChallengeTriggerSchema', 'PreTokenGenerationTriggerSchemaV1', 'PreTokenGenerationTriggerSchemaV2AndV3'].includes(event)) { _%>
|
|
62
62
|
return event;
|
|
63
63
|
<%_ } else { /* Event sources which don't need to return a response */ _%>
|
|
64
64
|
<%_ } _%>
|
|
@@ -68,7 +68,7 @@ export const handler = middy()
|
|
|
68
68
|
.use(captureLambdaHandler(tracer))
|
|
69
69
|
.use(injectLambdaContext(logger))
|
|
70
70
|
.use(logMetrics(metrics))
|
|
71
|
-
<%_ if (
|
|
72
|
-
.use(parser({ schema: <%=
|
|
71
|
+
<%_ if (event !== 'Any') { _%>
|
|
72
|
+
.use(parser({ schema: <%= event %> }))
|
|
73
73
|
<%_ } _%>
|
|
74
74
|
.handler(<%= lambdaFunctionCamelCase %>);
|
|
@@ -36,38 +36,38 @@ const tsLambdaFunctionGenerator = async (tree, schema) => {
|
|
|
36
36
|
const dir = projectConfig.root;
|
|
37
37
|
const projectNameWithOutScope = projectConfig.name.split('/').pop();
|
|
38
38
|
const projectNameKebabCase = (0, names_1.toKebabCase)(projectNameWithOutScope);
|
|
39
|
-
const
|
|
40
|
-
const constructFunctionNameKebabCase = `${projectNameKebabCase}-${
|
|
39
|
+
const nameKebabCase = (0, names_1.toKebabCase)(schema.name);
|
|
40
|
+
const constructFunctionNameKebabCase = `${projectNameKebabCase}-${nameKebabCase}`;
|
|
41
41
|
const constructFunctionClassName = (0, names_1.toClassName)(constructFunctionNameKebabCase);
|
|
42
|
-
const lambdaFunctionCamelCase = (0, lodash_camelcase_1.default)(schema.
|
|
43
|
-
const lambdaFunctionClassName = (0, names_1.pascalCase)(schema.
|
|
44
|
-
const lambdaFunctionKebabCase = (0, names_1.toKebabCase)(schema.
|
|
42
|
+
const lambdaFunctionCamelCase = (0, lodash_camelcase_1.default)(schema.name);
|
|
43
|
+
const lambdaFunctionClassName = (0, names_1.pascalCase)(schema.name);
|
|
44
|
+
const lambdaFunctionKebabCase = (0, names_1.toKebabCase)(schema.name);
|
|
45
45
|
const functionPathFromProjectRoot = (0, devkit_1.joinPathFragments)('src', schema.functionPath ?? '', `${lambdaFunctionKebabCase}.ts`);
|
|
46
46
|
const functionPath = (0, devkit_1.joinPathFragments)(projectConfig.root, functionPathFromProjectRoot);
|
|
47
47
|
// Check that the project does not already have a lambda handler
|
|
48
48
|
if (tree.exists(functionPath)) {
|
|
49
|
-
throw new Error(`This project already has a lambda function with the name ${
|
|
49
|
+
throw new Error(`This project already has a lambda function with the name ${nameKebabCase}. Please remove the lambda function before running this generator or use a different name.`);
|
|
50
50
|
}
|
|
51
|
-
const
|
|
51
|
+
const iac = await (0, iac_1.resolveIac)(tree, schema.iac);
|
|
52
52
|
await (0, shared_constructs_1.sharedConstructsGenerator)(tree, {
|
|
53
|
-
|
|
53
|
+
iac,
|
|
54
54
|
});
|
|
55
55
|
const bundleOutputDir = (0, devkit_1.joinPathFragments)('lambda', lambdaFunctionKebabCase);
|
|
56
56
|
await (0, function_constructs_1.addLambdaFunctionInfra)(tree, {
|
|
57
57
|
functionProjectName: projectConfig.name,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
nameClassName: constructFunctionClassName,
|
|
59
|
+
nameKebabCase: constructFunctionNameKebabCase,
|
|
60
60
|
handler: 'index.handler',
|
|
61
61
|
runtime: 'node',
|
|
62
62
|
bundlePathFromRoot: (0, devkit_1.joinPathFragments)('dist', dir, 'bundle', bundleOutputDir),
|
|
63
|
-
|
|
63
|
+
iac,
|
|
64
64
|
});
|
|
65
65
|
const enhancedOptions = {
|
|
66
66
|
...schema,
|
|
67
67
|
lambdaFunctionCamelCase,
|
|
68
68
|
lambdaFunctionClassName,
|
|
69
69
|
lambdaFunctionKebabCase,
|
|
70
|
-
returnType: io_1.TS_HANDLER_RETURN_TYPES[schema.
|
|
70
|
+
returnType: io_1.TS_HANDLER_RETURN_TYPES[schema.event],
|
|
71
71
|
};
|
|
72
72
|
// Add a bundle target for the function
|
|
73
73
|
await (0, bundle_1.addTypeScriptBundleTarget)(tree, projectConfig, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lambda-function/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCASoB;AAEpB,qEAA0E;AAC1E,6CAAyE;AACzE,+CAA0D;AAC1D,+CAAoD;AACpD,uCAKwB;AACxB,iDAAsE;AACtE,mDAAoD;AACpD,gFAAyC;AACzC,6BAA+C;AAC/C,6FAA6F;AAC7F,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/lambda-function/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCASoB;AAEpB,qEAA0E;AAC1E,6CAAyE;AACzE,+CAA0D;AAC1D,+CAAoD;AACpD,uCAKwB;AACxB,iDAAsE;AACtE,mDAAoD;AACpD,gFAAyC;AACzC,6BAA+C;AAC/C,6FAA6F;AAC7F,yCAA6C;AAC7C,sDAAsE;AAEzD,QAAA,iCAAiC,GAC5C,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAE/B;;GAEG;AACI,MAAM,yBAAyB,GAAG,KAAK,EAC5C,IAAU,EACV,MAAuC,EACX,EAAE;IAC9B,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,MAAM,CAAC,OAAO,CACf,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EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,EAChD,IAAA,0BAAiB,EAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,EACtE,eAAe,EACf,EAAE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY,EAAE,CACtD,CAAC;IAEF,IAAA,qCAA4B,EAC1B,IAAI,EACJ,IAAA,uBAAY,EAAC;QACX,+BAA+B;QAC/B,+BAA+B;QAC/B,gCAAgC;QAChC,mCAAmC;QACnC,+BAA+B;QAC/B,+BAA+B;QAC/B,aAAa;QACb,KAAK;KACN,CAAC,EACF,IAAA,uBAAY,EAAC,CAAC,mBAAmB,CAAC,CAAC,CACpC,CAAC;IAEF,IAAA,kCAA6B,EAC3B,IAAI,EACJ,aAAa,CAAC,IAAI,EAClB,yCAAiC,EACjC,2BAA2B,EAC3B,uBAAuB,CACxB,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,CAAC;AAxIW,QAAA,yBAAyB,6BAwIpC;AAEF,kBAAe,iCAAyB,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { IacOption } from '../../utils/iac';
|
|
7
7
|
|
|
8
8
|
export type EventSource =
|
|
9
9
|
| 'Any'
|
|
@@ -51,8 +51,8 @@ export type EventSource =
|
|
|
51
51
|
|
|
52
52
|
export interface TsLambdaFunctionGeneratorSchema {
|
|
53
53
|
readonly project: string;
|
|
54
|
-
readonly
|
|
54
|
+
readonly name: string;
|
|
55
55
|
readonly functionPath?: string;
|
|
56
|
-
readonly
|
|
57
|
-
readonly
|
|
56
|
+
readonly event?: EventSource;
|
|
57
|
+
readonly iac: IacOption;
|
|
58
58
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"x-prompt": "Select the project to add the lambda function to",
|
|
12
12
|
"x-dropdown": "projects"
|
|
13
13
|
},
|
|
14
|
-
"
|
|
14
|
+
"name": {
|
|
15
15
|
"type": "string",
|
|
16
16
|
"description": "The name of the function to add",
|
|
17
17
|
"$default": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"description": "Optional subdirectory within the project source directory to add the function to",
|
|
27
27
|
"x-prompt": "Enter the path within the project source directory to add the function to (e.g. 'lambda-functions/')"
|
|
28
28
|
},
|
|
29
|
-
"
|
|
29
|
+
"event": {
|
|
30
30
|
"type": "string",
|
|
31
31
|
"description": "Optional event source schema to use for the lambda function",
|
|
32
32
|
"x-priority": "important",
|
|
@@ -77,14 +77,14 @@
|
|
|
77
77
|
"default": "Any",
|
|
78
78
|
"x-prompt": "Enter the event source schema to use for the lambda function"
|
|
79
79
|
},
|
|
80
|
-
"
|
|
80
|
+
"iac": {
|
|
81
81
|
"type": "string",
|
|
82
82
|
"description": "The preferred IaC provider. By default this is inherited from your initial selection.",
|
|
83
|
-
"enum": ["
|
|
83
|
+
"enum": ["inherit", "cdk", "terraform"],
|
|
84
84
|
"x-priority": "important",
|
|
85
|
-
"default": "
|
|
86
|
-
"x-prompt": "Which provider would you like to manage your infrastructure? (default:
|
|
85
|
+
"default": "inherit",
|
|
86
|
+
"x-prompt": "Which provider would you like to manage your infrastructure? (default: inherit)"
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
-
"required": ["project", "
|
|
89
|
+
"required": ["project", "name"]
|
|
90
90
|
}
|
|
@@ -162,7 +162,7 @@ variable "server_protocol" {
|
|
|
162
162
|
default = "HTTP"
|
|
163
163
|
validation {
|
|
164
164
|
condition = contains(["MCP", "HTTP", "A2A"], var.server_protocol)
|
|
165
|
-
error_message = "Protocol type must be either '
|
|
165
|
+
error_message = "Protocol type must be either 'mcp', 'http', or 'a2a'."
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -33,11 +33,11 @@ const tsMcpServerGenerator = async (tree, options) => {
|
|
|
33
33
|
const targetSourceDir = (0, devkit_1.joinPathFragments)(project.root, targetSourceDirRelativeToProjectRoot);
|
|
34
34
|
const relativeSourceDir = targetSourceDir.replace(project.root + '/', './');
|
|
35
35
|
const distDir = (0, devkit_1.joinPathFragments)('dist', project.root);
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
console.warn('Warning: auth is ignored when no
|
|
36
|
+
const infra = options.infra ?? 'agentcore';
|
|
37
|
+
if (infra === 'none' && options.auth && options.auth !== 'iam') {
|
|
38
|
+
console.warn('Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)');
|
|
39
39
|
}
|
|
40
|
-
const auth = options.auth ?? '
|
|
40
|
+
const auth = options.auth ?? 'iam';
|
|
41
41
|
// Create a package.json if one doesn't exist, since we want to add the server as a bin target
|
|
42
42
|
const projectPackageJsonPath = (0, devkit_1.joinPathFragments)(project.root, 'package.json');
|
|
43
43
|
if (!tree.exists(projectPackageJsonPath)) {
|
|
@@ -79,9 +79,9 @@ const tsMcpServerGenerator = async (tree, options) => {
|
|
|
79
79
|
'@types/express',
|
|
80
80
|
'@modelcontextprotocol/inspector',
|
|
81
81
|
]);
|
|
82
|
-
// Add hosting based on
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
82
|
+
// Add hosting based on infra
|
|
83
|
+
if (infra === 'agentcore') {
|
|
84
|
+
const containers = await (0, containers_1.resolveContainers)(tree, 'inherit');
|
|
85
85
|
const dockerImageTag = `${(0, npm_scope_1.getNpmScope)(tree)}-${name}:latest`;
|
|
86
86
|
// Add bundle target
|
|
87
87
|
await (0, bundle_1.addTypeScriptBundleTarget)(tree, project, {
|
|
@@ -98,7 +98,7 @@ const tsMcpServerGenerator = async (tree, options) => {
|
|
|
98
98
|
options: {
|
|
99
99
|
commands: [
|
|
100
100
|
fs.cp(`${targetSourceDir}/Dockerfile`, `${dockerOutputDir}/Dockerfile`),
|
|
101
|
-
`${
|
|
101
|
+
`${containers} build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,
|
|
102
102
|
],
|
|
103
103
|
parallel: false,
|
|
104
104
|
},
|
|
@@ -107,8 +107,8 @@ const tsMcpServerGenerator = async (tree, options) => {
|
|
|
107
107
|
(0, nx_1.addDependencyToTargetIfNotPresent)(project, 'docker', dockerTargetName);
|
|
108
108
|
(0, nx_1.addDependencyToTargetIfNotPresent)(project, 'build', 'docker');
|
|
109
109
|
// Add shared constructs
|
|
110
|
-
const
|
|
111
|
-
await (0, shared_constructs_1.sharedConstructsGenerator)(tree, {
|
|
110
|
+
const iac = await (0, iac_1.resolveIac)(tree, options.iac);
|
|
111
|
+
await (0, shared_constructs_1.sharedConstructsGenerator)(tree, { iac });
|
|
112
112
|
// Add the construct to deploy the mcp server
|
|
113
113
|
await (0, agent_core_constructs_1.addMcpServerInfra)(tree, {
|
|
114
114
|
mcpServerNameKebabCase: name,
|
|
@@ -116,9 +116,9 @@ const tsMcpServerGenerator = async (tree, options) => {
|
|
|
116
116
|
projectName: project.name,
|
|
117
117
|
dockerImageTag,
|
|
118
118
|
dockerOutputDir,
|
|
119
|
-
|
|
119
|
+
iac,
|
|
120
120
|
auth,
|
|
121
|
-
|
|
121
|
+
containers,
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/mcp-server/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAaoB;AAEpB,uCAMwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,mDAAiE;AACjE,6CAA2D;AAC3D,qEAA0E;AAC1E,mGAA4F;AAE5F,qDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/mcp-server/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAaoB;AAEpB,uCAMwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,mDAAiE;AACjE,6CAA2D;AAC3D,qEAA0E;AAC1E,mGAA4F;AAE5F,qDAAoD;AACpD,yCAA6C;AAC7C,uDAA2D;AAC3D,sDAAsE;AACtE,2CAA8C;AAC9C,uCAA4C;AAE/B,QAAA,4BAA4B,GACvC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,oBAAoB,GAAG,KAAK,EACvC,IAAU,EACV,OAAmC,EACP,EAAE;IAC9B,MAAM,OAAO,GAAG,IAAA,wCAAmC,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3E,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,KAAK,CACb,uBAAuB,OAAO,CAAC,OAAO,wDAAwD,CAC/F,CAAC;IACJ,CAAC;IAED,MAAM,WAAW,GAAG,GAAG,IAAA,iBAAS,EAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC;IAC7E,MAAM,IAAI,GAAG,IAAA,iBAAS,EAAC,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC,CAAC;IACpD,MAAM,sBAAsB,GAAG,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC;IACjD,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC;IAC3D,MAAM,oCAAoC,GAAG,IAAA,0BAAiB,EAC5D,KAAK,EACL,eAAe,CAChB,CA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AAe,iBAAiB,UAAU,CAAC;oBACtD,GAAG,EAAE,eAAe;oBACpB,GAAG,EAAE;wBACH,IAAI,EAAE,GAAG,YAAY,EAAE;wBACvB,WAAW,EAAE,MAAM;qBACpB;iBACF;gBACD,UAAU,EAAE,IAAI;aACjB;YACD,CAAC,GAAG,eAAe,UAAU,CAAC,EAAE;gBAC9B,QAAQ,EAAE,iBAAiB;gBAC3B,OAAO,EAAE;oBACP,QAAQ,EAAE;wBACR,gCAAgC,iBAAiB,WAAW;qBAC7D;oBACD,GAAG,EAAE,eAAe;iBACrB;gBACD,UAAU,EAAE,IAAI;aACjB;SACF;KACF,CAAC,CAAC;IAEH,IAAA,kCAA6B,EAC3B,IAAI,EACJ,OAAO,CAAC,IAAI,EACZ,oCAA4B,EAC5B,oCAAoC,EACpC,eAAe,EACf;QACE,IAAI,EAAE,YAAY;QAClB,EAAE,EAAE,sBAAsB;QAC1B,IAAI;KACL,CACF,CAAC;IAEF,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE,CAAC,oCAA4B,CAAC,CAAC,CAAC;IAE5E,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE;QACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC,CAAC;AAnPW,QAAA,oBAAoB,wBAmP/B;AAEF,kBAAe,4BAAoB,CAAC"}
|
|
@@ -3,20 +3,16 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { IacOption } from '../../utils/iac';
|
|
7
7
|
|
|
8
|
-
export type
|
|
8
|
+
export type TsMcpServerInfra = 'none' | 'agentcore';
|
|
9
9
|
|
|
10
|
-
export type TsMcpServerAuth = '
|
|
10
|
+
export type TsMcpServerAuth = 'iam' | 'cognito';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* TypeScript types for options defined in schema.json
|
|
14
|
-
* Update this to match schema.json if you make changes.
|
|
15
|
-
*/
|
|
16
12
|
export interface TsMcpServerGeneratorSchema {
|
|
17
13
|
project: string;
|
|
18
14
|
name?: string;
|
|
19
|
-
|
|
15
|
+
infra?: TsMcpServerInfra;
|
|
20
16
|
auth?: TsMcpServerAuth;
|
|
21
|
-
|
|
17
|
+
iac: IacOption;
|
|
22
18
|
}
|
|
@@ -15,14 +15,6 @@
|
|
|
15
15
|
"x-prompt": "Select the TypeScript project to add the MCP server to",
|
|
16
16
|
"x-dropdown": "projects"
|
|
17
17
|
},
|
|
18
|
-
"computeType": {
|
|
19
|
-
"type": "string",
|
|
20
|
-
"description": "The type of compute to host your MCP server. Select None for no hosting.",
|
|
21
|
-
"x-prompt": "How would you like to host your MCP server?",
|
|
22
|
-
"enum": ["BedrockAgentCoreRuntime", "None"],
|
|
23
|
-
"default": "BedrockAgentCoreRuntime",
|
|
24
|
-
"x-priority": "important"
|
|
25
|
-
},
|
|
26
18
|
"name": {
|
|
27
19
|
"type": "string",
|
|
28
20
|
"description": "The name of your MCP server (default: mcp-server)",
|
|
@@ -30,19 +22,27 @@
|
|
|
30
22
|
},
|
|
31
23
|
"auth": {
|
|
32
24
|
"type": "string",
|
|
33
|
-
"description": "The method used to authenticate with your MCP server. Only applicable when
|
|
34
|
-
"default": "
|
|
35
|
-
"enum": ["
|
|
25
|
+
"description": "The method used to authenticate with your MCP server. Only applicable when infra is set (ignored when infra is none).",
|
|
26
|
+
"default": "iam",
|
|
27
|
+
"enum": ["iam", "cognito"],
|
|
36
28
|
"x-prompt": "How would you like to authenticate with your MCP server?",
|
|
37
29
|
"x-priority": "important"
|
|
38
30
|
},
|
|
39
|
-
"
|
|
31
|
+
"iac": {
|
|
40
32
|
"type": "string",
|
|
41
33
|
"description": "The preferred IaC provider. By default this is inherited from your initial selection.",
|
|
42
|
-
"enum": ["
|
|
34
|
+
"enum": ["inherit", "cdk", "terraform"],
|
|
43
35
|
"x-priority": "important",
|
|
44
|
-
"default": "
|
|
45
|
-
"x-prompt": "Which provider would you like to manage your infrastructure? (default:
|
|
36
|
+
"default": "inherit",
|
|
37
|
+
"x-prompt": "Which provider would you like to manage your infrastructure? (default: inherit)"
|
|
38
|
+
},
|
|
39
|
+
"infra": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"description": "The type of infrastructure to host your MCP server. Select none for no hosting.",
|
|
42
|
+
"x-prompt": "How would you like to host your MCP server?",
|
|
43
|
+
"enum": ["agentcore", "none"],
|
|
44
|
+
"default": "agentcore",
|
|
45
|
+
"x-priority": "important"
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"required": ["project"]
|
|
@@ -93,7 +93,7 @@ describe('foo#bar generator', () => {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
it('should add generator metric to app.ts', async () => {
|
|
96
|
-
await sharedConstructsGenerator(tree, {
|
|
96
|
+
await sharedConstructsGenerator(tree, { iac: 'cdk' });
|
|
97
97
|
|
|
98
98
|
await fooBarGenerator(tree, { exampleOption: 'example' });
|
|
99
99
|
|
|
@@ -18,7 +18,7 @@ describe('<%- name %> generator', () => {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('should add generator metric to app.ts', async () => {
|
|
21
|
-
await sharedConstructsGenerator(tree, {
|
|
21
|
+
await sharedConstructsGenerator(tree, { iac: 'cdk' });
|
|
22
22
|
|
|
23
23
|
await <%- nameCamelCase %>Generator(tree, { exampleOption: 'example' });
|
|
24
24
|
|
|
@@ -71,8 +71,8 @@ const tsNxPluginGenerator = async (tree, options) => {
|
|
|
71
71
|
// Add an MCP Server
|
|
72
72
|
await (0, generator_2.default)(tree, {
|
|
73
73
|
project: fullyQualifiedName,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
infra: 'none',
|
|
75
|
+
iac: 'cdk', // not used
|
|
76
76
|
});
|
|
77
77
|
const mcpPath = (0, devkit_1.joinPathFragments)(project.sourceRoot, 'mcp-server');
|
|
78
78
|
const mcpServerPath = (0, devkit_1.joinPathFragments)(mcpPath, 'server.ts');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCASoB;AAEpB,uCAKwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,sEAAuE;AACvE,mCAAuD;AACvD,gFAA2D;AAE9C,QAAA,2BAA2B,GACtC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,mBAAmB,GAAG,KAAK,EACtC,IAAU,EACV,OAAkC,EACN,EAAE;IAC9B,4CAA4C;IAC5C,MAAM,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,IAAA,2BAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnE,MAAM,IAAA,mBAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAExC,mDAAmD;IACnD,IAAA,oCAA4B,EAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IAEvD,+EAA+E;IAC/E,MAAM,OAAO,GAAG,IAAA,wCAAmC,EAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;IAC9E,OAAO,CAAC,OAAO,GAAG;QAChB,GAAG,OAAO,CAAC,OAAO;QAClB,OAAO,EAAE;YACP,QAAQ,EAAE,YAAY;YACtB,OAAO,EAAE,CAAC,sBAAsB,CAAC;YACjC,OAAO,EAAE;gBACP,UAAU,EAAE,4BAA4B;gBACxC,IAAI,EAAE,4BAA4B;gBAClC,QAAQ,EAAE,iCAAiC;gBAC3C,MAAM,EAAE;oBACN,oBAAoB;oBACpB,wBAAwB;oBACxB,sBAAsB;oBACtB;wBACE,KAAK,EAAE,qBAAqB;wBAC5B,IAAI,EAAE,YAAY;wBAClB,MAAM,EAAE,OAAO;qBAChB;oBACD;wBACE,KAAK,EAAE,qBAAqB;wBAC5B,IAAI,EAAE,WAAW;wBACjB,MAAM,EAAE,OAAO;qBAChB;oBACD;wBACE,KAAK,EAAE,iBAAiB;wBACxB,IAAI,EAAE,iBAAiB;wBACvB,MAAM,EAAE,GAAG;qBACZ;oBACD;wBACE,KAAK,EAAE,iBAAiB;wBACxB,IAAI,EAAE,gBAAgB;wBACtB,MAAM,EAAE,GAAG;qBACZ;iBACF;aACF;SACF;QACD,KAAK,EAAE;YACL,SAAS,EAAE;gBACT,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC,MAAM,CACjD,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,SAAS,CAChD;gBACD,SAAS;aACV;SACF;KACF,CAAC;IACF,IAAA,mCAA0B,EAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,CAAC;IAE9D,+CAA+C;IAC/C,IAAI,CAAC,KAAK,CAAC,IAAA,0BAAiB,EAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;IAElE,oBAAoB;IACpB,MAAM,IAAA,mBAAoB,EAAC,IAAI,EAAE;QAC/B,OAAO,EAAE,kBAAkB;QAC3B,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCASoB;AAEpB,uCAKwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,sEAAuE;AACvE,mCAAuD;AACvD,gFAA2D;AAE9C,QAAA,2BAA2B,GACtC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,mBAAmB,GAAG,KAAK,EACtC,IAAU,EACV,OAAkC,EACN,EAAE;IAC9B,4CAA4C;IAC5C,MAAM,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,IAAA,2BAAe,EAAC,IAAI,EAAE,OAAO,C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AAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC,CAAC;AAjGW,QAAA,mBAAmB,uBAiG9B;AAEF,kBAAe,2BAAmB,CAAC"}
|
|
@@ -901,7 +901,7 @@ export default defineConfig({
|
|
|
901
901
|
"
|
|
902
902
|
`;
|
|
903
903
|
|
|
904
|
-
exports[`ts#rdb generator > should generate terraform modules when
|
|
904
|
+
exports[`ts#rdb generator > should generate terraform modules when iac is Terraform 1`] = `
|
|
905
905
|
"# Core Aurora module
|
|
906
906
|
# This module creates an Aurora cluster and a generated admin secret.
|
|
907
907
|
|
|
@@ -1647,7 +1647,7 @@ output "admin_user" {
|
|
|
1647
1647
|
"
|
|
1648
1648
|
`;
|
|
1649
1649
|
|
|
1650
|
-
exports[`ts#rdb generator > should generate terraform modules when
|
|
1650
|
+
exports[`ts#rdb generator > should generate terraform modules when iac is Terraform 2`] = `
|
|
1651
1651
|
"terraform {
|
|
1652
1652
|
required_version = ">= 1.0"
|
|
1653
1653
|
|
|
@@ -4,7 +4,7 @@ const getDatabaseUrl = async () => {
|
|
|
4
4
|
if (process.env.SERVE_LOCAL === 'true') {
|
|
5
5
|
const { LOCAL_DB_HOST, LOCAL_DB_NAME, LOCAL_DB_PASSWORD, LOCAL_DB_PORT, LOCAL_DB_USER } =
|
|
6
6
|
await import('./src/constants.js');
|
|
7
|
-
<%_ if (engine === '
|
|
7
|
+
<%_ if (engine === 'mysql') { _%>
|
|
8
8
|
return `mysql://${LOCAL_DB_USER}:${LOCAL_DB_PASSWORD}@${LOCAL_DB_HOST}:${LOCAL_DB_PORT}/${LOCAL_DB_NAME}`;
|
|
9
9
|
<%_ } else { _%>
|
|
10
10
|
return `postgresql://${LOCAL_DB_USER}:${LOCAL_DB_PASSWORD}@${LOCAL_DB_HOST}:${LOCAL_DB_PORT}/${LOCAL_DB_NAME}`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { spawn, spawnSync } from 'child_process';
|
|
2
2
|
|
|
3
|
-
const ENGINE = '<%=
|
|
3
|
+
const ENGINE = '<%= containers %>';
|
|
4
4
|
|
|
5
|
-
<%_ if (engine === '
|
|
5
|
+
<%_ if (engine === 'mysql') { _%>
|
|
6
6
|
const [containerName, image, hostPort, dbName, dbPassword] =
|
|
7
7
|
process.argv.slice(2);
|
|
8
8
|
<%_ } else { _%>
|
|
@@ -32,7 +32,7 @@ if (containerExists()) {
|
|
|
32
32
|
if (start.status !== 0) process.exit(start.status ?? 1);
|
|
33
33
|
}
|
|
34
34
|
} else {
|
|
35
|
-
<%_ if (engine === '
|
|
35
|
+
<%_ if (engine === 'mysql') { _%>
|
|
36
36
|
const runArgs = [
|
|
37
37
|
'run',
|
|
38
38
|
'--name', containerName,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%_ if (engine === '
|
|
1
|
+
<%_ if (engine === 'mysql') { _%>
|
|
2
2
|
import { createConnection, Connection } from 'mariadb';
|
|
3
3
|
<%_ } else { _%>
|
|
4
4
|
import { Client } from 'pg';
|
|
@@ -10,7 +10,7 @@ const [portArg, dbArg, userArg, passwordArg] = process.argv.slice(2);
|
|
|
10
10
|
const timeoutAt = Date.now() + 60000;
|
|
11
11
|
|
|
12
12
|
while (Date.now() < timeoutAt) {
|
|
13
|
-
<%_ if (engine === '
|
|
13
|
+
<%_ if (engine === 'mysql') { _%>
|
|
14
14
|
let conn: Connection | undefined;
|
|
15
15
|
try {
|
|
16
16
|
conn = await createConnection({
|
|
@@ -52,4 +52,4 @@ while (Date.now() < timeoutAt) {
|
|
|
52
52
|
await new Promise((r) => setTimeout(r, 200));
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
throw new Error(`Timed out waiting for <%= engine === '
|
|
55
|
+
throw new Error(`Timed out waiting for <%= engine === 'mysql' ? 'mysql' : 'postgres' %> on port ${portArg}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CloudFormationCustomResourceEvent } from 'aws-lambda';
|
|
2
2
|
import { randomBytes } from 'node:crypto';
|
|
3
|
-
<%_ if (engine === '
|
|
3
|
+
<%_ if (engine === 'mysql') { _%>
|
|
4
4
|
import { createPool, type PoolConnection } from 'mariadb';
|
|
5
5
|
import { getDatabaseSecret, withConnectionRetry } from './utils.js';
|
|
6
6
|
<%_ } else { _%>
|
|
@@ -21,7 +21,7 @@ const resolveDbUser = (physicalResourceId?: string): string =>
|
|
|
21
21
|
: `db_${randomBytes(8).toString('hex')}`;
|
|
22
22
|
|
|
23
23
|
const ensureDatabaseUser = async (dbUser: string): Promise<void> => {
|
|
24
|
-
<%_ if (engine === '
|
|
24
|
+
<%_ if (engine === 'mysql') { _%>
|
|
25
25
|
const { dbname, username, password, host, port } = await getDatabaseSecret();
|
|
26
26
|
const pool = createPool({
|
|
27
27
|
host,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
|
-
<%_ if (engine === '
|
|
3
|
+
<%_ if (engine === 'mysql') { _%>
|
|
4
4
|
import { getDatabaseSecret, withConnectionRetry } from './utils.js';
|
|
5
5
|
<%_ } else { _%>
|
|
6
6
|
import { Signer } from '@aws-sdk/rds-signer';
|
|
@@ -8,7 +8,7 @@ import { withConnectionRetry } from './utils.js';
|
|
|
8
8
|
<%_ } _%>
|
|
9
9
|
|
|
10
10
|
const buildDatabaseUrl = async (): Promise<string> => {
|
|
11
|
-
<%_ if (engine === '
|
|
11
|
+
<%_ if (engine === 'mysql') { _%>
|
|
12
12
|
const { host, port, dbname, username, password } = await getDatabaseSecret();
|
|
13
13
|
|
|
14
14
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { <%= prismaAdapterClassName %> } from '<%= prismaAdapterPackage %>';
|
|
2
2
|
import { Signer } from '@aws-sdk/rds-signer';
|
|
3
3
|
import { Prisma, PrismaClient } from '../generated/prisma/client.js';
|
|
4
|
-
<%_ if (engine === '
|
|
4
|
+
<%_ if (engine === 'postgres') { _%>
|
|
5
5
|
import { Pool } from 'pg';
|
|
6
6
|
<%_ } _%>
|
|
7
7
|
import {
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
LOCAL_DB_USER,
|
|
14
14
|
} from './constants.js';
|
|
15
15
|
import { getDatabaseConfig } from './utils.js';
|
|
16
|
-
<%_ if (engine === '
|
|
16
|
+
<%_ if (engine === 'mysql') { _%>
|
|
17
17
|
|
|
18
18
|
export const getPrisma = async <LogOpts extends Prisma.LogLevel>(
|
|
19
19
|
log: LogOpts[] = ['warn', 'error'] as LogOpts[],
|