From a14c45430c3d4defa21e25efe8d23e932169f136 Mon Sep 17 00:00:00 2001 From: Chris Rybicki Date: Tue, 16 Jul 2024 16:27:18 -0400 Subject: [PATCH] feat!: sunset ex.Table and ex.Redis (#6903) Closes https://github.com/winglang/wing/issues/5857 BREAKING CHANGE: `ex.Redis` and `ex.Table` have been removed from the standard library in favor of dedicated libraries maintained in Winglang. We recommend migrating apps to use the [redis](https://github.com/winglang/winglibs/tree/main/redis) winglib for Redis support, and the [dynamodb](https://github.com/winglang/winglibs/blob/main/dynamodb) or [postgres](https://github.com/winglang/winglibs/tree/main/postgres) winglibs for functionality similar to `ex.Table`. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [x] Docs updated (only required for features) - [x] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*. --- .../src/docgen/view/wing-filters.ts | 1 - apps/wing-console/console/app/demo/main.w | 21 - .../console/app/test/ex.redis/index.test.ts | 57 - .../console/app/test/ex.redis/main.w | 3 - .../console/app/test/ex.table/index.test.ts | 71 -- .../console/app/test/ex.table/main.w | 20 - .../design-system/src/icons/react-icon.tsx | 27 - .../design-system/src/icons/redis-icon.tsx | 28 - .../console/design-system/src/index.ts | 3 - .../console/design-system/src/row-input.tsx | 91 -- .../console/design-system/src/table-row.tsx | 142 --- .../design-system/src/utils/icon-utils.ts | 22 - apps/wing-console/console/server/package.json | 1 - apps/wing-console/console/server/src/index.ts | 3 - .../console/server/src/router/index.ts | 4 - .../console/server/src/router/redis.ts | 68 -- .../console/server/src/router/table.ts | 202 ---- .../console/server/src/wingsdk.ts | 6 - .../resource-panes/redis-interaction-view.tsx | 123 -- .../resource-panes/redis-interaction.tsx | 140 --- .../resource-interaction-view.tsx | 8 - .../resource-panes/resource-metadata.tsx | 20 +- .../resource-panes/table-interaction-view.tsx | 129 --- .../table-interaction.stories.tsx | 124 -- .../resource-panes/table-interaction.tsx | 292 ----- .../resource-panes/use-redis.ts | 36 - .../resource-panes/use-table.tsx | 69 -- docs/api/03-language/08-classes.md | 32 +- .../04-standard-library/aws/api-reference.md | 86 -- docs/api/04-standard-library/cloud/api.md | 23 +- .../api/04-standard-library/ex/_category_.yml | 5 - docs/api/04-standard-library/ex/react-app.md | 441 ------- docs/api/04-standard-library/ex/redis.md | 458 -------- docs/api/04-standard-library/ex/table.md | 454 -------- docs/turbo.json | 4 +- .../valid/08-classes.md_example_4/main.w | 30 - .../valid/api.md_example_1/main.w | 21 +- examples/tests/sdk_tests/bucket/events.test.w | 21 +- examples/tests/sdk_tests/table/add_row.test.w | 27 - .../tests/sdk_tests/table/aws-table.test.w | 35 - examples/tests/sdk_tests/table/get.test.w | 38 - examples/tests/sdk_tests/table/list.test.w | 26 - examples/tests/sdk_tests/table/try_get.test.w | 31 - examples/tests/sdk_tests/table/upsert.test.w | 50 - examples/tests/valid/api_cors_custom.test.w | 1 - examples/tests/valid/api_cors_default.test.w | 1 - examples/tests/valid/redis.test.w | 34 - examples/tests/valid/table.test.w | 11 - examples/tests/valid/website_with_api.test.w | 16 +- libs/@wingcloud/framework/src/index.ts | 2 +- libs/wingc/src/lib.rs | 4 +- .../completions/bring_suggestions.snap | 3 - .../bring_suggestions_partial.snap | 3 - libs/wingsdk/.projen/deps.json | 4 - libs/wingsdk/.projenrc.ts | 1 - libs/wingsdk/package.json | 2 - libs/wingsdk/scripts/docgen.mts | 7 - libs/wingsdk/src/README.md | 1 - libs/wingsdk/src/cloud/api.md | 23 +- libs/wingsdk/src/ex/index.ts | 2 - libs/wingsdk/src/ex/redis.md | 7 - libs/wingsdk/src/ex/redis.ts | 186 --- libs/wingsdk/src/ex/table.md | 7 - libs/wingsdk/src/ex/table.ts | 193 ---- libs/wingsdk/src/index.ts | 1 - libs/wingsdk/src/shared-aws/index.ts | 1 - libs/wingsdk/src/shared-aws/table.inflight.ts | 122 -- libs/wingsdk/src/shared-aws/table.ts | 40 - libs/wingsdk/src/shared/table-utils.ts | 33 - libs/wingsdk/src/target-sim/app.ts | 9 - libs/wingsdk/src/target-sim/container.ts | 2 +- libs/wingsdk/src/target-sim/platform.ts | 9 - libs/wingsdk/src/target-sim/redis.inflight.ts | 71 -- libs/wingsdk/src/target-sim/redis.ts | 73 -- .../src/target-sim/schema-resources.ts | 22 - libs/wingsdk/src/target-sim/table.inflight.ts | 153 --- libs/wingsdk/src/target-sim/table.ts | 60 - libs/wingsdk/src/target-tf-aws/index.ts | 1 - libs/wingsdk/src/target-tf-aws/platform.ts | 9 - .../src/target-tf-aws/redis.inflight.ts | 74 -- libs/wingsdk/src/target-tf-aws/redis.ts | 150 --- libs/wingsdk/src/target-tf-aws/table.ts | 157 --- libs/wingsdk/src/target-tf-gcp/index.ts | 1 - libs/wingsdk/src/target-tf-gcp/platform.ts | 4 - libs/wingsdk/src/target-tf-gcp/table.ts | 109 -- .../__snapshots__/connections.test.ts.snap | 8 - .../test/shared-aws/table.inflight.test.ts | 217 ---- libs/wingsdk/test/simulator/cleanup.test.ts | 2 +- .../target-sim/__snapshots__/api.test.ts.snap | 128 --- .../__snapshots__/bucket.test.ts.snap | 32 - .../__snapshots__/counter.test.ts.snap | 56 - .../__snapshots__/dynamodb-table.test.ts.snap | 691 ----------- .../__snapshots__/file-counter.test.ts.snap | 8 - .../__snapshots__/function.test.ts.snap | 48 - .../immutable-capture.test.ts.snap | 112 -- .../__snapshots__/on-deploy.test.ts.snap | 8 - .../__snapshots__/queue.test.ts.snap | 491 -------- .../__snapshots__/redis.test.ts.snap | 160 --- .../__snapshots__/schedule.test.ts.snap | 32 - .../__snapshots__/secret.test.ts.snap | 8 - .../__snapshots__/service.test.ts.snap | 8 - .../__snapshots__/table.test.ts.snap | 1017 ----------------- .../__snapshots__/test.test.ts.snap | 8 - .../__snapshots__/topic.test.ts.snap | 8 - libs/wingsdk/test/target-sim/redis.test.ts | 137 --- libs/wingsdk/test/target-sim/table.test.ts | 370 ------ .../__snapshots__/redis.test.ts.snap | 249 ---- .../__snapshots__/table.test.ts.snap | 308 ----- .../test/target-tf-aws/redis.inflight.test.ts | 136 --- libs/wingsdk/test/target-tf-aws/redis.test.ts | 123 -- libs/wingsdk/test/target-tf-aws/table.test.ts | 51 - .../__snapshots__/table.test.ts.snap | 38 - libs/wingsdk/test/target-tf-gcp/table.test.ts | 20 - pnpm-lock.yaml | 122 +- .../bucket/events.test.w_compile_tf-aws.md | 66 +- .../table/add_row.test.w_compile_tf-aws.md | 68 -- .../table/add_row.test.w_test_sim.md | 12 - .../table/aws-table.test.w_compile_tf-aws.md | 44 - .../table/aws-table.test.w_test_sim.md | 12 - .../table/get.test.w_compile_tf-aws.md | 44 - .../sdk_tests/table/get.test.w_test_sim.md | 12 - .../table/list.test.w_compile_tf-aws.md | 44 - .../sdk_tests/table/list.test.w_test_sim.md | 12 - .../table/try_get.test.w_compile_tf-aws.md | 44 - .../table/try_get.test.w_test_sim.md | 12 - .../table/upsert.test.w_compile_tf-aws.md | 68 -- .../sdk_tests/table/upsert.test.w_test_sim.md | 12 - .../api_cors_custom.test.w_compile_tf-aws.md | 1 - .../api_cors_default.test.w_compile_tf-aws.md | 1 - .../valid/redis.test.w_compile_tf-aws.md | 787 ------------- .../valid/redis.test.w_test_sim.md | 12 - .../valid/table.test.w_compile_tf-aws.md | 70 -- .../valid/table.test.w_test_sim.md | 12 - .../website_with_api.test.w_compile_tf-aws.md | 67 +- 134 files changed, 87 insertions(+), 11011 deletions(-) delete mode 100644 apps/wing-console/console/app/test/ex.redis/index.test.ts delete mode 100644 apps/wing-console/console/app/test/ex.redis/main.w delete mode 100644 apps/wing-console/console/app/test/ex.table/index.test.ts delete mode 100644 apps/wing-console/console/app/test/ex.table/main.w delete mode 100644 apps/wing-console/console/design-system/src/icons/react-icon.tsx delete mode 100644 apps/wing-console/console/design-system/src/icons/redis-icon.tsx delete mode 100644 apps/wing-console/console/design-system/src/row-input.tsx delete mode 100644 apps/wing-console/console/design-system/src/table-row.tsx delete mode 100644 apps/wing-console/console/server/src/router/redis.ts delete mode 100644 apps/wing-console/console/server/src/router/table.ts delete mode 100644 apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/redis-interaction-view.tsx delete mode 100644 apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/redis-interaction.tsx delete mode 100644 apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/table-interaction-view.tsx delete mode 100644 apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/table-interaction.stories.tsx delete mode 100644 apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/table-interaction.tsx delete mode 100644 apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/use-redis.ts delete mode 100644 apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/use-table.tsx delete mode 100644 docs/api/04-standard-library/ex/_category_.yml delete mode 100644 docs/api/04-standard-library/ex/react-app.md delete mode 100644 docs/api/04-standard-library/ex/redis.md delete mode 100644 docs/api/04-standard-library/ex/table.md delete mode 100644 examples/tests/sdk_tests/table/add_row.test.w delete mode 100644 examples/tests/sdk_tests/table/aws-table.test.w delete mode 100644 examples/tests/sdk_tests/table/get.test.w delete mode 100644 examples/tests/sdk_tests/table/list.test.w delete mode 100644 examples/tests/sdk_tests/table/try_get.test.w delete mode 100644 examples/tests/sdk_tests/table/upsert.test.w delete mode 100644 examples/tests/valid/redis.test.w delete mode 100644 examples/tests/valid/table.test.w delete mode 100644 libs/wingsdk/src/ex/index.ts delete mode 100644 libs/wingsdk/src/ex/redis.md delete mode 100644 libs/wingsdk/src/ex/redis.ts delete mode 100644 libs/wingsdk/src/ex/table.md delete mode 100644 libs/wingsdk/src/ex/table.ts delete mode 100644 libs/wingsdk/src/shared-aws/table.inflight.ts delete mode 100644 libs/wingsdk/src/shared-aws/table.ts delete mode 100644 libs/wingsdk/src/shared/table-utils.ts delete mode 100644 libs/wingsdk/src/target-sim/redis.inflight.ts delete mode 100644 libs/wingsdk/src/target-sim/redis.ts delete mode 100644 libs/wingsdk/src/target-sim/table.inflight.ts delete mode 100644 libs/wingsdk/src/target-sim/table.ts delete mode 100644 libs/wingsdk/src/target-tf-aws/redis.inflight.ts delete mode 100644 libs/wingsdk/src/target-tf-aws/redis.ts delete mode 100644 libs/wingsdk/src/target-tf-aws/table.ts delete mode 100644 libs/wingsdk/src/target-tf-gcp/table.ts delete mode 100644 libs/wingsdk/test/shared-aws/table.inflight.test.ts delete mode 100644 libs/wingsdk/test/target-sim/__snapshots__/dynamodb-table.test.ts.snap delete mode 100644 libs/wingsdk/test/target-sim/__snapshots__/redis.test.ts.snap delete mode 100644 libs/wingsdk/test/target-sim/__snapshots__/table.test.ts.snap delete mode 100644 libs/wingsdk/test/target-sim/redis.test.ts delete mode 100644 libs/wingsdk/test/target-sim/table.test.ts delete mode 100644 libs/wingsdk/test/target-tf-aws/__snapshots__/redis.test.ts.snap delete mode 100644 libs/wingsdk/test/target-tf-aws/__snapshots__/table.test.ts.snap delete mode 100644 libs/wingsdk/test/target-tf-aws/redis.inflight.test.ts delete mode 100644 libs/wingsdk/test/target-tf-aws/redis.test.ts delete mode 100644 libs/wingsdk/test/target-tf-aws/table.test.ts delete mode 100644 libs/wingsdk/test/target-tf-gcp/__snapshots__/table.test.ts.snap delete mode 100644 libs/wingsdk/test/target-tf-gcp/table.test.ts delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.test.w_compile_tf-aws.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.test.w_test_sim.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/aws-table.test.w_compile_tf-aws.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/aws-table.test.w_test_sim.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/get.test.w_compile_tf-aws.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/get.test.w_test_sim.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.test.w_compile_tf-aws.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.test.w_test_sim.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/try_get.test.w_compile_tf-aws.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/try_get.test.w_test_sim.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/upsert.test.w_compile_tf-aws.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/sdk_tests/table/upsert.test.w_test_sim.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_test_sim.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md delete mode 100644 tools/hangar/__snapshots__/test_corpus/valid/table.test.w_test_sim.md diff --git a/apps/jsii-docgen/src/docgen/view/wing-filters.ts b/apps/jsii-docgen/src/docgen/view/wing-filters.ts index d840ac66a0f..863f0240699 100644 --- a/apps/jsii-docgen/src/docgen/view/wing-filters.ts +++ b/apps/jsii-docgen/src/docgen/view/wing-filters.ts @@ -4,7 +4,6 @@ export const VISIBLE_SUBMODULES = [ "fs", "std", "util", - "redis", "http", "math", ]; diff --git a/apps/wing-console/console/app/demo/main.w b/apps/wing-console/console/app/demo/main.w index bde1ce69bfa..df66d073e38 100644 --- a/apps/wing-console/console/app/demo/main.w +++ b/apps/wing-console/console/app/demo/main.w @@ -1,5 +1,4 @@ bring cloud; -bring ex; bring ui; bring util; bring sim; @@ -92,26 +91,6 @@ topic.onMessage(inflight (message: str): str => { return message; }); -// let r = new ex.Redis(); -// new cloud.Function(inflight (message :str) :str => { -// log("{r.url()}"); -// r.set("wing", message); -// let value = r.get("wing"); -// log("{value}"); -// return r.url(); -// }) as "Redis interaction"; - -let table = new ex.Table( - name: "simple-table", - primaryKey: "id", - columns: { - "id" => ex.ColumnType.STRING, - "name" => ex.ColumnType.STRING, - "date" => ex.ColumnType.DATE, - "active" => ex.ColumnType.BOOLEAN, - }, -); - let rateSchedule = new cloud.Schedule(cloud.ScheduleProps{ rate: 5m }) as "Rate Schedule"; diff --git a/apps/wing-console/console/app/test/ex.redis/index.test.ts b/apps/wing-console/console/app/test/ex.redis/index.test.ts deleted file mode 100644 index c289842664b..00000000000 --- a/apps/wing-console/console/app/test/ex.redis/index.test.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { execSync } from "node:child_process"; - -import { expect, test } from "@playwright/test"; - -import { describe } from "../describe.js"; -import { getResourceNode } from "../helpers.js"; - -const isDockerAvailable = () => { - try { - execSync("docker ps", { - stdio: "ignore", - }); - return true; - } catch { - return false; - } -}; - -describe(`${__dirname}/main.w`, () => { - test.beforeAll(async () => { - test.skip(!isDockerAvailable(), "Docker is not available"); - }); - - test.skip("opens redis help", async ({ page }) => { - await getResourceNode(page, "root/Default/Redis").click(); - - const input = page.getByTestId("ex.redis:input"); - - await input.type("help"); - - await input.press("Enter"); - - const history = await page - .getByTestId("ex.redis:history") - .allTextContents(); - - expect(history[0]).toContain( - "No problem! Let me just open this url for you", - ); - }); - - test.skip("navigates history", async ({ page }) => { - await getResourceNode(page, "root/Default/Redis").click(); - - const input = page.getByTestId("ex.redis:input"); - - await input.type("help"); - - await input.press("Enter"); - - expect(await input.inputValue()).toBe(""); - - await input.press("ArrowUp"); - - expect(await input.inputValue()).toBe("help"); - }); -}); diff --git a/apps/wing-console/console/app/test/ex.redis/main.w b/apps/wing-console/console/app/test/ex.redis/main.w deleted file mode 100644 index aa5f960661d..00000000000 --- a/apps/wing-console/console/app/test/ex.redis/main.w +++ /dev/null @@ -1,3 +0,0 @@ -bring ex; - -new ex.Redis(); diff --git a/apps/wing-console/console/app/test/ex.table/index.test.ts b/apps/wing-console/console/app/test/ex.table/index.test.ts deleted file mode 100644 index 2158c9031ee..00000000000 --- a/apps/wing-console/console/app/test/ex.table/index.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { type Page, expect, test } from "@playwright/test"; - -import { describe } from "../describe.js"; -import { getResourceNode } from "../helpers.js"; - -const addRow = async ( - page: Page, - rowId: string, - data?: { - key: string; - value: string; - }[], -) => { - await page.getByTestId("ex.table:new-row-column-id").type(rowId); - - for (const { key, value } of data || []) { - await page.getByTestId(`ex.table:new-row-column-${key}`).type(value); - } - - const addRowButton = page.getByTestId("ex.table:add-row"); - - await expect(addRowButton).toBeEnabled(); - - await addRowButton.click(); - - const row = page.getByTestId(`ex.table:row-${rowId}`); - - await expect(row).toBeVisible(); -}; - -describe(`${__dirname}/main.w`, () => { - test.skip("adds new row", async ({ page }) => { - await getResourceNode(page, "root/Default/Table").click(); - - await addRow(page, "Hello World!"); - }); - - test.skip("edits row", async ({ page }) => { - await getResourceNode(page, "root/Default/Table").click(); - - const rowId = "Hello World!"; - - await addRow(page, rowId); - - const nameInput = page.getByTestId(`ex.table:row-${rowId}-column-name`); - await nameInput.clear(); - await nameInput.type("Hello World! 2"); - await nameInput.blur(); - - const editedValue = await page - .getByTestId(`ex.table:row-${rowId}-column-name`) - .inputValue(); - - expect(editedValue).toBe("Hello World! 2"); - }); - - test.skip("removes row", async ({ page }) => { - await getResourceNode(page, "root/Default/Table").click(); - - const rowId = "Hello World!"; - - await addRow(page, rowId); - - const deleteButton = page.getByTestId(`ex.table:remove-row-${rowId}`); - await expect(deleteButton).toBeEnabled(); - await deleteButton.click(); - - const row = page.getByTestId(`ex.table:row-${rowId}`); - await expect(row).toBeHidden(); - }); -}); diff --git a/apps/wing-console/console/app/test/ex.table/main.w b/apps/wing-console/console/app/test/ex.table/main.w deleted file mode 100644 index 3ec4fea8219..00000000000 --- a/apps/wing-console/console/app/test/ex.table/main.w +++ /dev/null @@ -1,20 +0,0 @@ -bring ex; - -let table = new ex.Table(ex.TableProps{ - name: "table", - primaryKey: "id", - columns: { - "id" => ex.ColumnType.STRING, - "name" => ex.ColumnType.STRING, - "date" => ex.ColumnType.DATE, - "active" => ex.ColumnType.BOOLEAN, - }, - initialRows: { - "1" => { - id: "1", - name: "Joe", - date: "2020-01-01", - active: true, - }, - }, -}); diff --git a/apps/wing-console/console/design-system/src/icons/react-icon.tsx b/apps/wing-console/console/design-system/src/icons/react-icon.tsx deleted file mode 100644 index 27c7b642472..00000000000 --- a/apps/wing-console/console/design-system/src/icons/react-icon.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { forwardRef } from "react"; - -type ReactIconProps = React.PropsWithoutRef> & { - title?: string; - titleId?: string; -} & React.RefAttributes; - -export const ReactIcon = forwardRef( - ({ title, titleId, ...props }, svgRef) => { - return ( - <> - - - - - - - - ); - }, -); diff --git a/apps/wing-console/console/design-system/src/icons/redis-icon.tsx b/apps/wing-console/console/design-system/src/icons/redis-icon.tsx deleted file mode 100644 index 7bf5326abce..00000000000 --- a/apps/wing-console/console/design-system/src/icons/redis-icon.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { forwardRef } from "react"; - -type RedisIconProps = React.PropsWithoutRef> & { - title?: string; - titleId?: string; -} & React.RefAttributes; - -export const RedisIcon = forwardRef( - ({ title, titleId, ...props }, svgRef) => { - return ( - <> - - {title && {title}} - - - - ); - }, -); diff --git a/apps/wing-console/console/design-system/src/index.ts b/apps/wing-console/console/design-system/src/index.ts index 4345b736922..c271c63edb5 100644 --- a/apps/wing-console/console/design-system/src/index.ts +++ b/apps/wing-console/console/design-system/src/index.ts @@ -26,8 +26,6 @@ export * from "./modal.js"; export * from "./notification.js"; export * from "./pill.js"; export * from "./input.js"; -export * from "./row-input.js"; -export * from "./table-row.js"; export * from "./tree.js"; export * from "./attribute.js"; export * from "./left-resizable-widget.js"; @@ -39,7 +37,6 @@ export * from "./response-input.js"; export * from "./json-response-input.js"; export * from "./file-preview.js"; -export * from "./icons/redis-icon.js"; export * from "./icons/wing-icon.js"; export * from "./icons/spinner-icon.js"; export * from "./icons/arrow-long-right-icon.js"; diff --git a/apps/wing-console/console/design-system/src/row-input.tsx b/apps/wing-console/console/design-system/src/row-input.tsx deleted file mode 100644 index c121b293c9d..00000000000 --- a/apps/wing-console/console/design-system/src/row-input.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import classNames from "classnames"; -import type { RefObject } from "react"; -import { memo, useMemo, useState } from "react"; - -import { useTheme } from "./theme-provider.js"; - -export const RowInput = memo( - ({ - inputRef, - type, - placeholder, - inactivePlaceholder, - value, - onChange, - onKeyUp, - onBlur, - disabled, - error, - dataTestId, - }: { - inputRef?: RefObject; - type: string; - placeholder: string; - inactivePlaceholder?: string; - value: any; - onChange: (event: React.ChangeEvent) => void; - onKeyUp: (event: React.KeyboardEvent) => void; - onBlur?: (event: React.FocusEvent) => void; - disabled?: boolean; - error?: boolean; - dataTestId?: string; - }) => { - const { theme } = useTheme(); - - const [active, setActive] = useState(false); - - const showPlaceholderAsText = useMemo(() => { - return ( - !active && - ["text", "date", "number"].includes(type) && - !value && - inactivePlaceholder - ); - }, [active, type, value, inactivePlaceholder]); - - return ( - { - setActive(true); - }} - onChange={onChange} - onKeyUp={onKeyUp} - onBlur={(event) => { - setActive(false); - onBlur?.(event); - }} - data-testid={dataTestId} - /> - ); - }, -); diff --git a/apps/wing-console/console/design-system/src/table-row.tsx b/apps/wing-console/console/design-system/src/table-row.tsx deleted file mode 100644 index 3c8756e14c4..00000000000 --- a/apps/wing-console/console/design-system/src/table-row.tsx +++ /dev/null @@ -1,142 +0,0 @@ -import classNames from "classnames"; -import type { ChangeEvent, RefObject } from "react"; - -import { RowInput } from "./row-input.js"; - -export const getInputType = (type: string) => { - switch (type) { - case "string": { - return "text"; - } - case "number": { - return "text"; - } - case "boolean": { - return "checkbox"; - } - case "date": { - return "date"; - } - default: { - return "text"; - } - } -}; - -const getValue = (type: string, event: ChangeEvent) => { - switch (type) { - case "checkbox": { - return event.target.checked; - } - default: { - return event.target.value; - } - } -}; - -const hasError = (value: any, type: string) => { - if (value && type === "number" && Number.isNaN(Number(value))) { - return true; - } - return false; -}; - -export type Column = { name: string; type: string }; - -export type TableRowProps = { - inputRef?: RefObject; - row: Record; - newRow?: boolean; - placeholder?: string; - columns: Column[]; - primaryKey: string; - disabled?: boolean; - readonly?: boolean; - error?: string; - updateRow?: (column: string, value: any) => void; - saveRow?: (row: Record) => void; - actions?: (() => React.ReactNode) | JSX.Element; - rowClassName?: string; - columnClassName?: string; - actionsClassName?: string; - dataTestid?: string; -}; - -export const TableRow = ({ - inputRef, - row, - newRow, - placeholder, - columns, - primaryKey, - disabled, - readonly, - error, - updateRow, - saveRow, - actions, - rowClassName, - columnClassName, - actionsClassName, - dataTestid, -}: TableRowProps) => { - return ( - - {columns.map(({ name: column, type }, index) => { - const inputType = getInputType(type); - return ( - - { - updateRow?.(column, getValue(inputType, event)); - }} - onKeyUp={(event) => { - if (event.key === "Enter") { - saveRow?.(row); - } - }} - onBlur={() => { - !newRow && saveRow?.(row); - }} - disabled={ - (!newRow && column === primaryKey) || disabled || readonly - } - error={!readonly && hasError(row[column], type)} - dataTestId={`${dataTestid}-column-${column}`} - /> - - ); - })} - - {actions instanceof Function ? actions() : actions} - - - ); -}; diff --git a/apps/wing-console/console/design-system/src/utils/icon-utils.ts b/apps/wing-console/console/design-system/src/utils/icon-utils.ts index 121a7b49a54..0e2ad0b37aa 100644 --- a/apps/wing-console/console/design-system/src/utils/icon-utils.ts +++ b/apps/wing-console/console/design-system/src/utils/icon-utils.ts @@ -1,8 +1,6 @@ import * as OutlineHeroIcons from "@heroicons/react/24/outline"; import * as SolidHeroIcons from "@heroicons/react/24/solid"; -import { RedisIcon } from "../icons/redis-icon.js"; - import type { Colors } from "./colors.js"; const isTest = /(\/test$|\/test:([^/\\])+$)/; @@ -64,15 +62,9 @@ export const getResourceIconComponent = ( case "@winglang/sdk.cloud.Api": { return iconSet.CloudIcon; } - case "@winglang/sdk.ex.Table": { - return iconSet.TableCellsIcon; - } case "@winglang/sdk.cloud.Schedule": { return iconSet.ClockIcon; } - case "@winglang/sdk.ex.Redis": { - return RedisIcon; - } case "@winglang/sdk.std.Test": { return iconSet.BeakerIcon; } @@ -217,13 +209,6 @@ export const getResourceIconColors = (options: { options.forceDarken && colors.amber.forceDarken, ]; } - case "@winglang/sdk.ex.Table": { - return [ - colors.cyan.default, - options.darkenOnGroupHover && colors.cyan.groupHover, - options.forceDarken && colors.cyan.forceDarken, - ]; - } case "@winglang/sdk.cloud.Schedule": { return [ colors.purple.default, @@ -231,13 +216,6 @@ export const getResourceIconColors = (options: { options.forceDarken && colors.purple.forceDarken, ]; } - case "@winglang/sdk.ex.Redis": { - return [ - colors.red.default, - options.darkenOnGroupHover && colors.red.groupHover, - options.forceDarken && colors.red.forceDarken, - ]; - } case "@winglang/sdk.cloud.Website": { return [ colors.violet.default, diff --git a/apps/wing-console/console/server/package.json b/apps/wing-console/console/server/package.json index 227ff121743..fe74af49444 100644 --- a/apps/wing-console/console/server/package.json +++ b/apps/wing-console/console/server/package.json @@ -48,7 +48,6 @@ "lodash.uniqby": "^4.7.0", "nanoid": "^4.0.2", "node-fetch": "^3.3.2", - "redis": "^4.6.14", "tsup": "^8.1.0", "typescript": "^5.5.2", "vitest": "^1.6.0", diff --git a/apps/wing-console/console/server/src/index.ts b/apps/wing-console/console/server/src/index.ts index f3787650f6f..03ee1e1963c 100644 --- a/apps/wing-console/console/server/src/index.ts +++ b/apps/wing-console/console/server/src/index.ts @@ -34,7 +34,6 @@ export type { RouterContext } from "./utils/createRouter.js"; export type { RouterMeta } from "./utils/createRouter.js"; export type { MapEdge } from "./router/app.js"; export type { InternalTestResult } from "./router/test.js"; -export type { Column } from "./router/table.js"; export type { NodeDisplay } from "./utils/constructTreeNodeMap.js"; export type { LayoutConfig, @@ -42,8 +41,6 @@ export type { LayoutComponentType, } from "./utils/createRouter.js"; -export * from "@winglang/sdk/lib/ex/index.js"; - export type RouteNames = keyof inferRouterInputs | undefined; export { isTermsAccepted } from "./utils/terms-and-conditions.js"; diff --git a/apps/wing-console/console/server/src/router/index.ts b/apps/wing-console/console/server/src/router/index.ts index 4a5e645b330..a95f3994d11 100644 --- a/apps/wing-console/console/server/src/router/index.ts +++ b/apps/wing-console/console/server/src/router/index.ts @@ -10,8 +10,6 @@ import { createFileBrowserRouter } from "./file-browser.js"; import { createFunctionRouter } from "./function.js"; import { createHttpClientRouter } from "./http-client.js"; import { createQueueRouter } from "./queue.js"; -import { createRedisRouter } from "./redis.js"; -import { createTableRouter } from "./table.js"; import { createTestRouter } from "./test.js"; import { createTopicRouter } from "./topic.js"; import { createUiButtonRouter } from "./ui-button.js"; @@ -31,9 +29,7 @@ export const mergeAllRouters = () => { createTestRouter(), createTopicRouter(), createApiRouter(), - createTableRouter(), createUpdaterRouter(), - createRedisRouter(), createWebsiteRouter(), createConfigRouter(), createEndpointRouter(), diff --git a/apps/wing-console/console/server/src/router/redis.ts b/apps/wing-console/console/server/src/router/redis.ts deleted file mode 100644 index e8c261ec126..00000000000 --- a/apps/wing-console/console/server/src/router/redis.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { errorMessage } from "@wingconsole/error-message"; -import { createClient } from "redis"; -import { z } from "zod"; - -import { createProcedure, createRouter } from "../utils/createRouter.js"; -import type { IRedisClient } from "../wingsdk.js"; - -const parseRedisErrorMessage = (response: string) => { - const emptyArgumentsText = ", with args beginning with: "; - if (response.endsWith(emptyArgumentsText)) { - return response.replace(emptyArgumentsText, ""); - } - return response; -}; - -export const createRedisRouter = () => { - return createRouter({ - "redis.info": createProcedure - .input( - z.object({ - resourcePath: z.string(), - }), - ) - .query(async ({ input, ctx }) => { - const simulator = await ctx.simulator(); - const client = simulator.getResource( - input.resourcePath, - ) as IRedisClient; - - return { - url: await client.url(), - }; - }), - "redis.exec": createProcedure - .meta({ - analytics: { - action: "sendCommand", - resource: "Redis", - }, - }) - .input( - z.object({ - resourcePath: z.string(), - command: z.string(), - }), - ) - .mutation(async ({ input, ctx }) => { - const simulator = await ctx.simulator(); - const client = simulator.getResource( - input.resourcePath, - ) as IRedisClient; - const url = await client.url(); - - const redisClient = createClient({ url }); - try { - await redisClient.connect(); - const response = await redisClient.sendCommand( - input.command.split(" "), - ); - return response ? `"${response}"` : "(nil)"; - } catch (error) { - return parseRedisErrorMessage(errorMessage(error)); - } finally { - await redisClient.disconnect(); - } - }), - }); -}; diff --git a/apps/wing-console/console/server/src/router/table.ts b/apps/wing-console/console/server/src/router/table.ts deleted file mode 100644 index cfbd8d499a3..00000000000 --- a/apps/wing-console/console/server/src/router/table.ts +++ /dev/null @@ -1,202 +0,0 @@ -import { ColumnType as SdkColumnType } from "@winglang/sdk/lib/ex/table.js"; -import { z } from "zod"; - -import { createProcedure, createRouter } from "../utils/createRouter.js"; -import type { TableSchema, ITableClient } from "../wingsdk.js"; -import { Json } from "../wingsdk.js"; - -type ColumnType = "string" | "number" | "boolean" | "date" | "json"; - -export interface Column { - name: string; - type: ColumnType; -} - -const getColumns = ( - columns: Record, - primaryKey?: string, // add primaryKey to columns if not exists -): Column[] => { - const keys = Object.keys(SdkColumnType); - const values = Object.values(SdkColumnType); - - const newColumns = Object.keys(columns).map((key) => { - const index = values.indexOf(columns[key] as SdkColumnType); - const type = keys[index]?.toLowerCase() as ColumnType; - return { - name: key, - type, - }; - }); - - if (primaryKey && !newColumns.some((column) => column.name === primaryKey)) { - newColumns.unshift({ - name: primaryKey, - type: "string", - }); - } - - return newColumns; -}; - -const parseRow = (row: any, schema: Column[]): any => { - const parsedRow: any = {}; - - for (const column of schema) { - const { name, type } = column; - if (row.hasOwnProperty(name)) { - let value = row[name]; - - switch (type) { - case "number": { - value = Number(value); - parsedRow[name] = Number.isNaN(value) ? row[name] : value; - break; - } - case "boolean": { - parsedRow[name] = Boolean(value); - break; - } - - default: { - parsedRow[name] = value; - } - } - } - } - return parsedRow; -}; - -export const createTableRouter = () => { - return createRouter({ - "table.info": createProcedure - .meta({ - analytics: { - resource: "Table", - action: "list", - }, - }) - .input( - z.object({ - resourcePath: z.string(), - }), - ) - .query(async ({ input, ctx }) => { - const simulator = await ctx.simulator(); - const schema = simulator.getResourceConfig( - input.resourcePath, - ) as TableSchema; - const client = simulator.getResource( - input.resourcePath, - ) as ITableClient; - const rows = await client.list(); - const primaryKey = schema.props.primaryKey; - return { - name: schema.props.name, - primaryKey, - columns: getColumns(schema.props.columns, primaryKey), - rows, - }; - }), - "table.get": createProcedure - .meta({ - analytics: { - resource: "Table", - action: "get", - }, - }) - .input( - z.object({ - resourcePath: z.string(), - id: z.string(), - }), - ) - .query(async ({ input, ctx }) => { - const simulator = await ctx.simulator(); - const client = simulator.getResource( - input.resourcePath, - ) as ITableClient; - return await client.get(input.id); - }), - "table.insert": createProcedure - .meta({ - analytics: { - resource: "Table", - action: "insert", - }, - }) - .input( - z.object({ - resourcePath: z.string(), - data: z.record(z.any()), - }), - ) - .mutation(async ({ input, ctx }) => { - const simulator = await ctx.simulator(); - const client = simulator.getResource( - input.resourcePath, - ) as ITableClient; - - const schema = simulator.getResourceConfig( - input.resourcePath, - ) as TableSchema; - - const primaryKey = schema.props.primaryKey; - const id = input.data[primaryKey] as string; - const columns = getColumns(schema.props.columns); - await client.insert(id, parseRow(input.data, columns)); - }), - "table.update": createProcedure - .meta({ - analytics: { - resource: "Table", - action: "update", - }, - }) - .input( - z.object({ - resourcePath: z.string(), - data: z.record(z.any()), - }), - ) - .mutation(async ({ input, ctx }) => { - const simulator = await ctx.simulator(); - const client = simulator.getResource( - input.resourcePath, - ) as ITableClient; - - const schema = simulator.getResourceConfig( - input.resourcePath, - ) as TableSchema; - - const primaryKey = schema.props.primaryKey; - const id = input.data[primaryKey] as string; - const columns = getColumns(schema.props.columns); - return await client.update(id, parseRow(input.data, columns)); - }), - "table.delete": createProcedure - .meta({ - analytics: { - resource: "Table", - action: "delete", - }, - }) - .input( - z.object({ - resourcePath: z.string(), - data: z.record(z.any()), - }), - ) - .mutation(async ({ input, ctx }) => { - const simulator = await ctx.simulator(); - const client = simulator.getResource( - input.resourcePath, - ) as ITableClient; - - const schema = simulator.getResourceConfig( - input.resourcePath, - ) as TableSchema; - const id = input.data[schema.props.primaryKey] as string; - return await client.delete(id); - }), - }); -}; diff --git a/apps/wing-console/console/server/src/wingsdk.ts b/apps/wing-console/console/server/src/wingsdk.ts index 3c865304d9e..d2ccb9e4d4e 100644 --- a/apps/wing-console/console/server/src/wingsdk.ts +++ b/apps/wing-console/console/server/src/wingsdk.ts @@ -1,7 +1,6 @@ import type { BaseResourceSchema } from "@winglang/sdk/lib/simulator/index.js"; import type { ApiSchema as ApiSchema_, - TableSchema as TableSchema_, WebsiteSchema as WebsiteSchema_, EndpointSchema as EndpointSchema_, } from "@winglang/sdk/lib/target-sim/schema-resources.js"; @@ -27,14 +26,9 @@ export type { export type { ITestRunnerClient } from "@winglang/sdk/lib/std/index.js"; -export type { IRedisClient, ITableClient } from "@winglang/sdk/lib/ex/index.js"; - export type ApiSchema = BaseResourceSchema & { props: ApiSchema_; }; -export type TableSchema = BaseResourceSchema & { - props: TableSchema_; -}; export type WebsiteSchema = BaseResourceSchema & { props: WebsiteSchema_; }; diff --git a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/redis-interaction-view.tsx b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/redis-interaction-view.tsx deleted file mode 100644 index 778de91a833..00000000000 --- a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/redis-interaction-view.tsx +++ /dev/null @@ -1,123 +0,0 @@ -import { createPersistentState } from "@wingconsole/use-persistent-state"; -import { memo, useCallback } from "react"; - -import { RedisInteraction } from "./redis-interaction.js"; -import { useRedis } from "./use-redis.js"; -import { useTerminalHistory } from "./use-terminal-history.js"; - -export interface RedisViewProps { - resourcePath: string; -} - -const REDIS_HELP_URL = "https://redis.io/commands"; - -export const RedisInteractionView = memo(({ resourcePath }: RedisViewProps) => { - const { usePersistentState } = createPersistentState(resourcePath); - - const [command, setCommand] = usePersistentState(""); - const { - commandHistory, - terminalHistory, - cmdIndex, - setCmdIndex, - updateTerminalHistory, - updateCommandHistory, - clearTerminalHistory, - } = useTerminalHistory({ - useState: usePersistentState, - }); - - const { isLoading, redisUrl, execCommand } = useRedis({ resourcePath }); - - const executeCommand = useCallback( - async (command: string) => { - if (command === "") { - return; - } - - updateCommandHistory(command, true); - - switch (command.toLowerCase()) { - case "help": { - window.open(REDIS_HELP_URL, "_blank"); - updateTerminalHistory([ - { type: "message", message: command }, - { - type: "message", - message: "No problem! Let me just open this url for you", - }, - { - type: "message", - message: REDIS_HELP_URL, - }, - ]); - break; - } - case "clear": { - clearTerminalHistory(); - break; - } - default: { - updateTerminalHistory([{ type: "command", message: command }]); - execCommand(command).then((result) => { - updateTerminalHistory([{ type: "message", message: result }]); - }); - } - } - }, - [ - execCommand, - updateCommandHistory, - updateTerminalHistory, - clearTerminalHistory, - ], - ); - - const handleOnInputChange = useCallback( - (event: React.ChangeEvent) => { - setCommand(event.target.value); - if (cmdIndex === 0) { - updateCommandHistory(event.target.value); - } - }, - [cmdIndex, setCommand, updateCommandHistory], - ); - - const handleOnEnter = useCallback(async () => { - await executeCommand(command); - setCommand(""); - }, [command, executeCommand, setCommand]); - - const handleOnArrowUp = useCallback( - async (event: React.KeyboardEvent) => { - event.preventDefault(); - const newIndex = Math.min(commandHistory.length - 1, cmdIndex + 1); - setCmdIndex(newIndex); - setCommand(commandHistory[newIndex] ?? ""); - }, - [cmdIndex, commandHistory, setCmdIndex, setCommand], - ); - - const handleOnArrowDown = useCallback( - async (event: React.KeyboardEvent) => { - event.preventDefault(); - const newIndex = Math.max(0, cmdIndex - 1); - setCmdIndex(newIndex); - setCommand(commandHistory[newIndex] ?? ""); - }, - [cmdIndex, commandHistory, setCmdIndex, setCommand], - ); - - return ( - - ); -}); diff --git a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/redis-interaction.tsx b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/redis-interaction.tsx deleted file mode 100644 index c5485a1ebbf..00000000000 --- a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/redis-interaction.tsx +++ /dev/null @@ -1,140 +0,0 @@ -import { Attribute, useTheme } from "@wingconsole/design-system"; -import classNames from "classnames"; -import { useCallback, useEffect, useId, useRef } from "react"; - -import type { TerminalHistoryItem } from "../shared/terminal.js"; - -const REDIS_PROMPT = "redis>"; - -export interface RedisInteractionProps { - isLoading: boolean; - url: string; - currentCommand: string; - terminalHistory: TerminalHistoryItem[]; - onInputChange: (event: React.ChangeEvent) => void; - onEnter: () => void; - onArrowUp: (event: React.KeyboardEvent) => void; - onArrowDown: (event: React.KeyboardEvent) => void; -} - -export const RedisInteraction = ({ - isLoading, - url, - currentCommand, - terminalHistory, - onInputChange, - onArrowDown, - onArrowUp, - onEnter, -}: RedisInteractionProps) => { - const { theme } = useTheme(); - const inputId = useId(); - const inputRef = useRef(null); - const scrollableRef = useRef(null); - - const onInputKeyDown = useCallback( - async (event: React.KeyboardEvent) => { - switch (event.key) { - case "Enter": { - onEnter(); - break; - } - case "ArrowUp": { - onArrowUp(event); - break; - } - case "ArrowDown": { - onArrowDown(event); - break; - } - } - }, - [onArrowDown, onArrowUp, onEnter], - ); - - useEffect(() => { - inputRef.current?.focus(); - }, [isLoading]); - - // scroll to bottom - useEffect(() => { - scrollableRef.current?.scrollTo({ - top: scrollableRef.current.scrollHeight, - }); - }, [terminalHistory]); - - return ( -
- -
- -
- {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */} -
{ - if (window.getSelection()?.toString() !== "") { - return; - } - inputRef.current?.focus(); - }} - > -
- {terminalHistory.map((log, index) => ( -
- {log.type === "command" && ( -
- {REDIS_PROMPT} -
- )} -

- {log.message} -

-
- ))} -
-
- {REDIS_PROMPT} -
- -
-
-
-
-
-
- ); -}; diff --git a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/resource-interaction-view.tsx b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/resource-interaction-view.tsx index 6701856714b..9d26e2fe55d 100644 --- a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/resource-interaction-view.tsx +++ b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/resource-interaction-view.tsx @@ -6,9 +6,7 @@ import { CounterInteractionView } from "./counter-interaction-view.js"; import { EndpointInteractionView } from "./endpoint-interaction-view.js"; import { FunctionInteractionView } from "./function-interaction-view.js"; import { QueueInteractionView } from "./queue-interaction-view.js"; -import { RedisInteractionView } from "./redis-interaction-view.js"; import { ScheduleInteractionView } from "./schedule-interaction-view.js"; -import { TableInteractionView } from "./table-interaction-view.js"; import { TopicInteractionView } from "./topic-interaction-view.js"; import { UnsupportedInteractionView } from "./unsupported-interaction-view.js"; import { WebsiteInteractionView } from "./website-interaction-view.js"; @@ -40,15 +38,9 @@ export const ResourceInteractionView = memo( case "@winglang/sdk.cloud.Topic": { return ; } - case "@winglang/sdk.ex.Table": { - return ; - } case "@winglang/sdk.cloud.Schedule": { return ; } - case "@winglang/sdk.ex.Redis": { - return ; - } case "@winglang/sdk.cloud.Website": { return ; } diff --git a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/resource-metadata.tsx b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/resource-metadata.tsx index 097bcd7abef..9f5e0869762 100644 --- a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/resource-metadata.tsx +++ b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/resource-metadata.tsx @@ -144,28 +144,12 @@ export const ResourceMetadata = memo( break; } - case "@winglang/sdk.ex.Table": { - resourceGroup = { - groupName: "Table", - icon, - }; - - break; - } case "@winglang/sdk.cloud.Schedule": { resourceGroup = { groupName: "Schedule", icon, }; - break; - } - case "@winglang/sdk.ex.Redis": { - resourceGroup = { - groupName: "Redis", - icon, - }; - break; } } @@ -304,9 +288,7 @@ export const ResourceMetadata = memo( )} - {(node.type.startsWith("@winglang/sdk.cloud") || - node.type.startsWith("@winglang/sdk.redis") || - node.type.startsWith("@winglang/sdk.ex")) && ( + {node.type.startsWith("@winglang/sdk.cloud") && ( <> { - const notifications = useNotifications(); - - const showError = useCallback( - (error: string) => { - notifications.showNotification("Error", { - body: error, - type: "error", - }); - }, - [notifications], - ); - - const { table, editRow, removeRow, addRow, loading } = useTable({ - resourcePath, - }); - - const [rows, setRows] = useState([]); - - const handleError = useCallback( - (row: RowData, error: string) => { - const primaryKey = table.data?.primaryKey; - if (!primaryKey) { - return; - } - - const index = rows.findIndex( - (r) => r.data[primaryKey] === row[primaryKey], - ); - - if (index >= 0) { - setRows((rows) => { - const newRows = [...rows]; - newRows[index] = { - data: row, - error, - }; - return newRows; - }); - } - - showError(`Row "${row[primaryKey]}": ${error}`); - }, - [setRows, showError, rows, table.data?.primaryKey], - ); - - const onAddRow = useCallback( - async (row: RowData) => { - try { - await addRow(row); - } catch (error: any) { - const primaryKey = table.data?.primaryKey; - if (!primaryKey) { - return; - } - showError(error.message); - } - }, - [addRow, showError, table.data?.primaryKey], - ); - - const onRemoveRow = useCallback( - async (index: number) => { - await removeRow(index); - }, - [removeRow], - ); - - const onEditRow = useCallback( - async (row: any) => { - try { - await editRow(row); - } catch (error: any) { - handleError(row, error.message); - } - }, - [editRow, handleError], - ); - - useEffect(() => { - if (table.data?.rows) { - const rows = table.data.rows.map((row) => { - return { - data: row, - error: "", - }; - }); - setRows(rows); - } - }, [table.data?.rows]); - - return ( -
-
-
-
- -
- -
- -
-
-
-
- ); - }, -); diff --git a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/table-interaction.stories.tsx b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/table-interaction.stories.tsx deleted file mode 100644 index f7c134675e0..00000000000 --- a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/table-interaction.stories.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import type { Meta, StoryObj } from "@storybook/react"; - -import { TableInteraction } from "./table-interaction.js"; - -const meta = { - title: "UI/TableInteraction", - component: TableInteraction, - tags: ["autodocs"], -} satisfies Meta; - -export default meta; - -type Story = StoryObj; - -const columns = [ - { name: "id", type: "string" }, - { name: "date", type: "date" }, - { name: "age", type: "number" }, - { name: "active", type: "boolean" }, -]; - -const rows = [ - { - data: { - id: "1", - name: "foo", - age: 10, - active: true, - date: "2021-01-01", - }, - }, - { - data: { - id: "2", - name: "bar", - age: 20, - active: false, - date: "2022-02-02", - }, - }, - { - data: { - id: "3", - name: "baz", - age: 30, - active: true, - date: "2023-03-03", - }, - }, -]; - -export const Default: Story = { - args: { - primaryKey: "id", - columns, - rows, - disabled: false, - }, -}; - -export const EmptyTable: Story = { - args: { - primaryKey: "id", - columns, - rows: [], - disabled: false, - }, -}; - -export const ReadonlyTable: Story = { - args: { - primaryKey: "id", - columns, - rows: [ - ...rows, - { - data: { - id: "4", - name: "bar", - active: false, - }, - }, - { - data: { - id: "5", - name: "bar", - active: false, - date: "2022-02-02", - }, - }, - ], - readonly: true, - }, -}; - -export const TableWithErrors: Story = { - args: { - primaryKey: "id", - columns, - rows: [ - ...rows, - { - data: { - id: "4", - name: "bar", - age: "asd", - active: false, - date: "2022-02-02", - }, - error: "Invalid age", - }, - { - data: { - id: "5", - name: "baz", - age: 30, - active: true, - date: "2023-03-03", - }, - }, - ], - disabled: false, - }, -}; diff --git a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/table-interaction.tsx b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/table-interaction.tsx deleted file mode 100644 index 60916ca174a..00000000000 --- a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/table-interaction.tsx +++ /dev/null @@ -1,292 +0,0 @@ -import { PlusIcon, TrashIcon } from "@heroicons/react/24/outline"; -import type { Column } from "@wingconsole/design-system"; -import { - SpinnerLoader, - useTheme, - TableRow, - getInputType, -} from "@wingconsole/design-system"; -import { createPersistentState } from "@wingconsole/use-persistent-state"; -import classNames from "classnames"; -import { memo, useCallback, useEffect, useRef, useState } from "react"; - -export type RowData = Record; - -export type Row = { - data: RowData; - error?: string; -}; - -export interface TableInteractionProps { - resourceId: string; - primaryKey?: string; - columns?: Column[]; - rows?: Row[]; - onAddRow?: (row: RowData) => void; - onRemoveRow?: (index: number) => void; - onEditRow?: (row: RowData) => void; - disabled?: boolean; - readonly?: boolean; - loading?: boolean; -} - -export const TableInteraction = memo( - ({ - resourceId, - primaryKey = "", - columns = [], - rows = [], - onAddRow = (row: RowData) => {}, - onRemoveRow = (index: number) => {}, - onEditRow = (row: RowData) => {}, - disabled = false, - readonly = false, - loading = false, - }: TableInteractionProps) => { - const { theme } = useTheme(); - const { usePersistentState } = createPersistentState(resourceId); - - const [newRow, setNewRow] = usePersistentState({ - data: {}, - error: "", - }); - const [internalRows, setInternalRows] = useState([]); - const inputRef = useRef(null); - - const addRow = useCallback(async () => { - const row = newRow.data; - if (row[primaryKey] === undefined) { - return; - } - onAddRow(row); - setNewRow({ data: {}, error: "" }); - }, [newRow, onAddRow, primaryKey, setNewRow]); - - const updateNewRow = useCallback( - (key: string, newValue: any) => { - setNewRow((newRow) => ({ - data: { - ...newRow.data, - [key]: newValue, - }, - error: "", - })); - }, - [setNewRow], - ); - - const editRow = useCallback( - async (index: number, row: RowData) => { - if (rows[index]?.data === row) { - return; - } - onEditRow(row); - }, - [onEditRow, rows], - ); - - const updateRow = useCallback( - (index: number, row: RowData, key: string, newValue: any) => { - const newRow = { - ...row, - [key]: newValue, - }; - const newRows = [...internalRows]; - newRows[index] = { - data: newRow, - error: "", - }; - setInternalRows(newRows); - }, - [internalRows, setInternalRows], - ); - - useEffect(() => { - setInternalRows(rows); - }, [rows]); - - useEffect(() => { - inputRef.current?.focus(); - }, [internalRows.length]); - - return ( -
-
- {loading && ( -
-
- -
-
- )} - - - - {columns.map(({ name, type }) => ( - - ))} - - - - - {internalRows.length === 0 && ( - - - - )} - {internalRows.map(({ data: row, error }, index) => ( - editRow(index, row)} - updateRow={(key, value) => updateRow(index, row, key, value)} - actions={ - <> - {!readonly && ( - - )} - - } - dataTestid={`ex.table:row-${row[primaryKey]}`} - /> - ))} - {!readonly && columns.length > 0 && ( - <> - - - - updateNewRow(key, value)} - dataTestid="ex.table:new-row" - actions={ - - } - /> - - )} - -
- {`${name}${name === primaryKey ? "*" : ""}`} -
- No rows -
-
-
- NEW ROW -
-
-
-
-
- ); - }, -); diff --git a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/use-redis.ts b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/use-redis.ts deleted file mode 100644 index d788ba29ef8..00000000000 --- a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/use-redis.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { useEffect, useMemo, useState } from "react"; - -import { trpc } from "../../../trpc.js"; - -export interface UseRedisOptions { - resourcePath: string; -} -export const useRedis = ({ resourcePath }: UseRedisOptions) => { - const info = trpc["redis.info"].useQuery({ resourcePath }); - const exec = trpc["redis.exec"].useMutation(); - - const [redisUrl, setRedisUrl] = useState(""); - - useEffect(() => { - if (info.data) { - setRedisUrl(info.data.url); - } - }, [info.data]); - - const execCommand = async (command: string) => { - return exec.mutateAsync({ - resourcePath, - command, - }); - }; - - const isLoading = useMemo(() => { - return exec.isLoading; - }, [exec.isLoading]); - - return { - execCommand, - isLoading, - redisUrl, - }; -}; diff --git a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/use-table.tsx b/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/use-table.tsx deleted file mode 100644 index aed43ac274d..00000000000 --- a/apps/wing-console/console/ui/src/features/inspector-pane/resource-panes/use-table.tsx +++ /dev/null @@ -1,69 +0,0 @@ -import { useCallback, useMemo } from "react"; - -import { trpc } from "../../../trpc.js"; - -export interface UseTableOptions { - resourcePath: string; -} - -export const useTable = ({ resourcePath }: UseTableOptions) => { - const table = trpc["table.info"].useQuery({ resourcePath }); - const tableInsert = trpc["table.insert"].useMutation(); - const tableUpdate = trpc["table.update"].useMutation(); - const tableDelete = trpc["table.delete"].useMutation(); - - const addRow = useCallback( - async (row: any) => { - await tableInsert.mutateAsync({ - resourcePath, - data: row, - }); - }, - [tableInsert, resourcePath], - ); - - const removeRow = useCallback( - async (index: number) => { - if (!table.data?.rows[index]) { - return; - } - await tableDelete.mutateAsync({ - resourcePath, - data: table.data.rows[index] || {}, - }); - }, - [tableDelete, resourcePath, table.data?.rows], - ); - - const editRow = useCallback( - async (row: any) => { - await tableUpdate.mutateAsync({ - resourcePath, - data: row, - }); - }, - [tableUpdate, resourcePath], - ); - - const loading = useMemo(() => { - return ( - table.isFetching || - tableInsert.isLoading || - tableUpdate.isLoading || - tableDelete.isLoading - ); - }, [ - tableInsert.isLoading, - tableUpdate.isLoading, - tableDelete.isLoading, - table.isFetching, - ]); - - return { - table, - addRow, - removeRow, - editRow, - loading, - }; -}; diff --git a/docs/api/03-language/08-classes.md b/docs/api/03-language/08-classes.md index 96155a2e10a..02ae51ad50b 100644 --- a/docs/api/03-language/08-classes.md +++ b/docs/api/03-language/08-classes.md @@ -98,7 +98,6 @@ class BucketBasedKeyValueStore impl IKVStore { ### Complete IKVStore ```js playground example bring cloud; -bring ex; interface IKVStore extends std.IResource { inflight get(key: str): Json; @@ -118,27 +117,7 @@ class BucketBasedKeyValueStore impl IKVStore { } } -class TableBasedKeyValueStore impl IKVStore { - table: ex.Table; - new() { - this.table = new ex.Table( - name: "table", - primaryKey: "key", - columns: { - value: ex.ColumnType.STRING - } - ); - } - pub inflight get(key: str): Json { - return this.table.get(key); - } - pub inflight set(key: str, value: Json) { - this.table.insert(key, value); - } -} - let bucketBased: IKVStore = new BucketBasedKeyValueStore(); -let tableBased: IKVStore = new TableBasedKeyValueStore(); test "bucketBased KVStore" { bucketBased.set("k", Json { @@ -148,13 +127,4 @@ test "bucketBased KVStore" { log("{result.get("value")}"); assert("v" == str.fromJson(result.get("value"))); } - -test "tableBased KVStore" { - tableBased.set("k", Json { - value: "v" - }); - let result = tableBased.get("k"); - log("{result.get("value")}"); - assert("v" == str.fromJson(result.get("value"))); -} -``` \ No newline at end of file +``` diff --git a/docs/api/04-standard-library/aws/api-reference.md b/docs/api/04-standard-library/aws/api-reference.md index c6ad1fb16c9..4c3e6135823 100644 --- a/docs/api/04-standard-library/aws/api-reference.md +++ b/docs/api/04-standard-library/aws/api-reference.md @@ -1182,52 +1182,6 @@ The queue consumer handler. -### Table - -A helper class for working with AWS tables. - -#### Initializers - -```wing -bring aws; - -new aws.Table(); -``` - -| **Name** | **Type** | **Description** | -| --- | --- | --- | - ---- - - -#### Static Functions - -| **Name** | **Description** | -| --- | --- | -| from | If the table is an AWS DynamoDB, return a helper interface for working with it. | - ---- - -##### `from` - -```wing -bring aws; - -aws.Table.from(table: Table); -``` - -If the table is an AWS DynamoDB, return a helper interface for working with it. - -###### `table`Required - -- *Type:* Table - -The ex.Table. - ---- - - - ### Topic A helper class for working with AWS topics. @@ -1917,46 +1871,6 @@ AWS Queue url. --- -### IAwsTable - -- *Implemented By:* IAwsTable - -A shared interface for AWS tables. - - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| dynamoTableArn | str | AWS Table arn. | -| dynamoTableName | str | AWS Table name. | - ---- - -##### `dynamoTableArn`Required - -```wing -dynamoTableArn: str; -``` - -- *Type:* str - -AWS Table arn. - ---- - -##### `dynamoTableName`Required - -```wing -dynamoTableName: str; -``` - -- *Type:* str - -AWS Table name. - ---- - ### IAwsTopic - *Implemented By:* IAwsTopic diff --git a/docs/api/04-standard-library/cloud/api.md b/docs/api/04-standard-library/cloud/api.md index 5127273d45e..9fa20b935f9 100644 --- a/docs/api/04-standard-library/cloud/api.md +++ b/docs/api/04-standard-library/cloud/api.md @@ -27,28 +27,21 @@ When a client invokes a route, the corresponding event handler function executes ### REST API -The following example shows a complete REST API implementation using `cloud.Api`, `ex.Table` & `cloud.Counter` +The following example shows a complete REST API implementation using `cloud.Api`, `cloud.Bucket` & `cloud.Counter` ```ts playground example bring cloud; -bring ex; let api = new cloud.Api(); // Used for generating unique id let counter = new cloud.Counter(); -// our employee database -let db = new ex.Table( - name: "employees", - primaryKey: "id", - columns: { - "name" => ex.ColumnType.STRING - } -); +// our employee data +let store = new cloud.Bucket(); api.get("/employees", inflight (request: cloud.ApiRequest): cloud.ApiResponse => { let result = MutJson []; let var i = 0; - for employee in db.list() { + for employee in store.list() { result.setAt(i, employee); i = i + 1; } @@ -60,7 +53,7 @@ api.get("/employees", inflight (request: cloud.ApiRequest): cloud.ApiResponse => api.get("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiResponse => { - let employee = db.get(request.vars.get("id")); + let employee = store.get(request.vars.get("id")); return cloud.ApiResponse { status: 200, body: Json.stringify(employee) @@ -71,7 +64,7 @@ api.post("/employees", inflight (request: cloud.ApiRequest): cloud.ApiResponse = if let body = request.body { let employeeData = Json.parse(body); let id = "{counter.inc()}"; - db.insert(id, employeeData); + store.putJson(id, employeeData); return cloud.ApiResponse { status: 201, body: id @@ -83,7 +76,7 @@ api.put("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiRespons if let body = request.body { let employeeData = Json.parse(body); let id = request.vars.get("id"); - db.update(id, employeeData); + store.putJson(id, employeeData); return cloud.ApiResponse { status: 200, body: Json.stringify(employeeData) @@ -93,7 +86,7 @@ api.put("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiRespons api.delete("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiResponse => { let id = request.vars.get("id"); - db.delete(id); + store.delete(id); return cloud.ApiResponse { status: 204 }; diff --git a/docs/api/04-standard-library/ex/_category_.yml b/docs/api/04-standard-library/ex/_category_.yml deleted file mode 100644 index 3a23b22d46d..00000000000 --- a/docs/api/04-standard-library/ex/_category_.yml +++ /dev/null @@ -1,5 +0,0 @@ -label: ex -collapsible: true -collapsed: true -link: - type: generated-index \ No newline at end of file diff --git a/docs/api/04-standard-library/ex/react-app.md b/docs/api/04-standard-library/ex/react-app.md deleted file mode 100644 index 954a38305e0..00000000000 --- a/docs/api/04-standard-library/ex/react-app.md +++ /dev/null @@ -1,441 +0,0 @@ ---- -title: React App -id: react-app -description: A built-in resource for creating deployable websites using the React framework. -keywords: [Website, React, deployment, build] -sidebar_position: 1 ---- - -The `ex.ReactApp` resource represents a website, built using React, that can be both hosted in the cloud or to run on a development hot-reload server in the sim target. - -## Usage - -### Initialization - -Using the default arguments: - -```ts -bring ex; -bring util; - -let website = new ex.ReactApp(projectPath: "./client"); -``` - -or customizing them: - -```ts -bring ex; -bring util; - -let website = new ex.ReactApp( - projectPath: "./client", - useBuildCommand: true // `false` by default. Will run the build command if true, and the start command if not - buildDir: "/dist" // default is "/build" - startCommand: "pnpm start" // default is "npm start" - buildCommand: "pnpm build" // default is "npm build" - localPort: 4000 // default is 3001 - ); -``` - -When `ReactApp` is compiled to the `sim` target, by default it runs the start command (default: `npm start`) inside `projectPath` to serve your app in development mode on a local port. - -If the `useBuildCommand` environment variable is set OR if `ReactApp` is compiled to any other target, it will run the build command (default: `npm build`) inside of the `projectPath` to build the React app for production to `buildDir` and serve the app. - -### Using Wing variables within react code - -`ex.ReactApp` allows you to pass preflight string values from Wing to the React app using `addEnvironment` method: - -```ts -bring cloud; -bring util; -bring ex; - -let api = new cloud.Api(); -let website = new ex.ReactApp(projectPath: "./client"); - -website.addEnvironment("apiUrl", api.url); -website.addEnvironment("another", "some string variable"); - -``` - -Then in the React app use `window.wingEnv`: -(accessible after adding `` to the index file) - -```ts -const { apiUrl } = window.wingEnv; -const users = await fetch(apiUrl + "/users"); -``` - -Currently, we can only pass preflight string variables to the React app environment. - -## Target-specific details - -### Simulator (`sim`) - -sim implementations of `ex.ReactApp` is using either the [Website resource](../cloud/website) (when `useBuildCommand` is `true`) or starts React development server when `false`. - -### AWS (`tf-aws` and `awscdk`) - -AWS implementations of `ex.ReactApp` uses the [Website resource](../cloud/website). - -### Azure (`tf-azure`) - -🚧 Not supported yet (tracking issue: [#4220](https://github.com/winglang/wing/issues/4220)) - -### GCP (`tf-gcp`) - -🚧 Not supported yet (tracking issue: [#4221](https://github.com/winglang/wing/issues/4221)) -# API Reference - -## Resources - -### ReactApp - -A cloud deployable React App. - -#### Initializers - -```wing -bring ex; - -new ex.ReactApp(props: ReactAppProps); -``` - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| props | ReactAppProps | *No description.* | - ---- - -##### `props`Required - -- *Type:* ReactAppProps - ---- - -#### Methods - -##### Preflight Methods - -| **Name** | **Description** | -| --- | --- | -| addEnvironment | Adding a key-value pair that can be accessible later via the `window.wingEnv` object in the react code. | - ---- - -##### `addEnvironment` - -```wing -addEnvironment(key: str, value: str): void -``` - -Adding a key-value pair that can be accessible later via the `window.wingEnv` object in the react code. - -###### `key`Required - -- *Type:* str - -the key to add. - ---- - -###### `value`Required - -- *Type:* str - -the value to add. - ---- - -#### Static Functions - -| **Name** | **Description** | -| --- | --- | -| onLiftType | A hook called by the Wing compiler once for each inflight host that needs to use this type inflight. | - ---- - -##### `onLiftType` - -```wing -bring ex; - -ex.ReactApp.onLiftType(host: IInflightHost, ops: MutArray); -``` - -A hook called by the Wing compiler once for each inflight host that needs to use this type inflight. - -The list of requested inflight methods -needed by the inflight host are given by `ops`. - -This method is commonly used for adding permissions, environment variables, or -other capabilities to the inflight host. - -###### `host`Required - -- *Type:* IInflightHost - ---- - -###### `ops`Required - -- *Type:* MutArray<str> - ---- - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| url | str | Website's url. | - ---- - -##### `node`Required - -```wing -node: Node; -``` - -- *Type:* constructs.Node - -The tree node. - ---- - -##### `url`Required - -```wing -url: str; -``` - -- *Type:* str - -Website's url. - ---- - - - -## Structs - -### ReactAppOptions - -Basic options for `ReactApp`. - -#### Initializer - -```wing -bring ex; - -let ReactAppOptions = ex.ReactAppOptions{ ... }; -``` - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| projectPath | str | The path to the React app root folder- can be absolute or relative to the wing folder. | -| buildCommand | str | A command for building the React app. | -| buildDir | str | The path to the React app build folder- relative to the `projectPath`. | -| localPort | num | A port to start a local build of the React app on. | -| startCommand | str | A command for starting React app locally. | -| useBuildCommand | bool | In sim, if `true` - will use the start command, and if `false` - the build command. | - ---- - -##### `projectPath`Required - -```wing -projectPath: str; -``` - -- *Type:* str - -The path to the React app root folder- can be absolute or relative to the wing folder. - ---- - -##### `buildCommand`Optional - -```wing -buildCommand: str; -``` - -- *Type:* str -- *Default:* "npm run build" - -A command for building the React app. - ---- - -##### `buildDir`Optional - -```wing -buildDir: str; -``` - -- *Type:* str -- *Default:* "/build" - -The path to the React app build folder- relative to the `projectPath`. - ---- - -##### `localPort`Optional - -```wing -localPort: num; -``` - -- *Type:* num -- *Default:* 3001 - -A port to start a local build of the React app on. - ---- - -##### `startCommand`Optional - -```wing -startCommand: str; -``` - -- *Type:* str -- *Default:* "npm run start" - -A command for starting React app locally. - ---- - -##### `useBuildCommand`Optional - -```wing -useBuildCommand: bool; -``` - -- *Type:* bool -- *Default:* false - -In sim, if `true` - will use the start command, and if `false` - the build command. - ---- - -### ReactAppProps - -Options for `ReactApp`. - -#### Initializer - -```wing -bring ex; - -let ReactAppProps = ex.ReactAppProps{ ... }; -``` - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| domain | Domain | The website's custom domain object. | -| projectPath | str | The path to the React app root folder- can be absolute or relative to the wing folder. | -| buildCommand | str | A command for building the React app. | -| buildDir | str | The path to the React app build folder- relative to the `projectPath`. | -| localPort | num | A port to start a local build of the React app on. | -| startCommand | str | A command for starting React app locally. | -| useBuildCommand | bool | In sim, if `true` - will use the start command, and if `false` - the build command. | - ---- - -##### `domain`Optional - -```wing -domain: Domain; -``` - -- *Type:* Domain -- *Default:* undefined - -The website's custom domain object. - ---- - -##### `projectPath`Required - -```wing -projectPath: str; -``` - -- *Type:* str - -The path to the React app root folder- can be absolute or relative to the wing folder. - ---- - -##### `buildCommand`Optional - -```wing -buildCommand: str; -``` - -- *Type:* str -- *Default:* "npm run build" - -A command for building the React app. - ---- - -##### `buildDir`Optional - -```wing -buildDir: str; -``` - -- *Type:* str -- *Default:* "/build" - -The path to the React app build folder- relative to the `projectPath`. - ---- - -##### `localPort`Optional - -```wing -localPort: num; -``` - -- *Type:* num -- *Default:* 3001 - -A port to start a local build of the React app on. - ---- - -##### `startCommand`Optional - -```wing -startCommand: str; -``` - -- *Type:* str -- *Default:* "npm run start" - -A command for starting React app locally. - ---- - -##### `useBuildCommand`Optional - -```wing -useBuildCommand: bool; -``` - -- *Type:* bool -- *Default:* false - -In sim, if `true` - will use the start command, and if `false` - the build command. - ---- - - diff --git a/docs/api/04-standard-library/ex/redis.md b/docs/api/04-standard-library/ex/redis.md deleted file mode 100644 index 6c69132ab9c..00000000000 --- a/docs/api/04-standard-library/ex/redis.md +++ /dev/null @@ -1,458 +0,0 @@ ---- -title: Redis -id: redis -description: A cloud redis db. -keywords: [Redis, DB, database, store, cache] -sidebar_position: 1 ---- -# API Reference - -## Resources - -### Redis - -A cloud redis db. - -#### Initializers - -```wing -bring ex; - -new ex.Redis(); -``` - -| **Name** | **Type** | **Description** | -| --- | --- | --- | - ---- - -#### Methods - -##### Inflight Methods - -| **Name** | **Description** | -| --- | --- | -| del | Removes the specified key. | -| get | Get value at given key. | -| hget | Returns the value associated with field in the hash stored at key. | -| hset | Sets the specified field to respective value in the hash stored at key. | -| sadd | Add the specified members to the set stored at key. | -| set | Set key value pair. | -| smembers | Returns all the members of the set value stored at key. | -| url | Get url of redis server. | - ---- - -##### `del` - -```wing -inflight del(key: str): num -``` - -Removes the specified key. - -###### `key`Required - -- *Type:* str - -the key. - ---- - -##### `get` - -```wing -inflight get(key: str): str? -``` - -Get value at given key. - -###### `key`Required - -- *Type:* str - -the key to get. - ---- - -##### `hget` - -```wing -inflight hget(key: str, field: str): str? -``` - -Returns the value associated with field in the hash stored at key. - -###### `key`Required - -- *Type:* str - -the key. - ---- - -###### `field`Required - -- *Type:* str - -the field at given key. - ---- - -##### `hset` - -```wing -inflight hset(key: str, field: str, value: str): num -``` - -Sets the specified field to respective value in the hash stored at key. - -###### `key`Required - -- *Type:* str - -key to set. - ---- - -###### `field`Required - -- *Type:* str - -field in key to set. - ---- - -###### `value`Required - -- *Type:* str - -value to set at field in key. - ---- - -##### `sadd` - -```wing -inflight sadd(key: str, value: str): num -``` - -Add the specified members to the set stored at key. - -###### `key`Required - -- *Type:* str - -the key. - ---- - -###### `value`Required - -- *Type:* str - -the value to add to the set at given key. - ---- - -##### `set` - -```wing -inflight set(key: str, value: str): void -``` - -Set key value pair. - -###### `key`Required - -- *Type:* str - -the key to set. - ---- - -###### `value`Required - -- *Type:* str - -the value to store at given key. - ---- - -##### `smembers` - -```wing -inflight smembers(key: str): MutArray -``` - -Returns all the members of the set value stored at key. - -###### `key`Required - -- *Type:* str - -the key. - ---- - -##### `url` - -```wing -inflight url(): str -``` - -Get url of redis server. - -#### Static Functions - -| **Name** | **Description** | -| --- | --- | -| onLiftType | A hook called by the Wing compiler once for each inflight host that needs to use this type inflight. | -| toInflight | Generates an asynchronous JavaScript statement which can be used to create an inflight client for a resource. | - ---- - -##### `onLiftType` - -```wing -bring ex; - -ex.Redis.onLiftType(host: IInflightHost, ops: MutArray); -``` - -A hook called by the Wing compiler once for each inflight host that needs to use this type inflight. - -The list of requested inflight methods -needed by the inflight host are given by `ops`. - -This method is commonly used for adding permissions, environment variables, or -other capabilities to the inflight host. - -###### `host`Required - -- *Type:* IInflightHost - ---- - -###### `ops`Required - -- *Type:* MutArray<str> - ---- - -##### `toInflight` - -```wing -bring ex; - -ex.Redis.toInflight(obj: IResource); -``` - -Generates an asynchronous JavaScript statement which can be used to create an inflight client for a resource. - -NOTE: This statement must be executed within an async context. - -###### `obj`Required - -- *Type:* IResource - ---- - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | - ---- - -##### `node`Required - -```wing -node: Node; -``` - -- *Type:* constructs.Node - -The tree node. - ---- - - -## Classes - -### RedisClientBase - -- *Implements:* IRedisClient - -Base class for `Redis` Client. - -#### Initializers - -```wing -bring ex; - -new ex.RedisClientBase(); -``` - -| **Name** | **Type** | **Description** | -| --- | --- | --- | - ---- - -#### Methods - -| **Name** | **Description** | -| --- | --- | -| del | Removes the specified key. | -| get | Get value at given key. | -| hget | Returns the value associated with field in the hash stored at key. | -| hset | Sets the specified field to respective value in the hash stored at key. | -| sadd | Add the specified members to the set stored at key. | -| set | Set key value pair. | -| smembers | Returns all the members of the set value stored at key. | -| url | Get url of redis server. | - ---- - -##### `del` - -```wing -del(key: str): num -``` - -Removes the specified key. - -###### `key`Required - -- *Type:* str - ---- - -##### `get` - -```wing -get(key: str): str? -``` - -Get value at given key. - -###### `key`Required - -- *Type:* str - ---- - -##### `hget` - -```wing -hget(key: str, field: str): str? -``` - -Returns the value associated with field in the hash stored at key. - -###### `key`Required - -- *Type:* str - ---- - -###### `field`Required - -- *Type:* str - ---- - -##### `hset` - -```wing -hset(key: str, field: str, value: str): num -``` - -Sets the specified field to respective value in the hash stored at key. - -###### `key`Required - -- *Type:* str - ---- - -###### `field`Required - -- *Type:* str - ---- - -###### `value`Required - -- *Type:* str - ---- - -##### `sadd` - -```wing -sadd(key: str, value: str): num -``` - -Add the specified members to the set stored at key. - -###### `key`Required - -- *Type:* str - ---- - -###### `value`Required - -- *Type:* str - ---- - -##### `set` - -```wing -set(key: str, value: str): void -``` - -Set key value pair. - -###### `key`Required - -- *Type:* str - ---- - -###### `value`Required - -- *Type:* str - ---- - -##### `smembers` - -```wing -smembers(key: str): MutArray -``` - -Returns all the members of the set value stored at key. - -###### `key`Required - -- *Type:* str - ---- - -##### `url` - -```wing -url(): str -``` - -Get url of redis server. - - - - - - diff --git a/docs/api/04-standard-library/ex/table.md b/docs/api/04-standard-library/ex/table.md deleted file mode 100644 index 2b93ebe153d..00000000000 --- a/docs/api/04-standard-library/ex/table.md +++ /dev/null @@ -1,454 +0,0 @@ ---- -title: Table -id: table -description: A NoSQL database table that can be used to store and query data. -keywords: [dynamoDB, NoSQL, store, DB, database, cache] -sidebar_position: 1 ---- -# API Reference - -## Resources - -### Table - -A NoSQL database table that can be used to store and query data. - -#### Initializers - -```wing -bring ex; - -new ex.Table(props: TableProps); -``` - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| props | TableProps | *No description.* | - ---- - -##### `props`Required - -- *Type:* TableProps - ---- - -#### Methods - -##### Preflight Methods - -| **Name** | **Description** | -| --- | --- | -| addRow | Add a row to the table that is created when the app is deployed. | - -##### Inflight Methods - -| **Name** | **Description** | -| --- | --- | -| delete | Delete a row from the table, by primary key. | -| get | Get a row from the table, by primary key. | -| insert | Insert a row into the table. | -| list | List all rows in the table. | -| tryGet | Get a row from the table if exists, by primary key. | -| update | Update a row in the table. | -| upsert | Insert a row into the table if it doesn't exist, otherwise update it. | - ---- - -##### `addRow` - -```wing -addRow(key: str, row: Json): void -``` - -Add a row to the table that is created when the app is deployed. - -###### `key`Required - -- *Type:* str - ---- - -###### `row`Required - -- *Type:* Json - ---- - -##### `delete` - -```wing -inflight delete(key: str): void -``` - -Delete a row from the table, by primary key. - -###### `key`Required - -- *Type:* str - -primary key to delete the row. - ---- - -##### `get` - -```wing -inflight get(key: str): Json -``` - -Get a row from the table, by primary key. - -###### `key`Required - -- *Type:* str - -primary key to search. - ---- - -##### `insert` - -```wing -inflight insert(key: str, row: Json): void -``` - -Insert a row into the table. - -###### `key`Required - -- *Type:* str - -primary key to insert the row. - ---- - -###### `row`Required - -- *Type:* Json - -data to be inserted. - ---- - -##### `list` - -```wing -inflight list(): MutArray -``` - -List all rows in the table. - -##### `tryGet` - -```wing -inflight tryGet(key: str): Json? -``` - -Get a row from the table if exists, by primary key. - -###### `key`Required - -- *Type:* str - -primary key to search. - ---- - -##### `update` - -```wing -inflight update(key: str, row: Json): void -``` - -Update a row in the table. - -###### `key`Required - -- *Type:* str - -primary key to update the row. - ---- - -###### `row`Required - -- *Type:* Json - -data to be updated. - ---- - -##### `upsert` - -```wing -inflight upsert(key: str, row: Json): void -``` - -Insert a row into the table if it doesn't exist, otherwise update it. - -###### `key`Required - -- *Type:* str - -primary key to upsert the row. - ---- - -###### `row`Required - -- *Type:* Json - -data to be upserted. - ---- - -#### Static Functions - -| **Name** | **Description** | -| --- | --- | -| onLiftType | A hook called by the Wing compiler once for each inflight host that needs to use this type inflight. | -| toInflight | Generates an asynchronous JavaScript statement which can be used to create an inflight client for a resource. | - ---- - -##### `onLiftType` - -```wing -bring ex; - -ex.Table.onLiftType(host: IInflightHost, ops: MutArray); -``` - -A hook called by the Wing compiler once for each inflight host that needs to use this type inflight. - -The list of requested inflight methods -needed by the inflight host are given by `ops`. - -This method is commonly used for adding permissions, environment variables, or -other capabilities to the inflight host. - -###### `host`Required - -- *Type:* IInflightHost - ---- - -###### `ops`Required - -- *Type:* MutArray<str> - ---- - -##### `toInflight` - -```wing -bring ex; - -ex.Table.toInflight(obj: IResource); -``` - -Generates an asynchronous JavaScript statement which can be used to create an inflight client for a resource. - -NOTE: This statement must be executed within an async context. - -###### `obj`Required - -- *Type:* IResource - ---- - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| node | constructs.Node | The tree node. | -| columns | MutMap<ColumnType> | Table columns. | -| name | str | Table name. | -| primaryKey | str | Table primary key name. | - ---- - -##### `node`Required - -```wing -node: Node; -``` - -- *Type:* constructs.Node - -The tree node. - ---- - -##### `columns`Required - -```wing -columns: MutMap; -``` - -- *Type:* MutMap<ColumnType> - -Table columns. - ---- - -##### `name`Required - -```wing -name: str; -``` - -- *Type:* str - -Table name. - ---- - -##### `primaryKey`Required - -```wing -primaryKey: str; -``` - -- *Type:* str - -Table primary key name. - ---- - - - -## Structs - -### TableProps - -Properties for `Table`. - -#### Initializer - -```wing -bring ex; - -let TableProps = ex.TableProps{ ... }; -``` - -#### Properties - -| **Name** | **Type** | **Description** | -| --- | --- | --- | -| columns | MutMap<ColumnType> | The table's columns. | -| initialRows | MutMap<Json> | The table's initial rows. | -| name | str | The table's name. | -| primaryKey | str | The table's primary key. | - ---- - -##### `columns`Optional - -```wing -columns: MutMap; -``` - -- *Type:* MutMap<ColumnType> -- *Default:* undefined - -The table's columns. - ---- - -##### `initialRows`Optional - -```wing -initialRows: MutMap; -``` - -- *Type:* MutMap<Json> -- *Default:* undefined - -The table's initial rows. - ---- - -##### `name`Optional - -```wing -name: str; -``` - -- *Type:* str -- *Default:* undefined - -The table's name. - ---- - -##### `primaryKey`Optional - -```wing -primaryKey: str; -``` - -- *Type:* str -- *Default:* undefined - -The table's primary key. - -No two rows can have the same value for the -primary key. - ---- - - -## Enums - -### ColumnType - -Table column types. - -#### Members - -| **Name** | **Description** | -| --- | --- | -| STRING | String type. | -| NUMBER | Number type. | -| BOOLEAN | Bool type. | -| DATE | Date type. | -| JSON | Json type. | - ---- - -##### `STRING` - -String type. - ---- - - -##### `NUMBER` - -Number type. - ---- - - -##### `BOOLEAN` - -Bool type. - ---- - - -##### `DATE` - -Date type. - ---- - - -##### `JSON` - -Json type. - ---- - diff --git a/docs/turbo.json b/docs/turbo.json index 69aaab09a05..249f3ed7ddc 100644 --- a/docs/turbo.json +++ b/docs/turbo.json @@ -4,11 +4,11 @@ "pipeline": { "compile": { "inputs": [ - "docs/**/*.md" + "**/*.md" ], "outputs": [ "../examples/tests/doc_examples/**/*.w" ] } } -} \ No newline at end of file +} diff --git a/examples/tests/doc_examples/valid/08-classes.md_example_4/main.w b/examples/tests/doc_examples/valid/08-classes.md_example_4/main.w index 248a3276315..c3ad7f6f634 100644 --- a/examples/tests/doc_examples/valid/08-classes.md_example_4/main.w +++ b/examples/tests/doc_examples/valid/08-classes.md_example_4/main.w @@ -1,7 +1,6 @@ // This file was auto generated from an example found in: 08-classes.md_example_4 // Example metadata: {"valid":true} bring cloud; -bring ex; interface IKVStore extends std.IResource { inflight get(key: str): Json; @@ -21,27 +20,7 @@ class BucketBasedKeyValueStore impl IKVStore { } } -class TableBasedKeyValueStore impl IKVStore { - table: ex.Table; - new() { - this.table = new ex.Table( - name: "table", - primaryKey: "key", - columns: { - value: ex.ColumnType.STRING - } - ); - } - pub inflight get(key: str): Json { - return this.table.get(key); - } - pub inflight set(key: str, value: Json) { - this.table.insert(key, value); - } -} - let bucketBased: IKVStore = new BucketBasedKeyValueStore(); -let tableBased: IKVStore = new TableBasedKeyValueStore(); test "bucketBased KVStore" { bucketBased.set("k", Json { @@ -51,12 +30,3 @@ test "bucketBased KVStore" { log("{result.get("value")}"); assert("v" == str.fromJson(result.get("value"))); } - -test "tableBased KVStore" { - tableBased.set("k", Json { - value: "v" - }); - let result = tableBased.get("k"); - log("{result.get("value")}"); - assert("v" == str.fromJson(result.get("value"))); -} diff --git a/examples/tests/doc_examples/valid/api.md_example_1/main.w b/examples/tests/doc_examples/valid/api.md_example_1/main.w index eb37179001b..688b0fa8cef 100644 --- a/examples/tests/doc_examples/valid/api.md_example_1/main.w +++ b/examples/tests/doc_examples/valid/api.md_example_1/main.w @@ -1,24 +1,17 @@ // This file was auto generated from an example found in: api.md_example_1 // Example metadata: {"valid":true} bring cloud; -bring ex; let api = new cloud.Api(); // Used for generating unique id let counter = new cloud.Counter(); -// our employee database -let db = new ex.Table( - name: "employees", - primaryKey: "id", - columns: { - "name" => ex.ColumnType.STRING - } -); +// our employee data +let store = new cloud.Bucket(); api.get("/employees", inflight (request: cloud.ApiRequest): cloud.ApiResponse => { let result = MutJson []; let var i = 0; - for employee in db.list() { + for employee in store.list() { result.setAt(i, employee); i = i + 1; } @@ -30,7 +23,7 @@ api.get("/employees", inflight (request: cloud.ApiRequest): cloud.ApiResponse => api.get("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiResponse => { - let employee = db.get(request.vars.get("id")); + let employee = store.get(request.vars.get("id")); return cloud.ApiResponse { status: 200, body: Json.stringify(employee) @@ -41,7 +34,7 @@ api.post("/employees", inflight (request: cloud.ApiRequest): cloud.ApiResponse = if let body = request.body { let employeeData = Json.parse(body); let id = "{counter.inc()}"; - db.insert(id, employeeData); + store.putJson(id, employeeData); return cloud.ApiResponse { status: 201, body: id @@ -53,7 +46,7 @@ api.put("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiRespons if let body = request.body { let employeeData = Json.parse(body); let id = request.vars.get("id"); - db.update(id, employeeData); + store.putJson(id, employeeData); return cloud.ApiResponse { status: 200, body: Json.stringify(employeeData) @@ -63,7 +56,7 @@ api.put("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiRespons api.delete("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiResponse => { let id = request.vars.get("id"); - db.delete(id); + store.delete(id); return cloud.ApiResponse { status: 204 }; diff --git a/examples/tests/sdk_tests/bucket/events.test.w b/examples/tests/sdk_tests/bucket/events.test.w index df4a1e82d02..13a1dd176b7 100644 --- a/examples/tests/sdk_tests/bucket/events.test.w +++ b/examples/tests/sdk_tests/bucket/events.test.w @@ -1,5 +1,4 @@ bring cloud; -bring ex; bring util; enum Source { @@ -9,21 +8,10 @@ enum Source { let b = new cloud.Bucket(); let idsCounter = new cloud.Counter(); -let table = new ex.Table( - name: "key-history", - primaryKey: "_id", - columns: { - "_id" => ex.ColumnType.STRING, - "key" => ex.ColumnType.STRING, - "operation" => ex.ColumnType.STRING, - "source" => ex.ColumnType.STRING, - } -); - - +let logs = new cloud.Bucket() as "LogHistory"; let logHistory = inflight (key: str, operation: str, source: Source) => { - table.insert("{idsCounter.inc()}", Json { key: key, operation: operation, source: "{source}" }); + logs.putJson("{idsCounter.inc()}", Json { key: key, operation: operation, source: "{source}" }); }; @@ -55,8 +43,9 @@ let checkHitCount = inflight (opts: CheckHitCountOptions): void => { util.waitUntil(inflight () => { let var count = 0; - for u in table.list() { - if (u.get("key") == opts.key && u.get("operation") == opts.type && u.get("source") == "{opts.source}") { + for u in logs.list() { + let data = logs.getJson(u); + if (data.get("key") == opts.key && data.get("operation") == opts.type && data.get("source") == "{opts.source}") { count = count + 1; } } diff --git a/examples/tests/sdk_tests/table/add_row.test.w b/examples/tests/sdk_tests/table/add_row.test.w deleted file mode 100644 index 1f3b2c36388..00000000000 --- a/examples/tests/sdk_tests/table/add_row.test.w +++ /dev/null @@ -1,27 +0,0 @@ -bring ex; -bring util; - -let table = new ex.Table( - name: "users", - primaryKey: "name", - columns: { - "gender" => ex.ColumnType.STRING, - "role" => ex.ColumnType.STRING - } -); - -let marioInfo = Json { gender: "male", role: "plumber" }; -let peachInfo = Json { gender: "female", role: "princess" }; -table.addRow("mario", marioInfo); -table.addRow("peach", peachInfo); - - -test "addRow" { - assert(table.get("mario").get("name") == "mario"); - assert(table.get("mario").get("role") == marioInfo.get("role")); - assert(table.get("mario").get("gender") == marioInfo.get("gender")); - - assert(table.get("peach").get("name") == "peach"); - assert(table.get("peach").get("role") == peachInfo.get("role")); - assert(table.get("peach").get("gender") == peachInfo.get("gender")); -} diff --git a/examples/tests/sdk_tests/table/aws-table.test.w b/examples/tests/sdk_tests/table/aws-table.test.w deleted file mode 100644 index 561ac8cf110..00000000000 --- a/examples/tests/sdk_tests/table/aws-table.test.w +++ /dev/null @@ -1,35 +0,0 @@ -bring ex; -bring aws; -bring util; - -let target = util.env("WING_TARGET"); - -let table = new ex.Table( - name: "users", - primaryKey: "name", - columns: { "gender" => ex.ColumnType.STRING } -) as "aws-wing-table"; - -let getTableInfo = (t: ex.Table): Map? => { - if let table = aws.Table.from(t) { - return { - dynamoTableName: table.dynamoTableName, - dynamoTableArn: table.dynamoTableArn, - }; - } - return nil; -}; - -let tableInfo = getTableInfo(table); - -test "validates the AWS topic name" { - if let table = tableInfo { - if target == "tf-aws" { - assert(table.get("dynamoTableArn").contains("arn:aws:dynamodb:")); - assert(table.get("dynamoTableArn").contains("aws-wing-table")); - assert(table.get("dynamoTableName").contains("aws-wing-table")); - } - } - // If the test is not on AWS, it should not fail, so I am returning true. - assert(true); -} \ No newline at end of file diff --git a/examples/tests/sdk_tests/table/get.test.w b/examples/tests/sdk_tests/table/get.test.w deleted file mode 100644 index 6090ddef1a1..00000000000 --- a/examples/tests/sdk_tests/table/get.test.w +++ /dev/null @@ -1,38 +0,0 @@ -bring cloud; -bring ex; - -let table = new ex.Table( - name: "users", - primaryKey: "name", - columns: { "gender" => ex.ColumnType.STRING } -); - - -test "get" { - let COLUMN_NAME="gender"; - let COLUMN_VALUE="male"; - let VALID_KEY = "foo"; - let NON_EXISTENT_KEY = "bar"; - let ROW_DOES_NOT_EXIST_ERROR = "Row does not exist (key={NON_EXISTENT_KEY})"; - - let assertThrows = (expected: str, block: (): void) => { - let var error = false; - try { - block(); - } catch actual { - assert(actual.contains(expected)); - error = true; - } - assert(error); - }; - - table.insert(VALID_KEY, Json { gender: COLUMN_VALUE }); - assert(table.get(VALID_KEY).get(COLUMN_NAME) == COLUMN_VALUE); - assertThrows(ROW_DOES_NOT_EXIST_ERROR, () => { - table.get(NON_EXISTENT_KEY); - }); - - let var result: Json? = table.tryGet(VALID_KEY); - assert(result?.get(COLUMN_NAME) == COLUMN_VALUE); - assert(table.tryGet(NON_EXISTENT_KEY) == nil); -} diff --git a/examples/tests/sdk_tests/table/list.test.w b/examples/tests/sdk_tests/table/list.test.w deleted file mode 100644 index c44137e9d7d..00000000000 --- a/examples/tests/sdk_tests/table/list.test.w +++ /dev/null @@ -1,26 +0,0 @@ - -bring cloud; -bring ex; - -let table = new ex.Table( - name: "users", - primaryKey: "name", - columns: { "gender" => ex.ColumnType.STRING } -); - - -test "list" { - table.insert("eyal", Json { gender: "male" }); - table.insert("revital", Json { gender: "female" }); - let unorderded = MutJson {}; - for u in table.list() { - unorderded.set(str.fromJson(u.get("name")), u); - } - let revital = unorderded.get("revital"); - let eyal = unorderded.get("eyal"); - - assert("eyal" == str.fromJson(eyal.get("name"))); - assert("male" == str.fromJson(eyal.get("gender"))); - assert("revital" == str.fromJson(revital.get("name"))); - assert("female" == str.fromJson(revital.get("gender"))); -} diff --git a/examples/tests/sdk_tests/table/try_get.test.w b/examples/tests/sdk_tests/table/try_get.test.w deleted file mode 100644 index eab1d51f3ba..00000000000 --- a/examples/tests/sdk_tests/table/try_get.test.w +++ /dev/null @@ -1,31 +0,0 @@ -bring cloud; -bring ex; - -let table = new ex.Table( - name: "users", - primaryKey: "name", - columns: { "gender" => ex.ColumnType.STRING } -); - - -test "tryGet" { - let COLUMN_NAME="gender"; - let COLUMN_VALUE="male"; - let VALID_KEY = "foo"; - let NON_EXISTENT_KEY = "bar"; - - let assertThrows = (expected: str, block: (): void) => { - let var error = false; - try { - block(); - } catch actual { - assert(actual == expected); - error = true; - } - assert(error); - }; - - table.insert(VALID_KEY, Json { gender: COLUMN_VALUE }); - assert(table.tryGet(VALID_KEY)?.tryGet(COLUMN_NAME)?.tryAsStr() == COLUMN_VALUE); - assert(table.tryGet(NON_EXISTENT_KEY) == nil); -} diff --git a/examples/tests/sdk_tests/table/upsert.test.w b/examples/tests/sdk_tests/table/upsert.test.w deleted file mode 100644 index f82b2b5672b..00000000000 --- a/examples/tests/sdk_tests/table/upsert.test.w +++ /dev/null @@ -1,50 +0,0 @@ -bring ex; -bring util; - -let table = new ex.Table( - name: "users", - primaryKey: "name", - columns: { - "gender" => ex.ColumnType.STRING, - "role" => ex.ColumnType.STRING, - } -); - -table.addRow("mario", { gender: "male", role: "plumber" }); -table.addRow("luigi", { gender: "male", role: "plumber" }); - -test "upsert" { - let assertThrows = (expected: str, block: (): void) => { - let var error = false; - try { - block(); - } catch actual { - assert(actual == expected); - error = true; - } - assert(error); - }; - - let JSON_PROPERTY_ROLE_DOES_NOT_EXIST_ERROR = "Json property \"role\" does not exist"; - let JSON_PROPERTY_GENDER_DOES_NOT_EXIST_ERROR = "Json property \"gender\" does not exist"; - - table.upsert("mario", {}); - table.upsert("luigi", { role: "ghostbuster" }); - table.upsert("peach", { gender: "female", role: "princess" }); - - assertThrows(JSON_PROPERTY_ROLE_DOES_NOT_EXIST_ERROR, () => { - table.get("mario").get("role"); - }); - assertThrows(JSON_PROPERTY_GENDER_DOES_NOT_EXIST_ERROR, () => { - table.get("mario").get("gender"); - }); - - assert(table.get("luigi").get("role") == "ghostbuster"); - assertThrows(JSON_PROPERTY_GENDER_DOES_NOT_EXIST_ERROR, () => { - table.get("luigi").get("gender"); - }); - - assert(table.get("peach").get("name") == "peach"); - assert(table.get("peach").get("role") == "princess"); - assert(table.get("peach").get("gender") == "female"); -} diff --git a/examples/tests/valid/api_cors_custom.test.w b/examples/tests/valid/api_cors_custom.test.w index 20b71b971e5..ed2d49d0fe1 100644 --- a/examples/tests/valid/api_cors_custom.test.w +++ b/examples/tests/valid/api_cors_custom.test.w @@ -1,5 +1,4 @@ bring cloud; -bring ex; bring http; bring expect; diff --git a/examples/tests/valid/api_cors_default.test.w b/examples/tests/valid/api_cors_default.test.w index 725391a2b8b..72ecc6e6ddc 100644 --- a/examples/tests/valid/api_cors_default.test.w +++ b/examples/tests/valid/api_cors_default.test.w @@ -1,5 +1,4 @@ bring cloud; -bring ex; bring http; bring expect; diff --git a/examples/tests/valid/redis.test.w b/examples/tests/valid/redis.test.w deleted file mode 100644 index 617bc9a1325..00000000000 --- a/examples/tests/valid/redis.test.w +++ /dev/null @@ -1,34 +0,0 @@ -/*\ -skipPlatforms: - - win32 - - darwin -\*/ - -bring cloud; -bring util; -bring ex; - -let r = new ex.Redis(); -let r2 = new ex.Redis() as "r2"; - -let queue = new cloud.Queue(); - -queue.setConsumer(inflight (message: str) => { - r.set("hello", message); -}, timeout: 3s); - -test "testing Redis" { - // Using API - r2.set("wing", "does redis again"); - let value2 = r2.get("wing"); - assert(value2 == "does redis again"); - - //With waitUntil - queue.push("world!"); - - util.waitUntil((): bool => { - return r.get("hello") != nil; - }); - - assert("world!" == "{r.get("hello") ?? "nil"}"); -} diff --git a/examples/tests/valid/table.test.w b/examples/tests/valid/table.test.w deleted file mode 100644 index 4952a8aa801..00000000000 --- a/examples/tests/valid/table.test.w +++ /dev/null @@ -1,11 +0,0 @@ -bring ex; - -let t = new ex.Table( - name: "simple-table", - primaryKey: "id", - columns: { - "id" => ex.ColumnType.STRING, - "name" => ex.ColumnType.STRING, - "age" => ex.ColumnType.NUMBER, - } -); \ No newline at end of file diff --git a/examples/tests/valid/website_with_api.test.w b/examples/tests/valid/website_with_api.test.w index 5590e5bd30e..24005605adf 100644 --- a/examples/tests/valid/website_with_api.test.w +++ b/examples/tests/valid/website_with_api.test.w @@ -1,5 +1,4 @@ bring cloud; -bring ex; bring http; bring expect; @@ -17,20 +16,11 @@ let api = new cloud.Api( ); let website = new cloud.Website(path: "./website_with_api"); - -let usersTable = new ex.Table( - name: "users-table", - primaryKey: "id", - columns: { - "id" => ex.ColumnType.STRING, - "name" => ex.ColumnType.STRING, - "age" => ex.ColumnType.NUMBER, - } -); +let userData = new cloud.Bucket(); let getHandler = inflight (req: cloud.ApiRequest): cloud.ApiResponse => { return cloud.ApiResponse { - body: Json.stringify({ users: usersTable.list() }), + body: Json.stringify({ users: userData.list() }), status: 200 }; }; @@ -43,7 +33,7 @@ let postHandler = inflight (req: cloud.ApiRequest): cloud.ApiResponse => { status: 400 }; } - usersTable.insert(Json.stringify(body.get("id")), body); + userData.putJson(body.get("id").asStr(), body); return cloud.ApiResponse { body: Json.stringify({ user: body.get("id") }), status: 201 diff --git a/libs/@wingcloud/framework/src/index.ts b/libs/@wingcloud/framework/src/index.ts index 0d8f4a90991..2ba5be21e7b 100644 --- a/libs/@wingcloud/framework/src/index.ts +++ b/libs/@wingcloud/framework/src/index.ts @@ -1,5 +1,5 @@ // re-exporting useful types from the sdk -export { cloud, ex } from "@winglang/sdk"; +export { cloud } from "@winglang/sdk"; export { Construct } from "@winglang/sdk/lib/core/types"; // typescript workflow primitives diff --git a/libs/wingc/src/lib.rs b/libs/wingc/src/lib.rs index 6ae54eadf25..d7e1a8f1f5d 100644 --- a/libs/wingc/src/lib.rs +++ b/libs/wingc/src/lib.rs @@ -80,7 +80,6 @@ const WINGSDK_UTIL_MODULE: &'static str = "util"; const WINGSDK_HTTP_MODULE: &'static str = "http"; const WINGSDK_MATH_MODULE: &'static str = "math"; const WINGSDK_AWS_MODULE: &'static str = "aws"; -const WINGSDK_EX_MODULE: &'static str = "ex"; const WINGSDK_EXPECT_MODULE: &'static str = "expect"; const WINGSDK_REGEX_MODULE: &'static str = "regex"; const WINGSDK_FS_MODULE: &'static str = "fs"; @@ -89,13 +88,12 @@ const WINGSDK_UI_MODULE: &'static str = "ui"; pub const UTIL_CLASS_NAME: &'static str = "Util"; -const WINGSDK_BRINGABLE_MODULES: [&'static str; 11] = [ +const WINGSDK_BRINGABLE_MODULES: [&'static str; 10] = [ WINGSDK_CLOUD_MODULE, WINGSDK_UTIL_MODULE, WINGSDK_HTTP_MODULE, WINGSDK_MATH_MODULE, WINGSDK_AWS_MODULE, - WINGSDK_EX_MODULE, WINGSDK_EXPECT_MODULE, WINGSDK_REGEX_MODULE, WINGSDK_FS_MODULE, diff --git a/libs/wingc/src/lsp/snapshots/completions/bring_suggestions.snap b/libs/wingc/src/lsp/snapshots/completions/bring_suggestions.snap index 742df34a40e..872f845d882 100644 --- a/libs/wingc/src/lsp/snapshots/completions/bring_suggestions.snap +++ b/libs/wingc/src/lsp/snapshots/completions/bring_suggestions.snap @@ -7,9 +7,6 @@ source: libs/wingc/src/lsp/completions.rs - label: cloud kind: 9 sortText: kk|cloud -- label: ex - kind: 9 - sortText: kk|ex - label: expect kind: 9 sortText: kk|expect diff --git a/libs/wingc/src/lsp/snapshots/completions/bring_suggestions_partial.snap b/libs/wingc/src/lsp/snapshots/completions/bring_suggestions_partial.snap index 742df34a40e..872f845d882 100644 --- a/libs/wingc/src/lsp/snapshots/completions/bring_suggestions_partial.snap +++ b/libs/wingc/src/lsp/snapshots/completions/bring_suggestions_partial.snap @@ -7,9 +7,6 @@ source: libs/wingc/src/lsp/completions.rs - label: cloud kind: 9 sortText: kk|cloud -- label: ex - kind: 9 - sortText: kk|ex - label: expect kind: 9 sortText: kk|expect diff --git a/libs/wingsdk/.projen/deps.json b/libs/wingsdk/.projen/deps.json index afcdabea12d..54310bbd52c 100644 --- a/libs/wingsdk/.projen/deps.json +++ b/libs/wingsdk/.projen/deps.json @@ -304,10 +304,6 @@ "name": "google-auth-library", "type": "bundled" }, - { - "name": "ioredis", - "type": "bundled" - }, { "name": "jiti", "type": "bundled" diff --git a/libs/wingsdk/.projenrc.ts b/libs/wingsdk/.projenrc.ts index 7d3b116399c..b23ffbd0d30 100644 --- a/libs/wingsdk/.projenrc.ts +++ b/libs/wingsdk/.projenrc.ts @@ -82,7 +82,6 @@ const project = new cdk.JsiiProject({ "nanoid@^3.3.7", "cron-parser", // shared client dependencies - "ioredis", "ajv", "cron-validator", // fs module dependency diff --git a/libs/wingsdk/package.json b/libs/wingsdk/package.json index d3a4fbea42d..42a1dbb0a35 100644 --- a/libs/wingsdk/package.json +++ b/libs/wingsdk/package.json @@ -109,7 +109,6 @@ "express": "^4.19.2", "glob": "^8.1.0", "google-auth-library": "^8.9.0", - "ioredis": "^5.4.1", "jiti": "^1.21.6", "mime": "^3.0.0", "mime-types": "^2.1.35", @@ -155,7 +154,6 @@ "express", "glob", "google-auth-library", - "ioredis", "jiti", "mime", "mime-types", diff --git a/libs/wingsdk/scripts/docgen.mts b/libs/wingsdk/scripts/docgen.mts index 594dab07855..1814e49b3b9 100644 --- a/libs/wingsdk/scripts/docgen.mts +++ b/libs/wingsdk/scripts/docgen.mts @@ -46,7 +46,6 @@ const UNDOCUMENTED_STD_FILES = [ // those will be skipped out of the docs const SKIPPED_MODULES = [ "cloud", - "ex", "std", "simulator", "core", @@ -174,12 +173,6 @@ await generateResourceApiDocs("cloud", { filter: DocumentationFilter.ALL_REQUIRE_MD, }); -await generateResourceApiDocs("ex", { - docsPath: getStdlibDocsDir("ex"), - excludedFiles: UNDOCUMENTED_EX_FILES, - filter: DocumentationFilter.ALL_REQUIRE_MD, -}); - await generateResourceApiDocs("std", { docsPath: getStdlibDocsDir("std"), excludedFiles: UNDOCUMENTED_STD_FILES, diff --git a/libs/wingsdk/src/README.md b/libs/wingsdk/src/README.md index d0c690fe9a0..e3789a45914 100644 --- a/libs/wingsdk/src/README.md +++ b/libs/wingsdk/src/README.md @@ -3,7 +3,6 @@ Here's an overview of what each module in `src` contains: - `.gen` - generated code for [CDKTF](https://github.com/hashicorp/terraform-cdk) classes that are used to synthesize Terraform resource config - `cloud` - abstract APIs for Wing's built-in resources that can be accessed using a "bring cloud" statement - `core` - classes and logic underpinning how Wing applications are constructed, how preflight code is translated into inflight code, how Wing plugins work, and other APIs that may need to be exported publicly for the compiler but don't necessarily belong in the `cloud` module -- `redis` - abstract API for the `Redis` resource - `shared` - classes and functions that are used by multiple modules - `shared-aws` - classes and functions that are used by both the `awscdk` and `tf-aws` targets - `shared-tf` - classes and functions that are used by the `tf-aws`, `tf-gcp`, and `tf-azure` targets diff --git a/libs/wingsdk/src/cloud/api.md b/libs/wingsdk/src/cloud/api.md index ddf81b9cbbd..f451b3187b7 100644 --- a/libs/wingsdk/src/cloud/api.md +++ b/libs/wingsdk/src/cloud/api.md @@ -27,28 +27,21 @@ When a client invokes a route, the corresponding event handler function executes ### REST API -The following example shows a complete REST API implementation using `cloud.Api`, `ex.Table` & `cloud.Counter` +The following example shows a complete REST API implementation using `cloud.Api`, `cloud.Bucket` & `cloud.Counter` ```ts playground example bring cloud; -bring ex; let api = new cloud.Api(); // Used for generating unique id let counter = new cloud.Counter(); -// our employee database -let db = new ex.Table( - name: "employees", - primaryKey: "id", - columns: { - "name" => ex.ColumnType.STRING - } -); +// our employee data +let store = new cloud.Bucket(); api.get("/employees", inflight (request: cloud.ApiRequest): cloud.ApiResponse => { let result = MutJson []; let var i = 0; - for employee in db.list() { + for employee in store.list() { result.setAt(i, employee); i = i + 1; } @@ -60,7 +53,7 @@ api.get("/employees", inflight (request: cloud.ApiRequest): cloud.ApiResponse => api.get("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiResponse => { - let employee = db.get(request.vars.get("id")); + let employee = store.get(request.vars.get("id")); return cloud.ApiResponse { status: 200, body: Json.stringify(employee) @@ -71,7 +64,7 @@ api.post("/employees", inflight (request: cloud.ApiRequest): cloud.ApiResponse = if let body = request.body { let employeeData = Json.parse(body); let id = "{counter.inc()}"; - db.insert(id, employeeData); + store.putJson(id, employeeData); return cloud.ApiResponse { status: 201, body: id @@ -83,7 +76,7 @@ api.put("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiRespons if let body = request.body { let employeeData = Json.parse(body); let id = request.vars.get("id"); - db.update(id, employeeData); + store.putJson(id, employeeData); return cloud.ApiResponse { status: 200, body: Json.stringify(employeeData) @@ -93,7 +86,7 @@ api.put("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiRespons api.delete("/employees/:id", inflight (request: cloud.ApiRequest): cloud.ApiResponse => { let id = request.vars.get("id"); - db.delete(id); + store.delete(id); return cloud.ApiResponse { status: 204 }; diff --git a/libs/wingsdk/src/ex/index.ts b/libs/wingsdk/src/ex/index.ts deleted file mode 100644 index 0000b8b54e5..00000000000 --- a/libs/wingsdk/src/ex/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./redis"; -export * from "./table"; diff --git a/libs/wingsdk/src/ex/redis.md b/libs/wingsdk/src/ex/redis.md deleted file mode 100644 index 19500548218..00000000000 --- a/libs/wingsdk/src/ex/redis.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Redis -id: redis -description: A cloud redis db. -keywords: [Redis, DB, database, store, cache] -sidebar_position: 1 ---- diff --git a/libs/wingsdk/src/ex/redis.ts b/libs/wingsdk/src/ex/redis.ts deleted file mode 100644 index f2ea92a646b..00000000000 --- a/libs/wingsdk/src/ex/redis.ts +++ /dev/null @@ -1,186 +0,0 @@ -import { Construct } from "constructs"; -import { fqnForType } from "../constants"; -import { LiftMap } from "../core"; -import { INFLIGHT_SYMBOL } from "../core/types"; -import { Node, Resource } from "../std"; - -/** - * Global identifier for `Redis`. - */ -export const REDIS_FQN = fqnForType("ex.Redis"); - -/** - * A cloud redis db. - * - * @inflight `@winglang/sdk.ex.IRedisClient` - * @abstract - */ -export class Redis extends Resource { - /** @internal */ - public [INFLIGHT_SYMBOL]?: IRedisClient; - - constructor(scope: Construct, id: string) { - if (new.target === Redis) { - return Resource._newFromFactory(REDIS_FQN, scope, id); - } - - super(scope, id); - - Node.of(this).title = "Redis"; - Node.of(this).description = "A Redis server"; - } - - /** @internal */ - public get _liftMap(): LiftMap { - return {}; - } -} - -/** - * Inflight interface for `Redis`. - */ -export interface IRedisClient { - /** - * Get url of redis server. - * @inflight - */ - url(): Promise; - - /** - * Set key value pair. - * - * @param key the key to set - * @param value the value to store at given key - * @inflight - */ - set(key: string, value: string): Promise; - - /** - * Get value at given key. - * @param key the key to get - * @inflight - */ - get(key: string): Promise; - - /** - * Sets the specified field to respective value in the hash stored at key - * - * @param key key to set - * @param field field in key to set - * @param value value to set at field in key - * @inflight - */ - hset(key: string, field: string, value: string): Promise; - - /** - * Returns the value associated with field in the hash stored at key - * - * @param key the key - * @param field the field at given key - * @inflight - */ - hget(key: string, field: string): Promise; - - /** - * Add the specified members to the set stored at key - * @param key the key - * @param value the value to add to the set at given key - * @inflight - */ - sadd(key: string, value: string): Promise; - - /** - * Returns all the members of the set value stored at key - * - * @param key the key - * @inflight - */ - smembers(key: string): Promise; - - /** - * Removes the specified key - * - * @param key the key - * @inflight - */ - del(key: string): Promise; -} - -/** - * List of inflight operations available for `Redis`. - * @internal - */ -export enum RedisInflightMethods { - /** `Redis.url` */ - URL = "url", - /** `Redis.set` */ - SET = "set", - /** `Redis.get` */ - GET = "get", - /** `Redis.hset` */ - HSET = "hset", - /** `Redis.hget` */ - HGET = "hget", - /** `Redis.sadd` */ - SADD = "sadd", - /** `Redis.smembers` */ - SMEMBERS = "smembers", - /** `Redis.del` */ - DEL = "del", -} - -/** - * Base class for `Redis` Client. - */ -export abstract class RedisClientBase implements IRedisClient { - /** - * Get raw redis client (currently IoRedis). - */ - protected abstract rawClient(): Promise; - public abstract url(): Promise; - - public async set(key: string, value: string): Promise { - let redis = await this.rawClient(); - await redis.set(key, value); - } - - public async get(key: string): Promise { - let redis = await this.rawClient(); - let result = (await redis.get(key)) ?? undefined; // for wing to return nil - return result; - } - - public async hset( - key: string, - field: string, - value: string - ): Promise { - const redis = await this.rawClient(); - const result = await redis.hset(key, field, value); - return result; - } - - public async hget(key: string, field: string): Promise { - const redis = await this.rawClient(); - const result = await redis.hget(key, field); - return result; - } - - public async sadd(key: string, value: string): Promise { - const redis = await this.rawClient(); - const result = await redis.sadd(key, value); - return result; - } - - public async smembers(key: string): Promise { - const redis = await this.rawClient(); - const result = await redis.smembers(key); - return result ?? []; - } - - public async del(key: string): Promise { - const redis = await this.rawClient(); - const result = await redis.del(key); - return result; - } -} diff --git a/libs/wingsdk/src/ex/table.md b/libs/wingsdk/src/ex/table.md deleted file mode 100644 index 9ae23940e1b..00000000000 --- a/libs/wingsdk/src/ex/table.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -title: Table -id: table -description: A NoSQL database table that can be used to store and query data. -keywords: [dynamoDB, NoSQL, store, DB, database, cache] -sidebar_position: 1 ---- diff --git a/libs/wingsdk/src/ex/table.ts b/libs/wingsdk/src/ex/table.ts deleted file mode 100644 index 326c7da5a47..00000000000 --- a/libs/wingsdk/src/ex/table.ts +++ /dev/null @@ -1,193 +0,0 @@ -import { Construct } from "constructs"; -import { fqnForType } from "../constants"; -import { LiftMap } from "../core"; -import { AbstractMemberError } from "../core/errors"; -import { INFLIGHT_SYMBOL } from "../core/types"; -import { Json, Node, Resource } from "../std"; - -/** - * Global identifier for `Table`. - */ -export const TABLE_FQN = fqnForType("ex.Table"); - -/** - * Table column types - */ -export enum ColumnType { - /** String type */ - STRING, - /** Number type */ - NUMBER, - /** Bool type */ - BOOLEAN, - /** Date type */ - DATE, - /** Json type */ - JSON, -} - -/** - * Properties for `Table`. - */ -export interface TableProps { - /** - * The table's name. - * @default undefined - */ - readonly name?: string; - /** - * The table's columns. - * @default undefined - */ - readonly columns?: { [key: string]: ColumnType }; - /** - * The table's primary key. No two rows can have the same value for the - * primary key. - * @default undefined - */ - readonly primaryKey?: string; - /** - * The table's initial rows. - * @default undefined - */ - readonly initialRows?: { [key: string]: Json }; -} - -/** - * A NoSQL database table that can be used to store and query data. - * @inflight `@winglang/sdk.ex.ITableClient` - * @abstract - */ -export class Table extends Resource { - /** @internal */ - public [INFLIGHT_SYMBOL]?: ITableClient; - /** - * Table name - */ - public readonly name!: string; - /** - * Table primary key name - */ - public readonly primaryKey!: string; - /** - * Table columns - */ - public readonly columns!: { [key: string]: ColumnType }; - - constructor(scope: Construct, id: string, props: TableProps) { - if (new.target === Table) { - return Resource._newFromFactory(TABLE_FQN, scope, id, props); - } - - super(scope, id); - - Node.of(this).title = "Table"; - Node.of(this).description = - "A cloud NoSQL database table that can be used to store and query data"; - - if (!props.name) { - throw new Error("Table name is not defined"); - } - this.name = props.name; - if (!props.primaryKey) { - throw new Error("Primary Key is not defined"); - } - this.primaryKey = props.primaryKey; - - if (!props.columns) { - throw new Error("No column is defined"); - } - this.columns = props.columns; - } - - /** @internal */ - public get _liftMap(): LiftMap { - return {}; - } - - /** - * Add a row to the table that is created when the app is deployed. - * @abstract - */ - public addRow(key: string, row: Json): void { - key; - row; - throw new AbstractMemberError(); - } -} - -/** - * Inflight interface for `Table`. - */ -export interface ITableClient { - /** - * Insert a row into the table. - * @param key primary key to insert the row. - * @param row data to be inserted. - * @inflight - */ - insert(key: string, row: Json): Promise; - /** - * Insert a row into the table if it doesn't exist, otherwise update it. - * @param key primary key to upsert the row. - * @param row data to be upserted. - * @inflight - */ - upsert(key: string, row: Json): Promise; - /** - * Update a row in the table. - * @param key primary key to update the row. - * @param row data to be updated. - * @inflight - */ - update(key: string, row: Json): Promise; - /** - * Delete a row from the table, by primary key. - * @param key primary key to delete the row. - * @inflight - */ - delete(key: string): Promise; - /** - * Get a row from the table, by primary key. - * @param key primary key to search. - * @returns get the row from table. - * @throws if no row with the given key exists. - * @inflight - */ - get(key: string): Promise; - /** - * Get a row from the table if exists, by primary key. - * @param key primary key to search. - * @returns get the row from table if it exists, nil otherwise. - * @inflight - */ - tryGet(key: string): Promise; - /** - * List all rows in the table. - * @returns list all row. - * @inflight - */ - // TODO: change the return type to Iterator> in the future. - list(): Promise>; -} - -/** - * List of inflight operations available for `Table`. - * @internal - */ -export enum TableInflightMethods { - /** `Table.insert` */ - INSERT = "insert", - /** `Table.insert` */ - UPSERT = "upsert", - /** `Table.update` */ - UPDATE = "update", - /** `Table.delete` */ - DELETE = "delete", - /** `Table.get` */ - GET = "get", - /** `Table.tryGet` */ - TRYGET = "tryGet", - /** `Table.list` */ - LIST = "list", -} diff --git a/libs/wingsdk/src/index.ts b/libs/wingsdk/src/index.ts index bd6e8035e84..7bcd92d102f 100644 --- a/libs/wingsdk/src/index.ts +++ b/libs/wingsdk/src/index.ts @@ -1,7 +1,6 @@ // this file must only export the standard library types and not target-specific types. export * as cloud from "./cloud"; export * as core from "./core"; -export * as ex from "./ex"; export * as expect from "./expect"; export * as fs from "./fs"; export * as helpers from "./helpers"; diff --git a/libs/wingsdk/src/shared-aws/index.ts b/libs/wingsdk/src/shared-aws/index.ts index 63f86da9f2d..1f3d54e3922 100644 --- a/libs/wingsdk/src/shared-aws/index.ts +++ b/libs/wingsdk/src/shared-aws/index.ts @@ -6,7 +6,6 @@ export * from "./function"; export * from "./inflight-host"; export * from "./queue"; export * from "./secret"; -export * from "./table"; export * from "./topic"; export * from "./types"; export * from "./website"; diff --git a/libs/wingsdk/src/shared-aws/table.inflight.ts b/libs/wingsdk/src/shared-aws/table.inflight.ts deleted file mode 100644 index 18c55c23a7e..00000000000 --- a/libs/wingsdk/src/shared-aws/table.inflight.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { - DeleteItemCommand, - GetItemCommand, - UpdateItemCommand, - PutItemCommand, - ScanCommand, - DynamoDBClient, - ConditionalCheckFailedException, -} from "@aws-sdk/client-dynamodb"; -import { marshall, unmarshall } from "@aws-sdk/util-dynamodb"; -import { ITableClient } from "../ex"; -import { validateRow } from "../shared/table-utils"; -import { Json } from "../std"; - -export class TableClient implements ITableClient { - constructor( - private readonly tableName: string, - private readonly primaryKey: string, - private readonly columns: string, - private readonly client = new DynamoDBClient({}) - ) {} - - public async insert(key: string, row: Json): Promise { - validateRow(row, JSON.parse(this.columns)); - let insertRow = { [this.primaryKey]: key, ...row }; - try { - const command = new PutItemCommand({ - TableName: this.tableName, - Item: marshall(insertRow), - ConditionExpression: `attribute_not_exists(#primary_key)`, - ExpressionAttributeNames: { - "#primary_key": this.primaryKey, - }, - }); - await this.client.send(command); - } catch (e) { - if (e instanceof ConditionalCheckFailedException) { - throw new Error( - `The primary key "${key}" already exists in the "${ - this.tableName - }" table: ${(e as Error).stack})}` - ); - } - throw new Error((e as Error).stack); - } - } - - public async upsert(key: string, row: Json): Promise { - validateRow(row, JSON.parse(this.columns)); - let insertRow = { [this.primaryKey]: key, ...row }; - const command = new PutItemCommand({ - TableName: this.tableName, - Item: marshall(insertRow), - }); - await this.client.send(command); - } - - public async update(key: String, row: Json): Promise { - validateRow(row, JSON.parse(this.columns)); - let itemKey = { [this.primaryKey]: key }; - let updateExpression: string[] = []; - let expressionAttributes: any = {}; - const item = marshall(row); - for (const [id, value] of Object.entries(item)) { - if (id !== this.primaryKey) { - updateExpression.push(`${id} = :${id}`); - expressionAttributes[`:${id}`] = value; - } - } - const command = new UpdateItemCommand({ - TableName: this.tableName, - Key: marshall(itemKey), - UpdateExpression: `set ${updateExpression.toString()}`, - ExpressionAttributeValues: expressionAttributes, - }); - await this.client.send(command); - } - - public async delete(key: string): Promise { - const command = new DeleteItemCommand({ - TableName: this.tableName, - Key: { [this.primaryKey]: { S: key } }, - }); - await this.client.send(command); - } - - public async get(key: string): Promise { - const result = await this.tryGetJson(key); - if (!result) { - throw new Error(`Row does not exist (key=${key})`); - } - return result; - } - - public async tryGet(key: string): Promise { - return this.tryGetJson(key); - } - - public async list(): Promise> { - const command = new ScanCommand({ - TableName: this.tableName, - }); - const result = await this.client.send(command); - const response: any = []; - for (const item of result.Items!) { - response.push(unmarshall(item)); - } - return response; - } - - private async tryGetJson(key: string): Promise { - const command = new GetItemCommand({ - TableName: this.tableName, - Key: { [this.primaryKey]: { S: key } }, - }); - const result = await this.client.send(command); - if (result.Item) { - return unmarshall(result.Item) as Json; - } - return undefined; - } -} diff --git a/libs/wingsdk/src/shared-aws/table.ts b/libs/wingsdk/src/shared-aws/table.ts deleted file mode 100644 index f3569badff7..00000000000 --- a/libs/wingsdk/src/shared-aws/table.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { ex } from ".."; - -/** - * A shared interface for AWS tables. - */ -export interface IAwsTable { - /** - * AWS Table arn - */ - readonly dynamoTableArn: string; - - /** - * AWS Table name - */ - readonly dynamoTableName: string; -} - -/** - * A helper class for working with AWS tables. - */ -export class Table { - /** - * If the table is an AWS DynamoDB, return a helper interface for - * working with it. - * @param table The ex.Table. - */ - public static from(table: ex.Table): IAwsTable | undefined { - if (this.isAwsTable(table)) { - return table; - } - return undefined; - } - - private static isAwsTable(obj: any): obj is IAwsTable { - return ( - typeof obj.dynamoTableArn === "string" && - typeof obj.dynamoTableName === "string" - ); - } -} diff --git a/libs/wingsdk/src/shared/table-utils.ts b/libs/wingsdk/src/shared/table-utils.ts deleted file mode 100644 index 435e8fe57ba..00000000000 --- a/libs/wingsdk/src/shared/table-utils.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { ColumnType } from "../ex"; -import { Json } from "../std"; - -export function validateRow(row: Json, columns: { [key: string]: ColumnType }) { - for (const [key, value] of Object.entries(row)) { - if (!columns.hasOwnProperty(key)) { - throw new Error(`"${key}" is not a valid column in the table.`); - } - switch (columns[key]) { - case ColumnType.STRING: - case ColumnType.DATE: - if (typeof value !== "string") { - throw new Error(`"${key}" value is not a valid string.`); - } - break; - case ColumnType.NUMBER: - if (typeof value !== "number") { - throw new Error(`"${key}" value is not a valid number.`); - } - break; - case ColumnType.BOOLEAN: - if (typeof value !== "boolean") { - throw new Error(`"${key}" value is not a valid bool.`); - } - break; - case ColumnType.JSON: - if (typeof value !== "object") { - throw new Error(`"${key}" value is not a valid json.`); - } - break; - } - } -} diff --git a/libs/wingsdk/src/target-sim/app.ts b/libs/wingsdk/src/target-sim/app.ts index 840a261e3e0..47b196f78d6 100644 --- a/libs/wingsdk/src/target-sim/app.ts +++ b/libs/wingsdk/src/target-sim/app.ts @@ -26,7 +26,6 @@ import { SDK_VERSION } from "../constants"; import * as core from "../core"; import { preSynthesizeAllConstructs } from "../core/app"; import { registerTokenResolver } from "../core/tokens"; -import { REDIS_FQN, TABLE_FQN } from "../ex"; import { BaseResourceSchema, TypeSchema, @@ -50,14 +49,12 @@ const SIMULATOR_CLASS_DATA = { [ON_DEPLOY_FQN]: "OnDeploy", [POLICY_FQN]: "Policy", [QUEUE_FQN]: "Queue", - [REDIS_FQN]: "Redis", [SCHEDULE_FQN]: "Schedule", [SECRET_FQN]: "Secret", [SERVICE_FQN]: "Service", [STATE_FQN]: "State", [SIM_CONTAINER_FQN]: "Container", [SIM_RESOURCE_FQN]: "Resource", - [TABLE_FQN]: "Table", [TEST_RUNNER_FQN]: "TestRunner", [TOPIC_FQN]: "Topic", [WEBSITE_FQN]: "Website", @@ -111,9 +108,6 @@ export class App extends core.App { case QUEUE_FQN: return require.resolve("./queue.inflight"); - case REDIS_FQN: - return require.resolve("./redis.inflight"); - case SCHEDULE_FQN: return require.resolve("./schedule.inflight"); @@ -126,9 +120,6 @@ export class App extends core.App { case STATE_FQN: return require.resolve("./state.inflight"); - case TABLE_FQN: - return require.resolve("./table.inflight"); - case TEST_RUNNER_FQN: return require.resolve("./test-runner.inflight"); diff --git a/libs/wingsdk/src/target-sim/container.ts b/libs/wingsdk/src/target-sim/container.ts index 0cbbbcb1e01..15a56ad3b3d 100644 --- a/libs/wingsdk/src/target-sim/container.ts +++ b/libs/wingsdk/src/target-sim/container.ts @@ -161,6 +161,6 @@ export class Container extends Resource implements ISimulatorResource { export enum ContainerInflightMethods {} /** - * Inflight interface for `Redis`. + * Inflight interface for `sim.Container`. */ export interface IContainerClient {} diff --git a/libs/wingsdk/src/target-sim/platform.ts b/libs/wingsdk/src/target-sim/platform.ts index 39fff27d578..ff6cbd77893 100644 --- a/libs/wingsdk/src/target-sim/platform.ts +++ b/libs/wingsdk/src/target-sim/platform.ts @@ -10,12 +10,10 @@ import { Endpoint } from "./endpoint"; import { Function } from "./function"; import { OnDeploy } from "./on-deploy"; import { Queue } from "./queue"; -import { Redis } from "./redis"; import { Schedule } from "./schedule"; import { Secret } from "./secret"; import { Service } from "./service"; import { State, STATE_FQN } from "./state"; -import { Table } from "./table"; import { TestRunner } from "./test-runner"; import { Topic } from "./topic"; import { Website } from "./website"; @@ -34,7 +32,6 @@ import { TOPIC_FQN, WEBSITE_FQN, } from "../cloud"; -import { REDIS_FQN, TABLE_FQN } from "../ex"; import { IPlatform } from "../platform"; import { TEST_RUNNER_FQN } from "../std"; @@ -91,9 +88,6 @@ export class Platform implements IPlatform { case QUEUE_FQN: return Queue; - case REDIS_FQN: - return Redis; - case SCHEDULE_FQN: return Schedule; @@ -106,9 +100,6 @@ export class Platform implements IPlatform { case STATE_FQN: return State; - case TABLE_FQN: - return Table; - case TEST_RUNNER_FQN: return TestRunner; diff --git a/libs/wingsdk/src/target-sim/redis.inflight.ts b/libs/wingsdk/src/target-sim/redis.inflight.ts deleted file mode 100644 index 3c0a8fa2054..00000000000 --- a/libs/wingsdk/src/target-sim/redis.inflight.ts +++ /dev/null @@ -1,71 +0,0 @@ -import IoRedis from "ioredis"; -import { RedisAttributes, RedisSchema } from "./schema-resources"; -import { RedisClientBase } from "../ex"; -import { - ISimulatorContext, - ISimulatorResourceInstance, - UpdatePlan, -} from "../simulator/simulator"; - -export class Redis - extends RedisClientBase - implements ISimulatorResourceInstance -{ - private connectionUrl?: string = undefined; - private connection?: IoRedis; - private isCleanedUp = false; - - public constructor(private readonly props: RedisSchema) { - super(); - } - - public async init(_context: ISimulatorContext): Promise { - try { - if (this.isCleanedUp) { - return {}; - } - - // redis url based on host port - this.connectionUrl = `redis://0.0.0.0:${this.props.port}`; - - return {}; - } catch (e) { - throw Error(`Error setting up Redis resource simulation (${e}) - - Make sure you have docker installed and running`); - } - } - - public async cleanup(): Promise { - this.isCleanedUp = true; - // disconnect from the redis server - await this.connection?.quit(); - this.connection?.disconnect(); - } - - public async save(): Promise {} - - public async plan() { - return UpdatePlan.AUTO; - } - - public async rawClient(): Promise { - if (this.connection) { - return this.connection; - } - - if (this.connectionUrl) { - this.connection = new IoRedis(this.connectionUrl); - return this.connection; - } - - throw new Error("Redis server not initialized"); - } - - public async url(): Promise { - if (this.connectionUrl != undefined) { - return this.connectionUrl; - } else { - throw new Error("Redis server not initialized"); - } - } -} diff --git a/libs/wingsdk/src/target-sim/redis.ts b/libs/wingsdk/src/target-sim/redis.ts deleted file mode 100644 index 883b7b2dbb3..00000000000 --- a/libs/wingsdk/src/target-sim/redis.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { Construct } from "constructs"; -import { Container } from "./container"; -import { ISimulatorResource } from "./resource"; -import { RedisSchema } from "./schema-resources"; -import { bindSimulatorResource, makeSimulatorJsClient } from "./util"; -import { LiftMap } from "../core"; -import * as ex from "../ex"; -import { ToSimulatorOutput } from "../simulator"; -import { IInflightHost } from "../std"; - -/** - * Simulator implementation of `redis.Redis`. - * - * @inflight `@winglang/sdk.redis.IRedisClient` - */ -export class Redis extends ex.Redis implements ISimulatorResource { - private readonly WING_REDIS_IMAGE = - process.env.WING_REDIS_IMAGE ?? - // Redis version 7.0.9 - "redis@sha256:e50c7e23f79ae81351beacb20e004720d4bed657415e68c2b1a2b5557c075ce0"; - - private readonly hostPort: string; - - constructor(scope: Construct, id: string) { - super(scope, id); - - const c = new Container(this, "Container", { - name: "redis", - image: this.WING_REDIS_IMAGE, - containerPort: 6379, - }); - - if (!c.hostPort) { - throw new Error("Failed to get host port for the redis container"); - } - - this.hostPort = c.hostPort; - } - - public toSimulator(): ToSimulatorOutput { - const props: RedisSchema = { - port: this.hostPort, - }; - return { - type: ex.REDIS_FQN, - props, - }; - } - - public onLift(host: IInflightHost, ops: string[]): void { - bindSimulatorResource(__filename, this, host, ops); - super.onLift(host, ops); - } - - /** @internal */ - public get _liftMap(): LiftMap { - return { - [ex.RedisInflightMethods.URL]: [], - [ex.RedisInflightMethods.SET]: [], - [ex.RedisInflightMethods.GET]: [], - [ex.RedisInflightMethods.HSET]: [], - [ex.RedisInflightMethods.HGET]: [], - [ex.RedisInflightMethods.SADD]: [], - [ex.RedisInflightMethods.SMEMBERS]: [], - [ex.RedisInflightMethods.DEL]: [], - }; - } - - /** @internal */ - public _toInflight(): string { - return makeSimulatorJsClient(__filename, this); - } -} diff --git a/libs/wingsdk/src/target-sim/schema-resources.ts b/libs/wingsdk/src/target-sim/schema-resources.ts index 366aa0f262c..338485dab9b 100644 --- a/libs/wingsdk/src/target-sim/schema-resources.ts +++ b/libs/wingsdk/src/target-sim/schema-resources.ts @@ -1,7 +1,5 @@ import { CorsHeaders, HttpMethod, OpenApiSpec } from "../cloud/api"; -import { ColumnType } from "../ex"; import { PolicyStatement } from "../simulator/simulator"; -import { Json } from "../std"; export type ResourceHandle = string; @@ -132,17 +130,6 @@ export interface TopicSubscriber extends EventSubscription { readonly functionHandle: ResourceHandle; } -/** Properties for cloud.Table */ -export interface TableSchema { - readonly name: string; - readonly columns: { [key: string]: ColumnType }; - readonly primaryKey: string; - readonly initialRows: Record; -} - -/** Runtime attributes for cloud.Table */ -export interface TableAttributes {} - /** Properties for cloud.Bucket */ export interface BucketSchema { /** Whether the bucket should be publicly accessible. */ @@ -165,15 +152,6 @@ export interface TestRunnerSchema { /** Runtime attributes for cloud.TestRunner */ export interface TestRunnerAttributes {} -/** Properties for redis.Redis */ -export interface RedisSchema { - /** The port to run the Redis server on. */ - readonly port: string; -} - -/** Runtime attributes for ex.Redis */ -export interface RedisAttributes {} - /** * Custom routes created in preflight. * Each contains the data to send to the user and a contentType header. diff --git a/libs/wingsdk/src/target-sim/table.inflight.ts b/libs/wingsdk/src/target-sim/table.inflight.ts deleted file mode 100644 index d29e2c5a621..00000000000 --- a/libs/wingsdk/src/target-sim/table.inflight.ts +++ /dev/null @@ -1,153 +0,0 @@ -import { TableAttributes, TableSchema } from "./schema-resources"; -import { ColumnType, ITableClient } from "../ex"; -import { validateRow } from "../shared/table-utils"; -import { - ISimulatorContext, - ISimulatorResourceInstance, - UpdatePlan, -} from "../simulator/simulator"; -import { Json } from "../std"; - -export class Table implements ITableClient, ISimulatorResourceInstance { - private name: string; - private columns: { [key: string]: ColumnType }; - private primaryKey: string; - private table: Map; - private _context: ISimulatorContext | undefined; - private readonly initialRows: Record; - - public constructor(props: TableSchema) { - this.name = props.name; - this.columns = props.columns; - this.primaryKey = props.primaryKey; - this.table = new Map(); - this.initialRows = props.initialRows ?? {}; - } - - private get context(): ISimulatorContext { - if (!this._context) { - throw new Error("Cannot access context during class construction"); - } - return this._context; - } - - public async init(context: ISimulatorContext): Promise { - this._context = context; - for (const [key, row] of Object.entries(this.initialRows)) { - await this.context.withTrace({ - message: `Adding initial row (key=${key}).`, - activity: async () => { - return this.table.set(key, row); - }, - }); - } - return {}; - } - - public async cleanup(): Promise {} - - public async save(): Promise {} - - public async plan() { - return UpdatePlan.AUTO; - } - - public async insert(key: string, row: Json): Promise { - validateRow(row, this.columns); - const anyRow = row as any; - return this.context.withTrace({ - message: `insert row ${key} into the table ${this.name}.`, - activity: async () => { - if (await this.tryGet(key)) { - throw new Error( - `The primary key "${key}" already exists in the "${this.name}" table.` - ); - } - let item: Record = {}; - item[this.primaryKey] = key; - for (const column of Object.keys(this.columns)) { - item[column] = anyRow[column]; - } - this.table.set(key, item); - }, - }); - } - public async upsert(key: string, row: Json): Promise { - validateRow(row, this.columns); - const anyRow = row as any; - return this.context.withTrace({ - message: `upsert row ${key} into the table ${this.name}.`, - activity: async () => { - let item: Record = {}; - item[this.primaryKey] = key; - for (const column of Object.keys(this.columns)) { - item[column] = anyRow[column]; - } - this.table.set(key, item); - }, - }); - } - public async update(key: string, row: Json): Promise { - validateRow(row, this.columns); - const anyRow = row as any; - return this.context.withTrace({ - message: `update row ${key} in table ${this.name}.`, - activity: async () => { - try { - let item: any = await this.get(key); - - for (const column of Object.keys(this.columns)) { - if (anyRow[column]) { - item[column] = anyRow[column]; - } - } - this.table.set(key, item); - } catch { - throw new Error( - `The primary key "${key}" was not found in the "${this.name}" table.` - ); - } - }, - }); - } - public async delete(key: string): Promise { - return this.context.withTrace({ - message: `remove row ${key} from table ${this.name}.`, - activity: async () => { - if (!this.table.delete(key)) { - throw new Error( - `The primary key "${key}" not found in the "${this.name}" table.` - ); - } - }, - }); - } - public async get(key: string): Promise { - return this.context.withTrace({ - message: `get row ${key} from table ${this.name}.`, - activity: async () => { - let item = this.table.get(key); - if (item) { - return item; - } - throw new Error(`Row does not exist (key=${key})`); - }, - }); - } - - public async tryGet(key: string): Promise { - if (this.table.has(key)) { - return this.get(key); - } - return undefined; - } - - public async list(): Promise> { - return this.context.withTrace({ - message: `list all rows from table ${this.name}.`, - activity: async () => { - return Array.from(this.table.values()); - }, - }); - } -} diff --git a/libs/wingsdk/src/target-sim/table.ts b/libs/wingsdk/src/target-sim/table.ts deleted file mode 100644 index d303a40d5d0..00000000000 --- a/libs/wingsdk/src/target-sim/table.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { Construct } from "constructs"; -import { ISimulatorResource } from "./resource"; -import { TableSchema } from "./schema-resources"; -import { bindSimulatorResource, makeSimulatorJsClient } from "./util"; -import { LiftMap } from "../core"; -import * as ex from "../ex"; -import { ToSimulatorOutput } from "../simulator/simulator"; -import { Json, IInflightHost } from "../std"; - -/** - * Simulator implementation of `ex.Table`. - * - * @inflight `@winglang/sdk.ex.ITableClient` - */ -export class Table extends ex.Table implements ISimulatorResource { - private readonly initialRows: Record = {}; - constructor(scope: Construct, id: string, props: ex.TableProps = {}) { - super(scope, id, props); - } - - public addRow(key: string, row: Json): void { - this.initialRows[key] = { ...row, [this.primaryKey]: key } as Json; - } - - public toSimulator(): ToSimulatorOutput { - const props: TableSchema = { - name: this.name, - columns: this.columns, - primaryKey: this.primaryKey, - initialRows: this.initialRows, - }; - return { - type: ex.TABLE_FQN, - props, - }; - } - - /** @internal */ - public get _liftMap(): LiftMap { - return { - [ex.TableInflightMethods.INSERT]: [], - [ex.TableInflightMethods.UPSERT]: [], - [ex.TableInflightMethods.UPDATE]: [], - [ex.TableInflightMethods.DELETE]: [], - [ex.TableInflightMethods.GET]: [], - [ex.TableInflightMethods.TRYGET]: [], - [ex.TableInflightMethods.LIST]: [], - }; - } - - public onLift(host: IInflightHost, ops: string[]): void { - bindSimulatorResource(__filename, this, host, ops); - super.onLift(host, ops); - } - - /** @internal */ - public _toInflight(): string { - return makeSimulatorJsClient(__filename, this); - } -} diff --git a/libs/wingsdk/src/target-tf-aws/index.ts b/libs/wingsdk/src/target-tf-aws/index.ts index ab682552639..1a5c242eefa 100644 --- a/libs/wingsdk/src/target-tf-aws/index.ts +++ b/libs/wingsdk/src/target-tf-aws/index.ts @@ -6,6 +6,5 @@ export * from "./function"; export * from "./queue"; export * from "./schedule"; export * from "./secret"; -export * from "./table"; export * from "./test-runner"; export * from "./topic"; diff --git a/libs/wingsdk/src/target-tf-aws/platform.ts b/libs/wingsdk/src/target-tf-aws/platform.ts index 865f6a88d9f..7eecd1527d1 100644 --- a/libs/wingsdk/src/target-tf-aws/platform.ts +++ b/libs/wingsdk/src/target-tf-aws/platform.ts @@ -7,11 +7,9 @@ import { Endpoint } from "./endpoint"; import { Function } from "./function"; import { OnDeploy } from "./on-deploy"; import { Queue } from "./queue"; -import { Redis } from "./redis"; import { Schedule } from "./schedule"; import { Secret } from "./secret"; import { Service } from "./service"; -import { Table } from "./table"; import { TestRunner } from "./test-runner"; import { Topic } from "./topic"; import { Website } from "./website"; @@ -30,7 +28,6 @@ import { TOPIC_FQN, WEBSITE_FQN, } from "../cloud"; -import { REDIS_FQN, TABLE_FQN } from "../ex"; import { IPlatform } from "../platform"; import { Domain } from "../shared-aws/domain"; import { TEST_RUNNER_FQN } from "../std"; @@ -139,18 +136,12 @@ export class Platform implements IPlatform { case SCHEDULE_FQN: return Schedule; - case TABLE_FQN: - return Table; - case TOPIC_FQN: return Topic; case TEST_RUNNER_FQN: return TestRunner; - case REDIS_FQN: - return Redis; - case WEBSITE_FQN: return Website; diff --git a/libs/wingsdk/src/target-tf-aws/redis.inflight.ts b/libs/wingsdk/src/target-tf-aws/redis.inflight.ts deleted file mode 100644 index 6e2e9b752aa..00000000000 --- a/libs/wingsdk/src/target-tf-aws/redis.inflight.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { - DescribeCacheClustersCommand, - ElastiCacheClient, -} from "@aws-sdk/client-elasticache"; -import { RedisClientBase } from "../ex"; - -// eslint-disable-next-line @typescript-eslint/no-require-imports -const IoRedis = require("ioredis"); - -export class RedisClient extends RedisClientBase { - private connectionUrl?: string; - constructor( - private readonly clusterId: string, - private connection?: any, - private readonly elasticacheClient = new ElastiCacheClient({}) - ) { - super(); - } - - /** - * The Redis cluster endpoint is not available to inject from the cdktf resource, - * therefore we need to query the AWS API to get it. This is a helper function that will - * use the cluster id to get the endpoint. - * - * @returns The Redis cluster endpoint - */ - private async getEndpoint(): Promise { - const command = new DescribeCacheClustersCommand({ - CacheClusterId: this.clusterId, - ShowCacheNodeInfo: true, - }); - const resp = await this.elasticacheClient.send(command); - - if (!resp.CacheClusters) { - throw new Error("No Redis cache clusters found"); - } - - const cluster = resp.CacheClusters[0]; - if (!cluster.CacheNodes) { - throw new Error("No Redis cache nodes found"); - } - - const cacheNode = cluster.CacheNodes[0]; - if (!cacheNode.Endpoint) { - throw new Error("No Redis cache node endpoint found"); - } - - return cacheNode.Endpoint.Address!; - } - - protected async rawClient(): Promise { - if (!this.clusterId) { - throw new Error("No cluster id provided"); - } - - if (this.connection) { - return this.connection; - } - - if (!this.connectionUrl) { - this.connectionUrl = await this.getEndpoint(); - } - - this.connection = new IoRedis(this.connectionUrl); - return this.connection; - } - - public async url(): Promise { - if (this.connectionUrl == undefined) { - this.connectionUrl = await this.getEndpoint(); - } - return this.connectionUrl; - } -} diff --git a/libs/wingsdk/src/target-tf-aws/redis.ts b/libs/wingsdk/src/target-tf-aws/redis.ts deleted file mode 100644 index 55744e65489..00000000000 --- a/libs/wingsdk/src/target-tf-aws/redis.ts +++ /dev/null @@ -1,150 +0,0 @@ -import { Construct } from "constructs"; -import { App } from "./app"; -import { DataAwsSubnet } from "../.gen/providers/aws/data-aws-subnet"; -import { ElasticacheCluster } from "../.gen/providers/aws/elasticache-cluster"; -import { ElasticacheSubnetGroup } from "../.gen/providers/aws/elasticache-subnet-group"; -import { SecurityGroup } from "../.gen/providers/aws/security-group"; -import { Subnet } from "../.gen/providers/aws/subnet"; -import * as core from "../core"; -import * as ex from "../ex"; -import { - CaseConventions, - NameOptions, - ResourceNames, -} from "../shared/resource-names"; -import { AwsInflightHost } from "../shared-aws"; -import { IInflightHost } from "../std"; - -const ELASTICACHE_NAME_OPTS: NameOptions = { - maxLen: 50, - disallowedRegex: /([^a-zA-Z0-9]+)/g, - case: CaseConventions.LOWERCASE, -}; - -export class Redis extends ex.Redis { - private readonly clusterId: string; - private readonly clusterArn: string; - private readonly securityGroups: SecurityGroup[]; - private readonly subnets: (Subnet | DataAwsSubnet)[]; - - constructor(scope: Construct, id: string) { - super(scope, id); - - if ( - process.env.REDIS_ENGINE_VERSION && - !process.env.REDIS_PARAMETER_GROUP_NAME - ) { - throw new Error( - "REDIS_PARAMETER_GROUP_NAME must be set if REDIS_ENGINE_VERSION is set" - ); - } - - const engine = "redis"; - const engineVersion = process.env.REDIS_ENGINE_VERSION ?? "6.2"; - const nodeType = process.env.REDIS_CLUSTER_NODE_TYPE ?? "cache.t4g.small"; - const parameterGroupName = - process.env.REDIS_PARAMETER_GROUP_NAME ?? "default.redis6.x"; - const REDIS_PORT = 6379; - - const app = App.of(this) as App; - const vpc = app.vpc; - this.subnets = app.subnets.private; - this.securityGroups = []; - const clusterName = ResourceNames.generateName(this, ELASTICACHE_NAME_OPTS); - for (const subnet of this.subnets) { - this.securityGroups.push( - new SecurityGroup(this, `${subnet.id.slice(-8)}securityGroup`, { - vpcId: vpc.id, - name: `${this.node.addr.slice(-8)}-${subnet.id}-securityGroup`, - ingress: [ - { - cidrBlocks: [subnet.cidrBlock], - fromPort: REDIS_PORT, - toPort: REDIS_PORT, - protocol: "tcp", - selfAttribute: true, - }, - ], - egress: [ - { - cidrBlocks: ["0.0.0.0/0"], - fromPort: 0, - toPort: 0, - protocol: "-1", - }, - ], - }) - ); - } - - const subnetGroup = new ElasticacheSubnetGroup(this, "RedisSubnetGroup", { - name: `${clusterName}-subnetGroup`, - subnetIds: [...this.subnets.map((s) => s.id)], - }); - - const cluster = new ElasticacheCluster(this, "RedisCluster", { - clusterId: clusterName, - engine, - engineVersion, - nodeType, - parameterGroupName, - availabilityZone: this.subnets[0].availabilityZone, - subnetGroupName: subnetGroup.name, - securityGroupIds: [...this.securityGroups.map((s) => s.id)], - numCacheNodes: 1, // This number will always be 1 for Redis - }); - - this.clusterId = cluster.clusterId; - this.clusterArn = cluster.arn; - } - - /** @internal */ - public get _liftMap(): core.LiftMap { - return { - [ex.RedisInflightMethods.URL]: [], - [ex.RedisInflightMethods.SET]: [], - [ex.RedisInflightMethods.GET]: [], - [ex.RedisInflightMethods.HSET]: [], - [ex.RedisInflightMethods.HGET]: [], - [ex.RedisInflightMethods.SADD]: [], - [ex.RedisInflightMethods.SMEMBERS]: [], - [ex.RedisInflightMethods.DEL]: [], - }; - } - - public onLift(host: IInflightHost, ops: string[]): void { - const env = this.envName(); - - if (!AwsInflightHost.isAwsInflightHost(host)) { - throw new Error("Host is expected to implement `IAwsInfightHost`"); - } - - // Ops do not matter here since the client connects directly to the cluster. - // The only thing that we need to use AWS API for is to get the cluster endpoint - // from the cluster ID. - host.addPolicyStatements({ - actions: ["elasticache:Describe*"], - resources: [this.clusterArn], - }); - - host.addEnvironment(env, this.clusterId); - - host.addNetwork({ - securityGroupIds: [...this.securityGroups.map((s) => s.id)], - subnetIds: [...this.subnets.map((s) => s.id)], - }); - - super.onLift(host, ops); - } - - /** @internal */ - public _toInflight(): string { - return core.InflightClient.for(__dirname, __filename, "RedisClient", [ - `process.env["${this.envName()}"]`, - ]); - } - - private envName(): string { - return `REDIS_CLUSTER_ID_${this.node.addr.slice(-8)}`; - } -} diff --git a/libs/wingsdk/src/target-tf-aws/table.ts b/libs/wingsdk/src/target-tf-aws/table.ts deleted file mode 100644 index d266a2b442f..00000000000 --- a/libs/wingsdk/src/target-tf-aws/table.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { marshall } from "@aws-sdk/util-dynamodb"; -import { Construct } from "constructs"; -import { App } from "./app"; -import { DynamodbTable } from "../.gen/providers/aws/dynamodb-table"; -import { DynamodbTableItem } from "../.gen/providers/aws/dynamodb-table-item"; -import * as core from "../core"; -import * as ex from "../ex"; -import { NameOptions, ResourceNames } from "../shared/resource-names"; -import { AwsInflightHost } from "../shared-aws"; -import { IAwsTable } from "../shared-aws/table"; -import { Json, IInflightHost } from "../std"; - -/** - * Table names must be between 3 and 255 characters. - * You can use alphanumeric characters, dot (.), dash (-), and underscores (_). - */ -const NAME_OPTS: NameOptions = { - maxLen: 255, - disallowedRegex: /[^a-zA-Z0-9\_\.\-]+/g, -}; - -/** - * AWS implementation of `ex.Table`. - * - * @inflight `@winglang/sdk.ex.ITableClient` - */ -export class Table extends ex.Table implements IAwsTable { - private readonly table: DynamodbTable; - - constructor(scope: Construct, id: string, props: ex.TableProps = {}) { - super(scope, id, props); - - const isTestEnvironment = App.of(scope).isTestEnvironment; - - this.table = new DynamodbTable(this, "Default", { - name: ResourceNames.generateName(this, { - prefix: this.name, - ...NAME_OPTS, - }), - attribute: [{ name: this.primaryKey, type: "S" }], - hashKey: this.primaryKey, - billingMode: "PAY_PER_REQUEST", - pointInTimeRecovery: isTestEnvironment ? undefined : { enabled: true }, - }); - } - - public addRow(key: string, row: Json): void { - const item = { [this.primaryKey]: key, ...row }; - const marshalledItem = marshall(item); - const stringifiedItem = JSON.stringify(marshalledItem); - - new DynamodbTableItem(this, `DynamodbTableItem-${key}`, { - tableName: this.table.name, - hashKey: this.table.hashKey, - item: stringifiedItem, - }); - } - - public onLift(host: IInflightHost, ops: string[]): void { - if (!AwsInflightHost.isAwsInflightHost(host)) { - throw new Error("Host is expected to implement `IAwsInfightHost`"); - } - - if ( - ops.includes(ex.TableInflightMethods.INSERT) || - ops.includes(ex.TableInflightMethods.UPSERT) - ) { - host.addPolicyStatements({ - actions: ["dynamodb:PutItem"], - resources: [this.table.arn], - }); - } - if (ops.includes(ex.TableInflightMethods.UPDATE)) { - host.addPolicyStatements({ - actions: ["dynamodb:UpdateItem"], - resources: [this.table.arn], - }); - } - - if (ops.includes(ex.TableInflightMethods.DELETE)) { - host.addPolicyStatements({ - actions: ["dynamodb:DeleteItem"], - resources: [this.table.arn], - }); - } - - if ( - ops.includes(ex.TableInflightMethods.GET) || - ops.includes(ex.TableInflightMethods.TRYGET) - ) { - host.addPolicyStatements({ - actions: ["dynamodb:GetItem"], - resources: [this.table.arn], - }); - } - - if (ops.includes(ex.TableInflightMethods.LIST)) { - host.addPolicyStatements({ - actions: ["dynamodb:Scan"], - resources: [this.table.arn], - }); - } - - host.addEnvironment(this.envName(), this.table.name); - host.addEnvironment(this.primaryKeyEnvName(), this.primaryKey); - host.addEnvironment(this.columnsEnvName(), JSON.stringify(this.columns)); - - super.onLift(host, ops); - } - - /** @internal */ - public _toInflight(): string { - return core.InflightClient.for( - __dirname.replace("target-tf-aws", "shared-aws"), - __filename, - "TableClient", - [ - `process.env["${this.envName()}"]`, - `process.env["${this.primaryKeyEnvName()}"]`, - `process.env["${this.columnsEnvName()}"]`, - ] - ); - } - - /** @internal */ - public get _liftMap(): core.LiftMap { - return { - [ex.TableInflightMethods.INSERT]: [], - [ex.TableInflightMethods.UPSERT]: [], - [ex.TableInflightMethods.UPDATE]: [], - [ex.TableInflightMethods.DELETE]: [], - [ex.TableInflightMethods.GET]: [], - [ex.TableInflightMethods.TRYGET]: [], - [ex.TableInflightMethods.LIST]: [], - }; - } - - private envName(): string { - return `DYNAMODB_TABLE_NAME_${this.node.addr.slice(-8)}`; - } - - private primaryKeyEnvName(): string { - return `${this.envName()}_PRIMARY_KEY`; - } - - private columnsEnvName(): string { - return `${this.envName()}_COLUMNS`; - } - - public get dynamoTableArn(): string { - return this.table.arn; - } - - public get dynamoTableName(): string { - return this.table.name; - } -} diff --git a/libs/wingsdk/src/target-tf-gcp/index.ts b/libs/wingsdk/src/target-tf-gcp/index.ts index 49940b99f27..1cad1383a9f 100644 --- a/libs/wingsdk/src/target-tf-gcp/index.ts +++ b/libs/wingsdk/src/target-tf-gcp/index.ts @@ -1,4 +1,3 @@ export * from "./app"; export * from "./bucket"; export * from "./function"; -export * from "./table"; diff --git a/libs/wingsdk/src/target-tf-gcp/platform.ts b/libs/wingsdk/src/target-tf-gcp/platform.ts index 8d2adb913c0..0dc8fb22c22 100644 --- a/libs/wingsdk/src/target-tf-gcp/platform.ts +++ b/libs/wingsdk/src/target-tf-gcp/platform.ts @@ -4,10 +4,8 @@ import { Bucket } from "./bucket"; import { Counter } from "./counter"; import { Function } from "./function"; import { Schedule } from "./schedule"; -import { Table } from "./table"; import { TestRunner } from "./test-runner"; import { BUCKET_FQN, COUNTER_FQN, FUNCTION_FQN, SCHEDULE_FQN } from "../cloud"; -import { TABLE_FQN } from "../ex"; import { IPlatform } from "../platform"; import { TEST_RUNNER_FQN } from "../std"; @@ -44,8 +42,6 @@ export class Platform implements IPlatform { return Bucket; case FUNCTION_FQN: return Function; - case TABLE_FQN: - return Table; case COUNTER_FQN: return Counter; case SCHEDULE_FQN: diff --git a/libs/wingsdk/src/target-tf-gcp/table.ts b/libs/wingsdk/src/target-tf-gcp/table.ts deleted file mode 100644 index d9fc3dc9d65..00000000000 --- a/libs/wingsdk/src/target-tf-gcp/table.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { Construct } from "constructs"; -import { App } from "./app"; -import { - BigtableInstance, - BigtableInstanceCluster, - BigtableInstanceClusterAutoscalingConfig, - BigtableInstanceConfig, -} from "../.gen/providers/google/bigtable-instance"; -import { - BigtableTable, - BigtableTableConfig, - BigtableTableColumnFamily, -} from "../.gen/providers/google/bigtable-table"; -import { NotImplementedError } from "../core/errors"; -import * as ex from "../ex"; -import { - ResourceNames, - NameOptions, - CaseConventions, -} from "../shared/resource-names"; -import { IInflightHost, Json } from "../std"; - -const TABLE_NAME_OPTS: NameOptions = { - maxLen: 22, - disallowedRegex: /[a-z0-9\-\.\_]+/g, - sep: "a", -}; - -const INSTANCE_NAME_OPTS: NameOptions = { - maxLen: 22, - disallowedRegex: /[a-z0-9\-\.\_]+/g, - sep: "a", - case: CaseConventions.LOWERCASE, -}; - -/** - * GCP implementation of `ex.Table`. - * - * @inflight `@winglang/sdk.ex.ITableClient` - */ -export class Table extends ex.Table { - constructor(scope: Construct, id: string, props: ex.TableProps = {}) { - super(scope, id, props); - - if (props.initialRows) { - throw new NotImplementedError( - `Property initialRows is not supported for the GCP target`, - { resource: this.constructor.name, operation: "initialRows" } - ); - } - - const app = App.of(this) as App; - - const tableName = ResourceNames.generateName(this, TABLE_NAME_OPTS); - const instanceName = ResourceNames.generateName(this, INSTANCE_NAME_OPTS); - - const columnsFamily: BigtableTableColumnFamily[] = []; - for (let key in this.columns) { - columnsFamily.push({ family: key }); - } - - const autoscalingConfig: BigtableInstanceClusterAutoscalingConfig = { - minNodes: 1, - maxNodes: 3, - cpuTarget: 35, - }; - - const instanceCluster: BigtableInstanceCluster = { - clusterId: "default", - storageType: "SSD", - zone: app.zone, - autoscalingConfig: autoscalingConfig, - }; - - const instanceConfig: BigtableInstanceConfig = { - name: instanceName, - cluster: [instanceCluster], - deletionProtection: false, - }; - - let instance = new BigtableInstance(this, "Instance", instanceConfig); - - const tableConfig: BigtableTableConfig = { - name: tableName, - instanceName: instance.name, - columnFamily: columnsFamily, - project: app.projectId, - }; - - new BigtableTable(this, "Default", tableConfig); - } - - public addRow(_key: string, _row: Json): void { - throw new NotImplementedError( - "Method is not supported as a preflight for the GCP target.", - { resource: this.constructor.name, operation: "addRow" } - ); - } - - public onLift(_host: IInflightHost, _ops: string[]): void { - throw new NotImplementedError("Method not implemented."); - } - - public _toInflight(): string { - throw new NotImplementedError( - "Table's Inflight client is not implemented yet on tf-GCP target" - ); - } -} diff --git a/libs/wingsdk/test/core/__snapshots__/connections.test.ts.snap b/libs/wingsdk/test/core/__snapshots__/connections.test.ts.snap index 1a7c3e15a81..ba1c202649e 100644 --- a/libs/wingsdk/test/core/__snapshots__/connections.test.ts.snap +++ b/libs/wingsdk/test/core/__snapshots__/connections.test.ts.snap @@ -114,14 +114,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/shared-aws/table.inflight.test.ts b/libs/wingsdk/test/shared-aws/table.inflight.test.ts deleted file mode 100644 index 9340c1ba9c3..00000000000 --- a/libs/wingsdk/test/shared-aws/table.inflight.test.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { - PutItemCommandInput, - UpdateItemCommandInput, - DynamoDBClient, - PutItemCommand, - UpdateItemCommand, - PutItemCommandOutput, - UpdateItemCommandOutput, - DeleteItemCommandInput, - DeleteItemCommandOutput, - DeleteItemCommand, - GetItemCommandInput, - GetItemCommandOutput, - GetItemCommand, - ScanCommandInput, - ScanCommandOutput, - ScanCommand, -} from "@aws-sdk/client-dynamodb"; -import { mockClient } from "aws-sdk-client-mock"; -import { test, expect, describe, beforeEach } from "vitest"; - -import { ColumnType } from "../../src/ex"; -import { TableClient } from "../../src/shared-aws/table.inflight"; - -const MOCK_TABLE_NAME = "MyBeautifulTable"; -const PRIMARY_KEY = "id"; -const dynamoMock = mockClient(DynamoDBClient); - -describe("inflight table tests", () => { - let client, row, key; - beforeEach(() => { - key = "test"; - row = { somenumber: 1 }; - const columns = { - somenumber: ColumnType.NUMBER, - }; - client = new TableClient( - MOCK_TABLE_NAME, - PRIMARY_KEY, - JSON.stringify(columns) - ); - }); - - test("insert", async () => { - // GIVEN - const expectedRequest: PutItemCommandInput = { - TableName: MOCK_TABLE_NAME, - Item: { - id: { S: key }, - somenumber: { N: String(row.somenumber) }, - }, - }; - const mockResponse: PutItemCommandOutput = { - $metadata: {}, - }; - dynamoMock.on(PutItemCommand, expectedRequest).resolves(mockResponse); - // WHEN - const response = await client.insert(key, row as any); - // THEN - expect(response).toEqual(undefined); - }); - - test("update", async () => { - // GIVEN - const expectedRequest: UpdateItemCommandInput = { - TableName: MOCK_TABLE_NAME, - Key: { id: { S: key } }, - UpdateExpression: `SET somenumber = :somenumber`, - ExpressionAttributeValues: { - ":somenumber": { N: `${row.somenumber}` }, - }, - }; - const mockResponse: UpdateItemCommandOutput = { - $metadata: {}, - }; - dynamoMock.on(UpdateItemCommand, expectedRequest).resolves(mockResponse); - // WHEN - const response = await client.update(key, row as any); - // THEN - expect(response).toEqual(undefined); - }); - - test("delete", async () => { - // GIVEN - const expectedRequest: DeleteItemCommandInput = { - TableName: MOCK_TABLE_NAME, - Key: { id: { S: row.id } }, - }; - const mockResponse: DeleteItemCommandOutput = { - $metadata: {}, - }; - dynamoMock.on(DeleteItemCommand, expectedRequest).resolves(mockResponse); - // WHEN - const response = await client.delete(row.id); - // THEN - expect(response).toEqual(undefined); - }); - - test("get to an empty table", async () => { - // GIVEN - const expectedRequest: GetItemCommandInput = { - TableName: MOCK_TABLE_NAME, - Key: { id: { S: key } }, - }; - const mockResponse: GetItemCommandOutput = { - $metadata: {}, - }; - dynamoMock.on(GetItemCommand, expectedRequest).resolves(mockResponse); - - // WHEN - const get = client.get(key); - - // THEN - await expect(() => get).rejects.toThrowError(/Row does not exist/); - }); - - test("get", async () => { - // GIVEN - const expectedRequest: GetItemCommandInput = { - TableName: MOCK_TABLE_NAME, - Key: { - id: { S: key }, - }, - }; - const mockResponse: GetItemCommandOutput = { - $metadata: {}, - Item: { - id: { S: `${key}` }, - somenumber: { N: `${row.somenumber}` }, - }, - }; - dynamoMock.on(GetItemCommand, expectedRequest).resolves(mockResponse); - // WHEN - const response = await client.get(key); - // THEN - expect(response).toEqual({ id: key, somenumber: row.somenumber }); - }); - - test("tryGet to an empty table", async () => { - // GIVEN - const expectedRequest: GetItemCommandInput = { - TableName: MOCK_TABLE_NAME, - Key: { id: { S: key } }, - }; - const mockResponse: GetItemCommandOutput = { - $metadata: {}, - }; - dynamoMock.on(GetItemCommand, expectedRequest).resolves(mockResponse); - - // WHEN - const response = await client.tryGet(key); - - // THEN - expect(response).toEqual(undefined); - }); - - test("tryGet", async () => { - const expectedRequest: GetItemCommandInput = { - TableName: MOCK_TABLE_NAME, - Key: { - id: { S: key }, - }, - }; - const mockResponse: GetItemCommandOutput = { - $metadata: {}, - Item: { - id: { S: `${key}` }, - somenumber: { N: `${row.somenumber}` }, - }, - }; - dynamoMock.on(GetItemCommand, expectedRequest).resolves(mockResponse); - // WHEN - const response = await client.tryGet(key); - // THEN - expect(response).toEqual({ id: key, somenumber: row.somenumber }); - }); - - test("list", async () => { - // GIVEN - const expectedRequest: ScanCommandInput = { - TableName: MOCK_TABLE_NAME, - }; - const mockResponse: ScanCommandOutput = { - $metadata: {}, - Count: 0, - Items: [ - { id: { S: "test1" }, somenumber: { N: "1" } }, - { id: { S: "test2" }, somenumber: { N: "2" } }, - ], - }; - dynamoMock.on(ScanCommand, expectedRequest).resolves(mockResponse); - // WHEN - const response = await client.list(); - // THEN - expect(response).toEqual([ - { id: "test1", somenumber: 1 }, - { id: "test2", somenumber: 2 }, - ]); - }); - - test("empty list", async () => { - // GIVEN - const expectedRequest: ScanCommandInput = { - TableName: MOCK_TABLE_NAME, - }; - const mockResponse: ScanCommandOutput = { - $metadata: {}, - Count: 0, - Items: [], - }; - dynamoMock.on(ScanCommand, expectedRequest).resolves(mockResponse); - // WHEN - const response = await client.list(); - // THEN - expect(response).toEqual([]); - }); -}); diff --git a/libs/wingsdk/test/simulator/cleanup.test.ts b/libs/wingsdk/test/simulator/cleanup.test.ts index 2a72ac2f9c2..86dabd64a85 100644 --- a/libs/wingsdk/test/simulator/cleanup.test.ts +++ b/libs/wingsdk/test/simulator/cleanup.test.ts @@ -42,7 +42,7 @@ const code = inflight(async () => { // and that process has code set up for gracefully shutting down the simulator, // then the simulator will be stopped correctly (including child processes // like services). -test("simulator cleanup", async () => { +test("simulator cleanup", { timeout: 20_000 }, async () => { // Synthesize configuration for the simulator to use in the test const app = new SimApp({ isTestEnvironment: true }); new Service(app, "Service", code); 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 259bcdf577a..e8fea064928 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/api.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/api.test.ts.snap @@ -219,14 +219,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -552,14 +544,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -884,14 +868,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1217,14 +1193,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1550,14 +1518,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1883,14 +1843,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -2359,14 +2311,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -2708,14 +2652,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -3049,14 +2985,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -3385,14 +3313,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -3821,14 +3741,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -4283,14 +4195,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -4639,14 +4543,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -4980,14 +4876,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -5313,14 +5201,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -5524,14 +5404,6 @@ exports[`create an api 1`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/bucket.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/bucket.test.ts.snap index 22cceb4f71c..98d98391b5a 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/bucket.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/bucket.test.ts.snap @@ -151,14 +151,6 @@ exports[`can add file in preflight 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -322,14 +314,6 @@ exports[`can add object in preflight 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -478,14 +462,6 @@ exports[`create a bucket 1`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -644,14 +620,6 @@ exports[`get invalid object throws an error 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/counter.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/counter.test.ts.snap index 292707d8f0e..f0be780b012 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/counter.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/counter.test.ts.snap @@ -170,14 +170,6 @@ exports[`create a counter 1`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -430,14 +422,6 @@ exports[`dec 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -690,14 +674,6 @@ exports[`inc 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -950,14 +926,6 @@ exports[`key dec 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1210,14 +1178,6 @@ exports[`key inc 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1468,14 +1428,6 @@ exports[`key set to new value 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1726,14 +1678,6 @@ exports[`set to new value 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/dynamodb-table.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/dynamodb-table.test.ts.snap deleted file mode 100644 index 85bed0f3d53..00000000000 --- a/libs/wingsdk/test/target-sim/__snapshots__/dynamodb-table.test.ts.snap +++ /dev/null @@ -1,691 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`create a table 1`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": [ - { - "addr": "c80d8c0710fc41df32eaa9895ae0bbd6cfd22762c2", - "attrs": {}, - "path": "root/create_table", - "props": { - "attributeDefinitions": { - "id": "S", - }, - "hashKey": "id", - "hostPort": "\${wsim#root/create_table/Container#attrs.host_port}", - "name": "new_table", - }, - "type": "@winglang/sdk.ex.DynamodbTable", - }, - { - "addr": "c82d9c21ab6a376c9bcdf5239702cd3d3a582b5e50", - "attrs": {}, - "path": "root/create_table/Container", - "props": { - "containerPort": 8000, - "cwd": "/test", - "image": "amazon/dynamodb-local:2.0.0", - "imageTag": "amazon/dynamodb-local:2.0.0", - }, - "type": "@winglang/sdk.sim.Container", - }, - ], - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Counter": { - "className": "Counter", - "sourcePath": "/counter.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.DynamodbTable": { - "className": "DynamodbTable", - "sourcePath": "/dynamodb-table.inflight.js", - }, - "@winglang/sdk.ex.ReactApp": { - "className": "ReactApp", - "sourcePath": "/react-app.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "create_table": { - "children": { - "Container": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "Container", - "path": "root/create_table/Container", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A DynamoDb Table", - "title": "DynamodbTable", - }, - "id": "create_table", - "path": "root/create_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`get item 1`] = ` -[ - "image amazon/dynamodb-local:.0.0 already exists", - "starting container from image amazon/dynamodb-local:.0.0", - "docker run --detach --rm --name wing-container- -p 8000 amazon/dynamodb-local:.0.0", - "containerName=wing-container-", - "root/get_table/Container started", - "root/get_table started", - "root/get_table stopped", - "Stopping container wing-container-", - "root/get_table/Container stopped", -] -`; - -exports[`get item 2`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": [ - { - "addr": "c8b976f0619d4aad0e4bb55cbda7b8975704b8b11a", - "attrs": {}, - "path": "root/get_table", - "props": { - "attributeDefinitions": { - "id": "S", - }, - "hashKey": "id", - "hostPort": "\${wsim#root/get_table/Container#attrs.host_port}", - "name": "my_get_table", - }, - "type": "@winglang/sdk.ex.DynamodbTable", - }, - { - "addr": "c8b10674f74fa0a89c85159f18ee72997a19272e1a", - "attrs": {}, - "path": "root/get_table/Container", - "props": { - "containerPort": 8000, - "cwd": "/test", - "image": "amazon/dynamodb-local:2.0.0", - "imageTag": "amazon/dynamodb-local:2.0.0", - }, - "type": "@winglang/sdk.sim.Container", - }, - ], - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Counter": { - "className": "Counter", - "sourcePath": "/counter.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.DynamodbTable": { - "className": "DynamodbTable", - "sourcePath": "/dynamodb-table.inflight.js", - }, - "@winglang/sdk.ex.ReactApp": { - "className": "ReactApp", - "sourcePath": "/react-app.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "get_table": { - "children": { - "Container": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "Container", - "path": "root/get_table/Container", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A DynamoDb Table", - "title": "DynamodbTable", - }, - "id": "get_table", - "path": "root/get_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`put item 1`] = ` -[ - "image amazon/dynamodb-local:.0.0 already exists", - "starting container from image amazon/dynamodb-local:.0.0", - "docker run --detach --rm --name wing-container- -p 8000 amazon/dynamodb-local:.0.0", - "containerName=wing-container-", - "root/put_table/Container started", - "root/put_table started", - "root/put_table stopped", - "Stopping container wing-container-", - "root/put_table/Container stopped", -] -`; - -exports[`put item 2`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": [ - { - "addr": "c8fa1029e0255990ff9eb3bf212931386890380f82", - "attrs": {}, - "path": "root/put_table", - "props": { - "attributeDefinitions": { - "id": "S", - }, - "hashKey": "id", - "hostPort": "\${wsim#root/put_table/Container#attrs.host_port}", - "name": "my_insert_table", - }, - "type": "@winglang/sdk.ex.DynamodbTable", - }, - { - "addr": "c8934f0d9367e400f390b6380b526e9c5ceaa3833e", - "attrs": {}, - "path": "root/put_table/Container", - "props": { - "containerPort": 8000, - "cwd": "/test", - "image": "amazon/dynamodb-local:2.0.0", - "imageTag": "amazon/dynamodb-local:2.0.0", - }, - "type": "@winglang/sdk.sim.Container", - }, - ], - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Counter": { - "className": "Counter", - "sourcePath": "/counter.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.DynamodbTable": { - "className": "DynamodbTable", - "sourcePath": "/dynamodb-table.inflight.js", - }, - "@winglang/sdk.ex.ReactApp": { - "className": "ReactApp", - "sourcePath": "/react-app.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "put_table": { - "children": { - "Container": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "Container", - "path": "root/put_table/Container", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A DynamoDb Table", - "title": "DynamodbTable", - }, - "id": "put_table", - "path": "root/put_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`update item 1`] = ` -[ - "image amazon/dynamodb-local:.0.0 already exists", - "starting container from image amazon/dynamodb-local:.0.0", - "docker run --detach --rm --name wing-container- -p 8000 amazon/dynamodb-local:.0.0", - "containerName=wing-container-", - "root/update_table/Container started", - "root/update_table started", - "root/update_table stopped", - "Stopping container wing-container-", - "root/update_table/Container stopped", -] -`; - -exports[`update item 2`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": [ - { - "addr": "c8f403ebb1894f2ea172e92af9090b7c8a25806934", - "attrs": {}, - "path": "root/update_table", - "props": { - "attributeDefinitions": { - "id": "S", - }, - "hashKey": "id", - "hostPort": "\${wsim#root/update_table/Container#attrs.host_port}", - "name": "my_update_table", - }, - "type": "@winglang/sdk.ex.DynamodbTable", - }, - { - "addr": "c87d51114bd971aa78d45b09d1581b2d2490f8d31a", - "attrs": {}, - "path": "root/update_table/Container", - "props": { - "containerPort": 8000, - "cwd": "/test", - "image": "amazon/dynamodb-local:2.0.0", - "imageTag": "amazon/dynamodb-local:2.0.0", - }, - "type": "@winglang/sdk.sim.Container", - }, - ], - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Counter": { - "className": "Counter", - "sourcePath": "/counter.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.DynamodbTable": { - "className": "DynamodbTable", - "sourcePath": "/dynamodb-table.inflight.js", - }, - "@winglang/sdk.ex.ReactApp": { - "className": "ReactApp", - "sourcePath": "/react-app.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "update_table": { - "children": { - "Container": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "Container", - "path": "root/update_table/Container", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A DynamoDb Table", - "title": "DynamodbTable", - }, - "id": "update_table", - "path": "root/update_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; diff --git a/libs/wingsdk/test/target-sim/__snapshots__/file-counter.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/file-counter.test.ts.snap index bb61606ada2..afc335f35dc 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/file-counter.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/file-counter.test.ts.snap @@ -388,14 +388,6 @@ bucket: (function() { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/function.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/function.test.ts.snap index eb5500f3161..6a94a6ab5a3 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/function.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/function.test.ts.snap @@ -103,14 +103,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -275,14 +267,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -447,14 +431,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -621,14 +597,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -783,14 +751,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1039,14 +999,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/immutable-capture.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/immutable-capture.test.ts.snap index be36938ae6d..cdd5b1b4245 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/immutable-capture.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/immutable-capture.test.ts.snap @@ -109,14 +109,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -281,14 +273,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -452,14 +436,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -622,14 +598,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -794,14 +762,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -968,14 +928,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1144,14 +1096,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1317,14 +1261,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1487,14 +1423,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1660,14 +1588,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1832,14 +1752,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -2003,14 +1915,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -2176,14 +2080,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -2349,14 +2245,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/on-deploy.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/on-deploy.test.ts.snap index 4a279b8552a..24c101a11d4 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/on-deploy.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/on-deploy.test.ts.snap @@ -100,14 +100,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/queue.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/queue.test.ts.snap index 21df1d0e50b..2d4f795dfef 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/queue.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/queue.test.ts.snap @@ -77,14 +77,6 @@ exports[`create a queue 1`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -155,457 +147,6 @@ exports[`create a queue 1`] = ` } `; -exports[`messages are not requeued if the function fails before timeout 1`] = ` -[ - "@winglang/sdk.cloud.Function created.", - "@winglang/sdk.cloud.Queue created.", - "@winglang/sdk.sim.EventMapping created.", - "Push (messages=BAD MESSAGE).", - "Sending messages (messages=[\\"BAD MESSAGE\\"], subscriber=sim-0).", - "Invoke (payload=\\"{\\\\\\"messages\\\\\\":[\\\\\\"BAD MESSAGE\\\\\\"]}\\").", - "Subscriber error - returning 1 messages to queue: ERROR", - "@winglang/sdk.sim.EventMapping deleted.", - "@winglang/sdk.cloud.Queue deleted.", - "@winglang/sdk.cloud.Function deleted.", -] -`; - -exports[`messages are not requeued if the function fails before timeout 2`] = ` -{ - ".wing/setconsumer0_c8e33b9b.js": "\\"use strict\\"; -var $handler = undefined; -exports.handler = async function(event) { - $handler = $handler ?? (new (require(\\"[REDACTED]/wingsdk/src/target-sim/queue.setconsumer.inflight.js\\")).QueueSetConsumerHandlerClient({ handler: new ((function(){ -return class Handler { - constructor(clients) { - for (const [name, client] of Object.entries(clients)) { - this[name] = client; - } - } - -async handle(message) { - if (message === \\"BAD MESSAGE\\") { - throw new Error(\\"ERROR\\"); - } -} -}; -})())({ - -}), args: {} })); - return await $handler.handle(event); -};", - "connections.json": { - "connections": [ - { - "name": "setConsumer()", - "source": "root/my_queue", - "target": "root/my_queue/SetConsumer0", - }, - ], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": [ - { - "addr": "c8e33b9b91c909e579b9d3d703146eb66c2a657ffc", - "attrs": {}, - "path": "root/my_queue/SetConsumer0", - "props": { - "environmentVariables": {}, - "sourceCodeFile": ".wing/setconsumer0_c8e33b9b.js", - "sourceCodeLanguage": "javascript", - "timeout": 60000, - }, - "type": "@winglang/sdk.cloud.Function", - }, - { - "addr": "c8dee4ef24593d08aa22e8845be36d0ee754fcf4cd", - "attrs": {}, - "path": "root/my_queue", - "props": { - "retentionPeriod": 3600, - "timeout": 30, - }, - "type": "@winglang/sdk.cloud.Queue", - }, - { - "addr": "c8f9f7d56097ba3d2e0e82988718175a5d841f855e", - "attrs": {}, - "path": "root/my_queue/QueueEventMapping0", - "props": { - "publisher": "\${wsim#root/my_queue#attrs.handle}", - "subscriber": "\${wsim#root/my_queue/SetConsumer0#attrs.handle}", - "subscriptionProps": { - "batchSize": 1, - }, - }, - "type": "@winglang/sdk.sim.EventMapping", - }, - ], - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Counter": { - "className": "Counter", - "sourcePath": "/counter.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.DynamodbTable": { - "className": "DynamodbTable", - "sourcePath": "/dynamodb-table.inflight.js", - }, - "@winglang/sdk.ex.ReactApp": { - "className": "ReactApp", - "sourcePath": "/react-app.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_queue": { - "children": { - "QueueEventMapping0": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "hidden": true, - }, - "id": "QueueEventMapping0", - "path": "root/my_queue/QueueEventMapping0", - }, - "SetConsumer0": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud function (FaaS)", - "sourceModule": "@winglang/sdk", - "title": "setConsumer()", - }, - "id": "SetConsumer0", - "path": "root/my_queue/SetConsumer0", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A distributed message queue", - "title": "Queue", - }, - "id": "my_queue", - "path": "root/my_queue", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`messages are requeued if the function fails after timeout 1`] = ` -[ - "@winglang/sdk.cloud.Function created.", - "@winglang/sdk.cloud.Queue created.", - "@winglang/sdk.sim.EventMapping created.", - "Push (messages=BAD MESSAGE).", - "Sending messages (messages=[\\"BAD MESSAGE\\"], subscriber=sim-0).", - "Invoke (payload=\\"{\\\\\\"messages\\\\\\":[\\\\\\"BAD MESSAGE\\\\\\"]}\\").", - "Subscriber error - returning 1 messages to queue: ERROR", - "@winglang/sdk.sim.EventMapping deleted.", - "@winglang/sdk.cloud.Queue deleted.", - "@winglang/sdk.cloud.Function deleted.", - "1 messages pushed back to queue after visibility timeout.", -] -`; - -exports[`messages are requeued if the function fails after timeout 2`] = ` -{ - ".wing/setconsumer0_c8e33b9b.js": "\\"use strict\\"; -var $handler = undefined; -exports.handler = async function(event) { - $handler = $handler ?? (new (require(\\"[REDACTED]/wingsdk/src/target-sim/queue.setconsumer.inflight.js\\")).QueueSetConsumerHandlerClient({ handler: new ((function(){ -return class Handler { - constructor(clients) { - for (const [name, client] of Object.entries(clients)) { - this[name] = client; - } - } - -async handle(message) { - if (message === \\"BAD MESSAGE\\") { - throw new Error(\\"ERROR\\"); - } -} -}; -})())({ - -}), args: {} })); - return await $handler.handle(event); -};", - "connections.json": { - "connections": [ - { - "name": "setConsumer()", - "source": "root/my_queue", - "target": "root/my_queue/SetConsumer0", - }, - ], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": [ - { - "addr": "c8e33b9b91c909e579b9d3d703146eb66c2a657ffc", - "attrs": {}, - "path": "root/my_queue/SetConsumer0", - "props": { - "environmentVariables": {}, - "sourceCodeFile": ".wing/setconsumer0_c8e33b9b.js", - "sourceCodeLanguage": "javascript", - "timeout": 60000, - }, - "type": "@winglang/sdk.cloud.Function", - }, - { - "addr": "c8dee4ef24593d08aa22e8845be36d0ee754fcf4cd", - "attrs": {}, - "path": "root/my_queue", - "props": { - "retentionPeriod": 3600, - "timeout": 1, - }, - "type": "@winglang/sdk.cloud.Queue", - }, - { - "addr": "c8f9f7d56097ba3d2e0e82988718175a5d841f855e", - "attrs": {}, - "path": "root/my_queue/QueueEventMapping0", - "props": { - "publisher": "\${wsim#root/my_queue#attrs.handle}", - "subscriber": "\${wsim#root/my_queue/SetConsumer0#attrs.handle}", - "subscriptionProps": { - "batchSize": 1, - }, - }, - "type": "@winglang/sdk.sim.EventMapping", - }, - ], - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Counter": { - "className": "Counter", - "sourcePath": "/counter.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.DynamodbTable": { - "className": "DynamodbTable", - "sourcePath": "/dynamodb-table.inflight.js", - }, - "@winglang/sdk.ex.ReactApp": { - "className": "ReactApp", - "sourcePath": "/react-app.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_queue": { - "children": { - "QueueEventMapping0": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "hidden": true, - }, - "id": "QueueEventMapping0", - "path": "root/my_queue/QueueEventMapping0", - }, - "SetConsumer0": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud function (FaaS)", - "sourceModule": "@winglang/sdk", - "title": "setConsumer()", - }, - "id": "SetConsumer0", - "path": "root/my_queue/SetConsumer0", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A distributed message queue", - "title": "Queue", - }, - "id": "my_queue", - "path": "root/my_queue", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - exports[`push rejects empty message 1`] = ` [ "root/my_queue started", @@ -693,14 +234,6 @@ exports[`push rejects empty message 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -862,14 +395,6 @@ exports[`queue batch size of 2, purge the queue 2`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1199,14 +724,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -1501,14 +1018,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/redis.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/redis.test.ts.snap deleted file mode 100644 index 26d92bb5662..00000000000 --- a/libs/wingsdk/test/target-sim/__snapshots__/redis.test.ts.snap +++ /dev/null @@ -1,160 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`create a Redis resource 1`] = ` -{ - "connections.json": { - "connections": [ - { - "name": "", - "source": "root/my_redis", - "target": "root/my_redis/Container", - "targetOp": "host_port", - }, - ], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": { - "root/my_redis": { - "addr": "c84bd402f6d507613026d171fe74fc8ce07ced29ae", - "path": "root/my_redis", - "props": { - "port": "\${wsim#root/my_redis/Container#attrs.host_port}", - }, - "type": "@winglang/sdk.ex.Redis", - }, - "root/my_redis/Container": { - "addr": "c80acc96b1d952059eb0beee72912b94d23302fa03", - "path": "root/my_redis/Container", - "props": { - "containerPort": 6379, - "cwd": "/test", - "image": "redis@sha256:e50c7e23f79ae81351beacb20e004720d4bed657415e68c2b1a2b5557c075ce0", - "imageTag": "redis@sha256:e50c7e23f79ae81351beacb20e004720d4bed657415e68c2b1a2b5557c075ce0", - }, - "type": "@winglang/sdk.sim.Container", - }, - }, - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.Policy": { - "className": "Policy", - "sourcePath": "/policy.inflight.js", - }, - "@winglang/sdk.sim.Resource": { - "className": "Resource", - "sourcePath": "/resource.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_redis": { - "children": { - "Container": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "Container", - "path": "root/my_redis/Container", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A Redis server", - "title": "Redis", - }, - "id": "my_redis", - "path": "root/my_redis", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; diff --git a/libs/wingsdk/test/target-sim/__snapshots__/schedule.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/schedule.test.ts.snap index 123af737016..9d17caade3f 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/schedule.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/schedule.test.ts.snap @@ -76,14 +76,6 @@ exports[`create a schedule 1`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -303,14 +295,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -554,14 +538,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", @@ -805,14 +781,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/secret.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/secret.test.ts.snap index 4829b0fdcdb..52f142d2de4 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/secret.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/secret.test.ts.snap @@ -67,14 +67,6 @@ exports[`secrets > create a secret 1`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/service.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/service.test.ts.snap index fda6469189f..37d1d3c8978 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/service.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/service.test.ts.snap @@ -102,14 +102,6 @@ exports[`create a service with on start method 1`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/table.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/table.test.ts.snap deleted file mode 100644 index 4bbfbbebd96..00000000000 --- a/libs/wingsdk/test/target-sim/__snapshots__/table.test.ts.snap +++ /dev/null @@ -1,1017 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`can add row in preflight 1`] = ` -[ - "Adding initial row (key=joe-id).", - "root/my_table started", - "get row joe-id from table my_addrow_table.", - "root/my_table stopped", -] -`; - -exports[`can add row in preflight 2`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": { - "root/my_table": { - "addr": "c8e507baf046ceb6108a9fe64c08a39ccc39ffe11c", - "path": "root/my_table", - "props": { - "columns": { - "age": 1, - "name": 0, - }, - "initialRows": { - "joe-id": { - "age": 50, - "id": "joe-id", - "name": "Joe Doe", - }, - }, - "name": "my_addrow_table", - "primaryKey": "id", - }, - "type": "@winglang/sdk.ex.Table", - }, - }, - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.Policy": { - "className": "Policy", - "sourcePath": "/policy.inflight.js", - }, - "@winglang/sdk.sim.Resource": { - "className": "Resource", - "sourcePath": "/resource.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_table": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud NoSQL database table that can be used to store and query data", - "title": "Table", - }, - "id": "my_table", - "path": "root/my_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`create a table 1`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": { - "root/my_table": { - "addr": "c8e507baf046ceb6108a9fe64c08a39ccc39ffe11c", - "path": "root/my_table", - "props": { - "columns": { - "age": 1, - "name": 0, - }, - "initialRows": {}, - "name": "new_table", - "primaryKey": "id", - }, - "type": "@winglang/sdk.ex.Table", - }, - }, - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.Policy": { - "className": "Policy", - "sourcePath": "/policy.inflight.js", - }, - "@winglang/sdk.sim.Resource": { - "className": "Resource", - "sourcePath": "/resource.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_table": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud NoSQL database table that can be used to store and query data", - "title": "Table", - }, - "id": "my_table", - "path": "root/my_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`get row 1`] = ` -[ - "root/my_table started", - "insert row joe-id into the table my_get_table.", - "get row joe-id from table my_get_table.", - "Error: Row does not exist (key=NON_EXISTENT_KEY) (get row NON_EXISTENT_KEY from table my_get_table.)", - "root/my_table stopped", -] -`; - -exports[`get row 2`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": { - "root/my_table": { - "addr": "c8e507baf046ceb6108a9fe64c08a39ccc39ffe11c", - "path": "root/my_table", - "props": { - "columns": { - "age": 1, - "name": 0, - }, - "initialRows": {}, - "name": "my_get_table", - "primaryKey": "id", - }, - "type": "@winglang/sdk.ex.Table", - }, - }, - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.Policy": { - "className": "Policy", - "sourcePath": "/policy.inflight.js", - }, - "@winglang/sdk.sim.Resource": { - "className": "Resource", - "sourcePath": "/resource.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_table": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud NoSQL database table that can be used to store and query data", - "title": "Table", - }, - "id": "my_table", - "path": "root/my_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`insert row 1`] = ` -[ - "root/my_table started", - "insert row joe-id into the table my_insert_table.", - "root/my_table stopped", -] -`; - -exports[`insert row 2`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": { - "root/my_table": { - "addr": "c8e507baf046ceb6108a9fe64c08a39ccc39ffe11c", - "path": "root/my_table", - "props": { - "columns": { - "age": 1, - "name": 0, - }, - "initialRows": {}, - "name": "my_insert_table", - "primaryKey": "id", - }, - "type": "@winglang/sdk.ex.Table", - }, - }, - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.Policy": { - "className": "Policy", - "sourcePath": "/policy.inflight.js", - }, - "@winglang/sdk.sim.Resource": { - "className": "Resource", - "sourcePath": "/resource.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_table": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud NoSQL database table that can be used to store and query data", - "title": "Table", - }, - "id": "my_table", - "path": "root/my_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`list table 1`] = ` -[ - "root/my_table started", - "insert row joe-id into the table my_list_table.", - "insert row jane-id into the table my_list_table.", - "list all rows from table my_list_table.", - "root/my_table stopped", -] -`; - -exports[`list table 2`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": { - "root/my_table": { - "addr": "c8e507baf046ceb6108a9fe64c08a39ccc39ffe11c", - "path": "root/my_table", - "props": { - "columns": { - "age": 1, - "name": 0, - }, - "initialRows": {}, - "name": "my_list_table", - "primaryKey": "id", - }, - "type": "@winglang/sdk.ex.Table", - }, - }, - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.Policy": { - "className": "Policy", - "sourcePath": "/policy.inflight.js", - }, - "@winglang/sdk.sim.Resource": { - "className": "Resource", - "sourcePath": "/resource.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_table": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud NoSQL database table that can be used to store and query data", - "title": "Table", - }, - "id": "my_table", - "path": "root/my_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`tryGet row 1`] = ` -[ - "root/my_table started", - "insert row joe-id into the table my_get_table.", - "get row joe-id from table my_get_table.", - "root/my_table stopped", -] -`; - -exports[`tryGet row 2`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": { - "root/my_table": { - "addr": "c8e507baf046ceb6108a9fe64c08a39ccc39ffe11c", - "path": "root/my_table", - "props": { - "columns": { - "age": 1, - "name": 0, - }, - "initialRows": {}, - "name": "my_get_table", - "primaryKey": "id", - }, - "type": "@winglang/sdk.ex.Table", - }, - }, - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.Policy": { - "className": "Policy", - "sourcePath": "/policy.inflight.js", - }, - "@winglang/sdk.sim.Resource": { - "className": "Resource", - "sourcePath": "/resource.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_table": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud NoSQL database table that can be used to store and query data", - "title": "Table", - }, - "id": "my_table", - "path": "root/my_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; - -exports[`update row 1`] = ` -[ - "root/my_table started", - "insert row joe-id into the table my_update_table.", - "get row joe-id from table my_update_table.", - "get row joe-id from table my_update_table.", - "update row joe-id in table my_update_table.", - "get row joe-id from table my_update_table.", - "root/my_table stopped", -] -`; - -exports[`update row 2`] = ` -{ - "connections.json": { - "connections": [], - "version": "connections-0.1", - }, - "simulator.json": { - "resources": { - "root/my_table": { - "addr": "c8e507baf046ceb6108a9fe64c08a39ccc39ffe11c", - "path": "root/my_table", - "props": { - "columns": { - "age": 1, - "name": 0, - }, - "initialRows": {}, - "name": "my_update_table", - "primaryKey": "id", - }, - "type": "@winglang/sdk.ex.Table", - }, - }, - "sdkVersion": "0.0.0", - "types": { - "@winglang/sdk.cloud.Api": { - "className": "Api", - "sourcePath": "/api.inflight.js", - }, - "@winglang/sdk.cloud.Bucket": { - "className": "Bucket", - "sourcePath": "/bucket.inflight.js", - }, - "@winglang/sdk.cloud.Domain": { - "className": "Domain", - "sourcePath": "/domain.inflight.js", - }, - "@winglang/sdk.cloud.Endpoint": { - "className": "Endpoint", - "sourcePath": "/endpoint.inflight.js", - }, - "@winglang/sdk.cloud.Function": { - "className": "Function", - "sourcePath": "/function.inflight.js", - }, - "@winglang/sdk.cloud.OnDeploy": { - "className": "OnDeploy", - "sourcePath": "/on-deploy.inflight.js", - }, - "@winglang/sdk.cloud.Queue": { - "className": "Queue", - "sourcePath": "/queue.inflight.js", - }, - "@winglang/sdk.cloud.Schedule": { - "className": "Schedule", - "sourcePath": "/schedule.inflight.js", - }, - "@winglang/sdk.cloud.Secret": { - "className": "Secret", - "sourcePath": "/secret.inflight.js", - }, - "@winglang/sdk.cloud.Service": { - "className": "Service", - "sourcePath": "/service.inflight.js", - }, - "@winglang/sdk.cloud.Topic": { - "className": "Topic", - "sourcePath": "/topic.inflight.js", - }, - "@winglang/sdk.cloud.Website": { - "className": "Website", - "sourcePath": "/website.inflight.js", - }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, - "@winglang/sdk.sim.Container": { - "className": "Container", - "sourcePath": "/container.inflight.js", - }, - "@winglang/sdk.sim.EventMapping": { - "className": "EventMapping", - "sourcePath": "/event-mapping.inflight.js", - }, - "@winglang/sdk.sim.Policy": { - "className": "Policy", - "sourcePath": "/policy.inflight.js", - }, - "@winglang/sdk.sim.Resource": { - "className": "Resource", - "sourcePath": "/resource.inflight.js", - }, - "@winglang/sdk.sim.State": { - "className": "State", - "sourcePath": "/state.inflight.js", - }, - "@winglang/sdk.std.TestRunner": { - "className": "TestRunner", - "sourcePath": "/test-runner.inflight.js", - }, - }, - }, - "tree.json": { - "tree": { - "children": { - "my_table": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud NoSQL database table that can be used to store and query data", - "title": "Table", - }, - "id": "my_table", - "path": "root/my_table", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "root", - "path": "root", - }, - "version": "tree-0.1", - }, -} -`; diff --git a/libs/wingsdk/test/target-sim/__snapshots__/test.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/test.test.ts.snap index 55f284251ec..946bbff6795 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/test.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/test.test.ts.snap @@ -102,14 +102,6 @@ exports.handler = async function(event) { "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/__snapshots__/topic.test.ts.snap b/libs/wingsdk/test/target-sim/__snapshots__/topic.test.ts.snap index fcbbe9a5510..3c27d5203a1 100644 --- a/libs/wingsdk/test/target-sim/__snapshots__/topic.test.ts.snap +++ b/libs/wingsdk/test/target-sim/__snapshots__/topic.test.ts.snap @@ -74,14 +74,6 @@ exports[`create a topic 1`] = ` "className": "Website", "sourcePath": "/website.inflight.js", }, - "@winglang/sdk.ex.Redis": { - "className": "Redis", - "sourcePath": "/redis.inflight.js", - }, - "@winglang/sdk.ex.Table": { - "className": "Table", - "sourcePath": "/table.inflight.js", - }, "@winglang/sdk.sim.Container": { "className": "Container", "sourcePath": "/container.inflight.js", diff --git a/libs/wingsdk/test/target-sim/redis.test.ts b/libs/wingsdk/test/target-sim/redis.test.ts deleted file mode 100644 index e4bf2e9c0d5..00000000000 --- a/libs/wingsdk/test/target-sim/redis.test.ts +++ /dev/null @@ -1,137 +0,0 @@ -import { test, expect } from "vitest"; -import { Redis, IRedisClient, REDIS_FQN } from "../../src/ex"; -import { SimApp } from "../sim-app"; - -test("create a Redis resource", async () => { - // GIVEN - const app = new SimApp(); - new Redis(app, "my_redis"); - - // WHEN - const s = await app.startSimulator(); - const redisResource = s.getResourceConfig("/my_redis"); - await s.stop(); - - // THEN - expect(redisResource).toEqual({ - attrs: { - handle: expect.any(String), - }, - path: "root/my_redis", - addr: expect.any(String), - policy: [], - props: { - port: expect.any(String), - }, - type: REDIS_FQN, - }); - expect(app.snapshot()).toMatchSnapshot(); -}); - -test("can set and get a value", async () => { - // GIVEN - const app = new SimApp(); - new Redis(app, "my_redis"); - const key = "wing"; - const expectedValue = "does redis"; - - // WHEN - const s = await app.startSimulator(); - const client = s.getResource("/my_redis") as IRedisClient; - await client.set(key, expectedValue); - const value = await client.get(key); - await s.stop(); - - // THEN - expect(value).toEqual(expectedValue); -}); - -test("can hset and hget values", async () => { - // GIVEN - const app = new SimApp(); - new Redis(app, "my_redis"); - const key = "wing"; - const field = "secret_message"; - const expectedValue = "does redis"; - - // WHEN - const s = await app.startSimulator(); - const client = s.getResource("/my_redis") as IRedisClient; - await client.hset(key, field, expectedValue); - const value = await client.hget(key, field); - await s.stop(); - - // THEN - expect(value).toEqual(expectedValue); -}); - -test("can sadd and smembers values", async () => { - // GIVEN - const app = new SimApp(); - new Redis(app, "my_redis"); - const key = "wing"; - const expectedValues = ["a", "b", "c"]; - - // WHEN - const s = await app.startSimulator(); - const client = s.getResource("/my_redis") as IRedisClient; - await client.sadd(key, "a"); - await client.sadd(key, "b"); - await client.sadd(key, "c"); - const value = await client.smembers(key); - await s.stop(); - - // THEN - expect(value.sort()).toEqual(expectedValues); -}); - -test("can del a value", async () => { - // GIVEN - const app = new SimApp(); - new Redis(app, "my_redis"); - const key = "wing"; - const expectedValue = "does redis"; - - // WHEN - const s = await app.startSimulator(); - const client = s.getResource("/my_redis") as IRedisClient; - await client.set(key, expectedValue); - const recordsDeleted = await client.del(key); - const value = await client.get(key); - await s.stop(); - - // THEN - expect(recordsDeleted).toEqual(1); - expect(value).toBeUndefined(); -}); - -test("return empty array when smembers on a non-existent key", async () => { - // GIVEN - const app = new SimApp(); - new Redis(app, "my_redis"); - const key = "wing"; - - // THEN - const s = await app.startSimulator(); - const client = s.getResource("/my_redis") as IRedisClient; - const value = await client.smembers(key); - await s.stop(); - - expect(value).toEqual([]); -}); - -test("get a value that does not exist", async () => { - // GIVEN - const app = new SimApp(); - new Redis(app, "my_redis"); - const key = "wing"; - - // WHEN - const s = await app.startSimulator(); - const client = s.getResource("/my_redis") as IRedisClient; - const value = await client.get(key); - await s.stop(); - - // THEN - expect(value).toBeUndefined(); -}); diff --git a/libs/wingsdk/test/target-sim/table.test.ts b/libs/wingsdk/test/target-sim/table.test.ts deleted file mode 100644 index 6eda65e0710..00000000000 --- a/libs/wingsdk/test/target-sim/table.test.ts +++ /dev/null @@ -1,370 +0,0 @@ -import { test, expect } from "vitest"; -import { listMessages } from "./util"; -import * as ex from "../../src/ex"; -import { SimApp } from "../sim-app"; - -test("create a table", async () => { - // GIVEN - const app = new SimApp(); - const t = new ex.Table(app, "my_table", { - name: "new_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - }); - - const s = await app.startSimulator(); - expect(s.getResourceConfig("/my_table")).toEqual({ - attrs: { - handle: expect.any(String), - }, - path: "root/my_table", - addr: expect.any(String), - policy: [], - props: { - name: "new_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - initialRows: {}, - }, - type: ex.TABLE_FQN, - }); - await s.stop(); - - expect(app.snapshot()).toMatchSnapshot(); -}); - -test("insert row", async () => { - // GIVEN - const app = new SimApp(); - const t = new ex.Table(app, "my_table", { - name: "my_insert_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - }); - const s = await app.startSimulator(); - const client = s.getResource("/my_table") as ex.ITableClient; - - await client.insert("joe-id", { name: "Joe Doe", age: 50 } as any); - - expect(s.getResourceConfig("/my_table")).toEqual({ - attrs: { - handle: expect.any(String), - }, - path: "root/my_table", - addr: expect.any(String), - policy: [], - props: { - name: "my_insert_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - initialRows: {}, - }, - type: ex.TABLE_FQN, - }); - await s.stop(); - - expect(listMessages(s)).toMatchSnapshot(); - expect(app.snapshot()).toMatchSnapshot(); -}); - -test("get row", async () => { - // GIVEN - const app = new SimApp(); - const t = new ex.Table(app, "my_table", { - name: "my_get_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - }); - const s = await app.startSimulator(); - const client = s.getResource("/my_table") as ex.ITableClient; - - const KEY = "joe-id"; - await client.insert(KEY, { name: "Joe Doe", age: 50 } as any); - const joe = await client.get(KEY); - expect(joe).toEqual({ id: "joe-id", name: "Joe Doe", age: 50 }); - - await expect(() => client.get("NON_EXISTENT_KEY")).rejects.toThrowError( - /Row does not exist/ - ); - - expect(s.getResourceConfig("/my_table")).toEqual({ - attrs: { - handle: expect.any(String), - }, - path: "root/my_table", - addr: expect.any(String), - policy: [], - props: { - name: "my_get_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - initialRows: {}, - }, - type: ex.TABLE_FQN, - }); - await s.stop(); - - expect(listMessages(s)).toMatchSnapshot(); - expect(app.snapshot()).toMatchSnapshot(); -}); - -test("tryGet row", async () => { - // GIVEN - const app = new SimApp(); - const t = new ex.Table(app, "my_table", { - name: "my_get_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - }); - const s = await app.startSimulator(); - const client = s.getResource("/my_table") as ex.ITableClient; - - const KEY = "joe-id"; - await client.insert(KEY, { name: "Joe Doe", age: 50 } as any); - const joe = await client.tryGet(KEY); - expect(joe).toEqual({ id: "joe-id", name: "Joe Doe", age: 50 }); - - const nonExistentRow = await client.tryGet("NON_EXISTENT_KEY"); - expect(nonExistentRow).toEqual(undefined); - - expect(s.getResourceConfig("/my_table")).toEqual({ - attrs: { - handle: expect.any(String), - }, - path: "root/my_table", - addr: expect.any(String), - policy: [], - props: { - name: "my_get_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - initialRows: {}, - }, - type: ex.TABLE_FQN, - }); - await s.stop(); - - expect(listMessages(s)).toMatchSnapshot(); - expect(app.snapshot()).toMatchSnapshot(); -}); - -test("update row", async () => { - // GIVEN - const app = new SimApp(); - const t = new ex.Table(app, "my_table", { - name: "my_update_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - }); - const s = await app.startSimulator(); - const client = s.getResource("/my_table") as ex.ITableClient; - - await client.insert("joe-id", { name: "Joe Doe", age: 50 } as any); - let joe = await client.get("joe-id"); - expect(joe).toEqual({ id: "joe-id", name: "Joe Doe", age: 50 }); - await client.update("joe-id", { age: 51 } as any); - joe = await client.get("joe-id"); - expect(joe).toEqual({ id: "joe-id", name: "Joe Doe", age: 51 }); - - expect(s.getResourceConfig("/my_table")).toEqual({ - attrs: { - handle: expect.any(String), - }, - path: "root/my_table", - addr: expect.any(String), - policy: [], - props: { - name: "my_update_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - initialRows: {}, - }, - type: ex.TABLE_FQN, - }); - await s.stop(); - - expect(listMessages(s)).toMatchSnapshot(); - expect(app.snapshot()).toMatchSnapshot(); -}); - -test("list table", async () => { - // GIVEN - const app = new SimApp(); - const t = new ex.Table(app, "my_table", { - name: "my_list_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - }); - const s = await app.startSimulator(); - const client = s.getResource("/my_table") as ex.ITableClient; - - await client.insert("joe-id", { name: "Joe Doe", age: 50 } as any); - await client.insert("jane-id", { name: "Jane Doe", age: 45 } as any); - const list = await client.list(); - expect(list[0]).toEqual({ id: "joe-id", name: "Joe Doe", age: 50 }); - expect(list[1]).toEqual({ id: "jane-id", name: "Jane Doe", age: 45 }); - - expect(s.getResourceConfig("/my_table")).toEqual({ - attrs: { - handle: expect.any(String), - }, - path: "root/my_table", - addr: expect.any(String), - policy: [], - props: { - name: "my_list_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - initialRows: {}, - }, - type: ex.TABLE_FQN, - }); - await s.stop(); - - expect(listMessages(s)).toMatchSnapshot(); - expect(app.snapshot()).toMatchSnapshot(); -}); - -test("inserting the same id twice", async () => { - // GIVEN - const app = new SimApp(); - const t = new ex.Table(app, "my_table", { - name: "my_insert_twice_table", - columns: { - name: ex.ColumnType.STRING, - }, - primaryKey: "id", - }); - const s = await app.startSimulator(); - const client = s.getResource("/my_table") as ex.ITableClient; - - await client.insert("joe-id", { name: "Joe Doe" } as any); - await expect(() => - client.insert("joe-id", { name: "Joe Doe II" } as any) - ).rejects.toThrow( - `The primary key "joe-id" already exists in the "my_insert_twice_table" table.` - ); -}); - -test("update non-existent item", async () => { - // GIVEN - const app = new SimApp(); - const t = new ex.Table(app, "my_table", { - name: "my_update_non_existent_table", - columns: { - name: ex.ColumnType.STRING, - }, - primaryKey: "id", - }); - const s = await app.startSimulator(); - const client = s.getResource("/my_table") as ex.ITableClient; - - await expect(() => - client.update("joe-id", { name: "Joe Doe" } as any) - ).rejects.toThrow( - `The primary key "joe-id" was not found in the "my_update_non_existent_table" table.` - ); -}); - -test("deleting non-existent item", async () => { - // GIVEN - const app = new SimApp(); - const t = new ex.Table(app, "my_table", { - name: "my_delete_non_existent_table", - columns: { - name: ex.ColumnType.STRING, - }, - primaryKey: "id", - }); - const s = await app.startSimulator(); - const client = s.getResource("/my_table") as ex.ITableClient; - - await expect(() => client.delete("joe-id")).rejects.toThrow( - `The primary key "joe-id" not found in the "my_delete_non_existent_table" table.` - ); -}); - -test("can add row in preflight", async () => { - // GIVEN - const KEY = "joe-id"; - const ROW = { name: "Joe Doe", age: 50 }; - - const app = new SimApp(); - const table = new ex.Table(app, "my_table", { - name: "my_addrow_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - initialRows: {}, - }); - table.addRow(KEY, ROW as any); - - const s = await app.startSimulator(); - const client = s.getResource("/my_table") as ex.ITableClient; - - const joe = await client.get("joe-id"); - expect(joe).toEqual({ name: "Joe Doe", age: 50, id: KEY }); - - expect(s.getResourceConfig("/my_table")).toEqual({ - attrs: { - handle: expect.any(String), - }, - path: "root/my_table", - addr: expect.any(String), - policy: [], - props: { - name: "my_addrow_table", - columns: { - name: ex.ColumnType.STRING, - age: ex.ColumnType.NUMBER, - }, - primaryKey: "id", - initialRows: { - "joe-id": { name: "Joe Doe", age: 50, id: KEY }, - }, - }, - type: ex.TABLE_FQN, - }); - await s.stop(); - - expect(listMessages(s)).toMatchSnapshot(); - expect(app.snapshot()).toMatchSnapshot(); -}); diff --git a/libs/wingsdk/test/target-tf-aws/__snapshots__/redis.test.ts.snap b/libs/wingsdk/test/target-tf-aws/__snapshots__/redis.test.ts.snap deleted file mode 100644 index 7b8aa86eea1..00000000000 --- a/libs/wingsdk/test/target-tf-aws/__snapshots__/redis.test.ts.snap +++ /dev/null @@ -1,249 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`When creating a Redis resource > should create an elasticache cluster and required vpc networking resources 1`] = ` -{ - "data": { - "aws_region": { - "Region": {}, - }, - }, - "resource": { - "aws_eip": { - "EIP": {}, - }, - "aws_elasticache_cluster": { - "Redis_RedisCluster_F55D8A3B": { - "availability_zone": "\${aws_subnet.PrivateSubnet.availability_zone}", - "cluster_id": "redis-c8cdb969", - "engine": "redis", - "engine_version": "6.2", - "node_type": "cache.t4g.small", - "num_cache_nodes": 1, - "parameter_group_name": "default.redis6.x", - "security_group_ids": [ - "\${aws_security_group.Redis_KEN21securityGroup_139152DE.id}", - "\${aws_security_group.Redis_KEN25securityGroup_D3232AB7.id}", - ], - "subnet_group_name": "\${aws_elasticache_subnet_group.Redis_RedisSubnetGroup_E7D796E2.name}", - }, - }, - "aws_elasticache_subnet_group": { - "Redis_RedisSubnetGroup_E7D796E2": { - "name": "redis-c8cdb969-subnetGroup", - "subnet_ids": [ - "\${aws_subnet.PrivateSubnet.id}", - "\${aws_subnet.PrivateSubnet2.id}", - ], - }, - }, - "aws_internet_gateway": { - "InternetGateway": { - "tags": { - "Name": "Default-c82bf964-internet-gateway", - }, - "vpc_id": "\${aws_vpc.VPC.id}", - }, - }, - "aws_nat_gateway": { - "NATGateway": { - "allocation_id": "\${aws_eip.EIP.id}", - "subnet_id": "\${aws_subnet.PublicSubnet.id}", - "tags": { - "Name": "Default-c82bf964-nat-gateway", - }, - }, - }, - "aws_route_table": { - "PrivateRouteTable": { - "route": [ - { - "carrier_gateway_id": null, - "cidr_block": "0.0.0.0/0", - "core_network_arn": null, - "destination_prefix_list_id": null, - "egress_only_gateway_id": null, - "gateway_id": null, - "ipv6_cidr_block": null, - "local_gateway_id": null, - "nat_gateway_id": "\${aws_nat_gateway.NATGateway.id}", - "network_interface_id": null, - "transit_gateway_id": null, - "vpc_endpoint_id": null, - "vpc_peering_connection_id": null, - }, - ], - "tags": { - "Name": "Default-c82bf964-private-route-table-1", - }, - "vpc_id": "\${aws_vpc.VPC.id}", - }, - "PrivateRouteTable2": { - "route": [ - { - "carrier_gateway_id": null, - "cidr_block": "0.0.0.0/0", - "core_network_arn": null, - "destination_prefix_list_id": null, - "egress_only_gateway_id": null, - "gateway_id": null, - "ipv6_cidr_block": null, - "local_gateway_id": null, - "nat_gateway_id": "\${aws_nat_gateway.NATGateway.id}", - "network_interface_id": null, - "transit_gateway_id": null, - "vpc_endpoint_id": null, - "vpc_peering_connection_id": null, - }, - ], - "tags": { - "Name": "Default-c82bf964-private-route-table-2", - }, - "vpc_id": "\${aws_vpc.VPC.id}", - }, - "PublicRouteTable": { - "route": [ - { - "carrier_gateway_id": null, - "cidr_block": "0.0.0.0/0", - "core_network_arn": null, - "destination_prefix_list_id": null, - "egress_only_gateway_id": null, - "gateway_id": "\${aws_internet_gateway.InternetGateway.id}", - "ipv6_cidr_block": null, - "local_gateway_id": null, - "nat_gateway_id": null, - "network_interface_id": null, - "transit_gateway_id": null, - "vpc_endpoint_id": null, - "vpc_peering_connection_id": null, - }, - ], - "tags": { - "Name": "Default-c82bf964-public-route-table-1", - }, - "vpc_id": "\${aws_vpc.VPC.id}", - }, - }, - "aws_route_table_association": { - "PrivateRouteTableAssociation": { - "route_table_id": "\${aws_route_table.PrivateRouteTable.id}", - "subnet_id": "\${aws_subnet.PrivateSubnet.id}", - }, - "PrivateRouteTableAssociation2": { - "route_table_id": "\${aws_route_table.PrivateRouteTable2.id}", - "subnet_id": "\${aws_subnet.PrivateSubnet2.id}", - }, - "PublicRouteTableAssociation": { - "route_table_id": "\${aws_route_table.PublicRouteTable.id}", - "subnet_id": "\${aws_subnet.PublicSubnet.id}", - }, - }, - "aws_security_group": { - "Redis_KEN21securityGroup_139152DE": { - "egress": [ - { - "cidr_blocks": [ - "0.0.0.0/0", - ], - "description": null, - "from_port": 0, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "-1", - "security_groups": null, - "self": null, - "to_port": 0, - }, - ], - "ingress": [ - { - "cidr_blocks": [ - "\${aws_subnet.PrivateSubnet.cidr_block}", - ], - "description": null, - "from_port": 6379, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "tcp", - "security_groups": null, - "self": true, - "to_port": 6379, - }, - ], - "name": "3542402a-\${aws_subnet.PrivateSubnet.id}-securityGroup", - "vpc_id": "\${aws_vpc.VPC.id}", - }, - "Redis_KEN25securityGroup_D3232AB7": { - "egress": [ - { - "cidr_blocks": [ - "0.0.0.0/0", - ], - "description": null, - "from_port": 0, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "-1", - "security_groups": null, - "self": null, - "to_port": 0, - }, - ], - "ingress": [ - { - "cidr_blocks": [ - "\${aws_subnet.PrivateSubnet2.cidr_block}", - ], - "description": null, - "from_port": 6379, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "tcp", - "security_groups": null, - "self": true, - "to_port": 6379, - }, - ], - "name": "3542402a-\${aws_subnet.PrivateSubnet2.id}-securityGroup", - "vpc_id": "\${aws_vpc.VPC.id}", - }, - }, - "aws_subnet": { - "PrivateSubnet": { - "availability_zone": "\${data.aws_region.Region.name}a", - "cidr_block": "10.0.4.0/22", - "tags": { - "Name": "Default-c82bf964-private-subnet-1", - }, - "vpc_id": "\${aws_vpc.VPC.id}", - }, - "PrivateSubnet2": { - "availability_zone": "\${data.aws_region.Region.name}b", - "cidr_block": "10.0.8.0/22", - "tags": { - "Name": "Default-c82bf964-private-subnet-2", - }, - "vpc_id": "\${aws_vpc.VPC.id}", - }, - "PublicSubnet": { - "availability_zone": "\${data.aws_region.Region.name}a", - "cidr_block": "10.0.0.0/24", - "tags": { - "Name": "Default-c82bf964-public-subnet-1", - }, - "vpc_id": "\${aws_vpc.VPC.id}", - }, - }, - "aws_vpc": { - "VPC": { - "cidr_block": "10.0.0.0/16", - "enable_dns_hostnames": true, - "enable_dns_support": true, - "tags": { - "Name": "Default-c82bf964-vpc", - }, - }, - }, - }, -} -`; diff --git a/libs/wingsdk/test/target-tf-aws/__snapshots__/table.test.ts.snap b/libs/wingsdk/test/target-tf-aws/__snapshots__/table.test.ts.snap deleted file mode 100644 index 317fc88be98..00000000000 --- a/libs/wingsdk/test/target-tf-aws/__snapshots__/table.test.ts.snap +++ /dev/null @@ -1,308 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`default table behavior 1`] = ` -{ - "resource": { - "aws_dynamodb_table": { - "Table": { - "attribute": [ - { - "name": "id", - "type": "S", - }, - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "id", - "name": "my-wing-tableTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true, - }, - }, - }, - }, -} -`; - -exports[`function with a table binding 1`] = ` -"(await (async () => { - const $func = async (ctx) => { - await ctx.my_table.insert("test", { id: "test" }); - } - const $ctx = { - my_table: new (require("[REDACTED]/wingsdk/src/shared-aws/table.inflight")).TableClient(process.env["DYNAMODB_TABLE_NAME_e7245baa"], process.env["DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY"], process.env["DYNAMODB_TABLE_NAME_e7245baa_COLUMNS"]) - }; - let newFunction = async (...args) => { - return $func($ctx, ...args); - }; - newFunction.handle = newFunction; - return newFunction; -} -)())" -`; - -exports[`function with a table binding 2`] = ` -{ - "resource": { - "aws_cloudwatch_log_group": { - "Function_CloudwatchLogGroup_ABDCF4C4": { - "name": "/aws/lambda/Function-c852aba6", - "retention_in_days": 30, - }, - }, - "aws_dynamodb_table": { - "Table": { - "attribute": [ - { - "name": "id", - "type": "S", - }, - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "id", - "name": "my-wing-tableTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true, - }, - }, - }, - "aws_iam_role": { - "Function_IamRole_678BE84C": { - "assume_role_policy": "{"Version":"2012-10-17","Statement":[{"Action":"sts:AssumeRole","Principal":{"Service":"lambda.amazonaws.com"},"Effect":"Allow"}]}", - }, - }, - "aws_iam_role_policy": { - "Function_IamRolePolicy_E3B26607": { - "policy": "{"Version":"2012-10-17","Statement":[{"Action":["dynamodb:PutItem"],"Resource":["\${aws_dynamodb_table.Table.arn}"],"Effect":"Allow"}]}", - "role": "\${aws_iam_role.Function_IamRole_678BE84C.name}", - }, - }, - "aws_iam_role_policy_attachment": { - "Function_IamRolePolicyAttachment_CACE1358": { - "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", - "role": "\${aws_iam_role.Function_IamRole_678BE84C.name}", - }, - }, - "aws_lambda_function": { - "Function": { - "architectures": [ - "arm64", - ], - "environment": { - "variables": { - "DYNAMODB_TABLE_NAME_e7245baa": "\${aws_dynamodb_table.Table.name}", - "DYNAMODB_TABLE_NAME_e7245baa_COLUMNS": "{"name":0}", - "DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY": "id", - "NODE_OPTIONS": "--enable-source-maps", - "WING_FUNCTION_NAME": "Function-c852aba6", - }, - }, - "function_name": "Function-c852aba6", - "handler": "index.handler", - "logging_config": { - "log_format": "JSON", - }, - "memory_size": 1024, - "publish": true, - "role": "\${aws_iam_role.Function_IamRole_678BE84C.arn}", - "runtime": "nodejs20.x", - "s3_bucket": "\${aws_s3_bucket.Code.bucket}", - "s3_key": "\${aws_s3_object.Function_S3Object_C62A0C2D.key}", - "timeout": 60, - "vpc_config": { - "security_group_ids": [], - "subnet_ids": [], - }, - }, - }, - "aws_s3_bucket": { - "Code": { - "bucket_prefix": "code-c84a50b1-", - }, - }, - "aws_s3_object": { - "Function_S3Object_C62A0C2D": { - "bucket": "\${aws_s3_bucket.Code.bucket}", - "key": "", - "source": "", - }, - }, - }, -} -`; - -exports[`function with a table binding 3`] = ` -{ - "tree": { - "children": { - "root": { - "children": { - "Default": { - "children": { - "Code": { - "constructInfo": { - "fqn": "cdktf.TerraformResource", - "version": "0.20.7", - }, - "display": {}, - "id": "Code", - "path": "root/Default/Code", - }, - "Function": { - "children": { - "Asset": { - "constructInfo": { - "fqn": "cdktf.TerraformAsset", - "version": "0.20.7", - }, - "display": {}, - "id": "Asset", - "path": "root/Default/Function/Asset", - }, - "CloudwatchLogGroup": { - "constructInfo": { - "fqn": "cdktf.TerraformResource", - "version": "0.20.7", - }, - "display": {}, - "id": "CloudwatchLogGroup", - "path": "root/Default/Function/CloudwatchLogGroup", - }, - "Default": { - "constructInfo": { - "fqn": "cdktf.TerraformResource", - "version": "0.20.7", - }, - "display": {}, - "id": "Default", - "path": "root/Default/Function/Default", - }, - "IamRole": { - "constructInfo": { - "fqn": "cdktf.TerraformResource", - "version": "0.20.7", - }, - "display": {}, - "id": "IamRole", - "path": "root/Default/Function/IamRole", - }, - "IamRolePolicy": { - "constructInfo": { - "fqn": "cdktf.TerraformResource", - "version": "0.20.7", - }, - "display": {}, - "id": "IamRolePolicy", - "path": "root/Default/Function/IamRolePolicy", - }, - "IamRolePolicyAttachment": { - "constructInfo": { - "fqn": "cdktf.TerraformResource", - "version": "0.20.7", - }, - "display": {}, - "id": "IamRolePolicyAttachment", - "path": "root/Default/Function/IamRolePolicyAttachment", - }, - "S3Object": { - "constructInfo": { - "fqn": "cdktf.TerraformResource", - "version": "0.20.7", - }, - "display": {}, - "id": "S3Object", - "path": "root/Default/Function/S3Object", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud function (FaaS)", - "title": "Function", - }, - "id": "Function", - "path": "root/Default/Function", - }, - "ParameterRegistrar": { - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "hidden": true, - }, - "id": "ParameterRegistrar", - "path": "root/Default/ParameterRegistrar", - }, - "Table": { - "children": { - "Default": { - "constructInfo": { - "fqn": "cdktf.TerraformResource", - "version": "0.20.7", - }, - "display": {}, - "id": "Default", - "path": "root/Default/Table/Default", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": { - "description": "A cloud NoSQL database table that can be used to store and query data", - "title": "Table", - }, - "id": "Table", - "path": "root/Default/Table", - }, - "aws": { - "constructInfo": { - "fqn": "cdktf.TerraformProvider", - "version": "0.20.7", - }, - "display": {}, - "id": "aws", - "path": "root/Default/aws", - }, - }, - "constructInfo": { - "fqn": "constructs.Construct", - "version": "10.3.0", - }, - "display": {}, - "id": "Default", - "path": "root/Default", - }, - "backend": { - "constructInfo": { - "fqn": "cdktf.LocalBackend", - "version": "0.20.7", - }, - "display": {}, - "id": "backend", - "path": "root/backend", - }, - }, - "constructInfo": { - "fqn": "cdktf.TerraformStack", - "version": "0.20.7", - }, - "display": {}, - "id": "root", - "path": "root", - }, - }, - "constructInfo": { - "fqn": "cdktf.App", - "version": "0.20.7", - }, - "display": {}, - "id": "App", - "path": "", - }, - "version": "tree-0.1", -} -`; diff --git a/libs/wingsdk/test/target-tf-aws/redis.inflight.test.ts b/libs/wingsdk/test/target-tf-aws/redis.inflight.test.ts deleted file mode 100644 index 45d4ac8ac2b..00000000000 --- a/libs/wingsdk/test/target-tf-aws/redis.inflight.test.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { - ElastiCacheClient, - DescribeCacheClustersCommand, -} from "@aws-sdk/client-elasticache"; -import { mockClient } from "aws-sdk-client-mock"; -import { test, expect } from "vitest"; -import { RedisClient } from "../../src/target-tf-aws/redis.inflight"; - -const getMockClient = () => new RedisClient("fake-cluster", new MockRedis()); -mockClient(ElastiCacheClient) - .on(DescribeCacheClustersCommand) - .resolves({ - CacheClusters: [ - { - CacheNodes: [ - { - Endpoint: { - Address: "fake-cluster.1234567890.us-east-1.cache.amazonaws.com", - }, - }, - ], - }, - ], - }); - -test("can set and get a value", async () => { - // GIVEN - const key = "wing"; - const expectedValue = "does redis"; - - // WHEN - const client = getMockClient(); - await client.set(key, expectedValue); - const value = await client.get(key); - - // THEN - expect(value).toEqual(expectedValue); -}); - -test("can hset and hget values", async () => { - // GIVEN - const key = "wing"; - const field1 = "foo"; - const field2 = "hello"; - const expectedValue1 = "bar"; - const expectedValue2 = "world"; - - // WHEN - const client = getMockClient(); - await client.hset(key, field1, expectedValue1); - await client.hset(key, field2, expectedValue2); - const value1 = await client.hget(key, field1); - const value2 = await client.hget(key, field2); - - // THEN - expect(value1).toEqual(expectedValue1); - expect(value2).toEqual(expectedValue2); -}); - -test("can sadd and smembers values", async () => { - // GIVEN - const key = "wing"; - const expectedValues = ["a", "b", "c"]; - - // WHEN - const client = getMockClient(); - await client.sadd(key, "a"); - await client.sadd(key, "b"); - await client.sadd(key, "c"); - const values = (await client.smembers(key)).sort(); - - // THEN - expect(values).toEqual(expectedValues); -}); - -test("can delete a key", async () => { - // GIVEN - const key = "wing"; - - // WHEN - const client = getMockClient(); - await client.set(key, "does redis"); - await client.del(key); - const value = await client.get(key); - - // THEN - expect(value).toBeUndefined(); -}); - -class MockRedis { - public items: Map> = new Map(); - - public set(key: string, value: string) { - this.items.set(key, value); - } - - public get(key: string) { - return this.items.get(key); - } - - public hset(key: string, field: string, value: string) { - this.items.set(`${key}:${field}`, value); - } - - public hget(key: string, field: string) { - return this.items.get(`${key}:${field}`); - } - - public sadd(key: string, value: string) { - if (!this.items.has(key)) { - const set = new Set(); - this.items.set(key, set); - } - - const set = this.items.get(key); - if (set === undefined || typeof set === "string") { - throw new Error("Not a set"); - } - set.add(value); - } - - public smembers(key: string) { - const set = this.items.get(key); - if (!set) { - return []; - } else if (typeof set === "string") { - throw new Error("Not a set"); - } else { - return Array.from(set); - } - } - - public del(key: string) { - this.items.delete(key); - } -} diff --git a/libs/wingsdk/test/target-tf-aws/redis.test.ts b/libs/wingsdk/test/target-tf-aws/redis.test.ts deleted file mode 100644 index e55938d3bbd..00000000000 --- a/libs/wingsdk/test/target-tf-aws/redis.test.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { describe, it, expect } from "vitest"; -import { AwsApp } from "./aws-util"; -import { Function } from "../../src/cloud"; -import { inflight } from "../../src/core"; -import * as ex from "../../src/ex"; -import * as tfaws from "../../src/target-tf-aws"; -import { - mkdtemp, - getTfResource, - tfResourcesOf, - tfResourcesOfCount, - tfSanitize, -} from "../util"; - -const INFLIGHT_CODE = inflight(async (_, name) => { - console.log("Hello, " + name); -}); - -describe("When creating a Redis resource", () => { - it("should create an elasticache cluster and required vpc networking resources", () => { - // GIVEN - const app = new AwsApp(); - new ex.Redis(app, "Redis"); - - // WHEN - const output = app.synth(); - - // THEN - expect(tfResourcesOf(output)).toEqual([ - "aws_eip", // Elastic IP for NAT Gateway - "aws_elasticache_cluster", // Elasticache cluster - "aws_elasticache_subnet_group", // Elasticache subnet group - "aws_internet_gateway", // Internet Gateway - "aws_nat_gateway", // NAT for internet egress from private subnet - "aws_route_table", // Route tables for subnets - "aws_route_table_association", // Route table associations for subnets - "aws_security_group", // Security group for Elasticache cluster access - "aws_subnet", // App wide subnets - "aws_vpc", // VCP for app - ]); - expect(tfSanitize(output)).toMatchSnapshot(); - }); - - it("should only contain a single instance of the vpc resources", () => { - // GIVEN - const app = new AwsApp(); - new ex.Redis(app, "Redis"); - - // WHEN - const output = app.synth(); - - // THEN - expect(tfResourcesOfCount(output, "aws_vpc")).toEqual(1); - expect(tfResourcesOfCount(output, "aws_subnet")).toEqual(3); - expect(tfResourcesOfCount(output, "aws_route_table")).toEqual(3); - expect(tfResourcesOfCount(output, "aws_nat_gateway")).toEqual(1); - expect(tfResourcesOfCount(output, "aws_internet_gateway")).toEqual(1); - }); - - describe("that is used by a function", () => { - it("lambda function should have access to the redis cluster", () => { - // GIVEN - const app = new AwsApp(); - const redisCluster = new ex.Redis(app, "Redis") as ex.Redis; - const func = new Function(app, "Function", INFLIGHT_CODE); - redisCluster.onLift(func, ["set", "get"]); - - // WHEN - const output = app.synth(); - - const lambda = getTfResource(output, "aws_lambda_function"); - const vpcConfig = lambda.vpc_config; - - // THEN - expect(vpcConfig.security_group_ids).toBeDefined(); - expect(vpcConfig.subnet_ids).toBeDefined(); - }); - }); -}); - -describe("When creating multiple Redis resources", () => { - it("should only contain a single instance of the vpc resources", () => { - // GIVEN - const app = new AwsApp(); - new ex.Redis(app, "RedisOne"); - new ex.Redis(app, "RedisTwo"); - - // WHEN - const output = app.synth(); - - // THEN - // 2 clusters, 2 security groups, 1 vpc, 2 subnets, 2 route tables, 1 nat gateway, 1 internet gateway - expect(tfResourcesOfCount(output, "aws_elasticache_cluster")).toEqual(2); - expect(tfResourcesOfCount(output, "aws_security_group")).toEqual(4); - expect(tfResourcesOfCount(output, "aws_vpc")).toEqual(1); - expect(tfResourcesOfCount(output, "aws_subnet")).toEqual(3); - expect(tfResourcesOfCount(output, "aws_route_table")).toEqual(3); - expect(tfResourcesOfCount(output, "aws_nat_gateway")).toEqual(1); - expect(tfResourcesOfCount(output, "aws_internet_gateway")).toEqual(1); - }); - - describe("that are used by a function", () => { - it("the function should have access to both clusters", () => { - // GIVEN - const app = new AwsApp(); - const redisCluster = new ex.Redis(app, "Redis") as ex.Redis; - const otherCluster = new ex.Redis(app, "OtherRedis") as ex.Redis; - const func = new Function(app, "Function", INFLIGHT_CODE); - redisCluster.onLift(func, ["set", "get"]); - otherCluster.onLift(func, ["set", "get"]); - - // WHEN - const output = app.synth(); - - const lambda = getTfResource(output, "aws_lambda_function"); - const vpcConfig = JSON.parse(JSON.stringify(lambda.vpc_config)); - - // THEN - expect(vpcConfig.security_group_ids.length).toEqual(4); - expect(vpcConfig.subnet_ids.length).toEqual(4); - }); - }); -}); diff --git a/libs/wingsdk/test/target-tf-aws/table.test.ts b/libs/wingsdk/test/target-tf-aws/table.test.ts deleted file mode 100644 index 00ff4ddb038..00000000000 --- a/libs/wingsdk/test/target-tf-aws/table.test.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { test, expect } from "vitest"; -import { AwsApp } from "./aws-util"; -import * as cloud from "../../src/cloud"; -import { lift } from "../../src/core"; -import * as ex from "../../src/ex"; -import { sanitizeCode, tfResourcesOf, tfSanitize, treeJsonOf } from "../util"; - -test("default table behavior", () => { - const app = new AwsApp(); - new ex.Table(app, "Table", { - columns: { name: ex.ColumnType.STRING }, - primaryKey: "id", - name: "my-wing-table", - }); - const output = app.synth(); - - expect(tfResourcesOf(output)).toEqual(["aws_dynamodb_table"]); - expect(tfSanitize(output)).toMatchSnapshot(); -}); - -test("function with a table binding", () => { - const app = new AwsApp(); - const table = new ex.Table(app, "Table", { - columns: { name: ex.ColumnType.STRING }, - primaryKey: "id", - name: "my-wing-table", - }); - const inflight = lift({ my_table: table }) - .grant({ my_table: ["insert"] }) - .inflight(async (ctx) => { - await ctx.my_table.insert("test", { id: "test" } as any); - }); - - new cloud.Function(app, "Function", inflight); - - const output = app.synth(); - - expect(sanitizeCode(inflight._toInflight())).toMatchSnapshot(); - expect(tfResourcesOf(output)).toEqual([ - "aws_cloudwatch_log_group", // log group for function - "aws_dynamodb_table", // main table - "aws_iam_role", // role for function - "aws_iam_role_policy", // policy for role - "aws_iam_role_policy_attachment", // execution policy for role - "aws_lambda_function", // processor function - "aws_s3_bucket", // S3 bucket for code - "aws_s3_object", // S3 object for code - ]); - expect(tfSanitize(output)).toMatchSnapshot(); - expect(treeJsonOf(app.outdir)).toMatchSnapshot(); -}); diff --git a/libs/wingsdk/test/target-tf-gcp/__snapshots__/table.test.ts.snap b/libs/wingsdk/test/target-tf-gcp/__snapshots__/table.test.ts.snap deleted file mode 100644 index c655c9c3684..00000000000 --- a/libs/wingsdk/test/target-tf-gcp/__snapshots__/table.test.ts.snap +++ /dev/null @@ -1,38 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`create a table 1`] = ` -{ - "resource": { - "google_bigtable_instance": { - "my_table_Instance_531C1B73": { - "cluster": [ - { - "autoscaling_config": { - "cpu_target": 35, - "max_nodes": 3, - "min_nodes": 1, - }, - "cluster_id": "default", - "storage_type": "SSD", - "zone": "us-central1-a", - }, - ], - "deletion_protection": false, - "name": "aac8dce022", - }, - }, - "google_bigtable_table": { - "my_table": { - "column_family": [ - { - "family": "name", - }, - ], - "instance_name": "\${google_bigtable_instance.my_table_Instance_531C1B73.name}", - "name": "aac8dce022", - "project": "my-project", - }, - }, - }, -} -`; diff --git a/libs/wingsdk/test/target-tf-gcp/table.test.ts b/libs/wingsdk/test/target-tf-gcp/table.test.ts deleted file mode 100644 index 7fd77eaff5d..00000000000 --- a/libs/wingsdk/test/target-tf-gcp/table.test.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { test, expect } from "vitest"; -import { GcpApp } from "./gcp-util"; -import { Table, ColumnType } from "../../src/ex"; -import { tfResourcesOf, tfSanitize } from "../util"; - -test("create a table", () => { - const app = new GcpApp(); - new Table(app, "my_table", { - primaryKey: "id", - columns: { name: ColumnType.STRING }, - name: "simple-table", - }); - const output = app.synth(); - - expect(tfResourcesOf(output)).toEqual([ - "google_bigtable_instance", - "google_bigtable_table", - ]); - expect(tfSanitize(output)).toMatchSnapshot(); -}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99f98efcce6..f067157d32f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -725,9 +725,6 @@ importers: node-fetch: specifier: ^3.3.2 version: 3.3.2 - redis: - specifier: ^4.6.14 - version: 4.6.14 tsup: specifier: ^8.1.0 version: 8.1.0(postcss@8.4.38)(typescript@5.5.2) @@ -1386,9 +1383,6 @@ importers: google-auth-library: specifier: ^8.9.0 version: 8.9.0 - ioredis: - specifier: ^5.4.1 - version: 5.4.1 jiti: specifier: ^1.21.6 version: 1.21.6 @@ -6449,10 +6443,6 @@ packages: engines: {node: '>=18'} dev: true - /@ioredis/commands@1.2.0: - resolution: {integrity: sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==} - dev: false - /@isaacs/cliui@8.0.2: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -8571,55 +8561,6 @@ packages: '@babel/runtime': 7.24.7 dev: true - /@redis/bloom@1.2.0(@redis/client@1.5.16): - resolution: {integrity: sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==} - peerDependencies: - '@redis/client': ^1.0.0 - dependencies: - '@redis/client': 1.5.16 - dev: true - - /@redis/client@1.5.16: - resolution: {integrity: sha512-X1a3xQ5kEMvTib5fBrHKh6Y+pXbeKXqziYuxOUo1ojQNECg4M5Etd1qqyhMap+lFUOAh8S7UYevgJHOm4A+NOg==} - engines: {node: '>=14'} - dependencies: - cluster-key-slot: 1.1.2 - generic-pool: 3.9.0 - yallist: 4.0.0 - dev: true - - /@redis/graph@1.1.1(@redis/client@1.5.16): - resolution: {integrity: sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==} - peerDependencies: - '@redis/client': ^1.0.0 - dependencies: - '@redis/client': 1.5.16 - dev: true - - /@redis/json@1.0.6(@redis/client@1.5.16): - resolution: {integrity: sha512-rcZO3bfQbm2zPRpqo82XbW8zg4G/w4W3tI7X8Mqleq9goQjAGLL7q/1n1ZX4dXEAmORVZ4s1+uKLaUOg7LrUhw==} - peerDependencies: - '@redis/client': ^1.0.0 - dependencies: - '@redis/client': 1.5.16 - dev: true - - /@redis/search@1.1.6(@redis/client@1.5.16): - resolution: {integrity: sha512-mZXCxbTYKBQ3M2lZnEddwEAks0Kc7nauire8q20oA0oA/LoA+E/b5Y5KZn232ztPb1FkIGqo12vh3Lf+Vw5iTw==} - peerDependencies: - '@redis/client': ^1.0.0 - dependencies: - '@redis/client': 1.5.16 - dev: true - - /@redis/time-series@1.0.5(@redis/client@1.5.16): - resolution: {integrity: sha512-IFjIgTusQym2B5IZJG3XKr5llka7ey84fw/NOYqESP5WUfQs9zz1ww/9+qoz4ka/S6KcGBodzlCeZ5UImKbscg==} - peerDependencies: - '@redis/client': ^1.0.0 - dependencies: - '@redis/client': 1.5.16 - dev: true - /@rollup/pluginutils@5.1.0: resolution: {integrity: sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==} engines: {node: '>=14.0.0'} @@ -13382,10 +13323,6 @@ packages: engines: {node: '>=0.8'} dev: true - /cluster-key-slot@1.1.2: - resolution: {integrity: sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==} - engines: {node: '>=0.10.0'} - /cmd-shim@6.0.3: resolution: {integrity: sha512-FMabTRlc5t5zjdenF6mS0MBeFZm0XqHqeOkcskKFb/LYCcRQ5fVgLOHVc4Lq9CqABd9zhjwPjMBCJvMCziSVtA==} engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0} @@ -14174,11 +14111,6 @@ packages: resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} - /denque@2.1.0: - resolution: {integrity: sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==} - engines: {node: '>=0.10'} - dev: false - /depd@2.0.0: resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} engines: {node: '>= 0.8'} @@ -15913,11 +15845,6 @@ packages: - supports-color dev: false - /generic-pool@3.9.0: - resolution: {integrity: sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==} - engines: {node: '>= 4'} - dev: true - /gensync@1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} @@ -16770,23 +16697,6 @@ packages: resolution: {integrity: sha512-ikEvmeZFh9u5SkjKbFqJlmmhaQTulB3P7QoSoZ/xL8EDP5uj5QWbPeKcQ8ZJtszBLHRRnhIJJE8P1dhFx/oCMw==} dev: false - /ioredis@5.4.1: - resolution: {integrity: sha512-2YZsvl7jopIa1gaePkeMtd9rAcSjOOjPtpcLlOeusyO+XH2SK5ZcT+UCrElPP+WVIInh2TzeI4XW9ENaSLVVHA==} - engines: {node: '>=12.22.0'} - dependencies: - '@ioredis/commands': 1.2.0 - cluster-key-slot: 1.1.2 - debug: 4.3.5(supports-color@5.5.0) - denque: 2.1.0 - lodash.defaults: 4.2.0 - lodash.isarguments: 3.1.0 - redis-errors: 1.2.0 - redis-parser: 3.0.0 - standard-as-callback: 2.1.0 - transitivePeerDependencies: - - supports-color - dev: false - /ip-address@9.0.5: resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==} engines: {node: '>= 12'} @@ -18065,6 +17975,7 @@ packages: /lodash.defaults@4.2.0: resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==} + dev: true /lodash.difference@4.5.0: resolution: {integrity: sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==} @@ -18085,10 +17996,6 @@ packages: /lodash.includes@4.3.0: resolution: {integrity: sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==} - /lodash.isarguments@3.1.0: - resolution: {integrity: sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==} - dev: false - /lodash.isboolean@3.0.3: resolution: {integrity: sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==} @@ -20800,29 +20707,6 @@ packages: strip-indent: 3.0.0 dev: true - /redis-errors@1.2.0: - resolution: {integrity: sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==} - engines: {node: '>=4'} - dev: false - - /redis-parser@3.0.0: - resolution: {integrity: sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==} - engines: {node: '>=4'} - dependencies: - redis-errors: 1.2.0 - dev: false - - /redis@4.6.14: - resolution: {integrity: sha512-GrNg/e33HtsQwNXL7kJT+iNFPSwE1IPmd7wzV3j4f2z0EYxZfZE7FVTmUysgAtqQQtg5NXF5SNLR9OdO/UHOfw==} - dependencies: - '@redis/bloom': 1.2.0(@redis/client@1.5.16) - '@redis/client': 1.5.16 - '@redis/graph': 1.1.1(@redis/client@1.5.16) - '@redis/json': 1.0.6(@redis/client@1.5.16) - '@redis/search': 1.1.6(@redis/client@1.5.16) - '@redis/time-series': 1.0.5(@redis/client@1.5.16) - dev: true - /reflect.getprototypeof@1.0.6: resolution: {integrity: sha512-fmfw4XgoDke3kdI6h4xcUz1dG8uaiv5q9gcEwLS4Pnth2kxT+GZ7YehS1JTMGBQmtV7Y4GFGbs2re2NqhdozUg==} engines: {node: '>= 0.4'} @@ -21645,10 +21529,6 @@ packages: get-source: 2.0.12 dev: false - /standard-as-callback@2.1.0: - resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==} - dev: false - /standard-version@9.5.0: resolution: {integrity: sha512-3zWJ/mmZQsOaO+fOlsa0+QK90pwhNd042qEcw6hKFNoLFs7peGyvPffpEBbK/DSGPbyOvli0mUIFv5A4qTjh2Q==} engines: {node: '>=10'} diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/events.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/events.test.w_compile_tf-aws.md index 6880da99e11..c10503ba0fd 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/events.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/bucket/events.test.w_compile_tf-aws.md @@ -95,26 +95,6 @@ "billing_mode": "PAY_PER_REQUEST", "hash_key": "id", "name": "wing-counter-Counter-c824ef62" - }, - "Table": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/Default", - "uniqueId": "Table" - } - }, - "attribute": [ - { - "name": "_id", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "_id", - "name": "key-historyTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true - } } }, "aws_iam_role": { @@ -181,7 +161,7 @@ "uniqueId": "Bucket_OnCreate-OnMessage0_IamRolePolicy_9749552C" } }, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"dynamodb:PutItem\"],\"Resource\":[\"${aws_dynamodb_table.Table.arn}\"],\"Effect\":\"Allow\"}]}", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"s3:PutObject*\",\"s3:Abort*\"],\"Resource\":[\"${aws_s3_bucket.LogHistory.arn}\",\"${aws_s3_bucket.LogHistory.arn}/*\"],\"Effect\":\"Allow\"}]}", "role": "${aws_iam_role.Bucket_OnCreate-OnMessage0_IamRole_D3BF2935.name}" }, "Bucket_OnCreate-OnMessage1_IamRolePolicy_975FD372": { @@ -191,7 +171,7 @@ "uniqueId": "Bucket_OnCreate-OnMessage1_IamRolePolicy_975FD372" } }, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"dynamodb:PutItem\"],\"Resource\":[\"${aws_dynamodb_table.Table.arn}\"],\"Effect\":\"Allow\"}]}", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"s3:PutObject*\",\"s3:Abort*\"],\"Resource\":[\"${aws_s3_bucket.LogHistory.arn}\",\"${aws_s3_bucket.LogHistory.arn}/*\"],\"Effect\":\"Allow\"}]}", "role": "${aws_iam_role.Bucket_OnCreate-OnMessage1_IamRole_0E855131.name}" }, "Bucket_OnDelete-OnMessage0_IamRolePolicy_A027DCBC": { @@ -201,7 +181,7 @@ "uniqueId": "Bucket_OnDelete-OnMessage0_IamRolePolicy_A027DCBC" } }, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"dynamodb:PutItem\"],\"Resource\":[\"${aws_dynamodb_table.Table.arn}\"],\"Effect\":\"Allow\"}]}", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"s3:PutObject*\",\"s3:Abort*\"],\"Resource\":[\"${aws_s3_bucket.LogHistory.arn}\",\"${aws_s3_bucket.LogHistory.arn}/*\"],\"Effect\":\"Allow\"}]}", "role": "${aws_iam_role.Bucket_OnDelete-OnMessage0_IamRole_A52E721B.name}" }, "Bucket_OnDelete-OnMessage1_IamRolePolicy_07F086F7": { @@ -211,7 +191,7 @@ "uniqueId": "Bucket_OnDelete-OnMessage1_IamRolePolicy_07F086F7" } }, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"dynamodb:PutItem\"],\"Resource\":[\"${aws_dynamodb_table.Table.arn}\"],\"Effect\":\"Allow\"}]}", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"s3:PutObject*\",\"s3:Abort*\"],\"Resource\":[\"${aws_s3_bucket.LogHistory.arn}\",\"${aws_s3_bucket.LogHistory.arn}/*\"],\"Effect\":\"Allow\"}]}", "role": "${aws_iam_role.Bucket_OnDelete-OnMessage1_IamRole_AA3A5721.name}" }, "Bucket_OnUpdate-OnMessage0_IamRolePolicy_DAF73AB9": { @@ -221,7 +201,7 @@ "uniqueId": "Bucket_OnUpdate-OnMessage0_IamRolePolicy_DAF73AB9" } }, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"dynamodb:PutItem\"],\"Resource\":[\"${aws_dynamodb_table.Table.arn}\"],\"Effect\":\"Allow\"}]}", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"s3:PutObject*\",\"s3:Abort*\"],\"Resource\":[\"${aws_s3_bucket.LogHistory.arn}\",\"${aws_s3_bucket.LogHistory.arn}/*\"],\"Effect\":\"Allow\"}]}", "role": "${aws_iam_role.Bucket_OnUpdate-OnMessage0_IamRole_96499EB9.name}" }, "Bucket_OnUpdate-OnMessage1_IamRolePolicy_E38714A4": { @@ -231,7 +211,7 @@ "uniqueId": "Bucket_OnUpdate-OnMessage1_IamRolePolicy_E38714A4" } }, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"dynamodb:PutItem\"],\"Resource\":[\"${aws_dynamodb_table.Table.arn}\"],\"Effect\":\"Allow\"}]}", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:UpdateItem\"],\"Resource\":[\"${aws_dynamodb_table.Counter.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"s3:PutObject*\",\"s3:Abort*\"],\"Resource\":[\"${aws_s3_bucket.LogHistory.arn}\",\"${aws_s3_bucket.LogHistory.arn}/*\"],\"Effect\":\"Allow\"}]}", "role": "${aws_iam_role.Bucket_OnUpdate-OnMessage1_IamRole_7B19D23F.name}" } }, @@ -310,10 +290,8 @@ ], "environment": { "variables": { + "BUCKET_NAME_76338bfb": "${aws_s3_bucket.LogHistory.bucket}", "DYNAMODB_TABLE_NAME_6cb5a3a4": "${aws_dynamodb_table.Counter.name}", - "DYNAMODB_TABLE_NAME_e7245baa": "${aws_dynamodb_table.Table.name}", - "DYNAMODB_TABLE_NAME_e7245baa_COLUMNS": "{\"_id\":0,\"key\":0,\"operation\":0,\"source\":0}", - "DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY": "_id", "NODE_OPTIONS": "--enable-source-maps", "WING_FUNCTION_NAME": "OnCreate-OnMessage0-c8740b4b", "WING_TARGET": "tf-aws" @@ -348,10 +326,8 @@ ], "environment": { "variables": { + "BUCKET_NAME_76338bfb": "${aws_s3_bucket.LogHistory.bucket}", "DYNAMODB_TABLE_NAME_6cb5a3a4": "${aws_dynamodb_table.Counter.name}", - "DYNAMODB_TABLE_NAME_e7245baa": "${aws_dynamodb_table.Table.name}", - "DYNAMODB_TABLE_NAME_e7245baa_COLUMNS": "{\"_id\":0,\"key\":0,\"operation\":0,\"source\":0}", - "DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY": "_id", "NODE_OPTIONS": "--enable-source-maps", "WING_FUNCTION_NAME": "OnCreate-OnMessage1-c8347a52", "WING_TARGET": "tf-aws" @@ -386,10 +362,8 @@ ], "environment": { "variables": { + "BUCKET_NAME_76338bfb": "${aws_s3_bucket.LogHistory.bucket}", "DYNAMODB_TABLE_NAME_6cb5a3a4": "${aws_dynamodb_table.Counter.name}", - "DYNAMODB_TABLE_NAME_e7245baa": "${aws_dynamodb_table.Table.name}", - "DYNAMODB_TABLE_NAME_e7245baa_COLUMNS": "{\"_id\":0,\"key\":0,\"operation\":0,\"source\":0}", - "DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY": "_id", "NODE_OPTIONS": "--enable-source-maps", "WING_FUNCTION_NAME": "OnDelete-OnMessage0-c8e711ef", "WING_TARGET": "tf-aws" @@ -424,10 +398,8 @@ ], "environment": { "variables": { + "BUCKET_NAME_76338bfb": "${aws_s3_bucket.LogHistory.bucket}", "DYNAMODB_TABLE_NAME_6cb5a3a4": "${aws_dynamodb_table.Counter.name}", - "DYNAMODB_TABLE_NAME_e7245baa": "${aws_dynamodb_table.Table.name}", - "DYNAMODB_TABLE_NAME_e7245baa_COLUMNS": "{\"_id\":0,\"key\":0,\"operation\":0,\"source\":0}", - "DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY": "_id", "NODE_OPTIONS": "--enable-source-maps", "WING_FUNCTION_NAME": "OnDelete-OnMessage1-c8905f5b", "WING_TARGET": "tf-aws" @@ -462,10 +434,8 @@ ], "environment": { "variables": { + "BUCKET_NAME_76338bfb": "${aws_s3_bucket.LogHistory.bucket}", "DYNAMODB_TABLE_NAME_6cb5a3a4": "${aws_dynamodb_table.Counter.name}", - "DYNAMODB_TABLE_NAME_e7245baa": "${aws_dynamodb_table.Table.name}", - "DYNAMODB_TABLE_NAME_e7245baa_COLUMNS": "{\"_id\":0,\"key\":0,\"operation\":0,\"source\":0}", - "DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY": "_id", "NODE_OPTIONS": "--enable-source-maps", "WING_FUNCTION_NAME": "OnUpdate-OnMessage0-c81b9fec", "WING_TARGET": "tf-aws" @@ -500,10 +470,8 @@ ], "environment": { "variables": { + "BUCKET_NAME_76338bfb": "${aws_s3_bucket.LogHistory.bucket}", "DYNAMODB_TABLE_NAME_6cb5a3a4": "${aws_dynamodb_table.Counter.name}", - "DYNAMODB_TABLE_NAME_e7245baa": "${aws_dynamodb_table.Table.name}", - "DYNAMODB_TABLE_NAME_e7245baa_COLUMNS": "{\"_id\":0,\"key\":0,\"operation\":0,\"source\":0}", - "DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY": "_id", "NODE_OPTIONS": "--enable-source-maps", "WING_FUNCTION_NAME": "OnUpdate-OnMessage1-c8513427", "WING_TARGET": "tf-aws" @@ -620,6 +588,16 @@ } }, "bucket_prefix": "code-c84a50b1-" + }, + "LogHistory": { + "//": { + "metadata": { + "path": "root/Default/Default/LogHistory/Default", + "uniqueId": "LogHistory" + } + }, + "bucket_prefix": "loghistory-c817bcb3-", + "force_destroy": false } }, "aws_s3_bucket_notification": { diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.test.w_compile_tf-aws.md deleted file mode 100644 index 08b438523c2..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.test.w_compile_tf-aws.md +++ /dev/null @@ -1,68 +0,0 @@ -# [add_row.test.w](../../../../../../examples/tests/sdk_tests/table/add_row.test.w) | compile | tf-aws - -## main.tf.json -```json -{ - "//": { - "metadata": { - "backend": "local", - "stackName": "root" - }, - "outputs": {} - }, - "provider": { - "aws": [ - {} - ] - }, - "resource": { - "aws_dynamodb_table": { - "Table": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/Default", - "uniqueId": "Table" - } - }, - "attribute": [ - { - "name": "name", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "name", - "name": "usersTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true - } - } - }, - "aws_dynamodb_table_item": { - "Table_DynamodbTableItem-mario_6E16BC1F": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/DynamodbTableItem-mario", - "uniqueId": "Table_DynamodbTableItem-mario_6E16BC1F" - } - }, - "hash_key": "${aws_dynamodb_table.Table.hash_key}", - "item": "{\"name\":{\"S\":\"mario\"},\"gender\":{\"S\":\"male\"},\"role\":{\"S\":\"plumber\"}}", - "table_name": "${aws_dynamodb_table.Table.name}" - }, - "Table_DynamodbTableItem-peach_FD7A7AE1": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/DynamodbTableItem-peach", - "uniqueId": "Table_DynamodbTableItem-peach_FD7A7AE1" - } - }, - "hash_key": "${aws_dynamodb_table.Table.hash_key}", - "item": "{\"name\":{\"S\":\"peach\"},\"gender\":{\"S\":\"female\"},\"role\":{\"S\":\"princess\"}}", - "table_name": "${aws_dynamodb_table.Table.name}" - } - } - } -} -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.test.w_test_sim.md deleted file mode 100644 index 247c7d22251..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/add_row.test.w_test_sim.md +++ /dev/null @@ -1,12 +0,0 @@ -# [add_row.test.w](../../../../../../examples/tests/sdk_tests/table/add_row.test.w) | test | sim - -## stdout.log -```log -pass ─ add_row.test.wsim » root/env0/test:addRow - -Tests 1 passed (1) -Snapshots 1 skipped -Test Files 1 passed (1) -Duration -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/aws-table.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/aws-table.test.w_compile_tf-aws.md deleted file mode 100644 index eda164c4db7..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/aws-table.test.w_compile_tf-aws.md +++ /dev/null @@ -1,44 +0,0 @@ -# [aws-table.test.w](../../../../../../examples/tests/sdk_tests/table/aws-table.test.w) | compile | tf-aws - -## main.tf.json -```json -{ - "//": { - "metadata": { - "backend": "local", - "stackName": "root" - }, - "outputs": {} - }, - "provider": { - "aws": [ - {} - ] - }, - "resource": { - "aws_dynamodb_table": { - "aws-wing-table": { - "//": { - "metadata": { - "path": "root/Default/Default/aws-wing-table/Default", - "uniqueId": "aws-wing-table" - } - }, - "attribute": [ - { - "name": "name", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "name", - "name": "usersaws-wing-table-c82a4d4a", - "point_in_time_recovery": { - "enabled": true - } - } - } - } -} -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/aws-table.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/aws-table.test.w_test_sim.md deleted file mode 100644 index 8f7e6cf61ff..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/aws-table.test.w_test_sim.md +++ /dev/null @@ -1,12 +0,0 @@ -# [aws-table.test.w](../../../../../../examples/tests/sdk_tests/table/aws-table.test.w) | test | sim - -## stdout.log -```log -pass ─ aws-table.test.wsim » root/env0/test:validates the AWS topic name - -Tests 1 passed (1) -Snapshots 1 skipped -Test Files 1 passed (1) -Duration -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/get.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/get.test.w_compile_tf-aws.md deleted file mode 100644 index b6158189d58..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/get.test.w_compile_tf-aws.md +++ /dev/null @@ -1,44 +0,0 @@ -# [get.test.w](../../../../../../examples/tests/sdk_tests/table/get.test.w) | compile | tf-aws - -## main.tf.json -```json -{ - "//": { - "metadata": { - "backend": "local", - "stackName": "root" - }, - "outputs": {} - }, - "provider": { - "aws": [ - {} - ] - }, - "resource": { - "aws_dynamodb_table": { - "Table": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/Default", - "uniqueId": "Table" - } - }, - "attribute": [ - { - "name": "name", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "name", - "name": "usersTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true - } - } - } - } -} -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/get.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/get.test.w_test_sim.md deleted file mode 100644 index 3ce154984b6..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/get.test.w_test_sim.md +++ /dev/null @@ -1,12 +0,0 @@ -# [get.test.w](../../../../../../examples/tests/sdk_tests/table/get.test.w) | test | sim - -## stdout.log -```log -pass ─ get.test.wsim » root/env0/test:get - -Tests 1 passed (1) -Snapshots 1 skipped -Test Files 1 passed (1) -Duration -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.test.w_compile_tf-aws.md deleted file mode 100644 index c719eb4f371..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.test.w_compile_tf-aws.md +++ /dev/null @@ -1,44 +0,0 @@ -# [list.test.w](../../../../../../examples/tests/sdk_tests/table/list.test.w) | compile | tf-aws - -## main.tf.json -```json -{ - "//": { - "metadata": { - "backend": "local", - "stackName": "root" - }, - "outputs": {} - }, - "provider": { - "aws": [ - {} - ] - }, - "resource": { - "aws_dynamodb_table": { - "Table": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/Default", - "uniqueId": "Table" - } - }, - "attribute": [ - { - "name": "name", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "name", - "name": "usersTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true - } - } - } - } -} -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.test.w_test_sim.md deleted file mode 100644 index 7963d94dfe2..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/list.test.w_test_sim.md +++ /dev/null @@ -1,12 +0,0 @@ -# [list.test.w](../../../../../../examples/tests/sdk_tests/table/list.test.w) | test | sim - -## stdout.log -```log -pass ─ list.test.wsim » root/env0/test:list - -Tests 1 passed (1) -Snapshots 1 skipped -Test Files 1 passed (1) -Duration -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/try_get.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/try_get.test.w_compile_tf-aws.md deleted file mode 100644 index 1a1e85f272f..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/try_get.test.w_compile_tf-aws.md +++ /dev/null @@ -1,44 +0,0 @@ -# [try_get.test.w](../../../../../../examples/tests/sdk_tests/table/try_get.test.w) | compile | tf-aws - -## main.tf.json -```json -{ - "//": { - "metadata": { - "backend": "local", - "stackName": "root" - }, - "outputs": {} - }, - "provider": { - "aws": [ - {} - ] - }, - "resource": { - "aws_dynamodb_table": { - "Table": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/Default", - "uniqueId": "Table" - } - }, - "attribute": [ - { - "name": "name", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "name", - "name": "usersTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true - } - } - } - } -} -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/try_get.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/try_get.test.w_test_sim.md deleted file mode 100644 index de3ded219eb..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/try_get.test.w_test_sim.md +++ /dev/null @@ -1,12 +0,0 @@ -# [try_get.test.w](../../../../../../examples/tests/sdk_tests/table/try_get.test.w) | test | sim - -## stdout.log -```log -pass ─ try_get.test.wsim » root/env0/test:tryGet - -Tests 1 passed (1) -Snapshots 1 skipped -Test Files 1 passed (1) -Duration -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/upsert.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/upsert.test.w_compile_tf-aws.md deleted file mode 100644 index 749a80d1802..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/upsert.test.w_compile_tf-aws.md +++ /dev/null @@ -1,68 +0,0 @@ -# [upsert.test.w](../../../../../../examples/tests/sdk_tests/table/upsert.test.w) | compile | tf-aws - -## main.tf.json -```json -{ - "//": { - "metadata": { - "backend": "local", - "stackName": "root" - }, - "outputs": {} - }, - "provider": { - "aws": [ - {} - ] - }, - "resource": { - "aws_dynamodb_table": { - "Table": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/Default", - "uniqueId": "Table" - } - }, - "attribute": [ - { - "name": "name", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "name", - "name": "usersTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true - } - } - }, - "aws_dynamodb_table_item": { - "Table_DynamodbTableItem-luigi_46B8F6CB": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/DynamodbTableItem-luigi", - "uniqueId": "Table_DynamodbTableItem-luigi_46B8F6CB" - } - }, - "hash_key": "${aws_dynamodb_table.Table.hash_key}", - "item": "{\"name\":{\"S\":\"luigi\"},\"gender\":{\"S\":\"male\"},\"role\":{\"S\":\"plumber\"}}", - "table_name": "${aws_dynamodb_table.Table.name}" - }, - "Table_DynamodbTableItem-mario_6E16BC1F": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/DynamodbTableItem-mario", - "uniqueId": "Table_DynamodbTableItem-mario_6E16BC1F" - } - }, - "hash_key": "${aws_dynamodb_table.Table.hash_key}", - "item": "{\"name\":{\"S\":\"mario\"},\"gender\":{\"S\":\"male\"},\"role\":{\"S\":\"plumber\"}}", - "table_name": "${aws_dynamodb_table.Table.name}" - } - } - } -} -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/upsert.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/upsert.test.w_test_sim.md deleted file mode 100644 index ec15cfb24df..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/table/upsert.test.w_test_sim.md +++ /dev/null @@ -1,12 +0,0 @@ -# [upsert.test.w](../../../../../../examples/tests/sdk_tests/table/upsert.test.w) | test | sim - -## stdout.log -```log -pass ─ upsert.test.wsim » root/env0/test:upsert - -Tests 1 passed (1) -Snapshots 1 skipped -Test Files 1 passed (1) -Duration -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md index 25554c50c25..87d0f929b1c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md @@ -342,7 +342,6 @@ class $Root extends $stdlib.std.Resource { $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; const cloud = $stdlib.cloud; - const ex = $stdlib.ex; const http = $stdlib.http; const expect = $stdlib.expect; $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md index fc79a506193..82ea0e4e6a5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md @@ -317,7 +317,6 @@ class $Root extends $stdlib.std.Resource { $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; const cloud = $stdlib.cloud; - const ex = $stdlib.ex; const http = $stdlib.http; const expect = $stdlib.expect; $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md deleted file mode 100644 index c833d9b3ccf..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md +++ /dev/null @@ -1,787 +0,0 @@ -# [redis.test.w](../../../../../examples/tests/valid/redis.test.w) | compile | tf-aws - -## inflight.$Closure1-1.cjs -```cjs -"use strict"; -const $helpers = require("@winglang/sdk/lib/helpers"); -module.exports = function({ $r }) { - class $Closure1 { - constructor({ }) { - const $obj = (...args) => this.handle(...args); - Object.setPrototypeOf($obj, this); - return $obj; - } - async handle(message) { - (await $r.set("hello", message)); - } - } - return $Closure1; -} -//# sourceMappingURL=inflight.$Closure1-1.cjs.map -``` - -## inflight.$Closure2-1.cjs -```cjs -"use strict"; -const $helpers = require("@winglang/sdk/lib/helpers"); -module.exports = function({ $queue, $r, $r2, $util_Util }) { - class $Closure2 { - constructor({ }) { - const $obj = (...args) => this.handle(...args); - Object.setPrototypeOf($obj, this); - return $obj; - } - async handle() { - (await $r2.set("wing", "does redis again")); - const value2 = (await $r2.get("wing")); - $helpers.assert($helpers.eq(value2, "does redis again"), "value2 == \"does redis again\""); - (await $queue.push("world!")); - (await $util_Util.waitUntil((async () => { - return $helpers.neq((await $r.get("hello")), undefined); - }))); - $helpers.assert($helpers.eq("world!", String.raw({ raw: ["", ""] }, ((await $r.get("hello")) ?? "nil"))), "\"world!\" == \"{r.get(\"hello\") ?? \"nil\"}\""); - } - } - return $Closure2; -} -//# sourceMappingURL=inflight.$Closure2-1.cjs.map -``` - -## main.tf.json -```json -{ - "//": { - "metadata": { - "backend": "local", - "stackName": "root" - }, - "outputs": {} - }, - "data": { - "aws_region": { - "Region": { - "//": { - "metadata": { - "path": "root/Default/Region", - "uniqueId": "Region" - } - } - } - } - }, - "provider": { - "aws": [ - {} - ] - }, - "resource": { - "aws_cloudwatch_log_group": { - "Queue-SetConsumer0_CloudwatchLogGroup_56C2891C": { - "//": { - "metadata": { - "path": "root/Default/Default/Queue-SetConsumer0/CloudwatchLogGroup", - "uniqueId": "Queue-SetConsumer0_CloudwatchLogGroup_56C2891C" - } - }, - "name": "/aws/lambda/Queue-SetConsumer0-c83c303c", - "retention_in_days": 30 - } - }, - "aws_eip": { - "EIP": { - "//": { - "metadata": { - "path": "root/Default/EIP", - "uniqueId": "EIP" - } - } - } - }, - "aws_elasticache_cluster": { - "Redis_RedisCluster_F55D8A3B": { - "//": { - "metadata": { - "path": "root/Default/Default/Redis/RedisCluster", - "uniqueId": "Redis_RedisCluster_F55D8A3B" - } - }, - "availability_zone": "${aws_subnet.PrivateSubnet.availability_zone}", - "cluster_id": "redis-c8cdb969", - "engine": "redis", - "engine_version": "6.2", - "node_type": "cache.t4g.small", - "num_cache_nodes": 1, - "parameter_group_name": "default.redis6.x", - "security_group_ids": [ - "${aws_security_group.Redis_KEN21securityGroup_139152DE.id}", - "${aws_security_group.Redis_KEN25securityGroup_D3232AB7.id}" - ], - "subnet_group_name": "${aws_elasticache_subnet_group.Redis_RedisSubnetGroup_E7D796E2.name}" - }, - "r2_RedisCluster_C6087F40": { - "//": { - "metadata": { - "path": "root/Default/Default/r2/RedisCluster", - "uniqueId": "r2_RedisCluster_C6087F40" - } - }, - "availability_zone": "${aws_subnet.PrivateSubnet.availability_zone}", - "cluster_id": "r2-c882797c", - "engine": "redis", - "engine_version": "6.2", - "node_type": "cache.t4g.small", - "num_cache_nodes": 1, - "parameter_group_name": "default.redis6.x", - "security_group_ids": [ - "${aws_security_group.r2_KEN37securityGroup_BF109712.id}", - "${aws_security_group.r2_KEN41securityGroup_A4C819DF.id}" - ], - "subnet_group_name": "${aws_elasticache_subnet_group.r2_RedisSubnetGroup_C415566B.name}" - } - }, - "aws_elasticache_subnet_group": { - "Redis_RedisSubnetGroup_E7D796E2": { - "//": { - "metadata": { - "path": "root/Default/Default/Redis/RedisSubnetGroup", - "uniqueId": "Redis_RedisSubnetGroup_E7D796E2" - } - }, - "name": "redis-c8cdb969-subnetGroup", - "subnet_ids": [ - "${aws_subnet.PrivateSubnet.id}", - "${aws_subnet.PrivateSubnet2.id}" - ] - }, - "r2_RedisSubnetGroup_C415566B": { - "//": { - "metadata": { - "path": "root/Default/Default/r2/RedisSubnetGroup", - "uniqueId": "r2_RedisSubnetGroup_C415566B" - } - }, - "name": "r2-c882797c-subnetGroup", - "subnet_ids": [ - "${aws_subnet.PrivateSubnet.id}", - "${aws_subnet.PrivateSubnet2.id}" - ] - } - }, - "aws_iam_role": { - "Queue-SetConsumer0_IamRole_7F9ED9ED": { - "//": { - "metadata": { - "path": "root/Default/Default/Queue-SetConsumer0/IamRole", - "uniqueId": "Queue-SetConsumer0_IamRole_7F9ED9ED" - } - }, - "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"lambda.amazonaws.com\"},\"Effect\":\"Allow\"}]}" - } - }, - "aws_iam_role_policy": { - "Queue-SetConsumer0_IamRolePolicy_0299B5AB": { - "//": { - "metadata": { - "path": "root/Default/Default/Queue-SetConsumer0/IamRolePolicy", - "uniqueId": "Queue-SetConsumer0_IamRolePolicy_0299B5AB" - } - }, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"sqs:ReceiveMessage\",\"sqs:ChangeMessageVisibility\",\"sqs:GetQueueUrl\",\"sqs:DeleteMessage\",\"sqs:GetQueueAttributes\"],\"Resource\":[\"${aws_sqs_queue.Queue.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"elasticache:Describe*\"],\"Resource\":[\"${aws_elasticache_cluster.Redis_RedisCluster_F55D8A3B.arn}\"],\"Effect\":\"Allow\"},{\"Action\":[\"ec2:CreateNetworkInterface\",\"ec2:DescribeNetworkInterfaces\",\"ec2:DeleteNetworkInterface\",\"ec2:DescribeSubnets\",\"ec2:DescribeSecurityGroups\"],\"Resource\":[\"*\"],\"Effect\":\"Allow\"}]}", - "role": "${aws_iam_role.Queue-SetConsumer0_IamRole_7F9ED9ED.name}" - } - }, - "aws_iam_role_policy_attachment": { - "Queue-SetConsumer0_IamRolePolicyAttachment_4A4C5C5D": { - "//": { - "metadata": { - "path": "root/Default/Default/Queue-SetConsumer0/IamRolePolicyAttachment", - "uniqueId": "Queue-SetConsumer0_IamRolePolicyAttachment_4A4C5C5D" - } - }, - "policy_arn": "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole", - "role": "${aws_iam_role.Queue-SetConsumer0_IamRole_7F9ED9ED.name}" - } - }, - "aws_internet_gateway": { - "InternetGateway": { - "//": { - "metadata": { - "path": "root/Default/InternetGateway", - "uniqueId": "InternetGateway" - } - }, - "tags": { - "Name": "Default-c82bf964-internet-gateway" - }, - "vpc_id": "${aws_vpc.VPC.id}" - } - }, - "aws_lambda_event_source_mapping": { - "Queue_EventSourceMapping_8332F7DC": { - "//": { - "metadata": { - "path": "root/Default/Default/Queue/EventSourceMapping", - "uniqueId": "Queue_EventSourceMapping_8332F7DC" - } - }, - "batch_size": 1, - "event_source_arn": "${aws_sqs_queue.Queue.arn}", - "function_name": "${aws_lambda_function.Queue-SetConsumer0.function_name}", - "function_response_types": [ - "ReportBatchItemFailures" - ] - } - }, - "aws_lambda_function": { - "Queue-SetConsumer0": { - "//": { - "metadata": { - "path": "root/Default/Default/Queue-SetConsumer0/Default", - "uniqueId": "Queue-SetConsumer0" - } - }, - "architectures": [ - "arm64" - ], - "environment": { - "variables": { - "NODE_OPTIONS": "--enable-source-maps", - "REDIS_CLUSTER_ID_3542402a": "${aws_elasticache_cluster.Redis_RedisCluster_F55D8A3B.cluster_id}", - "WING_FUNCTION_NAME": "Queue-SetConsumer0-c83c303c", - "WING_TARGET": "tf-aws" - } - }, - "function_name": "Queue-SetConsumer0-c83c303c", - "handler": "index.handler", - "logging_config": { - "log_format": "JSON" - }, - "memory_size": 1024, - "publish": true, - "role": "${aws_iam_role.Queue-SetConsumer0_IamRole_7F9ED9ED.arn}", - "runtime": "nodejs20.x", - "s3_bucket": "${aws_s3_bucket.Code.bucket}", - "s3_key": "${aws_s3_object.Queue-SetConsumer0_S3Object_2AD0A795.key}", - "timeout": "${aws_sqs_queue.Queue.visibility_timeout_seconds}", - "vpc_config": { - "security_group_ids": [ - "${aws_security_group.Redis_KEN21securityGroup_139152DE.id}", - "${aws_security_group.Redis_KEN25securityGroup_D3232AB7.id}" - ], - "subnet_ids": [ - "${aws_subnet.PrivateSubnet.id}", - "${aws_subnet.PrivateSubnet2.id}" - ] - } - } - }, - "aws_nat_gateway": { - "NATGateway": { - "//": { - "metadata": { - "path": "root/Default/NATGateway", - "uniqueId": "NATGateway" - } - }, - "allocation_id": "${aws_eip.EIP.id}", - "subnet_id": "${aws_subnet.PublicSubnet.id}", - "tags": { - "Name": "Default-c82bf964-nat-gateway" - } - } - }, - "aws_route_table": { - "PrivateRouteTable": { - "//": { - "metadata": { - "path": "root/Default/PrivateRouteTable", - "uniqueId": "PrivateRouteTable" - } - }, - "route": [ - { - "carrier_gateway_id": null, - "cidr_block": "0.0.0.0/0", - "core_network_arn": null, - "destination_prefix_list_id": null, - "egress_only_gateway_id": null, - "gateway_id": null, - "ipv6_cidr_block": null, - "local_gateway_id": null, - "nat_gateway_id": "${aws_nat_gateway.NATGateway.id}", - "network_interface_id": null, - "transit_gateway_id": null, - "vpc_endpoint_id": null, - "vpc_peering_connection_id": null - } - ], - "tags": { - "Name": "Default-c82bf964-private-route-table-1" - }, - "vpc_id": "${aws_vpc.VPC.id}" - }, - "PrivateRouteTable2": { - "//": { - "metadata": { - "path": "root/Default/PrivateRouteTable2", - "uniqueId": "PrivateRouteTable2" - } - }, - "route": [ - { - "carrier_gateway_id": null, - "cidr_block": "0.0.0.0/0", - "core_network_arn": null, - "destination_prefix_list_id": null, - "egress_only_gateway_id": null, - "gateway_id": null, - "ipv6_cidr_block": null, - "local_gateway_id": null, - "nat_gateway_id": "${aws_nat_gateway.NATGateway.id}", - "network_interface_id": null, - "transit_gateway_id": null, - "vpc_endpoint_id": null, - "vpc_peering_connection_id": null - } - ], - "tags": { - "Name": "Default-c82bf964-private-route-table-2" - }, - "vpc_id": "${aws_vpc.VPC.id}" - }, - "PublicRouteTable": { - "//": { - "metadata": { - "path": "root/Default/PublicRouteTable", - "uniqueId": "PublicRouteTable" - } - }, - "route": [ - { - "carrier_gateway_id": null, - "cidr_block": "0.0.0.0/0", - "core_network_arn": null, - "destination_prefix_list_id": null, - "egress_only_gateway_id": null, - "gateway_id": "${aws_internet_gateway.InternetGateway.id}", - "ipv6_cidr_block": null, - "local_gateway_id": null, - "nat_gateway_id": null, - "network_interface_id": null, - "transit_gateway_id": null, - "vpc_endpoint_id": null, - "vpc_peering_connection_id": null - } - ], - "tags": { - "Name": "Default-c82bf964-public-route-table-1" - }, - "vpc_id": "${aws_vpc.VPC.id}" - } - }, - "aws_route_table_association": { - "PrivateRouteTableAssociation": { - "//": { - "metadata": { - "path": "root/Default/PrivateRouteTableAssociation", - "uniqueId": "PrivateRouteTableAssociation" - } - }, - "route_table_id": "${aws_route_table.PrivateRouteTable.id}", - "subnet_id": "${aws_subnet.PrivateSubnet.id}" - }, - "PrivateRouteTableAssociation2": { - "//": { - "metadata": { - "path": "root/Default/PrivateRouteTableAssociation2", - "uniqueId": "PrivateRouteTableAssociation2" - } - }, - "route_table_id": "${aws_route_table.PrivateRouteTable2.id}", - "subnet_id": "${aws_subnet.PrivateSubnet2.id}" - }, - "PublicRouteTableAssociation": { - "//": { - "metadata": { - "path": "root/Default/PublicRouteTableAssociation", - "uniqueId": "PublicRouteTableAssociation" - } - }, - "route_table_id": "${aws_route_table.PublicRouteTable.id}", - "subnet_id": "${aws_subnet.PublicSubnet.id}" - } - }, - "aws_s3_bucket": { - "Code": { - "//": { - "metadata": { - "path": "root/Default/Code", - "uniqueId": "Code" - } - }, - "bucket_prefix": "code-c84a50b1-" - } - }, - "aws_s3_object": { - "Queue-SetConsumer0_S3Object_2AD0A795": { - "//": { - "metadata": { - "path": "root/Default/Default/Queue-SetConsumer0/S3Object", - "uniqueId": "Queue-SetConsumer0_S3Object_2AD0A795" - } - }, - "bucket": "${aws_s3_bucket.Code.bucket}", - "key": "", - "source": "" - } - }, - "aws_security_group": { - "Redis_KEN21securityGroup_139152DE": { - "//": { - "metadata": { - "path": "root/Default/Default/Redis/KEN.21]}securityGroup", - "uniqueId": "Redis_KEN21securityGroup_139152DE" - } - }, - "egress": [ - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": null, - "from_port": 0, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "-1", - "security_groups": null, - "self": null, - "to_port": 0 - } - ], - "ingress": [ - { - "cidr_blocks": [ - "${aws_subnet.PrivateSubnet.cidr_block}" - ], - "description": null, - "from_port": 6379, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "tcp", - "security_groups": null, - "self": true, - "to_port": 6379 - } - ], - "name": "3542402a-${aws_subnet.PrivateSubnet.id}-securityGroup", - "vpc_id": "${aws_vpc.VPC.id}" - }, - "Redis_KEN25securityGroup_D3232AB7": { - "//": { - "metadata": { - "path": "root/Default/Default/Redis/KEN.25]}securityGroup", - "uniqueId": "Redis_KEN25securityGroup_D3232AB7" - } - }, - "egress": [ - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": null, - "from_port": 0, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "-1", - "security_groups": null, - "self": null, - "to_port": 0 - } - ], - "ingress": [ - { - "cidr_blocks": [ - "${aws_subnet.PrivateSubnet2.cidr_block}" - ], - "description": null, - "from_port": 6379, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "tcp", - "security_groups": null, - "self": true, - "to_port": 6379 - } - ], - "name": "3542402a-${aws_subnet.PrivateSubnet2.id}-securityGroup", - "vpc_id": "${aws_vpc.VPC.id}" - }, - "r2_KEN37securityGroup_BF109712": { - "//": { - "metadata": { - "path": "root/Default/Default/r2/KEN.37]}securityGroup", - "uniqueId": "r2_KEN37securityGroup_BF109712" - } - }, - "egress": [ - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": null, - "from_port": 0, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "-1", - "security_groups": null, - "self": null, - "to_port": 0 - } - ], - "ingress": [ - { - "cidr_blocks": [ - "${aws_subnet.PrivateSubnet.cidr_block}" - ], - "description": null, - "from_port": 6379, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "tcp", - "security_groups": null, - "self": true, - "to_port": 6379 - } - ], - "name": "30c8c4ae-${aws_subnet.PrivateSubnet.id}-securityGroup", - "vpc_id": "${aws_vpc.VPC.id}" - }, - "r2_KEN41securityGroup_A4C819DF": { - "//": { - "metadata": { - "path": "root/Default/Default/r2/KEN.41]}securityGroup", - "uniqueId": "r2_KEN41securityGroup_A4C819DF" - } - }, - "egress": [ - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": null, - "from_port": 0, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "-1", - "security_groups": null, - "self": null, - "to_port": 0 - } - ], - "ingress": [ - { - "cidr_blocks": [ - "${aws_subnet.PrivateSubnet2.cidr_block}" - ], - "description": null, - "from_port": 6379, - "ipv6_cidr_blocks": null, - "prefix_list_ids": null, - "protocol": "tcp", - "security_groups": null, - "self": true, - "to_port": 6379 - } - ], - "name": "30c8c4ae-${aws_subnet.PrivateSubnet2.id}-securityGroup", - "vpc_id": "${aws_vpc.VPC.id}" - } - }, - "aws_sqs_queue": { - "Queue": { - "//": { - "metadata": { - "path": "root/Default/Default/Queue/Default", - "uniqueId": "Queue" - } - }, - "message_retention_seconds": 3600, - "name": "Queue-c822c726", - "visibility_timeout_seconds": 30 - } - }, - "aws_subnet": { - "PrivateSubnet": { - "//": { - "metadata": { - "path": "root/Default/PrivateSubnet", - "uniqueId": "PrivateSubnet" - } - }, - "availability_zone": "${data.aws_region.Region.name}a", - "cidr_block": "10.0.4.0/22", - "tags": { - "Name": "Default-c82bf964-private-subnet-1" - }, - "vpc_id": "${aws_vpc.VPC.id}" - }, - "PrivateSubnet2": { - "//": { - "metadata": { - "path": "root/Default/PrivateSubnet2", - "uniqueId": "PrivateSubnet2" - } - }, - "availability_zone": "${data.aws_region.Region.name}b", - "cidr_block": "10.0.8.0/22", - "tags": { - "Name": "Default-c82bf964-private-subnet-2" - }, - "vpc_id": "${aws_vpc.VPC.id}" - }, - "PublicSubnet": { - "//": { - "metadata": { - "path": "root/Default/PublicSubnet", - "uniqueId": "PublicSubnet" - } - }, - "availability_zone": "${data.aws_region.Region.name}a", - "cidr_block": "10.0.0.0/24", - "tags": { - "Name": "Default-c82bf964-public-subnet-1" - }, - "vpc_id": "${aws_vpc.VPC.id}" - } - }, - "aws_vpc": { - "VPC": { - "//": { - "metadata": { - "path": "root/Default/VPC", - "uniqueId": "VPC" - } - }, - "cidr_block": "10.0.0.0/16", - "enable_dns_hostnames": true, - "enable_dns_support": true, - "tags": { - "Name": "Default-c82bf964-vpc" - } - } - } - } -} -``` - -## preflight.cjs -```cjs -"use strict"; -const $stdlib = require('@winglang/sdk'); -const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); -const $outdir = process.env.WING_SYNTH_DIR ?? "."; -const $wing_is_test = process.env.WING_IS_TEST === "true"; -const std = $stdlib.std; -const $helpers = $stdlib.helpers; -const $extern = $helpers.createExternRequire(__dirname); -const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); -class $Root extends $stdlib.std.Resource { - constructor($scope, $id) { - super($scope, $id); - $helpers.nodeof(this).root.$preflightTypesMap = { }; - let $preflightTypesMap = {}; - const cloud = $stdlib.cloud; - const util = $stdlib.util; - const ex = $stdlib.ex; - $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; - class $Closure1 extends $stdlib.std.AutoIdResource { - _id = $stdlib.core.closureId(); - constructor($scope, $id, ) { - super($scope, $id); - $helpers.nodeof(this).hidden = true; - } - static _toInflightType() { - return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.cjs")({ - $r: ${$stdlib.core.liftObject(r)}, - }) - `; - } - _toInflight() { - return ` - (await (async () => { - const $Closure1Client = ${$Closure1._toInflightType()}; - const client = new $Closure1Client({ - }); - if (client.$inflight_init) { await client.$inflight_init(); } - return client; - })()) - `; - } - get _liftMap() { - return ({ - "handle": [ - [r, ["set"]], - ], - "$inflight_init": [ - [r, []], - ], - }); - } - } - class $Closure2 extends $stdlib.std.AutoIdResource { - _id = $stdlib.core.closureId(); - constructor($scope, $id, ) { - super($scope, $id); - $helpers.nodeof(this).hidden = true; - } - static _toInflightType() { - return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure2-1.cjs")({ - $queue: ${$stdlib.core.liftObject(queue)}, - $r: ${$stdlib.core.liftObject(r)}, - $r2: ${$stdlib.core.liftObject(r2)}, - $util_Util: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"))}, - }) - `; - } - _toInflight() { - return ` - (await (async () => { - const $Closure2Client = ${$Closure2._toInflightType()}; - const client = new $Closure2Client({ - }); - if (client.$inflight_init) { await client.$inflight_init(); } - return client; - })()) - `; - } - get _liftMap() { - return ({ - "handle": [ - [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], - [queue, ["push"]], - [r, ["get"]], - [r2, [].concat(["set"], ["get"])], - ], - "$inflight_init": [ - [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], - [queue, []], - [r, []], - [r2, []], - ], - }); - } - } - const r = globalThis.$ClassFactory.new("@winglang/sdk.ex.Redis", ex.Redis, this, "Redis"); - const r2 = globalThis.$ClassFactory.new("@winglang/sdk.ex.Redis", ex.Redis, this, "r2"); - const queue = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Queue", cloud.Queue, this, "Queue"); - (queue.setConsumer(new $Closure1(this, "$Closure1"), { timeout: (std.Duration.fromSeconds(3)) })); - globalThis.$ClassFactory.new("@winglang/sdk.std.Test", std.Test, this, "test:testing Redis", new $Closure2(this, "$Closure2")); - } -} -const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "redis.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); -$APP.synth(); -//# sourceMappingURL=preflight.cjs.map -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_test_sim.md deleted file mode 100644 index 5a56e97045d..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_test_sim.md +++ /dev/null @@ -1,12 +0,0 @@ -# [redis.test.w](../../../../../examples/tests/valid/redis.test.w) | test | sim - -## stdout.log -```log -pass ─ redis.test.wsim » root/env0/test:testing Redis - -Tests 1 passed (1) -Snapshots 1 skipped -Test Files 1 passed (1) -Duration -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md deleted file mode 100644 index 077d0924b89..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md +++ /dev/null @@ -1,70 +0,0 @@ -# [table.test.w](../../../../../examples/tests/valid/table.test.w) | compile | tf-aws - -## main.tf.json -```json -{ - "//": { - "metadata": { - "backend": "local", - "stackName": "root" - }, - "outputs": {} - }, - "provider": { - "aws": [ - {} - ] - }, - "resource": { - "aws_dynamodb_table": { - "Table": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/Default", - "uniqueId": "Table" - } - }, - "attribute": [ - { - "name": "id", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "id", - "name": "simple-tableTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true - } - } - } - } -} -``` - -## preflight.cjs -```cjs -"use strict"; -const $stdlib = require('@winglang/sdk'); -const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); -const $outdir = process.env.WING_SYNTH_DIR ?? "."; -const $wing_is_test = process.env.WING_IS_TEST === "true"; -const std = $stdlib.std; -const $helpers = $stdlib.helpers; -const $extern = $helpers.createExternRequire(__dirname); -const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); -class $Root extends $stdlib.std.Resource { - constructor($scope, $id) { - super($scope, $id); - $helpers.nodeof(this).root.$preflightTypesMap = { }; - let $preflightTypesMap = {}; - const ex = $stdlib.ex; - $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; - const t = globalThis.$ClassFactory.new("@winglang/sdk.ex.Table", ex.Table, this, "Table", { name: "simple-table", primaryKey: "id", columns: ({["id"]: ex.ColumnType.STRING, ["name"]: ex.ColumnType.STRING, ["age"]: ex.ColumnType.NUMBER}) }); - } -} -const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "table.test", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); -$APP.synth(); -//# sourceMappingURL=preflight.cjs.map -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_test_sim.md deleted file mode 100644 index 4d87d3440bd..00000000000 --- a/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_test_sim.md +++ /dev/null @@ -1,12 +0,0 @@ -# [table.test.w](../../../../../examples/tests/valid/table.test.w) | test | sim - -## stdout.log -```log -pass ─ table.test.wsim (no tests) - -Tests 1 passed (1) -Snapshots 1 skipped -Test Files 1 passed (1) -Duration -``` - diff --git a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md index 608a9bd49b9..03b5d43ffb5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md @@ -4,7 +4,7 @@ ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); -module.exports = function({ $std_Json, $usersTable }) { +module.exports = function({ $std_Json, $userData }) { class $Closure1 { constructor({ }) { const $obj = (...args) => this.handle(...args); @@ -12,7 +12,7 @@ module.exports = function({ $std_Json, $usersTable }) { return $obj; } async handle(req) { - return ({"body": ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(({"users": (await $usersTable.list())})), "status": 200}); + return ({"body": ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(({"users": (await $userData.list())})), "status": 200}); } } return $Closure1; @@ -24,7 +24,7 @@ module.exports = function({ $std_Json, $usersTable }) { ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); -module.exports = function({ $std_Json, $usersTable }) { +module.exports = function({ $std_Json, $userData }) { class $Closure2 { constructor({ }) { const $obj = (...args) => this.handle(...args); @@ -36,7 +36,7 @@ module.exports = function({ $std_Json, $usersTable }) { if ((($helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "name"), "") || $helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "age"), "")) || $helpers.eq(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "id"), ""))) { return ({"body": ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(({"error": "incomplete details"})), "status": 400}); } - (await $usersTable.insert(((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "id")), body)); + (await $userData.putJson(((arg) => { if (typeof arg !== "string") {throw new Error("unable to parse " + typeof arg + " " + arg + " as a string")}; return JSON.parse(JSON.stringify(arg)) })(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "id")), body)); return ({"body": ((json, opts) => { return JSON.stringify(json, null, opts?.indent) })(({"user": ((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(body, "id")})), "status": 201}); } } @@ -328,28 +328,6 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util "retention_in_days": 30 } }, - "aws_dynamodb_table": { - "Table": { - "//": { - "metadata": { - "path": "root/Default/Default/Table/Default", - "uniqueId": "Table" - } - }, - "attribute": [ - { - "name": "id", - "type": "S" - } - ], - "billing_mode": "PAY_PER_REQUEST", - "hash_key": "id", - "name": "users-tableTable-c89b2d37", - "point_in_time_recovery": { - "enabled": true - } - } - }, "aws_iam_role": { "Api_get_users0_IamRole_950ACE40": { "//": { @@ -378,7 +356,7 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util "uniqueId": "Api_get_users0_IamRolePolicy_1C96E6D8" } }, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:Scan\"],\"Resource\":[\"${aws_dynamodb_table.Table.arn}\"],\"Effect\":\"Allow\"}]}", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"s3:List*\",\"s3:GetObject*\",\"s3:GetBucket*\"],\"Resource\":[\"${aws_s3_bucket.Bucket.arn}\",\"${aws_s3_bucket.Bucket.arn}/*\"],\"Effect\":\"Allow\"}]}", "role": "${aws_iam_role.Api_get_users0_IamRole_950ACE40.name}" }, "Api_post_users0_IamRolePolicy_32ED25A9": { @@ -388,7 +366,7 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util "uniqueId": "Api_post_users0_IamRolePolicy_32ED25A9" } }, - "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"dynamodb:PutItem\"],\"Resource\":[\"${aws_dynamodb_table.Table.arn}\"],\"Effect\":\"Allow\"}]}", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":[\"s3:PutObject*\",\"s3:Abort*\"],\"Resource\":[\"${aws_s3_bucket.Bucket.arn}\",\"${aws_s3_bucket.Bucket.arn}/*\"],\"Effect\":\"Allow\"}]}", "role": "${aws_iam_role.Api_post_users0_IamRole_B6E18B7C.name}" } }, @@ -427,9 +405,7 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util ], "environment": { "variables": { - "DYNAMODB_TABLE_NAME_e7245baa": "${aws_dynamodb_table.Table.name}", - "DYNAMODB_TABLE_NAME_e7245baa_COLUMNS": "{\"id\":0,\"name\":0,\"age\":1}", - "DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY": "id", + "BUCKET_NAME_1357ca3a": "${aws_s3_bucket.Bucket.bucket}", "NODE_OPTIONS": "--enable-source-maps", "WING_FUNCTION_NAME": "get_users0-c82bfbcd", "WING_TARGET": "tf-aws" @@ -464,9 +440,7 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util ], "environment": { "variables": { - "DYNAMODB_TABLE_NAME_e7245baa": "${aws_dynamodb_table.Table.name}", - "DYNAMODB_TABLE_NAME_e7245baa_COLUMNS": "{\"id\":0,\"name\":0,\"age\":1}", - "DYNAMODB_TABLE_NAME_e7245baa_PRIMARY_KEY": "id", + "BUCKET_NAME_1357ca3a": "${aws_s3_bucket.Bucket.bucket}", "NODE_OPTIONS": "--enable-source-maps", "WING_FUNCTION_NAME": "post_users0-c8ae30d9", "WING_TARGET": "tf-aws" @@ -519,6 +493,16 @@ module.exports = function({ $api_url, $expect_Util, $http_HttpMethod, $http_Util } }, "aws_s3_bucket": { + "Bucket": { + "//": { + "metadata": { + "path": "root/Default/Default/Bucket/Default", + "uniqueId": "Bucket" + } + }, + "bucket_prefix": "bucket-c88fdc5f-", + "force_destroy": false + }, "Code": { "//": { "metadata": { @@ -641,7 +625,6 @@ class $Root extends $stdlib.std.Resource { $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; const cloud = $stdlib.cloud; - const ex = $stdlib.ex; const http = $stdlib.http; const expect = $stdlib.expect; $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; @@ -655,7 +638,7 @@ class $Root extends $stdlib.std.Resource { return ` require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.cjs")({ $std_Json: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"))}, - $usersTable: ${$stdlib.core.liftObject(usersTable)}, + $userData: ${$stdlib.core.liftObject(userData)}, }) `; } @@ -674,11 +657,11 @@ class $Root extends $stdlib.std.Resource { return ({ "handle": [ [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], - [usersTable, ["list"]], + [userData, ["list"]], ], "$inflight_init": [ [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], - [usersTable, []], + [userData, []], ], }); } @@ -693,7 +676,7 @@ class $Root extends $stdlib.std.Resource { return ` require("${$helpers.normalPath(__dirname)}/inflight.$Closure2-1.cjs")({ $std_Json: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"))}, - $usersTable: ${$stdlib.core.liftObject(usersTable)}, + $userData: ${$stdlib.core.liftObject(userData)}, }) `; } @@ -712,11 +695,11 @@ class $Root extends $stdlib.std.Resource { return ({ "handle": [ [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), [].concat(["parse"], ["stringify"])], - [usersTable, ["insert"]], + [userData, ["putJson"]], ], "$inflight_init": [ [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], - [usersTable, []], + [userData, []], ], }); } @@ -811,7 +794,7 @@ class $Root extends $stdlib.std.Resource { } const api = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Api", cloud.Api, this, "Api", { cors: true, corsOptions: ({"allowOrigin": "*", "allowMethods": [cloud.HttpMethod.GET, cloud.HttpMethod.POST, cloud.HttpMethod.OPTIONS], "allowHeaders": ["Content-Type"], "allowCredentials": false, "exposeHeaders": ["Content-Type"], "maxAge": (std.Duration.fromSeconds(600))}) }); const website = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Website", cloud.Website, this, "Website", { path: "./website_with_api" }); - const usersTable = globalThis.$ClassFactory.new("@winglang/sdk.ex.Table", ex.Table, this, "Table", { name: "users-table", primaryKey: "id", columns: ({["id"]: ex.ColumnType.STRING, ["name"]: ex.ColumnType.STRING, ["age"]: ex.ColumnType.NUMBER}) }); + const userData = globalThis.$ClassFactory.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "Bucket"); const getHandler = new $Closure1(this, "$Closure1"); const postHandler = new $Closure2(this, "$Closure2"); (api.get("/users", getHandler));