@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.
- package/generators.json +22 -1
- package/package.json +1 -1
- package/sdk/ts.d.ts +2 -0
- package/sdk/ts.js +6 -3
- package/sdk/ts.js.map +1 -1
- package/src/api-connection/generator.d.ts +2 -2
- package/src/api-connection/generator.js +20 -0
- package/src/api-connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +124 -14
- package/src/infra/app/files/app/README.md.template +5 -5
- package/src/infra/app/files/app/checkov.yml.template +12 -0
- package/src/infra/app/files/app/src/main.ts.template +2 -4
- package/src/infra/app/generator.js +13 -8
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.ts +0 -8
- package/src/infra/app/schema.json +0 -16
- package/src/license/config.js +3 -3
- package/src/license/config.js.map +1 -1
- package/src/open-api/ts-hooks/__snapshots__/generator.spec.tsx.snap +114 -0
- package/src/open-api/ts-hooks/generator.spec.tsx +176 -0
- package/src/open-api/utils/codegen-data.js +42 -5
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +55 -2
- package/src/py/fast-api/generator.js +8 -55
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.js +9 -111
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/lambda-function/generator.js +1 -1
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +3 -2
- package/src/py/mcp-server/generator.js +1 -1
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +3 -2
- package/src/py/strands-agent/generator.js +1 -1
- package/src/py/strands-agent/generator.js.map +1 -1
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +576 -0
- package/src/smithy/project/files/build.Dockerfile.template +97 -0
- package/src/smithy/project/files/smithy-build.json.template +25 -0
- package/src/smithy/project/files/src/main.smithy.template +19 -0
- package/src/smithy/project/files/src/operations/echo.smithy.template +18 -0
- package/src/smithy/project/generator.d.ts +10 -0
- package/src/smithy/project/generator.js +70 -0
- package/src/smithy/project/generator.js.map +1 -0
- package/src/smithy/project/schema.d.ts +11 -0
- package/src/smithy/project/schema.json +42 -0
- package/src/smithy/react-connection/__snapshots__/generator.spec.ts.snap +270 -0
- package/src/smithy/react-connection/files/model/extensions.smithy.template +33 -0
- package/src/smithy/react-connection/generator.d.ts +10 -0
- package/src/smithy/react-connection/generator.js +100 -0
- package/src/smithy/react-connection/generator.js.map +1 -0
- package/src/smithy/react-connection/schema.d.ts +8 -0
- package/src/smithy/react-connection/schema.json +26 -0
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +3023 -0
- package/src/smithy/ts/api/files/context.ts.template +12 -0
- package/src/smithy/ts/api/files/handler.ts.template +50 -0
- package/src/smithy/ts/api/files/index.ts.template +0 -0
- package/src/smithy/ts/api/files/local-server.ts.template +41 -0
- package/src/smithy/ts/api/files/operations/echo.ts.template +7 -0
- package/src/smithy/ts/api/files/service.ts.template +8 -0
- package/src/smithy/ts/api/generator.d.ts +10 -0
- package/src/smithy/ts/api/generator.js +154 -0
- package/src/smithy/ts/api/generator.js.map +1 -0
- package/src/smithy/ts/api/schema.d.ts +14 -0
- package/src/smithy/ts/api/schema.json +56 -0
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +61 -2
- package/src/trpc/backend/generator.js +6 -20
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +2 -1
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/lambda-function/generator.js +10 -10
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lib/eslint.d.ts +7 -0
- package/src/ts/lib/eslint.js +37 -29
- package/src/ts/lib/eslint.js.map +1 -1
- package/src/ts/lib/generator.js +2 -2
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +3 -2
- package/src/ts/mcp-server/files/Dockerfile.template +1 -1
- package/src/ts/mcp-server/generator.js +20 -14
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/ts/nx-generator/generator.js +3 -2
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +264 -3
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/utils/__snapshots__/shared-constructs.spec.ts.snap +49 -0
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +1 -1
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +1 -1
- package/src/utils/api-connection/open-api/react.d.ts +43 -0
- package/src/utils/api-connection/open-api/react.js +132 -0
- package/src/utils/api-connection/open-api/react.js.map +1 -0
- package/src/utils/api-constructs/api-constructs.d.ts +6 -2
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +4 -4
- package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +7 -4
- package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +37 -2
- package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +15 -0
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -1
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -1
- package/src/utils/api-constructs/open-api-metadata.d.ts +17 -0
- package/src/utils/api-constructs/open-api-metadata.js +68 -0
- package/src/utils/api-constructs/open-api-metadata.js.map +1 -0
- package/src/utils/bundle/bundle.d.ts +35 -0
- package/src/utils/bundle/bundle.js +107 -0
- package/src/utils/bundle/bundle.js.map +1 -0
- package/src/utils/bundle/files/ts/rolldown.config.ts.template +3 -0
- package/src/utils/files/common/constructs/src/core/checkov.ts.template +44 -0
- package/src/utils/files/common/constructs/src/core/index.ts.template +1 -0
- package/src/utils/fs.d.ts +16 -0
- package/src/utils/fs.js +32 -0
- package/src/utils/fs.js.map +1 -0
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +8 -0
- package/src/utils/nx.d.ts +10 -3
- package/src/utils/nx.js +18 -3
- package/src/utils/nx.js.map +1 -1
- package/src/utils/versions.d.ts +6 -2
- package/src/utils/versions.js +5 -1
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +56 -2
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/aws-prototyping.guard +0 -1282
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/cfn-nag.guard +0 -6839
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/hipaa-security.guard +0 -2807
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/nist-csf.guard +0 -2585
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/pci-dss-3-2-1.guard +0 -2236
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-reliability-pillar.guard +0 -885
- package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-security-pillar.guard +0 -2205
- package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +0 -67
- package/src/utils/bundle.d.ts +0 -16
- package/src/utils/bundle.js +0 -48
- package/src/utils/bundle.js.map +0 -1
- package/src/utils/esbuild.d.ts +0 -15
- package/src/utils/esbuild.js +0 -46
- package/src/utils/esbuild.js.map +0 -1
- /package/src/{py/fast-api/react/files/website → utils/api-connection/open-api/files}/components/__apiNameClassName__Provider.tsx.template +0 -0
- /package/src/{py/fast-api/react/files/website → utils/api-connection/open-api/files}/hooks/use__apiNameClassName__.tsx.template +0 -0
- /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,19 @@
|
|
|
1
|
+
$version: "2.0"
|
|
2
|
+
|
|
3
|
+
namespace <%- namespace %>
|
|
4
|
+
|
|
5
|
+
use aws.protocols#restJson1
|
|
6
|
+
use smithy.framework#ValidationException
|
|
7
|
+
|
|
8
|
+
/// TODO: describe your service here
|
|
9
|
+
@title("<%- serviceNameClassName %>")
|
|
10
|
+
@restJson1
|
|
11
|
+
service <%- serviceNameClassName %> {
|
|
12
|
+
version: "1.0.0"
|
|
13
|
+
operations: [
|
|
14
|
+
Echo
|
|
15
|
+
]
|
|
16
|
+
errors: [
|
|
17
|
+
ValidationException
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
$version: "2.0"
|
|
2
|
+
|
|
3
|
+
namespace <%- namespace %>
|
|
4
|
+
|
|
5
|
+
/// An example operation
|
|
6
|
+
@http(method: "GET", uri: "/echo")
|
|
7
|
+
@readonly
|
|
8
|
+
operation Echo {
|
|
9
|
+
input := {
|
|
10
|
+
@httpQuery("message")
|
|
11
|
+
@required
|
|
12
|
+
message: String
|
|
13
|
+
}
|
|
14
|
+
output := {
|
|
15
|
+
@required
|
|
16
|
+
message: String
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
6
|
+
import { SmithyProjectGeneratorSchema } from './schema';
|
|
7
|
+
import { NxGeneratorInfo } from '../../utils/nx';
|
|
8
|
+
export declare const SMITHY_PROJECT_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
export declare const smithyProjectGenerator: (tree: Tree, options: SmithyProjectGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
|
+
export default smithyProjectGenerator;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.smithyProjectGenerator = exports.SMITHY_PROJECT_GENERATOR_INFO = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
10
|
+
const nx_1 = require("../../utils/nx");
|
|
11
|
+
const metrics_1 = require("../../utils/metrics");
|
|
12
|
+
const format_1 = require("../../utils/format");
|
|
13
|
+
const generator_1 = require("../../ts/lib/generator");
|
|
14
|
+
const names_1 = require("../../utils/names");
|
|
15
|
+
const npm_scope_1 = require("../../utils/npm-scope");
|
|
16
|
+
const fs_1 = require("../../utils/fs");
|
|
17
|
+
exports.SMITHY_PROJECT_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
18
|
+
const smithyProjectGenerator = (tree, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const cmd = new fs_1.FsCommands(tree);
|
|
21
|
+
// Create project.json
|
|
22
|
+
const { fullyQualifiedName, dir } = (0, generator_1.getTsLibDetails)(tree, options);
|
|
23
|
+
(0, devkit_1.addProjectConfiguration)(tree, fullyQualifiedName, {
|
|
24
|
+
name: fullyQualifiedName,
|
|
25
|
+
root: dir,
|
|
26
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(dir, 'src'),
|
|
27
|
+
projectType: 'library',
|
|
28
|
+
targets: {
|
|
29
|
+
build: {
|
|
30
|
+
dependsOn: ['compile'],
|
|
31
|
+
},
|
|
32
|
+
compile: {
|
|
33
|
+
cache: true,
|
|
34
|
+
outputs: ['{workspaceRoot}/dist/{projectRoot}/build'],
|
|
35
|
+
executor: 'nx:run-commands',
|
|
36
|
+
options: {
|
|
37
|
+
commands: [
|
|
38
|
+
cmd.rm(`dist/${dir}/build`),
|
|
39
|
+
cmd.mkdir(`dist/${dir}/build`),
|
|
40
|
+
`docker build -f ${dir}/build.Dockerfile --target export --output type=local,dest=dist/${dir}/build ${dir}`,
|
|
41
|
+
],
|
|
42
|
+
parallel: false,
|
|
43
|
+
cwd: '{workspaceRoot}',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const serviceName = (_a = options.serviceName) !== null && _a !== void 0 ? _a : options.name;
|
|
49
|
+
const serviceNameClassName = (0, names_1.toClassName)(serviceName);
|
|
50
|
+
const serviceNameKebabCase = (0, names_1.toKebabCase)(serviceName);
|
|
51
|
+
const scope = (0, npm_scope_1.getNpmScope)(tree);
|
|
52
|
+
const namespace = (_b = options.namespace) !== null && _b !== void 0 ? _b : (0, names_1.toKebabCase)(scope).replace(/-/g, '.');
|
|
53
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), dir, {
|
|
54
|
+
namespace,
|
|
55
|
+
serviceNameClassName,
|
|
56
|
+
serviceNameKebabCase,
|
|
57
|
+
scope,
|
|
58
|
+
});
|
|
59
|
+
(0, nx_1.addGeneratorMetadata)(tree, fullyQualifiedName, exports.SMITHY_PROJECT_GENERATOR_INFO, {
|
|
60
|
+
apiName: options.name,
|
|
61
|
+
});
|
|
62
|
+
yield (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [exports.SMITHY_PROJECT_GENERATOR_INFO]);
|
|
63
|
+
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
64
|
+
return () => {
|
|
65
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
exports.smithyProjectGenerator = smithyProjectGenerator;
|
|
69
|
+
exports.default = exports.smithyProjectGenerator;
|
|
70
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/smithy/project/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAOoB;AAEpB,uCAIwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,sDAAyD;AACzD,6CAA6D;AAC7D,qDAAoD;AACpD,uCAA4C;AAE/B,QAAA,6BAA6B,GACxC,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,sBAAsB,GAAG,CACpC,IAAU,EACV,OAAqC,EACT,EAAE;;IAC9B,MAAM,GAAG,GAAG,IAAI,eAAU,CAAC,IAAI,CAAC,CAAC;IAEjC,sBAAsB;IACtB,MAAM,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG,IAAA,2BAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnE,IAAA,gCAAuB,EAAC,IAAI,EAAE,kBAAkB,EAAE;QAChD,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,GAAG;QACT,UAAU,EAAE,IAAA,0BAAiB,EAAC,GAAG,EAAE,KAAK,CAAC;QACzC,WAAW,EAAE,SAAS;QACtB,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,SAAS,EAAE,CAAC,SAAS,CAAC;aACvB;YACD,OAAO,EAAE;gBACP,KAAK,EAAE,IAAI;gBACX,OAAO,EAAE,CAAC,0CAA0C,CAAC;gBACrD,QAAQ,EAAE,iBAAiB;gBAC3B,OAAO,EAAE;oBACP,QAAQ,EAAE;wBACR,GAAG,CAAC,EAAE,CAAC,QAAQ,GAAG,QAAQ,CAAC;wBAC3B,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;wBAC9B,mBAAmB,GAAG,mEAAmE,GAAG,UAAU,GAAG,EAAE;qBAC5G;oBAC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
+
export interface SmithyProjectGeneratorSchema {
|
|
6
|
+
name: string;
|
|
7
|
+
serviceName?: string;
|
|
8
|
+
namespace?: string;
|
|
9
|
+
directory?: string;
|
|
10
|
+
subDirectory?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "smithy#project",
|
|
4
|
+
"title": "smithy#project",
|
|
5
|
+
"description": "Generate a Smithy model project",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Smithy project name",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 0
|
|
14
|
+
},
|
|
15
|
+
"x-priority": "important",
|
|
16
|
+
"x-prompt": "What would you like to call your Smithy project?"
|
|
17
|
+
},
|
|
18
|
+
"serviceName": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The name of your Smithy service. Uses the supplied name by default.",
|
|
21
|
+
"x-prompt": "What name would you like your Smithy Service to have? i.e: MyService"
|
|
22
|
+
},
|
|
23
|
+
"namespace": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "The namespace for the Smithy API. Defaults to your monorepo scope",
|
|
26
|
+
"x-prompt": "What namespace would you like your API to have? i.e: com.example"
|
|
27
|
+
},
|
|
28
|
+
"directory": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "Parent directory where the Smithy project is placed.",
|
|
31
|
+
"default": "packages",
|
|
32
|
+
"x-prompt": "Which directory do you want to create the Smithy project in?",
|
|
33
|
+
"x-priority": "important"
|
|
34
|
+
},
|
|
35
|
+
"subDirectory": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "The sub directory the Smithy project is placed in. By default this is the project name.",
|
|
38
|
+
"x-prompt": "Which sub directory do you want to create the Smithy project in? (By default this is the project name)"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"required": ["name"]
|
|
42
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`smithy#react-connection generator > with model project as target > should generate client hook files > useTestApi.tsx 1`] = `
|
|
4
|
+
"import { useContext } from 'react';
|
|
5
|
+
import { TestApiContext } from '../components/TestApiProvider';
|
|
6
|
+
import { TestApiOptionsProxy } from '../generated/test-api/options-proxy.gen';
|
|
7
|
+
|
|
8
|
+
export const useTestApi = (): TestApiOptionsProxy => {
|
|
9
|
+
const optionsProxy = useContext(TestApiContext);
|
|
10
|
+
|
|
11
|
+
if (!optionsProxy) {
|
|
12
|
+
throw new Error('useTestApi must be used within a TestApiProvider');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return optionsProxy;
|
|
16
|
+
};
|
|
17
|
+
"
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
exports[`smithy#react-connection generator > with model project as target > should generate client hook files > useTestApiClient.tsx 1`] = `
|
|
21
|
+
"import { TestApi } from '../generated/test-api/client.gen';
|
|
22
|
+
import { TestApiClientContext } from '../components/TestApiProvider';
|
|
23
|
+
import { useContext } from 'react';
|
|
24
|
+
|
|
25
|
+
export const useTestApiClient = (): TestApi => {
|
|
26
|
+
const client = useContext(TestApiClientContext);
|
|
27
|
+
|
|
28
|
+
if (!client) {
|
|
29
|
+
throw new Error('useTestApiClient must be used within a TestApiProvider');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return client;
|
|
33
|
+
};
|
|
34
|
+
"
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
exports[`smithy#react-connection generator > with model project as target > should generate provider components > TestApiProvider.tsx 1`] = `
|
|
38
|
+
"import { createContext, FC, PropsWithChildren, useMemo } from 'react';
|
|
39
|
+
import { TestApi } from '../generated/test-api/client.gen';
|
|
40
|
+
import { TestApiOptionsProxy } from '../generated/test-api/options-proxy.gen';
|
|
41
|
+
import { useRuntimeConfig } from '../hooks/useRuntimeConfig';
|
|
42
|
+
import { useSigV4 } from '../hooks/useSigV4';
|
|
43
|
+
|
|
44
|
+
export const TestApiContext = createContext<TestApiOptionsProxy | undefined>(
|
|
45
|
+
undefined,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export const TestApiClientContext = createContext<TestApi | undefined>(
|
|
49
|
+
undefined,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const useCreateTestApiClient = (): TestApi => {
|
|
53
|
+
const runtimeConfig = useRuntimeConfig();
|
|
54
|
+
const apiUrl = runtimeConfig.apis.TestApi;
|
|
55
|
+
const sigv4Client = useSigV4();
|
|
56
|
+
return useMemo(
|
|
57
|
+
() =>
|
|
58
|
+
new TestApi({
|
|
59
|
+
url: apiUrl,
|
|
60
|
+
fetch: sigv4Client,
|
|
61
|
+
}),
|
|
62
|
+
[apiUrl, sigv4Client],
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const TestApiProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
67
|
+
const client = useCreateTestApiClient();
|
|
68
|
+
const optionsProxy = useMemo(
|
|
69
|
+
() => new TestApiOptionsProxy({ client }),
|
|
70
|
+
[client],
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<TestApiClientContext.Provider value={client}>
|
|
75
|
+
<TestApiContext.Provider value={optionsProxy}>
|
|
76
|
+
{children}
|
|
77
|
+
</TestApiContext.Provider>
|
|
78
|
+
</TestApiClientContext.Provider>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default TestApiProvider;
|
|
83
|
+
"
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
exports[`smithy#react-connection generator > with model project as target > should handle Cognito auth option > TestApiProvider-Cognito.tsx 1`] = `
|
|
87
|
+
"import { createContext, FC, PropsWithChildren, useMemo } from 'react';
|
|
88
|
+
import { TestApi } from '../generated/test-api/client.gen';
|
|
89
|
+
import { TestApiOptionsProxy } from '../generated/test-api/options-proxy.gen';
|
|
90
|
+
import { useRuntimeConfig } from '../hooks/useRuntimeConfig';
|
|
91
|
+
import { useAuth } from 'react-oidc-context';
|
|
92
|
+
|
|
93
|
+
export const TestApiContext = createContext<TestApiOptionsProxy | undefined>(
|
|
94
|
+
undefined,
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
export const TestApiClientContext = createContext<TestApi | undefined>(
|
|
98
|
+
undefined,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const useCreateTestApiClient = (): TestApi => {
|
|
102
|
+
const runtimeConfig = useRuntimeConfig();
|
|
103
|
+
const apiUrl = runtimeConfig.apis.TestApi;
|
|
104
|
+
const { user } = useAuth();
|
|
105
|
+
const cognitoClient: typeof fetch = (url, init) => {
|
|
106
|
+
const headers = { Authorization: \`Bearer \${user?.id_token}\` };
|
|
107
|
+
const existingHeaders = init?.headers;
|
|
108
|
+
|
|
109
|
+
return fetch(url, {
|
|
110
|
+
...init,
|
|
111
|
+
headers: !existingHeaders
|
|
112
|
+
? headers
|
|
113
|
+
: existingHeaders instanceof Headers
|
|
114
|
+
? (() => {
|
|
115
|
+
const h = new Headers(existingHeaders);
|
|
116
|
+
Object.entries(headers).forEach(([k, v]) => h.append(k, v));
|
|
117
|
+
return h;
|
|
118
|
+
})()
|
|
119
|
+
: Array.isArray(existingHeaders)
|
|
120
|
+
? [...existingHeaders, ...Object.entries(headers)]
|
|
121
|
+
: { ...existingHeaders, ...headers },
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
return useMemo(
|
|
125
|
+
() =>
|
|
126
|
+
new TestApi({
|
|
127
|
+
url: apiUrl,
|
|
128
|
+
fetch: cognitoClient,
|
|
129
|
+
}),
|
|
130
|
+
[apiUrl, cognitoClient],
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const TestApiProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
135
|
+
const client = useCreateTestApiClient();
|
|
136
|
+
const optionsProxy = useMemo(
|
|
137
|
+
() => new TestApiOptionsProxy({ client }),
|
|
138
|
+
[client],
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<TestApiClientContext.Provider value={client}>
|
|
143
|
+
<TestApiContext.Provider value={optionsProxy}>
|
|
144
|
+
{children}
|
|
145
|
+
</TestApiContext.Provider>
|
|
146
|
+
</TestApiClientContext.Provider>
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export default TestApiProvider;
|
|
151
|
+
"
|
|
152
|
+
`;
|
|
153
|
+
|
|
154
|
+
exports[`smithy#react-connection generator > with model project as target > should handle IAM auth option > TestApiProvider-IAM.tsx 1`] = `
|
|
155
|
+
"import { createContext, FC, PropsWithChildren, useMemo } from 'react';
|
|
156
|
+
import { TestApi } from '../generated/test-api/client.gen';
|
|
157
|
+
import { TestApiOptionsProxy } from '../generated/test-api/options-proxy.gen';
|
|
158
|
+
import { useRuntimeConfig } from '../hooks/useRuntimeConfig';
|
|
159
|
+
import { useSigV4 } from '../hooks/useSigV4';
|
|
160
|
+
|
|
161
|
+
export const TestApiContext = createContext<TestApiOptionsProxy | undefined>(
|
|
162
|
+
undefined,
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
export const TestApiClientContext = createContext<TestApi | undefined>(
|
|
166
|
+
undefined,
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const useCreateTestApiClient = (): TestApi => {
|
|
170
|
+
const runtimeConfig = useRuntimeConfig();
|
|
171
|
+
const apiUrl = runtimeConfig.apis.TestApi;
|
|
172
|
+
const sigv4Client = useSigV4();
|
|
173
|
+
return useMemo(
|
|
174
|
+
() =>
|
|
175
|
+
new TestApi({
|
|
176
|
+
url: apiUrl,
|
|
177
|
+
fetch: sigv4Client,
|
|
178
|
+
}),
|
|
179
|
+
[apiUrl, sigv4Client],
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const TestApiProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
184
|
+
const client = useCreateTestApiClient();
|
|
185
|
+
const optionsProxy = useMemo(
|
|
186
|
+
() => new TestApiOptionsProxy({ client }),
|
|
187
|
+
[client],
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<TestApiClientContext.Provider value={client}>
|
|
192
|
+
<TestApiContext.Provider value={optionsProxy}>
|
|
193
|
+
{children}
|
|
194
|
+
</TestApiContext.Provider>
|
|
195
|
+
</TestApiClientContext.Provider>
|
|
196
|
+
);
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export default TestApiProvider;
|
|
200
|
+
"
|
|
201
|
+
`;
|
|
202
|
+
|
|
203
|
+
exports[`smithy#react-connection generator > with model project as target > should handle None auth option > TestApiProvider-None.tsx 1`] = `
|
|
204
|
+
"import { createContext, FC, PropsWithChildren, useMemo } from 'react';
|
|
205
|
+
import { TestApi } from '../generated/test-api/client.gen';
|
|
206
|
+
import { TestApiOptionsProxy } from '../generated/test-api/options-proxy.gen';
|
|
207
|
+
import { useRuntimeConfig } from '../hooks/useRuntimeConfig';
|
|
208
|
+
|
|
209
|
+
export const TestApiContext = createContext<TestApiOptionsProxy | undefined>(
|
|
210
|
+
undefined,
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
export const TestApiClientContext = createContext<TestApi | undefined>(
|
|
214
|
+
undefined,
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
const useCreateTestApiClient = (): TestApi => {
|
|
218
|
+
const runtimeConfig = useRuntimeConfig();
|
|
219
|
+
const apiUrl = runtimeConfig.apis.TestApi;
|
|
220
|
+
return useMemo(
|
|
221
|
+
() =>
|
|
222
|
+
new TestApi({
|
|
223
|
+
url: apiUrl,
|
|
224
|
+
}),
|
|
225
|
+
[apiUrl],
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export const TestApiProvider: FC<PropsWithChildren> = ({ children }) => {
|
|
230
|
+
const client = useCreateTestApiClient();
|
|
231
|
+
const optionsProxy = useMemo(
|
|
232
|
+
() => new TestApiOptionsProxy({ client }),
|
|
233
|
+
[client],
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
return (
|
|
237
|
+
<TestApiClientContext.Provider value={client}>
|
|
238
|
+
<TestApiContext.Provider value={optionsProxy}>
|
|
239
|
+
{children}
|
|
240
|
+
</TestApiContext.Provider>
|
|
241
|
+
</TestApiClientContext.Provider>
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export default TestApiProvider;
|
|
246
|
+
"
|
|
247
|
+
`;
|
|
248
|
+
|
|
249
|
+
exports[`smithy#react-connection generator > with model project as target > should instrument providers in main.tsx > main.tsx 1`] = `
|
|
250
|
+
"import TestApiProvider from './components/TestApiProvider';
|
|
251
|
+
import QueryClientProvider from './components/QueryClientProvider';
|
|
252
|
+
import RuntimeConfigProvider from './components/RuntimeConfig';
|
|
253
|
+
|
|
254
|
+
import { RouterProvider } from '@tanstack/react-router';
|
|
255
|
+
|
|
256
|
+
const App = () => <RouterProvider router={router} />;
|
|
257
|
+
|
|
258
|
+
export function Main() {
|
|
259
|
+
return (
|
|
260
|
+
<RuntimeConfigProvider>
|
|
261
|
+
<QueryClientProvider>
|
|
262
|
+
<TestApiProvider>
|
|
263
|
+
<App />
|
|
264
|
+
</TestApiProvider>
|
|
265
|
+
</QueryClientProvider>
|
|
266
|
+
</RuntimeConfigProvider>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
"
|
|
270
|
+
`;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
$version: "2.0"
|
|
2
|
+
|
|
3
|
+
namespace <%- namespace %>
|
|
4
|
+
|
|
5
|
+
use smithy.openapi#specificationExtension
|
|
6
|
+
|
|
7
|
+
// This file contains traits which can apply certain OpenAPI vendor extensions to your operations
|
|
8
|
+
// This can be used to customise the client generated for calling your API
|
|
9
|
+
// If you do not need to customise the client, you can safely delete this file
|
|
10
|
+
|
|
11
|
+
/// Use this trait if you have an operation with an HTTP method typically associated with a mutation (PUT, POST, etc) but
|
|
12
|
+
/// wish for it to be considered as a query by the client
|
|
13
|
+
@trait
|
|
14
|
+
@specificationExtension
|
|
15
|
+
structure query {}
|
|
16
|
+
|
|
17
|
+
/// Use this trait if you have an operation with an HTTP method typically associated with a query (GET, HEAD, etc) but
|
|
18
|
+
/// wish for it to be considered as a mutation by the client
|
|
19
|
+
@trait
|
|
20
|
+
@specificationExtension
|
|
21
|
+
structure mutation {}
|
|
22
|
+
|
|
23
|
+
/// By default, operations which accept a parameter named "cursor" are treated as paginated by the client
|
|
24
|
+
/// Use this trait if you have an operation where the pagination cursor is named something other than "cursor"
|
|
25
|
+
@trait
|
|
26
|
+
@specificationExtension
|
|
27
|
+
structure cursor {
|
|
28
|
+
// Use inputToken to change the input parameter used for pagination
|
|
29
|
+
inputToken: String
|
|
30
|
+
// Set enabled to false if your operation defines an input named "cursor"
|
|
31
|
+
// but should not be treated as a paginated operation
|
|
32
|
+
enabled: Boolean
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
6
|
+
import { SmithyReactConnectionGeneratorSchema } from './schema';
|
|
7
|
+
import { NxGeneratorInfo } from '../../utils/nx';
|
|
8
|
+
export declare const SMITHY_REACT_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
export declare const smithyReactConnectionGenerator: (tree: Tree, options: SmithyReactConnectionGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
|
+
export default smithyReactConnectionGenerator;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.smithyReactConnectionGenerator = exports.SMITHY_REACT_CONNECTION_GENERATOR_INFO = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
*/
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
10
|
+
const nx_1 = require("../../utils/nx");
|
|
11
|
+
const metrics_1 = require("../../utils/metrics");
|
|
12
|
+
const format_1 = require("../../utils/format");
|
|
13
|
+
const generator_1 = require("../project/generator");
|
|
14
|
+
const generator_2 = require("../ts/api/generator");
|
|
15
|
+
const react_1 = require("../../utils/api-connection/open-api/react");
|
|
16
|
+
exports.SMITHY_REACT_CONNECTION_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
17
|
+
const smithyReactConnectionGenerator = (tree, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
var _a, _b, _c, _d;
|
|
19
|
+
const frontendProjectConfig = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.frontendProjectName);
|
|
20
|
+
const targetConfig = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.smithyModelOrBackendProjectName);
|
|
21
|
+
// Target could either be the model or backend project
|
|
22
|
+
const { modelProjectConfig, backendProjectConfig } = resolveProjectConfig(tree, targetConfig);
|
|
23
|
+
const backendMetadata = backendProjectConfig.metadata;
|
|
24
|
+
const apiName = backendMetadata === null || backendMetadata === void 0 ? void 0 : backendMetadata.apiName;
|
|
25
|
+
const auth = (_a = backendMetadata === null || backendMetadata === void 0 ? void 0 : backendMetadata.auth) !== null && _a !== void 0 ? _a : 'IAM';
|
|
26
|
+
const port = (_d = (_b = backendMetadata === null || backendMetadata === void 0 ? void 0 : backendMetadata.port) !== null && _b !== void 0 ? _b : (_c = backendMetadata === null || backendMetadata === void 0 ? void 0 : backendMetadata.ports) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : 3001;
|
|
27
|
+
const namespace = inferNamespace(tree, modelProjectConfig);
|
|
28
|
+
// Add extensions.smithy for customising the client
|
|
29
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'model'), modelProjectConfig.sourceRoot, {
|
|
30
|
+
namespace,
|
|
31
|
+
}, {
|
|
32
|
+
overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
|
|
33
|
+
});
|
|
34
|
+
yield (0, react_1.addOpenApiReactClient)(tree, {
|
|
35
|
+
apiName,
|
|
36
|
+
frontendProjectConfig,
|
|
37
|
+
backendProjectConfig,
|
|
38
|
+
specBuildProject: modelProjectConfig,
|
|
39
|
+
specPath: (0, devkit_1.joinPathFragments)('dist', modelProjectConfig.root, 'build', 'openapi', 'openapi.json'),
|
|
40
|
+
specBuildTargetName: `${modelProjectConfig.name}:build`,
|
|
41
|
+
auth,
|
|
42
|
+
port,
|
|
43
|
+
});
|
|
44
|
+
yield (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
|
|
45
|
+
exports.SMITHY_REACT_CONNECTION_GENERATOR_INFO,
|
|
46
|
+
]);
|
|
47
|
+
yield (0, format_1.formatFilesInSubtree)(tree);
|
|
48
|
+
return () => {
|
|
49
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
exports.smithyReactConnectionGenerator = smithyReactConnectionGenerator;
|
|
53
|
+
const resolveProjectConfig = (tree, modelOrBackendConfig) => {
|
|
54
|
+
var _a, _b, _c, _d, _e;
|
|
55
|
+
if (((_a = modelOrBackendConfig.metadata) !== null && _a !== void 0 ? _a : {}).generator ===
|
|
56
|
+
generator_1.SMITHY_PROJECT_GENERATOR_INFO.id) {
|
|
57
|
+
// It's the model project
|
|
58
|
+
const backendProjectName = ((_b = modelOrBackendConfig.metadata) !== null && _b !== void 0 ? _b : {})
|
|
59
|
+
.backendProject;
|
|
60
|
+
if (!backendProjectName) {
|
|
61
|
+
throw new Error(`Could not find associated backend for Smithy model project ${modelOrBackendConfig.name}`);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
modelProjectConfig: modelOrBackendConfig,
|
|
65
|
+
backendProjectConfig: (0, nx_1.readProjectConfigurationUnqualified)(tree, backendProjectName),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
else if (((_c = modelOrBackendConfig.metadata) !== null && _c !== void 0 ? _c : {}).generator ===
|
|
69
|
+
generator_2.TS_SMITHY_API_GENERATOR_INFO.id) {
|
|
70
|
+
// It's the backend project
|
|
71
|
+
const modelProjectName = ((_d = modelOrBackendConfig.metadata) !== null && _d !== void 0 ? _d : {})
|
|
72
|
+
.modelProject;
|
|
73
|
+
if (!modelProjectName) {
|
|
74
|
+
throw new Error(`Could not find associated model for Smithy backend project ${modelOrBackendConfig.name}`);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
modelProjectConfig: (0, nx_1.readProjectConfigurationUnqualified)(tree, ((_e = modelOrBackendConfig.metadata) !== null && _e !== void 0 ? _e : {}).modelProject),
|
|
78
|
+
backendProjectConfig: modelOrBackendConfig,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
throw new Error(`Unsupported api-connection target ${modelOrBackendConfig.name}. Expected a Smithy model or backend project.`);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Get the namespace from a model project
|
|
85
|
+
*/
|
|
86
|
+
const inferNamespace = (tree, modelProject) => {
|
|
87
|
+
const smithyBuildJsonPath = (0, devkit_1.joinPathFragments)(modelProject.root, 'smithy-build.json');
|
|
88
|
+
if (!tree.exists(smithyBuildJsonPath)) {
|
|
89
|
+
throw new Error(`No smithy-build.json file found for model project ${modelProject.name}`);
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const smithyBuild = JSON.parse(tree.read(smithyBuildJsonPath, 'utf-8'));
|
|
93
|
+
return smithyBuild.plugins.openapi.service.split('#')[0];
|
|
94
|
+
}
|
|
95
|
+
catch (_a) {
|
|
96
|
+
throw new Error(`Unable to determine namespace from ${smithyBuildJsonPath}. Expected plugins.openapi.service to be defined.`);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
exports.default = exports.smithyReactConnectionGenerator;
|
|
100
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/smithy/react-connection/generator.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAQoB;AAEpB,uCAIwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,oDAAqE;AACrE,mDAAmE;AACnE,qEAAkF;AAErE,QAAA,sCAAsC,GACjD,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,8BAA8B,GAAG,CAC5C,IAAU,EACV,OAA6C,EACjB,EAAE;;IAC9B,MAAM,qBAAqB,GAAG,IAAA,wCAAmC,EAC/D,IAAI,EACJ,OAAO,CAAC,mBAAmB,CAC5B,CAAC;IACF,MAAM,YAAY,GAAG,IAAA,wCAAmC,EACtD,IAAI,EACJ,OAAO,CAAC,+BAA+B,CACxC,CAAC;IAEF,sDAAsD;IACtD,MAAM,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,CACvE,IAAI,EACJ,YAAY,CACb,CAAC;IAEF,MAAM,eAAe,GAAG,oBAAoB,CAAC,QAAe,CAAC;IAC7D,MAAM,OAAO,GAAG,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,OAAO,CAAC;IACzC,MAAM,IAAI,GAAG,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,mCAAI,KAAK,CAAC;IAC5C,MAAM,IAAI,GAAG,MAAA,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,mCAAI,MAAA,eAAe,aAAf,eAA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QACH,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAC;QACxE,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IAAC,WAAM,CAAC;QACP,MAAM,IAAI,KAAK,CACb,sCAAsC,mBAAmB,mDAAmD,CAC7G,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAEF,kBAAe,sCAA8B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "smithy#react-connection",
|
|
4
|
+
"title": "smithy#react-connection",
|
|
5
|
+
"description": "Connects a react website to a Smithy API",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"frontendProjectName": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 0
|
|
14
|
+
},
|
|
15
|
+
"x-prompt": "React application's project name.",
|
|
16
|
+
"x-dropdown": "projects"
|
|
17
|
+
},
|
|
18
|
+
"smithyModelOrBackendProjectName": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "",
|
|
21
|
+
"x-prompt": "Project containing your Smithy API (either model or backend)",
|
|
22
|
+
"x-dropdown": "projects"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["frontendProjectName", "smithyModelOrBackendProjectName"]
|
|
26
|
+
}
|