@aws/nx-plugin 0.49.0 → 0.50.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.
Files changed (137) hide show
  1. package/generators.json +22 -1
  2. package/package.json +1 -1
  3. package/sdk/ts.d.ts +2 -0
  4. package/sdk/ts.js +6 -3
  5. package/sdk/ts.js.map +1 -1
  6. package/src/api-connection/generator.d.ts +2 -2
  7. package/src/api-connection/generator.js +20 -0
  8. package/src/api-connection/generator.js.map +1 -1
  9. package/src/infra/app/__snapshots__/generator.spec.ts.snap +124 -14
  10. package/src/infra/app/files/app/README.md.template +5 -5
  11. package/src/infra/app/files/app/checkov.yml.template +12 -0
  12. package/src/infra/app/files/app/src/main.ts.template +2 -4
  13. package/src/infra/app/generator.js +13 -8
  14. package/src/infra/app/generator.js.map +1 -1
  15. package/src/infra/app/schema.d.ts +0 -8
  16. package/src/infra/app/schema.json +0 -16
  17. package/src/license/config.js +3 -3
  18. package/src/license/config.js.map +1 -1
  19. package/src/open-api/ts-hooks/__snapshots__/generator.spec.tsx.snap +114 -0
  20. package/src/open-api/ts-hooks/generator.spec.tsx +176 -0
  21. package/src/open-api/utils/codegen-data.js +42 -5
  22. package/src/open-api/utils/codegen-data.js.map +1 -1
  23. package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
  24. package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +55 -2
  25. package/src/py/fast-api/generator.js +8 -55
  26. package/src/py/fast-api/generator.js.map +1 -1
  27. package/src/py/fast-api/react/generator.js +9 -111
  28. package/src/py/fast-api/react/generator.js.map +1 -1
  29. package/src/py/lambda-function/generator.js +1 -1
  30. package/src/py/lambda-function/generator.js.map +1 -1
  31. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +3 -2
  32. package/src/py/mcp-server/generator.js +1 -1
  33. package/src/py/mcp-server/generator.js.map +1 -1
  34. package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +3 -2
  35. package/src/py/strands-agent/generator.js +1 -1
  36. package/src/py/strands-agent/generator.js.map +1 -1
  37. package/src/smithy/project/__snapshots__/generator.spec.ts.snap +576 -0
  38. package/src/smithy/project/files/build.Dockerfile.template +97 -0
  39. package/src/smithy/project/files/smithy-build.json.template +25 -0
  40. package/src/smithy/project/files/src/main.smithy.template +19 -0
  41. package/src/smithy/project/files/src/operations/echo.smithy.template +18 -0
  42. package/src/smithy/project/generator.d.ts +10 -0
  43. package/src/smithy/project/generator.js +70 -0
  44. package/src/smithy/project/generator.js.map +1 -0
  45. package/src/smithy/project/schema.d.ts +11 -0
  46. package/src/smithy/project/schema.json +42 -0
  47. package/src/smithy/react-connection/__snapshots__/generator.spec.ts.snap +270 -0
  48. package/src/smithy/react-connection/files/model/extensions.smithy.template +33 -0
  49. package/src/smithy/react-connection/generator.d.ts +10 -0
  50. package/src/smithy/react-connection/generator.js +100 -0
  51. package/src/smithy/react-connection/generator.js.map +1 -0
  52. package/src/smithy/react-connection/schema.d.ts +8 -0
  53. package/src/smithy/react-connection/schema.json +26 -0
  54. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +3023 -0
  55. package/src/smithy/ts/api/files/context.ts.template +12 -0
  56. package/src/smithy/ts/api/files/handler.ts.template +50 -0
  57. package/src/smithy/ts/api/files/index.ts.template +0 -0
  58. package/src/smithy/ts/api/files/local-server.ts.template +41 -0
  59. package/src/smithy/ts/api/files/operations/echo.ts.template +7 -0
  60. package/src/smithy/ts/api/files/service.ts.template +8 -0
  61. package/src/smithy/ts/api/generator.d.ts +10 -0
  62. package/src/smithy/ts/api/generator.js +154 -0
  63. package/src/smithy/ts/api/generator.js.map +1 -0
  64. package/src/smithy/ts/api/schema.d.ts +14 -0
  65. package/src/smithy/ts/api/schema.json +56 -0
  66. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +61 -2
  67. package/src/trpc/backend/generator.js +6 -20
  68. package/src/trpc/backend/generator.js.map +1 -1
  69. package/src/trpc/backend/schema.d.ts +2 -1
  70. package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +3 -3
  71. package/src/ts/lambda-function/generator.js +10 -10
  72. package/src/ts/lambda-function/generator.js.map +1 -1
  73. package/src/ts/lib/eslint.d.ts +7 -0
  74. package/src/ts/lib/eslint.js +37 -29
  75. package/src/ts/lib/eslint.js.map +1 -1
  76. package/src/ts/lib/generator.js +2 -2
  77. package/src/ts/lib/generator.js.map +1 -1
  78. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +3 -2
  79. package/src/ts/mcp-server/files/Dockerfile.template +1 -1
  80. package/src/ts/mcp-server/generator.js +20 -14
  81. package/src/ts/mcp-server/generator.js.map +1 -1
  82. package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +6 -6
  83. package/src/ts/nx-generator/generator.js +3 -2
  84. package/src/ts/nx-generator/generator.js.map +1 -1
  85. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +264 -3
  86. package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +10 -0
  87. package/src/utils/__snapshots__/shared-constructs.spec.ts.snap +49 -0
  88. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +1 -1
  89. package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +1 -1
  90. package/src/utils/api-connection/open-api/react.d.ts +43 -0
  91. package/src/utils/api-connection/open-api/react.js +132 -0
  92. package/src/utils/api-connection/open-api/react.js.map +1 -0
  93. package/src/utils/api-constructs/api-constructs.d.ts +6 -2
  94. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  95. package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +4 -4
  96. package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +7 -4
  97. package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +37 -2
  98. package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +15 -0
  99. package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -1
  100. package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -1
  101. package/src/utils/api-constructs/open-api-metadata.d.ts +17 -0
  102. package/src/utils/api-constructs/open-api-metadata.js +68 -0
  103. package/src/utils/api-constructs/open-api-metadata.js.map +1 -0
  104. package/src/utils/bundle/bundle.d.ts +35 -0
  105. package/src/utils/bundle/bundle.js +107 -0
  106. package/src/utils/bundle/bundle.js.map +1 -0
  107. package/src/utils/bundle/files/ts/rolldown.config.ts.template +3 -0
  108. package/src/utils/files/common/constructs/src/core/checkov.ts.template +44 -0
  109. package/src/utils/files/common/constructs/src/core/index.ts.template +1 -0
  110. package/src/utils/fs.d.ts +16 -0
  111. package/src/utils/fs.js +32 -0
  112. package/src/utils/fs.js.map +1 -0
  113. package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +8 -0
  114. package/src/utils/nx.d.ts +10 -3
  115. package/src/utils/nx.js +18 -3
  116. package/src/utils/nx.js.map +1 -1
  117. package/src/utils/versions.d.ts +6 -2
  118. package/src/utils/versions.js +5 -1
  119. package/src/utils/versions.js.map +1 -1
  120. package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +56 -2
  121. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/aws-prototyping.guard +0 -1282
  122. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/cfn-nag.guard +0 -6839
  123. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/hipaa-security.guard +0 -2807
  124. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/nist-csf.guard +0 -2585
  125. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/pci-dss-3-2-1.guard +0 -2236
  126. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-reliability-pillar.guard +0 -885
  127. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-security-pillar.guard +0 -2205
  128. package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +0 -67
  129. package/src/utils/bundle.d.ts +0 -16
  130. package/src/utils/bundle.js +0 -48
  131. package/src/utils/bundle.js.map +0 -1
  132. package/src/utils/esbuild.d.ts +0 -15
  133. package/src/utils/esbuild.js +0 -46
  134. package/src/utils/esbuild.js.map +0 -1
  135. /package/src/{py/fast-api/react/files/website → utils/api-connection/open-api/files}/components/__apiNameClassName__Provider.tsx.template +0 -0
  136. /package/src/{py/fast-api/react/files/website → utils/api-connection/open-api/files}/hooks/use__apiNameClassName__.tsx.template +0 -0
  137. /package/src/{py/fast-api/react/files/website → utils/api-connection/open-api/files}/hooks/use__apiNameClassName__Client.tsx.template +0 -0
