diff --git a/examples/tests/sdk_tests/api/path_vars.w b/examples/tests/sdk_tests/api/path_vars.w new file mode 100644 index 00000000000..8544b0b0b13 --- /dev/null +++ b/examples/tests/sdk_tests/api/path_vars.w @@ -0,0 +1,64 @@ +bring cloud; +bring http; + +let api = new cloud.Api(); + + +let handler = inflight (req: cloud.ApiRequest): cloud.ApiResponse => { + return cloud.ApiResponse { + body: Json.stringify({ user: req.vars.get("name") }), + headers: { "content-type" => "application/json" }, + status: 200 + }; +}; + +let handler_two = inflight (req: cloud.ApiRequest): cloud.ApiResponse => { + return cloud.ApiResponse { + body: Json.stringify({ user: req.vars.get("name"), age: req.vars.get("age") }), + headers: { "content-type" => "application/json" }, + status: 200 + }; +}; + +api.get("/users/{name}", handler); +api.get("/{name}", handler); +api.get("/users/permission/{name}", handler); +api.get("/{name}/{age}", handler_two); + +test "test" { + let username = "tsuf"; + let res: http.Response = http.get("${api.url}/users/${username}"); + + + assert(res.status == 200); + assert(Json.parse(res.body ?? "").get("user") == username); +} + +test "test2" { + let username = "akhil"; + let res: http.Response = http.get("${api.url}/${username}"); + + + assert(res.status == 200); + assert(Json.parse(res.body ?? "").get("user") == username); +} + +test "test3" { + let username = "akhil"; + let res: http.Response = http.get("${api.url}/users/permission/${username}"); + + + assert(res.status == 200); + assert(Json.parse(res.body ?? "").get("user") == username); +} + +test "test4" { + let username = "akhil"; + let age = "23"; + let res: http.Response = http.get("${api.url}/${username}/${age}"); + + + assert(res.status == 200); + assert(Json.parse(res.body ?? "").get("user") == username); + assert(Json.parse(res.body ?? "").get("age") == age); +} diff --git a/examples/tests/valid/api_path_vars.w b/examples/tests/valid/api_path_vars.w deleted file mode 100644 index ea8c4c63273..00000000000 --- a/examples/tests/valid/api_path_vars.w +++ /dev/null @@ -1,25 +0,0 @@ -bring cloud; -bring http; - -let api = new cloud.Api(); - - -let handler = inflight (req: cloud.ApiRequest): cloud.ApiResponse => { - return cloud.ApiResponse { - body: Json.stringify({ user: req.vars.get("name") }), - headers: { "content-type" => "application/json" }, - status: 200 - }; -}; - -api.get("/users/{name}", handler); - - -test "test" { - let username = "tsuf"; - let res: http.Response = http.get("${api.url}/users/${username}"); - - - assert(res.status == 200); - assert(Json.parse(res.body ?? "").get("user") == username); -} diff --git a/examples/tests/valid/api_valid_path.w b/examples/tests/valid/api_valid_path.w index cdeeb6df8ff..8ea9a668d5e 100644 --- a/examples/tests/valid/api_valid_path.w +++ b/examples/tests/valid/api_valid_path.w @@ -40,7 +40,17 @@ testInvalidPath("/test/path/{unclosed"); testInvalidPath("/test/m{issplaced}"); testInvalidPath("/test/{misspla}ced"); testInvalidPath("/test/{}/empty"); - +testInvalidPath("/{sup:er/:annoying//path}"); +testInvalidPath("/{::another:annoying:path}"); +testInvalidPath("/n0t_alphanumer1cPa:th"); +testInvalidPath("/{with}/{two:invali4d#}/variables"); +testInvalidPath("/{unclosed"); +testInvalidPath("/m{issplaced}"); +testInvalidPath("/{misspla}ced"); +testInvalidPath("test"); +testInvalidPath("/{}/empty"); +testInvalidPath("/{}"); + // valid paths testValidPath("/test"); @@ -48,3 +58,9 @@ testValidPath("/test/alphanumer1cPa_th"); testValidPath("/test/regular/path"); testValidPath("/test/pa-th/{with}/two/{variable_s}/f?bla=5&b=6"); testValidPath("/test/param/is/{last}"); +testValidPath("/test/{param}"); +testValidPath("/{param}"); +testValidPath("/t/{param}"); +testValidPath("/test/regular/path/{param}"); +testValidPath("/test/segment1/{param1}/segment2?query1=value1?query2=value2"); +testValidPath("/test/segment1/segment2?query=value1&query2=value2"); diff --git a/libs/wingsdk/src/cloud/api.ts b/libs/wingsdk/src/cloud/api.ts index d1bd395f397..f839f51f7a7 100644 --- a/libs/wingsdk/src/cloud/api.ts +++ b/libs/wingsdk/src/cloud/api.ts @@ -172,7 +172,11 @@ export abstract class Api extends Resource { * @internal */ protected _validatePath(path: string) { - if (!/^([^\{\}\:\n]|.+\/\{\w+\}(\/|$))*$/g.test(path)) { + if ( + !/^(\/[a-zA-Z0-9_\-]+(\/\{[a-zA-Z0-9_\-]+\}|\/[a-zA-Z0-9_\-]+)*(?:\?[^#]*)?)?$|^(\/\{[a-zA-Z0-9_\-]+\})*\/?$/g.test( + path + ) + ) { throw new Error( `Invalid path ${path}. Url cannot contain ":", params contains only alpha-numeric chars or "_".` ); diff --git a/libs/wingsdk/test/target-sim/__snapshots__/api.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/api.test.ts.snap index b5fb8f6d08e..66c8ee9c55d 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/api.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/api.test.ts.snap @@ -1266,6 +1266,410 @@ return class Handler { } `; +exports[`api with 'name' & 'age' parameter 1`] = ` +[ + "wingsdk.cloud.TestRunner created.", + "wingsdk.cloud.Function created.", + "Server listening on http://127.0.0.1:", + "wingsdk.cloud.Api created.", + "wingsdk.sim.EventMapping created.", + "Processing \\"GET /{name}/{age}\\" params={\\"name\\":\\"akhil\\",\\"age\\":\\"23\\"}).", + "Invoke (payload={\\"headers\\":{\\"host\\":\\"127.0.0.1:\\",\\"connection\\":\\"keep-alive\\",\\"accept\\":\\"*/*\\",\\"accept-language\\":\\"*\\",\\"sec-fetch-mode\\":\\"cors\\",\\"user-agent\\":\\"undici\\",\\"accept-encoding\\":\\"gzip, deflate\\"},\\"body\\":\\"\\",\\"method\\":\\"GET\\",\\"path\\":\\"/akhil/23\\",\\"query\\":{},\\"vars\\":{\\"name\\":\\"akhil\\",\\"age\\":\\"23\\"}}).", + "GET /{name}/{age} - 200.", + "wingsdk.sim.EventMapping deleted.", + "Closing server on http://127.0.0.1:", + "wingsdk.cloud.Api deleted.", + "wingsdk.cloud.Function deleted.", + "wingsdk.cloud.TestRunner deleted.", +] +`; + +exports[`api with 'name' & 'age' parameter 2`] = ` +{ + ".wing/onrequesthandler-e645076f_c887c38c.js": "exports.handler = async function(event) { + return await (new ((function(){ +return class Handler { + constructor(clients) { + for (const [name, client] of Object.entries(clients)) { + this[name] = client; + } + } + async handle(req) { return { status: 200, body: req.vars ?? {} }; } +}; +})())({ + +})).handle(event); +};", + "connections.json": { + "connections": [ + { + "name": "get()", + "source": "root/my_api", + "target": "root/my_api/OnRequestHandler-e645076f", + }, + ], + "version": "connections-0.1", + }, + "simulator.json": { + "resources": [ + { + "attrs": {}, + "path": "root/cloud.TestRunner", + "props": { + "tests": {}, + }, + "type": "wingsdk.cloud.TestRunner", + }, + { + "attrs": {}, + "path": "root/my_api/OnRequestHandler-e645076f", + "props": { + "environmentVariables": {}, + "sourceCodeFile": ".wing/onrequesthandler-e645076f_c887c38c.js", + "sourceCodeLanguage": "javascript", + "timeout": 60000, + }, + "type": "wingsdk.cloud.Function", + }, + { + "attrs": {}, + "path": "root/my_api", + "props": { + "openApiSpec": { + "openapi": "3.0.3", + "paths": { + "/{name}/{age}": { + "get": { + "operationId": "get-{name}/{age}", + "parameters": [ + { + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string", + }, + }, + { + "in": "path", + "name": "age", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "responses": { + "200": { + "content": {}, + "description": "200 response", + }, + }, + }, + }, + }, + }, + }, + "type": "wingsdk.cloud.Api", + }, + { + "attrs": {}, + "path": "root/my_api/ApiEventMapping-e645076f", + "props": { + "publisher": "\${root/my_api#attrs.handle}", + "subscriber": "\${root/my_api/OnRequestHandler-e645076f#attrs.handle}", + "subscriptionProps": { + "routes": [ + { + "method": "GET", + "path": "/{name}/{age}", + }, + ], + }, + }, + "type": "wingsdk.sim.EventMapping", + }, + ], + "sdkVersion": "0.0.0", + }, + "tree.json": { + "tree": { + "children": { + "Handler": { + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "description": "An inflight resource", + "hidden": true, + "title": "Inflight", + }, + "id": "Handler", + "path": "root/Handler", + }, + "cloud.TestRunner": { + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "description": "A suite of APIs for running tests and collecting results.", + "hidden": true, + "title": "TestRunner", + }, + "id": "cloud.TestRunner", + "path": "root/cloud.TestRunner", + }, + "my_api": { + "children": { + "ApiEventMapping-e645076f": { + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "hidden": true, + }, + "id": "ApiEventMapping-e645076f", + "path": "root/my_api/ApiEventMapping-e645076f", + }, + "OnRequestHandler-e645076f": { + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "description": "A cloud function (FaaS)", + "sourceModule": "@winglang/sdk", + "title": "get()", + }, + "id": "OnRequestHandler-e645076f", + "path": "root/my_api/OnRequestHandler-e645076f", + }, + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "description": "A REST API endpoint", + "title": "Api", + }, + "id": "my_api", + "path": "root/my_api", + }, + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "id": "root", + "path": "root", + }, + "version": "tree-0.1", + }, +} +`; + +exports[`api with 'name' parameter 1`] = ` +[ + "wingsdk.cloud.TestRunner created.", + "wingsdk.cloud.Function created.", + "Server listening on http://127.0.0.1:", + "wingsdk.cloud.Api created.", + "wingsdk.sim.EventMapping created.", + "Processing \\"GET /{name}\\" params={\\"name\\":\\"akhil\\"}).", + "Invoke (payload={\\"headers\\":{\\"host\\":\\"127.0.0.1:\\",\\"connection\\":\\"keep-alive\\",\\"accept\\":\\"*/*\\",\\"accept-language\\":\\"*\\",\\"sec-fetch-mode\\":\\"cors\\",\\"user-agent\\":\\"undici\\",\\"accept-encoding\\":\\"gzip, deflate\\"},\\"body\\":\\"\\",\\"method\\":\\"GET\\",\\"path\\":\\"/akhil\\",\\"query\\":{},\\"vars\\":{\\"name\\":\\"akhil\\"}}).", + "GET /{name} - 200.", + "wingsdk.sim.EventMapping deleted.", + "Closing server on http://127.0.0.1:", + "wingsdk.cloud.Api deleted.", + "wingsdk.cloud.Function deleted.", + "wingsdk.cloud.TestRunner deleted.", +] +`; + +exports[`api with 'name' parameter 2`] = ` +{ + ".wing/onrequesthandler-e645076f_c887c38c.js": "exports.handler = async function(event) { + return await (new ((function(){ +return class Handler { + constructor(clients) { + for (const [name, client] of Object.entries(clients)) { + this[name] = client; + } + } + async handle(req) { return { status: 200, body: req.vars ?? {} }; } +}; +})())({ + +})).handle(event); +};", + "connections.json": { + "connections": [ + { + "name": "get()", + "source": "root/my_api", + "target": "root/my_api/OnRequestHandler-e645076f", + }, + ], + "version": "connections-0.1", + }, + "simulator.json": { + "resources": [ + { + "attrs": {}, + "path": "root/cloud.TestRunner", + "props": { + "tests": {}, + }, + "type": "wingsdk.cloud.TestRunner", + }, + { + "attrs": {}, + "path": "root/my_api/OnRequestHandler-e645076f", + "props": { + "environmentVariables": {}, + "sourceCodeFile": ".wing/onrequesthandler-e645076f_c887c38c.js", + "sourceCodeLanguage": "javascript", + "timeout": 60000, + }, + "type": "wingsdk.cloud.Function", + }, + { + "attrs": {}, + "path": "root/my_api", + "props": { + "openApiSpec": { + "openapi": "3.0.3", + "paths": { + "/{name}": { + "get": { + "operationId": "get-{name}", + "parameters": [ + { + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "responses": { + "200": { + "content": {}, + "description": "200 response", + }, + }, + }, + }, + }, + }, + }, + "type": "wingsdk.cloud.Api", + }, + { + "attrs": {}, + "path": "root/my_api/ApiEventMapping-e645076f", + "props": { + "publisher": "\${root/my_api#attrs.handle}", + "subscriber": "\${root/my_api/OnRequestHandler-e645076f#attrs.handle}", + "subscriptionProps": { + "routes": [ + { + "method": "GET", + "path": "/{name}", + }, + ], + }, + }, + "type": "wingsdk.sim.EventMapping", + }, + ], + "sdkVersion": "0.0.0", + }, + "tree.json": { + "tree": { + "children": { + "Handler": { + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "description": "An inflight resource", + "hidden": true, + "title": "Inflight", + }, + "id": "Handler", + "path": "root/Handler", + }, + "cloud.TestRunner": { + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "description": "A suite of APIs for running tests and collecting results.", + "hidden": true, + "title": "TestRunner", + }, + "id": "cloud.TestRunner", + "path": "root/cloud.TestRunner", + }, + "my_api": { + "children": { + "ApiEventMapping-e645076f": { + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "hidden": true, + }, + "id": "ApiEventMapping-e645076f", + "path": "root/my_api/ApiEventMapping-e645076f", + }, + "OnRequestHandler-e645076f": { + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "description": "A cloud function (FaaS)", + "sourceModule": "@winglang/sdk", + "title": "get()", + }, + "id": "OnRequestHandler-e645076f", + "path": "root/my_api/OnRequestHandler-e645076f", + }, + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "display": { + "description": "A REST API endpoint", + "title": "Api", + }, + "id": "my_api", + "path": "root/my_api", + }, + }, + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.2.69", + }, + "id": "root", + "path": "root", + }, + "version": "tree-0.1", + }, +} +`; + exports[`api with multiple GET routes and one lambda 1`] = ` { ".wing/onrequesthandler-e645076f_c887c38c.js": "exports.handler = async function(event) { diff --git a/libs/wingsdk/test/target-sim/api.test.ts b/libs/wingsdk/test/target-sim/api.test.ts index c57cd5d295a..daccf9da22f 100644 --- a/libs/wingsdk/test/target-sim/api.test.ts +++ b/libs/wingsdk/test/target-sim/api.test.ts @@ -104,6 +104,62 @@ test("api with one GET route with request params", async () => { expect(app.snapshot()).toMatchSnapshot(); }); +test("api with 'name' parameter", async () => { + // GIVEN + const ROUTE = "/{name}"; + + const app = new SimApp(); + const api = cloud.Api._newApi(app, "my_api"); + const inflight = Testing.makeHandler( + app, + "Handler", + INFLIGHT_CODE_ECHO_PARAMS + ); + api.get(ROUTE, inflight); + + // WHEN + const s = await app.startSimulator(); + const apiUrl = getApiUrl(s, "/my_api"); + const response = await fetch(`${apiUrl}/akhil`, { method: "GET" }); + + // THEN + await s.stop(); + + expect(response.status).toEqual(200); + expect(await response.json()).toEqual({ name: "akhil" }); + + expect(listMessages(s)).toMatchSnapshot(); + expect(app.snapshot()).toMatchSnapshot(); +}); + +test("api with 'name' & 'age' parameter", async () => { + // GIVEN + const ROUTE = "/{name}/{age}"; + + const app = new SimApp(); + const api = cloud.Api._newApi(app, "my_api"); + const inflight = Testing.makeHandler( + app, + "Handler", + INFLIGHT_CODE_ECHO_PARAMS + ); + api.get(ROUTE, inflight); + + // WHEN + const s = await app.startSimulator(); + const apiUrl = getApiUrl(s, "/my_api"); + const response = await fetch(`${apiUrl}/akhil/23`, { method: "GET" }); + + // THEN + await s.stop(); + + expect(response.status).toEqual(200); + expect(await response.json()).toEqual({ name: "akhil", age: "23" }); + + expect(listMessages(s)).toMatchSnapshot(); + expect(app.snapshot()).toMatchSnapshot(); +}); + test("api with multiple GET routes and one lambda", () => { // GIVEN const app = new SimApp(); diff --git a/libs/wingsdk/test/target-tf-aws/__snapshots__/api.test.ts.snap b/libs/wingsdk/test/target-tf-aws/__snapshots__/api.test.ts.snap index db5970b4911..3dd2d4d766d 100644 --- a/libs/wingsdk/test/target-tf-aws/__snapshots__/api.test.ts.snap +++ b/libs/wingsdk/test/target-tf-aws/__snapshots__/api.test.ts.snap @@ -1,5 +1,169 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html +exports[`api with 'name' & 'age' parameter 1`] = ` +{ + "openapi": "3.0.3", + "paths": { + "/{name}/{age}": { + "get": { + "operationId": "get-{name}/{age}", + "parameters": [ + { + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string", + }, + }, + { + "in": "path", + "name": "age", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "responses": { + "200": { + "content": {}, + "description": "200 response", + }, + }, + "x-amazon-apigateway-integration": { + "contentHandling": "CONVERT_TO_TEXT", + "httpMethod": "POST", + "passthroughBehavior": "when_no_match", + "responses": { + "default": { + "statusCode": "200", + }, + }, + "type": "aws_proxy", + "uri": "arn:aws:apigateway:\${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/\${aws_lambda_function.Api_Api-OnRequest-c5395e41_37F21C2B.arn}/invocations", + }, + }, + }, + "/{proxy+}": { + "x-amazon-apigateway-any-method": { + "consumes": [ + "application/json", + ], + "produces": [ + "application/json", + ], + "responses": { + "404": { + "description": "404 response", + "headers": { + "Content-Type": { + "type": "string", + }, + }, + }, + }, + "x-amazon-apigateway-integration": { + "requestTemplates": { + "application/json": "{\\"statusCode\\": 404}", + }, + "responses": { + "default": { + "responseParameters": { + "method.response.header.Content-Type": "'application/json'", + }, + "responseTemplates": { + "application/json": "{\\"statusCode: 404, \\"message\\": \\"Error: Resource not found\\"}", + }, + "statusCode": "404", + }, + }, + "type": "mock", + }, + }, + }, + }, +} +`; + +exports[`api with 'name' parameter 1`] = ` +{ + "openapi": "3.0.3", + "paths": { + "/{name}": { + "get": { + "operationId": "get-{name}", + "parameters": [ + { + "in": "path", + "name": "name", + "required": true, + "schema": { + "type": "string", + }, + }, + ], + "responses": { + "200": { + "content": {}, + "description": "200 response", + }, + }, + "x-amazon-apigateway-integration": { + "contentHandling": "CONVERT_TO_TEXT", + "httpMethod": "POST", + "passthroughBehavior": "when_no_match", + "responses": { + "default": { + "statusCode": "200", + }, + }, + "type": "aws_proxy", + "uri": "arn:aws:apigateway:\${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/\${aws_lambda_function.Api_Api-OnRequest-c5395e41_37F21C2B.arn}/invocations", + }, + }, + }, + "/{proxy+}": { + "x-amazon-apigateway-any-method": { + "consumes": [ + "application/json", + ], + "produces": [ + "application/json", + ], + "responses": { + "404": { + "description": "404 response", + "headers": { + "Content-Type": { + "type": "string", + }, + }, + }, + }, + "x-amazon-apigateway-integration": { + "requestTemplates": { + "application/json": "{\\"statusCode\\": 404}", + }, + "responses": { + "default": { + "responseParameters": { + "method.response.header.Content-Type": "'application/json'", + }, + "responseTemplates": { + "application/json": "{\\"statusCode: 404, \\"message\\": \\"Error: Resource not found\\"}", + }, + "statusCode": "404", + }, + }, + "type": "mock", + }, + }, + }, + }, +} +`; + exports[`api with CONNECT route 1`] = ` { "openapi": "3.0.3", diff --git a/libs/wingsdk/test/target-tf-aws/api.test.ts b/libs/wingsdk/test/target-tf-aws/api.test.ts index 5a362fb1ee5..97556cfe2d3 100644 --- a/libs/wingsdk/test/target-tf-aws/api.test.ts +++ b/libs/wingsdk/test/target-tf-aws/api.test.ts @@ -164,6 +164,40 @@ test("api with path parameter", () => { expect(extractApiSpec(output)).toMatchSnapshot(); }); +test("api with 'name' parameter", () => { + // GIVEN + const app = new tfaws.App({ outdir: mkdtemp() }); + const api = new Api(app, "Api"); + + const inflight = Testing.makeHandler(app, "Handler", INFLIGHT_CODE); + + api.get("/{name}", inflight); + + const output = app.synth(); + + // THEN + expect(tfResourcesOfCount(output, "aws_api_gateway_rest_api")).toEqual(1); + expect(tfResourcesOfCount(output, "aws_lambda_function")).toEqual(1); + expect(extractApiSpec(output)).toMatchSnapshot(); +}); + +test("api with 'name' & 'age' parameter", () => { + // GIVEN + const app = new tfaws.App({ outdir: mkdtemp() }); + const api = new Api(app, "Api"); + + const inflight = Testing.makeHandler(app, "Handler", INFLIGHT_CODE); + + api.get("/{name}/{age}", inflight); + + const output = app.synth(); + + // THEN + expect(tfResourcesOfCount(output, "aws_api_gateway_rest_api")).toEqual(1); + expect(tfResourcesOfCount(output, "aws_lambda_function")).toEqual(1); + expect(extractApiSpec(output)).toMatchSnapshot(); +}); + test("api with POST route", () => { // GIVEN const app = new tfaws.App({ outdir: mkdtemp() }); diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/path_vars.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/path_vars.w_compile_tf-aws.md new file mode 100644 index 00000000000..77922c0d393 --- /dev/null +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/path_vars.w_compile_tf-aws.md @@ -0,0 +1,929 @@ +# [path_vars.w](../../../../../../examples/tests/sdk_tests/api/path_vars.w) | compile | tf-aws + +## inflight.$Closure1-1.js +```js +module.exports = function({ $std_Json }) { + class $Closure1 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle(req) { + return ({"body": ((args) => { return JSON.stringify(args[0], null, args[1]?.indent) })([({"user": (req.vars)["name"]})]),"headers": ({"content-type": "application/json"}),"status": 200}); + } + } + return $Closure1; +} + +``` + +## inflight.$Closure2-1.js +```js +module.exports = function({ $std_Json }) { + class $Closure2 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle(req) { + return ({"body": ((args) => { return JSON.stringify(args[0], null, args[1]?.indent) })([({"user": (req.vars)["name"],"age": (req.vars)["age"]})]),"headers": ({"content-type": "application/json"}),"status": 200}); + } + } + return $Closure2; +} + +``` + +## inflight.$Closure3-1.js +```js +module.exports = function({ $api_url, $http_Util, $std_Json }) { + class $Closure3 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const username = "tsuf"; + const res = (await $http_Util.get(String.raw({ raw: ["", "/users/", ""] }, $api_url, username))); + {((cond) => {if (!cond) throw new Error("assertion failed: res.status == 200")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(res.status,200)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"user\") == username")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["user"],username)))}; + } + } + return $Closure3; +} + +``` + +## inflight.$Closure4-1.js +```js +module.exports = function({ $api_url, $http_Util, $std_Json }) { + class $Closure4 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const username = "akhil"; + const res = (await $http_Util.get(String.raw({ raw: ["", "/", ""] }, $api_url, username))); + {((cond) => {if (!cond) throw new Error("assertion failed: res.status == 200")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(res.status,200)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"user\") == username")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["user"],username)))}; + } + } + return $Closure4; +} + +``` + +## inflight.$Closure5-1.js +```js +module.exports = function({ $api_url, $http_Util, $std_Json }) { + class $Closure5 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const username = "akhil"; + const res = (await $http_Util.get(String.raw({ raw: ["", "/users/permission/", ""] }, $api_url, username))); + {((cond) => {if (!cond) throw new Error("assertion failed: res.status == 200")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(res.status,200)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"user\") == username")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["user"],username)))}; + } + } + return $Closure5; +} + +``` + +## inflight.$Closure6-1.js +```js +module.exports = function({ $api_url, $http_Util, $std_Json }) { + class $Closure6 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const username = "akhil"; + const age = "23"; + const res = (await $http_Util.get(String.raw({ raw: ["", "/", "/", ""] }, $api_url, username, age))); + {((cond) => {if (!cond) throw new Error("assertion failed: res.status == 200")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(res.status,200)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"user\") == username")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["user"],username)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"age\") == age")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["age"],age)))}; + } + } + return $Closure6; +} + +``` + +## main.tf.json +```json +{ + "//": { + "metadata": { + "backend": "local", + "stackName": "root", + "version": "0.17.0" + }, + "outputs": { + "root": { + "Default": { + "cloud.TestRunner": { + "TestFunctionArns": "WING_TEST_RUNNER_FUNCTION_ARNS" + } + } + } + } + }, + "data": { + "aws_region": { + "Region": { + "//": { + "metadata": { + "path": "root/Default/Region", + "uniqueId": "Region" + } + } + } + } + }, + "output": { + "WING_TEST_RUNNER_FUNCTION_ARNS": { + "value": "[[\"root/Default/Default/test:test\",\"${aws_lambda_function.testtest_Handler_295107CC.arn}\"],[\"root/Default/Default/test:test2\",\"${aws_lambda_function.testtest2_Handler_EB79E487.arn}\"],[\"root/Default/Default/test:test3\",\"${aws_lambda_function.testtest3_Handler_A2A8E3A1.arn}\"],[\"root/Default/Default/test:test4\",\"${aws_lambda_function.testtest4_Handler_4B54514B.arn}\"]]" + } + }, + "provider": { + "aws": [ + {} + ] + }, + "resource": { + "aws_api_gateway_deployment": { + "cloudApi_api_deployment_545514BF": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/deployment", + "uniqueId": "cloudApi_api_deployment_545514BF" + } + }, + "lifecycle": { + "create_before_destroy": true + }, + "rest_api_id": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.id}", + "triggers": { + "redeployment": "${sha256(aws_api_gateway_rest_api.cloudApi_api_2B334D75.body)}" + } + } + }, + "aws_api_gateway_rest_api": { + "cloudApi_api_2B334D75": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/api", + "uniqueId": "cloudApi_api_2B334D75" + } + }, + "body": "{\"openapi\":\"3.0.3\",\"paths\":{\"/users/{name}\":{\"get\":{\"operationId\":\"get-users/{name}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{name}\":{\"get\":{\"operationId\":\"get-{name}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/users/permission/{name}\":{\"get\":{\"operationId\":\"get-users/permission/{name}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{name}/{age}\":{\"get\":{\"operationId\":\"get-{name}/{age}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}},{\"name\":\"age\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-86898773_701F5CA7.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{proxy+}\":{\"x-amazon-apigateway-any-method\":{\"produces\":[\"application/json\"],\"consumes\":[\"application/json\"],\"x-amazon-apigateway-integration\":{\"type\":\"mock\",\"requestTemplates\":{\"application/json\":\"{\\\"statusCode\\\": 404}\"},\"responses\":{\"default\":{\"statusCode\":\"404\",\"responseParameters\":{\"method.response.header.Content-Type\":\"'application/json'\"},\"responseTemplates\":{\"application/json\":\"{\\\"statusCode: 404, \\\"message\\\": \\\"Error: Resource not found\\\"}\"}}}},\"responses\":{\"404\":{\"description\":\"404 response\",\"headers\":{\"Content-Type\":{\"type\":\"string\"}}}}}}}}", + "name": "api-c895068c" + } + }, + "aws_api_gateway_stage": { + "cloudApi_api_stage_BBB283E4": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/stage", + "uniqueId": "cloudApi_api_stage_BBB283E4" + } + }, + "deployment_id": "${aws_api_gateway_deployment.cloudApi_api_deployment_545514BF.id}", + "rest_api_id": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.id}", + "stage_name": "prod" + } + }, + "aws_iam_role": { + "cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/IamRole", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + }, + "cloudApi_cloudApi-OnRequest-cdafee6e_IamRole_4382C442": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-cdafee6e/IamRole", + "uniqueId": "cloudApi_cloudApi-OnRequest-cdafee6e_IamRole_4382C442" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + }, + "testtest2_Handler_IamRole_9304BBE5": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/IamRole", + "uniqueId": "testtest2_Handler_IamRole_9304BBE5" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + }, + "testtest3_Handler_IamRole_6E5F9CB2": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/IamRole", + "uniqueId": "testtest3_Handler_IamRole_6E5F9CB2" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + }, + "testtest4_Handler_IamRole_F3E77BF2": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/IamRole", + "uniqueId": "testtest4_Handler_IamRole_F3E77BF2" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + }, + "testtest_Handler_IamRole_15693C93": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test/Handler/IamRole", + "uniqueId": "testtest_Handler_IamRole_15693C93" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + } + }, + "aws_iam_role_policy": { + "cloudApi_cloudApi-OnRequest-86898773_IamRolePolicy_DAC639E5": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/IamRolePolicy", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_IamRolePolicy_DAC639E5" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F.name}" + }, + "cloudApi_cloudApi-OnRequest-cdafee6e_IamRolePolicy_8BF9C89F": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-cdafee6e/IamRolePolicy", + "uniqueId": "cloudApi_cloudApi-OnRequest-cdafee6e_IamRolePolicy_8BF9C89F" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-cdafee6e_IamRole_4382C442.name}" + }, + "testtest2_Handler_IamRolePolicy_77807769": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/IamRolePolicy", + "uniqueId": "testtest2_Handler_IamRolePolicy_77807769" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.testtest2_Handler_IamRole_9304BBE5.name}" + }, + "testtest3_Handler_IamRolePolicy_CD8584B9": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/IamRolePolicy", + "uniqueId": "testtest3_Handler_IamRolePolicy_CD8584B9" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.testtest3_Handler_IamRole_6E5F9CB2.name}" + }, + "testtest4_Handler_IamRolePolicy_92DB0F08": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/IamRolePolicy", + "uniqueId": "testtest4_Handler_IamRolePolicy_92DB0F08" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.testtest4_Handler_IamRole_F3E77BF2.name}" + }, + "testtest_Handler_IamRolePolicy_AF0279BD": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test/Handler/IamRolePolicy", + "uniqueId": "testtest_Handler_IamRolePolicy_AF0279BD" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.testtest_Handler_IamRole_15693C93.name}" + } + }, + "aws_iam_role_policy_attachment": { + "cloudApi_cloudApi-OnRequest-86898773_IamRolePolicyAttachment_6E485A17": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/IamRolePolicyAttachment", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_IamRolePolicyAttachment_6E485A17" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F.name}" + }, + "cloudApi_cloudApi-OnRequest-cdafee6e_IamRolePolicyAttachment_5383D6A2": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-cdafee6e/IamRolePolicyAttachment", + "uniqueId": "cloudApi_cloudApi-OnRequest-cdafee6e_IamRolePolicyAttachment_5383D6A2" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-cdafee6e_IamRole_4382C442.name}" + }, + "testtest2_Handler_IamRolePolicyAttachment_57665B6F": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/IamRolePolicyAttachment", + "uniqueId": "testtest2_Handler_IamRolePolicyAttachment_57665B6F" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.testtest2_Handler_IamRole_9304BBE5.name}" + }, + "testtest3_Handler_IamRolePolicyAttachment_EA1CC147": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/IamRolePolicyAttachment", + "uniqueId": "testtest3_Handler_IamRolePolicyAttachment_EA1CC147" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.testtest3_Handler_IamRole_6E5F9CB2.name}" + }, + "testtest4_Handler_IamRolePolicyAttachment_AC735E44": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/IamRolePolicyAttachment", + "uniqueId": "testtest4_Handler_IamRolePolicyAttachment_AC735E44" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.testtest4_Handler_IamRole_F3E77BF2.name}" + }, + "testtest_Handler_IamRolePolicyAttachment_ADF4752D": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test/Handler/IamRolePolicyAttachment", + "uniqueId": "testtest_Handler_IamRolePolicyAttachment_ADF4752D" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.testtest_Handler_IamRole_15693C93.name}" + } + }, + "aws_lambda_function": { + "cloudApi_cloudApi-OnRequest-86898773_701F5CA7": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/Default", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_701F5CA7" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "cloud-Api-OnRequest-86898773-c8ed6547", + "WING_TARGET": "tf-aws" + } + }, + "function_name": "cloud-Api-OnRequest-86898773-c8ed6547", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.cloudApi_cloudApi-OnRequest-86898773_S3Object_12D28469.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + }, + "cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-cdafee6e/Default", + "uniqueId": "cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "cloud-Api-OnRequest-cdafee6e-c8147384", + "WING_TARGET": "tf-aws" + } + }, + "function_name": "cloud-Api-OnRequest-cdafee6e-c8147384", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-cdafee6e_IamRole_4382C442.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.cloudApi_cloudApi-OnRequest-cdafee6e_S3Object_5DAAA0EF.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + }, + "testtest2_Handler_EB79E487": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/Default", + "uniqueId": "testtest2_Handler_EB79E487" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "Handler-c89fe587", + "WING_TARGET": "tf-aws", + "WING_TOKEN_TFTOKEN_TOKEN_8": "${jsonencode(aws_api_gateway_stage.cloudApi_api_stage_BBB283E4.invoke_url)}" + } + }, + "function_name": "Handler-c89fe587", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.testtest2_Handler_IamRole_9304BBE5.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.testtest2_Handler_S3Object_21FCD712.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + }, + "testtest3_Handler_A2A8E3A1": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/Default", + "uniqueId": "testtest3_Handler_A2A8E3A1" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "Handler-c8445457", + "WING_TARGET": "tf-aws", + "WING_TOKEN_TFTOKEN_TOKEN_8": "${jsonencode(aws_api_gateway_stage.cloudApi_api_stage_BBB283E4.invoke_url)}" + } + }, + "function_name": "Handler-c8445457", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.testtest3_Handler_IamRole_6E5F9CB2.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.testtest3_Handler_S3Object_417A3842.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + }, + "testtest4_Handler_4B54514B": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/Default", + "uniqueId": "testtest4_Handler_4B54514B" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "Handler-c82aef8d", + "WING_TARGET": "tf-aws", + "WING_TOKEN_TFTOKEN_TOKEN_8": "${jsonencode(aws_api_gateway_stage.cloudApi_api_stage_BBB283E4.invoke_url)}" + } + }, + "function_name": "Handler-c82aef8d", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.testtest4_Handler_IamRole_F3E77BF2.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.testtest4_Handler_S3Object_7A3CDC0E.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + }, + "testtest_Handler_295107CC": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test/Handler/Default", + "uniqueId": "testtest_Handler_295107CC" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "Handler-c8f4f2a1", + "WING_TARGET": "tf-aws", + "WING_TOKEN_TFTOKEN_TOKEN_8": "${jsonencode(aws_api_gateway_stage.cloudApi_api_stage_BBB283E4.invoke_url)}" + } + }, + "function_name": "Handler-c8f4f2a1", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.testtest_Handler_IamRole_15693C93.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.testtest_Handler_S3Object_9F4E28A7.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + } + }, + "aws_lambda_permission": { + "cloudApi_api_permission-GET-2e836e2d_1D868589": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-2e836e2d", + "uniqueId": "cloudApi_api_permission-GET-2e836e2d_1D868589" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/users/permission/{name}", + "statement_id": "AllowExecutionFromAPIGateway-GET-2e836e2d" + }, + "cloudApi_api_permission-GET-9f89597e_FFBE5338": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-9f89597e", + "uniqueId": "cloudApi_api_permission-GET-9f89597e_FFBE5338" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/users/{name}", + "statement_id": "AllowExecutionFromAPIGateway-GET-9f89597e" + }, + "cloudApi_api_permission-GET-da43a2f2_1CE7916D": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-da43a2f2", + "uniqueId": "cloudApi_api_permission-GET-da43a2f2_1CE7916D" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/{name}", + "statement_id": "AllowExecutionFromAPIGateway-GET-da43a2f2" + }, + "cloudApi_api_permission-GET-e6c024e8_94CCF201": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-e6c024e8", + "uniqueId": "cloudApi_api_permission-GET-e6c024e8_94CCF201" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-86898773_701F5CA7.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/{name}/{age}", + "statement_id": "AllowExecutionFromAPIGateway-GET-e6c024e8" + } + }, + "aws_s3_bucket": { + "Code": { + "//": { + "metadata": { + "path": "root/Default/Code", + "uniqueId": "Code" + } + }, + "bucket_prefix": "code-c84a50b1-" + } + }, + "aws_s3_object": { + "cloudApi_cloudApi-OnRequest-86898773_S3Object_12D28469": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/S3Object", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_S3Object_12D28469" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + }, + "cloudApi_cloudApi-OnRequest-cdafee6e_S3Object_5DAAA0EF": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-cdafee6e/S3Object", + "uniqueId": "cloudApi_cloudApi-OnRequest-cdafee6e_S3Object_5DAAA0EF" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + }, + "testtest2_Handler_S3Object_21FCD712": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/S3Object", + "uniqueId": "testtest2_Handler_S3Object_21FCD712" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + }, + "testtest3_Handler_S3Object_417A3842": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/S3Object", + "uniqueId": "testtest3_Handler_S3Object_417A3842" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + }, + "testtest4_Handler_S3Object_7A3CDC0E": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/S3Object", + "uniqueId": "testtest4_Handler_S3Object_7A3CDC0E" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + }, + "testtest_Handler_S3Object_9F4E28A7": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test/Handler/S3Object", + "uniqueId": "testtest_Handler_S3Object_9F4E28A7" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + } + } + } +} +``` + +## preflight.js +```js +const $stdlib = require('@winglang/sdk'); +const $plugins = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLUGIN_PATHS); +const $outdir = process.env.WING_SYNTH_DIR ?? "."; +const $wing_is_test = process.env.WING_IS_TEST === "true"; +const std = $stdlib.std; +const cloud = $stdlib.cloud; +const http = $stdlib.http; +class $Root extends $stdlib.std.Resource { + constructor(scope, id) { + super(scope, id); + class $Closure1 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure1-1.js")({ + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure1Client = ${$Closure1._toInflightType(this)}; + const client = new $Closure1Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure2 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure2-1.js")({ + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure2Client = ${$Closure2._toInflightType(this)}; + const client = new $Closure2Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + } + class $Closure3 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure3-1.js")({ + $api_url: ${context._lift(api.url)}, + $http_Util: ${context._lift(http.Util)}, + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure3Client = ${$Closure3._toInflightType(this)}; + const client = new $Closure3Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + _registerBind(host, ops) { + if (ops.includes("handle")) { + $Closure3._registerBindObject(api.url, host, []); + } + super._registerBind(host, ops); + } + } + class $Closure4 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure4-1.js")({ + $api_url: ${context._lift(api.url)}, + $http_Util: ${context._lift(http.Util)}, + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure4Client = ${$Closure4._toInflightType(this)}; + const client = new $Closure4Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + _registerBind(host, ops) { + if (ops.includes("handle")) { + $Closure4._registerBindObject(api.url, host, []); + } + super._registerBind(host, ops); + } + } + class $Closure5 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure5-1.js")({ + $api_url: ${context._lift(api.url)}, + $http_Util: ${context._lift(http.Util)}, + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure5Client = ${$Closure5._toInflightType(this)}; + const client = new $Closure5Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + _registerBind(host, ops) { + if (ops.includes("handle")) { + $Closure5._registerBindObject(api.url, host, []); + } + super._registerBind(host, ops); + } + } + class $Closure6 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure6-1.js")({ + $api_url: ${context._lift(api.url)}, + $http_Util: ${context._lift(http.Util)}, + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure6Client = ${$Closure6._toInflightType(this)}; + const client = new $Closure6Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + _registerBind(host, ops) { + if (ops.includes("handle")) { + $Closure6._registerBindObject(api.url, host, []); + } + super._registerBind(host, ops); + } + } + const api = this.node.root.newAbstract("@winglang/sdk.cloud.Api",this,"cloud.Api"); + const handler = new $Closure1(this,"$Closure1"); + const handler_two = new $Closure2(this,"$Closure2"); + (api.get("/users/{name}",handler)); + (api.get("/{name}",handler)); + (api.get("/users/permission/{name}",handler)); + (api.get("/{name}/{age}",handler_two)); + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test",new $Closure3(this,"$Closure3")); + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test2",new $Closure4(this,"$Closure4")); + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test3",new $Closure5(this,"$Closure5")); + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test4",new $Closure6(this,"$Closure6")); + } +} +const $App = $stdlib.core.App.for(process.env.WING_TARGET); +new $App({ outdir: $outdir, name: "path_vars", rootConstruct: $Root, plugins: $plugins, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }).synth(); + +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/path_vars.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/path_vars.w_test_sim.md new file mode 100644 index 00000000000..d8c0e957f2a --- /dev/null +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/api/path_vars.w_test_sim.md @@ -0,0 +1,15 @@ +# [path_vars.w](../../../../../../examples/tests/sdk_tests/api/path_vars.w) | test | sim + +## stdout.log +```log +pass ─ path_vars.wsim » root/env0/test:test +pass ─ path_vars.wsim » root/env1/test:test2 +pass ─ path_vars.wsim » root/env2/test:test3 +pass ─ path_vars.wsim » root/env3/test:test4 + + +Tests 4 passed (4) +Test Files 1 passed (1) +Duration +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_compile_tf-aws.md index 93573fab137..c32ae02d8e9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_compile_tf-aws.md @@ -20,8 +20,26 @@ module.exports = function({ $std_Json }) { ## inflight.$Closure2-1.js ```js -module.exports = function({ $api_url, $http_Util, $std_Json }) { +module.exports = function({ $std_Json }) { class $Closure2 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle(req) { + return ({"body": ((args) => { return JSON.stringify(args[0], null, args[1]?.indent) })([({"user": (req.vars)["name"],"age": (req.vars)["age"]})]),"headers": ({"content-type": "application/json"}),"status": 200}); + } + } + return $Closure2; +} + +``` + +## inflight.$Closure3-1.js +```js +module.exports = function({ $api_url, $http_Util, $std_Json }) { + class $Closure3 { constructor({ }) { const $obj = (...args) => this.handle(...args); Object.setPrototypeOf($obj, this); @@ -34,7 +52,72 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"user\") == username")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["user"],username)))}; } } - return $Closure2; + return $Closure3; +} + +``` + +## inflight.$Closure4-1.js +```js +module.exports = function({ $api_url, $http_Util, $std_Json }) { + class $Closure4 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const username = "akhil"; + const res = (await $http_Util.get(String.raw({ raw: ["", "/", ""] }, $api_url, username))); + {((cond) => {if (!cond) throw new Error("assertion failed: res.status == 200")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(res.status,200)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"user\") == username")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["user"],username)))}; + } + } + return $Closure4; +} + +``` + +## inflight.$Closure5-1.js +```js +module.exports = function({ $api_url, $http_Util, $std_Json }) { + class $Closure5 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const username = "akhil"; + const res = (await $http_Util.get(String.raw({ raw: ["", "/users/permission/", ""] }, $api_url, username))); + {((cond) => {if (!cond) throw new Error("assertion failed: res.status == 200")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(res.status,200)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"user\") == username")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["user"],username)))}; + } + } + return $Closure5; +} + +``` + +## inflight.$Closure6-1.js +```js +module.exports = function({ $api_url, $http_Util, $std_Json }) { + class $Closure6 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const username = "akhil"; + const age = "23"; + const res = (await $http_Util.get(String.raw({ raw: ["", "/", "/", ""] }, $api_url, username, age))); + {((cond) => {if (!cond) throw new Error("assertion failed: res.status == 200")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(res.status,200)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"user\") == username")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["user"],username)))}; + {((cond) => {if (!cond) throw new Error("assertion failed: Json.parse(res.body ?? \"\").get(\"age\") == age")})((((a,b) => { try { return require('assert').deepStrictEqual(a,b) === undefined; } catch { return false; } })(((JSON.parse((res.body ?? ""))))["age"],age)))}; + } + } + return $Closure6; } ``` @@ -72,7 +155,7 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { }, "output": { "WING_TEST_RUNNER_FUNCTION_ARNS": { - "value": "[[\"root/Default/Default/test:test\",\"${aws_lambda_function.testtest_Handler_295107CC.arn}\"]]" + "value": "[[\"root/Default/Default/test:test\",\"${aws_lambda_function.testtest_Handler_295107CC.arn}\"],[\"root/Default/Default/test:test2\",\"${aws_lambda_function.testtest2_Handler_EB79E487.arn}\"],[\"root/Default/Default/test:test3\",\"${aws_lambda_function.testtest3_Handler_A2A8E3A1.arn}\"],[\"root/Default/Default/test:test4\",\"${aws_lambda_function.testtest4_Handler_4B54514B.arn}\"]]" } }, "provider": { @@ -106,7 +189,7 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { "uniqueId": "cloudApi_api_2B334D75" } }, - "body": "{\"openapi\":\"3.0.3\",\"paths\":{\"/users/{name}\":{\"get\":{\"operationId\":\"get-users/{name}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{proxy+}\":{\"x-amazon-apigateway-any-method\":{\"produces\":[\"application/json\"],\"consumes\":[\"application/json\"],\"x-amazon-apigateway-integration\":{\"type\":\"mock\",\"requestTemplates\":{\"application/json\":\"{\\\"statusCode\\\": 404}\"},\"responses\":{\"default\":{\"statusCode\":\"404\",\"responseParameters\":{\"method.response.header.Content-Type\":\"'application/json'\"},\"responseTemplates\":{\"application/json\":\"{\\\"statusCode: 404, \\\"message\\\": \\\"Error: Resource not found\\\"}\"}}}},\"responses\":{\"404\":{\"description\":\"404 response\",\"headers\":{\"Content-Type\":{\"type\":\"string\"}}}}}}}}", + "body": "{\"openapi\":\"3.0.3\",\"paths\":{\"/users/{name}\":{\"get\":{\"operationId\":\"get-users/{name}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{name}\":{\"get\":{\"operationId\":\"get-{name}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/users/permission/{name}\":{\"get\":{\"operationId\":\"get-users/permission/{name}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{name}/{age}\":{\"get\":{\"operationId\":\"get-{name}/{age}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"name\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}},{\"name\":\"age\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-86898773_701F5CA7.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{proxy+}\":{\"x-amazon-apigateway-any-method\":{\"produces\":[\"application/json\"],\"consumes\":[\"application/json\"],\"x-amazon-apigateway-integration\":{\"type\":\"mock\",\"requestTemplates\":{\"application/json\":\"{\\\"statusCode\\\": 404}\"},\"responses\":{\"default\":{\"statusCode\":\"404\",\"responseParameters\":{\"method.response.header.Content-Type\":\"'application/json'\"},\"responseTemplates\":{\"application/json\":\"{\\\"statusCode: 404, \\\"message\\\": \\\"Error: Resource not found\\\"}\"}}}},\"responses\":{\"404\":{\"description\":\"404 response\",\"headers\":{\"Content-Type\":{\"type\":\"string\"}}}}}}}}", "name": "api-c895068c" } }, @@ -124,6 +207,15 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { } }, "aws_iam_role": { + "cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/IamRole", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + }, "cloudApi_cloudApi-OnRequest-cdafee6e_IamRole_4382C442": { "//": { "metadata": { @@ -133,6 +225,33 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { }, "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" }, + "testtest2_Handler_IamRole_9304BBE5": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/IamRole", + "uniqueId": "testtest2_Handler_IamRole_9304BBE5" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + }, + "testtest3_Handler_IamRole_6E5F9CB2": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/IamRole", + "uniqueId": "testtest3_Handler_IamRole_6E5F9CB2" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + }, + "testtest4_Handler_IamRole_F3E77BF2": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/IamRole", + "uniqueId": "testtest4_Handler_IamRole_F3E77BF2" + } + }, + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" + }, "testtest_Handler_IamRole_15693C93": { "//": { "metadata": { @@ -144,6 +263,16 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { } }, "aws_iam_role_policy": { + "cloudApi_cloudApi-OnRequest-86898773_IamRolePolicy_DAC639E5": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/IamRolePolicy", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_IamRolePolicy_DAC639E5" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F.name}" + }, "cloudApi_cloudApi-OnRequest-cdafee6e_IamRolePolicy_8BF9C89F": { "//": { "metadata": { @@ -154,6 +283,36 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-cdafee6e_IamRole_4382C442.name}" }, + "testtest2_Handler_IamRolePolicy_77807769": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/IamRolePolicy", + "uniqueId": "testtest2_Handler_IamRolePolicy_77807769" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.testtest2_Handler_IamRole_9304BBE5.name}" + }, + "testtest3_Handler_IamRolePolicy_CD8584B9": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/IamRolePolicy", + "uniqueId": "testtest3_Handler_IamRolePolicy_CD8584B9" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.testtest3_Handler_IamRole_6E5F9CB2.name}" + }, + "testtest4_Handler_IamRolePolicy_92DB0F08": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/IamRolePolicy", + "uniqueId": "testtest4_Handler_IamRolePolicy_92DB0F08" + } + }, + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"none:null\",\"Resource\":\"*\"}]}", + "role": "${aws_iam_role.testtest4_Handler_IamRole_F3E77BF2.name}" + }, "testtest_Handler_IamRolePolicy_AF0279BD": { "//": { "metadata": { @@ -166,6 +325,16 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { } }, "aws_iam_role_policy_attachment": { + "cloudApi_cloudApi-OnRequest-86898773_IamRolePolicyAttachment_6E485A17": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/IamRolePolicyAttachment", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_IamRolePolicyAttachment_6E485A17" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F.name}" + }, "cloudApi_cloudApi-OnRequest-cdafee6e_IamRolePolicyAttachment_5383D6A2": { "//": { "metadata": { @@ -176,6 +345,36 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-cdafee6e_IamRole_4382C442.name}" }, + "testtest2_Handler_IamRolePolicyAttachment_57665B6F": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/IamRolePolicyAttachment", + "uniqueId": "testtest2_Handler_IamRolePolicyAttachment_57665B6F" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.testtest2_Handler_IamRole_9304BBE5.name}" + }, + "testtest3_Handler_IamRolePolicyAttachment_EA1CC147": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/IamRolePolicyAttachment", + "uniqueId": "testtest3_Handler_IamRolePolicyAttachment_EA1CC147" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.testtest3_Handler_IamRole_6E5F9CB2.name}" + }, + "testtest4_Handler_IamRolePolicyAttachment_AC735E44": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/IamRolePolicyAttachment", + "uniqueId": "testtest4_Handler_IamRolePolicyAttachment_AC735E44" + } + }, + "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", + "role": "${aws_iam_role.testtest4_Handler_IamRole_F3E77BF2.name}" + }, "testtest_Handler_IamRolePolicyAttachment_ADF4752D": { "//": { "metadata": { @@ -188,6 +387,35 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { } }, "aws_lambda_function": { + "cloudApi_cloudApi-OnRequest-86898773_701F5CA7": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/Default", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_701F5CA7" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "cloud-Api-OnRequest-86898773-c8ed6547", + "WING_TARGET": "tf-aws" + } + }, + "function_name": "cloud-Api-OnRequest-86898773-c8ed6547", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.cloudApi_cloudApi-OnRequest-86898773_IamRole_6300C24F.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.cloudApi_cloudApi-OnRequest-86898773_S3Object_12D28469.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + }, "cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F": { "//": { "metadata": { @@ -217,6 +445,96 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { "subnet_ids": [] } }, + "testtest2_Handler_EB79E487": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/Default", + "uniqueId": "testtest2_Handler_EB79E487" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "Handler-c89fe587", + "WING_TARGET": "tf-aws", + "WING_TOKEN_TFTOKEN_TOKEN_8": "${jsonencode(aws_api_gateway_stage.cloudApi_api_stage_BBB283E4.invoke_url)}" + } + }, + "function_name": "Handler-c89fe587", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.testtest2_Handler_IamRole_9304BBE5.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.testtest2_Handler_S3Object_21FCD712.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + }, + "testtest3_Handler_A2A8E3A1": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/Default", + "uniqueId": "testtest3_Handler_A2A8E3A1" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "Handler-c8445457", + "WING_TARGET": "tf-aws", + "WING_TOKEN_TFTOKEN_TOKEN_8": "${jsonencode(aws_api_gateway_stage.cloudApi_api_stage_BBB283E4.invoke_url)}" + } + }, + "function_name": "Handler-c8445457", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.testtest3_Handler_IamRole_6E5F9CB2.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.testtest3_Handler_S3Object_417A3842.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + }, + "testtest4_Handler_4B54514B": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/Default", + "uniqueId": "testtest4_Handler_4B54514B" + } + }, + "architectures": [ + "arm64" + ], + "environment": { + "variables": { + "WING_FUNCTION_NAME": "Handler-c82aef8d", + "WING_TARGET": "tf-aws", + "WING_TOKEN_TFTOKEN_TOKEN_8": "${jsonencode(aws_api_gateway_stage.cloudApi_api_stage_BBB283E4.invoke_url)}" + } + }, + "function_name": "Handler-c82aef8d", + "handler": "index.handler", + "publish": true, + "role": "${aws_iam_role.testtest4_Handler_IamRole_F3E77BF2.arn}", + "runtime": "nodejs18.x", + "s3_bucket": "${aws_s3_bucket.Code.bucket}", + "s3_key": "${aws_s3_object.testtest4_Handler_S3Object_7A3CDC0E.key}", + "timeout": 30, + "vpc_config": { + "security_group_ids": [], + "subnet_ids": [] + } + }, "testtest_Handler_295107CC": { "//": { "metadata": { @@ -249,6 +567,19 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { } }, "aws_lambda_permission": { + "cloudApi_api_permission-GET-2e836e2d_1D868589": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-2e836e2d", + "uniqueId": "cloudApi_api_permission-GET-2e836e2d_1D868589" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/users/permission/{name}", + "statement_id": "AllowExecutionFromAPIGateway-GET-2e836e2d" + }, "cloudApi_api_permission-GET-9f89597e_FFBE5338": { "//": { "metadata": { @@ -261,6 +592,32 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { "principal": "apigateway.amazonaws.com", "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/users/{name}", "statement_id": "AllowExecutionFromAPIGateway-GET-9f89597e" + }, + "cloudApi_api_permission-GET-da43a2f2_1CE7916D": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-da43a2f2", + "uniqueId": "cloudApi_api_permission-GET-da43a2f2_1CE7916D" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/{name}", + "statement_id": "AllowExecutionFromAPIGateway-GET-da43a2f2" + }, + "cloudApi_api_permission-GET-e6c024e8_94CCF201": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-e6c024e8", + "uniqueId": "cloudApi_api_permission-GET-e6c024e8_94CCF201" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-86898773_701F5CA7.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/{name}/{age}", + "statement_id": "AllowExecutionFromAPIGateway-GET-e6c024e8" } }, "aws_s3_bucket": { @@ -275,6 +632,17 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { } }, "aws_s3_object": { + "cloudApi_cloudApi-OnRequest-86898773_S3Object_12D28469": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/cloud.Api-OnRequest-86898773/S3Object", + "uniqueId": "cloudApi_cloudApi-OnRequest-86898773_S3Object_12D28469" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + }, "cloudApi_cloudApi-OnRequest-cdafee6e_S3Object_5DAAA0EF": { "//": { "metadata": { @@ -286,6 +654,39 @@ module.exports = function({ $api_url, $http_Util, $std_Json }) { "key": "", "source": "" }, + "testtest2_Handler_S3Object_21FCD712": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test2/Handler/S3Object", + "uniqueId": "testtest2_Handler_S3Object_21FCD712" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + }, + "testtest3_Handler_S3Object_417A3842": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test3/Handler/S3Object", + "uniqueId": "testtest3_Handler_S3Object_417A3842" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + }, + "testtest4_Handler_S3Object_7A3CDC0E": { + "//": { + "metadata": { + "path": "root/Default/Default/test:test4/Handler/S3Object", + "uniqueId": "testtest4_Handler_S3Object_7A3CDC0E" + } + }, + "bucket": "${aws_s3_bucket.Code.bucket}", + "key": "", + "source": "" + }, "testtest_Handler_S3Object_9F4E28A7": { "//": { "metadata": { @@ -349,8 +750,6 @@ class $Root extends $stdlib.std.Resource { static _toInflightType(context) { return ` require("./inflight.$Closure2-1.js")({ - $api_url: ${context._lift(api.url)}, - $http_Util: ${context._lift(http.Util)}, $std_Json: ${context._lift(std.Json)}, }) `; @@ -369,17 +768,158 @@ class $Root extends $stdlib.std.Resource { _getInflightOps() { return ["handle", "$inflight_init"]; } + } + class $Closure3 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure3-1.js")({ + $api_url: ${context._lift(api.url)}, + $http_Util: ${context._lift(http.Util)}, + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure3Client = ${$Closure3._toInflightType(this)}; + const client = new $Closure3Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + _registerBind(host, ops) { + if (ops.includes("handle")) { + $Closure3._registerBindObject(api.url, host, []); + } + super._registerBind(host, ops); + } + } + class $Closure4 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure4-1.js")({ + $api_url: ${context._lift(api.url)}, + $http_Util: ${context._lift(http.Util)}, + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure4Client = ${$Closure4._toInflightType(this)}; + const client = new $Closure4Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + _registerBind(host, ops) { + if (ops.includes("handle")) { + $Closure4._registerBindObject(api.url, host, []); + } + super._registerBind(host, ops); + } + } + class $Closure5 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure5-1.js")({ + $api_url: ${context._lift(api.url)}, + $http_Util: ${context._lift(http.Util)}, + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure5Client = ${$Closure5._toInflightType(this)}; + const client = new $Closure5Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } + _registerBind(host, ops) { + if (ops.includes("handle")) { + $Closure5._registerBindObject(api.url, host, []); + } + super._registerBind(host, ops); + } + } + class $Closure6 extends $stdlib.std.Resource { + constructor(scope, id, ) { + super(scope, id); + (std.Node.of(this)).hidden = true; + } + static _toInflightType(context) { + return ` + require("./inflight.$Closure6-1.js")({ + $api_url: ${context._lift(api.url)}, + $http_Util: ${context._lift(http.Util)}, + $std_Json: ${context._lift(std.Json)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure6Client = ${$Closure6._toInflightType(this)}; + const client = new $Closure6Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + _getInflightOps() { + return ["handle", "$inflight_init"]; + } _registerBind(host, ops) { if (ops.includes("handle")) { - $Closure2._registerBindObject(api.url, host, []); + $Closure6._registerBindObject(api.url, host, []); } super._registerBind(host, ops); } } const api = this.node.root.newAbstract("@winglang/sdk.cloud.Api",this,"cloud.Api"); const handler = new $Closure1(this,"$Closure1"); + const handler_two = new $Closure2(this,"$Closure2"); (api.get("/users/{name}",handler)); - this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test",new $Closure2(this,"$Closure2")); + (api.get("/{name}",handler)); + (api.get("/users/permission/{name}",handler)); + (api.get("/{name}/{age}",handler_two)); + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test",new $Closure3(this,"$Closure3")); + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test2",new $Closure4(this,"$Closure4")); + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test3",new $Closure5(this,"$Closure5")); + this.node.root.new("@winglang/sdk.std.Test",std.Test,this,"test:test4",new $Closure6(this,"$Closure6")); } } const $App = $stdlib.core.App.for(process.env.WING_TARGET); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_test_sim.md index 6fa31afb5eb..c404af2b4d1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_path_vars.w_test_sim.md @@ -2,10 +2,13 @@ ## stdout.log ```log -pass ─ api_path_vars.wsim » root/env0/test:test +pass ─ api_path_vars.wsim » root/env0/test:test +pass ─ api_path_vars.wsim » root/env1/test:test2 +pass ─ api_path_vars.wsim » root/env2/test:test3 +pass ─ api_path_vars.wsim » root/env3/test:test4 -Tests 1 passed (1) +Tests 4 passed (4) Test Files 1 passed (1) Duration ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.w_compile_tf-aws.md index a227839df51..c2902ae8fbd 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.w_compile_tf-aws.md @@ -85,7 +85,7 @@ module.exports = function({ }) { "uniqueId": "cloudApi_api_2B334D75" } }, - "body": "{\"openapi\":\"3.0.3\",\"paths\":{\"/test\":{\"get\":{\"operationId\":\"get-test\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/alphanumer1cPa_th\":{\"get\":{\"operationId\":\"get-test/alphanumer1cPa_th\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/regular/path\":{\"get\":{\"operationId\":\"get-test/regular/path\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/pa-th/{with}/two/{variable_s}/f?bla=5&b=6\":{\"get\":{\"operationId\":\"get-test/pa-th/{with}/two/{variable_s}/f?bla=5&b=6\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"with\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}},{\"name\":\"variable_s\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/param/is/{last}\":{\"get\":{\"operationId\":\"get-test/param/is/{last}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"last\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{proxy+}\":{\"x-amazon-apigateway-any-method\":{\"produces\":[\"application/json\"],\"consumes\":[\"application/json\"],\"x-amazon-apigateway-integration\":{\"type\":\"mock\",\"requestTemplates\":{\"application/json\":\"{\\\"statusCode\\\": 404}\"},\"responses\":{\"default\":{\"statusCode\":\"404\",\"responseParameters\":{\"method.response.header.Content-Type\":\"'application/json'\"},\"responseTemplates\":{\"application/json\":\"{\\\"statusCode: 404, \\\"message\\\": \\\"Error: Resource not found\\\"}\"}}}},\"responses\":{\"404\":{\"description\":\"404 response\",\"headers\":{\"Content-Type\":{\"type\":\"string\"}}}}}}}}", + "body": "{\"openapi\":\"3.0.3\",\"paths\":{\"/test\":{\"get\":{\"operationId\":\"get-test\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/alphanumer1cPa_th\":{\"get\":{\"operationId\":\"get-test/alphanumer1cPa_th\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/regular/path\":{\"get\":{\"operationId\":\"get-test/regular/path\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/pa-th/{with}/two/{variable_s}/f?bla=5&b=6\":{\"get\":{\"operationId\":\"get-test/pa-th/{with}/two/{variable_s}/f?bla=5&b=6\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"with\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}},{\"name\":\"variable_s\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/param/is/{last}\":{\"get\":{\"operationId\":\"get-test/param/is/{last}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"last\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/{param}\":{\"get\":{\"operationId\":\"get-test/{param}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"param\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{param}\":{\"get\":{\"operationId\":\"get-{param}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"param\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/t/{param}\":{\"get\":{\"operationId\":\"get-t/{param}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"param\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/regular/path/{param}\":{\"get\":{\"operationId\":\"get-test/regular/path/{param}\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"param\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/segment1/{param1}/segment2?query1=value1?query2=value2\":{\"get\":{\"operationId\":\"get-test/segment1/{param1}/segment2?query1=value1?query2=value2\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[{\"name\":\"param1\",\"in\":\"path\",\"required\":true,\"schema\":{\"type\":\"string\"}}],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/test/segment1/segment2?query=value1&query2=value2\":{\"get\":{\"operationId\":\"get-test/segment1/segment2?query=value1&query2=value2\",\"responses\":{\"200\":{\"description\":\"200 response\",\"content\":{}}},\"parameters\":[],\"x-amazon-apigateway-integration\":{\"uri\":\"arn:aws:apigateway:${data.aws_region.Region.name}:lambda:path/2015-03-31/functions/${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.arn}/invocations\",\"type\":\"aws_proxy\",\"httpMethod\":\"POST\",\"responses\":{\"default\":{\"statusCode\":\"200\"}},\"passthroughBehavior\":\"when_no_match\",\"contentHandling\":\"CONVERT_TO_TEXT\"}}},\"/{proxy+}\":{\"x-amazon-apigateway-any-method\":{\"produces\":[\"application/json\"],\"consumes\":[\"application/json\"],\"x-amazon-apigateway-integration\":{\"type\":\"mock\",\"requestTemplates\":{\"application/json\":\"{\\\"statusCode\\\": 404}\"},\"responses\":{\"default\":{\"statusCode\":\"404\",\"responseParameters\":{\"method.response.header.Content-Type\":\"'application/json'\"},\"responseTemplates\":{\"application/json\":\"{\\\"statusCode: 404, \\\"message\\\": \\\"Error: Resource not found\\\"}\"}}}},\"responses\":{\"404\":{\"description\":\"404 response\",\"headers\":{\"Content-Type\":{\"type\":\"string\"}}}}}}}}", "name": "api-c895068c" } }, @@ -182,6 +182,32 @@ module.exports = function({ }) { "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/test/pa-th/{with}/two/{variable_s}/f?bla=5&b=6", "statement_id": "AllowExecutionFromAPIGateway-GET-08e6e523" }, + "cloudApi_api_permission-GET-28ae85ef_1688C1E0": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-28ae85ef", + "uniqueId": "cloudApi_api_permission-GET-28ae85ef_1688C1E0" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/test/regular/path/{param}", + "statement_id": "AllowExecutionFromAPIGateway-GET-28ae85ef" + }, + "cloudApi_api_permission-GET-43f8ccb9_8100AD68": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-43f8ccb9", + "uniqueId": "cloudApi_api_permission-GET-43f8ccb9_8100AD68" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/t/{param}", + "statement_id": "AllowExecutionFromAPIGateway-GET-43f8ccb9" + }, "cloudApi_api_permission-GET-8d6a8a39_7FDACFF5": { "//": { "metadata": { @@ -208,6 +234,58 @@ module.exports = function({ }) { "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/test/alphanumer1cPa_th", "statement_id": "AllowExecutionFromAPIGateway-GET-8dfdf611" }, + "cloudApi_api_permission-GET-a7795791_E2DC1B63": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-a7795791", + "uniqueId": "cloudApi_api_permission-GET-a7795791_E2DC1B63" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/test/segment1/{param1}/segment2?query1=value1?query2=value2", + "statement_id": "AllowExecutionFromAPIGateway-GET-a7795791" + }, + "cloudApi_api_permission-GET-b171b58d_9FC71DD1": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-b171b58d", + "uniqueId": "cloudApi_api_permission-GET-b171b58d_9FC71DD1" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/test/segment1/segment2?query=value1&query2=value2", + "statement_id": "AllowExecutionFromAPIGateway-GET-b171b58d" + }, + "cloudApi_api_permission-GET-b1b0106b_07B1AED7": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-b1b0106b", + "uniqueId": "cloudApi_api_permission-GET-b1b0106b_07B1AED7" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/test/{param}", + "statement_id": "AllowExecutionFromAPIGateway-GET-b1b0106b" + }, + "cloudApi_api_permission-GET-b49a0d1b_4BF20C26": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Api/api/permission-GET-b49a0d1b", + "uniqueId": "cloudApi_api_permission-GET-b49a0d1b_4BF20C26" + } + }, + "action": "lambda:InvokeFunction", + "function_name": "${aws_lambda_function.cloudApi_cloudApi-OnRequest-cdafee6e_A6C8366F.function_name}", + "principal": "apigateway.amazonaws.com", + "source_arn": "${aws_api_gateway_rest_api.cloudApi_api_2B334D75.execution_arn}/*/GET/{param}", + "statement_id": "AllowExecutionFromAPIGateway-GET-b49a0d1b" + }, "cloudApi_api_permission-GET-b53ce5f6_5CFB8031": { "//": { "metadata": { @@ -333,11 +411,27 @@ class $Root extends $stdlib.std.Resource { (testInvalidPath("/test/m{issplaced}")); (testInvalidPath("/test/{misspla}ced")); (testInvalidPath("/test/{}/empty")); + (testInvalidPath("/{sup:er/:annoying//path}")); + (testInvalidPath("/{::another:annoying:path}")); + (testInvalidPath("/n0t_alphanumer1cPa:th")); + (testInvalidPath("/{with}/{two:invali4d#}/variables")); + (testInvalidPath("/{unclosed")); + (testInvalidPath("/m{issplaced}")); + (testInvalidPath("/{misspla}ced")); + (testInvalidPath("test")); + (testInvalidPath("/{}/empty")); + (testInvalidPath("/{}")); (testValidPath("/test")); (testValidPath("/test/alphanumer1cPa_th")); (testValidPath("/test/regular/path")); (testValidPath("/test/pa-th/{with}/two/{variable_s}/f?bla=5&b=6")); (testValidPath("/test/param/is/{last}")); + (testValidPath("/test/{param}")); + (testValidPath("/{param}")); + (testValidPath("/t/{param}")); + (testValidPath("/test/regular/path/{param}")); + (testValidPath("/test/segment1/{param1}/segment2?query1=value1?query2=value2")); + (testValidPath("/test/segment1/segment2?query=value1&query2=value2")); } } const $App = $stdlib.core.App.for(process.env.WING_TARGET);