@aws/nx-plugin 0.80.1 → 0.82.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/LICENSE-THIRD-PARTY +141 -373
- package/package.json +4 -4
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +11 -11
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +368 -86
- package/src/py/fast-api/generator.js +3 -0
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/schema.d.ts +1 -0
- package/src/py/fast-api/schema.json +22 -0
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +12 -8
- package/src/smithy/ts/api/generator.js +3 -0
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/smithy/ts/api/schema.d.ts +4 -0
- package/src/smithy/ts/api/schema.json +22 -0
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +392 -102
- package/src/trpc/backend/generator.js +20 -1
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +1 -0
- package/src/trpc/backend/schema.json +22 -0
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +2 -3
- package/src/trpc/react/generator.js +1 -2
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +28 -28
- package/src/ts/strands-agent/__snapshots__/generator.spec.ts.snap +5 -4
- package/src/ts/strands-agent/files/app/router.ts.template +5 -4
- package/src/utils/api-constructs/api-constructs.d.ts +1 -0
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +18 -10
- package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +28 -16
- package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +25 -5
- package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +32 -8
- package/src/utils/api-constructs/files/cdk/core/api/utils/utils.ts.template +151 -32
- package/src/utils/connection/open-api/react.js +1 -2
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/alert.tsx.template +3 -3
- package/src/utils/files/common/shadcn/src/components/ui/breadcrumb.tsx.template +3 -3
- package/src/utils/files/common/shadcn/src/components/ui/button.tsx.template +4 -4
- package/src/utils/files/common/shadcn/src/components/ui/card.tsx.template +2 -2
- package/src/utils/files/common/shadcn/src/components/ui/input.tsx.template +3 -3
- package/src/utils/files/common/shadcn/src/components/ui/separator.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/sheet.tsx.template +9 -9
- package/src/utils/files/common/shadcn/src/components/ui/sidebar.tsx.template +18 -18
- package/src/utils/files/common/shadcn/src/components/ui/skeleton.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/tooltip.tsx.template +2 -2
- package/src/utils/files/website/hooks/sigv4/useSigV4.tsx.template +2 -3
- package/src/utils/versions.d.ts +40 -42
- package/src/utils/versions.js +39 -41
- package/src/utils/versions.js.map +1 -1
|
@@ -22,8 +22,15 @@ const port_1 = require("../../utils/port");
|
|
|
22
22
|
const iac_1 = require("../../utils/iac");
|
|
23
23
|
const bundle_1 = require("../../utils/bundle/bundle");
|
|
24
24
|
exports.TRPC_BACKEND_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
25
|
+
const VALID_TRPC_INTEGRATION_PERMUTATIONS = new Set([
|
|
26
|
+
'ServerlessApiGatewayRestApi::isolated',
|
|
27
|
+
'ServerlessApiGatewayRestApi::shared',
|
|
28
|
+
'ServerlessApiGatewayHttpApi::isolated',
|
|
29
|
+
'ServerlessApiGatewayHttpApi::shared',
|
|
30
|
+
]);
|
|
25
31
|
function tsTrpcApiGenerator(tree, options) {
|
|
26
32
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
validateTrpcComputeTypeAndIntegrationPatternCombination(options);
|
|
27
34
|
const iacProvider = yield (0, iac_1.resolveIacProvider)(tree, options.iacProvider);
|
|
28
35
|
yield (0, shared_constructs_1.sharedConstructsGenerator)(tree, {
|
|
29
36
|
iacProvider,
|
|
@@ -52,11 +59,12 @@ function tsTrpcApiGenerator(tree, options) {
|
|
|
52
59
|
type: 'trpc',
|
|
53
60
|
projectAlias: enhancedOptions.backendProjectAlias,
|
|
54
61
|
bundleOutputDir: (0, devkit_1.joinPathFragments)('dist', backendRoot, 'bundle'),
|
|
62
|
+
integrationPattern: getIntegrationPattern(options),
|
|
55
63
|
},
|
|
56
64
|
auth: options.auth,
|
|
57
65
|
iacProvider,
|
|
58
66
|
});
|
|
59
|
-
projectConfig.metadata = Object.assign(Object.assign({}, projectConfig.metadata), { apiName: options.name, apiType: 'trpc', auth: options.auth, computeType: options.computeType });
|
|
67
|
+
projectConfig.metadata = Object.assign(Object.assign({}, projectConfig.metadata), { apiName: options.name, apiType: 'trpc', auth: options.auth, computeType: options.computeType, integrationPattern: getIntegrationPattern(options) });
|
|
60
68
|
projectConfig.targets.serve = {
|
|
61
69
|
executor: 'nx:run-commands',
|
|
62
70
|
options: {
|
|
@@ -100,6 +108,17 @@ function tsTrpcApiGenerator(tree, options) {
|
|
|
100
108
|
};
|
|
101
109
|
});
|
|
102
110
|
}
|
|
111
|
+
const validateTrpcComputeTypeAndIntegrationPatternCombination = (options) => {
|
|
112
|
+
const integrationPattern = getIntegrationPattern(options);
|
|
113
|
+
const permutation = `${options.computeType}::${integrationPattern}`;
|
|
114
|
+
if (!VALID_TRPC_INTEGRATION_PERMUTATIONS.has(permutation)) {
|
|
115
|
+
throw new Error(`Invalid tRPC computeType/integrationPattern combination: ${options.computeType} + ${integrationPattern}.`);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const getIntegrationPattern = (options) => {
|
|
119
|
+
var _a;
|
|
120
|
+
return (_a = options.integrationPattern) !== null && _a !== void 0 ? _a : 'isolated';
|
|
121
|
+
};
|
|
103
122
|
const getApiGatewayEventType = (options) => {
|
|
104
123
|
if (options.computeType === 'ServerlessApiGatewayRestApi') {
|
|
105
124
|
return 'APIGatewayProxyEvent';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/backend/generator.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/backend/generator.ts"],"names":[],"mappings":";;;AA6CA,gDAqIC;;AAlLD;;;GAGG;AACH,uCASoB;AAEpB,qEAA0E;AAC1E,+EAAwD;AACxD,qDAAwE;AACxE,mDAAoD;AACpD,6CAA2D;AAC3D,+CAA0D;AAC1D,+CAAoD;AACpD,uCAMwB;AACxB,iDAAsE;AACtE,8EAA+E;AAC/E,2CAA8C;AAC9C,yCAAqD;AACrD,sDAAsE;AAEzD,QAAA,2BAA2B,GACtC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAE/B,MAAM,mCAAmC,GAAG,IAAI,GAAG,CAAC;IAClD,uCAAuC;IACvC,qCAAqC;IACrC,uCAAuC;IACvC,qCAAqC;CACtC,CAAC,CAAC;AAEH,SAAsB,kBAAkB,CACtC,IAAU,EACV,OAAiC;;QAEjC,uDAAuD,CAAC,OAAO,CAAC,CAAC;QAEjE,MAAM,WAAW,GAAG,MAAM,IAAA,wBAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;QAExE,MAAM,IAAA,6CAAyB,EAAC,IAAI,EAAE;YACpC,WAAW;SACZ,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,gBAAgB,GAAG,IAAA,iBAAS,EAAC,OAAO,CAAC,IAAI,CAAC,C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CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,OAAiC,EAAU,EAAE;IAC3E,IAAI,OAAO,CAAC,WAAW,KAAK,6BAA6B,EAAE,CAAC;QAC1D,OAAO,sBAAsB,CAAC;IAChC,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3B,OAAO,yCAAyC,CAAC;IACnD,CAAC;SAAM,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,yCAAyC,CAAC;IACnD,CAAC;IACD,OAAO,wBAAwB,CAAC;AAClC,CAAC,CAAC;AAEF,kBAAe,kBAAkB,CAAC"}
|
|
@@ -9,6 +9,7 @@ import { TsProjectGeneratorSchema } from '../../ts/lib/schema';
|
|
|
9
9
|
export interface TsTrpcApiGeneratorSchema {
|
|
10
10
|
name: string;
|
|
11
11
|
computeType: 'ServerlessApiGatewayRestApi' | 'ServerlessApiGatewayHttpApi';
|
|
12
|
+
integrationPattern?: 'isolated' | 'shared';
|
|
12
13
|
auth: 'IAM' | 'Cognito' | 'None';
|
|
13
14
|
directory?: TsProjectGeneratorSchema['directory'];
|
|
14
15
|
iacProvider: IacProviderOption;
|
|
@@ -21,6 +21,28 @@
|
|
|
21
21
|
"x-prompt": "What compute type would you like to deploy your API with?",
|
|
22
22
|
"x-priority": "important"
|
|
23
23
|
},
|
|
24
|
+
"integrationPattern": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "How API Gateway integrations are generated for the API. Choose between isolated (default) and shared.",
|
|
27
|
+
"default": "isolated",
|
|
28
|
+
"enum": ["isolated", "shared"],
|
|
29
|
+
"x-priority": "important",
|
|
30
|
+
"x-prompt": {
|
|
31
|
+
"message": "How would you like to map integrations to your tRPC procedures?",
|
|
32
|
+
"type": "list",
|
|
33
|
+
"items": [
|
|
34
|
+
{
|
|
35
|
+
"value": "isolated",
|
|
36
|
+
"label": "isolated (one integration per procedure)"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"value": "shared",
|
|
40
|
+
"label": "shared (single default integration with optional overrides)"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"default": "isolated"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
24
46
|
"auth": {
|
|
25
47
|
"type": "string",
|
|
26
48
|
"description": "The method used to authenticate with your API. Choose between IAM (default), Cognito or None.",
|
|
@@ -419,8 +419,7 @@ export default TestApiClientProvider;
|
|
|
419
419
|
|
|
420
420
|
exports[`trpc react generator > should handle IAM auth option > useSigV4.tsx 1`] = `
|
|
421
421
|
"import { AwsClient } from 'aws4fetch';
|
|
422
|
-
import {
|
|
423
|
-
import { fromCognitoIdentityPool } from '@aws-sdk/credential-provider-cognito-identity';
|
|
422
|
+
import { fromCognitoIdentityPool } from '@aws-sdk/credential-providers';
|
|
424
423
|
import { useCallback, useRef } from 'react';
|
|
425
424
|
import { useAuth } from 'react-oidc-context';
|
|
426
425
|
import { useRuntimeConfig } from './useRuntimeConfig';
|
|
@@ -484,7 +483,7 @@ export const useSigV4 = (): SigV4Client => {
|
|
|
484
483
|
}
|
|
485
484
|
|
|
486
485
|
const credentialsFromCognitoIdentityPool = fromCognitoIdentityPool({
|
|
487
|
-
|
|
486
|
+
clientConfig: { region: cognitoProps.region },
|
|
488
487
|
identityPoolId: cognitoProps.identityPoolId,
|
|
489
488
|
logins: {
|
|
490
489
|
[\`cognito-idp.\${cognitoProps.region}.amazonaws.com/\${cognitoProps.userPoolId}\`]:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/react/generator.ts"],"names":[],"mappings":";;;AAoCA,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/trpc/react/generator.ts"],"names":[],"mappings":";;;AAoCA,wCAuKC;;AA3MD;;;GAGG;AACH,uCAOoB;AAGpB,+EAAyF;AACzF,qDA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AA,yCAA+B,EAAC,IAAI,EAAE,CAAC,iCAAyB,CAAC,CAAC,CAAC;QAEzE,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;QACjC,OAAO,GAAG,EAAE;YACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,CAAC;IACJ,CAAC;CAAA;AACD,kBAAe,cAAc,CAAC"}
|
|
@@ -640,7 +640,7 @@ exports[`ts#mcp-server generator > should match snapshot for generated files > u
|
|
|
640
640
|
"snapshot-server": "./src/snapshot-server/stdio.js"
|
|
641
641
|
},
|
|
642
642
|
"dependencies": {
|
|
643
|
-
"@modelcontextprotocol/sdk": "1.27.
|
|
643
|
+
"@modelcontextprotocol/sdk": "1.27.1",
|
|
644
644
|
"express": "5.2.1",
|
|
645
645
|
"zod": "4.3.6"
|
|
646
646
|
},
|
|
@@ -1043,14 +1043,14 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1043
1043
|
"{
|
|
1044
1044
|
"name": "@proj/source",
|
|
1045
1045
|
"dependencies": {
|
|
1046
|
-
"@cloudscape-design/board-components": "3.0.
|
|
1047
|
-
"@cloudscape-design/components": "3.0.
|
|
1048
|
-
"@cloudscape-design/global-styles": "1.0.
|
|
1049
|
-
"aws-cdk-lib": "2.
|
|
1050
|
-
"constructs": "10.5.
|
|
1046
|
+
"@cloudscape-design/board-components": "3.0.150",
|
|
1047
|
+
"@cloudscape-design/components": "3.0.1217",
|
|
1048
|
+
"@cloudscape-design/global-styles": "1.0.51",
|
|
1049
|
+
"aws-cdk-lib": "2.241.0",
|
|
1050
|
+
"constructs": "10.5.1",
|
|
1051
1051
|
"react": "19.2.4",
|
|
1052
1052
|
"react-dom": "19.2.4",
|
|
1053
|
-
"tailwindcss": "4.1
|
|
1053
|
+
"tailwindcss": "4.2.1"
|
|
1054
1054
|
},
|
|
1055
1055
|
"devDependencies": {
|
|
1056
1056
|
"@eslint/js": "^9.8.0",
|
|
@@ -1065,10 +1065,10 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1065
1065
|
"@swc/cli": "~0.8.0",
|
|
1066
1066
|
"@swc/core": "~1.15.5",
|
|
1067
1067
|
"@swc/helpers": "~0.5.18",
|
|
1068
|
-
"@tailwindcss/vite": "4.1
|
|
1068
|
+
"@tailwindcss/vite": "4.2.1",
|
|
1069
1069
|
"@testing-library/dom": "10.4.0",
|
|
1070
1070
|
"@testing-library/react": "16.3.0",
|
|
1071
|
-
"@types/node": "22.19.
|
|
1071
|
+
"@types/node": "22.19.13",
|
|
1072
1072
|
"@types/react": "^19.0.0",
|
|
1073
1073
|
"@types/react-dom": "^19.0.0",
|
|
1074
1074
|
"@vitejs/plugin-react": "^4.2.0",
|
|
@@ -2470,15 +2470,15 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2470
2470
|
"{
|
|
2471
2471
|
"name": "@proj/source",
|
|
2472
2472
|
"dependencies": {
|
|
2473
|
-
"@cloudscape-design/board-components": "3.0.
|
|
2474
|
-
"@cloudscape-design/components": "3.0.
|
|
2475
|
-
"@cloudscape-design/global-styles": "1.0.
|
|
2476
|
-
"@tanstack/react-router": "1.
|
|
2477
|
-
"aws-cdk-lib": "2.
|
|
2478
|
-
"constructs": "10.5.
|
|
2473
|
+
"@cloudscape-design/board-components": "3.0.150",
|
|
2474
|
+
"@cloudscape-design/components": "3.0.1217",
|
|
2475
|
+
"@cloudscape-design/global-styles": "1.0.51",
|
|
2476
|
+
"@tanstack/react-router": "1.163.3",
|
|
2477
|
+
"aws-cdk-lib": "2.241.0",
|
|
2478
|
+
"constructs": "10.5.1",
|
|
2479
2479
|
"react": "19.2.4",
|
|
2480
2480
|
"react-dom": "19.2.4",
|
|
2481
|
-
"tailwindcss": "4.1
|
|
2481
|
+
"tailwindcss": "4.2.1"
|
|
2482
2482
|
},
|
|
2483
2483
|
"devDependencies": {
|
|
2484
2484
|
"@eslint/js": "^9.8.0",
|
|
@@ -2493,14 +2493,14 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2493
2493
|
"@swc/cli": "~0.8.0",
|
|
2494
2494
|
"@swc/core": "~1.15.5",
|
|
2495
2495
|
"@swc/helpers": "~0.5.18",
|
|
2496
|
-
"@tailwindcss/vite": "4.1
|
|
2497
|
-
"@tanstack/router-generator": "1.
|
|
2498
|
-
"@tanstack/router-plugin": "1.
|
|
2499
|
-
"@tanstack/router-utils": "1.
|
|
2500
|
-
"@tanstack/virtual-file-routes": "1.
|
|
2496
|
+
"@tailwindcss/vite": "4.2.1",
|
|
2497
|
+
"@tanstack/router-generator": "1.164.0",
|
|
2498
|
+
"@tanstack/router-plugin": "1.164.0",
|
|
2499
|
+
"@tanstack/router-utils": "1.161.4",
|
|
2500
|
+
"@tanstack/virtual-file-routes": "1.161.4",
|
|
2501
2501
|
"@testing-library/dom": "10.4.0",
|
|
2502
2502
|
"@testing-library/react": "16.3.0",
|
|
2503
|
-
"@types/node": "22.19.
|
|
2503
|
+
"@types/node": "22.19.13",
|
|
2504
2504
|
"@types/react": "^19.0.0",
|
|
2505
2505
|
"@types/react-dom": "^19.0.0",
|
|
2506
2506
|
"@vitejs/plugin-react": "^4.2.0",
|
|
@@ -4553,15 +4553,15 @@ root &&
|
|
|
4553
4553
|
|
|
4554
4554
|
exports[`react-website generator > should handle npm scope prefix correctly > scoped-dependencies 1`] = `
|
|
4555
4555
|
{
|
|
4556
|
-
"@cloudscape-design/board-components": "3.0.
|
|
4557
|
-
"@cloudscape-design/components": "3.0.
|
|
4558
|
-
"@cloudscape-design/global-styles": "1.0.
|
|
4559
|
-
"@tanstack/react-router": "1.
|
|
4560
|
-
"aws-cdk-lib": "2.
|
|
4561
|
-
"constructs": "10.5.
|
|
4556
|
+
"@cloudscape-design/board-components": "3.0.150",
|
|
4557
|
+
"@cloudscape-design/components": "3.0.1217",
|
|
4558
|
+
"@cloudscape-design/global-styles": "1.0.51",
|
|
4559
|
+
"@tanstack/react-router": "1.163.3",
|
|
4560
|
+
"aws-cdk-lib": "2.241.0",
|
|
4561
|
+
"constructs": "10.5.1",
|
|
4562
4562
|
"react": "19.2.4",
|
|
4563
4563
|
"react-dom": "19.2.4",
|
|
4564
|
-
"tailwindcss": "4.1
|
|
4564
|
+
"tailwindcss": "4.2.1",
|
|
4565
4565
|
}
|
|
4566
4566
|
`;
|
|
4567
4567
|
|
|
@@ -937,11 +937,12 @@ export const appRouter = router({
|
|
|
937
937
|
|
|
938
938
|
for await (const event of agent.stream(opts.input.message)) {
|
|
939
939
|
if (
|
|
940
|
-
event.type === '
|
|
941
|
-
event.
|
|
940
|
+
event.type === 'modelStreamUpdateEvent' &&
|
|
941
|
+
event.event.type === 'modelContentBlockDeltaEvent' &&
|
|
942
|
+
event.event.delta.type === 'textDelta'
|
|
942
943
|
) {
|
|
943
|
-
yield event.delta.text;
|
|
944
|
-
} else if (event.type === '
|
|
944
|
+
yield event.event.delta.text;
|
|
945
|
+
} else if (event.type === 'modelMessageEvent') {
|
|
945
946
|
yield '\\n';
|
|
946
947
|
}
|
|
947
948
|
}
|
|
@@ -19,11 +19,12 @@ export const appRouter = router({
|
|
|
19
19
|
|
|
20
20
|
for await (const event of agent.stream(opts.input.message)) {
|
|
21
21
|
if (
|
|
22
|
-
event.type === '
|
|
23
|
-
event.
|
|
22
|
+
event.type === 'modelStreamUpdateEvent' &&
|
|
23
|
+
event.event.type === 'modelContentBlockDeltaEvent' &&
|
|
24
|
+
event.event.delta.type === 'textDelta'
|
|
24
25
|
) {
|
|
25
|
-
yield event.delta.text;
|
|
26
|
-
} else if (event.type === '
|
|
26
|
+
yield event.event.delta.text;
|
|
27
|
+
} else if (event.type === 'modelMessageEvent') {
|
|
27
28
|
yield '\n';
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -6,6 +6,7 @@ import { Tree } from '@nx/devkit';
|
|
|
6
6
|
import { IacProvider } from '../iac';
|
|
7
7
|
interface BackendOptions {
|
|
8
8
|
type: 'trpc' | 'fastapi' | 'smithy';
|
|
9
|
+
integrationPattern: 'isolated' | 'shared';
|
|
9
10
|
}
|
|
10
11
|
export interface TrpcBackendOptions extends BackendOptions {
|
|
11
12
|
type: 'trpc';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-constructs.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/utils/api-constructs/api-constructs.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAOoB;AACpB,gFAIwC;AACxC,gCAAuC;
|
|
1
|
+
{"version":3,"file":"api-constructs.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/utils/api-constructs/api-constructs.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAOoB;AACpB,gFAIwC;AACxC,gCAAuC;AAkChC,MAAM,kBAAkB,GAAG,CAChC,IAAU,EACV,OAAqE,EACrE,EAAE;IACF,IAAI,OAAO,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;QAClC,0BAA0B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;SAAM,IAAI,OAAO,CAAC,WAAW,KAAK,WAAW,EAAE,CAAC;QAC/C,6BAA6B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,IAAA,mBAAU,EACR,IAAI,EACJ,IAAA,0BAAiB,EACf,0CAAY,EACZ,OAAO,CAAC,WAAW,KAAK,KAAK;QAC3B,CAAC,CAAC,mDAAqB;QACvB,CAAC,CAAC,kDAAoB,EACxB,cAAc,CACf,EACD,CAAC,MAA4B,EAAE,EAAE;;QAC/B,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC1B,MAAM,CAAC,OAAO,CAAC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iB,EAAE,0BAAiB,CAAC,YAAY;KAClD,CACF,CAAC;IAEF,oCAAoC;IACpC,IAAA,mBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EACf,0CAAY,EACZ,mDAAqB,EACrB,KAAK,EACL,KAAK,EACL,MAAM,EACN,UAAU,CACX,EACD,KAAK,OAAO,CAAC,gBAAgB,KAAK,CACnC,CAAC;IACF,IAAA,mBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EACf,0CAAY,EACZ,mDAAqB,EACrB,KAAK,EACL,KAAK,EACL,UAAU,CACX,EACD,iBAAiB,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,6BAA6B,GAAG,CACpC,IAAU,EACV,OAAsC,EACtC,EAAE;IACF,iCAAiC;IACjC,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EACf,SAAS,EACT,OAAO,EACP,WAAW,EACX,MAAM,EACN,KAAK,EACL,OAAO,CAAC,aAAa,CACtB,EACD,IAAA,0BAAiB,EAAC,0CAAY,EAAE,kDAAoB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAC3E,EAAE,EACF;QACE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY;KAClD,CACF,CAAC;IAEF,yCAAyC;IACzC,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EACf,SAAS,EACT,OAAO,EACP,WAAW,EACX,KAAK,EACL,MAAM,EACN,OAAO,CAAC,aAAa,CACtB,EACD,IAAA,0BAAiB,EAAC,0CAAY,EAAE,kDAAoB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,EAC3E,OAAO,EACP;QACE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY;KAClD,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -37,6 +37,7 @@ import { IUserPool, IUserPoolClient } from 'aws-cdk-lib/aws-cognito';
|
|
|
37
37
|
import { Grant, IGrantable } from 'aws-cdk-lib/aws-iam';
|
|
38
38
|
<%_ } _%>
|
|
39
39
|
import {
|
|
40
|
+
ApiIntegrations,
|
|
40
41
|
HttpApiIntegration,
|
|
41
42
|
IntegrationBuilder,
|
|
42
43
|
} from '../../core/api/utils.js';
|
|
@@ -60,7 +61,7 @@ import {
|
|
|
60
61
|
* @template TIntegrations - Map of operation names to their integrations
|
|
61
62
|
*/
|
|
62
63
|
export interface <%= apiNameClassName %>Props<
|
|
63
|
-
TIntegrations extends
|
|
64
|
+
TIntegrations extends ApiIntegrations<Operations, HttpApiIntegration>,
|
|
64
65
|
> {
|
|
65
66
|
/**
|
|
66
67
|
* Map of operation names to their API Gateway integrations
|
|
@@ -83,23 +84,29 @@ export interface <%= apiNameClassName %>Props<
|
|
|
83
84
|
* @template TIntegrations - Map of operation names to their integrations
|
|
84
85
|
*/
|
|
85
86
|
export class <%= apiNameClassName %><
|
|
86
|
-
TIntegrations extends
|
|
87
|
+
TIntegrations extends ApiIntegrations<Operations, HttpApiIntegration>,
|
|
87
88
|
> extends HttpApi<Operations, TIntegrations> {
|
|
88
89
|
/**
|
|
90
|
+
<%_ if (backend.integrationPattern === 'shared') { _%>
|
|
91
|
+
* Creates default integrations for all operations using a single shared
|
|
92
|
+
* router lambda function.
|
|
93
|
+
<%_ } else { _%>
|
|
89
94
|
* Creates default integrations for all operations, which implement each operation as
|
|
90
95
|
* its own individual lambda function.
|
|
96
|
+
<%_ } _%>
|
|
91
97
|
*
|
|
92
98
|
* @param scope - The CDK construct scope
|
|
93
99
|
* @returns An IntegrationBuilder with default lambda integrations
|
|
94
|
-
|
|
100
|
+
*/
|
|
95
101
|
public static defaultIntegrations = (scope: Construct) => {
|
|
96
102
|
return IntegrationBuilder.http({
|
|
103
|
+
pattern: '<%= backend.integrationPattern %>',
|
|
97
104
|
<%_ if (backend.type === 'trpc') { _%>
|
|
98
105
|
operations: routerToOperations(appRouter),
|
|
99
106
|
<%_ } else { _%>
|
|
100
107
|
operations: OPERATION_DETAILS,
|
|
101
108
|
<%_ } _%>
|
|
102
|
-
defaultIntegrationOptions: {
|
|
109
|
+
defaultIntegrationOptions: <FunctionProps>{
|
|
103
110
|
<%_ if (['trpc', 'smithy'].includes(backend.type)) { _%>
|
|
104
111
|
runtime: Runtime.NODEJS_LATEST,
|
|
105
112
|
handler: 'index.handler',
|
|
@@ -136,8 +143,10 @@ export class <%= apiNameClassName %><
|
|
|
136
143
|
AWS_LAMBDA_EXEC_WRAPPER: '/opt/bootstrap',
|
|
137
144
|
<%_ } _%>
|
|
138
145
|
},
|
|
139
|
-
}
|
|
146
|
+
},
|
|
140
147
|
buildDefaultIntegration: (op, props: FunctionProps) => {
|
|
148
|
+
<%_ const lambdaTarget = backend.type === 'fastapi' ? 'handler.currentVersion' : 'handler'; _%>
|
|
149
|
+
<%_ const integrationOptions = backend.integrationPattern === 'shared' ? ', { scopePermissionToRoute: false }' : ''; _%>
|
|
141
150
|
const handler = new Function(scope, `<%= apiNameClassName %>${op}Handler`, props);
|
|
142
151
|
<%_ if (backend.type === 'fastapi') { _%>
|
|
143
152
|
const stack = Stack.of(scope);
|
|
@@ -151,11 +160,10 @@ export class <%= apiNameClassName %><
|
|
|
151
160
|
<%_ } _%>
|
|
152
161
|
return {
|
|
153
162
|
handler,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
<%_ } _%>
|
|
163
|
+
integration: new HttpLambdaIntegration(
|
|
164
|
+
`<%= apiNameClassName %><%_ if (backend.integrationPattern === 'shared') { _%>Router<%_ } _%>${op}Integration`,
|
|
165
|
+
<%- lambdaTarget %><%- integrationOptions %>,
|
|
166
|
+
),
|
|
159
167
|
};
|
|
160
168
|
},
|
|
161
169
|
});
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
import { IUserPool } from 'aws-cdk-lib/aws-cognito';
|
|
39
39
|
<%_ } _%>
|
|
40
40
|
import {
|
|
41
|
+
ApiIntegrations,
|
|
41
42
|
IntegrationBuilder,
|
|
42
43
|
RestApiIntegration,
|
|
43
44
|
} from '../../core/api/utils.js';
|
|
@@ -61,7 +62,7 @@ import {
|
|
|
61
62
|
* @template TIntegrations - Map of operation names to their integrations
|
|
62
63
|
*/
|
|
63
64
|
export interface <%= apiNameClassName %>Props<
|
|
64
|
-
TIntegrations extends
|
|
65
|
+
TIntegrations extends ApiIntegrations<Operations, RestApiIntegration>,
|
|
65
66
|
> {
|
|
66
67
|
/**
|
|
67
68
|
* Map of operation names to their API Gateway integrations
|
|
@@ -83,23 +84,29 @@ export interface <%= apiNameClassName %>Props<
|
|
|
83
84
|
* @template TIntegrations - Map of operation names to their integrations
|
|
84
85
|
*/
|
|
85
86
|
export class <%= apiNameClassName %><
|
|
86
|
-
TIntegrations extends
|
|
87
|
+
TIntegrations extends ApiIntegrations<Operations, RestApiIntegration>,
|
|
87
88
|
> extends RestApi<Operations, TIntegrations> {
|
|
88
89
|
/**
|
|
90
|
+
<%_ if (backend.integrationPattern === 'shared') { _%>
|
|
91
|
+
* Creates default integrations for all operations using a single shared
|
|
92
|
+
* router lambda function.
|
|
93
|
+
<%_ } else { _%>
|
|
89
94
|
* Creates default integrations for all operations, which implement each operation as
|
|
90
95
|
* its own individual lambda function.
|
|
96
|
+
<%_ } _%>
|
|
91
97
|
*
|
|
92
98
|
* @param scope - The CDK construct scope
|
|
93
99
|
* @returns An IntegrationBuilder with default lambda integrations
|
|
94
|
-
|
|
100
|
+
*/
|
|
95
101
|
public static defaultIntegrations = (scope: Construct) => {
|
|
96
102
|
return IntegrationBuilder.rest({
|
|
103
|
+
pattern: '<%= backend.integrationPattern %>',
|
|
97
104
|
<%_ if (backend.type === 'trpc') { _%>
|
|
98
105
|
operations: routerToOperations(appRouter),
|
|
99
106
|
<%_ } else { _%>
|
|
100
107
|
operations: OPERATION_DETAILS,
|
|
101
108
|
<%_ } _%>
|
|
102
|
-
defaultIntegrationOptions: {
|
|
109
|
+
defaultIntegrationOptions: <FunctionProps>{
|
|
103
110
|
<%_ if (['trpc', 'smithy'].includes(backend.type)) { _%>
|
|
104
111
|
runtime: Runtime.NODEJS_LATEST,
|
|
105
112
|
handler: 'index.handler',
|
|
@@ -136,8 +143,23 @@ export class <%= apiNameClassName %><
|
|
|
136
143
|
AWS_LAMBDA_EXEC_WRAPPER: '/opt/bootstrap',
|
|
137
144
|
<%_ } _%>
|
|
138
145
|
},
|
|
139
|
-
}
|
|
146
|
+
},
|
|
140
147
|
buildDefaultIntegration: (op, props: FunctionProps) => {
|
|
148
|
+
<%_ const lambdaTarget = backend.type === 'fastapi' ? 'handler.currentVersion' : 'handler'; _%>
|
|
149
|
+
<%_
|
|
150
|
+
const integrationOptionEntries = [];
|
|
151
|
+
if (backend.integrationPattern === 'shared') {
|
|
152
|
+
integrationOptionEntries.push('scopePermissionToMethod: false');
|
|
153
|
+
}
|
|
154
|
+
if (['fastapi', 'trpc'].includes(backend.type)) {
|
|
155
|
+
integrationOptionEntries.push(
|
|
156
|
+
'responseTransferMode: ResponseTransferMode.STREAM',
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
const integrationOptions = integrationOptionEntries.length
|
|
160
|
+
? `, { ${integrationOptionEntries.join(', ')} }`
|
|
161
|
+
: '';
|
|
162
|
+
_%>
|
|
141
163
|
const handler = new Function(scope, `<%= apiNameClassName %>${op}Handler`, props);
|
|
142
164
|
<%_ if (backend.type === 'fastapi') { _%>
|
|
143
165
|
const stack = Stack.of(scope);
|
|
@@ -151,17 +173,7 @@ export class <%= apiNameClassName %><
|
|
|
151
173
|
<%_ } _%>
|
|
152
174
|
return {
|
|
153
175
|
handler,
|
|
154
|
-
|
|
155
|
-
integration: new LambdaIntegration(handler.currentVersion, {
|
|
156
|
-
responseTransferMode: ResponseTransferMode.STREAM,
|
|
157
|
-
}),
|
|
158
|
-
<%_ } else if (backend.type === 'trpc') { _%>
|
|
159
|
-
integration: new LambdaIntegration(handler, {
|
|
160
|
-
responseTransferMode: ResponseTransferMode.STREAM,
|
|
161
|
-
}),
|
|
162
|
-
<%_ } else { _%>
|
|
163
|
-
integration: new LambdaIntegration(handler),
|
|
164
|
-
<%_ } _%>
|
|
176
|
+
integration: new LambdaIntegration(<%- lambdaTarget %><%- integrationOptions %>),
|
|
165
177
|
};
|
|
166
178
|
},
|
|
167
179
|
});
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { Construct } from 'constructs';
|
|
2
2
|
import { RuntimeConfig } from '../runtime-config.js';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ApiIntegrations,
|
|
5
|
+
HttpApiIntegration,
|
|
6
|
+
OperationDetails,
|
|
7
|
+
} from './utils.js';
|
|
4
8
|
import { CfnOutput } from 'aws-cdk-lib';
|
|
5
9
|
import {
|
|
6
10
|
HttpApi as _HttpApi,
|
|
@@ -19,7 +23,7 @@ import { suppressRules } from '../checkov.js';
|
|
|
19
23
|
* @template TOperation - String literal type representing operation names
|
|
20
24
|
*/
|
|
21
25
|
export interface HttpApiProps<
|
|
22
|
-
TIntegrations extends
|
|
26
|
+
TIntegrations extends ApiIntegrations<TOperation, HttpApiIntegration>,
|
|
23
27
|
TOperation extends string,
|
|
24
28
|
> extends _HttpApiProps {
|
|
25
29
|
/**
|
|
@@ -49,7 +53,7 @@ export interface HttpApiProps<
|
|
|
49
53
|
*/
|
|
50
54
|
export class HttpApi<
|
|
51
55
|
TOperation extends string,
|
|
52
|
-
TIntegrations extends
|
|
56
|
+
TIntegrations extends ApiIntegrations<TOperation, HttpApiIntegration>,
|
|
53
57
|
> extends Construct {
|
|
54
58
|
/** The underlying CDK HttpApi instance */
|
|
55
59
|
public readonly api: _HttpApi;
|
|
@@ -99,16 +103,32 @@ export class HttpApi<
|
|
|
99
103
|
},
|
|
100
104
|
});
|
|
101
105
|
|
|
106
|
+
// Resolve the integration for a given operation.
|
|
107
|
+
// If the operation has a dedicated integration, use it; otherwise fall back to $router.
|
|
108
|
+
const resolveIntegration = (op: TOperation): HttpApiIntegration => {
|
|
109
|
+
const record = integrations as Record<string, HttpApiIntegration>;
|
|
110
|
+
if (op in record) {
|
|
111
|
+
return record[op];
|
|
112
|
+
}
|
|
113
|
+
if ('$router' in record) {
|
|
114
|
+
return record['$router'];
|
|
115
|
+
}
|
|
116
|
+
throw new Error(
|
|
117
|
+
`No integration found for operation '${op}' and no $router integration available`,
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
102
121
|
// Create API resources and methods for each operation
|
|
103
122
|
(Object.entries(operations) as [TOperation, OperationDetails][]).map(
|
|
104
123
|
([op, details]) => {
|
|
124
|
+
const integration = resolveIntegration(op);
|
|
105
125
|
this.api.addRoutes({
|
|
106
126
|
path: details.path.startsWith('/')
|
|
107
127
|
? details.path
|
|
108
128
|
: `/${details.path}`,
|
|
109
129
|
methods: [details.method as HttpMethod],
|
|
110
|
-
integration:
|
|
111
|
-
...
|
|
130
|
+
integration: integration.integration,
|
|
131
|
+
...integration.options,
|
|
112
132
|
});
|
|
113
133
|
},
|
|
114
134
|
);
|