@aws/nx-plugin-mcp 1.0.0-rc.45 → 1.0.0-rc.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/bin/aws-nx-mcp.js +63 -47
  2. package/docs/get_started/existing-project.mdx +4 -0
  3. package/docs/get_started/quick-start.mdx +1 -1
  4. package/docs/get_started/tutorials/contribute-generator.mdx +1 -1
  5. package/docs/get_started/tutorials/dungeon-game/1.mdx +2 -2
  6. package/docs/get_started/tutorials/dungeon-game/2.mdx +3 -3
  7. package/docs/guides/agentcore-gateway.mdx +1 -1
  8. package/docs/guides/connection/py-agent-dynamodb.mdx +1 -1
  9. package/docs/guides/connection/py-agent-rdb.mdx +1 -1
  10. package/docs/guides/connection/py-fast-api-dynamodb.mdx +1 -1
  11. package/docs/guides/connection/py-fast-api-rdb.mdx +2 -2
  12. package/docs/guides/connection/py-mcp-server-dynamodb.mdx +1 -1
  13. package/docs/guides/connection/py-mcp-server-rdb.mdx +1 -1
  14. package/docs/guides/connection/smithy-dynamodb.mdx +1 -1
  15. package/docs/guides/connection/smithy-rdb.mdx +3 -3
  16. package/docs/guides/connection/trpc-dynamodb.mdx +1 -1
  17. package/docs/guides/connection/ts-agent-a2a.mdx +1 -1
  18. package/docs/guides/connection/ts-agent-dynamodb.mdx +2 -2
  19. package/docs/guides/connection/ts-agent-gateway.mdx +1 -1
  20. package/docs/guides/connection/ts-agent-mcp.mdx +1 -1
  21. package/docs/guides/connection/ts-agent-rdb.mdx +4 -4
  22. package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +2 -2
  23. package/docs/guides/connection/ts-mcp-server-rdb.mdx +2 -2
  24. package/docs/guides/docker-bundling.mdx +2 -2
  25. package/docs/guides/fastapi.mdx +2 -2
  26. package/docs/guides/react-website-auth.mdx +3 -3
  27. package/docs/guides/react-website.mdx +4 -3
  28. package/docs/guides/runtime-config.mdx +1 -1
  29. package/docs/guides/trpc.mdx +4 -3
  30. package/docs/guides/ts-dcr-proxy.mdx +1 -1
  31. package/docs/guides/ts-dynamodb.mdx +2 -1
  32. package/docs/guides/ts-mcp-server.mdx +44 -27
  33. package/docs/guides/ts-nx-plugin.mdx +2 -2
  34. package/docs/guides/ts-rdb.mdx +3 -2
  35. package/docs/guides/ts-smithy-api.mdx +3 -2
  36. package/docs/guides/typescript-infrastructure.mdx +10 -8
  37. package/docs/guides/typescript-project.mdx +133 -26
  38. package/docs/guides/workspace.mdx +6 -1
  39. package/docs/snippets/agent/bedrock-deployment.mdx +4 -4
  40. package/docs/snippets/agent/runtime-arn.mdx +1 -1
  41. package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
  42. package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
  43. package/docs/snippets/connection/rdb-api-infrastructure.mdx +1 -1
  44. package/docs/snippets/dynamodb/deploying-table.mdx +5 -5
  45. package/docs/snippets/lambda-function/deploying-your-function.mdx +2 -2
  46. package/docs/snippets/mcp/bedrock-deployment.mdx +4 -4
  47. package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
  48. package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
  49. package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
  50. package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +1 -1
  51. package/docs/snippets/rdb/cluster-instances.mdx +1 -1
  52. package/docs/snippets/rdb/deletion-protection.mdx +1 -1
  53. package/docs/snippets/rdb/deploying.mdx +1 -1
  54. package/docs/snippets/rdb/encryption-key-rotation.mdx +1 -1
  55. package/docs/snippets/rdb/engine-version.mdx +2 -2
  56. package/docs/snippets/rdb/performance-insights.mdx +1 -1
  57. package/docs/snippets/rdb/rds-proxy.mdx +1 -1
  58. package/docs/snippets/rdb/removal-policy.mdx +2 -2
  59. package/docs/snippets/rdb/serverless-capacity.mdx +1 -1
  60. package/generators.json +9 -9
  61. package/package.json +1 -1
  62. package/src/preset/schema.json +5 -0
@@ -3,12 +3,13 @@ title: TypeScript Projects
3
3
  description: Reference documentation for TypeScript projects
4
4
  generator: ts#project
5
5
  ---
6
- import { FileTree } from '@astrojs/starlight/components';
6
+ import { FileTree, Tabs, TabItem, Steps } from '@astrojs/starlight/components';
7
7
  import RunGenerator from '@components/run-generator.astro';
8
8
  import InstallCommand from '@components/install-command.astro';
9
9
  import GeneratorParameters from '@components/generator-parameters.astro';
10
10
  import NxCommands from '@components/nx-commands.astro';
11
11
  import PackageManagerShortCommand from '@components/package-manager-short-command.astro';
12
+ import CreateNxWorkspaceCommand from '@components/create-nx-workspace-command.astro';
12
13
  import Link from '@components/link.astro';
13
14
 
