@aws/nx-plugin-mcp 1.0.0-rc.31 → 1.0.0-rc.32
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.
|
@@ -312,6 +312,42 @@ function CreateItemForm() {
|
|
|
312
312
|
```
|
|
313
313
|
</Drawer>
|
|
314
314
|
|
|
315
|
+
### File Uploads
|
|
316
|
+
|
|
317
|
+
For endpoints that accept a file upload, the generated client sends the request as `FormData`. Define an operation with a `multipart/form-data` body in your FastAPI, for example using `UploadFile`:
|
|
318
|
+
|
|
319
|
+
```python
|
|
320
|
+
from fastapi import UploadFile
|
|
321
|
+
|
|
322
|
+
@app.post("/files")
|
|
323
|
+
async def upload_file(file: UploadFile, description: str = "") -> FileMetadata:
|
|
324
|
+
contents = await file.read()
|
|
325
|
+
...
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
Binary fields are typed as `Blob` on the generated client, and other fields (such as `description` above) keep their modelled types. Pass a `Blob` or `File` — for example one obtained from an `<input type="file">`:
|
|
329
|
+
|
|
330
|
+
```tsx {9-12}
|
|
331
|
+
import { useMutation } from '@tanstack/react-query';
|
|
332
|
+
import { useMyApi } from './hooks/useMyApi';
|
|
333
|
+
|
|
334
|
+
function UploadForm() {
|
|
335
|
+
const api = useMyApi();
|
|
336
|
+
const uploadFile = useMutation(api.uploadFile.mutationOptions());
|
|
337
|
+
|
|
338
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
339
|
+
const file = e.target.files?.[0];
|
|
340
|
+
if (file) {
|
|
341
|
+
uploadFile.mutate({ file, description: file.name });
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
return <input type="file" onChange={handleChange} />;
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
The client builds a `FormData` body and lets `fetch` set the `Content-Type` (including the multipart boundary) automatically.
|
|
350
|
+
|
|
315
351
|
### Pagination with Infinite Queries
|
|
316
352
|
|
|
317
353
|
For endpoints that accept a `cursor` parameter as input, the generated hooks provide support for infinite queries using TanStack Query's `useInfiniteQuery` hook. This makes it easy to implement "load more" or infinite scrolling functionality.
|
|
@@ -56,7 +56,6 @@ The generator will add the following files to your existing TypeScript project:
|
|
|
56
56
|
- resources/
|
|
57
57
|
- sample-guidance.ts Sample resource
|
|
58
58
|
- Dockerfile Entry point for hosting your MCP server (excluded when `infra` is set to `None`)
|
|
59
|
-
- package.json Updated with bin entry and MCP dependencies
|
|
60
59
|
- project.json Updated with MCP server serve target
|
|
61
60
|
</FileTree>
|
|
62
61
|
|
|
@@ -46,7 +46,7 @@ The generator will create the following project structure:
|
|
|
46
46
|
- generator-guide.ts Tool for detailed generator information
|
|
47
47
|
- utils.ts Utility functions for the MCP server
|
|
48
48
|
- generators.json Nx generator configuration (initially empty)
|
|
49
|
-
- package.json Plugin package configuration
|
|
49
|
+
- package.json Plugin package configuration
|
|
50
50
|
- tsconfig.json TypeScript configuration (CommonJS for Nx compatibility)
|
|
51
51
|
- project.json Nx project configuration with build and package targets
|
|
52
52
|
</FileTree>
|