@@ -0,0 +1,576 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`smithyProjectGenerator > should generate smithy project with all custom options > all-custom-main.smithy 1`] = `
4
+ "$version: "2.0"
5
+
6
+ namespace com.mycompany.api
7
+
8
+ use aws.protocols#restJson1
9
+ use smithy.framework#ValidationException
10
+
11
+ /// TODO: describe your service here
12
+ @title("MyCustomService")
13
+ @restJson1
14
+ service MyCustomService {
15
+ version: "1.0.0"
16
+ operations: [
17
+ Echo
18
+ ]
19
+ errors: [
20
+ ValidationException
21
+ ]
22
+ }
23
+ "
24
+ `;
25
+
26
+ exports[`smithyProjectGenerator > should generate smithy project with all custom options > all-custom-project.json 1`] = `
27
+ "{
28
+ "name": "@proj/test-api",
29
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
30
+ "sourceRoot": "backend/model/src",
31
+ "projectType": "library",
32
+ "targets": {
33
+ "build": {
34
+ "dependsOn": ["compile"]
35
+ },
36
+ "compile": {
37
+ "cache": true,
38
+ "outputs": ["{workspaceRoot}/dist/{projectRoot}/build"],
39
+ "executor": "nx:run-commands",
40
+ "options": {
41
+ "commands": [
42
+ "rimraf dist/backend/model/build",
43
+ "make-dir dist/backend/model/build",
44
+ "docker build -f backend/model/build.Dockerfile --target export --output type=local,dest=dist/backend/model/build backend/model"
45
+ ],
46
+ "parallel": false,
47
+ "cwd": "{workspaceRoot}"
48
+ }
49
+ }
50
+ },
51
+ "metadata": {
52
+ "generator": "smithy#project",
53
+ "apiName": "test-api"
54
+ }
55
+ }
56
+ "
57
+ `;
58
+
59
+ exports[`smithyProjectGenerator > should generate smithy project with custom directory > custom-dir-project.json 1`] = `
60
+ "{
61
+ "name": "@proj/test-api",
62
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
63
+ "sourceRoot": "apis/test-api/src",
64
+ "projectType": "library",
65
+ "targets": {
66
+ "build": {
67
+ "dependsOn": ["compile"]
68
+ },
69
+ "compile": {
70
+ "cache": true,
71
+ "outputs": ["{workspaceRoot}/dist/{projectRoot}/build"],
72
+ "executor": "nx:run-commands",
73
+ "options": {
74
+ "commands": [
75
+ "rimraf dist/apis/test-api/build",
76
+ "make-dir dist/apis/test-api/build",
77
+ "docker build -f apis/test-api/build.Dockerfile --target export --output type=local,dest=dist/apis/test-api/build apis/test-api"
78
+ ],
79
+ "parallel": false,
80
+ "cwd": "{workspaceRoot}"
81
+ }
82
+ }
83
+ },
84
+ "metadata": {
85
+ "generator": "smithy#project",
86
+ "apiName": "test-api"
87
+ }
88
+ }
89
+ "
90
+ `;
91
+
92
+ exports[`smithyProjectGenerator > should generate smithy project with custom namespace > custom-namespace-main.smithy 1`] = `
93
+ "$version: "2.0"
94
+
95
+ namespace com.example.custom
96
+
97
+ use aws.protocols#restJson1
98
+ use smithy.framework#ValidationException
99
+
100
+ /// TODO: describe your service here
101
+ @title("TestApi")
102
+ @restJson1
103
+ service TestApi {
104
+ version: "1.0.0"
105
+ operations: [
106
+ Echo
107
+ ]
108
+ errors: [
109
+ ValidationException
110
+ ]
111
+ }
112
+ "
113
+ `;
114
+
115
+ exports[`smithyProjectGenerator > should generate smithy project with custom service name > custom-service-main.smithy 1`] = `
116
+ "$version: "2.0"
117
+
118
+ namespace proj
119
+
120
+ use aws.protocols#restJson1
121
+ use smithy.framework#ValidationException
122
+
123
+ /// TODO: describe your service here
124
+ @title("CustomService")
125
+ @restJson1
126
+ service CustomService {
127
+ version: "1.0.0"
128
+ operations: [
129
+ Echo
130
+ ]
131
+ errors: [
132
+ ValidationException
133
+ ]
134
+ }
135
+ "
136
+ `;
137
+
138
+ exports[`smithyProjectGenerator > should generate smithy project with default options > build.Dockerfile 1`] = `
139
+ "FROM public.ecr.aws/docker/library/node:24 AS builder
140
+
141
+ # Output directory
142
+ RUN mkdir /out
143
+
144
+ # Install Smithy CLI
145
+ # https://smithy.io/2.0/guides/smithy-cli/cli_installation.html
146
+ WORKDIR /smithy
147
+ ARG TARGETPLATFORM
148
+ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCH="aarch64"; else ARCH="x86_64"; fi && \\
149
+ mkdir -p smithy-install/smithy && \\
150
+ curl -L https://github.com/smithy-lang/smithy/releases/download/1.61.0/smithy-cli-linux-$ARCH.zip -o smithy-install/smithy-cli-linux-$ARCH.zip && \\
151
+ unzip -qo smithy-install/smithy-cli-linux-$ARCH.zip -d smithy-install && \\
152
+ mv smithy-install/smithy-cli-linux-$ARCH/* smithy-install/smithy
153
+ RUN smithy-install/smithy/install
154
+
155
+ # Add node dependencies for bundling
156
+ WORKDIR /project
157
+ RUN npm i -g pnpm@10.15.1 rolldown@1.0.0-beta.38
158
+
159
+ # Copy project files
160
+ COPY smithy-build.json .
161
+ COPY src src
162
+
163
+ # Smithy build with Maven cache mount
164
+ RUN --mount=type=cache,target=/root/.m2/repository,id=maven-cache \\
165
+ smithy build
166
+
167
+ # Copy OpenAPI specification to output location
168
+ RUN mkdir -p /out/openapi
169
+ RUN cp /project/build/smithy/source/openapi/*.openapi.json /out/openapi/openapi.json
170
+
171
+ WORKDIR /project/build/smithy/source/typescript-ssdk-codegen
172
+
173
+ # Install SSDK dependencies with pnpm cache mount
174
+ RUN --mount=type=cache,target=/root/.local/share/pnpm/store,id=pnpm-store \\
175
+ --mount=type=cache,target=/project/build/smithy/source/typescript-ssdk-codegen/node_modules,id=ssdk-node-modules \\
176
+ pnpm install --prefer-offline
177
+
178
+ # Install rolldown plugins with pnpm cache mount
179
+ RUN --mount=type=cache,target=/root/.local/share/pnpm/store,id=pnpm-store \\
180
+ --mount=type=cache,target=/project/build/smithy/source/typescript-ssdk-codegen/node_modules,id=ssdk-node-modules \\
181
+ pnpm add -D rolldown-plugin-dts@0.16.5 @rollup/plugin-esm-shim@0.1.8
182
+
183
+ RUN cat <<EOF > rolldown.config.js
184
+ import { dts } from 'rolldown-plugin-dts';
185
+ import esmShim from '@rollup/plugin-esm-shim';
186
+ import fs from 'fs';
187
+ import path from 'path';
188
+
189
+ // Bundle the re2-wasm wasm file as part of the module
190
+ const re2WasmPlugin = () => ({
191
+ name: 're2-wasm-plugin',
192
+ resolveId: (id) => {
193
+ if (!(id === 're2-wasm' || id.endsWith('/re2-wasm'))) return null;
194
+ try {
195
+ const dir = path.join(path.dirname(require.resolve('re2-wasm/package.json')), 'build/wasm');
196
+ return fs.existsSync(path.join(dir, 're2.wasm')) && fs.existsSync(path.join(dir, 're2.js')) ? path.join(dir, 're2.js') : null;
197
+ } catch { return null; }
198
+ },
199
+ load: (id) => {
200
+ if (!(id.endsWith('re2.js') && id.includes('re2-wasm'))) return null;
201
+ try {
202
+ const wasmPath = path.join(path.dirname(id), 're2.wasm');
203
+ return fs.existsSync(wasmPath) && fs.existsSync(id) ? \\\`var Module = { wasmBinary: Buffer.from("\\\${fs.readFileSync(wasmPath).toString('base64')}", "base64") }\\n\\\${fs.readFileSync(id, 'utf8')}\\\` : null;
204
+ } catch { return null; }
205
+ }
206
+ });
207
+
208
+ export default {
209
+ input: './src/index.ts',
210
+ plugins: [
211
+ re2WasmPlugin(),
212
+ dts({ resolve: true }),
213
+ esmShim(),
214
+ ],
215
+ output: [{
216
+ dir: 'dist',
217
+ format: 'es',
218
+ }],
219
+ resolve: {
220
+ tsconfigFilename: 'tsconfig.es.json',
221
+ },
222
+ platform: 'node',
223
+ };
224
+ EOF
225
+
226
+ # Create SSDK bundle with rolldown
227
+ RUN --mount=type=cache,target=/project/build/smithy/source/typescript-ssdk-codegen/node_modules,id=ssdk-node-modules \\
228
+ rolldown -c
229
+
230
+ RUN mkdir -p /out/ssdk
231
+ RUN cp dist/* /out/ssdk/
232
+
233
+ # Export the /out directory
234
+ FROM scratch AS export
235
+ COPY --from=builder /out /
236
+ "
237
+ `;
238
+
239
+ exports[`smithyProjectGenerator > should generate smithy project with default options > echo.smithy 1`] = `
240
+ "$version: "2.0"
241
+
242
+ namespace proj
243
+
244
+ /// An example operation
245
+ @http(method: "GET", uri: "/echo")
246
+ @readonly
247
+ operation Echo {
248
+ input := {
249
+ @httpQuery("message")
250
+ @required
251
+ message: String
252
+ }
253
+ output := {
254
+ @required
255
+ message: String
256
+ }
257
+ }
258
+ "
259
+ `;
260
+
261
+ exports[`smithyProjectGenerator > should generate smithy project with default options > main.smithy 1`] = `
262
+ "$version: "2.0"
263
+
264
+ namespace proj
265
+
266
+ use aws.protocols#restJson1
267
+ use smithy.framework#ValidationException
268
+
269
+ /// TODO: describe your service here
270
+ @title("TestApi")
271
+ @restJson1
272
+ service TestApi {
273
+ version: "1.0.0"
274
+ operations: [
275
+ Echo
276
+ ]
277
+ errors: [
278
+ ValidationException
279
+ ]
280
+ }
281
+ "
282
+ `;
283
+
284
+ exports[`smithyProjectGenerator > should generate smithy project with default options > project.json 1`] = `
285
+ "{
286
+ "name": "@proj/test-api",
287
+ "$schema": "../node_modules/nx/schemas/project-schema.json",
288
+ "sourceRoot": "test-api/src",
289
+ "projectType": "library",
290
+ "targets": {
291
+ "build": {
292
+ "dependsOn": ["compile"]
293
+ },
294
+ "compile": {
295
+ "cache": true,
296
+ "outputs": ["{workspaceRoot}/dist/{projectRoot}/build"],
297
+ "executor": "nx:run-commands",
298
+ "options": {
299
+ "commands": [
300
+ "rimraf dist/test-api/build",
301
+ "make-dir dist/test-api/build",
302
+ "docker build -f test-api/build.Dockerfile --target export --output type=local,dest=dist/test-api/build test-api"
303
+ ],
304
+ "parallel": false,
305
+ "cwd": "{workspaceRoot}"
306
+ }
307
+ }
308
+ },
309
+ "metadata": {
310
+ "generator": "smithy#project",
311
+ "apiName": "test-api"
312
+ }
313
+ }
314
+ "
315
+ `;
316
+
317
+ exports[`smithyProjectGenerator > should generate smithy project with default options > smithy-build.json 1`] = `
318
+ "{
319
+ "version": "1.0",
320
+ "sources": ["src/"],
321
+ "plugins": {
322
+ "openapi": {
323
+ "service": "proj#TestApi",
324
+ "version": "3.1.0",
325
+ "tags": true,
326
+ "useIntegerType": true
327
+ },
328
+ "typescript-ssdk-codegen": {
329
+ "package": "@proj/test-api-ssdk",
330
+ "packageVersion": "0.0.1"
331
+ }
332
+ },
333
+ "maven": {
334
+ "dependencies": [
335
+ "software.amazon.smithy:smithy-model:1.61.0",
336
+ "software.amazon.smithy:smithy-aws-traits:1.61.0",
337
+ "software.amazon.smithy:smithy-validation-model:1.61.0",
338
+ "software.amazon.smithy:smithy-openapi:1.61.0",
339
+ "software.amazon.smithy.typescript:smithy-aws-typescript-codegen:0.34.1"
340
+ ]
341
+ }
342
+ }
343
+ "
344
+ `;
345
+
346
+ exports[`smithyProjectGenerator > should generate smithy project with subdirectory > subdir-project.json 1`] = `
347
+ "{
348
+ "name": "@proj/test-api",
349
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
350
+ "sourceRoot": "services/model/src",
351
+ "projectType": "library",
352
+ "targets": {
353
+ "build": {
354
+ "dependsOn": ["compile"]
355
+ },
356
+ "compile": {
357
+ "cache": true,
358
+ "outputs": ["{workspaceRoot}/dist/{projectRoot}/build"],
359
+ "executor": "nx:run-commands",
360
+ "options": {
361
+ "commands": [
362
+ "rimraf dist/services/model/build",
363
+ "make-dir dist/services/model/build",
364
+ "docker build -f services/model/build.Dockerfile --target export --output type=local,dest=dist/services/model/build services/model"
365
+ ],
366
+ "parallel": false,
367
+ "cwd": "{workspaceRoot}"
368
+ }
369
+ }
370
+ },
371
+ "metadata": {
372
+ "generator": "smithy#project",
373
+ "apiName": "test-api"
374
+ }
375
+ }
376
+ "
377
+ `;
378
+
379
+ exports[`smithyProjectGenerator > should generate valid Docker build configuration > dockerfile 1`] = `
380
+ "FROM public.ecr.aws/docker/library/node:24 AS builder
381
+
382
+ # Output directory
383
+ RUN mkdir /out
384
+
385
+ # Install Smithy CLI
386
+ # https://smithy.io/2.0/guides/smithy-cli/cli_installation.html
387
+ WORKDIR /smithy
388
+ ARG TARGETPLATFORM
389
+ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCH="aarch64"; else ARCH="x86_64"; fi && \\
390
+ mkdir -p smithy-install/smithy && \\
391
+ curl -L https://github.com/smithy-lang/smithy/releases/download/1.61.0/smithy-cli-linux-$ARCH.zip -o smithy-install/smithy-cli-linux-$ARCH.zip && \\
392
+ unzip -qo smithy-install/smithy-cli-linux-$ARCH.zip -d smithy-install && \\
393
+ mv smithy-install/smithy-cli-linux-$ARCH/* smithy-install/smithy
394
+ RUN smithy-install/smithy/install
395
+
396
+ # Add node dependencies for bundling
397
+ WORKDIR /project
398
+ RUN npm i -g pnpm@10.15.1 rolldown@1.0.0-beta.38
399
+
400
+ # Copy project files
401
+ COPY smithy-build.json .
402
+ COPY src src
403
+
404
+ # Smithy build with Maven cache mount
405
+ RUN --mount=type=cache,target=/root/.m2/repository,id=maven-cache \\
406
+ smithy build
407
+
408
+ # Copy OpenAPI specification to output location
409
+ RUN mkdir -p /out/openapi
410
+ RUN cp /project/build/smithy/source/openapi/*.openapi.json /out/openapi/openapi.json
411
+
412
+ WORKDIR /project/build/smithy/source/typescript-ssdk-codegen
413
+
414
+ # Install SSDK dependencies with pnpm cache mount
415
+ RUN --mount=type=cache,target=/root/.local/share/pnpm/store,id=pnpm-store \\
416
+ --mount=type=cache,target=/project/build/smithy/source/typescript-ssdk-codegen/node_modules,id=ssdk-node-modules \\
417
+ pnpm install --prefer-offline
418
+
419
+ # Install rolldown plugins with pnpm cache mount
420
+ RUN --mount=type=cache,target=/root/.local/share/pnpm/store,id=pnpm-store \\
421
+ --mount=type=cache,target=/project/build/smithy/source/typescript-ssdk-codegen/node_modules,id=ssdk-node-modules \\
422
+ pnpm add -D rolldown-plugin-dts@0.16.5 @rollup/plugin-esm-shim@0.1.8
423
+
424
+ RUN cat <<EOF > rolldown.config.js
425
+ import { dts } from 'rolldown-plugin-dts';
426
+ import esmShim from '@rollup/plugin-esm-shim';
427
+ import fs from 'fs';
428
+ import path from 'path';
429
+
430
+ // Bundle the re2-wasm wasm file as part of the module
431
+ const re2WasmPlugin = () => ({
432
+ name: 're2-wasm-plugin',
433
+ resolveId: (id) => {
434
+ if (!(id === 're2-wasm' || id.endsWith('/re2-wasm'))) return null;
435
+ try {
436
+ const dir = path.join(path.dirname(require.resolve('re2-wasm/package.json')), 'build/wasm');
437
+ return fs.existsSync(path.join(dir, 're2.wasm')) && fs.existsSync(path.join(dir, 're2.js')) ? path.join(dir, 're2.js') : null;
438
+ } catch { return null; }
439
+ },
440
+ load: (id) => {
441
+ if (!(id.endsWith('re2.js') && id.includes('re2-wasm'))) return null;
442
+ try {
443
+ const wasmPath = path.join(path.dirname(id), 're2.wasm');
444
+ return fs.existsSync(wasmPath) && fs.existsSync(id) ? \\\`var Module = { wasmBinary: Buffer.from("\\\${fs.readFileSync(wasmPath).toString('base64')}", "base64") }\\n\\\${fs.readFileSync(id, 'utf8')}\\\` : null;
445
+ } catch { return null; }
446
+ }
447
+ });
448
+
449
+ export default {
450
+ input: './src/index.ts',
451
+ plugins: [
452
+ re2WasmPlugin(),
453
+ dts({ resolve: true }),
454
+ esmShim(),
455
+ ],
456
+ output: [{
457
+ dir: 'dist',
458
+ format: 'es',
459
+ }],
460
+ resolve: {
461
+ tsconfigFilename: 'tsconfig.es.json',
462
+ },
463
+ platform: 'node',
464
+ };
465
+ EOF
466
+
467
+ # Create SSDK bundle with rolldown
468
+ RUN --mount=type=cache,target=/project/build/smithy/source/typescript-ssdk-codegen/node_modules,id=ssdk-node-modules \\
469
+ rolldown -c
470
+
471
+ RUN mkdir -p /out/ssdk
472
+ RUN cp dist/* /out/ssdk/
473
+
474
+ # Export the /out directory
475
+ FROM scratch AS export
476
+ COPY --from=builder /out /
477
+ "
478
+ `;
479
+
480
+ exports[`smithyProjectGenerator > should handle empty service name by using project name > default-service-name-main.smithy 1`] = `
481
+ "$version: "2.0"
482
+
483
+ namespace proj
484
+
485
+ use aws.protocols#restJson1
486
+ use smithy.framework#ValidationException
487
+
488
+ /// TODO: describe your service here
489
+ @title("MyService")
490
+ @restJson1
491
+ service MyService {
492
+ version: "1.0.0"
493
+ operations: [
494
+ Echo
495
+ ]
496
+ errors: [
497
+ ValidationException
498
+ ]
499
+ }
500
+ "
501
+ `;
502
+
503
+ exports[`smithyProjectGenerator > should handle kebab-case conversion for service names > kebab-case-main.smithy 1`] = `
504
+ "$version: "2.0"
505
+
506
+ namespace proj
507
+
508
+ use aws.protocols#restJson1
509
+ use smithy.framework#ValidationException
510
+
511
+ /// TODO: describe your service here
512
+ @title("MyTestService")
513
+ @restJson1
514
+ service MyTestService {
515
+ version: "1.0.0"
516
+ operations: [
517
+ Echo
518
+ ]
519
+ errors: [
520
+ ValidationException
521
+ ]
522
+ }
523
+ "
524
+ `;
525
+
526
+ exports[`smithyProjectGenerator > should handle kebab-case conversion for service names > kebab-case-smithy-build.json 1`] = `
527
+ "{
528
+ "version": "1.0",
529
+ "sources": ["src/"],
530
+ "plugins": {
531
+ "openapi": {
532
+ "service": "proj#MyTestService",
533
+ "version": "3.1.0",
534
+ "tags": true,
535
+ "useIntegerType": true
536
+ },
537
+ "typescript-ssdk-codegen": {
538
+ "package": "@proj/my-test-service-ssdk",
539
+ "packageVersion": "0.0.1"
540
+ }
541
+ },
542
+ "maven": {
543
+ "dependencies": [
544
+ "software.amazon.smithy:smithy-model:1.61.0",
545
+ "software.amazon.smithy:smithy-aws-traits:1.61.0",
546
+ "software.amazon.smithy:smithy-validation-model:1.61.0",
547
+ "software.amazon.smithy:smithy-openapi:1.61.0",
548
+ "software.amazon.smithy.typescript:smithy-aws-typescript-codegen:0.34.1"
549
+ ]
550
+ }
551
+ }
552
+ "
553
+ `;
554
+
555
+ exports[`smithyProjectGenerator > should use npm scope for default namespace > npm-scope-main.smithy 1`] = `
556
+ "$version: "2.0"
557
+
558
+ namespace myorg
559
+
560
+ use aws.protocols#restJson1
561
+ use smithy.framework#ValidationException
562
+
563
+ /// TODO: describe your service here
564
+ @title("TestApi")
565
+ @restJson1
566
+ service TestApi {
567
+ version: "1.0.0"
568
+ operations: [
569
+ Echo
570
+ ]
571
+ errors: [
572
+ ValidationException
573
+ ]
574
+ }
575
+ "
576
+ `;
@@ -0,0 +1,97 @@
1
+ FROM public.ecr.aws/docker/library/node:24 AS builder
2
+
3
+ # Output directory
4
+ RUN mkdir /out
5
+
6
+ # Install Smithy CLI
7
+ # https://smithy.io/2.0/guides/smithy-cli/cli_installation.html
8
+ WORKDIR /smithy
9
+ ARG TARGETPLATFORM
10
+ RUN if [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCH="aarch64"; else ARCH="x86_64"; fi && \
11
+ mkdir -p smithy-install/smithy && \
12
+ curl -L https://github.com/smithy-lang/smithy/releases/download/1.61.0/smithy-cli-linux-$ARCH.zip -o smithy-install/smithy-cli-linux-$ARCH.zip && \
13
+ unzip -qo smithy-install/smithy-cli-linux-$ARCH.zip -d smithy-install && \
14
+ mv smithy-install/smithy-cli-linux-$ARCH/* smithy-install/smithy
15
+ RUN smithy-install/smithy/install
16
+
17
+ # Add node dependencies for bundling
18
+ WORKDIR /project
19
+ RUN npm i -g pnpm@10.15.1 rolldown@1.0.0-beta.38
20
+
21
+ # Copy project files
22
+ COPY smithy-build.json .
23
+ COPY src src
24
+
25
+ # Smithy build with Maven cache mount
26
+ RUN --mount=type=cache,target=/root/.m2/repository,id=maven-cache \
27
+ smithy build
28
+
29
+ # Copy OpenAPI specification to output location
30
+ RUN mkdir -p /out/openapi
31
+ RUN cp /project/build/smithy/source/openapi/*.openapi.json /out/openapi/openapi.json
32
+
33
+ WORKDIR /project/build/smithy/source/typescript-ssdk-codegen
34
+
35
+ # Install SSDK dependencies with pnpm cache mount
36
+ RUN --mount=type=cache,target=/root/.local/share/pnpm/store,id=pnpm-store \
37
+ --mount=type=cache,target=/project/build/smithy/source/typescript-ssdk-codegen/node_modules,id=ssdk-node-modules \
38
+ pnpm install --prefer-offline
39
+
40
+ # Install rolldown plugins with pnpm cache mount
41
+ RUN --mount=type=cache,target=/root/.local/share/pnpm/store,id=pnpm-store \
42
+ --mount=type=cache,target=/project/build/smithy/source/typescript-ssdk-codegen/node_modules,id=ssdk-node-modules \
43
+ pnpm add -D rolldown-plugin-dts@0.16.5 @rollup/plugin-esm-shim@0.1.8
44
+
45
+ RUN cat <<EOF > rolldown.config.js
46
+ import { dts } from 'rolldown-plugin-dts';
47
+ import esmShim from '@rollup/plugin-esm-shim';
48
+ import fs from 'fs';
49
+ import path from 'path';
50
+
51
+ // Bundle the re2-wasm wasm file as part of the module
52
+ const re2WasmPlugin = () => ({
53
+ name: 're2-wasm-plugin',
54
+ resolveId: (id) => {
55
+ if (!(id === 're2-wasm' || id.endsWith('/re2-wasm'))) return null;
56
+ try {
57
+ const dir = path.join(path.dirname(require.resolve('re2-wasm/package.json')), 'build/wasm');
58
+ return fs.existsSync(path.join(dir, 're2.wasm')) && fs.existsSync(path.join(dir, 're2.js')) ? path.join(dir, 're2.js') : null;
59
+ } catch { return null; }
60
+ },
61
+ load: (id) => {
62
+ if (!(id.endsWith('re2.js') && id.includes('re2-wasm'))) return null;
63
+ try {
64
+ const wasmPath = path.join(path.dirname(id), 're2.wasm');
65
+ return fs.existsSync(wasmPath) && fs.existsSync(id) ? \`var Module = { wasmBinary: Buffer.from("\${fs.readFileSync(wasmPath).toString('base64')}", "base64") }\n\${fs.readFileSync(id, 'utf8')}\` : null;
66
+ } catch { return null; }
67
+ }
68
+ });
69
+
70
+ export default {
71
+ input: './src/index.ts',
72
+ plugins: [
73
+ re2WasmPlugin(),
74
+ dts({ resolve: true }),
75
+ esmShim(),
76
+ ],
77
+ output: [{
78
+ dir: 'dist',
79
+ format: 'es',
80
+ }],
81
+ resolve: {
82
+ tsconfigFilename: 'tsconfig.es.json',
83
+ },
84
+ platform: 'node',
85
+ };
86
+ EOF
87
+
88
+ # Create SSDK bundle with rolldown
89
+ RUN --mount=type=cache,target=/project/build/smithy/source/typescript-ssdk-codegen/node_modules,id=ssdk-node-modules \
90
+ rolldown -c
91
+
92
+ RUN mkdir -p /out/ssdk
93
+ RUN cp dist/* /out/ssdk/
94
+
95
+ # Export the /out directory
96
+ FROM scratch AS export
97
+ COPY --from=builder /out /
@@ -0,0 +1,25 @@
1
+ {
2
+ "version": "1.0",
3
+ "sources": ["src/"],
4
+ "plugins": {
5
+ "openapi": {
6
+ "service": "<%- namespace %>#<%- serviceNameClassName %>",
7
+ "version": "3.1.0",
8
+ "tags": true,
9
+ "useIntegerType": true
10
+ },
11
+ "typescript-ssdk-codegen": {
12
+ "package" : "@<%- scope %>/<%- serviceNameKebabCase %>-ssdk",
13
+ "packageVersion": "0.0.1"
14
+ }
15
+ },
16
+ "maven": {
17
+ "dependencies": [
18
+ "software.amazon.smithy:smithy-model:1.61.0",
19
+ "software.amazon.smithy:smithy-aws-traits:1.61.0",
20
+ "software.amazon.smithy:smithy-validation-model:1.61.0",
21
+ "software.amazon.smithy:smithy-openapi:1.61.0",
22
+ "software.amazon.smithy.typescript:smithy-aws-typescript-codegen:0.34.1"
23
+ ]
24
+ }
25
+ }