14
15
  The TypeScript project generator can be used to create a modern [TypeScript](https://www.typescriptlang.org/) library or application configured with best practices such as [ECMAScript Modules (ESM)](https://www.typescriptlang.org/docs/handbook/modules/reference.html), TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html), [Vitest](https://vitest.dev/) for running tests and [Biome](https://biomejs.dev/) for linting and formatting.
@@ -33,6 +34,7 @@ The generator will create the following project structure in the `<directory>/<n
33
34
 
34
35
  - src TypeScript source code
35
36
  - index.ts
37
+ - package.json Project manifest defining the project's package name and dependencies
36
38
  - project.json Project configuration and build targets
37
39
  - tsconfig.json Base TypeScript configuration for this project (extends workspace root tsconfig.base.json)
38
40
  - tsconfig.lib.json TypeScript configuration for your library (your runtime or packaged source)
@@ -41,8 +43,8 @@ The generator will create the following project structure in the `<directory>/<n
41
43
 
42
44
  </FileTree>
43
45
 
44
- :::tip[No package.json Needed]
45
- Notice that no `package.json` file is created for this project! You can find out why [below](#dependencies).
46
+ :::tip[Project package.json]
47
+ The project's `package.json` starts minimal. As you add runtime dependencies they are declared here (shared build/test tooling stays in the workspace root) — you can find out more [below](#dependencies).
46
48
  :::
47
49
 
48
50
  You will also notice some changes to the following files in your workspace root:
@@ -85,13 +87,9 @@ export * from './algorithms/index.js';
85
87
  [TypeScript aliases](https://www.typescriptlang.org/docs/handbook/modules/reference.html#paths) for your project are configured in your workspace `tsconfig.base.json`, which allows you to reference your TypeScript project from other TypeScript projects:
86
88
 
87
89
  ```ts title="packages/my-other-project/src/index.ts"
88
- import { sayHello } from ':my-scope/my-library';
90
+ import { sayHello } from '@my-scope/my-library';
89
91
  ```
90
92
 
91
- :::note[Project Aliases]
92
- Aliases for your TypeScript projects begin with a `:` rather than the traditional `@`, since this avoids the possibility of name conflicts between local packages in your workspace and remote packages in [NPM](https://www.npmjs.com/).
93
- :::
94
-
95
93
  When you add an import statement for a new project in your workspace for the first time, you will likely see an error in your IDE similar to the below:
96
94
 
97
95
  <details>
@@ -106,28 +104,40 @@ File '/path/to/my/workspace/packages/my-library/src/index.ts' is not listed with
106
104
 
107
105
  </details>
108
106
 
109
- This is because a [project reference](https://www.typescriptlang.org/docs/handbook/project-references.html) has not yet been set up.
107
+ This is because a [project reference](https://www.typescriptlang.org/docs/handbook/project-references.html) has not yet been set up, and the imported project has not yet been declared as a workspace dependency in your project's `package.json`.
110
108
 
111
- TypeScript projects are configured with the Nx TypeScript Sync generator out of the box, saving you from needing to manually configure the project reference. Simply run the following command and Nx will add the required configuration:
109
+ Your workspace is configured with sync generators which manage both for you, so you don't need to configure them by hand. Simply run the following command and Nx will add the required configuration:
112
110
 
113
111
  <NxCommands commands={['sync']} />
114
112
 
115
- After this, the error in your IDE should be gone and you are ready to use your library.
113
+ ```bash wrap
114
+ NX The workspace is out of sync
115
+
116
+ [@nx/js:typescript-sync]: Some TypeScript configuration files are missing project references to the projects they depend on, contain stale project references, or have duplicate project references.
117
+ [@aws/nx-plugin:ts#sync]: Local project dependencies are out of sync. The following workspace dependencies will be declared:
118
+ packages/my-other-project/package.json:
119
+ - @my-scope/my-library: workspace:*
120
+
121
+ Syncing the workspace...
122
+ The workspace was synced successfully!
123
+ ```
124
+
125
+ Nx's TypeScript sync generator adds the project reference, and the plugin's `ts#sync` generator declares the imported project in your project's `package.json` (`workspace:*` where the package manager supports the workspace protocol, `*` on npm and yarn classic), so the package manager links the local project on install. After this, the error in your IDE should be gone and you are ready to use your library.
116
126
 
117
127
  :::tip[Build Shortcut]
118
- You can also just build your project and you'll be prompted with a message such as:
128
+ You can also just build your project — the sync generators run first and you'll be prompted to apply any outstanding changes:
119
129
 
120
130
  ```bash wrap
121
- [@nx/js:typescript-sync]: Some TypeScript configuration files are missing project references to the projects they depend on or contain outdated project references.
131
+ NX The workspace is out of sync
122
132
 
123
- This will result in an error in CI.
133
+ ...
124
134
 
125
- ? Would you like to sync the identified changes to get your workspace up to date?
135
+ ? Would you like to sync the identified changes to get your workspace up to date? …
126
136
  Yes, sync the changes and run the tasks
127
137
  No, run the tasks without syncing the changes
128
138
  ```
129
139
 
130
- Select `Yes` to allow Nx to update your project references.
140
+ Select `Yes` to allow Nx to sync your workspace.
131
141
  :::
132
142
 
133
143
  ### Keeping Path Aliases In Sync
@@ -136,13 +146,116 @@ If you add custom `compilerOptions.paths` entries in a project's `tsconfig.json`
136
146
 
137
147
  ### Dependencies
138
148
 
139
- You will notice that your TypeScript project does not have a `package.json` file, which might be unexpected if you are used to traditional TypeScript monorepos.
149
+ Each TypeScript project declares its third-party runtime dependencies in its own `package.json`. Build and test tooling shared across projects is defined in the root `package.json`.
150
+
151
+ To add a runtime dependency to a project, install it into that project:
152
+
153
+ <InstallCommand pkg="some-npm-package" project="@my-scope/my-library" />
154
+
155
+ You can also run your package manager's plain `add`/`install` command from within the project's directory.
156
+
157
+ To add a shared dev tool, install it at the workspace root:
158
+
159
+ <InstallCommand pkg="some-dev-tool" dev />
160
+
161
+ :::note
162
+ Biome's [`noUndeclaredDependencies`](https://biomejs.dev/linter/rules/no-undeclared-dependencies/) lint rule enforces that a project's source only imports packages declared in its own `package.json`. Config files, build scripts and tests are exempt, so shared tooling can stay at the root.
163
+ :::
164
+
165
+ #### Catalogs
166
+
167
+ For package managers which support catalogs ([pnpm](https://pnpm.io/catalogs), [yarn](https://yarnpkg.com/features/catalogs) and [bun](https://bun.com/docs/install/catalogs)), generators record each version in the catalog and reference it with the `catalog:` protocol (eg `"zod": "catalog:"`), so the catalog is the single source of truth for versions regardless of which project declares the dependency. This helps you to follow a [single version policy](https://nx.dev/concepts/decisions/dependency-management#single-version-policy), avoiding type conflicts and multiple copies of packages in deployment bundles.
168
+
169
+ When you add a new dependency yourself, keep it in the catalog too:
170
+
171
+ <Tabs syncKey="package-manager">
172
+ <TabItem label="pnpm">
173
+ The workspace sets [`catalogMode: strict`](https://pnpm.io/settings#catalogmode), so `pnpm add` records the version in the catalog and references it automatically — no extra steps.
174
+
175
+ ```bash
176
+ pnpm add some-npm-package --filter my-library
177
+ ```
178
+ </TabItem>
179
+ <TabItem label="yarn">
180
+ yarn's `catalog:` protocol only *references* an existing catalog entry — it cannot create one — so record the version first.
181
+
182
+ <Steps>
183
+ 1. Add the version under `catalog` in `.yarnrc.yml`:
184
+
185
+ ```yaml title=".yarnrc.yml"
186
+ catalog:
187
+ some-npm-package: ^1.0.0
188
+ ```
189
+
190
+ 2. Reference it from the project:
191
+
192
+ ```bash
193
+ yarn workspace @my-scope/my-library add some-npm-package@catalog:
194
+ ```
195
+ </Steps>
196
+ </TabItem>
197
+ <TabItem label="bun">
198
+ bun's `catalog:` protocol only *references* an existing catalog entry — it cannot create one — so record the version first.
140
199
 
141
- To add a dependency for any TypeScript package in your monorepo, simply add the dependency to the `package.json` in the root of your workspace. You can do this via the command line for your package manager:
200
+ <Steps>
201
+ 1. Add the version under `catalog` in the root `package.json`:
142
202
 
143
- <InstallCommand pkg="some-npm-package" />
203
+ ```json title="package.json"
204
+ {
205
+ "catalog": {
206
+ "some-npm-package": "^1.0.0"
207
+ }
208
+ }
209
+ ```
144
210
 
145
- The dependency is then available for any of the TypeScript projects in your workspace to use.
211
+ 2. Reference it from the project:
212
+
213
+ ```bash
214
+ bun add some-npm-package@catalog: --cwd packages/my-library
215
+ ```
216
+ </Steps>
217
+ </TabItem>
218
+ </Tabs>
219
+
220
+ :::tip[Aligning versions on npm]
221
+ npm has no catalog feature, so versions are declared directly in each `package.json`. To keep them consistent across projects, we recommend [syncpack](https://github.com/JamieMason/syncpack) (`npx syncpack lint`).
222
+ :::
223
+
224
+ ##### Opting out of catalogs
225
+
226
+ Catalogs are enabled by default. To turn them off, create your workspace with `--catalog false`:
227
+
228
+ <CreateNxWorkspaceCommand workspace="my-project" extraArgs="--catalog false" />
229
+
230
+ Or set it in `aws-nx-plugin.config.mts` at any time:
231
+
232
+ ```ts title="aws-nx-plugin.config.mts"
233
+ export default {
234
+ packageManager: {
235
+ catalogs: false,
236
+ },
237
+ } satisfies AwsNxPluginConfig;
238
+ ```
239
+
240
+ With catalogs disabled, generators write dependency versions directly into each project's `package.json`, and keeping versions aligned across projects is your responsibility.
241
+
242
+ #### Declaring all dependencies at the root
243
+
244
+ If you prefer declaring every dependency in the root `package.json` only (no per-project dependency declarations), turn off the lint rule in the workspace `biome.json`:
245
+
246
+ ```json title="biome.json"
247
+ {
248
+ "linter": {
249
+ "rules": {
250
+ "correctness": {
251
+ "noUndeclaredDependencies": "off"
252
+ }
253
+ }
254
+ }
255
+ }
256
+ ```
257
+
258
+ Projects resolve root-installed packages at build time, so everything still builds — you give up per-project manifests as an accurate record of each project's dependencies (which matters if you later publish a project or split the repo).
146
259
 
147
260
  #### Runtime Code
148
261
 
@@ -193,12 +306,6 @@ Note that in the above target, we chose `src/index.ts` as our entrypoint for the
193
306
  If you're building an AWS Lambda function, check out the <Link path="/guides/ts-lambda-function">`ts#lambda-function`</Link> generator as this configures bundling for you, as well as generating infrastructure and adding observability and type-safety.
194
307
  :::
195
308
 
196
- #### Publishing to NPM
197
-
198
- If you are publishing your TypeScript project to NPM, you must create a `package.json` file for it.
199
-
200
- This must declare the dependencies that your project references. Since at build time your project will resolve dependencies installed via the workspace root `package.json`, Biome's `noUndeclaredDependencies` rule will warn you if your project imports a package that isn't listed in its `package.json`.
201
-
202
309
  ### Building
203
310
 
204
311
  Your TypeScript project is configured with a `build` target (defined in `project.json`), which you can run via:
@@ -6,6 +6,7 @@ import { FileTree } from '@astrojs/starlight/components';
6
6
  import Link from '@components/link.astro';
7
7
  import CreateNxWorkspaceCommand from '@components/create-nx-workspace-command.astro';
8
8
  import PackageManagerShortCommand from '@components/package-manager-short-command.astro';
9
+ import InstallCommand from '@components/install-command.astro';
9
10
  import NxCommands from '@components/nx-commands.astro';
10
11
  import GeneratorParameters from '@components/generator-parameters.astro';
11
12
 
@@ -82,7 +83,11 @@ The default monorepo setup uses a [single version policy](https://nx.dev/concept
82
83
 
83
84
  This means that all projects within your monorepo use the same version of dependencies by default, reducing issues related to packages in the same monorepo running into version mismatch issues.
84
85
 
85
- From a Node perspective this means a single lockfile at the root with a single `node_modules` containing all dependencies. If you need to add a new dependency, add it in the root `package.json`.
86
+ From a Node perspective this means a single lockfile at the root, with dependencies installed once and linked into each project. Each Node project declares the runtime dependencies its source imports in its own `package.json`, while shared build/test tooling lives in the root `package.json` `devDependencies`. Add a project's runtime dependency by installing it into that project:
87
+
88
+ <InstallCommand pkg="some-npm-package" project="@my-scope/my-project" />
89
+
90
+ For package managers with catalog support ([pnpm](https://pnpm.io/catalogs), [yarn](https://yarnpkg.com/features/catalogs) and [bun](https://bun.com/docs/install/catalogs)), dependency versions are recorded in the catalog and referenced with the `catalog:` protocol, keeping a single source of truth for versions across every project's `package.json`. For npm workspaces, we recommend [syncpack](https://github.com/JamieMason/syncpack) to align versions declared across multiple `package.json` files.
86
91
 
87
92
  From a Python perspective, this means a single `.venv` in the root of the monorepo with all dependencies installed into it. Each Python project has its own `pyproject.toml`, but the versions of those dependencies are managed by the UV workspace and subsequently written out to the `uv.lock` file in the root.
88
93
 
@@ -15,7 +15,7 @@ A CDK construct is generated for your agent, named based on the `name` you chose
15
15
  You can use this CDK construct in a CDK application:
16
16
 
17
17
  ```ts
18
- import { MyProjectAgent } from ':my-scope/common-constructs';
18
+ import { MyProjectAgent } from '@my-scope/common-constructs';
19
19
 
20
20
  export class ExampleStack extends Stack {
21
21
  constructor(scope: Construct, id: string) {
@@ -69,7 +69,7 @@ By default, your Agent will be secured using IAM authentication, simply deploy i
69
69
  <Infrastructure>
70
70
  <Fragment slot="cdk">
71
71
  ```ts {5}
72
- import { MyProjectAgent } from ':my-scope/common-constructs';
72
+ import { MyProjectAgent } from '@my-scope/common-constructs';
73
73
 
74
74
  export class ExampleStack extends Stack {
75
75
  constructor(scope: Construct, id: string) {
@@ -81,7 +81,7 @@ export class ExampleStack extends Stack {
81
81
  You can grant access to invoke your agent on Bedrock AgentCore Runtime using the `grantInvokeAccess` method, for example:
82
82
 
83
83
  ```ts {8}
84
- import { MyProjectAgent } from ':my-scope/common-constructs';
84
+ import { MyProjectAgent } from '@my-scope/common-constructs';
85
85
 
86
86
  export class ExampleStack extends Stack {
87
87
  constructor(scope: Construct, id: string) {
@@ -131,7 +131,7 @@ When you select `Cognito` authentication, the generator configures the agent to
131
131
  The generated construct accepts an `identity` prop which configures Cognito authentication:
132
132
 
133
133
  ```ts {8}
134
- import { MyProjectAgent, UserIdentity } from ':my-scope/common-constructs';
134
+ import { MyProjectAgent, UserIdentity } from '@my-scope/common-constructs';
135
135
 
136
136
  export class ExampleStack extends Stack {
137
137
  constructor(scope: Construct, id: string) {
@@ -12,7 +12,7 @@ You can obtain the runtime ARN from your infrastructure as follows:
12
12
  <Fragment slot="cdk">
13
13
  ```ts {9}
14
14
  import { CfnOutput } from 'aws-cdk-lib';
15
- import { MyProjectAgent } from ':my-scope/common-constructs';
15
+ import { MyProjectAgent } from '@my-scope/common-constructs';
16
16
 
17
17
  export class ExampleStack extends Stack {
18
18
  constructor(scope: Construct, id: string) {
@@ -8,7 +8,7 @@ If your solution includes a website you can configure its CloudFront distributio
8
8
  You can call the API `restrictCorsTo` method with website constructs, CloudFront distributions, origin strings, or a mix of them.
9
9
 
10
10
  ```ts
11
- import { MyApi, MyWebsite } from ':my-scope/common-constructs';
11
+ import { MyApi, MyWebsite } from '@my-scope/common-constructs';
12
12
 
13
13
  export class ExampleStack extends Stack {
14
14
  constructor(scope: Construct, id: string) {
@@ -11,7 +11,7 @@ To allow Lambda functions to access the DynamoDB table, grant the necessary perm
11
11
  Call `grantReadWriteData` on the table construct. This grants both the DynamoDB and KMS permissions required by the Lambda execution role:
12
12
 
13
13
  ```ts title="packages/infra/src/stacks/application-stack.ts"
14
- import { MyTable } from ':my-scope/common-constructs';
14
+ import { MyTable } from '@my-scope/common-constructs';
15
15
 
16
16
  const table = new MyTable(this, 'Table');
17
17
 
@@ -12,7 +12,7 @@ To allow your API to connect to the database at runtime, the API Lambda function
12
12
  In your application stack, deploy the API into the same VPC as the database, then call `allowDefaultPortFrom` and `grantConnect` to open the network path and grant IAM `rds-db:connect` permission to each Lambda handler:
13
13
 
14
14
  ```ts title="packages/infra/src/stacks/application-stack.ts"
15
- import { MyDatabase } from ':my-scope/common-constructs';
15
+ import { MyDatabase } from '@my-scope/common-constructs';
16
16
 
17
17
  const db = new MyDatabase(this, 'Db', { vpc, ... });
18
18
 
@@ -10,7 +10,7 @@ The DynamoDB generator creates CDK or Terraform infrastructure based on your sel
10
10
  The CDK construct is created in `common/constructs`. Example usage:
11
11
 
12
12
  ```ts title="packages/infra/src/stacks/application-stack.ts"
13
- import { MyTable } from ':my-scope/common-constructs';
13
+ import { MyTable } from '@my-scope/common-constructs';
14
14
 
15
15
  export class ApplicationStack extends Stack {
16
16
  constructor(scope: Construct, id: string, props?: StackProps) {
@@ -62,7 +62,7 @@ Disable it for environments where table deletion is expected, such as short-live
62
62
  <Fragment slot="cdk">
63
63
 
64
64
  ```ts title="packages/infra/src/stacks/application-stack.ts"
65
- import { MyTable } from ':my-scope/common-constructs';
65
+ import { MyTable } from '@my-scope/common-constructs';
66
66
 
67
67
  const table = new MyTable(this, 'Table', {
68
68
  deletionProtection: false,
@@ -89,7 +89,7 @@ The table defaults to on-demand (`PAY_PER_REQUEST`) billing. Switch to provision
89
89
 
90
90
  ```ts title="packages/infra/src/stacks/application-stack.ts"
91
91
  import { BillingMode } from 'aws-cdk-lib/aws-dynamodb';
92
- import { MyTable } from ':my-scope/common-constructs';
92
+ import { MyTable } from '@my-scope/common-constructs';
93
93
 
94
94
  const table = new MyTable(this, 'Table', {
95
95
  billingMode: BillingMode.PROVISIONED,
@@ -119,7 +119,7 @@ module "my_table" {
119
119
  <Fragment slot="cdk">
120
120
 
121
121
  ```ts title="packages/infra/src/stacks/application-stack.ts"
122
- import { MyTable } from ':my-scope/common-constructs';
122
+ import { MyTable } from '@my-scope/common-constructs';
123
123
 
124
124
  const table = new MyTable(this, 'Table', {
125
125
  pointInTimeRecoverySpecification: { pointInTimeRecoveryEnabled: false },
@@ -147,7 +147,7 @@ The KMS key used to encrypt the table has automatic key rotation enabled by defa
147
147
  <Fragment slot="cdk">
148
148
 
149
149
  ```ts title="packages/infra/src/stacks/application-stack.ts"
150
- import { MyTable } from ':my-scope/common-constructs';
150
+ import { MyTable } from '@my-scope/common-constructs';
151
151
 
152
152
  const table = new MyTable(this, 'Table', {
153
153
  enableKeyRotation: false,
@@ -10,7 +10,7 @@ This generator creates CDK or Terraform infrastructure as code based on your sel
10
10
  This generator creates a CDK construct for deploying your function in the `common/constructs` folder. You can use this in a CDK application:
11
11
 
12
12
  ```typescript {1, 6}
13
- import { MyProjectMyFunction } from ':my-scope/common-constructs';
13
+ import { MyProjectMyFunction } from '@my-scope/common-constructs';
14
14
 
15
15
  export class ExampleStack extends Stack {
16
16
  constructor(scope: Construct, id: string) {
@@ -38,7 +38,7 @@ The example below demonstrates the CDK code for invoking your lambda function on
38
38
  ```typescript
39
39
  import { Rule, Schedule } from 'aws-cdk-lib/aws-events';
40
40
  import { LambdaFunction } from 'aws-cdk-lib/aws-events-targets';
41
- import { MyProjectMyFunction } from ':my-scope/common-constructs';
41
+ import { MyProjectMyFunction } from '@my-scope/common-constructs';
42
42
 
43
43
  export class ExampleStack extends Stack {
44
44
  constructor(scope: Construct, id: string) {
@@ -15,7 +15,7 @@ A CDK construct is generated for your MCP Server, named based on the `name` you
15
15
  You can use this CDK construct in a CDK application:
16
16
 
17
17
  ```ts {6}
18
- import { MyProjectMcpServer } from ':my-scope/common-constructs';
18
+ import { MyProjectMcpServer } from '@my-scope/common-constructs';
19
19
 
20
20
  export class ExampleStack extends Stack {
21
21
  constructor(scope: Construct, id: string) {
@@ -64,7 +64,7 @@ By default, your MCP server will be secured using IAM authentication, simply dep
64
64
  <Infrastructure>
65
65
  <Fragment slot="cdk">
66
66
  ```ts {5}
67
- import { MyProjectMcpServer } from ':my-scope/common-constructs';
67
+ import { MyProjectMcpServer } from '@my-scope/common-constructs';
68
68
 
69
69
  export class ExampleStack extends Stack {
70
70
  constructor(scope: Construct, id: string) {
@@ -76,7 +76,7 @@ export class ExampleStack extends Stack {
76
76
  You can grant access to invoke your MCP server on Bedrock AgentCore Runtime using the `grantInvokeAccess` method. For example you may wish for an agent generated with the <Link path="/guides/py-agent">`py#agent`</Link> generator to call your MCP server:
77
77
 
78
78
  ```ts {8}
79
- import { MyProjectAgent, MyProjectMcpServer } from ':my-scope/common-constructs';
79
+ import { MyProjectAgent, MyProjectMcpServer } from '@my-scope/common-constructs';
80
80
 
81
81
  export class ExampleStack extends Stack {
82
82
  constructor(scope: Construct, id: string) {
@@ -126,7 +126,7 @@ When you select `Cognito` authentication, the generator configures the MCP serve
126
126
  The generated construct accepts an `identity` prop which configures Cognito authentication:
127
127
 
128
128
  ```ts {8}
129
- import { MyProjectMcpServer, UserIdentity } from ':my-scope/common-constructs';
129
+ import { MyProjectMcpServer, UserIdentity } from '@my-scope/common-constructs';
130
130
 
131
131
  export class ExampleStack extends Stack {
132
132
  constructor(scope: Construct, id: string) {
@@ -23,9 +23,9 @@ If you used OpenAPI or TypeSpec as your modelling language, or have handlers imp
23
23
 
24
24
  #### Generate a TypeScript Smithy API
25
25
 
26
- Run the <Link path="/guides/ts-smithy-api">`ts#smithy-api` generator</Link> to set up your api project in `packages/api`:
26
+ Run the <Link path="/guides/ts-smithy-api">`ts#api` generator</Link> with `framework` set to `smithy` to set up your api project in `packages/api`:
27
27
 
28
- <RunGenerator generator="ts#smithy-api" noInteractive requiredParameters={{ name: 'api', namespace: 'com.aws', auth: 'IAM' }} />
28
+ <RunGenerator generator="ts#api" noInteractive requiredParameters={{ name: 'api', framework: 'smithy', namespace: 'com.aws', auth: 'iam' }} />
29
29
 
30
30
  You will notice this generates a `model` project, as well as a `backend` project. The `model` project contains your Smithy model, and `backend` contains your server implementation.
31
31
 
@@ -128,12 +128,14 @@ You can consider the `api/backend` project as somewhat equivalent to Type Safe A
128
128
 
129
129
  One of the main differences between Type Safe API and the `ts#smithy-api` generator is that handlers are implemented using the [Smithy Server Generator for TypeScript](https://smithy.io/2.0/languages/typescript/ts-ssdk/index.html), rather than Type Safe API's own generated handler wrappers (found in the `api/generated/typescript/runtime` project).
130
130
 
131
- The shopping list application's lambda handlers rely on the `@aws-sdk/client-dynamodb` package, so let's install that first:
131
+ The shopping list application's lambda handlers rely on the `@aws-sdk/client-dynamodb` package, so let's install that into the `@shopping-list/api` project:
132
132
 
133
- <InstallCommand pkg="@aws-sdk/client-dynamodb" />
133
+ <InstallCommand pkg="@aws-sdk/client-dynamodb" project="@shopping-list/api" />
134
134
 
135
135
  Then, let's copy the `handlers/src/dynamo-client.ts` file from the PDK project to `backend/src/operations` so it's available for our handlers.
136
136
 
137
+ The `ts#smithy-api` generator scaffolds an example `Echo` operation. Since we removed this from our model, delete the corresponding handler in `backend/src/operations/echo.ts`. We'll register our migrated operations in `service.ts` further below.
138
+
137
139
  To migrate the handlers, you can follow these general steps:
138
140
 
139
141
  <Steps>
@@ -583,7 +585,7 @@ Additionally, update `packages/api/backend/project.json` and update `metadata.ap
583
585
  "generator": "ts#smithy-api",
584
586
  - "apiName": "api",
585
587
  + "apiName": "my-api",
586
- "auth": "IAM",
588
+ "auth": "iam",
587
589
  "modelProject": "@shopping-list/api-model",
588
590
  "ports": [3001]
589
591
  },
@@ -11,21 +11,21 @@ import InstallCommand from '@components/install-command.astro';
11
11
 
12
12
  The `CloudscapeReactTsWebsiteProject` used in the shopping list application configured a React website with CloudScape and Cognito authentication built in.
13
13
 
14
- This project type leveraged [`create-react-app`](https://github.com/facebook/create-react-app), which is now deprecated. For migrating the website in this guide, we will use the <Link path="/guides/react-website">`ts#react-website` generator</Link>, which uses more modern and supported technologies, namely [Vite](https://vite.dev/).
14
+ This project type leveraged [`create-react-app`](https://github.com/facebook/create-react-app), which is now deprecated. For migrating the website in this guide, we will use the <Link path="/guides/react-website">`ts#website` generator</Link>, which uses more modern and supported technologies, namely [Vite](https://vite.dev/).
15
15
 
16
16
  As part of the migration, we will also move from PDK's configured React Router to [TanStack Router](https://tanstack.com/router), which adds additional type-safety to website routing.
17
17
 
18
18
  #### Generate a React Website
19
19
 
20
- Run the <Link path="/guides/react-website">`ts#react-website` generator</Link> to set up your website project in `packages/website`:
20
+ Run the <Link path="/guides/react-website">`ts#website` generator</Link> with `framework` set to `react` to set up your website project in `packages/website`. Since the shopping list application is built with CloudScape components, we also set `ux` to `cloudscape` (the default is `shadcn`):
21
21
 
22
- <RunGenerator generator="ts#react-website" noInteractive requiredParameters={{ name: 'website' }} />
22
+ <RunGenerator generator="ts#website" noInteractive requiredParameters={{ name: 'website', framework: 'react', ux: 'cloudscape' }} />
23
23
 
24
24
  #### Add Cognito Authentication
25
25
 
26
- The React website generator above doesn't bundle cognito authentication by default like `CloudscapeReactTsWebsiteProject`, instead it's added explicitly via the <Link path="/guides/react-website-auth">`ts#react-website#auth` generator</Link>.
26
+ The React website generator above doesn't bundle cognito authentication by default like `CloudscapeReactTsWebsiteProject`, instead it's added explicitly via the <Link path="/guides/react-website-auth">`ts#website#auth` generator</Link>.
27
27
 
28
- <RunGenerator generator="ts#react-website#auth" noInteractive requiredParameters={{ project: 'website', cognitoDomain: 'shopping-list' }} />
28
+ <RunGenerator generator="ts#website#auth" noInteractive requiredParameters={{ project: 'website', cognitoDomain: 'shopping-list' }} />
29
29
 
30
30
  This adds React components which manage the appropriate redirects to ensure users log in using the Cognito hosted UI. This also adds a CDK construct to deploy the Cognito resources in `packages/common/constructs`, called `UserIdentity`.
31
31
 
@@ -57,9 +57,26 @@ This generates the necessary client providers and build targets for your website
57
57
 
58
58
  #### Add AWS Northstar Dependency
59
59
 
60
- The `CloudscapeReactTsWebsiteProject` automatically included a dependency on `@aws-northstar/ui` which is used in our shopping list application, so we add it here:
60
+ The `CloudscapeReactTsWebsiteProject` automatically included a dependency on `@aws-northstar/ui` which is used in our shopping list application, so we add it to the `@shopping-list/website` project:
61
61
 
62
- <InstallCommand pkg="@aws-northstar/ui" />
62
+ <InstallCommand pkg="@aws-northstar/ui" project="@shopping-list/website" />
63
+
64
+ `@aws-northstar/ui` bundles a code editor component which depends on `ace-builds`, using a webpack-specific import that Vite cannot resolve. Since our shopping list application doesn't use this component, we exclude it from the bundle by adding it to the `external` configuration within the existing `build` options in `packages/website/vite.config.mts`:
65
+
66
+ ```diff lang="ts"
67
+ // packages/website/vite.config.mts
68
+ build: {
69
+ outDir: '../../dist/packages/website/bundle',
70
+ emptyOutDir: true,
71
+ reportCompressedSize: true,
72
+ commonjsOptions: {
73
+ transformMixedEsModules: true,
74
+ },
75
+ + rollupOptions: {
76
+ + external: ['ace-builds/webpack-resolver'],
77
+ + },
78
+ },
79
+ ```
63
80
 
64
81
  #### Move the Components and Pages
65
82
 
@@ -79,12 +96,14 @@ Note that you'll now have some build errors visible in your IDE, we'll need to m
79
96
 
80
97
  #### Migrate from React Router to TanStack Router
81
98
 
82
- Since we're using [file-based routing](https://tanstack.com/router/latest/docs/framework/react/routing/file-based-routing), we can use the website local development server to manage automatically generating route configuration. Let's start the local website server:
99
+ Since we're using [file-based routing](https://tanstack.com/router/latest/docs/framework/react/routing/file-based-routing), we can use the website local development server to manage automatically generating route configuration.
100
+
101
+ Let's start the local website server:
83
102
 
84
- <NxCommands commands={["serve-local website"]} />
103
+ <NxCommands commands={["dev website"]} />
85
104
 
86
105
  :::tip
87
- We're using the `serve-local` target here, which also starts local servers for any APIs which have been connected with `connection`, and hot-reloads if your website, model, or backend changes! This allows us to test our API and website locally before we've even written any CDK code.
106
+ We're using the `dev` target here, which also starts local servers for any APIs which have been connected with `connection`, and hot-reloads if your website, model, or backend changes! This allows us to test our API and website locally before we've even written any CDK code.
88
107
  :::
89
108
 
90
109
  You'll see some errors, but the local website server should start on port `4200`, as well as the local Smithy API server on port `3001`.
@@ -46,7 +46,7 @@ Since the Nx Plugin for AWS uses [Checkov](https://www.checkov.io/) for security
46
46
 
47
47
  ```diff lang="ts"
48
48
  // constructs/database.ts
49
- +import { suppressRules } from ':shopping-list/common-constructs';
49
+ +import { suppressRules } from '@shopping-list/common-constructs';
50
50
  ...
51
51
  +suppressRules(
52
52
  + this.shoppingListTable,
@@ -69,7 +69,7 @@ The `UserIdentity` construct can generally be swapped out without changes by adj
69
69
 
70
70
  ```diff lang="ts"
71
71
  -import { UserIdentity } from "@aws/pdk/identity";
72
- +import { UserIdentity } from ':shopping-list/common-constructs';
72
+ +import { UserIdentity } from '@shopping-list/common-constructs';
73
73
  ...
74
74
  const userIdentity = new UserIdentity(this, `${id}UserIdentity`);
75
75
  ```
@@ -93,7 +93,7 @@ Follow the below steps:
93
93
  ```diff lang="ts"
94
94
  // stacks/application-stack.ts
95
95
  -import { MyApi } from "../constructs/apis/myapi";
96
- +import { Api } from ':shopping-list/common-constructs';
96
+ +import { Api } from '@shopping-list/common-constructs';
97
97
  ...
98
98
  -const myapi = new MyApi(this, "MyApi", {
99
99
  - databaseConstruct,
@@ -139,7 +139,7 @@ Finally, we add the `Website` construct from `packages/common/constructs/src/app
139
139
 
140
140
  ```diff lang="ts"
141
141
  -import { Website } from "../constructs/websites/website";
142
- +import { Website } from ':shopping-list/common-constructs';
142
+ +import { Website } from '@shopping-list/common-constructs';
143
143
  ...
144
144
  -new Website(this, "Website", {
145
145
  - userIdentity,
@@ -26,7 +26,7 @@ For Python, the [python-fastapi](https://openapi-generator.tech/docs/generators/
26
26
 
27
27
  ##### Client
28
28
 
29
- For TypeScript clients, you can use the <Link path="/guides/react-website">`ts#react-website` generator</Link> and <Link path="/guides/connection">`connection` generator</Link> with an example `ts#smithy-api` to see how clients are generated and integrated with a website. This configures build targets which generate clients by invoking our `open-api#ts-client` or `open-api#ts-hooks` generators. You can use these generators yourself by pointing them at your OpenAPI Specification.
29
+ For TypeScript clients, you can use the <Link path="/guides/react-website">`ts#website` generator</Link> and <Link path="/guides/connection">`connection` generator</Link> with an example `ts#api` (with `framework` set to `smithy`) to see how clients are generated and integrated with a website. This configures build targets which generate clients by invoking our `open-api#ts-client` or `open-api#ts-hooks` generators. You can use these generators yourself by pointing them at your OpenAPI Specification.
30
30
 
31
31
  For other languages, you can also see if any of the generators from [OpenAPI Generator](https://openapi-generator.tech/docs/generators#client-generators) fit your needs.
32
32
 
@@ -9,7 +9,7 @@ Configure the writer and reader instances for your Aurora cluster.
9
9
  <Fragment slot="cdk">
10
10
 
11
11
  ```ts title="packages/infra/src/stacks/application-stack.ts"
12
- import { MyDatabase } from ':my-scope/common-constructs';
12
+ import { MyDatabase } from '@my-scope/common-constructs';
13
13
 
14
14
  const db = new MyDatabase(this, 'Db', {
15
15
  ...
@@ -13,7 +13,7 @@ You can disable deletion protection for environments where database deletion is
13
13
  <Fragment slot="cdk">
14
14
 
15
15
  ```ts title="packages/infra/src/stacks/application-stack.ts"
16
- import { MyDatabase } from ':my-scope/common-constructs';
16
+ import { MyDatabase } from '@my-scope/common-constructs';
17
17
 
18
18
  const db = new MyDatabase(this, 'Db', {
19
19
  ...
@@ -12,7 +12,7 @@ The relational database generator creates CDK or Terraform infrastructure based
12
12
  The CDK construct is created in `common/constructs`. Example usage:
13
13
 
14
14
  ```ts title="packages/infra/src/stacks/application-stack.ts"
15
- import { MyDatabase } from ':my-scope/common-constructs';
15
+ import { MyDatabase } from '@my-scope/common-constructs';
16
16
 
17
17
  export class ApplicationStack extends Stack {
18
18
  constructor(scope: Construct, id: string, props?: StackProps) {
@@ -9,7 +9,7 @@ The KMS key used to encrypt the Aurora cluster and its credentials secret has au
9
9
  <Fragment slot="cdk">
10
10
 
11
11
  ```ts title="packages/infra/src/stacks/application-stack.ts"
12
- import { MyDatabase } from ':my-scope/common-constructs';
12
+ import { MyDatabase } from '@my-scope/common-constructs';
13
13
 
14
14
  const db = new MyDatabase(this, 'Db', {
15
15
  ...