@aws/nx-plugin-mcp 1.0.0-rc.51 → 1.0.0-rc.53
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/bin/aws-nx-mcp.js +2 -2
- package/docs/guides/react-website-auth.mdx +4 -0
- package/docs/guides/smithy-project.mdx +175 -0
- package/docs/guides/ts-smithy-api.mdx +25 -0
- package/docs/snippets/prerequisites.mdx +1 -1
- package/generators.json +2 -2
- package/package.json +1 -1
- package/src/smithy/project/schema.json +23 -1
package/bin/aws-nx-mcp.js
CHANGED
|
@@ -54200,9 +54200,9 @@ var generators$1 = {
|
|
|
54200
54200
|
"smithy#project": {
|
|
54201
54201
|
"factory": "./src/smithy/project/generator",
|
|
54202
54202
|
"schema": "./src/smithy/project/schema.json",
|
|
54203
|
-
"description": "Generate a Smithy model project",
|
|
54203
|
+
"description": "Generate a Smithy model project, either defining a service or a library of reusable shapes",
|
|
54204
54204
|
"metric": "g27",
|
|
54205
|
-
"
|
|
54205
|
+
"guidePages": ["smithy-project"]
|
|
54206
54206
|
},
|
|
54207
54207
|
"smithy#react-connection": {
|
|
54208
54208
|
"factory": "./src/smithy/react-connection/generator",
|
|
@@ -140,6 +140,10 @@ module "user_identity" {
|
|
|
140
140
|
</Fragment>
|
|
141
141
|
</Infrastructure>
|
|
142
142
|
|
|
143
|
+
:::caution[`EC2MetaDataSSRF_QUERYARGUMENTS` is set to Count]
|
|
144
|
+
This rule flags loopback addresses in query arguments as [SSRF](https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-list.html) attempts, which would block local sign-in since the Hosted UI receives a `localhost` `redirect_uri`. It is therefore set to [Count](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-rule-action.html#web-acl-rule-action-count) while local callback URLs are configured — matches are still logged, and every other rule blocks. Remove the local callback URLs to restore it to Block.
|
|
145
|
+
:::
|
|
146
|
+
|
|
143
147
|
## Infrastructure Usage
|
|
144
148
|
|
|
145
149
|
<Infrastructure>
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Smithy Projects
|
|
3
|
+
description: Reference documentation for the Smithy project generator
|
|
4
|
+
generator: smithy#project
|
|
5
|
+
---
|
|
6
|
+
import { FileTree, Steps } from '@astrojs/starlight/components';
|
|
7
|
+
import RunGenerator from '@components/run-generator.astro';
|
|
8
|
+
import Link from '@components/link.astro';
|
|
9
|
+
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
10
|
+
import NxCommands from '@components/nx-commands.astro';
|
|
11
|
+
import OptionFilter from '@components/option-filter.astro';
|
|
12
|
+
|
|
13
|
+
[Smithy](https://smithy.io/) is an interface definition language for describing services and the data they exchange. The Smithy project generator creates a project containing a Smithy model.
|
|
14
|
+
|
|
15
|
+
There are two kinds of Smithy project:
|
|
16
|
+
|
|
17
|
+
- **Service** (`--type=service`) — a model which defines a service and its operations. This is what the <Link path="guides/ts-smithy-api">`ts#api --framework=smithy` generator</Link> creates for you alongside a TypeScript implementation.
|
|
18
|
+
- **Shape library** (`--type=shapes`) — a model which defines reusable shapes but no service. Connect a shape library to your Smithy projects to share shapes between them, rather than duplicating the definitions in each.
|
|
19
|
+
|
|
20
|
+
:::tip
|
|
21
|
+
If you want an API with an implementation, use the <Link path="guides/ts-smithy-api">`ts#api` generator</Link> instead. It creates a Smithy model project _and_ a TypeScript server which implements it.
|
|
22
|
+
:::
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Generate a Smithy Project
|
|
27
|
+
|
|
28
|
+
<RunGenerator generator="smithy#project" requiredParameters={{ name: 'my-shapes' }} />
|
|
29
|
+
|
|
30
|
+
### Options
|
|
31
|
+
|
|
32
|
+
<GeneratorParameters generator="smithy#project" />
|
|
33
|
+
|
|
34
|
+
## Generator Output
|
|
35
|
+
|
|
36
|
+
<OptionFilter when={{ type: 'shapes' }} description="Shape library: a model with no service">
|
|
37
|
+
|
|
38
|
+
### Shape Library
|
|
39
|
+
|
|
40
|
+
<FileTree>
|
|
41
|
+
|
|
42
|
+
- my-shapes
|
|
43
|
+
- src
|
|
44
|
+
- main.smithy Your shared shape definitions
|
|
45
|
+
- smithy-build.json Smithy build configuration
|
|
46
|
+
- build.Dockerfile Builds and validates the model
|
|
47
|
+
- project.json Project configuration and build targets
|
|
48
|
+
|
|
49
|
+
</FileTree>
|
|
50
|
+
|
|
51
|
+
A shape library defines shapes and nothing else:
|
|
52
|
+
|
|
53
|
+
```smithy
|
|
54
|
+
$version: "2.0"
|
|
55
|
+
|
|
56
|
+
namespace com.example
|
|
57
|
+
|
|
58
|
+
structure Customer {
|
|
59
|
+
@required
|
|
60
|
+
id: String
|
|
61
|
+
|
|
62
|
+
name: String
|
|
63
|
+
email: String
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Since a shape library has no service, its `smithy-build.json` configures no code generation — building it validates the model and assembles it into a single JSON model file at `dist/<my-shapes>/build/model/model.json`.
|
|
68
|
+
|
|
69
|
+
</OptionFilter>
|
|
70
|
+
|
|
71
|
+
<OptionFilter when={{ type: 'service' }} description="Service: a model which defines a service and its operations">
|
|
72
|
+
|
|
73
|
+
### Service
|
|
74
|
+
|
|
75
|
+
<FileTree>
|
|
76
|
+
|
|
77
|
+
- my-service
|
|
78
|
+
- src
|
|
79
|
+
- main.smithy Your service definition
|
|
80
|
+
- operations
|
|
81
|
+
- echo.smithy An example operation
|
|
82
|
+
- smithy-build.json Smithy build configuration, including code generation
|
|
83
|
+
- build.Dockerfile Builds the model, OpenAPI spec and TypeScript Server SDK
|
|
84
|
+
- project.json Project configuration and build targets
|
|
85
|
+
|
|
86
|
+
</FileTree>
|
|
87
|
+
|
|
88
|
+
A service model defines a service shape and the operations it exposes:
|
|
89
|
+
|
|
90
|
+
```smithy
|
|
91
|
+
$version: "2.0"
|
|
92
|
+
|
|
93
|
+
namespace com.example
|
|
94
|
+
|
|
95
|
+
use aws.protocols#restJson1
|
|
96
|
+
|
|
97
|
+
@title("MyService")
|
|
98
|
+
@restJson1
|
|
99
|
+
service MyService {
|
|
100
|
+
version: "1.0.0"
|
|
101
|
+
operations: [
|
|
102
|
+
Echo
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Building a service project generates an OpenAPI specification and a TypeScript Server SDK into `dist/<my-service>/build/`.
|
|
108
|
+
|
|
109
|
+
</OptionFilter>
|
|
110
|
+
|
|
111
|
+
## Building
|
|
112
|
+
|
|
113
|
+
Smithy projects build using [Docker](https://www.docker.com/), which runs the [Smithy CLI](https://smithy.io/2.0/guides/smithy-cli/index.html) to validate your model:
|
|
114
|
+
|
|
115
|
+
<NxCommands commands={['build my-shapes']} />
|
|
116
|
+
|
|
117
|
+
## Depending on a Shape Library
|
|
118
|
+
|
|
119
|
+
Building a shape library writes an assembled model to `dist/<my-shapes>/build/model/model.json`. This single file contains every shape the library defines, along with any it depends on, so a consumer only ever declares the libraries it references directly.
|
|
120
|
+
|
|
121
|
+
To depend on a shape library from another Smithy project, make three changes to the consuming project:
|
|
122
|
+
|
|
123
|
+
<Steps>
|
|
124
|
+
|
|
125
|
+
1. Smithy projects build inside a container, and the build is given the workspace root as a named build context. Add a `COPY` to the consuming project's `build.Dockerfile`, alongside where its own sources are copied in:
|
|
126
|
+
|
|
127
|
+
```dockerfile ins={4}
|
|
128
|
+
# Copy project files
|
|
129
|
+
COPY smithy-build.json .
|
|
130
|
+
COPY src src
|
|
131
|
+
COPY --from=workspace dist/packages/my-shapes/build/model/model.json deps/my-shapes.json
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
2. Add the copied file to `imports` in the consuming project's `smithy-build.json`:
|
|
135
|
+
|
|
136
|
+
```json ins={4}
|
|
137
|
+
{
|
|
138
|
+
"version": "1.0",
|
|
139
|
+
"sources": ["src/"],
|
|
140
|
+
"imports": ["deps/my-shapes.json"],
|
|
141
|
+
...
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
3. Add the library's `build` target as a dependency of the consuming project's `compile` target in its `project.json`, so the model exists before the consumer builds:
|
|
146
|
+
|
|
147
|
+
```json ins={4}
|
|
148
|
+
{
|
|
149
|
+
"targets": {
|
|
150
|
+
"compile": {
|
|
151
|
+
"dependsOn": ["@my-scope/my-shapes:build"],
|
|
152
|
+
...
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
</Steps>
|
|
159
|
+
|
|
160
|
+
Your model can now reference the library's shapes with `use`:
|
|
161
|
+
|
|
162
|
+
```smithy
|
|
163
|
+
$version: "2.0"
|
|
164
|
+
|
|
165
|
+
namespace com.example.api
|
|
166
|
+
|
|
167
|
+
use com.example.shared#Customer
|
|
168
|
+
|
|
169
|
+
structure GetCustomerOutput {
|
|
170
|
+
@required
|
|
171
|
+
customer: Customer
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Shape libraries can depend on other shape libraries the same way. Since each library's built model already contains its own dependencies, you only need to repeat these steps for the libraries you reference directly. A library reached by more than one path is resolved once — Smithy ignores duplicate but equivalent shape definitions.
|
|
@@ -224,6 +224,31 @@ You can change the folder structure however you like - all `.smithy` files in th
|
|
|
224
224
|
For more details on Smithy and its syntax, refer to the [Smithy specification](https://smithy.io/2.0/spec/index.html).
|
|
225
225
|
:::
|
|
226
226
|
|
|
227
|
+
### Adding a Shape Library
|
|
228
|
+
|
|
229
|
+
If you have several Smithy APIs which share the same data types, you can define those types once in a shape library rather than duplicating them in each model. A shape library is a Smithy project with no service — just reusable shapes — which any number of Smithy projects can depend on.
|
|
230
|
+
|
|
231
|
+
Generate one with the <Link path="guides/smithy-project">`smithy#project`</Link> generator:
|
|
232
|
+
|
|
233
|
+
<RunGenerator generator="smithy#project" requiredParameters={{ name: 'my-shapes', type: 'shapes' }} />
|
|
234
|
+
|
|
235
|
+
Your API's model can then reference its shapes with `use`:
|
|
236
|
+
|
|
237
|
+
```smithy
|
|
238
|
+
$version: "2.0"
|
|
239
|
+
|
|
240
|
+
namespace com.example.api
|
|
241
|
+
|
|
242
|
+
use com.example.shared#Customer
|
|
243
|
+
|
|
244
|
+
structure GetCustomerOutput {
|
|
245
|
+
@required
|
|
246
|
+
customer: Customer
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
See the <Link path="guides/smithy-project">Smithy project guide</Link> for how to create a shape library and wire it up as a dependency of your API's model.
|
|
251
|
+
|
|
227
252
|
### Implementing Operations in TypeScript
|
|
228
253
|
|
|
229
254
|
Operation implementations are located in the backend project's `src/operations/` directory. Each operation is implemented using the generated types from the TypeScript Server SDK (generated at build time from your Smithy model).
|
|
@@ -11,7 +11,7 @@ import Snippet from '@components/snippet.astro';
|
|
|
11
11
|
### Recommended
|
|
12
12
|
|
|
13
13
|
- [AWS Credentials](https://docs.aws.amazon.com/sdkref/latest/guide/access.html) configured to your target AWS account are required to deploy your application (as well as for some local development workflows).
|
|
14
|
-
- [Docker](https://www.docker.com/) or [Finch](https://runfinch.com/) is required for some generators. For Docker, [multi-platform builds](https://docs.docker.com/build/building/multi-platform/) must be set up; Finch supports [multi-platform builds](https://runfinch.com/docs/getting-started/building-images/#building-a-multi-architecture-container-image) out of the box.
|
|
14
|
+
- [Docker](https://www.docker.com/) or [Finch >= 1.6.0](https://runfinch.com/) is required for some generators. For Docker, [multi-platform builds](https://docs.docker.com/build/building/multi-platform/) must be set up; Finch supports [multi-platform builds](https://runfinch.com/docs/getting-started/building-images/#building-a-multi-architecture-container-image) out of the box.
|
|
15
15
|
- [Terraform >= 1.12](https://developer.hashicorp.com/terraform/install) is required if you choose to use this for infrastructure as code instead of CDK
|
|
16
16
|
- verify by running `terraform --version`
|
|
17
17
|
- If you are using [VSCode](https://code.visualstudio.com/), we recommend installing the [Nx Console VSCode Plugin](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console).
|
package/generators.json
CHANGED
|
@@ -165,9 +165,9 @@
|
|
|
165
165
|
"smithy#project": {
|
|
166
166
|
"factory": "./src/smithy/project/generator",
|
|
167
167
|
"schema": "./src/smithy/project/schema.json",
|
|
168
|
-
"description": "Generate a Smithy model project",
|
|
168
|
+
"description": "Generate a Smithy model project, either defining a service or a library of reusable shapes",
|
|
169
169
|
"metric": "g27",
|
|
170
|
-
"
|
|
170
|
+
"guidePages": ["smithy-project"]
|
|
171
171
|
},
|
|
172
172
|
"smithy#react-connection": {
|
|
173
173
|
"factory": "./src/smithy/react-connection/generator",
|
package/package.json
CHANGED
|
@@ -15,9 +15,31 @@
|
|
|
15
15
|
"x-priority": "important",
|
|
16
16
|
"x-prompt": "What would you like to call your Smithy project?"
|
|
17
17
|
},
|
|
18
|
+
"type": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The type of Smithy project to create. Choose between service (a model with a service shape, ready for an implementation) and shapes (a shape library of reusable shapes, shared between multiple Smithy projects).",
|
|
21
|
+
"default": "service",
|
|
22
|
+
"enum": ["service", "shapes"],
|
|
23
|
+
"x-priority": "important",
|
|
24
|
+
"x-prompt": {
|
|
25
|
+
"message": "What type of Smithy project would you like to create?",
|
|
26
|
+
"type": "list",
|
|
27
|
+
"items": [
|
|
28
|
+
{
|
|
29
|
+
"value": "service",
|
|
30
|
+
"label": "service (a model which defines a service and its operations)"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"value": "shapes",
|
|
34
|
+
"label": "shapes (a library of reusable shapes, shared between Smithy projects)"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"default": "service"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
18
40
|
"serviceName": {
|
|
19
41
|
"type": "string",
|
|
20
|
-
"description": "The name of your Smithy service. Uses the supplied name by default.",
|
|
42
|
+
"description": "The name of your Smithy service. Uses the supplied name by default. Not applicable to shape libraries.",
|
|
21
43
|
"x-prompt": "What name would you like your Smithy Service to have? i.e: MyService"
|
|
22
44
|
},
|
|
23
45
|
"namespace": {
|