diff --git a/.github/workflows/cd-containers.yaml b/.github/workflows/cd-containers.yaml index 3479718c6c..b7d9fe1c29 100644 --- a/.github/workflows/cd-containers.yaml +++ b/.github/workflows/cd-containers.yaml @@ -42,6 +42,7 @@ jobs: run: | echo IMAGE_RS_VM_DIR=./packages/cli/src/lib/defaults/build-strategies/wasm/rust/vm >> $GITHUB_ENV echo IMAGE_AS_VM_DIR=./packages/cli/src/lib/defaults/build-strategies/wasm/assemblyscript/vm >> $GITHUB_ENV + echo IMAGE_GO_VM_DIR=./packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm >> $GITHUB_ENV - name: Read Image VERSION & NAME into env.IMAGE_..._VERSION/NAME run: | @@ -49,11 +50,14 @@ jobs: echo IMAGE_RS_VM_VERSION=$(cat $IMAGE_RS_VM_DIR/VERSION) >> $GITHUB_ENV echo IMAGE_AS_VM_NAME=$(cat $IMAGE_AS_VM_DIR/NAME) >> $GITHUB_ENV echo IMAGE_AS_VM_VERSION=$(cat $IMAGE_AS_VM_DIR/VERSION) >> $GITHUB_ENV + echo IMAGE_GO_VM_NAME=$(cat $IMAGE_GO_VM_DIR/NAME) >> $GITHUB_ENV + echo IMAGE_GO_VM_VERSION=$(cat $IMAGE_GO_VM_DIR/VERSION) >> $GITHUB_ENV - name: Check if image tags already exist run: | echo IMAGE_RS_VM_UNPUBLISHED=$(! curl -s "https://hub.docker.com/v2/repositories/$IMAGE_RS_VM_NAME/tags/$IMAGE_RS_VM_VERSION" | grep -q "error 404" > /dev/null ; echo $?) >> $GITHUB_ENV echo IMAGE_AS_VM_UNPUBLISHED=$(! curl -s "https://hub.docker.com/v2/repositories/$IMAGE_AS_VM_NAME/tags/$IMAGE_AS_VM_VERSION" | grep -q "error 404" > /dev/null ; echo $?) >> $GITHUB_ENV + echo IMAGE_GO_VM_UNPUBLISHED=$(! curl -s "https://hub.docker.com/v2/repositories/$IMAGE_GO_VM_NAME/tags/$IMAGE_GO_VM_VERSION" | grep -q "error 404" > /dev/null ; echo $?) >> $GITHUB_ENV - name: Build & Publish RS VM Image if: env.IMAGE_RS_VM_UNPUBLISHED == '1' @@ -70,3 +74,11 @@ jobs: docker buildx create --use --name as-vm-builder docker buildx build . --platform=linux/amd64,linux/arm64 -t $IMAGE_AS_VM_NAME:latest -t $IMAGE_AS_VM_NAME:$IMAGE_AS_VM_VERSION --output type=registry docker buildx rm as-vm-builder + + - name: Build & Publish GO VM Image + if: env.IMAGE_GO_VM_UNPUBLISHED == '1' + working-directory: ${{env.IMAGE_GO_VM_DIR}} + run: | + docker buildx create --use --name go-vm-builder + docker buildx build . --platform=linux/amd64,linux/arm64 -t $IMAGE_GO_VM_NAME:latest -t $IMAGE_GO_VM_NAME:$IMAGE_GO_VM_VERSION --output type=registry + docker buildx rm go-vm-builder diff --git a/.github/workflows/ci-golang.yaml b/.github/workflows/ci-golang.yaml new file mode 100644 index 0000000000..4a28418d0b --- /dev/null +++ b/.github/workflows/ci-golang.yaml @@ -0,0 +1,45 @@ +name: CI-Golang + +on: + push: + branches: + - origin + - origin-dev + pull_request: + +jobs: + Test-Cli: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Read .nvmrc + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + id: nvm + + - name: Setup Node.js + uses: actions/setup-node@master + with: + node-version: '${{ steps.nvm.outputs.NVMRC }}' + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: yarn install --nonInteractive --frozen-lockfile --prefer-offline + + - name: Build + run: yarn build + + - name: Test + run: yarn test:golang + working-directory: ./packages/cli diff --git a/.github/workflows/ci-javascript.yaml b/.github/workflows/ci-javascript.yaml index 2fba40ed31..e7cd22da9a 100644 --- a/.github/workflows/ci-javascript.yaml +++ b/.github/workflows/ci-javascript.yaml @@ -83,9 +83,8 @@ jobs: CI-WRAP-Test-Harness: uses: ./.github/workflows/ci-wrap-test-harness.yaml - Test-Core: + Test-Templates: runs-on: ubuntu-latest - needs: CI-WRAP-Test-Harness timeout-minutes: 60 if: ${{ always() }} steps: @@ -139,18 +138,63 @@ jobs: - name: Build run: yarn build - - name: Get updated wrappers - if: ${{ needs.CI-WRAP-Test-Harness.outputs.rebuild_required == 'true' }} - uses: actions/download-artifact@v3 - id: get-wrappers + - name: Test + run: yarn test:templates + + Test-Core: + runs-on: ubuntu-latest + timeout-minutes: 60 + if: ${{ always() }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Read .nvmrc + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + id: nvm + + - name: Setup Node.js + uses: actions/setup-node@master with: - name: rebuilt-wrappers - path: ./wrappers + node-version: '${{ steps.nvm.outputs.NVMRC }}' - - if: ${{ needs.CI-WRAP-Test-Harness.outputs.rebuild_required == 'true' }} - run: | - rm -rf packages/test-cases/cases/wrappers - mv wrappers packages/test-cases/cases + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Setup Poetry + uses: abatilo/actions-poetry@v2 + with: + poetry-version: '1.4.2' + + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: '^1.13.1' + + - name: Install cue lang + run: go install cuelang.org/go/cmd/cue@latest + + - name: Check if cue is installed + run: cue version + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + + - uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: yarn install --nonInteractive --frozen-lockfile --prefer-offline + + - name: Build + run: yarn build - name: Test run: yarn test:core @@ -224,3 +268,7 @@ jobs: - name: Test cli:e2e:p2 run: yarn test:e2e:p2 working-directory: ./packages/cli + + - name: Test CLI JS + run: yarn test + working-directory: ./packages/js/cli diff --git a/CHANGELOG.md b/CHANGELOG.md index fcedd09037..5b2283063e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,37 @@ +# Polywrap Origin (0.11.0) +## Features +**`polywrap` CLI:** +* [PR-1074](https://github.com/polywrap/cli/pull/1074) **Golang-based Wraps Now Supported!** + * Polywrap projects of `type: wasm/golang` are now supported. + * To get started, simply run `polywrap create wasm golang my-wrap` +* [PR-1829](https://github.com/polywrap/cli/pull/1829) **Support User-Defined Bindgen URIs** + * The `build` and `codegen` commands now have the option `--bindgen `, which allows for the use of a custom bindgen wrap. +* [PR-1774](https://github.com/polywrap/cli/pull/1774) **`polywrap deploy` Defaults To IPFS on wrapscan.io** + * When you run the `polywrap deploy` command, you no longer need a `polywrap.deploy.yaml` manifest file. By default it will deploy your wrap to IPFS on https://wrapscan.io. + +**`@polywrap/schema-bind`:** +* [PR-1795](https://github.com/polywrap/cli/pull/1795) **Add `wrap-abi-bindgen` Support** + * All wrap bindings are now emitted using the wraps defined within the [wrap-abi-bindgen](https://github.com/polywrap/wrap-abi-bindgen) project. + * This enables binding updates to be released, without us needing to create a new release of the CLI. +* [PR-1840](https://github.com/polywrap/cli/pull/1840) **Support Swift Plugin Bindings** + * Add support for `plugin/swift` bindings, used when building plugins in Swift. + +## Breaking Changes +**`polywrap` CLI:** +* [PR-1809](https://github.com/polywrap/cli/pull/1809) **`docgen` Command Removed** + * The `docgen` command has been largely unused so it has been removed. +* [PR-1839](https://github.com/polywrap/cli/pull/1839) **Remove ENS Deploy Modules** + * All ENS deploy modules have been removed. If you'd like to publish your wrap's IPFS hash to ENS, simply use the [ENS web app](https://ens.domains/). + +## Bugs +**`polywrap` CLI:** +* [PR-1823](https://github.com/polywrap/cli/pull/1823) **Support Fuzzy URI Strings in Manifests** + * URIs within manifest files are no longer as strict, and can be any string. +* [PR-1808](https://github.com/polywrap/cli/pull/1808) **IPFS Deploy W/ Node v18** + * The IPFS deployer module has been updated so that it runs on all node versions, including version 18. +* [PR-1804](https://github.com/polywrap/cli/pull/1804) **Emit Resources & Docs For Interface Wraps** + * When building an wrap of type `interface`, resources and doc artifacts were not being properly emitted to the build folder. + # Polywrap Origin (0.10.6) ## Bugs **`polywrap` CLI:** diff --git a/VERSION b/VERSION index 69da6ebcd0..d9df1bbc0c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.10.6 +0.11.0 diff --git a/WRAP_TEST_HARNESS b/WRAP_TEST_HARNESS index 8b25206ff9..650c38f2e9 100644 --- a/WRAP_TEST_HARNESS +++ b/WRAP_TEST_HARNESS @@ -1 +1 @@ -master \ No newline at end of file +chore/latest-rust-wrap-bindings \ No newline at end of file diff --git a/package.json b/package.json index 41edc88e78..cba5f7b4a3 100644 --- a/package.json +++ b/package.json @@ -31,11 +31,14 @@ "lint:fix": "lerna run lint -- --fix", "lint:ci": "yarn lint", "test": "lerna run test --no-private --concurrency 1", - "test:core": "lerna run test --no-private --ignore polywrap* --concurrency 1", - "test:cli": "yarn test:cli:unit && yarn test:cli:e2e", - "test:cli:unit": "lerna run test:unit --no-private --scope polywrap --concurrency 1", - "test:cli:e2e:p1": "lerna run test:e2e:p1 --no-private --scope polywrap --concurrency 1", - "test:cli:e2e:p2": "lerna run test:e2e:p2 --no-private --scope polywrap --concurrency 1", + "test:core": "lerna run test --no-private --ignore polywrap* --ignore @polywrap/cli-js --ignore @polywrap/templates --concurrency 1", + "test:cli": "yarn test:cli:unit && yarn test:cli:e2e && yarn test:cli:js", + "test:cli:unit": "lerna run test:unit --scope polywrap --concurrency 1", + "test:cli:e2e": "yarn test:cli:e2e:p1 && yarn test:cli:e2e:p2", + "test:cli:e2e:p1": "lerna run test:e2e:p1 --scope polywrap --concurrency 1", + "test:cli:e2e:p2": "lerna run test:e2e:p2 --scope polywrap --concurrency 1", + "test:cli:js": "lerna run test --scope @polywrap/cli-js --concurrency 1", + "test:templates": "lerna run test --no-private --scope @polywrap/templates --concurrency 1", "version:apply": "lerna version $(cat VERSION) --exact --no-git-tag-version --yes", "postversion:apply": "git add . && git commit -m \"build(release): migrate to `cat ./VERSION`\"", "publish:npm": "lerna exec --no-private --concurrency 1 -- yarn publish --access public --non-interactive --verbose", @@ -58,6 +61,7 @@ }, "resolutions": { "@types/react": "16.9.0", - "@types/react-dom": "16.9.0" + "@types/react-dom": "16.9.0", + "@types/node": "18.15.0" } } diff --git a/packages/cli/jest.config.js b/packages/cli/jest.config.js index aef0111dbf..57c9519473 100644 --- a/packages/cli/jest.config.js +++ b/packages/cli/jest.config.js @@ -11,7 +11,8 @@ module.exports = { modulePathIgnorePatterns: [ "/build", "/src/__tests__/project/.polywrap", - "/src/__tests__/e2e/build-rs.spec.ts" + "/src/__tests__/e2e/build-rs.spec.ts", + "/src/__tests__/e2e/build-go.spec.ts" ], testPathIgnorePatterns: [ "/src/__tests__/project/.polywrap" diff --git a/packages/cli/jest.go.config.js b/packages/cli/jest.go.config.js new file mode 100644 index 0000000000..7465b45559 --- /dev/null +++ b/packages/cli/jest.go.config.js @@ -0,0 +1,22 @@ +module.exports = { + collectCoverage: true, + preset: "ts-jest", + testEnvironment: "node", + globals: { + "ts-jest": { + diagnostics: false + }, + }, + modulePathIgnorePatterns: [ + "/build", + "/src/__tests__/project/.polywrap" + ], + testPathIgnorePatterns: [ + "/src/__tests__/project/.polywrap" + ], + transformIgnorePatterns: [ + "/src/__tests__/project/.polywrap" + ], + setupFilesAfterEnv: ["./jest.setup.js"], + testMatch: ["**/build-go.spec.ts"] +}; diff --git a/packages/cli/lang/en.json b/packages/cli/lang/en.json index d5abbed875..0e32cb952e 100644 --- a/packages/cli/lang/en.json +++ b/packages/cli/lang/en.json @@ -9,6 +9,7 @@ "commands_build_description": "Build Polywrap Projects (type: interface, wasm)", "commands_build_error_manifestPathMissing": "{option} option missing {argument} argument", "commands_build_error_manifestNotFound": "Manifest not found. Search paths used: {paths}", + "commands_build_error_goModNotFound": "go.mod file not found. Search paths used: {paths}", "commands_build_error_outputDirMissingPath": "{option} option missing {argument} argument", "commands_build_error_unsupportedProjectType": "Unsupported project type. You can only build the following project types: {supportedTypes}", "commands_build_keypressListener_exit": "Exit: [CTRL + C], [ESC], or [Q]", @@ -91,19 +92,11 @@ "commands_codegen_options_m": "Path to the Polywrap manifest file (default: {default})", "commands_codegen_options_o": "Output directory for custom generated types (default: 'types/')", "commands_codegen_options_o_path": "path", + "commands_codegen_options_b": "Uri for custom bindgen wrap (must implement wrap-abi-bindgen interface; see https://github.com/polywrap/wrap-abi-bindgen)", "commands_codegen_success": "Types were generated successfully", + "commands_codegen_invalid_uri": "Invalid WRAP URI format: {uri}.", "commands_codegen_project_load_error": "Failed to load project, please make sure {manifestPath} is a valid Project manifest", "commands_codegen_options_publish": "Output path for the built schema and manifest (default: {default})", - "commands_docgen_description": "Generate wrapper documentation", - "commands_docgen_success": "Docs were generated successfully", - "commands_docgen_default": "default", - "commands_docgen_options_c": "Output directory for generated docs (default: {default})", - "commands_docgen_options_m": "Path to the project manifest file (default: {default})", - "commands_docgen_options_schema": "Generate GraphQL schema", - "commands_docgen_options_markdown": "Generate {framework} markdown", - "commands_docgen_options_i": "Also generate docs for dependencies", - "commands_docgen_error_manifestNotFound": "Manifest not found. Search paths used: {paths}", - "commands_docgen_error_projectLoadFailed": "Could not load project form the given manifest. Manifest: `{manifestFile}`", "commands_create_description": "Create New Projects", "commands_create_directoryExists": "Directory with name {dir} already exists", "commands_create_error_commandFail": "Command failed: {error}", @@ -176,7 +169,6 @@ "commands_test_error_unsupportedOutputFileExt": "Unsupported outputFile extention: {outputFileExt}", "commands_test_error_cueDoesNotExist": "Require cue to run validator, checkout https://cuelang.org/ for more information", "commands_test_error_noWorkflowScriptFound": "Workflow script not found at path: {path}", - "commands_test_error_noTestEnvFound": "polywrap test-env not found, please run 'polywrap infra up --modules=eth-ens-ipfs'", "commands_polywrap_error_notACommand": "is not a command", "commands_polywrap_helpPrompt": "Type {command} to view common commands", "commands_manifest_description": "Inspect & Migrade Polywrap Manifests", @@ -243,6 +235,8 @@ "lib_helpers_deployManifestExt_loadError": "Failed to load deploy manifest extension from {path}", "lib_helpers_deployManifestExt_loadText": "Load manifest extension from {path}", "lib_helpers_deployManifestExt_loadWarning": "No manifest extension found in {path}", + "lib_helpers_gomod_unableToLoad": "Unable to load go.mod: {path}", + "lib_helpers_gomod_invalid": "Invalid format of go.mod: {path}", "lib_helpers_manifest_outputError": "Failed to output manifest to {path}", "lib_helpers_manifest_outputText": "Manifest written to {path}", "lib_helpers_manifest_outputWarning": "Warnings writing manifest to {path}", @@ -282,6 +276,7 @@ "lib_typescript_tsNodeNotInstalled": "Your project uses typescript, but ts-node is not installed", "lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}", "lib_wasm_rust_invalidModule": "Module paths must point to Cargo.toml files. Found: {path}", + "lib_wasm_golang_invalidModule": "Module paths must point to go.mod file. Found: {path}", "lib_docker_invalidImageId": "Invalid docker image ID returned: {imageId}", "lib_docker_noInstall": "Docker executable not found in PATH", "lib_infra_unrecognizedModule": "Unrecognized modules: {modules}. Default modules: {defaultModules}", diff --git a/packages/cli/lang/es.json b/packages/cli/lang/es.json index d5abbed875..0e32cb952e 100644 --- a/packages/cli/lang/es.json +++ b/packages/cli/lang/es.json @@ -9,6 +9,7 @@ "commands_build_description": "Build Polywrap Projects (type: interface, wasm)", "commands_build_error_manifestPathMissing": "{option} option missing {argument} argument", "commands_build_error_manifestNotFound": "Manifest not found. Search paths used: {paths}", + "commands_build_error_goModNotFound": "go.mod file not found. Search paths used: {paths}", "commands_build_error_outputDirMissingPath": "{option} option missing {argument} argument", "commands_build_error_unsupportedProjectType": "Unsupported project type. You can only build the following project types: {supportedTypes}", "commands_build_keypressListener_exit": "Exit: [CTRL + C], [ESC], or [Q]", @@ -91,19 +92,11 @@ "commands_codegen_options_m": "Path to the Polywrap manifest file (default: {default})", "commands_codegen_options_o": "Output directory for custom generated types (default: 'types/')", "commands_codegen_options_o_path": "path", + "commands_codegen_options_b": "Uri for custom bindgen wrap (must implement wrap-abi-bindgen interface; see https://github.com/polywrap/wrap-abi-bindgen)", "commands_codegen_success": "Types were generated successfully", + "commands_codegen_invalid_uri": "Invalid WRAP URI format: {uri}.", "commands_codegen_project_load_error": "Failed to load project, please make sure {manifestPath} is a valid Project manifest", "commands_codegen_options_publish": "Output path for the built schema and manifest (default: {default})", - "commands_docgen_description": "Generate wrapper documentation", - "commands_docgen_success": "Docs were generated successfully", - "commands_docgen_default": "default", - "commands_docgen_options_c": "Output directory for generated docs (default: {default})", - "commands_docgen_options_m": "Path to the project manifest file (default: {default})", - "commands_docgen_options_schema": "Generate GraphQL schema", - "commands_docgen_options_markdown": "Generate {framework} markdown", - "commands_docgen_options_i": "Also generate docs for dependencies", - "commands_docgen_error_manifestNotFound": "Manifest not found. Search paths used: {paths}", - "commands_docgen_error_projectLoadFailed": "Could not load project form the given manifest. Manifest: `{manifestFile}`", "commands_create_description": "Create New Projects", "commands_create_directoryExists": "Directory with name {dir} already exists", "commands_create_error_commandFail": "Command failed: {error}", @@ -176,7 +169,6 @@ "commands_test_error_unsupportedOutputFileExt": "Unsupported outputFile extention: {outputFileExt}", "commands_test_error_cueDoesNotExist": "Require cue to run validator, checkout https://cuelang.org/ for more information", "commands_test_error_noWorkflowScriptFound": "Workflow script not found at path: {path}", - "commands_test_error_noTestEnvFound": "polywrap test-env not found, please run 'polywrap infra up --modules=eth-ens-ipfs'", "commands_polywrap_error_notACommand": "is not a command", "commands_polywrap_helpPrompt": "Type {command} to view common commands", "commands_manifest_description": "Inspect & Migrade Polywrap Manifests", @@ -243,6 +235,8 @@ "lib_helpers_deployManifestExt_loadError": "Failed to load deploy manifest extension from {path}", "lib_helpers_deployManifestExt_loadText": "Load manifest extension from {path}", "lib_helpers_deployManifestExt_loadWarning": "No manifest extension found in {path}", + "lib_helpers_gomod_unableToLoad": "Unable to load go.mod: {path}", + "lib_helpers_gomod_invalid": "Invalid format of go.mod: {path}", "lib_helpers_manifest_outputError": "Failed to output manifest to {path}", "lib_helpers_manifest_outputText": "Manifest written to {path}", "lib_helpers_manifest_outputWarning": "Warnings writing manifest to {path}", @@ -282,6 +276,7 @@ "lib_typescript_tsNodeNotInstalled": "Your project uses typescript, but ts-node is not installed", "lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}", "lib_wasm_rust_invalidModule": "Module paths must point to Cargo.toml files. Found: {path}", + "lib_wasm_golang_invalidModule": "Module paths must point to go.mod file. Found: {path}", "lib_docker_invalidImageId": "Invalid docker image ID returned: {imageId}", "lib_docker_noInstall": "Docker executable not found in PATH", "lib_infra_unrecognizedModule": "Unrecognized modules: {modules}. Default modules: {defaultModules}", diff --git a/packages/cli/package.json b/packages/cli/package.json index d20311d753..1015854d74 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,7 +1,7 @@ { "name": "polywrap", "description": "Polywrap CLI", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", @@ -19,14 +19,10 @@ "types": "build/types/index.d.ts", "scripts": { "build": "yarn build:intl && yarn build:fast", - "build:fast": "rimraf ./build && tsc --project tsconfig.build.json && yarn build:build-strategies && yarn build:deploy-modules && yarn build:infra-modules && yarn build:docgen-templates", + "build:fast": "rimraf ./build && tsc --project tsconfig.build.json && yarn build:build-strategies && yarn build:deploy-modules && yarn build:infra-modules", "build:build-strategies": "ts-node ./scripts/copyfiles ./src/lib/defaults/build-strategies ./build/lib/defaults/build-strategies", "build:deploy-modules": "copyfiles ./src/lib/defaults/deploy-modules/**/polywrap.deploy.ext.json ./build/lib/defaults/deploy-modules -u 4", "build:infra-modules": "ts-node ./scripts/copyfiles ./src/lib/defaults/infra-modules ./build/lib/defaults/infra-modules", - "build:docgen-templates": "yarn build:docgen-templates:docusaurus && yarn build:docgen-templates:jsdoc && yarn build:docgen-templates:schema", - "build:docgen-templates:docusaurus": "ts-node ./scripts/copyfiles ./src/lib/docgen/docusaurus/templates ./build/lib/docgen/docusaurus/templates", - "build:docgen-templates:jsdoc": "ts-node ./scripts/copyfiles ./src/lib/docgen/jsdoc/templates ./build/lib/docgen/jsdoc/templates", - "build:docgen-templates:schema": "ts-node ./scripts/copyfiles ./src/lib/docgen/schema/templates ./build/lib/docgen/schema/templates", "build:intl": "ts-node ./scripts/generateIntlTypes.ts", "install:tracer": "ts-node ./scripts/installTracerInfraModule.ts", "lint": "eslint --color -c ../../.eslintrc.js .", @@ -36,6 +32,7 @@ "test:e2e:p1": "yarn test:cmd -- ./src/__tests__/e2e/p1/*.spec.ts", "test:e2e:p2": "yarn test:cmd -- ./src/__tests__/e2e/p2/*.spec.ts", "test:rust": "yarn test:cmd -- --config ./jest.rs.config.js", + "test:golang": "yarn test:cmd -- --config ./jest.go.config.js", "test:watch": "yarn test -- --watch" }, "resolutions": { @@ -46,22 +43,24 @@ "@ethersproject/providers": "5.6.8", "@ethersproject/wallet": "5.6.2", "@formatjs/intl": "1.8.2", - "@polywrap/asyncify-js": "0.10.0", - "@polywrap/client-config-builder-js": "0.10.0", - "@polywrap/client-js": "0.10.0", - "@polywrap/core-js": "0.10.0", - "@polywrap/ethereum-provider-js-v1": "npm:@polywrap/ethereum-provider-js@~0.2.4", - "@polywrap/logging-js": "0.10.6", - "@polywrap/os-js": "0.10.6", - "@polywrap/polywrap-manifest-types-js": "0.10.6", - "@polywrap/result": "0.10.0", - "@polywrap/schema-bind": "0.10.6", - "@polywrap/schema-compose": "0.10.6", - "@polywrap/schema-parse": "0.10.6", - "@polywrap/uri-resolver-extensions-js": "0.10.0", - "@polywrap/uri-resolvers-js": "0.10.0", - "@polywrap/wasm-js": "0.10.0", - "@polywrap/wrap-manifest-types-js": "0.10.0", + "@polywrap/asyncify-js": "0.12.0", + "@polywrap/client-config-builder-js": "0.12.0", + "@polywrap/client-js": "0.12.0", + "@polywrap/core-js": "0.12.0", + "@polywrap/ethereum-wallet-js": "~0.1.0", + "@polywrap/logging-js": "0.11.0-pre.4", + "@polywrap/os-js": "0.11.0-pre.4", + "@polywrap/polywrap-manifest-types-js": "0.11.0-pre.4", + "@polywrap/result": "0.12.0", + "@polywrap/schema-bind": "0.11.0-pre.4", + "@polywrap/schema-compose": "0.11.0-pre.4", + "@polywrap/schema-parse": "0.11.0-pre.4", + "@polywrap/sys-config-bundle-js": "0.12.0", + "@polywrap/uri-resolver-extensions-js": "0.12.0", + "@polywrap/uri-resolvers-js": "0.12.0", + "@polywrap/wasm-js": "0.12.0", + "@polywrap/web3-config-bundle-js": "0.12.0", + "@polywrap/wrap-manifest-types-js": "0.12.0", "axios": "0.21.2", "chalk": "4.1.0", "chokidar": "3.5.1", @@ -72,7 +71,6 @@ "extract-zip": "2.0.1", "form-data": "4.0.0", "fs-extra": "9.0.1", - "ipfs-http-client": "48.1.3", "json-schema": "0.4.0", "jsonschema": "1.4.0", "mustache": "4.0.1", @@ -85,12 +83,12 @@ "yesno": "0.4.0" }, "devDependencies": { - "@polywrap/cli-js": "0.10.6", + "@polywrap/cli-js": "0.11.0-pre.4", "@types/copyfiles": "2.4.0", "@types/fs-extra": "9.0.12", "@types/jest": "26.0.8", "@types/mustache": "4.0.1", - "@types/node": "^18.14.6", + "@types/node": "18.15.0", "@types/prettier": "2.6.0", "@types/rimraf": "3.0.0", "dir-compare": "3.3.0", diff --git a/packages/cli/src/__tests__/e2e/build-go.spec.ts b/packages/cli/src/__tests__/e2e/build-go.spec.ts new file mode 100644 index 0000000000..8c9606fe0f --- /dev/null +++ b/packages/cli/src/__tests__/e2e/build-go.spec.ts @@ -0,0 +1,72 @@ +import { polywrapCli } from "./utils"; +import { Commands } from "@polywrap/cli-js"; +import { GetPathToCliTestFiles } from "@polywrap/test-cases"; +import fs from "fs"; +import path from "path"; + +jest.setTimeout(1500000); + +describe("e2e tests for build command", () => { + const testCaseRoot = path.join(GetPathToCliTestFiles(), "build-cmd/wasm/golang"); + const testCases = fs + .readdirSync(testCaseRoot, { withFileTypes: true }) + .filter((dirent) => dirent.isDirectory()) + .map((dirent) => dirent.name); + + const getTestCaseDir = (index: number) => + path.join(testCaseRoot, testCases[index]); + + describe("Image strategy", () => { + it("Builds for go", async () => { + const { exitCode: code, stdout: output } = await Commands.build({ + strategy: "image", + verbose: true + }, { + cwd: getTestCaseDir(0), + cli: polywrapCli, + }); + const buildDir = `./build`; + + expect(code).toEqual(0); + expect(output).toContain(`Artifacts written to ${buildDir}`); + expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); + }); + }) + + // NOTE: Skipped because CI needs system prequisites: golang + describe.skip("Local strategy", () => { + it("Builds for rust", async () => { + const { exitCode: code, stdout: output } = await Commands.build({ + strategy: "local", + verbose: true + }, { + cwd: getTestCaseDir(0), + cli: polywrapCli, + }); + + const buildDir = `./build`; + + expect(code).toEqual(0); + expect(output).toContain(`Artifacts written to ${buildDir}`); + expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); + }); + }) + + describe("VM strategy", () => { + it("Builds for go", async () => { + const { exitCode: code, stdout: output } = await Commands.build({ + strategy: "vm", + verbose: true + }, { + cwd: getTestCaseDir(0), + cli: polywrapCli, + }); + + const buildDir = `./build`; + + expect(code).toEqual(0); + expect(output).toContain(`Artifacts written to ${buildDir}`); + expect(output).toContain(`WRAP manifest written in ${buildDir}/wrap.info`); + }); + }) +}); diff --git a/packages/cli/src/__tests__/e2e/helpers/testCliOutput.ts b/packages/cli/src/__tests__/e2e/helpers/testCliOutput.ts index 72b72310ed..2d11958f18 100644 --- a/packages/cli/src/__tests__/e2e/helpers/testCliOutput.ts +++ b/packages/cli/src/__tests__/e2e/helpers/testCliOutput.ts @@ -19,6 +19,10 @@ export const testCliOutput = ( ) ); + if (expected.exitCode !== expected.exitCode) { + console.error(error) + } + if (expected.stdout) { if (Array.isArray(expected.stdout)) { for (const line of expected.stdout) { diff --git a/packages/cli/src/__tests__/e2e/p1/create.spec.ts b/packages/cli/src/__tests__/e2e/p1/create.spec.ts index 5287d3442f..574b6c0d26 100644 --- a/packages/cli/src/__tests__/e2e/p1/create.spec.ts +++ b/packages/cli/src/__tests__/e2e/p1/create.spec.ts @@ -4,8 +4,7 @@ import { UrlFormat } from "../../../lib"; import { runCli } from "@polywrap/cli-js"; import rimraf from "rimraf"; -import path from "path"; -import fs from "fs"; +import pjson from "../../../../package.json"; const HELP = `Usage: polywrap create|c [options] [command] @@ -16,7 +15,7 @@ Options: Commands: wasm [options] Create a Polywrap wasm wrapper. langs: - assemblyscript, rust, interface + assemblyscript, rust, golang, interface app [options] Create a Polywrap application. langs: typescript plugin [options] Create a Polywrap plugin. langs: @@ -26,13 +25,7 @@ Commands: help [command] display help for command `; -const VERSION = - fs.readFileSync( - path.join(__dirname, "../../../../../../VERSION"), - "utf-8" - ) - .replace(/\n/g, "") - .replace(/\r/g, ""); +const VERSION = pjson.version; const urlExamples = (format: UrlFormat): string => { if (format === UrlFormat.git) { diff --git a/packages/cli/src/__tests__/e2e/p1/deploy.spec.ts b/packages/cli/src/__tests__/e2e/p1/deploy.spec.ts index cbce429c9b..98d69ba1c6 100644 --- a/packages/cli/src/__tests__/e2e/p1/deploy.spec.ts +++ b/packages/cli/src/__tests__/e2e/p1/deploy.spec.ts @@ -44,10 +44,6 @@ const setup = async () => { process.env = { ...process.env, IPFS_GATEWAY_URI: ETH_ENS_IPFS_MODULE_CONSTANTS.ipfsProvider, - DOMAIN_NAME: "test1.eth", - ENS_REG_ADDR: ETH_ENS_IPFS_MODULE_CONSTANTS.ensAddresses.ensAddress, - ENS_REGISTRAR_ADDR: ETH_ENS_IPFS_MODULE_CONSTANTS.ensAddresses.registrarAddress, - ENS_RESOLVER_ADDR: ETH_ENS_IPFS_MODULE_CONSTANTS.ensAddresses.resolverAddress, }; } @@ -78,33 +74,20 @@ describe("e2e tests for deploy command", () => { }); it("Should deploy the project successfully", async () => { - const { exitCode: code, stdout: output } = await Commands.deploy({}, { + const { exitCode: code, stdout: output, stderr: error } = await Commands.deploy({}, { cwd: getTestCaseDir(0), cli: polywrapCli, env: process.env as Record }); const sanitizedOutput = clearStyle(output); + const sanitizedError = clearStyle(error); expect(code).toEqual(0); + expect(sanitizedError).toBeFalsy(); expect(sanitizedOutput).toContain( "Successfully executed step 'ipfs_deploy'" ); - expect(sanitizedOutput).toContain( - "Successfully executed step 'from_deploy'" - ); - expect(sanitizedOutput).toContain( - "Successfully executed step 'from_deploy2'" - ); - expect(sanitizedOutput).toContain( - "Successfully executed 'fs_to_ens' deployment job" - ); - expect(sanitizedOutput).toContain( - "Successfully executed step 'from_uri'" - ); - expect(sanitizedOutput).toContain( - "Successfully executed 'ipfs_to_ens' deployment job" - ); }); it("Should output the deployment uri to URI.txt", async () => { @@ -128,7 +111,7 @@ describe("e2e tests for deploy command", () => { const sanitizedOutput = clearStyle(output); expect(sanitizedOutput).toContain( - `The URI result from job fs_to_ens has been written to ${deploymentFilePath}. ` + + `The URI result from job fs_to_ipfs has been written to ${deploymentFilePath}. ` + "It is recommended to store this file at the root of your wrap package and commit it to your repository.", ); }); @@ -204,57 +187,16 @@ describe("e2e tests for deploy command", () => { expect(yamlOutputFileContents).toMatchObject(jsonOutputFileContents); expect(jsonOutputFileContents).toMatchObject([ { - "name": "fs_to_ens", + "name": "fs_to_ipfs", "steps": [ - { - "name": "ens_register", - "id": "fs_to_ens.ens_register", - "input": "wrap://ens/test1.eth", - "result": "wrap://ens/testnet/test1.eth", - }, - { - "name": "ens_register2", - "id": "fs_to_ens.ens_register2", - "input": "wrap://ens/test2.eth", - "result": "wrap://ens/testnet/test2.eth", - }, { "name": "ipfs_deploy", - "id": "fs_to_ens.ipfs_deploy", + "id": "fs_to_ipfs.ipfs_deploy", "input": "wrap://fs/../wrapper", "result": "wrap://ipfs/QmcZJ1NudpTdF96NEJZiKnDDXhydqanTusw7DXGj7PfbxH", }, - { - "name": "from_deploy", - "id": "fs_to_ens.from_deploy", - "input": "wrap://ipfs/QmcZJ1NudpTdF96NEJZiKnDDXhydqanTusw7DXGj7PfbxH", - "result": "wrap://ens/testnet/test1.eth", - }, - { - "name": "from_deploy2", - "id": "fs_to_ens.from_deploy2", - "input": "wrap://ipfs/QmcZJ1NudpTdF96NEJZiKnDDXhydqanTusw7DXGj7PfbxH", - "result": "wrap://ens/testnet/test2.eth", - } ] }, - { - "name": "ipfs_to_ens", - "steps": [ - { - "name": "ens_register", - "id": "ipfs_to_ens.ens_register", - "input": "wrap://ens/test3.eth", - "result": "wrap://ens/testnet/test3.eth", - }, - { - "name": "from_uri", - "id": "ipfs_to_ens.from_uri", - "input": "wrap://ipfs/QmVdDR6QtigTt38Xwpj2Ki73X1AyZn5WRCreBCJq1CEtpF", - "result": "wrap://ens/testnet/test3.eth", - } - ] - } ]) }); @@ -283,7 +225,7 @@ describe("e2e tests for deploy command", () => { const sanitizedErr = clearStyle(stderr); expect(code).toEqual(1); - expect(sanitizedErr).toContain("domainName is not of a type(s) string") + expect(sanitizedErr).toContain("gatewayUri is not of a type(s) string") }); it("Should throw and stop chain if error is found", async () => { @@ -295,18 +237,17 @@ describe("e2e tests for deploy command", () => { const sanitizedOutput = clearStyle(output); const sanitizedErr = clearStyle(stderr); - - expect(code).toEqual(1); + expect(sanitizedOutput).toContain( - "Successfully executed step 'ipfs_deploy'" + "Successfully executed step 'ipfs_deploy_1'" ); expect(sanitizedOutput).not.toContain( - "Successfully executed step 'from_deploy2'" + "Successfully executed step 'from_deploy_3'" ); - - expect(sanitizedErr).toContain( - "Failed to execute step 'from_deploy'" + expect(sanitizedErr.replace("\n", "")).toContain( + "Failed to execute step 'ipfs_deploy_2'" ); + expect(code).toEqual(1); }); it("Should throw if environment variable is not loaded but defined in manifest", async () => { @@ -316,7 +257,7 @@ describe("e2e tests for deploy command", () => { env: process.env as Record }); const sanitizedErr = clearStyle(stderr); - expect(code).toEqual(1); expect(sanitizedErr).toContain("Environment variable not found: `NON_LOADED_VAR`"); + expect(code).toEqual(1); }); }); diff --git a/packages/cli/src/__tests__/e2e/p1/docgen.spec.ts b/packages/cli/src/__tests__/e2e/p1/docgen.spec.ts deleted file mode 100644 index 332a8bff82..0000000000 --- a/packages/cli/src/__tests__/e2e/p1/docgen.spec.ts +++ /dev/null @@ -1,228 +0,0 @@ -import { clearStyle, polywrapCli } from "../utils"; -import { DocgenCommandOptions } from "../../../commands"; - -import { Commands, runCli } from "@polywrap/cli-js"; -import { GetPathToCliTestFiles } from "@polywrap/test-cases"; -import path from "path"; -import fs from "fs"; -import os from "os"; -import rimraf from "rimraf"; -import { compareSync } from "dir-compare"; - -const HELP = `Usage: polywrap docgen|o [options] - -Generate wrapper documentation - -Arguments: - action - schema Generate GraphQL schema - docusaurus Generate Docusaurus markdown - jsdoc Generate JSDoc markdown - (choices: "schema", "docusaurus", "jsdoc") - -Options: - -m, --manifest-file Path to the project manifest file - (default: polywrap.yaml | polywrap.yml) - -g, --docgen-dir Output directory for generated docs - (default: ./docs) - -c, --client-config Add custom configuration to the - PolywrapClient - --wrapper-envs Path to a JSON file containing wrapper - envs - -i, --imports Also generate docs for dependencies - -v, --verbose Verbose output (default: false) - -q, --quiet Suppress output (default: false) - -l, --log-file [path] Log file to save console output to - -h, --help display help for command -`; - -describe("e2e tests for docgen command", () => { - const testCaseRoot = path.join(GetPathToCliTestFiles(), "docgen"); - const testCases = fs - .readdirSync(testCaseRoot, { withFileTypes: true }) - .filter((dirent) => dirent.isDirectory()) - .map((dirent) => dirent.name); - const getTestCaseDir = (index: number) => - path.join(testCaseRoot, testCases[index]); - - const testCliOutput = ( - testCaseDir: string, - exitCode: number, - stdout: string, - stder: string - ) => { - const output = clearStyle(stdout); - const error = clearStyle(stder); - - const expected = JSON.parse( - fs.readFileSync( - path.join(testCaseDir, "expected", "stdout.json"), - "utf-8" - ) - ); - - if (expected.stdout) { - if (Array.isArray(expected.stdout)) { - for (const line of expected.stdout) { - expect(output).toContain(line); - } - } else { - expect(output).toContain(expected.stdout); - } - } - - if (expected.stderr) { - if (Array.isArray(expected.stderr)) { - for (const line of expected.stderr) { - expect(error).toContain(line); - } - } else { - expect(error).toContain(expected.stderr); - } - } - - if (expected.exitCode) { - expect(exitCode).toEqual(expected.exitCode); - } - - if (expected.files) { - for (const file of expected.files) { - expect(fs.existsSync(path.join(testCaseDir, file))).toBeTruthy(); - } - } - }; - - const testDocgenOutput = (testCaseDir: string, docgenDir: string) => { - if (fs.existsSync(path.join(testCaseDir, "expected", "docs"))) { - const expectedTypesResult = compareSync( - docgenDir, - path.join(testCaseDir, "expected", "docs"), - { compareContent: true } - ); - expect(expectedTypesResult.differences).toBe(0); - } - }; - - test("Should show help text", async () => { - const { exitCode: code, stdout: output, stderr: error } = await runCli({ - args: ["docgen", "--help"], - config: { - cwd: getTestCaseDir(0), - cli: polywrapCli, - } - }); - - expect(error).toBe(""); - expect(code).toEqual(0); - expect(clearStyle(output)).toEqual(HELP); - }); - - it("Should throw error for unknown option --invalid", async () => { - const { exitCode: code, stdout: output, stderr: error } = await Commands.docgen("docusaurus",{ - args: ["--invalid"], - }, { - cwd: getTestCaseDir(0), - cli: polywrapCli, - }); - - - expect(code).toEqual(1); - expect(error).toBe("error: unknown option '--invalid'\n"); - expect(output).toEqual(``); - }); - - describe("missing option arguments", () => { - const missingOptionArgs = { - "--manifest-file": "-m, --manifest-file ", - "--docgen-dir": "-g, --docgen-dir ", - "--client-config": "-c, --client-config ", - }; - - for (const [option, errorMessage] of Object.entries(missingOptionArgs)) { - it(`Should throw error if params not specified for ${option} option`, async () => { - const { exitCode: code, stdout: output, stderr: error } = await Commands.docgen("docusaurus", { - args: [option], - }, { - cwd: getTestCaseDir(0), - cli: polywrapCli, - }); - - expect(code).toEqual(1); - expect(error).toBe( - `error: option '${errorMessage}' argument missing\n` - ); - expect(output).toEqual(``); - }); - } - }); - - it("Should store build files in specified docgen dir", async () => { - const docgenDir = fs.mkdtempSync( - path.join(os.tmpdir(), `polywrap-cli-tests`) - ); - const testCaseDir = getTestCaseDir(0); - const { exitCode: code, stdout: output, stderr: error } = await Commands.docgen("docusaurus", { - args: ["docgen", "docusaurus", "--docgen-dir", docgenDir], - }, { - cwd: testCaseDir, - cli: polywrapCli, - }); - - expect(error).toBe(""); - expect(code).toEqual(0); - expect(clearStyle(output)).toContain( - `🔥 Docs were generated successfully 🔥` - ); - }); - - it("Should successfully generate docs", async () => { - rimraf.sync(`${getTestCaseDir(0)}/docs`); - - const { exitCode: code, stdout: output, stderr: error } = await Commands.docgen("docusaurus", {}, { - cwd: getTestCaseDir(0), - cli: polywrapCli, - }); - - expect(code).toEqual(0); - expect(error).toBe(""); - expect(clearStyle(output)).toContain( - `🔥 Docs were generated successfully 🔥` - ); - - rimraf.sync(`${getTestCaseDir(0)}/docs`); - }); - - describe("test-cases", () => { - for (let i = 0; i < testCases.length; ++i) { - const testCaseName = testCases[i]; - const testCaseDir = getTestCaseDir(i); - - let docgenDir = path.join(testCaseDir, "docs"); - let args: Partial & { doc: string } = { doc: "docusaurus" }; - let cmdFile = path.join(testCaseDir, "cmd.json"); - if (fs.existsSync(cmdFile)) { - const cmdConfig = JSON.parse(fs.readFileSync(cmdFile, "utf-8")); - if (cmdConfig) { - args = cmdConfig; - } - - if(cmdConfig.docgenDir) { - docgenDir = path.join(testCaseDir, cmdConfig.docgenDir); - } - } - - const docType = args.doc as "docusaurus" | "jsdoc" | "schema"; - // @ts-ignore - delete args.doc; - test(testCaseName, async () => { - let { exitCode, stdout, stderr } = await Commands.docgen(docType, args, { - cwd: testCaseDir, - cli: polywrapCli, - }); - - testCliOutput(testCaseDir, exitCode, stdout, stderr); - testDocgenOutput(testCaseDir, docgenDir); - }); - } - }); -}); diff --git a/packages/cli/src/__tests__/e2e/p1/help.spec.ts b/packages/cli/src/__tests__/e2e/p1/help.spec.ts index 34e883a3a6..1dcfc61585 100644 --- a/packages/cli/src/__tests__/e2e/p1/help.spec.ts +++ b/packages/cli/src/__tests__/e2e/p1/help.spec.ts @@ -6,19 +6,18 @@ import { runCli } from "@polywrap/cli-js"; const HELP = `Usage: polywrap [options] [command] Options: - -h, --help display help for command + -h, --help display help for command Commands: - build|b [options] Build Polywrap Projects (type: interface, wasm) - codegen|g [options] Generate Code For Polywrap Projects - create|c Create New Projects - deploy|d [options] Deploys Polywrap Projects - docgen|o [options] Generate wrapper documentation - infra|i [options] Modular Infrastructure-As-Code Orchestrator - manifest|m Inspect & Migrade Polywrap Manifests - test|t [options] Execute Tests - docs Documentation commands - help [command] display help for command + build|b [options] Build Polywrap Projects (type: interface, wasm) + codegen|g [options] Generate Code For Polywrap Projects + create|c Create New Projects + deploy|d [options] Deploys Polywrap Projects + infra|i [options] Modular Infrastructure-As-Code Orchestrator + manifest|m Inspect & Migrade Polywrap Manifests + test|t [options] Execute Tests + docs Documentation commands + help [command] display help for command `; describe("e2e tests for no help", () => { diff --git a/packages/cli/src/__tests__/e2e/p1/no-command.spec.ts b/packages/cli/src/__tests__/e2e/p1/no-command.spec.ts index 785821b0b4..9a1c7919d3 100644 --- a/packages/cli/src/__tests__/e2e/p1/no-command.spec.ts +++ b/packages/cli/src/__tests__/e2e/p1/no-command.spec.ts @@ -6,19 +6,18 @@ import { runCli } from "@polywrap/cli-js"; const HELP = `Usage: polywrap [options] [command] Options: - -h, --help display help for command + -h, --help display help for command Commands: - build|b [options] Build Polywrap Projects (type: interface, wasm) - codegen|g [options] Generate Code For Polywrap Projects - create|c Create New Projects - deploy|d [options] Deploys Polywrap Projects - docgen|o [options] Generate wrapper documentation - infra|i [options] Modular Infrastructure-As-Code Orchestrator - manifest|m Inspect & Migrade Polywrap Manifests - test|t [options] Execute Tests - docs Documentation commands - help [command] display help for command + build|b [options] Build Polywrap Projects (type: interface, wasm) + codegen|g [options] Generate Code For Polywrap Projects + create|c Create New Projects + deploy|d [options] Deploys Polywrap Projects + infra|i [options] Modular Infrastructure-As-Code Orchestrator + manifest|m Inspect & Migrade Polywrap Manifests + test|t [options] Execute Tests + docs Documentation commands + help [command] display help for command `; describe("e2e tests for no command", () => { diff --git a/packages/cli/src/__tests__/e2e/p2/build.wasm.spec.ts b/packages/cli/src/__tests__/e2e/p2/build.wasm.spec.ts index d794da5702..43d64f6526 100644 --- a/packages/cli/src/__tests__/e2e/p2/build.wasm.spec.ts +++ b/packages/cli/src/__tests__/e2e/p2/build.wasm.spec.ts @@ -17,6 +17,10 @@ Options: (default: polywrap.yaml | polywrap.yml) -o, --output-dir Output directory for build results (default: ./build) + -b, --bindgen Uri for custom bindgen wrap (must + implement wrap-abi-bindgen interface; + see + https://github.com/polywrap/wrap-abi-bindgen) -c, --client-config Add custom configuration to the PolywrapClient -n, --no-codegen Skip code generation before build diff --git a/packages/cli/src/__tests__/e2e/p2/codegen.spec.ts b/packages/cli/src/__tests__/e2e/p2/codegen.spec.ts index 060b9611d4..ba388daa40 100644 --- a/packages/cli/src/__tests__/e2e/p2/codegen.spec.ts +++ b/packages/cli/src/__tests__/e2e/p2/codegen.spec.ts @@ -16,6 +16,9 @@ Options: (default: polywrap.yaml | polywrap.yml) -g, --codegen-dir Output directory for the generated code (default: ./src/wrap) + -b, --bindgen Uri for custom bindgen wrap (must + implement wrap-abi-bindgen interface; see + https://github.com/polywrap/wrap-abi-bindgen) -s, --script Path to a custom generation script (JavaScript | TypeScript) -c, --client-config Add custom configuration to the @@ -188,4 +191,23 @@ describe("e2e tests for codegen command", () => { rimraf.sync(`${getTestCaseDir(1)}/types`); }); + + it("Should successfully generate types with custom bindgen wrap", async () => { + rimraf.sync(`${getTestCaseDir(0)}/types`); + + const { exitCode: code, stdout: output, stderr: error } = await Commands.codegen({ + bindgen: "https://github.com/polywrap/wrap-abi-bindgen/tree/wrap-0.1/implementations/wrap-rust" + }, { + cwd: getTestCaseDir(0), + cli: polywrapCli, + }); + + expect(code).toEqual(0); + expect(error).toBe(""); + expect(clearStyle(output)).toContain( + `🔥 Types were generated successfully 🔥` + ); + + rimraf.sync(`${getTestCaseDir(0)}/types`); + }); }); diff --git a/packages/cli/src/__tests__/unit/deploy-manifest.spec.ts b/packages/cli/src/__tests__/unit/deploy-manifest.spec.ts new file mode 100644 index 0000000000..483c3b8d1b --- /dev/null +++ b/packages/cli/src/__tests__/unit/deploy-manifest.spec.ts @@ -0,0 +1,11 @@ +import { defaultDeployManifest, loadDeployManifest, Logger } from "../../lib"; + +describe("default deploy manifest", () => { + const logger = new Logger({}); + + it("should load a default deploy manifest when none exists", async () => { + const manifest = await loadDeployManifest("polywrap.deploy.yaml", logger); + + expect(manifest).toEqual(defaultDeployManifest); + }); +}); diff --git a/packages/cli/src/__tests__/unit/jobrunner.spec.ts b/packages/cli/src/__tests__/unit/jobrunner.spec.ts index fb141f3ab1..3df5273abb 100644 --- a/packages/cli/src/__tests__/unit/jobrunner.spec.ts +++ b/packages/cli/src/__tests__/unit/jobrunner.spec.ts @@ -1,23 +1,26 @@ import path from "path"; import { GetPathToTestWrappers } from "@polywrap/test-cases"; -import { ClientConfigBuilder, IClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { + PolywrapClientConfigBuilder, + ClientConfigBuilder, +} from "@polywrap/client-config-builder-js"; import { testCases } from "./jobrunner-test-cases"; import { JobRunner } from "../../lib"; jest.setTimeout(200000); describe("workflow JobRunner", () => { - let configBuilder: IClientConfigBuilder; + let configBuilder: ClientConfigBuilder; beforeAll(async () => { - configBuilder = new ClientConfigBuilder(); + configBuilder = new PolywrapClientConfigBuilder(); const subinvokeUri = `fs/${path.join( GetPathToTestWrappers(), "subinvoke", "00-subinvoke", "implementations", "rs" - )}` + )}`; const invokeUri = `fs/${path.join( GetPathToTestWrappers(), @@ -25,9 +28,11 @@ describe("workflow JobRunner", () => { "01-invoke", "implementations", "rs" - )}` + )}`; - configBuilder.addRedirect("ens/imported-invoke.eth", invokeUri).addRedirect("ens/imported-subinvoke.eth", subinvokeUri); + configBuilder + .setRedirect("ens/imported-invoke.eth", invokeUri) + .setRedirect("ens/imported-subinvoke.eth", subinvokeUri); configBuilder.addDefaults(); }); diff --git a/packages/cli/src/__tests__/unit/option-parsers/option-parsers.spec.ts b/packages/cli/src/__tests__/unit/option-parsers/option-parsers.spec.ts index 6307f00310..eba9f4a74e 100644 --- a/packages/cli/src/__tests__/unit/option-parsers/option-parsers.spec.ts +++ b/packages/cli/src/__tests__/unit/option-parsers/option-parsers.spec.ts @@ -4,13 +4,13 @@ import { parseWrapperEnvsOption } from "../../../lib"; describe("unit tests for option-parsers", () => { describe("wrapper-envs", () => { const sampleFileEnvs = { - "wrap://ens/wraps.eth:ethereum@1.0.0": { - connection: { - networkNameOrChainId: "mainnet", - node: "https://mainnet.infura.io/v3/some_api_key", + "wrap://authority/wrap": { + prop: { + value: "bar", + value2: 2, }, }, - "wrap://ens/hello-world.polywrap.eth": { foo: "bar" }, + "wrap://authority/some-wrap": { foo: "bar" }, }; it("Should return undefined when undefined is provided for wrapperEnvsPath", async () => { diff --git a/packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.json b/packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.json index 9e7ae61386..63792dfc71 100644 --- a/packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.json +++ b/packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.json @@ -1,11 +1,9 @@ { - "ens/hello-world.polywrap.eth": { - "foo": "bar" - }, - "ens/wraps.eth:ethereum@1.0.0": { - "connection": { - "node": "https://mainnet.infura.io/v3/some_api_key", - "networkNameOrChainId": "mainnet" + "authority/some-wrap": { "foo": "bar" }, + "authority/wrap": { + "prop": { + "value": "bar", + "value2": 2 } } } diff --git a/packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.yaml b/packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.yaml index dcaa2a8649..2a6f6fa121 100644 --- a/packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.yaml +++ b/packages/cli/src/__tests__/unit/option-parsers/samples/wrapper-envs.yaml @@ -1,6 +1,6 @@ -ens/hello-world.polywrap.eth: +authority/some-wrap: foo: bar -ens/wraps.eth:ethereum@1.0.0: - connection: - node: https://mainnet.infura.io/v3/some_api_key - networkNameOrChainId: mainnet +authority/wrap: + prop: + value: bar + value2: 2 diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts index 4fd735e068..5b457c3766 100644 --- a/packages/cli/src/commands/build.ts +++ b/packages/cli/src/commands/build.ts @@ -5,7 +5,7 @@ import { PolywrapProject, SchemaComposer, intlMsg, - defaultPolywrapManifest, + defaultPolywrapManifestFiles, parseDirOption, parseClientConfigOption, parseManifestFileOption, @@ -15,6 +15,7 @@ import { polywrapManifestLanguages, pluginManifestLanguages, parseWrapperEnvsOption, + parseDirOptionNoDefault, } from "../lib"; import { CodeGenerator } from "../lib/codegen"; import { @@ -27,6 +28,7 @@ import { } from "../lib/build-strategies"; import { DEFAULT_CODEGEN_DIR } from "../lib/defaults"; import { watchProject } from "../lib/watchProject"; +import { parseUriOption } from "../lib/option-parsers/uri"; import { PolywrapClient } from "@polywrap/client-js"; import { PolywrapManifest } from "@polywrap/polywrap-manifest-types-js"; @@ -34,7 +36,7 @@ import { PolywrapManifest } from "@polywrap/polywrap-manifest-types-js"; const defaultOutputDir = "./build"; const defaultStrategy = SupportedStrategies.VM; const strategyStr = Object.values(SupportedStrategies).join(" | "); -const defaultManifestStr = defaultPolywrapManifest.join(" | "); +const defaultManifestStr = defaultPolywrapManifestFiles.join(" | "); const pathStr = intlMsg.commands_build_options_o_path(); const supportedProjectTypes = [ @@ -45,10 +47,11 @@ const supportedProjectTypes = [ export interface BuildCommandOptions extends BaseCommandOptions { manifestFile: string; outputDir: string; + bindgen: string | false; clientConfig: string | false; wrapperEnvs: string | false; noCodegen: boolean; - codegenDir: string; + codegenDir: string | false; watch: boolean; strategy: `${SupportedStrategies}`; } @@ -71,6 +74,7 @@ export const build: Command = { default: defaultOutputDir, })}` ) + .option(`-b, --bindgen `, `${intlMsg.commands_codegen_options_b()}`) .option( `-c, --client-config <${intlMsg.commands_common_options_configPath()}>`, `${intlMsg.commands_common_options_config()}` @@ -106,13 +110,14 @@ export const build: Command = { await run({ manifestFile: parseManifestFileOption( options.manifestFile, - defaultPolywrapManifest + defaultPolywrapManifestFiles ), clientConfig: options.clientConfig || false, wrapperEnvs: options.wrapperEnvs || false, outputDir: parseDirOption(options.outputDir, defaultOutputDir), + bindgen: options.bindgen || false, noCodegen: !options.codegen || false, - codegenDir: parseDirOption(options.codegenDir, DEFAULT_CODEGEN_DIR), + codegenDir: parseDirOptionNoDefault(options.codegenDir), strategy: options.strategy || defaultStrategy, watch: options.watch || false, verbose: options.verbose || false, @@ -166,6 +171,7 @@ async function run(options: Required) { clientConfig, wrapperEnvs, outputDir, + bindgen, strategy, noCodegen, codegenDir, @@ -175,7 +181,7 @@ async function run(options: Required) { } = options; const logger = createLogger({ verbose, quiet, logFile }); - + const bindgenUri = parseUriOption(bindgen); const envs = await parseWrapperEnvsOption(wrapperEnvs); const configBuilder = await parseClientConfigOption(clientConfig); @@ -241,7 +247,8 @@ async function run(options: Required) { const codeGenerator = new CodeGenerator({ project, schemaComposer, - codegenDirAbs: codegenDir, + codegenDirAbs: codegenDir || undefined, + bindgenUri, }); const codegenSuccess = await codeGenerator.generate(); diff --git a/packages/cli/src/commands/codegen.ts b/packages/cli/src/commands/codegen.ts index 81b59da2b6..e2d4e739f6 100644 --- a/packages/cli/src/commands/codegen.ts +++ b/packages/cli/src/commands/codegen.ts @@ -11,22 +11,24 @@ import { parseClientConfigOption, getProjectFromManifest, defaultProjectManifestFiles, - defaultPolywrapManifest, + defaultPolywrapManifestFiles, parseLogFileOption, parseWrapperEnvsOption, } from "../lib"; import { ScriptCodegenerator } from "../lib/codegen/ScriptCodeGenerator"; import { DEFAULT_CODEGEN_DIR } from "../lib/defaults"; import { watchProject } from "../lib/watchProject"; +import { parseUriOption } from "../lib/option-parsers/uri"; import { PolywrapClient } from "@polywrap/client-js"; const pathStr = intlMsg.commands_codegen_options_o_path(); -const defaultManifestStr = defaultPolywrapManifest.join(" | "); +const defaultManifestStr = defaultPolywrapManifestFiles.join(" | "); export interface CodegenCommandOptions extends BaseCommandOptions { manifestFile: string; codegenDir: string | false; + bindgen: string | false; script: string | false; clientConfig: string | false; wrapperEnvs: string | false; @@ -51,6 +53,7 @@ export const codegen: Command = { default: DEFAULT_CODEGEN_DIR, })}` ) + .option(`-b, --bindgen `, `${intlMsg.commands_codegen_options_b()}`) .option( `-s, --script <${pathStr}>`, `${intlMsg.commands_codegen_options_s()}` @@ -77,6 +80,7 @@ export const codegen: Command = { defaultProjectManifestFiles ), codegenDir: parseDirOptionNoDefault(options.codegenDir), + bindgen: options.bindgen || false, script: parseCodegenScriptOption(options.script), clientConfig: options.clientConfig || false, wrapperEnvs: options.wrapperEnvs || false, @@ -95,6 +99,7 @@ async function run(options: Required) { clientConfig, wrapperEnvs, codegenDir, + bindgen, script, verbose, quiet, @@ -102,7 +107,7 @@ async function run(options: Required) { watch, } = options; const logger = createLogger({ verbose, quiet, logFile }); - + const bindgenUri = parseUriOption(bindgen); const envs = await parseWrapperEnvsOption(wrapperEnvs); const configBuilder = await parseClientConfigOption(clientConfig); @@ -142,6 +147,7 @@ async function run(options: Required) { codegenDirAbs: codegenDir || undefined, schemaComposer, project, + bindgenUri, }); const execute = async (): Promise => { diff --git a/packages/cli/src/commands/create.ts b/packages/cli/src/commands/create.ts index 516652e439..f840396b4e 100644 --- a/packages/cli/src/commands/create.ts +++ b/packages/cli/src/commands/create.ts @@ -27,7 +27,7 @@ const pathStr = intlMsg.commands_create_options_o_path(); const urlStr = intlMsg.commands_create_options_t_url(); export const supportedLangs = { - wasm: ["assemblyscript", "rust", "interface"] as const, + wasm: ["assemblyscript", "rust", "golang", "interface"] as const, app: ["typescript"] as const, plugin: ["typescript", "rust", "python"] as const, }; diff --git a/packages/cli/src/commands/deploy.ts b/packages/cli/src/commands/deploy.ts index 82d27e7565..153a4f197b 100644 --- a/packages/cli/src/commands/deploy.ts +++ b/packages/cli/src/commands/deploy.ts @@ -6,7 +6,7 @@ import { parseManifestFileOption, parseLogFileOption, Deployer, - defaultDeployManifest, + defaultDeployManifestFiles, DeployJobResult, } from "../lib"; @@ -14,7 +14,7 @@ import fs from "fs"; import path from "path"; import yaml from "yaml"; -const defaultManifestStr = defaultDeployManifest.join(" | "); +const defaultManifestStr = defaultDeployManifestFiles.join(" | "); const pathStr = intlMsg.commands_deploy_options_o_path(); export interface DeployCommandOptions extends BaseCommandOptions { @@ -48,7 +48,7 @@ export const deploy: Command = { await run({ manifestFile: parseManifestFileOption( options.manifestFile, - defaultDeployManifest + defaultDeployManifestFiles ), outputFile: options.outputFile || false, verbose: options.verbose || false, diff --git a/packages/cli/src/commands/docgen.ts b/packages/cli/src/commands/docgen.ts deleted file mode 100644 index 347b9ba058..0000000000 --- a/packages/cli/src/commands/docgen.ts +++ /dev/null @@ -1,185 +0,0 @@ -/* eslint-disable prefer-const */ -import { - defaultPolywrapManifest, - SchemaComposer, - intlMsg, - parseClientConfigOption, - parseDirOption, - parseManifestFileOption, - defaultProjectManifestFiles, - getProjectFromManifest, - parseLogFileOption, - parseWrapperEnvsOption, -} from "../lib"; -import { Command, Program, BaseCommandOptions } from "./types"; -import { createLogger } from "./utils/createLogger"; -import { scriptPath as docusaurusScriptPath } from "../lib/docgen/docusaurus"; -import { scriptPath as jsdocScriptPath } from "../lib/docgen/jsdoc"; -import { scriptPath as schemaScriptPath } from "../lib/docgen/schema"; -import { ScriptCodegenerator } from "../lib/codegen/ScriptCodeGenerator"; - -import { PolywrapClient } from "@polywrap/client-js"; -import chalk from "chalk"; -import { Argument } from "commander"; - -const commandToPathMap: Record = { - schema: schemaScriptPath, - docusaurus: docusaurusScriptPath, - jsdoc: jsdocScriptPath, -}; - -const defaultDocgenDir = "./docs"; -const pathStr = intlMsg.commands_codegen_options_o_path(); - -export enum DocgenActions { - SCHEMA = "schema", - DOCUSAURUS = "docusaurus", - JSDOC = "jsdoc", -} - -export interface DocgenCommandOptions extends BaseCommandOptions { - manifestFile: string; - docgenDir: string; - clientConfig: string | false; - wrapperEnvs: string | false; - imports: boolean; -} - -const argumentsDescription = ` - ${chalk.bold( - DocgenActions.SCHEMA - )} ${intlMsg.commands_docgen_options_schema()} - ${chalk.bold( - DocgenActions.DOCUSAURUS - )} ${intlMsg.commands_docgen_options_markdown({ - framework: "Docusaurus", -})} - ${chalk.bold( - DocgenActions.JSDOC - )} ${intlMsg.commands_docgen_options_markdown({ - framework: "JSDoc", -})} -`; - -export const docgen: Command = { - setup: (program: Program) => { - program - .command("docgen") - .alias("o") - .description(intlMsg.commands_docgen_description()) - .usage(" [options]") - .addArgument( - new Argument("", argumentsDescription).choices([ - DocgenActions.SCHEMA, - DocgenActions.DOCUSAURUS, - DocgenActions.JSDOC, - ]) - ) - .option( - `-m, --manifest-file <${pathStr}>`, - intlMsg.commands_docgen_options_m({ - default: defaultPolywrapManifest.join(" | "), - }) - ) - .option( - `-g, --docgen-dir <${pathStr}>`, - intlMsg.commands_docgen_options_c({ - default: `${defaultDocgenDir}`, - }) - ) - .option( - `-c, --client-config <${intlMsg.commands_common_options_configPath()}>`, - `${intlMsg.commands_common_options_config()}` - ) - .option( - `--wrapper-envs <${intlMsg.commands_common_options_wrapperEnvsPath()}>`, - `${intlMsg.commands_common_options_wrapperEnvs()}` - ) - .option(`-i, --imports`, `${intlMsg.commands_docgen_options_i()}`) - .option("-v, --verbose", intlMsg.commands_common_options_verbose()) - .option("-q, --quiet", intlMsg.commands_common_options_quiet()) - .option( - `-l, --log-file [${pathStr}]`, - `${intlMsg.commands_build_options_l()}` - ) - .action(async (action, options: Partial) => { - await run(action, { - manifestFile: parseManifestFileOption( - options.manifestFile, - defaultProjectManifestFiles - ), - docgenDir: parseDirOption(options.docgenDir, defaultDocgenDir), - clientConfig: options.clientConfig || false, - wrapperEnvs: options.wrapperEnvs || false, - imports: options.imports || false, - verbose: options.verbose || false, - quiet: options.quiet || false, - logFile: parseLogFileOption(options.logFile), - }); - }); - }, -}; - -async function run( - action: DocgenActions, - options: Required -) { - const { - manifestFile, - clientConfig, - wrapperEnvs, - docgenDir, - imports, - verbose, - quiet, - logFile, - } = options; - const logger = createLogger({ verbose, quiet, logFile }); - - const envs = await parseWrapperEnvsOption(wrapperEnvs); - const configBuilder = await parseClientConfigOption(clientConfig); - - if (envs) { - configBuilder.addEnvs(envs); - } - - let project = await getProjectFromManifest(manifestFile, logger); - - if (!project) { - logger.error( - intlMsg.commands_docgen_error_projectLoadFailed({ - manifestFile: manifestFile, - }) - ); - - process.exit(1); - } - - await project.validate(); - - // Resolve custom script - const customScript = require.resolve(commandToPathMap[action]); - - const client = new PolywrapClient(configBuilder.build()); - - const schemaComposer = new SchemaComposer({ - project, - client, - }); - - const codeGenerator = new ScriptCodegenerator({ - project, - schemaComposer, - script: customScript, - codegenDirAbs: docgenDir, - omitHeader: true, - mustacheView: { imports }, - }); - - if (await codeGenerator.generate()) { - logger.info(`🔥 ${intlMsg.commands_docgen_success()} 🔥`); - process.exit(0); - } else { - process.exit(1); - } -} diff --git a/packages/cli/src/commands/docs.ts b/packages/cli/src/commands/docs.ts index bafa87c9df..7c1d9e54f9 100644 --- a/packages/cli/src/commands/docs.ts +++ b/packages/cli/src/commands/docs.ts @@ -1,6 +1,6 @@ import { defaultDocsManifest, - defaultPolywrapManifest, + defaultPolywrapManifestFiles, intlMsg, parseLogFileOption, parseManifestFileOption, @@ -12,7 +12,7 @@ import { createLogger } from "./utils/createLogger"; import fse from "fs-extra"; const pathStr = intlMsg.commands_docs_init_m_path(); -const defaultManifestStr = defaultPolywrapManifest.join(" | "); +const defaultManifestStr = defaultPolywrapManifestFiles.join(" | "); export interface DocsInitCommandOptions extends BaseCommandOptions { manifestFile: string; @@ -44,7 +44,7 @@ export const docs: Command = { await runDocsInitCommand({ manifestFile: parseManifestFileOption( options.manifestFile, - defaultPolywrapManifest + defaultPolywrapManifestFiles ), dir: options.dir || false, force: options.force || false, diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 03027c008c..10cb79abb9 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -2,7 +2,6 @@ export * from "./build"; export * from "./codegen"; export * from "./create"; export * from "./deploy"; -export * from "./docgen"; export * from "./infra"; export * from "./manifest"; export * from "./test"; @@ -18,7 +17,6 @@ import { SupportedWasmLangs, } from "./create"; import { DeployCommandOptions } from "./deploy"; -import { DocgenCommandOptions, DocgenActions } from "./docgen"; import { InfraCommandOptions, InfraActions } from "./infra"; import { ManifestSchemaCommandOptions, @@ -50,10 +48,6 @@ export interface CommandTypings { }; }; deploy: DeployCommandOptions; - docgen: { - options: DocgenCommandOptions; - arguments: [action: `${DocgenActions}`]; - }; infra: { options: InfraCommandOptions; arguments: [action: `${InfraActions}`]; diff --git a/packages/cli/src/commands/infra.ts b/packages/cli/src/commands/infra.ts index cce6352870..2bdba39f4a 100644 --- a/packages/cli/src/commands/infra.ts +++ b/packages/cli/src/commands/infra.ts @@ -2,7 +2,7 @@ import { intlMsg, Infra, loadInfraManifest, - defaultInfraManifest, + defaultInfraManifestFiles, resolvePathIfExists, parseLogFileOption, } from "../lib"; @@ -35,7 +35,7 @@ const DEFAULT_MODULES_PATH = path.join( "infra-modules" ); -const defaultManifestStr = defaultInfraManifest.join(" | "); +const defaultManifestStr = defaultInfraManifestFiles.join(" | "); const pathStr = intlMsg.commands_infra_options_m_path(); const moduleNameStr = intlMsg.commands_infra_options_o_module(); @@ -118,7 +118,7 @@ async function run( const manifest: string[] = manifestFile ? [manifestFile] - : defaultInfraManifest; + : defaultInfraManifestFiles; const manifestPath = resolvePathIfExists(manifest); let infraManifest: InfraManifest | undefined; diff --git a/packages/cli/src/commands/manifest.ts b/packages/cli/src/commands/manifest.ts index 724924fb87..19a476bd89 100644 --- a/packages/cli/src/commands/manifest.ts +++ b/packages/cli/src/commands/manifest.ts @@ -1,10 +1,10 @@ import { Argument, Command, Program, BaseCommandOptions } from "./types"; import { createLogger } from "./utils/createLogger"; import { - defaultBuildManifest, - defaultDeployManifest, - defaultInfraManifest, - defaultWorkflowManifest, + defaultBuildManifestFiles, + defaultDeployManifestFiles, + defaultInfraManifestFiles, + defaultWorkflowManifestFiles, getProjectManifestLanguage, intlMsg, isAppManifestLanguage, @@ -13,7 +13,7 @@ import { maybeGetManifestFormatVersion, parseManifestFileOption, CacheDirectory, - defaultPolywrapManifest, + defaultPolywrapManifestFiles, Logger, parseLogFileOption, defaultDocsManifest, @@ -68,7 +68,7 @@ import path from "path"; const pathStr = intlMsg.commands_manifest_options_m_path(); const formatStr = intlMsg.commands_manifest_options_m_format(); -const defaultProjectManifestStr = defaultPolywrapManifest.join(" | "); +const defaultProjectManifestStr = defaultPolywrapManifestFiles.join(" | "); const manifestTypes = [ "project", @@ -194,28 +194,28 @@ export const runSchemaCommand = async ( case "build": manifestFile = parseManifestFileOption( options.manifestFile, - defaultBuildManifest + defaultBuildManifestFiles ); break; case "deploy": manifestFile = parseManifestFileOption( options.manifestFile, - defaultDeployManifest + defaultDeployManifestFiles ); break; case "infra": manifestFile = parseManifestFileOption( options.manifestFile, - defaultInfraManifest + defaultInfraManifestFiles ); break; case "workflow": manifestFile = parseManifestFileOption( options.manifestFile, - defaultWorkflowManifest + defaultWorkflowManifestFiles ); break; case "docs": @@ -474,7 +474,10 @@ const runMigrateCommand = async ( logger ); migrateManifestFile( - parseManifestFileOption(options.manifestFile, defaultBuildManifest), + parseManifestFileOption( + options.manifestFile, + defaultBuildManifestFiles + ), migrateBuildExtensionManifest, options.format || latestBuildManifestFormat, logger @@ -488,7 +491,10 @@ const runMigrateCommand = async ( logger ); migrateManifestFile( - parseManifestFileOption(options.manifestFile, defaultDeployManifest), + parseManifestFileOption( + options.manifestFile, + defaultDeployManifestFiles + ), migrateDeployExtensionManifest, options.format || latestDeployManifestFormat, logger @@ -502,7 +508,10 @@ const runMigrateCommand = async ( logger ); migrateManifestFile( - parseManifestFileOption(options.manifestFile, defaultInfraManifest), + parseManifestFileOption( + options.manifestFile, + defaultInfraManifestFiles + ), migrateInfraExtensionManifest, options.format || latestInfraManifestFormat, logger @@ -516,7 +525,10 @@ const runMigrateCommand = async ( logger ); migrateManifestFile( - parseManifestFileOption(options.manifestFile, defaultWorkflowManifest), + parseManifestFileOption( + options.manifestFile, + defaultWorkflowManifestFiles + ), migrateWorkflow, options.format || latestPolywrapWorkflowFormat, logger diff --git a/packages/cli/src/commands/test.ts b/packages/cli/src/commands/test.ts index f20564a7e3..3c15168864 100644 --- a/packages/cli/src/commands/test.ts +++ b/packages/cli/src/commands/test.ts @@ -12,7 +12,7 @@ import { validateJobNames, validateOutput, WorkflowOutput, - defaultWorkflowManifest, + defaultWorkflowManifestFiles, parseManifestFileOption, parseLogFileOption, parseWrapperEnvsOption, @@ -33,7 +33,7 @@ export interface TestCommandOptions extends BaseCommandOptions { outputFile: string | false; } -const defaultManifestStr = defaultWorkflowManifest.join(" | "); +const defaultManifestStr = defaultWorkflowManifestFiles.join(" | "); const pathStr = intlMsg.commands_test_options_m_path(); export const test: Command = { @@ -74,7 +74,7 @@ export const test: Command = { await _run({ manifestFile: parseManifestFileOption( options.manifestFile, - defaultWorkflowManifest + defaultWorkflowManifestFiles ), clientConfig: options.clientConfig || false, wrapperEnvs: options.wrapperEnvs || false, diff --git a/packages/cli/src/lib/Compiler.ts b/packages/cli/src/lib/Compiler.ts index 6946f6ee3b..bc41d306f3 100644 --- a/packages/cli/src/lib/Compiler.ts +++ b/packages/cli/src/lib/Compiler.ts @@ -42,10 +42,15 @@ export class Compiler { // Output: wrap.info await this._outputWrapManifest(); - if (await this._isWasm()) { + const buildModules = await this._isWasm(); + const emitResourcesAndDocs = buildModules || (await this._isInterface()); + + if (buildModules) { // Build & Output: wasm.wrap await this._buildModules(); + } + if (emitResourcesAndDocs) { // Copy: Resources folder await this._copyResourcesFolder(); @@ -76,6 +81,12 @@ export class Compiler { return manifest.project.type.startsWith("wasm/"); } + private async _isInterface(): Promise { + const { project } = this._config; + const manifest = await project.getManifest(); + return manifest.project.type === "interface"; + } + private async _buildModules(): Promise { const { outputDir, project } = this._config; diff --git a/packages/cli/src/lib/build-strategies/BuildOverrides.ts b/packages/cli/src/lib/build-strategies/BuildOverrides.ts new file mode 100644 index 0000000000..8ba5de7c82 --- /dev/null +++ b/packages/cli/src/lib/build-strategies/BuildOverrides.ts @@ -0,0 +1,36 @@ +import { PolywrapManifestLanguage } from "../"; + +import { PolywrapManifest } from "@polywrap/polywrap-manifest-types-js"; +import path from "path"; +import fs from "fs"; + +export interface BuildOverrides { + validateManifest?: (manifest: PolywrapManifest) => Promise; + + sourcesSubDirectory?: string; +} + +export async function tryGetBuildOverrides( + language: PolywrapManifestLanguage +): Promise { + const modulePath = path.join( + __dirname, + "..", + "defaults", + "language-overrides", + language, + "index.js" + ); + let overrides: BuildOverrides | undefined; + + if (fs.existsSync(modulePath)) { + const module = await import(modulePath); + + // Get any build overrides for the given build-image + if (module.getBuildOverrides) { + overrides = module.getBuildOverrides() as BuildOverrides; + } + } + + return Promise.resolve(overrides); +} diff --git a/packages/cli/src/lib/build-strategies/BuildStrategy.ts b/packages/cli/src/lib/build-strategies/BuildStrategy.ts index 9b0086903c..3792cddc5c 100644 --- a/packages/cli/src/lib/build-strategies/BuildStrategy.ts +++ b/packages/cli/src/lib/build-strategies/BuildStrategy.ts @@ -1,9 +1,10 @@ +import { BuildOverrides, tryGetBuildOverrides } from "./BuildOverrides"; import { PolywrapProject } from "../project"; import fse from "fs-extra"; import path from "path"; -export interface BuildStrategyArgs { +export interface BuildStrategyConfig { project: PolywrapProject; outputDir: string; } @@ -11,8 +12,9 @@ export interface BuildStrategyArgs { export abstract class BuildStrategy { protected project: PolywrapProject; protected outputDir: string; + protected overrides?: BuildOverrides; - constructor({ project, outputDir }: BuildStrategyArgs) { + constructor({ project, outputDir }: BuildStrategyConfig) { this.project = project; this.outputDir = outputDir; } @@ -23,7 +25,7 @@ export abstract class BuildStrategy { async build(): Promise { const language = await this.project.getManifestLanguage(); - const defaultsOfStrategyUsed = path.join( + const buildStrategyDir = path.join( __dirname, "..", "defaults", @@ -31,17 +33,25 @@ export abstract class BuildStrategy { language, this.getStrategyName() ); + + // Cache all build strategy files const strategyUsedCacheDir = this.project.getCachePath( PolywrapProject.cacheLayout.buildStrategyUsed ); - if (fse.existsSync(strategyUsedCacheDir)) { fse.removeSync(strategyUsedCacheDir); } - fse.mkdirSync(strategyUsedCacheDir, { recursive: true }); + fse.copySync(buildStrategyDir, strategyUsedCacheDir); + + // Check if build overrides exist + this.overrides = await tryGetBuildOverrides(language); + + // If they do, ensure the manifest if valid before build starts + if (this.overrides && this.overrides.validateManifest) { + await this.overrides.validateManifest(await this.project.getManifest()); + } - fse.copySync(defaultsOfStrategyUsed, strategyUsedCacheDir); return this.buildSources(); } } diff --git a/packages/cli/src/lib/build-strategies/index.ts b/packages/cli/src/lib/build-strategies/index.ts index 6aa24c9e22..1daa4e6083 100644 --- a/packages/cli/src/lib/build-strategies/index.ts +++ b/packages/cli/src/lib/build-strategies/index.ts @@ -1,3 +1,4 @@ +export * from "./BuildOverrides"; export * from "./BuildStrategy"; export * from "./strategies"; diff --git a/packages/cli/src/lib/build-strategies/strategies/DockerImageStrategy.ts b/packages/cli/src/lib/build-strategies/strategies/DockerImageStrategy.ts index 0de8d4552a..d200659b5a 100644 --- a/packages/cli/src/lib/build-strategies/strategies/DockerImageStrategy.ts +++ b/packages/cli/src/lib/build-strategies/strategies/DockerImageStrategy.ts @@ -7,7 +7,7 @@ import { runCommand, runCommandSync, } from "../../system"; -import { BuildStrategyArgs, BuildStrategy } from "../BuildStrategy"; +import { BuildStrategyConfig, BuildStrategy } from "../BuildStrategy"; import { intlMsg } from "../../intl"; import { logActivity } from "../../logging"; @@ -21,8 +21,8 @@ type BuildImageId = string; export class DockerImageBuildStrategy extends BuildStrategy { private _dockerLock: FileLock; - constructor(args: BuildStrategyArgs) { - super(args); + constructor(config: BuildStrategyConfig) { + super(config); if (!isDockerInstalled(this.project.logger)) { throw new Error(intlMsg.lib_docker_noInstall()); diff --git a/packages/cli/src/lib/build-strategies/strategies/DockerVMStrategy.ts b/packages/cli/src/lib/build-strategies/strategies/DockerVMStrategy.ts index 35133ab8db..178d50ec23 100644 --- a/packages/cli/src/lib/build-strategies/strategies/DockerVMStrategy.ts +++ b/packages/cli/src/lib/build-strategies/strategies/DockerVMStrategy.ts @@ -4,7 +4,7 @@ import { isDockerInstalled, runCommand, } from "../../system"; -import { BuildStrategyArgs, BuildStrategy } from "../BuildStrategy"; +import { BuildStrategyConfig, BuildStrategy } from "../BuildStrategy"; import { intlMsg } from "../../intl"; import { BuildManifestConfig, @@ -43,6 +43,11 @@ const CONFIGS: Record = { baseImage: "polywrap/vm-base-as", version: "0.2.0", }, + "wasm/golang": { + defaultIncludes: ["go.mod", "go.sum"], + baseImage: "polywrap/vm-base-go", + version: "0.1.6", + }, }; export class DockerVMBuildStrategy extends BuildStrategy { @@ -50,8 +55,8 @@ export class DockerVMBuildStrategy extends BuildStrategy { project: string; linkedPackages: string; }; - constructor(args: BuildStrategyArgs) { - super(args); + constructor(config: BuildStrategyConfig) { + super(config); if (!isDockerInstalled(this.project.logger)) { throw new Error(intlMsg.lib_docker_noInstall()); @@ -133,21 +138,14 @@ export class DockerVMBuildStrategy extends BuildStrategy { // Copy sources and build if (buildManifestConfig.polywrap_module) { - // HACK: moduleDir is path to Cargo.toml in Rust - if (language === "wasm/rust") { - fse.copySync( - path.join(manifestDir, "src"), - path.join(this._volumePaths.project, "src") - ); - } else { - fse.copySync( - path.join(manifestDir, buildManifestConfig.polywrap_module.dir), - path.join( - this._volumePaths.project, - buildManifestConfig.polywrap_module.dir - ) - ); - } + const sourcesSubDirectory = + this.overrides?.sourcesSubDirectory || + buildManifestConfig.polywrap_module.dir; + + fse.copySync( + path.join(manifestDir, sourcesSubDirectory), + path.join(this._volumePaths.project, sourcesSubDirectory) + ); const scriptTemplate = fse.readFileSync( path.join( diff --git a/packages/cli/src/lib/codegen/CodeGenerator.ts b/packages/cli/src/lib/codegen/CodeGenerator.ts index affc649213..1aee32cde4 100644 --- a/packages/cli/src/lib/codegen/CodeGenerator.ts +++ b/packages/cli/src/lib/codegen/CodeGenerator.ts @@ -16,15 +16,18 @@ import { } from "../project"; import { resetDir } from "../system"; import { SchemaComposer } from "../SchemaComposer"; +import { CodegenOverrides, tryGetCodegenOverrides } from "./CodegenOverrides"; import path from "path"; import { BindLanguage } from "@polywrap/schema-bind"; import { writeDirectorySync } from "@polywrap/os-js"; +import { Uri } from "@polywrap/core-js"; export interface CodeGeneratorConfig { project: Project; schemaComposer: SchemaComposer; codegenDirAbs?: string; + bindgenUri?: Uri; } export class CodeGenerator { @@ -48,13 +51,16 @@ export class CodeGenerator { ); } + // Get overrides if they exist + const overrides = await tryGetCodegenOverrides(language); + await logActivity( this._config.project.logger, intlMsg.lib_codeGenerator_genCodeText(), intlMsg.lib_codeGenerator_genCodeError(), intlMsg.lib_codeGenerator_genCodeWarning(), async () => { - return this.runCodegen(bindLanguage); + return this.runCodegen(bindLanguage, overrides); } ); @@ -65,7 +71,11 @@ export class CodeGenerator { } } - protected async runCodegen(_: BindLanguage): Promise { + protected async runCodegen( + _: BindLanguage, + overrides?: CodegenOverrides + ): Promise { + // TODO: move codegen dir overrides into the new "language-overrides" const codegenDir = this._config.codegenDirAbs ? path.relative( this._config.project.getManifestDir(), @@ -73,10 +83,16 @@ export class CodeGenerator { ) : undefined; + const bindConfig = overrides + ? await overrides.getSchemaBindConfig(this._config.project) + : {}; + const abi = await this._config.schemaComposer.getComposedAbis(); const binding = await this._config.project.generateSchemaBindings( abi, - codegenDir + codegenDir, + this._config.bindgenUri?.toString(), + bindConfig ); resetDir(binding.outputDirAbs); diff --git a/packages/cli/src/lib/codegen/CodegenOverrides.ts b/packages/cli/src/lib/codegen/CodegenOverrides.ts new file mode 100644 index 0000000000..dd224839b5 --- /dev/null +++ b/packages/cli/src/lib/codegen/CodegenOverrides.ts @@ -0,0 +1,35 @@ +import { Project, AnyProjectManifest, AnyProjectManifestLanguage } from "../"; + +import path from "path"; +import fs from "fs"; + +export interface CodegenOverrides { + getSchemaBindConfig: ( + project: Project + ) => Promise>; +} + +export async function tryGetCodegenOverrides( + language: AnyProjectManifestLanguage +): Promise { + const modulePath = path.join( + __dirname, + "..", + "defaults", + "language-overrides", + language, + "index.js" + ); + let overrides: CodegenOverrides | undefined; + + if (fs.existsSync(modulePath)) { + const module = await import(modulePath); + + // Get any build overrides for the given build-image + if (module.getCodegenOverrides) { + overrides = module.getCodegenOverrides() as CodegenOverrides; + } + } + + return Promise.resolve(overrides); +} diff --git a/packages/cli/src/lib/codegen/ScriptCodeGenerator.ts b/packages/cli/src/lib/codegen/ScriptCodeGenerator.ts index 984bf4c7e5..c5487b6142 100644 --- a/packages/cli/src/lib/codegen/ScriptCodeGenerator.ts +++ b/packages/cli/src/lib/codegen/ScriptCodeGenerator.ts @@ -5,10 +5,15 @@ import { SchemaComposer } from "../SchemaComposer"; import { CodeGenerator } from "./CodeGenerator"; import { writeDirectorySync } from "@polywrap/os-js"; -import { BindLanguage, GenerateBindingFn } from "@polywrap/schema-bind"; +import { + BindLanguage, + bindLanguageToWrapInfoType, + GenerateBindingFn, +} from "@polywrap/schema-bind"; import { readFileSync } from "fs-extra"; import Mustache from "mustache"; import path from "path"; +import { latestWrapManifestVersion } from "@polywrap/wrap-manifest-types-js"; export class ScriptCodegenerator extends CodeGenerator { private readonly _script: string; @@ -62,11 +67,15 @@ export class ScriptCodegenerator extends CodeGenerator { ); const binding = await generateBinding({ - projectName: await this._config.project.getName(), - abi: await this._config.schemaComposer.getComposedAbis(), - outputDirAbs, bindLanguage, + wrapInfo: { + version: latestWrapManifestVersion, + name: await this._config.project.getName(), + type: bindLanguageToWrapInfoType(bindLanguage), + abi: await this._config.schemaComposer.getComposedAbis(), + }, config: this._mustacheView, + outputDirAbs, }); resetDir(outputDirAbs); diff --git a/packages/cli/src/lib/codegen/index.ts b/packages/cli/src/lib/codegen/index.ts index fb9b3a2ef5..cd95e5446c 100644 --- a/packages/cli/src/lib/codegen/index.ts +++ b/packages/cli/src/lib/codegen/index.ts @@ -1,2 +1,3 @@ export * from "./CodeGenerator"; +export * from "./CodegenOverrides"; export * from "./ScriptCodeGenerator"; diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/default.build.yaml b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/default.build.yaml new file mode 100644 index 0000000000..2d69edd896 --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/default.build.yaml @@ -0,0 +1,4 @@ +format: 0.2.0 +strategies: + image: + dockerfile: ./Dockerfile.mustache diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/image/Dockerfile.mustache b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/image/Dockerfile.mustache new file mode 100644 index 0000000000..c6168ef9de --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/image/Dockerfile.mustache @@ -0,0 +1,68 @@ +FROM polywrap/vm-base-go:0.1.6 + +WORKDIR /project + +COPY . . + +# Ensure all go mod deps are correct +RUN go mod tidy + +# Reset our build-staging directory +RUN rm -rf ./build-staging +RUN mkdir ./build-staging + +# Build the module with tinygo +RUN tinygo build -o ./build-staging/module.wasm -target wasm-target ./module/wrap/main/main.go + +# Extract the names of all "extra" exports from the wasm module +# 1. convert to wasm text +RUN wasm2wat ./build-staging/module.wasm | \ + # 2. extract all exports + grep -oP '(?<=export ")[^"]+' | \ + # 3. keep all necessary exports (wrap & asyncify) + grep -vE '_wrap_invoke|asyncify_start_unwind|asyncify_stop_unwind|asyncify_start_rewind|asyncify_stop_rewind|asyncify_get_state' | \ + # 4. convert remaining string into single-line seperated by spaces + tr '\n' ' ' \ + # Finally, write the result to a file + >> ./build-staging/EXTRA_EXPORTS + +# Remove the extra exports from the wasm module via wasm-snip (if they exist) +RUN if [ ! -s ./build-staging/EXTRA_EXPORTS ]; then \ + echo "No extra exports to remove"; \ + cp ./build-staging/module.wasm ./build-staging/module_exports.wasm; \ + else \ + EXTRA_EXPORTS=$(cat ./build-staging/EXTRA_EXPORTS); \ + echo "Removing extra exports: $EXTRA_EXPORTS"; \ + wasm-snip ./build-staging/module.wasm -o ./build-staging/module_exports.wasm $EXTRA_EXPORTS; \ + fi + +# Extract the unsupported wasi imports, and forcefully remove them. +# This ideally would not be necessary, but it is for go-based wraps. +# 1. convert to wasm text +RUN wasm2wat ./build-staging/module_exports.wasm | \ + # 2. extract all wasi imports + grep -oP '(?<=wasi_snapshot_preview1" ")[^"]+' | \ + # 3. convert string into single-line seperated by spaces + tr '\n' ' ' \ + # Finally, write the result to a file + >> ./build-staging/EXTRA_IMPORTS + +# Remove the extra impors from the wasm module via wasm-snip (if they exist) +RUN if [ ! -s ./build-staging/EXTRA_IMPORTS ]; then \ + echo "No extra imports to remove"; \ + cp ./build-staging/module_exports.wasm ./build-staging/module_exports_imports.wasm; \ + else \ + EXTRA_IMPORTS=$(cat ./build-staging/EXTRA_IMPORTS); \ + echo "Removing extra imports: $EXTRA_IMPORTS"; \ + wasm-snip ./build-staging/module_exports.wasm -o ./build-staging/module_exports_imports.wasm -p $EXTRA_IMPORTS; \ + fi + +# Optimize the module now that exports & imports are removed +RUN wasm-opt ./build-staging/module_exports_imports.wasm -Oz --converge -o ./build-staging/module_exports_imports_opt.wasm + +# Make the build directory +RUN rm -rf ./build +RUN mkdir ./build + +# Copy the result to the build folder +RUN cp ./build-staging/module_exports_imports_opt.wasm ./build/wrap.wasm diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/local/local.sh b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/local/local.sh new file mode 100644 index 0000000000..743e311e2d --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/local/local.sh @@ -0,0 +1,58 @@ +# Ensure all go mod deps are correct +go mod tidy + +# Reset our build-staging directory +rm -rf ./build-staging +mkdir ./build-staging + +# Build the module with tinygo +tinygo build -o ./build-staging/module.wasm -target ./.polywrap/wasm/build/strategy-used/wasm-target.json ./module/wrap/main/main.go + +# Extract the names of all "extra" exports from the wasm module +EXTRA_EXPORTS=$( + # 1. convert to wasm text + wasm2wat ./build-staging/module.wasm | + # 2. extract all exports + grep -oP '(?<=export ")[^"]+' | + # 3. keep all necessary exports (wrap & asyncify) + grep -vE '_wrap_invoke|asyncify_start_unwind|asyncify_stop_unwind|asyncify_start_rewind|asyncify_stop_rewind|asyncify_get_state' | + # 4. convert remaining string into single-line seperated by spaces + tr '\n' ' ' +) + +if [ -z "$EXTRA_EXPORTS" ] +then + echo "No extra exports to remove" + cp ./build-staging/module.wasm ./build-staging/module_exports.wasm +else + echo "Removing extra exports: $EXTRA_EXPORTS" + # Remove these extra exports from the wasm module via wasm-snip + wasm-snip ./build-staging/module.wasm -o ./build-staging/module_exports.wasm $EXTRA_EXPORTS +fi + +# Extract the unsupported wasi imports, and forcefully remove them. +# This ideally would not be necessary, but it is for go-based wraps. +EXTRA_IMPORTS=$( + # 1. convert to wasm text + wasm2wat ./build-staging/module_exports.wasm | + # 2. extract all wasi imports + grep -oP '(?<=wasi_snapshot_preview1" ")[^"]+' | + # 3. convert string into single-line seperated by spaces + tr '\n' ' ' +) + +if [ -z "$EXTRA_IMPORTS" ] +then + echo "No extra imports to remove" + cp ./build-staging/module_exports.wasm ./build-staging/module_exports_imports.wasm +else + echo "Removing extra imports: $EXTRA_IMPORTS" + # Remove these extra imports from the wasm module via wasm-snip + wasm-snip ./build-staging/module_exports.wasm -o ./build-staging/module_exports_imports.wasm -p $EXTRA_IMPORTS +fi + +# Optimize the module now that exports & imports are removed +wasm-opt ./build-staging/module_exports_imports.wasm -Oz --converge -o ./build-staging/module_exports_imports_opt.wasm + +# Copy the result to the build folder +cp ./build-staging/module_exports_imports_opt.wasm ./build/wrap.wasm diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/local/wasm-target.json b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/local/wasm-target.json new file mode 100644 index 0000000000..2e45a55999 --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/local/wasm-target.json @@ -0,0 +1,27 @@ +{ + "llvm-target": "wasm32-unknown-wasi", + "cpu": "generic", + "features": "+bulk-memory,+nontrapping-fptoint,+sign-ext", + "build-tags": ["tinygo.wasm", "wasi"], + "goos": "linux", + "goarch": "arm", + "linker": "wasm-ld", + "libc": "wasi-libc", + "scheduler": "asyncify", + "default-stack-size": 24576, + "cflags": [ + "-mbulk-memory", + "-mnontrapping-fptoint", + "-msign-ext" + ], + "ldflags": [ + "--stack-first", + "--no-demangle", + "--import-memory" + ], + "extra-files": [ + "src/runtime/asm_tinygowasm.S" + ], + "emulator": "wasmtime --mapdir=/tmp::{tmpDir} {}", + "wasm-abi": "generic" +} diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/manifest.ext.json b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/manifest.ext.json new file mode 100644 index 0000000000..6894091f3d --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/manifest.ext.json @@ -0,0 +1,22 @@ +{ + "properties": { + "strategies": { + "properties": { + "image": { + "type": "object", + "properties": { + "include": { + "description": "Files to include in docker image.", + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "local": { }, + "vm": { } + } +} \ No newline at end of file diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/Dockerfile b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/Dockerfile new file mode 100644 index 0000000000..c82a25ee53 --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/Dockerfile @@ -0,0 +1,34 @@ +FROM ubuntu:22.10 as ubuntu + +# Install build essentials (needed by wasm binary toolkit) +RUN apt-get update && apt-get install -y \ + build-essential \ + libstdc++6 \ + wget + +# Install Wasm Binary Toolkit +RUN wget https://github.com/WebAssembly/wabt/releases/download/1.0.33/wabt-1.0.33-ubuntu.tar.gz && \ + tar xfv wabt-1.0.33-ubuntu.tar.gz -C /usr/local + +# Add it to the path +ENV PATH=${PATH}:/usr/local/wabt-1.0.33/bin + +FROM rust:1.60.0 as rust + +# Install wasm-snip +RUN cargo install -f wasm-snip + +FROM polywrap/tinygo:0.28.1-polywrap.2 + +# Copy wasm-snip +COPY --from=rust /usr/local/cargo/bin/wasm-snip /usr/local/bin/ + +# Copy wasm binary toolkit +COPY --from=ubuntu /usr/local/wabt-1.0.33/bin /usr/local/bin/ + +# Copy wasm-target.json +COPY wasm-target.json /usr/local/tinygo/targets/ + +USER root + +WORKDIR /project diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/NAME b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/NAME new file mode 100644 index 0000000000..97d7c2778e --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/NAME @@ -0,0 +1 @@ +polywrap/vm-base-go \ No newline at end of file diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/VERSION b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/VERSION new file mode 100644 index 0000000000..a192233208 --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/VERSION @@ -0,0 +1 @@ +0.1.6 \ No newline at end of file diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/vm-script.mustache b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/vm-script.mustache new file mode 100644 index 0000000000..959ef98fc4 --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/vm-script.mustache @@ -0,0 +1,64 @@ +set -e + +# Ensure all go mod deps are correct +go mod tidy + +# Reset our build-staging directory +rm -rf ./build-staging +mkdir ./build-staging + +# Build the module with tinygo +tinygo build -o ./build-staging/module.wasm -target wasm-target ./module/wrap/main/main.go + +# Extract the names of all "extra" exports from the wasm module +EXTRA_EXPORTS=$( + # 1. convert to wasm text + wasm2wat ./build-staging/module.wasm | + # 2. extract all exports + grep -oP '(?<=export ")[^"]+' | + # 3. keep all necessary exports (wrap & asyncify) + grep -vE '_wrap_invoke|asyncify_start_unwind|asyncify_stop_unwind|asyncify_start_rewind|asyncify_stop_rewind|asyncify_get_state' | + # 4. convert remaining string into single-line seperated by spaces + tr '\n' ' ' +) + +if [ -z "$EXTRA_EXPORTS" ] +then + echo "No extra exports to remove" + cp ./build-staging/module.wasm ./build-staging/module_exports.wasm +else + echo "Removing extra exports: $EXTRA_EXPORTS" + # Remove these extra exports from the wasm module via wasm-snip + wasm-snip ./build-staging/module.wasm -o ./build-staging/module_exports.wasm $EXTRA_EXPORTS +fi + +# Extract the unsupported wasi imports, and forcefully remove them. +# This ideally would not be necessary, but it is for go-based wraps. +EXTRA_IMPORTS=$( + # 1. convert to wasm text + wasm2wat ./build-staging/module_exports.wasm | + # 2. extract all wasi imports + grep -oP '(?<=wasi_snapshot_preview1" ")[^"]+' | + # 3. convert string into single-line seperated by spaces + tr '\n' ' ' +) + +if [ -z "$EXTRA_IMPORTS" ] +then + echo "No extra imports to remove" + cp ./build-staging/module_exports.wasm ./build-staging/module_exports_imports.wasm +else + echo "Removing extra imports: $EXTRA_IMPORTS" + # Remove these extra imports from the wasm module via wasm-snip + wasm-snip ./build-staging/module_exports.wasm -o ./build-staging/module_exports_imports.wasm -p $EXTRA_IMPORTS +fi + +# Optimize the module now that exports & imports are removed +wasm-opt ./build-staging/module_exports_imports.wasm -Oz --converge -o ./build-staging/module_exports_imports_opt.wasm + +# Reset build directory +rm -rf ./build +mkdir ./build + +# Copy the result to the build folder +cp ./build-staging/module_exports_imports_opt.wasm ./build/wrap.wasm diff --git a/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/wasm-target.json b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/wasm-target.json new file mode 100644 index 0000000000..2e45a55999 --- /dev/null +++ b/packages/cli/src/lib/defaults/build-strategies/wasm/golang/vm/wasm-target.json @@ -0,0 +1,27 @@ +{ + "llvm-target": "wasm32-unknown-wasi", + "cpu": "generic", + "features": "+bulk-memory,+nontrapping-fptoint,+sign-ext", + "build-tags": ["tinygo.wasm", "wasi"], + "goos": "linux", + "goarch": "arm", + "linker": "wasm-ld", + "libc": "wasi-libc", + "scheduler": "asyncify", + "default-stack-size": 24576, + "cflags": [ + "-mbulk-memory", + "-mnontrapping-fptoint", + "-msign-ext" + ], + "ldflags": [ + "--stack-first", + "--no-demangle", + "--import-memory" + ], + "extra-files": [ + "src/runtime/asm_tinygowasm.S" + ], + "emulator": "wasmtime --mapdir=/tmp::{tmpDir} {}", + "wasm-abi": "generic" +} diff --git a/packages/cli/src/lib/defaults/deploy-modules/ens-recursive-name-register/index.ts b/packages/cli/src/lib/defaults/deploy-modules/ens-recursive-name-register/index.ts deleted file mode 100644 index 05384bedbc..0000000000 --- a/packages/cli/src/lib/defaults/deploy-modules/ens-recursive-name-register/index.ts +++ /dev/null @@ -1,136 +0,0 @@ -/* eslint-disable @typescript-eslint/no-require-imports */ -/* eslint-disable @typescript-eslint/no-var-requires */ -import { DeployModule } from "../../../deploy"; -import { invokeWithTimeout } from "./invokeWithTimeout"; - -import { Wallet } from "@ethersproject/wallet"; -import { JsonRpcProvider } from "@ethersproject/providers"; -import { Uri } from "@polywrap/core-js"; -import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js"; -import { DefaultBundle } from "@polywrap/client-config-builder-js"; -import { - Connection, - Connections, - ethereumProviderPlugin, -} from "@polywrap/ethereum-provider-js-v1"; - -class ENSRecursiveNameRegisterPublisher implements DeployModule { - async execute( - uri: Uri, - config: { - provider: string; - privateKey?: string; - ensRegistryAddress: string; - ensRegistrarAddress: string; - ensResolverAddress: string; - } - ): Promise { - if (uri.authority !== "ens") { - throw new Error( - `ENS Recursive Name Register Deployer: argument URI needs to be an ENS URI. Example: wrap://ens/foo.bar.eth` - ); - } - - let ensDomain = uri.path; - - const connectionProvider = new JsonRpcProvider(config.provider); - const { - chainId: chainIdNum, - name: networkName, - } = await connectionProvider.getNetwork(); - - const network = chainIdNum === 1337 ? "testnet" : networkName; - - if (ensDomain.startsWith(network)) { - ensDomain = ensDomain.split("/")[1]; - } - - const signer = config.privateKey - ? new Wallet(config.privateKey).connect(connectionProvider) - : undefined; - - // Default connections - const connections = new Connections({ - networks: { - [network]: new Connection({ - provider: config.provider, - signer, - }), - }, - defaultNetwork: network, - }); - - const clientConfig = new ClientConfigBuilder() - .addDefaults() - .addPackage( - DefaultBundle.plugins.ethereumProviderV1.uri.uri, - ethereumProviderPlugin({ - connections: connections, - }) - ) - .build(); - - const client = new PolywrapClient(clientConfig); - - const signerAddress = await client.invoke({ - method: "getSignerAddress", - uri: "ens/wraps.eth:ethereum@1.0.0", - args: { - connection: { - networkNameOrChainId: network, - }, - }, - }); - - if (!signerAddress.ok) { - throw new Error("Could not get signer. " + signerAddress.error); - } - - const registerData = await client.invoke< - { tx: { hash: string }; didRegister: boolean }[] - >({ - method: "registerDomainAndSubdomainsRecursively", - uri: "ens/wraps.eth:ens@1.0.0", - args: { - domain: ensDomain, - owner: signerAddress.value, - resolverAddress: config.ensResolverAddress, - ttl: "0", - registrarAddress: config.ensRegistrarAddress, - registryAddress: config.ensRegistryAddress, - connection: { - networkNameOrChainId: network, - }, - }, - }); - - if (!registerData.ok) { - throw new Error( - `Could not register domain '${ensDomain}'` + - (registerData.error ? `\nError: ${registerData.error.message}` : "") - ); - } - - // didRegister can be false if the ens domain is already registered, in which case there is no transaction - if (registerData.value[0].didRegister) { - await invokeWithTimeout( - client, - { - method: "awaitTransaction", - uri: Uri.from("ens/wraps.eth:ethereum@1.0.0"), - args: { - txHash: registerData.value[0].tx.hash, - connection: { - networkNameOrChainId: network, - }, - }, - }, - 15000 - ); - } - - return new Uri(`ens/${network}/${ensDomain}`); - } -} - -export default new ENSRecursiveNameRegisterPublisher(); diff --git a/packages/cli/src/lib/defaults/deploy-modules/ens-recursive-name-register/invokeWithTimeout.ts b/packages/cli/src/lib/defaults/deploy-modules/ens-recursive-name-register/invokeWithTimeout.ts deleted file mode 100644 index bd8523c65b..0000000000 --- a/packages/cli/src/lib/defaults/deploy-modules/ens-recursive-name-register/invokeWithTimeout.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - Invoker, - InvokeResult, - InvokerOptions, - WrapError, - WrapErrorCode, -} from "@polywrap/core-js"; -import { ResultErr } from "@polywrap/result"; - -/** - * Invoke a wrapper; abort the invocation if a timeout expires. - * - * @param client - a Polywrap Invoker (e.g. CoreClient) - * @param options - invocation options - * @param timeout - a timeout period (in ms) - * */ -export async function invokeWithTimeout( - client: Invoker, - options: InvokerOptions, - timeout: number -): Promise> { - const controller = new AbortController(); - - const timer = setTimeout(() => { - controller.abort(); - }, timeout); - - return await new Promise>((resolve, reject) => { - controller.signal.addEventListener("abort", () => { - const wrapError = new WrapError("Timeout has been reached", { - code: WrapErrorCode.WRAPPER_INVOKE_ABORTED, - uri: options.uri.uri, - method: options.method, - args: JSON.stringify(options.args, null, 2), - }); - reject(wrapError); - }); - client - .invoke(options) - .then((result) => resolve(result)) - .catch((error) => { - // the client threw an error (this should never happen) - const wrapError = new WrapError(error.message, { - code: WrapErrorCode.WRAPPER_INVOKE_FAIL, - uri: options.uri.uri, - method: options.method, - args: JSON.stringify(options.args, null, 2), - }); - resolve(ResultErr(wrapError)); - }); - }) - .catch((error) => { - return ResultErr(error as WrapError); - }) - .finally(() => timer && clearTimeout(timer)); -} diff --git a/packages/cli/src/lib/defaults/deploy-modules/ens-recursive-name-register/polywrap.deploy.ext.json b/packages/cli/src/lib/defaults/deploy-modules/ens-recursive-name-register/polywrap.deploy.ext.json deleted file mode 100644 index 31ef9b84aa..0000000000 --- a/packages/cli/src/lib/defaults/deploy-modules/ens-recursive-name-register/polywrap.deploy.ext.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "id": "DeployManifest_ENSRecursiveNameRegister_WasmAsExt", - "type": "object", - "required": [ - "provider", - "ensRegistryAddress", - "ensRegistrarAddress", - "ensResolverAddress" - ], - "properties": { - "provider": { - "type": "string" - }, - "privateKey": { - "type": "string" - }, - "ensRegistryAddress": { - "type": "string" - }, - "ensRegistrarAddress": { - "type": "string" - }, - "ensResolverAddress": { - "type": "string" - } - } -} \ No newline at end of file diff --git a/packages/cli/src/lib/defaults/deploy-modules/ens/index.ts b/packages/cli/src/lib/defaults/deploy-modules/ens/index.ts deleted file mode 100644 index 44cd35bdc6..0000000000 --- a/packages/cli/src/lib/defaults/deploy-modules/ens/index.ts +++ /dev/null @@ -1,134 +0,0 @@ -/* eslint-disable @typescript-eslint/no-require-imports */ -/* eslint-disable @typescript-eslint/no-var-requires */ -import { DeployModule } from "../../../deploy"; -import { invokeWithTimeout } from "./invokeWithTimeout"; - -import { Wallet } from "@ethersproject/wallet"; -import { JsonRpcProvider } from "@ethersproject/providers"; -import { Uri } from "@polywrap/core-js"; -import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js"; -import { DefaultBundle } from "@polywrap/client-config-builder-js"; -import { - Connection, - Connections, - ethereumProviderPlugin, -} from "@polywrap/ethereum-provider-js-v1"; - -const contentHash = require("content-hash"); - -class ENSPublisher implements DeployModule { - async execute( - uri: Uri, - config: { - domainName: string; - provider: string; - privateKey?: string; - ensRegistryAddress: string; - } - ): Promise { - if (uri.authority !== "ipfs") { - throw new Error( - `ENS Deployer: resolved URI from ${uri} does not represent an IPFS contentHash` - ); - } - - const cid = uri.path; - - const connectionProvider = new JsonRpcProvider(config.provider); - const { - chainId: chainIdNum, - name: networkName, - } = await connectionProvider.getNetwork(); - - const network = chainIdNum === 1337 ? "testnet" : networkName; - - const signer = config.privateKey - ? new Wallet(config.privateKey).connect(connectionProvider) - : undefined; - - // Default connections - const connections = new Connections({ - networks: { - [network]: new Connection({ - provider: config.provider, - signer, - }), - }, - defaultNetwork: network, - }); - - const clientConfig = new ClientConfigBuilder() - .addDefaults() - .addPackage( - DefaultBundle.plugins.ethereumProviderV1.uri.uri, - ethereumProviderPlugin({ - connections: connections, - }) - ) - .build(); - - const client = new PolywrapClient(clientConfig); - - const resolver = await client.invoke({ - method: "getResolver", - uri: "ens/wraps.eth:ens@1.0.0", - args: { - registryAddress: config.ensRegistryAddress, - domain: config.domainName, - connection: { - networkNameOrChainId: network, - }, - }, - }); - - if (!resolver.ok) { - throw new Error( - `Could not get resolver for '${config.domainName}'. ${resolver.error}` - ); - } - - if (resolver.value === "0x0000000000000000000000000000000000000000") { - throw new Error(`Resolver not set for '${config.domainName}'`); - } - - const hash = "0x" + contentHash.fromIpfs(cid); - - const setContenthashData = await client.invoke<{ hash: string }>({ - method: "setContentHash", - uri: "ens/wraps.eth:ens@1.0.0", - args: { - domain: config.domainName, - cid: hash, - resolverAddress: resolver.value, - connection: { - networkNameOrChainId: network, - }, - }, - }); - - if (!setContenthashData.ok) { - throw new Error( - `Could not set contentHash for '${config.domainName}'. ${setContenthashData.error}` - ); - } - - await invokeWithTimeout( - client, - { - method: "awaitTransaction", - uri: Uri.from("ens/wraps.eth:ethereum@1.0.0"), - args: { - txHash: setContenthashData.value.hash, - connection: { - networkNameOrChainId: network, - }, - }, - }, - 15000 - ); - - return new Uri(`ens/${network}/${config.domainName}`); - } -} - -export default new ENSPublisher(); diff --git a/packages/cli/src/lib/defaults/deploy-modules/ens/invokeWithTimeout.ts b/packages/cli/src/lib/defaults/deploy-modules/ens/invokeWithTimeout.ts deleted file mode 100644 index bd8523c65b..0000000000 --- a/packages/cli/src/lib/defaults/deploy-modules/ens/invokeWithTimeout.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - Invoker, - InvokeResult, - InvokerOptions, - WrapError, - WrapErrorCode, -} from "@polywrap/core-js"; -import { ResultErr } from "@polywrap/result"; - -/** - * Invoke a wrapper; abort the invocation if a timeout expires. - * - * @param client - a Polywrap Invoker (e.g. CoreClient) - * @param options - invocation options - * @param timeout - a timeout period (in ms) - * */ -export async function invokeWithTimeout( - client: Invoker, - options: InvokerOptions, - timeout: number -): Promise> { - const controller = new AbortController(); - - const timer = setTimeout(() => { - controller.abort(); - }, timeout); - - return await new Promise>((resolve, reject) => { - controller.signal.addEventListener("abort", () => { - const wrapError = new WrapError("Timeout has been reached", { - code: WrapErrorCode.WRAPPER_INVOKE_ABORTED, - uri: options.uri.uri, - method: options.method, - args: JSON.stringify(options.args, null, 2), - }); - reject(wrapError); - }); - client - .invoke(options) - .then((result) => resolve(result)) - .catch((error) => { - // the client threw an error (this should never happen) - const wrapError = new WrapError(error.message, { - code: WrapErrorCode.WRAPPER_INVOKE_FAIL, - uri: options.uri.uri, - method: options.method, - args: JSON.stringify(options.args, null, 2), - }); - resolve(ResultErr(wrapError)); - }); - }) - .catch((error) => { - return ResultErr(error as WrapError); - }) - .finally(() => timer && clearTimeout(timer)); -} diff --git a/packages/cli/src/lib/defaults/deploy-modules/ens/polywrap.deploy.ext.json b/packages/cli/src/lib/defaults/deploy-modules/ens/polywrap.deploy.ext.json deleted file mode 100644 index 180605c257..0000000000 --- a/packages/cli/src/lib/defaults/deploy-modules/ens/polywrap.deploy.ext.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "id": "DeployManifest_ENS_WasmAsExt", - "type": "object", - "required": [ - "domainName", - "provider", - "ensRegistryAddress" - ], - "properties": { - "domainName": { - "type": "string" - }, - "provider": { - "type": "string" - }, - "privateKey": { - "type": "string" - }, - "ensRegistryAddress": { - "type": "string" - } - } -} \ No newline at end of file diff --git a/packages/cli/src/lib/defaults/deploy-modules/ipfs/index.ts b/packages/cli/src/lib/defaults/deploy-modules/ipfs/index.ts index 9a9de9c00f..bb674ee54c 100644 --- a/packages/cli/src/lib/defaults/deploy-modules/ipfs/index.ts +++ b/packages/cli/src/lib/defaults/deploy-modules/ipfs/index.ts @@ -1,14 +1,74 @@ import { DeployModule } from "../../../deploy"; import { Uri } from "@polywrap/core-js"; - -// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires,@typescript-eslint/naming-convention -const IPFSClient = require("ipfs-http-client"); -const { globSource } = IPFSClient; +import { PolywrapClient } from "@polywrap/client-js"; +import * as Sys from "@polywrap/sys-config-bundle-js"; +import { PolywrapClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import fs from "fs"; const isValidUri = (uri: Uri) => uri.authority === "fs" || uri.authority === "file"; +interface FileEntry { + name: string; + data: Uint8Array; +} + +interface DirectoryEntry { + name: string; + directories?: DirectoryEntry[]; + files?: FileEntry[]; +} + +interface AddOptions { + pin?: boolean; + onlyHash?: boolean; + wrapWithDirectory?: boolean; +} + +interface AddResult { + name: string; + hash: string; + size: string; +} + +interface ArgsAddDir { + data: DirectoryEntry; + ipfsProvider: string; + timeout?: number; + addOptions?: AddOptions; +} + +const readDirContents = async ( + path: string, + dirName: string +): Promise => { + const dirents: fs.Dirent[] = await fs.promises.readdir(path, { + withFileTypes: true, + }); + const data: DirectoryEntry = { name: dirName }; + + for (const dirent of dirents) { + if (dirent.isDirectory()) { + const subDir = await readDirContents( + `${path}/${dirent.name}`, + `${dirName}/${dirent.name}` + ); + data.directories = data.directories ?? []; + data.directories?.push(subDir); + } else { + const fileData = await fs.promises.readFile(`${path}/${dirent.name}`); + data.files = data.files ?? []; + data.files?.push({ + name: dirent.name, + data: fileData, + }); + } + } + + return data; +}; + class IPFSDeployer implements DeployModule { async execute(uri: Uri, config?: { gatewayUri: string }): Promise { if (!isValidUri(uri)) { @@ -18,26 +78,37 @@ class IPFSDeployer implements DeployModule { } const path = uri.path; + const data: DirectoryEntry = await readDirContents(path, ""); - const ipfsUrl = config?.gatewayUri ?? "http://localhost:5001"; + const ipfsProvider = config?.gatewayUri ?? "http://localhost:5001"; - const client = new IPFSClient({ url: ipfsUrl }); - const globOptions = { - recursive: true, + const args: ArgsAddDir = { + data, + ipfsProvider, + addOptions: { + pin: true, + wrapWithDirectory: false, + }, + timeout: 10000, }; - const addOptions = { - wrapWithDirectory: false, - }; + const clientConfig = new PolywrapClientConfigBuilder() + .addDefaults() + .build(); + const client: PolywrapClient = new PolywrapClient(clientConfig); - let rootCID = ""; + const result = await client.invoke({ + uri: Sys.bundle.ipfsHttpClient.uri, + method: "addDir", + args: (args as unknown) as Record, + }); - for await (const file of client.addAll( - globSource(path, globOptions), - addOptions - )) { - if (file.path.indexOf("/") === -1) { - rootCID = file.cid.toString(); + if (!result.ok) throw result.error; + + let rootCID = ""; + for (const addResult of result.value) { + if (addResult.name.indexOf("/") === -1) { + rootCID = addResult.hash; } } diff --git a/packages/cli/src/lib/defaults/infra-modules/http/server/package.json b/packages/cli/src/lib/defaults/infra-modules/http/server/package.json index 03d1dda74a..95dd20d2ac 100644 --- a/packages/cli/src/lib/defaults/infra-modules/http/server/package.json +++ b/packages/cli/src/lib/defaults/infra-modules/http/server/package.json @@ -27,7 +27,7 @@ "@types/file-saver": "2.0.5", "@types/fs-extra": "7.0.0", "@types/jest": "26.0.8", - "@types/node": "^18.14.6", + "@types/node": "18.15.0", "jest": "26.6.3", "nodemon": "2.0.19", "rimraf": "3.0.2", diff --git a/packages/cli/src/lib/defaults/language-overrides/wasm/golang/index.ts b/packages/cli/src/lib/defaults/language-overrides/wasm/golang/index.ts new file mode 100644 index 0000000000..16f31636c1 --- /dev/null +++ b/packages/cli/src/lib/defaults/language-overrides/wasm/golang/index.ts @@ -0,0 +1,72 @@ +import { BuildOverrides } from "../../../../build-strategies"; +import { CodegenOverrides } from "../../../../codegen"; +import { PolywrapProject } from "../../../../project"; +import { resolvePathIfExists } from "../../../../system"; +import { intlMsg } from "../../../../intl"; + +import { PolywrapManifest } from "@polywrap/polywrap-manifest-types-js"; +import fs from "fs"; + +export function getBuildOverrides(): BuildOverrides { + return { + validateManifest: (manifest: PolywrapManifest) => { + getGoModulePath(manifest); + return Promise.resolve(); + }, + sourcesSubDirectory: "module", + }; +} + +export function getCodegenOverrides(): CodegenOverrides { + return { + getSchemaBindConfig: async (project: PolywrapProject) => { + const manifest = await project.getManifest(); + const goModpath = getGoModulePath(manifest); + const goModuleName = readGoModuleName(goModpath); + return { + goModuleName, + }; + }, + }; +} + +function getGoModulePath(manifest: PolywrapManifest): string { + // Ensure `module: ...` is pointing to a `go.mod` file + const module = manifest.source.module; + if (!module || module.indexOf("go.mod") === -1) { + throw Error( + intlMsg.lib_wasm_golang_invalidModule({ path: module || "N/A" }) + ); + } + + // Ensure the `go.mod` file exists + const goModFile = resolvePathIfExists([module]); + if (!goModFile) { + throw Error( + intlMsg.commands_build_error_goModNotFound({ + paths: module, + }) + ); + } + + return goModFile; +} + +function readGoModuleName(filePath: string): string { + const goMod = fs.readFileSync(filePath, "utf-8"); + + if (!goMod) { + const noLoadMessage = intlMsg.lib_helpers_gomod_unableToLoad({ + path: filePath, + }); + throw Error(noLoadMessage); + } + + const regex = /module (.+)/m; + const module = goMod.match(regex); + if (!module || module.length != 2) { + throw Error(intlMsg.lib_helpers_gomod_invalid({ path: filePath })); + } + + return module[1]; +} diff --git a/packages/cli/src/lib/defaults/language-overrides/wasm/rust/index.ts b/packages/cli/src/lib/defaults/language-overrides/wasm/rust/index.ts new file mode 100644 index 0000000000..948da95d1a --- /dev/null +++ b/packages/cli/src/lib/defaults/language-overrides/wasm/rust/index.ts @@ -0,0 +1,19 @@ +import { BuildOverrides } from "../../../../build-strategies"; +import { intlMsg } from "../../../../intl"; + +import { PolywrapManifest } from "@polywrap/polywrap-manifest-types-js"; + +export function getBuildOverrides(): BuildOverrides { + return { + validateManifest: (manifest: PolywrapManifest) => { + const module = manifest.source.module; + + if (module && module.indexOf("Cargo.toml") === -1) { + throw Error(intlMsg.lib_wasm_rust_invalidModule({ path: module })); + } + + return Promise.resolve(); + }, + sourcesSubDirectory: "src", + }; +} diff --git a/packages/cli/src/lib/docgen/docusaurus/index.ts b/packages/cli/src/lib/docgen/docusaurus/index.ts deleted file mode 100644 index ef175f7dae..0000000000 --- a/packages/cli/src/lib/docgen/docusaurus/index.ts +++ /dev/null @@ -1,188 +0,0 @@ -import * as Functions from "./../functions"; -import { - arrangeByNamespace, - sortMethodsInPlaceByName, - sortObjectsInPlaceByType, -} from "../utils"; - -import { - WrapAbi, - transformAbi, - addFirstLast, - toPrefixedGraphQLType, - extendType, - methodParentPointers, -} from "@polywrap/schema-parse"; -import { - BindOptions, - BindOutput, - GenerateBindingFn, - TypeScript, -} from "@polywrap/schema-bind"; -import Mustache from "mustache"; -import path from "path"; -import { readFileSync } from "fs"; - -export const scriptPath = path.join(__dirname, "index.js"); - -export const generateBinding: GenerateBindingFn = ( - options: BindOptions -): BindOutput => { - const result: BindOutput = { - output: { - entries: [], - }, - outputDirAbs: options.outputDirAbs, - }; - const output = result.output; - const abi = applyTransforms(options.abi); - sortObjectsInPlaceByType(abi); - sortMethodsInPlaceByName(abi); - - const renderTemplate = ( - subPath: string, - context: unknown, - fileName: string - ) => { - const absPath = path.join(__dirname, subPath); - const template = readFileSync(absPath, { encoding: "utf-8" }); - - output.entries.push({ - type: "File", - name: fileName, - data: Mustache.render(template, context), - }); - }; - - // generate modules - if (abi.moduleType) { - renderTemplate( - "./templates/docusaurus-module.mustache", - abi.moduleType, - "module.md" - ); - } - - // generate object types - if (abi.objectTypes && abi.objectTypes.length > 0) { - const objectContext = { - objectTypes: abi.objectTypes, - }; - renderTemplate( - "./templates/docusaurus-objects.mustache", - objectContext, - "objects.md" - ); - } - - // generate enum types - if (abi.enumTypes && abi.enumTypes.length > 0) { - const enumContext = { - enumTypes: abi.enumTypes, - }; - renderTemplate( - "./templates/docusaurus-enums.mustache", - enumContext, - "enums.md" - ); - } - - // generate env type - if (abi.envType) { - const envContext = { - envType: abi.envType, - }; - renderTemplate("./templates/docusaurus-env.mustache", envContext, "env.md"); - } - - if (options.config?.["imports"]) { - // TODO: for imported modules, module.type contains the namespace. Should it? - // generate imported modules - if (abi.importedModuleTypes) { - for (const module of abi.importedModuleTypes) { - const moduleType = module.type.split("_")[1]; - const moduleContext = { - ...module, - type: moduleType, - imported: { namespace: module.namespace }, - }; - renderTemplate( - "./templates/docusaurus-module.mustache", - moduleContext, - `${module.namespace}_${moduleType.toLowerCase()}.md` - ); - } - } - - // generated imported object types - if (abi.importedObjectTypes) { - const importedObjects = arrangeByNamespace(abi.importedObjectTypes); - for (const [namespace, objectTypes] of Object.entries(importedObjects)) { - if (objectTypes.length > 0) { - const objectContext = { - objectTypes, - imported: { namespace }, - }; - renderTemplate( - "./templates/docusaurus-objects.mustache", - objectContext, - `${namespace}_objects.md` - ); - } - } - } - - // generate imported enum types - if (abi.importedEnumTypes) { - const importedEnums = arrangeByNamespace(abi.importedEnumTypes); - for (const [namespace, enumTypes] of Object.entries(importedEnums)) { - if (enumTypes.length > 0) { - const enumContext = { - enumTypes, - imported: { namespace }, - }; - renderTemplate( - "./templates/docusaurus-enums.mustache", - enumContext, - `${namespace}_enums.md` - ); - } - } - } - - // generate imported env types - if (abi.importedEnvTypes) { - const importedEnvs = arrangeByNamespace(abi.importedEnvTypes); - for (const [namespace, envType] of Object.entries(importedEnvs)) { - if (envType) { - const envContext = { - envType, - imported: { namespace }, - }; - renderTemplate( - "./templates/docusaurus-env.mustache", - envContext, - `${namespace}_env.md` - ); - } - } - } - } - - return result; -}; - -function applyTransforms(abi: WrapAbi): WrapAbi { - const transforms = [ - extendType(Functions), - extendType(TypeScript.Functions), - addFirstLast, - toPrefixedGraphQLType, - methodParentPointers(), - ]; - - for (const transform of transforms) { - abi = transformAbi(abi, transform); - } - return abi; -} diff --git a/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-enums.mustache b/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-enums.mustache deleted file mode 100644 index ad9003cc5f..0000000000 --- a/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-enums.mustache +++ /dev/null @@ -1,19 +0,0 @@ ---- -id: {{#imported}}{{namespace}}_{{/imported}}enums -title: {{#imported}}{{namespace}} {{/imported}}Enum Types -sidebar_position: 3 ---- - - -{{#enumTypes}} -### {{type}} -{{#addReturnsIfText}}{{#markdownItalics}}{{comment}}{{/markdownItalics}}{{/addReturnsIfText}} -```graphql -enum {{type}} { - {{#constants}} - {{.}} - {{/constants}} -} -``` - -{{/enumTypes}} \ No newline at end of file diff --git a/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-env.mustache b/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-env.mustache deleted file mode 100644 index d25872b38c..0000000000 --- a/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-env.mustache +++ /dev/null @@ -1,19 +0,0 @@ ---- -id: {{#imported}}{{namespace}}_{{/imported}}env -title: {{#imported}}{{namespace}} {{/imported}}Env Type -sidebar_position: 4 ---- - - -{{#envType}} -### {{type}} {{#addImplements}}{{#interfaces}} {{name}}{{/interfaces}}{{/addImplements}} -{{#addReturnsIfText}}{{#markdownItalics}}{{comment}}{{/markdownItalics}}{{/addReturnsIfText}} -```graphql -type {{type}} { - {{#properties}} - {{name}}: {{#typeFormatFilter}}{{type}}{{/typeFormatFilter}}{{#required}}!{{/required}} {{#hashtagPrefix}}{{comment}}{{/hashtagPrefix}} - {{/properties}} -} -``` - -{{/envType}} \ No newline at end of file diff --git a/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-module.mustache b/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-module.mustache deleted file mode 100644 index 70419c35b5..0000000000 --- a/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-module.mustache +++ /dev/null @@ -1,18 +0,0 @@ ---- -id: {{#imported}}{{namespace}}_{{/imported}}{{#toLowerCase}}{{type}}{{/toLowerCase}} -title: {{#toTitle}}{{#imported}}{{namespace}} {{/imported}}{{type}}{{/toTitle}} -sidebar_position: 1 ---- - -{{#methods}} -### {{name}} {{#addImplements}}{{#interfaces}} {{name}}{{/interfaces}}{{/addImplements}} -{{#addReturnsIfText}}{{#markdownItalics}}{{comment}}{{/markdownItalics}}{{/addReturnsIfText}} -```graphql -{{name}}( - {{#arguments}} - {{name}}: {{#typeFormatFilter}}{{type}}{{/typeFormatFilter}}{{#required}}!{{/required}} {{#hashtagPrefix}}{{comment}}{{/hashtagPrefix}} - {{/arguments}} -): {{#return}}{{#typeFormatFilter}}{{type}}{{/typeFormatFilter}}{{#required}}!{{/required}}{{/return}} -``` - -{{/methods}} \ No newline at end of file diff --git a/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-objects.mustache b/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-objects.mustache deleted file mode 100644 index 6cd78c2ae7..0000000000 --- a/packages/cli/src/lib/docgen/docusaurus/templates/docusaurus-objects.mustache +++ /dev/null @@ -1,19 +0,0 @@ ---- -id: {{#imported}}{{namespace}}_{{/imported}}objects -title: {{#imported}}{{namespace}} {{/imported}}Object Types -sidebar_position: 2 ---- - - -{{#objectTypes}} -### {{type}} {{#addImplements}}{{#interfaces}} {{name}}{{/interfaces}}{{/addImplements}} -{{#addReturnsIfText}}{{#markdownItalics}}{{comment}}{{/markdownItalics}}{{/addReturnsIfText}} -```graphql -type {{type}} { - {{#properties}} - {{name}}: {{#typeFormatFilter}}{{type}}{{/typeFormatFilter}}{{#required}}!{{/required}} {{#hashtagPrefix}}{{comment}}{{/hashtagPrefix}} - {{/properties}} -} -``` - -{{/objectTypes}} \ No newline at end of file diff --git a/packages/cli/src/lib/docgen/functions.ts b/packages/cli/src/lib/docgen/functions.ts deleted file mode 100644 index 91d7b03f36..0000000000 --- a/packages/cli/src/lib/docgen/functions.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { MustacheFn } from "@polywrap/schema-bind"; - -export const typeFormatFilter: MustacheFn = () => { - return (text: string, render: (template: string) => string): string => { - const rendered: string = render(text); - if (rendered.startsWith("[")) { - return rendered.substring(1, rendered.length - 1) + "[]"; - } - return rendered; - }; -}; - -export const hashtagPrefix: MustacheFn = () => { - return (text: string, render: (template: string) => string): string => { - const rendered: string = render(text); - if (rendered === "") { - return ""; - } - return "# " + rendered; - }; -}; - -export const markdownItalics: MustacheFn = () => { - return (text: string, render: (template: string) => string): string => { - const rendered: string = render(text); - if (rendered === "") { - return ""; - } - return "_" + rendered + "_"; - }; -}; - -export const addReturnsIfText: MustacheFn = () => { - return (text: string, render: (template: string) => string): string => { - const rendered: string = render(text); - if (rendered === "") { - return ""; - } - return "\n" + rendered + "\n"; - }; -}; - -export const toTitle: MustacheFn = () => { - return (text: string, render: (template: string) => string): string => { - const rendered: string = render(text); - const tokens: string[] = rendered.split("_"); - for (let i = 0; i < tokens.length; i++) { - tokens[i] = tokens[i].charAt(0).toUpperCase() + tokens[i].substring(1); - } - return tokens.join(" "); - }; -}; - -export const addImplements: MustacheFn = () => { - return (text: string, render: (template: string) => string): string => { - const rendered: string = render(text); - const trimmed: string = rendered.trim(); - if (!trimmed) { - return ""; - } - const tokens: string[] = trimmed.split(" "); - return "implements " + tokens.join(", "); - }; -}; - -export const addExtends: MustacheFn = () => { - return (text: string, render: (template: string) => string): string => { - const rendered: string = render(text); - const trimmed: string = rendered.trim(); - if (!trimmed) { - return ""; - } - const tokens: string[] = trimmed.split(" "); - return "@extends " + tokens.join(", "); - }; -}; diff --git a/packages/cli/src/lib/docgen/jsdoc/index.ts b/packages/cli/src/lib/docgen/jsdoc/index.ts deleted file mode 100644 index d9d95ce684..0000000000 --- a/packages/cli/src/lib/docgen/jsdoc/index.ts +++ /dev/null @@ -1,188 +0,0 @@ -import * as Functions from "../functions"; -import { - arrangeByNamespace, - sortMethodsInPlaceByName, - sortObjectsInPlaceByType, -} from "../utils"; - -import { - transformAbi, - addFirstLast, - toPrefixedGraphQLType, - extendType, - methodParentPointers, - ImportedDefinition, - ModuleDefinition, - WrapAbi, -} from "@polywrap/schema-parse"; -import { - BindOptions, - BindOutput, - GenerateBindingFn, - TypeScript, -} from "@polywrap/schema-bind"; -import Mustache from "mustache"; -import path from "path"; -import { readFileSync } from "fs"; - -export const scriptPath = path.join(__dirname, "index.js"); - -export const generateBinding: GenerateBindingFn = ( - options: BindOptions -): BindOutput => { - const result: BindOutput = { - output: { - entries: [], - }, - outputDirAbs: options.outputDirAbs, - }; - const output = result.output; - const abi = applyTransforms(options.abi); - sortObjectsInPlaceByType(abi); - sortMethodsInPlaceByName(abi); - - const renderTemplate = ( - subPath: string, - context: unknown, - fileName: string - ) => { - const absPath = path.join(__dirname, subPath); - const template = readFileSync(absPath, { encoding: "utf-8" }); - - output.entries.push({ - type: "File", - name: fileName, - data: Mustache.render(template, context), - }); - }; - - // generate modules - if (abi.moduleType) { - const module: ModuleDefinition = abi.moduleType; - renderTemplate( - "./templates/jsdoc-module.mustache", - module, - `${module.type.toLowerCase()}.js` - ); - } - - // generate object types - if (abi.objectTypes && abi.objectTypes.length > 0) { - renderTemplate("./templates/jsdoc-objects.mustache", abi, "objects.js"); - } - - // generate enum types - if (abi.enumTypes && abi.enumTypes.length > 0) { - renderTemplate("./templates/jsdoc-enums.mustache", abi, "enums.js"); - } - - // generate env type - if (abi.envType) { - const envContext = { - envType: abi.envType, - }; - renderTemplate("./templates/jsdoc-env.mustache", envContext, "env.js"); - } - - if (options.config?.["imports"]) { - // TODO: for imported modules, module.type contains the namespace. Should it? - // generate imported modules - if (abi.importedModuleTypes) { - for (const module of abi.importedModuleTypes) { - const moduleContext = { - ...module, - imported: { namespace: module.namespace }, - }; - renderTemplate( - "./templates/jsdoc-module.mustache", - moduleContext, - `${module.type}.js` - ); - } - } - - // generated imported object types - if (abi.importedObjectTypes) { - const importedObjects = sortByNamespace(abi.importedObjectTypes); - for (const [namespace, objectTypes] of Object.entries(importedObjects)) { - if (objectTypes.length > 0) { - const objectContext = { - objectTypes, - imported: { namespace }, - }; - renderTemplate( - "./templates/jsdoc-objects.mustache", - objectContext, - `${namespace}_objects.js` - ); - } - } - } - - // generate imported enum types - if (abi.importedEnumTypes) { - const importedEnums = sortByNamespace(abi.importedEnumTypes); - for (const [namespace, enumTypes] of Object.entries(importedEnums)) { - if (enumTypes.length > 0) { - const enumContext = { - enumTypes, - imported: { namespace }, - }; - renderTemplate( - "./templates/jsdoc-enums.mustache", - enumContext, - `${namespace}_enums.js` - ); - } - } - } - - // generate imported env types - if (abi.importedEnvTypes) { - const importedEnvs = arrangeByNamespace(abi.importedEnvTypes); - for (const [namespace, envType] of Object.entries(importedEnvs)) { - if (envType) { - const envContext = { - envType, - imported: { namespace }, - }; - renderTemplate( - "./templates/jsdoc-env.mustache", - envContext, - `${namespace}_env.js` - ); - } - } - } - } - - return result; -}; - -function applyTransforms(abi: WrapAbi): WrapAbi { - const transforms = [ - extendType(Functions), - extendType(TypeScript.Functions), - addFirstLast, - toPrefixedGraphQLType, - methodParentPointers(), - ]; - - for (const transform of transforms) { - abi = transformAbi(abi, transform); - } - return abi; -} - -function sortByNamespace( - definitions: Array -): Record> { - const result: Record> = {}; - for (const val of definitions) { - if (!result[val.namespace]) { - result[val.namespace] = new Array(); - } - result[val.namespace].push(val); - } - return result; -} diff --git a/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-enums.mustache b/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-enums.mustache deleted file mode 100644 index 8efd65fac8..0000000000 --- a/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-enums.mustache +++ /dev/null @@ -1,12 +0,0 @@ -/** -* {{#imported}}{{namespace}} {{/imported}}Enum Types -* @module {{#imported}}{{namespace}}_{{/imported}}enums -*/ - -{{#enumTypes}} -/** -* {{comment}} -* @typedef { {{#unionTypeTrim}}{{#constants}}"{{.}}" | {{/constants}}{{/unionTypeTrim}} } module:{{#imported}}{{namespace}}_{{/imported}}enums.{{type}} {{comment}} -*/ - -{{/enumTypes}} \ No newline at end of file diff --git a/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-env.mustache b/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-env.mustache deleted file mode 100644 index 3d39df8f1a..0000000000 --- a/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-env.mustache +++ /dev/null @@ -1,16 +0,0 @@ -/** -* {{#imported}}{{namespace}} {{/imported}}Env Type -* @module {{#imported}}{{namespace}}_{{/imported}}env -*/ - -{{#envType}} -/** -* {{comment}} -* @typedef {Object} module:{{#imported}}{{namespace}}_{{/imported}}objects.{{type}} -* {{#addExtends}}{{#interfaces}} {{name}}{{/interfaces}}{{/addExtends}} -{{#properties}} -* @property { {{#typeFormatFilter}}{{type}}{{/typeFormatFilter}} } {{name}} {{comment}} -{{/properties}} -*/ - -{{/envType}} \ No newline at end of file diff --git a/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-module.mustache b/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-module.mustache deleted file mode 100644 index 7db6635b8a..0000000000 --- a/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-module.mustache +++ /dev/null @@ -1,22 +0,0 @@ -/** -* {{#toTitle}}{{type}}{{/toTitle}} -* @module {{#toLowerCase}}{{type}}{{/toLowerCase}} -* {{#addImplements}}{{#interfaces}} {{name}}{{/interfaces}}{{/addImplements}} -*/ - -{{#methods}} -/** -* {{comment}} -* @function module:{{#toLowerCase}}{{type}}{{/toLowerCase}}.{{name}} -{{#arguments}} - {{#required}} -* @param { {{#typeFormatFilter}}{{type}}{{/typeFormatFilter}} } {{name}} {{comment}} - {{/required}} - {{^required}} -* @param { {{#typeFormatFilter}}{{type}}{{/typeFormatFilter}} | null } {{name}} {{comment}} - {{/required}} -{{/arguments}} -* @returns { {{#return}}{{#typeFormatFilter}}{{type}}{{/typeFormatFilter}}{{/return}} } -*/ - -{{/methods}} \ No newline at end of file diff --git a/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-objects.mustache b/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-objects.mustache deleted file mode 100644 index 91411cb1b8..0000000000 --- a/packages/cli/src/lib/docgen/jsdoc/templates/jsdoc-objects.mustache +++ /dev/null @@ -1,16 +0,0 @@ -/** -* {{#imported}}{{namespace}} {{/imported}}Object Types -* @module {{#imported}}{{namespace}}_{{/imported}}objects -*/ - -{{#objectTypes}} -/** -* {{comment}} -* @typedef {Object} module:{{#imported}}{{namespace}}_{{/imported}}objects.{{type}} -* {{#addExtends}}{{#interfaces}} {{name}}{{/interfaces}}{{/addExtends}} -{{#properties}} -* @property { {{#typeFormatFilter}}{{type}}{{/typeFormatFilter}} } {{name}} {{comment}} -{{/properties}} -*/ - -{{/objectTypes}} \ No newline at end of file diff --git a/packages/cli/src/lib/docgen/schema/index.ts b/packages/cli/src/lib/docgen/schema/index.ts deleted file mode 100644 index 0f85d1254d..0000000000 --- a/packages/cli/src/lib/docgen/schema/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { - BindOptions, - BindOutput, - GenerateBindingFn, -} from "@polywrap/schema-bind"; -import Mustache from "mustache"; -import path from "path"; -import { readFileSync } from "fs"; -import { renderSchema } from "@polywrap/schema-compose"; - -export const scriptPath = path.join(__dirname, "index.js"); - -export const generateBinding: GenerateBindingFn = ( - options: BindOptions -): BindOutput => { - const result: BindOutput = { - output: { - entries: [], - }, - outputDirAbs: options.outputDirAbs, - }; - const output = result.output; - - const renderTemplate = ( - subPath: string, - context: unknown, - fileName: string - ) => { - const absPath = path.join(__dirname, subPath); - const template = readFileSync(absPath, { encoding: "utf-8" }); - - output.entries.push({ - type: "File", - name: fileName, - data: Mustache.render(template, context), - }); - }; - - // generate schema - const schemaContext = { - schema: renderSchema(options.abi, true), - }; - renderTemplate( - "./templates/schema.mustache", - schemaContext, - "generated-schema.graphql" - ); - - return result; -}; diff --git a/packages/cli/src/lib/docgen/schema/templates/schema.mustache b/packages/cli/src/lib/docgen/schema/templates/schema.mustache deleted file mode 100644 index 45b42444e3..0000000000 --- a/packages/cli/src/lib/docgen/schema/templates/schema.mustache +++ /dev/null @@ -1 +0,0 @@ -{{schema}} diff --git a/packages/cli/src/lib/docgen/utils.ts b/packages/cli/src/lib/docgen/utils.ts deleted file mode 100644 index e41b84045e..0000000000 --- a/packages/cli/src/lib/docgen/utils.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - ImportedDefinition, - MethodDefinition, - Abi, - GenericDefinition, -} from "@polywrap/schema-parse"; - -export function arrangeByNamespace( - definitions: Array -): Record> { - const result: Record> = {}; - for (const val of definitions) { - if (!result[val.namespace]) { - result[val.namespace] = new Array(); - } - result[val.namespace].push(val); - } - return result; -} - -export function sortObjectsInPlaceByType(abi: Abi): void { - const typesToSort: (GenericDefinition[] | undefined)[] = [ - abi.objectTypes, - abi.enumTypes, - abi.importedObjectTypes, - abi.importedEnumTypes, - ]; - for (const definitions of typesToSort) { - if (definitions) { - definitions.sort((a: { type: string }, b: { type: string }) => - a.type.localeCompare(b.type) - ); - } - } -} - -export function sortMethodsInPlaceByName(abi: Abi): void { - const methodsToSort: MethodDefinition[][] = []; - if (abi.moduleType && abi.moduleType.methods) { - methodsToSort.push(abi.moduleType.methods); - } - if (abi.importedModuleTypes) { - for (const moduleType of abi.importedModuleTypes) { - if (moduleType.methods) { - methodsToSort.push(moduleType.methods); - } - } - } - - for (const definitions of methodsToSort) { - definitions.sort((a: MethodDefinition, b: MethodDefinition) => { - if (!a.name || !b.name) return 0; - return a.name.localeCompare(b.name); - }); - } -} diff --git a/packages/cli/src/lib/option-defaults/defaultManifestFiles.ts b/packages/cli/src/lib/option-defaults/defaultManifestFiles.ts index d27d42ed40..863bd333af 100644 --- a/packages/cli/src/lib/option-defaults/defaultManifestFiles.ts +++ b/packages/cli/src/lib/option-defaults/defaultManifestFiles.ts @@ -1,14 +1,14 @@ import { defaultAppManifest, defaultPluginManifest, - defaultPolywrapManifest, + defaultPolywrapManifestFiles, } from "../project"; const filterUniqueFn = (value: string, index: number, self: Array) => self.indexOf(value) === index; export const defaultProjectManifestFiles = [ - ...defaultPolywrapManifest, + ...defaultPolywrapManifestFiles, ...defaultAppManifest, ...defaultPluginManifest, ].filter(filterUniqueFn); diff --git a/packages/cli/src/lib/option-parsers/client-config.ts b/packages/cli/src/lib/option-parsers/client-config.ts index 6d57d580e8..3cec63fc1e 100644 --- a/packages/cli/src/lib/option-parsers/client-config.ts +++ b/packages/cli/src/lib/option-parsers/client-config.ts @@ -2,21 +2,16 @@ import { intlMsg } from "../intl"; import { importTypescriptModule } from "../system"; import { getTestEnvClientConfig } from "../test-env"; -import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { PolywrapClientConfigBuilder } from "@polywrap/client-config-builder-js"; import path from "path"; -import { IClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; export async function parseClientConfigOption( clientConfig: string | undefined | false -): Promise { - const builder = new ClientConfigBuilder().addDefaults(); +): Promise { + const builder = new PolywrapClientConfigBuilder().addDefaults(); - try { - builder.add(getTestEnvClientConfig()); - } catch (e) { - console.error(intlMsg.commands_test_error_noTestEnvFound()); - process.exit(1); - } + builder.add(getTestEnvClientConfig()); if (clientConfig) { let configModule; diff --git a/packages/cli/src/lib/option-parsers/uri.ts b/packages/cli/src/lib/option-parsers/uri.ts new file mode 100644 index 0000000000..2986d34d4a --- /dev/null +++ b/packages/cli/src/lib/option-parsers/uri.ts @@ -0,0 +1,17 @@ +import { intlMsg } from "../intl"; + +import { Uri } from "@polywrap/core-js"; + +export function parseUriOption( + uri: string | undefined | false +): Uri | undefined { + if (uri) { + try { + return Uri.from(uri); + } catch { + console.error(intlMsg.commands_codegen_invalid_uri({ uri })); + process.exit(1); + } + } + return undefined; +} diff --git a/packages/cli/src/lib/option-parsers/wrapper-envs.ts b/packages/cli/src/lib/option-parsers/wrapper-envs.ts index a386087c63..d34f1416b3 100644 --- a/packages/cli/src/lib/option-parsers/wrapper-envs.ts +++ b/packages/cli/src/lib/option-parsers/wrapper-envs.ts @@ -1,6 +1,6 @@ import { loadEnvironmentVariables } from "../system"; -import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { PolywrapClientConfigBuilder } from "@polywrap/client-config-builder-js"; import fs from "fs"; import YAML from "yaml"; @@ -34,7 +34,7 @@ export async function parseWrapperEnvsOption( Record >; - const builder = new ClientConfigBuilder(); + const builder = new PolywrapClientConfigBuilder(); for (const env in wrapperEnvs) { builder.addEnv(env, wrapperEnvs[env]); diff --git a/packages/cli/src/lib/project/AppProject.ts b/packages/cli/src/lib/project/AppProject.ts index a57de16759..1e6dd30efe 100644 --- a/packages/cli/src/lib/project/AppProject.ts +++ b/packages/cli/src/lib/project/AppProject.ts @@ -8,9 +8,17 @@ import { } from "./manifests"; import { AppManifest } from "@polywrap/polywrap-manifest-types-js"; -import { bindSchema, BindOutput } from "@polywrap/schema-bind"; +import { + bindSchema, + BindOutput, + BindOptions, + bindLanguageToWrapInfoType, +} from "@polywrap/schema-bind"; import path from "path"; -import { WrapAbi } from "@polywrap/wrap-manifest-types-js"; +import { + latestWrapManifestVersion, + WrapAbi, +} from "@polywrap/wrap-manifest-types-js"; export interface AppProjectConfig extends ProjectConfig { appManifestPath: string; @@ -105,16 +113,23 @@ export class AppProject extends Project { public async generateSchemaBindings( abi: WrapAbi, - generationSubPath?: string + generationSubPath?: string, + bindgenUri?: string ): Promise { - return bindSchema({ - projectName: await this.getName(), - abi, + const bindLanguage = appManifestLanguageToBindLanguage( + await this.getManifestLanguage() + ); + const options: BindOptions = { + bindLanguage, + wrapInfo: { + version: latestWrapManifestVersion, + name: await this.getName(), + type: bindLanguageToWrapInfoType(bindLanguage), + abi, + }, outputDirAbs: await this.getGenerationDirectory(generationSubPath), - bindLanguage: appManifestLanguageToBindLanguage( - await this.getManifestLanguage() - ), - }); + }; + return bindSchema(options, bindgenUri); } private _getGenerationDirectory( diff --git a/packages/cli/src/lib/project/PluginProject.ts b/packages/cli/src/lib/project/PluginProject.ts index d8b9f9f189..583f5d9046 100644 --- a/packages/cli/src/lib/project/PluginProject.ts +++ b/packages/cli/src/lib/project/PluginProject.ts @@ -10,9 +10,15 @@ import { import { resetDir } from "../system"; import { PluginManifest } from "@polywrap/polywrap-manifest-types-js"; -import { bindSchema, BindOutput, BindOptions } from "@polywrap/schema-bind"; +import { + bindSchema, + BindOutput, + BindOptions, + bindLanguageToWrapInfoType, +} from "@polywrap/schema-bind"; import { WrapAbi } from "@polywrap/schema-parse"; import path from "path"; +import { latestWrapManifestVersion } from "@polywrap/wrap-manifest-types-js"; export interface PluginProjectConfig extends ProjectConfig { pluginManifestPath: string; @@ -111,27 +117,32 @@ export class PluginProject extends Project { public async generateSchemaBindings( abi: WrapAbi, - generationSubPath?: string + generationSubPath?: string, + bindgenUri?: string ): Promise { - const manifest = await this.getManifest(); const moduleDirectory = await this.getGenerationDirectory( generationSubPath ); // Clean the code generation resetDir(moduleDirectory); + const bindLanguage = pluginManifestLanguageToBindLanguage( await this.getManifestLanguage() ); const options: BindOptions = { - projectName: manifest.project.name, - abi, - outputDirAbs: moduleDirectory, bindLanguage, + wrapInfo: { + version: latestWrapManifestVersion, + name: await this.getName(), + type: bindLanguageToWrapInfoType(bindLanguage), + abi, + }, + outputDirAbs: moduleDirectory, }; - return bindSchema(options); + return bindSchema(options, bindgenUri); } private _getGenerationDirectory( diff --git a/packages/cli/src/lib/project/PolywrapProject.ts b/packages/cli/src/lib/project/PolywrapProject.ts index 465a6fc2d3..a15688aa8e 100644 --- a/packages/cli/src/lib/project/PolywrapProject.ts +++ b/packages/cli/src/lib/project/PolywrapProject.ts @@ -19,12 +19,18 @@ import { PolywrapManifest, } from "@polywrap/polywrap-manifest-types-js"; import { normalizePath } from "@polywrap/os-js"; -import { BindOptions, BindOutput, bindSchema } from "@polywrap/schema-bind"; +import { + bindLanguageToWrapInfoType, + BindOptions, + BindOutput, + bindSchema, +} from "@polywrap/schema-bind"; import { WrapAbi } from "@polywrap/schema-parse"; import regexParser from "regex-parser"; import path from "path"; import fs from "fs"; import fsExtra from "fs-extra"; +import { latestWrapManifestVersion } from "@polywrap/wrap-manifest-types-js"; export interface PolywrapProjectConfig extends ProjectConfig { polywrapManifestPath: string; @@ -146,9 +152,10 @@ export class PolywrapProject extends Project { public async generateSchemaBindings( abi: WrapAbi, - generationSubPath?: string + generationSubPath?: string, + bindgenUri?: string, + bindConfig?: Record ): Promise { - const manifest = await this.getManifest(); const codegenDirectory = await this.getGenerationDirectory( generationSubPath ); @@ -161,13 +168,18 @@ export class PolywrapProject extends Project { ); const options: BindOptions = { - projectName: manifest.project.name, - abi, - outputDirAbs: codegenDirectory, bindLanguage, + wrapInfo: { + version: latestWrapManifestVersion, + name: await this.getName(), + type: bindLanguageToWrapInfoType(bindLanguage), + abi, + }, + outputDirAbs: codegenDirectory, + config: bindConfig, }; - return bindSchema(options); + return bindSchema(options, bindgenUri); } /// Polywrap Build Manifest (polywrap.build.yaml) diff --git a/packages/cli/src/lib/project/Project.ts b/packages/cli/src/lib/project/Project.ts index 75a6a945a6..8fc8903153 100644 --- a/packages/cli/src/lib/project/Project.ts +++ b/packages/cli/src/lib/project/Project.ts @@ -72,7 +72,9 @@ export abstract class Project { public abstract generateSchemaBindings( abi: Abi, - generationSubPath?: string + generationSubPath?: string, + bindgenUri?: string, + bindConfig?: Record ): Promise; public get logger(): Logger { diff --git a/packages/cli/src/lib/project/manifests/plugin/languages.ts b/packages/cli/src/lib/project/manifests/plugin/languages.ts index 72811e9c62..36218b5bb7 100644 --- a/packages/cli/src/lib/project/manifests/plugin/languages.ts +++ b/packages/cli/src/lib/project/manifests/plugin/languages.ts @@ -6,6 +6,8 @@ export const pluginManifestLanguages = { "plugin/typescript": "plugin/typescript", "plugin/rust": "plugin/rust", "plugin/python": "plugin/python", + "plugin/kotlin": "plugin/kotlin", + "plugin/swift": "plugin/swift", }; export type PluginManifestLanguages = typeof pluginManifestLanguages; @@ -28,6 +30,10 @@ export function pluginManifestLanguageToBindLanguage( return "plugin-rs"; case "plugin/python": return "plugin-py"; + case "plugin/kotlin": + return "plugin-kt"; + case "plugin/swift": + return "plugin-swift"; default: throw Error( intlMsg.lib_language_unsupportedManifestLanguage({ diff --git a/packages/cli/src/lib/project/manifests/polywrap/languages.ts b/packages/cli/src/lib/project/manifests/polywrap/languages.ts index d12c067c01..055aa479cc 100644 --- a/packages/cli/src/lib/project/manifests/polywrap/languages.ts +++ b/packages/cli/src/lib/project/manifests/polywrap/languages.ts @@ -5,6 +5,7 @@ import { BindLanguage } from "@polywrap/schema-bind"; export const polywrapManifestLanguages = { "wasm/assemblyscript": "wasm/assemblyscript", "wasm/rust": "wasm/rust", + "wasm/golang": "wasm/golang", interface: "interface", }; @@ -23,9 +24,11 @@ export function polywrapManifestLanguageToBindLanguage( ): BindLanguage { switch (manifestLanguage) { case "wasm/assemblyscript": - return "wasm-as"; + return "wrap-as"; case "wasm/rust": - return "wasm-rs"; + return "wrap-rs"; + case "wasm/golang": + return "wrap-go"; case "interface": throw Error(intlMsg.lib_language_noInterfaceCodegen()); default: @@ -48,6 +51,8 @@ export function polywrapManifestOverrideCodegenDir( // the codegen directory to be `./src/wrap` case "wasm/rust": return "./src/wrap"; + case "wasm/golang": + return "./module/wrap"; default: return undefined; } diff --git a/packages/cli/src/lib/project/manifests/polywrap/load.ts b/packages/cli/src/lib/project/manifests/polywrap/load.ts index 97d5f3cd9a..eaf18b2db2 100644 --- a/packages/cli/src/lib/project/manifests/polywrap/load.ts +++ b/packages/cli/src/lib/project/manifests/polywrap/load.ts @@ -25,7 +25,7 @@ import { Schema as JsonSchema } from "jsonschema"; import path from "path"; import fs from "fs"; -export const defaultPolywrapManifest = ["polywrap.yaml", "polywrap.yml"]; +export const defaultPolywrapManifestFiles = ["polywrap.yaml", "polywrap.yml"]; export async function loadPolywrapManifest( manifestPath: string, @@ -61,7 +61,7 @@ export async function loadPolywrapManifest( ); } -export const defaultBuildManifest = [ +export const defaultBuildManifestFiles = [ "polywrap.build.yaml", "polywrap.build.yml", ]; @@ -118,19 +118,51 @@ export async function loadBuildManifest( ); } -export const defaultDeployManifest = [ +export const defaultDeployManifestFiles = [ "polywrap.deploy.yaml", "polywrap.deploy.yml", ]; +export const defaultDeployManifest: DeployManifest = { + format: "0.4.0", + jobs: { + // eslint-disable-next-line @typescript-eslint/naming-convention + ipfs_deploy: { + steps: [ + { + name: "deploy to ipfs.wrappers.io", + package: "ipfs", + uri: "file/./build", + config: { + gatewayUri: "https://ipfs.wrappers.io", + }, + }, + ], + }, + }, + // eslint-disable-next-line @typescript-eslint/naming-convention + __type: "DeployManifest", +}; + export async function loadDeployManifest( manifestPath: string, logger: Logger ): Promise { const run = (): Promise => { - const manifest = fs.readFileSync(manifestPath, "utf-8"); + let manifest: string; + try { + manifest = fs.readFileSync(manifestPath, "utf-8"); + } catch { + // If the manifest wasn't found, and it was a default path, + // assume we should fallback to a default manifest. + if ( + defaultDeployManifestFiles + .map((x) => displayPath(x)) + .includes(manifestPath) + ) { + return Promise.resolve(defaultDeployManifest); + } - if (!manifest) { const noLoadMessage = intlMsg.lib_helpers_manifest_unableToLoad({ path: `${manifestPath}`, }); @@ -197,7 +229,7 @@ export async function loadDeployManifestExt( ); } -export const defaultInfraManifest = [ +export const defaultInfraManifestFiles = [ "polywrap.infra.yaml", "polywrap.infra.yml", ]; @@ -239,7 +271,7 @@ export async function loadInfraManifest( ); } -export const defaultWorkflowManifest = [ +export const defaultWorkflowManifestFiles = [ "polywrap.test.yaml", "polywrap.test.yml", ]; diff --git a/packages/cli/src/lib/test-env/client-config.ts b/packages/cli/src/lib/test-env/client-config.ts index a9f719f6ef..7b5f67312d 100644 --- a/packages/cli/src/lib/test-env/client-config.ts +++ b/packages/cli/src/lib/test-env/client-config.ts @@ -3,14 +3,17 @@ import { ETH_ENS_IPFS_MODULE_CONSTANTS } from "../../lib"; import { BuilderConfig, - DefaultBundle, + PolywrapClientConfigBuilder, } from "@polywrap/client-config-builder-js"; +import * as Web3 from "@polywrap/web3-config-bundle-js"; +import * as Sys from "@polywrap/sys-config-bundle-js"; import { ExtendableUriResolver } from "@polywrap/uri-resolver-extensions-js"; import { - ethereumProviderPlugin, + ethereumWalletPlugin, Connections, Connection, -} from "@polywrap/ethereum-provider-js-v1"; +} from "@polywrap/ethereum-wallet-js"; +import { IWrapPackage } from "@polywrap/core-js"; export function getTestEnvClientConfig(): Partial { // TODO: move this into its own package, since it's being used everywhere? @@ -24,25 +27,24 @@ export function getTestEnvClientConfig(): Partial { } const ensAddress = ETH_ENS_IPFS_MODULE_CONSTANTS.ensAddresses.ensAddress; + const testnetEnsResolverUri = "proxy/testnet-ens-contenthash-uri-resolver"; - return { - envs: { - [DefaultBundle.embeds.ipfsResolver.uri.uri]: { + const builder = new PolywrapClientConfigBuilder() + .addDefaults() + .addEnvs({ + [Sys.bundle.ipfsResolver.uri]: { provider: ipfsProvider, - fallbackProviders: DefaultBundle.ipfsProviders, retries: { tryResolveUri: 1, getFile: 1 }, }, - "proxy/testnet-ens-uri-resolver-ext": { + [testnetEnsResolverUri]: { registryAddress: ensAddress, }, - }, - redirects: { - "proxy/testnet-ens-uri-resolver-ext": - "ens/wraps.eth:ens-uri-resolver-ext@1.0.1", - }, - packages: { - [DefaultBundle.plugins.ethereumProviderV1.uri - .uri]: ethereumProviderPlugin({ + }) + .setRedirects({ + [testnetEnsResolverUri]: Web3.bundle.ensContenthashResolver.uri, + }) + .setPackages({ + [Web3.bundle.ethereumWallet.uri]: ethereumWalletPlugin({ connections: new Connections({ networks: { testnet: new Connection({ @@ -58,15 +60,18 @@ export function getTestEnvClientConfig(): Partial { }), }, }), - }), - }, - interfaces: { - [ExtendableUriResolver.defaultExtInterfaceUris[0].uri]: new Set([ - "proxy/testnet-ens-uri-resolver-ext", - ...DefaultBundle.getConfig().interfaces[ - ExtendableUriResolver.defaultExtInterfaceUris[0].uri - ], - ]), - }, - }; + }) as IWrapPackage, + }); + + const resolverExtensions = + builder.config.interfaces[ + ExtendableUriResolver.defaultExtInterfaceUris[0].uri + ]; + + builder.addInterfaceImplementations( + ExtendableUriResolver.defaultExtInterfaceUris[0].uri, + [testnetEnsResolverUri, ...resolverExtensions] + ); + + return builder.config; } diff --git a/packages/cli/src/lib/workflow/JobRunner.ts b/packages/cli/src/lib/workflow/JobRunner.ts index e16a8d1c05..67e73275ee 100644 --- a/packages/cli/src/lib/workflow/JobRunner.ts +++ b/packages/cli/src/lib/workflow/JobRunner.ts @@ -1,6 +1,6 @@ import { JobResult, Status, Step } from "./types"; -import { IClientConfigBuilder, PolywrapClient } from "@polywrap/client-js"; +import { ClientConfigBuilder, PolywrapClient } from "@polywrap/client-js"; import { CoreClient, MaybeAsync, Uri } from "@polywrap/core-js"; import { WorkflowJobs } from "@polywrap/polywrap-manifest-types-js"; @@ -9,7 +9,7 @@ export class JobRunner { private _client: CoreClient; constructor( - private _configBuilder: IClientConfigBuilder, + private _configBuilder: ClientConfigBuilder, private _onExecution?: ( id: string, JobResult: JobResult diff --git a/packages/js/cli/package.json b/packages/js/cli/package.json index e3ac07a0fd..f2457ab079 100644 --- a/packages/js/cli/package.json +++ b/packages/js/cli/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/cli-js", "description": "Programmatically execute the Polywrap CLI", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", @@ -17,7 +17,7 @@ "test": "jest --passWithNoTests --runInBand --detectOpenHandles --verbose" }, "dependencies": { - "polywrap": "0.10.6", + "polywrap": "0.11.0-pre.4", "spawn-command": "0.0.2-1" }, "devDependencies": { diff --git a/packages/js/cli/src/__tests__/commands.spec.ts b/packages/js/cli/src/__tests__/commands.spec.ts index 93eab7113f..fbe5c0d2c0 100644 --- a/packages/js/cli/src/__tests__/commands.spec.ts +++ b/packages/js/cli/src/__tests__/commands.spec.ts @@ -148,17 +148,13 @@ const testData: CommandTestCaseData = { env: { PATH: process.env.PATH || "", IPFS_GATEWAY_URI: ETH_ENS_IPFS_MODULE_CONSTANTS.ipfsProvider, - DOMAIN_NAME: "test1.eth", - ENS_REG_ADDR: ETH_ENS_IPFS_MODULE_CONSTANTS.ensAddresses.ensAddress, - ENS_REGISTRAR_ADDR: ETH_ENS_IPFS_MODULE_CONSTANTS.ensAddresses.registrarAddress, - ENS_RESOLVER_ADDR: ETH_ENS_IPFS_MODULE_CONSTANTS.ensAddresses.resolverAddress, }, before: async () => { await Commands.infra("down", { modules: ["eth-ens-ipfs"]}); await Commands.infra("up", { modules: ["eth-ens-ipfs"]}); // Wait a little longer just in case - await new Promise((resolve) => setTimeout(resolve, 3000)); + await new Promise((resolve) => setTimeout(resolve, 15000)); }, after: async (_, stdout) => { expect(stdout).toContain( @@ -167,13 +163,6 @@ const testData: CommandTestCaseData = { await Commands.infra("down", { modules: ["eth-ens-ipfs"]}); } }], - docgen: [{ - cwd: path.join(GetPathToCliTestFiles(), "docgen", "001-sanity"), - arguments: ["docusaurus"], - after: (_, stdout) => { - expect(stdout).toContain("Docs were generated successfully"); - } - }], infra: [{ cwd: path.join(GetPathToCliTestFiles(), "infra/001-sanity"), env: { diff --git a/packages/js/cli/src/commands/index.ts b/packages/js/cli/src/commands/index.ts index 131504f557..d7511a7fb9 100644 --- a/packages/js/cli/src/commands/index.ts +++ b/packages/js/cli/src/commands/index.ts @@ -43,7 +43,6 @@ export const commands: CommandFns = { ), }, deploy: execCommandFn("deploy"), - docgen: execCommandWithArgsFn("docgen"), infra: execCommandWithArgsFn("infra"), manifest: { migrate: execCommandWithArgsFn( diff --git a/packages/js/logging/package.json b/packages/js/logging/package.json index 33394d78e0..a8cc296c26 100644 --- a/packages/js/logging/package.json +++ b/packages/js/logging/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/logging-js", "description": "Polywrap Core Logging Interface", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", diff --git a/packages/js/manifests/polywrap/package.json b/packages/js/manifests/polywrap/package.json index f286c7f7be..ecd21410b6 100644 --- a/packages/js/manifests/polywrap/package.json +++ b/packages/js/manifests/polywrap/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/polywrap-manifest-types-js", "description": "Polywrap Manifest TypeScript Typings", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", @@ -15,14 +15,14 @@ "test:watch": "yarn test -- --watch" }, "dependencies": { - "@polywrap/logging-js": "0.10.6", - "@polywrap/polywrap-manifest-schemas": "0.10.6", + "@polywrap/logging-js": "0.11.0-pre.4", + "@polywrap/polywrap-manifest-schemas": "0.11.0-pre.4", "jsonschema": "1.4.0", "semver": "7.5.3", "yaml": "2.2.2" }, "devDependencies": { - "@polywrap/os-js": "0.10.6", + "@polywrap/os-js": "0.11.0-pre.4", "@types/jest": "26.0.8", "@types/mustache": "4.0.1", "@types/prettier": "2.6.0", diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.app/0.4.0.ts b/packages/js/manifests/polywrap/src/formats/polywrap.app/0.4.0.ts new file mode 100644 index 0000000000..630c988b5c --- /dev/null +++ b/packages/js/manifests/polywrap/src/formats/polywrap.app/0.4.0.ts @@ -0,0 +1,51 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +/* tslint:disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export interface AppManifest { + /** + * Polywrap manifest format version. + */ + format: "0.4.0"; + /** + * Basic project properties. + */ + project: { + /** + * Name of this project. + */ + name: string; + /** + * Type of this project. + */ + type: string; + }; + /** + * Project source files. + */ + source: { + /** + * Path to the project's graphql schema. + */ + schema: string; + /** + * Specify ABIs to be used for the import URIs within your schema. + */ + import_abis?: ImportAbis[]; + }; + __type: "AppManifest"; +} +export interface ImportAbis { + /** + * One of the schema's import URI. + */ + uri: string; + /** + * Path to a local ABI (or schema). Supported file formats: [*.graphql, *.info, *.json, *.yaml] + */ + abi: string; +} diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.app/index.ts b/packages/js/manifests/polywrap/src/formats/polywrap.app/index.ts index 913db8c0c1..fbcbcca317 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.app/index.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.app/index.ts @@ -14,11 +14,15 @@ import { import { AppManifest as AppManifest_0_3_0, } from "./0.3.0"; +import { + AppManifest as AppManifest_0_4_0, +} from "./0.4.0"; export { AppManifest_0_1_0, AppManifest_0_2_0, AppManifest_0_3_0, + AppManifest_0_4_0, }; export enum AppManifestFormats { @@ -27,6 +31,7 @@ export enum AppManifestFormats { "v0.1.0" = "0.1.0", "v0.2.0" = "0.2.0", "v0.3.0" = "0.3.0", + "v0.4.0" = "0.4.0", } export const AppManifestSchemaFiles: Record = { @@ -35,17 +40,19 @@ export const AppManifestSchemaFiles: Record = { "0.1.0": "formats/polywrap.app/0.1.0.json", "0.2.0": "formats/polywrap.app/0.2.0.json", "0.3.0": "formats/polywrap.app/0.3.0.json", + "0.4.0": "formats/polywrap.app/0.4.0.json", } export type AnyAppManifest = | AppManifest_0_1_0 | AppManifest_0_2_0 | AppManifest_0_3_0 + | AppManifest_0_4_0 -export type AppManifest = AppManifest_0_3_0; +export type AppManifest = AppManifest_0_4_0; -export const latestAppManifestFormat = AppManifestFormats["v0.3.0"] +export const latestAppManifestFormat = AppManifestFormats["v0.4.0"] export { migrateAppManifest } from "./migrate"; diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.app/migrators/0.3.0_to_0.4.0.ts b/packages/js/manifests/polywrap/src/formats/polywrap.app/migrators/0.3.0_to_0.4.0.ts new file mode 100644 index 0000000000..9441c764c6 --- /dev/null +++ b/packages/js/manifests/polywrap/src/formats/polywrap.app/migrators/0.3.0_to_0.4.0.ts @@ -0,0 +1,9 @@ +import { AppManifest as OldManifest } from "../0.3.0"; +import { AppManifest as NewManifest } from "../0.4.0"; + +export function migrate(migrate: OldManifest): NewManifest { + return { + ...migrate, + format: "0.4.0", + }; +} diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.app/migrators/index.ts b/packages/js/manifests/polywrap/src/formats/polywrap.app/migrators/index.ts index 02204ed348..cc377561c0 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.app/migrators/index.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.app/migrators/index.ts @@ -1,6 +1,7 @@ import { Migrator } from "../../../migrations"; import { migrate as migrate_0_1_0_to_0_2_0 } from "./0.1.0_to_0.2.0"; import { migrate as migrate_0_2_0_to_0_3_0 } from "./0.2.0_to_0.3.0"; +import { migrate as migrate_0_3_0_to_0_4_0 } from "./0.3.0_to_0.4.0"; export const migrators: Migrator[] = [ { @@ -18,4 +19,9 @@ export const migrators: Migrator[] = [ to: "0.3.0", migrate: migrate_0_2_0_to_0_3_0, }, + { + from: "0.3.0", + to: "0.4.0", + migrate: migrate_0_3_0_to_0_4_0, + }, ]; diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.app/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap.app/validate.ts index b53e83e4fe..b787856ce3 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.app/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.app/validate.ts @@ -12,6 +12,7 @@ import { import AppManifestSchema_0_1_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.app/0.1.0.json"; import AppManifestSchema_0_2_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.app/0.2.0.json"; import AppManifestSchema_0_3_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.app/0.3.0.json"; +import AppManifestSchema_0_4_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.app/0.4.0.json"; import { Schema, @@ -30,6 +31,7 @@ const schemas: AppManifestSchemas = { "0.1.0": AppManifestSchema_0_1_0, "0.2.0": AppManifestSchema_0_2_0, "0.3.0": AppManifestSchema_0_3_0, + "0.4.0": AppManifestSchema_0_4_0, }; const validator = new Validator(); diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/0.4.0.ts b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/0.4.0.ts new file mode 100644 index 0000000000..a60efb5cb6 --- /dev/null +++ b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/0.4.0.ts @@ -0,0 +1,61 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +/* tslint:disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export interface DeployManifest { + /** + * Polywrap deployment manifest format version. + */ + format: "0.4.0"; + /** + * Name of the job that runs the primary deployment sequence. + */ + primaryJobName?: string; + /** + * Sequences of deployment steps + */ + jobs: { + [k: string]: Job; + }; + __type: "DeployManifest"; +} +/** + * This interface was referenced by `undefined`'s JSON-Schema definition + * via the `patternProperty` "^.*$". + */ +export interface Job { + /** + * Deployment steps + */ + steps: Step[]; + /** + * Sequence-level custom configuration. + */ + config?: { + [k: string]: unknown; + }; +} +export interface Step { + /** + * Name of the step + */ + name: string; + /** + * Name of the deployer package. + */ + package: string; + /** + * Step-level custom configuration. + */ + config?: { + [k: string]: unknown; + }; + /** + * URI or name of other step prefixed with '$$' to pass into the deploy step. + */ + uri: string; +} diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/index.ts b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/index.ts index d5035950b6..19d98dfd90 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/index.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/index.ts @@ -14,11 +14,15 @@ import { import { DeployManifest as DeployManifest_0_3_0, } from "./0.3.0"; +import { + DeployManifest as DeployManifest_0_4_0, +} from "./0.4.0"; export { DeployManifest_0_1_0, DeployManifest_0_2_0, DeployManifest_0_3_0, + DeployManifest_0_4_0, }; export enum DeployManifestFormats { @@ -27,6 +31,7 @@ export enum DeployManifestFormats { "v0.1.0" = "0.1.0", "v0.2.0" = "0.2.0", "v0.3.0" = "0.3.0", + "v0.4.0" = "0.4.0", } export const DeployManifestSchemaFiles: Record = { @@ -35,17 +40,19 @@ export const DeployManifestSchemaFiles: Record = { "0.1.0": "formats/polywrap.deploy/0.1.0.json", "0.2.0": "formats/polywrap.deploy/0.2.0.json", "0.3.0": "formats/polywrap.deploy/0.3.0.json", + "0.4.0": "formats/polywrap.deploy/0.4.0.json", } export type AnyDeployManifest = | DeployManifest_0_1_0 | DeployManifest_0_2_0 | DeployManifest_0_3_0 + | DeployManifest_0_4_0 -export type DeployManifest = DeployManifest_0_3_0; +export type DeployManifest = DeployManifest_0_4_0; -export const latestDeployManifestFormat = DeployManifestFormats["v0.3.0"] +export const latestDeployManifestFormat = DeployManifestFormats["v0.4.0"] export { migrateDeployManifest } from "./migrate"; diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/migrators/0.3.0_to_0.4.0.ts b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/migrators/0.3.0_to_0.4.0.ts new file mode 100644 index 0000000000..082cb17d67 --- /dev/null +++ b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/migrators/0.3.0_to_0.4.0.ts @@ -0,0 +1,9 @@ +import { DeployManifest as OldManifest } from "../0.3.0"; +import { DeployManifest as NewManifest } from "../0.4.0"; + +export function migrate(old: OldManifest): NewManifest { + return { + ...old, + format: "0.4.0", + }; +} diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/migrators/index.ts b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/migrators/index.ts index 02204ed348..cc377561c0 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/migrators/index.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/migrators/index.ts @@ -1,6 +1,7 @@ import { Migrator } from "../../../migrations"; import { migrate as migrate_0_1_0_to_0_2_0 } from "./0.1.0_to_0.2.0"; import { migrate as migrate_0_2_0_to_0_3_0 } from "./0.2.0_to_0.3.0"; +import { migrate as migrate_0_3_0_to_0_4_0 } from "./0.3.0_to_0.4.0"; export const migrators: Migrator[] = [ { @@ -18,4 +19,9 @@ export const migrators: Migrator[] = [ to: "0.3.0", migrate: migrate_0_2_0_to_0_3_0, }, + { + from: "0.3.0", + to: "0.4.0", + migrate: migrate_0_3_0_to_0_4_0, + }, ]; diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/validate.ts index c11ee85e49..05ca7075a2 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.deploy/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.deploy/validate.ts @@ -12,6 +12,7 @@ import { import DeployManifestSchema_0_1_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.deploy/0.1.0.json"; import DeployManifestSchema_0_2_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.deploy/0.2.0.json"; import DeployManifestSchema_0_3_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.deploy/0.3.0.json"; +import DeployManifestSchema_0_4_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.deploy/0.4.0.json"; import { Schema, @@ -30,6 +31,7 @@ const schemas: DeployManifestSchemas = { "0.1.0": DeployManifestSchema_0_1_0, "0.2.0": DeployManifestSchema_0_2_0, "0.3.0": DeployManifestSchema_0_3_0, + "0.4.0": DeployManifestSchema_0_4_0, }; const validator = new Validator(); diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/0.4.0.ts b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/0.4.0.ts new file mode 100644 index 0000000000..e2b42898d4 --- /dev/null +++ b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/0.4.0.ts @@ -0,0 +1,55 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +/* tslint:disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export interface PluginManifest { + /** + * Polywrap manifest format version. + */ + format: "0.4.0"; + /** + * Basic project properties. + */ + project: { + /** + * Name of this project. + */ + name: string; + /** + * Type of this project. + */ + type: string; + }; + /** + * Project source files. + */ + source: { + /** + * Path to the project's entry point. + */ + module: string; + /** + * Path to the project's graphql schema. + */ + schema: string; + /** + * Specify ABIs to be used for the import URIs within your schema. + */ + import_abis?: ImportAbis[]; + }; + __type: "PluginManifest"; +} +export interface ImportAbis { + /** + * One of the schema's import URI. + */ + uri: string; + /** + * Path to a local ABI (or schema). Supported file formats: [*.graphql, *.info, *.json, *.yaml] + */ + abi: string; +} diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/index.ts b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/index.ts index 2a66aa6fdb..1d473b447f 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/index.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/index.ts @@ -14,11 +14,15 @@ import { import { PluginManifest as PluginManifest_0_3_0, } from "./0.3.0"; +import { + PluginManifest as PluginManifest_0_4_0, +} from "./0.4.0"; export { PluginManifest_0_1_0, PluginManifest_0_2_0, PluginManifest_0_3_0, + PluginManifest_0_4_0, }; export enum PluginManifestFormats { @@ -27,6 +31,7 @@ export enum PluginManifestFormats { "v0.1.0" = "0.1.0", "v0.2.0" = "0.2.0", "v0.3.0" = "0.3.0", + "v0.4.0" = "0.4.0", } export const PluginManifestSchemaFiles: Record = { @@ -35,17 +40,19 @@ export const PluginManifestSchemaFiles: Record = { "0.1.0": "formats/polywrap.plugin/0.1.0.json", "0.2.0": "formats/polywrap.plugin/0.2.0.json", "0.3.0": "formats/polywrap.plugin/0.3.0.json", + "0.4.0": "formats/polywrap.plugin/0.4.0.json", } export type AnyPluginManifest = | PluginManifest_0_1_0 | PluginManifest_0_2_0 | PluginManifest_0_3_0 + | PluginManifest_0_4_0 -export type PluginManifest = PluginManifest_0_3_0; +export type PluginManifest = PluginManifest_0_4_0; -export const latestPluginManifestFormat = PluginManifestFormats["v0.3.0"] +export const latestPluginManifestFormat = PluginManifestFormats["v0.4.0"] export { migratePluginManifest } from "./migrate"; diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/migrators/0.3.0_to_0.4.0.ts b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/migrators/0.3.0_to_0.4.0.ts new file mode 100644 index 0000000000..a3c3e74c64 --- /dev/null +++ b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/migrators/0.3.0_to_0.4.0.ts @@ -0,0 +1,9 @@ +import { PluginManifest as OldManifest } from "../0.3.0"; +import { PluginManifest as NewManifest } from "../0.4.0"; + +export function migrate(migrate: OldManifest): NewManifest { + return { + ...migrate, + format: "0.4.0", + }; +} diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/migrators/index.ts b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/migrators/index.ts index 02204ed348..cc377561c0 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/migrators/index.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/migrators/index.ts @@ -1,6 +1,7 @@ import { Migrator } from "../../../migrations"; import { migrate as migrate_0_1_0_to_0_2_0 } from "./0.1.0_to_0.2.0"; import { migrate as migrate_0_2_0_to_0_3_0 } from "./0.2.0_to_0.3.0"; +import { migrate as migrate_0_3_0_to_0_4_0 } from "./0.3.0_to_0.4.0"; export const migrators: Migrator[] = [ { @@ -18,4 +19,9 @@ export const migrators: Migrator[] = [ to: "0.3.0", migrate: migrate_0_2_0_to_0_3_0, }, + { + from: "0.3.0", + to: "0.4.0", + migrate: migrate_0_3_0_to_0_4_0, + }, ]; diff --git a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/validate.ts index 20d91e186e..2824b4afcc 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap.plugin/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap.plugin/validate.ts @@ -12,6 +12,7 @@ import { import PluginManifestSchema_0_1_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.plugin/0.1.0.json"; import PluginManifestSchema_0_2_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.plugin/0.2.0.json"; import PluginManifestSchema_0_3_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.plugin/0.3.0.json"; +import PluginManifestSchema_0_4_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap.plugin/0.4.0.json"; import { Schema, @@ -30,6 +31,7 @@ const schemas: PluginManifestSchemas = { "0.1.0": PluginManifestSchema_0_1_0, "0.2.0": PluginManifestSchema_0_2_0, "0.3.0": PluginManifestSchema_0_3_0, + "0.4.0": PluginManifestSchema_0_4_0, }; const validator = new Validator(); diff --git a/packages/js/manifests/polywrap/src/formats/polywrap/0.5.0.ts b/packages/js/manifests/polywrap/src/formats/polywrap/0.5.0.ts new file mode 100644 index 0000000000..d043dc9175 --- /dev/null +++ b/packages/js/manifests/polywrap/src/formats/polywrap/0.5.0.ts @@ -0,0 +1,72 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +/* tslint:disable */ +/** + * This file was automatically generated by json-schema-to-typescript. + * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, + * and run json-schema-to-typescript to regenerate this file. + */ + +export interface PolywrapManifest { + /** + * Polywrap manifest format version. + */ + format: "0.5.0"; + /** + * Basic project properties. + */ + project: { + /** + * Name of this project. + */ + name: string; + /** + * Type of this project. + */ + type: string; + }; + /** + * Project source files. + */ + source: { + /** + * Path to the project's entry point. + */ + module?: string; + /** + * Path to the project's graphql schema. + */ + schema: string; + /** + * Specify ABIs to be used for the import URIs within your schema. + */ + import_abis?: ImportAbis[]; + }; + /** + * Project resources folder + */ + resources?: string; + /** + * Project extension manifest files. + */ + extensions?: { + /** + * Path to the project build manifest file. + */ + build?: string; + /** + * Path to the project docs manifest file. + */ + docs?: string; + }; + __type: "PolywrapManifest"; +} +export interface ImportAbis { + /** + * One of the schema's import URI. + */ + uri: string; + /** + * Path to a local ABI (or schema). Supported file formats: [*.graphql, *.info, *.json, *.yaml] + */ + abi: string; +} diff --git a/packages/js/manifests/polywrap/src/formats/polywrap/index.ts b/packages/js/manifests/polywrap/src/formats/polywrap/index.ts index 22e98e2908..921461bdde 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap/index.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap/index.ts @@ -17,12 +17,16 @@ import { import { PolywrapManifest as PolywrapManifest_0_4_0, } from "./0.4.0"; +import { + PolywrapManifest as PolywrapManifest_0_5_0, +} from "./0.5.0"; export { PolywrapManifest_0_1_0, PolywrapManifest_0_2_0, PolywrapManifest_0_3_0, PolywrapManifest_0_4_0, + PolywrapManifest_0_5_0, }; export enum PolywrapManifestFormats { @@ -32,6 +36,7 @@ export enum PolywrapManifestFormats { "v0.2.0" = "0.2.0", "v0.3.0" = "0.3.0", "v0.4.0" = "0.4.0", + "v0.5.0" = "0.5.0", } export const PolywrapManifestSchemaFiles: Record = { @@ -41,6 +46,7 @@ export const PolywrapManifestSchemaFiles: Record = { "0.2.0": "formats/polywrap/0.2.0.json", "0.3.0": "formats/polywrap/0.3.0.json", "0.4.0": "formats/polywrap/0.4.0.json", + "0.5.0": "formats/polywrap/0.5.0.json", } export type AnyPolywrapManifest = @@ -48,11 +54,12 @@ export type AnyPolywrapManifest = | PolywrapManifest_0_2_0 | PolywrapManifest_0_3_0 | PolywrapManifest_0_4_0 + | PolywrapManifest_0_5_0 -export type PolywrapManifest = PolywrapManifest_0_4_0; +export type PolywrapManifest = PolywrapManifest_0_5_0; -export const latestPolywrapManifestFormat = PolywrapManifestFormats["v0.4.0"] +export const latestPolywrapManifestFormat = PolywrapManifestFormats["v0.5.0"] export { migratePolywrapManifest } from "./migrate"; diff --git a/packages/js/manifests/polywrap/src/formats/polywrap/migrators/0.4.0_to_0.5.0.ts b/packages/js/manifests/polywrap/src/formats/polywrap/migrators/0.4.0_to_0.5.0.ts new file mode 100644 index 0000000000..43f63b72f8 --- /dev/null +++ b/packages/js/manifests/polywrap/src/formats/polywrap/migrators/0.4.0_to_0.5.0.ts @@ -0,0 +1,9 @@ +import { PolywrapManifest as OldManifest } from "../0.4.0"; +import { PolywrapManifest as NewManifest } from "../0.5.0"; + +export function migrate(migrate: OldManifest): NewManifest { + return { + ...migrate, + format: "0.5.0", + }; +} diff --git a/packages/js/manifests/polywrap/src/formats/polywrap/migrators/index.ts b/packages/js/manifests/polywrap/src/formats/polywrap/migrators/index.ts index f7c2f28329..51bcb41727 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap/migrators/index.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap/migrators/index.ts @@ -2,6 +2,7 @@ import { Migrator } from "../../../migrations"; import { migrate as migrate_0_1_0_to_0_2_0 } from "./0.1.0_to_0.2.0"; import { migrate as migrate_0_2_0_to_0_3_0 } from "./0.2.0_to_0.3.0"; import { migrate as migrate_0_3_0_to_0_4_0 } from "./0.3.0_to_0.4.0"; +import { migrate as migrate_0_4_0_to_0_5_0 } from "./0.4.0_to_0.5.0"; export const migrators: Migrator[] = [ { @@ -23,5 +24,10 @@ export const migrators: Migrator[] = [ from: "0.3.0", to: "0.4.0", migrate: migrate_0_3_0_to_0_4_0, + }, + { + from: "0.4.0", + to: "0.5.0", + migrate: migrate_0_4_0_to_0_5_0, } ]; diff --git a/packages/js/manifests/polywrap/src/formats/polywrap/validate.ts b/packages/js/manifests/polywrap/src/formats/polywrap/validate.ts index 11ab97a548..cb58b80c19 100644 --- a/packages/js/manifests/polywrap/src/formats/polywrap/validate.ts +++ b/packages/js/manifests/polywrap/src/formats/polywrap/validate.ts @@ -13,6 +13,7 @@ import PolywrapManifestSchema_0_1_0 from "@polywrap/polywrap-manifest-schemas/fo import PolywrapManifestSchema_0_2_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap/0.2.0.json"; import PolywrapManifestSchema_0_3_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap/0.3.0.json"; import PolywrapManifestSchema_0_4_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap/0.4.0.json"; +import PolywrapManifestSchema_0_5_0 from "@polywrap/polywrap-manifest-schemas/formats/polywrap/0.5.0.json"; import { Schema, @@ -32,6 +33,7 @@ const schemas: PolywrapManifestSchemas = { "0.2.0": PolywrapManifestSchema_0_2_0, "0.3.0": PolywrapManifestSchema_0_3_0, "0.4.0": PolywrapManifestSchema_0_4_0, + "0.5.0": PolywrapManifestSchema_0_5_0, }; const validator = new Validator(); diff --git a/packages/js/os/package.json b/packages/js/os/package.json index 1fc8ff7ea7..dc5b68dca7 100644 --- a/packages/js/os/package.json +++ b/packages/js/os/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/os-js", "description": "Polywrap Javascript OS Utilities", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", @@ -16,7 +16,7 @@ "lint": "eslint --color -c ../../../.eslintrc.js src/" }, "devDependencies": { - "@types/node": "^18.14.6", + "@types/node": "18.15.0", "rimraf": "3.0.2", "typescript": "4.9.5" }, diff --git a/packages/js/validation/package.json b/packages/js/validation/package.json index 55e3f0f145..fda60ccde7 100644 --- a/packages/js/validation/package.json +++ b/packages/js/validation/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/package-validation", "description": "Polywrap Package Validator", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", @@ -18,12 +18,12 @@ "test:watch": "yarn test -- --watch" }, "dependencies": { - "@polywrap/schema-compose": "0.10.6", - "@polywrap/wrap-manifest-types-js": "0.10.0" + "@polywrap/schema-compose": "0.11.0-pre.4", + "@polywrap/wrap-manifest-types-js": "0.12.0" }, "devDependencies": { "@polywrap/msgpack-js": "0.10.0", - "@polywrap/os-js": "0.10.6", + "@polywrap/os-js": "0.11.0-pre.4", "@types/jest": "26.0.8", "jest": "26.6.3", "rimraf": "3.0.2", diff --git a/packages/js/validation/src/__tests__/wrappers/missing-abi/wrap.info b/packages/js/validation/src/__tests__/wrappers/missing-abi/wrap.info index eb1db54e61..b00b8bda6b 100644 --- a/packages/js/validation/src/__tests__/wrappers/missing-abi/wrap.info +++ b/packages/js/validation/src/__tests__/wrappers/missing-abi/wrap.info @@ -1 +1 @@ -‚¤name¤test§version¥0.1.0 \ No newline at end of file +ƒ¤name¤test¤type¤wasm§version¥0.1.0 \ No newline at end of file diff --git a/packages/js/validation/src/__tests__/wrappers/missing-abi/wrap.info.json b/packages/js/validation/src/__tests__/wrappers/missing-abi/wrap.info.json index d4a0e5fa0a..77ab3f4429 100644 --- a/packages/js/validation/src/__tests__/wrappers/missing-abi/wrap.info.json +++ b/packages/js/validation/src/__tests__/wrappers/missing-abi/wrap.info.json @@ -1,4 +1,5 @@ { "name": "test", + "type": "wasm", "version": "0.1.0" } diff --git a/packages/js/validation/src/types/WasmPackageValidator.ts b/packages/js/validation/src/types/WasmPackageValidator.ts index 97b5096503..2047e6a593 100644 --- a/packages/js/validation/src/types/WasmPackageValidator.ts +++ b/packages/js/validation/src/types/WasmPackageValidator.ts @@ -135,10 +135,10 @@ export class WasmPackageValidator { manifest: await deserializeWrapManifest(info), }; } catch (e) { - if (e.message.includes('instance requires property "abi"')) { + if (e.message.includes('"missingProperty": "abi"')) { return this._fail(ValidationFailReason.AbiNotFound); } else if ( - e.message.includes("instance.abi") && + e.message.includes("abi") && e.message.includes("Validation errors encountered") ) { return this._fail(ValidationFailReason.InvalidAbi); diff --git a/packages/manifests/polywrap/formats/polywrap.app/0.4.0.json b/packages/manifests/polywrap/formats/polywrap.app/0.4.0.json new file mode 100644 index 0000000000..10e31ae03f --- /dev/null +++ b/packages/manifests/polywrap/formats/polywrap.app/0.4.0.json @@ -0,0 +1,69 @@ +{ + "id": "AppManifest", + "type": "object", + "additionalProperties": false, + "required": ["format", "project", "source"], + "properties": { + "format": { + "description": "Polywrap manifest format version.", + "type": "string", + "enum": ["0.4.0"] + }, + "project": { + "description": "Basic project properties.", + "type": "object", + "additionalProperties": false, + "required": ["name", "type"], + "properties": { + "name": { + "description": "Name of this project.", + "type": "string", + "pattern": "^[a-zA-Z0-9\\-\\_]+$" + }, + "type": { + "description": "Type of this project.", + "type": "string", + "pattern": "^app\\/[a-z0-9]+$" + } + } + }, + "source": { + "description": "Project source files.", + "type": "object", + "additionalProperties": false, + "required": ["schema"], + "properties": { + "schema": { + "description": "Path to the project's graphql schema.", + "type": "string", + "pattern": "^\\.?\\.?\\/?((\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)+\\/)?[\\w\\-\\.]+\\.graphql$" + }, + "import_abis": { + "description": "Specify ABIs to be used for the import URIs within your schema.", + "type": "array", + "items": { + "$ref": "#/definitions/import_abis" + } + } + } + } + }, + "definitions": { + "import_abis": { + "type": "object", + "additionalProperties": false, + "properties": { + "uri": { + "description": "One of the schema's import URI.", + "type": "string" + }, + "abi": { + "description": "Path to a local ABI (or schema). Supported file formats: [*.graphql, *.info, *.json, *.yaml]", + "type": "string", + "pattern": "^\\.?\\.?\\/?((\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)+\\/)?[\\w\\-\\.]+\\.(info|graphql|json|yaml)$" + } + }, + "required": ["uri", "abi"] + } + } +} diff --git a/packages/manifests/polywrap/formats/polywrap.deploy/0.4.0.json b/packages/manifests/polywrap/formats/polywrap.deploy/0.4.0.json new file mode 100644 index 0000000000..522b6e2445 --- /dev/null +++ b/packages/manifests/polywrap/formats/polywrap.deploy/0.4.0.json @@ -0,0 +1,69 @@ +{ + "id": "DeployManifest", + "type": "object", + "additionalProperties": false, + "required": ["format", "jobs"], + "properties": { + "format": { + "description": "Polywrap deployment manifest format version.", + "type": "string", + "const": "0.4.0" + }, + "primaryJobName": { + "description": "Name of the job that runs the primary deployment sequence.", + "type": "string" + }, + "jobs": { + "description": "Sequences of deployment steps", + "type": "object", + "patternProperties": { + "^.*$": { + "$ref": "#/definitions/job" + } + } + } + }, + "definitions": { + "job": { + "type": "object", + "additionalProperties": false, + "required": ["steps"], + "properties": { + "steps": { + "description": "Deployment steps", + "type": "array", + "items": { + "$ref": "#/definitions/step" + } + }, + "config": { + "description": "Sequence-level custom configuration.", + "type": "object" + } + } + }, + "step": { + "type": "object", + "additionalProperties": false, + "required": ["name", "package", "uri"], + "properties": { + "name": { + "description": "Name of the step", + "type": "string" + }, + "package": { + "description": "Name of the deployer package.", + "type": "string" + }, + "config": { + "description": "Step-level custom configuration.", + "type": "object" + }, + "uri": { + "description": "URI or name of other step prefixed with '$$' to pass into the deploy step.", + "type": "string" + } + } + } + } +} diff --git a/packages/manifests/polywrap/formats/polywrap.plugin/0.4.0.json b/packages/manifests/polywrap/formats/polywrap.plugin/0.4.0.json new file mode 100644 index 0000000000..ba62dc3c1e --- /dev/null +++ b/packages/manifests/polywrap/formats/polywrap.plugin/0.4.0.json @@ -0,0 +1,74 @@ +{ + "id": "PluginManifest", + "type": "object", + "additionalProperties": false, + "required": ["format", "project", "source"], + "properties": { + "format": { + "description": "Polywrap manifest format version.", + "type": "string", + "enum": ["0.4.0"] + }, + "project": { + "description": "Basic project properties.", + "type": "object", + "additionalProperties": false, + "required": ["name", "type"], + "properties": { + "name": { + "description": "Name of this project.", + "type": "string", + "pattern": "^[a-zA-Z0-9\\-\\_]+$" + }, + "type": { + "description": "Type of this project.", + "type": "string", + "pattern": "^plugin\\/[a-z0-9]+$" + } + } + }, + "source": { + "description": "Project source files.", + "type": "object", + "additionalProperties": false, + "required": ["schema", "module"], + "properties": { + "module": { + "description": "Path to the project's entry point.", + "type": "string", + "pattern": "^\\.?\\.?\\/?((\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)+\\/)?[\\w\\-\\.]+\\.?[\\w\\-\\.]*$" + }, + "schema": { + "description": "Path to the project's graphql schema.", + "type": "string", + "pattern": "^\\.?\\.?\\/?((\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)+\\/)?[\\w\\-\\.]+\\.graphql$" + }, + "import_abis": { + "description": "Specify ABIs to be used for the import URIs within your schema.", + "type": "array", + "items": { + "$ref": "#/definitions/import_abis" + } + } + } + } + }, + "definitions": { + "import_abis": { + "type": "object", + "additionalProperties": false, + "properties": { + "uri": { + "description": "One of the schema's import URI.", + "type": "string" + }, + "abi": { + "description": "Path to a local ABI (or schema). Supported file formats: [*.graphql, *.info, *.json, *.yaml]", + "type": "string", + "pattern": "^\\.?\\.?\\/?((\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)+\\/)?[\\w\\-\\.]+\\.(info|graphql|json|yaml)$" + } + }, + "required": ["uri", "abi"] + } + } +} diff --git a/packages/manifests/polywrap/formats/polywrap/0.5.0.json b/packages/manifests/polywrap/formats/polywrap/0.5.0.json new file mode 100644 index 0000000000..657f5c260c --- /dev/null +++ b/packages/manifests/polywrap/formats/polywrap/0.5.0.json @@ -0,0 +1,96 @@ +{ + "id": "PolywrapManifest", + "type": "object", + "additionalProperties": false, + "required": ["format", "project", "source"], + "properties": { + "format": { + "description": "Polywrap manifest format version.", + "type": "string", + "enum": ["0.5.0"] + }, + "project": { + "description": "Basic project properties.", + "type": "object", + "additionalProperties": false, + "required": ["name", "type"], + "properties": { + "name": { + "description": "Name of this project.", + "type": "string", + "pattern": "^[a-zA-Z0-9\\-\\_]+$" + }, + "type": { + "description": "Type of this project.", + "type": "string", + "pattern": "^((interface)|(wasm\\/[a-z0-9]+))$" + } + } + }, + "source": { + "description": "Project source files.", + "type": "object", + "additionalProperties": false, + "required": ["schema"], + "properties": { + "module": { + "description": "Path to the project's entry point.", + "type": "string", + "pattern": "^\\.?\\.?\\/?((\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)+\\/)?[\\w\\-\\.]+\\.?[\\w\\-\\.]*$" + }, + "schema": { + "description": "Path to the project's graphql schema.", + "type": "string", + "pattern": "^\\.?\\.?\\/?((\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)+\\/)?[\\w\\-\\.]+\\.graphql$" + }, + "import_abis": { + "description": "Specify ABIs to be used for the import URIs within your schema.", + "type": "array", + "items": { + "$ref": "#/definitions/import_abis" + } + } + } + }, + "resources": { + "description": "Project resources folder", + "type": "string", + "pattern": "^\\.?\\.?\\/?((\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)+\\/)?[\\w\\-\\.]+\\.?[\\w\\-\\.]*\\/?$" + }, + "extensions": { + "description": "Project extension manifest files.", + "type": "object", + "additionalProperties": false, + "properties": { + "build": { + "description": "Path to the project build manifest file.", + "type": "string", + "pattern": "^\\.?\\.?(\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)*\\/[\\w\\-\\.]+\\.(yaml|json)$" + }, + "docs": { + "description": "Path to the project docs manifest file.", + "type": "string", + "pattern": "^\\.?\\.?(\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)*\\/[\\w\\-\\.]+\\.(yaml|json)$" + } + } + } + }, + "definitions": { + "import_abis": { + "type": "object", + "additionalProperties": false, + "properties": { + "uri": { + "description": "One of the schema's import URI.", + "type": "string" + }, + "abi": { + "description": "Path to a local ABI (or schema). Supported file formats: [*.graphql, *.info, *.json, *.yaml]", + "type": "string", + "pattern": "^\\.?\\.?\\/?((\\/[\\w\\-\\.@]+|\\/\\.\\.|\\/\\.)+\\/)?[\\w\\-\\.]+\\.(info|graphql|json|yaml)$" + } + }, + "required": ["uri", "abi"] + } + } +} diff --git a/packages/manifests/polywrap/package.json b/packages/manifests/polywrap/package.json index 418b315c74..c6f58b5b40 100644 --- a/packages/manifests/polywrap/package.json +++ b/packages/manifests/polywrap/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/polywrap-manifest-schemas", "description": "Polywrap Manifest Schemas", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", diff --git a/packages/schema/bind/package.json b/packages/schema/bind/package.json index d0ad3b01bf..cb329f605f 100644 --- a/packages/schema/bind/package.json +++ b/packages/schema/bind/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/schema-bind", "description": "Polywrap Schema Binding", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", @@ -19,13 +19,14 @@ "copy:templates": "copyfiles -u 1 src/**/*.mustache build/" }, "dependencies": { - "@polywrap/os-js": "0.10.6", - "@polywrap/schema-parse": "0.10.6", - "@polywrap/wrap-manifest-types-js": "0.10.0", + "@polywrap/client-js": "0.12.0", + "@polywrap/os-js": "0.11.0-pre.4", + "@polywrap/schema-parse": "0.11.0-pre.4", + "@polywrap/wrap-manifest-types-js": "0.12.0", "mustache": "4.0.1" }, "devDependencies": { - "@polywrap/test-cases": "0.10.6", + "@polywrap/test-cases": "0.11.0-pre.4", "@types/jest": "26.0.8", "@types/lodash": "4.14.178", "@types/mustache": "4.0.1", diff --git a/packages/schema/bind/src/__tests__/index.ts b/packages/schema/bind/src/__tests__/index.ts index 1fd3557924..1b2dd4bcd3 100644 --- a/packages/schema/bind/src/__tests__/index.ts +++ b/packages/schema/bind/src/__tests__/index.ts @@ -1,4 +1,4 @@ -import { BindOptions, BindLanguage } from "../"; +import { BindOptions, BindLanguage, bindLanguage } from "../"; import fs from "fs"; import path from "path"; @@ -14,7 +14,7 @@ export type TestCase = { input: BindOptions; outputLanguages: { language: string; - directory: string; + directory?: string; }[]; }; @@ -25,6 +25,7 @@ export type TestCases = { export function fetchTestCases(): TestCases { const cases: TestCases = []; + const bindLanguages = Object.keys(bindLanguage); const fetchIfExists = (file: string): string | undefined => { if (fs.existsSync(file)) { @@ -61,23 +62,34 @@ export function fetchTestCases(): TestCases { // Fetch each language's expected output const outputDir = path.join(root, dirent.name, "output"); - const outputLanguages = fs - .readdirSync(outputDir, { withFileTypes: true }) - .filter((item: fs.Dirent) => item.isDirectory()) - .map((item: fs.Dirent) => { - return { - language: item.name, - directory: path.join(outputDir, item.name) - }; - }); + const outputLanguages: { + language: string; + directory?: string; + }[] = []; + + for (const language of bindLanguages) { + const outputLanguageDir = path.join(outputDir, language); + if (fs.existsSync(outputLanguageDir)) { + outputLanguages.push({ + language, + directory: outputLanguageDir + }); + } else { + outputLanguages.push({ language }); + } + } // Parse the input schema into the Abi structure const abi = parseSchema(schema); const input: BindOptions = { - projectName: "Test", + wrapInfo: { + name: "Test", + version: "0.1", + abi, + type: "TBD" as "wasm" | "plugin" | "interface", + }, bindLanguage: "TBD" as BindLanguage, - abi, outputDirAbs: path.join(root, "combined") }; diff --git a/packages/schema/bind/src/__tests__/test-cases.spec.ts b/packages/schema/bind/src/__tests__/test-cases.spec.ts index 7f3af50937..08768073a6 100644 --- a/packages/schema/bind/src/__tests__/test-cases.spec.ts +++ b/packages/schema/bind/src/__tests__/test-cases.spec.ts @@ -2,7 +2,9 @@ import { fetchTestCases } from "./index"; import { bindSchema, BindLanguage, - BindOutput + BindOutput, + bindLanguageToWrapInfoType, + BindOptions } from "../"; import { @@ -12,11 +14,13 @@ import { OutputEntry } from "@polywrap/os-js"; -import fs from "fs"; +import fs, {existsSync, mkdirSync} from "fs"; import path from "path"; import { deepCopy } from "./utils"; +jest.setTimeout(60000); + describe("Polywrap Binding Test Suite", () => { const cases = fetchTestCases(); @@ -33,17 +37,30 @@ describe("Polywrap Binding Test Suite", () => { // Verify it binds correctly const { language, directory } = outputLanguage; + const bindOptions: BindOptions = { + ...deepCopy(testCase.input), + wrapInfo: { + ...deepCopy(testCase.input.wrapInfo), + type: bindLanguageToWrapInfoType(language as BindLanguage) + }, + bindLanguage: language as BindLanguage, + }; + + if (language == "wrap-go") { + if (!bindOptions.config) { + bindOptions.config = {}; + } + bindOptions.config.goModuleName = "github.com/testorg/testrepo"; + } + + const output = await bindSchema(bindOptions); + // Read the expected output directories - let expectedOutput: BindOutput = { + let expectedOutput: BindOutput | undefined = !directory ? undefined : { output: readDirectorySync(directory), outputDirAbs: testCase.input.outputDirAbs, }; - const output = bindSchema({ - ...deepCopy(testCase.input), - bindLanguage: language as BindLanguage, - }); - const sort = (array: OutputEntry[]): OutputEntry[] => { array.forEach((entry) => { if (typeof entry.data !== "string") entry.data = sort(entry.data); @@ -53,30 +70,56 @@ describe("Polywrap Binding Test Suite", () => { }; output.output.entries = sort(output.output.entries); - expectedOutput.output.entries = sort(expectedOutput.output.entries); - const testResultDir = path.join(__dirname, "/test-results/"); + if (expectedOutput) { + expectedOutput.output.entries = sort(expectedOutput.output.entries); + } + + const testResultDir = path.join(__dirname, "/test-results/", language); if (!fs.existsSync(testResultDir)) { - fs.mkdirSync(testResultDir); + fs.mkdirSync(testResultDir, { recursive: true }); } - writeFileSync( - path.join( - testResultDir, - `${language}-output.json` - ), - JSON.stringify(output, null, 2), - ); - writeFileSync( - path.join( - testResultDir, - `${language}-expected.json` - ), - JSON.stringify(expectedOutput, null, 2), - ); - - expect(output).toMatchObject(expectedOutput); + const paths: string[] = []; + + const outputDirectoryEntry = (root: string, entry: OutputEntry) => { + const entryPath = path.join(root, entry.name); + paths.push(entryPath); + + switch (entry.type) { + case "File": { + writeFileSync(entryPath, entry.data); + break; + } + case "Directory": { + for (const subEntry of entry.data) { + if (!existsSync(entryPath)) { + mkdirSync(entryPath, { recursive: true }); + } + outputDirectoryEntry(entryPath, subEntry); + } + break; + } + default: { + throw Error( + `outputDirectoryEntry: Unknown entry type. Entry: ${JSON.stringify( + entry + )}` + ); + } + } + }; + + for (const entry of output.output.entries) { + outputDirectoryEntry(testResultDir, entry); + } + + if (expectedOutput) { + expect(output).toMatchObject(expectedOutput); + } else { + expect(output.output.entries.length).toBeGreaterThan(0); + } } }); } diff --git a/packages/schema/bind/src/bindings/assemblyscript/functions.ts b/packages/schema/bind/src/bindings/assemblyscript/functions.ts deleted file mode 100644 index f58c5d5e12..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/functions.ts +++ /dev/null @@ -1,254 +0,0 @@ -import { MustacheFn } from "../types"; -import { isBaseType, isKeyword } from "./types"; - -// check if any of the keywords match the property name; -// if there's a match, insert `_` at the beginning of the property name. -export const detectKeyword: MustacheFn = () => { - return (value: string, render: (template: string) => string): string => { - const type = render(value); - if (isKeyword(type)) { - return "_" + type; - } - return type; - }; -}; - -export const toMsgPack: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - - let modifier = ""; - if (type[type.length - 1] === "!") { - type = type.substring(0, type.length - 1); - } else { - modifier = "Optional"; - } - - if (type[0] === "[") { - return modifier + "Array"; - } - if (type.startsWith("Map<")) { - return modifier + "ExtGenericMap"; - } - switch (type) { - case "Int": - return modifier + "Int32"; - case "UInt": - return modifier + "UInt32"; - case "Boolean": - return modifier + "Bool"; - default: - return modifier + type; - } - }; -}; - -export const toWasmInit: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - - if (type[type.length - 1] === "!") { - type = type.substring(0, type.length - 1); - } else { - const nullType = toWasm()(value, render); - const nullOptional = "| null"; - - if (nullType.endsWith(nullOptional)) { - return "null"; - } - } - - if (type[0] === "[") { - return "[]"; - } - - if (type.startsWith("Map<")) { - const firstOpenBracketIdx = type.indexOf("<"); - const lastCloseBracketIdx = type.lastIndexOf(">"); - if (firstOpenBracketIdx === -1 || lastCloseBracketIdx === -1) { - throw new Error(`Invalid Map: ${type}`); - } - - const keyValTypes = type.substring( - firstOpenBracketIdx + 1, - lastCloseBracketIdx - ); - - const firstCommaIdx = keyValTypes.indexOf(","); - if (firstCommaIdx === -1) { - throw new Error(`Invalid Map: ${type}`); - } - - const keyType = keyValTypes.substring(0, firstCommaIdx).trim(); - const valType = keyValTypes.substring(firstCommaIdx + 1).trim(); - - const wasmKeyType = toWasm()(keyType, (str) => str); - const wasmValType = toWasm()(valType, (str) => str); - - return `new Map<${wasmKeyType}, ${wasmValType}>()`; - } - - switch (type) { - case "Int": - case "Int8": - case "Int16": - case "Int32": - case "UInt": - case "UInt8": - case "UInt16": - case "UInt32": - return "0"; - case "String": - return `""`; - case "Boolean": - return "false"; - case "Bytes": - return `new ArrayBuffer(0)`; - case "BigInt": - return `BigInt.fromUInt16(0)`; - case "BigNumber": - return `new BigNumber(BigInt.fromUInt16(0), 0, 0)`; - case "JSON": - return `JSON.Value.Null()`; - default: - if (type.includes("Enum_")) { - return "0"; - } else { - type = detectKeyword()(type, (str) => str); - return `new Types.${type}()`; - } - } - }; -}; - -export const toWasm: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - let isEnum = false; - - let optional = false; - if (type[type.length - 1] === "!") { - type = type.substring(0, type.length - 1); - } else { - optional = true; - } - - if (type[0] === "[") { - return toWasmArray(type, optional); - } - - if (type.startsWith("Map<")) { - return toWasmMap(type, optional); - } - - switch (type) { - case "Int": - type = "i32"; - break; - case "Int8": - type = "i8"; - break; - case "Int16": - type = "i16"; - break; - case "Int32": - type = "i32"; - break; - case "UInt": - case "UInt32": - type = "u32"; - break; - case "UInt8": - type = "u8"; - break; - case "UInt16": - type = "u16"; - break; - case "String": - type = "string"; - break; - case "Boolean": - type = "bool"; - break; - case "Bytes": - type = "ArrayBuffer"; - break; - case "BigInt": - type = "BigInt"; - break; - case "BigNumber": - type = "BigNumber"; - break; - case "JSON": - type = "JSON.Value"; - break; - default: - if (type.includes("Enum_")) { - type = type.replace("Enum_", ""); - isEnum = true; - } - type = detectKeyword()(type, (str) => str); - type = `Types.${type}`; - } - - return applyOptional(type, optional, isEnum); - }; -}; - -const toWasmArray = (type: string, optional: boolean): string => { - const result = type.match(/(\[)([[\]A-Za-z0-9_.!]+)(\])/); - - if (!result || result.length !== 4) { - throw Error(`Invalid Array: ${type}`); - } - - const wasmType = toWasm()(result[2], (str) => str); - return applyOptional("Array<" + wasmType + ">", optional, false); -}; - -const toWasmMap = (type: string, optional: boolean): string => { - const firstOpenBracketIdx = type.indexOf("<"); - const lastCloseBracketIdx = type.lastIndexOf(">"); - - if (firstOpenBracketIdx === -1 || lastCloseBracketIdx === -1) { - throw new Error(`Invalid Map: ${type}`); - } - - const keyValTypes = type.substring( - firstOpenBracketIdx + 1, - lastCloseBracketIdx - ); - - const firstCommaIdx = keyValTypes.indexOf(","); - if (firstCommaIdx === -1) { - throw new Error(`Invalid Map: ${type}`); - } - - const keyType = keyValTypes.substring(0, firstCommaIdx).trim(); - const valType = keyValTypes.substring(firstCommaIdx + 1).trim(); - - const wasmKeyType = toWasm()(keyType, (str) => str); - const wasmValType = toWasm()(valType, (str) => str); - - return applyOptional(`Map<${wasmKeyType}, ${wasmValType}>`, optional, false); -}; - -const applyOptional = ( - type: string, - optional: boolean, - isEnum: boolean -): string => { - if (optional) { - if ( - type.indexOf("Array") === 0 || - type.indexOf("string") === 0 || - (!isEnum && !isBaseType(type)) - ) { - return `${type} | null`; - } else { - return `Box<${type}> | null`; - } - } else { - return type; - } -}; diff --git a/packages/schema/bind/src/bindings/assemblyscript/types.ts b/packages/schema/bind/src/bindings/assemblyscript/types.ts deleted file mode 100644 index 6961a87298..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/types.ts +++ /dev/null @@ -1,233 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ - -const baseTypes = { - u8: "u8", - u16: "u16", - u32: "u32", - i8: "i8", - i16: "i16", - i32: "i32", - string: "string", - bool: "bool", -}; - -export type BaseTypes = typeof baseTypes; - -export type BaseType = keyof BaseTypes; - -export function isBaseType(type: string): type is BaseType { - return type in baseTypes; -} - -// based on: -// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#keywords -// - https://github.com/AssemblyScript/assemblyscript/blob/f54dbfb527842f3d68f18643bb614d104b4f0160/src/common.ts#L107 -// - https://github.com/AssemblyScript/assemblyscript/blob/f54dbfb527842f3d68f18643bb614d104b4f0160/src/tokenizer.ts#L181 -const keywords = { - async: "async", - await: "await", - arguments: "arguments", - abstract: "abstract", - as: "as", - break: "break", - const: "const", - class: "class", - catch: "catch", - case: "case", - continue: "continue", - constructor: "constructor", - default: "default", - declare: "declare", - do: "do", - delete: "delete", - debugger: "debugger", - else: "else", - enum: "enum", - export: "export", - extends: "extends", - for: "for", - from: "from", - function: "function", - finally: "finally", - // get: "get", - if: "if", - in: "in", - is: "is", - implements: "implements", - import: "import", - instanceof: "instanceof", - interface: "interface", - keyof: "keyof", - let: "let", - module: "module", - new: "new", - namespace: "namespace", - of: "of", - private: "private", - package: "package", - public: "public", - protected: "protected", - return: "return", - readonly: "readonly", - switch: "switch", - static: "static", - // set: "set", - super: "super", - this: "this", - type: "type", - try: "try", - throw: "throw", - typeof: "typeof", - var: "var", - while: "while", - with: "with", - yield: "yield", - // types - i8: "i8", - i16: "i16", - i32: "i32", - i64: "i64", - isize: "isize", - u8: "u8", - u16: "u16", - u32: "u32", - u64: "u64", - usize: "usize", - bool: "bool", - f32: "f32", - f64: "f64", - v128: "v128", - funcref: "funcref", - externref: "externref", - anyref: "anyref", - eqref: "eqref", - i31ref: "i31ref", - dataref: "dataref", - i8x16: "i8x16", - u8x16: "u8x16", - i16x8: "i16x8", - u16x8: "u16x8", - i32x4: "i32x4", - u32x4: "u32x4", - i64x2: "i64x2", - u64x2: "u64x2", - f32x4: "f32x4", - f64x2: "f64x2", - void: "void", - number: "number", - boolean: "boolean", - string: "string", - native: "native", - indexof: "indexof", - valueof: "valueof", - returnof: "returnof", - nonnull: "nonnull", - // aliases - null: "null", - true: "true", - false: "false", - // constants - ASC_TARGET: "ASC_TARGET", - ASC_RUNTIME: "ASC_RUNTIME", - ASC_NO_ASSERT: "ASC_NO_ASSERT", - ASC_MEMORY_BASE: "ASC_MEMORY_BASE", - ASC_TABLE_BASE: "ASC_TABLE_BASE", - ASC_OPTIMIZE_LEVEL: "ASC_OPTIMIZE_LEVEL", - ASC_SHRINK_LEVEL: "ASC_SHRINK_LEVEL", - ASC_LOW_MEMORY_LIMIT: "ASC_LOW_MEMORY_LIMIT", - ASC_EXPORT_RUNTIME: "ASC_EXPORT_RUNTIME", - ASC_WASI: "ASC_WASI", - ASC_FEATURE_SIGN_EXTENSION: "ASC_FEATURE_SIGN_EXTENSION", - ASC_FEATURE_MUTABLE_GLOBALS: "ASC_FEATURE_MUTABLE_GLOBALS", - ASC_FEATURE_NONTRAPPING_F2I: "ASC_FEATURE_NONTRAPPING_F2I", - ASC_FEATURE_BULK_MEMORY: "ASC_FEATURE_BULK_MEMORY", - ASC_FEATURE_SIMD: "ASC_FEATURE_SIMD", - ASC_FEATURE_THREADS: "ASC_FEATURE_THREADS", - ASC_FEATURE_EXCEPTION_HANDLING: "ASC_FEATURE_EXCEPTION_HANDLING", - ASC_FEATURE_TAIL_CALLS: "ASC_FEATURE_TAIL_CALLS", - ASC_FEATURE_REFERENCE_TYPES: "ASC_FEATURE_REFERENCE_TYPES", - ASC_FEATURE_MULTI_VALUE: "ASC_FEATURE_MULTI_VALUE", - ASC_FEATURE_GC: "ASC_FEATURE_GC", - ASC_FEATURE_MEMORY64: "ASC_FEATURE_MEMORY64", - ASC_VERSION_MAJOR: "ASC_VERSION_MAJOR", - ASC_VERSION_MINOR: "ASC_VERSION_MINOR", - ASC_VERSION_PATCH: "ASC_VERSION_PATCH", - // classes - I8: "I8", - I16: "I16", - I32: "I32", - I64: "I64", - Isize: "Isize", - U8: "U8", - U16: "U16", - U32: "U32", - U64: "U64", - Usize: "Usize", - Bool: "Bool", - F32: "F32", - F64: "F64", - V128: "V128", - Funcref: "Funcref", - Externref: "Externref", - Anyref: "Anyref", - Eqref: "Eqref", - I31ref: "I31ref", - Dataref: "Dataref", - String: "String", - Object: "Object", - Array: "Array", - StaticArray: "StaticArray", - Set: "Set", - Map: "Map", - Function: "Function", - ArrayBufferView: "ArrayBufferView", - ArrayBuffer: "ArrayBuffer", - Math: "Math", - Mathf: "Mathf", - NativeMath: "NativeMath", - NativeMathf: "NativeMathf", - Int8Array: "Int8Array", - Int16Array: "Int16Array", - Int32Array: "Int32Array", - Int64Array: "Int64Array", - Uint8Array: "Uint8Array", - Uint8ClampedArray: "Uint8ClampedArray", - Uint16Array: "Uint16Array", - Uint32Array: "Uint32Array", - Uint64Array: "Uint64Array", - Float32Array: "Float32Array", - Float64Array: "Float64Array", - TemplateStringsArray: "TemplateStringsArray", - Error: "Error", - Result: "Result", - Box: "Box", - JSON: "JSON", - // runtime - abort: "abort", - trace: "trace", - seed: "seed", - pow: "pow", - ipow32: "ipow32", - ipow64: "ipow64", - mod: "mod", - __alloc: "__alloc", - __realloc: "__realloc", - __free: "__free", - __new: "__new", - __renew: "__renew", - __link: "__link", - __collect: "__collect", - __typeinfo: "__typeinfo", - __instanceof: "__instanceof", - __visit: "__visit", - __newBuffer: "__newBuffer", - __newArray: "__newArray", -}; - -export type Keywords = typeof keywords; - -export type Keyword = keyof Keywords; - -export function isKeyword(keyword: string): keyword is Keyword { - return keyword in keywords; -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_array.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_array.mustache deleted file mode 100644 index 5ee4a8a43b..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_array.mustache +++ /dev/null @@ -1,23 +0,0 @@ -{{#scalar}} -return reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); -{{/scalar}} -{{#array}} -return reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} -}); -{{/array}} -{{#map}} -return reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); -}, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} -}); -{{/map}} -{{#enum}} -{{> deserialize_enum}} -return value; -{{/enum}} -{{#object}} -{{> deserialize_object}} -return object; -{{/object}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_enum.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_enum.mustache deleted file mode 100644 index 6702368f21..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_enum.mustache +++ /dev/null @@ -1,26 +0,0 @@ -{{#required}} -let value: Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}; -if (reader.isNextString()) { - value = Types.get{{type}}Value(reader.readString()); -} else { - value = reader.readInt32(); - Types.sanitize{{type}}Value(value); -} -{{/required}} -{{^required}} -let value: Box | null; -if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.get{{type}}Value(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitize{{type}}Value(value.unwrap()); - } -} else { - value = null; -} -{{/required}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_map_value.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_map_value.mustache deleted file mode 100644 index 5ee4a8a43b..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_map_value.mustache +++ /dev/null @@ -1,23 +0,0 @@ -{{#scalar}} -return reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); -{{/scalar}} -{{#array}} -return reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} -}); -{{/array}} -{{#map}} -return reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); -}, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} -}); -{{/map}} -{{#enum}} -{{> deserialize_enum}} -return value; -{{/enum}} -{{#object}} -{{> deserialize_object}} -return object; -{{/object}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_object.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_object.mustache deleted file mode 100644 index 18f27d1c1e..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$deserialize_object.mustache +++ /dev/null @@ -1,9 +0,0 @@ -{{#required}} -const object = Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.read(reader); -{{/required}} -{{^required}} -let object: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = null; -if (!reader.isNextNil()) { - object = Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.read(reader); -} -{{/required}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialization_imports.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialization_imports.mustache deleted file mode 100644 index 933d73f458..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialization_imports.mustache +++ /dev/null @@ -1,12 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_array.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_array.mustache deleted file mode 100644 index a32a8fbfb0..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_array.mustache +++ /dev/null @@ -1,21 +0,0 @@ -{{#scalar}} -writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(item); -{{/scalar}} -{{#array}} -writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(item, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} -}); -{{/array}} -{{#map}} -writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(item, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(key); -}, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} -}); -{{/map}} -{{#enum}} -{{> serialize_enum}} -{{/enum}} -{{#object}} -{{> serialize_object}} -{{/object}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_enum.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_enum.mustache deleted file mode 100644 index 36c482f6ce..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_enum.mustache +++ /dev/null @@ -1,6 +0,0 @@ -{{#required}} -writer.writeInt32(item); -{{/required}} -{{^required}} -writer.writeOptionalInt32(item); -{{/required}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_map_value.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_map_value.mustache deleted file mode 100644 index 4dc36f8422..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_map_value.mustache +++ /dev/null @@ -1,35 +0,0 @@ -{{#scalar}} -writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(value); -{{/scalar}} -{{#array}} -writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(value, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} -}); -{{/array}} -{{#map}} -writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(value, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); -}, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} -}); -{{/map}} -{{#enum}} -{{#required}} -writer.writeInt32(value); -{{/required}} -{{^required}} -writer.writeOptionalInt32(value); -{{/required}} -{{/enum}} -{{#object}} -{{#required}} -Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, value); -{{/required}} -{{^required}} -if (value) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, value as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); -} else { - writer.writeNil(); -} -{{/required}} -{{/object}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_object.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_object.mustache deleted file mode 100644 index 10a177af22..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/$serialize_object.mustache +++ /dev/null @@ -1,10 +0,0 @@ -{{#required}} -Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, item); -{{/required}} -{{^required}} -if (item) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, item as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); -} else { - writer.writeNil(); -} -{{/required}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/entry-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/entry-ts.mustache deleted file mode 100644 index c3a24bd116..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/entry-ts.mustache +++ /dev/null @@ -1,57 +0,0 @@ -import { - wrap_invoke_args, - wrap_invoke_result, - wrap_invoke_error, - wrap_abort, - InvokeArgs -} from "@polywrap/wasm-as"; - -{{#moduleType}} -{{#methods.length}} -import { - {{#methods}} - {{name}}Wrapped{{^last}},{{/last}} - {{/methods}} -} from "./{{type}}/wrapped"; -{{/methods.length}} -{{/moduleType}} - -import { Module } from "../index"; - -export function _wrap_invoke(method_size: u32, args_size: u32, env_size: u32): bool { - const module = new Module(); - const args: InvokeArgs = wrap_invoke_args( - method_size, - args_size - ); - let result: ArrayBuffer; - {{#moduleType}} - {{#methods}} - {{^first}}else {{/first}}if (args.method == "{{name}}") { - result = {{name}}Wrapped(module, args.args, env_size); - } - {{/methods}} - {{/moduleType}} - else { - wrap_invoke_error( - `Could not find invoke function "${args.method}"` - ); - return false; - } - wrap_invoke_result(result); - return true; -} - -export function wrapAbort( - msg: string | null, - file: string | null, - line: u32, - column: u32 -): void { - wrap_abort( - msg ? msg : "", - file ? file : "", - line, - column - ); -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/enum-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/enum-type/index-ts.mustache deleted file mode 100644 index c738d94e84..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/enum-type/index-ts.mustache +++ /dev/null @@ -1,35 +0,0 @@ -export enum {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#constants}} - {{#detectKeyword}}{{.}}{{/detectKeyword}}, - {{/constants}} - _MAX_ -} - -export function sanitize{{type}}Value(value: i32): void { - const valid = value >= 0 && value < {{#detectKeyword}}{{type}}{{/detectKeyword}}._MAX_; - if (!valid) { - throw new Error("Invalid value for enum '{{#detectKeyword}}{{type}}{{/detectKeyword}}': " + value.toString()); - } -} - -export function get{{type}}Value(key: string): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#constants}} - if (key == "{{#detectKeyword}}{{.}}{{/detectKeyword}}") { - return {{#detectKeyword}}{{type}}{{/detectKeyword}}.{{#detectKeyword}}{{.}}{{/detectKeyword}}; - } - {{/constants}} - - throw new Error("Invalid key for enum '{{#detectKeyword}}{{type}}{{/detectKeyword}}': " + key); -} - -export function get{{type}}Key(value: {{#detectKeyword}}{{type}}{{/detectKeyword}}): string { - sanitize{{type}}Value(value); - - switch (value) { - {{#constants}} - case {{#detectKeyword}}{{type}}{{/detectKeyword}}.{{#detectKeyword}}{{.}}{{/detectKeyword}}: return "{{#detectKeyword}}{{.}}{{/detectKeyword}}"; - {{/constants}} - default: - throw new Error("Invalid value for enum '{{#detectKeyword}}{{type}}{{/detectKeyword}}': " + value.toString()); - } -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/env-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/env-type/index-ts.mustache deleted file mode 100644 index 8199149c0d..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/env-type/index-ts.mustache +++ /dev/null @@ -1,37 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serialize{{type}}, - deserialize{{type}}, - write{{type}}, - read{{type}} -} from "./serialization"; -import * as Types from ".."; - -export class {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}; - {{/properties}} - - static toBuffer(type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): ArrayBuffer { - return serialize{{type}}(type); - } - - static fromBuffer(buffer: ArrayBuffer): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - return deserialize{{type}}(buffer); - } - - static write(writer: Write, type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): void { - write{{type}}(writer, type); - } - - static read(reader: Read): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - return read{{type}}(reader); - } -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/env-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/env-type/serialization-ts.mustache deleted file mode 100644 index 5b9a53d9b6..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/env-type/serialization-ts.mustache +++ /dev/null @@ -1,149 +0,0 @@ -{{> serialization_imports}} -import { {{#detectKeyword}}{{type}}{{/detectKeyword}} } from "./"; -import * as Types from ".."; - -export function serialize{{type}}(type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) env-type: {{type}}"); - const sizer = new WriteSizer(sizerContext); - write{{type}}(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) env-type: {{type}}"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - write{{type}}(encoder, type); - return buffer; -} - -export function write{{type}}(writer: Write, type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): void { - {{#properties.length}} - writer.writeMapLength({{properties.length}}); - {{/properties.length}} - {{^properties}} - writer.writeMapLength(0); - {{/properties}} - {{#properties}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.writeString("{{name}}"); - {{#scalar}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/scalar}} - {{#array}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} - }); - {{/array}} - {{#map}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); - }, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} - }); - {{/map}} - {{#object}} - {{#required}} - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - if (type.{{#detectKeyword}}{{name}}{{/detectKeyword}}) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, type.{{#detectKeyword}}{{name}}{{/detectKeyword}} as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); - } else { - writer.writeNil(); - } - {{/required}} - {{/object}} - {{#enum}} - {{#required}} - writer.writeInt32(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - writer.writeOptionalInt32(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{/enum}} - writer.context().pop(); - {{/properties}} -} - -export function deserialize{{type}}(buffer: ArrayBuffer): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - const context: Context = new Context("Deserializing env-type {{type}}"); - const reader = new ReadDecoder(buffer, context); - return read{{type}}(reader); -} - -export function read{{type}}(reader: Read): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - let numFields = reader.readMapLength(); - - {{#properties}} - {{^object}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} | null = null; - {{/required}} - {{^required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{/object}} - {{#required}} - let _{{name}}Set: bool = false; - {{/required}} - {{/properties}} - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - {{#properties}} - {{^first}}else {{/first}}if (field == "{{name}}") { - reader.context().push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); - {{/scalar}} - {{#array}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} - }); - {{/array}} - {{#map}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); - }, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} - }); - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{name}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object }} - _{{name}} = object; - {{/object}} - {{#required}} - _{{name}}Set = true; - {{/required}} - reader.context().pop(); - } - {{/properties}} - reader.context().pop(); - } - - {{#properties}} - {{#required}} - {{^object}} - if (!_{{name}}Set) { - {{/object}} - {{#object}} - if (!_{{name}} || !_{{name}}Set) { - {{/object}} - throw new Error(reader.context().printWithContext("Missing required property: '{{name}}: {{type}}'")); - } - {{/required}} - {{/properties}} - - return { - {{#properties}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: _{{name}}{{^last}},{{/last}} - {{/properties}} - }; -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/enum-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/enum-type/index-ts.mustache deleted file mode 100644 index c738d94e84..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/enum-type/index-ts.mustache +++ /dev/null @@ -1,35 +0,0 @@ -export enum {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#constants}} - {{#detectKeyword}}{{.}}{{/detectKeyword}}, - {{/constants}} - _MAX_ -} - -export function sanitize{{type}}Value(value: i32): void { - const valid = value >= 0 && value < {{#detectKeyword}}{{type}}{{/detectKeyword}}._MAX_; - if (!valid) { - throw new Error("Invalid value for enum '{{#detectKeyword}}{{type}}{{/detectKeyword}}': " + value.toString()); - } -} - -export function get{{type}}Value(key: string): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#constants}} - if (key == "{{#detectKeyword}}{{.}}{{/detectKeyword}}") { - return {{#detectKeyword}}{{type}}{{/detectKeyword}}.{{#detectKeyword}}{{.}}{{/detectKeyword}}; - } - {{/constants}} - - throw new Error("Invalid key for enum '{{#detectKeyword}}{{type}}{{/detectKeyword}}': " + key); -} - -export function get{{type}}Key(value: {{#detectKeyword}}{{type}}{{/detectKeyword}}): string { - sanitize{{type}}Value(value); - - switch (value) { - {{#constants}} - case {{#detectKeyword}}{{type}}{{/detectKeyword}}.{{#detectKeyword}}{{.}}{{/detectKeyword}}: return "{{#detectKeyword}}{{.}}{{/detectKeyword}}"; - {{/constants}} - default: - throw new Error("Invalid value for enum '{{#detectKeyword}}{{type}}{{/detectKeyword}}': " + value.toString()); - } -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/env-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/env-type/index-ts.mustache deleted file mode 100644 index d06607f9f6..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/env-type/index-ts.mustache +++ /dev/null @@ -1,42 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON, -} from "@polywrap/wasm-as"; -import { - serialize{{type}}, - deserialize{{type}}, - write{{type}}, - read{{type}} -} from "./serialization"; -import * as Types from "../.."; - -@serializable -export class {{#detectKeyword}}{{type}}{{/detectKeyword}} { - - public static uri: string = "{{uri}}"; - - {{#properties}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}; - {{/properties}} - - static toBuffer(type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): ArrayBuffer { - return serialize{{type}}(type); - } - - static fromBuffer(buffer: ArrayBuffer): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - return deserialize{{type}}(buffer); - } - - static write(writer: Write, type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): void { - write{{type}}(writer, type); - } - - static read(reader: Read): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - return read{{type}}(reader); - } - {{> json_methods}} -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/env-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/env-type/serialization-ts.mustache deleted file mode 100644 index 9d524437cf..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/env-type/serialization-ts.mustache +++ /dev/null @@ -1,149 +0,0 @@ -{{> serialization_imports}} -import { {{#detectKeyword}}{{type}}{{/detectKeyword}} } from "./"; -import * as Types from "../.."; - -export function serialize{{type}}(type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported env-type: {{type}}"); - const sizer = new WriteSizer(sizerContext); - write{{type}}(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported env-type: {{type}}"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - write{{type}}(encoder, type); - return buffer; -} - -export function write{{type}}(writer: Write, type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): void { - {{#properties.length}} - writer.writeMapLength({{properties.length}}); - {{/properties.length}} - {{^properties}} - writer.writeMapLength(0); - {{/properties}} - {{#properties}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.writeString("{{name}}"); - {{#scalar}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/scalar}} - {{#array}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} - }); - {{/array}} - {{#map}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); - }, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} - }); - {{/map}} - {{#object}} - {{#required}} - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - if (type.{{#detectKeyword}}{{name}}{{/detectKeyword}}) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, type.{{#detectKeyword}}{{name}}{{/detectKeyword}} as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); - } else { - writer.writeNil(); - } - {{/required}} - {{/object}} - {{#enum}} - {{#required}} - writer.writeInt32(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - writer.writeOptionalInt32(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{/enum}} - writer.context().pop(); - {{/properties}} -} - -export function deserialize{{type}}(buffer: ArrayBuffer): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - const context: Context = new Context("Deserializing imported env-type {{type}}"); - const reader = new ReadDecoder(buffer, context); - return read{{type}}(reader); -} - -export function read{{type}}(reader: Read): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - let numFields = reader.readMapLength(); - - {{#properties}} - {{^object}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} | null = null; - {{/required}} - {{^required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{/object}} - {{#required}} - let _{{name}}Set: bool = false; - {{/required}} - {{/properties}} - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - {{#properties}} - {{^first}}else {{/first}}if (field == "{{name}}") { - reader.context().push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); - {{/scalar}} - {{#array}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} - }); - {{/array}} - {{#map}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); - }, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} - }); - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{name}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object }} - _{{name}} = object; - {{/object}} - {{#required}} - _{{name}}Set = true; - {{/required}} - reader.context().pop(); - } - {{/properties}} - reader.context().pop(); - } - - {{#properties}} - {{#required}} - {{^object}} - if (!_{{name}}Set) { - {{/object}} - {{#object}} - if (!_{{name}} || !_{{name}}Set) { - {{/object}} - throw new Error(reader.context().printWithContext("Missing required property: '{{name}}: {{type}}'")); - } - {{/required}} - {{/properties}} - - return { - {{#properties}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: _{{name}}{{^last}},{{/last}} - {{/properties}} - }; -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/index-ts.mustache deleted file mode 100644 index f37a0641b8..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/index-ts.mustache +++ /dev/null @@ -1,12 +0,0 @@ -{{#importedModuleTypes}} -export * from "./{{type}}"; -{{/importedModuleTypes}} -{{#importedObjectTypes}} -export * from "./{{type}}"; -{{/importedObjectTypes}} -{{#importedEnumTypes}} -export * from "./{{type}}"; -{{/importedEnumTypes}} -{{#importedEnvTypes}} -export * from "./{{type}}"; -{{/importedEnvTypes}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/module-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/module-type/index-ts.mustache deleted file mode 100644 index a1b0abaa22..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/module-type/index-ts.mustache +++ /dev/null @@ -1,91 +0,0 @@ -import { - wrap_subinvoke, - wrap_subinvokeImplementation, - Box, - BigInt, - BigNumber, - JSON, - Result -} from "@polywrap/wasm-as"; -{{#methods.length}} -import { - {{#methods}} - serialize{{name}}Args, - deserialize{{name}}Result, - Args_{{#detectKeyword}}{{name}}{{/detectKeyword}}{{^last}},{{/last}} - {{/methods}} -} from "./serialization"; -{{/methods.length}} -import * as Types from "../.."; - -{{^isInterface}} -export class {{#detectKeyword}}{{type}}{{/detectKeyword}} { - - public static uri: string = "{{uri}}"; - - {{#methods}} - public static {{name}}( - args: Args_{{#detectKeyword}}{{name}}{{/detectKeyword}} - ): Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string> { - const argsBuf = serialize{{name}}Args(args); - const result = wrap_subinvoke( - "{{uri}}", - "{{name}}", - argsBuf - ); - - if (result.isErr) { - return Result.Err<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string>( - result.unwrapErr() - ); - } - - return Result.Ok<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string>( - deserialize{{name}}Result(result.unwrap()) - ); - } - {{^last}} - - {{/last}} - {{/methods}} -} -{{/isInterface}} -{{#isInterface}} -export class {{#detectKeyword}}{{type}}{{/detectKeyword}} { - - public static interfaceUri: string = "{{uri}}"; - - public uri: string; - - constructor(uri: string) { - this.uri = uri; - } - - {{#methods}} - public {{name}}( - args: Args_{{#detectKeyword}}{{name}}{{/detectKeyword}} - ): Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string> { - const argsBuf = serialize{{name}}Args(args); - const result = wrap_subinvokeImplementation( - "{{uri}}", - this.uri, - "{{name}}", - argsBuf - ); - - if (result.isErr) { - return Result.Err<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string>( - result.unwrapErr() - ); - } - - return Result.Ok<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, string>( - deserialize{{name}}Result(result.unwrap()) - ); - } - {{^last}} - - {{/last}} - {{/methods}} -} -{{/isInterface}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/module-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/module-type/serialization-ts.mustache deleted file mode 100644 index f63acad622..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/module-type/serialization-ts.mustache +++ /dev/null @@ -1,250 +0,0 @@ -{{#methods.length}} -{{> serialization_imports}} -import * as Types from "../.."; - -{{#methods}} -export class Args_{{#detectKeyword}}{{name}}{{/detectKeyword}} { - {{#arguments}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}; - {{/arguments}} -} - -export function deserialize{{name}}Args(argsBuf: ArrayBuffer): Args_{{#detectKeyword}}{{name}}{{/detectKeyword}} { - const context: Context = new Context("Deserializing imported module-type: {{name}} Args"); - {{#arguments.length}} - const reader = new ReadDecoder(argsBuf, context); - let numFields = reader.readMapLength(); - - {{#arguments}} - {{^object}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} | null = null; - {{/required}} - {{^required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{/object}} - {{#required}} - let _{{name}}Set: bool = false; - {{/required}} - {{/arguments}} - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - {{#arguments}} - {{^first}}else {{/first}}if (field == "{{name}}") { - reader.context().push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); - {{/scalar}} - {{#array}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} - }); - {{/array}} - {{#map}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); - }, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} - }); - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{name}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object}} - _{{name}} = object; - {{/object}} - {{#required}} - _{{name}}Set = true; - {{/required}} - reader.context().pop(); - } - {{/arguments}} - reader.context().pop(); - } - - {{#arguments}} - {{#required}} - {{^object}} - if (!_{{name}}Set) { - {{/object}} - {{#object}} - if (!_{{name}} || !_{{name}}Set) { - {{/object}} - throw new Error(reader.context().printWithContext("Missing required argument: '{{name}}: {{type}}'")); - } - {{/required}} - {{/arguments}} - {{/arguments.length}} - - return { - {{#arguments}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: _{{name}}{{^last}},{{/last}} - {{/arguments}} - }; -} - -export function serialize{{name}}Args(args: Args_{{#detectKeyword}}{{name}}{{/detectKeyword}}): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported module-type: {{name}} Args"); - const sizer = new WriteSizer(sizerContext); - write{{name}}Args(sizer, args); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported module-type: {{name}} Args"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - write{{name}}Args(encoder, args); - return buffer; -} - -export function write{{name}}Args( - writer: Write, - args: Args_{{#detectKeyword}}{{name}}{{/detectKeyword}} -): void { - {{#arguments.length}} - writer.writeMapLength({{arguments.length}}); - {{/arguments.length}} - {{^arguments}} - writer.writeMapLength(0); - {{/arguments}} - {{#arguments}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.writeString("{{name}}"); - {{#scalar}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/scalar}} - {{#array}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} - }); - {{/array}} - {{#map}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); - }, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} - }); - {{/map}} - {{#enum}} - {{#required}} - writer.writeInt32(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - writer.writeOptionalInt32(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{/enum}} - {{#object}} - {{#required}} - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, args.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - if (args.{{#detectKeyword}}{{name}}{{/detectKeyword}}) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, args.{{#detectKeyword}}{{name}}{{/detectKeyword}} as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); - } else { - writer.writeNil(); - } - {{/required}} - {{/object}} - writer.context().pop(); - {{/arguments}} -} - -export function serialize{{name}}Result(result: {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported module-type: {{name}} Result"); - const sizer = new WriteSizer(sizerContext); - write{{name}}Result(sizer, result); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported module-type: {{name}} Result"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - write{{name}}Result(encoder, result); - return buffer; -} - -export function write{{name}}Result(writer: Write, result: {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}): void { - {{#return}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - {{#scalar}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(result); - {{/scalar}} - {{#array}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(result, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} - }); - {{/array}} - {{#map}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(result, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); - }, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} - }); - {{/map}} - {{#enum}} - {{#required}} - writer.writeInt32(result); - {{/required}} - {{^required}} - writer.writeOptionalInt32(result); - {{/required}} - {{/enum}} - {{#object}} - {{#required}} - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, result); - {{/required}} - {{^required}} - if (result) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, result as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); - } else { - writer.writeNil(); - } - {{/required}} - {{/object}} - writer.context().pop(); - {{/return}} -} - -export function deserialize{{name}}Result(buffer: ArrayBuffer): {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}} { - const context: Context = new Context("Deserializing imported module-type: {{name}} Result"); - const reader = new ReadDecoder(buffer, context); - - {{#return}} - reader.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "reading function output"); - {{#scalar}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); - {{/scalar}} - {{#array}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} - }); - {{/array}} - {{#map}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); - }, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} - }); - {{/map}} - {{#enum}} - {{> deserialize_enum}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = object; - {{/object}} - {{/return}} - reader.context().pop(); - - return res; -} -{{^last}} - -{{/last}} -{{/methods}} -{{/methods.length}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/object-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/object-type/index-ts.mustache deleted file mode 100644 index 3d914e5ae1..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/object-type/index-ts.mustache +++ /dev/null @@ -1,40 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serialize{{type}}, - deserialize{{type}}, - write{{type}}, - read{{type}} -} from "./serialization"; -import * as Types from "../.."; - -export class {{#detectKeyword}}{{type}}{{/detectKeyword}} { - - public static uri: string = "{{uri}}"; - - {{#properties}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}; - {{/properties}} - - static toBuffer(type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): ArrayBuffer { - return serialize{{type}}(type); - } - - static fromBuffer(buffer: ArrayBuffer): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - return deserialize{{type}}(buffer); - } - - static write(writer: Write, type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): void { - write{{type}}(writer, type); - } - - static read(reader: Read): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - return read{{type}}(reader); - } -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/object-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/object-type/serialization-ts.mustache deleted file mode 100644 index c2b2bb40ec..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/imported/object-type/serialization-ts.mustache +++ /dev/null @@ -1,149 +0,0 @@ -{{> serialization_imports}} -import { {{#detectKeyword}}{{type}}{{/detectKeyword}} } from "./"; -import * as Types from "../.."; - -export function serialize{{type}}(type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported object-type: {{type}}"); - const sizer = new WriteSizer(sizerContext); - write{{type}}(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) import object-type: {{type}}"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - write{{type}}(encoder, type); - return buffer; -} - -export function write{{type}}(writer: Write, type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): void { - {{#properties.length}} - writer.writeMapLength({{properties.length}}); - {{/properties.length}} - {{^properties}} - writer.writeMapLength(0); - {{/properties}} - {{#properties}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.writeString("{{name}}"); - {{#scalar}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/scalar}} - {{#array}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} - }); - {{/array}} - {{#map}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); - }, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} - }); - {{/map}} - {{#object}} - {{#required}} - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - if (type.{{#detectKeyword}}{{name}}{{/detectKeyword}}) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, type.{{#detectKeyword}}{{name}}{{/detectKeyword}} as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); - } else { - writer.writeNil(); - } - {{/required}} - {{/object}} - {{#enum}} - {{#required}} - writer.writeInt32(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - writer.writeOptionalInt32(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{/enum}} - writer.context().pop(); - {{/properties}} -} - -export function deserialize{{type}}(buffer: ArrayBuffer): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - const context: Context = new Context("Deserializing imported object-type {{type}}"); - const reader = new ReadDecoder(buffer, context); - return read{{type}}(reader); -} - -export function read{{type}}(reader: Read): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - let numFields = reader.readMapLength(); - - {{#properties}} - {{^object}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} | null = null; - {{/required}} - {{^required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{/object}} - {{#required}} - let _{{name}}Set: bool = false; - {{/required}} - {{/properties}} - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - {{#properties}} - {{^first}}else {{/first}}if (field == "{{name}}") { - reader.context().push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); - {{/scalar}} - {{#array}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} - }); - {{/array}} - {{#map}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); - }, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} - }); - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{name}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object }} - _{{name}} = object; - {{/object}} - {{#required}} - _{{name}}Set = true; - {{/required}} - reader.context().pop(); - } - {{/properties}} - reader.context().pop(); - } - - {{#properties}} - {{#required}} - {{^object}} - if (!_{{name}}Set) { - {{/object}} - {{#object}} - if (!_{{name}} || !_{{name}}Set) { - {{/object}} - throw new Error(reader.context().printWithContext("Missing required property: '{{name}}: {{type}}'")); - } - {{/required}} - {{/properties}} - - return { - {{#properties}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: _{{name}}{{^last}},{{/last}} - {{/properties}} - }; -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/index-ts.mustache deleted file mode 100644 index 626b0cda60..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/index-ts.mustache +++ /dev/null @@ -1,55 +0,0 @@ -{{#moduleType}} -{{#methods.length}} -import { - {{#methods}} - Args_{{#detectKeyword}}{{name}}{{/detectKeyword}}{{^last}},{{/last}} - {{/methods}} -} from "./{{type}}"; -{{/methods.length}} -{{/moduleType}} -{{#moduleType}} -{{#methods.length}} -export { - {{#methods}} - Args_{{#detectKeyword}}{{name}}{{/detectKeyword}}{{^last}},{{/last}} - {{/methods}} -}; -{{/methods.length}} -{{/moduleType}} -{{#moduleType}} -export { ModuleBase } from "./Module"; -{{/moduleType}} -{{#objectTypes}} -export { {{#detectKeyword}}{{type}}{{/detectKeyword}} } from "./{{type}}"; -{{/objectTypes}} -{{#enumTypes}} -export { - {{#detectKeyword}}{{type}}{{/detectKeyword}}, - get{{type}}Key, - get{{type}}Value, - sanitize{{type}}Value -} from "./{{type}}"; -{{/enumTypes}} -{{#importedModuleTypes}} -export { {{#detectKeyword}}{{type}}{{/detectKeyword}} } from "./imported/{{type}}"; -{{/importedModuleTypes}} -{{#importedObjectTypes}} -export { {{#detectKeyword}}{{type}}{{/detectKeyword}} } from "./imported/{{type}}"; -{{/importedObjectTypes}} -{{#importedEnvTypes}} -export { {{#detectKeyword}}{{type}}{{/detectKeyword}} } from "./imported/{{type}}"; -{{/importedEnvTypes}} -{{#importedEnumTypes}} -export { - {{#detectKeyword}}{{type}}{{/detectKeyword}}, - get{{type}}Key, - get{{type}}Value, - sanitize{{type}}Value -} from "./imported/{{type}}"; -{{/importedEnumTypes}} -{{#interfaceTypes}} -export { {{#detectKeyword}}{{namespace}}{{/detectKeyword}} } from "./{{namespace}}"; -{{/interfaceTypes}} -{{#envType}} -export { Env } from "./Env"; -{{/envType}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/interface-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/interface-type/index-ts.mustache deleted file mode 100644 index 25239251f4..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/interface-type/index-ts.mustache +++ /dev/null @@ -1,23 +0,0 @@ -{{#capabilities}} -{{#getImplementations}} -{{#enabled}} -import { - wrap_getImplementations -} from "@polywrap/wasm-as"; -{{/enabled}} -{{/getImplementations}} -{{/capabilities}} - -export class {{#detectKeyword}}{{namespace}}{{/detectKeyword}} { - static uri: string = "{{uri}}" - - {{#capabilities}} - {{#getImplementations}} - {{#enabled}} - public static getImplementations(): string[] { - return wrap_getImplementations(this.uri); - } - {{/enabled}} - {{/getImplementations}} - {{/capabilities}} -} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/index-ts.mustache deleted file mode 100644 index 654a54f746..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/index-ts.mustache +++ /dev/null @@ -1,14 +0,0 @@ -{{#methods.length}} -import { - {{#methods}} - Args_{{#detectKeyword}}{{name}}{{/detectKeyword}}{{^last}},{{/last}} - {{/methods}} -} from "./serialization"; - -export { - {{#methods}} - Args_{{#detectKeyword}}{{name}}{{/detectKeyword}}{{^last}},{{/last}} - {{/methods}} -}; -export { ModuleBase } from "./module"; -{{/methods.length}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/module-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/module-ts.mustache deleted file mode 100644 index 728479210d..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/module-ts.mustache +++ /dev/null @@ -1,20 +0,0 @@ -import * as Types from ".."; - -import { - BigInt, - BigNumber, - Box, - JSON, -} from "@polywrap/wasm-as"; - -export abstract class ModuleBase { - {{#methods}} - abstract {{#detectKeyword}}{{name}}{{/detectKeyword}}( - args: Types.Args_{{#detectKeyword}}{{name}}{{/detectKeyword}}{{#env}}, - env: {{#required}}Types.Env{{/required}}{{^required}}Types.Env | null{{/required}}{{/env}} - ): {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}; - {{^last}} - - {{/last}} - {{/methods}} -} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/serialization-ts.mustache deleted file mode 100644 index 415a33a2fb..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/serialization-ts.mustache +++ /dev/null @@ -1,248 +0,0 @@ -{{> serialization_imports}} -import * as Types from ".."; - -{{#methods}} -export class Args_{{#detectKeyword}}{{name}}{{/detectKeyword}} { - {{#arguments}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}; - {{/arguments}} -} - -export function deserialize{{name}}Args(argsBuf: ArrayBuffer): Args_{{#detectKeyword}}{{name}}{{/detectKeyword}} { - const context: Context = new Context("Deserializing module-type: {{name}} Args"); - {{#arguments.length}} - const reader = new ReadDecoder(argsBuf, context); - let numFields = reader.readMapLength(); - - {{#arguments}} - {{^object}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} | null = null; - {{/required}} - {{^required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{/object}} - {{#required}} - let _{{name}}Set: bool = false; - {{/required}} - {{/arguments}} - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - {{#arguments}} - {{^first}}else {{/first}}if (field == "{{name}}") { - reader.context().push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); - {{/scalar}} - {{#array}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} - }); - {{/array}} - {{#map}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); - }, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} - }); - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{name}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object}} - _{{name}} = object; - {{/object}} - {{#required}} - _{{name}}Set = true; - {{/required}} - reader.context().pop(); - } - {{/arguments}} - reader.context().pop(); - } - - {{#arguments}} - {{#required}} - {{^object}} - if (!_{{name}}Set) { - {{/object}} - {{#object}} - if (!_{{name}} || !_{{name}}Set) { - {{/object}} - throw new Error(reader.context().printWithContext("Missing required argument: '{{name}}: {{type}}'")); - } - {{/required}} - {{/arguments}} - {{/arguments.length}} - - return { - {{#arguments}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: _{{name}}{{^last}},{{/last}} - {{/arguments}} - }; -} - -export function serialize{{name}}Args(args: Args_{{#detectKeyword}}{{name}}{{/detectKeyword}}): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: {{name}} Args"); - const sizer = new WriteSizer(sizerContext); - write{{name}}Args(sizer, args); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: {{name}} Args"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - write{{name}}Args(encoder, args); - return buffer; -} - -export function write{{name}}Args( - writer: Write, - args: Args_{{#detectKeyword}}{{name}}{{/detectKeyword}} -): void { - {{#arguments.length}} - writer.writeMapLength({{arguments.length}}); - {{/arguments.length}} - {{^arguments}} - writer.writeMapLength(0); - {{/arguments}} - {{#arguments}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.writeString("{{name}}"); - {{#scalar}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/scalar}} - {{#array}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} - }); - {{/array}} - {{#map}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); - }, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} - }); - {{/map}} - {{#enum}} - {{#required}} - writer.writeInt32(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - writer.writeOptionalInt32(args.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{/enum}} - {{#object}} - {{#required}} - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, args.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - if (args.{{#detectKeyword}}{{name}}{{/detectKeyword}}) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, args.{{#detectKeyword}}{{name}}{{/detectKeyword}} as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); - } else { - writer.writeNil(); - } - {{/required}} - {{/object}} - writer.context().pop(); - {{/arguments}} -} - -export function serialize{{name}}Result(result: {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: {{name}} Result"); - const sizer = new WriteSizer(sizerContext); - write{{name}}Result(sizer, result); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: {{name}} Result"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - write{{name}}Result(encoder, result); - return buffer; -} - -export function write{{name}}Result(writer: Write, result: {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}): void { - {{#return}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - {{#scalar}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(result); - {{/scalar}} - {{#array}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(result, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} - }); - {{/array}} - {{#map}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(result, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); - }, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} - }); - {{/map}} - {{#enum}} - {{#required}} - writer.writeInt32(result); - {{/required}} - {{^required}} - writer.writeOptionalInt32(result); - {{/required}} - {{/enum}} - {{#object}} - {{#required}} - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, result); - {{/required}} - {{^required}} - if (result) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, result as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); - } else { - writer.writeNil(); - } - {{/required}} - {{/object}} - writer.context().pop(); - {{/return}} -} - -export function deserialize{{name}}Result(buffer: ArrayBuffer): {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}} { - const context: Context = new Context("Deserializing module-type: {{name}} Result"); - const reader = new ReadDecoder(buffer, context); - - {{#return}} - reader.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "reading function output"); - {{#scalar}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); - {{/scalar}} - {{#array}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} - }); - {{/array}} - {{#map}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); - }, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} - }); - {{/map}} - {{#enum}} - {{> deserialize_enum}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object}} - const res: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = object; - {{/object}} - {{/return}} - reader.context().pop(); - - return res; -} -{{^last}} - -{{/last}} -{{/methods}} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/wrapped-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/wrapped-ts.mustache deleted file mode 100644 index c2f461f292..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/module-type/wrapped-ts.mustache +++ /dev/null @@ -1,49 +0,0 @@ -{{#methods.length}} -import { wrap_load_env } from "@polywrap/wasm-as"; -import { - {{#methods}} - deserialize{{name}}Args, - serialize{{name}}Result{{^last}},{{/last}} - {{/methods}} -} from "./serialization"; -{{/methods.length}} -import { ModuleBase } from "./module"; -import * as Types from ".."; - -{{#methods}} -export function {{name}}Wrapped(module: ModuleBase, argsBuf: ArrayBuffer, env_size: u32): ArrayBuffer { - {{#env}} - {{#required}} - if (env_size == 0) { - throw new Error("Environment is not set, and it is required by method '{{name}}'") - } - - const envBuf = wrap_load_env(env_size); - const env = Types.Env.fromBuffer(envBuf); - {{/required}} - {{^required}} - let env: Types.Env | null = null; - if (env_size > 0) { - const envBuf = wrap_load_env(env_size); - env = Types.Env.fromBuffer(envBuf); - } - {{/required}} - {{/env}} - {{#arguments.length}} - const args = deserialize{{name}}Args(argsBuf); - {{/arguments.length}} - - const result = module.{{#detectKeyword}}{{name}}{{/detectKeyword}}({{#arguments.length}} - { - {{#arguments}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: args.{{#detectKeyword}}{{name}}{{/detectKeyword}}{{^last}},{{/last}} - {{/arguments}} - }{{/arguments.length}}{{^arguments.length}}{}{{/arguments.length}}{{#env}}, - env{{/env}} - ); - return serialize{{name}}Result(result); -} -{{^last}} - -{{/last}} -{{/methods}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/object-type/index-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/object-type/index-ts.mustache deleted file mode 100644 index 8199149c0d..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/object-type/index-ts.mustache +++ /dev/null @@ -1,37 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serialize{{type}}, - deserialize{{type}}, - write{{type}}, - read{{type}} -} from "./serialization"; -import * as Types from ".."; - -export class {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}; - {{/properties}} - - static toBuffer(type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): ArrayBuffer { - return serialize{{type}}(type); - } - - static fromBuffer(buffer: ArrayBuffer): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - return deserialize{{type}}(buffer); - } - - static write(writer: Write, type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): void { - write{{type}}(writer, type); - } - - static read(reader: Read): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - return read{{type}}(reader); - } -} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/object-type/serialization-ts.mustache b/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/object-type/serialization-ts.mustache deleted file mode 100644 index 831b72a573..0000000000 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/templates/object-type/serialization-ts.mustache +++ /dev/null @@ -1,149 +0,0 @@ -{{> serialization_imports}} -import { {{#detectKeyword}}{{type}}{{/detectKeyword}} } from "./"; -import * as Types from ".."; - -export function serialize{{type}}(type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) object-type: {{type}}"); - const sizer = new WriteSizer(sizerContext); - write{{type}}(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) object-type: {{type}}"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - write{{type}}(encoder, type); - return buffer; -} - -export function write{{type}}(writer: Write, type: {{#detectKeyword}}{{type}}{{/detectKeyword}}): void { - {{#properties.length}} - writer.writeMapLength({{properties.length}}); - {{/properties.length}} - {{^properties}} - writer.writeMapLength(0); - {{/properties}} - {{#properties}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.writeString("{{name}}"); - {{#scalar}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/scalar}} - {{#array}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, item: {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}}): void => { - {{> serialize_array}} - }); - {{/array}} - {{#map}} - writer.write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}, (writer: Write, key: {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}}) => { - writer.write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(key); - }, (writer: Write, value: {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}}): void => { - {{> serialize_map_value}} - }); - {{/map}} - {{#object}} - {{#required}} - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - if (type.{{#detectKeyword}}{{name}}{{/detectKeyword}}) { - Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}.write(writer, type.{{#detectKeyword}}{{name}}{{/detectKeyword}} as Types.{{#detectKeyword}}{{type}}{{/detectKeyword}}); - } else { - writer.writeNil(); - } - {{/required}} - {{/object}} - {{#enum}} - {{#required}} - writer.writeInt32(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{^required}} - writer.writeOptionalInt32(type.{{#detectKeyword}}{{name}}{{/detectKeyword}}); - {{/required}} - {{/enum}} - writer.context().pop(); - {{/properties}} -} - -export function deserialize{{type}}(buffer: ArrayBuffer): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - const context: Context = new Context("Deserializing object-type {{type}}"); - const reader = new ReadDecoder(buffer, context); - return read{{type}}(reader); -} - -export function read{{type}}(reader: Read): {{#detectKeyword}}{{type}}{{/detectKeyword}} { - let numFields = reader.readMapLength(); - - {{#properties}} - {{^object}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} | null = null; - {{/required}} - {{^required}} - let _{{name}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{/object}} - {{#required}} - let _{{name}}Set: bool = false; - {{/required}} - {{/properties}} - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - {{#properties}} - {{^first}}else {{/first}}if (field == "{{name}}") { - reader.context().push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(); - {{/scalar}} - {{#array}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#item}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/item}} => { - {{> deserialize_array}} - }); - {{/array}} - {{#map}} - _{{name}} = reader.read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}((reader: Read): {{#key}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/key}} => { - return reader.read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}(); - }, (reader: Read): {{#value}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/value}} => { - {{> deserialize_map_value}} - }); - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{name}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object }} - _{{name}} = object; - {{/object}} - {{#required}} - _{{name}}Set = true; - {{/required}} - reader.context().pop(); - } - {{/properties}} - reader.context().pop(); - } - - {{#properties}} - {{#required}} - {{^object}} - if (!_{{name}}Set) { - {{/object}} - {{#object}} - if (!_{{name}} || !_{{name}}Set) { - {{/object}} - throw new Error(reader.context().printWithContext("Missing required property: '{{name}}: {{type}}'")); - } - {{/required}} - {{/properties}} - - return { - {{#properties}} - {{#detectKeyword}}{{name}}{{/detectKeyword}}: _{{name}}{{^last}},{{/last}} - {{/properties}} - }; -} diff --git a/packages/schema/bind/src/bindings/golang/functions.ts b/packages/schema/bind/src/bindings/golang/functions.ts new file mode 100644 index 0000000000..11d2d8e32b --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/functions.ts @@ -0,0 +1,374 @@ +import { reservedWordsAS } from "./reservedWords"; +import { MustacheFn } from "../types"; + +let num = -1; + +export const startIter: MustacheFn = () => { + return (): string => { + num = -1; + return ""; + }; +}; + +export const stopIter: MustacheFn = () => { + return (): string => { + num = -1; + return ""; + }; +}; + +export const currIter: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const rendered: string = render(text); + return `${rendered}${num}`; + }; +}; + +export const nextIter: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const rendered: string = render(text); + return `${rendered}${++num}`; + }; +}; + +export const prevFullIter: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const rendered: string = render(text); + if (rendered == "stop") { + return ""; + } + return Array(num) + .fill(0) + .map((_, i) => `[${rendered}${i}]`) + .join(""); + }; +}; + +export const lastFullIter: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const rendered: string = render(text); + if (rendered == "stop") { + return ""; + } + return Array(num + 1) + .fill(0) + .map((_, i) => `[${rendered}${i}]`) + .join(""); + }; +}; + +export const writePointer: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const [type, value] = render(text).split(" - "); + let pointer = "*"; + switch (type) { + case "BigInt": + case "Json": + case "Bytes": + pointer = ""; + break; + } + return `writer.Write${type}(${pointer}${value})`; + }; +}; + +export const readPointer: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const [type, value] = render(text).split(" - "); + let pointer = "&"; + switch (type) { + case "BigInt": + case "Json": + case "Bytes": + pointer = ""; + break; + } + return `${pointer}${value}`; + }; +}; + +export const toSnakeCase: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + text = render(text).replace(/([A-Z])/g, "_$1"); + text = text.startsWith("_") ? text.slice(1) : text; + return text.toLowerCase(); + }; +}; + +export const makeImports: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const types = render(text).split(","); + const exist: { [key: string]: boolean } = {}; + for (let t of types) { + t = t.trim(); + if (t.endsWith("big.Int")) { + exist["github.com/polywrap/go-wrap/msgpack/big"] = true; + } else if (t.endsWith("fastjson.Value")) { + exist["github.com/valyala/fastjson"] = true; + } else if (/([^/\s]+\/)(.*)/.test(t)) { + exist[t] = true; + } + } + const imports: Array = []; + imports.push(...Object.keys(exist)); + const txt = imports + .sort() + .map((imp) => { + let res = ""; + if (imp.startsWith(". ")) { + res = `. "${imp.slice(2)}"`; + } else { + const parts = imp.split(" as "); + if (parts.length > 1) { + res = `${parts[1]} "${parts[0]}"`; + } else { + res = `"${imp}"`; + } + } + return `\t${res}`; + }) + .join("\n"); + return txt !== "" ? `\nimport (\n${txt}\n)\n\n` : "\n"; + }; +}; + +export const stuctProps: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const props: [string, string][] = render(text) + .split("\n") + .map((line) => line.trimEnd()) + .filter((line) => line !== "") + .map((line) => line.split(" ") as [string, string]); + let maxPropNameLn = 0; + for (const [propName] of props) { + if (propName.length > maxPropNameLn) { + maxPropNameLn = propName.length; + } + } + for (let i = 0; i < props.length; i++) { + if (props[i][0].length < maxPropNameLn) { + props[i][0] += Array(maxPropNameLn - props[i][0].length) + .fill(" ") + .join(""); + } + props[i][0] = "\t" + props[i][0]; + } + return props.map((v) => v.join(" ")).join("\n") + "\n"; + }; +}; + +export const handleKeywords: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const rendered: string = render(text); + if (reservedWordsAS.has(rendered)) { + return "m_" + rendered; + } + return rendered; + }; +}; + +export const toMsgPack: MustacheFn = () => { + return (value: string, render: (template: string) => string) => { + let type = render(value); + if (type[type.length - 1] === "!") { + type = type.substring(0, type.length - 1); + } + let t = type; + if (type.startsWith("[")) { + t = "Array"; + } else if (type.startsWith("Map")) { + t = "Map"; + } else if (type.startsWith("Int8")) { + t = "I8"; + } else if (type.startsWith("Int16")) { + t = "I16"; + } else if (type.startsWith("Int32")) { + t = "I32"; + } else if (type.startsWith("Int64")) { + t = "I64"; + } else if (type.startsWith("Int")) { + t = "I32"; + } else if (type.startsWith("UInt8")) { + t = "U8"; + } else if (type.startsWith("UInt16")) { + t = "U16"; + } else if (type.startsWith("UInt32")) { + t = "U32"; + } else if (type.startsWith("UInt64")) { + t = "U64"; + } else if (type.startsWith("UInt")) { + t = "U32"; + } else if (type.startsWith("String")) { + t = "String"; + } else if (type.startsWith("Boolean")) { + t = "Bool"; + } else if (type.startsWith("Bytes")) { + t = "Bytes"; + } else if (type.startsWith("BigInt")) { + t = "BigInt"; + } else if (type.startsWith("BigNumber")) { + t = "BigInt"; + } else if (type.startsWith("JSON")) { + t = "Json"; + } + return t; + }; +}; + +export const toWasm: MustacheFn = () => { + return (value: string, render: (template: string) => string) => { + let type = render(value); + let isEnum = false; + + let optional = false; + if (type[type.length - 1] === "!") { + type = type.substring(0, type.length - 1); + } else { + optional = true; + } + + if (type[0] === "[") { + return toWasmArray(type, optional); + } + + if (type.startsWith("Map<")) { + return toWasmMap(type, optional); + } + + switch (type) { + case "Int": + type = "int32"; + break; + case "Int8": + type = "int8"; + break; + case "Int16": + type = "int16"; + break; + case "Int32": + type = "int32"; + break; + case "Int64": + type = "int64"; + break; + case "UInt": + type = "uint32"; + break; + case "UInt8": + type = "uint8"; + break; + case "UInt16": + type = "uint16"; + break; + case "UInt32": + type = "uint32"; + break; + case "UInt64": + type = "uint64"; + break; + case "String": + type = "string"; + break; + case "Boolean": + type = "bool"; + break; + case "Bytes": + type = "[]byte"; + break; + case "BigInt": + type = "*big.Int"; + break; + case "BigNumber": + type = "*big.Int"; + break; + case "JSON": + type = "*fastjson.Value"; + break; + default: + if (type.includes("Enum_")) { + type = `${type.replace("Enum_", "")}`; + isEnum = true; + } else { + type = type.charAt(0).toUpperCase() + type.slice(1); + } + } + + return applyOptional(type, optional, isEnum); + }; +}; + +const toWasmArray = (type: string, optional: boolean): string => { + const result = type.match(/(\[)([[\]A-Za-z0-9_.!]+)(\])/); + + if (!result || result.length !== 4) { + throw Error(`Invalid Array: ${type}`); + } + + const wasmType = toWasm()(result[2], (str) => str); + return applyOptional(`[]${wasmType}`, optional, false); +}; + +const toWasmMap = (type: string, optional: boolean): string => { + const firstOpenBracketIdx = type.indexOf("<"); + const lastCloseBracketIdx = type.lastIndexOf(">"); + + if (!(firstOpenBracketIdx !== -1 && lastCloseBracketIdx !== -1)) { + throw new Error(`Invalid Map: ${type}`); + } + + const keyValTypes = type + .substring(firstOpenBracketIdx + 1, lastCloseBracketIdx) + .split(","); + + if (keyValTypes.length < 2) { + throw new Error(`Invalid Map: ${type}`); + } + + const keyType = toWasm()(keyValTypes[0].trim(), (str) => str); + const valType = toWasm()(keyValTypes.slice(1).join(",").trim(), (str) => str); + + return applyOptional(`map[${keyType}]${valType}`, optional, false); +}; + +const applyOptional = (type: string, optional: boolean, _: boolean): string => { + if ( + optional && + !type.startsWith("*") && + !type.startsWith("[]") && + !type.startsWith("map") + ) { + return `*${type}`; + } else { + return type; + } +}; + +export const toLower: MustacheFn = () => { + return (value: string, render: (template: string) => string) => { + return render(value) + .split("") + .map((v) => v.toLowerCase()) + .join(""); + }; +}; + +export const toFirstLower: MustacheFn = () => { + return (value: string, render: (template: string) => string) => { + const type = render(value); + return type.charAt(0).toLowerCase() + type.slice(1); + }; +}; + +export const toUpper: MustacheFn = () => { + return (value: string, render: (template: string) => string) => { + const type = render(value); + return type.charAt(0).toUpperCase() + type.slice(1); + }; +}; + +export const pkgName: MustacheFn = () => { + return (text: string, render: (template: string) => string): string => { + const name = render(text); + return reservedWordsAS.has(name) ? `pkg${name}` : name; + }; +}; diff --git a/packages/schema/bind/src/bindings/assemblyscript/index.ts b/packages/schema/bind/src/bindings/golang/index.ts similarity index 100% rename from packages/schema/bind/src/bindings/assemblyscript/index.ts rename to packages/schema/bind/src/bindings/golang/index.ts diff --git a/packages/schema/bind/src/bindings/golang/reservedWords.ts b/packages/schema/bind/src/bindings/golang/reservedWords.ts new file mode 100644 index 0000000000..696a767cb4 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/reservedWords.ts @@ -0,0 +1,226 @@ +// based on: +// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#keywords +// - https://github.com/AssemblyScript/assemblyscript/blob/f54dbfb527842f3d68f18643bb614d104b4f0160/src/common.ts#L107 +// - https://github.com/AssemblyScript/assemblyscript/blob/f54dbfb527842f3d68f18643bb614d104b4f0160/src/tokenizer.ts#L181 +export const reservedWordsAS: Set = new Set([ + "async", + "await", + "arguments", + "abstract", + "as", + "break", + "const", + "class", + "catch", + "case", + "continue", + "constructor", + "default", + "declare", + "do", + "delete", + "debugger", + "else", + "enum", + "export", + "extends", + "for", + "from", + "function", + "finally", + "get", + "if", + "in", + "is", + "implements", + "import", + "instanceof", + "interface", + "keyof", + "let", + "module", + "new", + "namespace", + "of", + "private", + "package", + "public", + "protected", + "return", + "readonly", + "switch", + "static", + "set", + "super", + "this", + "type", + "try", + "throw", + "typeof", + "var", + "while", + "with", + "yield", + // types + "i8", + "i16", + "i32", + "i64", + "isize", + "u8", + "u16", + "u32", + "u64", + "usize", + "bool", + "f32", + "f64", + "v128", + "funcref", + "externref", + "anyref", + "eqref", + "i31ref", + "dataref", + "i8x16", + "u8x16", + "i16x8", + "u16x8", + "i32x4", + "u32x4", + "i64x2", + "u64x2", + "f32x4", + "f64x2", + "void", + "number", + "boolean", + "string", + "native", + "indexof", + "valueof", + "returnof", + "nonnull", + // aliases + "null", + "true", + "false", + // constants + "ASC_TARGET", + "ASC_RUNTIME", + "ASC_NO_ASSERT", + "ASC_MEMORY_BASE", + "ASC_TABLE_BASE", + "ASC_OPTIMIZE_LEVEL", + "ASC_SHRINK_LEVEL", + "ASC_LOW_MEMORY_LIMIT", + "ASC_EXPORT_RUNTIME", + "ASC_WASI", + "ASC_FEATURE_SIGN_EXTENSION", + "ASC_FEATURE_MUTABLE_GLOBALS", + "ASC_FEATURE_NONTRAPPING_F2I", + "ASC_FEATURE_BULK_MEMORY", + "ASC_FEATURE_SIMD", + "ASC_FEATURE_THREADS", + "ASC_FEATURE_EXCEPTION_HANDLING", + "ASC_FEATURE_TAIL_CALLS", + "ASC_FEATURE_REFERENCE_TYPES", + "ASC_FEATURE_MULTI_VALUE", + "ASC_FEATURE_GC", + "ASC_FEATURE_MEMORY64", + "ASC_VERSION_MAJOR", + "ASC_VERSION_MINOR", + "ASC_VERSION_PATCH", + // classes + "I8", + "I16", + "I32", + "I64", + "Isize", + "U8", + "U16", + "U32", + "U64", + "Usize", + "Bool", + "F32", + "F64", + "V128", + "Funcref", + "Externref", + "Anyref", + "Eqref", + "I31ref", + "Dataref", + "String", + "Object", + "Array", + "StaticArray", + "Set", + "Map", + "Function", + "ArrayBufferView", + "ArrayBuffer", + "Math", + "Mathf", + "NativeMath", + "NativeMathf", + "Int8Array", + "Int16Array", + "Int32Array", + "Int64Array", + "Uint8Array", + "Uint8ClampedArray", + "Uint16Array", + "Uint32Array", + "Uint64Array", + "Float32Array", + "Float64Array", + "TemplateStringsArray", + "Error", + // runtime + "abort", + "trace", + "seed", + "pow", + "ipow32", + "ipow64", + "mod", + "__alloc", + "__realloc", + "__free", + "__new", + "__renew", + "__link", + "__collect", + "__typeinfo", + "__instanceof", + "__visit", + "__newBuffer", + "__newArray", + "break", + "default", + "func", + "interface", + "select", + "case", + "defer", + "go", + "map", + "struct", + "chan", + "else", + "goto", + "package", + "switch", + "const", + "fallthrough", + "if", + "range", + "type", + "continue", + "for", + "import", + "return", + "var", +]); diff --git a/packages/schema/bind/src/bindings/golang/transforms/index.ts b/packages/schema/bind/src/bindings/golang/transforms/index.ts new file mode 100644 index 0000000000..c1d98bed8c --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/transforms/index.ts @@ -0,0 +1,2 @@ +export * from "./moduleNeedsTypes"; +export * from "./moduleNeedsImportedTypes"; diff --git a/packages/schema/bind/src/bindings/golang/transforms/moduleNeedsImportedTypes.ts b/packages/schema/bind/src/bindings/golang/transforms/moduleNeedsImportedTypes.ts new file mode 100644 index 0000000000..05b6d37d6a --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/transforms/moduleNeedsImportedTypes.ts @@ -0,0 +1,129 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import { + Abi, + ImportedEnumDefinition, + ImportedEnvDefinition, + ImportedModuleDefinition, + ImportedObjectDefinition, + MethodDefinition, + ModuleDefinition, +} from "@polywrap/wrap-manifest-types-js"; +import { AbiTransforms } from "@polywrap/schema-parse"; + +interface ImportedTypesState { + importedTypes: Map; +} + +interface ModuleNeedsImportedTypesState extends ImportedTypesState { + needsImportedNamespaces: Set; +} + +export function extractImportedTypes(): AbiTransforms { + const state: ImportedTypesState = { + importedTypes: new Map(), + }; + + return { + enter: { + ImportedEnumDefinition: (def: ImportedEnumDefinition) => { + state.importedTypes = state.importedTypes.set(def.type, def.namespace); + return def; + }, + ImportedEnvDefinition: (def: ImportedEnvDefinition) => { + state.importedTypes = state.importedTypes.set(def.type, def.namespace); + return def; + }, + ImportedModuleDefinition: (def: ImportedModuleDefinition) => { + state.importedTypes = state.importedTypes.set(def.type, def.namespace); + return def; + }, + ImportedObjectDefinition: (def: ImportedObjectDefinition) => { + state.importedTypes = state.importedTypes.set(def.type, def.namespace); + return def; + }, + }, + leave: { + Abi(abi: Abi) { + return { + ...abi, + _importedTypes: state.importedTypes, + }; + }, + }, + }; +} + +export function extractNeededImportedNamespaces(): AbiTransforms { + const state: ModuleNeedsImportedTypesState = { + importedTypes: new Map(), + needsImportedNamespaces: new Set(), + }; + + return { + enter: { + Abi: (abi: Abi) => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + state.importedTypes = abi._importedTypes; + return abi; + }, + MethodDefinition: (def: MethodDefinition) => { + if (def.arguments && def.arguments.length > 0) { + for (const arg of def.arguments) { + const argType = arg.type; + const importNamespace = state.importedTypes?.get(argType); + if (importNamespace) { + state.needsImportedNamespaces?.add(importNamespace); + } + } + } + + if (def.return) { + const returnType = def.return.type; + const importNamespace = state.importedTypes?.get(returnType); + if (importNamespace) { + state.needsImportedNamespaces?.add(importNamespace); + } + } + return def; + }, + }, + leave: { + Abi: (abi: Abi) => { + return { + ...abi, + _needsImportedNamespaces: state.needsImportedNamespaces, + }; + }, + }, + }; +} + +export function needsImportedNamespaces(): AbiTransforms { + const state: ModuleNeedsImportedTypesState = { + importedTypes: new Map(), + needsImportedNamespaces: new Set(), + }; + + return { + enter: { + Abi: (abi: Abi) => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + state.needsImportedNamespaces = abi._needsImportedNamespaces; + return abi; + }, + }, + leave: { + ModuleDefinition: (def: ModuleDefinition) => { + const needsImportedNamespaces = Array.from( + state.needsImportedNamespaces + ); + return { + ...def, + needsImportedNamespaces, + }; + }, + }, + }; +} diff --git a/packages/schema/bind/src/bindings/golang/transforms/moduleNeedsTypes.ts b/packages/schema/bind/src/bindings/golang/transforms/moduleNeedsTypes.ts new file mode 100644 index 0000000000..766010c8a9 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/transforms/moduleNeedsTypes.ts @@ -0,0 +1,62 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +import { isBaseType, isBuiltInType } from "../types"; + +import { + MethodDefinition, + ModuleDefinition, +} from "@polywrap/wrap-manifest-types-js"; +import { AbiTransforms } from "@polywrap/schema-parse"; + +interface ModuleNeedsTypesState { + moduleDefinition?: ModuleDefinition; + needsTypes?: boolean; + importedTypes?: Map; +} + +export function moduleNeedsTypes(): AbiTransforms { + const state: ModuleNeedsTypesState = {}; + + return { + enter: { + Abi: (abi) => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + state.importedTypes = abi._importedTypes; + return abi; + }, + ModuleDefinition: (def: ModuleDefinition) => { + state.moduleDefinition = def; + state.needsTypes = false; + return def; + }, + MethodDefinition: (def: MethodDefinition) => { + if (def.arguments && def.arguments.length > 0) { + state.needsTypes = true; + } + + if (def.return) { + const returnType = def.return.type; + if ( + !isBaseType(returnType) && + !isBuiltInType(returnType) && + !state.importedTypes?.has(returnType) + ) { + state.needsTypes = true; + } + } + return def; + }, + }, + leave: { + ModuleDefinition: (def: ModuleDefinition) => { + const needsTypes = state.needsTypes; + state.moduleDefinition = undefined; + state.needsTypes = undefined; + return { + ...def, + needsTypes, + }; + }, + }, + }; +} diff --git a/packages/schema/bind/src/bindings/golang/types.ts b/packages/schema/bind/src/bindings/golang/types.ts new file mode 100644 index 0000000000..8c2087252d --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/types.ts @@ -0,0 +1,38 @@ +/* eslint-disable @typescript-eslint/naming-convention */ +const baseTypes = { + UInt: "UInt", + UInt8: "UInt8", + UInt16: "UInt16", + UInt32: "UInt32", + UInt64: "UInt64", + Int: "Int", + Int8: "Int8", + Int16: "Int16", + Int32: "Int32", + Int64: "Int64", + String: "String", + Boolean: "Boolean", + Bytes: "Bytes", +}; + +export type BaseTypes = typeof baseTypes; + +export type BaseType = keyof BaseTypes; + +export function isBaseType(type: string): type is BaseType { + return type in baseTypes; +} + +const builtInTypes = { + BigInt: "BigInt", + BigNumber: "BigNumber", + JSON: "JSON", +}; + +export type BuiltInTypes = typeof builtInTypes; + +export type BuiltInType = keyof BuiltInTypes; + +export function isBuiltInType(type: string): type is BuiltInType { + return type in builtInTypes; +} diff --git a/packages/schema/bind/src/bindings/assemblyscript/wasm/index.ts b/packages/schema/bind/src/bindings/golang/wasm/index.ts similarity index 55% rename from packages/schema/bind/src/bindings/assemblyscript/wasm/index.ts rename to packages/schema/bind/src/bindings/golang/wasm/index.ts index 1bfdea57cc..4c3faf5a7e 100644 --- a/packages/schema/bind/src/bindings/assemblyscript/wasm/index.ts +++ b/packages/schema/bind/src/bindings/golang/wasm/index.ts @@ -1,9 +1,13 @@ import { Functions } from "../"; -import { GenerateBindingFn, renderTemplates } from "../.."; +import { GenerateBindingFn } from "../.."; +import { renderTemplates } from "../.."; import { loadSubTemplates } from "../../utils"; import { BindOptions, BindOutput } from "../../.."; +import { reservedWordsAS } from "../reservedWords"; +import * as Transforms from "../transforms"; import { + Abi, transformAbi, addFirstLast, extendType, @@ -11,13 +15,22 @@ import { } from "@polywrap/schema-parse"; import { OutputEntry, readDirectorySync } from "@polywrap/os-js"; import path from "path"; -import { WrapAbi } from "@polywrap/wrap-manifest-types-js/src"; const templatesDir = readDirectorySync(path.join(__dirname, "./templates")); const subTemplates = loadSubTemplates(templatesDir.entries); const templatePath = (subpath: string) => path.join(__dirname, "./templates", subpath); +function pkgName(str: string): string { + return reservedWordsAS.has(str) ? `pkg${str}` : str; +} + +function camel2snake(str: string): string { + str = str.replace(/([A-Z])/g, "_$1"); + str = str.startsWith("_") ? str.slice(1) : str; + return str.toLowerCase(); +} + export const generateBinding: GenerateBindingFn = ( options: BindOptions ): BindOutput => { @@ -28,14 +41,21 @@ export const generateBinding: GenerateBindingFn = ( outputDirAbs: options.outputDirAbs, }; const output = result.output; - const abi = applyTransforms(options.abi); + const abi = applyTransforms(options.wrapInfo.abi); + const goImport = options.config?.goModuleName; + + if (!goImport) { + throw Error( + "wasm/golang bindings requires the config property 'goModuleName' to be set" + ); + } // Generate object type folders if (abi.objectTypes) { for (const objectType of abi.objectTypes) { output.entries.push({ type: "Directory", - name: objectType.type, + name: "types", data: renderTemplates( templatePath("object-type"), objectType, @@ -53,7 +73,7 @@ export const generateBinding: GenerateBindingFn = ( for (const importedModuleType of abi.importedModuleTypes) { importEntries.push({ type: "Directory", - name: importedModuleType.type, + name: `${pkgName(camel2snake(importedModuleType.namespace))}`, data: renderTemplates( templatePath("imported/module-type"), importedModuleType, @@ -63,12 +83,12 @@ export const generateBinding: GenerateBindingFn = ( } } - // Generate imported env type folders + // // Generate imported env type folders if (abi.importedEnvTypes) { for (const importedEnvType of abi.importedEnvTypes) { importEntries.push({ type: "Directory", - name: importedEnvType.type, + name: `${pkgName(camel2snake(importedEnvType.namespace))}`, data: renderTemplates( templatePath("imported/env-type"), importedEnvType, @@ -83,7 +103,7 @@ export const generateBinding: GenerateBindingFn = ( for (const importedEnumType of abi.importedEnumTypes) { importEntries.push({ type: "Directory", - name: importedEnumType.type, + name: `${pkgName(camel2snake(importedEnumType.namespace))}`, data: renderTemplates( templatePath("imported/enum-type"), importedEnumType, @@ -98,7 +118,7 @@ export const generateBinding: GenerateBindingFn = ( for (const importedObectType of abi.importedObjectTypes) { importEntries.push({ type: "Directory", - name: importedObectType.type, + name: `${pkgName(camel2snake(importedObectType.namespace))}`, data: renderTemplates( templatePath("imported/object-type"), importedObectType, @@ -124,7 +144,7 @@ export const generateBinding: GenerateBindingFn = ( for (const interfaceType of abi.interfaceTypes) { output.entries.push({ type: "Directory", - name: interfaceType.type, + name: "interfaces", data: renderTemplates( templatePath("interface-type"), interfaceType, @@ -136,12 +156,35 @@ export const generateBinding: GenerateBindingFn = ( // Generate module type folders if (abi.moduleType) { + const imports: { [key: string]: boolean } = {}; + abi.moduleType.methods?.forEach(function (method) { + method.arguments?.forEach(function (arg) { + const tp = abi.importedObjectTypes?.find(function (mt) { + return mt.type === arg.type; + }); + if (tp) { + imports[tp.namespace] = true; + } + }); + }); + const importedTypes = Object.keys(imports).map((namespace) => ({ + namespace, + })); + output.entries.push({ + type: "Directory", + name: "types", + data: renderTemplates( + templatePath("module-type/types"), + { importedTypes, goImport, ...abi.moduleType }, + subTemplates + ), + }); output.entries.push({ type: "Directory", - name: abi.moduleType.type, + name: "module_wrapped", data: renderTemplates( - templatePath("module-type"), - abi.moduleType, + templatePath("module-type/module_wrapped"), + { importedTypes, goImport, ...abi.moduleType }, subTemplates ), }); @@ -152,7 +195,7 @@ export const generateBinding: GenerateBindingFn = ( for (const enumType of abi.enumTypes) { output.entries.push({ type: "Directory", - name: enumType.type, + name: "types", data: renderTemplates( templatePath("enum-type"), enumType, @@ -166,9 +209,9 @@ export const generateBinding: GenerateBindingFn = ( if (abi.envType) { output.entries.push({ type: "Directory", - name: abi.envType.type, + name: "types", data: renderTemplates( - templatePath("env-type"), + templatePath("object-type"), abi.envType, subTemplates ), @@ -176,16 +219,62 @@ export const generateBinding: GenerateBindingFn = ( } // Generate root entry file - output.entries.push(...renderTemplates(templatePath(""), abi, subTemplates)); + output.entries.push({ + type: "Directory", + name: "main", + data: renderTemplates( + templatePath("main"), + { goImport, ...abi }, + subTemplates + ), + }); + + // Render the root directory + output.entries.push( + ...renderTemplates(templatePath(""), { goImport, ...abi }, subTemplates) + ); + + output.entries = mergePaths(output.entries); return result; }; -function applyTransforms(abi: WrapAbi): WrapAbi { +function mergePaths(array: OutputEntry[]): OutputEntry[] { + const tmp: { [key: string]: OutputEntry } = {}; + for (let i = 0; i < array.length; i++) { + switch (array[i].type) { + case "File": + tmp[array[i].name] = array[i]; + break; + case "Directory": + if (!tmp[array[i].name]) { + tmp[array[i].name] = array[i]; + } else { + (tmp[array[i].name].data as OutputEntry[]).push( + ...(array[i].data as OutputEntry[]) + ); + } + break; + } + } + array = Object.values(tmp); + for (let i = 0; i < array.length; i++) { + if (array[i].type === "Directory") { + array[i].data = mergePaths(array[i].data as OutputEntry[]); + } + } + return array; +} + +function applyTransforms(abi: Abi): Abi { const transforms = [ extendType(Functions), addFirstLast, toPrefixedGraphQLType, + Transforms.extractImportedTypes(), + Transforms.extractNeededImportedNamespaces(), + Transforms.needsImportedNamespaces(), + Transforms.moduleNeedsTypes(), ]; for (const transform of transforms) { diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_array.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_array.mustache new file mode 100644 index 0000000000..c66ee906d9 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_array.mustache @@ -0,0 +1,23 @@ +if reader.IsNil() { + _{{name}}{{#lastFullIter}}i{{/lastFullIter}} = nil +} else { + {{#nextIter}}ln{{/nextIter}} := reader.ReadArrayLength() + _{{name}}{{#prevFullIter}}i{{/prevFullIter}} = make({{#toWasm}}{{toGraphQLType}}{{/toWasm}}, {{#currIter}}ln{{/currIter}}) + for {{#currIter}}i{{/currIter}} := uint32(0); {{#currIter}}i{{/currIter}} < {{#currIter}}ln{{/currIter}}; {{#currIter}}i{{/currIter}}++ { + {{#scalar}} + {{> deserialize_scalar}} + {{/scalar}} + {{#enum}} + {{> deserialize_enum}} + {{/enum}} + {{#array}} + {{> deserialize_array}} + {{/array}} + {{#map}} + {{> deserialize_map}} + {{/map}} + {{#object}} + {{> deserialize_object}} + {{/object}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_enum.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_enum.mustache new file mode 100644 index 0000000000..b5ac1f35bb --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_enum.mustache @@ -0,0 +1,11 @@ +{{#required}} +_{{name}}{{#lastFullIter}}i{{/lastFullIter}} = {{#toUpper}}{{type}}{{/toUpper}}(reader.ReadI32()) +Sanitize{{#toUpper}}{{type}}{{/toUpper}}Value(int32(_{{name}}{{#lastFullIter}}i{{/lastFullIter}})) +{{/required}} +{{^required}} +if !reader.IsNil() { + v := {{#toUpper}}{{type}}{{/toUpper}}(reader.ReadI32()) + Sanitize{{#toUpper}}{{type}}{{/toUpper}}Value(int32(v)) + _{{name}}{{#lastFullIter}}i{{/lastFullIter}} = &v +} +{{/required}} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_map.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_map.mustache new file mode 100644 index 0000000000..409d6c97db --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_map.mustache @@ -0,0 +1,24 @@ +if reader.IsNil() { + _{{name}}{{#lastFullIter}}i{{/lastFullIter}} = nil +} else { + {{#nextIter}}ln{{/nextIter}} := reader.ReadMapLength() + _{{name}}{{#prevFullIter}}i{{/prevFullIter}} = make({{#toWasm}}{{toGraphQLType}}{{/toWasm}}) + for {{#currIter}}j{{/currIter}} := uint32(0); {{#currIter}}j{{/currIter}} < {{#currIter}}ln{{/currIter}}; {{#currIter}}j{{/currIter}}++ { + {{#currIter}}i{{/currIter}} := reader.Read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}() + {{#scalar}} + {{> deserialize_scalar}} + {{/scalar}} + {{#enum}} + {{> deserialize_enum}} + {{/enum}} + {{#array}} + {{> deserialize_array}} + {{/array}} + {{#map}} + {{> deserialize_map}} + {{/map}} + {{#object}} + {{> deserialize_object}} + {{/object}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_object.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_object.mustache new file mode 100644 index 0000000000..6fc0c5ba2f --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_object.mustache @@ -0,0 +1,8 @@ +if v := {{#toUpper}}{{type}}{{/toUpper}}Read(reader); v != nil { + {{#required}} + _{{name}}{{#lastFullIter}}i{{/lastFullIter}} = *v + {{/required}} + {{^required}} + _{{name}}{{#lastFullIter}}i{{/lastFullIter}} = v + {{/required}} +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_scalar.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_scalar.mustache new file mode 100644 index 0000000000..2c65dc5c0e --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$deserialize_scalar.mustache @@ -0,0 +1,9 @@ +{{#required}} +_{{name}}{{#lastFullIter}}i{{/lastFullIter}} = reader.Read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}() +{{/required}} +{{^required}} +if !reader.IsNil() { + v := reader.Read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}() + _{{name}}{{#lastFullIter}}i{{/lastFullIter}} = {{#readPointer}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}} - v{{/readPointer}} +} +{{/required}} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_array.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_array.mustache new file mode 100644 index 0000000000..0607326928 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_array.mustache @@ -0,0 +1,24 @@ +if value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}{{#lastFullIter}}i{{/lastFullIter}} == nil { + writer.WriteNil() +} else if len(value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}{{#lastFullIter}}i{{/lastFullIter}}) == 0 { + writer.WriteNil() +} else { + writer.WriteArrayLength(uint32(len(value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}{{#lastFullIter}}i{{/lastFullIter}}))) + for {{#nextIter}}i{{/nextIter}} := range value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}{{#prevFullIter}}i{{/prevFullIter}} { + {{#scalar}} + {{> serialize_scalar}} + {{/scalar}} + {{#enum}} + {{> serialize_enum}} + {{/enum}} + {{#array}} + {{> serialize_array}} + {{/array}} + {{#map}} + {{> serialize_map_value}} + {{/map}} + {{#object}} + {{> serialize_object}} + {{/object}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_enum.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_enum.mustache new file mode 100644 index 0000000000..cf2d5be270 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_enum.mustache @@ -0,0 +1,13 @@ +{ + v := value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}{{#lastFullIter}}i{{/lastFullIter}} + {{#required}} + writer.WriteI32(int32(v)) + {{/required}} + {{^required}} + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + {{/required}} +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_map.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_map.mustache new file mode 100644 index 0000000000..3191f3ad83 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_map.mustache @@ -0,0 +1,24 @@ +if value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}} == nil { + writer.WriteNil() +} else if len(value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}) == 0 { + writer.WriteNil() +} else { + for {{#nextIter}}i{{/nextIter}} := range value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}{{#getPrevIter}}i{{/getPrevIter}} { + writer.Write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}({{#currIter}}i{{/currIter}}) + {{#scalar}} + {{> serialize_scalar}} + {{/scalar}} + {{#enum}} + {{> serialize_enum}} + {{/enum}} + {{#array}} + {{> serialize_array}} + {{/array}} + {{#map}} + {{> serialize_map}} + {{/map}} + {{#object}} + {{> serialize_object}} + {{/object}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_object.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_object.mustache new file mode 100644 index 0000000000..62c6d07eeb --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_object.mustache @@ -0,0 +1,9 @@ +{ + v := value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}{{#lastFullIter}}i{{/lastFullIter}} + {{#required}} + {{#toUpper}}{{type}}{{/toUpper}}Write(writer, &v) + {{/required}} + {{^required}} + {{#toUpper}}{{type}}{{/toUpper}}Write(writer, v) + {{/required}} +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_scalar.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_scalar.mustache new file mode 100644 index 0000000000..322a1867ce --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$serialize_scalar.mustache @@ -0,0 +1,13 @@ +{ + v := value.{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}{{#lastFullIter}}i{{/lastFullIter}} + {{#required}} + writer.Write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(v) + {{/required}} + {{^required}} + if v == nil { + writer.WriteNil() + } else { + {{#writePointer}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}} - v{{/writePointer}} + } + {{/required}} +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_array.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_array.mustache new file mode 100644 index 0000000000..808965046e --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_array.mustache @@ -0,0 +1,23 @@ +if reader.IsNil() { + value{{#lastFullIter}}i{{/lastFullIter}} = nil +} else { + {{#nextIter}}ln{{/nextIter}} := reader.ReadArrayLength() + value{{#prevFullIter}}i{{/prevFullIter}} = make({{#toWasm}}{{toGraphQLType}}{{/toWasm}}, {{#currIter}}ln{{/currIter}}) + for {{#currIter}}i{{/currIter}} := uint32(0); {{#currIter}}i{{/currIter}} < {{#currIter}}ln{{/currIter}}; {{#currIter}}i{{/currIter}}++ { + {{#scalar}} + {{> deserialize_scalar}} + {{/scalar}} + {{#enum}} + {{> deserialize_enum}} + {{/enum}} + {{#array}} + {{> deserialize_array}} + {{/array}} + {{#map}} + {{> deserialize_map}} + {{/map}} + {{#object}} + {{> deserialize_object}} + {{/object}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_enum.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_enum.mustache new file mode 100644 index 0000000000..b498c3d4f5 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_enum.mustache @@ -0,0 +1,11 @@ +{{#required}} +value{{#lastFullIter}}i{{/lastFullIter}} = {{#toUpper}}{{type}}{{/toUpper}}(reader.ReadI32()) +Sanitize{{#toUpper}}{{type}}{{/toUpper}}Value(int32(_{{name}}{{#lastFullIter}}i{{/lastFullIter}})) +{{/required}} +{{^required}} +if !reader.IsNil() { + v := {{#toUpper}}{{type}}{{/toUpper}}(reader.ReadI32()) + Sanitize{{#toUpper}}{{type}}{{/toUpper}}Value(int32(v)) + value{{#lastFullIter}}i{{/lastFullIter}} = &v +} +{{/required}} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_map.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_map.mustache new file mode 100644 index 0000000000..c0eeaa66d6 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_map.mustache @@ -0,0 +1,24 @@ +if reader.IsNil() { + value{{#lastFullIter}}i{{/lastFullIter}} = nil +} else { + {{#nextIter}}ln{{/nextIter}} := reader.ReadMapLength() + value{{#prevFullIter}}i{{/prevFullIter}} = make({{#toWasm}}{{toGraphQLType}}{{/toWasm}}) + for {{#currIter}}j{{/currIter}} := uint32(0); {{#currIter}}j{{/currIter}} < {{#currIter}}ln{{/currIter}}; {{#currIter}}j{{/currIter}}++ { + {{#currIter}}i{{/currIter}} := reader.Read{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}() + {{#scalar}} + {{> deserialize_scalar}} + {{/scalar}} + {{#enum}} + {{> deserialize_enum}} + {{/enum}} + {{#array}} + {{> deserialize_array}} + {{/array}} + {{#map}} + {{> deserialize_map}} + {{/map}} + {{#object}} + {{> deserialize_object}} + {{/object}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_object.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_object.mustache new file mode 100644 index 0000000000..2a7c26cd0c --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_object.mustache @@ -0,0 +1,8 @@ +if v := {{#toUpper}}{{type}}{{/toUpper}}Read(reader); v != nil { + {{#required}} + value{{#lastFullIter}}i{{/lastFullIter}} = *v + {{/required}} + {{^required}} + value{{#lastFullIter}}i{{/lastFullIter}} = v + {{/required}} +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_scalar.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_scalar.mustache new file mode 100644 index 0000000000..09966bd026 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_deserialize_scalar.mustache @@ -0,0 +1,9 @@ +{{#required}} +value{{#lastFullIter}}i{{/lastFullIter}} = reader.Read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}() +{{/required}} +{{^required}} +if !reader.IsNil() { + v := reader.Read{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}() + value{{#lastFullIter}}i{{/lastFullIter}} = {{#readPointer}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}} - v{{/readPointer}} +} +{{/required}} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_array.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_array.mustache new file mode 100644 index 0000000000..e70e40e7cf --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_array.mustache @@ -0,0 +1,24 @@ +if value{{#lastFullIter}}i{{/lastFullIter}} == nil { + writer.WriteNil() +} else if len(value{{#lastFullIter}}i{{/lastFullIter}}) == 0 { + writer.WriteNil() +} else { + writer.WriteArrayLength(uint32(len(value{{#lastFullIter}}i{{/lastFullIter}}))) + for {{#nextIter}}i{{/nextIter}} := range value{{#prevFullIter}}i{{/prevFullIter}} { + {{#scalar}} + {{> value_serialize_scalar}} + {{/scalar}} + {{#enum}} + {{> value_serialize_enum}} + {{/enum}} + {{#array}} + {{> value_serialize_array}} + {{/array}} + {{#map}} + {{> value_serialize_map}} + {{/map}} + {{#object}} + {{> value_serialize_object}} + {{/object}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_enum.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_enum.mustache new file mode 100644 index 0000000000..590702b638 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_enum.mustache @@ -0,0 +1,13 @@ +{ + v := value{{#lastFullIter}}i{{/lastFullIter}} + {{#required}} + writer.WriteI32(int32(v)) + {{/required}} + {{^required}} + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + {{/required}} +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_map.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_map.mustache new file mode 100644 index 0000000000..41b00f5949 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_map.mustache @@ -0,0 +1,24 @@ +if value == nil { + writer.WriteNil() +} else if len(value) == 0 { + writer.WriteNil() +} else { + for {{#nextIter}}i{{/nextIter}} := range value{{#getPrevIter}}i{{/getPrevIter}} { + writer.Write{{#key}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/key}}({{#currIter}}i{{/currIter}}) + {{#scalar}} + {{> value_serialize_scalar}} + {{/scalar}} + {{#enum}} + {{> value_serialize_enum}} + {{/enum}} + {{#array}} + {{> value_serialize_array}} + {{/array}} + {{#map}} + {{> value_serialize_map}} + {{/map}} + {{#object}} + {{> value_serialize_object}} + {{/object}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_object.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_object.mustache new file mode 100644 index 0000000000..3b6ae4d7c6 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_object.mustache @@ -0,0 +1,9 @@ +{ + v := value{{#lastFullIter}}i{{/lastFullIter}} + {{#required}} + {{#toUpper}}{{type}}{{/toUpper}}Write(writer, &v) + {{/required}} + {{^required}} + {{#toUpper}}{{type}}{{/toUpper}}Write(writer, v) + {{/required}} +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_scalar.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_scalar.mustache new file mode 100644 index 0000000000..440c44f87c --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/$value_serialize_scalar.mustache @@ -0,0 +1,13 @@ +{ + v := value{{#lastFullIter}}i{{/lastFullIter}} + {{#required}} + writer.Write{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}(v) + {{/required}} + {{^required}} + if v == nil { + writer.WriteNil() + } else { + {{#writePointer}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}} - v{{/writePointer}} + } + {{/required}} +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/enum-type/Enum%type%-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/enum-type/Enum%type%-go.mustache new file mode 100644 index 0000000000..f88d287c1b --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/enum-type/Enum%type%-go.mustache @@ -0,0 +1,41 @@ +package types + +type {{#toUpper}}{{type}}{{/toUpper}} int32 + +const ( +{{#stuctProps}} +{{#constants}} +{{#toUpper}}{{type}}{{/toUpper}}{{.}} = iota +{{/constants}} +{{#toFirstLower}}{{type}}{{/toFirstLower}}Max = iota +{{/stuctProps}} +) + +func Sanitize{{#toUpper}}{{type}}{{/toUpper}}Value(value int32) { + if !(value >= 0 && value < int32({{#toFirstLower}}{{type}}{{/toFirstLower}}Max)) { + panic("Invalid value for enum '{{#toUpper}}{{type}}{{/toUpper}}'") + } +} + +func Get{{#toUpper}}{{type}}{{/toUpper}}Value(key string) {{#toUpper}}{{type}}{{/toUpper}} { + switch key { + {{#constants}} + case "{{.}}": + return {{#toUpper}}{{type}}{{/toUpper}}{{.}} + {{/constants}} + default: + panic("Invalid key for enum '{{#toUpper}}{{type}}{{/toUpper}}'") + } +} + +func Get{{#toUpper}}{{type}}{{/toUpper}}Key(value {{#toUpper}}{{type}}{{/toUpper}}) string { + Sanitize{{#toUpper}}{{type}}{{/toUpper}}Value(int32(value)) + switch value { + {{#constants}} + case {{#toUpper}}{{type}}{{/toUpper}}{{.}}: + return "{{.}}" + {{/constants}} + default: + panic("Invalid value for enum '{{#toUpper}}{{type}}{{/toUpper}}'") + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/env-type/Env%type%-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/env-type/Env%type%-go.mustache new file mode 100644 index 0000000000..a64e346848 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/env-type/Env%type%-go.mustache @@ -0,0 +1,27 @@ +package types + +{{#makeImports}}github.com/polywrap/go-wrap/msgpack,{{#properties}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{^last}},{{/last}}{{/properties}}{{/makeImports}} + +type {{#toUpper}}{{type}}{{/toUpper}} struct { + {{#stuctProps}} + {{#properties}} + {{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} `json:"{{name}}"` + {{/properties}} + {{/stuctProps}} +} + +func {{#toUpper}}{{type}}{{/toUpper}}ToBuffer(value *{{#toUpper}}{{type}}{{/toUpper}}) []byte { + return serialize{{#toUpper}}{{type}}{{/toUpper}}(value) +} + +func {{#toUpper}}{{type}}{{/toUpper}}FromBuffer(data []byte) *{{#toUpper}}{{type}}{{/toUpper}} { + return deserialize{{#toUpper}}{{type}}{{/toUpper}}(data) +} + +func {{#toUpper}}{{type}}{{/toUpper}}Write(writer msgpack.Write, value *{{#toUpper}}{{type}}{{/toUpper}}) { + write{{#toUpper}}{{type}}{{/toUpper}}(writer, value) +} + +func {{#toUpper}}{{type}}{{/toUpper}}Read(reader msgpack.Read) *{{#toUpper}}{{type}}{{/toUpper}} { + return read{{#toUpper}}{{type}}{{/toUpper}}(reader) +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/env-type/Env%type%Serialization-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/env-type/Env%type%Serialization-go.mustache new file mode 100644 index 0000000000..903b26da04 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/env-type/Env%type%Serialization-go.mustache @@ -0,0 +1,108 @@ +package types + +{{#makeImports}}github.com/polywrap/go-wrap/msgpack,{{#properties}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{^last}},{{/last}}{{/properties}}{{/makeImports}} + +func serialize{{#toUpper}}{{type}}{{/toUpper}}(value *{{#toUpper}}{{type}}{{/toUpper}}) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: {{#toUpper}}{{type}}{{/toUpper}}") + encoder := msgpack.NewWriteEncoder(ctx) + write{{#toUpper}}{{type}}{{/toUpper}}(encoder, value) + return encoder.Buffer() +} + +func write{{#toUpper}}{{type}}{{/toUpper}}(writer msgpack.Write, value *{{#toUpper}}{{type}}{{/toUpper}}) { + writer.WriteMapLength({{properties.length}}) + {{#properties}} + writer.Context().Push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property") + writer.WriteString("{{name}}") + {{#scalar}} + {{> serialize_scalar}} + {{/scalar}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> serialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> serialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> serialize_object}} + {{/object}} + {{#enum}} + {{> serialize_enum}} + {{/enum}} + writer.Context().Pop() + {{/properties}} +} + +func deserialize{{#toUpper}}{{type}}{{/toUpper}}(data []byte) *{{#toUpper}}{{type}}{{/toUpper}} { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: {{#toUpper}}{{type}}{{/toUpper}}") + reader := msgpack.NewReadDecoder(ctx, data) + return read{{#toUpper}}{{type}}{{/toUpper}}(reader) +} + +func read{{#toUpper}}{{type}}{{/toUpper}}(reader msgpack.Read) *{{#toUpper}}{{type}}{{/toUpper}} { + var ( + {{#stuctProps}} + {{#properties}} + _{{name}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} + {{#required}} + _{{name}}Set bool + {{/required}} + {{/properties}} + {{/stuctProps}} + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + {{#properties}} + case "{{name}}": + reader.Context().Push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property") + {{#scalar}} + {{> deserialize_scalar}} + {{/scalar}} + {{#enum}} + {{> deserialize_enum}} + {{/enum}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> deserialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> deserialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> deserialize_object}} + {{/object}} + {{#required}} + _{{name}}Set = true + {{/required}} + reader.Context().Pop() + {{/properties}} + } + reader.Context().Pop() + } + + {{#properties}} + {{#required}} + if !_{{name}}Set { + panic(reader.Context().PrintWithContext("Missing required property: '{{name}}: {{type}}'")) + } + {{/required}} + {{/properties}} + + return &{{#toUpper}}{{type}}{{/toUpper}}{ + {{#stuctProps}} + {{#properties}} + {{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}: _{{name}}, + {{/properties}} + {{/stuctProps}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/imported/enum-type/Enum%type%-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/enum-type/Enum%type%-go.mustache new file mode 100644 index 0000000000..72cd7bfeb6 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/enum-type/Enum%type%-go.mustache @@ -0,0 +1,41 @@ +package {{#pkgName}}{{#toSnakeCase}}{{namespace}}{{/toSnakeCase}}{{/pkgName}} + +type {{#toUpper}}{{type}}{{/toUpper}} int32 + +const ( +{{#stuctProps}} +{{#constants}} +{{#toUpper}}{{type}}{{/toUpper}}{{.}} = iota +{{/constants}} +{{#toFirstLower}}{{type}}{{/toFirstLower}}Max = iota +{{/stuctProps}} +) + +func Sanitize{{#toUpper}}{{type}}{{/toUpper}}Value(value int32) { + if !(value >= 0 && value < int32({{#toFirstLower}}{{type}}{{/toFirstLower}}Max)) { + panic("Invalid value for enum '{{#toUpper}}{{type}}{{/toUpper}}'") + } +} + +func Get{{#toUpper}}{{type}}{{/toUpper}}Value(key string) {{#toUpper}}{{type}}{{/toUpper}} { + switch key { + {{#constants}} + case "{{.}}": + return {{#toUpper}}{{type}}{{/toUpper}}{{.}} + {{/constants}} + default: + panic("Invalid key for enum '{{#toUpper}}{{type}}{{/toUpper}}'") + } +} + +func Get{{#toUpper}}{{type}}{{/toUpper}}Key(value {{#toUpper}}{{type}}{{/toUpper}}) string { + Sanitize{{#toUpper}}{{type}}{{/toUpper}}Value(int32(value)) + switch value { + {{#constants}} + case {{#toUpper}}{{type}}{{/toUpper}}{{.}}: + return "{{.}}" + {{/constants}} + default: + panic("Invalid value for enum '{{#toUpper}}{{type}}{{/toUpper}}'") + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/imported/env-type/Env%type%-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/env-type/Env%type%-go.mustache new file mode 100644 index 0000000000..70cc14ba31 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/env-type/Env%type%-go.mustache @@ -0,0 +1,30 @@ +package {{#pkgName}}{{#toSnakeCase}}{{namespace}}{{/toSnakeCase}}{{/pkgName}} +{{#makeImports}} + github.com/polywrap/go-wrap/msgpack, + {{#properties}} + {{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{^last}},{{/last}} + {{/properties}} +{{/makeImports}} +type {{#toUpper}}{{type}}{{/toUpper}} struct { +{{#stuctProps}} +{{#properties}} +{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} `json:"{{name}}"` +{{/properties}} +{{/stuctProps}} +} + +func {{#toUpper}}{{type}}{{/toUpper}}ToBuffer(value *{{#toUpper}}{{type}}{{/toUpper}}) []byte { + return serialize{{#toUpper}}{{type}}{{/toUpper}}(value) +} + +func {{#toUpper}}{{type}}{{/toUpper}}FromBuffer(data []byte) *{{#toUpper}}{{type}}{{/toUpper}} { + return deserialize{{#toUpper}}{{type}}{{/toUpper}}(data) +} + +func {{#toUpper}}{{type}}{{/toUpper}}Write(writer msgpack.Write, value *{{#toUpper}}{{type}}{{/toUpper}}) { + write{{#toUpper}}{{type}}{{/toUpper}}(writer, value) +} + +func {{#toUpper}}{{type}}{{/toUpper}}Read(reader msgpack.Read) *{{#toUpper}}{{type}}{{/toUpper}} { + return read{{#toUpper}}{{type}}{{/toUpper}}(reader) +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/imported/env-type/Env%type%Serialization-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/env-type/Env%type%Serialization-go.mustache new file mode 100644 index 0000000000..d84030967a --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/env-type/Env%type%Serialization-go.mustache @@ -0,0 +1,111 @@ +package {{#pkgName}}{{#toSnakeCase}}{{namespace}}{{/toSnakeCase}}{{/pkgName}} +{{#makeImports}} + github.com/polywrap/go-wrap/msgpack, + {{#properties}} + {{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{^last}},{{/last}} + {{/properties}} +{{/makeImports}} +func serialize{{#toUpper}}{{type}}{{/toUpper}}(value *{{#toUpper}}{{type}}{{/toUpper}}) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: {{#toUpper}}{{type}}{{/toUpper}}") + encoder := msgpack.NewWriteEncoder(ctx) + write{{#toUpper}}{{type}}{{/toUpper}}(encoder, value) + return encoder.Buffer() +} + +func write{{#toUpper}}{{type}}{{/toUpper}}(writer msgpack.Write, value *{{#toUpper}}{{type}}{{/toUpper}}) { + writer.WriteMapLength({{properties.length}}) + {{#properties}} + writer.Context().Push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property") + writer.WriteString("{{name}}") + {{#scalar}} + {{> serialize_scalar}} + {{/scalar}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> serialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> serialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> serialize_object}} + {{/object}} + {{#enum}} + {{> serialize_enum}} + {{/enum}} + writer.Context().Pop() + {{/properties}} +} + +func deserialize{{#toUpper}}{{type}}{{/toUpper}}(data []byte) *{{#toUpper}}{{type}}{{/toUpper}} { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: {{#toUpper}}{{type}}{{/toUpper}}") + reader := msgpack.NewReadDecoder(ctx, data) + return read{{#toUpper}}{{type}}{{/toUpper}}(reader) +} + +func read{{#toUpper}}{{type}}{{/toUpper}}(reader msgpack.Read) *{{#toUpper}}{{type}}{{/toUpper}} { + var ( + {{#stuctProps}} + {{#properties}} + _{{name}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} + {{#required}} + _{{name}}Set bool + {{/required}} + {{/properties}} + {{/stuctProps}} + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + {{#properties}} + case "{{name}}": + reader.Context().Push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property") + {{#scalar}} + {{> deserialize_scalar}} + {{/scalar}} + {{#enum}} + {{> deserialize_enum}} + {{/enum}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> deserialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> deserialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> deserialize_object}} + {{/object}} + {{#required}} + _{{name}}Set = true + {{/required}} + reader.Context().Pop() + {{/properties}} + } + reader.Context().Pop() + } + + {{#properties}} + {{#required}} + if !_{{name}}Set { + panic(reader.Context().PrintWithContext("Missing required property: '{{name}}: {{type}}'")) + } + {{/required}} + {{/properties}} + + return &{{#toUpper}}{{type}}{{/toUpper}}{ + {{#stuctProps}} + {{#properties}} + {{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}: _{{name}}, + {{/properties}} + {{/stuctProps}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/imported/interface-type/%type%-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/interface-type/%type%-go.mustache new file mode 100644 index 0000000000..bc55d77962 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/interface-type/%type%-go.mustache @@ -0,0 +1,19 @@ +package {{#pkgName}}{{#toSnakeCase}}{{namespace}}{{/toSnakeCase}}{{/pkgName}} + +{{#capabilities}} +{{#getImplementations}} +{{#enabled}} +import "github.com/polywrap/go-wrap/wrap" +{{/enabled}} +{{/getImplementations}} +{{/capabilities}} + +{{#capabilities}} +{{#getImplementations}} +{{#enabled}} +func {{#toUpper}}{{namespace}}{{/toUpper}}Implementations() []string { + return wrap.WrapGetImplementations("{{uri}}") +} +{{/enabled}} +{{/getImplementations}} +{{/capabilities}} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/imported/module-type/%type%Serialization-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/module-type/%type%Serialization-go.mustache new file mode 100644 index 0000000000..f3487aee8e --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/module-type/%type%Serialization-go.mustache @@ -0,0 +1,90 @@ +package {{#pkgName}}{{#toSnakeCase}}{{namespace}}{{/toSnakeCase}}{{/pkgName}} +{{#makeImports}} + github.com/polywrap/go-wrap/msgpack, + {{#arguments}} + {{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{^last}},{{/last}} + {{/arguments}} +{{/makeImports}} +{{#methods}} +type {{#toUpper}}{{namespace}}{{/toUpper}}_Args{{#toUpper}}{{name}}{{/toUpper}} struct { +{{#stuctProps}} +{{#arguments}} +{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} `json:"{{name}}"` +{{/arguments}} +{{/stuctProps}} +} + +func Serialize{{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}Args(value *{{#toUpper}}{{namespace}}{{/toUpper}}_Args{{#toUpper}}{{name}}{{/toUpper}}) []byte { + ctx := msgpack.NewContext("Serializing module-type: {{#toUpper}}{{name}}{{/toUpper}}") + encoder := msgpack.NewWriteEncoder(ctx) + Write{{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}Args(encoder, value) + return encoder.Buffer() +} + +func Write{{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}Args(writer msgpack.Write, value *{{#toUpper}}{{namespace}}{{/toUpper}}_Args{{#toUpper}}{{name}}{{/toUpper}}) { + {{#arguments.length}} + writer.WriteMapLength({{arguments.length}}) + {{/arguments.length}} + {{^arguments}} + writer.WriteMapLength(0) + {{/arguments}} + {{#arguments}} + writer.Context().Push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property") + writer.WriteString("{{name}}") + {{#scalar}} + {{> serialize_scalar}} + {{/scalar}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> serialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> serialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> serialize_object}} + {{/object}} + {{#enum}} + {{> serialize_enum}} + {{/enum}} + writer.Context().Pop() + {{/arguments}} +} + +func Deserialize{{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}Result(argsBuf []byte) {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}} { + ctx := msgpack.NewContext("Deserializing module-type: {{#toUpper}}{{name}}{{/toUpper}}") + reader := msgpack.NewReadDecoder(ctx, argsBuf) + + {{#return}} + reader.Context().Push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "reading function output") + var value {{#toWasm}}{{toGraphQLType}}{{/toWasm}} + {{#scalar}} + {{> value_deserialize_scalar}} + {{/scalar}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> value_deserialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> value_deserialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> value_deserialize_object}} + {{/object}} + {{#enum}} + {{> value_deserialize_enum}} + {{/enum}} + reader.Context().Pop() + return value + {{/return}} +} +{{^last}} + +{{/last}} +{{/methods}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/imported/module-type/%type%Wrapped-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/module-type/%type%Wrapped-go.mustache new file mode 100644 index 0000000000..86c2153a7f --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/module-type/%type%Wrapped-go.mustache @@ -0,0 +1,48 @@ +package {{#pkgName}}{{#toSnakeCase}}{{namespace}}{{/toSnakeCase}}{{/pkgName}} + +{{#methods.length}} +import ( + "github.com/polywrap/go-wrap/wrap" +) +{{/methods.length}} + +{{^isInterface}} +{{#methods}} +func {{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}(args *{{#toUpper}}{{namespace}}{{/toUpper}}_Args{{#toUpper}}{{name}}{{/toUpper}}) ({{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, error) { + argsBuf := Serialize{{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}Args(args) + var ( + err error + raw []byte + data {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}} + ) + raw, err = wrap.WrapSubinvoke("{{uri}}", "{{name}}", argsBuf) + if err == nil { + data = Deserialize{{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}Result(raw) + } + return data, err +} +{{^last}} + +{{/last}} +{{/methods}} +{{/isInterface}} +{{#isInterface}} +{{#methods}} +func {{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}(uri string, args *{{#toUpper}}{{namespace}}{{/toUpper}}_Args{{#toUpper}}{{name}}{{/toUpper}}) ({{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, error) { + argsBuf := Serialize{{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}Args(args) + var ( + err error + raw []byte + data {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}} + ) + raw, err = wrap.WrapSubinvokeImplementation("{{uri}}", uri, "{{name}}", argsBuf) + if err == nil { + data = Deserialize{{#toUpper}}{{namespace}}{{/toUpper}}_{{#toUpper}}{{name}}{{/toUpper}}Result(raw) + } + return data, err +} +{{^last}} + +{{/last}} +{{/methods}} +{{/isInterface}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/imported/object-type/Object%type%-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/object-type/Object%type%-go.mustache new file mode 100644 index 0000000000..70cc14ba31 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/object-type/Object%type%-go.mustache @@ -0,0 +1,30 @@ +package {{#pkgName}}{{#toSnakeCase}}{{namespace}}{{/toSnakeCase}}{{/pkgName}} +{{#makeImports}} + github.com/polywrap/go-wrap/msgpack, + {{#properties}} + {{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{^last}},{{/last}} + {{/properties}} +{{/makeImports}} +type {{#toUpper}}{{type}}{{/toUpper}} struct { +{{#stuctProps}} +{{#properties}} +{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} `json:"{{name}}"` +{{/properties}} +{{/stuctProps}} +} + +func {{#toUpper}}{{type}}{{/toUpper}}ToBuffer(value *{{#toUpper}}{{type}}{{/toUpper}}) []byte { + return serialize{{#toUpper}}{{type}}{{/toUpper}}(value) +} + +func {{#toUpper}}{{type}}{{/toUpper}}FromBuffer(data []byte) *{{#toUpper}}{{type}}{{/toUpper}} { + return deserialize{{#toUpper}}{{type}}{{/toUpper}}(data) +} + +func {{#toUpper}}{{type}}{{/toUpper}}Write(writer msgpack.Write, value *{{#toUpper}}{{type}}{{/toUpper}}) { + write{{#toUpper}}{{type}}{{/toUpper}}(writer, value) +} + +func {{#toUpper}}{{type}}{{/toUpper}}Read(reader msgpack.Read) *{{#toUpper}}{{type}}{{/toUpper}} { + return read{{#toUpper}}{{type}}{{/toUpper}}(reader) +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/imported/object-type/Object%type%Serialization-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/object-type/Object%type%Serialization-go.mustache new file mode 100644 index 0000000000..d584c641cc --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/imported/object-type/Object%type%Serialization-go.mustache @@ -0,0 +1,111 @@ +package {{#pkgName}}{{#toSnakeCase}}{{namespace}}{{/toSnakeCase}}{{/pkgName}} +{{#makeImports}} + github.com/polywrap/go-wrap/msgpack, + {{#properties}} + {{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{^last}},{{/last}} + {{/properties}} +{{/makeImports}} +func serialize{{#toUpper}}{{type}}{{/toUpper}}(value *{{#toUpper}}{{type}}{{/toUpper}}) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: {{#toUpper}}{{type}}{{/toUpper}}") + encoder := msgpack.NewWriteEncoder(ctx) + write{{#toUpper}}{{type}}{{/toUpper}}(encoder, value) + return encoder.Buffer() +} + +func write{{#toUpper}}{{type}}{{/toUpper}}(writer msgpack.Write, value *{{#toUpper}}{{type}}{{/toUpper}}) { + writer.WriteMapLength({{properties.length}}) + {{#properties}} + writer.Context().Push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property") + writer.WriteString("{{name}}") + {{#scalar}} + {{> serialize_scalar}} + {{/scalar}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> serialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> serialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> serialize_object}} + {{/object}} + {{#enum}} + {{> serialize_enum}} + {{/enum}} + writer.Context().Pop() + {{/properties}} +} + +func deserialize{{#toUpper}}{{type}}{{/toUpper}}(data []byte) *{{#toUpper}}{{type}}{{/toUpper}} { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: {{#toUpper}}{{type}}{{/toUpper}}") + reader := msgpack.NewReadDecoder(ctx, data) + return read{{#toUpper}}{{type}}{{/toUpper}}(reader) +} + +func read{{#toUpper}}{{type}}{{/toUpper}}(reader msgpack.Read) *{{#toUpper}}{{type}}{{/toUpper}} { + var ( + {{#stuctProps}} + {{#properties}} + _{{name}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} + {{#required}} + _{{name}}Set bool + {{/required}} + {{/properties}} + {{/stuctProps}} + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + {{#properties}} + case "{{name}}": + reader.Context().Push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property") + {{#scalar}} + {{> deserialize_scalar}} + {{/scalar}} + {{#enum}} + {{> deserialize_enum}} + {{/enum}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> deserialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> deserialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> deserialize_object}} + {{/object}} + {{#required}} + _{{name}}Set = true + {{/required}} + reader.Context().Pop() + {{/properties}} + } + reader.Context().Pop() + } + + {{#properties}} + {{#required}} + if !_{{name}}Set { + panic(reader.Context().PrintWithContext("Missing required property: '{{name}}: {{type}}'")) + } + {{/required}} + {{/properties}} + + return &{{#toUpper}}{{type}}{{/toUpper}}{ + {{#stuctProps}} + {{#properties}} + {{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}: _{{name}}, + {{/properties}} + {{/stuctProps}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/interface-type/%type%-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/interface-type/%type%-go.mustache new file mode 100644 index 0000000000..953c66a21a --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/interface-type/%type%-go.mustache @@ -0,0 +1,19 @@ +package interfaces + +{{#capabilities}} +{{#getImplementations}} +{{#enabled}} +import "github.com/polywrap/go-wrap/wrap" +{{/enabled}} +{{/getImplementations}} +{{/capabilities}} + +{{#capabilities}} +{{#getImplementations}} +{{#enabled}} +func {{#toUpper}}{{namespace}}{{/toUpper}}_GetImplementations() []string { + return wrap.WrapGetImplementations("{{uri}}") +} +{{/enabled}} +{{/getImplementations}} +{{/capabilities}} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/main/main-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/main/main-go.mustache new file mode 100644 index 0000000000..583f70dacd --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/main/main-go.mustache @@ -0,0 +1,24 @@ +package main + +import ( + "{{goImport}}/module/wrap/module_wrapped" + "github.com/polywrap/go-wrap/wrap" +) + +//export _wrap_invoke +func _wrap_invoke(methodSize, argsSize, envSize uint32) bool { + args := wrap.WrapInvokeArgs(methodSize, argsSize) + switch args.Method { + {{#moduleType}} + {{#methods}} + case "{{name}}": + return wrap.WrapInvoke(args, envSize, module_wrapped.{{#toUpper}}{{name}}{{/toUpper}}Wrapped) + {{/methods}} + {{/moduleType}} + default: + return wrap.WrapInvoke(args, envSize, nil) + } +} + +func main() { +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/module-type/module_wrapped/%type%Serialization-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/module-type/module_wrapped/%type%Serialization-go.mustache new file mode 100644 index 0000000000..57d8c176e6 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/module-type/module_wrapped/%type%Serialization-go.mustache @@ -0,0 +1,119 @@ +package module_wrapped +{{#makeImports}} + github.com/polywrap/go-wrap/msgpack, + {{#needsTypes}} + . {{goImport}}/module/wrap/types, + {{/needsTypes}} + {{#needsImportedNamespaces}} + . {{goImport}}/module/wrap/imported/{{#pkgName}}{{#toSnakeCase}}{{.}}{{/toSnakeCase}}{{/pkgName}}, + {{/needsImportedNamespaces}} + {{#methods}} + {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, + {{/methods}} +{{/makeImports}} +{{#methods}} +{{#arguments.length}} +func Deserialize{{#toUpper}}{{name}}{{/toUpper}}Args(argsBuf []byte) *Args{{#toUpper}}{{name}}{{/toUpper}} { + ctx := msgpack.NewContext("Deserializing module-type: {{#toUpper}}{{name}}{{/toUpper}}") + reader := msgpack.NewReadDecoder(ctx, argsBuf) + + var ( + {{#stuctProps}} + {{#arguments}} + _{{name}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} + {{#required}} + _{{name}}Set bool + {{/required}} + {{/arguments}} + {{/stuctProps}} + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + {{#arguments}} + case "{{name}}": + reader.Context().Push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property") + {{#scalar}} + {{> deserialize_scalar}} + {{/scalar}} + {{#enum}} + {{> deserialize_enum}} + {{/enum}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> deserialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> deserialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> deserialize_object}} + {{/object}} + {{#required}} + _{{name}}Set = true + {{/required}} + reader.Context().Pop() + {{/arguments}} + } + reader.Context().Pop() + } + + {{#arguments}} + {{#required}} + if !_{{name}}Set { + panic(reader.Context().PrintWithContext("Missing required property: '{{name}}: {{type}}'")) + } + {{/required}} + {{/arguments}} + + return &Args{{#toUpper}}{{name}}{{/toUpper}}{ + {{#stuctProps}} + {{#arguments}} + {{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}: _{{name}}, + {{/arguments}} + {{/stuctProps}} + } +} +{{/arguments.length}} + +func Serialize{{#toUpper}}{{name}}{{/toUpper}}Result(value {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}) []byte { + ctx := msgpack.NewContext("Serializing module-type: {{#toUpper}}{{name}}{{/toUpper}}") + encoder := msgpack.NewWriteEncoder(ctx) + Write{{#toUpper}}{{name}}{{/toUpper}}Result(encoder, value); + return encoder.Buffer() +} + +func Write{{#toUpper}}{{name}}{{/toUpper}}Result(writer msgpack.Write, value {{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}) { + {{#return}} + writer.Context().Push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property") + {{#scalar}} + {{> value_serialize_scalar}} + {{/scalar}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> value_serialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> value_serialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> value_serialize_object}} + {{/object}} + {{#enum}} + {{> value_serialize_enum}} + {{/enum}} + writer.Context().Pop() + {{/return}} +} +{{^last}} + +{{/last}} +{{/methods}} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/module-type/module_wrapped/%type%Wrapped-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/module-type/module_wrapped/%type%Wrapped-go.mustache new file mode 100644 index 0000000000..9e19e28d88 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/module-type/module_wrapped/%type%Wrapped-go.mustache @@ -0,0 +1,31 @@ +package module_wrapped +{{#makeImports}} + {{#methods}}{{#env}}github.com/polywrap/go-wrap/wrap,. {{goImport}}/module/wrap/types,{{/env}}{{/methods}} + {{goImport}}/module as methods, +{{/makeImports}} +{{#methods}} +func {{#toUpper}}{{name}}{{/toUpper}}Wrapped(argsBuf []byte, envSize uint32) []byte { + {{#env}} + var env *Env + {{#required}} + if envSize == 0 { + panic("Environment is not set, and it is required by method 'objectMethod'") + } + {{/required}} + if envSize > 0 { + envBuf := wrap.WrapLoadEnv(envSize) + env = EnvFromBuffer(envBuf) + } + {{/env}} + + {{#arguments.length}} + args := Deserialize{{#toUpper}}{{name}}{{/toUpper}}Args(argsBuf) + {{/arguments.length}} + + result := methods.{{#toUpper}}{{name}}{{/toUpper}}({{#arguments.length}}args{{#env}},{{/env}}{{/arguments.length}}{{#env}}env{{/env}}) + return Serialize{{#toUpper}}{{name}}{{/toUpper}}Result(result) +} +{{^last}} + +{{/last}} +{{/methods}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/module-type/types/%type%Args-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/module-type/types/%type%Args-go.mustache new file mode 100644 index 0000000000..4d7a27be0f --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/module-type/types/%type%Args-go.mustache @@ -0,0 +1,25 @@ +package types +{{#makeImports}} + {{#importedTypes}} + . {{goImport}}/module/wrap/imported/{{#pkgName}}{{#toSnakeCase}}{{namespace}}{{/toSnakeCase}}{{/pkgName}}, + {{/importedTypes}} + {{#methods}} + {{#arguments}} + {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, + {{/arguments}} + {{/methods}} +{{/makeImports}} +{{#methods}} +{{#arguments.length}} +type Args{{#toUpper}}{{name}}{{/toUpper}} struct { +{{#stuctProps}} +{{#arguments}} +{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} `json:"{{name}}"` +{{/arguments}} +{{/stuctProps}} +} +{{/arguments.length}} +{{^last}} + +{{/last}} +{{/methods}} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/object-type/Object%type%-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/object-type/Object%type%-go.mustache new file mode 100644 index 0000000000..fbd7e01f18 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/object-type/Object%type%-go.mustache @@ -0,0 +1,30 @@ +package types +{{#makeImports}} + github.com/polywrap/go-wrap/msgpack, + {{#properties}} + {{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{^last}},{{/last}} + {{/properties}} +{{/makeImports}} +type {{#toUpper}}{{type}}{{/toUpper}} struct { +{{#stuctProps}} +{{#properties}} +{{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} `json:"{{name}}"` +{{/properties}} +{{/stuctProps}} +} + +func {{#toUpper}}{{type}}{{/toUpper}}ToBuffer(value *{{#toUpper}}{{type}}{{/toUpper}}) []byte { + return serialize{{#toUpper}}{{type}}{{/toUpper}}(value) +} + +func {{#toUpper}}{{type}}{{/toUpper}}FromBuffer(data []byte) *{{#toUpper}}{{type}}{{/toUpper}} { + return deserialize{{#toUpper}}{{type}}{{/toUpper}}(data) +} + +func {{#toUpper}}{{type}}{{/toUpper}}Write(writer msgpack.Write, value *{{#toUpper}}{{type}}{{/toUpper}}) { + write{{#toUpper}}{{type}}{{/toUpper}}(writer, value) +} + +func {{#toUpper}}{{type}}{{/toUpper}}Read(reader msgpack.Read) *{{#toUpper}}{{type}}{{/toUpper}} { + return read{{#toUpper}}{{type}}{{/toUpper}}(reader) +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/object-type/Object%type%Serialization-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/object-type/Object%type%Serialization-go.mustache new file mode 100644 index 0000000000..de60363f36 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/object-type/Object%type%Serialization-go.mustache @@ -0,0 +1,110 @@ +package types +{{#makeImports}} + github.com/polywrap/go-wrap/msgpack, + {{#properties}} + {{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{^last}},{{/last}} + {{/properties}} +{{/makeImports}} +func serialize{{#toUpper}}{{type}}{{/toUpper}}(value *{{#toUpper}}{{type}}{{/toUpper}}) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: {{#toUpper}}{{type}}{{/toUpper}}") + encoder := msgpack.NewWriteEncoder(ctx) + write{{#toUpper}}{{type}}{{/toUpper}}(encoder, value) + return encoder.Buffer() +} + +func write{{#toUpper}}{{type}}{{/toUpper}}(writer msgpack.Write, value *{{#toUpper}}{{type}}{{/toUpper}}) { + writer.WriteMapLength({{properties.length}}) + {{#properties}} + writer.Context().Push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property") + writer.WriteString("{{name}}") + {{#scalar}} + {{> serialize_scalar}} + {{/scalar}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> serialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> serialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> serialize_object}} + {{/object}} + {{#enum}} + {{> serialize_enum}} + {{/enum}} + writer.Context().Pop() + {{/properties}} +} + +func deserialize{{#toUpper}}{{type}}{{/toUpper}}(data []byte) *{{#toUpper}}{{type}}{{/toUpper}} { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: {{#toUpper}}{{type}}{{/toUpper}}") + reader := msgpack.NewReadDecoder(ctx, data) + return read{{#toUpper}}{{type}}{{/toUpper}}(reader) +} + +func read{{#toUpper}}{{type}}{{/toUpper}}(reader msgpack.Read) *{{#toUpper}}{{type}}{{/toUpper}} { + var ( + {{#stuctProps}} + {{#properties}} + _{{name}} {{#toWasm}}{{toGraphQLType}}{{/toWasm}} + {{#required}} + _{{name}}Set bool + {{/required}} + {{/properties}} + {{/stuctProps}} + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + {{#properties}} + case "{{name}}": + reader.Context().Push(field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property") + {{#scalar}} + {{> deserialize_scalar}} + {{/scalar}} + {{#enum}} + {{> deserialize_enum}} + {{/enum}} + {{#array}} + {{#startIter}}{{/startIter}} + {{> deserialize_array}} + {{#stopIter}}{{/stopIter}} + {{/array}} + {{#map}} + {{#startIter}}{{/startIter}} + {{> deserialize_map}} + {{#stopIter}}{{/stopIter}} + {{/map}} + {{#object}} + {{> deserialize_object}} + {{/object}} + {{#required}} + _{{name}}Set = true + {{/required}} + reader.Context().Pop() + {{/properties}} + } + reader.Context().Pop() + } + + {{#properties}} + {{#required}} + if !_{{name}}Set { + panic(reader.Context().PrintWithContext("Missing required property: '{{name}}: {{type}}'")) + } + {{/required}} + {{/properties}} + return &{{#toUpper}}{{type}}{{/toUpper}}{ + {{#stuctProps}} + {{#properties}} + {{#toUpper}}{{#handleKeywords}}{{name}}{{/handleKeywords}}{{/toUpper}}: _{{name}}, + {{/properties}} + {{/stuctProps}} + } +} diff --git a/packages/schema/bind/src/bindings/golang/wasm/templates/wrap-go.mustache b/packages/schema/bind/src/bindings/golang/wasm/templates/wrap-go.mustache new file mode 100644 index 0000000000..a1080fa322 --- /dev/null +++ b/packages/schema/bind/src/bindings/golang/wasm/templates/wrap-go.mustache @@ -0,0 +1 @@ +package wrap diff --git a/packages/schema/bind/src/bindings/index.ts b/packages/schema/bind/src/bindings/index.ts index c6913c970c..6cb3df38f6 100644 --- a/packages/schema/bind/src/bindings/index.ts +++ b/packages/schema/bind/src/bindings/index.ts @@ -1,11 +1,9 @@ import { GenerateBindingFn } from "./types"; import { BindLanguage } from "../"; -import * as AssemblyScript from "./assemblyscript"; -import * as Rust from "./rust"; -import * as Python from "./python"; -import * as TypeScript from "./typescript"; +import * as WrapBindgen from "./wrap-bindgen"; +import * as Golang from "./golang"; -export { AssemblyScript, Rust, TypeScript }; +export { Golang }; export * from "./types"; export * from "./utils"; @@ -13,18 +11,40 @@ export function getGenerateBindingFn( bindLanguage: BindLanguage ): GenerateBindingFn { switch (bindLanguage) { - case "wasm-as": - return AssemblyScript.Wasm.generateBinding; - case "wasm-rs": - return Rust.Wasm.generateBinding; + case "wrap-as": + return WrapBindgen.getGenerateBindingFn( + "https://github.com/polywrap/wrap-abi-bindgen/tree/wrap-0.1/implementations/wrap-assemblyscript" + ); + case "wrap-rs": + return WrapBindgen.getGenerateBindingFn( + "https://github.com/polywrap/wrap-abi-bindgen/tree/wrap-0.1/implementations/wrap-rust" + ); + case "wrap-go": + return Golang.Wasm.generateBinding; case "plugin-ts": - return TypeScript.Plugin.generateBinding; + return WrapBindgen.getGenerateBindingFn( + "https://github.com/polywrap/wrap-abi-bindgen/tree/wrap-0.1/implementations/plugin-typescript" + ); case "plugin-rs": - return Rust.Plugin.generateBinding; + return WrapBindgen.getGenerateBindingFn( + "https://github.com/polywrap/wrap-abi-bindgen/tree/wrap-0.1/implementations/plugin-rust" + ); case "plugin-py": - return Python.Plugin.generateBinding; + return WrapBindgen.getGenerateBindingFn( + "https://github.com/polywrap/wrap-abi-bindgen/tree/wrap-0.1/implementations/plugin-python" + ); + case "plugin-kt": + return WrapBindgen.getGenerateBindingFn( + "https://github.com/polywrap/wrap-abi-bindgen/tree/wrap-0.1/implementations/plugin-kotlin" + ); + case "plugin-swift": + return WrapBindgen.getGenerateBindingFn( + "https://github.com/polywrap/wrap-abi-bindgen/tree/wrap-0.1/implementations/plugin-swift" + ); case "app-ts": - return TypeScript.App.generateBinding; + return WrapBindgen.getGenerateBindingFn( + "https://github.com/polywrap/wrap-abi-bindgen/tree/wrap-0.1/implementations/app-typescript" + ); default: throw Error(`Error: Language binding unsupported - ${bindLanguage}`); } diff --git a/packages/schema/bind/src/bindings/python/functions.ts b/packages/schema/bind/src/bindings/python/functions.ts deleted file mode 100644 index 6aa4e0119c..0000000000 --- a/packages/schema/bind/src/bindings/python/functions.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { MustacheFn } from "../types"; -import { isKeyword } from "./types"; - -// check if any of the keywords match the property name; -// if there's a match, insert `r_` at the beginning of the property name. -// `_` has special meaning in Python, so we use `r_` to avoid conflicts. -export const detectKeyword: MustacheFn = () => { - return (value: string, render: (template: string) => string): string => { - const type = render(value); - if (isKeyword(type)) { - return "r_" + type; // `r_` is the prefix we use for reserved keywords - } - return type; - }; -}; - -function replaceAt(str: string, index: number, replacement: string): string { - return ( - str.substr(0, index) + replacement + str.substr(index + replacement.length) - ); -} - -function insertAt(str: string, index: number, insert: string): string { - return str.substr(0, index) + insert + str.substr(index); -} - -function removeAt(str: string, index: number): string { - return str.substr(0, index) + str.substr(index + 1); -} - -export const toLower: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - - for (let i = 0; i < type.length; ++i) { - const char = type.charAt(i); - const lower = char.toLowerCase(); - - if (char !== lower) { - // Replace the uppercase char w/ the lowercase version - type = replaceAt(type, i, lower); - - if (i !== 0 && type[i - 1] !== "_") { - // Make sure all lowercase conversions have an underscore before them - type = insertAt(type, i, "_"); - } - } - } - - return type; - }; -}; - -export const toUpper: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - - // First character must always be upper case - const firstChar = type.charAt(0); - const firstUpper = firstChar.toUpperCase(); - type = replaceAt(type, 0, firstUpper); - - // Look for any underscores, remove them if they exist, and make next letter uppercase - for (let i = 0; i < type.length; ++i) { - const char = type.charAt(i); - - if (char === "_") { - const nextChar = type.charAt(i + 1); - const nextCharUpper = nextChar.toUpperCase(); - type = replaceAt(type, i + 1, nextCharUpper); - type = removeAt(type, i); - } - } - - return type; - }; -}; - -export const toPython: MustacheFn = () => { - return _toPython; -}; - -const _toPython = (value: string, render: (template: string) => string) => { - let type = render(value); - - let optional = false; - if (type[type.length - 1] === "!") { - type = type.substring(0, type.length - 1); - } else { - optional = true; - } - - if (type[0] === "[") { - return toPythonList(type, optional); - } - - if (type.startsWith("Map<")) { - return toPythonGenericMap(type, optional); - } - - switch (type) { - case "Int": - case "Int8": - case "Int16": - case "Int32": - case "Int64": - case "UInt": - case "UInt32": - case "UInt8": - case "UInt16": - case "UInt64": - type = "int"; - break; - case "JSON": - case "String": - case "BigInt": - case "BigNumber": - type = "str"; - break; - case "Boolean": - type = "bool"; - break; - case "Bytes": - type = "bytes"; - break; - default: - if (type.includes("Enum_")) { - type = type.replace("Enum_", ""); - } - type = toUpper()(type, (str) => str); - type = detectKeyword()(type, (str) => str); - type = `"${type}"`; - } - - return applyOptional(type, optional); -}; - -const toPythonList = (type: string, optional: boolean): string => { - const result = type.match(/(\[)([[\]A-Za-z0-9_.!]+)(\])/); - - if (!result || result.length !== 4) { - throw Error(`Invalid List: ${type}`); - } - - const tsType = _toPython(result[2], (str) => str); - return applyOptional("list[" + tsType + "]", optional); -}; - -const toPythonGenericMap = (type: string, optional: boolean): string => { - const openAngleBracketIdx = type.indexOf("<"); - const closeAngleBracketIdx = type.lastIndexOf(">"); - - const keyValTypes = type.substring( - openAngleBracketIdx + 1, - closeAngleBracketIdx - ); - - const firstCommaIdx = keyValTypes.indexOf(","); - const keyType = keyValTypes.substring(0, firstCommaIdx).trim(); - const valType = keyValTypes.substring(firstCommaIdx + 1).trim(); - - const tsKeyType = _toPython(keyType, (str) => str); - const tsValType = _toPython(valType, (str) => str); - - return applyOptional(`GenericMap[${tsKeyType}, ${tsValType}]`, optional); -}; - -const applyOptional = (type: string, optional: boolean): string => { - if (optional) { - return `Optional[${type}]`; - } else { - return type; - } -}; diff --git a/packages/schema/bind/src/bindings/python/index.ts b/packages/schema/bind/src/bindings/python/index.ts deleted file mode 100644 index 8587b3391c..0000000000 --- a/packages/schema/bind/src/bindings/python/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * as Plugin from "./plugin"; -export * as Functions from "./functions"; -export * as Types from "./types"; diff --git a/packages/schema/bind/src/bindings/python/plugin/index.ts b/packages/schema/bind/src/bindings/python/plugin/index.ts deleted file mode 100644 index 086605fe7e..0000000000 --- a/packages/schema/bind/src/bindings/python/plugin/index.ts +++ /dev/null @@ -1,86 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import * as Functions from "../functions"; -import { GenerateBindingFn, renderTemplates } from "../.."; -import { BindOptions, BindOutput } from "../../.."; -import { addEnumMembers } from "../transformers"; - -import { - transformAbi, - extendType, - addFirstLast, - toPrefixedGraphQLType, - methodParentPointers, - interfaceUris, -} from "@polywrap/schema-parse"; -import { WrapAbi } from "@polywrap/wrap-manifest-types-js"; -import path from "path"; -import { latestWrapManifestVersion } from "@polywrap/wrap-manifest-types-js"; - -export { Functions }; - -const templatePath = (subpath: string) => - path.join(__dirname, "./templates", subpath); - -const sort = (obj: Record) => - Object.keys(obj || {}) - .sort() - .reduce((map: Record, key: string) => { - if (typeof obj[key] === "object") { - map[key] = sort(obj[key] as Record); - - if (Array.isArray(obj[key])) { - map[key] = Object.values(map[key] as Record); - } - } else { - map[key] = obj[key]; - } - return map; - }, {}); - -export const generateBinding: GenerateBindingFn = ( - options: BindOptions -): BindOutput => { - const escapedAbi = JSON.stringify( - sort((options.abi as unknown) as Record) - ).replace(/\\n/g, "\\\\n"); - - const formattedAbi = JSON.stringify(JSON.parse(escapedAbi), null, 2); - - // Apply Abi transforms - const abi = applyTransforms(options.abi); - - // Generate Bindings - const result: BindOutput = { - output: { - entries: [], - }, - outputDirAbs: options.outputDirAbs, - }; - const output = result.output; - const manifest = { - name: options.projectName, - type: "plugin", - version: latestWrapManifestVersion, - abi: formattedAbi, - }; - - output.entries = renderTemplates(templatePath(""), { ...abi, manifest }, {}); - - return result; -}; - -function applyTransforms(abi: WrapAbi): WrapAbi { - const transforms = [ - extendType(Functions), - addFirstLast, - toPrefixedGraphQLType, - methodParentPointers(), - interfaceUris(), - addEnumMembers, - ]; - - for (const transform of transforms) { - abi = transformAbi(abi, transform); - } - return abi; -} diff --git a/packages/schema/bind/src/bindings/python/plugin/templates/__init__-py.mustache b/packages/schema/bind/src/bindings/python/plugin/templates/__init__-py.mustache deleted file mode 100644 index d2ad6b3725..0000000000 --- a/packages/schema/bind/src/bindings/python/plugin/templates/__init__-py.mustache +++ /dev/null @@ -1,6 +0,0 @@ -# NOTE: This is an auto-generated file. All modifications will be overwritten. -# type: ignore - -from .types import * -from .module import * -from .wrap_info import * diff --git a/packages/schema/bind/src/bindings/python/plugin/templates/module-py.mustache b/packages/schema/bind/src/bindings/python/plugin/templates/module-py.mustache deleted file mode 100644 index 76184395ef..0000000000 --- a/packages/schema/bind/src/bindings/python/plugin/templates/module-py.mustache +++ /dev/null @@ -1,54 +0,0 @@ -# NOTE: This is an auto-generated file. All modifications will be overwritten. -# type: ignore -from __future__ import annotations - -from abc import abstractmethod -from typing import TypeVar, Generic, TypedDict, Optional - -from .types import * - -from polywrap_core import InvokerClient -from polywrap_plugin import PluginModule -from polywrap_msgpack import GenericMap - -TConfig = TypeVar("TConfig") - - -{{#moduleType}} -{{#methods}} -Args{{#toUpper}}{{name}}{{/toUpper}} = TypedDict("Args{{#toUpper}}{{name}}{{/toUpper}}", { - {{#arguments}} - "{{name}}": {{#toPython}}{{toGraphQLType}}{{/toPython}}{{^last}},{{/last}} - {{/arguments}} -}) - -{{/methods}} -{{/moduleType}} - -class Module(Generic[TConfig], PluginModule[TConfig]): - def __new__(cls, *args, **kwargs): - # NOTE: This is used to dynamically add WRAP ABI compatible methods to the class - instance = super().__new__(cls) - {{#moduleType}} - {{#methods}} - setattr(instance, "{{name}}", instance.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}) - {{/methods}} - {{/moduleType}} - return instance - - {{#moduleType}} - {{#methods}} - @abstractmethod - def {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}( - self, - args: Args{{#toUpper}}{{name}}{{/toUpper}}, - client: InvokerClient, - {{^env}}env: None{{/env}}{{#env}}env: {{^required}}Optional[{{/required}}Env{{^required}}] = None{{/required}}{{/env}} - ) -> {{#return}}{{#toPython}}{{toGraphQLType}}{{/toPython}}{{/return}}: - pass - {{^last}} - - {{/last}} - {{/methods}} - {{/moduleType}} - diff --git a/packages/schema/bind/src/bindings/python/plugin/templates/types-py.mustache b/packages/schema/bind/src/bindings/python/plugin/templates/types-py.mustache deleted file mode 100644 index ea1a1886a2..0000000000 --- a/packages/schema/bind/src/bindings/python/plugin/templates/types-py.mustache +++ /dev/null @@ -1,169 +0,0 @@ -# NOTE: This is an auto-generated file. All modifications will be overwritten. -# type: ignore -from __future__ import annotations - -from typing import TypedDict, Optional -from enum import IntEnum - -from polywrap_core import InvokerClient, Uri -from polywrap_msgpack import GenericMap - - -### Env START ### - -{{#envType}} -{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} = TypedDict("{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}", { - {{#properties}} - "{{name}}": {{#toPython}}{{toGraphQLType}}{{/toPython}}, - {{/properties}} -}) - -{{/envType}} -### Env END ### - -### Objects START ### - -{{#objectTypes}} -{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} = TypedDict("{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}", { - {{#properties}} - "{{name}}": {{#toPython}}{{toGraphQLType}}{{/toPython}}, - {{/properties}} -}) - -{{/objectTypes}} -### Objects END ### - -### Enums START ### -{{#enumTypes}} -class {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}(IntEnum): - {{#members}} - {{#detectKeyword}}{{name}}{{/detectKeyword}} = {{value}}, "{{value}}", "{{name}}" - {{/members}} - - def __new__(cls, value: int, *aliases: str): - obj = int.__new__(cls) - obj._value_ = value - for alias in aliases: - cls._value2member_map_[alias] = obj - return obj - -{{/enumTypes}} -### Enums END ### - -### Imported Objects START ### - -{{#importedObjectTypes}} -# URI: "{{uri}}" # -{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} = TypedDict("{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}", { - {{#properties}} - "{{name}}": {{#toPython}}{{toGraphQLType}}{{/toPython}}, - {{/properties}} -}) - -{{/importedObjectTypes}} -### Imported Objects END ### - -### Imported Enums START ### - -{{#importedEnumTypes}} -# URI: "{{uri}}" # -class {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}(IntEnum): - {{#members}} - {{#detectKeyword}}{{name}}{{/detectKeyword}} = {{value}}, "{{value}}", "{{name}}" - {{/members}} - - def __new__(cls, value: int, *aliases: str): - obj = int.__new__(cls) - obj._value_ = value - for alias in aliases: - cls._value2member_map_[alias] = obj - return obj - -{{/importedEnumTypes}} - -### Imported Enums END ### - -### Imported Modules START ### - -{{#importedModuleTypes}} -{{#methods}} -# URI: "{{parent.uri}}" # -{{#toUpper}}{{parent.type}}{{/toUpper}}Args{{#toUpper}}{{name}}{{/toUpper}} = TypedDict("{{#toUpper}}{{parent.type}}{{/toUpper}}Args{{#toUpper}}{{name}}{{/toUpper}}", { - {{#arguments}} - "{{name}}": {{#toPython}}{{toGraphQLType}}{{/toPython}}, - {{/arguments}} -}) - -{{/methods}} -# URI: "{{uri}}" # -{{^isInterface}} -class {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}: - {{#methods}} - @staticmethod - def {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}( - args: {{#toUpper}}{{parent.type}}{{/toUpper}}Args{{#toUpper}}{{name}}{{/toUpper}}, - client: InvokerClient - ) -> {{#return}}{{#toPython}}{{toGraphQLType}}{{/toPython}}{{/return}}: - return client.invoke( - uri=Uri.from_str("{{parent.uri}}"), - method="{{name}}", - args=args, - ) - {{^last}} - - {{/last}} - {{/methods}} - - -{{/isInterface}} -{{#isInterface}} -class {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}: - INTERFACE_URI: Uri = Uri.from_str("{{uri}}") - uri: Uri - - def __init__(self, uri: Uri): - self.uri = uri - - {{#methods}} - def {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}( - self, - args: {{#toUpper}}{{parent.type}}{{/toUpper}}Args{{#toUpper}}{{name}}{{/toUpper}}, - client: InvokerClient - ) -> {{#return}}{{#toPython}}{{toGraphQLType}}{{/toPython}}{{/return}}: - return client.invoke( - uri=self.uri, - method="{{name}}", - args=args, - ) - {{^last}} - - {{/last}} - {{/methods}} - -{{/isInterface}} -{{/importedModuleTypes}} -### Imported Modules END ### - -### Interface START ### - -{{#interfaceTypes.length}} -{{#interfaceTypes}} - -class {{#detectKeyword}}{{#toUpper}}{{namespace}}{{/toUpper}}{{/detectKeyword}}: - URI: Uri = Uri.from_str("{{uri}}") - - {{#capabilities}} - {{#getImplementations}} - {{#enabled}} - def get_implementations( - client: InvokerClient - ) -> list[str]: - impls = client.getImplementations(self.uri) - return [impl.uri for impl in impls] - {{/enabled}} - {{/getImplementations}} - {{/capabilities}} -{{/interfaceTypes}} -{{/interfaceTypes.length}} - -### Interface END ### diff --git a/packages/schema/bind/src/bindings/python/plugin/templates/wrap_info-py.mustache b/packages/schema/bind/src/bindings/python/plugin/templates/wrap_info-py.mustache deleted file mode 100644 index a8f991aa58..0000000000 --- a/packages/schema/bind/src/bindings/python/plugin/templates/wrap_info-py.mustache +++ /dev/null @@ -1,20 +0,0 @@ -# NOTE: This is an auto-generated file. All modifications will be overwritten. -# type: ignore -from __future__ import annotations - -import json - -from polywrap_manifest import WrapManifest - -{{#manifest}} -abi = json.loads(""" -{{abi}} -""") - -manifest = WrapManifest.parse_obj({ - "name": "{{name}}", - "type": "{{type}}", - "version": "{{version}}", - "abi": abi, -}) -{{/manifest}} diff --git a/packages/schema/bind/src/bindings/python/transformers.ts b/packages/schema/bind/src/bindings/python/transformers.ts deleted file mode 100644 index a74fd5c9b2..0000000000 --- a/packages/schema/bind/src/bindings/python/transformers.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { AbiTransforms } from "@polywrap/schema-parse"; -import { EnumDefinition } from "@polywrap/wrap-manifest-types-js"; - -export const addEnumMembers: AbiTransforms = { - enter: { - // eslint-disable-next-line @typescript-eslint/naming-convention - EnumDefinition: (def: EnumDefinition): EnumDefinition => { - if (!def.constants) { - return { ...def }; - } - - const members: Array> = []; - let value = 0; - - for (const constant of def.constants) { - members.push({ - name: constant, - value: value, - }); - value += 1; - } - - return { - ...def, - members, - } as EnumDefinition; - }, - }, -}; diff --git a/packages/schema/bind/src/bindings/python/types.ts b/packages/schema/bind/src/bindings/python/types.ts deleted file mode 100644 index 7e5d045ccf..0000000000 --- a/packages/schema/bind/src/bindings/python/types.ts +++ /dev/null @@ -1,199 +0,0 @@ -// based on: -// - https://github.com/python/cpython/blob/3.11/Lib/keyword.py - -const keywords = new Set([ - "False", - "None", - "True", - "and", - "as", - "assert", - "async", - "await", - "break", - "class", - "continue", - "def", - "del", - "elif", - "else", - "except", - "finally", - "for", - "from", - "global", - "if", - "import", - "in", - "is", - "lambda", - "nonlocal", - "not", - "or", - "pass", - "raise", - "return", - "try", - "while", - "with", - "yield", -]); - -const builtins = new Set([ - "ArithmeticError", - "AssertionError", - "AttributeError", - "BaseException", - "BlockingIOError", - "BrokenPipeError", - "BufferError", - "BytesWarning", - "ChildProcessError", - "ConnectionAbortedError", - "ConnectionError", - "ConnectionRefusedError", - "ConnectionResetError", - "DeprecationWarning", - "EOFError", - "Ellipsis", - "EnvironmentError", - "Exception", - "False", - "FileExistsError", - "FileNotFoundError", - "FloatingPointError", - "FutureWarning", - "GeneratorExit", - "IOError", - "ImportError", - "ImportWarning", - "IndentationError", - "IndexError", - "InterruptedError", - "IsADirectoryError", - "KeyError", - "KeyboardInterrupt", - "LookupError", - "MemoryError", - "ModuleNotFoundError", - "NameError", - "None", - "NotADirectoryError", - "NotImplemented", - "NotImplementedError", - "OSError", - "OverflowError", - "PendingDeprecationWarning", - "PermissionError", - "ProcessLookupError", - "RecursionError", - "ReferenceError", - "ResourceWarning", - "RuntimeError", - "RuntimeWarning", - "StopAsyncIteration", - "StopIteration", - "SyntaxError", - "SyntaxWarning", - "SystemError", - "SystemExit", - "TabError", - "TimeoutError", - "True", - "TypeError", - "UnboundLocalError", - "UnicodeDecodeError", - "UnicodeEncodeError", - "UnicodeError", - "UnicodeTranslateError", - "UnicodeWarning", - "UserWarning", - "ValueError", - "Warning", - "ZeroDivisionError", - "__build_class__", - "__debug__", - "__doc__", - "__import__", - "__loader__", - "__name__", - "__package__", - "__spec__", - "abs", - "all", - "any", - "ascii", - "bin", - "bool", - "breakpoint", - "bytearray", - "bytes", - "callable", - "chr", - "classmethod", - "compile", - "complex", - "copyright", - "credits", - "delattr", - "dict", - "dir", - "divmod", - "enumerate", - "eval", - "exec", - "exit", - "filter", - "float", - "format", - "frozenset", - "getattr", - "globals", - "hasattr", - "hash", - "help", - "hex", - "id", - "input", - "int", - "isinstance", - "issubclass", - "iter", - "len", - "license", - "list", - "locals", - "map", - "max", - "memoryview", - "min", - "next", - "object", - "oct", - "open", - "ord", - "pow", - "print", - "property", - "quit", - "range", - "repr", - "reversed", - "round", - "set", - "setattr", - "slice", - "sorted", - "staticmethod", - "str", - "sum", - "super", - "tuple", - "type", - "vars", - "zip", -]); - -export function isKeyword(keyword: string): boolean { - return keywords.has(keyword) || builtins.has(keyword); -} diff --git a/packages/schema/bind/src/bindings/rust/functions.ts b/packages/schema/bind/src/bindings/rust/functions.ts deleted file mode 100644 index aca46a07b5..0000000000 --- a/packages/schema/bind/src/bindings/rust/functions.ts +++ /dev/null @@ -1,385 +0,0 @@ -import { isKeyword } from "./types"; -import { MustacheFn } from "../types"; - -function replaceAt(str: string, index: number, replacement: string): string { - return ( - str.substr(0, index) + replacement + str.substr(index + replacement.length) - ); -} - -function insertAt(str: string, index: number, insert: string): string { - return str.substr(0, index) + insert + str.substr(index); -} - -function removeAt(str: string, index: number): string { - return str.substr(0, index) + str.substr(index + 1); -} - -export const toLower: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - - for (let i = 0; i < type.length; ++i) { - const char = type.charAt(i); - const lower = char.toLowerCase(); - - if (char !== lower) { - // Replace the uppercase char w/ the lowercase version - type = replaceAt(type, i, lower); - - if (i !== 0 && type[i - 1] !== "_") { - // Make sure all lowercase conversions have an underscore before them - type = insertAt(type, i, "_"); - } - } - } - - return type; - }; -}; - -export const toUpper: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - - // First character must always be upper case - const firstChar = type.charAt(0); - const firstUpper = firstChar.toUpperCase(); - type = replaceAt(type, 0, firstUpper); - - // Look for any underscores, remove them if they exist, and make next letter uppercase - for (let i = 0; i < type.length; ++i) { - const char = type.charAt(i); - - if (char === "_") { - const nextChar = type.charAt(i + 1); - const nextCharUpper = nextChar.toUpperCase(); - type = replaceAt(type, i + 1, nextCharUpper); - type = removeAt(type, i); - } - } - - return type; - }; -}; - -export const noBox: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - const type = render(value); - const extract = /(.*)Box<([a-zA-Z0-9]*)>(.*)/gm; - const match = [...type.matchAll(extract)]; - - if (match.length === 0) { - return type; - } - - const strings = match[0] as string[]; - return strings[1] + strings[2] + strings[3]; - }; -}; - -export const toMsgPack: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - - let modifier = ""; - if (type[type.length - 1] === "!") { - type = type.substr(0, type.length - 1); - } else { - modifier = "optional_"; - } - - if (type[0] === "[") { - return modifier + "array"; - } - if (type.startsWith("Map<")) { - return modifier + "ext_generic_map"; - } - - switch (type) { - case "Int": - return modifier + "i32"; - case "Int8": - return modifier + "i8"; - case "Int16": - return modifier + "i16"; - case "Int32": - return modifier + "i32"; - case "Int64": - return modifier + "i64"; - case "UInt": - case "UInt32": - return modifier + "u32"; - case "UInt8": - return modifier + "u8"; - case "UInt16": - return modifier + "u16"; - case "UInt64": - return modifier + "u64"; - case "String": - return modifier + "string"; - case "Boolean": - return modifier + "bool"; - case "Bytes": - return modifier + "bytes"; - case "BigInt": - return modifier + "bigint"; - case "BigNumber": - return modifier + "bignumber"; - case "JSON": - return modifier + "json"; - default: - throw Error(`Unknown toWasm type "${type}"`); - } - }; -}; - -export const toWasmInit: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - let optional = false; - - const optionalModifier = (str: string): string => { - return !optional ? str : "None"; - }; - - if (type[type.length - 1] === "!") { - type = type.substr(0, type.length - 1); - } else { - optional = true; - } - - if (type[0] === "[") { - return optionalModifier("vec![]"); - } - - if (type.startsWith("Map<")) { - const firstOpenBracketIdx = type.indexOf("<"); - const lastCloseBracketIdx = type.lastIndexOf(">"); - - if (firstOpenBracketIdx === -1 || lastCloseBracketIdx === -1) { - throw new Error(`Invalid Map: ${type}`); - } - - const keyValTypes = type.substring( - firstOpenBracketIdx + 1, - lastCloseBracketIdx - ); - - const firstCommaIdx = keyValTypes.indexOf(","); - if (firstCommaIdx === -1) { - throw new Error(`Invalid Map: ${type}`); - } - - const keyType = keyValTypes.substring(0, firstCommaIdx).trim(); - const valType = keyValTypes.substring(firstCommaIdx + 1).trim(); - - const wasmKeyType = toWasm()(keyType, (str) => str); - const wasmValType = toWasm()(valType, (str) => str); - - return optionalModifier(`Map::<${wasmKeyType}, ${wasmValType}>::new()`); - } - - switch (type) { - case "Int": - case "Int8": - case "Int16": - case "Int32": - case "Int64": - case "UInt": - case "UInt8": - case "UInt16": - case "UInt32": - case "UInt64": - return optionalModifier("0"); - case "String": - return optionalModifier("String::new()"); - case "Boolean": - return optionalModifier("false"); - case "Bytes": - return optionalModifier("vec![]"); - case "BigInt": - return optionalModifier("BigInt::default()"); - case "BigNumber": - return optionalModifier("BigNumber::default()"); - case "JSON": - return optionalModifier("JSON::Value::Null"); - default: - if (type.includes("Enum_")) { - return optionalModifier(`${toWasm()(value, render)}::_MAX_`); - } else { - return optionalModifier(`${toWasm()(value, render)}::new()`); - } - } - }; -}; - -export const toWasm: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let type = render(value); - - let optional = false; - if (type[type.length - 1] === "!") { - type = type.substr(0, type.length - 1); - } else { - optional = true; - } - - if (type[0] === "[") { - return toWasmArray(type, optional); - } - - if (type.startsWith("Map<")) { - return toWasmMap(type, optional); - } - - switch (type) { - case "Int": - type = "i32"; - break; - case "Int8": - type = "i8"; - break; - case "Int16": - type = "i16"; - break; - case "Int32": - type = "i32"; - break; - case "Int64": - type = "i64"; - break; - case "UInt": - case "UInt32": - type = "u32"; - break; - case "UInt8": - type = "u8"; - break; - case "UInt16": - type = "u16"; - break; - case "UInt64": - type = "u64"; - break; - case "String": - type = "String"; - break; - case "Boolean": - type = "bool"; - break; - case "Bytes": - type = "Vec"; - break; - case "BigInt": - type = "BigInt"; - break; - case "BigNumber": - type = "BigNumber"; - break; - case "JSON": - type = "JSON::Value"; - break; - default: - if (type.includes("Enum_")) { - type = type.replace("Enum_", ""); - } - type = toUpper()(type, (str) => str); - type = detectKeyword()(type, (str) => str); - } - - return applyOptional(type, optional); - }; -}; - -// check if any of the keywords match the property name; -// if there's a match, insert `_` at the beginning of the property name. -export const detectKeyword: MustacheFn = () => { - return (value: string, render: (template: string) => string): string => { - const type = render(value); - if (isKeyword(type)) { - return "_" + type; - } - return type; - }; -}; - -export const serdeKeyword: MustacheFn = () => { - return (value: string, render: (template: string) => string): string => { - const type = render(value); - if (isKeyword(type)) { - return `#[serde(rename = "${type}")]\n `; - } - return ""; - }; -}; - -export const serdeAnnotateIfBytes: MustacheFn = () => { - return (value: string, render: (template: string) => string): string => { - const scalarType: string | undefined = render(value); - - if (scalarType === "Bytes") { - return `#[serde(with = "serde_bytes")]\n `; - } - return ""; - }; -}; - -export const serdeRenameIfCaseMismatch: MustacheFn = () => { - return (value: string, render: (template: string) => string): string => { - const type = render(value); - - if (hasUppercase(type) || isKeyword(type)) { - return `#[serde(rename = "${type}")]\n `; - } - return ""; - }; -}; - -const hasUppercase = (value: string): boolean => value !== value.toLowerCase(); - -const toWasmArray = (type: string, optional: boolean): string => { - const result = type.match(/(\[)([[\]A-Za-z1-9_.!]+)(\])/); - - if (!result || result.length !== 4) { - throw Error(`Invalid Array: ${type}`); - } - - const wasmType = toWasm()(result[2], (str) => str); - return applyOptional("Vec<" + wasmType + ">", optional); -}; - -const toWasmMap = (type: string, optional: boolean): string => { - const firstOpenBracketIdx = type.indexOf("<"); - const lastCloseBracketIdx = type.lastIndexOf(">"); - - if (firstOpenBracketIdx === -1 || lastCloseBracketIdx === -1) { - throw new Error(`Invalid Map: ${type}`); - } - - const keyValTypes = type.substring( - firstOpenBracketIdx + 1, - lastCloseBracketIdx - ); - - const firstCommaIdx = keyValTypes.indexOf(","); - if (firstCommaIdx === -1) { - throw new Error(`Invalid Map: ${type}`); - } - - const keyType = keyValTypes.substring(0, firstCommaIdx).trim(); - const valType = keyValTypes.substring(firstCommaIdx + 1).trim(); - - const wasmKeyType = toWasm()(keyType, (str) => str); - const wasmValType = toWasm()(valType, (str) => str); - - return applyOptional(`Map<${wasmKeyType}, ${wasmValType}>`, optional); -}; - -const applyOptional = (type: string, optional: boolean): string => { - if (optional) { - return `Option<${type}>`; - } else { - return type; - } -}; diff --git a/packages/schema/bind/src/bindings/rust/index.ts b/packages/schema/bind/src/bindings/rust/index.ts deleted file mode 100644 index 7bdebbf2d4..0000000000 --- a/packages/schema/bind/src/bindings/rust/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * as Wasm from "./wasm"; -export * as Plugin from "./plugin"; -export * as Functions from "./functions"; -export * as Types from "./types"; diff --git a/packages/schema/bind/src/bindings/rust/plugin/index.ts b/packages/schema/bind/src/bindings/rust/plugin/index.ts deleted file mode 100644 index 180a40ccdd..0000000000 --- a/packages/schema/bind/src/bindings/rust/plugin/index.ts +++ /dev/null @@ -1,80 +0,0 @@ -import * as Transforms from "../transforms"; -import { Functions } from "../"; -import { GenerateBindingFn, renderTemplates } from "../.."; -import { BindOptions, BindOutput } from "../../.."; - -import { - transformAbi, - extendType, - addFirstLast, - toPrefixedGraphQLType, - hasImports, - methodParentPointers, - latestWrapManifestVersion, -} from "@polywrap/schema-parse"; -import path from "path"; -import { WrapAbi } from "@polywrap/wrap-manifest-types-js/src"; - -const templatePath = (subpath: string) => - path.join(__dirname, "./templates", subpath); - -const sort = (obj: Record) => - Object.keys(obj) - .sort() - .reduce((map: Record, key: string) => { - if (typeof obj[key] === "object") { - map[key] = sort(obj[key] as Record); - - if (Array.isArray(obj[key])) { - map[key] = Object.values(map[key] as Record); - } - } else { - map[key] = obj[key]; - } - return map; - }, {}); - -export const generateBinding: GenerateBindingFn = ( - options: BindOptions -): BindOutput => { - const result: BindOutput = { - output: { - entries: [], - }, - outputDirAbs: options.outputDirAbs, - }; - const output = result.output; - const abi = applyTransforms(options.abi); - - const manifest = { - name: options.projectName, - type: "plugin", - version: latestWrapManifestVersion, - abi: JSON.stringify( - sort((options.abi as unknown) as Record), - null, - 2 - ), - }; - - output.entries = renderTemplates(templatePath(""), { ...abi, manifest }, {}); - - return result; -}; - -function applyTransforms(abi: WrapAbi): WrapAbi { - const transforms = [ - extendType(Functions), - addFirstLast, - toPrefixedGraphQLType, - hasImports, - methodParentPointers(), - Transforms.propertyDeps(), - Transforms.byRef(), - ]; - - for (const transform of transforms) { - abi = transformAbi(abi, transform); - } - return abi; -} diff --git a/packages/schema/bind/src/bindings/rust/plugin/templates/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/plugin/templates/mod-rs.mustache deleted file mode 100644 index 88b7de7bdf..0000000000 --- a/packages/schema/bind/src/bindings/rust/plugin/templates/mod-rs.mustache +++ /dev/null @@ -1,7 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -pub mod types; -#[path = "wrap.info.rs"] -pub mod wrap_info; -pub mod module; \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/plugin/templates/module-rs.mustache b/packages/schema/bind/src/bindings/rust/plugin/templates/module-rs.mustache deleted file mode 100644 index 568a5d64d6..0000000000 --- a/packages/schema/bind/src/bindings/rust/plugin/templates/module-rs.mustache +++ /dev/null @@ -1,30 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -use std::sync::Arc; -use polywrap_core::invoke::Invoker; -use polywrap_plugin::{error::PluginError, module::PluginModule}; -use serde::{Serialize, Deserialize}; -use super::types::*; - -{{#moduleType}} -{{#methods}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Args{{#toUpper}}{{name}}{{/toUpper}} { - {{#arguments}} - {{#serdeAnnotateIfBytes}}{{#scalar}}{{type}}{{/scalar}}{{/serdeAnnotateIfBytes}}{{#serdeRenameIfCaseMismatch}}{{name}}{{/serdeRenameIfCaseMismatch}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/arguments}} -} - -{{/methods}} -{{/moduleType}} -pub trait Module: PluginModule { - {{#moduleType}} - {{#methods}} - fn {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}(&mut self, args: &Args{{#toUpper}}{{name}}{{/toUpper}}, invoker: Arc{{#env}}, env: {{^required}}Option<{{/required}}Env{{^required}}>{{/required}}{{/env}}) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, PluginError>; - {{^last}} - - {{/last}} - {{/methods}} - {{/moduleType}} -} diff --git a/packages/schema/bind/src/bindings/rust/plugin/templates/types-rs.mustache b/packages/schema/bind/src/bindings/rust/plugin/templates/types-rs.mustache deleted file mode 100644 index 746eea972b..0000000000 --- a/packages/schema/bind/src/bindings/rust/plugin/templates/types-rs.mustache +++ /dev/null @@ -1,180 +0,0 @@ -#![allow(unused_imports)] -#![allow(non_camel_case_types)] - -// NOTE: This is an auto-generated file. -// All modifications will be overwritten. -use polywrap_core::{invoke::Invoker, uri::Uri}; -use polywrap_msgpack::{decode, serialize}; -use polywrap_plugin::{error::PluginError, BigInt, BigNumber, Map, JSON}; -use serde::{Serialize, Deserialize}; -{{#importedModuleTypes}} -use std::sync::Arc; -{{/importedModuleTypes}} - -// Env START // - -{{#envType}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#serdeAnnotateIfBytes}}{{#scalar}}{{type}}{{/scalar}}{{/serdeAnnotateIfBytes}}{{#serdeRenameIfCaseMismatch}}{{name}}{{/serdeRenameIfCaseMismatch}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/properties}} -} -{{/envType}} -// Env END // - -// Objects START // - -{{#objectTypes}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#serdeAnnotateIfBytes}}{{#scalar}}{{type}}{{/scalar}}{{/serdeAnnotateIfBytes}}{{#serdeRenameIfCaseMismatch}}{{name}}{{/serdeRenameIfCaseMismatch}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/properties}} -} -{{/objectTypes}} -// Objects END // - -// Enums START // - -{{#enumTypes}} -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#constants}} - {{#serdeRenameIfCaseMismatch}}{{name}}{{/serdeRenameIfCaseMismatch}}{{#detectKeyword}}{{.}}{{/detectKeyword}}, - {{/constants}} - _MAX_ -} -{{/enumTypes}} -// Enums END // - -// Imported objects START // - -{{#importedObjectTypes}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#serdeAnnotateIfBytes}}{{#scalar}}{{type}}{{/scalar}}{{/serdeAnnotateIfBytes}}{{#serdeRenameIfCaseMismatch}}{{name}}{{/serdeRenameIfCaseMismatch}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/properties}} -} -{{/importedObjectTypes}} -// Imported objects END // - -// Imported envs START // - -{{#importedEnvType}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#serdeAnnotateIfBytes}}{{#scalar}}{{type}}{{/scalar}}{{/serdeAnnotateIfBytes}}{{#serdeRenameIfCaseMismatch}}{{name}}{{/serdeRenameIfCaseMismatch}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/properties}} -} -{{/importedEnvType}} -// Imported envs END // - -// Imported enums START // - -{{#importedEnumTypes}} -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#constants}} - {{#serdeRenameIfCaseMismatch}}{{name}}{{/serdeRenameIfCaseMismatch}}{{#detectKeyword}}{{.}}{{/detectKeyword}}, - {{/constants}} - _MAX_ -} -{{/importedEnumTypes}} -// Imported enums END // - -// Imported Modules START // - -{{#importedModuleTypes}} -{{#methods}} -// URI: "{{parent.uri}}" // -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#toUpper}}{{parent.type}}{{/toUpper}}Args{{#toUpper}}{{name}}{{/toUpper}} { - {{#arguments}} - {{#serdeAnnotateIfBytes}}{{#scalar}}{{type}}{{/scalar}}{{/serdeAnnotateIfBytes}}{{#serdeRenameIfCaseMismatch}}{{name}}{{/serdeRenameIfCaseMismatch}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/arguments}} -} - -{{/methods}} -{{^isInterface}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} {} - -impl {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - pub const URI: &'static str = "{{uri}}"; - - pub fn new() -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} {} - } - - {{#methods}} - pub fn {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}(args: &{{#toUpper}}{{parent.type}}{{/toUpper}}Args{{#toUpper}}{{name}}{{/toUpper}}, invoker: Arc) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, PluginError> { - let uri = {{#parent}}{{#toUpper}}{{type}}{{/toUpper}}{{/parent}}::URI; - let serialized_args = serialize(args.clone()).unwrap(); - let opt_args = Some(serialized_args.as_slice()); - let uri = Uri::try_from(uri).unwrap(); - let result = invoker.invoke_raw( - &uri, - "{{name}}", - opt_args, - None, - None - ) - .map_err(|e| PluginError::SubinvocationError { - uri: uri.to_string(), - method: "{{name}}".to_string(), - args: JSON::to_string(&args).unwrap(), - exception: e.to_string(), - })?; - - Ok({{#return}}{{^required}}Some({{/required}}{{/return}}decode(result.as_slice())?{{#return}}{{^required}}){{/required}}{{/return}}) - } - {{^last}} - - {{/last}} - {{/methods}} -} -{{/isInterface}} -{{#isInterface}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}<'a> { - {{#isInterface}}uri: &'a str{{/isInterface}} -} - -impl<'a> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}<'a> { - pub const INTERFACE_URI: &'static str = "{{uri}}"; - - pub fn new(uri: &'a str) -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}<'a> { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { uri: uri } - } - - {{#methods}} - pub fn {{#toLower}}{{name}}{{/toLower}}(&self, args: &{{#toUpper}}{{parent.type}}{{/toUpper}}Args{{#toUpper}}{{name}}{{/toUpper}}) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, PluginError> { - let uri = self.uri; - let serialized_args = serialize(args.clone()).unwrap(); - let result = invoker.invoke_raw( - uri, - "{{name}}", - serialized_args, - None, - None - ) - .map_err(|e| PluginError::SubinvocationError { - uri: uri.to_string(), - method: "{{name}}".to_string(), - args: JSON::to_string(&args).unwrap(), - exception: e.to_string(), - })?; - - Ok({{#return}}{{^required}}Some({{/required}}{{/return}}decode(result.as_slice())?{{#return}}{{^required}}){{/required}}{{/return}}) - } - {{^last}} - - {{/last}} - {{/methods}} -} -{{/isInterface}} -{{/importedModuleTypes}} -// Imported Modules END // diff --git a/packages/schema/bind/src/bindings/rust/plugin/templates/wrap.info-rs.mustache b/packages/schema/bind/src/bindings/rust/plugin/templates/wrap.info-rs.mustache deleted file mode 100644 index 096aec98b4..0000000000 --- a/packages/schema/bind/src/bindings/rust/plugin/templates/wrap.info-rs.mustache +++ /dev/null @@ -1,15 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. -use polywrap_plugin::JSON::{from_value, json}; -use wrap_manifest_schemas::versions::{WrapManifest, WrapManifestAbi}; - -{{#manifest}} -pub fn get_manifest() -> WrapManifest { - WrapManifest { - name: "{{name}}".to_string(), - type_: "{{type}}".to_string(), - version: "{{version}}".to_string(), - abi: from_value::(json!({{abi}})).unwrap() - } -} -{{/manifest}} diff --git a/packages/schema/bind/src/bindings/rust/transforms/byRef.ts b/packages/schema/bind/src/bindings/rust/transforms/byRef.ts deleted file mode 100644 index b5f87a673c..0000000000 --- a/packages/schema/bind/src/bindings/rust/transforms/byRef.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { AbiTransforms } from "@polywrap/schema-parse"; -import { AnyDefinition } from "@polywrap/wrap-manifest-types-js"; - -export function byRef(): AbiTransforms { - return { - enter: { - // eslint-disable-next-line @typescript-eslint/naming-convention - AnyDefinition: (def: AnyDefinition) => { - const byRefScalars = ["String", "BigInt", "BigNumber", "Map", "Bytes"]; - - if (def.scalar) { - if (byRefScalars.indexOf(def.scalar.type) > -1 || !def.required) { - return { - ...def, - byRef: true, - }; - } - } - - return def; - }, - }, - }; -} diff --git a/packages/schema/bind/src/bindings/rust/transforms/index.ts b/packages/schema/bind/src/bindings/rust/transforms/index.ts deleted file mode 100644 index 56b11478c3..0000000000 --- a/packages/schema/bind/src/bindings/rust/transforms/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./byRef"; -export * from "./propertyDeps"; diff --git a/packages/schema/bind/src/bindings/rust/transforms/propertyDeps.ts b/packages/schema/bind/src/bindings/rust/transforms/propertyDeps.ts deleted file mode 100644 index 5a6a5d20ba..0000000000 --- a/packages/schema/bind/src/bindings/rust/transforms/propertyDeps.ts +++ /dev/null @@ -1,207 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -/* eslint-disable no-useless-escape */ -import { isBaseType, isBuiltInType } from "../types"; - -import { - ImportedModuleDefinition, - ObjectDefinition, - AnyDefinition, - ModuleDefinition, - EnvDefinition, - Abi, - ImportedEnvDefinition, -} from "@polywrap/wrap-manifest-types-js"; -import { AbiTransforms } from "@polywrap/schema-parse"; - -interface PropertyDep { - crate: string; - type: string; - isEnum: boolean; -} - -interface PropertyDepsState { - abiEnvDefinition?: EnvDefinition; - envDefinition?: EnvDefinition; - importedEnvDefinition?: ImportedEnvDefinition; - objectDefinition?: ObjectDefinition; - moduleDefinition?: ModuleDefinition; - importedModuleDefinition?: ImportedModuleDefinition; - propertyDeps?: PropertyDep[]; -} - -export function propertyDeps(): AbiTransforms { - const state: PropertyDepsState = {}; - - return { - enter: { - Abi: (abi: Abi) => { - if (abi.envType) { - state.abiEnvDefinition = abi.envType; - } - return abi; - }, - EnvDefinition: (def: EnvDefinition) => { - state.envDefinition = def; - state.propertyDeps = []; - return def; - }, - ImportedEnvDefinition: (def: ImportedEnvDefinition) => { - state.envDefinition = def; - state.propertyDeps = []; - return def; - }, - ObjectDefinition: (def: ObjectDefinition) => { - state.objectDefinition = def; - state.propertyDeps = []; - return def; - }, - ModuleDefinition: (def: ModuleDefinition) => { - state.moduleDefinition = def; - state.propertyDeps = []; - if (state.abiEnvDefinition) { - state.propertyDeps.push({ - crate: "crate", - type: "Env", - isEnum: false, - }); - } - return def; - }, - ImportedModuleDefinition: (def: ImportedModuleDefinition) => { - state.importedModuleDefinition = def; - state.propertyDeps = []; - return def; - }, - AnyDefinition: (def: AnyDefinition) => { - const appendPropertyDep = ( - rootType: string, - array: PropertyDep[] - ): PropertyDep[] => { - let typeName = def.type; - - if (typeName.indexOf("[") === 0) { - typeName = typeName.replace(/\[|\]|\!|\?/g, ""); - } - - const appendUnique = (item: PropertyDep) => { - if ( - array.findIndex( - (i) => i.crate === item.crate && i.type === item.type - ) === -1 - ) { - array.push(item); - } - }; - - const isKnownType = (name: string) => - isBaseType(name) || isBuiltInType(name) || name === rootType; - - // if type is map and the value is custom, - // we need to add it into property dependency - if (typeName.startsWith("Map<")) { - const valueName = def.map?.object?.type ?? def.map?.enum?.type; - if (valueName && !isKnownType(valueName)) { - appendUnique({ - crate: "crate", - type: valueName, - isEnum: valueName === def.map?.enum?.type, - }); - - return array; - } - - return array; - } - - if (isKnownType(typeName)) { - return array; - } - - appendUnique({ - crate: "crate", - type: typeName, - isEnum: !!def.enum || !!def.array?.enum, - }); - - return array; - }; - - if (state.envDefinition && state.propertyDeps) { - state.propertyDeps = appendPropertyDep( - state.envDefinition.type, - state.propertyDeps - ); - } else if (state.importedEnvDefinition && state.propertyDeps) { - state.propertyDeps = appendPropertyDep( - state.importedEnvDefinition.type, - state.propertyDeps - ); - } else if (state.objectDefinition && state.propertyDeps) { - state.propertyDeps = appendPropertyDep( - state.objectDefinition.type, - state.propertyDeps - ); - } else if (state.moduleDefinition && state.propertyDeps) { - state.propertyDeps = appendPropertyDep( - state.moduleDefinition.type, - state.propertyDeps - ); - } else if (state.importedModuleDefinition && state.propertyDeps) { - state.propertyDeps = appendPropertyDep( - state.importedModuleDefinition.type, - state.propertyDeps - ); - } - - return def; - }, - }, - leave: { - EnvDefinition: (def: EnvDefinition) => { - const propertyDeps = state.propertyDeps; - state.propertyDeps = undefined; - state.envDefinition = undefined; - return { - ...def, - propertyDeps, - }; - }, - ImportedEnvDefinition: (def: ImportedEnvDefinition) => { - const propertyDeps = state.propertyDeps; - state.propertyDeps = undefined; - state.importedEnvDefinition = undefined; - return { - ...def, - propertyDeps, - }; - }, - ObjectDefinition: (def: ObjectDefinition) => { - const propertyDeps = state.propertyDeps; - state.propertyDeps = undefined; - state.objectDefinition = undefined; - return { - ...def, - propertyDeps, - }; - }, - ModuleDefinition: (def: ModuleDefinition) => { - const propertyDeps = state.propertyDeps; - state.propertyDeps = undefined; - state.moduleDefinition = undefined; - return { - ...def, - propertyDeps, - }; - }, - ImportedModuleDefinition: (def: ImportedModuleDefinition) => { - const propertyDeps = state.propertyDeps; - state.propertyDeps = undefined; - state.importedModuleDefinition = undefined; - return { - ...def, - propertyDeps, - }; - }, - }, - }; -} diff --git a/packages/schema/bind/src/bindings/rust/types.ts b/packages/schema/bind/src/bindings/rust/types.ts deleted file mode 100644 index 2ca3c140a5..0000000000 --- a/packages/schema/bind/src/bindings/rust/types.ts +++ /dev/null @@ -1,103 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -const baseTypes = { - UInt: "UInt", - UInt8: "UInt8", - UInt16: "UInt16", - UInt32: "UInt32", - UInt64: "UInt64", - Int: "Int", - Int8: "Int8", - Int16: "Int16", - Int32: "Int32", - Int64: "Int64", - String: "String", - Boolean: "Boolean", - Bytes: "Bytes", -}; - -export type BaseTypes = typeof baseTypes; - -export type BaseType = keyof BaseTypes; - -export function isBaseType(type: string): type is BaseType { - return type in baseTypes; -} - -const builtInTypes = { - BigInt: "BigInt", - BigNumber: "BigNumber", - JSON: "JSON", -}; - -export type BuiltInTypes = typeof builtInTypes; - -export type BuiltInType = keyof BuiltInTypes; - -export function isBuiltInType(type: string): type is BuiltInType { - return type in builtInTypes; -} - -const keywords = { - as: "as", - break: "break", - const: "const", - continue: "continue", - crate: "crate", - else: "else", - enum: "enum", - extern: "extern", - false: "false", - fn: "fn", - for: "for", - if: "if", - impl: "impl", - in: "in", - let: "let", - loop: "loop", - match: "match", - mod: "mod", - move: "move", - mut: "mut", - pub: "pub", - ref: "ref", - return: "return", - self: "self", - Self: "Self", - static: "static", - struct: "struct", - super: "super", - trait: "trait", - true: "true", - type: "type", - unsafe: "unsafe", - use: "use", - where: "where", - while: "while", - async: "async", - await: "await", - dyn: "dyn", - abstract: "abstract", - become: "become", - box: "box", - Box: "Box", - do: "do", - final: "final", - macro: "macro", - override: "override", - priv: "priv", - typeof: "typeof", - unsized: "unsized", - virtual: "virtual", - yield: "yield", - try: "try", - macro_rules: "macro_rules", - union: "union", -}; - -export type Keywords = typeof keywords; - -export type Keyword = keyof Keywords; - -export function isKeyword(keyword: string): keyword is Keyword { - return keyword in keywords; -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/index.ts b/packages/schema/bind/src/bindings/rust/wasm/index.ts deleted file mode 100644 index ff7fdcc617..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/index.ts +++ /dev/null @@ -1,209 +0,0 @@ -import * as Transforms from "../transforms"; -import { Functions } from "../"; -import { GenerateBindingFn, renderTemplates } from "../.."; -import { loadSubTemplates } from "../../utils"; -import { BindOptions, BindOutput } from "../../.."; - -import { - transformAbi, - extendType, - addFirstLast, - toPrefixedGraphQLType, - hasImports, - methodParentPointers, -} from "@polywrap/schema-parse"; -import { OutputEntry, readDirectorySync } from "@polywrap/os-js"; -import path from "path"; -import { WrapAbi } from "@polywrap/wrap-manifest-types-js/src"; - -const templatesDir = readDirectorySync(path.join(__dirname, "./templates")); -const subTemplates = loadSubTemplates(templatesDir.entries); -const templatePath = (subpath: string) => - path.join(__dirname, "./templates", subpath); - -const toLower = (type: string) => Functions.toLower()(type, (str) => str); - -export const generateBinding: GenerateBindingFn = ( - options: BindOptions -): BindOutput => { - const result: BindOutput = { - output: { - entries: [], - }, - outputDirAbs: options.outputDirAbs, - }; - const output = result.output; - const abi = applyTransforms(options.abi); - - // Generate object type folders - if (abi.objectTypes) { - for (const objectType of abi.objectTypes) { - output.entries.push({ - type: "Directory", - name: Functions.detectKeyword()(toLower(objectType.type), (str) => str), - data: renderTemplates( - templatePath("object-type"), - objectType, - subTemplates - ), - }); - } - } - - // Generate env type folders - if (abi.envType) { - output.entries.push({ - type: "Directory", - name: Functions.detectKeyword()(toLower(abi.envType.type), (str) => str), - data: renderTemplates( - templatePath("env-type"), - abi.envType, - subTemplates - ), - }); - } - - // Generate imported folder - const importEntries: OutputEntry[] = []; - - // Generate imported module type folders - if (abi.importedModuleTypes) { - for (const importedModuleType of abi.importedModuleTypes) { - importEntries.push({ - type: "Directory", - name: toLower(importedModuleType.type), - data: renderTemplates( - templatePath("imported/module-type"), - importedModuleType, - subTemplates - ), - }); - } - } - - // Generate imported enum type folders - if (abi.importedEnumTypes) { - for (const importedEnumType of abi.importedEnumTypes) { - importEntries.push({ - type: "Directory", - name: Functions.detectKeyword()( - toLower(importedEnumType.type), - (str) => str - ), - data: renderTemplates( - templatePath("imported/enum-type"), - importedEnumType, - subTemplates - ), - }); - } - } - - // Generate imported object type folders - if (abi.importedObjectTypes) { - for (const importedObectType of abi.importedObjectTypes) { - importEntries.push({ - type: "Directory", - name: Functions.detectKeyword()( - toLower(importedObectType.type), - (str) => str - ), - data: renderTemplates( - templatePath("imported/object-type"), - importedObectType, - subTemplates - ), - }); - } - } - - // Generate imported env type folders - if (abi.importedEnvTypes) { - for (const importedEnvType of abi.importedEnvTypes) { - importEntries.push({ - type: "Directory", - name: Functions.detectKeyword()( - toLower(importedEnvType.type), - (str) => str - ), - data: renderTemplates( - templatePath("imported/env-type"), - importedEnvType, - subTemplates - ), - }); - } - } - - if (importEntries.length > 0) { - output.entries.push({ - type: "Directory", - name: "imported", - data: [ - ...importEntries, - ...renderTemplates(templatePath("imported"), abi, subTemplates), - ], - }); - } - - // Generate interface type folders - if (abi.interfaceTypes) { - for (const interfaceType of abi.interfaceTypes) { - output.entries.push({ - type: "Directory", - name: toLower(interfaceType.type), - data: renderTemplates( - templatePath("interface-type"), - interfaceType, - subTemplates - ), - }); - } - } - - // Generate module type folders - if (abi.moduleType) { - output.entries.push({ - type: "Directory", - name: toLower(abi.moduleType.type), - data: renderTemplates(templatePath("module-type"), abi, subTemplates), - }); - } - - // Generate enum type folders - if (abi.enumTypes) { - for (const enumType of abi.enumTypes) { - output.entries.push({ - type: "Directory", - name: Functions.detectKeyword()(toLower(enumType.type), (str) => str), - data: renderTemplates( - templatePath("enum-type"), - enumType, - subTemplates - ), - }); - } - } - - // Generate root entry file - output.entries.push(...renderTemplates(templatePath(""), abi, subTemplates)); - - return result; -}; - -function applyTransforms(abi: WrapAbi): WrapAbi { - const transforms = [ - extendType(Functions), - addFirstLast, - toPrefixedGraphQLType, - hasImports, - methodParentPointers(), - Transforms.propertyDeps(), - Transforms.byRef(), - ]; - - for (const transform of transforms) { - abi = transformAbi(abi, transform); - } - return abi; -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_array.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_array.mustache deleted file mode 100644 index 677e8785b0..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_array.mustache +++ /dev/null @@ -1,23 +0,0 @@ -{{#scalar}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}() -{{/scalar}} -{{#array}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array}} -}) -{{/array}} -{{#map}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() -}, |reader| { - {{> deserialize_map_value}} -}) -{{/map}} -{{#enum}} -{{> deserialize_enum}} -Ok(value) -{{/enum}} -{{#object}} -{{> deserialize_object}} -Ok(object) -{{/object}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_array_nobox.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_array_nobox.mustache deleted file mode 100644 index 3ff7fb4f1b..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_array_nobox.mustache +++ /dev/null @@ -1,23 +0,0 @@ -{{#scalar}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}() -{{/scalar}} -{{#array}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} -}) -{{/array}} -{{#map}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() -}, |reader| { - {{> deserialize_map_value_nobox}} -}) -{{/map}} -{{#enum}} -{{> deserialize_enum}} -Ok(value) -{{/enum}} -{{#object}} -{{> deserialize_object_nobox}} -Ok(object) -{{/object}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_enum.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_enum.mustache deleted file mode 100644 index 4c5c792b2f..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_enum.mustache +++ /dev/null @@ -1,22 +0,0 @@ -{{#required}} -let mut value: {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} = {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_; -if reader.is_next_string()? { - value = get_{{#toLower}}{{type}}{{/toLower}}_value(&reader.read_string()?)?; -} else { - value = {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::try_from(reader.read_i32()?)?; - sanitize_{{#toLower}}{{type}}{{/toLower}}_value(value as i32)?; -} -{{/required}} -{{^required}} -let mut value: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; -if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_{{#toLower}}{{type}}{{/toLower}}_value(&reader.read_string()?)?); - } else { - value = Some({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::try_from(reader.read_i32()?)?); - sanitize_{{#toLower}}{{type}}{{/toLower}}_value(value.unwrap() as i32)?; - } -} else { - value = None; -} -{{/required}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_map_value.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_map_value.mustache deleted file mode 100644 index 85fa4c841b..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_map_value.mustache +++ /dev/null @@ -1,23 +0,0 @@ -{{#scalar}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}() -{{/scalar}} -{{#array}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array}} -}) -{{/array}} -{{#map}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() -}, |reader| { - {{> deserialize_map_value}} -}) -{{/map}} -{{#enum}} -{{> deserialize_enum}} -Ok(value) -{{/enum}} -{{#object}} -{{> deserialize_object}} -Ok(object) -{{/object}} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_map_value_nobox.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_map_value_nobox.mustache deleted file mode 100644 index 6147316f80..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_map_value_nobox.mustache +++ /dev/null @@ -1,23 +0,0 @@ -{{#scalar}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}() -{{/scalar}} -{{#array}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} -}) -{{/array}} -{{#map}} -reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() -}, |reader| { - {{> deserialize_map_value_nobox}} -}) -{{/map}} -{{#enum}} -{{> deserialize_enum}} -Ok(value) -{{/enum}} -{{#object}} -{{> deserialize_object_nobox}} -Ok(object) -{{/object}} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_object.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_object.mustache deleted file mode 100644 index ba82c73512..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_object.mustache +++ /dev/null @@ -1,11 +0,0 @@ -{{#required}} -let object = Box::new({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::read(reader)?); -{{/required}} -{{^required}} -let mut object: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; -if !reader.is_next_nil()? { - object = Some(Box::new({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::read(reader)?)); -} else { - object = None; -} -{{/required}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_object_nobox.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_object_nobox.mustache deleted file mode 100644 index bf4cb82114..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_object_nobox.mustache +++ /dev/null @@ -1,11 +0,0 @@ -{{#required}} -let object = {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::read(reader)?; -{{/required}} -{{^required}} -let mut object: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; -if !reader.is_next_nil()? { - object = Some({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::read(reader)?); -} else { - object = None; -} -{{/required}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_object_refmut.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_object_refmut.mustache deleted file mode 100644 index bd6e80fd9e..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$deserialize_object_refmut.mustache +++ /dev/null @@ -1,11 +0,0 @@ -{{#required}} -let object = {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::read(&mut reader)?; -{{/required}} -{{^required}} -let mut object: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; -if !reader.is_next_nil()? { - object = Some({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::read(&mut reader)?); -} else { - object = None; -} -{{/required}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_array.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_array.mustache deleted file mode 100644 index 793cd62322..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_array.mustache +++ /dev/null @@ -1,21 +0,0 @@ -{{#scalar}} -writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(item) -{{/scalar}} -{{#array}} -writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(item, |writer, item| { - {{> serialize_array}} -}) -{{/array}} -{{#map}} -writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(item, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) -}, |writer, value| { - {{> serialize_map_value}} -}) -{{/map}} -{{#enum}} -{{> serialize_enum}} -{{/enum}} -{{#object}} -{{> serialize_object}} -{{/object}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_enum.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_enum.mustache deleted file mode 100644 index 5ada8b40f4..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_enum.mustache +++ /dev/null @@ -1,6 +0,0 @@ -{{#required}} -writer.write_i32(&(*item as i32)) -{{/required}} -{{^required}} -writer.write_optional_i32(&item.map(|f| f as i32)) -{{/required}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_map_value.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_map_value.mustache deleted file mode 100644 index b0550dca9a..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_map_value.mustache +++ /dev/null @@ -1,35 +0,0 @@ -{{#scalar}} -writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(value) -{{/scalar}} -{{#array}} -writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(value, |writer, item| { - {{> serialize_array}} -}) -{{/array}} -{{#map}} -writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(value, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) -}, |writer, value| { - {{> serialize_map_value}} -}) -{{/map}} -{{#enum}} -{{#required}} -writer.write_i32(&(*value as i32)) -{{/required}} -{{^required}} -writer.write_optional_i32(&value.map(|f| f as i32)) -{{/required}} -{{/enum}} -{{#object}} -{{#required}} -{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(value, writer) -{{/required}} -{{^required}} -if value.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(value.as_ref().as_ref().unwrap(), writer) -} else { - writer.write_nil() -} -{{/required}} -{{/object}} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_object.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_object.mustache deleted file mode 100644 index 8a1ca4d6d1..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/$serialize_object.mustache +++ /dev/null @@ -1,10 +0,0 @@ -{{#required}} -{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(item, writer) -{{/required}} -{{^required}} -if item.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(item.as_ref().as_ref().unwrap(), writer) -} else { - writer.write_nil() -} -{{/required}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/entry-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/entry-rs.mustache deleted file mode 100644 index 4287286a50..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/entry-rs.mustache +++ /dev/null @@ -1,40 +0,0 @@ -{{#moduleType}} -{{#methods.length}} -use crate::{ - {{#methods}} - {{#toLower}}{{name}}{{/toLower}}_wrapped{{^last}},{{/last}} - {{/methods}} -}; -{{/methods.length}} -{{/moduleType}} -use polywrap_wasm_rs::{ - abort, - invoke, - InvokeArgs, -}; -use crate::module::Module; - -#[no_mangle] -pub extern "C" fn _wrap_invoke(method_size: u32, args_size: u32, env_size: u32) -> bool { - // Ensure the abort handler is properly setup - abort::wrap_abort_setup(); - - let args: InvokeArgs = invoke::wrap_invoke_args(method_size, args_size); - let result: Vec; - - match args.method.as_str() { - {{#moduleType}} - {{#methods}} - "{{name}}" => { - result = {{#toLower}}{{name}}{{/toLower}}_wrapped(args.args.as_slice(), env_size); - } - {{/methods}} - {{/moduleType}} - _ => { - invoke::wrap_invoke_error(format!("Could not find invoke function {}", args.method)); - return false; - } - }; - invoke::wrap_invoke_result(result); - return true; -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/enum-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/enum-type/mod-rs.mustache deleted file mode 100644 index f87a2c5691..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/enum-type/mod-rs.mustache +++ /dev/null @@ -1,55 +0,0 @@ -use polywrap_wasm_rs::{EnumTypeError}; -use serde::{Serialize, Deserialize}; -use std::convert::TryFrom; - -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#constants}} - {{#serdeKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/serdeKeyword}}{{#detectKeyword}}{{.}}{{/detectKeyword}}, - {{/constants}} - _MAX_ -} - -pub fn sanitize_{{#toLower}}{{type}}{{/toLower}}_value(value: i32) -> Result<(), EnumTypeError> { - if value < 0 && value >= {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_ as i32 { - return Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum '{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}': {}", value.to_string()))); - } - Ok(()) -} - -pub fn get_{{#toLower}}{{type}}{{/toLower}}_value(key: &str) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, EnumTypeError> { - match key { - {{#constants}} - "{{#detectKeyword}}{{.}}{{/detectKeyword}}" => Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::{{#detectKeyword}}{{.}}{{/detectKeyword}}), - {{/constants}} - "_MAX_" => Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_), - err => Err(EnumTypeError::EnumProcessingError(format!("Invalid key for enum '{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}': {}", err))) - } -} - -pub fn get_{{#toLower}}{{type}}{{/toLower}}_key(value: {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result { - if sanitize_{{#toLower}}{{type}}{{/toLower}}_value(value as i32).is_ok() { - match value { - {{#constants}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::{{#detectKeyword}}{{.}}{{/detectKeyword}} => Ok("{{#detectKeyword}}{{.}}{{/detectKeyword}}".to_string()), - {{/constants}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_ => Ok("_MAX_".to_string()), - } - } else { - Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum '{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}': {}", (value as i32).to_string()))) - } -} - -impl TryFrom for {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - type Error = EnumTypeError; - - fn try_from(v: i32) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, Self::Error> { - match v { - {{#constants}} - x if x == {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::{{#detectKeyword}}{{.}}{{/detectKeyword}} as i32 => Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::{{#detectKeyword}}{{.}}{{/detectKeyword}}), - {{/constants}} - x if x == {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_ as i32 => Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_), - _ => Err(EnumTypeError::ParseEnumError(format!("Invalid value for enum '{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}': {}", (v as i32).to_string()))), - } - } -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/env-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/env-type/mod-rs.mustache deleted file mode 100644 index 77569c3e85..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/env-type/mod-rs.mustache +++ /dev/null @@ -1,54 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_{{#toLower}}{{type}}{{/toLower}}, - read_{{#toLower}}{{type}}{{/toLower}}, - serialize_{{#toLower}}{{type}}{{/toLower}}, - write_{{#toLower}}{{type}}{{/toLower}} -}; -{{#propertyDeps}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/propertyDeps}} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#serdeKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/serdeKeyword}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/properties}} -} - -impl {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - pub fn new() -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}, - {{/properties}} - } - } - - pub fn to_buffer(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result, EncodeError> { - serialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - deserialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, writer: &mut W) -> Result<(), EncodeError> { - write_{{#toLower}}{{type}}{{/toLower}}(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - read_{{#toLower}}{{type}}{{/toLower}}(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/env-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/env-type/serialization-rs.mustache deleted file mode 100644 index fad845897d..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/env-type/serialization-rs.mustache +++ /dev/null @@ -1,169 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{#propertyDeps.length}} - -{{/propertyDeps.length}}{{#propertyDeps}} -{{^isEnum}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/isEnum}} -{{#isEnum}} -use crate::{ - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, - get_{{#toLower}}{{type}}{{/toLower}}_value, - sanitize_{{#toLower}}{{type}}{{/toLower}}_value -}; -{{/isEnum}} -{{/propertyDeps}} - -pub fn serialize_{{#toLower}}{{type}}{{/toLower}}(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) env-type: {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{type}}{{/toLower}}(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_{{#toLower}}{{type}}{{/toLower}}(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, writer: &mut W) -> Result<(), EncodeError> { - {{#properties.length}} - writer.write_map_length(&{{properties.length}})?; - {{/properties.length}} - {{^properties}} - writer.write_map_length(&0)?; - {{/properties}} - {{#properties}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.write_string("{{name}}")?; - {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; - {{/scalar}} - {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { - {{> serialize_array}} - })?; - {{/array}} - {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) - }, |writer, value| { - {{> serialize_map_value}} - })?; - {{/map}} - {{#object}} - {{#required}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; - {{/required}} - {{^required}} - if args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - {{/required}} - {{/object}} - {{#enum}} - {{#required}} - writer.write_i32(&(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; - {{/required}} - {{^required}} - writer.write_optional_i32(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; - {{/required}} - {{/enum}} - writer.context().pop(); - {{/properties}} - Ok(()) -} - -pub fn deserialize_{{#toLower}}{{type}}{{/toLower}}(args: &[u8]) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing env-type: {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_{{#toLower}}{{type}}{{/toLower}}(&mut reader) -} - -pub fn read_{{#toLower}}{{type}}{{/toLower}}(reader: &mut R) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - let mut num_of_fields = reader.read_map_length()?; - - {{#properties}} - {{^object}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{^required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; - {{/required}} - {{/object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}_set = false; - {{/required}} - {{/properties}} - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - {{#properties}} - "{{name}}" => { - reader.context().push(&field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}()?; - {{/scalar}} - {{#array}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} - })?; - {{/array}} - {{#map}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}()? - }, |reader| { - {{> deserialize_map_value_nobox}} - })?; - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{#toLower}}{{name}}{{/toLower}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object_nobox}} - _{{#toLower}}{{name}}{{/toLower}} = object; - {{/object}} - {{#required}} - _{{#toLower}}{{name}}{{/toLower}}_set = true; - {{/required}} - reader.context().pop(); - } - {{/properties}} - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - {{#properties}} - {{#required}} - if !_{{#toLower}}{{name}}{{/toLower}}_set { - return Err(DecodeError::MissingField("{{name}}: {{type}}.".to_string())); - } - {{/required}} - {{/properties}} - - Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: _{{#toLower}}{{name}}{{/toLower}}, - {{/properties}} - }) -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/enum-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/imported/enum-type/mod-rs.mustache deleted file mode 100644 index ff39f8054b..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/enum-type/mod-rs.mustache +++ /dev/null @@ -1,55 +0,0 @@ -use polywrap_wasm_rs::EnumTypeError; -use serde::{Serialize, Deserialize}; -use std::convert::TryFrom; - -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#constants}} - {{#serdeKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/serdeKeyword}}{{#detectKeyword}}{{.}}{{/detectKeyword}}, - {{/constants}} - _MAX_ -} - -pub fn sanitize_{{#toLower}}{{type}}{{/toLower}}_value(value: i32) -> Result<(), EnumTypeError> { - if value < 0 && value >= {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_ as i32 { - return Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum '{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}': {}", value.to_string()))); - } - Ok(()) -} - -pub fn get_{{#toLower}}{{type}}{{/toLower}}_value(key: &str) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, EnumTypeError> { - match key { - {{#constants}} - "{{#detectKeyword}}{{.}}{{/detectKeyword}}" => Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::{{#detectKeyword}}{{.}}{{/detectKeyword}}), - {{/constants}} - "_MAX_" => Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_), - err => Err(EnumTypeError::EnumProcessingError(format!("Invalid key for enum '{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}': {}", err))) - } -} - -pub fn get_{{#toLower}}{{type}}{{/toLower}}_key(value: {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result { - if sanitize_{{#toLower}}{{type}}{{/toLower}}_value(value as i32).is_ok() { - match value { - {{#constants}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::{{#detectKeyword}}{{.}}{{/detectKeyword}} => Ok("{{#detectKeyword}}{{.}}{{/detectKeyword}}".to_string()), - {{/constants}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_ => Ok("_MAX_".to_string()), - } - } else { - Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum '{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}': {}", (value as i32).to_string()))) - } -} - -impl TryFrom for {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - type Error = EnumTypeError; - - fn try_from(v: i32) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, Self::Error> { - match v { - {{#constants}} - x if x == {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::{{#detectKeyword}}{{.}}{{/detectKeyword}} as i32 => Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::{{#detectKeyword}}{{.}}{{/detectKeyword}}), - {{/constants}} - x if x == {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_ as i32 => Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::_MAX_), - _ => Err(EnumTypeError::ParseEnumError(format!("Invalid value for enum '{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}': {}", (v as i32).to_string()))), - } - } -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/env-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/imported/env-type/mod-rs.mustache deleted file mode 100644 index 0553426858..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/env-type/mod-rs.mustache +++ /dev/null @@ -1,59 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_{{#toLower}}{{type}}{{/toLower}}, - read_{{#toLower}}{{type}}{{/toLower}}, - serialize_{{#toLower}}{{type}}{{/toLower}}, - write_{{#toLower}}{{type}}{{/toLower}} -}; -{{#propertyDeps.length}} - -{{#propertyDeps}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/propertyDeps}} -{{/propertyDeps.length}} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/properties}} -} - -impl {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - pub const URI: &'static str = "{{uri}}"; - - pub fn new() -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}, - {{/properties}} - } - } - - pub fn to_buffer(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result, EncodeError> { - serialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - deserialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, writer: &mut W) -> Result<(), EncodeError> { - write_{{#toLower}}{{type}}{{/toLower}}(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - read_{{#toLower}}{{type}}{{/toLower}}(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/env-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/imported/env-type/serialization-rs.mustache deleted file mode 100644 index e451fe9180..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/env-type/serialization-rs.mustache +++ /dev/null @@ -1,169 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{#propertyDeps.length}} - -{{/propertyDeps.length}}{{#propertyDeps}} -{{^isEnum}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/isEnum}} -{{#isEnum}} -use crate::{ - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, - get_{{#toLower}}{{type}}{{/toLower}}_value, - sanitize_{{#toLower}}{{type}}{{/toLower}}_value -}; -{{/isEnum}} -{{/propertyDeps}} - -pub fn serialize_{{#toLower}}{{type}}{{/toLower}}(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported env-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{type}}{{/toLower}}(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_{{#toLower}}{{type}}{{/toLower}}(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, writer: &mut W) -> Result<(), EncodeError> { - {{#properties.length}} - writer.write_map_length(&{{properties.length}})?; - {{/properties.length}} - {{^properties}} - writer.write_map_length(&0)?; - {{/properties}} - {{#properties}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.write_string("{{name}}")?; - {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; - {{/scalar}} - {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { - {{> serialize_array}} - })?; - {{/array}} - {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) - }, |writer, value| { - {{> serialize_map_value}} - })?; - {{/map}} - {{#object}} - {{#required}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; - {{/required}} - {{^required}} - if args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - {{/required}} - {{/object}} - {{#enum}} - {{#required}} - writer.write_i32(&(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; - {{/required}} - {{^required}} - writer.write_optional_i32(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; - {{/required}} - {{/enum}} - writer.context().pop(); - {{/properties}} - Ok(()) -} - -pub fn deserialize_{{#toLower}}{{type}}{{/toLower}}(args: &[u8]) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing imported env-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_{{#toLower}}{{type}}{{/toLower}}(&mut reader) -} - -pub fn read_{{#toLower}}{{type}}{{/toLower}}(reader: &mut R) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - let mut num_of_fields = reader.read_map_length()?; - - {{#properties}} - {{^object}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{^required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; - {{/required}} - {{/object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}_set = false; - {{/required}} - {{/properties}} - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - {{#properties}} - "{{name}}" => { - reader.context().push(&field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}()?; - {{/scalar}} - {{#array}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} - })?; - {{/array}} - {{#map}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}()? - }, |reader| { - {{> deserialize_map_value_nobox}} - })?; - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{#toLower}}{{name}}{{/toLower}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object_nobox}} - _{{#toLower}}{{name}}{{/toLower}} = object; - {{/object}} - {{#required}} - _{{#toLower}}{{name}}{{/toLower}}_set = true; - {{/required}} - reader.context().pop(); - } - {{/properties}} - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - {{#properties}} - {{#required}} - if !_{{#toLower}}{{name}}{{/toLower}}_set { - return Err(DecodeError::MissingField("{{name}}: {{type}}.".to_string())); - } - {{/required}} - {{/properties}} - - Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: _{{#toLower}}{{name}}{{/toLower}}, - {{/properties}} - }) -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/imported/mod-rs.mustache deleted file mode 100644 index 1ba73c7a99..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/mod-rs.mustache +++ /dev/null @@ -1,16 +0,0 @@ -{{#importedObjectTypes}} -pub mod {{#toLower}}{{type}}{{/toLower}}; -pub use {{#toLower}}{{type}}{{/toLower}}::*; -{{/importedObjectTypes}} -{{#importedEnumTypes}} -pub mod {{#toLower}}{{type}}{{/toLower}}; -pub use {{#toLower}}{{type}}{{/toLower}}::*; -{{/importedEnumTypes}} -{{#importedModuleTypes}} -pub mod {{#toLower}}{{type}}{{/toLower}}; -pub use {{#toLower}}{{type}}{{/toLower}}::*; -{{/importedModuleTypes}} -{{#importedEnvTypes}} -pub mod {{#toLower}}{{type}}{{/toLower}}; -pub use {{#toLower}}{{type}}{{/toLower}}::*; -{{/importedEnvTypes}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/module-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/imported/module-type/mod-rs.mustache deleted file mode 100644 index 68a3c9bb93..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/module-type/mod-rs.mustache +++ /dev/null @@ -1,85 +0,0 @@ -use serde::{Serialize, Deserialize}; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Read, - Write, - JSON, - subinvoke, -}; -pub mod serialization; -{{#methods.length}} -pub use serialization::{ - {{#methods}} - deserialize_{{#toLower}}{{name}}{{/toLower}}_result, - serialize_{{#toLower}}{{name}}{{/toLower}}_args, - Args{{#toUpper}}{{name}}{{/toUpper}}{{^last}},{{/last}} - {{/methods}} -}; -{{/methods.length}} -{{#propertyDeps.length}} - -{{#propertyDeps}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/propertyDeps}} -{{/propertyDeps.length}} - -{{^isInterface}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} {} - -impl {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - pub const URI: &'static str = "{{uri}}"; - - pub fn new() -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} {} - } - - {{#methods}} - pub fn {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}(args: &Args{{#toUpper}}{{name}}{{/toUpper}}) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, String> { - let uri = {{#parent}}{{#toUpper}}{{type}}{{/toUpper}}{{/parent}}::URI; - let args = serialize_{{#toLower}}{{name}}{{/toLower}}_args(args).map_err(|e| e.to_string())?; - let result = subinvoke::wrap_subinvoke( - uri, - "{{name}}", - args, - )?; - deserialize_{{#toLower}}{{name}}{{/toLower}}_result(result.as_slice()).map_err(|e| e.to_string()) - } - {{^last}} - - {{/last}} - {{/methods}} -} -{{/isInterface}} -{{#isInterface}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#isInterface}}uri: String{{/isInterface}} -} - -impl {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - pub const INTERFACE_URI: &'static str = "{{uri}}"; - - pub fn new(uri: String) -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { uri } - } - - {{#methods}} - pub fn {{#toLower}}{{name}}{{/toLower}}(&self, args: &Args{{#toUpper}}{{name}}{{/toUpper}}) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, String> { - let ref uri = self.uri; - let args = serialize_{{#toLower}}{{name}}{{/toLower}}_args(args).map_err(|e| e.to_string())?; - let result = subinvoke::wrap_subinvoke( - uri.as_str(), - "{{name}}", - args, - )?; - deserialize_{{#toLower}}{{name}}{{/toLower}}_result(result.as_slice()).map_err(|e| e.to_string()) - } - {{^last}} - - {{/last}} - {{/methods}} -} -{{/isInterface}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/module-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/imported/module-type/serialization-rs.mustache deleted file mode 100644 index c0f580c851..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/module-type/serialization-rs.mustache +++ /dev/null @@ -1,268 +0,0 @@ -{{#methods.length}} -use serde::{Serialize, Deserialize}; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -{{#propertyDeps.length}} - -{{#propertyDeps}} -{{^isEnum}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/isEnum}} -{{#isEnum}} -use crate::{ - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, - get_{{#toLower}}{{type}}{{/toLower}}_value, - sanitize_{{#toLower}}{{type}}{{/toLower}}_value -}; -{{/isEnum}} -{{/propertyDeps}} -{{/propertyDeps.length}} - -{{#methods}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Args{{#toUpper}}{{name}}{{/toUpper}} { - {{#arguments}} - {{#serdeKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/serdeKeyword}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/arguments}} -} - -pub fn deserialize_{{#toLower}}{{name}}{{/toLower}}_args(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing imported module-type: {{#toLower}}{{name}}{{/toLower}} Args".to_string(); - - {{#arguments.length}} - let mut reader = ReadDecoder::new(args, context); - let mut num_of_fields = reader.read_map_length()?; - - {{#arguments}} - {{^object}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{^required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; - {{/required}} - {{/object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}_set = false; - {{/required}} - {{/arguments}} - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - {{#arguments}} - "{{name}}" => { - reader.context().push(&field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading argument"); - {{#scalar}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}()?; - {{/scalar}} - {{#array}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} - })?; - {{/array}} - {{#map}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() - }, |reader| { - {{> deserialize_map_value_nobox}} - })?; - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{#toLower}}{{name}}{{/toLower}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object_refmut}} - _{{#toLower}}{{name}}{{/toLower}} = object; - {{/object}} - {{#required}} - _{{#toLower}}{{name}}{{/toLower}}_set = true; - {{/required}} - reader.context().pop(); - } - {{/arguments}} - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - {{#arguments}} - {{#required}} - if !_{{#toLower}}{{name}}{{/toLower}}_set { - return Err(DecodeError::MissingField("{{name}}: {{type}}.".to_string())); - } - {{/required}} - {{/arguments}} - {{/arguments.length}} - - Ok(Args{{#toUpper}}{{name}}{{/toUpper}} { - {{#arguments}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: _{{#toLower}}{{name}}{{/toLower}}, - {{/arguments}} - }) -} - -pub fn serialize_{{#toLower}}{{name}}{{/toLower}}_args(args: &Args{{#toUpper}}{{name}}{{/toUpper}}) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported module-type: {{#toLower}}{{name}}{{/toLower}} Args".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{name}}{{/toLower}}_args(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_{{#toLower}}{{name}}{{/toLower}}_args(args: &Args{{#toUpper}}{{name}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { - {{#arguments.length}} - writer.write_map_length(&{{arguments.length}})?; - {{/arguments.length}} - {{^arguments}} - writer.write_map_length(&0)?; - {{/arguments}} - {{#arguments}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.write_string("{{name}}")?; - {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; - {{/scalar}} - {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { - {{> serialize_array}} - })?; - {{/array}} - {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) - }, |writer, value| { - {{> serialize_map_value}} - })?; - {{/map}} - {{#enum}} - {{#required}} - writer.write_i32(&(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; - {{/required}} - {{^required}} - writer.write_optional_i32(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; - {{/required}} - {{/enum}} - {{#object}} - {{#required}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; - {{/required}} - {{^required}} - if args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - {{/required}} - {{/object}} - writer.context().pop(); - {{/arguments}} - Ok(()) -} - -pub fn serialize_{{#toLower}}{{name}}{{/toLower}}_result(result: {{#return}}&{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported module-type: {{#toLower}}{{name}}{{/toLower}} Result".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{name}}{{/toLower}}_result(result, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_{{#toLower}}{{name}}{{/toLower}}_result(result: {{#return}}&{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, writer: &mut W) -> Result<(), EncodeError> { - {{#return}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing result"); - {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(result)?; - {{/scalar}} - {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&result, |writer, item| { - {{> serialize_array}} - })?; - {{/array}} - {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&result, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) - }, |writer, value| { - {{> serialize_map_value}} - })?; - {{/map}} - {{#enum}} - {{#required}} - writer.write_i32(&(*result as i32))?; - {{/required}} - {{^required}} - writer.write_optional_i32(&result.map(|f| f as i32))?; - {{/required}} - {{/enum}} - {{#object}} - {{#required}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(&result, writer)?; - {{/required}} - {{^required}} - if result.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(result.as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - {{/required}} - {{/object}} - writer.context().pop(); - {{/return}} - Ok(()) -} - -pub fn deserialize_{{#toLower}}{{name}}{{/toLower}}_result(result: &[u8]) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing imported module-type: {{#toLower}}{{name}}{{/toLower}} Result".to_string(); - let mut reader = ReadDecoder::new(result, context); - - {{#return}} - reader.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "reading function output"); - {{#scalar}} - let res = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}()?; - {{/scalar}} - {{#array}} - let res = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} - })?; - {{/array}} - {{#map}} - let res = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() - }, |reader| { - {{> deserialize_map_value_nobox}} - })?; - {{/map}} - {{#enum}} - {{> deserialize_enum}} - let res = value; - {{/enum}} - {{#object}} - {{> deserialize_object_refmut}} - let res = object; - {{/object}} - {{/return}} - reader.context().pop(); - Ok(res) -} -{{^last}} - -{{/last}} -{{/methods}} -{{/methods.length}} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/object-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/imported/object-type/mod-rs.mustache deleted file mode 100644 index 80312021cc..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/object-type/mod-rs.mustache +++ /dev/null @@ -1,59 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_{{#toLower}}{{type}}{{/toLower}}, - read_{{#toLower}}{{type}}{{/toLower}}, - serialize_{{#toLower}}{{type}}{{/toLower}}, - write_{{#toLower}}{{type}}{{/toLower}} -}; -{{#propertyDeps.length}} - -{{#propertyDeps}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/propertyDeps}} -{{/propertyDeps.length}} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#serdeKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/serdeKeyword}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/properties}} -} - -impl {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - pub const URI: &'static str = "{{uri}}"; - - pub fn new() -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}, - {{/properties}} - } - } - - pub fn to_buffer(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result, EncodeError> { - serialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - deserialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, writer: &mut W) -> Result<(), EncodeError> { - write_{{#toLower}}{{type}}{{/toLower}}(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - read_{{#toLower}}{{type}}{{/toLower}}(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/object-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/imported/object-type/serialization-rs.mustache deleted file mode 100644 index 5c5d2f149a..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/imported/object-type/serialization-rs.mustache +++ /dev/null @@ -1,169 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{#propertyDeps.length}} - -{{/propertyDeps.length}}{{#propertyDeps}} -{{^isEnum}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/isEnum}} -{{#isEnum}} -use crate::{ - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, - get_{{#toLower}}{{type}}{{/toLower}}_value, - sanitize_{{#toLower}}{{type}}{{/toLower}}_value -}; -{{/isEnum}} -{{/propertyDeps}} - -pub fn serialize_{{#toLower}}{{type}}{{/toLower}}(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported object-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{type}}{{/toLower}}(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_{{#toLower}}{{type}}{{/toLower}}(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, writer: &mut W) -> Result<(), EncodeError> { - {{#properties.length}} - writer.write_map_length(&{{properties.length}})?; - {{/properties.length}} - {{^properties}} - writer.write_map_length(&0)?; - {{/properties}} - {{#properties}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.write_string("{{name}}")?; - {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; - {{/scalar}} - {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { - {{> serialize_array}} - })?; - {{/array}} - {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) - }, |writer, value| { - {{> serialize_map_value}} - })?; - {{/map}} - {{#object}} - {{#required}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; - {{/required}} - {{^required}} - if args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - {{/required}} - {{/object}} - {{#enum}} - {{#required}} - writer.write_i32(&(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; - {{/required}} - {{^required}} - writer.write_optional_i32(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; - {{/required}} - {{/enum}} - writer.context().pop(); - {{/properties}} - Ok(()) -} - -pub fn deserialize_{{#toLower}}{{type}}{{/toLower}}(args: &[u8]) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing imported object-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_{{#toLower}}{{type}}{{/toLower}}(&mut reader) -} - -pub fn read_{{#toLower}}{{type}}{{/toLower}}(reader: &mut R) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - let mut num_of_fields = reader.read_map_length()?; - - {{#properties}} - {{^object}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{^required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; - {{/required}} - {{/object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}_set = false; - {{/required}} - {{/properties}} - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - {{#properties}} - "{{name}}" => { - reader.context().push(&field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}()?; - {{/scalar}} - {{#array}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} - })?; - {{/array}} - {{#map}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() - }, |reader| { - {{> deserialize_map_value_nobox}} - })?; - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{#toLower}}{{name}}{{/toLower}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object_nobox}} - _{{#toLower}}{{name}}{{/toLower}} = object; - {{/object}} - {{#required}} - _{{#toLower}}{{name}}{{/toLower}}_set = true; - {{/required}} - reader.context().pop(); - } - {{/properties}} - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - {{#properties}} - {{#required}} - if !_{{#toLower}}{{name}}{{/toLower}}_set { - return Err(DecodeError::MissingField("{{name}}: {{type}}.".to_string())); - } - {{/required}} - {{/properties}} - - Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: _{{#toLower}}{{name}}{{/toLower}}, - {{/properties}} - }) -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/interface-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/interface-type/mod-rs.mustache deleted file mode 100644 index 3235c088b4..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/interface-type/mod-rs.mustache +++ /dev/null @@ -1,23 +0,0 @@ -{{#capabilities}} -{{#getImplementations}} -{{#enabled}} -use polywrap_wasm_rs::wrap_get_implementations; -{{/enabled}} -{{/getImplementations}} -{{/capabilities}} - -pub struct {{#detectKeyword}}{{#toUpper}}{{namespace}}{{/toUpper}}{{/detectKeyword}} {} - -impl {{#detectKeyword}}{{#toUpper}}{{namespace}}{{/toUpper}}{{/detectKeyword}} { - const uri: &'static str = "{{uri}}"; - - {{#capabilities}} - {{#getImplementations}} - {{#enabled}} - pub fn get_implementations() -> Vec { - wrap_get_implementations(Self::uri) - } - {{/enabled}} - {{/getImplementations}} - {{/capabilities}} -} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/mod-rs.mustache deleted file mode 100644 index 4995ae44f4..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/mod-rs.mustache +++ /dev/null @@ -1,61 +0,0 @@ -pub mod entry; -{{#objectTypes}} -pub mod {{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}; -pub use {{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/objectTypes}} -{{#enumTypes}} -pub mod {{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}; -pub use {{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}::{ - get_{{#toLower}}{{type}}{{/toLower}}_key, - get_{{#toLower}}{{type}}{{/toLower}}_value, - sanitize_{{#toLower}}{{type}}{{/toLower}}_value, - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} -}; -{{/enumTypes}} -{{#envType}} -pub mod {{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}; -pub use {{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/envType}} -{{#hasImports}} -pub mod imported; -{{/hasImports}} -{{#importedObjectTypes}} -pub use imported::{{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/importedObjectTypes}} -{{#importedEnumTypes}} -pub use imported::{{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}::{ - get_{{#toLower}}{{type}}{{/toLower}}_key, - get_{{#toLower}}{{type}}{{/toLower}}_value, - sanitize_{{#toLower}}{{type}}{{/toLower}}_value, - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} -}; -{{/importedEnumTypes}} -{{#importedEnvTypes}} -pub use imported::{{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/importedEnvTypes}} -{{#importedModuleTypes}} -pub use imported::{{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/importedModuleTypes}} -{{#interfaceTypes}} -pub mod {{#detectKeyword}}{{#toLower}}{{namespace}}{{/toLower}}{{/detectKeyword}}; -pub use {{#detectKeyword}}{{#toLower}}{{namespace}}{{/toLower}}{{/detectKeyword}}::{{#detectKeyword}}{{#toUpper}}{{namespace}}{{/toUpper}}{{/detectKeyword}}; -{{/interfaceTypes}} -{{#moduleType}} -pub mod {{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}; -pub use {{#detectKeyword}}{{#toLower}}{{type}}{{/toLower}}{{/detectKeyword}}::{ - Module, - ModuleTrait, - {{#methods}} - deserialize_{{#toLower}}{{name}}{{/toLower}}_args, - serialize_{{#toLower}}{{name}}{{/toLower}}_result, - {{#toLower}}{{name}}{{/toLower}}_wrapped, - Args{{#toUpper}}{{name}}{{/toUpper}}{{^last}},{{/last}} - {{/methods}} -}; -{{/moduleType}} - -// Override print!(...) & println!(...) macros -#[macro_export] -macro_rules! println { ($($args:tt)*) => { polywrap_wasm_rs::wrap_debug_log(format!($($args)*).as_str()); } } -#[macro_export] -macro_rules! print { ($($args:tt)*) => { polywrap_wasm_rs::wrap_debug_log(format!($($args)*).as_str()); } } diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/mod-rs.mustache deleted file mode 100644 index ed7476933f..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/mod-rs.mustache +++ /dev/null @@ -1,21 +0,0 @@ -{{#moduleType}} -{{#methods.length}} -pub mod wrapped; -pub use wrapped::{ - {{#methods}} - {{#toLower}}{{name}}{{/toLower}}_wrapped{{^last}},{{/last}} - {{/methods}} -}; -pub mod serialization; -pub use serialization::{ - {{#methods}} - deserialize_{{#toLower}}{{name}}{{/toLower}}_args, - serialize_{{#toLower}}{{name}}{{/toLower}}_result, - Args{{#toUpper}}{{name}}{{/toUpper}}{{^last}},{{/last}} - {{/methods}} -}; -{{/methods.length}} - -pub mod module; -pub use module::*; -{{/moduleType}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/module-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/module-rs.mustache deleted file mode 100644 index 1e4490872b..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/module-rs.mustache +++ /dev/null @@ -1,37 +0,0 @@ -{{#moduleType}} -use crate::{ - {{#methods}} - Args{{#toUpper}}{{name}}{{/toUpper}}, - {{/methods}} -}; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - JSON, -}; -{{#propertyDeps.length}} - -{{#propertyDeps}} -{{^isEnum}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/isEnum}} -{{#isEnum}} -use crate::{ - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, -}; -{{/isEnum}} -{{/propertyDeps}} -{{/propertyDeps.length}} - -pub struct Module; - -pub trait ModuleTrait { - {{#methods}} - fn {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}(args: Args{{#toUpper}}{{name}}{{/toUpper}}{{#env}}, env: {{#required}}Env{{/required}}{{^required}}Option{{/required}}{{/env}}) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, String>; - {{^last}} - - {{/last}} - {{/methods}} -} -{{/moduleType}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/serialization-rs.mustache deleted file mode 100644 index 2b94133316..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/serialization-rs.mustache +++ /dev/null @@ -1,269 +0,0 @@ -{{#moduleType}} -use serde::{Serialize, Deserialize}; -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -{{#propertyDeps.length}} - -{{#propertyDeps}} -{{^isEnum}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/isEnum}} -{{#isEnum}} -use crate::{ - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, - get_{{#toLower}}{{type}}{{/toLower}}_value, - sanitize_{{#toLower}}{{type}}{{/toLower}}_value -}; -{{/isEnum}} -{{/propertyDeps}} -{{/propertyDeps.length}} - -{{#methods}} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Args{{#toUpper}}{{name}}{{/toUpper}} { - {{#arguments}} - {{#serdeKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/serdeKeyword}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/arguments}} -} - -pub fn deserialize_{{#toLower}}{{name}}{{/toLower}}_args(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing module-type: {{#toLower}}{{name}}{{/toLower}} Args".to_string(); - - {{#arguments.length}} - let mut reader = ReadDecoder::new(args, context); - let mut num_of_fields = reader.read_map_length()?; - - {{#arguments}} - {{^object}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{^required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; - {{/required}} - {{/object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}_set = false; - {{/required}} - {{/arguments}} - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - {{#arguments}} - "{{name}}" => { - reader.context().push(&field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading argument"); - {{#scalar}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}()?; - {{/scalar}} - {{#array}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} - })?; - {{/array}} - {{#map}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() - }, |reader| { - {{> deserialize_map_value_nobox}} - })?; - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{#toLower}}{{name}}{{/toLower}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object_refmut}} - _{{#toLower}}{{name}}{{/toLower}} = object; - {{/object}} - {{#required}} - _{{#toLower}}{{name}}{{/toLower}}_set = true; - {{/required}} - reader.context().pop(); - } - {{/arguments}} - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - {{#arguments}} - {{#required}} - if !_{{#toLower}}{{name}}{{/toLower}}_set { - return Err(DecodeError::MissingField("{{name}}: {{type}}.".to_string())); - } - {{/required}} - {{/arguments}} - {{/arguments.length}} - - Ok(Args{{#toUpper}}{{name}}{{/toUpper}} { - {{#arguments}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: _{{#toLower}}{{name}}{{/toLower}}, - {{/arguments}} - }) -} - -pub fn serialize_{{#toLower}}{{name}}{{/toLower}}_args(args: &Args{{#toUpper}}{{name}}{{/toUpper}}) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: {{#toLower}}{{name}}{{/toLower}} Args".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{name}}{{/toLower}}_args(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_{{#toLower}}{{name}}{{/toLower}}_args(args: &Args{{#toUpper}}{{name}}{{/toUpper}}, writer: &mut W) -> Result<(), EncodeError> { - {{#arguments.length}} - writer.write_map_length(&{{arguments.length}})?; - {{/arguments.length}} - {{^arguments}} - writer.write_map_length(&0)?; - {{/arguments}} - {{#arguments}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.write_string("{{name}}")?; - {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; - {{/scalar}} - {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { - {{> serialize_array}} - })?; - {{/array}} - {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) - }, |writer, value| { - {{> serialize_map_value}} - })?; - {{/map}} - {{#enum}} - {{#required}} - writer.write_i32(&(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; - {{/required}} - {{^required}} - writer.write_optional_i32(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; - {{/required}} - {{/enum}} - {{#object}} - {{#required}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; - {{/required}} - {{^required}} - if args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - {{/required}} - {{/object}} - writer.context().pop(); - {{/arguments}} - Ok(()) -} - -pub fn serialize_{{#toLower}}{{name}}{{/toLower}}_result(result: {{#return}}&{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: {{#toLower}}{{name}}{{/toLower}} Result".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{name}}{{/toLower}}_result(result, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_{{#toLower}}{{name}}{{/toLower}}_result(result: {{#return}}&{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, writer: &mut W) -> Result<(), EncodeError> { - {{#return}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing result"); - {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(result)?; - {{/scalar}} - {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&result, |writer, item| { - {{> serialize_array}} - })?; - {{/array}} - {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&result, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) - }, |writer, value| { - {{> serialize_map_value}} - })?; - {{/map}} - {{#enum}} - {{#required}} - writer.write_i32(&(*result as i32))?; - {{/required}} - {{^required}} - writer.write_optional_i32(&result.map(|f| f as i32))?; - {{/required}} - {{/enum}} - {{#object}} - {{#required}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(&result, writer)?; - {{/required}} - {{^required}} - if result.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(result.as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - {{/required}} - {{/object}} - writer.context().pop(); - {{/return}} - Ok(()) -} - -pub fn deserialize_{{#toLower}}{{name}}{{/toLower}}_result(result: &[u8]) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing module-type: {{#toLower}}{{name}}{{/toLower}} Result".to_string(); - let mut reader = ReadDecoder::new(result, context); - - {{#return}} - reader.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "reading function output"); - {{#scalar}} - let res = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}()?; - {{/scalar}} - {{#array}} - let res = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} - })?; - {{/array}} - {{#map}} - let res = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() - }, |reader| { - {{> deserialize_map_value_nobox}} - })?; - {{/map}} - {{#enum}} - {{> deserialize_enum}} - let res = value; - {{/enum}} - {{#object}} - {{> deserialize_object_refmut}} - let res = object; - {{/object}} - {{/return}} - reader.context().pop(); - Ok(res) -} -{{^last}} - -{{/last}} -{{/methods}} -{{/moduleType}} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/wrapped-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/wrapped-rs.mustache deleted file mode 100644 index 1ab6becd14..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/module-type/wrapped-rs.mustache +++ /dev/null @@ -1,71 +0,0 @@ -{{#moduleType}} -{{#methods.length}} -use polywrap_wasm_rs::{ - wrap_load_env -}; - -use crate::{ - {{#methods}} - Args{{#toUpper}}{{name}}{{/toUpper}}, - deserialize_{{#toLower}}{{name}}{{/toLower}}_args, - serialize_{{#toLower}}{{name}}{{/toLower}}_result{{^last}},{{/last}} - {{/methods}} -}; -{{/methods.length}} - -use crate::module::{ModuleTrait, Module}; -{{#envType}} -use crate::Env; -{{/envType}} - -{{#methods}} -pub fn {{#toLower}}{{name}}{{/toLower}}_wrapped(args: &[u8], env_size: u32) -> Vec { - {{#env}} - {{#required}} - if env_size == 0 { - panic!("Environment is not set, and it is required by method '{{name}}'"); - } - - let env_buf = wrap_load_env(env_size); - let env = Env::from_buffer(&env_buf).unwrap(); - - {{/required}} - {{^required}} - let mut env: Option = None; - if env_size > 0 { - let env_buf = wrap_load_env(env_size); - env = Some(Env::from_buffer(&env_buf).unwrap()); - } - - {{/required}} - {{/env}} - {{#arguments.length}} - match deserialize_{{#toLower}}{{name}}{{/toLower}}_args(args) { - Ok(args) => { - {{/arguments.length}} - let result = Module::{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}(Args{{#toUpper}}{{name}}{{/toUpper}} { - {{#arguments}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, - {{/arguments}} - }{{#env}}, env{{/env}}); - match result { - Ok(res) => { - serialize_{{#toLower}}{{name}}{{/toLower}}_result({{#return}}&{{/return}}res).unwrap() - } - Err(e) => { - panic!("{}", e.to_string()) - } - } - {{#arguments.length}} - } - Err(e) => { - panic!("{}", e.to_string()) - } - } - {{/arguments.length}} -} -{{^last}} - -{{/last}} -{{/methods}} -{{/moduleType}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/object-type/mod-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/object-type/mod-rs.mustache deleted file mode 100644 index 1dc58d4cb4..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/object-type/mod-rs.mustache +++ /dev/null @@ -1,55 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_{{#toLower}}{{type}}{{/toLower}}, - read_{{#toLower}}{{type}}{{/toLower}}, - serialize_{{#toLower}}{{type}}{{/toLower}}, - write_{{#toLower}}{{type}}{{/toLower}} -}; - -{{#propertyDeps}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/propertyDeps}} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#serdeKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/serdeKeyword}}pub {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}}, - {{/properties}} -} - -impl {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - pub fn new() -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}, - {{/properties}} - } - } - - pub fn to_buffer(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result, EncodeError> { - serialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - deserialize_{{#toLower}}{{type}}{{/toLower}}(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, writer: &mut W) -> Result<(), EncodeError> { - write_{{#toLower}}{{type}}{{/toLower}}(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - read_{{#toLower}}{{type}}{{/toLower}}(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/schema/bind/src/bindings/rust/wasm/templates/object-type/serialization-rs.mustache b/packages/schema/bind/src/bindings/rust/wasm/templates/object-type/serialization-rs.mustache deleted file mode 100644 index 0743b3c9f3..0000000000 --- a/packages/schema/bind/src/bindings/rust/wasm/templates/object-type/serialization-rs.mustache +++ /dev/null @@ -1,169 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{#propertyDeps.length}} - -{{/propertyDeps.length}}{{#propertyDeps}} -{{^isEnum}} -use {{crate}}::{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}; -{{/isEnum}} -{{#isEnum}} -use crate::{ - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, - get_{{#toLower}}{{type}}{{/toLower}}_value, - sanitize_{{#toLower}}{{type}}{{/toLower}}_value -}; -{{/isEnum}} -{{/propertyDeps}} - -pub fn serialize_{{#toLower}}{{type}}{{/toLower}}(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) object-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_{{#toLower}}{{type}}{{/toLower}}(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_{{#toLower}}{{type}}{{/toLower}}(args: &{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, writer: &mut W) -> Result<(), EncodeError> { - {{#properties.length}} - writer.write_map_length(&{{properties.length}})?; - {{/properties.length}} - {{^properties}} - writer.write_map_length(&0)?; - {{/properties}} - {{#properties}} - writer.context().push("{{name}}", "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "writing property"); - writer.write_string("{{name}}")?; - {{#scalar}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}})?; - {{/scalar}} - {{#array}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, item| { - {{> serialize_array}} - })?; - {{/array}} - {{#map}} - writer.write_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, |writer, key| { - writer.write_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}(key) - }, |writer, value| { - {{> serialize_map_value}} - })?; - {{/map}} - {{#object}} - {{#required}} - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}, writer)?; - {{/required}} - {{^required}} - if args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.is_some() { - {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}::write(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - {{/required}} - {{/object}} - {{#enum}} - {{#required}} - writer.write_i32(&(args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}} as i32))?; - {{/required}} - {{^required}} - writer.write_optional_i32(&args.{{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}.map(|f| f as i32))?; - {{/required}} - {{/enum}} - writer.context().pop(); - {{/properties}} - Ok(()) -} - -pub fn deserialize_{{#toLower}}{{type}}{{/toLower}}(args: &[u8]) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing object-type: {{#toUpper}}{{type}}{{/toUpper}}".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_{{#toLower}}{{type}}{{/toLower}}(&mut reader) -} - -pub fn read_{{#toLower}}{{type}}{{/toLower}}(reader: &mut R) -> Result<{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}, DecodeError> { - let mut num_of_fields = reader.read_map_length()?; - - {{#properties}} - {{^object}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/object}} - {{#object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = {{#toWasmInit}}{{toGraphQLType}}{{/toWasmInit}}; - {{/required}} - {{^required}} - let mut _{{#toLower}}{{name}}{{/toLower}}: {{#toWasm}}{{toGraphQLType}}{{/toWasm}} = None; - {{/required}} - {{/object}} - {{#required}} - let mut _{{#toLower}}{{name}}{{/toLower}}_set = false; - {{/required}} - {{/properties}} - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - {{#properties}} - "{{name}}" => { - reader.context().push(&field, "{{#toWasm}}{{toGraphQLType}}{{/toWasm}}", "type found, reading property"); - {{#scalar}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}()?; - {{/scalar}} - {{#array}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - {{> deserialize_array_nobox}} - })?; - {{/array}} - {{#map}} - _{{#toLower}}{{name}}{{/toLower}} = reader.read_{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}(|reader| { - reader.read_{{#key}}{{#toLower}}{{#toMsgPack}}{{toGraphQLType}}{{/toMsgPack}}{{/toLower}}{{/key}}() - }, |reader| { - {{> deserialize_map_value_nobox}} - })?; - {{/map}} - {{#enum}} - {{> deserialize_enum}} - _{{#toLower}}{{name}}{{/toLower}} = value; - {{/enum}} - {{#object}} - {{> deserialize_object_nobox}} - _{{#toLower}}{{name}}{{/toLower}} = object; - {{/object}} - {{#required}} - _{{#toLower}}{{name}}{{/toLower}}_set = true; - {{/required}} - reader.context().pop(); - } - {{/properties}} - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - {{#properties}} - {{#required}} - if !_{{#toLower}}{{name}}{{/toLower}}_set { - return Err(DecodeError::MissingField("{{name}}: {{type}}.".to_string())); - } - {{/required}} - {{/properties}} - - Ok({{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { - {{#properties}} - {{#detectKeyword}}{{#toLower}}{{name}}{{/toLower}}{{/detectKeyword}}: _{{#toLower}}{{name}}{{/toLower}}, - {{/properties}} - }) -} diff --git a/packages/schema/bind/src/bindings/types.ts b/packages/schema/bind/src/bindings/types.ts index cdae810318..bb57623e20 100644 --- a/packages/schema/bind/src/bindings/types.ts +++ b/packages/schema/bind/src/bindings/types.ts @@ -1,8 +1,39 @@ import { BindOptions, BindOutput } from "../"; -export type GenerateBindingFn = (options: BindOptions) => BindOutput; +export type GenerateBindingFn = ( + options: BindOptions +) => Promise | BindOutput; export type MustacheFn = () => ( value: string, render: (template: string) => string ) => string; + +// eslint-disable-next-line @typescript-eslint/naming-convention +export interface Args_generateBindings { + wrapInfo: WrapInfo; + context?: string | null; // JSON string +} + +export interface WrapInfo { + version: string; + name: string; + type: string; + abi: string; // JSON string +} + +export interface Output { + files: Array; + dirs: Array; +} + +export interface File { + name: string; + data: string; +} + +export interface Directory { + name: string; + files: Array; + dirs: Array; +} diff --git a/packages/schema/bind/src/bindings/typescript/app/index.ts b/packages/schema/bind/src/bindings/typescript/app/index.ts deleted file mode 100644 index 4a3a71bd8a..0000000000 --- a/packages/schema/bind/src/bindings/typescript/app/index.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import * as Functions from "../functions"; -import { GenerateBindingFn, renderTemplates } from "../.."; -import { BindOptions, BindOutput } from "../../.."; - -import { - transformAbi, - extendType, - addFirstLast, - toPrefixedGraphQLType, - methodParentPointers, -} from "@polywrap/schema-parse"; -import { WrapAbi } from "@polywrap/wrap-manifest-types-js"; -import path from "path"; - -export { Functions }; - -export const generateBinding: GenerateBindingFn = ( - options: BindOptions -): BindOutput => { - const result: BindOutput = { - output: { - entries: [], - }, - outputDirAbs: options.outputDirAbs, - }; - const output = result.output; - const abi = applyTransforms(options.abi); - - output.entries = renderTemplates( - path.join(__dirname, "./templates"), - abi, - {} - ); - - return result; -}; - -function applyTransforms(abi: WrapAbi): WrapAbi { - const transforms = [ - extendType(Functions), - addFirstLast, - toPrefixedGraphQLType, - methodParentPointers(), - ]; - - for (const transform of transforms) { - abi = transformAbi(abi, transform); - } - return abi; -} diff --git a/packages/schema/bind/src/bindings/typescript/app/templates/index-ts.mustache b/packages/schema/bind/src/bindings/typescript/app/templates/index-ts.mustache deleted file mode 100644 index eea524d655..0000000000 --- a/packages/schema/bind/src/bindings/typescript/app/templates/index-ts.mustache +++ /dev/null @@ -1 +0,0 @@ -export * from "./types"; diff --git a/packages/schema/bind/src/bindings/typescript/app/templates/types-ts.mustache b/packages/schema/bind/src/bindings/typescript/app/templates/types-ts.mustache deleted file mode 100644 index bd3f9732ca..0000000000 --- a/packages/schema/bind/src/bindings/typescript/app/templates/types-ts.mustache +++ /dev/null @@ -1,121 +0,0 @@ -// @ts-ignore -import * as Types from "./"; - -// @ts-ignore -import { - CoreClient, - InvokeResult, - Uri, -} from "@polywrap/core-js"; - -export type UInt = number; -export type UInt8 = number; -export type UInt16 = number; -export type UInt32 = number; -export type Int = number; -export type Int8 = number; -export type Int16 = number; -export type Int32 = number; -export type Bytes = Uint8Array; -export type BigInt = string; -export type BigNumber = string; -export type Json = string; -export type String = string; -export type Boolean = boolean; -{{#objectTypes}} - -export interface {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#properties}} - {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; - {{/properties}} -} -{{/objectTypes}} -{{#enumTypes}} - -export enum {{type}}Enum { - {{#constants}} - {{.}}, - {{/constants}} -} - -export type {{type}}String = - {{#constants}} - | "{{.}}" - {{/constants}} - -export type {{#detectKeyword}}{{type}}{{/detectKeyword}} = {{type}}Enum | {{type}}String; -{{/enumTypes}} -{{#importedObjectTypes.length}} - -/// Imported Objects START /// -{{#importedObjectTypes}} - -/* URI: "{{uri}}" */ -export interface {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#properties}} - {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; - {{/properties}} -} -{{/importedObjectTypes}} - -/// Imported Objects END /// -{{/importedObjectTypes.length}} -{{#importedEnumTypes.length}} - -/// Imported Enums START /// -{{#importedEnumTypes}} - -/* URI: "{{uri}}" */ -export enum {{type}}Enum { - {{#constants}} - {{.}}, - {{/constants}} -} - -export type {{type}}String = - {{#constants}} - | "{{.}}" - {{/constants}} - -export type {{#detectKeyword}}{{type}}{{/detectKeyword}} = {{type}}Enum | {{type}}String; -{{/importedEnumTypes}} - -/// Imported Enums END /// -{{/importedEnumTypes.length}} -{{#importedModuleTypes.length}} - -/// Imported Modules START /// -{{#importedModuleTypes}} -{{#methods}} - -/* URI: "{{parent.uri}}" */ -export interface {{parent.type}}_Args_{{name}} { - {{#arguments}} - {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; - {{/arguments}} -} -{{/methods}} - -/* URI: "{{uri}}" */ -export const {{type}} = { - {{#methods}} - {{name}}: async ( - args: {{parent.type}}_Args_{{name}}, - client: CoreClient, - uri: string = "{{parent.uri}}" - ): Promise> => { - return client.invoke<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>({ - uri: Uri.from(uri), - method: "{{name}}", - args: (args as unknown) as Record, - }); - }{{^last}},{{/last}} - {{^last}} - - {{/last}} - {{/methods}} -}; -{{/importedModuleTypes}} - -/// Imported Modules END /// -{{/importedModuleTypes.length}} \ No newline at end of file diff --git a/packages/schema/bind/src/bindings/typescript/functions.ts b/packages/schema/bind/src/bindings/typescript/functions.ts deleted file mode 100644 index 1c47e7f24a..0000000000 --- a/packages/schema/bind/src/bindings/typescript/functions.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { MustacheFn } from "../types"; -import { isKeyword } from "./types"; - -// check if any of the keywords match the property name; -// if there's a match, insert `_` at the beginning of the property name. -export const detectKeyword: MustacheFn = () => { - return (value: string, render: (template: string) => string): string => { - const type = render(value); - if (isKeyword(type)) { - return "_" + type; - } - return type; - }; -}; - -const firstUpper = (str: string) => - str ? str[0].toUpperCase() + str.slice(1) : ""; - -const firstLower = (str: string) => - str ? str[0].toLowerCase() + str.slice(1) : ""; - -export const toLowerCase: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - const rendered = render(value); - return rendered.toLowerCase(); - }; -}; - -export const toClassName: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - const rendered = render(value); - rendered.replace(/([^A-Za-z0-9])+/g, ","); - return rendered - .split(",") - .map((x) => (x ? firstUpper(x.replace(",", "")) : "")) - .join(); - }; -}; - -export const toFuncName: MustacheFn = () => { - return (value: string, render: (template: string) => string) => { - let rendered = render(value); - rendered = rendered.replace(/([^A-Za-z0-9])+/g, ","); - return rendered - .split(",") - .map((x, index) => { - x = x.replace(",", ""); - return index === 0 ? firstLower(x) : firstUpper(x); - }) - .join(); - }; -}; - -export const toTypescript: MustacheFn = () => { - return _toTypescript; -}; - -const _toTypescript = ( - value: string, - render: (template: string) => string, - undefinable = false -) => { - let type = render(value); - - let optional = false; - if (type[type.length - 1] === "!") { - type = type.substring(0, type.length - 1); - } else { - optional = true; - } - - if (type[0] === "[") { - return toTypescriptArray(type, optional); - } - - if (type.startsWith("Map<")) { - return toTypescriptMap(type, optional); - } - - switch (type) { - case "JSON": - type = "Types.Json"; - break; - default: - if (type.includes("Enum_")) { - type = type.replace("Enum_", ""); - } - type = detectKeyword()(type, (str) => str); - type = `Types.${type}`; - } - - return undefinable - ? applyUndefinable(type, optional) - : applyOptional(type, optional); -}; - -const toTypescriptArray = (type: string, optional: boolean): string => { - const result = type.match(/(\[)([[\]A-Za-z0-9_.!]+)(\])/); - - if (!result || result.length !== 4) { - throw Error(`Invalid Array: ${type}`); - } - - const tsType = _toTypescript(result[2], (str) => str); - return applyOptional("Array<" + tsType + ">", optional); -}; - -const toTypescriptMap = (type: string, optional: boolean): string => { - const openAngleBracketIdx = type.indexOf("<"); - const closeAngleBracketIdx = type.lastIndexOf(">"); - - const keyValTypes = type.substring( - openAngleBracketIdx + 1, - closeAngleBracketIdx - ); - - const firstCommaIdx = keyValTypes.indexOf(","); - const keyType = keyValTypes.substring(0, firstCommaIdx).trim(); - const valType = keyValTypes.substring(firstCommaIdx + 1).trim(); - - const tsKeyType = _toTypescript(keyType, (str) => str); - const tsValType = _toTypescript(valType, (str) => str, true); - - return applyOptional(`Map<${tsKeyType}, ${tsValType}>`, optional); -}; - -const applyOptional = (type: string, optional: boolean): string => { - if (optional) { - return `${type} | null`; - } else { - return type; - } -}; - -const applyUndefinable = (type: string, undefinable: boolean): string => { - if (undefinable) { - return `${type} | undefined`; - } else { - return type; - } -}; diff --git a/packages/schema/bind/src/bindings/typescript/index.ts b/packages/schema/bind/src/bindings/typescript/index.ts deleted file mode 100644 index 4d7a06f114..0000000000 --- a/packages/schema/bind/src/bindings/typescript/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * as App from "./app"; -export * as Plugin from "./plugin"; -export * as Functions from "./functions"; -export * as Types from "./types"; diff --git a/packages/schema/bind/src/bindings/typescript/plugin/index.ts b/packages/schema/bind/src/bindings/typescript/plugin/index.ts deleted file mode 100644 index c6111472dc..0000000000 --- a/packages/schema/bind/src/bindings/typescript/plugin/index.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -import * as Functions from "../functions"; -import { GenerateBindingFn, renderTemplates } from "../.."; -import { BindOptions, BindOutput } from "../../.."; - -import { - transformAbi, - extendType, - addFirstLast, - toPrefixedGraphQLType, - methodParentPointers, - interfaceUris, -} from "@polywrap/schema-parse"; -import { WrapAbi } from "@polywrap/wrap-manifest-types-js"; -import path from "path"; -import { latestWrapManifestVersion } from "@polywrap/wrap-manifest-types-js"; - -export { Functions }; - -const templatePath = (subpath: string) => - path.join(__dirname, "./templates", subpath); - -const sort = (obj: Record) => - Object.keys(obj) - .sort() - .reduce((map: Record, key: string) => { - if (typeof obj[key] === "object") { - map[key] = sort(obj[key] as Record); - - if (Array.isArray(obj[key])) { - map[key] = Object.values(map[key] as Record); - } - } else { - map[key] = obj[key]; - } - return map; - }, {}); - -export const generateBinding: GenerateBindingFn = ( - options: BindOptions -): BindOutput => { - // Apply Abi transforms - const abi = applyTransforms(options.abi); - - // Generate Bindings - const result: BindOutput = { - output: { - entries: [], - }, - outputDirAbs: options.outputDirAbs, - }; - const output = result.output; - const manifest = { - name: options.projectName, - type: "plugin", - version: latestWrapManifestVersion, - abi: JSON.stringify( - sort((options.abi as unknown) as Record), - null, - 2 - ), - }; - - output.entries = renderTemplates(templatePath(""), { ...abi, manifest }, {}); - - return result; -}; - -function applyTransforms(abi: WrapAbi): WrapAbi { - const transforms = [ - extendType(Functions), - addFirstLast, - toPrefixedGraphQLType, - methodParentPointers(), - interfaceUris(), - ]; - - for (const transform of transforms) { - abi = transformAbi(abi, transform); - } - return abi; -} diff --git a/packages/schema/bind/src/bindings/typescript/plugin/templates/index-ts.mustache b/packages/schema/bind/src/bindings/typescript/plugin/templates/index-ts.mustache deleted file mode 100644 index 4f5ca809d5..0000000000 --- a/packages/schema/bind/src/bindings/typescript/plugin/templates/index-ts.mustache +++ /dev/null @@ -1,8 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -export * from "./wrap.info"; -export * from "./module"; -export * from "./types"; - -export { CoreClient } from "@polywrap/core-js"; diff --git a/packages/schema/bind/src/bindings/typescript/plugin/templates/module-ts.mustache b/packages/schema/bind/src/bindings/typescript/plugin/templates/module-ts.mustache deleted file mode 100644 index ac87418014..0000000000 --- a/packages/schema/bind/src/bindings/typescript/plugin/templates/module-ts.mustache +++ /dev/null @@ -1,34 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -// @ts-ignore -import * as Types from "./types"; - -// @ts-ignore -import { CoreClient, MaybeAsync } from "@polywrap/core-js"; -import { PluginModule } from "@polywrap/plugin-js"; -{{#moduleType}} -{{#methods}} - -export interface Args_{{name}} { - {{#arguments}} - {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; - {{/arguments}} -} -{{/methods}} -{{/moduleType}} - -export abstract class Module extends PluginModule { - {{#moduleType}} - {{#methods}} - abstract {{name}}( - args: Args_{{name}}, - client: CoreClient, - {{^env}}env?: null{{/env}}{{#env}}env{{^required}}?{{/required}}: Types.Env{{^required}} | null{{/required}}{{/env}} - ): MaybeAsync<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>; - {{^last}} - - {{/last}} - {{/methods}} - {{/moduleType}} -} diff --git a/packages/schema/bind/src/bindings/typescript/plugin/templates/types-ts.mustache b/packages/schema/bind/src/bindings/typescript/plugin/templates/types-ts.mustache deleted file mode 100644 index 35673f6a5d..0000000000 --- a/packages/schema/bind/src/bindings/typescript/plugin/templates/types-ts.mustache +++ /dev/null @@ -1,184 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -// @ts-ignore -import * as Types from "./"; - -// @ts-ignore -import { - CoreClient,{{#interfaceTypes.length}} - Result,{{/interfaceTypes.length}} - InvokeResult, - Uri, -} from "@polywrap/core-js"; - -export type UInt = number; -export type UInt8 = number; -export type UInt16 = number; -export type UInt32 = number; -export type Int = number; -export type Int8 = number; -export type Int16 = number; -export type Int32 = number; -export type Bytes = Uint8Array; -export type BigInt = string; -export type BigNumber = string; -export type Json = string; -export type String = string; -export type Boolean = boolean; - -/// Env START /// -{{#envType}} -export interface {{#detectKeyword}}{{type}}{{/detectKeyword}} extends Record { - {{#properties}} - {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; - {{/properties}} -} -{{/envType}} -/// Env END /// - -/// Objects START /// -{{#objectTypes}} -export interface {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#properties}} - {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; - {{/properties}} -} - -{{/objectTypes}} -/// Objects END /// - -/// Enums START /// -{{#enumTypes}} -export enum {{type}}Enum { - {{#constants}} - {{.}}, - {{/constants}} -} - -export type {{type}}String = - {{#constants}} - | "{{.}}" - {{/constants}} - -export type {{#detectKeyword}}{{type}}{{/detectKeyword}} = {{type}}Enum | {{type}}String; - -{{/enumTypes}} -/// Enums END /// - -/// Imported Objects START /// - -{{#importedObjectTypes}} -/* URI: "{{uri}}" */ -export interface {{#detectKeyword}}{{type}}{{/detectKeyword}} { - {{#properties}} - {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; - {{/properties}} -} - -{{/importedObjectTypes}} -{{#importedEnumTypes}} -/* URI: "{{uri}}" */ -export enum {{type}}Enum { - {{#constants}} - {{.}}, - {{/constants}} -} - -export type {{type}}String = - {{#constants}} - | "{{.}}" - {{/constants}} - -export type {{#detectKeyword}}{{type}}{{/detectKeyword}} = {{type}}Enum | {{type}}String; - -{{/importedEnumTypes}} -/// Imported Objects END /// - -/// Imported Modules START /// - -{{#importedModuleTypes}} -{{#methods}} -/* URI: "{{parent.uri}}" */ -export interface {{parent.type}}_Args_{{name}} { - {{#arguments}} - {{name}}{{^required}}?{{/required}}: {{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}; - {{/arguments}} -} - -{{/methods}} -/* URI: "{{uri}}" */ -{{^isInterface}} -export const {{type}} = { - {{#methods}} - {{name}}: async ( - args: {{parent.type}}_Args_{{name}}, - client: CoreClient - ): Promise> => { - return client.invoke<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>({ - uri: Uri.from("{{parent.uri}}"), - method: "{{name}}", - args: (args as unknown) as Record, - }); - }{{^last}},{{/last}} - {{^last}} - - {{/last}} - {{/methods}} -} - -{{/isInterface}} -{{#isInterface}} -export class {{#detectKeyword}}{{type}}{{/detectKeyword}} { - public static interfaceUri: string = "{{uri}}"; - public uri: Uri; - - constructor(uri: string) { - this.uri = Uri.from(uri); - } - - {{#methods}} - public async {{name}}( - args: {{parent.type}}_Args_{{name}}, - client: CoreClient - ): Promise> { - return client.invoke<{{#return}}{{#toTypescript}}{{toGraphQLType}}{{/toTypescript}}{{/return}}>({ - uri: this.uri, - method: "{{name}}", - args: (args as unknown) as Record, - }); - } - {{^last}} - - {{/last}} - {{/methods}} -} - -{{/isInterface}} -{{/importedModuleTypes}} -/// Imported Modules END /// -{{#interfaceTypes.length}} -{{#interfaceTypes}} - -export class {{#detectKeyword}}{{namespace}}{{/detectKeyword}} { - static uri: Uri = Uri.from("{{uri}}"); - - {{#capabilities}} - {{#getImplementations}} - {{#enabled}} - public static async getImplementations( - client: CoreClient - ): Promise> { - const impls = await client.getImplementations(this.uri, {}); - if (!impls.ok) { - return { ok: false, error: impls.error}; - } - - return { ok: true, value: impls.value.map((impl) => (impl.uri))}; - } - {{/enabled}} - {{/getImplementations}} - {{/capabilities}} -} -{{/interfaceTypes}} -{{/interfaceTypes.length}} diff --git a/packages/schema/bind/src/bindings/typescript/plugin/templates/wrap.info-ts.mustache b/packages/schema/bind/src/bindings/typescript/plugin/templates/wrap.info-ts.mustache deleted file mode 100644 index 32296868a0..0000000000 --- a/packages/schema/bind/src/bindings/typescript/plugin/templates/wrap.info-ts.mustache +++ /dev/null @@ -1,12 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. -import { WrapManifest } from "@polywrap/wrap-manifest-types-js" - -{{#manifest}} -export const manifest: WrapManifest = { - name: "{{name}}", - type: "{{type}}", - version: "{{version}}", - abi: {{abi}} -} -{{/manifest}} diff --git a/packages/schema/bind/src/bindings/typescript/types.ts b/packages/schema/bind/src/bindings/typescript/types.ts deleted file mode 100644 index 20f6bfbcee..0000000000 --- a/packages/schema/bind/src/bindings/typescript/types.ts +++ /dev/null @@ -1,74 +0,0 @@ -const baseTypes = { - boolean: "boolean", - number: "number", - string: "string", -}; - -export type BaseTypes = typeof baseTypes; - -export type BaseType = keyof BaseTypes; - -export function isBaseType(type: string): type is BaseType { - return type in baseTypes; -} - -// based on: -// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#keywords -const keywords = { - break: "break", - case: "case", - catch: "catch", - class: "class", - const: "const", - continue: "continue", - debugger: "debugger", - default: "default", - delete: "delete", - do: "do", - else: "else", - export: "export", - extends: "extends", - false: "false", - finally: "finally", - for: "for", - function: "function", - if: "if", - import: "import", - in: "in", - instanceof: "instanceof", - new: "new", - null: "null", - return: "return", - super: "super", - switch: "switch", - this: "this", - throw: "throw", - true: "true", - try: "try", - typeof: "typeof", - var: "var", - void: "void", - while: "while", - with: "with", - yield: "yield", - let: "let", - await: "await", - enum: "enum", - implements: "implements", - interface: "interface", - package: "package", - private: "private", - protected: "protected", - public: "public", - static: "static", - arguments: "arguments", - eval: "eval", -}; - -export type Keywords = typeof keywords; - -export type Keyword = keyof Keywords; - -export function isKeyword(keyword: string): keyword is Keyword { - return keyword in keywords; -} diff --git a/packages/schema/bind/src/bindings/utils.ts b/packages/schema/bind/src/bindings/utils.ts index fdcd426fe4..dc7256606a 100644 --- a/packages/schema/bind/src/bindings/utils.ts +++ b/packages/schema/bind/src/bindings/utils.ts @@ -1,7 +1,21 @@ import { OutputEntry, readDirectorySync } from "@polywrap/os-js"; +import { GenericDefinition } from "@polywrap/schema-parse"; import Mustache from "mustache"; import path from "path"; +function transformName(str: string, view: unknown): string { + str = str.replace("-", "."); + if (!str.endsWith(".go")) { + return str; + } + const def = view as GenericDefinition; + str = str + .replace("%type%", def.type) + .replace(/([A-Z])/g, "_$1") + .toLowerCase(); + return str.startsWith("_") ? str.slice(1) : str; +} + export function renderTemplates( templateDirAbs: string, view: unknown, @@ -27,7 +41,7 @@ export function renderTemplates( if (data) { output.push({ type: "File", - name: name.replace("-", "."), + name: transformName(name, view), data, }); } diff --git a/packages/schema/bind/src/bindings/wrap-bindgen.ts b/packages/schema/bind/src/bindings/wrap-bindgen.ts new file mode 100644 index 0000000000..a1498cc8a1 --- /dev/null +++ b/packages/schema/bind/src/bindings/wrap-bindgen.ts @@ -0,0 +1,70 @@ +import { BindOutput, BindOptions } from "../types"; +import { Args_generateBindings, GenerateBindingFn, Output } from "./types"; + +import { + PolywrapClient, + ExtendableUriResolver, + PolywrapClientConfigBuilder, +} from "@polywrap/client-js"; +import { OutputEntry } from "@polywrap/os-js"; + +export function getGenerateBindingFn(uri: string): GenerateBindingFn { + return (options: BindOptions) => invokeBindgenWrap(uri, options); +} + +async function invokeBindgenWrap( + uri: string, + options: BindOptions +): Promise { + // TODO: Can simplify if github resolver is added to a default config bundle + const config = new PolywrapClientConfigBuilder() + .addInterfaceImplementation( + ExtendableUriResolver.defaultExtInterfaceUris[0].uri, + "wrap://ipfs/QmYPp2bQpRxR7WCoiAgWsWoiQzqxyFdqWxp1i65VW8wNv2" + ) + .addDefaults() + .build(); + + const client = new PolywrapClient(config); + const args: Args_generateBindings = { + wrapInfo: { + version: options.wrapInfo.version, + name: options.wrapInfo.name, + type: options.wrapInfo.type, + abi: JSON.stringify(options.wrapInfo.abi), + }, + context: options.config ? JSON.stringify(options.config) : undefined, + }; + + const result = await client.invoke({ + uri, + method: "generateBindings", + args: (args as unknown) as Record, + }); + if (!result.ok) throw result.error; + const output = result.value; + + return { + output: { entries: toOutputEntries(output) }, + outputDirAbs: options.outputDirAbs, + }; +} + +function toOutputEntries(output: Output): OutputEntry[] { + const entries: OutputEntry[] = []; + output.files.forEach((file) => { + entries.push({ + type: "File", + name: file.name, + data: file.data, + }); + }); + output.dirs.forEach((dir) => { + entries.push({ + type: "Directory", + name: dir.name, + data: toOutputEntries(dir), + }); + }); + return entries; +} diff --git a/packages/schema/bind/src/index.ts b/packages/schema/bind/src/index.ts index ecdf3c5f15..8826be6c4c 100644 --- a/packages/schema/bind/src/index.ts +++ b/packages/schema/bind/src/index.ts @@ -1,5 +1,6 @@ import { BindOptions, BindOutput } from "./types"; import { getGenerateBindingFn } from "./bindings"; +import * as WrapBindgen from "./bindings/wrap-bindgen"; import Mustache from "mustache"; @@ -9,6 +10,12 @@ Mustache.escape = (value) => value; export * from "./types"; export * from "./bindings"; -export function bindSchema(options: BindOptions): BindOutput { +export async function bindSchema( + options: BindOptions, + uri?: string +): Promise { + if (uri) { + return WrapBindgen.getGenerateBindingFn(uri)(options); + } return getGenerateBindingFn(options.bindLanguage)(options); } diff --git a/packages/schema/bind/src/types.ts b/packages/schema/bind/src/types.ts index 8ba900f272..c7d043e9f6 100644 --- a/packages/schema/bind/src/types.ts +++ b/packages/schema/bind/src/types.ts @@ -1,13 +1,21 @@ import { OutputDirectory } from "@polywrap/os-js"; -import { WrapAbi } from "@polywrap/schema-parse"; +import { WrapManifest } from "@polywrap/wrap-manifest-types-js"; -export type BindLanguage = - | "wasm-as" - | "wasm-rs" - | "plugin-ts" - | "plugin-rs" - | "plugin-py" - | "app-ts"; +export const bindLanguage = { + "wrap-as": "wrap-as", + "wrap-rs": "wrap-rs", + "wrap-go": "wrap-go", + "plugin-ts": "plugin-ts", + "plugin-rs": "plugin-rs", + "plugin-py": "plugin-py", + "plugin-kt": "plugin-kt", + "plugin-swift": "plugin-swift", + "app-ts": "app-ts", +}; + +export type BindLanguages = typeof bindLanguage; + +export type BindLanguage = keyof BindLanguages; export interface BindOutput { output: OutputDirectory; @@ -15,9 +23,15 @@ export interface BindOutput { } export interface BindOptions { - projectName: string; bindLanguage: BindLanguage; - abi: WrapAbi; + wrapInfo: WrapManifest; config?: Record; outputDirAbs: string; } + +// TODO: Can I use types instead of hardcoded values here? +export function bindLanguageToWrapInfoType( + bindLanguage: BindLanguage +): "wasm" | "plugin" | "interface" { + return bindLanguage.startsWith("plugin") ? "plugin" : "wasm"; +} diff --git a/packages/schema/compose/package.json b/packages/schema/compose/package.json index a38c79d99c..7f1b396426 100644 --- a/packages/schema/compose/package.json +++ b/packages/schema/compose/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/schema-compose", "description": "Polywrap Schema Composition", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", @@ -18,14 +18,14 @@ "test:watch": "yarn test -- --watch" }, "dependencies": { - "@polywrap/schema-parse": "0.10.6", - "@polywrap/wrap-manifest-types-js": "0.10.0", + "@polywrap/schema-parse": "0.11.0-pre.4", + "@polywrap/wrap-manifest-types-js": "0.12.0", "graphql": "15.5.0", "mustache": "4.0.1" }, "devDependencies": { - "@polywrap/os-js": "0.10.6", - "@polywrap/test-cases": "0.10.6", + "@polywrap/os-js": "0.11.0-pre.4", + "@polywrap/test-cases": "0.11.0-pre.4", "@types/jest": "26.0.8", "@types/mustache": "4.0.1", "@types/prettier": "2.6.0", diff --git a/packages/schema/parse/package.json b/packages/schema/parse/package.json index 8903f21a5d..2163c7a216 100644 --- a/packages/schema/parse/package.json +++ b/packages/schema/parse/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/schema-parse", "description": "Polywrap Schema Parsing", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", @@ -19,11 +19,11 @@ }, "dependencies": { "@dorgjelli/graphql-schema-cycles": "1.1.4", - "@polywrap/wrap-manifest-types-js": "0.10.0", + "@polywrap/wrap-manifest-types-js": "0.12.0", "graphql": "15.5.0" }, "devDependencies": { - "@polywrap/test-cases": "0.10.6", + "@polywrap/test-cases": "0.11.0-pre.4", "@types/deep-equal": "1.0.1", "@types/jest": "26.0.8", "@types/prettier": "2.6.0", diff --git a/packages/templates/app/typescript/package.json b/packages/templates/app/typescript/package.json index e746fb599f..c01d697629 100644 --- a/packages/templates/app/typescript/package.json +++ b/packages/templates/app/typescript/package.json @@ -2,17 +2,17 @@ "name": "templates-app-typescript", "description": "Polywrap App TypeScript Template", "private": true, - "version": "0.10.6", + "version": "0.11.0-pre.4", "scripts": { "build": "npx polywrap codegen", "test": "ts-node ./src/index.ts" }, "dependencies": { - "@polywrap/client-js": "~0.10.0" + "@polywrap/client-js": "~0.12.0" }, "devDependencies": { - "@types/node": "^18.14.6", - "polywrap": "0.10.6", + "@types/node": "18.15.0", + "polywrap": "0.11.0-pre.4", "ts-node": "10.9.1", "typescript": "4.9.5" } diff --git a/packages/templates/package.json b/packages/templates/package.json index 1495a4a6b9..6efbfad803 100644 --- a/packages/templates/package.json +++ b/packages/templates/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/templates", "description": "Polywrap Templates", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", diff --git a/packages/templates/plugin/python/package.json b/packages/templates/plugin/python/package.json index 932148136c..5fed5a933f 100644 --- a/packages/templates/plugin/python/package.json +++ b/packages/templates/plugin/python/package.json @@ -1,7 +1,8 @@ { "name": "templates-plugin-python", "private": true, + "version": "0.11.0-pre.4", "dependencies": { - "polywrap": "~0.10.2" + "polywrap": "0.11.0-pre.4" } } diff --git a/packages/templates/plugin/rust/Cargo.toml b/packages/templates/plugin/rust/Cargo.toml index 1715867d8b..79b0b23af8 100644 --- a/packages/templates/plugin/rust/Cargo.toml +++ b/packages/templates/plugin/rust/Cargo.toml @@ -11,10 +11,11 @@ include = [ ] [dependencies] -polywrap_core = { version = "0.1.6-beta.1" } -polywrap_plugin = { version = "0.1.6-beta.1" } -polywrap_msgpack = { version = "0.1.6-beta.1" } -wrap_manifest_schemas = { version = "0.1.6-beta.1" } +polywrap_core = { version = "~0.1.6-beta.1" } +polywrap_plugin = { version = "~0.1.6-beta.1" } +polywrap_msgpack = { version = "~0.1.6-beta.1" } +polywrap_msgpack_serde = { version = "~0.0.2-beta.5" } +wrap_manifest_schemas = { version = "~0.1.6-beta.1" } serde = {version = "1.0.145", features = ["derive"]} [dev-dependencies] diff --git a/packages/templates/plugin/rust/package.json b/packages/templates/plugin/rust/package.json index 9e7a123fb6..8c1c23108b 100644 --- a/packages/templates/plugin/rust/package.json +++ b/packages/templates/plugin/rust/package.json @@ -1,7 +1,8 @@ { "name": "templates-plugin-rust", "private": true, + "version": "0.11.0-pre.4", "dependencies": { - "polywrap": "~0.10.2" + "polywrap": "0.11.0-pre.4" } } diff --git a/packages/templates/plugin/rust/src/lib.rs b/packages/templates/plugin/rust/src/lib.rs index 73e8c4539c..6fc1dc2105 100644 --- a/packages/templates/plugin/rust/src/lib.rs +++ b/packages/templates/plugin/rust/src/lib.rs @@ -1,5 +1,5 @@ use crate::wrap::wrap_info::get_manifest; -use polywrap_core::invoke::Invoker; +use polywrap_core::invoker::Invoker; use polywrap_plugin::{error::PluginError, implementor::plugin_impl, JSON}; use wrap::{ module::{ArgsSampleMethod, Module}, diff --git a/packages/templates/plugin/rust/tests/e2e.rs b/packages/templates/plugin/rust/tests/e2e.rs index e0dbf56088..9c16e8b54b 100644 --- a/packages/templates/plugin/rust/tests/e2e.rs +++ b/packages/templates/plugin/rust/tests/e2e.rs @@ -1,16 +1,13 @@ use template_plugin_rs::SamplePlugin; use polywrap_core::{ client::ClientConfig, - resolvers::{ - static_resolver::{StaticResolver, StaticResolverLike}, - uri_resolution_context::UriPackage, - }, uri::Uri, }; use polywrap_msgpack::{msgpack}; use polywrap_plugin::{package::PluginPackage}; use polywrap_client::{ client::PolywrapClient, + builder::{PolywrapClientConfig, PolywrapClientConfigBuilder}, }; use std::{ sync::{Arc, Mutex}, @@ -18,19 +15,15 @@ use std::{ fn get_client() -> PolywrapClient { let sample_plugin = SamplePlugin {}; - let plugin_pkg: PluginPackage = sample_plugin.into(); - let package = Arc::new(Mutex::new(plugin_pkg)); + let plugin_pkg = PluginPackage::::from(sample_plugin); - let resolver = StaticResolver::from(vec![StaticResolverLike::Package(UriPackage { - uri: Uri::try_from("plugin/sample").unwrap(), - package, - })]); + let mut config = PolywrapClientConfig::new(); + config.add_package( + Uri::try_from("plugin/sample").unwrap(), + Arc::new(plugin_pkg) + ); - PolywrapClient::new(ClientConfig { - resolver: Arc::new(resolver), - interfaces: None, - envs: None, - }) + PolywrapClient::new(config.into()) } #[test] diff --git a/packages/templates/plugin/typescript/package.json b/packages/templates/plugin/typescript/package.json index ee69d77fcf..677140fe6c 100644 --- a/packages/templates/plugin/typescript/package.json +++ b/packages/templates/plugin/typescript/package.json @@ -2,7 +2,7 @@ "name": "templates-plugin-typescript", "description": "Polywrap Plugin Typescript Template", "private": true, - "version": "0.10.6", + "version": "0.11.0-pre.4", "main": "build/index.js", "scripts": { "build": "rimraf ./build && yarn codegen && tsc --project tsconfig.json", @@ -11,19 +11,19 @@ "test:watch": "yarn test -- --watch" }, "dependencies": { - "@polywrap/core-js": "~0.10.0", - "@polywrap/plugin-js": "~0.10.0" + "@polywrap/core-js": "~0.12.0", + "@polywrap/plugin-js": "~0.12.0" }, "peerDependencies": { - "@polywrap/core-js": "0.10.x", - "@polywrap/plugin-js": "0.10.x" + "@polywrap/core-js": "0.12.x", + "@polywrap/plugin-js": "0.12.x" }, "devDependencies": { - "@polywrap/client-js": "~0.10.0", + "@polywrap/client-js": "~0.12.0", "@types/jest": "26.0.8", "@types/prettier": "2.6.0", "jest": "26.6.3", - "polywrap": "0.10.6", + "polywrap": "0.11.0-pre.4", "rimraf": "3.0.2", "ts-jest": "26.5.4", "ts-node": "10.9.1", diff --git a/packages/templates/plugin/typescript/src/__tests__/e2e.spec.ts b/packages/templates/plugin/typescript/src/__tests__/e2e.spec.ts index cd3647bec9..7d143801d2 100644 --- a/packages/templates/plugin/typescript/src/__tests__/e2e.spec.ts +++ b/packages/templates/plugin/typescript/src/__tests__/e2e.spec.ts @@ -1,4 +1,4 @@ -import { ClientConfigBuilder, IWrapPackage, PolywrapClient } from "@polywrap/client-js"; +import { PolywrapClientConfigBuilder, IWrapPackage, PolywrapClient } from "@polywrap/client-js"; import { samplePlugin } from "../"; describe("e2e", () => { @@ -7,9 +7,9 @@ describe("e2e", () => { beforeAll(() => { // Add the samplePlugin to the PolywrapClient - const config = new ClientConfigBuilder() + const config = new PolywrapClientConfigBuilder() .addDefaults() - .addPackage( + .setPackage( uri, samplePlugin({ defaultValue: "foo bar", diff --git a/packages/templates/polywrap.wasm-golang-linked.build.yaml b/packages/templates/polywrap.wasm-golang-linked.build.yaml new file mode 100644 index 0000000000..7544889104 --- /dev/null +++ b/packages/templates/polywrap.wasm-golang-linked.build.yaml @@ -0,0 +1,4 @@ +format: 0.3.0 +strategies: + image: + name: template-wasm-go diff --git a/packages/templates/polywrap.wasm-golang-linked.yaml b/packages/templates/polywrap.wasm-golang-linked.yaml new file mode 100644 index 0000000000..014ae3dfc5 --- /dev/null +++ b/packages/templates/polywrap.wasm-golang-linked.yaml @@ -0,0 +1,9 @@ +format: 0.3.0 +project: + name: template-wasm-go + type: wasm/golang +source: + module: ./go.mod + schema: ./polywrap.graphql +extensions: + build: ./polywrap.wasm-golang-linked.build.yaml \ No newline at end of file diff --git a/packages/templates/tests.spec.ts b/packages/templates/tests.spec.ts index 75a9df4e86..395fb12314 100644 --- a/packages/templates/tests.spec.ts +++ b/packages/templates/tests.spec.ts @@ -29,11 +29,15 @@ describe("Templates", () => { build: "yarn build -m ./polywrap.wasm-rust-linked.yaml", test: "yarn test", }, + "wasm/golang": { + codegen: "yarn codegen", + build: "yarn build", + test: "yarn test", + }, "plugin/rust": { codegen: "npx polywrap codegen", - // Uncomment after release of 0.10.3 - /*build: "cargo build", - test: "cargo test",*/ + build: "cargo build", + test: "cargo test", }, interface: { build: "npx polywrap build" }, }; @@ -87,7 +91,7 @@ describe("Templates", () => { beforeAll(() => { // Copy test configs - if (projectType === "wasm" && language !== "interface") { + if (projectType === "wasm" && language !== "interface" && language !== "golang") { execSync( `cp ${rootDir}/polywrap.${projectType}-${language}-linked* ${rootDir}/${projectType}/${language}/` ); diff --git a/packages/templates/wasm/assemblyscript/package.json b/packages/templates/wasm/assemblyscript/package.json index 3adf03ad91..5f9310b855 100644 --- a/packages/templates/wasm/assemblyscript/package.json +++ b/packages/templates/wasm/assemblyscript/package.json @@ -2,7 +2,7 @@ "name": "template-wasm-as", "description": "Polywrap AssemblyScript Wrapper Template", "private": true, - "version": "0.10.6", + "version": "0.11.0-pre.4", "scripts": { "codegen": "npx polywrap codegen", "build": "npx polywrap build", @@ -17,12 +17,12 @@ "devDependencies": { "@types/jest": "26.0.8", "jest": "26.6.3", - "polywrap": "0.10.6", + "polywrap": "0.11.0-pre.4", "ts-jest": "26.5.4", "typescript": "4.9.5" }, "dependencies": { - "@polywrap/wasm-as": "0.10.6", + "@polywrap/wasm-as": "0.11.0-pre.4", "assemblyscript": "0.19.23" } } diff --git a/packages/templates/wasm/golang/.gitignore b/packages/templates/wasm/golang/.gitignore new file mode 100644 index 0000000000..ec0cd1fa68 --- /dev/null +++ b/packages/templates/wasm/golang/.gitignore @@ -0,0 +1,6 @@ +build +node_modules +wrap +.polywrap +target +workflows/output.json diff --git a/packages/templates/wasm/golang/.nvmrc b/packages/templates/wasm/golang/.nvmrc new file mode 100644 index 0000000000..501570628a --- /dev/null +++ b/packages/templates/wasm/golang/.nvmrc @@ -0,0 +1 @@ +v17.9.1 \ No newline at end of file diff --git a/packages/templates/wasm/golang/README.md b/packages/templates/wasm/golang/README.md new file mode 100644 index 0000000000..502931c4e1 --- /dev/null +++ b/packages/templates/wasm/golang/README.md @@ -0,0 +1,15 @@ +# Polywrap Wasm Wrapper Template +A simple starter template for a Golang Wasm wrapper. For more information on how this project works, and a step by step on how to extend its behavior, see the documentation [here](https://docs.polywrap.io/). + +# How To Run + +## Install Dependencies +`nvm install && nvm use` +`yarn` + +## Codegen & Build +`yarn codegen` +`yarn build` + +## Test +`yarn test` diff --git a/packages/templates/wasm/golang/build-staging/module.wasm b/packages/templates/wasm/golang/build-staging/module.wasm new file mode 100755 index 0000000000..749b174e7e Binary files /dev/null and b/packages/templates/wasm/golang/build-staging/module.wasm differ diff --git a/packages/templates/wasm/golang/go.mod b/packages/templates/wasm/golang/go.mod new file mode 100644 index 0000000000..78573cf707 --- /dev/null +++ b/packages/templates/wasm/golang/go.mod @@ -0,0 +1,7 @@ +module example.com/template-wasm-go + +go 1.18 + +require github.com/polywrap/go-wrap wrap-0.1 + +require github.com/valyala/fastjson v1.6.3 // indirect diff --git a/packages/templates/wasm/golang/go.sum b/packages/templates/wasm/golang/go.sum new file mode 100644 index 0000000000..8df2badd73 --- /dev/null +++ b/packages/templates/wasm/golang/go.sum @@ -0,0 +1,4 @@ +github.com/polywrap/go-wrap v0.0.0-20230712212127-6895977d63c2 h1:+O3G/996rX4SMlJNFA9AIjPSyrInzOEVb7PFOT96G9A= +github.com/polywrap/go-wrap v0.0.0-20230712212127-6895977d63c2/go.mod h1:rxqhIFKUzn/M46+zjnA1RHlCzLGQn2BiLWalezhLj/k= +github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc= +github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= diff --git a/packages/templates/wasm/golang/jest.config.js b/packages/templates/wasm/golang/jest.config.js new file mode 100644 index 0000000000..4a4c022f7b --- /dev/null +++ b/packages/templates/wasm/golang/jest.config.js @@ -0,0 +1,15 @@ +module.exports = { + collectCoverage: false, + preset: "ts-jest", + testEnvironment: "node", + testMatch: ["**/__tests__/**/?(*.)+(spec|test).[jt]s?(x)"], + globals: { + "ts-jest": { + tsconfig: "tsconfig.json", + diagnostics: false, + }, + }, + testPathIgnorePatterns: [ + "/.polywrap/" + ], +}; diff --git a/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts b/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts new file mode 100644 index 0000000000..55913c174a --- /dev/null +++ b/packages/templates/wasm/golang/module/__tests__/e2e/integration.spec.ts @@ -0,0 +1,31 @@ +import { PolywrapClient } from "@polywrap/client-js"; +import * as App from "../types/wrap"; +import path from "path"; + +jest.setTimeout(60000); + +describe("Template Wrapper End to End Tests", () => { + + const client: PolywrapClient = new PolywrapClient(); + let wrapperUri: string; + + beforeAll(() => { + const dirname: string = path.resolve(__dirname); + const wrapperPath: string = path.join(dirname, "..", "..", ".."); + wrapperUri = `fs/${wrapperPath}/build`; + }) + + it("calls sampleMethod", async () => { + const expected: string = "polywrap"; + + const result = await client.invoke({ + uri: wrapperUri, + method: "sampleMethod", + args: { arg: expected } + }); + + expect(result.ok).toBeTruthy(); + if (!result.ok) return; + expect(result.value.result).toEqual(expected); + }); +}); diff --git a/packages/templates/wasm/golang/module/__tests__/types/polywrap.app.yaml b/packages/templates/wasm/golang/module/__tests__/types/polywrap.app.yaml new file mode 100644 index 0000000000..4259744c31 --- /dev/null +++ b/packages/templates/wasm/golang/module/__tests__/types/polywrap.app.yaml @@ -0,0 +1,9 @@ +format: 0.4.0 +project: + name: sample-typescript-type-generation + type: app/typescript +source: + schema: ./schema.graphql + import_abis: + - uri: "wrap://ens/sample.eth" + abi: "../../../build/wrap.info" diff --git a/packages/templates/wasm/golang/module/__tests__/types/schema.graphql b/packages/templates/wasm/golang/module/__tests__/types/schema.graphql new file mode 100644 index 0000000000..6d75bfc9bc --- /dev/null +++ b/packages/templates/wasm/golang/module/__tests__/types/schema.graphql @@ -0,0 +1 @@ +#import * into Template from "wrap://ens/sample.eth" diff --git a/packages/templates/wasm/golang/module/module.go b/packages/templates/wasm/golang/module/module.go new file mode 100644 index 0000000000..a3d140b943 --- /dev/null +++ b/packages/templates/wasm/golang/module/module.go @@ -0,0 +1,11 @@ +package module + +import ( + "example.com/template-wasm-go/module/wrap/types" +) + +func SampleMethod(args *types.ArgsSampleMethod) types.SampleResult { + return types.SampleResult{ + Result: args.Arg, + } +} diff --git a/packages/templates/wasm/golang/package.json b/packages/templates/wasm/golang/package.json new file mode 100644 index 0000000000..9d6d0cc44f --- /dev/null +++ b/packages/templates/wasm/golang/package.json @@ -0,0 +1,22 @@ +{ + "name": "template-wasm-go", + "description": "Polywrap Golang Wrapper Template", + "private": true, + "version": "0.11.0-pre.4", + "scripts": { + "codegen": "npx polywrap codegen", + "build": "npx polywrap build", + "deploy": "npx polywrap deploy", + "test": "yarn test:e2e && yarn test:workflow", + "test:e2e": "yarn test:e2e:codegen && jest --passWithNoTests --runInBand --verbose", + "test:e2e:codegen": "npx polywrap codegen -m ./module/__tests__/types/polywrap.app.yaml -g ./module/__tests__/types/wrap", + "test:workflow": "npx polywrap test" + }, + "devDependencies": { + "@types/jest": "26.0.8", + "jest": "26.6.3", + "polywrap": "0.11.0-pre.4", + "ts-jest": "26.5.4", + "typescript": "4.9.5" + } +} diff --git a/packages/templates/wasm/golang/polywrap.graphql b/packages/templates/wasm/golang/polywrap.graphql new file mode 100644 index 0000000000..5b34469c7e --- /dev/null +++ b/packages/templates/wasm/golang/polywrap.graphql @@ -0,0 +1,7 @@ +type Module { + sampleMethod(arg: String!): SampleResult! +} + +type SampleResult { + result: String! +} diff --git a/packages/templates/wasm/golang/polywrap.test.cue b/packages/templates/wasm/golang/polywrap.test.cue new file mode 100644 index 0000000000..a71f50ace0 --- /dev/null +++ b/packages/templates/wasm/golang/polywrap.test.cue @@ -0,0 +1,11 @@ +package e2e + +sampleMethod: { + $0: { + data: { + value: "polywrap" + }, + error?: _|_, + } +} + diff --git a/packages/templates/wasm/golang/polywrap.test.yaml b/packages/templates/wasm/golang/polywrap.test.yaml new file mode 100644 index 0000000000..2603e2d03f --- /dev/null +++ b/packages/templates/wasm/golang/polywrap.test.yaml @@ -0,0 +1,10 @@ +name: template-wasm-go +format: 0.1.0 +validation: "./polywrap.test.cue" +jobs: + sampleMethod: + steps: + - uri: fs/build + method: sampleMethod + args: + arg: "polywrap" diff --git a/packages/templates/wasm/golang/polywrap.yaml b/packages/templates/wasm/golang/polywrap.yaml new file mode 100644 index 0000000000..0b1f3f35d6 --- /dev/null +++ b/packages/templates/wasm/golang/polywrap.yaml @@ -0,0 +1,7 @@ +format: 0.3.0 +project: + name: template-wasm-go + type: wasm/golang +source: + schema: ./polywrap.graphql + module: ./go.mod diff --git a/packages/templates/wasm/golang/tsconfig.json b/packages/templates/wasm/golang/tsconfig.json new file mode 100644 index 0000000000..75bfa86f2e --- /dev/null +++ b/packages/templates/wasm/golang/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "lib": [ + "es2015", + "es5", + "dom" + ], + "esModuleInterop": true, + "outDir": "build", + "moduleResolution": "node", + "declaration": true, + "preserveSymlinks": true, + "preserveWatchOutput": true, + "pretty": false, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "module": "commonjs", + "sourceMap": true, + "target": "es5", + "resolveJsonModule": true, + "strictNullChecks": true, + "experimentalDecorators": true + }, + "typeAcquisition": { "include": ["jest"] } +} \ No newline at end of file diff --git a/packages/templates/wasm/interface/package.json b/packages/templates/wasm/interface/package.json index 2889225063..5d3d5d5e6d 100644 --- a/packages/templates/wasm/interface/package.json +++ b/packages/templates/wasm/interface/package.json @@ -2,6 +2,6 @@ "name": "templates-interface", "private": true, "dependencies": { - "polywrap": "~0.10.2" + "polywrap": "0.11.0-pre.2" } } diff --git a/packages/templates/wasm/rust/Cargo.toml b/packages/templates/wasm/rust/Cargo.toml index 0e49e40b70..b5e4af31ea 100644 --- a/packages/templates/wasm/rust/Cargo.toml +++ b/packages/templates/wasm/rust/Cargo.toml @@ -8,7 +8,8 @@ license = "MIT" edition = "2021" [dependencies] -polywrap-wasm-rs = { version = "~0.10.2" } +polywrap-wasm-rs = { version = "~0.11.0-pre.4" } +polywrap_msgpack_serde = "~0.0.2-beta.5" serde = { version = "1.0", features = ["derive"] } [lib] diff --git a/packages/templates/wasm/rust/package.json b/packages/templates/wasm/rust/package.json index 0541b4d249..cf073b47d0 100644 --- a/packages/templates/wasm/rust/package.json +++ b/packages/templates/wasm/rust/package.json @@ -2,7 +2,7 @@ "name": "template-wasm-rs", "description": "Polywrap Rust Wrapper Template", "private": true, - "version": "0.10.6", + "version": "0.11.0-pre.4", "scripts": { "codegen": "npx polywrap codegen", "build": "npx polywrap build", @@ -15,7 +15,7 @@ "devDependencies": { "@types/jest": "26.0.8", "jest": "26.6.3", - "polywrap": "0.10.6", + "polywrap": "0.11.0-pre.4", "ts-jest": "26.5.4", "typescript": "4.9.5" } diff --git a/packages/test-cases/cases/bind/sanity/output/app-ts/index.ts b/packages/test-cases/cases/bind/sanity/output/app-ts/index.ts deleted file mode 100644 index eea524d655..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/app-ts/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types"; diff --git a/packages/test-cases/cases/bind/sanity/output/app-ts/types.ts b/packages/test-cases/cases/bind/sanity/output/app-ts/types.ts deleted file mode 100644 index 63cbd9c017..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/app-ts/types.ts +++ /dev/null @@ -1,224 +0,0 @@ -// @ts-ignore -import * as Types from "./"; - -// @ts-ignore -import { - CoreClient, - InvokeResult, - Uri, -} from "@polywrap/core-js"; - -export type UInt = number; -export type UInt8 = number; -export type UInt16 = number; -export type UInt32 = number; -export type Int = number; -export type Int8 = number; -export type Int16 = number; -export type Int32 = number; -export type Bytes = Uint8Array; -export type BigInt = string; -export type BigNumber = string; -export type Json = string; -export type String = string; -export type Boolean = boolean; - -export interface CustomType { - str: Types.String; - optStr?: Types.String | null; - u: Types.UInt; - optU?: Types.UInt | null; - u8: Types.UInt8; - u16: Types.UInt16; - u32: Types.UInt32; - i: Types.Int; - i8: Types.Int8; - i16: Types.Int16; - i32: Types.Int32; - bigint: Types.BigInt; - optBigint?: Types.BigInt | null; - bignumber: Types.BigNumber; - optBignumber?: Types.BigNumber | null; - json: Types.Json; - optJson?: Types.Json | null; - bytes: Types.Bytes; - optBytes?: Types.Bytes | null; - boolean: Types.Boolean; - optBoolean?: Types.Boolean | null; - u_array: Array; - uOpt_array?: Array | null; - _opt_uOptArray?: Array | null; - optStrOptArray?: Array | null; - uArrayArray: Array>; - uOptArrayOptArray: Array | null>; - uArrayOptArrayArray: Array> | null>; - crazyArray?: Array | null>> | null> | null; - object: Types.AnotherType; - optObject?: Types.AnotherType | null; - objectArray: Array; - optObjectArray?: Array | null; - en: Types.CustomEnum; - optEnum?: Types.CustomEnum | null; - enumArray: Array; - optEnumArray?: Array | null; - map: Map; - mapOfArr: Map>; - mapOfObj: Map; - mapOfArrOfObj: Map>; - mapCustomValue: Map; -} - -export interface AnotherType { - prop?: Types.String | null; - circular?: Types.CustomType | null; - const?: Types.String | null; -} - -export interface CustomMapValue { - foo: Types.String; -} - -export interface _else { - else: Types.String; -} - -export enum CustomEnumEnum { - STRING, - BYTES, -} - -export type CustomEnumString = - | "STRING" - | "BYTES" - -export type CustomEnum = CustomEnumEnum | CustomEnumString; - -export enum whileEnum { - for, - in, -} - -export type whileString = - | "for" - | "in" - -export type _while = whileEnum | whileString; - -/// Imported Objects START /// - -/* URI: "testimport.uri.eth" */ -export interface TestImport_Object { - object: Types.TestImport_AnotherObject; - optObject?: Types.TestImport_AnotherObject | null; - objectArray: Array; - optObjectArray?: Array | null; - en: Types.TestImport_Enum; - optEnum?: Types.TestImport_Enum | null; - enumArray: Array; - optEnumArray?: Array | null; -} - -/* URI: "testimport.uri.eth" */ -export interface TestImport_AnotherObject { - prop: Types.String; -} - -/// Imported Objects END /// - -/// Imported Enums START /// - -/* URI: "testimport.uri.eth" */ -export enum TestImport_EnumEnum { - STRING, - BYTES, -} - -export type TestImport_EnumString = - | "STRING" - | "BYTES" - -export type TestImport_Enum = TestImport_EnumEnum | TestImport_EnumString; - -/* URI: "testimport.uri.eth" */ -export enum TestImport_Enum_ReturnEnum { - STRING, - BYTES, -} - -export type TestImport_Enum_ReturnString = - | "STRING" - | "BYTES" - -export type TestImport_Enum_Return = TestImport_Enum_ReturnEnum | TestImport_Enum_ReturnString; - -/// Imported Enums END /// - -/// Imported Modules START /// - -/* URI: "testimport.uri.eth" */ -export interface TestImport_Module_Args_importedMethod { - str: Types.String; - optStr?: Types.String | null; - u: Types.UInt; - optU?: Types.UInt | null; - uArrayArray: Array | null>; - object: Types.TestImport_Object; - optObject?: Types.TestImport_Object | null; - objectArray: Array; - optObjectArray?: Array | null; - en: Types.TestImport_Enum; - optEnum?: Types.TestImport_Enum | null; - enumArray: Array; - optEnumArray?: Array | null; -} - -/* URI: "testimport.uri.eth" */ -export interface TestImport_Module_Args_anotherMethod { - arg: Array; -} - -/* URI: "testimport.uri.eth" */ -export interface TestImport_Module_Args_returnsArrayOfEnums { - arg: Types.String; -} - -/* URI: "testimport.uri.eth" */ -export const TestImport_Module = { - importedMethod: async ( - args: TestImport_Module_Args_importedMethod, - client: CoreClient, - uri: string = "testimport.uri.eth" - ): Promise> => { - return client.invoke({ - uri: Uri.from(uri), - method: "importedMethod", - args: (args as unknown) as Record, - }); - }, - - anotherMethod: async ( - args: TestImport_Module_Args_anotherMethod, - client: CoreClient, - uri: string = "testimport.uri.eth" - ): Promise> => { - return client.invoke({ - uri: Uri.from(uri), - method: "anotherMethod", - args: (args as unknown) as Record, - }); - }, - - returnsArrayOfEnums: async ( - args: TestImport_Module_Args_returnsArrayOfEnums, - client: CoreClient, - uri: string = "testimport.uri.eth" - ): Promise>> => { - return client.invoke>({ - uri: Uri.from(uri), - method: "returnsArrayOfEnums", - args: (args as unknown) as Record, - }); - } -}; - -/// Imported Modules END /// diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-py/__init__.py b/packages/test-cases/cases/bind/sanity/output/plugin-py/__init__.py deleted file mode 100644 index d2ad6b3725..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-py/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# NOTE: This is an auto-generated file. All modifications will be overwritten. -# type: ignore - -from .types import * -from .module import * -from .wrap_info import * diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-py/module.py b/packages/test-cases/cases/bind/sanity/output/plugin-py/module.py deleted file mode 100644 index b9cb94ba2a..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-py/module.py +++ /dev/null @@ -1,95 +0,0 @@ -# NOTE: This is an auto-generated file. All modifications will be overwritten. -# type: ignore -from __future__ import annotations - -from abc import abstractmethod -from typing import TypeVar, Generic, TypedDict, Optional - -from .types import * - -from polywrap_core import InvokerClient -from polywrap_plugin import PluginModule -from polywrap_msgpack import GenericMap - -TConfig = TypeVar("TConfig") - - -ArgsModuleMethod = TypedDict("ArgsModuleMethod", { - "str": str, - "optStr": Optional[str], - "en": "CustomEnum", - "optEnum": Optional["CustomEnum"], - "enumArray": list["CustomEnum"], - "optEnumArray": Optional[list[Optional["CustomEnum"]]], - "map": GenericMap[str, int], - "mapOfArr": GenericMap[str, list[int]], - "mapOfMap": GenericMap[str, GenericMap[str, int]], - "mapOfObj": GenericMap[str, "AnotherType"], - "mapOfArrOfObj": GenericMap[str, list["AnotherType"]] -}) - -ArgsObjectMethod = TypedDict("ArgsObjectMethod", { - "object": "AnotherType", - "optObject": Optional["AnotherType"], - "objectArray": list["AnotherType"], - "optObjectArray": Optional[list[Optional["AnotherType"]]] -}) - -ArgsOptionalEnvMethod = TypedDict("ArgsOptionalEnvMethod", { - "object": "AnotherType", - "optObject": Optional["AnotherType"], - "objectArray": list["AnotherType"], - "optObjectArray": Optional[list[Optional["AnotherType"]]] -}) - -ArgsIf = TypedDict("ArgsIf", { - "if": "Else" -}) - - -class Module(Generic[TConfig], PluginModule[TConfig]): - def __new__(cls, *args, **kwargs): - # NOTE: This is used to dynamically add WRAP ABI compatible methods to the class - instance = super().__new__(cls) - setattr(instance, "moduleMethod", instance.module_method) - setattr(instance, "objectMethod", instance.object_method) - setattr(instance, "optionalEnvMethod", instance.optional_env_method) - setattr(instance, "if", instance.r_if) - return instance - - @abstractmethod - def module_method( - self, - args: ArgsModuleMethod, - client: InvokerClient, - env: None - ) -> int: - pass - - @abstractmethod - def object_method( - self, - args: ArgsObjectMethod, - client: InvokerClient, - env: Env - ) -> Optional["AnotherType"]: - pass - - @abstractmethod - def optional_env_method( - self, - args: ArgsOptionalEnvMethod, - client: InvokerClient, - env: Optional[Env] = None - ) -> Optional["AnotherType"]: - pass - - @abstractmethod - def r_if( - self, - args: ArgsIf, - client: InvokerClient, - env: None - ) -> "Else": - pass - diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-py/types.py b/packages/test-cases/cases/bind/sanity/output/plugin-py/types.py deleted file mode 100644 index fa5d31f1a3..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-py/types.py +++ /dev/null @@ -1,244 +0,0 @@ -# NOTE: This is an auto-generated file. All modifications will be overwritten. -# type: ignore -from __future__ import annotations - -from typing import TypedDict, Optional -from enum import IntEnum - -from polywrap_core import InvokerClient, Uri -from polywrap_msgpack import GenericMap - - -### Env START ### - -Env = TypedDict("Env", { - "prop": str, - "optProp": Optional[str], - "optMap": Optional[GenericMap[str, Optional[int]]], -}) - -### Env END ### - -### Objects START ### - -CustomType = TypedDict("CustomType", { - "str": str, - "optStr": Optional[str], - "u": int, - "optU": Optional[int], - "u8": int, - "u16": int, - "u32": int, - "i": int, - "i8": int, - "i16": int, - "i32": int, - "bigint": str, - "optBigint": Optional[str], - "bignumber": str, - "optBignumber": Optional[str], - "json": str, - "optJson": Optional[str], - "bytes": bytes, - "optBytes": Optional[bytes], - "boolean": bool, - "optBoolean": Optional[bool], - "u_array": list[int], - "uOpt_array": Optional[list[int]], - "_opt_uOptArray": Optional[list[Optional[int]]], - "optStrOptArray": Optional[list[Optional[str]]], - "uArrayArray": list[list[int]], - "uOptArrayOptArray": list[Optional[list[Optional[int]]]], - "uArrayOptArrayArray": list[Optional[list[list[int]]]], - "crazyArray": Optional[list[Optional[list[list[Optional[list[int]]]]]]], - "object": "AnotherType", - "optObject": Optional["AnotherType"], - "objectArray": list["AnotherType"], - "optObjectArray": Optional[list[Optional["AnotherType"]]], - "en": "CustomEnum", - "optEnum": Optional["CustomEnum"], - "enumArray": list["CustomEnum"], - "optEnumArray": Optional[list[Optional["CustomEnum"]]], - "map": GenericMap[str, int], - "mapOfArr": GenericMap[str, list[int]], - "mapOfObj": GenericMap[str, "AnotherType"], - "mapOfArrOfObj": GenericMap[str, list["AnotherType"]], - "mapCustomValue": GenericMap[str, Optional["CustomMapValue"]], -}) - -AnotherType = TypedDict("AnotherType", { - "prop": Optional[str], - "circular": Optional["CustomType"], - "const": Optional[str], -}) - -CustomMapValue = TypedDict("CustomMapValue", { - "foo": str, -}) - -Else = TypedDict("Else", { - "else": str, -}) - -### Objects END ### - -### Enums START ### -class CustomEnum(IntEnum): - STRING = 0, "0", "STRING" - BYTES = 1, "1", "BYTES" - - def __new__(cls, value: int, *aliases: str): - obj = int.__new__(cls) - obj._value_ = value - for alias in aliases: - cls._value2member_map_[alias] = obj - return obj - -class While(IntEnum): - r_for = 0, "0", "for" - r_in = 1, "1", "in" - - def __new__(cls, value: int, *aliases: str): - obj = int.__new__(cls) - obj._value_ = value - for alias in aliases: - cls._value2member_map_[alias] = obj - return obj - -### Enums END ### - -### Imported Objects START ### - -# URI: "testimport.uri.eth" # -TestImportObject = TypedDict("TestImportObject", { - "object": "TestImportAnotherObject", - "optObject": Optional["TestImportAnotherObject"], - "objectArray": list["TestImportAnotherObject"], - "optObjectArray": Optional[list[Optional["TestImportAnotherObject"]]], - "en": "TestImportEnum", - "optEnum": Optional["TestImportEnum"], - "enumArray": list["TestImportEnum"], - "optEnumArray": Optional[list[Optional["TestImportEnum"]]], -}) - -# URI: "testimport.uri.eth" # -TestImportAnotherObject = TypedDict("TestImportAnotherObject", { - "prop": str, -}) - -### Imported Objects END ### - -### Imported Enums START ### - -# URI: "testimport.uri.eth" # -class TestImportEnum(IntEnum): - STRING = 0, "0", "STRING" - BYTES = 1, "1", "BYTES" - - def __new__(cls, value: int, *aliases: str): - obj = int.__new__(cls) - obj._value_ = value - for alias in aliases: - cls._value2member_map_[alias] = obj - return obj - -# URI: "testimport.uri.eth" # -class TestImportEnumReturn(IntEnum): - STRING = 0, "0", "STRING" - BYTES = 1, "1", "BYTES" - - def __new__(cls, value: int, *aliases: str): - obj = int.__new__(cls) - obj._value_ = value - for alias in aliases: - cls._value2member_map_[alias] = obj - return obj - - -### Imported Enums END ### - -### Imported Modules START ### - -# URI: "testimport.uri.eth" # -TestImportModuleArgsImportedMethod = TypedDict("TestImportModuleArgsImportedMethod", { - "str": str, - "optStr": Optional[str], - "u": int, - "optU": Optional[int], - "uArrayArray": list[Optional[list[Optional[int]]]], - "object": "TestImportObject", - "optObject": Optional["TestImportObject"], - "objectArray": list["TestImportObject"], - "optObjectArray": Optional[list[Optional["TestImportObject"]]], - "en": "TestImportEnum", - "optEnum": Optional["TestImportEnum"], - "enumArray": list["TestImportEnum"], - "optEnumArray": Optional[list[Optional["TestImportEnum"]]], -}) - -# URI: "testimport.uri.eth" # -TestImportModuleArgsAnotherMethod = TypedDict("TestImportModuleArgsAnotherMethod", { - "arg": list[str], -}) - -# URI: "testimport.uri.eth" # -TestImportModuleArgsReturnsArrayOfEnums = TypedDict("TestImportModuleArgsReturnsArrayOfEnums", { - "arg": str, -}) - -# URI: "testimport.uri.eth" # -class TestImportModule: - INTERFACE_URI: Uri = Uri.from_str("testimport.uri.eth") - uri: Uri - - def __init__(self, uri: Uri): - self.uri = uri - - def imported_method( - self, - args: TestImportModuleArgsImportedMethod, - client: InvokerClient - ) -> Optional["TestImportObject"]: - return client.invoke( - uri=self.uri, - method="importedMethod", - args=args, - ) - - def another_method( - self, - args: TestImportModuleArgsAnotherMethod, - client: InvokerClient - ) -> int: - return client.invoke( - uri=self.uri, - method="anotherMethod", - args=args, - ) - - def returns_array_of_enums( - self, - args: TestImportModuleArgsReturnsArrayOfEnums, - client: InvokerClient - ) -> list[Optional["TestImportEnumReturn"]]: - return client.invoke( - uri=self.uri, - method="returnsArrayOfEnums", - args=args, - ) - -### Imported Modules END ### - -### Interface START ### - - -class TestImport: - URI: Uri = Uri.from_str("testimport.uri.eth") - - def get_implementations( - client: InvokerClient - ) -> list[str]: - impls = client.getImplementations(self.uri) - return [impl.uri for impl in impls] - -### Interface END ### diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-py/wrap_info.py b/packages/test-cases/cases/bind/sanity/output/plugin-py/wrap_info.py deleted file mode 100644 index 7bf75c8e64..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-py/wrap_info.py +++ /dev/null @@ -1,2441 +0,0 @@ -# NOTE: This is an auto-generated file. All modifications will be overwritten. -# type: ignore -from __future__ import annotations - -import json - -from polywrap_manifest import WrapManifest - -abi = json.loads(""" -{ - "enumTypes": [ - { - "constants": [ - "STRING", - "BYTES" - ], - "kind": 8, - "type": "CustomEnum" - }, - { - "constants": [ - "for", - "in" - ], - "kind": 8, - "type": "while" - } - ], - "envType": { - "kind": 65536, - "properties": [ - { - "kind": 34, - "name": "prop", - "required": true, - "scalar": { - "kind": 4, - "name": "prop", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optProp", - "scalar": { - "kind": 4, - "name": "optProp", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "optMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "optMap", - "scalar": { - "kind": 4, - "name": "optMap", - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "optMap", - "type": "Int" - } - }, - "name": "optMap", - "type": "Map" - } - ], - "type": "Env" - }, - "importedEnumTypes": [ - { - "constants": [ - "STRING", - "BYTES" - ], - "kind": 520, - "namespace": "TestImport", - "nativeType": "Enum", - "type": "TestImport_Enum", - "uri": "testimport.uri.eth" - }, - { - "constants": [ - "STRING", - "BYTES" - ], - "kind": 520, - "namespace": "TestImport", - "nativeType": "Enum", - "type": "TestImport_Enum_Return", - "uri": "testimport.uri.eth" - } - ], - "importedEnvTypes": [ - { - "kind": 524288, - "namespace": "TestImport", - "nativeType": "Env", - "properties": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "TestImport_AnotherObject" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "TestImport_AnotherObject" - }, - "type": "TestImport_AnotherObject" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[TestImport_AnotherObject]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[TestImport_AnotherObject]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "optEnum", - "type": "TestImport_Enum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - } - ], - "type": "TestImport_Env", - "uri": "testimport.uri.eth" - } - ], - "importedModuleTypes": [ - { - "isInterface": true, - "kind": 256, - "methods": [ - { - "arguments": [ - { - "kind": 34, - "name": "str", - "required": true, - "scalar": { - "kind": 4, - "name": "str", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optStr", - "scalar": { - "kind": 4, - "name": "optStr", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "u", - "required": true, - "scalar": { - "kind": 4, - "name": "u", - "required": true, - "type": "UInt" - }, - "type": "UInt" - }, - { - "kind": 34, - "name": "optU", - "scalar": { - "kind": 4, - "name": "optU", - "type": "UInt" - }, - "type": "UInt" - }, - { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "scalar": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "type": "[UInt]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "scalar": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - "kind": 34, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "TestImport_Object" - }, - "required": true, - "type": "TestImport_Object" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "TestImport_Object" - }, - "type": "TestImport_Object" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_Object" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_Object" - }, - "required": true, - "type": "[TestImport_Object]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[TestImport_Object]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_Object" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_Object" - }, - "type": "[TestImport_Object]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[TestImport_Object]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "optEnum", - "type": "TestImport_Enum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - } - ], - "env": { - "required": true - }, - "kind": 64, - "name": "importedMethod", - "required": true, - "return": { - "kind": 34, - "name": "importedMethod", - "object": { - "kind": 8192, - "name": "importedMethod", - "type": "TestImport_Object" - }, - "type": "TestImport_Object" - }, - "type": "Method" - }, - { - "arguments": [ - { - "array": { - "item": { - "kind": 4, - "name": "arg", - "required": true, - "type": "String" - }, - "kind": 18, - "name": "arg", - "required": true, - "scalar": { - "kind": 4, - "name": "arg", - "required": true, - "type": "String" - }, - "type": "[String]" - }, - "kind": 34, - "name": "arg", - "required": true, - "type": "[String]" - } - ], - "kind": 64, - "name": "anotherMethod", - "required": true, - "return": { - "kind": 34, - "name": "anotherMethod", - "required": true, - "scalar": { - "kind": 4, - "name": "anotherMethod", - "required": true, - "type": "Int32" - }, - "type": "Int32" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "arg", - "required": true, - "scalar": { - "kind": 4, - "name": "arg", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "kind": 64, - "name": "returnsArrayOfEnums", - "required": true, - "return": { - "array": { - "enum": { - "kind": 16384, - "name": "returnsArrayOfEnums", - "type": "TestImport_Enum_Return" - }, - "item": { - "kind": 16384, - "name": "returnsArrayOfEnums", - "type": "TestImport_Enum_Return" - }, - "kind": 18, - "name": "returnsArrayOfEnums", - "required": true, - "type": "[TestImport_Enum_Return]" - }, - "kind": 34, - "name": "returnsArrayOfEnums", - "required": true, - "type": "[TestImport_Enum_Return]" - }, - "type": "Method" - } - ], - "namespace": "TestImport", - "nativeType": "Module", - "type": "TestImport_Module", - "uri": "testimport.uri.eth" - } - ], - "importedObjectTypes": [ - { - "kind": 1025, - "namespace": "TestImport", - "nativeType": "Object", - "properties": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "TestImport_AnotherObject" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "TestImport_AnotherObject" - }, - "type": "TestImport_AnotherObject" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[TestImport_AnotherObject]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[TestImport_AnotherObject]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "optEnum", - "type": "TestImport_Enum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - } - ], - "type": "TestImport_Object", - "uri": "testimport.uri.eth" - }, - { - "kind": 1025, - "namespace": "TestImport", - "nativeType": "AnotherObject", - "properties": [ - { - "kind": 34, - "name": "prop", - "required": true, - "scalar": { - "kind": 4, - "name": "prop", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "type": "TestImport_AnotherObject", - "uri": "testimport.uri.eth" - } - ], - "interfaceTypes": [ - { - "capabilities": { - "getImplementations": { - "enabled": true - } - }, - "kind": 32768, - "namespace": "TestImport", - "nativeType": "Interface", - "type": "TestImport", - "uri": "testimport.uri.eth" - } - ], - "moduleType": { - "imports": [ - { - "type": "TestImport_Module" - }, - { - "type": "TestImport_Object" - }, - { - "type": "TestImport_AnotherObject" - }, - { - "type": "TestImport_Enum" - }, - { - "type": "TestImport_Enum_Return" - } - ], - "kind": 128, - "methods": [ - { - "arguments": [ - { - "kind": 34, - "name": "str", - "required": true, - "scalar": { - "kind": 4, - "name": "str", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optStr", - "scalar": { - "kind": 4, - "name": "optStr", - "type": "String" - }, - "type": "String" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "CustomEnum" - }, - "kind": 34, - "name": "optEnum", - "type": "CustomEnum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "map", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "map", - "required": true, - "scalar": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - } - }, - "name": "map", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - }, - "key": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArr", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - } - }, - "name": "mapOfArr", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "map": { - "key": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfMap", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - } - }, - "name": "mapOfMap", - "required": true, - "type": "Map>", - "value": { - "key": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfMap", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - } - } - }, - "name": "mapOfMap", - "required": true, - "type": "Map>" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfObj", - "object": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "Map", - "value": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - } - }, - "name": "mapOfObj", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "key": { - "kind": 4, - "name": "mapOfArrOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - } - }, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map" - } - ], - "kind": 64, - "name": "moduleMethod", - "required": true, - "return": { - "kind": 34, - "name": "moduleMethod", - "required": true, - "scalar": { - "kind": 4, - "name": "moduleMethod", - "required": true, - "type": "Int" - }, - "type": "Int" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "AnotherType" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[AnotherType]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[AnotherType]" - } - ], - "env": { - "required": true - }, - "kind": 64, - "name": "objectMethod", - "required": true, - "return": { - "kind": 34, - "name": "objectMethod", - "object": { - "kind": 8192, - "name": "objectMethod", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "AnotherType" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[AnotherType]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[AnotherType]" - } - ], - "env": { - "required": false - }, - "kind": 64, - "name": "optionalEnvMethod", - "required": true, - "return": { - "kind": 34, - "name": "optionalEnvMethod", - "object": { - "kind": 8192, - "name": "optionalEnvMethod", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "if", - "object": { - "kind": 8192, - "name": "if", - "required": true, - "type": "else" - }, - "required": true, - "type": "else" - } - ], - "kind": 64, - "name": "if", - "required": true, - "return": { - "kind": 34, - "name": "if", - "object": { - "kind": 8192, - "name": "if", - "required": true, - "type": "else" - }, - "required": true, - "type": "else" - }, - "type": "Method" - } - ], - "type": "Module" - }, - "objectTypes": [ - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "str", - "required": true, - "scalar": { - "kind": 4, - "name": "str", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optStr", - "scalar": { - "kind": 4, - "name": "optStr", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "u", - "required": true, - "scalar": { - "kind": 4, - "name": "u", - "required": true, - "type": "UInt" - }, - "type": "UInt" - }, - { - "kind": 34, - "name": "optU", - "scalar": { - "kind": 4, - "name": "optU", - "type": "UInt" - }, - "type": "UInt" - }, - { - "kind": 34, - "name": "u8", - "required": true, - "scalar": { - "kind": 4, - "name": "u8", - "required": true, - "type": "UInt8" - }, - "type": "UInt8" - }, - { - "kind": 34, - "name": "u16", - "required": true, - "scalar": { - "kind": 4, - "name": "u16", - "required": true, - "type": "UInt16" - }, - "type": "UInt16" - }, - { - "kind": 34, - "name": "u32", - "required": true, - "scalar": { - "kind": 4, - "name": "u32", - "required": true, - "type": "UInt32" - }, - "type": "UInt32" - }, - { - "kind": 34, - "name": "i", - "required": true, - "scalar": { - "kind": 4, - "name": "i", - "required": true, - "type": "Int" - }, - "type": "Int" - }, - { - "kind": 34, - "name": "i8", - "required": true, - "scalar": { - "kind": 4, - "name": "i8", - "required": true, - "type": "Int8" - }, - "type": "Int8" - }, - { - "kind": 34, - "name": "i16", - "required": true, - "scalar": { - "kind": 4, - "name": "i16", - "required": true, - "type": "Int16" - }, - "type": "Int16" - }, - { - "kind": 34, - "name": "i32", - "required": true, - "scalar": { - "kind": 4, - "name": "i32", - "required": true, - "type": "Int32" - }, - "type": "Int32" - }, - { - "kind": 34, - "name": "bigint", - "required": true, - "scalar": { - "kind": 4, - "name": "bigint", - "required": true, - "type": "BigInt" - }, - "type": "BigInt" - }, - { - "kind": 34, - "name": "optBigint", - "scalar": { - "kind": 4, - "name": "optBigint", - "type": "BigInt" - }, - "type": "BigInt" - }, - { - "kind": 34, - "name": "bignumber", - "required": true, - "scalar": { - "kind": 4, - "name": "bignumber", - "required": true, - "type": "BigNumber" - }, - "type": "BigNumber" - }, - { - "kind": 34, - "name": "optBignumber", - "scalar": { - "kind": 4, - "name": "optBignumber", - "type": "BigNumber" - }, - "type": "BigNumber" - }, - { - "kind": 34, - "name": "json", - "required": true, - "scalar": { - "kind": 4, - "name": "json", - "required": true, - "type": "JSON" - }, - "type": "JSON" - }, - { - "kind": 34, - "name": "optJson", - "scalar": { - "kind": 4, - "name": "optJson", - "type": "JSON" - }, - "type": "JSON" - }, - { - "kind": 34, - "name": "bytes", - "required": true, - "scalar": { - "kind": 4, - "name": "bytes", - "required": true, - "type": "Bytes" - }, - "type": "Bytes" - }, - { - "kind": 34, - "name": "optBytes", - "scalar": { - "kind": 4, - "name": "optBytes", - "type": "Bytes" - }, - "type": "Bytes" - }, - { - "kind": 34, - "name": "boolean", - "required": true, - "scalar": { - "kind": 4, - "name": "boolean", - "required": true, - "type": "Boolean" - }, - "type": "Boolean" - }, - { - "kind": 34, - "name": "optBoolean", - "scalar": { - "kind": 4, - "name": "optBoolean", - "type": "Boolean" - }, - "type": "Boolean" - }, - { - "array": { - "item": { - "kind": 4, - "name": "u_array", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "u_array", - "required": true, - "scalar": { - "kind": 4, - "name": "u_array", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 34, - "name": "u_array", - "required": true, - "type": "[UInt]" - }, - { - "array": { - "item": { - "kind": 4, - "name": "uOpt_array", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "uOpt_array", - "scalar": { - "kind": 4, - "name": "uOpt_array", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 34, - "name": "uOpt_array", - "type": "[UInt]" - }, - { - "array": { - "item": { - "kind": 4, - "name": "_opt_uOptArray", - "type": "UInt" - }, - "kind": 18, - "name": "_opt_uOptArray", - "scalar": { - "kind": 4, - "name": "_opt_uOptArray", - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 34, - "name": "_opt_uOptArray", - "type": "[UInt]" - }, - { - "array": { - "item": { - "kind": 4, - "name": "optStrOptArray", - "type": "String" - }, - "kind": 18, - "name": "optStrOptArray", - "scalar": { - "kind": 4, - "name": "optStrOptArray", - "type": "String" - }, - "type": "[String]" - }, - "kind": 34, - "name": "optStrOptArray", - "type": "[String]" - }, - { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - "kind": 34, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "kind": 18, - "name": "uOptArrayOptArray", - "scalar": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "kind": 18, - "name": "uOptArrayOptArray", - "scalar": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "uOptArrayOptArray", - "required": true, - "type": "[[UInt32]]" - }, - "kind": 34, - "name": "uOptArrayOptArray", - "required": true, - "type": "[[UInt32]]" - }, - { - "array": { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "type": "[[UInt32]]" - }, - "item": { - "array": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "type": "[[UInt32]]" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "type": "[[[UInt32]]]" - }, - "kind": 34, - "name": "uArrayOptArrayArray", - "required": true, - "type": "[[[UInt32]]]" - }, - { - "array": { - "array": { - "array": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "item": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "kind": 18, - "name": "crazyArray", - "type": "[[[UInt32]]]" - }, - "item": { - "array": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "item": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "kind": 18, - "name": "crazyArray", - "type": "[[[UInt32]]]" - }, - "kind": 18, - "name": "crazyArray", - "type": "[[[[UInt32]]]]" - }, - "kind": 34, - "name": "crazyArray", - "type": "[[[[UInt32]]]]" - }, - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "AnotherType" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[AnotherType]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[AnotherType]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "CustomEnum" - }, - "kind": 34, - "name": "optEnum", - "type": "CustomEnum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "map", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "map", - "required": true, - "scalar": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - } - }, - "name": "map", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - }, - "key": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArr", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - } - }, - "name": "mapOfArr", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfObj", - "object": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "Map", - "value": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - } - }, - "name": "mapOfObj", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "key": { - "kind": 4, - "name": "mapOfArrOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - } - }, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapCustomValue", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapCustomValue", - "object": { - "kind": 8192, - "name": "mapCustomValue", - "type": "CustomMapValue" - }, - "required": true, - "type": "Map", - "value": { - "kind": 8192, - "name": "mapCustomValue", - "type": "CustomMapValue" - } - }, - "name": "mapCustomValue", - "required": true, - "type": "Map" - } - ], - "type": "CustomType" - }, - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "prop", - "scalar": { - "kind": 4, - "name": "prop", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "circular", - "object": { - "kind": 8192, - "name": "circular", - "type": "CustomType" - }, - "type": "CustomType" - }, - { - "kind": 34, - "name": "const", - "scalar": { - "kind": 4, - "name": "const", - "type": "String" - }, - "type": "String" - } - ], - "type": "AnotherType" - }, - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "foo", - "required": true, - "scalar": { - "kind": 4, - "name": "foo", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "type": "CustomMapValue" - }, - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "else", - "required": true, - "scalar": { - "kind": 4, - "name": "else", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "type": "else" - } - ], - "version": "0.1" -} -""") - -manifest = WrapManifest.parse_obj({ - "name": "Test", - "type": "plugin", - "version": "0.1", - "abi": abi, -}) diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-rs/mod.rs b/packages/test-cases/cases/bind/sanity/output/plugin-rs/mod.rs deleted file mode 100644 index 88b7de7bdf..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-rs/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -pub mod types; -#[path = "wrap.info.rs"] -pub mod wrap_info; -pub mod module; \ No newline at end of file diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-rs/module.rs b/packages/test-cases/cases/bind/sanity/output/plugin-rs/module.rs deleted file mode 100644 index db0deb7938..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-rs/module.rs +++ /dev/null @@ -1,69 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -use std::sync::Arc; -use polywrap_core::invoke::Invoker; -use polywrap_plugin::{error::PluginError, module::PluginModule}; -use serde::{Serialize, Deserialize}; -use super::types::*; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsModuleMethod { - pub str: String, - #[serde(rename = "optStr")] - pub opt_str: Option, - pub en: CustomEnum, - #[serde(rename = "optEnum")] - pub opt_enum: Option, - #[serde(rename = "enumArray")] - pub enum_array: Vec, - #[serde(rename = "optEnumArray")] - pub opt_enum_array: Option>>, - pub map: Map, - #[serde(rename = "mapOfArr")] - pub map_of_arr: Map>, - #[serde(rename = "mapOfMap")] - pub map_of_map: Map>, - #[serde(rename = "mapOfObj")] - pub map_of_obj: Map, - #[serde(rename = "mapOfArrOfObj")] - pub map_of_arr_of_obj: Map>, -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsObjectMethod { - pub object: AnotherType, - #[serde(rename = "optObject")] - pub opt_object: Option, - #[serde(rename = "objectArray")] - pub object_array: Vec, - #[serde(rename = "optObjectArray")] - pub opt_object_array: Option>>, -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsOptionalEnvMethod { - pub object: AnotherType, - #[serde(rename = "optObject")] - pub opt_object: Option, - #[serde(rename = "objectArray")] - pub object_array: Vec, - #[serde(rename = "optObjectArray")] - pub opt_object_array: Option>>, -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsIf { - #[serde(rename = "if")] - pub _if: Else, -} - -pub trait Module: PluginModule { - fn module_method(&mut self, args: &ArgsModuleMethod, invoker: Arc) -> Result; - - fn object_method(&mut self, args: &ArgsObjectMethod, invoker: Arc, env: Env) -> Result, PluginError>; - - fn optional_env_method(&mut self, args: &ArgsOptionalEnvMethod, invoker: Arc, env: Option) -> Result, PluginError>; - - fn _if(&mut self, args: &ArgsIf, invoker: Arc) -> Result; -} diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-rs/types.rs b/packages/test-cases/cases/bind/sanity/output/plugin-rs/types.rs deleted file mode 100644 index fe3c18556b..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-rs/types.rs +++ /dev/null @@ -1,289 +0,0 @@ -#![allow(unused_imports)] -#![allow(non_camel_case_types)] - -// NOTE: This is an auto-generated file. -// All modifications will be overwritten. -use polywrap_core::{invoke::Invoker, uri::Uri}; -use polywrap_msgpack::{decode, serialize}; -use polywrap_plugin::{error::PluginError, BigInt, BigNumber, Map, JSON}; -use serde::{Serialize, Deserialize}; -use std::sync::Arc; - -// Env START // - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Env { - pub prop: String, - #[serde(rename = "optProp")] - pub opt_prop: Option, - #[serde(rename = "optMap")] - pub opt_map: Option>>, -} -// Env END // - -// Objects START // - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct CustomType { - pub str: String, - #[serde(rename = "optStr")] - pub opt_str: Option, - pub u: u32, - #[serde(rename = "optU")] - pub opt_u: Option, - pub u8: u8, - pub u16: u16, - pub u32: u32, - pub i: i32, - pub i8: i8, - pub i16: i16, - pub i32: i32, - pub bigint: BigInt, - #[serde(rename = "optBigint")] - pub opt_bigint: Option, - pub bignumber: BigNumber, - #[serde(rename = "optBignumber")] - pub opt_bignumber: Option, - pub json: JSON::Value, - #[serde(rename = "optJson")] - pub opt_json: Option, - #[serde(with = "serde_bytes")] - pub bytes: Vec, - #[serde(with = "serde_bytes")] - #[serde(rename = "optBytes")] - pub opt_bytes: Option>, - pub boolean: bool, - #[serde(rename = "optBoolean")] - pub opt_boolean: Option, - pub u_array: Vec, - #[serde(rename = "uOpt_array")] - pub u_opt_array: Option>, - #[serde(rename = "_opt_uOptArray")] - pub _opt_u_opt_array: Option>>, - #[serde(rename = "optStrOptArray")] - pub opt_str_opt_array: Option>>, - #[serde(rename = "uArrayArray")] - pub u_array_array: Vec>, - #[serde(rename = "uOptArrayOptArray")] - pub u_opt_array_opt_array: Vec>>>, - #[serde(rename = "uArrayOptArrayArray")] - pub u_array_opt_array_array: Vec>>>, - #[serde(rename = "crazyArray")] - pub crazy_array: Option>>>>>>, - pub object: AnotherType, - #[serde(rename = "optObject")] - pub opt_object: Option, - #[serde(rename = "objectArray")] - pub object_array: Vec, - #[serde(rename = "optObjectArray")] - pub opt_object_array: Option>>, - pub en: CustomEnum, - #[serde(rename = "optEnum")] - pub opt_enum: Option, - #[serde(rename = "enumArray")] - pub enum_array: Vec, - #[serde(rename = "optEnumArray")] - pub opt_enum_array: Option>>, - pub map: Map, - #[serde(rename = "mapOfArr")] - pub map_of_arr: Map>, - #[serde(rename = "mapOfObj")] - pub map_of_obj: Map, - #[serde(rename = "mapOfArrOfObj")] - pub map_of_arr_of_obj: Map>, - #[serde(rename = "mapCustomValue")] - pub map_custom_value: Map>, -} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct AnotherType { - pub prop: Option, - pub circular: Option, - #[serde(rename = "const")] - pub _const: Option, -} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct CustomMapValue { - pub foo: String, -} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Else { - #[serde(rename = "else")] - pub _else: String, -} -// Objects END // - -// Enums START // - -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum CustomEnum { - STRING, - BYTES, - _MAX_ -} -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum While { - _for, - _in, - _MAX_ -} -// Enums END // - -// Imported objects START // - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportObject { - pub object: TestImportAnotherObject, - #[serde(rename = "optObject")] - pub opt_object: Option, - #[serde(rename = "objectArray")] - pub object_array: Vec, - #[serde(rename = "optObjectArray")] - pub opt_object_array: Option>>, - pub en: TestImportEnum, - #[serde(rename = "optEnum")] - pub opt_enum: Option, - #[serde(rename = "enumArray")] - pub enum_array: Vec, - #[serde(rename = "optEnumArray")] - pub opt_enum_array: Option>>, -} -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportAnotherObject { - pub prop: String, -} -// Imported objects END // - -// Imported envs START // - -// Imported envs END // - -// Imported enums START // - -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum TestImportEnum { - STRING, - BYTES, - _MAX_ -} -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum TestImportEnumReturn { - STRING, - BYTES, - _MAX_ -} -// Imported enums END // - -// Imported Modules START // - -// URI: "testimport.uri.eth" // -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportModuleArgsImportedMethod { - pub str: String, - #[serde(rename = "optStr")] - pub opt_str: Option, - pub u: u32, - #[serde(rename = "optU")] - pub opt_u: Option, - #[serde(rename = "uArrayArray")] - pub u_array_array: Vec>>>, - pub object: TestImportObject, - #[serde(rename = "optObject")] - pub opt_object: Option, - #[serde(rename = "objectArray")] - pub object_array: Vec, - #[serde(rename = "optObjectArray")] - pub opt_object_array: Option>>, - pub en: TestImportEnum, - #[serde(rename = "optEnum")] - pub opt_enum: Option, - #[serde(rename = "enumArray")] - pub enum_array: Vec, - #[serde(rename = "optEnumArray")] - pub opt_enum_array: Option>>, -} - -// URI: "testimport.uri.eth" // -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportModuleArgsAnotherMethod { - pub arg: Vec, -} - -// URI: "testimport.uri.eth" // -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportModuleArgsReturnsArrayOfEnums { - pub arg: String, -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportModule<'a> { - uri: &'a str -} - -impl<'a> TestImportModule<'a> { - pub const INTERFACE_URI: &'static str = "testimport.uri.eth"; - - pub fn new(uri: &'a str) -> TestImportModule<'a> { - TestImportModule { uri: uri } - } - - pub fn imported_method(&self, args: &TestImportModuleArgsImportedMethod) -> Result, PluginError> { - let uri = self.uri; - let serialized_args = serialize(args.clone()).unwrap(); - let result = invoker.invoke_raw( - uri, - "importedMethod", - serialized_args, - None, - None - ) - .map_err(|e| PluginError::SubinvocationError { - uri: uri.to_string(), - method: "importedMethod".to_string(), - args: JSON::to_string(&args).unwrap(), - exception: e.to_string(), - })?; - - Ok(Some(decode(result.as_slice())?)) - } - - pub fn another_method(&self, args: &TestImportModuleArgsAnotherMethod) -> Result { - let uri = self.uri; - let serialized_args = serialize(args.clone()).unwrap(); - let result = invoker.invoke_raw( - uri, - "anotherMethod", - serialized_args, - None, - None - ) - .map_err(|e| PluginError::SubinvocationError { - uri: uri.to_string(), - method: "anotherMethod".to_string(), - args: JSON::to_string(&args).unwrap(), - exception: e.to_string(), - })?; - - Ok(decode(result.as_slice())?) - } - - pub fn returns_array_of_enums(&self, args: &TestImportModuleArgsReturnsArrayOfEnums) -> Result>, PluginError> { - let uri = self.uri; - let serialized_args = serialize(args.clone()).unwrap(); - let result = invoker.invoke_raw( - uri, - "returnsArrayOfEnums", - serialized_args, - None, - None - ) - .map_err(|e| PluginError::SubinvocationError { - uri: uri.to_string(), - method: "returnsArrayOfEnums".to_string(), - args: JSON::to_string(&args).unwrap(), - exception: e.to_string(), - })?; - - Ok(decode(result.as_slice())?) - } -} -// Imported Modules END // diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-rs/wrap.info.rs b/packages/test-cases/cases/bind/sanity/output/plugin-rs/wrap.info.rs deleted file mode 100644 index a7fab1e26d..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-rs/wrap.info.rs +++ /dev/null @@ -1,2436 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. -use polywrap_plugin::JSON::{from_value, json}; -use wrap_manifest_schemas::versions::{WrapManifest, WrapManifestAbi}; - -pub fn get_manifest() -> WrapManifest { - WrapManifest { - name: "Test".to_string(), - type_: "plugin".to_string(), - version: "0.1".to_string(), - abi: from_value::(json!({ - "enumTypes": [ - { - "constants": [ - "STRING", - "BYTES" - ], - "kind": 8, - "type": "CustomEnum" - }, - { - "constants": [ - "for", - "in" - ], - "kind": 8, - "type": "while" - } - ], - "envType": { - "kind": 65536, - "properties": [ - { - "kind": 34, - "name": "prop", - "required": true, - "scalar": { - "kind": 4, - "name": "prop", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optProp", - "scalar": { - "kind": 4, - "name": "optProp", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "optMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "optMap", - "scalar": { - "kind": 4, - "name": "optMap", - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "optMap", - "type": "Int" - } - }, - "name": "optMap", - "type": "Map" - } - ], - "type": "Env" - }, - "importedEnumTypes": [ - { - "constants": [ - "STRING", - "BYTES" - ], - "kind": 520, - "namespace": "TestImport", - "nativeType": "Enum", - "type": "TestImport_Enum", - "uri": "testimport.uri.eth" - }, - { - "constants": [ - "STRING", - "BYTES" - ], - "kind": 520, - "namespace": "TestImport", - "nativeType": "Enum", - "type": "TestImport_Enum_Return", - "uri": "testimport.uri.eth" - } - ], - "importedEnvTypes": [ - { - "kind": 524288, - "namespace": "TestImport", - "nativeType": "Env", - "properties": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "TestImport_AnotherObject" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "TestImport_AnotherObject" - }, - "type": "TestImport_AnotherObject" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[TestImport_AnotherObject]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[TestImport_AnotherObject]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "optEnum", - "type": "TestImport_Enum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - } - ], - "type": "TestImport_Env", - "uri": "testimport.uri.eth" - } - ], - "importedModuleTypes": [ - { - "isInterface": true, - "kind": 256, - "methods": [ - { - "arguments": [ - { - "kind": 34, - "name": "str", - "required": true, - "scalar": { - "kind": 4, - "name": "str", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optStr", - "scalar": { - "kind": 4, - "name": "optStr", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "u", - "required": true, - "scalar": { - "kind": 4, - "name": "u", - "required": true, - "type": "UInt" - }, - "type": "UInt" - }, - { - "kind": 34, - "name": "optU", - "scalar": { - "kind": 4, - "name": "optU", - "type": "UInt" - }, - "type": "UInt" - }, - { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "scalar": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "type": "[UInt]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "scalar": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - "kind": 34, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "TestImport_Object" - }, - "required": true, - "type": "TestImport_Object" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "TestImport_Object" - }, - "type": "TestImport_Object" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_Object" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_Object" - }, - "required": true, - "type": "[TestImport_Object]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[TestImport_Object]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_Object" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_Object" - }, - "type": "[TestImport_Object]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[TestImport_Object]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "optEnum", - "type": "TestImport_Enum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - } - ], - "env": { - "required": true - }, - "kind": 64, - "name": "importedMethod", - "required": true, - "return": { - "kind": 34, - "name": "importedMethod", - "object": { - "kind": 8192, - "name": "importedMethod", - "type": "TestImport_Object" - }, - "type": "TestImport_Object" - }, - "type": "Method" - }, - { - "arguments": [ - { - "array": { - "item": { - "kind": 4, - "name": "arg", - "required": true, - "type": "String" - }, - "kind": 18, - "name": "arg", - "required": true, - "scalar": { - "kind": 4, - "name": "arg", - "required": true, - "type": "String" - }, - "type": "[String]" - }, - "kind": 34, - "name": "arg", - "required": true, - "type": "[String]" - } - ], - "kind": 64, - "name": "anotherMethod", - "required": true, - "return": { - "kind": 34, - "name": "anotherMethod", - "required": true, - "scalar": { - "kind": 4, - "name": "anotherMethod", - "required": true, - "type": "Int32" - }, - "type": "Int32" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "arg", - "required": true, - "scalar": { - "kind": 4, - "name": "arg", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "kind": 64, - "name": "returnsArrayOfEnums", - "required": true, - "return": { - "array": { - "enum": { - "kind": 16384, - "name": "returnsArrayOfEnums", - "type": "TestImport_Enum_Return" - }, - "item": { - "kind": 16384, - "name": "returnsArrayOfEnums", - "type": "TestImport_Enum_Return" - }, - "kind": 18, - "name": "returnsArrayOfEnums", - "required": true, - "type": "[TestImport_Enum_Return]" - }, - "kind": 34, - "name": "returnsArrayOfEnums", - "required": true, - "type": "[TestImport_Enum_Return]" - }, - "type": "Method" - } - ], - "namespace": "TestImport", - "nativeType": "Module", - "type": "TestImport_Module", - "uri": "testimport.uri.eth" - } - ], - "importedObjectTypes": [ - { - "kind": 1025, - "namespace": "TestImport", - "nativeType": "Object", - "properties": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "TestImport_AnotherObject" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "TestImport_AnotherObject" - }, - "type": "TestImport_AnotherObject" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[TestImport_AnotherObject]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[TestImport_AnotherObject]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "optEnum", - "type": "TestImport_Enum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - } - ], - "type": "TestImport_Object", - "uri": "testimport.uri.eth" - }, - { - "kind": 1025, - "namespace": "TestImport", - "nativeType": "AnotherObject", - "properties": [ - { - "kind": 34, - "name": "prop", - "required": true, - "scalar": { - "kind": 4, - "name": "prop", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "type": "TestImport_AnotherObject", - "uri": "testimport.uri.eth" - } - ], - "interfaceTypes": [ - { - "capabilities": { - "getImplementations": { - "enabled": true - } - }, - "kind": 32768, - "namespace": "TestImport", - "nativeType": "Interface", - "type": "TestImport", - "uri": "testimport.uri.eth" - } - ], - "moduleType": { - "imports": [ - { - "type": "TestImport_Module" - }, - { - "type": "TestImport_Object" - }, - { - "type": "TestImport_AnotherObject" - }, - { - "type": "TestImport_Enum" - }, - { - "type": "TestImport_Enum_Return" - } - ], - "kind": 128, - "methods": [ - { - "arguments": [ - { - "kind": 34, - "name": "str", - "required": true, - "scalar": { - "kind": 4, - "name": "str", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optStr", - "scalar": { - "kind": 4, - "name": "optStr", - "type": "String" - }, - "type": "String" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "CustomEnum" - }, - "kind": 34, - "name": "optEnum", - "type": "CustomEnum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "map", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "map", - "required": true, - "scalar": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - } - }, - "name": "map", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - }, - "key": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArr", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - } - }, - "name": "mapOfArr", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "map": { - "key": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfMap", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - } - }, - "name": "mapOfMap", - "required": true, - "type": "Map>", - "value": { - "key": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfMap", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - } - } - }, - "name": "mapOfMap", - "required": true, - "type": "Map>" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfObj", - "object": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "Map", - "value": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - } - }, - "name": "mapOfObj", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "key": { - "kind": 4, - "name": "mapOfArrOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - } - }, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map" - } - ], - "kind": 64, - "name": "moduleMethod", - "required": true, - "return": { - "kind": 34, - "name": "moduleMethod", - "required": true, - "scalar": { - "kind": 4, - "name": "moduleMethod", - "required": true, - "type": "Int" - }, - "type": "Int" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "AnotherType" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[AnotherType]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[AnotherType]" - } - ], - "env": { - "required": true - }, - "kind": 64, - "name": "objectMethod", - "required": true, - "return": { - "kind": 34, - "name": "objectMethod", - "object": { - "kind": 8192, - "name": "objectMethod", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "AnotherType" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[AnotherType]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[AnotherType]" - } - ], - "env": { - "required": false - }, - "kind": 64, - "name": "optionalEnvMethod", - "required": true, - "return": { - "kind": 34, - "name": "optionalEnvMethod", - "object": { - "kind": 8192, - "name": "optionalEnvMethod", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "if", - "object": { - "kind": 8192, - "name": "if", - "required": true, - "type": "else" - }, - "required": true, - "type": "else" - } - ], - "kind": 64, - "name": "if", - "required": true, - "return": { - "kind": 34, - "name": "if", - "object": { - "kind": 8192, - "name": "if", - "required": true, - "type": "else" - }, - "required": true, - "type": "else" - }, - "type": "Method" - } - ], - "type": "Module" - }, - "objectTypes": [ - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "str", - "required": true, - "scalar": { - "kind": 4, - "name": "str", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optStr", - "scalar": { - "kind": 4, - "name": "optStr", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "u", - "required": true, - "scalar": { - "kind": 4, - "name": "u", - "required": true, - "type": "UInt" - }, - "type": "UInt" - }, - { - "kind": 34, - "name": "optU", - "scalar": { - "kind": 4, - "name": "optU", - "type": "UInt" - }, - "type": "UInt" - }, - { - "kind": 34, - "name": "u8", - "required": true, - "scalar": { - "kind": 4, - "name": "u8", - "required": true, - "type": "UInt8" - }, - "type": "UInt8" - }, - { - "kind": 34, - "name": "u16", - "required": true, - "scalar": { - "kind": 4, - "name": "u16", - "required": true, - "type": "UInt16" - }, - "type": "UInt16" - }, - { - "kind": 34, - "name": "u32", - "required": true, - "scalar": { - "kind": 4, - "name": "u32", - "required": true, - "type": "UInt32" - }, - "type": "UInt32" - }, - { - "kind": 34, - "name": "i", - "required": true, - "scalar": { - "kind": 4, - "name": "i", - "required": true, - "type": "Int" - }, - "type": "Int" - }, - { - "kind": 34, - "name": "i8", - "required": true, - "scalar": { - "kind": 4, - "name": "i8", - "required": true, - "type": "Int8" - }, - "type": "Int8" - }, - { - "kind": 34, - "name": "i16", - "required": true, - "scalar": { - "kind": 4, - "name": "i16", - "required": true, - "type": "Int16" - }, - "type": "Int16" - }, - { - "kind": 34, - "name": "i32", - "required": true, - "scalar": { - "kind": 4, - "name": "i32", - "required": true, - "type": "Int32" - }, - "type": "Int32" - }, - { - "kind": 34, - "name": "bigint", - "required": true, - "scalar": { - "kind": 4, - "name": "bigint", - "required": true, - "type": "BigInt" - }, - "type": "BigInt" - }, - { - "kind": 34, - "name": "optBigint", - "scalar": { - "kind": 4, - "name": "optBigint", - "type": "BigInt" - }, - "type": "BigInt" - }, - { - "kind": 34, - "name": "bignumber", - "required": true, - "scalar": { - "kind": 4, - "name": "bignumber", - "required": true, - "type": "BigNumber" - }, - "type": "BigNumber" - }, - { - "kind": 34, - "name": "optBignumber", - "scalar": { - "kind": 4, - "name": "optBignumber", - "type": "BigNumber" - }, - "type": "BigNumber" - }, - { - "kind": 34, - "name": "json", - "required": true, - "scalar": { - "kind": 4, - "name": "json", - "required": true, - "type": "JSON" - }, - "type": "JSON" - }, - { - "kind": 34, - "name": "optJson", - "scalar": { - "kind": 4, - "name": "optJson", - "type": "JSON" - }, - "type": "JSON" - }, - { - "kind": 34, - "name": "bytes", - "required": true, - "scalar": { - "kind": 4, - "name": "bytes", - "required": true, - "type": "Bytes" - }, - "type": "Bytes" - }, - { - "kind": 34, - "name": "optBytes", - "scalar": { - "kind": 4, - "name": "optBytes", - "type": "Bytes" - }, - "type": "Bytes" - }, - { - "kind": 34, - "name": "boolean", - "required": true, - "scalar": { - "kind": 4, - "name": "boolean", - "required": true, - "type": "Boolean" - }, - "type": "Boolean" - }, - { - "kind": 34, - "name": "optBoolean", - "scalar": { - "kind": 4, - "name": "optBoolean", - "type": "Boolean" - }, - "type": "Boolean" - }, - { - "array": { - "item": { - "kind": 4, - "name": "u_array", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "u_array", - "required": true, - "scalar": { - "kind": 4, - "name": "u_array", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 34, - "name": "u_array", - "required": true, - "type": "[UInt]" - }, - { - "array": { - "item": { - "kind": 4, - "name": "uOpt_array", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "uOpt_array", - "scalar": { - "kind": 4, - "name": "uOpt_array", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 34, - "name": "uOpt_array", - "type": "[UInt]" - }, - { - "array": { - "item": { - "kind": 4, - "name": "_opt_uOptArray", - "type": "UInt" - }, - "kind": 18, - "name": "_opt_uOptArray", - "scalar": { - "kind": 4, - "name": "_opt_uOptArray", - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 34, - "name": "_opt_uOptArray", - "type": "[UInt]" - }, - { - "array": { - "item": { - "kind": 4, - "name": "optStrOptArray", - "type": "String" - }, - "kind": 18, - "name": "optStrOptArray", - "scalar": { - "kind": 4, - "name": "optStrOptArray", - "type": "String" - }, - "type": "[String]" - }, - "kind": 34, - "name": "optStrOptArray", - "type": "[String]" - }, - { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - "kind": 34, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "kind": 18, - "name": "uOptArrayOptArray", - "scalar": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "kind": 18, - "name": "uOptArrayOptArray", - "scalar": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "uOptArrayOptArray", - "required": true, - "type": "[[UInt32]]" - }, - "kind": 34, - "name": "uOptArrayOptArray", - "required": true, - "type": "[[UInt32]]" - }, - { - "array": { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "type": "[[UInt32]]" - }, - "item": { - "array": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "type": "[[UInt32]]" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "type": "[[[UInt32]]]" - }, - "kind": 34, - "name": "uArrayOptArrayArray", - "required": true, - "type": "[[[UInt32]]]" - }, - { - "array": { - "array": { - "array": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "item": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "kind": 18, - "name": "crazyArray", - "type": "[[[UInt32]]]" - }, - "item": { - "array": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "item": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "kind": 18, - "name": "crazyArray", - "type": "[[[UInt32]]]" - }, - "kind": 18, - "name": "crazyArray", - "type": "[[[[UInt32]]]]" - }, - "kind": 34, - "name": "crazyArray", - "type": "[[[[UInt32]]]]" - }, - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "AnotherType" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[AnotherType]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[AnotherType]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "CustomEnum" - }, - "kind": 34, - "name": "optEnum", - "type": "CustomEnum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "map", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "map", - "required": true, - "scalar": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - } - }, - "name": "map", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - }, - "key": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArr", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - } - }, - "name": "mapOfArr", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfObj", - "object": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "Map", - "value": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - } - }, - "name": "mapOfObj", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "key": { - "kind": 4, - "name": "mapOfArrOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - } - }, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapCustomValue", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapCustomValue", - "object": { - "kind": 8192, - "name": "mapCustomValue", - "type": "CustomMapValue" - }, - "required": true, - "type": "Map", - "value": { - "kind": 8192, - "name": "mapCustomValue", - "type": "CustomMapValue" - } - }, - "name": "mapCustomValue", - "required": true, - "type": "Map" - } - ], - "type": "CustomType" - }, - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "prop", - "scalar": { - "kind": 4, - "name": "prop", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "circular", - "object": { - "kind": 8192, - "name": "circular", - "type": "CustomType" - }, - "type": "CustomType" - }, - { - "kind": 34, - "name": "const", - "scalar": { - "kind": 4, - "name": "const", - "type": "String" - }, - "type": "String" - } - ], - "type": "AnotherType" - }, - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "foo", - "required": true, - "scalar": { - "kind": 4, - "name": "foo", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "type": "CustomMapValue" - }, - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "else", - "required": true, - "scalar": { - "kind": 4, - "name": "else", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "type": "else" - } - ], - "version": "0.1" -})).unwrap() - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-ts/index.ts b/packages/test-cases/cases/bind/sanity/output/plugin-ts/index.ts deleted file mode 100644 index 4f5ca809d5..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-ts/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -export * from "./wrap.info"; -export * from "./module"; -export * from "./types"; - -export { CoreClient } from "@polywrap/core-js"; diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-ts/module.ts b/packages/test-cases/cases/bind/sanity/output/plugin-ts/module.ts deleted file mode 100644 index 96d6faf2fb..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-ts/module.ts +++ /dev/null @@ -1,67 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -// @ts-ignore -import * as Types from "./types"; - -// @ts-ignore -import { CoreClient, MaybeAsync } from "@polywrap/core-js"; -import { PluginModule } from "@polywrap/plugin-js"; - -export interface Args_moduleMethod { - str: Types.String; - optStr?: Types.String | null; - en: Types.CustomEnum; - optEnum?: Types.CustomEnum | null; - enumArray: Array; - optEnumArray?: Array | null; - map: Map; - mapOfArr: Map>; - mapOfMap: Map>; - mapOfObj: Map; - mapOfArrOfObj: Map>; -} - -export interface Args_objectMethod { - object: Types.AnotherType; - optObject?: Types.AnotherType | null; - objectArray: Array; - optObjectArray?: Array | null; -} - -export interface Args_optionalEnvMethod { - object: Types.AnotherType; - optObject?: Types.AnotherType | null; - objectArray: Array; - optObjectArray?: Array | null; -} - -export interface Args_if { - if: Types._else; -} - -export abstract class Module extends PluginModule { - abstract moduleMethod( - args: Args_moduleMethod, - client: CoreClient, - env?: null - ): MaybeAsync; - - abstract objectMethod( - args: Args_objectMethod, - client: CoreClient, - env: Types.Env - ): MaybeAsync; - - abstract optionalEnvMethod( - args: Args_optionalEnvMethod, - client: CoreClient, - env?: Types.Env | null - ): MaybeAsync; - - abstract if( - args: Args_if, - client: CoreClient, - env?: null - ): MaybeAsync; -} diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts b/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts deleted file mode 100644 index 428ddf9e92..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-ts/types.ts +++ /dev/null @@ -1,257 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. - -// @ts-ignore -import * as Types from "./"; - -// @ts-ignore -import { - CoreClient, - Result, - InvokeResult, - Uri, -} from "@polywrap/core-js"; - -export type UInt = number; -export type UInt8 = number; -export type UInt16 = number; -export type UInt32 = number; -export type Int = number; -export type Int8 = number; -export type Int16 = number; -export type Int32 = number; -export type Bytes = Uint8Array; -export type BigInt = string; -export type BigNumber = string; -export type Json = string; -export type String = string; -export type Boolean = boolean; - -/// Env START /// -export interface Env extends Record { - prop: Types.String; - optProp?: Types.String | null; - optMap?: Map | null; -} -/// Env END /// - -/// Objects START /// -export interface CustomType { - str: Types.String; - optStr?: Types.String | null; - u: Types.UInt; - optU?: Types.UInt | null; - u8: Types.UInt8; - u16: Types.UInt16; - u32: Types.UInt32; - i: Types.Int; - i8: Types.Int8; - i16: Types.Int16; - i32: Types.Int32; - bigint: Types.BigInt; - optBigint?: Types.BigInt | null; - bignumber: Types.BigNumber; - optBignumber?: Types.BigNumber | null; - json: Types.Json; - optJson?: Types.Json | null; - bytes: Types.Bytes; - optBytes?: Types.Bytes | null; - boolean: Types.Boolean; - optBoolean?: Types.Boolean | null; - u_array: Array; - uOpt_array?: Array | null; - _opt_uOptArray?: Array | null; - optStrOptArray?: Array | null; - uArrayArray: Array>; - uOptArrayOptArray: Array | null>; - uArrayOptArrayArray: Array> | null>; - crazyArray?: Array | null>> | null> | null; - object: Types.AnotherType; - optObject?: Types.AnotherType | null; - objectArray: Array; - optObjectArray?: Array | null; - en: Types.CustomEnum; - optEnum?: Types.CustomEnum | null; - enumArray: Array; - optEnumArray?: Array | null; - map: Map; - mapOfArr: Map>; - mapOfObj: Map; - mapOfArrOfObj: Map>; - mapCustomValue: Map; -} - -export interface AnotherType { - prop?: Types.String | null; - circular?: Types.CustomType | null; - const?: Types.String | null; -} - -export interface CustomMapValue { - foo: Types.String; -} - -export interface _else { - else: Types.String; -} - -/// Objects END /// - -/// Enums START /// -export enum CustomEnumEnum { - STRING, - BYTES, -} - -export type CustomEnumString = - | "STRING" - | "BYTES" - -export type CustomEnum = CustomEnumEnum | CustomEnumString; - -export enum whileEnum { - for, - in, -} - -export type whileString = - | "for" - | "in" - -export type _while = whileEnum | whileString; - -/// Enums END /// - -/// Imported Objects START /// - -/* URI: "testimport.uri.eth" */ -export interface TestImport_Object { - object: Types.TestImport_AnotherObject; - optObject?: Types.TestImport_AnotherObject | null; - objectArray: Array; - optObjectArray?: Array | null; - en: Types.TestImport_Enum; - optEnum?: Types.TestImport_Enum | null; - enumArray: Array; - optEnumArray?: Array | null; -} - -/* URI: "testimport.uri.eth" */ -export interface TestImport_AnotherObject { - prop: Types.String; -} - -/* URI: "testimport.uri.eth" */ -export enum TestImport_EnumEnum { - STRING, - BYTES, -} - -export type TestImport_EnumString = - | "STRING" - | "BYTES" - -export type TestImport_Enum = TestImport_EnumEnum | TestImport_EnumString; - -/* URI: "testimport.uri.eth" */ -export enum TestImport_Enum_ReturnEnum { - STRING, - BYTES, -} - -export type TestImport_Enum_ReturnString = - | "STRING" - | "BYTES" - -export type TestImport_Enum_Return = TestImport_Enum_ReturnEnum | TestImport_Enum_ReturnString; - -/// Imported Objects END /// - -/// Imported Modules START /// - -/* URI: "testimport.uri.eth" */ -export interface TestImport_Module_Args_importedMethod { - str: Types.String; - optStr?: Types.String | null; - u: Types.UInt; - optU?: Types.UInt | null; - uArrayArray: Array | null>; - object: Types.TestImport_Object; - optObject?: Types.TestImport_Object | null; - objectArray: Array; - optObjectArray?: Array | null; - en: Types.TestImport_Enum; - optEnum?: Types.TestImport_Enum | null; - enumArray: Array; - optEnumArray?: Array | null; -} - -/* URI: "testimport.uri.eth" */ -export interface TestImport_Module_Args_anotherMethod { - arg: Array; -} - -/* URI: "testimport.uri.eth" */ -export interface TestImport_Module_Args_returnsArrayOfEnums { - arg: Types.String; -} - -/* URI: "testimport.uri.eth" */ -export class TestImport_Module { - public static interfaceUri: string = "testimport.uri.eth"; - public uri: Uri; - - constructor(uri: string) { - this.uri = Uri.from(uri); - } - - public async importedMethod( - args: TestImport_Module_Args_importedMethod, - client: CoreClient - ): Promise> { - return client.invoke({ - uri: this.uri, - method: "importedMethod", - args: (args as unknown) as Record, - }); - } - - public async anotherMethod( - args: TestImport_Module_Args_anotherMethod, - client: CoreClient - ): Promise> { - return client.invoke({ - uri: this.uri, - method: "anotherMethod", - args: (args as unknown) as Record, - }); - } - - public async returnsArrayOfEnums( - args: TestImport_Module_Args_returnsArrayOfEnums, - client: CoreClient - ): Promise>> { - return client.invoke>({ - uri: this.uri, - method: "returnsArrayOfEnums", - args: (args as unknown) as Record, - }); - } -} - -/// Imported Modules END /// - -export class TestImport { - static uri: Uri = Uri.from("testimport.uri.eth"); - - public static async getImplementations( - client: CoreClient - ): Promise> { - const impls = await client.getImplementations(this.uri, {}); - if (!impls.ok) { - return { ok: false, error: impls.error}; - } - - return { ok: true, value: impls.value.map((impl) => (impl.uri))}; - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/plugin-ts/wrap.info.ts b/packages/test-cases/cases/bind/sanity/output/plugin-ts/wrap.info.ts deleted file mode 100644 index 559110bb09..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/plugin-ts/wrap.info.ts +++ /dev/null @@ -1,2433 +0,0 @@ -/// NOTE: This is an auto-generated file. -/// All modifications will be overwritten. -import { WrapManifest } from "@polywrap/wrap-manifest-types-js" - -export const manifest: WrapManifest = { - name: "Test", - type: "plugin", - version: "0.1", - abi: { - "enumTypes": [ - { - "constants": [ - "STRING", - "BYTES" - ], - "kind": 8, - "type": "CustomEnum" - }, - { - "constants": [ - "for", - "in" - ], - "kind": 8, - "type": "while" - } - ], - "envType": { - "kind": 65536, - "properties": [ - { - "kind": 34, - "name": "prop", - "required": true, - "scalar": { - "kind": 4, - "name": "prop", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optProp", - "scalar": { - "kind": 4, - "name": "optProp", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "optMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "optMap", - "scalar": { - "kind": 4, - "name": "optMap", - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "optMap", - "type": "Int" - } - }, - "name": "optMap", - "type": "Map" - } - ], - "type": "Env" - }, - "importedEnumTypes": [ - { - "constants": [ - "STRING", - "BYTES" - ], - "kind": 520, - "namespace": "TestImport", - "nativeType": "Enum", - "type": "TestImport_Enum", - "uri": "testimport.uri.eth" - }, - { - "constants": [ - "STRING", - "BYTES" - ], - "kind": 520, - "namespace": "TestImport", - "nativeType": "Enum", - "type": "TestImport_Enum_Return", - "uri": "testimport.uri.eth" - } - ], - "importedEnvTypes": [ - { - "kind": 524288, - "namespace": "TestImport", - "nativeType": "Env", - "properties": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "TestImport_AnotherObject" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "TestImport_AnotherObject" - }, - "type": "TestImport_AnotherObject" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[TestImport_AnotherObject]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[TestImport_AnotherObject]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "optEnum", - "type": "TestImport_Enum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - } - ], - "type": "TestImport_Env", - "uri": "testimport.uri.eth" - } - ], - "importedModuleTypes": [ - { - "isInterface": true, - "kind": 256, - "methods": [ - { - "arguments": [ - { - "kind": 34, - "name": "str", - "required": true, - "scalar": { - "kind": 4, - "name": "str", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optStr", - "scalar": { - "kind": 4, - "name": "optStr", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "u", - "required": true, - "scalar": { - "kind": 4, - "name": "u", - "required": true, - "type": "UInt" - }, - "type": "UInt" - }, - { - "kind": 34, - "name": "optU", - "scalar": { - "kind": 4, - "name": "optU", - "type": "UInt" - }, - "type": "UInt" - }, - { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "scalar": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "type": "[UInt]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "scalar": { - "kind": 4, - "name": "uArrayArray", - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - "kind": 34, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "TestImport_Object" - }, - "required": true, - "type": "TestImport_Object" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "TestImport_Object" - }, - "type": "TestImport_Object" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_Object" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_Object" - }, - "required": true, - "type": "[TestImport_Object]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[TestImport_Object]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_Object" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_Object" - }, - "type": "[TestImport_Object]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[TestImport_Object]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "optEnum", - "type": "TestImport_Enum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - } - ], - "env": { - "required": true - }, - "kind": 64, - "name": "importedMethod", - "required": true, - "return": { - "kind": 34, - "name": "importedMethod", - "object": { - "kind": 8192, - "name": "importedMethod", - "type": "TestImport_Object" - }, - "type": "TestImport_Object" - }, - "type": "Method" - }, - { - "arguments": [ - { - "array": { - "item": { - "kind": 4, - "name": "arg", - "required": true, - "type": "String" - }, - "kind": 18, - "name": "arg", - "required": true, - "scalar": { - "kind": 4, - "name": "arg", - "required": true, - "type": "String" - }, - "type": "[String]" - }, - "kind": 34, - "name": "arg", - "required": true, - "type": "[String]" - } - ], - "kind": 64, - "name": "anotherMethod", - "required": true, - "return": { - "kind": 34, - "name": "anotherMethod", - "required": true, - "scalar": { - "kind": 4, - "name": "anotherMethod", - "required": true, - "type": "Int32" - }, - "type": "Int32" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "arg", - "required": true, - "scalar": { - "kind": 4, - "name": "arg", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "kind": 64, - "name": "returnsArrayOfEnums", - "required": true, - "return": { - "array": { - "enum": { - "kind": 16384, - "name": "returnsArrayOfEnums", - "type": "TestImport_Enum_Return" - }, - "item": { - "kind": 16384, - "name": "returnsArrayOfEnums", - "type": "TestImport_Enum_Return" - }, - "kind": 18, - "name": "returnsArrayOfEnums", - "required": true, - "type": "[TestImport_Enum_Return]" - }, - "kind": 34, - "name": "returnsArrayOfEnums", - "required": true, - "type": "[TestImport_Enum_Return]" - }, - "type": "Method" - } - ], - "namespace": "TestImport", - "nativeType": "Module", - "type": "TestImport_Module", - "uri": "testimport.uri.eth" - } - ], - "importedObjectTypes": [ - { - "kind": 1025, - "namespace": "TestImport", - "nativeType": "Object", - "properties": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "TestImport_AnotherObject" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "TestImport_AnotherObject" - }, - "type": "TestImport_AnotherObject" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "TestImport_AnotherObject" - }, - "required": true, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[TestImport_AnotherObject]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "TestImport_AnotherObject" - }, - "type": "[TestImport_AnotherObject]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[TestImport_AnotherObject]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "TestImport_Enum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "TestImport_Enum" - }, - "kind": 34, - "name": "optEnum", - "type": "TestImport_Enum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[TestImport_Enum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "TestImport_Enum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[TestImport_Enum]" - } - ], - "type": "TestImport_Object", - "uri": "testimport.uri.eth" - }, - { - "kind": 1025, - "namespace": "TestImport", - "nativeType": "AnotherObject", - "properties": [ - { - "kind": 34, - "name": "prop", - "required": true, - "scalar": { - "kind": 4, - "name": "prop", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "type": "TestImport_AnotherObject", - "uri": "testimport.uri.eth" - } - ], - "interfaceTypes": [ - { - "capabilities": { - "getImplementations": { - "enabled": true - } - }, - "kind": 32768, - "namespace": "TestImport", - "nativeType": "Interface", - "type": "TestImport", - "uri": "testimport.uri.eth" - } - ], - "moduleType": { - "imports": [ - { - "type": "TestImport_Module" - }, - { - "type": "TestImport_Object" - }, - { - "type": "TestImport_AnotherObject" - }, - { - "type": "TestImport_Enum" - }, - { - "type": "TestImport_Enum_Return" - } - ], - "kind": 128, - "methods": [ - { - "arguments": [ - { - "kind": 34, - "name": "str", - "required": true, - "scalar": { - "kind": 4, - "name": "str", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optStr", - "scalar": { - "kind": 4, - "name": "optStr", - "type": "String" - }, - "type": "String" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "CustomEnum" - }, - "kind": 34, - "name": "optEnum", - "type": "CustomEnum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "map", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "map", - "required": true, - "scalar": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - } - }, - "name": "map", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - }, - "key": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArr", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - } - }, - "name": "mapOfArr", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "map": { - "key": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfMap", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - } - }, - "name": "mapOfMap", - "required": true, - "type": "Map>", - "value": { - "key": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfMap", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "mapOfMap", - "required": true, - "type": "Int" - } - } - }, - "name": "mapOfMap", - "required": true, - "type": "Map>" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfObj", - "object": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "Map", - "value": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - } - }, - "name": "mapOfObj", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "key": { - "kind": 4, - "name": "mapOfArrOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - } - }, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map" - } - ], - "kind": 64, - "name": "moduleMethod", - "required": true, - "return": { - "kind": 34, - "name": "moduleMethod", - "required": true, - "scalar": { - "kind": 4, - "name": "moduleMethod", - "required": true, - "type": "Int" - }, - "type": "Int" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "AnotherType" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[AnotherType]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[AnotherType]" - } - ], - "env": { - "required": true - }, - "kind": 64, - "name": "objectMethod", - "required": true, - "return": { - "kind": 34, - "name": "objectMethod", - "object": { - "kind": 8192, - "name": "objectMethod", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "AnotherType" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[AnotherType]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[AnotherType]" - } - ], - "env": { - "required": false - }, - "kind": 64, - "name": "optionalEnvMethod", - "required": true, - "return": { - "kind": 34, - "name": "optionalEnvMethod", - "object": { - "kind": 8192, - "name": "optionalEnvMethod", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - "type": "Method" - }, - { - "arguments": [ - { - "kind": 34, - "name": "if", - "object": { - "kind": 8192, - "name": "if", - "required": true, - "type": "else" - }, - "required": true, - "type": "else" - } - ], - "kind": 64, - "name": "if", - "required": true, - "return": { - "kind": 34, - "name": "if", - "object": { - "kind": 8192, - "name": "if", - "required": true, - "type": "else" - }, - "required": true, - "type": "else" - }, - "type": "Method" - } - ], - "type": "Module" - }, - "objectTypes": [ - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "str", - "required": true, - "scalar": { - "kind": 4, - "name": "str", - "required": true, - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "optStr", - "scalar": { - "kind": 4, - "name": "optStr", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "u", - "required": true, - "scalar": { - "kind": 4, - "name": "u", - "required": true, - "type": "UInt" - }, - "type": "UInt" - }, - { - "kind": 34, - "name": "optU", - "scalar": { - "kind": 4, - "name": "optU", - "type": "UInt" - }, - "type": "UInt" - }, - { - "kind": 34, - "name": "u8", - "required": true, - "scalar": { - "kind": 4, - "name": "u8", - "required": true, - "type": "UInt8" - }, - "type": "UInt8" - }, - { - "kind": 34, - "name": "u16", - "required": true, - "scalar": { - "kind": 4, - "name": "u16", - "required": true, - "type": "UInt16" - }, - "type": "UInt16" - }, - { - "kind": 34, - "name": "u32", - "required": true, - "scalar": { - "kind": 4, - "name": "u32", - "required": true, - "type": "UInt32" - }, - "type": "UInt32" - }, - { - "kind": 34, - "name": "i", - "required": true, - "scalar": { - "kind": 4, - "name": "i", - "required": true, - "type": "Int" - }, - "type": "Int" - }, - { - "kind": 34, - "name": "i8", - "required": true, - "scalar": { - "kind": 4, - "name": "i8", - "required": true, - "type": "Int8" - }, - "type": "Int8" - }, - { - "kind": 34, - "name": "i16", - "required": true, - "scalar": { - "kind": 4, - "name": "i16", - "required": true, - "type": "Int16" - }, - "type": "Int16" - }, - { - "kind": 34, - "name": "i32", - "required": true, - "scalar": { - "kind": 4, - "name": "i32", - "required": true, - "type": "Int32" - }, - "type": "Int32" - }, - { - "kind": 34, - "name": "bigint", - "required": true, - "scalar": { - "kind": 4, - "name": "bigint", - "required": true, - "type": "BigInt" - }, - "type": "BigInt" - }, - { - "kind": 34, - "name": "optBigint", - "scalar": { - "kind": 4, - "name": "optBigint", - "type": "BigInt" - }, - "type": "BigInt" - }, - { - "kind": 34, - "name": "bignumber", - "required": true, - "scalar": { - "kind": 4, - "name": "bignumber", - "required": true, - "type": "BigNumber" - }, - "type": "BigNumber" - }, - { - "kind": 34, - "name": "optBignumber", - "scalar": { - "kind": 4, - "name": "optBignumber", - "type": "BigNumber" - }, - "type": "BigNumber" - }, - { - "kind": 34, - "name": "json", - "required": true, - "scalar": { - "kind": 4, - "name": "json", - "required": true, - "type": "JSON" - }, - "type": "JSON" - }, - { - "kind": 34, - "name": "optJson", - "scalar": { - "kind": 4, - "name": "optJson", - "type": "JSON" - }, - "type": "JSON" - }, - { - "kind": 34, - "name": "bytes", - "required": true, - "scalar": { - "kind": 4, - "name": "bytes", - "required": true, - "type": "Bytes" - }, - "type": "Bytes" - }, - { - "kind": 34, - "name": "optBytes", - "scalar": { - "kind": 4, - "name": "optBytes", - "type": "Bytes" - }, - "type": "Bytes" - }, - { - "kind": 34, - "name": "boolean", - "required": true, - "scalar": { - "kind": 4, - "name": "boolean", - "required": true, - "type": "Boolean" - }, - "type": "Boolean" - }, - { - "kind": 34, - "name": "optBoolean", - "scalar": { - "kind": 4, - "name": "optBoolean", - "type": "Boolean" - }, - "type": "Boolean" - }, - { - "array": { - "item": { - "kind": 4, - "name": "u_array", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "u_array", - "required": true, - "scalar": { - "kind": 4, - "name": "u_array", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 34, - "name": "u_array", - "required": true, - "type": "[UInt]" - }, - { - "array": { - "item": { - "kind": 4, - "name": "uOpt_array", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "uOpt_array", - "scalar": { - "kind": 4, - "name": "uOpt_array", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 34, - "name": "uOpt_array", - "type": "[UInt]" - }, - { - "array": { - "item": { - "kind": 4, - "name": "_opt_uOptArray", - "type": "UInt" - }, - "kind": 18, - "name": "_opt_uOptArray", - "scalar": { - "kind": 4, - "name": "_opt_uOptArray", - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 34, - "name": "_opt_uOptArray", - "type": "[UInt]" - }, - { - "array": { - "item": { - "kind": 4, - "name": "optStrOptArray", - "type": "String" - }, - "kind": 18, - "name": "optStrOptArray", - "scalar": { - "kind": 4, - "name": "optStrOptArray", - "type": "String" - }, - "type": "[String]" - }, - "kind": 34, - "name": "optStrOptArray", - "type": "[String]" - }, - { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayArray", - "required": true, - "type": "UInt" - }, - "type": "[UInt]" - }, - "kind": 18, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - "kind": 34, - "name": "uArrayArray", - "required": true, - "type": "[[UInt]]" - }, - { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "kind": 18, - "name": "uOptArrayOptArray", - "scalar": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "kind": 18, - "name": "uOptArrayOptArray", - "scalar": { - "kind": 4, - "name": "uOptArrayOptArray", - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "uOptArrayOptArray", - "required": true, - "type": "[[UInt32]]" - }, - "kind": 34, - "name": "uOptArrayOptArray", - "required": true, - "type": "[[UInt32]]" - }, - { - "array": { - "array": { - "array": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "type": "[[UInt32]]" - }, - "item": { - "array": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "scalar": { - "kind": 4, - "name": "uArrayOptArrayArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "type": "[[UInt32]]" - }, - "kind": 18, - "name": "uArrayOptArrayArray", - "required": true, - "type": "[[[UInt32]]]" - }, - "kind": 34, - "name": "uArrayOptArrayArray", - "required": true, - "type": "[[[UInt32]]]" - }, - { - "array": { - "array": { - "array": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "item": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "kind": 18, - "name": "crazyArray", - "type": "[[[UInt32]]]" - }, - "item": { - "array": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "item": { - "array": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "item": { - "item": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "kind": 18, - "name": "crazyArray", - "scalar": { - "kind": 4, - "name": "crazyArray", - "required": true, - "type": "UInt32" - }, - "type": "[UInt32]" - }, - "kind": 18, - "name": "crazyArray", - "required": true, - "type": "[[UInt32]]" - }, - "kind": 18, - "name": "crazyArray", - "type": "[[[UInt32]]]" - }, - "kind": 18, - "name": "crazyArray", - "type": "[[[[UInt32]]]]" - }, - "kind": 34, - "name": "crazyArray", - "type": "[[[[UInt32]]]]" - }, - { - "kind": 34, - "name": "object", - "object": { - "kind": 8192, - "name": "object", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "AnotherType" - }, - { - "kind": 34, - "name": "optObject", - "object": { - "kind": 8192, - "name": "optObject", - "type": "AnotherType" - }, - "type": "AnotherType" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "objectArray", - "object": { - "kind": 8192, - "name": "objectArray", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "objectArray", - "required": true, - "type": "[AnotherType]" - }, - { - "array": { - "item": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "kind": 18, - "name": "optObjectArray", - "object": { - "kind": 8192, - "name": "optObjectArray", - "type": "AnotherType" - }, - "type": "[AnotherType]" - }, - "kind": 34, - "name": "optObjectArray", - "type": "[AnotherType]" - }, - { - "enum": { - "kind": 16384, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - "kind": 34, - "name": "en", - "required": true, - "type": "CustomEnum" - }, - { - "enum": { - "kind": 16384, - "name": "optEnum", - "type": "CustomEnum" - }, - "kind": 34, - "name": "optEnum", - "type": "CustomEnum" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "enumArray", - "required": true, - "type": "CustomEnum" - }, - "kind": 18, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "enumArray", - "required": true, - "type": "[CustomEnum]" - }, - { - "array": { - "enum": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "item": { - "kind": 16384, - "name": "optEnumArray", - "type": "CustomEnum" - }, - "kind": 18, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - "kind": 34, - "name": "optEnumArray", - "type": "[CustomEnum]" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "map", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "map", - "required": true, - "scalar": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - }, - "type": "Map", - "value": { - "kind": 4, - "name": "map", - "required": true, - "type": "Int" - } - }, - "name": "map", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - }, - "key": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArr", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "kind": 18, - "name": "mapOfArr", - "required": true, - "scalar": { - "kind": 4, - "name": "mapOfArr", - "required": true, - "type": "Int" - }, - "type": "[Int]" - } - }, - "name": "mapOfArr", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfObj", - "object": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "Map", - "value": { - "kind": 8192, - "name": "mapOfObj", - "required": true, - "type": "AnotherType" - } - }, - "name": "mapOfObj", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "array": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - }, - "key": { - "kind": 4, - "name": "mapOfArrOfObj", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map", - "value": { - "item": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "kind": 18, - "name": "mapOfArrOfObj", - "object": { - "kind": 8192, - "name": "mapOfArrOfObj", - "required": true, - "type": "AnotherType" - }, - "required": true, - "type": "[AnotherType]" - } - }, - "name": "mapOfArrOfObj", - "required": true, - "type": "Map" - }, - { - "kind": 34, - "map": { - "key": { - "kind": 4, - "name": "mapCustomValue", - "required": true, - "type": "String" - }, - "kind": 262146, - "name": "mapCustomValue", - "object": { - "kind": 8192, - "name": "mapCustomValue", - "type": "CustomMapValue" - }, - "required": true, - "type": "Map", - "value": { - "kind": 8192, - "name": "mapCustomValue", - "type": "CustomMapValue" - } - }, - "name": "mapCustomValue", - "required": true, - "type": "Map" - } - ], - "type": "CustomType" - }, - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "prop", - "scalar": { - "kind": 4, - "name": "prop", - "type": "String" - }, - "type": "String" - }, - { - "kind": 34, - "name": "circular", - "object": { - "kind": 8192, - "name": "circular", - "type": "CustomType" - }, - "type": "CustomType" - }, - { - "kind": 34, - "name": "const", - "scalar": { - "kind": 4, - "name": "const", - "type": "String" - }, - "type": "String" - } - ], - "type": "AnotherType" - }, - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "foo", - "required": true, - "scalar": { - "kind": 4, - "name": "foo", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "type": "CustomMapValue" - }, - { - "kind": 1, - "properties": [ - { - "kind": 34, - "name": "else", - "required": true, - "scalar": { - "kind": 4, - "name": "else", - "required": true, - "type": "String" - }, - "type": "String" - } - ], - "type": "else" - } - ], - "version": "0.1" -} -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/index.ts deleted file mode 100644 index 7d2d0c8391..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serializeAnotherType, - deserializeAnotherType, - writeAnotherType, - readAnotherType -} from "./serialization"; -import * as Types from ".."; - -export class AnotherType { - prop: string | null; - circular: Types.CustomType | null; - _const: string | null; - - static toBuffer(type: AnotherType): ArrayBuffer { - return serializeAnotherType(type); - } - - static fromBuffer(buffer: ArrayBuffer): AnotherType { - return deserializeAnotherType(buffer); - } - - static write(writer: Write, type: AnotherType): void { - writeAnotherType(writer, type); - } - - static read(reader: Read): AnotherType { - return readAnotherType(reader); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/serialization.ts deleted file mode 100644 index 9ed99bc7a3..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/AnotherType/serialization.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import { AnotherType } from "./"; -import * as Types from ".."; - -export function serializeAnotherType(type: AnotherType): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) object-type: AnotherType"); - const sizer = new WriteSizer(sizerContext); - writeAnotherType(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) object-type: AnotherType"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeAnotherType(encoder, type); - return buffer; -} - -export function writeAnotherType(writer: Write, type: AnotherType): void { - writer.writeMapLength(3); - writer.context().push("prop", "string | null", "writing property"); - writer.writeString("prop"); - writer.writeOptionalString(type.prop); - writer.context().pop(); - writer.context().push("circular", "Types.CustomType | null", "writing property"); - writer.writeString("circular"); - if (type.circular) { - Types.CustomType.write(writer, type.circular as Types.CustomType); - } else { - writer.writeNil(); - } - writer.context().pop(); - writer.context().push("const", "string | null", "writing property"); - writer.writeString("const"); - writer.writeOptionalString(type._const); - writer.context().pop(); -} - -export function deserializeAnotherType(buffer: ArrayBuffer): AnotherType { - const context: Context = new Context("Deserializing object-type AnotherType"); - const reader = new ReadDecoder(buffer, context); - return readAnotherType(reader); -} - -export function readAnotherType(reader: Read): AnotherType { - let numFields = reader.readMapLength(); - - let _prop: string | null = null; - let _circular: Types.CustomType | null = null; - let _const: string | null = null; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "prop") { - reader.context().push(field, "string | null", "type found, reading property"); - _prop = reader.readOptionalString(); - reader.context().pop(); - } - else if (field == "circular") { - reader.context().push(field, "Types.CustomType | null", "type found, reading property"); - let object: Types.CustomType | null = null; - if (!reader.isNextNil()) { - object = Types.CustomType.read(reader); - } - _circular = object; - reader.context().pop(); - } - else if (field == "const") { - reader.context().push(field, "string | null", "type found, reading property"); - _const = reader.readOptionalString(); - reader.context().pop(); - } - reader.context().pop(); - } - - - return { - prop: _prop, - circular: _circular, - _const: _const - }; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomEnum/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomEnum/index.ts deleted file mode 100644 index 27c57a440b..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomEnum/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -export enum CustomEnum { - STRING, - BYTES, - _MAX_ -} - -export function sanitizeCustomEnumValue(value: i32): void { - const valid = value >= 0 && value < CustomEnum._MAX_; - if (!valid) { - throw new Error("Invalid value for enum 'CustomEnum': " + value.toString()); - } -} - -export function getCustomEnumValue(key: string): CustomEnum { - if (key == "STRING") { - return CustomEnum.STRING; - } - if (key == "BYTES") { - return CustomEnum.BYTES; - } - - throw new Error("Invalid key for enum 'CustomEnum': " + key); -} - -export function getCustomEnumKey(value: CustomEnum): string { - sanitizeCustomEnumValue(value); - - switch (value) { - case CustomEnum.STRING: return "STRING"; - case CustomEnum.BYTES: return "BYTES"; - default: - throw new Error("Invalid value for enum 'CustomEnum': " + value.toString()); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomMapValue/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomMapValue/index.ts deleted file mode 100644 index 4162a95785..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomMapValue/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serializeCustomMapValue, - deserializeCustomMapValue, - writeCustomMapValue, - readCustomMapValue -} from "./serialization"; -import * as Types from ".."; - -export class CustomMapValue { - foo: string; - - static toBuffer(type: CustomMapValue): ArrayBuffer { - return serializeCustomMapValue(type); - } - - static fromBuffer(buffer: ArrayBuffer): CustomMapValue { - return deserializeCustomMapValue(buffer); - } - - static write(writer: Write, type: CustomMapValue): void { - writeCustomMapValue(writer, type); - } - - static read(reader: Read): CustomMapValue { - return readCustomMapValue(reader); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomMapValue/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomMapValue/serialization.ts deleted file mode 100644 index d3f1ee9fb8..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomMapValue/serialization.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import { CustomMapValue } from "./"; -import * as Types from ".."; - -export function serializeCustomMapValue(type: CustomMapValue): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) object-type: CustomMapValue"); - const sizer = new WriteSizer(sizerContext); - writeCustomMapValue(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) object-type: CustomMapValue"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeCustomMapValue(encoder, type); - return buffer; -} - -export function writeCustomMapValue(writer: Write, type: CustomMapValue): void { - writer.writeMapLength(1); - writer.context().push("foo", "string", "writing property"); - writer.writeString("foo"); - writer.writeString(type.foo); - writer.context().pop(); -} - -export function deserializeCustomMapValue(buffer: ArrayBuffer): CustomMapValue { - const context: Context = new Context("Deserializing object-type CustomMapValue"); - const reader = new ReadDecoder(buffer, context); - return readCustomMapValue(reader); -} - -export function readCustomMapValue(reader: Read): CustomMapValue { - let numFields = reader.readMapLength(); - - let _foo: string = ""; - let _fooSet: bool = false; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "foo") { - reader.context().push(field, "string", "type found, reading property"); - _foo = reader.readString(); - _fooSet = true; - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_fooSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'foo: String'")); - } - - return { - foo: _foo - }; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/index.ts deleted file mode 100644 index 3a0d39079e..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/index.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serializeCustomType, - deserializeCustomType, - writeCustomType, - readCustomType -} from "./serialization"; -import * as Types from ".."; - -export class CustomType { - str: string; - optStr: string | null; - u: u32; - optU: Box | null; - _u8: u8; - _u16: u16; - _u32: u32; - i: i32; - _i8: i8; - _i16: i16; - _i32: i32; - bigint: BigInt; - optBigint: BigInt | null; - bignumber: BigNumber; - optBignumber: BigNumber | null; - json: JSON.Value; - optJson: JSON.Value | null; - bytes: ArrayBuffer; - optBytes: ArrayBuffer | null; - _boolean: bool; - optBoolean: Box | null; - u_array: Array; - uOpt_array: Array | null; - _opt_uOptArray: Array | null> | null; - optStrOptArray: Array | null; - uArrayArray: Array>; - uOptArrayOptArray: Array | null> | null>; - uArrayOptArrayArray: Array> | null>; - crazyArray: Array | null>> | null> | null; - object: Types.AnotherType; - optObject: Types.AnotherType | null; - objectArray: Array; - optObjectArray: Array | null; - en: Types.CustomEnum; - optEnum: Box | null; - enumArray: Array; - optEnumArray: Array | null> | null; - map: Map; - mapOfArr: Map>; - mapOfObj: Map; - mapOfArrOfObj: Map>; - mapCustomValue: Map; - - static toBuffer(type: CustomType): ArrayBuffer { - return serializeCustomType(type); - } - - static fromBuffer(buffer: ArrayBuffer): CustomType { - return deserializeCustomType(buffer); - } - - static write(writer: Write, type: CustomType): void { - writeCustomType(writer, type); - } - - static read(reader: Read): CustomType { - return readCustomType(reader); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/serialization.ts deleted file mode 100644 index fa047d5f7d..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/CustomType/serialization.ts +++ /dev/null @@ -1,845 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import { CustomType } from "./"; -import * as Types from ".."; - -export function serializeCustomType(type: CustomType): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) object-type: CustomType"); - const sizer = new WriteSizer(sizerContext); - writeCustomType(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) object-type: CustomType"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeCustomType(encoder, type); - return buffer; -} - -export function writeCustomType(writer: Write, type: CustomType): void { - writer.writeMapLength(42); - writer.context().push("str", "string", "writing property"); - writer.writeString("str"); - writer.writeString(type.str); - writer.context().pop(); - writer.context().push("optStr", "string | null", "writing property"); - writer.writeString("optStr"); - writer.writeOptionalString(type.optStr); - writer.context().pop(); - writer.context().push("u", "u32", "writing property"); - writer.writeString("u"); - writer.writeUInt32(type.u); - writer.context().pop(); - writer.context().push("optU", "Box | null", "writing property"); - writer.writeString("optU"); - writer.writeOptionalUInt32(type.optU); - writer.context().pop(); - writer.context().push("u8", "u8", "writing property"); - writer.writeString("u8"); - writer.writeUInt8(type._u8); - writer.context().pop(); - writer.context().push("u16", "u16", "writing property"); - writer.writeString("u16"); - writer.writeUInt16(type._u16); - writer.context().pop(); - writer.context().push("u32", "u32", "writing property"); - writer.writeString("u32"); - writer.writeUInt32(type._u32); - writer.context().pop(); - writer.context().push("i", "i32", "writing property"); - writer.writeString("i"); - writer.writeInt32(type.i); - writer.context().pop(); - writer.context().push("i8", "i8", "writing property"); - writer.writeString("i8"); - writer.writeInt8(type._i8); - writer.context().pop(); - writer.context().push("i16", "i16", "writing property"); - writer.writeString("i16"); - writer.writeInt16(type._i16); - writer.context().pop(); - writer.context().push("i32", "i32", "writing property"); - writer.writeString("i32"); - writer.writeInt32(type._i32); - writer.context().pop(); - writer.context().push("bigint", "BigInt", "writing property"); - writer.writeString("bigint"); - writer.writeBigInt(type.bigint); - writer.context().pop(); - writer.context().push("optBigint", "BigInt | null", "writing property"); - writer.writeString("optBigint"); - writer.writeOptionalBigInt(type.optBigint); - writer.context().pop(); - writer.context().push("bignumber", "BigNumber", "writing property"); - writer.writeString("bignumber"); - writer.writeBigNumber(type.bignumber); - writer.context().pop(); - writer.context().push("optBignumber", "BigNumber | null", "writing property"); - writer.writeString("optBignumber"); - writer.writeOptionalBigNumber(type.optBignumber); - writer.context().pop(); - writer.context().push("json", "JSON.Value", "writing property"); - writer.writeString("json"); - writer.writeJSON(type.json); - writer.context().pop(); - writer.context().push("optJson", "JSON.Value | null", "writing property"); - writer.writeString("optJson"); - writer.writeOptionalJSON(type.optJson); - writer.context().pop(); - writer.context().push("bytes", "ArrayBuffer", "writing property"); - writer.writeString("bytes"); - writer.writeBytes(type.bytes); - writer.context().pop(); - writer.context().push("optBytes", "ArrayBuffer | null", "writing property"); - writer.writeString("optBytes"); - writer.writeOptionalBytes(type.optBytes); - writer.context().pop(); - writer.context().push("boolean", "bool", "writing property"); - writer.writeString("boolean"); - writer.writeBool(type._boolean); - writer.context().pop(); - writer.context().push("optBoolean", "Box | null", "writing property"); - writer.writeString("optBoolean"); - writer.writeOptionalBool(type.optBoolean); - writer.context().pop(); - writer.context().push("u_array", "Array", "writing property"); - writer.writeString("u_array"); - writer.writeArray(type.u_array, (writer: Write, item: u32): void => { - writer.writeUInt32(item); - }); - writer.context().pop(); - writer.context().push("uOpt_array", "Array | null", "writing property"); - writer.writeString("uOpt_array"); - writer.writeOptionalArray(type.uOpt_array, (writer: Write, item: u32): void => { - writer.writeUInt32(item); - }); - writer.context().pop(); - writer.context().push("_opt_uOptArray", "Array | null> | null", "writing property"); - writer.writeString("_opt_uOptArray"); - writer.writeOptionalArray(type._opt_uOptArray, (writer: Write, item: Box | null): void => { - writer.writeOptionalUInt32(item); - }); - writer.context().pop(); - writer.context().push("optStrOptArray", "Array | null", "writing property"); - writer.writeString("optStrOptArray"); - writer.writeOptionalArray(type.optStrOptArray, (writer: Write, item: string | null): void => { - writer.writeOptionalString(item); - }); - writer.context().pop(); - writer.context().push("uArrayArray", "Array>", "writing property"); - writer.writeString("uArrayArray"); - writer.writeArray(type.uArrayArray, (writer: Write, item: Array): void => { - writer.writeArray(item, (writer: Write, item: u32): void => { - writer.writeUInt32(item); - }); - }); - writer.context().pop(); - writer.context().push("uOptArrayOptArray", "Array | null> | null>", "writing property"); - writer.writeString("uOptArrayOptArray"); - writer.writeArray(type.uOptArrayOptArray, (writer: Write, item: Array | null> | null): void => { - writer.writeOptionalArray(item, (writer: Write, item: Box | null): void => { - writer.writeOptionalUInt32(item); - }); - }); - writer.context().pop(); - writer.context().push("uArrayOptArrayArray", "Array> | null>", "writing property"); - writer.writeString("uArrayOptArrayArray"); - writer.writeArray(type.uArrayOptArrayArray, (writer: Write, item: Array> | null): void => { - writer.writeOptionalArray(item, (writer: Write, item: Array): void => { - writer.writeArray(item, (writer: Write, item: u32): void => { - writer.writeUInt32(item); - }); - }); - }); - writer.context().pop(); - writer.context().push("crazyArray", "Array | null>> | null> | null", "writing property"); - writer.writeString("crazyArray"); - writer.writeOptionalArray(type.crazyArray, (writer: Write, item: Array | null>> | null): void => { - writer.writeOptionalArray(item, (writer: Write, item: Array | null>): void => { - writer.writeArray(item, (writer: Write, item: Array | null): void => { - writer.writeOptionalArray(item, (writer: Write, item: u32): void => { - writer.writeUInt32(item); - }); - }); - }); - }); - writer.context().pop(); - writer.context().push("object", "Types.AnotherType", "writing property"); - writer.writeString("object"); - Types.AnotherType.write(writer, type.object); - writer.context().pop(); - writer.context().push("optObject", "Types.AnotherType | null", "writing property"); - writer.writeString("optObject"); - if (type.optObject) { - Types.AnotherType.write(writer, type.optObject as Types.AnotherType); - } else { - writer.writeNil(); - } - writer.context().pop(); - writer.context().push("objectArray", "Array", "writing property"); - writer.writeString("objectArray"); - writer.writeArray(type.objectArray, (writer: Write, item: Types.AnotherType): void => { - Types.AnotherType.write(writer, item); - }); - writer.context().pop(); - writer.context().push("optObjectArray", "Array | null", "writing property"); - writer.writeString("optObjectArray"); - writer.writeOptionalArray(type.optObjectArray, (writer: Write, item: Types.AnotherType | null): void => { - if (item) { - Types.AnotherType.write(writer, item as Types.AnotherType); - } else { - writer.writeNil(); - } - }); - writer.context().pop(); - writer.context().push("en", "Types.CustomEnum", "writing property"); - writer.writeString("en"); - writer.writeInt32(type.en); - writer.context().pop(); - writer.context().push("optEnum", "Box | null", "writing property"); - writer.writeString("optEnum"); - writer.writeOptionalInt32(type.optEnum); - writer.context().pop(); - writer.context().push("enumArray", "Array", "writing property"); - writer.writeString("enumArray"); - writer.writeArray(type.enumArray, (writer: Write, item: Types.CustomEnum): void => { - writer.writeInt32(item); - }); - writer.context().pop(); - writer.context().push("optEnumArray", "Array | null> | null", "writing property"); - writer.writeString("optEnumArray"); - writer.writeOptionalArray(type.optEnumArray, (writer: Write, item: Box | null): void => { - writer.writeOptionalInt32(item); - }); - writer.context().pop(); - writer.context().push("map", "Map", "writing property"); - writer.writeString("map"); - writer.writeExtGenericMap(type.map, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: i32): void => { - writer.writeInt32(value); - }); - writer.context().pop(); - writer.context().push("mapOfArr", "Map>", "writing property"); - writer.writeString("mapOfArr"); - writer.writeExtGenericMap(type.mapOfArr, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: Array): void => { - writer.writeArray(value, (writer: Write, item: i32): void => { - writer.writeInt32(item); - }); - }); - writer.context().pop(); - writer.context().push("mapOfObj", "Map", "writing property"); - writer.writeString("mapOfObj"); - writer.writeExtGenericMap(type.mapOfObj, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: Types.AnotherType): void => { - Types.AnotherType.write(writer, value); - }); - writer.context().pop(); - writer.context().push("mapOfArrOfObj", "Map>", "writing property"); - writer.writeString("mapOfArrOfObj"); - writer.writeExtGenericMap(type.mapOfArrOfObj, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: Array): void => { - writer.writeArray(value, (writer: Write, item: Types.AnotherType): void => { - Types.AnotherType.write(writer, item); - }); - }); - writer.context().pop(); - writer.context().push("mapCustomValue", "Map", "writing property"); - writer.writeString("mapCustomValue"); - writer.writeExtGenericMap(type.mapCustomValue, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: Types.CustomMapValue | null): void => { - if (value) { - Types.CustomMapValue.write(writer, value as Types.CustomMapValue); - } else { - writer.writeNil(); - } - }); - writer.context().pop(); -} - -export function deserializeCustomType(buffer: ArrayBuffer): CustomType { - const context: Context = new Context("Deserializing object-type CustomType"); - const reader = new ReadDecoder(buffer, context); - return readCustomType(reader); -} - -export function readCustomType(reader: Read): CustomType { - let numFields = reader.readMapLength(); - - let _str: string = ""; - let _strSet: bool = false; - let _optStr: string | null = null; - let _u: u32 = 0; - let _uSet: bool = false; - let _optU: Box | null = null; - let _u8: u8 = 0; - let _u8Set: bool = false; - let _u16: u16 = 0; - let _u16Set: bool = false; - let _u32: u32 = 0; - let _u32Set: bool = false; - let _i: i32 = 0; - let _iSet: bool = false; - let _i8: i8 = 0; - let _i8Set: bool = false; - let _i16: i16 = 0; - let _i16Set: bool = false; - let _i32: i32 = 0; - let _i32Set: bool = false; - let _bigint: BigInt = BigInt.fromUInt16(0); - let _bigintSet: bool = false; - let _optBigint: BigInt | null = null; - let _bignumber: BigNumber = new BigNumber(BigInt.fromUInt16(0), 0, 0); - let _bignumberSet: bool = false; - let _optBignumber: BigNumber | null = null; - let _json: JSON.Value = JSON.Value.Null(); - let _jsonSet: bool = false; - let _optJson: JSON.Value | null = null; - let _bytes: ArrayBuffer = new ArrayBuffer(0); - let _bytesSet: bool = false; - let _optBytes: ArrayBuffer | null = null; - let _boolean: bool = false; - let _booleanSet: bool = false; - let _optBoolean: Box | null = null; - let _u_array: Array = []; - let _u_arraySet: bool = false; - let _uOpt_array: Array | null = null; - let __opt_uOptArray: Array | null> | null = null; - let _optStrOptArray: Array | null = null; - let _uArrayArray: Array> = []; - let _uArrayArraySet: bool = false; - let _uOptArrayOptArray: Array | null> | null> = []; - let _uOptArrayOptArraySet: bool = false; - let _uArrayOptArrayArray: Array> | null> = []; - let _uArrayOptArrayArraySet: bool = false; - let _crazyArray: Array | null>> | null> | null = null; - let _object: Types.AnotherType | null = null; - let _objectSet: bool = false; - let _optObject: Types.AnotherType | null = null; - let _objectArray: Array = []; - let _objectArraySet: bool = false; - let _optObjectArray: Array | null = null; - let _en: Types.CustomEnum = 0; - let _enSet: bool = false; - let _optEnum: Box | null = null; - let _enumArray: Array = []; - let _enumArraySet: bool = false; - let _optEnumArray: Array | null> | null = null; - let _map: Map = new Map(); - let _mapSet: bool = false; - let _mapOfArr: Map> = new Map>(); - let _mapOfArrSet: bool = false; - let _mapOfObj: Map = new Map(); - let _mapOfObjSet: bool = false; - let _mapOfArrOfObj: Map> = new Map>(); - let _mapOfArrOfObjSet: bool = false; - let _mapCustomValue: Map = new Map(); - let _mapCustomValueSet: bool = false; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "str") { - reader.context().push(field, "string", "type found, reading property"); - _str = reader.readString(); - _strSet = true; - reader.context().pop(); - } - else if (field == "optStr") { - reader.context().push(field, "string | null", "type found, reading property"); - _optStr = reader.readOptionalString(); - reader.context().pop(); - } - else if (field == "u") { - reader.context().push(field, "u32", "type found, reading property"); - _u = reader.readUInt32(); - _uSet = true; - reader.context().pop(); - } - else if (field == "optU") { - reader.context().push(field, "Box | null", "type found, reading property"); - _optU = reader.readOptionalUInt32(); - reader.context().pop(); - } - else if (field == "u8") { - reader.context().push(field, "u8", "type found, reading property"); - _u8 = reader.readUInt8(); - _u8Set = true; - reader.context().pop(); - } - else if (field == "u16") { - reader.context().push(field, "u16", "type found, reading property"); - _u16 = reader.readUInt16(); - _u16Set = true; - reader.context().pop(); - } - else if (field == "u32") { - reader.context().push(field, "u32", "type found, reading property"); - _u32 = reader.readUInt32(); - _u32Set = true; - reader.context().pop(); - } - else if (field == "i") { - reader.context().push(field, "i32", "type found, reading property"); - _i = reader.readInt32(); - _iSet = true; - reader.context().pop(); - } - else if (field == "i8") { - reader.context().push(field, "i8", "type found, reading property"); - _i8 = reader.readInt8(); - _i8Set = true; - reader.context().pop(); - } - else if (field == "i16") { - reader.context().push(field, "i16", "type found, reading property"); - _i16 = reader.readInt16(); - _i16Set = true; - reader.context().pop(); - } - else if (field == "i32") { - reader.context().push(field, "i32", "type found, reading property"); - _i32 = reader.readInt32(); - _i32Set = true; - reader.context().pop(); - } - else if (field == "bigint") { - reader.context().push(field, "BigInt", "type found, reading property"); - _bigint = reader.readBigInt(); - _bigintSet = true; - reader.context().pop(); - } - else if (field == "optBigint") { - reader.context().push(field, "BigInt | null", "type found, reading property"); - _optBigint = reader.readOptionalBigInt(); - reader.context().pop(); - } - else if (field == "bignumber") { - reader.context().push(field, "BigNumber", "type found, reading property"); - _bignumber = reader.readBigNumber(); - _bignumberSet = true; - reader.context().pop(); - } - else if (field == "optBignumber") { - reader.context().push(field, "BigNumber | null", "type found, reading property"); - _optBignumber = reader.readOptionalBigNumber(); - reader.context().pop(); - } - else if (field == "json") { - reader.context().push(field, "JSON.Value", "type found, reading property"); - _json = reader.readJSON(); - _jsonSet = true; - reader.context().pop(); - } - else if (field == "optJson") { - reader.context().push(field, "JSON.Value | null", "type found, reading property"); - _optJson = reader.readOptionalJSON(); - reader.context().pop(); - } - else if (field == "bytes") { - reader.context().push(field, "ArrayBuffer", "type found, reading property"); - _bytes = reader.readBytes(); - _bytesSet = true; - reader.context().pop(); - } - else if (field == "optBytes") { - reader.context().push(field, "ArrayBuffer | null", "type found, reading property"); - _optBytes = reader.readOptionalBytes(); - reader.context().pop(); - } - else if (field == "boolean") { - reader.context().push(field, "bool", "type found, reading property"); - _boolean = reader.readBool(); - _booleanSet = true; - reader.context().pop(); - } - else if (field == "optBoolean") { - reader.context().push(field, "Box | null", "type found, reading property"); - _optBoolean = reader.readOptionalBool(); - reader.context().pop(); - } - else if (field == "u_array") { - reader.context().push(field, "Array", "type found, reading property"); - _u_array = reader.readArray((reader: Read): u32 => { - return reader.readUInt32(); - }); - _u_arraySet = true; - reader.context().pop(); - } - else if (field == "uOpt_array") { - reader.context().push(field, "Array | null", "type found, reading property"); - _uOpt_array = reader.readOptionalArray((reader: Read): u32 => { - return reader.readUInt32(); - }); - reader.context().pop(); - } - else if (field == "_opt_uOptArray") { - reader.context().push(field, "Array | null> | null", "type found, reading property"); - __opt_uOptArray = reader.readOptionalArray((reader: Read): Box | null => { - return reader.readOptionalUInt32(); - }); - reader.context().pop(); - } - else if (field == "optStrOptArray") { - reader.context().push(field, "Array | null", "type found, reading property"); - _optStrOptArray = reader.readOptionalArray((reader: Read): string | null => { - return reader.readOptionalString(); - }); - reader.context().pop(); - } - else if (field == "uArrayArray") { - reader.context().push(field, "Array>", "type found, reading property"); - _uArrayArray = reader.readArray((reader: Read): Array => { - return reader.readArray((reader: Read): u32 => { - return reader.readUInt32(); - }); - }); - _uArrayArraySet = true; - reader.context().pop(); - } - else if (field == "uOptArrayOptArray") { - reader.context().push(field, "Array | null> | null>", "type found, reading property"); - _uOptArrayOptArray = reader.readArray((reader: Read): Array | null> | null => { - return reader.readOptionalArray((reader: Read): Box | null => { - return reader.readOptionalUInt32(); - }); - }); - _uOptArrayOptArraySet = true; - reader.context().pop(); - } - else if (field == "uArrayOptArrayArray") { - reader.context().push(field, "Array> | null>", "type found, reading property"); - _uArrayOptArrayArray = reader.readArray((reader: Read): Array> | null => { - return reader.readOptionalArray((reader: Read): Array => { - return reader.readArray((reader: Read): u32 => { - return reader.readUInt32(); - }); - }); - }); - _uArrayOptArrayArraySet = true; - reader.context().pop(); - } - else if (field == "crazyArray") { - reader.context().push(field, "Array | null>> | null> | null", "type found, reading property"); - _crazyArray = reader.readOptionalArray((reader: Read): Array | null>> | null => { - return reader.readOptionalArray((reader: Read): Array | null> => { - return reader.readArray((reader: Read): Array | null => { - return reader.readOptionalArray((reader: Read): u32 => { - return reader.readUInt32(); - }); - }); - }); - }); - reader.context().pop(); - } - else if (field == "object") { - reader.context().push(field, "Types.AnotherType", "type found, reading property"); - const object = Types.AnotherType.read(reader); - _object = object; - _objectSet = true; - reader.context().pop(); - } - else if (field == "optObject") { - reader.context().push(field, "Types.AnotherType | null", "type found, reading property"); - let object: Types.AnotherType | null = null; - if (!reader.isNextNil()) { - object = Types.AnotherType.read(reader); - } - _optObject = object; - reader.context().pop(); - } - else if (field == "objectArray") { - reader.context().push(field, "Array", "type found, reading property"); - _objectArray = reader.readArray((reader: Read): Types.AnotherType => { - const object = Types.AnotherType.read(reader); - return object; - }); - _objectArraySet = true; - reader.context().pop(); - } - else if (field == "optObjectArray") { - reader.context().push(field, "Array | null", "type found, reading property"); - _optObjectArray = reader.readOptionalArray((reader: Read): Types.AnotherType | null => { - let object: Types.AnotherType | null = null; - if (!reader.isNextNil()) { - object = Types.AnotherType.read(reader); - } - return object; - }); - reader.context().pop(); - } - else if (field == "en") { - reader.context().push(field, "Types.CustomEnum", "type found, reading property"); - let value: Types.CustomEnum; - if (reader.isNextString()) { - value = Types.getCustomEnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeCustomEnumValue(value); - } - _en = value; - _enSet = true; - reader.context().pop(); - } - else if (field == "optEnum") { - reader.context().push(field, "Box | null", "type found, reading property"); - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getCustomEnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeCustomEnumValue(value.unwrap()); - } - } else { - value = null; - } - _optEnum = value; - reader.context().pop(); - } - else if (field == "enumArray") { - reader.context().push(field, "Array", "type found, reading property"); - _enumArray = reader.readArray((reader: Read): Types.CustomEnum => { - let value: Types.CustomEnum; - if (reader.isNextString()) { - value = Types.getCustomEnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeCustomEnumValue(value); - } - return value; - }); - _enumArraySet = true; - reader.context().pop(); - } - else if (field == "optEnumArray") { - reader.context().push(field, "Array | null> | null", "type found, reading property"); - _optEnumArray = reader.readOptionalArray((reader: Read): Box | null => { - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getCustomEnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeCustomEnumValue(value.unwrap()); - } - } else { - value = null; - } - return value; - }); - reader.context().pop(); - } - else if (field == "map") { - reader.context().push(field, "Map", "type found, reading property"); - _map = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): i32 => { - return reader.readInt32(); - }); - _mapSet = true; - reader.context().pop(); - } - else if (field == "mapOfArr") { - reader.context().push(field, "Map>", "type found, reading property"); - _mapOfArr = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): Array => { - return reader.readArray((reader: Read): i32 => { - return reader.readInt32(); - }); - }); - _mapOfArrSet = true; - reader.context().pop(); - } - else if (field == "mapOfObj") { - reader.context().push(field, "Map", "type found, reading property"); - _mapOfObj = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): Types.AnotherType => { - const object = Types.AnotherType.read(reader); - return object; - }); - _mapOfObjSet = true; - reader.context().pop(); - } - else if (field == "mapOfArrOfObj") { - reader.context().push(field, "Map>", "type found, reading property"); - _mapOfArrOfObj = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): Array => { - return reader.readArray((reader: Read): Types.AnotherType => { - const object = Types.AnotherType.read(reader); - return object; - }); - }); - _mapOfArrOfObjSet = true; - reader.context().pop(); - } - else if (field == "mapCustomValue") { - reader.context().push(field, "Map", "type found, reading property"); - _mapCustomValue = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): Types.CustomMapValue | null => { - let object: Types.CustomMapValue | null = null; - if (!reader.isNextNil()) { - object = Types.CustomMapValue.read(reader); - } - return object; - }); - _mapCustomValueSet = true; - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_strSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'str: String'")); - } - if (!_uSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'u: UInt'")); - } - if (!_u8Set) { - throw new Error(reader.context().printWithContext("Missing required property: 'u8: UInt8'")); - } - if (!_u16Set) { - throw new Error(reader.context().printWithContext("Missing required property: 'u16: UInt16'")); - } - if (!_u32Set) { - throw new Error(reader.context().printWithContext("Missing required property: 'u32: UInt32'")); - } - if (!_iSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'i: Int'")); - } - if (!_i8Set) { - throw new Error(reader.context().printWithContext("Missing required property: 'i8: Int8'")); - } - if (!_i16Set) { - throw new Error(reader.context().printWithContext("Missing required property: 'i16: Int16'")); - } - if (!_i32Set) { - throw new Error(reader.context().printWithContext("Missing required property: 'i32: Int32'")); - } - if (!_bigintSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'bigint: BigInt'")); - } - if (!_bignumberSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'bignumber: BigNumber'")); - } - if (!_jsonSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'json: JSON'")); - } - if (!_bytesSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'bytes: Bytes'")); - } - if (!_booleanSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'boolean: Boolean'")); - } - if (!_u_arraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'u_array: [UInt]'")); - } - if (!_uArrayArraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'uArrayArray: [[UInt]]'")); - } - if (!_uOptArrayOptArraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'uOptArrayOptArray: [[UInt32]]'")); - } - if (!_uArrayOptArrayArraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'uArrayOptArrayArray: [[[UInt32]]]'")); - } - if (!_object || !_objectSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'object: AnotherType'")); - } - if (!_objectArraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'objectArray: [AnotherType]'")); - } - if (!_enSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'en: CustomEnum'")); - } - if (!_enumArraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'enumArray: [CustomEnum]'")); - } - if (!_mapSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'map: Map'")); - } - if (!_mapOfArrSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'mapOfArr: Map'")); - } - if (!_mapOfObjSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'mapOfObj: Map'")); - } - if (!_mapOfArrOfObjSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'mapOfArrOfObj: Map'")); - } - if (!_mapCustomValueSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'mapCustomValue: Map'")); - } - - return { - str: _str, - optStr: _optStr, - u: _u, - optU: _optU, - _u8: _u8, - _u16: _u16, - _u32: _u32, - i: _i, - _i8: _i8, - _i16: _i16, - _i32: _i32, - bigint: _bigint, - optBigint: _optBigint, - bignumber: _bignumber, - optBignumber: _optBignumber, - json: _json, - optJson: _optJson, - bytes: _bytes, - optBytes: _optBytes, - _boolean: _boolean, - optBoolean: _optBoolean, - u_array: _u_array, - uOpt_array: _uOpt_array, - _opt_uOptArray: __opt_uOptArray, - optStrOptArray: _optStrOptArray, - uArrayArray: _uArrayArray, - uOptArrayOptArray: _uOptArrayOptArray, - uArrayOptArrayArray: _uArrayOptArrayArray, - crazyArray: _crazyArray, - object: _object, - optObject: _optObject, - objectArray: _objectArray, - optObjectArray: _optObjectArray, - en: _en, - optEnum: _optEnum, - enumArray: _enumArray, - optEnumArray: _optEnumArray, - map: _map, - mapOfArr: _mapOfArr, - mapOfObj: _mapOfObj, - mapOfArrOfObj: _mapOfArrOfObj, - mapCustomValue: _mapCustomValue - }; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/index.ts deleted file mode 100644 index 6e9417c587..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serializeEnv, - deserializeEnv, - writeEnv, - readEnv -} from "./serialization"; -import * as Types from ".."; - -export class Env { - prop: string; - optProp: string | null; - optMap: Map | null> | null; - - static toBuffer(type: Env): ArrayBuffer { - return serializeEnv(type); - } - - static fromBuffer(buffer: ArrayBuffer): Env { - return deserializeEnv(buffer); - } - - static write(writer: Write, type: Env): void { - writeEnv(writer, type); - } - - static read(reader: Read): Env { - return readEnv(reader); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/serialization.ts deleted file mode 100644 index 84186a0ea1..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Env/serialization.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import { Env } from "./"; -import * as Types from ".."; - -export function serializeEnv(type: Env): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) env-type: Env"); - const sizer = new WriteSizer(sizerContext); - writeEnv(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) env-type: Env"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeEnv(encoder, type); - return buffer; -} - -export function writeEnv(writer: Write, type: Env): void { - writer.writeMapLength(3); - writer.context().push("prop", "string", "writing property"); - writer.writeString("prop"); - writer.writeString(type.prop); - writer.context().pop(); - writer.context().push("optProp", "string | null", "writing property"); - writer.writeString("optProp"); - writer.writeOptionalString(type.optProp); - writer.context().pop(); - writer.context().push("optMap", "Map | null> | null", "writing property"); - writer.writeString("optMap"); - writer.writeOptionalExtGenericMap(type.optMap, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: Box | null): void => { - writer.writeOptionalInt32(value); - }); - writer.context().pop(); -} - -export function deserializeEnv(buffer: ArrayBuffer): Env { - const context: Context = new Context("Deserializing env-type Env"); - const reader = new ReadDecoder(buffer, context); - return readEnv(reader); -} - -export function readEnv(reader: Read): Env { - let numFields = reader.readMapLength(); - - let _prop: string = ""; - let _propSet: bool = false; - let _optProp: string | null = null; - let _optMap: Map | null> | null = null; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "prop") { - reader.context().push(field, "string", "type found, reading property"); - _prop = reader.readString(); - _propSet = true; - reader.context().pop(); - } - else if (field == "optProp") { - reader.context().push(field, "string | null", "type found, reading property"); - _optProp = reader.readOptionalString(); - reader.context().pop(); - } - else if (field == "optMap") { - reader.context().push(field, "Map | null> | null", "type found, reading property"); - _optMap = reader.readOptionalExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): Box | null => { - return reader.readOptionalInt32(); - }); - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_propSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'prop: String'")); - } - - return { - prop: _prop, - optProp: _optProp, - optMap: _optMap - }; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/index.ts deleted file mode 100644 index 2cd8b85ef7..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { - Args_moduleMethod, - Args_objectMethod, - Args_optionalEnvMethod, - Args__if -} from "./serialization"; - -export { - Args_moduleMethod, - Args_objectMethod, - Args_optionalEnvMethod, - Args__if -}; -export { ModuleBase } from "./module"; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/module.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/module.ts deleted file mode 100644 index 6f307a2e1a..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/module.ts +++ /dev/null @@ -1,28 +0,0 @@ -import * as Types from ".."; - -import { - BigInt, - BigNumber, - Box, - JSON, -} from "@polywrap/wasm-as"; - -export abstract class ModuleBase { - abstract moduleMethod( - args: Types.Args_moduleMethod - ): i32; - - abstract objectMethod( - args: Types.Args_objectMethod, - env: Types.Env - ): Types.AnotherType | null; - - abstract optionalEnvMethod( - args: Types.Args_optionalEnvMethod, - env: Types.Env | null - ): Types.AnotherType | null; - - abstract _if( - args: Types.Args__if - ): Types._else; -} \ No newline at end of file diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts deleted file mode 100644 index 3cf8cc78d7..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/serialization.ts +++ /dev/null @@ -1,770 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import * as Types from ".."; - -export class Args_moduleMethod { - str: string; - optStr: string | null; - en: Types.CustomEnum; - optEnum: Box | null; - enumArray: Array; - optEnumArray: Array | null> | null; - map: Map; - mapOfArr: Map>; - mapOfMap: Map>; - mapOfObj: Map; - mapOfArrOfObj: Map>; -} - -export function deserializemoduleMethodArgs(argsBuf: ArrayBuffer): Args_moduleMethod { - const context: Context = new Context("Deserializing module-type: moduleMethod Args"); - const reader = new ReadDecoder(argsBuf, context); - let numFields = reader.readMapLength(); - - let _str: string = ""; - let _strSet: bool = false; - let _optStr: string | null = null; - let _en: Types.CustomEnum = 0; - let _enSet: bool = false; - let _optEnum: Box | null = null; - let _enumArray: Array = []; - let _enumArraySet: bool = false; - let _optEnumArray: Array | null> | null = null; - let _map: Map = new Map(); - let _mapSet: bool = false; - let _mapOfArr: Map> = new Map>(); - let _mapOfArrSet: bool = false; - let _mapOfMap: Map> = new Map>(); - let _mapOfMapSet: bool = false; - let _mapOfObj: Map = new Map(); - let _mapOfObjSet: bool = false; - let _mapOfArrOfObj: Map> = new Map>(); - let _mapOfArrOfObjSet: bool = false; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "str") { - reader.context().push(field, "string", "type found, reading property"); - _str = reader.readString(); - _strSet = true; - reader.context().pop(); - } - else if (field == "optStr") { - reader.context().push(field, "string | null", "type found, reading property"); - _optStr = reader.readOptionalString(); - reader.context().pop(); - } - else if (field == "en") { - reader.context().push(field, "Types.CustomEnum", "type found, reading property"); - let value: Types.CustomEnum; - if (reader.isNextString()) { - value = Types.getCustomEnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeCustomEnumValue(value); - } - _en = value; - _enSet = true; - reader.context().pop(); - } - else if (field == "optEnum") { - reader.context().push(field, "Box | null", "type found, reading property"); - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getCustomEnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeCustomEnumValue(value.unwrap()); - } - } else { - value = null; - } - _optEnum = value; - reader.context().pop(); - } - else if (field == "enumArray") { - reader.context().push(field, "Array", "type found, reading property"); - _enumArray = reader.readArray((reader: Read): Types.CustomEnum => { - let value: Types.CustomEnum; - if (reader.isNextString()) { - value = Types.getCustomEnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeCustomEnumValue(value); - } - return value; - }); - _enumArraySet = true; - reader.context().pop(); - } - else if (field == "optEnumArray") { - reader.context().push(field, "Array | null> | null", "type found, reading property"); - _optEnumArray = reader.readOptionalArray((reader: Read): Box | null => { - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getCustomEnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeCustomEnumValue(value.unwrap()); - } - } else { - value = null; - } - return value; - }); - reader.context().pop(); - } - else if (field == "map") { - reader.context().push(field, "Map", "type found, reading property"); - _map = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): i32 => { - return reader.readInt32(); - }); - _mapSet = true; - reader.context().pop(); - } - else if (field == "mapOfArr") { - reader.context().push(field, "Map>", "type found, reading property"); - _mapOfArr = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): Array => { - return reader.readArray((reader: Read): i32 => { - return reader.readInt32(); - }); - }); - _mapOfArrSet = true; - reader.context().pop(); - } - else if (field == "mapOfMap") { - reader.context().push(field, "Map>", "type found, reading property"); - _mapOfMap = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): Map => { - return reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): i32 => { - return reader.readInt32(); - }); - }); - _mapOfMapSet = true; - reader.context().pop(); - } - else if (field == "mapOfObj") { - reader.context().push(field, "Map", "type found, reading property"); - _mapOfObj = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): Types.AnotherType => { - const object = Types.AnotherType.read(reader); - return object; - }); - _mapOfObjSet = true; - reader.context().pop(); - } - else if (field == "mapOfArrOfObj") { - reader.context().push(field, "Map>", "type found, reading property"); - _mapOfArrOfObj = reader.readExtGenericMap((reader: Read): string => { - return reader.readString(); - }, (reader: Read): Array => { - return reader.readArray((reader: Read): Types.AnotherType => { - const object = Types.AnotherType.read(reader); - return object; - }); - }); - _mapOfArrOfObjSet = true; - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_strSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'str: String'")); - } - if (!_enSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'en: CustomEnum'")); - } - if (!_enumArraySet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'enumArray: [CustomEnum]'")); - } - if (!_mapSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'map: Map'")); - } - if (!_mapOfArrSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'mapOfArr: Map'")); - } - if (!_mapOfMapSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'mapOfMap: Map>'")); - } - if (!_mapOfObjSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'mapOfObj: Map'")); - } - if (!_mapOfArrOfObjSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'mapOfArrOfObj: Map'")); - } - - return { - str: _str, - optStr: _optStr, - en: _en, - optEnum: _optEnum, - enumArray: _enumArray, - optEnumArray: _optEnumArray, - map: _map, - mapOfArr: _mapOfArr, - mapOfMap: _mapOfMap, - mapOfObj: _mapOfObj, - mapOfArrOfObj: _mapOfArrOfObj - }; -} - -export function serializemoduleMethodArgs(args: Args_moduleMethod): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: moduleMethod Args"); - const sizer = new WriteSizer(sizerContext); - writemoduleMethodArgs(sizer, args); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: moduleMethod Args"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writemoduleMethodArgs(encoder, args); - return buffer; -} - -export function writemoduleMethodArgs( - writer: Write, - args: Args_moduleMethod -): void { - writer.writeMapLength(11); - writer.context().push("str", "string", "writing property"); - writer.writeString("str"); - writer.writeString(args.str); - writer.context().pop(); - writer.context().push("optStr", "string | null", "writing property"); - writer.writeString("optStr"); - writer.writeOptionalString(args.optStr); - writer.context().pop(); - writer.context().push("en", "Types.CustomEnum", "writing property"); - writer.writeString("en"); - writer.writeInt32(args.en); - writer.context().pop(); - writer.context().push("optEnum", "Box | null", "writing property"); - writer.writeString("optEnum"); - writer.writeOptionalInt32(args.optEnum); - writer.context().pop(); - writer.context().push("enumArray", "Array", "writing property"); - writer.writeString("enumArray"); - writer.writeArray(args.enumArray, (writer: Write, item: Types.CustomEnum): void => { - writer.writeInt32(item); - }); - writer.context().pop(); - writer.context().push("optEnumArray", "Array | null> | null", "writing property"); - writer.writeString("optEnumArray"); - writer.writeOptionalArray(args.optEnumArray, (writer: Write, item: Box | null): void => { - writer.writeOptionalInt32(item); - }); - writer.context().pop(); - writer.context().push("map", "Map", "writing property"); - writer.writeString("map"); - writer.writeExtGenericMap(args.map, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: i32): void => { - writer.writeInt32(value); - }); - writer.context().pop(); - writer.context().push("mapOfArr", "Map>", "writing property"); - writer.writeString("mapOfArr"); - writer.writeExtGenericMap(args.mapOfArr, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: Array): void => { - writer.writeArray(value, (writer: Write, item: i32): void => { - writer.writeInt32(item); - }); - }); - writer.context().pop(); - writer.context().push("mapOfMap", "Map>", "writing property"); - writer.writeString("mapOfMap"); - writer.writeExtGenericMap(args.mapOfMap, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: Map): void => { - writer.writeExtGenericMap(value, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: i32): void => { - writer.writeInt32(value); - }); - }); - writer.context().pop(); - writer.context().push("mapOfObj", "Map", "writing property"); - writer.writeString("mapOfObj"); - writer.writeExtGenericMap(args.mapOfObj, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: Types.AnotherType): void => { - Types.AnotherType.write(writer, value); - }); - writer.context().pop(); - writer.context().push("mapOfArrOfObj", "Map>", "writing property"); - writer.writeString("mapOfArrOfObj"); - writer.writeExtGenericMap(args.mapOfArrOfObj, (writer: Write, key: string) => { - writer.writeString(key); - }, (writer: Write, value: Array): void => { - writer.writeArray(value, (writer: Write, item: Types.AnotherType): void => { - Types.AnotherType.write(writer, item); - }); - }); - writer.context().pop(); -} - -export function serializemoduleMethodResult(result: i32): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: moduleMethod Result"); - const sizer = new WriteSizer(sizerContext); - writemoduleMethodResult(sizer, result); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: moduleMethod Result"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writemoduleMethodResult(encoder, result); - return buffer; -} - -export function writemoduleMethodResult(writer: Write, result: i32): void { - writer.context().push("moduleMethod", "i32", "writing property"); - writer.writeInt32(result); - writer.context().pop(); -} - -export function deserializemoduleMethodResult(buffer: ArrayBuffer): i32 { - const context: Context = new Context("Deserializing module-type: moduleMethod Result"); - const reader = new ReadDecoder(buffer, context); - - reader.context().push("moduleMethod", "i32", "reading function output"); - const res: i32 = reader.readInt32(); - reader.context().pop(); - - return res; -} - -export class Args_objectMethod { - object: Types.AnotherType; - optObject: Types.AnotherType | null; - objectArray: Array; - optObjectArray: Array | null; -} - -export function deserializeobjectMethodArgs(argsBuf: ArrayBuffer): Args_objectMethod { - const context: Context = new Context("Deserializing module-type: objectMethod Args"); - const reader = new ReadDecoder(argsBuf, context); - let numFields = reader.readMapLength(); - - let _object: Types.AnotherType | null = null; - let _objectSet: bool = false; - let _optObject: Types.AnotherType | null = null; - let _objectArray: Array = []; - let _objectArraySet: bool = false; - let _optObjectArray: Array | null = null; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "object") { - reader.context().push(field, "Types.AnotherType", "type found, reading property"); - const object = Types.AnotherType.read(reader); - _object = object; - _objectSet = true; - reader.context().pop(); - } - else if (field == "optObject") { - reader.context().push(field, "Types.AnotherType | null", "type found, reading property"); - let object: Types.AnotherType | null = null; - if (!reader.isNextNil()) { - object = Types.AnotherType.read(reader); - } - _optObject = object; - reader.context().pop(); - } - else if (field == "objectArray") { - reader.context().push(field, "Array", "type found, reading property"); - _objectArray = reader.readArray((reader: Read): Types.AnotherType => { - const object = Types.AnotherType.read(reader); - return object; - }); - _objectArraySet = true; - reader.context().pop(); - } - else if (field == "optObjectArray") { - reader.context().push(field, "Array | null", "type found, reading property"); - _optObjectArray = reader.readOptionalArray((reader: Read): Types.AnotherType | null => { - let object: Types.AnotherType | null = null; - if (!reader.isNextNil()) { - object = Types.AnotherType.read(reader); - } - return object; - }); - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_object || !_objectSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'object: AnotherType'")); - } - if (!_objectArraySet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'objectArray: [AnotherType]'")); - } - - return { - object: _object, - optObject: _optObject, - objectArray: _objectArray, - optObjectArray: _optObjectArray - }; -} - -export function serializeobjectMethodArgs(args: Args_objectMethod): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: objectMethod Args"); - const sizer = new WriteSizer(sizerContext); - writeobjectMethodArgs(sizer, args); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: objectMethod Args"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeobjectMethodArgs(encoder, args); - return buffer; -} - -export function writeobjectMethodArgs( - writer: Write, - args: Args_objectMethod -): void { - writer.writeMapLength(4); - writer.context().push("object", "Types.AnotherType", "writing property"); - writer.writeString("object"); - Types.AnotherType.write(writer, args.object); - writer.context().pop(); - writer.context().push("optObject", "Types.AnotherType | null", "writing property"); - writer.writeString("optObject"); - if (args.optObject) { - Types.AnotherType.write(writer, args.optObject as Types.AnotherType); - } else { - writer.writeNil(); - } - writer.context().pop(); - writer.context().push("objectArray", "Array", "writing property"); - writer.writeString("objectArray"); - writer.writeArray(args.objectArray, (writer: Write, item: Types.AnotherType): void => { - Types.AnotherType.write(writer, item); - }); - writer.context().pop(); - writer.context().push("optObjectArray", "Array | null", "writing property"); - writer.writeString("optObjectArray"); - writer.writeOptionalArray(args.optObjectArray, (writer: Write, item: Types.AnotherType | null): void => { - if (item) { - Types.AnotherType.write(writer, item as Types.AnotherType); - } else { - writer.writeNil(); - } - }); - writer.context().pop(); -} - -export function serializeobjectMethodResult(result: Types.AnotherType | null): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: objectMethod Result"); - const sizer = new WriteSizer(sizerContext); - writeobjectMethodResult(sizer, result); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: objectMethod Result"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeobjectMethodResult(encoder, result); - return buffer; -} - -export function writeobjectMethodResult(writer: Write, result: Types.AnotherType | null): void { - writer.context().push("objectMethod", "Types.AnotherType | null", "writing property"); - if (result) { - Types.AnotherType.write(writer, result as Types.AnotherType); - } else { - writer.writeNil(); - } - writer.context().pop(); -} - -export function deserializeobjectMethodResult(buffer: ArrayBuffer): Types.AnotherType | null { - const context: Context = new Context("Deserializing module-type: objectMethod Result"); - const reader = new ReadDecoder(buffer, context); - - reader.context().push("objectMethod", "Types.AnotherType | null", "reading function output"); - let object: Types.AnotherType | null = null; - if (!reader.isNextNil()) { - object = Types.AnotherType.read(reader); - } - const res: Types.AnotherType | null = object; - reader.context().pop(); - - return res; -} - -export class Args_optionalEnvMethod { - object: Types.AnotherType; - optObject: Types.AnotherType | null; - objectArray: Array; - optObjectArray: Array | null; -} - -export function deserializeoptionalEnvMethodArgs(argsBuf: ArrayBuffer): Args_optionalEnvMethod { - const context: Context = new Context("Deserializing module-type: optionalEnvMethod Args"); - const reader = new ReadDecoder(argsBuf, context); - let numFields = reader.readMapLength(); - - let _object: Types.AnotherType | null = null; - let _objectSet: bool = false; - let _optObject: Types.AnotherType | null = null; - let _objectArray: Array = []; - let _objectArraySet: bool = false; - let _optObjectArray: Array | null = null; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "object") { - reader.context().push(field, "Types.AnotherType", "type found, reading property"); - const object = Types.AnotherType.read(reader); - _object = object; - _objectSet = true; - reader.context().pop(); - } - else if (field == "optObject") { - reader.context().push(field, "Types.AnotherType | null", "type found, reading property"); - let object: Types.AnotherType | null = null; - if (!reader.isNextNil()) { - object = Types.AnotherType.read(reader); - } - _optObject = object; - reader.context().pop(); - } - else if (field == "objectArray") { - reader.context().push(field, "Array", "type found, reading property"); - _objectArray = reader.readArray((reader: Read): Types.AnotherType => { - const object = Types.AnotherType.read(reader); - return object; - }); - _objectArraySet = true; - reader.context().pop(); - } - else if (field == "optObjectArray") { - reader.context().push(field, "Array | null", "type found, reading property"); - _optObjectArray = reader.readOptionalArray((reader: Read): Types.AnotherType | null => { - let object: Types.AnotherType | null = null; - if (!reader.isNextNil()) { - object = Types.AnotherType.read(reader); - } - return object; - }); - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_object || !_objectSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'object: AnotherType'")); - } - if (!_objectArraySet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'objectArray: [AnotherType]'")); - } - - return { - object: _object, - optObject: _optObject, - objectArray: _objectArray, - optObjectArray: _optObjectArray - }; -} - -export function serializeoptionalEnvMethodArgs(args: Args_optionalEnvMethod): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: optionalEnvMethod Args"); - const sizer = new WriteSizer(sizerContext); - writeoptionalEnvMethodArgs(sizer, args); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: optionalEnvMethod Args"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeoptionalEnvMethodArgs(encoder, args); - return buffer; -} - -export function writeoptionalEnvMethodArgs( - writer: Write, - args: Args_optionalEnvMethod -): void { - writer.writeMapLength(4); - writer.context().push("object", "Types.AnotherType", "writing property"); - writer.writeString("object"); - Types.AnotherType.write(writer, args.object); - writer.context().pop(); - writer.context().push("optObject", "Types.AnotherType | null", "writing property"); - writer.writeString("optObject"); - if (args.optObject) { - Types.AnotherType.write(writer, args.optObject as Types.AnotherType); - } else { - writer.writeNil(); - } - writer.context().pop(); - writer.context().push("objectArray", "Array", "writing property"); - writer.writeString("objectArray"); - writer.writeArray(args.objectArray, (writer: Write, item: Types.AnotherType): void => { - Types.AnotherType.write(writer, item); - }); - writer.context().pop(); - writer.context().push("optObjectArray", "Array | null", "writing property"); - writer.writeString("optObjectArray"); - writer.writeOptionalArray(args.optObjectArray, (writer: Write, item: Types.AnotherType | null): void => { - if (item) { - Types.AnotherType.write(writer, item as Types.AnotherType); - } else { - writer.writeNil(); - } - }); - writer.context().pop(); -} - -export function serializeoptionalEnvMethodResult(result: Types.AnotherType | null): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: optionalEnvMethod Result"); - const sizer = new WriteSizer(sizerContext); - writeoptionalEnvMethodResult(sizer, result); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: optionalEnvMethod Result"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeoptionalEnvMethodResult(encoder, result); - return buffer; -} - -export function writeoptionalEnvMethodResult(writer: Write, result: Types.AnotherType | null): void { - writer.context().push("optionalEnvMethod", "Types.AnotherType | null", "writing property"); - if (result) { - Types.AnotherType.write(writer, result as Types.AnotherType); - } else { - writer.writeNil(); - } - writer.context().pop(); -} - -export function deserializeoptionalEnvMethodResult(buffer: ArrayBuffer): Types.AnotherType | null { - const context: Context = new Context("Deserializing module-type: optionalEnvMethod Result"); - const reader = new ReadDecoder(buffer, context); - - reader.context().push("optionalEnvMethod", "Types.AnotherType | null", "reading function output"); - let object: Types.AnotherType | null = null; - if (!reader.isNextNil()) { - object = Types.AnotherType.read(reader); - } - const res: Types.AnotherType | null = object; - reader.context().pop(); - - return res; -} - -export class Args__if { - _if: Types._else; -} - -export function deserializeifArgs(argsBuf: ArrayBuffer): Args__if { - const context: Context = new Context("Deserializing module-type: if Args"); - const reader = new ReadDecoder(argsBuf, context); - let numFields = reader.readMapLength(); - - let _if: Types._else | null = null; - let _ifSet: bool = false; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "if") { - reader.context().push(field, "Types._else", "type found, reading property"); - const object = Types._else.read(reader); - _if = object; - _ifSet = true; - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_if || !_ifSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'if: else'")); - } - - return { - _if: _if - }; -} - -export function serializeifArgs(args: Args__if): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: if Args"); - const sizer = new WriteSizer(sizerContext); - writeifArgs(sizer, args); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: if Args"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeifArgs(encoder, args); - return buffer; -} - -export function writeifArgs( - writer: Write, - args: Args__if -): void { - writer.writeMapLength(1); - writer.context().push("if", "Types._else", "writing property"); - writer.writeString("if"); - Types._else.write(writer, args._if); - writer.context().pop(); -} - -export function serializeifResult(result: Types._else): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) module-type: if Result"); - const sizer = new WriteSizer(sizerContext); - writeifResult(sizer, result); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) module-type: if Result"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeifResult(encoder, result); - return buffer; -} - -export function writeifResult(writer: Write, result: Types._else): void { - writer.context().push("if", "Types._else", "writing property"); - Types._else.write(writer, result); - writer.context().pop(); -} - -export function deserializeifResult(buffer: ArrayBuffer): Types._else { - const context: Context = new Context("Deserializing module-type: if Result"); - const reader = new ReadDecoder(buffer, context); - - reader.context().push("if", "Types._else", "reading function output"); - const object = Types._else.read(reader); - const res: Types._else = object; - reader.context().pop(); - - return res; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/wrapped.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/wrapped.ts deleted file mode 100644 index cd9ca3ba74..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/Module/wrapped.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { wrap_load_env } from "@polywrap/wasm-as"; -import { - deserializemoduleMethodArgs, - serializemoduleMethodResult, - deserializeobjectMethodArgs, - serializeobjectMethodResult, - deserializeoptionalEnvMethodArgs, - serializeoptionalEnvMethodResult, - deserializeifArgs, - serializeifResult -} from "./serialization"; -import { ModuleBase } from "./module"; -import * as Types from ".."; - -export function moduleMethodWrapped(module: ModuleBase, argsBuf: ArrayBuffer, env_size: u32): ArrayBuffer { - const args = deserializemoduleMethodArgs(argsBuf); - - const result = module.moduleMethod( - { - str: args.str, - optStr: args.optStr, - en: args.en, - optEnum: args.optEnum, - enumArray: args.enumArray, - optEnumArray: args.optEnumArray, - map: args.map, - mapOfArr: args.mapOfArr, - mapOfMap: args.mapOfMap, - mapOfObj: args.mapOfObj, - mapOfArrOfObj: args.mapOfArrOfObj - } - ); - return serializemoduleMethodResult(result); -} - -export function objectMethodWrapped(module: ModuleBase, argsBuf: ArrayBuffer, env_size: u32): ArrayBuffer { - if (env_size == 0) { - throw new Error("Environment is not set, and it is required by method 'objectMethod'") - } - - const envBuf = wrap_load_env(env_size); - const env = Types.Env.fromBuffer(envBuf); - const args = deserializeobjectMethodArgs(argsBuf); - - const result = module.objectMethod( - { - object: args.object, - optObject: args.optObject, - objectArray: args.objectArray, - optObjectArray: args.optObjectArray - }, - env - ); - return serializeobjectMethodResult(result); -} - -export function optionalEnvMethodWrapped(module: ModuleBase, argsBuf: ArrayBuffer, env_size: u32): ArrayBuffer { - let env: Types.Env | null = null; - if (env_size > 0) { - const envBuf = wrap_load_env(env_size); - env = Types.Env.fromBuffer(envBuf); - } - const args = deserializeoptionalEnvMethodArgs(argsBuf); - - const result = module.optionalEnvMethod( - { - object: args.object, - optObject: args.optObject, - objectArray: args.objectArray, - optObjectArray: args.optObjectArray - }, - env - ); - return serializeoptionalEnvMethodResult(result); -} - -export function ifWrapped(module: ModuleBase, argsBuf: ArrayBuffer, env_size: u32): ArrayBuffer { - const args = deserializeifArgs(argsBuf); - - const result = module._if( - { - _if: args._if - } - ); - return serializeifResult(result); -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/TestImport/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/TestImport/index.ts deleted file mode 100644 index 8ab00e6d1c..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/TestImport/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - wrap_getImplementations -} from "@polywrap/wasm-as"; - -export class TestImport { - static uri: string = "testimport.uri.eth" - - public static getImplementations(): string[] { - return wrap_getImplementations(this.uri); - } -} \ No newline at end of file diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/else/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/else/index.ts deleted file mode 100644 index 48f590f30b..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/else/index.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serializeelse, - deserializeelse, - writeelse, - readelse -} from "./serialization"; -import * as Types from ".."; - -export class _else { - _else: string; - - static toBuffer(type: _else): ArrayBuffer { - return serializeelse(type); - } - - static fromBuffer(buffer: ArrayBuffer): _else { - return deserializeelse(buffer); - } - - static write(writer: Write, type: _else): void { - writeelse(writer, type); - } - - static read(reader: Read): _else { - return readelse(reader); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/else/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/else/serialization.ts deleted file mode 100644 index 08a0df0df3..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/else/serialization.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import { _else } from "./"; -import * as Types from ".."; - -export function serializeelse(type: _else): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) object-type: else"); - const sizer = new WriteSizer(sizerContext); - writeelse(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) object-type: else"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeelse(encoder, type); - return buffer; -} - -export function writeelse(writer: Write, type: _else): void { - writer.writeMapLength(1); - writer.context().push("else", "string", "writing property"); - writer.writeString("else"); - writer.writeString(type._else); - writer.context().pop(); -} - -export function deserializeelse(buffer: ArrayBuffer): _else { - const context: Context = new Context("Deserializing object-type else"); - const reader = new ReadDecoder(buffer, context); - return readelse(reader); -} - -export function readelse(reader: Read): _else { - let numFields = reader.readMapLength(); - - let _else: string = ""; - let _elseSet: bool = false; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "else") { - reader.context().push(field, "string", "type found, reading property"); - _else = reader.readString(); - _elseSet = true; - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_elseSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'else: String'")); - } - - return { - _else: _else - }; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/entry.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/entry.ts deleted file mode 100644 index b68944d823..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/entry.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { - wrap_invoke_args, - wrap_invoke_result, - wrap_invoke_error, - wrap_abort, - InvokeArgs -} from "@polywrap/wasm-as"; - -import { - moduleMethodWrapped, - objectMethodWrapped, - optionalEnvMethodWrapped, - ifWrapped -} from "./Module/wrapped"; - -import { Module } from "../index"; - -export function _wrap_invoke(method_size: u32, args_size: u32, env_size: u32): bool { - const module = new Module(); - const args: InvokeArgs = wrap_invoke_args( - method_size, - args_size - ); - let result: ArrayBuffer; - if (args.method == "moduleMethod") { - result = moduleMethodWrapped(module, args.args, env_size); - } - else if (args.method == "objectMethod") { - result = objectMethodWrapped(module, args.args, env_size); - } - else if (args.method == "optionalEnvMethod") { - result = optionalEnvMethodWrapped(module, args.args, env_size); - } - else if (args.method == "if") { - result = ifWrapped(module, args.args, env_size); - } - else { - wrap_invoke_error( - `Could not find invoke function "${args.method}"` - ); - return false; - } - wrap_invoke_result(result); - return true; -} - -export function wrapAbort( - msg: string | null, - file: string | null, - line: u32, - column: u32 -): void { - wrap_abort( - msg ? msg : "", - file ? file : "", - line, - column - ); -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_AnotherObject/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_AnotherObject/index.ts deleted file mode 100644 index 54d80f554c..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_AnotherObject/index.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serializeTestImport_AnotherObject, - deserializeTestImport_AnotherObject, - writeTestImport_AnotherObject, - readTestImport_AnotherObject -} from "./serialization"; -import * as Types from "../.."; - -export class TestImport_AnotherObject { - - public static uri: string = "testimport.uri.eth"; - - prop: string; - - static toBuffer(type: TestImport_AnotherObject): ArrayBuffer { - return serializeTestImport_AnotherObject(type); - } - - static fromBuffer(buffer: ArrayBuffer): TestImport_AnotherObject { - return deserializeTestImport_AnotherObject(buffer); - } - - static write(writer: Write, type: TestImport_AnotherObject): void { - writeTestImport_AnotherObject(writer, type); - } - - static read(reader: Read): TestImport_AnotherObject { - return readTestImport_AnotherObject(reader); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_AnotherObject/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_AnotherObject/serialization.ts deleted file mode 100644 index 1835851b49..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_AnotherObject/serialization.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import { TestImport_AnotherObject } from "./"; -import * as Types from "../.."; - -export function serializeTestImport_AnotherObject(type: TestImport_AnotherObject): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported object-type: TestImport_AnotherObject"); - const sizer = new WriteSizer(sizerContext); - writeTestImport_AnotherObject(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) import object-type: TestImport_AnotherObject"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeTestImport_AnotherObject(encoder, type); - return buffer; -} - -export function writeTestImport_AnotherObject(writer: Write, type: TestImport_AnotherObject): void { - writer.writeMapLength(1); - writer.context().push("prop", "string", "writing property"); - writer.writeString("prop"); - writer.writeString(type.prop); - writer.context().pop(); -} - -export function deserializeTestImport_AnotherObject(buffer: ArrayBuffer): TestImport_AnotherObject { - const context: Context = new Context("Deserializing imported object-type TestImport_AnotherObject"); - const reader = new ReadDecoder(buffer, context); - return readTestImport_AnotherObject(reader); -} - -export function readTestImport_AnotherObject(reader: Read): TestImport_AnotherObject { - let numFields = reader.readMapLength(); - - let _prop: string = ""; - let _propSet: bool = false; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "prop") { - reader.context().push(field, "string", "type found, reading property"); - _prop = reader.readString(); - _propSet = true; - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_propSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'prop: String'")); - } - - return { - prop: _prop - }; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Enum/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Enum/index.ts deleted file mode 100644 index b06028d316..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Enum/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -export enum TestImport_Enum { - STRING, - BYTES, - _MAX_ -} - -export function sanitizeTestImport_EnumValue(value: i32): void { - const valid = value >= 0 && value < TestImport_Enum._MAX_; - if (!valid) { - throw new Error("Invalid value for enum 'TestImport_Enum': " + value.toString()); - } -} - -export function getTestImport_EnumValue(key: string): TestImport_Enum { - if (key == "STRING") { - return TestImport_Enum.STRING; - } - if (key == "BYTES") { - return TestImport_Enum.BYTES; - } - - throw new Error("Invalid key for enum 'TestImport_Enum': " + key); -} - -export function getTestImport_EnumKey(value: TestImport_Enum): string { - sanitizeTestImport_EnumValue(value); - - switch (value) { - case TestImport_Enum.STRING: return "STRING"; - case TestImport_Enum.BYTES: return "BYTES"; - default: - throw new Error("Invalid value for enum 'TestImport_Enum': " + value.toString()); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Enum_Return/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Enum_Return/index.ts deleted file mode 100644 index 6f9f65b1bd..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Enum_Return/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -export enum TestImport_Enum_Return { - STRING, - BYTES, - _MAX_ -} - -export function sanitizeTestImport_Enum_ReturnValue(value: i32): void { - const valid = value >= 0 && value < TestImport_Enum_Return._MAX_; - if (!valid) { - throw new Error("Invalid value for enum 'TestImport_Enum_Return': " + value.toString()); - } -} - -export function getTestImport_Enum_ReturnValue(key: string): TestImport_Enum_Return { - if (key == "STRING") { - return TestImport_Enum_Return.STRING; - } - if (key == "BYTES") { - return TestImport_Enum_Return.BYTES; - } - - throw new Error("Invalid key for enum 'TestImport_Enum_Return': " + key); -} - -export function getTestImport_Enum_ReturnKey(value: TestImport_Enum_Return): string { - sanitizeTestImport_Enum_ReturnValue(value); - - switch (value) { - case TestImport_Enum_Return.STRING: return "STRING"; - case TestImport_Enum_Return.BYTES: return "BYTES"; - default: - throw new Error("Invalid value for enum 'TestImport_Enum_Return': " + value.toString()); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Env/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Env/index.ts deleted file mode 100644 index 13da9f9059..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Env/index.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON, -} from "@polywrap/wasm-as"; -import { - serializeTestImport_Env, - deserializeTestImport_Env, - writeTestImport_Env, - readTestImport_Env -} from "./serialization"; -import * as Types from "../.."; - -@serializable -export class TestImport_Env { - - public static uri: string = "testimport.uri.eth"; - - object: Types.TestImport_AnotherObject; - optObject: Types.TestImport_AnotherObject | null; - objectArray: Array; - optObjectArray: Array | null; - en: Types.TestImport_Enum; - optEnum: Box | null; - enumArray: Array; - optEnumArray: Array | null> | null; - - static toBuffer(type: TestImport_Env): ArrayBuffer { - return serializeTestImport_Env(type); - } - - static fromBuffer(buffer: ArrayBuffer): TestImport_Env { - return deserializeTestImport_Env(buffer); - } - - static write(writer: Write, type: TestImport_Env): void { - writeTestImport_Env(writer, type); - } - - static read(reader: Read): TestImport_Env { - return readTestImport_Env(reader); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Env/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Env/serialization.ts deleted file mode 100644 index f86f58f15c..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Env/serialization.ts +++ /dev/null @@ -1,238 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import { TestImport_Env } from "./"; -import * as Types from "../.."; - -export function serializeTestImport_Env(type: TestImport_Env): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported env-type: TestImport_Env"); - const sizer = new WriteSizer(sizerContext); - writeTestImport_Env(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported env-type: TestImport_Env"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeTestImport_Env(encoder, type); - return buffer; -} - -export function writeTestImport_Env(writer: Write, type: TestImport_Env): void { - writer.writeMapLength(8); - writer.context().push("object", "Types.TestImport_AnotherObject", "writing property"); - writer.writeString("object"); - Types.TestImport_AnotherObject.write(writer, type.object); - writer.context().pop(); - writer.context().push("optObject", "Types.TestImport_AnotherObject | null", "writing property"); - writer.writeString("optObject"); - if (type.optObject) { - Types.TestImport_AnotherObject.write(writer, type.optObject as Types.TestImport_AnotherObject); - } else { - writer.writeNil(); - } - writer.context().pop(); - writer.context().push("objectArray", "Array", "writing property"); - writer.writeString("objectArray"); - writer.writeArray(type.objectArray, (writer: Write, item: Types.TestImport_AnotherObject): void => { - Types.TestImport_AnotherObject.write(writer, item); - }); - writer.context().pop(); - writer.context().push("optObjectArray", "Array | null", "writing property"); - writer.writeString("optObjectArray"); - writer.writeOptionalArray(type.optObjectArray, (writer: Write, item: Types.TestImport_AnotherObject | null): void => { - if (item) { - Types.TestImport_AnotherObject.write(writer, item as Types.TestImport_AnotherObject); - } else { - writer.writeNil(); - } - }); - writer.context().pop(); - writer.context().push("en", "Types.TestImport_Enum", "writing property"); - writer.writeString("en"); - writer.writeInt32(type.en); - writer.context().pop(); - writer.context().push("optEnum", "Box | null", "writing property"); - writer.writeString("optEnum"); - writer.writeOptionalInt32(type.optEnum); - writer.context().pop(); - writer.context().push("enumArray", "Array", "writing property"); - writer.writeString("enumArray"); - writer.writeArray(type.enumArray, (writer: Write, item: Types.TestImport_Enum): void => { - writer.writeInt32(item); - }); - writer.context().pop(); - writer.context().push("optEnumArray", "Array | null> | null", "writing property"); - writer.writeString("optEnumArray"); - writer.writeOptionalArray(type.optEnumArray, (writer: Write, item: Box | null): void => { - writer.writeOptionalInt32(item); - }); - writer.context().pop(); -} - -export function deserializeTestImport_Env(buffer: ArrayBuffer): TestImport_Env { - const context: Context = new Context("Deserializing imported env-type TestImport_Env"); - const reader = new ReadDecoder(buffer, context); - return readTestImport_Env(reader); -} - -export function readTestImport_Env(reader: Read): TestImport_Env { - let numFields = reader.readMapLength(); - - let _object: Types.TestImport_AnotherObject | null = null; - let _objectSet: bool = false; - let _optObject: Types.TestImport_AnotherObject | null = null; - let _objectArray: Array = []; - let _objectArraySet: bool = false; - let _optObjectArray: Array | null = null; - let _en: Types.TestImport_Enum = 0; - let _enSet: bool = false; - let _optEnum: Box | null = null; - let _enumArray: Array = []; - let _enumArraySet: bool = false; - let _optEnumArray: Array | null> | null = null; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "object") { - reader.context().push(field, "Types.TestImport_AnotherObject", "type found, reading property"); - const object = Types.TestImport_AnotherObject.read(reader); - _object = object; - _objectSet = true; - reader.context().pop(); - } - else if (field == "optObject") { - reader.context().push(field, "Types.TestImport_AnotherObject | null", "type found, reading property"); - let object: Types.TestImport_AnotherObject | null = null; - if (!reader.isNextNil()) { - object = Types.TestImport_AnotherObject.read(reader); - } - _optObject = object; - reader.context().pop(); - } - else if (field == "objectArray") { - reader.context().push(field, "Array", "type found, reading property"); - _objectArray = reader.readArray((reader: Read): Types.TestImport_AnotherObject => { - const object = Types.TestImport_AnotherObject.read(reader); - return object; - }); - _objectArraySet = true; - reader.context().pop(); - } - else if (field == "optObjectArray") { - reader.context().push(field, "Array | null", "type found, reading property"); - _optObjectArray = reader.readOptionalArray((reader: Read): Types.TestImport_AnotherObject | null => { - let object: Types.TestImport_AnotherObject | null = null; - if (!reader.isNextNil()) { - object = Types.TestImport_AnotherObject.read(reader); - } - return object; - }); - reader.context().pop(); - } - else if (field == "en") { - reader.context().push(field, "Types.TestImport_Enum", "type found, reading property"); - let value: Types.TestImport_Enum; - if (reader.isNextString()) { - value = Types.getTestImport_EnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeTestImport_EnumValue(value); - } - _en = value; - _enSet = true; - reader.context().pop(); - } - else if (field == "optEnum") { - reader.context().push(field, "Box | null", "type found, reading property"); - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getTestImport_EnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeTestImport_EnumValue(value.unwrap()); - } - } else { - value = null; - } - _optEnum = value; - reader.context().pop(); - } - else if (field == "enumArray") { - reader.context().push(field, "Array", "type found, reading property"); - _enumArray = reader.readArray((reader: Read): Types.TestImport_Enum => { - let value: Types.TestImport_Enum; - if (reader.isNextString()) { - value = Types.getTestImport_EnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeTestImport_EnumValue(value); - } - return value; - }); - _enumArraySet = true; - reader.context().pop(); - } - else if (field == "optEnumArray") { - reader.context().push(field, "Array | null> | null", "type found, reading property"); - _optEnumArray = reader.readOptionalArray((reader: Read): Box | null => { - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getTestImport_EnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeTestImport_EnumValue(value.unwrap()); - } - } else { - value = null; - } - return value; - }); - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_object || !_objectSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'object: TestImport_AnotherObject'")); - } - if (!_objectArraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'objectArray: [TestImport_AnotherObject]'")); - } - if (!_enSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'en: TestImport_Enum'")); - } - if (!_enumArraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'enumArray: [TestImport_Enum]'")); - } - - return { - object: _object, - optObject: _optObject, - objectArray: _objectArray, - optObjectArray: _optObjectArray, - en: _en, - optEnum: _optEnum, - enumArray: _enumArray, - optEnumArray: _optEnumArray - }; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts deleted file mode 100644 index f924a389c9..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/index.ts +++ /dev/null @@ -1,98 +0,0 @@ -import { - wrap_subinvoke, - wrap_subinvokeImplementation, - Box, - BigInt, - BigNumber, - JSON, - Result -} from "@polywrap/wasm-as"; -import { - serializeimportedMethodArgs, - deserializeimportedMethodResult, - Args_importedMethod, - serializeanotherMethodArgs, - deserializeanotherMethodResult, - Args_anotherMethod, - serializereturnsArrayOfEnumsArgs, - deserializereturnsArrayOfEnumsResult, - Args_returnsArrayOfEnums -} from "./serialization"; -import * as Types from "../.."; - -export class TestImport_Module { - - public static interfaceUri: string = "testimport.uri.eth"; - - public uri: string; - - constructor(uri: string) { - this.uri = uri; - } - - public importedMethod( - args: Args_importedMethod - ): Result { - const argsBuf = serializeimportedMethodArgs(args); - const result = wrap_subinvokeImplementation( - "testimport.uri.eth", - this.uri, - "importedMethod", - argsBuf - ); - - if (result.isErr) { - return Result.Err( - result.unwrapErr() - ); - } - - return Result.Ok( - deserializeimportedMethodResult(result.unwrap()) - ); - } - - public anotherMethod( - args: Args_anotherMethod - ): Result { - const argsBuf = serializeanotherMethodArgs(args); - const result = wrap_subinvokeImplementation( - "testimport.uri.eth", - this.uri, - "anotherMethod", - argsBuf - ); - - if (result.isErr) { - return Result.Err( - result.unwrapErr() - ); - } - - return Result.Ok( - deserializeanotherMethodResult(result.unwrap()) - ); - } - - public returnsArrayOfEnums( - args: Args_returnsArrayOfEnums - ): Result | null>, string> { - const argsBuf = serializereturnsArrayOfEnumsArgs(args); - const result = wrap_subinvokeImplementation( - "testimport.uri.eth", - this.uri, - "returnsArrayOfEnums", - argsBuf - ); - - if (result.isErr) { - return Result.Err | null>, string>( - result.unwrapErr() - ); - } - - return Result.Ok | null>, string>( - deserializereturnsArrayOfEnumsResult(result.unwrap()) - ); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts deleted file mode 100644 index ff0a51b0db..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Module/serialization.ts +++ /dev/null @@ -1,559 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import * as Types from "../.."; - -export class Args_importedMethod { - str: string; - optStr: string | null; - u: u32; - optU: Box | null; - uArrayArray: Array | null> | null>; - object: Types.TestImport_Object; - optObject: Types.TestImport_Object | null; - objectArray: Array; - optObjectArray: Array | null; - en: Types.TestImport_Enum; - optEnum: Box | null; - enumArray: Array; - optEnumArray: Array | null> | null; -} - -export function deserializeimportedMethodArgs(argsBuf: ArrayBuffer): Args_importedMethod { - const context: Context = new Context("Deserializing imported module-type: importedMethod Args"); - const reader = new ReadDecoder(argsBuf, context); - let numFields = reader.readMapLength(); - - let _str: string = ""; - let _strSet: bool = false; - let _optStr: string | null = null; - let _u: u32 = 0; - let _uSet: bool = false; - let _optU: Box | null = null; - let _uArrayArray: Array | null> | null> = []; - let _uArrayArraySet: bool = false; - let _object: Types.TestImport_Object | null = null; - let _objectSet: bool = false; - let _optObject: Types.TestImport_Object | null = null; - let _objectArray: Array = []; - let _objectArraySet: bool = false; - let _optObjectArray: Array | null = null; - let _en: Types.TestImport_Enum = 0; - let _enSet: bool = false; - let _optEnum: Box | null = null; - let _enumArray: Array = []; - let _enumArraySet: bool = false; - let _optEnumArray: Array | null> | null = null; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "str") { - reader.context().push(field, "string", "type found, reading property"); - _str = reader.readString(); - _strSet = true; - reader.context().pop(); - } - else if (field == "optStr") { - reader.context().push(field, "string | null", "type found, reading property"); - _optStr = reader.readOptionalString(); - reader.context().pop(); - } - else if (field == "u") { - reader.context().push(field, "u32", "type found, reading property"); - _u = reader.readUInt32(); - _uSet = true; - reader.context().pop(); - } - else if (field == "optU") { - reader.context().push(field, "Box | null", "type found, reading property"); - _optU = reader.readOptionalUInt32(); - reader.context().pop(); - } - else if (field == "uArrayArray") { - reader.context().push(field, "Array | null> | null>", "type found, reading property"); - _uArrayArray = reader.readArray((reader: Read): Array | null> | null => { - return reader.readOptionalArray((reader: Read): Box | null => { - return reader.readOptionalUInt32(); - }); - }); - _uArrayArraySet = true; - reader.context().pop(); - } - else if (field == "object") { - reader.context().push(field, "Types.TestImport_Object", "type found, reading property"); - const object = Types.TestImport_Object.read(reader); - _object = object; - _objectSet = true; - reader.context().pop(); - } - else if (field == "optObject") { - reader.context().push(field, "Types.TestImport_Object | null", "type found, reading property"); - let object: Types.TestImport_Object | null = null; - if (!reader.isNextNil()) { - object = Types.TestImport_Object.read(reader); - } - _optObject = object; - reader.context().pop(); - } - else if (field == "objectArray") { - reader.context().push(field, "Array", "type found, reading property"); - _objectArray = reader.readArray((reader: Read): Types.TestImport_Object => { - const object = Types.TestImport_Object.read(reader); - return object; - }); - _objectArraySet = true; - reader.context().pop(); - } - else if (field == "optObjectArray") { - reader.context().push(field, "Array | null", "type found, reading property"); - _optObjectArray = reader.readOptionalArray((reader: Read): Types.TestImport_Object | null => { - let object: Types.TestImport_Object | null = null; - if (!reader.isNextNil()) { - object = Types.TestImport_Object.read(reader); - } - return object; - }); - reader.context().pop(); - } - else if (field == "en") { - reader.context().push(field, "Types.TestImport_Enum", "type found, reading property"); - let value: Types.TestImport_Enum; - if (reader.isNextString()) { - value = Types.getTestImport_EnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeTestImport_EnumValue(value); - } - _en = value; - _enSet = true; - reader.context().pop(); - } - else if (field == "optEnum") { - reader.context().push(field, "Box | null", "type found, reading property"); - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getTestImport_EnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeTestImport_EnumValue(value.unwrap()); - } - } else { - value = null; - } - _optEnum = value; - reader.context().pop(); - } - else if (field == "enumArray") { - reader.context().push(field, "Array", "type found, reading property"); - _enumArray = reader.readArray((reader: Read): Types.TestImport_Enum => { - let value: Types.TestImport_Enum; - if (reader.isNextString()) { - value = Types.getTestImport_EnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeTestImport_EnumValue(value); - } - return value; - }); - _enumArraySet = true; - reader.context().pop(); - } - else if (field == "optEnumArray") { - reader.context().push(field, "Array | null> | null", "type found, reading property"); - _optEnumArray = reader.readOptionalArray((reader: Read): Box | null => { - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getTestImport_EnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeTestImport_EnumValue(value.unwrap()); - } - } else { - value = null; - } - return value; - }); - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_strSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'str: String'")); - } - if (!_uSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'u: UInt'")); - } - if (!_uArrayArraySet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'uArrayArray: [[UInt]]'")); - } - if (!_object || !_objectSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'object: TestImport_Object'")); - } - if (!_objectArraySet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'objectArray: [TestImport_Object]'")); - } - if (!_enSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'en: TestImport_Enum'")); - } - if (!_enumArraySet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'enumArray: [TestImport_Enum]'")); - } - - return { - str: _str, - optStr: _optStr, - u: _u, - optU: _optU, - uArrayArray: _uArrayArray, - object: _object, - optObject: _optObject, - objectArray: _objectArray, - optObjectArray: _optObjectArray, - en: _en, - optEnum: _optEnum, - enumArray: _enumArray, - optEnumArray: _optEnumArray - }; -} - -export function serializeimportedMethodArgs(args: Args_importedMethod): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported module-type: importedMethod Args"); - const sizer = new WriteSizer(sizerContext); - writeimportedMethodArgs(sizer, args); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported module-type: importedMethod Args"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeimportedMethodArgs(encoder, args); - return buffer; -} - -export function writeimportedMethodArgs( - writer: Write, - args: Args_importedMethod -): void { - writer.writeMapLength(13); - writer.context().push("str", "string", "writing property"); - writer.writeString("str"); - writer.writeString(args.str); - writer.context().pop(); - writer.context().push("optStr", "string | null", "writing property"); - writer.writeString("optStr"); - writer.writeOptionalString(args.optStr); - writer.context().pop(); - writer.context().push("u", "u32", "writing property"); - writer.writeString("u"); - writer.writeUInt32(args.u); - writer.context().pop(); - writer.context().push("optU", "Box | null", "writing property"); - writer.writeString("optU"); - writer.writeOptionalUInt32(args.optU); - writer.context().pop(); - writer.context().push("uArrayArray", "Array | null> | null>", "writing property"); - writer.writeString("uArrayArray"); - writer.writeArray(args.uArrayArray, (writer: Write, item: Array | null> | null): void => { - writer.writeOptionalArray(item, (writer: Write, item: Box | null): void => { - writer.writeOptionalUInt32(item); - }); - }); - writer.context().pop(); - writer.context().push("object", "Types.TestImport_Object", "writing property"); - writer.writeString("object"); - Types.TestImport_Object.write(writer, args.object); - writer.context().pop(); - writer.context().push("optObject", "Types.TestImport_Object | null", "writing property"); - writer.writeString("optObject"); - if (args.optObject) { - Types.TestImport_Object.write(writer, args.optObject as Types.TestImport_Object); - } else { - writer.writeNil(); - } - writer.context().pop(); - writer.context().push("objectArray", "Array", "writing property"); - writer.writeString("objectArray"); - writer.writeArray(args.objectArray, (writer: Write, item: Types.TestImport_Object): void => { - Types.TestImport_Object.write(writer, item); - }); - writer.context().pop(); - writer.context().push("optObjectArray", "Array | null", "writing property"); - writer.writeString("optObjectArray"); - writer.writeOptionalArray(args.optObjectArray, (writer: Write, item: Types.TestImport_Object | null): void => { - if (item) { - Types.TestImport_Object.write(writer, item as Types.TestImport_Object); - } else { - writer.writeNil(); - } - }); - writer.context().pop(); - writer.context().push("en", "Types.TestImport_Enum", "writing property"); - writer.writeString("en"); - writer.writeInt32(args.en); - writer.context().pop(); - writer.context().push("optEnum", "Box | null", "writing property"); - writer.writeString("optEnum"); - writer.writeOptionalInt32(args.optEnum); - writer.context().pop(); - writer.context().push("enumArray", "Array", "writing property"); - writer.writeString("enumArray"); - writer.writeArray(args.enumArray, (writer: Write, item: Types.TestImport_Enum): void => { - writer.writeInt32(item); - }); - writer.context().pop(); - writer.context().push("optEnumArray", "Array | null> | null", "writing property"); - writer.writeString("optEnumArray"); - writer.writeOptionalArray(args.optEnumArray, (writer: Write, item: Box | null): void => { - writer.writeOptionalInt32(item); - }); - writer.context().pop(); -} - -export function serializeimportedMethodResult(result: Types.TestImport_Object | null): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported module-type: importedMethod Result"); - const sizer = new WriteSizer(sizerContext); - writeimportedMethodResult(sizer, result); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported module-type: importedMethod Result"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeimportedMethodResult(encoder, result); - return buffer; -} - -export function writeimportedMethodResult(writer: Write, result: Types.TestImport_Object | null): void { - writer.context().push("importedMethod", "Types.TestImport_Object | null", "writing property"); - if (result) { - Types.TestImport_Object.write(writer, result as Types.TestImport_Object); - } else { - writer.writeNil(); - } - writer.context().pop(); -} - -export function deserializeimportedMethodResult(buffer: ArrayBuffer): Types.TestImport_Object | null { - const context: Context = new Context("Deserializing imported module-type: importedMethod Result"); - const reader = new ReadDecoder(buffer, context); - - reader.context().push("importedMethod", "Types.TestImport_Object | null", "reading function output"); - let object: Types.TestImport_Object | null = null; - if (!reader.isNextNil()) { - object = Types.TestImport_Object.read(reader); - } - const res: Types.TestImport_Object | null = object; - reader.context().pop(); - - return res; -} - -export class Args_anotherMethod { - arg: Array; -} - -export function deserializeanotherMethodArgs(argsBuf: ArrayBuffer): Args_anotherMethod { - const context: Context = new Context("Deserializing imported module-type: anotherMethod Args"); - const reader = new ReadDecoder(argsBuf, context); - let numFields = reader.readMapLength(); - - let _arg: Array = []; - let _argSet: bool = false; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "arg") { - reader.context().push(field, "Array", "type found, reading property"); - _arg = reader.readArray((reader: Read): string => { - return reader.readString(); - }); - _argSet = true; - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_argSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'arg: [String]'")); - } - - return { - arg: _arg - }; -} - -export function serializeanotherMethodArgs(args: Args_anotherMethod): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported module-type: anotherMethod Args"); - const sizer = new WriteSizer(sizerContext); - writeanotherMethodArgs(sizer, args); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported module-type: anotherMethod Args"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeanotherMethodArgs(encoder, args); - return buffer; -} - -export function writeanotherMethodArgs( - writer: Write, - args: Args_anotherMethod -): void { - writer.writeMapLength(1); - writer.context().push("arg", "Array", "writing property"); - writer.writeString("arg"); - writer.writeArray(args.arg, (writer: Write, item: string): void => { - writer.writeString(item); - }); - writer.context().pop(); -} - -export function serializeanotherMethodResult(result: i32): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported module-type: anotherMethod Result"); - const sizer = new WriteSizer(sizerContext); - writeanotherMethodResult(sizer, result); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported module-type: anotherMethod Result"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeanotherMethodResult(encoder, result); - return buffer; -} - -export function writeanotherMethodResult(writer: Write, result: i32): void { - writer.context().push("anotherMethod", "i32", "writing property"); - writer.writeInt32(result); - writer.context().pop(); -} - -export function deserializeanotherMethodResult(buffer: ArrayBuffer): i32 { - const context: Context = new Context("Deserializing imported module-type: anotherMethod Result"); - const reader = new ReadDecoder(buffer, context); - - reader.context().push("anotherMethod", "i32", "reading function output"); - const res: i32 = reader.readInt32(); - reader.context().pop(); - - return res; -} - -export class Args_returnsArrayOfEnums { - arg: string; -} - -export function deserializereturnsArrayOfEnumsArgs(argsBuf: ArrayBuffer): Args_returnsArrayOfEnums { - const context: Context = new Context("Deserializing imported module-type: returnsArrayOfEnums Args"); - const reader = new ReadDecoder(argsBuf, context); - let numFields = reader.readMapLength(); - - let _arg: string = ""; - let _argSet: bool = false; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "arg") { - reader.context().push(field, "string", "type found, reading property"); - _arg = reader.readString(); - _argSet = true; - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_argSet) { - throw new Error(reader.context().printWithContext("Missing required argument: 'arg: String'")); - } - - return { - arg: _arg - }; -} - -export function serializereturnsArrayOfEnumsArgs(args: Args_returnsArrayOfEnums): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported module-type: returnsArrayOfEnums Args"); - const sizer = new WriteSizer(sizerContext); - writereturnsArrayOfEnumsArgs(sizer, args); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported module-type: returnsArrayOfEnums Args"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writereturnsArrayOfEnumsArgs(encoder, args); - return buffer; -} - -export function writereturnsArrayOfEnumsArgs( - writer: Write, - args: Args_returnsArrayOfEnums -): void { - writer.writeMapLength(1); - writer.context().push("arg", "string", "writing property"); - writer.writeString("arg"); - writer.writeString(args.arg); - writer.context().pop(); -} - -export function serializereturnsArrayOfEnumsResult(result: Array | null>): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported module-type: returnsArrayOfEnums Result"); - const sizer = new WriteSizer(sizerContext); - writereturnsArrayOfEnumsResult(sizer, result); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) imported module-type: returnsArrayOfEnums Result"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writereturnsArrayOfEnumsResult(encoder, result); - return buffer; -} - -export function writereturnsArrayOfEnumsResult(writer: Write, result: Array | null>): void { - writer.context().push("returnsArrayOfEnums", "Array | null>", "writing property"); - writer.writeArray(result, (writer: Write, item: Box | null): void => { - writer.writeOptionalInt32(item); - }); - writer.context().pop(); -} - -export function deserializereturnsArrayOfEnumsResult(buffer: ArrayBuffer): Array | null> { - const context: Context = new Context("Deserializing imported module-type: returnsArrayOfEnums Result"); - const reader = new ReadDecoder(buffer, context); - - reader.context().push("returnsArrayOfEnums", "Array | null>", "reading function output"); - const res: Array | null> = reader.readArray((reader: Read): Box | null => { - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getTestImport_Enum_ReturnValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeTestImport_Enum_ReturnValue(value.unwrap()); - } - } else { - value = null; - } - return value; - }); - reader.context().pop(); - - return res; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/index.ts deleted file mode 100644 index 984be2af32..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/index.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { - Read, - Write, - Box, - BigInt, - BigNumber, - JSON -} from "@polywrap/wasm-as"; -import { - serializeTestImport_Object, - deserializeTestImport_Object, - writeTestImport_Object, - readTestImport_Object -} from "./serialization"; -import * as Types from "../.."; - -export class TestImport_Object { - - public static uri: string = "testimport.uri.eth"; - - object: Types.TestImport_AnotherObject; - optObject: Types.TestImport_AnotherObject | null; - objectArray: Array; - optObjectArray: Array | null; - en: Types.TestImport_Enum; - optEnum: Box | null; - enumArray: Array; - optEnumArray: Array | null> | null; - - static toBuffer(type: TestImport_Object): ArrayBuffer { - return serializeTestImport_Object(type); - } - - static fromBuffer(buffer: ArrayBuffer): TestImport_Object { - return deserializeTestImport_Object(buffer); - } - - static write(writer: Write, type: TestImport_Object): void { - writeTestImport_Object(writer, type); - } - - static read(reader: Read): TestImport_Object { - return readTestImport_Object(reader); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/serialization.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/serialization.ts deleted file mode 100644 index b243ba964a..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/TestImport_Object/serialization.ts +++ /dev/null @@ -1,238 +0,0 @@ -import { - Read, - ReadDecoder, - Write, - WriteSizer, - WriteEncoder, - Box, - BigInt, - BigNumber, - JSON, - Context -} from "@polywrap/wasm-as"; -import { TestImport_Object } from "./"; -import * as Types from "../.."; - -export function serializeTestImport_Object(type: TestImport_Object): ArrayBuffer { - const sizerContext: Context = new Context("Serializing (sizing) imported object-type: TestImport_Object"); - const sizer = new WriteSizer(sizerContext); - writeTestImport_Object(sizer, type); - const buffer = new ArrayBuffer(sizer.length); - const encoderContext: Context = new Context("Serializing (encoding) import object-type: TestImport_Object"); - const encoder = new WriteEncoder(buffer, sizer, encoderContext); - writeTestImport_Object(encoder, type); - return buffer; -} - -export function writeTestImport_Object(writer: Write, type: TestImport_Object): void { - writer.writeMapLength(8); - writer.context().push("object", "Types.TestImport_AnotherObject", "writing property"); - writer.writeString("object"); - Types.TestImport_AnotherObject.write(writer, type.object); - writer.context().pop(); - writer.context().push("optObject", "Types.TestImport_AnotherObject | null", "writing property"); - writer.writeString("optObject"); - if (type.optObject) { - Types.TestImport_AnotherObject.write(writer, type.optObject as Types.TestImport_AnotherObject); - } else { - writer.writeNil(); - } - writer.context().pop(); - writer.context().push("objectArray", "Array", "writing property"); - writer.writeString("objectArray"); - writer.writeArray(type.objectArray, (writer: Write, item: Types.TestImport_AnotherObject): void => { - Types.TestImport_AnotherObject.write(writer, item); - }); - writer.context().pop(); - writer.context().push("optObjectArray", "Array | null", "writing property"); - writer.writeString("optObjectArray"); - writer.writeOptionalArray(type.optObjectArray, (writer: Write, item: Types.TestImport_AnotherObject | null): void => { - if (item) { - Types.TestImport_AnotherObject.write(writer, item as Types.TestImport_AnotherObject); - } else { - writer.writeNil(); - } - }); - writer.context().pop(); - writer.context().push("en", "Types.TestImport_Enum", "writing property"); - writer.writeString("en"); - writer.writeInt32(type.en); - writer.context().pop(); - writer.context().push("optEnum", "Box | null", "writing property"); - writer.writeString("optEnum"); - writer.writeOptionalInt32(type.optEnum); - writer.context().pop(); - writer.context().push("enumArray", "Array", "writing property"); - writer.writeString("enumArray"); - writer.writeArray(type.enumArray, (writer: Write, item: Types.TestImport_Enum): void => { - writer.writeInt32(item); - }); - writer.context().pop(); - writer.context().push("optEnumArray", "Array | null> | null", "writing property"); - writer.writeString("optEnumArray"); - writer.writeOptionalArray(type.optEnumArray, (writer: Write, item: Box | null): void => { - writer.writeOptionalInt32(item); - }); - writer.context().pop(); -} - -export function deserializeTestImport_Object(buffer: ArrayBuffer): TestImport_Object { - const context: Context = new Context("Deserializing imported object-type TestImport_Object"); - const reader = new ReadDecoder(buffer, context); - return readTestImport_Object(reader); -} - -export function readTestImport_Object(reader: Read): TestImport_Object { - let numFields = reader.readMapLength(); - - let _object: Types.TestImport_AnotherObject | null = null; - let _objectSet: bool = false; - let _optObject: Types.TestImport_AnotherObject | null = null; - let _objectArray: Array = []; - let _objectArraySet: bool = false; - let _optObjectArray: Array | null = null; - let _en: Types.TestImport_Enum = 0; - let _enSet: bool = false; - let _optEnum: Box | null = null; - let _enumArray: Array = []; - let _enumArraySet: bool = false; - let _optEnumArray: Array | null> | null = null; - - while (numFields > 0) { - numFields--; - const field = reader.readString(); - - reader.context().push(field, "unknown", "searching for property type"); - if (field == "object") { - reader.context().push(field, "Types.TestImport_AnotherObject", "type found, reading property"); - const object = Types.TestImport_AnotherObject.read(reader); - _object = object; - _objectSet = true; - reader.context().pop(); - } - else if (field == "optObject") { - reader.context().push(field, "Types.TestImport_AnotherObject | null", "type found, reading property"); - let object: Types.TestImport_AnotherObject | null = null; - if (!reader.isNextNil()) { - object = Types.TestImport_AnotherObject.read(reader); - } - _optObject = object; - reader.context().pop(); - } - else if (field == "objectArray") { - reader.context().push(field, "Array", "type found, reading property"); - _objectArray = reader.readArray((reader: Read): Types.TestImport_AnotherObject => { - const object = Types.TestImport_AnotherObject.read(reader); - return object; - }); - _objectArraySet = true; - reader.context().pop(); - } - else if (field == "optObjectArray") { - reader.context().push(field, "Array | null", "type found, reading property"); - _optObjectArray = reader.readOptionalArray((reader: Read): Types.TestImport_AnotherObject | null => { - let object: Types.TestImport_AnotherObject | null = null; - if (!reader.isNextNil()) { - object = Types.TestImport_AnotherObject.read(reader); - } - return object; - }); - reader.context().pop(); - } - else if (field == "en") { - reader.context().push(field, "Types.TestImport_Enum", "type found, reading property"); - let value: Types.TestImport_Enum; - if (reader.isNextString()) { - value = Types.getTestImport_EnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeTestImport_EnumValue(value); - } - _en = value; - _enSet = true; - reader.context().pop(); - } - else if (field == "optEnum") { - reader.context().push(field, "Box | null", "type found, reading property"); - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getTestImport_EnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeTestImport_EnumValue(value.unwrap()); - } - } else { - value = null; - } - _optEnum = value; - reader.context().pop(); - } - else if (field == "enumArray") { - reader.context().push(field, "Array", "type found, reading property"); - _enumArray = reader.readArray((reader: Read): Types.TestImport_Enum => { - let value: Types.TestImport_Enum; - if (reader.isNextString()) { - value = Types.getTestImport_EnumValue(reader.readString()); - } else { - value = reader.readInt32(); - Types.sanitizeTestImport_EnumValue(value); - } - return value; - }); - _enumArraySet = true; - reader.context().pop(); - } - else if (field == "optEnumArray") { - reader.context().push(field, "Array | null> | null", "type found, reading property"); - _optEnumArray = reader.readOptionalArray((reader: Read): Box | null => { - let value: Box | null; - if (!reader.isNextNil()) { - if (reader.isNextString()) { - value = Box.from( - Types.getTestImport_EnumValue(reader.readString()) - ); - } else { - value = Box.from( - reader.readInt32() - ); - Types.sanitizeTestImport_EnumValue(value.unwrap()); - } - } else { - value = null; - } - return value; - }); - reader.context().pop(); - } - reader.context().pop(); - } - - if (!_object || !_objectSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'object: TestImport_AnotherObject'")); - } - if (!_objectArraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'objectArray: [TestImport_AnotherObject]'")); - } - if (!_enSet) { - throw new Error(reader.context().printWithContext("Missing required property: 'en: TestImport_Enum'")); - } - if (!_enumArraySet) { - throw new Error(reader.context().printWithContext("Missing required property: 'enumArray: [TestImport_Enum]'")); - } - - return { - object: _object, - optObject: _optObject, - objectArray: _objectArray, - optObjectArray: _optObjectArray, - en: _en, - optEnum: _optEnum, - enumArray: _enumArray, - optEnumArray: _optEnumArray - }; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/index.ts deleted file mode 100644 index f414d6c925..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/imported/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./TestImport_Module"; -export * from "./TestImport_Object"; -export * from "./TestImport_AnotherObject"; -export * from "./TestImport_Enum"; -export * from "./TestImport_Enum_Return"; -export * from "./TestImport_Env"; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/index.ts deleted file mode 100644 index a398b972b9..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/index.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { - Args_moduleMethod, - Args_objectMethod, - Args_optionalEnvMethod, - Args__if -} from "./Module"; -export { - Args_moduleMethod, - Args_objectMethod, - Args_optionalEnvMethod, - Args__if -}; -export { ModuleBase } from "./Module"; -export { CustomType } from "./CustomType"; -export { AnotherType } from "./AnotherType"; -export { CustomMapValue } from "./CustomMapValue"; -export { _else } from "./else"; -export { - CustomEnum, - getCustomEnumKey, - getCustomEnumValue, - sanitizeCustomEnumValue -} from "./CustomEnum"; -export { - _while, - getwhileKey, - getwhileValue, - sanitizewhileValue -} from "./while"; -export { TestImport_Module } from "./imported/TestImport_Module"; -export { TestImport_Object } from "./imported/TestImport_Object"; -export { TestImport_AnotherObject } from "./imported/TestImport_AnotherObject"; -export { TestImport_Env } from "./imported/TestImport_Env"; -export { - TestImport_Enum, - getTestImport_EnumKey, - getTestImport_EnumValue, - sanitizeTestImport_EnumValue -} from "./imported/TestImport_Enum"; -export { - TestImport_Enum_Return, - getTestImport_Enum_ReturnKey, - getTestImport_Enum_ReturnValue, - sanitizeTestImport_Enum_ReturnValue -} from "./imported/TestImport_Enum_Return"; -export { TestImport } from "./TestImport"; -export { Env } from "./Env"; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-as/while/index.ts b/packages/test-cases/cases/bind/sanity/output/wasm-as/while/index.ts deleted file mode 100644 index d15bc02f7b..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-as/while/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -export enum _while { - _for, - _in, - _MAX_ -} - -export function sanitizewhileValue(value: i32): void { - const valid = value >= 0 && value < _while._MAX_; - if (!valid) { - throw new Error("Invalid value for enum '_while': " + value.toString()); - } -} - -export function getwhileValue(key: string): _while { - if (key == "_for") { - return _while._for; - } - if (key == "_in") { - return _while._in; - } - - throw new Error("Invalid key for enum '_while': " + key); -} - -export function getwhileKey(value: _while): string { - sanitizewhileValue(value); - - switch (value) { - case _while._for: return "_for"; - case _while._in: return "_in"; - default: - throw new Error("Invalid value for enum '_while': " + value.toString()); - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/_else/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/_else/mod.rs deleted file mode 100644 index d474a4a346..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/_else/mod.rs +++ /dev/null @@ -1,49 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_else, - read_else, - serialize_else, - write_else -}; - - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Else { - #[serde(rename = "else")] - pub _else: String, -} - -impl Else { - pub fn new() -> Else { - Else { - _else: String::new(), - } - } - - pub fn to_buffer(args: &Else) -> Result, EncodeError> { - serialize_else(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result { - deserialize_else(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &Else, writer: &mut W) -> Result<(), EncodeError> { - write_else(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result { - read_else(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/_else/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/_else/serialization.rs deleted file mode 100644 index 5e0481623e..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/_else/serialization.rs +++ /dev/null @@ -1,68 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::Else; - -pub fn serialize_else(args: &Else) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) object-type: Else".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_else(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_else(args: &Else, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&1)?; - writer.context().push("else", "String", "writing property"); - writer.write_string("else")?; - writer.write_string(&args._else)?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_else(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing object-type: Else".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_else(&mut reader) -} - -pub fn read_else(reader: &mut R) -> Result { - let mut num_of_fields = reader.read_map_length()?; - - let mut _else: String = String::new(); - let mut _else_set = false; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "else" => { - reader.context().push(&field, "String", "type found, reading property"); - _else = reader.read_string()?; - _else_set = true; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_else_set { - return Err(DecodeError::MissingField("else: String.".to_string())); - } - - Ok(Else { - _else: _else, - }) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/_while/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/_while/mod.rs deleted file mode 100644 index a17acc23f4..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/_while/mod.rs +++ /dev/null @@ -1,51 +0,0 @@ -use polywrap_wasm_rs::{EnumTypeError}; -use serde::{Serialize, Deserialize}; -use std::convert::TryFrom; - -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum While { - _for, - _in, - _MAX_ -} - -pub fn sanitize_while_value(value: i32) -> Result<(), EnumTypeError> { - if value < 0 && value >= While::_MAX_ as i32 { - return Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum 'While': {}", value.to_string()))); - } - Ok(()) -} - -pub fn get_while_value(key: &str) -> Result { - match key { - "_for" => Ok(While::_for), - "_in" => Ok(While::_in), - "_MAX_" => Ok(While::_MAX_), - err => Err(EnumTypeError::EnumProcessingError(format!("Invalid key for enum 'While': {}", err))) - } -} - -pub fn get_while_key(value: While) -> Result { - if sanitize_while_value(value as i32).is_ok() { - match value { - While::_for => Ok("_for".to_string()), - While::_in => Ok("_in".to_string()), - While::_MAX_ => Ok("_MAX_".to_string()), - } - } else { - Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum 'While': {}", (value as i32).to_string()))) - } -} - -impl TryFrom for While { - type Error = EnumTypeError; - - fn try_from(v: i32) -> Result { - match v { - x if x == While::_for as i32 => Ok(While::_for), - x if x == While::_in as i32 => Ok(While::_in), - x if x == While::_MAX_ as i32 => Ok(While::_MAX_), - _ => Err(EnumTypeError::ParseEnumError(format!("Invalid value for enum 'While': {}", (v as i32).to_string()))), - } - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/mod.rs deleted file mode 100644 index 15091a2e37..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/mod.rs +++ /dev/null @@ -1,54 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_another_type, - read_another_type, - serialize_another_type, - write_another_type -}; - -use crate::CustomType; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct AnotherType { - pub prop: Option, - pub circular: Option, - #[serde(rename = "const")] - pub _const: Option, -} - -impl AnotherType { - pub fn new() -> AnotherType { - AnotherType { - prop: None, - circular: None, - _const: None, - } - } - - pub fn to_buffer(args: &AnotherType) -> Result, EncodeError> { - serialize_another_type(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result { - deserialize_another_type(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &AnotherType, writer: &mut W) -> Result<(), EncodeError> { - write_another_type(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result { - read_another_type(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs deleted file mode 100644 index f8c50b4675..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/another_type/serialization.rs +++ /dev/null @@ -1,97 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::AnotherType; - -use crate::CustomType; - -pub fn serialize_another_type(args: &AnotherType) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) object-type: AnotherType".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_another_type(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_another_type(args: &AnotherType, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&3)?; - writer.context().push("prop", "Option", "writing property"); - writer.write_string("prop")?; - writer.write_optional_string(&args.prop)?; - writer.context().pop(); - writer.context().push("circular", "Option", "writing property"); - writer.write_string("circular")?; - if args.circular.is_some() { - CustomType::write(args.circular.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - writer.context().push("const", "Option", "writing property"); - writer.write_string("const")?; - writer.write_optional_string(&args._const)?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_another_type(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing object-type: AnotherType".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_another_type(&mut reader) -} - -pub fn read_another_type(reader: &mut R) -> Result { - let mut num_of_fields = reader.read_map_length()?; - - let mut _prop: Option = None; - let mut _circular: Option = None; - let mut _const: Option = None; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "prop" => { - reader.context().push(&field, "Option", "type found, reading property"); - _prop = reader.read_optional_string()?; - reader.context().pop(); - } - "circular" => { - reader.context().push(&field, "Option", "type found, reading property"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(CustomType::read(reader)?); - } else { - object = None; - } - _circular = object; - reader.context().pop(); - } - "const" => { - reader.context().push(&field, "Option", "type found, reading property"); - _const = reader.read_optional_string()?; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - - Ok(AnotherType { - prop: _prop, - circular: _circular, - _const: _const, - }) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_enum/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_enum/mod.rs deleted file mode 100644 index dd8f6bb187..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_enum/mod.rs +++ /dev/null @@ -1,51 +0,0 @@ -use polywrap_wasm_rs::{EnumTypeError}; -use serde::{Serialize, Deserialize}; -use std::convert::TryFrom; - -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum CustomEnum { - STRING, - BYTES, - _MAX_ -} - -pub fn sanitize_custom_enum_value(value: i32) -> Result<(), EnumTypeError> { - if value < 0 && value >= CustomEnum::_MAX_ as i32 { - return Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum 'CustomEnum': {}", value.to_string()))); - } - Ok(()) -} - -pub fn get_custom_enum_value(key: &str) -> Result { - match key { - "STRING" => Ok(CustomEnum::STRING), - "BYTES" => Ok(CustomEnum::BYTES), - "_MAX_" => Ok(CustomEnum::_MAX_), - err => Err(EnumTypeError::EnumProcessingError(format!("Invalid key for enum 'CustomEnum': {}", err))) - } -} - -pub fn get_custom_enum_key(value: CustomEnum) -> Result { - if sanitize_custom_enum_value(value as i32).is_ok() { - match value { - CustomEnum::STRING => Ok("STRING".to_string()), - CustomEnum::BYTES => Ok("BYTES".to_string()), - CustomEnum::_MAX_ => Ok("_MAX_".to_string()), - } - } else { - Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum 'CustomEnum': {}", (value as i32).to_string()))) - } -} - -impl TryFrom for CustomEnum { - type Error = EnumTypeError; - - fn try_from(v: i32) -> Result { - match v { - x if x == CustomEnum::STRING as i32 => Ok(CustomEnum::STRING), - x if x == CustomEnum::BYTES as i32 => Ok(CustomEnum::BYTES), - x if x == CustomEnum::_MAX_ as i32 => Ok(CustomEnum::_MAX_), - _ => Err(EnumTypeError::ParseEnumError(format!("Invalid value for enum 'CustomEnum': {}", (v as i32).to_string()))), - } - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_map_value/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_map_value/mod.rs deleted file mode 100644 index e8c525f0ea..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_map_value/mod.rs +++ /dev/null @@ -1,48 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_custom_map_value, - read_custom_map_value, - serialize_custom_map_value, - write_custom_map_value -}; - - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct CustomMapValue { - pub foo: String, -} - -impl CustomMapValue { - pub fn new() -> CustomMapValue { - CustomMapValue { - foo: String::new(), - } - } - - pub fn to_buffer(args: &CustomMapValue) -> Result, EncodeError> { - serialize_custom_map_value(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result { - deserialize_custom_map_value(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &CustomMapValue, writer: &mut W) -> Result<(), EncodeError> { - write_custom_map_value(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result { - read_custom_map_value(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_map_value/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_map_value/serialization.rs deleted file mode 100644 index aafbc308bd..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_map_value/serialization.rs +++ /dev/null @@ -1,68 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::CustomMapValue; - -pub fn serialize_custom_map_value(args: &CustomMapValue) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) object-type: CustomMapValue".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_custom_map_value(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_custom_map_value(args: &CustomMapValue, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&1)?; - writer.context().push("foo", "String", "writing property"); - writer.write_string("foo")?; - writer.write_string(&args.foo)?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_custom_map_value(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing object-type: CustomMapValue".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_custom_map_value(&mut reader) -} - -pub fn read_custom_map_value(reader: &mut R) -> Result { - let mut num_of_fields = reader.read_map_length()?; - - let mut _foo: String = String::new(); - let mut _foo_set = false; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "foo" => { - reader.context().push(&field, "String", "type found, reading property"); - _foo = reader.read_string()?; - _foo_set = true; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_foo_set { - return Err(DecodeError::MissingField("foo: String.".to_string())); - } - - Ok(CustomMapValue { - foo: _foo, - }) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/mod.rs deleted file mode 100644 index a15c664dc8..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/mod.rs +++ /dev/null @@ -1,133 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_custom_type, - read_custom_type, - serialize_custom_type, - write_custom_type -}; - -use crate::AnotherType; -use crate::CustomEnum; -use crate::CustomMapValue; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct CustomType { - pub str: String, - pub opt_str: Option, - pub u: u32, - pub opt_u: Option, - pub u8: u8, - pub u16: u16, - pub u32: u32, - pub i: i32, - pub i8: i8, - pub i16: i16, - pub i32: i32, - pub bigint: BigInt, - pub opt_bigint: Option, - pub bignumber: BigNumber, - pub opt_bignumber: Option, - pub json: JSON::Value, - pub opt_json: Option, - pub bytes: Vec, - pub opt_bytes: Option>, - pub boolean: bool, - pub opt_boolean: Option, - pub u_array: Vec, - pub u_opt_array: Option>, - pub _opt_u_opt_array: Option>>, - pub opt_str_opt_array: Option>>, - pub u_array_array: Vec>, - pub u_opt_array_opt_array: Vec>>>, - pub u_array_opt_array_array: Vec>>>, - pub crazy_array: Option>>>>>>, - pub object: AnotherType, - pub opt_object: Option, - pub object_array: Vec, - pub opt_object_array: Option>>, - pub en: CustomEnum, - pub opt_enum: Option, - pub enum_array: Vec, - pub opt_enum_array: Option>>, - pub map: Map, - pub map_of_arr: Map>, - pub map_of_obj: Map, - pub map_of_arr_of_obj: Map>, - pub map_custom_value: Map>, -} - -impl CustomType { - pub fn new() -> CustomType { - CustomType { - str: String::new(), - opt_str: None, - u: 0, - opt_u: None, - u8: 0, - u16: 0, - u32: 0, - i: 0, - i8: 0, - i16: 0, - i32: 0, - bigint: BigInt::default(), - opt_bigint: None, - bignumber: BigNumber::default(), - opt_bignumber: None, - json: JSON::Value::Null, - opt_json: None, - bytes: vec![], - opt_bytes: None, - boolean: false, - opt_boolean: None, - u_array: vec![], - u_opt_array: None, - _opt_u_opt_array: None, - opt_str_opt_array: None, - u_array_array: vec![], - u_opt_array_opt_array: vec![], - u_array_opt_array_array: vec![], - crazy_array: None, - object: AnotherType::new(), - opt_object: None, - object_array: vec![], - opt_object_array: None, - en: CustomEnum::_MAX_, - opt_enum: None, - enum_array: vec![], - opt_enum_array: None, - map: Map::::new(), - map_of_arr: Map::>::new(), - map_of_obj: Map::::new(), - map_of_arr_of_obj: Map::>::new(), - map_custom_value: Map::>::new(), - } - } - - pub fn to_buffer(args: &CustomType) -> Result, EncodeError> { - serialize_custom_type(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result { - deserialize_custom_type(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &CustomType, writer: &mut W) -> Result<(), EncodeError> { - write_custom_type(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result { - read_custom_type(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs deleted file mode 100644 index a9faa0a662..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/custom_type/serialization.rs +++ /dev/null @@ -1,851 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::CustomType; - -use crate::AnotherType; -use crate::{ - CustomEnum, - get_custom_enum_value, - sanitize_custom_enum_value -}; -use crate::CustomMapValue; - -pub fn serialize_custom_type(args: &CustomType) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) object-type: CustomType".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_custom_type(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_custom_type(args: &CustomType, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&42)?; - writer.context().push("str", "String", "writing property"); - writer.write_string("str")?; - writer.write_string(&args.str)?; - writer.context().pop(); - writer.context().push("optStr", "Option", "writing property"); - writer.write_string("optStr")?; - writer.write_optional_string(&args.opt_str)?; - writer.context().pop(); - writer.context().push("u", "u32", "writing property"); - writer.write_string("u")?; - writer.write_u32(&args.u)?; - writer.context().pop(); - writer.context().push("optU", "Option", "writing property"); - writer.write_string("optU")?; - writer.write_optional_u32(&args.opt_u)?; - writer.context().pop(); - writer.context().push("u8", "u8", "writing property"); - writer.write_string("u8")?; - writer.write_u8(&args.u8)?; - writer.context().pop(); - writer.context().push("u16", "u16", "writing property"); - writer.write_string("u16")?; - writer.write_u16(&args.u16)?; - writer.context().pop(); - writer.context().push("u32", "u32", "writing property"); - writer.write_string("u32")?; - writer.write_u32(&args.u32)?; - writer.context().pop(); - writer.context().push("i", "i32", "writing property"); - writer.write_string("i")?; - writer.write_i32(&args.i)?; - writer.context().pop(); - writer.context().push("i8", "i8", "writing property"); - writer.write_string("i8")?; - writer.write_i8(&args.i8)?; - writer.context().pop(); - writer.context().push("i16", "i16", "writing property"); - writer.write_string("i16")?; - writer.write_i16(&args.i16)?; - writer.context().pop(); - writer.context().push("i32", "i32", "writing property"); - writer.write_string("i32")?; - writer.write_i32(&args.i32)?; - writer.context().pop(); - writer.context().push("bigint", "BigInt", "writing property"); - writer.write_string("bigint")?; - writer.write_bigint(&args.bigint)?; - writer.context().pop(); - writer.context().push("optBigint", "Option", "writing property"); - writer.write_string("optBigint")?; - writer.write_optional_bigint(&args.opt_bigint)?; - writer.context().pop(); - writer.context().push("bignumber", "BigNumber", "writing property"); - writer.write_string("bignumber")?; - writer.write_bignumber(&args.bignumber)?; - writer.context().pop(); - writer.context().push("optBignumber", "Option", "writing property"); - writer.write_string("optBignumber")?; - writer.write_optional_bignumber(&args.opt_bignumber)?; - writer.context().pop(); - writer.context().push("json", "JSON::Value", "writing property"); - writer.write_string("json")?; - writer.write_json(&args.json)?; - writer.context().pop(); - writer.context().push("optJson", "Option", "writing property"); - writer.write_string("optJson")?; - writer.write_optional_json(&args.opt_json)?; - writer.context().pop(); - writer.context().push("bytes", "Vec", "writing property"); - writer.write_string("bytes")?; - writer.write_bytes(&args.bytes)?; - writer.context().pop(); - writer.context().push("optBytes", "Option>", "writing property"); - writer.write_string("optBytes")?; - writer.write_optional_bytes(&args.opt_bytes)?; - writer.context().pop(); - writer.context().push("boolean", "bool", "writing property"); - writer.write_string("boolean")?; - writer.write_bool(&args.boolean)?; - writer.context().pop(); - writer.context().push("optBoolean", "Option", "writing property"); - writer.write_string("optBoolean")?; - writer.write_optional_bool(&args.opt_boolean)?; - writer.context().pop(); - writer.context().push("u_array", "Vec", "writing property"); - writer.write_string("u_array")?; - writer.write_array(&args.u_array, |writer, item| { - writer.write_u32(item) - })?; - writer.context().pop(); - writer.context().push("uOpt_array", "Option>", "writing property"); - writer.write_string("uOpt_array")?; - writer.write_optional_array(&args.u_opt_array, |writer, item| { - writer.write_u32(item) - })?; - writer.context().pop(); - writer.context().push("_opt_uOptArray", "Option>>", "writing property"); - writer.write_string("_opt_uOptArray")?; - writer.write_optional_array(&args._opt_u_opt_array, |writer, item| { - writer.write_optional_u32(item) - })?; - writer.context().pop(); - writer.context().push("optStrOptArray", "Option>>", "writing property"); - writer.write_string("optStrOptArray")?; - writer.write_optional_array(&args.opt_str_opt_array, |writer, item| { - writer.write_optional_string(item) - })?; - writer.context().pop(); - writer.context().push("uArrayArray", "Vec>", "writing property"); - writer.write_string("uArrayArray")?; - writer.write_array(&args.u_array_array, |writer, item| { - writer.write_array(item, |writer, item| { - writer.write_u32(item) - }) - })?; - writer.context().pop(); - writer.context().push("uOptArrayOptArray", "Vec>>>", "writing property"); - writer.write_string("uOptArrayOptArray")?; - writer.write_array(&args.u_opt_array_opt_array, |writer, item| { - writer.write_optional_array(item, |writer, item| { - writer.write_optional_u32(item) - }) - })?; - writer.context().pop(); - writer.context().push("uArrayOptArrayArray", "Vec>>>", "writing property"); - writer.write_string("uArrayOptArrayArray")?; - writer.write_array(&args.u_array_opt_array_array, |writer, item| { - writer.write_optional_array(item, |writer, item| { - writer.write_array(item, |writer, item| { - writer.write_u32(item) - }) - }) - })?; - writer.context().pop(); - writer.context().push("crazyArray", "Option>>>>>>", "writing property"); - writer.write_string("crazyArray")?; - writer.write_optional_array(&args.crazy_array, |writer, item| { - writer.write_optional_array(item, |writer, item| { - writer.write_array(item, |writer, item| { - writer.write_optional_array(item, |writer, item| { - writer.write_u32(item) - }) - }) - }) - })?; - writer.context().pop(); - writer.context().push("object", "AnotherType", "writing property"); - writer.write_string("object")?; - AnotherType::write(&args.object, writer)?; - writer.context().pop(); - writer.context().push("optObject", "Option", "writing property"); - writer.write_string("optObject")?; - if args.opt_object.is_some() { - AnotherType::write(args.opt_object.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - writer.context().push("objectArray", "Vec", "writing property"); - writer.write_string("objectArray")?; - writer.write_array(&args.object_array, |writer, item| { - AnotherType::write(item, writer) - })?; - writer.context().pop(); - writer.context().push("optObjectArray", "Option>>", "writing property"); - writer.write_string("optObjectArray")?; - writer.write_optional_array(&args.opt_object_array, |writer, item| { - if item.is_some() { - AnotherType::write(item.as_ref().as_ref().unwrap(), writer) - } else { - writer.write_nil() - } - })?; - writer.context().pop(); - writer.context().push("en", "CustomEnum", "writing property"); - writer.write_string("en")?; - writer.write_i32(&(args.en as i32))?; - writer.context().pop(); - writer.context().push("optEnum", "Option", "writing property"); - writer.write_string("optEnum")?; - writer.write_optional_i32(&args.opt_enum.map(|f| f as i32))?; - writer.context().pop(); - writer.context().push("enumArray", "Vec", "writing property"); - writer.write_string("enumArray")?; - writer.write_array(&args.enum_array, |writer, item| { - writer.write_i32(&(*item as i32)) - })?; - writer.context().pop(); - writer.context().push("optEnumArray", "Option>>", "writing property"); - writer.write_string("optEnumArray")?; - writer.write_optional_array(&args.opt_enum_array, |writer, item| { - writer.write_optional_i32(&item.map(|f| f as i32)) - })?; - writer.context().pop(); - writer.context().push("map", "Map", "writing property"); - writer.write_string("map")?; - writer.write_ext_generic_map(&args.map, |writer, key| { - writer.write_string(key) - }, |writer, value| { - writer.write_i32(value) - })?; - writer.context().pop(); - writer.context().push("mapOfArr", "Map>", "writing property"); - writer.write_string("mapOfArr")?; - writer.write_ext_generic_map(&args.map_of_arr, |writer, key| { - writer.write_string(key) - }, |writer, value| { - writer.write_array(value, |writer, item| { - writer.write_i32(item) - }) - })?; - writer.context().pop(); - writer.context().push("mapOfObj", "Map", "writing property"); - writer.write_string("mapOfObj")?; - writer.write_ext_generic_map(&args.map_of_obj, |writer, key| { - writer.write_string(key) - }, |writer, value| { - AnotherType::write(value, writer) - })?; - writer.context().pop(); - writer.context().push("mapOfArrOfObj", "Map>", "writing property"); - writer.write_string("mapOfArrOfObj")?; - writer.write_ext_generic_map(&args.map_of_arr_of_obj, |writer, key| { - writer.write_string(key) - }, |writer, value| { - writer.write_array(value, |writer, item| { - AnotherType::write(item, writer) - }) - })?; - writer.context().pop(); - writer.context().push("mapCustomValue", "Map>", "writing property"); - writer.write_string("mapCustomValue")?; - writer.write_ext_generic_map(&args.map_custom_value, |writer, key| { - writer.write_string(key) - }, |writer, value| { - if value.is_some() { - CustomMapValue::write(value.as_ref().as_ref().unwrap(), writer) - } else { - writer.write_nil() - } - })?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_custom_type(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing object-type: CustomType".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_custom_type(&mut reader) -} - -pub fn read_custom_type(reader: &mut R) -> Result { - let mut num_of_fields = reader.read_map_length()?; - - let mut _str: String = String::new(); - let mut _str_set = false; - let mut _opt_str: Option = None; - let mut _u: u32 = 0; - let mut _u_set = false; - let mut _opt_u: Option = None; - let mut _u8: u8 = 0; - let mut _u8_set = false; - let mut _u16: u16 = 0; - let mut _u16_set = false; - let mut _u32: u32 = 0; - let mut _u32_set = false; - let mut _i: i32 = 0; - let mut _i_set = false; - let mut _i8: i8 = 0; - let mut _i8_set = false; - let mut _i16: i16 = 0; - let mut _i16_set = false; - let mut _i32: i32 = 0; - let mut _i32_set = false; - let mut _bigint: BigInt = BigInt::default(); - let mut _bigint_set = false; - let mut _opt_bigint: Option = None; - let mut _bignumber: BigNumber = BigNumber::default(); - let mut _bignumber_set = false; - let mut _opt_bignumber: Option = None; - let mut _json: JSON::Value = JSON::Value::Null; - let mut _json_set = false; - let mut _opt_json: Option = None; - let mut _bytes: Vec = vec![]; - let mut _bytes_set = false; - let mut _opt_bytes: Option> = None; - let mut _boolean: bool = false; - let mut _boolean_set = false; - let mut _opt_boolean: Option = None; - let mut _u_array: Vec = vec![]; - let mut _u_array_set = false; - let mut _u_opt_array: Option> = None; - let mut __opt_u_opt_array: Option>> = None; - let mut _opt_str_opt_array: Option>> = None; - let mut _u_array_array: Vec> = vec![]; - let mut _u_array_array_set = false; - let mut _u_opt_array_opt_array: Vec>>> = vec![]; - let mut _u_opt_array_opt_array_set = false; - let mut _u_array_opt_array_array: Vec>>> = vec![]; - let mut _u_array_opt_array_array_set = false; - let mut _crazy_array: Option>>>>>> = None; - let mut _object: AnotherType = AnotherType::new(); - let mut _object_set = false; - let mut _opt_object: Option = None; - let mut _object_array: Vec = vec![]; - let mut _object_array_set = false; - let mut _opt_object_array: Option>> = None; - let mut _en: CustomEnum = CustomEnum::_MAX_; - let mut _en_set = false; - let mut _opt_enum: Option = None; - let mut _enum_array: Vec = vec![]; - let mut _enum_array_set = false; - let mut _opt_enum_array: Option>> = None; - let mut _map: Map = Map::::new(); - let mut _map_set = false; - let mut _map_of_arr: Map> = Map::>::new(); - let mut _map_of_arr_set = false; - let mut _map_of_obj: Map = Map::::new(); - let mut _map_of_obj_set = false; - let mut _map_of_arr_of_obj: Map> = Map::>::new(); - let mut _map_of_arr_of_obj_set = false; - let mut _map_custom_value: Map> = Map::>::new(); - let mut _map_custom_value_set = false; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "str" => { - reader.context().push(&field, "String", "type found, reading property"); - _str = reader.read_string()?; - _str_set = true; - reader.context().pop(); - } - "optStr" => { - reader.context().push(&field, "Option", "type found, reading property"); - _opt_str = reader.read_optional_string()?; - reader.context().pop(); - } - "u" => { - reader.context().push(&field, "u32", "type found, reading property"); - _u = reader.read_u32()?; - _u_set = true; - reader.context().pop(); - } - "optU" => { - reader.context().push(&field, "Option", "type found, reading property"); - _opt_u = reader.read_optional_u32()?; - reader.context().pop(); - } - "u8" => { - reader.context().push(&field, "u8", "type found, reading property"); - _u8 = reader.read_u8()?; - _u8_set = true; - reader.context().pop(); - } - "u16" => { - reader.context().push(&field, "u16", "type found, reading property"); - _u16 = reader.read_u16()?; - _u16_set = true; - reader.context().pop(); - } - "u32" => { - reader.context().push(&field, "u32", "type found, reading property"); - _u32 = reader.read_u32()?; - _u32_set = true; - reader.context().pop(); - } - "i" => { - reader.context().push(&field, "i32", "type found, reading property"); - _i = reader.read_i32()?; - _i_set = true; - reader.context().pop(); - } - "i8" => { - reader.context().push(&field, "i8", "type found, reading property"); - _i8 = reader.read_i8()?; - _i8_set = true; - reader.context().pop(); - } - "i16" => { - reader.context().push(&field, "i16", "type found, reading property"); - _i16 = reader.read_i16()?; - _i16_set = true; - reader.context().pop(); - } - "i32" => { - reader.context().push(&field, "i32", "type found, reading property"); - _i32 = reader.read_i32()?; - _i32_set = true; - reader.context().pop(); - } - "bigint" => { - reader.context().push(&field, "BigInt", "type found, reading property"); - _bigint = reader.read_bigint()?; - _bigint_set = true; - reader.context().pop(); - } - "optBigint" => { - reader.context().push(&field, "Option", "type found, reading property"); - _opt_bigint = reader.read_optional_bigint()?; - reader.context().pop(); - } - "bignumber" => { - reader.context().push(&field, "BigNumber", "type found, reading property"); - _bignumber = reader.read_bignumber()?; - _bignumber_set = true; - reader.context().pop(); - } - "optBignumber" => { - reader.context().push(&field, "Option", "type found, reading property"); - _opt_bignumber = reader.read_optional_bignumber()?; - reader.context().pop(); - } - "json" => { - reader.context().push(&field, "JSON::Value", "type found, reading property"); - _json = reader.read_json()?; - _json_set = true; - reader.context().pop(); - } - "optJson" => { - reader.context().push(&field, "Option", "type found, reading property"); - _opt_json = reader.read_optional_json()?; - reader.context().pop(); - } - "bytes" => { - reader.context().push(&field, "Vec", "type found, reading property"); - _bytes = reader.read_bytes()?; - _bytes_set = true; - reader.context().pop(); - } - "optBytes" => { - reader.context().push(&field, "Option>", "type found, reading property"); - _opt_bytes = reader.read_optional_bytes()?; - reader.context().pop(); - } - "boolean" => { - reader.context().push(&field, "bool", "type found, reading property"); - _boolean = reader.read_bool()?; - _boolean_set = true; - reader.context().pop(); - } - "optBoolean" => { - reader.context().push(&field, "Option", "type found, reading property"); - _opt_boolean = reader.read_optional_bool()?; - reader.context().pop(); - } - "u_array" => { - reader.context().push(&field, "Vec", "type found, reading property"); - _u_array = reader.read_array(|reader| { - reader.read_u32() - })?; - _u_array_set = true; - reader.context().pop(); - } - "uOpt_array" => { - reader.context().push(&field, "Option>", "type found, reading property"); - _u_opt_array = reader.read_optional_array(|reader| { - reader.read_u32() - })?; - reader.context().pop(); - } - "_opt_uOptArray" => { - reader.context().push(&field, "Option>>", "type found, reading property"); - __opt_u_opt_array = reader.read_optional_array(|reader| { - reader.read_optional_u32() - })?; - reader.context().pop(); - } - "optStrOptArray" => { - reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_str_opt_array = reader.read_optional_array(|reader| { - reader.read_optional_string() - })?; - reader.context().pop(); - } - "uArrayArray" => { - reader.context().push(&field, "Vec>", "type found, reading property"); - _u_array_array = reader.read_array(|reader| { - reader.read_array(|reader| { - reader.read_u32() - }) - })?; - _u_array_array_set = true; - reader.context().pop(); - } - "uOptArrayOptArray" => { - reader.context().push(&field, "Vec>>>", "type found, reading property"); - _u_opt_array_opt_array = reader.read_array(|reader| { - reader.read_optional_array(|reader| { - reader.read_optional_u32() - }) - })?; - _u_opt_array_opt_array_set = true; - reader.context().pop(); - } - "uArrayOptArrayArray" => { - reader.context().push(&field, "Vec>>>", "type found, reading property"); - _u_array_opt_array_array = reader.read_array(|reader| { - reader.read_optional_array(|reader| { - reader.read_array(|reader| { - reader.read_u32() - }) - }) - })?; - _u_array_opt_array_array_set = true; - reader.context().pop(); - } - "crazyArray" => { - reader.context().push(&field, "Option>>>>>>", "type found, reading property"); - _crazy_array = reader.read_optional_array(|reader| { - reader.read_optional_array(|reader| { - reader.read_array(|reader| { - reader.read_optional_array(|reader| { - reader.read_u32() - }) - }) - }) - })?; - reader.context().pop(); - } - "object" => { - reader.context().push(&field, "AnotherType", "type found, reading property"); - let object = AnotherType::read(reader)?; - _object = object; - _object_set = true; - reader.context().pop(); - } - "optObject" => { - reader.context().push(&field, "Option", "type found, reading property"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(AnotherType::read(reader)?); - } else { - object = None; - } - _opt_object = object; - reader.context().pop(); - } - "objectArray" => { - reader.context().push(&field, "Vec", "type found, reading property"); - _object_array = reader.read_array(|reader| { - let object = AnotherType::read(reader)?; - Ok(object) - })?; - _object_array_set = true; - reader.context().pop(); - } - "optObjectArray" => { - reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_object_array = reader.read_optional_array(|reader| { - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(AnotherType::read(reader)?); - } else { - object = None; - } - Ok(object) - })?; - reader.context().pop(); - } - "en" => { - reader.context().push(&field, "CustomEnum", "type found, reading property"); - let mut value: CustomEnum = CustomEnum::_MAX_; - if reader.is_next_string()? { - value = get_custom_enum_value(&reader.read_string()?)?; - } else { - value = CustomEnum::try_from(reader.read_i32()?)?; - sanitize_custom_enum_value(value as i32)?; - } - _en = value; - _en_set = true; - reader.context().pop(); - } - "optEnum" => { - reader.context().push(&field, "Option", "type found, reading property"); - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_custom_enum_value(&reader.read_string()?)?); - } else { - value = Some(CustomEnum::try_from(reader.read_i32()?)?); - sanitize_custom_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - _opt_enum = value; - reader.context().pop(); - } - "enumArray" => { - reader.context().push(&field, "Vec", "type found, reading property"); - _enum_array = reader.read_array(|reader| { - let mut value: CustomEnum = CustomEnum::_MAX_; - if reader.is_next_string()? { - value = get_custom_enum_value(&reader.read_string()?)?; - } else { - value = CustomEnum::try_from(reader.read_i32()?)?; - sanitize_custom_enum_value(value as i32)?; - } - Ok(value) - })?; - _enum_array_set = true; - reader.context().pop(); - } - "optEnumArray" => { - reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_enum_array = reader.read_optional_array(|reader| { - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_custom_enum_value(&reader.read_string()?)?); - } else { - value = Some(CustomEnum::try_from(reader.read_i32()?)?); - sanitize_custom_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - Ok(value) - })?; - reader.context().pop(); - } - "map" => { - reader.context().push(&field, "Map", "type found, reading property"); - _map = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - reader.read_i32() - })?; - _map_set = true; - reader.context().pop(); - } - "mapOfArr" => { - reader.context().push(&field, "Map>", "type found, reading property"); - _map_of_arr = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - reader.read_array(|reader| { - reader.read_i32() - }) - })?; - _map_of_arr_set = true; - reader.context().pop(); - } - "mapOfObj" => { - reader.context().push(&field, "Map", "type found, reading property"); - _map_of_obj = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - let object = AnotherType::read(reader)?; - Ok(object) - })?; - _map_of_obj_set = true; - reader.context().pop(); - } - "mapOfArrOfObj" => { - reader.context().push(&field, "Map>", "type found, reading property"); - _map_of_arr_of_obj = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - reader.read_array(|reader| { - let object = AnotherType::read(reader)?; - Ok(object) - }) - })?; - _map_of_arr_of_obj_set = true; - reader.context().pop(); - } - "mapCustomValue" => { - reader.context().push(&field, "Map>", "type found, reading property"); - _map_custom_value = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(CustomMapValue::read(reader)?); - } else { - object = None; - } - Ok(object) - })?; - _map_custom_value_set = true; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_str_set { - return Err(DecodeError::MissingField("str: String.".to_string())); - } - if !_u_set { - return Err(DecodeError::MissingField("u: UInt.".to_string())); - } - if !_u8_set { - return Err(DecodeError::MissingField("u8: UInt8.".to_string())); - } - if !_u16_set { - return Err(DecodeError::MissingField("u16: UInt16.".to_string())); - } - if !_u32_set { - return Err(DecodeError::MissingField("u32: UInt32.".to_string())); - } - if !_i_set { - return Err(DecodeError::MissingField("i: Int.".to_string())); - } - if !_i8_set { - return Err(DecodeError::MissingField("i8: Int8.".to_string())); - } - if !_i16_set { - return Err(DecodeError::MissingField("i16: Int16.".to_string())); - } - if !_i32_set { - return Err(DecodeError::MissingField("i32: Int32.".to_string())); - } - if !_bigint_set { - return Err(DecodeError::MissingField("bigint: BigInt.".to_string())); - } - if !_bignumber_set { - return Err(DecodeError::MissingField("bignumber: BigNumber.".to_string())); - } - if !_json_set { - return Err(DecodeError::MissingField("json: JSON.".to_string())); - } - if !_bytes_set { - return Err(DecodeError::MissingField("bytes: Bytes.".to_string())); - } - if !_boolean_set { - return Err(DecodeError::MissingField("boolean: Boolean.".to_string())); - } - if !_u_array_set { - return Err(DecodeError::MissingField("u_array: [UInt].".to_string())); - } - if !_u_array_array_set { - return Err(DecodeError::MissingField("uArrayArray: [[UInt]].".to_string())); - } - if !_u_opt_array_opt_array_set { - return Err(DecodeError::MissingField("uOptArrayOptArray: [[UInt32]].".to_string())); - } - if !_u_array_opt_array_array_set { - return Err(DecodeError::MissingField("uArrayOptArrayArray: [[[UInt32]]].".to_string())); - } - if !_object_set { - return Err(DecodeError::MissingField("object: AnotherType.".to_string())); - } - if !_object_array_set { - return Err(DecodeError::MissingField("objectArray: [AnotherType].".to_string())); - } - if !_en_set { - return Err(DecodeError::MissingField("en: CustomEnum.".to_string())); - } - if !_enum_array_set { - return Err(DecodeError::MissingField("enumArray: [CustomEnum].".to_string())); - } - if !_map_set { - return Err(DecodeError::MissingField("map: Map.".to_string())); - } - if !_map_of_arr_set { - return Err(DecodeError::MissingField("mapOfArr: Map.".to_string())); - } - if !_map_of_obj_set { - return Err(DecodeError::MissingField("mapOfObj: Map.".to_string())); - } - if !_map_of_arr_of_obj_set { - return Err(DecodeError::MissingField("mapOfArrOfObj: Map.".to_string())); - } - if !_map_custom_value_set { - return Err(DecodeError::MissingField("mapCustomValue: Map.".to_string())); - } - - Ok(CustomType { - str: _str, - opt_str: _opt_str, - u: _u, - opt_u: _opt_u, - u8: _u8, - u16: _u16, - u32: _u32, - i: _i, - i8: _i8, - i16: _i16, - i32: _i32, - bigint: _bigint, - opt_bigint: _opt_bigint, - bignumber: _bignumber, - opt_bignumber: _opt_bignumber, - json: _json, - opt_json: _opt_json, - bytes: _bytes, - opt_bytes: _opt_bytes, - boolean: _boolean, - opt_boolean: _opt_boolean, - u_array: _u_array, - u_opt_array: _u_opt_array, - _opt_u_opt_array: __opt_u_opt_array, - opt_str_opt_array: _opt_str_opt_array, - u_array_array: _u_array_array, - u_opt_array_opt_array: _u_opt_array_opt_array, - u_array_opt_array_array: _u_array_opt_array_array, - crazy_array: _crazy_array, - object: _object, - opt_object: _opt_object, - object_array: _object_array, - opt_object_array: _opt_object_array, - en: _en, - opt_enum: _opt_enum, - enum_array: _enum_array, - opt_enum_array: _opt_enum_array, - map: _map, - map_of_arr: _map_of_arr, - map_of_obj: _map_of_obj, - map_of_arr_of_obj: _map_of_arr_of_obj, - map_custom_value: _map_custom_value, - }) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/entry.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/entry.rs deleted file mode 100644 index 9a410f9c8e..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/entry.rs +++ /dev/null @@ -1,42 +0,0 @@ -use crate::{ - module_method_wrapped, - object_method_wrapped, - optional_env_method_wrapped, - if_wrapped -}; -use polywrap_wasm_rs::{ - abort, - invoke, - InvokeArgs, -}; -use crate::module::Module; - -#[no_mangle] -pub extern "C" fn _wrap_invoke(method_size: u32, args_size: u32, env_size: u32) -> bool { - // Ensure the abort handler is properly setup - abort::wrap_abort_setup(); - - let args: InvokeArgs = invoke::wrap_invoke_args(method_size, args_size); - let result: Vec; - - match args.method.as_str() { - "moduleMethod" => { - result = module_method_wrapped(args.args.as_slice(), env_size); - } - "objectMethod" => { - result = object_method_wrapped(args.args.as_slice(), env_size); - } - "optionalEnvMethod" => { - result = optional_env_method_wrapped(args.args.as_slice(), env_size); - } - "if" => { - result = if_wrapped(args.args.as_slice(), env_size); - } - _ => { - invoke::wrap_invoke_error(format!("Could not find invoke function {}", args.method)); - return false; - } - }; - invoke::wrap_invoke_result(result); - return true; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/env/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/env/mod.rs deleted file mode 100644 index 2a79852d21..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/env/mod.rs +++ /dev/null @@ -1,51 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_env, - read_env, - serialize_env, - write_env -}; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Env { - pub prop: String, - pub opt_prop: Option, - pub opt_map: Option>>, -} - -impl Env { - pub fn new() -> Env { - Env { - prop: String::new(), - opt_prop: None, - opt_map: None, - } - } - - pub fn to_buffer(args: &Env) -> Result, EncodeError> { - serialize_env(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result { - deserialize_env(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &Env, writer: &mut W) -> Result<(), EncodeError> { - write_env(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result { - read_env(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/env/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/env/serialization.rs deleted file mode 100644 index df2a91bc9c..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/env/serialization.rs +++ /dev/null @@ -1,98 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::Env; - -pub fn serialize_env(args: &Env) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) env-type: Env".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_env(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_env(args: &Env, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&3)?; - writer.context().push("prop", "String", "writing property"); - writer.write_string("prop")?; - writer.write_string(&args.prop)?; - writer.context().pop(); - writer.context().push("optProp", "Option", "writing property"); - writer.write_string("optProp")?; - writer.write_optional_string(&args.opt_prop)?; - writer.context().pop(); - writer.context().push("optMap", "Option>>", "writing property"); - writer.write_string("optMap")?; - writer.write_optional_ext_generic_map(&args.opt_map, |writer, key| { - writer.write_string(key) - }, |writer, value| { - writer.write_optional_i32(value) - })?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_env(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing env-type: Env".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_env(&mut reader) -} - -pub fn read_env(reader: &mut R) -> Result { - let mut num_of_fields = reader.read_map_length()?; - - let mut _prop: String = String::new(); - let mut _prop_set = false; - let mut _opt_prop: Option = None; - let mut _opt_map: Option>> = None; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "prop" => { - reader.context().push(&field, "String", "type found, reading property"); - _prop = reader.read_string()?; - _prop_set = true; - reader.context().pop(); - } - "optProp" => { - reader.context().push(&field, "Option", "type found, reading property"); - _opt_prop = reader.read_optional_string()?; - reader.context().pop(); - } - "optMap" => { - reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_map = reader.read_optional_ext_generic_map(|reader| { - reader.read_string()? - }, |reader| { - reader.read_optional_i32() - })?; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_prop_set { - return Err(DecodeError::MissingField("prop: String.".to_string())); - } - - Ok(Env { - prop: _prop, - opt_prop: _opt_prop, - opt_map: _opt_map, - }) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/mod.rs deleted file mode 100644 index 6d97b84f52..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub mod test_import_object; -pub use test_import_object::*; -pub mod test_import_another_object; -pub use test_import_another_object::*; -pub mod test_import_enum; -pub use test_import_enum::*; -pub mod test_import_enum_return; -pub use test_import_enum_return::*; -pub mod test_import_module; -pub use test_import_module::*; -pub mod test_import_env; -pub use test_import_env::*; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/mod.rs deleted file mode 100644 index 838d59b797..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/mod.rs +++ /dev/null @@ -1,49 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_test_import_another_object, - read_test_import_another_object, - serialize_test_import_another_object, - write_test_import_another_object -}; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportAnotherObject { - pub prop: String, -} - -impl TestImportAnotherObject { - pub const URI: &'static str = "testimport.uri.eth"; - - pub fn new() -> TestImportAnotherObject { - TestImportAnotherObject { - prop: String::new(), - } - } - - pub fn to_buffer(args: &TestImportAnotherObject) -> Result, EncodeError> { - serialize_test_import_another_object(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result { - deserialize_test_import_another_object(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &TestImportAnotherObject, writer: &mut W) -> Result<(), EncodeError> { - write_test_import_another_object(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result { - read_test_import_another_object(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/serialization.rs deleted file mode 100644 index 43d97eb245..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_another_object/serialization.rs +++ /dev/null @@ -1,68 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::TestImportAnotherObject; - -pub fn serialize_test_import_another_object(args: &TestImportAnotherObject) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported object-type: TestImportAnotherObject".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_test_import_another_object(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_test_import_another_object(args: &TestImportAnotherObject, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&1)?; - writer.context().push("prop", "String", "writing property"); - writer.write_string("prop")?; - writer.write_string(&args.prop)?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_test_import_another_object(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing imported object-type: TestImportAnotherObject".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_test_import_another_object(&mut reader) -} - -pub fn read_test_import_another_object(reader: &mut R) -> Result { - let mut num_of_fields = reader.read_map_length()?; - - let mut _prop: String = String::new(); - let mut _prop_set = false; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "prop" => { - reader.context().push(&field, "String", "type found, reading property"); - _prop = reader.read_string()?; - _prop_set = true; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_prop_set { - return Err(DecodeError::MissingField("prop: String.".to_string())); - } - - Ok(TestImportAnotherObject { - prop: _prop, - }) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_enum/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_enum/mod.rs deleted file mode 100644 index e0426d64f1..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_enum/mod.rs +++ /dev/null @@ -1,51 +0,0 @@ -use polywrap_wasm_rs::EnumTypeError; -use serde::{Serialize, Deserialize}; -use std::convert::TryFrom; - -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum TestImportEnum { - STRING, - BYTES, - _MAX_ -} - -pub fn sanitize_test_import_enum_value(value: i32) -> Result<(), EnumTypeError> { - if value < 0 && value >= TestImportEnum::_MAX_ as i32 { - return Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum 'TestImportEnum': {}", value.to_string()))); - } - Ok(()) -} - -pub fn get_test_import_enum_value(key: &str) -> Result { - match key { - "STRING" => Ok(TestImportEnum::STRING), - "BYTES" => Ok(TestImportEnum::BYTES), - "_MAX_" => Ok(TestImportEnum::_MAX_), - err => Err(EnumTypeError::EnumProcessingError(format!("Invalid key for enum 'TestImportEnum': {}", err))) - } -} - -pub fn get_test_import_enum_key(value: TestImportEnum) -> Result { - if sanitize_test_import_enum_value(value as i32).is_ok() { - match value { - TestImportEnum::STRING => Ok("STRING".to_string()), - TestImportEnum::BYTES => Ok("BYTES".to_string()), - TestImportEnum::_MAX_ => Ok("_MAX_".to_string()), - } - } else { - Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum 'TestImportEnum': {}", (value as i32).to_string()))) - } -} - -impl TryFrom for TestImportEnum { - type Error = EnumTypeError; - - fn try_from(v: i32) -> Result { - match v { - x if x == TestImportEnum::STRING as i32 => Ok(TestImportEnum::STRING), - x if x == TestImportEnum::BYTES as i32 => Ok(TestImportEnum::BYTES), - x if x == TestImportEnum::_MAX_ as i32 => Ok(TestImportEnum::_MAX_), - _ => Err(EnumTypeError::ParseEnumError(format!("Invalid value for enum 'TestImportEnum': {}", (v as i32).to_string()))), - } - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_enum_return/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_enum_return/mod.rs deleted file mode 100644 index 137826420b..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_enum_return/mod.rs +++ /dev/null @@ -1,51 +0,0 @@ -use polywrap_wasm_rs::EnumTypeError; -use serde::{Serialize, Deserialize}; -use std::convert::TryFrom; - -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum TestImportEnumReturn { - STRING, - BYTES, - _MAX_ -} - -pub fn sanitize_test_import_enum_return_value(value: i32) -> Result<(), EnumTypeError> { - if value < 0 && value >= TestImportEnumReturn::_MAX_ as i32 { - return Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum 'TestImportEnumReturn': {}", value.to_string()))); - } - Ok(()) -} - -pub fn get_test_import_enum_return_value(key: &str) -> Result { - match key { - "STRING" => Ok(TestImportEnumReturn::STRING), - "BYTES" => Ok(TestImportEnumReturn::BYTES), - "_MAX_" => Ok(TestImportEnumReturn::_MAX_), - err => Err(EnumTypeError::EnumProcessingError(format!("Invalid key for enum 'TestImportEnumReturn': {}", err))) - } -} - -pub fn get_test_import_enum_return_key(value: TestImportEnumReturn) -> Result { - if sanitize_test_import_enum_return_value(value as i32).is_ok() { - match value { - TestImportEnumReturn::STRING => Ok("STRING".to_string()), - TestImportEnumReturn::BYTES => Ok("BYTES".to_string()), - TestImportEnumReturn::_MAX_ => Ok("_MAX_".to_string()), - } - } else { - Err(EnumTypeError::EnumProcessingError(format!("Invalid value for enum 'TestImportEnumReturn': {}", (value as i32).to_string()))) - } -} - -impl TryFrom for TestImportEnumReturn { - type Error = EnumTypeError; - - fn try_from(v: i32) -> Result { - match v { - x if x == TestImportEnumReturn::STRING as i32 => Ok(TestImportEnumReturn::STRING), - x if x == TestImportEnumReturn::BYTES as i32 => Ok(TestImportEnumReturn::BYTES), - x if x == TestImportEnumReturn::_MAX_ as i32 => Ok(TestImportEnumReturn::_MAX_), - _ => Err(EnumTypeError::ParseEnumError(format!("Invalid value for enum 'TestImportEnumReturn': {}", (v as i32).to_string()))), - } - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_env/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_env/mod.rs deleted file mode 100644 index 993de8d519..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_env/mod.rs +++ /dev/null @@ -1,66 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_test_import_env, - read_test_import_env, - serialize_test_import_env, - write_test_import_env -}; - -use crate::TestImportAnotherObject; -use crate::TestImportEnum; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportEnv { - pub object: TestImportAnotherObject, - pub opt_object: Option, - pub object_array: Vec, - pub opt_object_array: Option>>, - pub en: TestImportEnum, - pub opt_enum: Option, - pub enum_array: Vec, - pub opt_enum_array: Option>>, -} - -impl TestImportEnv { - pub const URI: &'static str = "testimport.uri.eth"; - - pub fn new() -> TestImportEnv { - TestImportEnv { - object: TestImportAnotherObject::new(), - opt_object: None, - object_array: vec![], - opt_object_array: None, - en: TestImportEnum::_MAX_, - opt_enum: None, - enum_array: vec![], - opt_enum_array: None, - } - } - - pub fn to_buffer(args: &TestImportEnv) -> Result, EncodeError> { - serialize_test_import_env(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result { - deserialize_test_import_env(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &TestImportEnv, writer: &mut W) -> Result<(), EncodeError> { - write_test_import_env(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result { - read_test_import_env(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_env/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_env/serialization.rs deleted file mode 100644 index 6de6ef69d3..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_env/serialization.rs +++ /dev/null @@ -1,241 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::TestImportEnv; - -use crate::TestImportAnotherObject; -use crate::{ - TestImportEnum, - get_test_import_enum_value, - sanitize_test_import_enum_value -}; - -pub fn serialize_test_import_env(args: &TestImportEnv) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported env-type: TestImportEnv".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_test_import_env(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_test_import_env(args: &TestImportEnv, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&8)?; - writer.context().push("object", "TestImportAnotherObject", "writing property"); - writer.write_string("object")?; - TestImportAnotherObject::write(&args.object, writer)?; - writer.context().pop(); - writer.context().push("optObject", "Option", "writing property"); - writer.write_string("optObject")?; - if args.opt_object.is_some() { - TestImportAnotherObject::write(args.opt_object.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - writer.context().push("objectArray", "Vec", "writing property"); - writer.write_string("objectArray")?; - writer.write_array(&args.object_array, |writer, item| { - TestImportAnotherObject::write(item, writer) - })?; - writer.context().pop(); - writer.context().push("optObjectArray", "Option>>", "writing property"); - writer.write_string("optObjectArray")?; - writer.write_optional_array(&args.opt_object_array, |writer, item| { - if item.is_some() { - TestImportAnotherObject::write(item.as_ref().as_ref().unwrap(), writer) - } else { - writer.write_nil() - } - })?; - writer.context().pop(); - writer.context().push("en", "TestImportEnum", "writing property"); - writer.write_string("en")?; - writer.write_i32(&(args.en as i32))?; - writer.context().pop(); - writer.context().push("optEnum", "Option", "writing property"); - writer.write_string("optEnum")?; - writer.write_optional_i32(&args.opt_enum.map(|f| f as i32))?; - writer.context().pop(); - writer.context().push("enumArray", "Vec", "writing property"); - writer.write_string("enumArray")?; - writer.write_array(&args.enum_array, |writer, item| { - writer.write_i32(&(*item as i32)) - })?; - writer.context().pop(); - writer.context().push("optEnumArray", "Option>>", "writing property"); - writer.write_string("optEnumArray")?; - writer.write_optional_array(&args.opt_enum_array, |writer, item| { - writer.write_optional_i32(&item.map(|f| f as i32)) - })?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_test_import_env(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing imported env-type: TestImportEnv".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_test_import_env(&mut reader) -} - -pub fn read_test_import_env(reader: &mut R) -> Result { - let mut num_of_fields = reader.read_map_length()?; - - let mut _object: TestImportAnotherObject = TestImportAnotherObject::new(); - let mut _object_set = false; - let mut _opt_object: Option = None; - let mut _object_array: Vec = vec![]; - let mut _object_array_set = false; - let mut _opt_object_array: Option>> = None; - let mut _en: TestImportEnum = TestImportEnum::_MAX_; - let mut _en_set = false; - let mut _opt_enum: Option = None; - let mut _enum_array: Vec = vec![]; - let mut _enum_array_set = false; - let mut _opt_enum_array: Option>> = None; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "object" => { - reader.context().push(&field, "TestImportAnotherObject", "type found, reading property"); - let object = TestImportAnotherObject::read(reader)?; - _object = object; - _object_set = true; - reader.context().pop(); - } - "optObject" => { - reader.context().push(&field, "Option", "type found, reading property"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(TestImportAnotherObject::read(reader)?); - } else { - object = None; - } - _opt_object = object; - reader.context().pop(); - } - "objectArray" => { - reader.context().push(&field, "Vec", "type found, reading property"); - _object_array = reader.read_array(|reader| { - let object = TestImportAnotherObject::read(reader)?; - Ok(object) - })?; - _object_array_set = true; - reader.context().pop(); - } - "optObjectArray" => { - reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_object_array = reader.read_optional_array(|reader| { - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(TestImportAnotherObject::read(reader)?); - } else { - object = None; - } - Ok(object) - })?; - reader.context().pop(); - } - "en" => { - reader.context().push(&field, "TestImportEnum", "type found, reading property"); - let mut value: TestImportEnum = TestImportEnum::_MAX_; - if reader.is_next_string()? { - value = get_test_import_enum_value(&reader.read_string()?)?; - } else { - value = TestImportEnum::try_from(reader.read_i32()?)?; - sanitize_test_import_enum_value(value as i32)?; - } - _en = value; - _en_set = true; - reader.context().pop(); - } - "optEnum" => { - reader.context().push(&field, "Option", "type found, reading property"); - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_test_import_enum_value(&reader.read_string()?)?); - } else { - value = Some(TestImportEnum::try_from(reader.read_i32()?)?); - sanitize_test_import_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - _opt_enum = value; - reader.context().pop(); - } - "enumArray" => { - reader.context().push(&field, "Vec", "type found, reading property"); - _enum_array = reader.read_array(|reader| { - let mut value: TestImportEnum = TestImportEnum::_MAX_; - if reader.is_next_string()? { - value = get_test_import_enum_value(&reader.read_string()?)?; - } else { - value = TestImportEnum::try_from(reader.read_i32()?)?; - sanitize_test_import_enum_value(value as i32)?; - } - Ok(value) - })?; - _enum_array_set = true; - reader.context().pop(); - } - "optEnumArray" => { - reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_enum_array = reader.read_optional_array(|reader| { - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_test_import_enum_value(&reader.read_string()?)?); - } else { - value = Some(TestImportEnum::try_from(reader.read_i32()?)?); - sanitize_test_import_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - Ok(value) - })?; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_object_set { - return Err(DecodeError::MissingField("object: TestImport_AnotherObject.".to_string())); - } - if !_object_array_set { - return Err(DecodeError::MissingField("objectArray: [TestImport_AnotherObject].".to_string())); - } - if !_en_set { - return Err(DecodeError::MissingField("en: TestImport_Enum.".to_string())); - } - if !_enum_array_set { - return Err(DecodeError::MissingField("enumArray: [TestImport_Enum].".to_string())); - } - - Ok(TestImportEnv { - object: _object, - opt_object: _opt_object, - object_array: _object_array, - opt_object_array: _opt_object_array, - en: _en, - opt_enum: _opt_enum, - enum_array: _enum_array, - opt_enum_array: _opt_enum_array, - }) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/mod.rs deleted file mode 100644 index d265f90a57..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/mod.rs +++ /dev/null @@ -1,72 +0,0 @@ -use serde::{Serialize, Deserialize}; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Read, - Write, - JSON, - subinvoke, -}; -pub mod serialization; -pub use serialization::{ - deserialize_imported_method_result, - serialize_imported_method_args, - ArgsImportedMethod, - deserialize_another_method_result, - serialize_another_method_args, - ArgsAnotherMethod, - deserialize_returns_array_of_enums_result, - serialize_returns_array_of_enums_args, - ArgsReturnsArrayOfEnums -}; - -use crate::TestImportObject; -use crate::TestImportEnum; -use crate::TestImportEnumReturn; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportModule { - uri: String -} - -impl TestImportModule { - pub const INTERFACE_URI: &'static str = "testimport.uri.eth"; - - pub fn new(uri: String) -> TestImportModule { - TestImportModule { uri } - } - - pub fn imported_method(&self, args: &ArgsImportedMethod) -> Result, String> { - let ref uri = self.uri; - let args = serialize_imported_method_args(args).map_err(|e| e.to_string())?; - let result = subinvoke::wrap_subinvoke( - uri.as_str(), - "importedMethod", - args, - )?; - deserialize_imported_method_result(result.as_slice()).map_err(|e| e.to_string()) - } - - pub fn another_method(&self, args: &ArgsAnotherMethod) -> Result { - let ref uri = self.uri; - let args = serialize_another_method_args(args).map_err(|e| e.to_string())?; - let result = subinvoke::wrap_subinvoke( - uri.as_str(), - "anotherMethod", - args, - )?; - deserialize_another_method_result(result.as_slice()).map_err(|e| e.to_string()) - } - - pub fn returns_array_of_enums(&self, args: &ArgsReturnsArrayOfEnums) -> Result>, String> { - let ref uri = self.uri; - let args = serialize_returns_array_of_enums_args(args).map_err(|e| e.to_string())?; - let result = subinvoke::wrap_subinvoke( - uri.as_str(), - "returnsArrayOfEnums", - args, - )?; - deserialize_returns_array_of_enums_result(result.as_slice()).map_err(|e| e.to_string()) - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs deleted file mode 100644 index 92ed22e3ed..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_module/serialization.rs +++ /dev/null @@ -1,554 +0,0 @@ -use serde::{Serialize, Deserialize}; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; - -use crate::TestImportObject; -use crate::{ - TestImportEnum, - get_test_import_enum_value, - sanitize_test_import_enum_value -}; -use crate::{ - TestImportEnumReturn, - get_test_import_enum_return_value, - sanitize_test_import_enum_return_value -}; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsImportedMethod { - pub str: String, - pub opt_str: Option, - pub u: u32, - pub opt_u: Option, - pub u_array_array: Vec>>>, - pub object: TestImportObject, - pub opt_object: Option, - pub object_array: Vec, - pub opt_object_array: Option>>, - pub en: TestImportEnum, - pub opt_enum: Option, - pub enum_array: Vec, - pub opt_enum_array: Option>>, -} - -pub fn deserialize_imported_method_args(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing imported module-type: imported_method Args".to_string(); - - let mut reader = ReadDecoder::new(args, context); - let mut num_of_fields = reader.read_map_length()?; - - let mut _str: String = String::new(); - let mut _str_set = false; - let mut _opt_str: Option = None; - let mut _u: u32 = 0; - let mut _u_set = false; - let mut _opt_u: Option = None; - let mut _u_array_array: Vec>>> = vec![]; - let mut _u_array_array_set = false; - let mut _object: TestImportObject = TestImportObject::new(); - let mut _object_set = false; - let mut _opt_object: Option = None; - let mut _object_array: Vec = vec![]; - let mut _object_array_set = false; - let mut _opt_object_array: Option>> = None; - let mut _en: TestImportEnum = TestImportEnum::_MAX_; - let mut _en_set = false; - let mut _opt_enum: Option = None; - let mut _enum_array: Vec = vec![]; - let mut _enum_array_set = false; - let mut _opt_enum_array: Option>> = None; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "str" => { - reader.context().push(&field, "String", "type found, reading argument"); - _str = reader.read_string()?; - _str_set = true; - reader.context().pop(); - } - "optStr" => { - reader.context().push(&field, "Option", "type found, reading argument"); - _opt_str = reader.read_optional_string()?; - reader.context().pop(); - } - "u" => { - reader.context().push(&field, "u32", "type found, reading argument"); - _u = reader.read_u32()?; - _u_set = true; - reader.context().pop(); - } - "optU" => { - reader.context().push(&field, "Option", "type found, reading argument"); - _opt_u = reader.read_optional_u32()?; - reader.context().pop(); - } - "uArrayArray" => { - reader.context().push(&field, "Vec>>>", "type found, reading argument"); - _u_array_array = reader.read_array(|reader| { - reader.read_optional_array(|reader| { - reader.read_optional_u32() - }) - })?; - _u_array_array_set = true; - reader.context().pop(); - } - "object" => { - reader.context().push(&field, "TestImportObject", "type found, reading argument"); - let object = TestImportObject::read(&mut reader)?; - _object = object; - _object_set = true; - reader.context().pop(); - } - "optObject" => { - reader.context().push(&field, "Option", "type found, reading argument"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(TestImportObject::read(&mut reader)?); - } else { - object = None; - } - _opt_object = object; - reader.context().pop(); - } - "objectArray" => { - reader.context().push(&field, "Vec", "type found, reading argument"); - _object_array = reader.read_array(|reader| { - let object = TestImportObject::read(reader)?; - Ok(object) - })?; - _object_array_set = true; - reader.context().pop(); - } - "optObjectArray" => { - reader.context().push(&field, "Option>>", "type found, reading argument"); - _opt_object_array = reader.read_optional_array(|reader| { - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(TestImportObject::read(reader)?); - } else { - object = None; - } - Ok(object) - })?; - reader.context().pop(); - } - "en" => { - reader.context().push(&field, "TestImportEnum", "type found, reading argument"); - let mut value: TestImportEnum = TestImportEnum::_MAX_; - if reader.is_next_string()? { - value = get_test_import_enum_value(&reader.read_string()?)?; - } else { - value = TestImportEnum::try_from(reader.read_i32()?)?; - sanitize_test_import_enum_value(value as i32)?; - } - _en = value; - _en_set = true; - reader.context().pop(); - } - "optEnum" => { - reader.context().push(&field, "Option", "type found, reading argument"); - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_test_import_enum_value(&reader.read_string()?)?); - } else { - value = Some(TestImportEnum::try_from(reader.read_i32()?)?); - sanitize_test_import_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - _opt_enum = value; - reader.context().pop(); - } - "enumArray" => { - reader.context().push(&field, "Vec", "type found, reading argument"); - _enum_array = reader.read_array(|reader| { - let mut value: TestImportEnum = TestImportEnum::_MAX_; - if reader.is_next_string()? { - value = get_test_import_enum_value(&reader.read_string()?)?; - } else { - value = TestImportEnum::try_from(reader.read_i32()?)?; - sanitize_test_import_enum_value(value as i32)?; - } - Ok(value) - })?; - _enum_array_set = true; - reader.context().pop(); - } - "optEnumArray" => { - reader.context().push(&field, "Option>>", "type found, reading argument"); - _opt_enum_array = reader.read_optional_array(|reader| { - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_test_import_enum_value(&reader.read_string()?)?); - } else { - value = Some(TestImportEnum::try_from(reader.read_i32()?)?); - sanitize_test_import_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - Ok(value) - })?; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_str_set { - return Err(DecodeError::MissingField("str: String.".to_string())); - } - if !_u_set { - return Err(DecodeError::MissingField("u: UInt.".to_string())); - } - if !_u_array_array_set { - return Err(DecodeError::MissingField("uArrayArray: [[UInt]].".to_string())); - } - if !_object_set { - return Err(DecodeError::MissingField("object: TestImport_Object.".to_string())); - } - if !_object_array_set { - return Err(DecodeError::MissingField("objectArray: [TestImport_Object].".to_string())); - } - if !_en_set { - return Err(DecodeError::MissingField("en: TestImport_Enum.".to_string())); - } - if !_enum_array_set { - return Err(DecodeError::MissingField("enumArray: [TestImport_Enum].".to_string())); - } - - Ok(ArgsImportedMethod { - str: _str, - opt_str: _opt_str, - u: _u, - opt_u: _opt_u, - u_array_array: _u_array_array, - object: _object, - opt_object: _opt_object, - object_array: _object_array, - opt_object_array: _opt_object_array, - en: _en, - opt_enum: _opt_enum, - enum_array: _enum_array, - opt_enum_array: _opt_enum_array, - }) -} - -pub fn serialize_imported_method_args(args: &ArgsImportedMethod) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported module-type: imported_method Args".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_imported_method_args(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_imported_method_args(args: &ArgsImportedMethod, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&13)?; - writer.context().push("str", "String", "writing property"); - writer.write_string("str")?; - writer.write_string(&args.str)?; - writer.context().pop(); - writer.context().push("optStr", "Option", "writing property"); - writer.write_string("optStr")?; - writer.write_optional_string(&args.opt_str)?; - writer.context().pop(); - writer.context().push("u", "u32", "writing property"); - writer.write_string("u")?; - writer.write_u32(&args.u)?; - writer.context().pop(); - writer.context().push("optU", "Option", "writing property"); - writer.write_string("optU")?; - writer.write_optional_u32(&args.opt_u)?; - writer.context().pop(); - writer.context().push("uArrayArray", "Vec>>>", "writing property"); - writer.write_string("uArrayArray")?; - writer.write_array(&args.u_array_array, |writer, item| { - writer.write_optional_array(item, |writer, item| { - writer.write_optional_u32(item) - }) - })?; - writer.context().pop(); - writer.context().push("object", "TestImportObject", "writing property"); - writer.write_string("object")?; - TestImportObject::write(&args.object, writer)?; - writer.context().pop(); - writer.context().push("optObject", "Option", "writing property"); - writer.write_string("optObject")?; - if args.opt_object.is_some() { - TestImportObject::write(args.opt_object.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - writer.context().push("objectArray", "Vec", "writing property"); - writer.write_string("objectArray")?; - writer.write_array(&args.object_array, |writer, item| { - TestImportObject::write(item, writer) - })?; - writer.context().pop(); - writer.context().push("optObjectArray", "Option>>", "writing property"); - writer.write_string("optObjectArray")?; - writer.write_optional_array(&args.opt_object_array, |writer, item| { - if item.is_some() { - TestImportObject::write(item.as_ref().as_ref().unwrap(), writer) - } else { - writer.write_nil() - } - })?; - writer.context().pop(); - writer.context().push("en", "TestImportEnum", "writing property"); - writer.write_string("en")?; - writer.write_i32(&(args.en as i32))?; - writer.context().pop(); - writer.context().push("optEnum", "Option", "writing property"); - writer.write_string("optEnum")?; - writer.write_optional_i32(&args.opt_enum.map(|f| f as i32))?; - writer.context().pop(); - writer.context().push("enumArray", "Vec", "writing property"); - writer.write_string("enumArray")?; - writer.write_array(&args.enum_array, |writer, item| { - writer.write_i32(&(*item as i32)) - })?; - writer.context().pop(); - writer.context().push("optEnumArray", "Option>>", "writing property"); - writer.write_string("optEnumArray")?; - writer.write_optional_array(&args.opt_enum_array, |writer, item| { - writer.write_optional_i32(&item.map(|f| f as i32)) - })?; - writer.context().pop(); - Ok(()) -} - -pub fn serialize_imported_method_result(result: &Option) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported module-type: imported_method Result".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_imported_method_result(result, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_imported_method_result(result: &Option, writer: &mut W) -> Result<(), EncodeError> { - writer.context().push("importedMethod", "Option", "writing result"); - if result.is_some() { - TestImportObject::write(result.as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_imported_method_result(result: &[u8]) -> Result, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing imported module-type: imported_method Result".to_string(); - let mut reader = ReadDecoder::new(result, context); - - reader.context().push("importedMethod", "Option", "reading function output"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(TestImportObject::read(&mut reader)?); - } else { - object = None; - } - let res = object; - reader.context().pop(); - Ok(res) -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsAnotherMethod { - pub arg: Vec, -} - -pub fn deserialize_another_method_args(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing imported module-type: another_method Args".to_string(); - - let mut reader = ReadDecoder::new(args, context); - let mut num_of_fields = reader.read_map_length()?; - - let mut _arg: Vec = vec![]; - let mut _arg_set = false; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "arg" => { - reader.context().push(&field, "Vec", "type found, reading argument"); - _arg = reader.read_array(|reader| { - reader.read_string() - })?; - _arg_set = true; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_arg_set { - return Err(DecodeError::MissingField("arg: [String].".to_string())); - } - - Ok(ArgsAnotherMethod { - arg: _arg, - }) -} - -pub fn serialize_another_method_args(args: &ArgsAnotherMethod) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported module-type: another_method Args".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_another_method_args(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_another_method_args(args: &ArgsAnotherMethod, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&1)?; - writer.context().push("arg", "Vec", "writing property"); - writer.write_string("arg")?; - writer.write_array(&args.arg, |writer, item| { - writer.write_string(item) - })?; - writer.context().pop(); - Ok(()) -} - -pub fn serialize_another_method_result(result: &i32) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported module-type: another_method Result".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_another_method_result(result, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_another_method_result(result: &i32, writer: &mut W) -> Result<(), EncodeError> { - writer.context().push("anotherMethod", "i32", "writing result"); - writer.write_i32(result)?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_another_method_result(result: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing imported module-type: another_method Result".to_string(); - let mut reader = ReadDecoder::new(result, context); - - reader.context().push("anotherMethod", "i32", "reading function output"); - let res = reader.read_i32()?; - reader.context().pop(); - Ok(res) -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsReturnsArrayOfEnums { - pub arg: String, -} - -pub fn deserialize_returns_array_of_enums_args(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing imported module-type: returns_array_of_enums Args".to_string(); - - let mut reader = ReadDecoder::new(args, context); - let mut num_of_fields = reader.read_map_length()?; - - let mut _arg: String = String::new(); - let mut _arg_set = false; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "arg" => { - reader.context().push(&field, "String", "type found, reading argument"); - _arg = reader.read_string()?; - _arg_set = true; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_arg_set { - return Err(DecodeError::MissingField("arg: String.".to_string())); - } - - Ok(ArgsReturnsArrayOfEnums { - arg: _arg, - }) -} - -pub fn serialize_returns_array_of_enums_args(args: &ArgsReturnsArrayOfEnums) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported module-type: returns_array_of_enums Args".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_returns_array_of_enums_args(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_returns_array_of_enums_args(args: &ArgsReturnsArrayOfEnums, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&1)?; - writer.context().push("arg", "String", "writing property"); - writer.write_string("arg")?; - writer.write_string(&args.arg)?; - writer.context().pop(); - Ok(()) -} - -pub fn serialize_returns_array_of_enums_result(result: &Vec>) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported module-type: returns_array_of_enums Result".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_returns_array_of_enums_result(result, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_returns_array_of_enums_result(result: &Vec>, writer: &mut W) -> Result<(), EncodeError> { - writer.context().push("returnsArrayOfEnums", "Vec>", "writing result"); - writer.write_array(&result, |writer, item| { - writer.write_optional_i32(&item.map(|f| f as i32)) - })?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_returns_array_of_enums_result(result: &[u8]) -> Result>, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing imported module-type: returns_array_of_enums Result".to_string(); - let mut reader = ReadDecoder::new(result, context); - - reader.context().push("returnsArrayOfEnums", "Vec>", "reading function output"); - let res = reader.read_array(|reader| { - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_test_import_enum_return_value(&reader.read_string()?)?); - } else { - value = Some(TestImportEnumReturn::try_from(reader.read_i32()?)?); - sanitize_test_import_enum_return_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - Ok(value) - })?; - reader.context().pop(); - Ok(res) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/mod.rs deleted file mode 100644 index ab9c3cf3c4..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/mod.rs +++ /dev/null @@ -1,66 +0,0 @@ -use serde::{Serialize, Deserialize}; -pub mod serialization; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - DecodeError, - EncodeError, - Read, - Write, - JSON, -}; -pub use serialization::{ - deserialize_test_import_object, - read_test_import_object, - serialize_test_import_object, - write_test_import_object -}; - -use crate::TestImportAnotherObject; -use crate::TestImportEnum; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct TestImportObject { - pub object: TestImportAnotherObject, - pub opt_object: Option, - pub object_array: Vec, - pub opt_object_array: Option>>, - pub en: TestImportEnum, - pub opt_enum: Option, - pub enum_array: Vec, - pub opt_enum_array: Option>>, -} - -impl TestImportObject { - pub const URI: &'static str = "testimport.uri.eth"; - - pub fn new() -> TestImportObject { - TestImportObject { - object: TestImportAnotherObject::new(), - opt_object: None, - object_array: vec![], - opt_object_array: None, - en: TestImportEnum::_MAX_, - opt_enum: None, - enum_array: vec![], - opt_enum_array: None, - } - } - - pub fn to_buffer(args: &TestImportObject) -> Result, EncodeError> { - serialize_test_import_object(args).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn from_buffer(args: &[u8]) -> Result { - deserialize_test_import_object(args).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } - - pub fn write(args: &TestImportObject, writer: &mut W) -> Result<(), EncodeError> { - write_test_import_object(args, writer).map_err(|e| EncodeError::TypeWriteError(e.to_string())) - } - - pub fn read(reader: &mut R) -> Result { - read_test_import_object(reader).map_err(|e| DecodeError::TypeReadError(e.to_string())) - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs deleted file mode 100644 index 691cf5d323..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/imported/test_import_object/serialization.rs +++ /dev/null @@ -1,241 +0,0 @@ -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; -use crate::TestImportObject; - -use crate::TestImportAnotherObject; -use crate::{ - TestImportEnum, - get_test_import_enum_value, - sanitize_test_import_enum_value -}; - -pub fn serialize_test_import_object(args: &TestImportObject) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) imported object-type: TestImportObject".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_test_import_object(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_test_import_object(args: &TestImportObject, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&8)?; - writer.context().push("object", "TestImportAnotherObject", "writing property"); - writer.write_string("object")?; - TestImportAnotherObject::write(&args.object, writer)?; - writer.context().pop(); - writer.context().push("optObject", "Option", "writing property"); - writer.write_string("optObject")?; - if args.opt_object.is_some() { - TestImportAnotherObject::write(args.opt_object.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - writer.context().push("objectArray", "Vec", "writing property"); - writer.write_string("objectArray")?; - writer.write_array(&args.object_array, |writer, item| { - TestImportAnotherObject::write(item, writer) - })?; - writer.context().pop(); - writer.context().push("optObjectArray", "Option>>", "writing property"); - writer.write_string("optObjectArray")?; - writer.write_optional_array(&args.opt_object_array, |writer, item| { - if item.is_some() { - TestImportAnotherObject::write(item.as_ref().as_ref().unwrap(), writer) - } else { - writer.write_nil() - } - })?; - writer.context().pop(); - writer.context().push("en", "TestImportEnum", "writing property"); - writer.write_string("en")?; - writer.write_i32(&(args.en as i32))?; - writer.context().pop(); - writer.context().push("optEnum", "Option", "writing property"); - writer.write_string("optEnum")?; - writer.write_optional_i32(&args.opt_enum.map(|f| f as i32))?; - writer.context().pop(); - writer.context().push("enumArray", "Vec", "writing property"); - writer.write_string("enumArray")?; - writer.write_array(&args.enum_array, |writer, item| { - writer.write_i32(&(*item as i32)) - })?; - writer.context().pop(); - writer.context().push("optEnumArray", "Option>>", "writing property"); - writer.write_string("optEnumArray")?; - writer.write_optional_array(&args.opt_enum_array, |writer, item| { - writer.write_optional_i32(&item.map(|f| f as i32)) - })?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_test_import_object(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing imported object-type: TestImportObject".to_string(); - let mut reader = ReadDecoder::new(args, context); - read_test_import_object(&mut reader) -} - -pub fn read_test_import_object(reader: &mut R) -> Result { - let mut num_of_fields = reader.read_map_length()?; - - let mut _object: TestImportAnotherObject = TestImportAnotherObject::new(); - let mut _object_set = false; - let mut _opt_object: Option = None; - let mut _object_array: Vec = vec![]; - let mut _object_array_set = false; - let mut _opt_object_array: Option>> = None; - let mut _en: TestImportEnum = TestImportEnum::_MAX_; - let mut _en_set = false; - let mut _opt_enum: Option = None; - let mut _enum_array: Vec = vec![]; - let mut _enum_array_set = false; - let mut _opt_enum_array: Option>> = None; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "object" => { - reader.context().push(&field, "TestImportAnotherObject", "type found, reading property"); - let object = TestImportAnotherObject::read(reader)?; - _object = object; - _object_set = true; - reader.context().pop(); - } - "optObject" => { - reader.context().push(&field, "Option", "type found, reading property"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(TestImportAnotherObject::read(reader)?); - } else { - object = None; - } - _opt_object = object; - reader.context().pop(); - } - "objectArray" => { - reader.context().push(&field, "Vec", "type found, reading property"); - _object_array = reader.read_array(|reader| { - let object = TestImportAnotherObject::read(reader)?; - Ok(object) - })?; - _object_array_set = true; - reader.context().pop(); - } - "optObjectArray" => { - reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_object_array = reader.read_optional_array(|reader| { - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(TestImportAnotherObject::read(reader)?); - } else { - object = None; - } - Ok(object) - })?; - reader.context().pop(); - } - "en" => { - reader.context().push(&field, "TestImportEnum", "type found, reading property"); - let mut value: TestImportEnum = TestImportEnum::_MAX_; - if reader.is_next_string()? { - value = get_test_import_enum_value(&reader.read_string()?)?; - } else { - value = TestImportEnum::try_from(reader.read_i32()?)?; - sanitize_test_import_enum_value(value as i32)?; - } - _en = value; - _en_set = true; - reader.context().pop(); - } - "optEnum" => { - reader.context().push(&field, "Option", "type found, reading property"); - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_test_import_enum_value(&reader.read_string()?)?); - } else { - value = Some(TestImportEnum::try_from(reader.read_i32()?)?); - sanitize_test_import_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - _opt_enum = value; - reader.context().pop(); - } - "enumArray" => { - reader.context().push(&field, "Vec", "type found, reading property"); - _enum_array = reader.read_array(|reader| { - let mut value: TestImportEnum = TestImportEnum::_MAX_; - if reader.is_next_string()? { - value = get_test_import_enum_value(&reader.read_string()?)?; - } else { - value = TestImportEnum::try_from(reader.read_i32()?)?; - sanitize_test_import_enum_value(value as i32)?; - } - Ok(value) - })?; - _enum_array_set = true; - reader.context().pop(); - } - "optEnumArray" => { - reader.context().push(&field, "Option>>", "type found, reading property"); - _opt_enum_array = reader.read_optional_array(|reader| { - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_test_import_enum_value(&reader.read_string()?)?); - } else { - value = Some(TestImportEnum::try_from(reader.read_i32()?)?); - sanitize_test_import_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - Ok(value) - })?; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_object_set { - return Err(DecodeError::MissingField("object: TestImport_AnotherObject.".to_string())); - } - if !_object_array_set { - return Err(DecodeError::MissingField("objectArray: [TestImport_AnotherObject].".to_string())); - } - if !_en_set { - return Err(DecodeError::MissingField("en: TestImport_Enum.".to_string())); - } - if !_enum_array_set { - return Err(DecodeError::MissingField("enumArray: [TestImport_Enum].".to_string())); - } - - Ok(TestImportObject { - object: _object, - opt_object: _opt_object, - object_array: _object_array, - opt_object_array: _opt_object_array, - en: _en, - opt_enum: _opt_enum, - enum_array: _enum_array, - opt_enum_array: _opt_enum_array, - }) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/mod.rs deleted file mode 100644 index d5a8b8e1e8..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/mod.rs +++ /dev/null @@ -1,71 +0,0 @@ -pub mod entry; -pub mod custom_type; -pub use custom_type::CustomType; -pub mod another_type; -pub use another_type::AnotherType; -pub mod custom_map_value; -pub use custom_map_value::CustomMapValue; -pub mod _else; -pub use _else::Else; -pub mod custom_enum; -pub use custom_enum::{ - get_custom_enum_key, - get_custom_enum_value, - sanitize_custom_enum_value, - CustomEnum -}; -pub mod _while; -pub use _while::{ - get_while_key, - get_while_value, - sanitize_while_value, - While -}; -pub mod env; -pub use env::Env; -pub mod imported; -pub use imported::test_import_object::TestImportObject; -pub use imported::test_import_another_object::TestImportAnotherObject; -pub use imported::test_import_enum::{ - get_test_import_enum_key, - get_test_import_enum_value, - sanitize_test_import_enum_value, - TestImportEnum -}; -pub use imported::test_import_enum_return::{ - get_test_import_enum_return_key, - get_test_import_enum_return_value, - sanitize_test_import_enum_return_value, - TestImportEnumReturn -}; -pub use imported::test_import_env::TestImportEnv; -pub use imported::test_import_module::TestImportModule; -pub mod test_import; -pub use test_import::TestImport; -pub mod module; -pub use module::{ - Module, - ModuleTrait, - deserialize_module_method_args, - serialize_module_method_result, - module_method_wrapped, - ArgsModuleMethod, - deserialize_object_method_args, - serialize_object_method_result, - object_method_wrapped, - ArgsObjectMethod, - deserialize_optional_env_method_args, - serialize_optional_env_method_result, - optional_env_method_wrapped, - ArgsOptionalEnvMethod, - deserialize_if_args, - serialize_if_result, - if_wrapped, - ArgsIf -}; - -// Override print!(...) & println!(...) macros -#[macro_export] -macro_rules! println { ($($args:tt)*) => { polywrap_wasm_rs::wrap_debug_log(format!($($args)*).as_str()); } } -#[macro_export] -macro_rules! print { ($($args:tt)*) => { polywrap_wasm_rs::wrap_debug_log(format!($($args)*).as_str()); } } diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/mod.rs deleted file mode 100644 index 7823ef5b88..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -pub mod wrapped; -pub use wrapped::{ - module_method_wrapped, - object_method_wrapped, - optional_env_method_wrapped, - if_wrapped -}; -pub mod serialization; -pub use serialization::{ - deserialize_module_method_args, - serialize_module_method_result, - ArgsModuleMethod, - deserialize_object_method_args, - serialize_object_method_result, - ArgsObjectMethod, - deserialize_optional_env_method_args, - serialize_optional_env_method_result, - ArgsOptionalEnvMethod, - deserialize_if_args, - serialize_if_result, - ArgsIf -}; - -pub mod module; -pub use module::*; diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/module.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/module.rs deleted file mode 100644 index f0fbdf1bcb..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/module.rs +++ /dev/null @@ -1,31 +0,0 @@ -use crate::{ - ArgsModuleMethod, - ArgsObjectMethod, - ArgsOptionalEnvMethod, - ArgsIf, -}; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - JSON, -}; - -use crate::Env; -use crate::{ - CustomEnum, -}; -use crate::AnotherType; -use crate::Else; - -pub struct Module; - -pub trait ModuleTrait { - fn module_method(args: ArgsModuleMethod) -> Result; - - fn object_method(args: ArgsObjectMethod, env: Env) -> Result, String>; - - fn optional_env_method(args: ArgsOptionalEnvMethod, env: Option) -> Result, String>; - - fn _if(args: ArgsIf) -> Result; -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs deleted file mode 100644 index f4146f90b0..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/serialization.rs +++ /dev/null @@ -1,770 +0,0 @@ -use serde::{Serialize, Deserialize}; -use std::convert::TryFrom; -use polywrap_wasm_rs::{ - BigInt, - BigNumber, - Map, - Context, - DecodeError, - EncodeError, - Read, - ReadDecoder, - Write, - WriteEncoder, - JSON, -}; - -use crate::Env; -use crate::{ - CustomEnum, - get_custom_enum_value, - sanitize_custom_enum_value -}; -use crate::AnotherType; -use crate::Else; - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsModuleMethod { - pub str: String, - pub opt_str: Option, - pub en: CustomEnum, - pub opt_enum: Option, - pub enum_array: Vec, - pub opt_enum_array: Option>>, - pub map: Map, - pub map_of_arr: Map>, - pub map_of_map: Map>, - pub map_of_obj: Map, - pub map_of_arr_of_obj: Map>, -} - -pub fn deserialize_module_method_args(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing module-type: module_method Args".to_string(); - - let mut reader = ReadDecoder::new(args, context); - let mut num_of_fields = reader.read_map_length()?; - - let mut _str: String = String::new(); - let mut _str_set = false; - let mut _opt_str: Option = None; - let mut _en: CustomEnum = CustomEnum::_MAX_; - let mut _en_set = false; - let mut _opt_enum: Option = None; - let mut _enum_array: Vec = vec![]; - let mut _enum_array_set = false; - let mut _opt_enum_array: Option>> = None; - let mut _map: Map = Map::::new(); - let mut _map_set = false; - let mut _map_of_arr: Map> = Map::>::new(); - let mut _map_of_arr_set = false; - let mut _map_of_map: Map> = Map::>::new(); - let mut _map_of_map_set = false; - let mut _map_of_obj: Map = Map::::new(); - let mut _map_of_obj_set = false; - let mut _map_of_arr_of_obj: Map> = Map::>::new(); - let mut _map_of_arr_of_obj_set = false; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "str" => { - reader.context().push(&field, "String", "type found, reading argument"); - _str = reader.read_string()?; - _str_set = true; - reader.context().pop(); - } - "optStr" => { - reader.context().push(&field, "Option", "type found, reading argument"); - _opt_str = reader.read_optional_string()?; - reader.context().pop(); - } - "en" => { - reader.context().push(&field, "CustomEnum", "type found, reading argument"); - let mut value: CustomEnum = CustomEnum::_MAX_; - if reader.is_next_string()? { - value = get_custom_enum_value(&reader.read_string()?)?; - } else { - value = CustomEnum::try_from(reader.read_i32()?)?; - sanitize_custom_enum_value(value as i32)?; - } - _en = value; - _en_set = true; - reader.context().pop(); - } - "optEnum" => { - reader.context().push(&field, "Option", "type found, reading argument"); - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_custom_enum_value(&reader.read_string()?)?); - } else { - value = Some(CustomEnum::try_from(reader.read_i32()?)?); - sanitize_custom_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - _opt_enum = value; - reader.context().pop(); - } - "enumArray" => { - reader.context().push(&field, "Vec", "type found, reading argument"); - _enum_array = reader.read_array(|reader| { - let mut value: CustomEnum = CustomEnum::_MAX_; - if reader.is_next_string()? { - value = get_custom_enum_value(&reader.read_string()?)?; - } else { - value = CustomEnum::try_from(reader.read_i32()?)?; - sanitize_custom_enum_value(value as i32)?; - } - Ok(value) - })?; - _enum_array_set = true; - reader.context().pop(); - } - "optEnumArray" => { - reader.context().push(&field, "Option>>", "type found, reading argument"); - _opt_enum_array = reader.read_optional_array(|reader| { - let mut value: Option = None; - if !reader.is_next_nil()? { - if reader.is_next_string()? { - value = Some(get_custom_enum_value(&reader.read_string()?)?); - } else { - value = Some(CustomEnum::try_from(reader.read_i32()?)?); - sanitize_custom_enum_value(value.unwrap() as i32)?; - } - } else { - value = None; - } - Ok(value) - })?; - reader.context().pop(); - } - "map" => { - reader.context().push(&field, "Map", "type found, reading argument"); - _map = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - reader.read_i32() - })?; - _map_set = true; - reader.context().pop(); - } - "mapOfArr" => { - reader.context().push(&field, "Map>", "type found, reading argument"); - _map_of_arr = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - reader.read_array(|reader| { - reader.read_i32() - }) - })?; - _map_of_arr_set = true; - reader.context().pop(); - } - "mapOfMap" => { - reader.context().push(&field, "Map>", "type found, reading argument"); - _map_of_map = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - reader.read_i32() - }) - })?; - _map_of_map_set = true; - reader.context().pop(); - } - "mapOfObj" => { - reader.context().push(&field, "Map", "type found, reading argument"); - _map_of_obj = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - let object = AnotherType::read(reader)?; - Ok(object) - })?; - _map_of_obj_set = true; - reader.context().pop(); - } - "mapOfArrOfObj" => { - reader.context().push(&field, "Map>", "type found, reading argument"); - _map_of_arr_of_obj = reader.read_ext_generic_map(|reader| { - reader.read_string() - }, |reader| { - reader.read_array(|reader| { - let object = AnotherType::read(reader)?; - Ok(object) - }) - })?; - _map_of_arr_of_obj_set = true; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_str_set { - return Err(DecodeError::MissingField("str: String.".to_string())); - } - if !_en_set { - return Err(DecodeError::MissingField("en: CustomEnum.".to_string())); - } - if !_enum_array_set { - return Err(DecodeError::MissingField("enumArray: [CustomEnum].".to_string())); - } - if !_map_set { - return Err(DecodeError::MissingField("map: Map.".to_string())); - } - if !_map_of_arr_set { - return Err(DecodeError::MissingField("mapOfArr: Map.".to_string())); - } - if !_map_of_map_set { - return Err(DecodeError::MissingField("mapOfMap: Map>.".to_string())); - } - if !_map_of_obj_set { - return Err(DecodeError::MissingField("mapOfObj: Map.".to_string())); - } - if !_map_of_arr_of_obj_set { - return Err(DecodeError::MissingField("mapOfArrOfObj: Map.".to_string())); - } - - Ok(ArgsModuleMethod { - str: _str, - opt_str: _opt_str, - en: _en, - opt_enum: _opt_enum, - enum_array: _enum_array, - opt_enum_array: _opt_enum_array, - map: _map, - map_of_arr: _map_of_arr, - map_of_map: _map_of_map, - map_of_obj: _map_of_obj, - map_of_arr_of_obj: _map_of_arr_of_obj, - }) -} - -pub fn serialize_module_method_args(args: &ArgsModuleMethod) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: module_method Args".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_module_method_args(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_module_method_args(args: &ArgsModuleMethod, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&11)?; - writer.context().push("str", "String", "writing property"); - writer.write_string("str")?; - writer.write_string(&args.str)?; - writer.context().pop(); - writer.context().push("optStr", "Option", "writing property"); - writer.write_string("optStr")?; - writer.write_optional_string(&args.opt_str)?; - writer.context().pop(); - writer.context().push("en", "CustomEnum", "writing property"); - writer.write_string("en")?; - writer.write_i32(&(args.en as i32))?; - writer.context().pop(); - writer.context().push("optEnum", "Option", "writing property"); - writer.write_string("optEnum")?; - writer.write_optional_i32(&args.opt_enum.map(|f| f as i32))?; - writer.context().pop(); - writer.context().push("enumArray", "Vec", "writing property"); - writer.write_string("enumArray")?; - writer.write_array(&args.enum_array, |writer, item| { - writer.write_i32(&(*item as i32)) - })?; - writer.context().pop(); - writer.context().push("optEnumArray", "Option>>", "writing property"); - writer.write_string("optEnumArray")?; - writer.write_optional_array(&args.opt_enum_array, |writer, item| { - writer.write_optional_i32(&item.map(|f| f as i32)) - })?; - writer.context().pop(); - writer.context().push("map", "Map", "writing property"); - writer.write_string("map")?; - writer.write_ext_generic_map(&args.map, |writer, key| { - writer.write_string(key) - }, |writer, value| { - writer.write_i32(value) - })?; - writer.context().pop(); - writer.context().push("mapOfArr", "Map>", "writing property"); - writer.write_string("mapOfArr")?; - writer.write_ext_generic_map(&args.map_of_arr, |writer, key| { - writer.write_string(key) - }, |writer, value| { - writer.write_array(value, |writer, item| { - writer.write_i32(item) - }) - })?; - writer.context().pop(); - writer.context().push("mapOfMap", "Map>", "writing property"); - writer.write_string("mapOfMap")?; - writer.write_ext_generic_map(&args.map_of_map, |writer, key| { - writer.write_string(key) - }, |writer, value| { - writer.write_ext_generic_map(value, |writer, key| { - writer.write_string(key) - }, |writer, value| { - writer.write_i32(value) - }) - })?; - writer.context().pop(); - writer.context().push("mapOfObj", "Map", "writing property"); - writer.write_string("mapOfObj")?; - writer.write_ext_generic_map(&args.map_of_obj, |writer, key| { - writer.write_string(key) - }, |writer, value| { - AnotherType::write(value, writer) - })?; - writer.context().pop(); - writer.context().push("mapOfArrOfObj", "Map>", "writing property"); - writer.write_string("mapOfArrOfObj")?; - writer.write_ext_generic_map(&args.map_of_arr_of_obj, |writer, key| { - writer.write_string(key) - }, |writer, value| { - writer.write_array(value, |writer, item| { - AnotherType::write(item, writer) - }) - })?; - writer.context().pop(); - Ok(()) -} - -pub fn serialize_module_method_result(result: &i32) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: module_method Result".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_module_method_result(result, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_module_method_result(result: &i32, writer: &mut W) -> Result<(), EncodeError> { - writer.context().push("moduleMethod", "i32", "writing result"); - writer.write_i32(result)?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_module_method_result(result: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing module-type: module_method Result".to_string(); - let mut reader = ReadDecoder::new(result, context); - - reader.context().push("moduleMethod", "i32", "reading function output"); - let res = reader.read_i32()?; - reader.context().pop(); - Ok(res) -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsObjectMethod { - pub object: AnotherType, - pub opt_object: Option, - pub object_array: Vec, - pub opt_object_array: Option>>, -} - -pub fn deserialize_object_method_args(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing module-type: object_method Args".to_string(); - - let mut reader = ReadDecoder::new(args, context); - let mut num_of_fields = reader.read_map_length()?; - - let mut _object: AnotherType = AnotherType::new(); - let mut _object_set = false; - let mut _opt_object: Option = None; - let mut _object_array: Vec = vec![]; - let mut _object_array_set = false; - let mut _opt_object_array: Option>> = None; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "object" => { - reader.context().push(&field, "AnotherType", "type found, reading argument"); - let object = AnotherType::read(&mut reader)?; - _object = object; - _object_set = true; - reader.context().pop(); - } - "optObject" => { - reader.context().push(&field, "Option", "type found, reading argument"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(AnotherType::read(&mut reader)?); - } else { - object = None; - } - _opt_object = object; - reader.context().pop(); - } - "objectArray" => { - reader.context().push(&field, "Vec", "type found, reading argument"); - _object_array = reader.read_array(|reader| { - let object = AnotherType::read(reader)?; - Ok(object) - })?; - _object_array_set = true; - reader.context().pop(); - } - "optObjectArray" => { - reader.context().push(&field, "Option>>", "type found, reading argument"); - _opt_object_array = reader.read_optional_array(|reader| { - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(AnotherType::read(reader)?); - } else { - object = None; - } - Ok(object) - })?; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_object_set { - return Err(DecodeError::MissingField("object: AnotherType.".to_string())); - } - if !_object_array_set { - return Err(DecodeError::MissingField("objectArray: [AnotherType].".to_string())); - } - - Ok(ArgsObjectMethod { - object: _object, - opt_object: _opt_object, - object_array: _object_array, - opt_object_array: _opt_object_array, - }) -} - -pub fn serialize_object_method_args(args: &ArgsObjectMethod) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: object_method Args".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_object_method_args(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_object_method_args(args: &ArgsObjectMethod, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&4)?; - writer.context().push("object", "AnotherType", "writing property"); - writer.write_string("object")?; - AnotherType::write(&args.object, writer)?; - writer.context().pop(); - writer.context().push("optObject", "Option", "writing property"); - writer.write_string("optObject")?; - if args.opt_object.is_some() { - AnotherType::write(args.opt_object.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - writer.context().push("objectArray", "Vec", "writing property"); - writer.write_string("objectArray")?; - writer.write_array(&args.object_array, |writer, item| { - AnotherType::write(item, writer) - })?; - writer.context().pop(); - writer.context().push("optObjectArray", "Option>>", "writing property"); - writer.write_string("optObjectArray")?; - writer.write_optional_array(&args.opt_object_array, |writer, item| { - if item.is_some() { - AnotherType::write(item.as_ref().as_ref().unwrap(), writer) - } else { - writer.write_nil() - } - })?; - writer.context().pop(); - Ok(()) -} - -pub fn serialize_object_method_result(result: &Option) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: object_method Result".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_object_method_result(result, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_object_method_result(result: &Option, writer: &mut W) -> Result<(), EncodeError> { - writer.context().push("objectMethod", "Option", "writing result"); - if result.is_some() { - AnotherType::write(result.as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_object_method_result(result: &[u8]) -> Result, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing module-type: object_method Result".to_string(); - let mut reader = ReadDecoder::new(result, context); - - reader.context().push("objectMethod", "Option", "reading function output"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(AnotherType::read(&mut reader)?); - } else { - object = None; - } - let res = object; - reader.context().pop(); - Ok(res) -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsOptionalEnvMethod { - pub object: AnotherType, - pub opt_object: Option, - pub object_array: Vec, - pub opt_object_array: Option>>, -} - -pub fn deserialize_optional_env_method_args(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing module-type: optional_env_method Args".to_string(); - - let mut reader = ReadDecoder::new(args, context); - let mut num_of_fields = reader.read_map_length()?; - - let mut _object: AnotherType = AnotherType::new(); - let mut _object_set = false; - let mut _opt_object: Option = None; - let mut _object_array: Vec = vec![]; - let mut _object_array_set = false; - let mut _opt_object_array: Option>> = None; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "object" => { - reader.context().push(&field, "AnotherType", "type found, reading argument"); - let object = AnotherType::read(&mut reader)?; - _object = object; - _object_set = true; - reader.context().pop(); - } - "optObject" => { - reader.context().push(&field, "Option", "type found, reading argument"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(AnotherType::read(&mut reader)?); - } else { - object = None; - } - _opt_object = object; - reader.context().pop(); - } - "objectArray" => { - reader.context().push(&field, "Vec", "type found, reading argument"); - _object_array = reader.read_array(|reader| { - let object = AnotherType::read(reader)?; - Ok(object) - })?; - _object_array_set = true; - reader.context().pop(); - } - "optObjectArray" => { - reader.context().push(&field, "Option>>", "type found, reading argument"); - _opt_object_array = reader.read_optional_array(|reader| { - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(AnotherType::read(reader)?); - } else { - object = None; - } - Ok(object) - })?; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_object_set { - return Err(DecodeError::MissingField("object: AnotherType.".to_string())); - } - if !_object_array_set { - return Err(DecodeError::MissingField("objectArray: [AnotherType].".to_string())); - } - - Ok(ArgsOptionalEnvMethod { - object: _object, - opt_object: _opt_object, - object_array: _object_array, - opt_object_array: _opt_object_array, - }) -} - -pub fn serialize_optional_env_method_args(args: &ArgsOptionalEnvMethod) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: optional_env_method Args".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_optional_env_method_args(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_optional_env_method_args(args: &ArgsOptionalEnvMethod, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&4)?; - writer.context().push("object", "AnotherType", "writing property"); - writer.write_string("object")?; - AnotherType::write(&args.object, writer)?; - writer.context().pop(); - writer.context().push("optObject", "Option", "writing property"); - writer.write_string("optObject")?; - if args.opt_object.is_some() { - AnotherType::write(args.opt_object.as_ref().as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - writer.context().push("objectArray", "Vec", "writing property"); - writer.write_string("objectArray")?; - writer.write_array(&args.object_array, |writer, item| { - AnotherType::write(item, writer) - })?; - writer.context().pop(); - writer.context().push("optObjectArray", "Option>>", "writing property"); - writer.write_string("optObjectArray")?; - writer.write_optional_array(&args.opt_object_array, |writer, item| { - if item.is_some() { - AnotherType::write(item.as_ref().as_ref().unwrap(), writer) - } else { - writer.write_nil() - } - })?; - writer.context().pop(); - Ok(()) -} - -pub fn serialize_optional_env_method_result(result: &Option) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: optional_env_method Result".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_optional_env_method_result(result, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_optional_env_method_result(result: &Option, writer: &mut W) -> Result<(), EncodeError> { - writer.context().push("optionalEnvMethod", "Option", "writing result"); - if result.is_some() { - AnotherType::write(result.as_ref().unwrap(), writer)?; - } else { - writer.write_nil()?; - } - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_optional_env_method_result(result: &[u8]) -> Result, DecodeError> { - let mut context = Context::new(); - context.description = "Deserializing module-type: optional_env_method Result".to_string(); - let mut reader = ReadDecoder::new(result, context); - - reader.context().push("optionalEnvMethod", "Option", "reading function output"); - let mut object: Option = None; - if !reader.is_next_nil()? { - object = Some(AnotherType::read(&mut reader)?); - } else { - object = None; - } - let res = object; - reader.context().pop(); - Ok(res) -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -pub struct ArgsIf { - #[serde(rename = "if")] - pub _if: Else, -} - -pub fn deserialize_if_args(args: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing module-type: if Args".to_string(); - - let mut reader = ReadDecoder::new(args, context); - let mut num_of_fields = reader.read_map_length()?; - - let mut _if: Else = Else::new(); - let mut _if_set = false; - - while num_of_fields > 0 { - num_of_fields -= 1; - let field = reader.read_string()?; - - match field.as_str() { - "if" => { - reader.context().push(&field, "Else", "type found, reading argument"); - let object = Else::read(&mut reader)?; - _if = object; - _if_set = true; - reader.context().pop(); - } - err => return Err(DecodeError::UnknownFieldName(err.to_string())), - } - } - if !_if_set { - return Err(DecodeError::MissingField("if: else.".to_string())); - } - - Ok(ArgsIf { - _if: _if, - }) -} - -pub fn serialize_if_args(args: &ArgsIf) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: if Args".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_if_args(args, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_if_args(args: &ArgsIf, writer: &mut W) -> Result<(), EncodeError> { - writer.write_map_length(&1)?; - writer.context().push("if", "Else", "writing property"); - writer.write_string("if")?; - Else::write(&args._if, writer)?; - writer.context().pop(); - Ok(()) -} - -pub fn serialize_if_result(result: &Else) -> Result, EncodeError> { - let mut encoder_context = Context::new(); - encoder_context.description = "Serializing (encoding) module-type: if Result".to_string(); - let mut encoder = WriteEncoder::new(&[], encoder_context); - write_if_result(result, &mut encoder)?; - Ok(encoder.get_buffer()) -} - -pub fn write_if_result(result: &Else, writer: &mut W) -> Result<(), EncodeError> { - writer.context().push("if", "Else", "writing result"); - Else::write(&result, writer)?; - writer.context().pop(); - Ok(()) -} - -pub fn deserialize_if_result(result: &[u8]) -> Result { - let mut context = Context::new(); - context.description = "Deserializing module-type: if Result".to_string(); - let mut reader = ReadDecoder::new(result, context); - - reader.context().push("if", "Else", "reading function output"); - let object = Else::read(&mut reader)?; - let res = object; - reader.context().pop(); - Ok(res) -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/wrapped.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/wrapped.rs deleted file mode 100644 index e9316ed244..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/module/wrapped.rs +++ /dev/null @@ -1,134 +0,0 @@ -use polywrap_wasm_rs::{ - wrap_load_env -}; - -use crate::{ - ArgsModuleMethod, - deserialize_module_method_args, - serialize_module_method_result, - ArgsObjectMethod, - deserialize_object_method_args, - serialize_object_method_result, - ArgsOptionalEnvMethod, - deserialize_optional_env_method_args, - serialize_optional_env_method_result, - ArgsIf, - deserialize_if_args, - serialize_if_result -}; - -use crate::module::{ModuleTrait, Module}; -use crate::Env; - -pub fn module_method_wrapped(args: &[u8], env_size: u32) -> Vec { - match deserialize_module_method_args(args) { - Ok(args) => { - let result = Module::module_method(ArgsModuleMethod { - str: args.str, - opt_str: args.opt_str, - en: args.en, - opt_enum: args.opt_enum, - enum_array: args.enum_array, - opt_enum_array: args.opt_enum_array, - map: args.map, - map_of_arr: args.map_of_arr, - map_of_map: args.map_of_map, - map_of_obj: args.map_of_obj, - map_of_arr_of_obj: args.map_of_arr_of_obj, - }); - match result { - Ok(res) => { - serialize_module_method_result(&res).unwrap() - } - Err(e) => { - panic!("{}", e.to_string()) - } - } - } - Err(e) => { - panic!("{}", e.to_string()) - } - } -} - -pub fn object_method_wrapped(args: &[u8], env_size: u32) -> Vec { - if env_size == 0 { - panic!("Environment is not set, and it is required by method 'objectMethod'"); - } - - let env_buf = wrap_load_env(env_size); - let env = Env::from_buffer(&env_buf).unwrap(); - - match deserialize_object_method_args(args) { - Ok(args) => { - let result = Module::object_method(ArgsObjectMethod { - object: args.object, - opt_object: args.opt_object, - object_array: args.object_array, - opt_object_array: args.opt_object_array, - }, env); - match result { - Ok(res) => { - serialize_object_method_result(&res).unwrap() - } - Err(e) => { - panic!("{}", e.to_string()) - } - } - } - Err(e) => { - panic!("{}", e.to_string()) - } - } -} - -pub fn optional_env_method_wrapped(args: &[u8], env_size: u32) -> Vec { - let mut env: Option = None; - if env_size > 0 { - let env_buf = wrap_load_env(env_size); - env = Some(Env::from_buffer(&env_buf).unwrap()); - } - - match deserialize_optional_env_method_args(args) { - Ok(args) => { - let result = Module::optional_env_method(ArgsOptionalEnvMethod { - object: args.object, - opt_object: args.opt_object, - object_array: args.object_array, - opt_object_array: args.opt_object_array, - }, env); - match result { - Ok(res) => { - serialize_optional_env_method_result(&res).unwrap() - } - Err(e) => { - panic!("{}", e.to_string()) - } - } - } - Err(e) => { - panic!("{}", e.to_string()) - } - } -} - -pub fn if_wrapped(args: &[u8], env_size: u32) -> Vec { - match deserialize_if_args(args) { - Ok(args) => { - let result = Module::_if(ArgsIf { - _if: args._if, - }); - match result { - Ok(res) => { - serialize_if_result(&res).unwrap() - } - Err(e) => { - panic!("{}", e.to_string()) - } - } - } - Err(e) => { - panic!("{}", e.to_string()) - } - } -} diff --git a/packages/test-cases/cases/bind/sanity/output/wasm-rs/test_import/mod.rs b/packages/test-cases/cases/bind/sanity/output/wasm-rs/test_import/mod.rs deleted file mode 100644 index 7cae6addae..0000000000 --- a/packages/test-cases/cases/bind/sanity/output/wasm-rs/test_import/mod.rs +++ /dev/null @@ -1,11 +0,0 @@ -use polywrap_wasm_rs::wrap_get_implementations; - -pub struct TestImport {} - -impl TestImport { - const uri: &'static str = "testimport.uri.eth"; - - pub fn get_implementations() -> Vec { - wrap_get_implementations(Self::uri) - } -} \ No newline at end of file diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/enum_test_import__enum.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/enum_test_import__enum.go new file mode 100644 index 0000000000..e70a6de407 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/enum_test_import__enum.go @@ -0,0 +1,38 @@ +package test_import + +type TestImport_Enum int32 + +const ( + TestImport_EnumSTRING = iota + TestImport_EnumBYTES = iota + testImport_EnumMax = iota +) + +func SanitizeTestImport_EnumValue(value int32) { + if !(value >= 0 && value < int32(testImport_EnumMax)) { + panic("Invalid value for enum 'TestImport_Enum'") + } +} + +func GetTestImport_EnumValue(key string) TestImport_Enum { + switch key { + case "STRING": + return TestImport_EnumSTRING + case "BYTES": + return TestImport_EnumBYTES + default: + panic("Invalid key for enum 'TestImport_Enum'") + } +} + +func GetTestImport_EnumKey(value TestImport_Enum) string { + SanitizeTestImport_EnumValue(int32(value)) + switch value { + case TestImport_EnumSTRING: + return "STRING" + case TestImport_EnumBYTES: + return "BYTES" + default: + panic("Invalid value for enum 'TestImport_Enum'") + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/enum_test_import__enum__return.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/enum_test_import__enum__return.go new file mode 100644 index 0000000000..893faccee3 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/enum_test_import__enum__return.go @@ -0,0 +1,38 @@ +package test_import + +type TestImport_Enum_Return int32 + +const ( + TestImport_Enum_ReturnSTRING = iota + TestImport_Enum_ReturnBYTES = iota + testImport_Enum_ReturnMax = iota +) + +func SanitizeTestImport_Enum_ReturnValue(value int32) { + if !(value >= 0 && value < int32(testImport_Enum_ReturnMax)) { + panic("Invalid value for enum 'TestImport_Enum_Return'") + } +} + +func GetTestImport_Enum_ReturnValue(key string) TestImport_Enum_Return { + switch key { + case "STRING": + return TestImport_Enum_ReturnSTRING + case "BYTES": + return TestImport_Enum_ReturnBYTES + default: + panic("Invalid key for enum 'TestImport_Enum_Return'") + } +} + +func GetTestImport_Enum_ReturnKey(value TestImport_Enum_Return) string { + SanitizeTestImport_Enum_ReturnValue(int32(value)) + switch value { + case TestImport_Enum_ReturnSTRING: + return "STRING" + case TestImport_Enum_ReturnBYTES: + return "BYTES" + default: + panic("Invalid value for enum 'TestImport_Enum_Return'") + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/env_test_import__env.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/env_test_import__env.go new file mode 100644 index 0000000000..5478dd8ab9 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/env_test_import__env.go @@ -0,0 +1,32 @@ +package test_import + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +type TestImport_Env struct { + Object TestImport_AnotherObject `json:"object"` + OptObject *TestImport_AnotherObject `json:"optObject"` + ObjectArray []TestImport_AnotherObject `json:"objectArray"` + OptObjectArray []*TestImport_AnotherObject `json:"optObjectArray"` + En TestImport_Enum `json:"en"` + OptEnum *TestImport_Enum `json:"optEnum"` + EnumArray []TestImport_Enum `json:"enumArray"` + OptEnumArray []*TestImport_Enum `json:"optEnumArray"` +} + +func TestImport_EnvToBuffer(value *TestImport_Env) []byte { + return serializeTestImport_Env(value) +} + +func TestImport_EnvFromBuffer(data []byte) *TestImport_Env { + return deserializeTestImport_Env(data) +} + +func TestImport_EnvWrite(writer msgpack.Write, value *TestImport_Env) { + writeTestImport_Env(writer, value) +} + +func TestImport_EnvRead(reader msgpack.Read) *TestImport_Env { + return readTestImport_Env(reader) +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/env_test_import__env_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/env_test_import__env_serialization.go new file mode 100644 index 0000000000..1020a49736 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/env_test_import__env_serialization.go @@ -0,0 +1,257 @@ +package test_import + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +func serializeTestImport_Env(value *TestImport_Env) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: TestImport_Env") + encoder := msgpack.NewWriteEncoder(ctx) + writeTestImport_Env(encoder, value) + return encoder.Buffer() +} + +func writeTestImport_Env(writer msgpack.Write, value *TestImport_Env) { + writer.WriteMapLength(8) + writer.Context().Push("object", "TestImport_AnotherObject", "writing property") + writer.WriteString("object") + { + v := value.Object + TestImport_AnotherObjectWrite(writer, &v) + } + writer.Context().Pop() + writer.Context().Push("optObject", "*TestImport_AnotherObject", "writing property") + writer.WriteString("optObject") + { + v := value.OptObject + TestImport_AnotherObjectWrite(writer, v) + } + writer.Context().Pop() + writer.Context().Push("objectArray", "[]TestImport_AnotherObject", "writing property") + writer.WriteString("objectArray") + if value.ObjectArray == nil { + writer.WriteNil() + } else if len(value.ObjectArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.ObjectArray))) + for i0 := range value.ObjectArray { + { + v := value.ObjectArray[i0] + TestImport_AnotherObjectWrite(writer, &v) + } + } + } + writer.Context().Pop() + writer.Context().Push("optObjectArray", "[]*TestImport_AnotherObject", "writing property") + writer.WriteString("optObjectArray") + if value.OptObjectArray == nil { + writer.WriteNil() + } else if len(value.OptObjectArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.OptObjectArray))) + for i0 := range value.OptObjectArray { + { + v := value.OptObjectArray[i0] + TestImport_AnotherObjectWrite(writer, v) + } + } + } + writer.Context().Pop() + writer.Context().Push("en", "TestImport_Enum", "writing property") + writer.WriteString("en") + { + v := value.En + writer.WriteI32(int32(v)) + } + writer.Context().Pop() + writer.Context().Push("optEnum", "*TestImport_Enum", "writing property") + writer.WriteString("optEnum") + { + v := value.OptEnum + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + } + writer.Context().Pop() + writer.Context().Push("enumArray", "[]TestImport_Enum", "writing property") + writer.WriteString("enumArray") + if value.EnumArray == nil { + writer.WriteNil() + } else if len(value.EnumArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.EnumArray))) + for i0 := range value.EnumArray { + { + v := value.EnumArray[i0] + writer.WriteI32(int32(v)) + } + } + } + writer.Context().Pop() + writer.Context().Push("optEnumArray", "[]*TestImport_Enum", "writing property") + writer.WriteString("optEnumArray") + if value.OptEnumArray == nil { + writer.WriteNil() + } else if len(value.OptEnumArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.OptEnumArray))) + for i0 := range value.OptEnumArray { + { + v := value.OptEnumArray[i0] + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + } + } + } + writer.Context().Pop() +} + +func deserializeTestImport_Env(data []byte) *TestImport_Env { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: TestImport_Env") + reader := msgpack.NewReadDecoder(ctx, data) + return readTestImport_Env(reader) +} + +func readTestImport_Env(reader msgpack.Read) *TestImport_Env { + var ( + _object TestImport_AnotherObject + _objectSet bool + _optObject *TestImport_AnotherObject + _objectArray []TestImport_AnotherObject + _objectArraySet bool + _optObjectArray []*TestImport_AnotherObject + _en TestImport_Enum + _enSet bool + _optEnum *TestImport_Enum + _enumArray []TestImport_Enum + _enumArraySet bool + _optEnumArray []*TestImport_Enum + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "object": + reader.Context().Push(field, "TestImport_AnotherObject", "type found, reading property") + if v := TestImport_AnotherObjectRead(reader); v != nil { + _object = *v + } + _objectSet = true + reader.Context().Pop() + case "optObject": + reader.Context().Push(field, "*TestImport_AnotherObject", "type found, reading property") + if v := TestImport_AnotherObjectRead(reader); v != nil { + _optObject = v + } + reader.Context().Pop() + case "objectArray": + reader.Context().Push(field, "[]TestImport_AnotherObject", "type found, reading property") + if reader.IsNil() { + _objectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _objectArray = make([]TestImport_AnotherObject, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := TestImport_AnotherObjectRead(reader); v != nil { + _objectArray[i0] = *v + } + } + } + _objectArraySet = true + reader.Context().Pop() + case "optObjectArray": + reader.Context().Push(field, "[]*TestImport_AnotherObject", "type found, reading property") + if reader.IsNil() { + _optObjectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optObjectArray = make([]*TestImport_AnotherObject, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := TestImport_AnotherObjectRead(reader); v != nil { + _optObjectArray[i0] = v + } + } + } + reader.Context().Pop() + case "en": + reader.Context().Push(field, "TestImport_Enum", "type found, reading property") + _en = TestImport_Enum(reader.ReadI32()) + SanitizeTestImport_EnumValue(int32(_en)) + _enSet = true + reader.Context().Pop() + case "optEnum": + reader.Context().Push(field, "*TestImport_Enum", "type found, reading property") + if !reader.IsNil() { + v := TestImport_Enum(reader.ReadI32()) + SanitizeTestImport_EnumValue(int32(v)) + _optEnum = &v + } + reader.Context().Pop() + case "enumArray": + reader.Context().Push(field, "[]TestImport_Enum", "type found, reading property") + if reader.IsNil() { + _enumArray = nil + } else { + ln0 := reader.ReadArrayLength() + _enumArray = make([]TestImport_Enum, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + _enumArray[i0] = TestImport_Enum(reader.ReadI32()) + SanitizeTestImport_EnumValue(int32(_enumArray[i0])) + } + } + _enumArraySet = true + reader.Context().Pop() + case "optEnumArray": + reader.Context().Push(field, "[]*TestImport_Enum", "type found, reading property") + if reader.IsNil() { + _optEnumArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optEnumArray = make([]*TestImport_Enum, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if !reader.IsNil() { + v := TestImport_Enum(reader.ReadI32()) + SanitizeTestImport_EnumValue(int32(v)) + _optEnumArray[i0] = &v + } + } + } + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_objectSet { + panic(reader.Context().PrintWithContext("Missing required property: 'object: TestImport_AnotherObject'")) + } + if !_objectArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'objectArray: [TestImport_AnotherObject]'")) + } + if !_enSet { + panic(reader.Context().PrintWithContext("Missing required property: 'en: TestImport_Enum'")) + } + if !_enumArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'enumArray: [TestImport_Enum]'")) + } + + return &TestImport_Env{ + Object: _object, + OptObject: _optObject, + ObjectArray: _objectArray, + OptObjectArray: _optObjectArray, + En: _en, + OptEnum: _optEnum, + EnumArray: _enumArray, + OptEnumArray: _optEnumArray, + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__another_object.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__another_object.go new file mode 100644 index 0000000000..f01380602e --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__another_object.go @@ -0,0 +1,25 @@ +package test_import + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +type TestImport_AnotherObject struct { + Prop string `json:"prop"` +} + +func TestImport_AnotherObjectToBuffer(value *TestImport_AnotherObject) []byte { + return serializeTestImport_AnotherObject(value) +} + +func TestImport_AnotherObjectFromBuffer(data []byte) *TestImport_AnotherObject { + return deserializeTestImport_AnotherObject(data) +} + +func TestImport_AnotherObjectWrite(writer msgpack.Write, value *TestImport_AnotherObject) { + writeTestImport_AnotherObject(writer, value) +} + +func TestImport_AnotherObjectRead(reader msgpack.Read) *TestImport_AnotherObject { + return readTestImport_AnotherObject(reader) +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__another_object_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__another_object_serialization.go new file mode 100644 index 0000000000..019cc8ad67 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__another_object_serialization.go @@ -0,0 +1,57 @@ +package test_import + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +func serializeTestImport_AnotherObject(value *TestImport_AnotherObject) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: TestImport_AnotherObject") + encoder := msgpack.NewWriteEncoder(ctx) + writeTestImport_AnotherObject(encoder, value) + return encoder.Buffer() +} + +func writeTestImport_AnotherObject(writer msgpack.Write, value *TestImport_AnotherObject) { + writer.WriteMapLength(1) + writer.Context().Push("prop", "string", "writing property") + writer.WriteString("prop") + { + v := value.Prop + writer.WriteString(v) + } + writer.Context().Pop() +} + +func deserializeTestImport_AnotherObject(data []byte) *TestImport_AnotherObject { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: TestImport_AnotherObject") + reader := msgpack.NewReadDecoder(ctx, data) + return readTestImport_AnotherObject(reader) +} + +func readTestImport_AnotherObject(reader msgpack.Read) *TestImport_AnotherObject { + var ( + _prop string + _propSet bool + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "prop": + reader.Context().Push(field, "string", "type found, reading property") + _prop = reader.ReadString() + _propSet = true + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_propSet { + panic(reader.Context().PrintWithContext("Missing required property: 'prop: String'")) + } + + return &TestImport_AnotherObject{ + Prop: _prop, + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__object.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__object.go new file mode 100644 index 0000000000..1fc1c743a3 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__object.go @@ -0,0 +1,32 @@ +package test_import + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +type TestImport_Object struct { + Object TestImport_AnotherObject `json:"object"` + OptObject *TestImport_AnotherObject `json:"optObject"` + ObjectArray []TestImport_AnotherObject `json:"objectArray"` + OptObjectArray []*TestImport_AnotherObject `json:"optObjectArray"` + En TestImport_Enum `json:"en"` + OptEnum *TestImport_Enum `json:"optEnum"` + EnumArray []TestImport_Enum `json:"enumArray"` + OptEnumArray []*TestImport_Enum `json:"optEnumArray"` +} + +func TestImport_ObjectToBuffer(value *TestImport_Object) []byte { + return serializeTestImport_Object(value) +} + +func TestImport_ObjectFromBuffer(data []byte) *TestImport_Object { + return deserializeTestImport_Object(data) +} + +func TestImport_ObjectWrite(writer msgpack.Write, value *TestImport_Object) { + writeTestImport_Object(writer, value) +} + +func TestImport_ObjectRead(reader msgpack.Read) *TestImport_Object { + return readTestImport_Object(reader) +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__object_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__object_serialization.go new file mode 100644 index 0000000000..ef21ee4bfc --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/object_test_import__object_serialization.go @@ -0,0 +1,257 @@ +package test_import + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +func serializeTestImport_Object(value *TestImport_Object) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: TestImport_Object") + encoder := msgpack.NewWriteEncoder(ctx) + writeTestImport_Object(encoder, value) + return encoder.Buffer() +} + +func writeTestImport_Object(writer msgpack.Write, value *TestImport_Object) { + writer.WriteMapLength(8) + writer.Context().Push("object", "TestImport_AnotherObject", "writing property") + writer.WriteString("object") + { + v := value.Object + TestImport_AnotherObjectWrite(writer, &v) + } + writer.Context().Pop() + writer.Context().Push("optObject", "*TestImport_AnotherObject", "writing property") + writer.WriteString("optObject") + { + v := value.OptObject + TestImport_AnotherObjectWrite(writer, v) + } + writer.Context().Pop() + writer.Context().Push("objectArray", "[]TestImport_AnotherObject", "writing property") + writer.WriteString("objectArray") + if value.ObjectArray == nil { + writer.WriteNil() + } else if len(value.ObjectArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.ObjectArray))) + for i0 := range value.ObjectArray { + { + v := value.ObjectArray[i0] + TestImport_AnotherObjectWrite(writer, &v) + } + } + } + writer.Context().Pop() + writer.Context().Push("optObjectArray", "[]*TestImport_AnotherObject", "writing property") + writer.WriteString("optObjectArray") + if value.OptObjectArray == nil { + writer.WriteNil() + } else if len(value.OptObjectArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.OptObjectArray))) + for i0 := range value.OptObjectArray { + { + v := value.OptObjectArray[i0] + TestImport_AnotherObjectWrite(writer, v) + } + } + } + writer.Context().Pop() + writer.Context().Push("en", "TestImport_Enum", "writing property") + writer.WriteString("en") + { + v := value.En + writer.WriteI32(int32(v)) + } + writer.Context().Pop() + writer.Context().Push("optEnum", "*TestImport_Enum", "writing property") + writer.WriteString("optEnum") + { + v := value.OptEnum + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + } + writer.Context().Pop() + writer.Context().Push("enumArray", "[]TestImport_Enum", "writing property") + writer.WriteString("enumArray") + if value.EnumArray == nil { + writer.WriteNil() + } else if len(value.EnumArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.EnumArray))) + for i0 := range value.EnumArray { + { + v := value.EnumArray[i0] + writer.WriteI32(int32(v)) + } + } + } + writer.Context().Pop() + writer.Context().Push("optEnumArray", "[]*TestImport_Enum", "writing property") + writer.WriteString("optEnumArray") + if value.OptEnumArray == nil { + writer.WriteNil() + } else if len(value.OptEnumArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.OptEnumArray))) + for i0 := range value.OptEnumArray { + { + v := value.OptEnumArray[i0] + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + } + } + } + writer.Context().Pop() +} + +func deserializeTestImport_Object(data []byte) *TestImport_Object { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: TestImport_Object") + reader := msgpack.NewReadDecoder(ctx, data) + return readTestImport_Object(reader) +} + +func readTestImport_Object(reader msgpack.Read) *TestImport_Object { + var ( + _object TestImport_AnotherObject + _objectSet bool + _optObject *TestImport_AnotherObject + _objectArray []TestImport_AnotherObject + _objectArraySet bool + _optObjectArray []*TestImport_AnotherObject + _en TestImport_Enum + _enSet bool + _optEnum *TestImport_Enum + _enumArray []TestImport_Enum + _enumArraySet bool + _optEnumArray []*TestImport_Enum + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "object": + reader.Context().Push(field, "TestImport_AnotherObject", "type found, reading property") + if v := TestImport_AnotherObjectRead(reader); v != nil { + _object = *v + } + _objectSet = true + reader.Context().Pop() + case "optObject": + reader.Context().Push(field, "*TestImport_AnotherObject", "type found, reading property") + if v := TestImport_AnotherObjectRead(reader); v != nil { + _optObject = v + } + reader.Context().Pop() + case "objectArray": + reader.Context().Push(field, "[]TestImport_AnotherObject", "type found, reading property") + if reader.IsNil() { + _objectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _objectArray = make([]TestImport_AnotherObject, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := TestImport_AnotherObjectRead(reader); v != nil { + _objectArray[i0] = *v + } + } + } + _objectArraySet = true + reader.Context().Pop() + case "optObjectArray": + reader.Context().Push(field, "[]*TestImport_AnotherObject", "type found, reading property") + if reader.IsNil() { + _optObjectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optObjectArray = make([]*TestImport_AnotherObject, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := TestImport_AnotherObjectRead(reader); v != nil { + _optObjectArray[i0] = v + } + } + } + reader.Context().Pop() + case "en": + reader.Context().Push(field, "TestImport_Enum", "type found, reading property") + _en = TestImport_Enum(reader.ReadI32()) + SanitizeTestImport_EnumValue(int32(_en)) + _enSet = true + reader.Context().Pop() + case "optEnum": + reader.Context().Push(field, "*TestImport_Enum", "type found, reading property") + if !reader.IsNil() { + v := TestImport_Enum(reader.ReadI32()) + SanitizeTestImport_EnumValue(int32(v)) + _optEnum = &v + } + reader.Context().Pop() + case "enumArray": + reader.Context().Push(field, "[]TestImport_Enum", "type found, reading property") + if reader.IsNil() { + _enumArray = nil + } else { + ln0 := reader.ReadArrayLength() + _enumArray = make([]TestImport_Enum, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + _enumArray[i0] = TestImport_Enum(reader.ReadI32()) + SanitizeTestImport_EnumValue(int32(_enumArray[i0])) + } + } + _enumArraySet = true + reader.Context().Pop() + case "optEnumArray": + reader.Context().Push(field, "[]*TestImport_Enum", "type found, reading property") + if reader.IsNil() { + _optEnumArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optEnumArray = make([]*TestImport_Enum, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if !reader.IsNil() { + v := TestImport_Enum(reader.ReadI32()) + SanitizeTestImport_EnumValue(int32(v)) + _optEnumArray[i0] = &v + } + } + } + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_objectSet { + panic(reader.Context().PrintWithContext("Missing required property: 'object: TestImport_AnotherObject'")) + } + if !_objectArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'objectArray: [TestImport_AnotherObject]'")) + } + if !_enSet { + panic(reader.Context().PrintWithContext("Missing required property: 'en: TestImport_Enum'")) + } + if !_enumArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'enumArray: [TestImport_Enum]'")) + } + + return &TestImport_Object{ + Object: _object, + OptObject: _optObject, + ObjectArray: _objectArray, + OptObjectArray: _optObjectArray, + En: _en, + OptEnum: _optEnum, + EnumArray: _enumArray, + OptEnumArray: _optEnumArray, + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/test_import__module_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/test_import__module_serialization.go new file mode 100644 index 0000000000..661c0fc8d0 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/test_import__module_serialization.go @@ -0,0 +1,297 @@ +package test_import + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +type TestImport_ArgsImportedMethod struct { + Str string `json:"str"` + OptStr *string `json:"optStr"` + U uint32 `json:"u"` + OptU *uint32 `json:"optU"` + UArrayArray [][]*uint32 `json:"uArrayArray"` + Object TestImport_Object `json:"object"` + OptObject *TestImport_Object `json:"optObject"` + ObjectArray []TestImport_Object `json:"objectArray"` + OptObjectArray []*TestImport_Object `json:"optObjectArray"` + En TestImport_Enum `json:"en"` + OptEnum *TestImport_Enum `json:"optEnum"` + EnumArray []TestImport_Enum `json:"enumArray"` + OptEnumArray []*TestImport_Enum `json:"optEnumArray"` +} + +func SerializeTestImport_ImportedMethodArgs(value *TestImport_ArgsImportedMethod) []byte { + ctx := msgpack.NewContext("Serializing module-type: ImportedMethod") + encoder := msgpack.NewWriteEncoder(ctx) + WriteTestImport_ImportedMethodArgs(encoder, value) + return encoder.Buffer() +} + +func WriteTestImport_ImportedMethodArgs(writer msgpack.Write, value *TestImport_ArgsImportedMethod) { + writer.WriteMapLength(13) + writer.Context().Push("str", "string", "writing property") + writer.WriteString("str") + { + v := value.Str + writer.WriteString(v) + } + writer.Context().Pop() + writer.Context().Push("optStr", "*string", "writing property") + writer.WriteString("optStr") + { + v := value.OptStr + if v == nil { + writer.WriteNil() + } else { + writer.WriteString(*v) + } + } + writer.Context().Pop() + writer.Context().Push("u", "uint32", "writing property") + writer.WriteString("u") + { + v := value.U + writer.WriteU32(v) + } + writer.Context().Pop() + writer.Context().Push("optU", "*uint32", "writing property") + writer.WriteString("optU") + { + v := value.OptU + if v == nil { + writer.WriteNil() + } else { + writer.WriteU32(*v) + } + } + writer.Context().Pop() + writer.Context().Push("uArrayArray", "[][]*uint32", "writing property") + writer.WriteString("uArrayArray") + if value.UArrayArray == nil { + writer.WriteNil() + } else if len(value.UArrayArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UArrayArray))) + for i0 := range value.UArrayArray { + if value.UArrayArray[i0] == nil { + writer.WriteNil() + } else if len(value.UArrayArray[i0]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UArrayArray[i0]))) + for i1 := range value.UArrayArray[i0] { + { + v := value.UArrayArray[i0][i1] + if v == nil { + writer.WriteNil() + } else { + writer.WriteU32(*v) + } + } + } + } + } + } + writer.Context().Pop() + writer.Context().Push("object", "TestImport_Object", "writing property") + writer.WriteString("object") + { + v := value.Object + TestImport_ObjectWrite(writer, &v) + } + writer.Context().Pop() + writer.Context().Push("optObject", "*TestImport_Object", "writing property") + writer.WriteString("optObject") + { + v := value.OptObject + TestImport_ObjectWrite(writer, v) + } + writer.Context().Pop() + writer.Context().Push("objectArray", "[]TestImport_Object", "writing property") + writer.WriteString("objectArray") + if value.ObjectArray == nil { + writer.WriteNil() + } else if len(value.ObjectArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.ObjectArray))) + for i0 := range value.ObjectArray { + { + v := value.ObjectArray[i0] + TestImport_ObjectWrite(writer, &v) + } + } + } + writer.Context().Pop() + writer.Context().Push("optObjectArray", "[]*TestImport_Object", "writing property") + writer.WriteString("optObjectArray") + if value.OptObjectArray == nil { + writer.WriteNil() + } else if len(value.OptObjectArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.OptObjectArray))) + for i0 := range value.OptObjectArray { + { + v := value.OptObjectArray[i0] + TestImport_ObjectWrite(writer, v) + } + } + } + writer.Context().Pop() + writer.Context().Push("en", "TestImport_Enum", "writing property") + writer.WriteString("en") + { + v := value.En + writer.WriteI32(int32(v)) + } + writer.Context().Pop() + writer.Context().Push("optEnum", "*TestImport_Enum", "writing property") + writer.WriteString("optEnum") + { + v := value.OptEnum + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + } + writer.Context().Pop() + writer.Context().Push("enumArray", "[]TestImport_Enum", "writing property") + writer.WriteString("enumArray") + if value.EnumArray == nil { + writer.WriteNil() + } else if len(value.EnumArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.EnumArray))) + for i0 := range value.EnumArray { + { + v := value.EnumArray[i0] + writer.WriteI32(int32(v)) + } + } + } + writer.Context().Pop() + writer.Context().Push("optEnumArray", "[]*TestImport_Enum", "writing property") + writer.WriteString("optEnumArray") + if value.OptEnumArray == nil { + writer.WriteNil() + } else if len(value.OptEnumArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.OptEnumArray))) + for i0 := range value.OptEnumArray { + { + v := value.OptEnumArray[i0] + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + } + } + } + writer.Context().Pop() +} + +func DeserializeTestImport_ImportedMethodResult(argsBuf []byte) *TestImport_Object { + ctx := msgpack.NewContext("Deserializing module-type: ImportedMethod") + reader := msgpack.NewReadDecoder(ctx, argsBuf) + + reader.Context().Push("importedMethod", "*TestImport_Object", "reading function output") + var value *TestImport_Object + if v := TestImport_ObjectRead(reader); v != nil { + value = v + } + reader.Context().Pop() + return value +} + +type TestImport_ArgsAnotherMethod struct { + Arg []string `json:"arg"` +} + +func SerializeTestImport_AnotherMethodArgs(value *TestImport_ArgsAnotherMethod) []byte { + ctx := msgpack.NewContext("Serializing module-type: AnotherMethod") + encoder := msgpack.NewWriteEncoder(ctx) + WriteTestImport_AnotherMethodArgs(encoder, value) + return encoder.Buffer() +} + +func WriteTestImport_AnotherMethodArgs(writer msgpack.Write, value *TestImport_ArgsAnotherMethod) { + writer.WriteMapLength(1) + writer.Context().Push("arg", "[]string", "writing property") + writer.WriteString("arg") + if value.Arg == nil { + writer.WriteNil() + } else if len(value.Arg) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.Arg))) + for i0 := range value.Arg { + { + v := value.Arg[i0] + writer.WriteString(v) + } + } + } + writer.Context().Pop() +} + +func DeserializeTestImport_AnotherMethodResult(argsBuf []byte) int32 { + ctx := msgpack.NewContext("Deserializing module-type: AnotherMethod") + reader := msgpack.NewReadDecoder(ctx, argsBuf) + + reader.Context().Push("anotherMethod", "int32", "reading function output") + var value int32 + value = reader.ReadI32() + reader.Context().Pop() + return value +} + +type TestImport_ArgsReturnsArrayOfEnums struct { + Arg string `json:"arg"` +} + +func SerializeTestImport_ReturnsArrayOfEnumsArgs(value *TestImport_ArgsReturnsArrayOfEnums) []byte { + ctx := msgpack.NewContext("Serializing module-type: ReturnsArrayOfEnums") + encoder := msgpack.NewWriteEncoder(ctx) + WriteTestImport_ReturnsArrayOfEnumsArgs(encoder, value) + return encoder.Buffer() +} + +func WriteTestImport_ReturnsArrayOfEnumsArgs(writer msgpack.Write, value *TestImport_ArgsReturnsArrayOfEnums) { + writer.WriteMapLength(1) + writer.Context().Push("arg", "string", "writing property") + writer.WriteString("arg") + { + v := value.Arg + writer.WriteString(v) + } + writer.Context().Pop() +} + +func DeserializeTestImport_ReturnsArrayOfEnumsResult(argsBuf []byte) []*TestImport_Enum_Return { + ctx := msgpack.NewContext("Deserializing module-type: ReturnsArrayOfEnums") + reader := msgpack.NewReadDecoder(ctx, argsBuf) + + reader.Context().Push("returnsArrayOfEnums", "[]*TestImport_Enum_Return", "reading function output") + var value []*TestImport_Enum_Return + if reader.IsNil() { + value = nil + } else { + ln0 := reader.ReadArrayLength() + value = make([]*TestImport_Enum_Return, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if !reader.IsNil() { + v := TestImport_Enum_Return(reader.ReadI32()) + SanitizeTestImport_Enum_ReturnValue(int32(v)) + _returnsArrayOfEnums[i0] = &v + } + } + } + reader.Context().Pop() + return value +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/test_import__module_wrapped.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/test_import__module_wrapped.go new file mode 100644 index 0000000000..2b97c088d7 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/imported/test_import/test_import__module_wrapped.go @@ -0,0 +1,47 @@ +package test_import + +import ( + "github.com/polywrap/go-wrap/wrap" +) + +func TestImport_ImportedMethod(uri string, args *TestImport_ArgsImportedMethod) (*TestImport_Object, error) { + argsBuf := SerializeTestImport_ImportedMethodArgs(args) + var ( + err error + raw []byte + data *TestImport_Object + ) + raw, err = wrap.WrapSubinvokeImplementation("testimport.uri.eth", uri, "importedMethod", argsBuf) + if err == nil { + data = DeserializeTestImport_ImportedMethodResult(raw) + } + return data, err +} + +func TestImport_AnotherMethod(uri string, args *TestImport_ArgsAnotherMethod) (int32, error) { + argsBuf := SerializeTestImport_AnotherMethodArgs(args) + var ( + err error + raw []byte + data int32 + ) + raw, err = wrap.WrapSubinvokeImplementation("testimport.uri.eth", uri, "anotherMethod", argsBuf) + if err == nil { + data = DeserializeTestImport_AnotherMethodResult(raw) + } + return data, err +} + +func TestImport_ReturnsArrayOfEnums(uri string, args *TestImport_ArgsReturnsArrayOfEnums) ([]*TestImport_Enum_Return, error) { + argsBuf := SerializeTestImport_ReturnsArrayOfEnumsArgs(args) + var ( + err error + raw []byte + data []*TestImport_Enum_Return + ) + raw, err = wrap.WrapSubinvokeImplementation("testimport.uri.eth", uri, "returnsArrayOfEnums", argsBuf) + if err == nil { + data = DeserializeTestImport_ReturnsArrayOfEnumsResult(raw) + } + return data, err +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/interfaces/test_import.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/interfaces/test_import.go new file mode 100644 index 0000000000..a2ce917fff --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/interfaces/test_import.go @@ -0,0 +1,7 @@ +package interfaces + +import "github.com/polywrap/go-wrap/wrap" + +func TestImport_GetImplementations() []string { + return wrap.WrapGetImplementations("testimport.uri.eth") +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/main/main.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/main/main.go new file mode 100644 index 0000000000..46bbee1c6d --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/main/main.go @@ -0,0 +1,26 @@ +package main + +import ( + "github.com/testorg/testrepo/module/wrap/module_wrapped" + "github.com/polywrap/go-wrap/wrap" +) + +//export _wrap_invoke +func _wrap_invoke(methodSize, argsSize, envSize uint32) bool { + args := wrap.WrapInvokeArgs(methodSize, argsSize) + switch args.Method { + case "moduleMethod": + return wrap.WrapInvoke(args, envSize, module_wrapped.ModuleMethodWrapped) + case "objectMethod": + return wrap.WrapInvoke(args, envSize, module_wrapped.ObjectMethodWrapped) + case "optionalEnvMethod": + return wrap.WrapInvoke(args, envSize, module_wrapped.OptionalEnvMethodWrapped) + case "if": + return wrap.WrapInvoke(args, envSize, module_wrapped.IfWrapped) + default: + return wrap.WrapInvoke(args, envSize, nil) + } +} + +func main() { +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/module_wrapped/module_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/module_wrapped/module_serialization.go new file mode 100644 index 0000000000..77627d7244 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/module_wrapped/module_serialization.go @@ -0,0 +1,489 @@ +package module_wrapped + +import ( + . "github.com/testorg/testrepo/module/wrap/imported/test_import" + . "github.com/testorg/testrepo/module/wrap/types" + "github.com/polywrap/go-wrap/msgpack" +) + +func DeserializeModuleMethodArgs(argsBuf []byte) *ArgsModuleMethod { + ctx := msgpack.NewContext("Deserializing module-type: ModuleMethod") + reader := msgpack.NewReadDecoder(ctx, argsBuf) + + var ( + _str string + _strSet bool + _optStr *string + _en CustomEnum + _enSet bool + _optEnum *CustomEnum + _enumArray []CustomEnum + _enumArraySet bool + _optEnumArray []*CustomEnum + _map map[string]int32 + _mapSet bool + _mapOfArr map[string][]int32 + _mapOfArrSet bool + _mapOfMap map[string]map[string]int32 + _mapOfMapSet bool + _mapOfObj map[string]AnotherType + _mapOfObjSet bool + _mapOfArrOfObj map[string][]AnotherType + _mapOfArrOfObjSet bool + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "str": + reader.Context().Push(field, "string", "type found, reading property") + _str = reader.ReadString() + _strSet = true + reader.Context().Pop() + case "optStr": + reader.Context().Push(field, "*string", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadString() + _optStr = &v + } + reader.Context().Pop() + case "en": + reader.Context().Push(field, "CustomEnum", "type found, reading property") + _en = CustomEnum(reader.ReadI32()) + SanitizeCustomEnumValue(int32(_en)) + _enSet = true + reader.Context().Pop() + case "optEnum": + reader.Context().Push(field, "*CustomEnum", "type found, reading property") + if !reader.IsNil() { + v := CustomEnum(reader.ReadI32()) + SanitizeCustomEnumValue(int32(v)) + _optEnum = &v + } + reader.Context().Pop() + case "enumArray": + reader.Context().Push(field, "[]CustomEnum", "type found, reading property") + if reader.IsNil() { + _enumArray = nil + } else { + ln0 := reader.ReadArrayLength() + _enumArray = make([]CustomEnum, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + _enumArray[i0] = CustomEnum(reader.ReadI32()) + SanitizeCustomEnumValue(int32(_enumArray[i0])) + } + } + _enumArraySet = true + reader.Context().Pop() + case "optEnumArray": + reader.Context().Push(field, "[]*CustomEnum", "type found, reading property") + if reader.IsNil() { + _optEnumArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optEnumArray = make([]*CustomEnum, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if !reader.IsNil() { + v := CustomEnum(reader.ReadI32()) + SanitizeCustomEnumValue(int32(v)) + _optEnumArray[i0] = &v + } + } + } + reader.Context().Pop() + case "map": + reader.Context().Push(field, "map[string]int32", "type found, reading property") + if reader.IsNil() { + _map = nil + } else { + ln0 := reader.ReadMapLength() + _map = make(map[string]int32) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + _map[i0] = reader.ReadI32() + } + } + _mapSet = true + reader.Context().Pop() + case "mapOfArr": + reader.Context().Push(field, "map[string][]int32", "type found, reading property") + if reader.IsNil() { + _mapOfArr = nil + } else { + ln0 := reader.ReadMapLength() + _mapOfArr = make(map[string][]int32) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + if reader.IsNil() { + _mapOfArr[i0] = nil + } else { + ln1 := reader.ReadArrayLength() + _mapOfArr[i0] = make([]int32, ln1) + for i1 := uint32(0); i1 < ln1; i1++ { + _mapOfArr[i0][i1] = reader.ReadI32() + } + } + } + } + _mapOfArrSet = true + reader.Context().Pop() + case "mapOfMap": + reader.Context().Push(field, "map[string]map[string]int32", "type found, reading property") + if reader.IsNil() { + _mapOfMap = nil + } else { + ln0 := reader.ReadMapLength() + _mapOfMap = make(map[string]map[string]int32) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + if reader.IsNil() { + _mapOfMap[i0] = nil + } else { + ln1 := reader.ReadMapLength() + _mapOfMap[i0] = make(map[string]int32) + for j1 := uint32(0); j1 < ln1; j1++ { + i1 := reader.ReadString() + _mapOfMap[i0][i1] = reader.ReadI32() + } + } + } + } + _mapOfMapSet = true + reader.Context().Pop() + case "mapOfObj": + reader.Context().Push(field, "map[string]AnotherType", "type found, reading property") + if reader.IsNil() { + _mapOfObj = nil + } else { + ln0 := reader.ReadMapLength() + _mapOfObj = make(map[string]AnotherType) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + if v := AnotherTypeRead(reader); v != nil { + _mapOfObj[i0] = *v + } + } + } + _mapOfObjSet = true + reader.Context().Pop() + case "mapOfArrOfObj": + reader.Context().Push(field, "map[string][]AnotherType", "type found, reading property") + if reader.IsNil() { + _mapOfArrOfObj = nil + } else { + ln0 := reader.ReadMapLength() + _mapOfArrOfObj = make(map[string][]AnotherType) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + if reader.IsNil() { + _mapOfArrOfObj[i0] = nil + } else { + ln1 := reader.ReadArrayLength() + _mapOfArrOfObj[i0] = make([]AnotherType, ln1) + for i1 := uint32(0); i1 < ln1; i1++ { + if v := AnotherTypeRead(reader); v != nil { + _mapOfArrOfObj[i0][i1] = *v + } + } + } + } + } + _mapOfArrOfObjSet = true + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_strSet { + panic(reader.Context().PrintWithContext("Missing required property: 'str: String'")) + } + if !_enSet { + panic(reader.Context().PrintWithContext("Missing required property: 'en: CustomEnum'")) + } + if !_enumArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'enumArray: [CustomEnum]'")) + } + if !_mapSet { + panic(reader.Context().PrintWithContext("Missing required property: 'map: Map'")) + } + if !_mapOfArrSet { + panic(reader.Context().PrintWithContext("Missing required property: 'mapOfArr: Map'")) + } + if !_mapOfMapSet { + panic(reader.Context().PrintWithContext("Missing required property: 'mapOfMap: Map>'")) + } + if !_mapOfObjSet { + panic(reader.Context().PrintWithContext("Missing required property: 'mapOfObj: Map'")) + } + if !_mapOfArrOfObjSet { + panic(reader.Context().PrintWithContext("Missing required property: 'mapOfArrOfObj: Map'")) + } + + return &ArgsModuleMethod{ + Str: _str, + OptStr: _optStr, + En: _en, + OptEnum: _optEnum, + EnumArray: _enumArray, + OptEnumArray: _optEnumArray, + M_map: _map, + MapOfArr: _mapOfArr, + MapOfMap: _mapOfMap, + MapOfObj: _mapOfObj, + MapOfArrOfObj: _mapOfArrOfObj, + } +} + +func SerializeModuleMethodResult(value int32) []byte { + ctx := msgpack.NewContext("Serializing module-type: ModuleMethod") + encoder := msgpack.NewWriteEncoder(ctx) + WriteModuleMethodResult(encoder, value); + return encoder.Buffer() +} + +func WriteModuleMethodResult(writer msgpack.Write, value int32) { + writer.Context().Push("moduleMethod", "int32", "writing property") + { + v := value + writer.WriteI32(v) + } + writer.Context().Pop() +} + +func DeserializeObjectMethodArgs(argsBuf []byte) *ArgsObjectMethod { + ctx := msgpack.NewContext("Deserializing module-type: ObjectMethod") + reader := msgpack.NewReadDecoder(ctx, argsBuf) + + var ( + _object AnotherType + _objectSet bool + _optObject *AnotherType + _objectArray []AnotherType + _objectArraySet bool + _optObjectArray []*AnotherType + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "object": + reader.Context().Push(field, "AnotherType", "type found, reading property") + if v := AnotherTypeRead(reader); v != nil { + _object = *v + } + _objectSet = true + reader.Context().Pop() + case "optObject": + reader.Context().Push(field, "*AnotherType", "type found, reading property") + if v := AnotherTypeRead(reader); v != nil { + _optObject = v + } + reader.Context().Pop() + case "objectArray": + reader.Context().Push(field, "[]AnotherType", "type found, reading property") + if reader.IsNil() { + _objectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _objectArray = make([]AnotherType, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := AnotherTypeRead(reader); v != nil { + _objectArray[i0] = *v + } + } + } + _objectArraySet = true + reader.Context().Pop() + case "optObjectArray": + reader.Context().Push(field, "[]*AnotherType", "type found, reading property") + if reader.IsNil() { + _optObjectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optObjectArray = make([]*AnotherType, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := AnotherTypeRead(reader); v != nil { + _optObjectArray[i0] = v + } + } + } + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_objectSet { + panic(reader.Context().PrintWithContext("Missing required property: 'object: AnotherType'")) + } + if !_objectArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'objectArray: [AnotherType]'")) + } + + return &ArgsObjectMethod{ + Object: _object, + OptObject: _optObject, + ObjectArray: _objectArray, + OptObjectArray: _optObjectArray, + } +} + +func SerializeObjectMethodResult(value *AnotherType) []byte { + ctx := msgpack.NewContext("Serializing module-type: ObjectMethod") + encoder := msgpack.NewWriteEncoder(ctx) + WriteObjectMethodResult(encoder, value); + return encoder.Buffer() +} + +func WriteObjectMethodResult(writer msgpack.Write, value *AnotherType) { + writer.Context().Push("objectMethod", "*AnotherType", "writing property") + { + v := value + AnotherTypeWrite(writer, v) + } + writer.Context().Pop() +} + +func DeserializeOptionalEnvMethodArgs(argsBuf []byte) *ArgsOptionalEnvMethod { + ctx := msgpack.NewContext("Deserializing module-type: OptionalEnvMethod") + reader := msgpack.NewReadDecoder(ctx, argsBuf) + + var ( + _object AnotherType + _objectSet bool + _optObject *AnotherType + _objectArray []AnotherType + _objectArraySet bool + _optObjectArray []*AnotherType + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "object": + reader.Context().Push(field, "AnotherType", "type found, reading property") + if v := AnotherTypeRead(reader); v != nil { + _object = *v + } + _objectSet = true + reader.Context().Pop() + case "optObject": + reader.Context().Push(field, "*AnotherType", "type found, reading property") + if v := AnotherTypeRead(reader); v != nil { + _optObject = v + } + reader.Context().Pop() + case "objectArray": + reader.Context().Push(field, "[]AnotherType", "type found, reading property") + if reader.IsNil() { + _objectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _objectArray = make([]AnotherType, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := AnotherTypeRead(reader); v != nil { + _objectArray[i0] = *v + } + } + } + _objectArraySet = true + reader.Context().Pop() + case "optObjectArray": + reader.Context().Push(field, "[]*AnotherType", "type found, reading property") + if reader.IsNil() { + _optObjectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optObjectArray = make([]*AnotherType, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := AnotherTypeRead(reader); v != nil { + _optObjectArray[i0] = v + } + } + } + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_objectSet { + panic(reader.Context().PrintWithContext("Missing required property: 'object: AnotherType'")) + } + if !_objectArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'objectArray: [AnotherType]'")) + } + + return &ArgsOptionalEnvMethod{ + Object: _object, + OptObject: _optObject, + ObjectArray: _objectArray, + OptObjectArray: _optObjectArray, + } +} + +func SerializeOptionalEnvMethodResult(value *AnotherType) []byte { + ctx := msgpack.NewContext("Serializing module-type: OptionalEnvMethod") + encoder := msgpack.NewWriteEncoder(ctx) + WriteOptionalEnvMethodResult(encoder, value); + return encoder.Buffer() +} + +func WriteOptionalEnvMethodResult(writer msgpack.Write, value *AnotherType) { + writer.Context().Push("optionalEnvMethod", "*AnotherType", "writing property") + { + v := value + AnotherTypeWrite(writer, v) + } + writer.Context().Pop() +} + +func DeserializeIfArgs(argsBuf []byte) *ArgsIf { + ctx := msgpack.NewContext("Deserializing module-type: If") + reader := msgpack.NewReadDecoder(ctx, argsBuf) + + var ( + _if Else + _ifSet bool + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "if": + reader.Context().Push(field, "Else", "type found, reading property") + if v := ElseRead(reader); v != nil { + _if = *v + } + _ifSet = true + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_ifSet { + panic(reader.Context().PrintWithContext("Missing required property: 'if: else'")) + } + + return &ArgsIf{ + M_if: _if, + } +} + +func SerializeIfResult(value Else) []byte { + ctx := msgpack.NewContext("Serializing module-type: If") + encoder := msgpack.NewWriteEncoder(ctx) + WriteIfResult(encoder, value); + return encoder.Buffer() +} + +func WriteIfResult(writer msgpack.Write, value Else) { + writer.Context().Push("if", "Else", "writing property") + { + v := value + ElseWrite(writer, &v) + } + writer.Context().Pop() +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/module_wrapped/module_wrapped.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/module_wrapped/module_wrapped.go new file mode 100644 index 0000000000..037cab3ab6 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/module_wrapped/module_wrapped.go @@ -0,0 +1,52 @@ +package module_wrapped + +import ( + . "github.com/testorg/testrepo/module/wrap/types" + "github.com/polywrap/go-wrap/wrap" + methods "github.com/testorg/testrepo/module" +) + +func ModuleMethodWrapped(argsBuf []byte, envSize uint32) []byte { + + args := DeserializeModuleMethodArgs(argsBuf) + + result := methods.ModuleMethod(args) + return SerializeModuleMethodResult(result) +} + +func ObjectMethodWrapped(argsBuf []byte, envSize uint32) []byte { + var env *Env + if envSize == 0 { + panic("Environment is not set, and it is required by method 'objectMethod'") + } + if envSize > 0 { + envBuf := wrap.WrapLoadEnv(envSize) + env = EnvFromBuffer(envBuf) + } + + args := DeserializeObjectMethodArgs(argsBuf) + + result := methods.ObjectMethod(args,env) + return SerializeObjectMethodResult(result) +} + +func OptionalEnvMethodWrapped(argsBuf []byte, envSize uint32) []byte { + var env *Env + if envSize > 0 { + envBuf := wrap.WrapLoadEnv(envSize) + env = EnvFromBuffer(envBuf) + } + + args := DeserializeOptionalEnvMethodArgs(argsBuf) + + result := methods.OptionalEnvMethod(args,env) + return SerializeOptionalEnvMethodResult(result) +} + +func IfWrapped(argsBuf []byte, envSize uint32) []byte { + + args := DeserializeIfArgs(argsBuf) + + result := methods.If(args) + return SerializeIfResult(result) +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/enum_custom_enum.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/enum_custom_enum.go new file mode 100644 index 0000000000..5ee8b8ac5d --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/enum_custom_enum.go @@ -0,0 +1,38 @@ +package types + +type CustomEnum int32 + +const ( + CustomEnumSTRING = iota + CustomEnumBYTES = iota + customEnumMax = iota +) + +func SanitizeCustomEnumValue(value int32) { + if !(value >= 0 && value < int32(customEnumMax)) { + panic("Invalid value for enum 'CustomEnum'") + } +} + +func GetCustomEnumValue(key string) CustomEnum { + switch key { + case "STRING": + return CustomEnumSTRING + case "BYTES": + return CustomEnumBYTES + default: + panic("Invalid key for enum 'CustomEnum'") + } +} + +func GetCustomEnumKey(value CustomEnum) string { + SanitizeCustomEnumValue(int32(value)) + switch value { + case CustomEnumSTRING: + return "STRING" + case CustomEnumBYTES: + return "BYTES" + default: + panic("Invalid value for enum 'CustomEnum'") + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/enumwhile.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/enumwhile.go new file mode 100644 index 0000000000..16ed26f498 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/enumwhile.go @@ -0,0 +1,38 @@ +package types + +type While int32 + +const ( + Whilefor = iota + Whilein = iota + whileMax = iota +) + +func SanitizeWhileValue(value int32) { + if !(value >= 0 && value < int32(whileMax)) { + panic("Invalid value for enum 'While'") + } +} + +func GetWhileValue(key string) While { + switch key { + case "for": + return Whilefor + case "in": + return Whilein + default: + panic("Invalid key for enum 'While'") + } +} + +func GetWhileKey(value While) string { + SanitizeWhileValue(int32(value)) + switch value { + case Whilefor: + return "for" + case Whilein: + return "in" + default: + panic("Invalid value for enum 'While'") + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/module_args.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/module_args.go new file mode 100644 index 0000000000..eb228b6267 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/module_args.go @@ -0,0 +1,33 @@ +package types + +type ArgsModuleMethod struct { + Str string `json:"str"` + OptStr *string `json:"optStr"` + En CustomEnum `json:"en"` + OptEnum *CustomEnum `json:"optEnum"` + EnumArray []CustomEnum `json:"enumArray"` + OptEnumArray []*CustomEnum `json:"optEnumArray"` + M_map map[string]int32 `json:"map"` + MapOfArr map[string][]int32 `json:"mapOfArr"` + MapOfMap map[string]map[string]int32 `json:"mapOfMap"` + MapOfObj map[string]AnotherType `json:"mapOfObj"` + MapOfArrOfObj map[string][]AnotherType `json:"mapOfArrOfObj"` +} + +type ArgsObjectMethod struct { + Object AnotherType `json:"object"` + OptObject *AnotherType `json:"optObject"` + ObjectArray []AnotherType `json:"objectArray"` + OptObjectArray []*AnotherType `json:"optObjectArray"` +} + +type ArgsOptionalEnvMethod struct { + Object AnotherType `json:"object"` + OptObject *AnotherType `json:"optObject"` + ObjectArray []AnotherType `json:"objectArray"` + OptObjectArray []*AnotherType `json:"optObjectArray"` +} + +type ArgsIf struct { + M_if Else `json:"if"` +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_another_type.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_another_type.go new file mode 100644 index 0000000000..92d48c4722 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_another_type.go @@ -0,0 +1,27 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +type AnotherType struct { + Prop *string `json:"prop"` + Circular *CustomType `json:"circular"` + M_const *string `json:"const"` +} + +func AnotherTypeToBuffer(value *AnotherType) []byte { + return serializeAnotherType(value) +} + +func AnotherTypeFromBuffer(data []byte) *AnotherType { + return deserializeAnotherType(data) +} + +func AnotherTypeWrite(writer msgpack.Write, value *AnotherType) { + writeAnotherType(writer, value) +} + +func AnotherTypeRead(reader msgpack.Read) *AnotherType { + return readAnotherType(reader) +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_another_type_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_another_type_serialization.go new file mode 100644 index 0000000000..32c1a99aad --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_another_type_serialization.go @@ -0,0 +1,93 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +func serializeAnotherType(value *AnotherType) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: AnotherType") + encoder := msgpack.NewWriteEncoder(ctx) + writeAnotherType(encoder, value) + return encoder.Buffer() +} + +func writeAnotherType(writer msgpack.Write, value *AnotherType) { + writer.WriteMapLength(3) + writer.Context().Push("prop", "*string", "writing property") + writer.WriteString("prop") + { + v := value.Prop + if v == nil { + writer.WriteNil() + } else { + writer.WriteString(*v) + } + } + writer.Context().Pop() + writer.Context().Push("circular", "*CustomType", "writing property") + writer.WriteString("circular") + { + v := value.Circular + CustomTypeWrite(writer, v) + } + writer.Context().Pop() + writer.Context().Push("const", "*string", "writing property") + writer.WriteString("const") + { + v := value.M_const + if v == nil { + writer.WriteNil() + } else { + writer.WriteString(*v) + } + } + writer.Context().Pop() +} + +func deserializeAnotherType(data []byte) *AnotherType { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: AnotherType") + reader := msgpack.NewReadDecoder(ctx, data) + return readAnotherType(reader) +} + +func readAnotherType(reader msgpack.Read) *AnotherType { + var ( + _prop *string + _circular *CustomType + _const *string + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "prop": + reader.Context().Push(field, "*string", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadString() + _prop = &v + } + reader.Context().Pop() + case "circular": + reader.Context().Push(field, "*CustomType", "type found, reading property") + if v := CustomTypeRead(reader); v != nil { + _circular = v + } + reader.Context().Pop() + case "const": + reader.Context().Push(field, "*string", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadString() + _const = &v + } + reader.Context().Pop() + } + reader.Context().Pop() + } + + return &AnotherType{ + Prop: _prop, + Circular: _circular, + M_const: _const, + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_map_value.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_map_value.go new file mode 100644 index 0000000000..49729b0e00 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_map_value.go @@ -0,0 +1,25 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +type CustomMapValue struct { + Foo string `json:"foo"` +} + +func CustomMapValueToBuffer(value *CustomMapValue) []byte { + return serializeCustomMapValue(value) +} + +func CustomMapValueFromBuffer(data []byte) *CustomMapValue { + return deserializeCustomMapValue(data) +} + +func CustomMapValueWrite(writer msgpack.Write, value *CustomMapValue) { + writeCustomMapValue(writer, value) +} + +func CustomMapValueRead(reader msgpack.Read) *CustomMapValue { + return readCustomMapValue(reader) +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_map_value_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_map_value_serialization.go new file mode 100644 index 0000000000..66e8cd2346 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_map_value_serialization.go @@ -0,0 +1,56 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +func serializeCustomMapValue(value *CustomMapValue) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: CustomMapValue") + encoder := msgpack.NewWriteEncoder(ctx) + writeCustomMapValue(encoder, value) + return encoder.Buffer() +} + +func writeCustomMapValue(writer msgpack.Write, value *CustomMapValue) { + writer.WriteMapLength(1) + writer.Context().Push("foo", "string", "writing property") + writer.WriteString("foo") + { + v := value.Foo + writer.WriteString(v) + } + writer.Context().Pop() +} + +func deserializeCustomMapValue(data []byte) *CustomMapValue { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: CustomMapValue") + reader := msgpack.NewReadDecoder(ctx, data) + return readCustomMapValue(reader) +} + +func readCustomMapValue(reader msgpack.Read) *CustomMapValue { + var ( + _foo string + _fooSet bool + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "foo": + reader.Context().Push(field, "string", "type found, reading property") + _foo = reader.ReadString() + _fooSet = true + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_fooSet { + panic(reader.Context().PrintWithContext("Missing required property: 'foo: String'")) + } + return &CustomMapValue{ + Foo: _foo, + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_type.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_type.go new file mode 100644 index 0000000000..6c97ef1ba9 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_type.go @@ -0,0 +1,68 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" + "github.com/polywrap/go-wrap/msgpack/big" + "github.com/valyala/fastjson" +) + +type CustomType struct { + Str string `json:"str"` + OptStr *string `json:"optStr"` + U uint32 `json:"u"` + OptU *uint32 `json:"optU"` + M_u8 uint8 `json:"u8"` + M_u16 uint16 `json:"u16"` + M_u32 uint32 `json:"u32"` + I int32 `json:"i"` + M_i8 int8 `json:"i8"` + M_i16 int16 `json:"i16"` + M_i32 int32 `json:"i32"` + Bigint *big.Int `json:"bigint"` + OptBigint *big.Int `json:"optBigint"` + Bignumber *big.Int `json:"bignumber"` + OptBignumber *big.Int `json:"optBignumber"` + Json *fastjson.Value `json:"json"` + OptJson *fastjson.Value `json:"optJson"` + Bytes []byte `json:"bytes"` + OptBytes []byte `json:"optBytes"` + M_boolean bool `json:"boolean"` + OptBoolean *bool `json:"optBoolean"` + U_array []uint32 `json:"u_array"` + UOpt_array []uint32 `json:"uOpt_array"` + _opt_uOptArray []*uint32 `json:"_opt_uOptArray"` + OptStrOptArray []*string `json:"optStrOptArray"` + UArrayArray [][]uint32 `json:"uArrayArray"` + UOptArrayOptArray [][]*uint32 `json:"uOptArrayOptArray"` + UArrayOptArrayArray [][][]uint32 `json:"uArrayOptArrayArray"` + CrazyArray [][][][]uint32 `json:"crazyArray"` + Object AnotherType `json:"object"` + OptObject *AnotherType `json:"optObject"` + ObjectArray []AnotherType `json:"objectArray"` + OptObjectArray []*AnotherType `json:"optObjectArray"` + En CustomEnum `json:"en"` + OptEnum *CustomEnum `json:"optEnum"` + EnumArray []CustomEnum `json:"enumArray"` + OptEnumArray []*CustomEnum `json:"optEnumArray"` + M_map map[string]int32 `json:"map"` + MapOfArr map[string][]int32 `json:"mapOfArr"` + MapOfObj map[string]AnotherType `json:"mapOfObj"` + MapOfArrOfObj map[string][]AnotherType `json:"mapOfArrOfObj"` + MapCustomValue map[string]*CustomMapValue `json:"mapCustomValue"` +} + +func CustomTypeToBuffer(value *CustomType) []byte { + return serializeCustomType(value) +} + +func CustomTypeFromBuffer(data []byte) *CustomType { + return deserializeCustomType(data) +} + +func CustomTypeWrite(writer msgpack.Write, value *CustomType) { + writeCustomType(writer, value) +} + +func CustomTypeRead(reader msgpack.Read) *CustomType { + return readCustomType(reader) +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_type_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_type_serialization.go new file mode 100644 index 0000000000..87941c77a2 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_custom_type_serialization.go @@ -0,0 +1,1270 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" + "github.com/polywrap/go-wrap/msgpack/big" + "github.com/valyala/fastjson" +) + +func serializeCustomType(value *CustomType) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: CustomType") + encoder := msgpack.NewWriteEncoder(ctx) + writeCustomType(encoder, value) + return encoder.Buffer() +} + +func writeCustomType(writer msgpack.Write, value *CustomType) { + writer.WriteMapLength(42) + writer.Context().Push("str", "string", "writing property") + writer.WriteString("str") + { + v := value.Str + writer.WriteString(v) + } + writer.Context().Pop() + writer.Context().Push("optStr", "*string", "writing property") + writer.WriteString("optStr") + { + v := value.OptStr + if v == nil { + writer.WriteNil() + } else { + writer.WriteString(*v) + } + } + writer.Context().Pop() + writer.Context().Push("u", "uint32", "writing property") + writer.WriteString("u") + { + v := value.U + writer.WriteU32(v) + } + writer.Context().Pop() + writer.Context().Push("optU", "*uint32", "writing property") + writer.WriteString("optU") + { + v := value.OptU + if v == nil { + writer.WriteNil() + } else { + writer.WriteU32(*v) + } + } + writer.Context().Pop() + writer.Context().Push("u8", "uint8", "writing property") + writer.WriteString("u8") + { + v := value.M_u8 + writer.WriteU8(v) + } + writer.Context().Pop() + writer.Context().Push("u16", "uint16", "writing property") + writer.WriteString("u16") + { + v := value.M_u16 + writer.WriteU16(v) + } + writer.Context().Pop() + writer.Context().Push("u32", "uint32", "writing property") + writer.WriteString("u32") + { + v := value.M_u32 + writer.WriteU32(v) + } + writer.Context().Pop() + writer.Context().Push("i", "int32", "writing property") + writer.WriteString("i") + { + v := value.I + writer.WriteI32(v) + } + writer.Context().Pop() + writer.Context().Push("i8", "int8", "writing property") + writer.WriteString("i8") + { + v := value.M_i8 + writer.WriteI8(v) + } + writer.Context().Pop() + writer.Context().Push("i16", "int16", "writing property") + writer.WriteString("i16") + { + v := value.M_i16 + writer.WriteI16(v) + } + writer.Context().Pop() + writer.Context().Push("i32", "int32", "writing property") + writer.WriteString("i32") + { + v := value.M_i32 + writer.WriteI32(v) + } + writer.Context().Pop() + writer.Context().Push("bigint", "*big.Int", "writing property") + writer.WriteString("bigint") + { + v := value.Bigint + writer.WriteBigInt(v) + } + writer.Context().Pop() + writer.Context().Push("optBigint", "*big.Int", "writing property") + writer.WriteString("optBigint") + { + v := value.OptBigint + if v == nil { + writer.WriteNil() + } else { + writer.WriteBigInt(v) + } + } + writer.Context().Pop() + writer.Context().Push("bignumber", "*big.Int", "writing property") + writer.WriteString("bignumber") + { + v := value.Bignumber + writer.WriteBigInt(v) + } + writer.Context().Pop() + writer.Context().Push("optBignumber", "*big.Int", "writing property") + writer.WriteString("optBignumber") + { + v := value.OptBignumber + if v == nil { + writer.WriteNil() + } else { + writer.WriteBigInt(v) + } + } + writer.Context().Pop() + writer.Context().Push("json", "*fastjson.Value", "writing property") + writer.WriteString("json") + { + v := value.Json + writer.WriteJson(v) + } + writer.Context().Pop() + writer.Context().Push("optJson", "*fastjson.Value", "writing property") + writer.WriteString("optJson") + { + v := value.OptJson + if v == nil { + writer.WriteNil() + } else { + writer.WriteJson(v) + } + } + writer.Context().Pop() + writer.Context().Push("bytes", "[]byte", "writing property") + writer.WriteString("bytes") + { + v := value.Bytes + writer.WriteBytes(v) + } + writer.Context().Pop() + writer.Context().Push("optBytes", "[]byte", "writing property") + writer.WriteString("optBytes") + { + v := value.OptBytes + if v == nil { + writer.WriteNil() + } else { + writer.WriteBytes(v) + } + } + writer.Context().Pop() + writer.Context().Push("boolean", "bool", "writing property") + writer.WriteString("boolean") + { + v := value.M_boolean + writer.WriteBool(v) + } + writer.Context().Pop() + writer.Context().Push("optBoolean", "*bool", "writing property") + writer.WriteString("optBoolean") + { + v := value.OptBoolean + if v == nil { + writer.WriteNil() + } else { + writer.WriteBool(*v) + } + } + writer.Context().Pop() + writer.Context().Push("u_array", "[]uint32", "writing property") + writer.WriteString("u_array") + if value.U_array == nil { + writer.WriteNil() + } else if len(value.U_array) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.U_array))) + for i0 := range value.U_array { + { + v := value.U_array[i0] + writer.WriteU32(v) + } + } + } + writer.Context().Pop() + writer.Context().Push("uOpt_array", "[]uint32", "writing property") + writer.WriteString("uOpt_array") + if value.UOpt_array == nil { + writer.WriteNil() + } else if len(value.UOpt_array) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UOpt_array))) + for i0 := range value.UOpt_array { + { + v := value.UOpt_array[i0] + writer.WriteU32(v) + } + } + } + writer.Context().Pop() + writer.Context().Push("_opt_uOptArray", "[]*uint32", "writing property") + writer.WriteString("_opt_uOptArray") + if value._opt_uOptArray == nil { + writer.WriteNil() + } else if len(value._opt_uOptArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value._opt_uOptArray))) + for i0 := range value._opt_uOptArray { + { + v := value._opt_uOptArray[i0] + if v == nil { + writer.WriteNil() + } else { + writer.WriteU32(*v) + } + } + } + } + writer.Context().Pop() + writer.Context().Push("optStrOptArray", "[]*string", "writing property") + writer.WriteString("optStrOptArray") + if value.OptStrOptArray == nil { + writer.WriteNil() + } else if len(value.OptStrOptArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.OptStrOptArray))) + for i0 := range value.OptStrOptArray { + { + v := value.OptStrOptArray[i0] + if v == nil { + writer.WriteNil() + } else { + writer.WriteString(*v) + } + } + } + } + writer.Context().Pop() + writer.Context().Push("uArrayArray", "[][]uint32", "writing property") + writer.WriteString("uArrayArray") + if value.UArrayArray == nil { + writer.WriteNil() + } else if len(value.UArrayArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UArrayArray))) + for i0 := range value.UArrayArray { + if value.UArrayArray[i0] == nil { + writer.WriteNil() + } else if len(value.UArrayArray[i0]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UArrayArray[i0]))) + for i1 := range value.UArrayArray[i0] { + { + v := value.UArrayArray[i0][i1] + writer.WriteU32(v) + } + } + } + } + } + writer.Context().Pop() + writer.Context().Push("uOptArrayOptArray", "[][]*uint32", "writing property") + writer.WriteString("uOptArrayOptArray") + if value.UOptArrayOptArray == nil { + writer.WriteNil() + } else if len(value.UOptArrayOptArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UOptArrayOptArray))) + for i0 := range value.UOptArrayOptArray { + if value.UOptArrayOptArray[i0] == nil { + writer.WriteNil() + } else if len(value.UOptArrayOptArray[i0]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UOptArrayOptArray[i0]))) + for i1 := range value.UOptArrayOptArray[i0] { + { + v := value.UOptArrayOptArray[i0][i1] + if v == nil { + writer.WriteNil() + } else { + writer.WriteU32(*v) + } + } + } + } + } + } + writer.Context().Pop() + writer.Context().Push("uArrayOptArrayArray", "[][][]uint32", "writing property") + writer.WriteString("uArrayOptArrayArray") + if value.UArrayOptArrayArray == nil { + writer.WriteNil() + } else if len(value.UArrayOptArrayArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UArrayOptArrayArray))) + for i0 := range value.UArrayOptArrayArray { + if value.UArrayOptArrayArray[i0] == nil { + writer.WriteNil() + } else if len(value.UArrayOptArrayArray[i0]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UArrayOptArrayArray[i0]))) + for i1 := range value.UArrayOptArrayArray[i0] { + if value.UArrayOptArrayArray[i0][i1] == nil { + writer.WriteNil() + } else if len(value.UArrayOptArrayArray[i0][i1]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.UArrayOptArrayArray[i0][i1]))) + for i2 := range value.UArrayOptArrayArray[i0][i1] { + { + v := value.UArrayOptArrayArray[i0][i1][i2] + writer.WriteU32(v) + } + } + } + } + } + } + } + writer.Context().Pop() + writer.Context().Push("crazyArray", "[][][][]uint32", "writing property") + writer.WriteString("crazyArray") + if value.CrazyArray == nil { + writer.WriteNil() + } else if len(value.CrazyArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.CrazyArray))) + for i0 := range value.CrazyArray { + if value.CrazyArray[i0] == nil { + writer.WriteNil() + } else if len(value.CrazyArray[i0]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.CrazyArray[i0]))) + for i1 := range value.CrazyArray[i0] { + if value.CrazyArray[i0][i1] == nil { + writer.WriteNil() + } else if len(value.CrazyArray[i0][i1]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.CrazyArray[i0][i1]))) + for i2 := range value.CrazyArray[i0][i1] { + if value.CrazyArray[i0][i1][i2] == nil { + writer.WriteNil() + } else if len(value.CrazyArray[i0][i1][i2]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.CrazyArray[i0][i1][i2]))) + for i3 := range value.CrazyArray[i0][i1][i2] { + { + v := value.CrazyArray[i0][i1][i2][i3] + writer.WriteU32(v) + } + } + } + } + } + } + } + } + } + writer.Context().Pop() + writer.Context().Push("object", "AnotherType", "writing property") + writer.WriteString("object") + { + v := value.Object + AnotherTypeWrite(writer, &v) + } + writer.Context().Pop() + writer.Context().Push("optObject", "*AnotherType", "writing property") + writer.WriteString("optObject") + { + v := value.OptObject + AnotherTypeWrite(writer, v) + } + writer.Context().Pop() + writer.Context().Push("objectArray", "[]AnotherType", "writing property") + writer.WriteString("objectArray") + if value.ObjectArray == nil { + writer.WriteNil() + } else if len(value.ObjectArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.ObjectArray))) + for i0 := range value.ObjectArray { + { + v := value.ObjectArray[i0] + AnotherTypeWrite(writer, &v) + } + } + } + writer.Context().Pop() + writer.Context().Push("optObjectArray", "[]*AnotherType", "writing property") + writer.WriteString("optObjectArray") + if value.OptObjectArray == nil { + writer.WriteNil() + } else if len(value.OptObjectArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.OptObjectArray))) + for i0 := range value.OptObjectArray { + { + v := value.OptObjectArray[i0] + AnotherTypeWrite(writer, v) + } + } + } + writer.Context().Pop() + writer.Context().Push("en", "CustomEnum", "writing property") + writer.WriteString("en") + { + v := value.En + writer.WriteI32(int32(v)) + } + writer.Context().Pop() + writer.Context().Push("optEnum", "*CustomEnum", "writing property") + writer.WriteString("optEnum") + { + v := value.OptEnum + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + } + writer.Context().Pop() + writer.Context().Push("enumArray", "[]CustomEnum", "writing property") + writer.WriteString("enumArray") + if value.EnumArray == nil { + writer.WriteNil() + } else if len(value.EnumArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.EnumArray))) + for i0 := range value.EnumArray { + { + v := value.EnumArray[i0] + writer.WriteI32(int32(v)) + } + } + } + writer.Context().Pop() + writer.Context().Push("optEnumArray", "[]*CustomEnum", "writing property") + writer.WriteString("optEnumArray") + if value.OptEnumArray == nil { + writer.WriteNil() + } else if len(value.OptEnumArray) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.OptEnumArray))) + for i0 := range value.OptEnumArray { + { + v := value.OptEnumArray[i0] + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(int32(*v)) + } + } + } + } + writer.Context().Pop() + writer.Context().Push("map", "map[string]int32", "writing property") + writer.WriteString("map") + if value.M_map == nil { + writer.WriteNil() + } else if len(value.M_map) == 0 { + writer.WriteNil() + } else { + for i0 := range value.M_map { + writer.WriteString(i0) + { + v := value.M_map[i0] + writer.WriteI32(v) + } + } + } + writer.Context().Pop() + writer.Context().Push("mapOfArr", "map[string][]int32", "writing property") + writer.WriteString("mapOfArr") + if value.MapOfArr == nil { + writer.WriteNil() + } else if len(value.MapOfArr) == 0 { + writer.WriteNil() + } else { + for i0 := range value.MapOfArr { + writer.WriteString(i0) + if value.MapOfArr[i0] == nil { + writer.WriteNil() + } else if len(value.MapOfArr[i0]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.MapOfArr[i0]))) + for i1 := range value.MapOfArr[i0] { + { + v := value.MapOfArr[i0][i1] + writer.WriteI32(v) + } + } + } + } + } + writer.Context().Pop() + writer.Context().Push("mapOfObj", "map[string]AnotherType", "writing property") + writer.WriteString("mapOfObj") + if value.MapOfObj == nil { + writer.WriteNil() + } else if len(value.MapOfObj) == 0 { + writer.WriteNil() + } else { + for i0 := range value.MapOfObj { + writer.WriteString(i0) + { + v := value.MapOfObj[i0] + AnotherTypeWrite(writer, &v) + } + } + } + writer.Context().Pop() + writer.Context().Push("mapOfArrOfObj", "map[string][]AnotherType", "writing property") + writer.WriteString("mapOfArrOfObj") + if value.MapOfArrOfObj == nil { + writer.WriteNil() + } else if len(value.MapOfArrOfObj) == 0 { + writer.WriteNil() + } else { + for i0 := range value.MapOfArrOfObj { + writer.WriteString(i0) + if value.MapOfArrOfObj[i0] == nil { + writer.WriteNil() + } else if len(value.MapOfArrOfObj[i0]) == 0 { + writer.WriteNil() + } else { + writer.WriteArrayLength(uint32(len(value.MapOfArrOfObj[i0]))) + for i1 := range value.MapOfArrOfObj[i0] { + { + v := value.MapOfArrOfObj[i0][i1] + AnotherTypeWrite(writer, &v) + } + } + } + } + } + writer.Context().Pop() + writer.Context().Push("mapCustomValue", "map[string]*CustomMapValue", "writing property") + writer.WriteString("mapCustomValue") + if value.MapCustomValue == nil { + writer.WriteNil() + } else if len(value.MapCustomValue) == 0 { + writer.WriteNil() + } else { + for i0 := range value.MapCustomValue { + writer.WriteString(i0) + { + v := value.MapCustomValue[i0] + CustomMapValueWrite(writer, v) + } + } + } + writer.Context().Pop() +} + +func deserializeCustomType(data []byte) *CustomType { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: CustomType") + reader := msgpack.NewReadDecoder(ctx, data) + return readCustomType(reader) +} + +func readCustomType(reader msgpack.Read) *CustomType { + var ( + _str string + _strSet bool + _optStr *string + _u uint32 + _uSet bool + _optU *uint32 + _u8 uint8 + _u8Set bool + _u16 uint16 + _u16Set bool + _u32 uint32 + _u32Set bool + _i int32 + _iSet bool + _i8 int8 + _i8Set bool + _i16 int16 + _i16Set bool + _i32 int32 + _i32Set bool + _bigint *big.Int + _bigintSet bool + _optBigint *big.Int + _bignumber *big.Int + _bignumberSet bool + _optBignumber *big.Int + _json *fastjson.Value + _jsonSet bool + _optJson *fastjson.Value + _bytes []byte + _bytesSet bool + _optBytes []byte + _boolean bool + _booleanSet bool + _optBoolean *bool + _u_array []uint32 + _u_arraySet bool + _uOpt_array []uint32 + __opt_uOptArray []*uint32 + _optStrOptArray []*string + _uArrayArray [][]uint32 + _uArrayArraySet bool + _uOptArrayOptArray [][]*uint32 + _uOptArrayOptArraySet bool + _uArrayOptArrayArray [][][]uint32 + _uArrayOptArrayArraySet bool + _crazyArray [][][][]uint32 + _object AnotherType + _objectSet bool + _optObject *AnotherType + _objectArray []AnotherType + _objectArraySet bool + _optObjectArray []*AnotherType + _en CustomEnum + _enSet bool + _optEnum *CustomEnum + _enumArray []CustomEnum + _enumArraySet bool + _optEnumArray []*CustomEnum + _map map[string]int32 + _mapSet bool + _mapOfArr map[string][]int32 + _mapOfArrSet bool + _mapOfObj map[string]AnotherType + _mapOfObjSet bool + _mapOfArrOfObj map[string][]AnotherType + _mapOfArrOfObjSet bool + _mapCustomValue map[string]*CustomMapValue + _mapCustomValueSet bool + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "str": + reader.Context().Push(field, "string", "type found, reading property") + _str = reader.ReadString() + _strSet = true + reader.Context().Pop() + case "optStr": + reader.Context().Push(field, "*string", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadString() + _optStr = &v + } + reader.Context().Pop() + case "u": + reader.Context().Push(field, "uint32", "type found, reading property") + _u = reader.ReadU32() + _uSet = true + reader.Context().Pop() + case "optU": + reader.Context().Push(field, "*uint32", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadU32() + _optU = &v + } + reader.Context().Pop() + case "u8": + reader.Context().Push(field, "uint8", "type found, reading property") + _u8 = reader.ReadU8() + _u8Set = true + reader.Context().Pop() + case "u16": + reader.Context().Push(field, "uint16", "type found, reading property") + _u16 = reader.ReadU16() + _u16Set = true + reader.Context().Pop() + case "u32": + reader.Context().Push(field, "uint32", "type found, reading property") + _u32 = reader.ReadU32() + _u32Set = true + reader.Context().Pop() + case "i": + reader.Context().Push(field, "int32", "type found, reading property") + _i = reader.ReadI32() + _iSet = true + reader.Context().Pop() + case "i8": + reader.Context().Push(field, "int8", "type found, reading property") + _i8 = reader.ReadI8() + _i8Set = true + reader.Context().Pop() + case "i16": + reader.Context().Push(field, "int16", "type found, reading property") + _i16 = reader.ReadI16() + _i16Set = true + reader.Context().Pop() + case "i32": + reader.Context().Push(field, "int32", "type found, reading property") + _i32 = reader.ReadI32() + _i32Set = true + reader.Context().Pop() + case "bigint": + reader.Context().Push(field, "*big.Int", "type found, reading property") + _bigint = reader.ReadBigInt() + _bigintSet = true + reader.Context().Pop() + case "optBigint": + reader.Context().Push(field, "*big.Int", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadBigInt() + _optBigint = v + } + reader.Context().Pop() + case "bignumber": + reader.Context().Push(field, "*big.Int", "type found, reading property") + _bignumber = reader.ReadBigInt() + _bignumberSet = true + reader.Context().Pop() + case "optBignumber": + reader.Context().Push(field, "*big.Int", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadBigInt() + _optBignumber = v + } + reader.Context().Pop() + case "json": + reader.Context().Push(field, "*fastjson.Value", "type found, reading property") + _json = reader.ReadJson() + _jsonSet = true + reader.Context().Pop() + case "optJson": + reader.Context().Push(field, "*fastjson.Value", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadJson() + _optJson = v + } + reader.Context().Pop() + case "bytes": + reader.Context().Push(field, "[]byte", "type found, reading property") + _bytes = reader.ReadBytes() + _bytesSet = true + reader.Context().Pop() + case "optBytes": + reader.Context().Push(field, "[]byte", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadBytes() + _optBytes = v + } + reader.Context().Pop() + case "boolean": + reader.Context().Push(field, "bool", "type found, reading property") + _boolean = reader.ReadBool() + _booleanSet = true + reader.Context().Pop() + case "optBoolean": + reader.Context().Push(field, "*bool", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadBool() + _optBoolean = &v + } + reader.Context().Pop() + case "u_array": + reader.Context().Push(field, "[]uint32", "type found, reading property") + if reader.IsNil() { + _u_array = nil + } else { + ln0 := reader.ReadArrayLength() + _u_array = make([]uint32, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + _u_array[i0] = reader.ReadU32() + } + } + _u_arraySet = true + reader.Context().Pop() + case "uOpt_array": + reader.Context().Push(field, "[]uint32", "type found, reading property") + if reader.IsNil() { + _uOpt_array = nil + } else { + ln0 := reader.ReadArrayLength() + _uOpt_array = make([]uint32, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + _uOpt_array[i0] = reader.ReadU32() + } + } + reader.Context().Pop() + case "_opt_uOptArray": + reader.Context().Push(field, "[]*uint32", "type found, reading property") + if reader.IsNil() { + __opt_uOptArray = nil + } else { + ln0 := reader.ReadArrayLength() + __opt_uOptArray = make([]*uint32, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if !reader.IsNil() { + v := reader.ReadU32() + __opt_uOptArray[i0] = &v + } + } + } + reader.Context().Pop() + case "optStrOptArray": + reader.Context().Push(field, "[]*string", "type found, reading property") + if reader.IsNil() { + _optStrOptArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optStrOptArray = make([]*string, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if !reader.IsNil() { + v := reader.ReadString() + _optStrOptArray[i0] = &v + } + } + } + reader.Context().Pop() + case "uArrayArray": + reader.Context().Push(field, "[][]uint32", "type found, reading property") + if reader.IsNil() { + _uArrayArray = nil + } else { + ln0 := reader.ReadArrayLength() + _uArrayArray = make([][]uint32, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if reader.IsNil() { + _uArrayArray[i0] = nil + } else { + ln1 := reader.ReadArrayLength() + _uArrayArray[i0] = make([]uint32, ln1) + for i1 := uint32(0); i1 < ln1; i1++ { + _uArrayArray[i0][i1] = reader.ReadU32() + } + } + } + } + _uArrayArraySet = true + reader.Context().Pop() + case "uOptArrayOptArray": + reader.Context().Push(field, "[][]*uint32", "type found, reading property") + if reader.IsNil() { + _uOptArrayOptArray = nil + } else { + ln0 := reader.ReadArrayLength() + _uOptArrayOptArray = make([][]*uint32, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if reader.IsNil() { + _uOptArrayOptArray[i0] = nil + } else { + ln1 := reader.ReadArrayLength() + _uOptArrayOptArray[i0] = make([]*uint32, ln1) + for i1 := uint32(0); i1 < ln1; i1++ { + if !reader.IsNil() { + v := reader.ReadU32() + _uOptArrayOptArray[i0][i1] = &v + } + } + } + } + } + _uOptArrayOptArraySet = true + reader.Context().Pop() + case "uArrayOptArrayArray": + reader.Context().Push(field, "[][][]uint32", "type found, reading property") + if reader.IsNil() { + _uArrayOptArrayArray = nil + } else { + ln0 := reader.ReadArrayLength() + _uArrayOptArrayArray = make([][][]uint32, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if reader.IsNil() { + _uArrayOptArrayArray[i0] = nil + } else { + ln1 := reader.ReadArrayLength() + _uArrayOptArrayArray[i0] = make([][]uint32, ln1) + for i1 := uint32(0); i1 < ln1; i1++ { + if reader.IsNil() { + _uArrayOptArrayArray[i0][i1] = nil + } else { + ln2 := reader.ReadArrayLength() + _uArrayOptArrayArray[i0][i1] = make([]uint32, ln2) + for i2 := uint32(0); i2 < ln2; i2++ { + _uArrayOptArrayArray[i0][i1][i2] = reader.ReadU32() + } + } + } + } + } + } + _uArrayOptArrayArraySet = true + reader.Context().Pop() + case "crazyArray": + reader.Context().Push(field, "[][][][]uint32", "type found, reading property") + if reader.IsNil() { + _crazyArray = nil + } else { + ln0 := reader.ReadArrayLength() + _crazyArray = make([][][][]uint32, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if reader.IsNil() { + _crazyArray[i0] = nil + } else { + ln1 := reader.ReadArrayLength() + _crazyArray[i0] = make([][][]uint32, ln1) + for i1 := uint32(0); i1 < ln1; i1++ { + if reader.IsNil() { + _crazyArray[i0][i1] = nil + } else { + ln2 := reader.ReadArrayLength() + _crazyArray[i0][i1] = make([][]uint32, ln2) + for i2 := uint32(0); i2 < ln2; i2++ { + if reader.IsNil() { + _crazyArray[i0][i1][i2] = nil + } else { + ln3 := reader.ReadArrayLength() + _crazyArray[i0][i1][i2] = make([]uint32, ln3) + for i3 := uint32(0); i3 < ln3; i3++ { + _crazyArray[i0][i1][i2][i3] = reader.ReadU32() + } + } + } + } + } + } + } + } + reader.Context().Pop() + case "object": + reader.Context().Push(field, "AnotherType", "type found, reading property") + if v := AnotherTypeRead(reader); v != nil { + _object = *v + } + _objectSet = true + reader.Context().Pop() + case "optObject": + reader.Context().Push(field, "*AnotherType", "type found, reading property") + if v := AnotherTypeRead(reader); v != nil { + _optObject = v + } + reader.Context().Pop() + case "objectArray": + reader.Context().Push(field, "[]AnotherType", "type found, reading property") + if reader.IsNil() { + _objectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _objectArray = make([]AnotherType, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := AnotherTypeRead(reader); v != nil { + _objectArray[i0] = *v + } + } + } + _objectArraySet = true + reader.Context().Pop() + case "optObjectArray": + reader.Context().Push(field, "[]*AnotherType", "type found, reading property") + if reader.IsNil() { + _optObjectArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optObjectArray = make([]*AnotherType, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if v := AnotherTypeRead(reader); v != nil { + _optObjectArray[i0] = v + } + } + } + reader.Context().Pop() + case "en": + reader.Context().Push(field, "CustomEnum", "type found, reading property") + _en = CustomEnum(reader.ReadI32()) + SanitizeCustomEnumValue(int32(_en)) + _enSet = true + reader.Context().Pop() + case "optEnum": + reader.Context().Push(field, "*CustomEnum", "type found, reading property") + if !reader.IsNil() { + v := CustomEnum(reader.ReadI32()) + SanitizeCustomEnumValue(int32(v)) + _optEnum = &v + } + reader.Context().Pop() + case "enumArray": + reader.Context().Push(field, "[]CustomEnum", "type found, reading property") + if reader.IsNil() { + _enumArray = nil + } else { + ln0 := reader.ReadArrayLength() + _enumArray = make([]CustomEnum, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + _enumArray[i0] = CustomEnum(reader.ReadI32()) + SanitizeCustomEnumValue(int32(_enumArray[i0])) + } + } + _enumArraySet = true + reader.Context().Pop() + case "optEnumArray": + reader.Context().Push(field, "[]*CustomEnum", "type found, reading property") + if reader.IsNil() { + _optEnumArray = nil + } else { + ln0 := reader.ReadArrayLength() + _optEnumArray = make([]*CustomEnum, ln0) + for i0 := uint32(0); i0 < ln0; i0++ { + if !reader.IsNil() { + v := CustomEnum(reader.ReadI32()) + SanitizeCustomEnumValue(int32(v)) + _optEnumArray[i0] = &v + } + } + } + reader.Context().Pop() + case "map": + reader.Context().Push(field, "map[string]int32", "type found, reading property") + if reader.IsNil() { + _map = nil + } else { + ln0 := reader.ReadMapLength() + _map = make(map[string]int32) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + _map[i0] = reader.ReadI32() + } + } + _mapSet = true + reader.Context().Pop() + case "mapOfArr": + reader.Context().Push(field, "map[string][]int32", "type found, reading property") + if reader.IsNil() { + _mapOfArr = nil + } else { + ln0 := reader.ReadMapLength() + _mapOfArr = make(map[string][]int32) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + if reader.IsNil() { + _mapOfArr[i0] = nil + } else { + ln1 := reader.ReadArrayLength() + _mapOfArr[i0] = make([]int32, ln1) + for i1 := uint32(0); i1 < ln1; i1++ { + _mapOfArr[i0][i1] = reader.ReadI32() + } + } + } + } + _mapOfArrSet = true + reader.Context().Pop() + case "mapOfObj": + reader.Context().Push(field, "map[string]AnotherType", "type found, reading property") + if reader.IsNil() { + _mapOfObj = nil + } else { + ln0 := reader.ReadMapLength() + _mapOfObj = make(map[string]AnotherType) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + if v := AnotherTypeRead(reader); v != nil { + _mapOfObj[i0] = *v + } + } + } + _mapOfObjSet = true + reader.Context().Pop() + case "mapOfArrOfObj": + reader.Context().Push(field, "map[string][]AnotherType", "type found, reading property") + if reader.IsNil() { + _mapOfArrOfObj = nil + } else { + ln0 := reader.ReadMapLength() + _mapOfArrOfObj = make(map[string][]AnotherType) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + if reader.IsNil() { + _mapOfArrOfObj[i0] = nil + } else { + ln1 := reader.ReadArrayLength() + _mapOfArrOfObj[i0] = make([]AnotherType, ln1) + for i1 := uint32(0); i1 < ln1; i1++ { + if v := AnotherTypeRead(reader); v != nil { + _mapOfArrOfObj[i0][i1] = *v + } + } + } + } + } + _mapOfArrOfObjSet = true + reader.Context().Pop() + case "mapCustomValue": + reader.Context().Push(field, "map[string]*CustomMapValue", "type found, reading property") + if reader.IsNil() { + _mapCustomValue = nil + } else { + ln0 := reader.ReadMapLength() + _mapCustomValue = make(map[string]*CustomMapValue) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + if v := CustomMapValueRead(reader); v != nil { + _mapCustomValue[i0] = v + } + } + } + _mapCustomValueSet = true + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_strSet { + panic(reader.Context().PrintWithContext("Missing required property: 'str: String'")) + } + if !_uSet { + panic(reader.Context().PrintWithContext("Missing required property: 'u: UInt'")) + } + if !_u8Set { + panic(reader.Context().PrintWithContext("Missing required property: 'u8: UInt8'")) + } + if !_u16Set { + panic(reader.Context().PrintWithContext("Missing required property: 'u16: UInt16'")) + } + if !_u32Set { + panic(reader.Context().PrintWithContext("Missing required property: 'u32: UInt32'")) + } + if !_iSet { + panic(reader.Context().PrintWithContext("Missing required property: 'i: Int'")) + } + if !_i8Set { + panic(reader.Context().PrintWithContext("Missing required property: 'i8: Int8'")) + } + if !_i16Set { + panic(reader.Context().PrintWithContext("Missing required property: 'i16: Int16'")) + } + if !_i32Set { + panic(reader.Context().PrintWithContext("Missing required property: 'i32: Int32'")) + } + if !_bigintSet { + panic(reader.Context().PrintWithContext("Missing required property: 'bigint: BigInt'")) + } + if !_bignumberSet { + panic(reader.Context().PrintWithContext("Missing required property: 'bignumber: BigNumber'")) + } + if !_jsonSet { + panic(reader.Context().PrintWithContext("Missing required property: 'json: JSON'")) + } + if !_bytesSet { + panic(reader.Context().PrintWithContext("Missing required property: 'bytes: Bytes'")) + } + if !_booleanSet { + panic(reader.Context().PrintWithContext("Missing required property: 'boolean: Boolean'")) + } + if !_u_arraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'u_array: [UInt]'")) + } + if !_uArrayArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'uArrayArray: [[UInt]]'")) + } + if !_uOptArrayOptArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'uOptArrayOptArray: [[UInt32]]'")) + } + if !_uArrayOptArrayArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'uArrayOptArrayArray: [[[UInt32]]]'")) + } + if !_objectSet { + panic(reader.Context().PrintWithContext("Missing required property: 'object: AnotherType'")) + } + if !_objectArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'objectArray: [AnotherType]'")) + } + if !_enSet { + panic(reader.Context().PrintWithContext("Missing required property: 'en: CustomEnum'")) + } + if !_enumArraySet { + panic(reader.Context().PrintWithContext("Missing required property: 'enumArray: [CustomEnum]'")) + } + if !_mapSet { + panic(reader.Context().PrintWithContext("Missing required property: 'map: Map'")) + } + if !_mapOfArrSet { + panic(reader.Context().PrintWithContext("Missing required property: 'mapOfArr: Map'")) + } + if !_mapOfObjSet { + panic(reader.Context().PrintWithContext("Missing required property: 'mapOfObj: Map'")) + } + if !_mapOfArrOfObjSet { + panic(reader.Context().PrintWithContext("Missing required property: 'mapOfArrOfObj: Map'")) + } + if !_mapCustomValueSet { + panic(reader.Context().PrintWithContext("Missing required property: 'mapCustomValue: Map'")) + } + return &CustomType{ + Str: _str, + OptStr: _optStr, + U: _u, + OptU: _optU, + M_u8: _u8, + M_u16: _u16, + M_u32: _u32, + I: _i, + M_i8: _i8, + M_i16: _i16, + M_i32: _i32, + Bigint: _bigint, + OptBigint: _optBigint, + Bignumber: _bignumber, + OptBignumber: _optBignumber, + Json: _json, + OptJson: _optJson, + Bytes: _bytes, + OptBytes: _optBytes, + M_boolean: _boolean, + OptBoolean: _optBoolean, + U_array: _u_array, + UOpt_array: _uOpt_array, + _opt_uOptArray: __opt_uOptArray, + OptStrOptArray: _optStrOptArray, + UArrayArray: _uArrayArray, + UOptArrayOptArray: _uOptArrayOptArray, + UArrayOptArrayArray: _uArrayOptArrayArray, + CrazyArray: _crazyArray, + Object: _object, + OptObject: _optObject, + ObjectArray: _objectArray, + OptObjectArray: _optObjectArray, + En: _en, + OptEnum: _optEnum, + EnumArray: _enumArray, + OptEnumArray: _optEnumArray, + M_map: _map, + MapOfArr: _mapOfArr, + MapOfObj: _mapOfObj, + MapOfArrOfObj: _mapOfArrOfObj, + MapCustomValue: _mapCustomValue, + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_env.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_env.go new file mode 100644 index 0000000000..14f90adbc6 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_env.go @@ -0,0 +1,27 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +type Env struct { + Prop string `json:"prop"` + OptProp *string `json:"optProp"` + OptMap map[string]*int32 `json:"optMap"` +} + +func EnvToBuffer(value *Env) []byte { + return serializeEnv(value) +} + +func EnvFromBuffer(data []byte) *Env { + return deserializeEnv(data) +} + +func EnvWrite(writer msgpack.Write, value *Env) { + writeEnv(writer, value) +} + +func EnvRead(reader msgpack.Read) *Env { + return readEnv(reader) +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_env_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_env_serialization.go new file mode 100644 index 0000000000..393202c3f7 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/object_env_serialization.go @@ -0,0 +1,114 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +func serializeEnv(value *Env) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: Env") + encoder := msgpack.NewWriteEncoder(ctx) + writeEnv(encoder, value) + return encoder.Buffer() +} + +func writeEnv(writer msgpack.Write, value *Env) { + writer.WriteMapLength(3) + writer.Context().Push("prop", "string", "writing property") + writer.WriteString("prop") + { + v := value.Prop + writer.WriteString(v) + } + writer.Context().Pop() + writer.Context().Push("optProp", "*string", "writing property") + writer.WriteString("optProp") + { + v := value.OptProp + if v == nil { + writer.WriteNil() + } else { + writer.WriteString(*v) + } + } + writer.Context().Pop() + writer.Context().Push("optMap", "map[string]*int32", "writing property") + writer.WriteString("optMap") + if value.OptMap == nil { + writer.WriteNil() + } else if len(value.OptMap) == 0 { + writer.WriteNil() + } else { + for i0 := range value.OptMap { + writer.WriteString(i0) + { + v := value.OptMap[i0] + if v == nil { + writer.WriteNil() + } else { + writer.WriteI32(*v) + } + } + } + } + writer.Context().Pop() +} + +func deserializeEnv(data []byte) *Env { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: Env") + reader := msgpack.NewReadDecoder(ctx, data) + return readEnv(reader) +} + +func readEnv(reader msgpack.Read) *Env { + var ( + _prop string + _propSet bool + _optProp *string + _optMap map[string]*int32 + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "prop": + reader.Context().Push(field, "string", "type found, reading property") + _prop = reader.ReadString() + _propSet = true + reader.Context().Pop() + case "optProp": + reader.Context().Push(field, "*string", "type found, reading property") + if !reader.IsNil() { + v := reader.ReadString() + _optProp = &v + } + reader.Context().Pop() + case "optMap": + reader.Context().Push(field, "map[string]*int32", "type found, reading property") + if reader.IsNil() { + _optMap = nil + } else { + ln0 := reader.ReadMapLength() + _optMap = make(map[string]*int32) + for j0 := uint32(0); j0 < ln0; j0++ { + i0 := reader.ReadString() + if !reader.IsNil() { + v := reader.ReadI32() + _optMap[i0] = &v + } + } + } + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_propSet { + panic(reader.Context().PrintWithContext("Missing required property: 'prop: String'")) + } + return &Env{ + Prop: _prop, + OptProp: _optProp, + OptMap: _optMap, + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/objectelse.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/objectelse.go new file mode 100644 index 0000000000..930eb8f8e3 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/objectelse.go @@ -0,0 +1,25 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +type Else struct { + M_else string `json:"else"` +} + +func ElseToBuffer(value *Else) []byte { + return serializeElse(value) +} + +func ElseFromBuffer(data []byte) *Else { + return deserializeElse(data) +} + +func ElseWrite(writer msgpack.Write, value *Else) { + writeElse(writer, value) +} + +func ElseRead(reader msgpack.Read) *Else { + return readElse(reader) +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/types/objectelse_serialization.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/objectelse_serialization.go new file mode 100644 index 0000000000..b7bf1eeba4 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/types/objectelse_serialization.go @@ -0,0 +1,56 @@ +package types + +import ( + "github.com/polywrap/go-wrap/msgpack" +) + +func serializeElse(value *Else) []byte { + ctx := msgpack.NewContext("Serializing (encoding) env-type: Else") + encoder := msgpack.NewWriteEncoder(ctx) + writeElse(encoder, value) + return encoder.Buffer() +} + +func writeElse(writer msgpack.Write, value *Else) { + writer.WriteMapLength(1) + writer.Context().Push("else", "string", "writing property") + writer.WriteString("else") + { + v := value.M_else + writer.WriteString(v) + } + writer.Context().Pop() +} + +func deserializeElse(data []byte) *Else { + ctx := msgpack.NewContext("Deserializing (decoding) env-type: Else") + reader := msgpack.NewReadDecoder(ctx, data) + return readElse(reader) +} + +func readElse(reader msgpack.Read) *Else { + var ( + _else string + _elseSet bool + ) + + for i := int32(reader.ReadMapLength()); i > 0; i-- { + field := reader.ReadString() + reader.Context().Push(field, "unknown", "searching for property type") + switch field { + case "else": + reader.Context().Push(field, "string", "type found, reading property") + _else = reader.ReadString() + _elseSet = true + reader.Context().Pop() + } + reader.Context().Pop() + } + + if !_elseSet { + panic(reader.Context().PrintWithContext("Missing required property: 'else: String'")) + } + return &Else{ + M_else: _else, + } +} diff --git a/packages/test-cases/cases/bind/sanity/output/wrap-go/wrap.go b/packages/test-cases/cases/bind/sanity/output/wrap-go/wrap.go new file mode 100644 index 0000000000..a1080fa322 --- /dev/null +++ b/packages/test-cases/cases/bind/sanity/output/wrap-go/wrap.go @@ -0,0 +1 @@ +package wrap diff --git a/packages/test-cases/cases/cli/build-cmd/plugin/005-custom-config/config.ts b/packages/test-cases/cases/cli/build-cmd/plugin/005-custom-config/config.ts index 97850e3b0d..215a5f860b 100644 --- a/packages/test-cases/cases/cli/build-cmd/plugin/005-custom-config/config.ts +++ b/packages/test-cases/cases/cli/build-cmd/plugin/005-custom-config/config.ts @@ -1,4 +1,4 @@ -import { IClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; import { PluginModule, PluginPackage } from "@polywrap/plugin-js"; import { latestWrapManifestVersion } from "@polywrap/wrap-manifest-types-js"; import { parseSchema } from "@polywrap/schema-parse"; @@ -37,6 +37,6 @@ const mockPlugin = () => { }); }; -export function configure(builder: IClientConfigBuilder): IClientConfigBuilder { - return builder.addPackage("wrap://ens/mock.eth", mockPlugin()); +export function configure(builder: ClientConfigBuilder): ClientConfigBuilder { + return builder.setPackage("wrap://ens/mock.eth", mockPlugin()); } diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/010-custom-config/config.ts b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/010-custom-config/config.ts index 78d89bef30..8c503db0c6 100644 --- a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/010-custom-config/config.ts +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/010-custom-config/config.ts @@ -1,4 +1,4 @@ -import { IClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; import { PluginModule, PluginPackage } from "@polywrap/plugin-js"; import { latestWrapManifestVersion } from "@polywrap/wrap-manifest-types-js"; @@ -119,6 +119,6 @@ const mockPlugin = () => { ); }; -export function configure(builder: IClientConfigBuilder): IClientConfigBuilder { - return builder.addPackage("wrap://ens/mock.eth", mockPlugin()); +export function configure(builder: ClientConfigBuilder): ClientConfigBuilder { + return builder.setPackage("wrap://ens/mock.eth", mockPlugin()); } diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/014-override-config/config.ts b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/014-override-config/config.ts index c6cac57534..b3bb8df976 100644 --- a/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/014-override-config/config.ts +++ b/packages/test-cases/cases/cli/build-cmd/wasm/assemblyscript/014-override-config/config.ts @@ -1,6 +1,6 @@ import { - IClientConfigBuilder, ClientConfigBuilder, + PolywrapClientConfigBuilder, } from "@polywrap/client-js"; import { PluginModule, PluginPackage } from "@polywrap/plugin-js"; import { latestWrapManifestVersion } from "@polywrap/wrap-manifest-types-js"; @@ -122,8 +122,8 @@ const mockPlugin = () => { ); }; -export function configure(_: IClientConfigBuilder): IClientConfigBuilder { - return new ClientConfigBuilder() +export function configure(_: ClientConfigBuilder): ClientConfigBuilder { + return new PolywrapClientConfigBuilder() .addDefaults() - .addPackage("wrap://ens/mock.eth", mockPlugin()); + .setPackage("wrap://ens/mock.eth", mockPlugin()); } diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/go.mod b/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/go.mod new file mode 100644 index 0000000000..5ce3eb4094 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/go.mod @@ -0,0 +1,7 @@ +module example.com/go-wrap-test + +go 1.18 + +require github.com/polywrap/go-wrap v0.0.0-20230712212127-6895977d63c2 + +require github.com/valyala/fastjson v1.6.3 // indirect diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/go.sum b/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/go.sum new file mode 100644 index 0000000000..8df2badd73 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/go.sum @@ -0,0 +1,4 @@ +github.com/polywrap/go-wrap v0.0.0-20230712212127-6895977d63c2 h1:+O3G/996rX4SMlJNFA9AIjPSyrInzOEVb7PFOT96G9A= +github.com/polywrap/go-wrap v0.0.0-20230712212127-6895977d63c2/go.mod h1:rxqhIFKUzn/M46+zjnA1RHlCzLGQn2BiLWalezhLj/k= +github.com/valyala/fastjson v1.6.3 h1:tAKFnnwmeMGPbwJ7IwxcTPCNr3uIzoIj3/Fh90ra4xc= +github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY= diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/module/module.go b/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/module/module.go new file mode 100644 index 0000000000..67c8df4810 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/module/module.go @@ -0,0 +1,7 @@ +package module + +import "example.com/go-wrap-test/module/wrap/types" + +func Method(args *types.ArgsMethod) string { + return args.Arg +} diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/polywrap.yaml b/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/polywrap.yaml new file mode 100644 index 0000000000..be21a65d27 --- /dev/null +++ b/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/polywrap.yaml @@ -0,0 +1,7 @@ +format: 0.5.0 +project: + name: ObjectTypes + type: wasm/golang +source: + schema: ./schema.graphql + module: ./go.mod diff --git a/packages/test-cases/cases/cli/docgen/001-sanity/schema.graphql b/packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/schema.graphql similarity index 100% rename from packages/test-cases/cases/cli/docgen/001-sanity/schema.graphql rename to packages/test-cases/cases/cli/build-cmd/wasm/golang/001-sanity/schema.graphql diff --git a/packages/test-cases/cases/cli/build-cmd/wasm/rust/001-sanity/Cargo.toml b/packages/test-cases/cases/cli/build-cmd/wasm/rust/001-sanity/Cargo.toml index 0604b9b1a7..0f0fc6300b 100644 --- a/packages/test-cases/cases/cli/build-cmd/wasm/rust/001-sanity/Cargo.toml +++ b/packages/test-cases/cases/cli/build-cmd/wasm/rust/001-sanity/Cargo.toml @@ -12,6 +12,7 @@ edition = "2021" [dependencies] polywrap-wasm-rs = { path = "../../../../../../../wasm/rs" } +polywrap_msgpack_serde = "~0.0.2-beta.5" serde = { version = "1.0", features = ["derive"] } [lib] diff --git a/packages/test-cases/cases/cli/codegen/app/004-custom-config/config.ts b/packages/test-cases/cases/cli/codegen/app/004-custom-config/config.ts index e1a1c1fb38..4fb529f0fe 100644 --- a/packages/test-cases/cases/cli/codegen/app/004-custom-config/config.ts +++ b/packages/test-cases/cases/cli/codegen/app/004-custom-config/config.ts @@ -1,4 +1,4 @@ -import { IClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; import { PluginModule, PluginPackage } from "@polywrap/plugin-js"; import { latestWrapManifestVersion, @@ -28,8 +28,8 @@ const mockPlugin = () => { return PluginPackage.from(new MockPlugin({ val: 0 }), mockPluginManifest); }; -export function configure(builder: IClientConfigBuilder): IClientConfigBuilder { - return builder.addPackage("wrap://ens/mock.eth", mockPlugin()); +export function configure(builder: ClientConfigBuilder): ClientConfigBuilder { + return builder.setPackage("wrap://ens/mock.eth", mockPlugin()); } export const mockPluginManifest: WrapManifest = { diff --git a/packages/test-cases/cases/cli/codegen/plugin/005-custom-config/config.ts b/packages/test-cases/cases/cli/codegen/plugin/005-custom-config/config.ts index 97850e3b0d..215a5f860b 100644 --- a/packages/test-cases/cases/cli/codegen/plugin/005-custom-config/config.ts +++ b/packages/test-cases/cases/cli/codegen/plugin/005-custom-config/config.ts @@ -1,4 +1,4 @@ -import { IClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; import { PluginModule, PluginPackage } from "@polywrap/plugin-js"; import { latestWrapManifestVersion } from "@polywrap/wrap-manifest-types-js"; import { parseSchema } from "@polywrap/schema-parse"; @@ -37,6 +37,6 @@ const mockPlugin = () => { }); }; -export function configure(builder: IClientConfigBuilder): IClientConfigBuilder { - return builder.addPackage("wrap://ens/mock.eth", mockPlugin()); +export function configure(builder: ClientConfigBuilder): ClientConfigBuilder { + return builder.setPackage("wrap://ens/mock.eth", mockPlugin()); } diff --git a/packages/test-cases/cases/cli/codegen/plugin/008-python/expected/wrap/module.py b/packages/test-cases/cases/cli/codegen/plugin/008-python/expected/wrap/module.py index 6ca1f63a5c..66d15b7acc 100644 --- a/packages/test-cases/cases/cli/codegen/plugin/008-python/expected/wrap/module.py +++ b/packages/test-cases/cases/cli/codegen/plugin/008-python/expected/wrap/module.py @@ -34,4 +34,3 @@ def sample_method( env: None ) -> str: pass - diff --git a/packages/test-cases/cases/cli/codegen/wasm/001-sanity-assemblyscript/polywrap.yaml b/packages/test-cases/cases/cli/codegen/wasm/001-sanity-assemblyscript/polywrap.yaml index ee9034f333..59f654c7b3 100644 --- a/packages/test-cases/cases/cli/codegen/wasm/001-sanity-assemblyscript/polywrap.yaml +++ b/packages/test-cases/cases/cli/codegen/wasm/001-sanity-assemblyscript/polywrap.yaml @@ -1,4 +1,4 @@ -format: 0.4.0 +format: 0.5.0 project: name: test-project type: wasm/assemblyscript diff --git a/packages/test-cases/cases/cli/codegen/wasm/002-sanity-rust/polywrap.yaml b/packages/test-cases/cases/cli/codegen/wasm/002-sanity-rust/polywrap.yaml index 55eecfe9bc..ae4b4ebd7a 100644 --- a/packages/test-cases/cases/cli/codegen/wasm/002-sanity-rust/polywrap.yaml +++ b/packages/test-cases/cases/cli/codegen/wasm/002-sanity-rust/polywrap.yaml @@ -1,4 +1,4 @@ -format: 0.4.0 +format: 0.5.0 project: name: ObjectTypes type: wasm/rust @@ -6,4 +6,4 @@ source: schema: ./schema.graphql module: ./Cargo.toml extensions: - build: ./polywrap.build.yaml \ No newline at end of file + build: ./polywrap.build.yaml diff --git a/packages/test-cases/cases/cli/codegen/wasm/005-custom-config/config.ts b/packages/test-cases/cases/cli/codegen/wasm/005-custom-config/config.ts index 3dd8b8bacc..bb9f2ee52e 100644 --- a/packages/test-cases/cases/cli/codegen/wasm/005-custom-config/config.ts +++ b/packages/test-cases/cases/cli/codegen/wasm/005-custom-config/config.ts @@ -1,4 +1,4 @@ -import { IClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; import { IWrapPackage } from "@polywrap/core-js"; import { PluginModule, PluginPackage } from "@polywrap/plugin-js"; import { @@ -34,8 +34,8 @@ const mockPlugin = (): IWrapPackage => { }); }; -export function configure(builder: IClientConfigBuilder): IClientConfigBuilder { - return builder.addPackage("wrap://ens/mock.eth", mockPlugin()); +export function configure(builder: ClientConfigBuilder): ClientConfigBuilder { + return builder.setPackage("wrap://ens/mock.eth", mockPlugin()); } const abi: WrapAbi = { diff --git a/packages/test-cases/cases/cli/codegen/wasm/007-override-config/config.ts b/packages/test-cases/cases/cli/codegen/wasm/007-override-config/config.ts index 8aabb19cdd..9e67a9fd70 100644 --- a/packages/test-cases/cases/cli/codegen/wasm/007-override-config/config.ts +++ b/packages/test-cases/cases/cli/codegen/wasm/007-override-config/config.ts @@ -1,6 +1,6 @@ import { - IClientConfigBuilder, ClientConfigBuilder, + PolywrapClientConfigBuilder, } from "@polywrap/client-js"; import { PluginModule, PluginPackage } from "@polywrap/plugin-js"; import { latestWrapManifestVersion } from "@polywrap/schema-parse"; @@ -122,8 +122,8 @@ const mockPlugin = () => { ); }; -export function configure(_: IClientConfigBuilder): IClientConfigBuilder { - return new ClientConfigBuilder() +export function configure(_: ClientConfigBuilder): ClientConfigBuilder { + return new PolywrapClientConfigBuilder() .addDefaults() - .addPackage("wrap://ens/mock.eth", mockPlugin()); + .setPackage("wrap://ens/mock.eth", mockPlugin()); } diff --git a/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/expected/stdout.json b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/expected/stdout.json new file mode 100644 index 0000000000..735a6dca2c --- /dev/null +++ b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/expected/stdout.json @@ -0,0 +1,4 @@ +{ + "stdout": "Types were generated successfully", + "exitCode": 0 +} diff --git a/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/go.mod b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/go.mod new file mode 100644 index 0000000000..ef679eeb1b --- /dev/null +++ b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/go.mod @@ -0,0 +1,7 @@ +module example.com/go-wrap-test + +go 1.18 + +require github.com/polywrap/go-wrap wrap-0.1 + +require github.com/valyala/fastjson v1.6.3 // indirect diff --git a/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/module/module.go b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/module/module.go new file mode 100644 index 0000000000..67c8df4810 --- /dev/null +++ b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/module/module.go @@ -0,0 +1,7 @@ +package module + +import "example.com/go-wrap-test/module/wrap/types" + +func Method(args *types.ArgsMethod) string { + return args.Arg +} diff --git a/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/polywrap.yaml b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/polywrap.yaml new file mode 100644 index 0000000000..07650dd125 --- /dev/null +++ b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/polywrap.yaml @@ -0,0 +1,7 @@ +format: 0.4.0 +project: + name: ObjectTypes + type: wasm/golang +source: + schema: ./schema.graphql + module: ./go.mod diff --git a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/schema.graphql b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/schema.graphql similarity index 96% rename from packages/test-cases/cases/cli/docgen/003-custom-manifest-file/schema.graphql rename to packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/schema.graphql index 325e224971..3dc66d388a 100644 --- a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/schema.graphql +++ b/packages/test-cases/cases/cli/codegen/wasm/008-sanity-golang/schema.graphql @@ -2,4 +2,4 @@ type Module { method( arg: String! ): String! -} +} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/deploy/.gitignore b/packages/test-cases/cases/cli/deploy/.gitignore new file mode 100644 index 0000000000..8348879d7f --- /dev/null +++ b/packages/test-cases/cases/cli/deploy/.gitignore @@ -0,0 +1 @@ +URI.txt \ No newline at end of file diff --git a/packages/test-cases/cases/cli/deploy/001-sanity/URI.txt b/packages/test-cases/cases/cli/deploy/001-sanity/URI.txt deleted file mode 100644 index 8f865f00c3..0000000000 --- a/packages/test-cases/cases/cli/deploy/001-sanity/URI.txt +++ /dev/null @@ -1 +0,0 @@ -wrap://ens/testnet/test2.eth \ No newline at end of file diff --git a/packages/test-cases/cases/cli/deploy/001-sanity/polywrap.deploy.yaml b/packages/test-cases/cases/cli/deploy/001-sanity/polywrap.deploy.yaml index 5f6e44217e..99f69b156c 100644 --- a/packages/test-cases/cases/cli/deploy/001-sanity/polywrap.deploy.yaml +++ b/packages/test-cases/cases/cli/deploy/001-sanity/polywrap.deploy.yaml @@ -1,44 +1,10 @@ -format: "0.3.0" +format: 0.4.0 jobs: - fs_to_ens: + fs_to_ipfs: config: - provider: 'http://localhost:8545' - ensRegistryAddress: $ENS_REG_ADDR - ensRegistrarAddress: $ENS_REGISTRAR_ADDR - ensResolverAddress: $ENS_RESOLVER_ADDR + provider: http://localhost:8545 gatewayUri: $IPFS_GATEWAY_URI steps: - - name: ens_register - package: ens-recursive-name-register - uri: wrap://ens/test1.eth - - name: ens_register2 - package: ens-recursive-name-register - uri: wrap://ens/test2.eth - name: ipfs_deploy package: ipfs uri: wrap://fs/../wrapper - - name: from_deploy - package: ens - uri: $$ipfs_deploy - config: - domainName: test1.eth - - name: from_deploy2 - package: ens - uri: $$ipfs_deploy - config: - domainName: test2.eth - ipfs_to_ens: - config: - provider: 'http://localhost:8545' - ensRegistryAddress: $ENS_REG_ADDR - ensRegistrarAddress: $ENS_REGISTRAR_ADDR - ensResolverAddress: $ENS_RESOLVER_ADDR - steps: - - name: ens_register - package: ens-recursive-name-register - uri: wrap://ens/test3.eth - - name: from_uri - package: ens - uri: wrap://ipfs/QmVdDR6QtigTt38Xwpj2Ki73X1AyZn5WRCreBCJq1CEtpF - config: - domainName: test3.eth \ No newline at end of file diff --git a/packages/test-cases/cases/cli/deploy/002-no-ext/polywrap.deploy.yaml b/packages/test-cases/cases/cli/deploy/002-no-ext/polywrap.deploy.yaml index 739aab7812..62af12305a 100644 --- a/packages/test-cases/cases/cli/deploy/002-no-ext/polywrap.deploy.yaml +++ b/packages/test-cases/cases/cli/deploy/002-no-ext/polywrap.deploy.yaml @@ -1,4 +1,4 @@ -format: "0.3.0" +format: 0.4.0 jobs: test: steps: diff --git a/packages/test-cases/cases/cli/deploy/003-invalid-config/polywrap.deploy.yaml b/packages/test-cases/cases/cli/deploy/003-invalid-config/polywrap.deploy.yaml index d7a079a1d4..17b948d8d8 100644 --- a/packages/test-cases/cases/cli/deploy/003-invalid-config/polywrap.deploy.yaml +++ b/packages/test-cases/cases/cli/deploy/003-invalid-config/polywrap.deploy.yaml @@ -1,4 +1,4 @@ -format: "0.3.0" +format: 0.4.0 jobs: test: config: @@ -7,10 +7,5 @@ jobs: - name: ipfs_deploy package: ipfs uri: wrap://fs/../wrapper - - name: from_deploy - package: ens - uri: $$ipfs_deploy config: - domainName: true - ports: - ethereum: 8545 \ No newline at end of file + gatewayUri: false diff --git a/packages/test-cases/cases/cli/deploy/004-fail-between/polywrap.deploy.yaml b/packages/test-cases/cases/cli/deploy/004-fail-between/polywrap.deploy.yaml index 7eb0672b5b..6798f7599f 100644 --- a/packages/test-cases/cases/cli/deploy/004-fail-between/polywrap.deploy.yaml +++ b/packages/test-cases/cases/cli/deploy/004-fail-between/polywrap.deploy.yaml @@ -1,30 +1,17 @@ -format: "0.3.0" +format: 0.4.0 jobs: test: config: - provider: 'http://localhost:8545' gatewayUri: $IPFS_GATEWAY_URI - ensRegistryAddress: $ENS_REG_ADDR - ensRegistrarAddress: $ENS_REGISTRAR_ADDR - ensResolverAddress: $ENS_RESOLVER_ADDR steps: - - name: ipfs_deploy + - name: ipfs_deploy_1 + package: ipfs + uri: fs/../wrapper + - name: ipfs_deploy_2 package: ipfs uri: fs/../wrapper - - name: from_deploy - package: ens - uri: $$ipfs_deploy - config: - domainName: foo - ports: - ethereum: 8545 - - name: ens_register - package: ens-recursive-name-register - uri: wrap://ens/test2.eth - - name: from_deploy2 - package: ens - uri: $$ipfs_deploy config: - domainName: test2.eth - ports: - ethereum: 8545 \ No newline at end of file + gatewayUri: "this_should_throw" + - name: ipfs_deploy_3 + package: ipfs + uri: fs/../wrapper diff --git a/packages/test-cases/cases/cli/deploy/005-non-loaded-env-var/polywrap.deploy.yaml b/packages/test-cases/cases/cli/deploy/005-non-loaded-env-var/polywrap.deploy.yaml index 93d1f271b5..ca75f64d3a 100644 --- a/packages/test-cases/cases/cli/deploy/005-non-loaded-env-var/polywrap.deploy.yaml +++ b/packages/test-cases/cases/cli/deploy/005-non-loaded-env-var/polywrap.deploy.yaml @@ -1,4 +1,4 @@ -format: "0.3.0" +format: 0.4.0 jobs: test: config: @@ -7,10 +7,5 @@ jobs: - name: ipfs_deploy package: ipfs uri: fs/../wrapper - - name: from_deploy - package: ens - uri: $$ipfs_deploy config: - domainName: $NON_LOADED_VAR - provider: 'http://localhost:8545' - ensRegistryAddress: '0x9b1f7F645351AF3631a656421eD2e40f2802E6c0' + gatewayUri: $NON_LOADED_VAR diff --git a/packages/test-cases/cases/cli/docgen/001-sanity/.gitignore b/packages/test-cases/cases/cli/docgen/001-sanity/.gitignore deleted file mode 100644 index 29d09945fc..0000000000 --- a/packages/test-cases/cases/cli/docgen/001-sanity/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -docs -!expected/** \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/001-sanity/cmd.json b/packages/test-cases/cases/cli/docgen/001-sanity/cmd.json deleted file mode 100644 index e88975e499..0000000000 --- a/packages/test-cases/cases/cli/docgen/001-sanity/cmd.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "doc": "docusaurus" -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/001-sanity/expected/docs/module.md b/packages/test-cases/cases/cli/docgen/001-sanity/expected/docs/module.md deleted file mode 100644 index a2abb12a0a..0000000000 --- a/packages/test-cases/cases/cli/docgen/001-sanity/expected/docs/module.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -id: module -title: Module -sidebar_position: 1 ---- - -### method - -```graphql -method( - arg: String! -): String! -``` - diff --git a/packages/test-cases/cases/cli/docgen/001-sanity/expected/stdout.json b/packages/test-cases/cases/cli/docgen/001-sanity/expected/stdout.json deleted file mode 100644 index a7621f6c30..0000000000 --- a/packages/test-cases/cases/cli/docgen/001-sanity/expected/stdout.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "stdout": "Docs were generated successfully", - "exitCode": 0 -} diff --git a/packages/test-cases/cases/cli/docgen/001-sanity/package.json b/packages/test-cases/cases/cli/docgen/001-sanity/package.json deleted file mode 100644 index 3360b30d0f..0000000000 --- a/packages/test-cases/cases/cli/docgen/001-sanity/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@polywrap/test-project", - "version": "0.1.0", - "license": "MIT", - "private": true, - "scripts": { - "build": "polywrap build" - }, - "dependencies": { - "@polywrap/wasm-as": "0.3.0" - }, - "devDependencies": { - "assemblyscript": "0.19.23" - } -} diff --git a/packages/test-cases/cases/cli/docgen/001-sanity/polywrap.build.yaml b/packages/test-cases/cases/cli/docgen/001-sanity/polywrap.build.yaml deleted file mode 100644 index c3dcbe22cb..0000000000 --- a/packages/test-cases/cases/cli/docgen/001-sanity/polywrap.build.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.2.0 -strategies: - image: - node_version: "14.16.0" - include: - - ./package.json -linked_packages: - - name: "@polywrap/wasm-as" - path: ../../../../../../wasm/as diff --git a/packages/test-cases/cases/cli/docgen/001-sanity/polywrap.yaml b/packages/test-cases/cases/cli/docgen/001-sanity/polywrap.yaml deleted file mode 100644 index ee9034f333..0000000000 --- a/packages/test-cases/cases/cli/docgen/001-sanity/polywrap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.4.0 -project: - name: test-project - type: wasm/assemblyscript -source: - schema: ./schema.graphql - module: ./src/index.ts -extensions: - build: ./polywrap.build.yaml diff --git a/packages/test-cases/cases/cli/docgen/001-sanity/src/index.ts b/packages/test-cases/cases/cli/docgen/001-sanity/src/index.ts deleted file mode 100644 index 862d4cb226..0000000000 --- a/packages/test-cases/cases/cli/docgen/001-sanity/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Args_method } from "./wrap"; - -export function method(args: Args_method): string { - return args.arg; -} diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/.gitignore b/packages/test-cases/cases/cli/docgen/002-custom-config/.gitignore deleted file mode 100644 index 29d09945fc..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -docs -!expected/** \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/cmd.json b/packages/test-cases/cases/cli/docgen/002-custom-config/cmd.json deleted file mode 100644 index 831f18e391..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/cmd.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "clientConfig": "./config.ts", - "doc": "docusaurus" -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/config.ts b/packages/test-cases/cases/cli/docgen/002-custom-config/config.ts deleted file mode 100644 index e1a1c1fb38..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/config.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { IClientConfigBuilder } from "@polywrap/client-config-builder-js"; -import { PluginModule, PluginPackage } from "@polywrap/plugin-js"; -import { - latestWrapManifestVersion, - WrapManifest, -} from "@polywrap/wrap-manifest-types-js"; - -interface Config extends Record { - val: number; -} - -class MockPlugin extends PluginModule { - getData(_: unknown): number { - return this.config.val; - } - - setData(args: { value: number }) { - this.config.val = +args.value; - return true; - } - - deployContract(): string { - return "0x100"; - } -} - -const mockPlugin = () => { - return PluginPackage.from(new MockPlugin({ val: 0 }), mockPluginManifest); -}; - -export function configure(builder: IClientConfigBuilder): IClientConfigBuilder { - return builder.addPackage("wrap://ens/mock.eth", mockPlugin()); -} - -export const mockPluginManifest: WrapManifest = { - name: "mock", - type: "plugin", - version: latestWrapManifestVersion, - abi: { - version: "0.1", - moduleType: { - type: "Module", - kind: 128, - methods: [ - { - type: "Method", - name: "getData", - required: true, - kind: 64, - return: { - type: "Int", - name: "getData", - required: true, - kind: 34, - scalar: { - type: "Int", - name: "getData", - required: true, - kind: 4, - }, - }, - }, - { - type: "Method", - name: "setData", - required: true, - kind: 64, - arguments: [ - { - type: "Int", - name: "value", - required: true, - kind: 34, - scalar: { - type: "Int", - name: "value", - required: true, - kind: 4, - }, - }, - ], - return: { - type: "Boolean", - name: "setData", - required: true, - kind: 34, - scalar: { - type: "Boolean", - name: "setData", - required: true, - kind: 4, - }, - }, - }, - { - type: "Method", - name: "deployContract", - required: true, - kind: 64, - return: { - type: "String", - name: "deployContract", - required: true, - kind: 34, - scalar: { - type: "String", - name: "deployContract", - required: true, - kind: 4, - }, - }, - }, - ], - }, - }, -}; diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/expected/docs/module.md b/packages/test-cases/cases/cli/docgen/002-custom-config/expected/docs/module.md deleted file mode 100644 index 46bf7e0d15..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/expected/docs/module.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -id: module -title: Module -sidebar_position: 1 ---- - -### deployContract - -```graphql -deployContract( -): String! -``` - -### method - -```graphql -method( - arg: String! -): String! -``` - diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/expected/stdout.json b/packages/test-cases/cases/cli/docgen/002-custom-config/expected/stdout.json deleted file mode 100644 index 249fae9c62..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/expected/stdout.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "stdout": [ - "Docs were generated successfully" - ], - "exitCode": 0 -} diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/package.json b/packages/test-cases/cases/cli/docgen/002-custom-config/package.json deleted file mode 100644 index 3360b30d0f..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@polywrap/test-project", - "version": "0.1.0", - "license": "MIT", - "private": true, - "scripts": { - "build": "polywrap build" - }, - "dependencies": { - "@polywrap/wasm-as": "0.3.0" - }, - "devDependencies": { - "assemblyscript": "0.19.23" - } -} diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/polywrap.build.yaml b/packages/test-cases/cases/cli/docgen/002-custom-config/polywrap.build.yaml deleted file mode 100644 index c3dcbe22cb..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/polywrap.build.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.2.0 -strategies: - image: - node_version: "14.16.0" - include: - - ./package.json -linked_packages: - - name: "@polywrap/wasm-as" - path: ../../../../../../wasm/as diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/polywrap.yaml b/packages/test-cases/cases/cli/docgen/002-custom-config/polywrap.yaml deleted file mode 100644 index ee9034f333..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/polywrap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.4.0 -project: - name: test-project - type: wasm/assemblyscript -source: - schema: ./schema.graphql - module: ./src/index.ts -extensions: - build: ./polywrap.build.yaml diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/schema.graphql b/packages/test-cases/cases/cli/docgen/002-custom-config/schema.graphql deleted file mode 100644 index 928ed3bdb9..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/schema.graphql +++ /dev/null @@ -1,9 +0,0 @@ -#import * into Mock from "wrap://ens/mock.eth" - -type Module { - method( - arg: String! - ): String! - - deployContract: String! -} diff --git a/packages/test-cases/cases/cli/docgen/002-custom-config/src/index.ts b/packages/test-cases/cases/cli/docgen/002-custom-config/src/index.ts deleted file mode 100644 index 2c9e567878..0000000000 --- a/packages/test-cases/cases/cli/docgen/002-custom-config/src/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Args_method, Mock_deployContract } from "./wrap"; - -export function method(args: Args_method): string { - return args.arg; -} - -export function deployContract(): string { - return Mock_deployContract({}).unwrap(); -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/.gitignore b/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/.gitignore deleted file mode 100644 index 29d09945fc..0000000000 --- a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -docs -!expected/** \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/cmd.json b/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/cmd.json deleted file mode 100644 index 7ff8530b42..0000000000 --- a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/cmd.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "doc": "docusaurus", - "manifestFile": "./polywrap.custom.yaml" -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/expected/docs/module.md b/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/expected/docs/module.md deleted file mode 100644 index a2abb12a0a..0000000000 --- a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/expected/docs/module.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -id: module -title: Module -sidebar_position: 1 ---- - -### method - -```graphql -method( - arg: String! -): String! -``` - diff --git a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/expected/stdout.json b/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/expected/stdout.json deleted file mode 100644 index a7621f6c30..0000000000 --- a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/expected/stdout.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "stdout": "Docs were generated successfully", - "exitCode": 0 -} diff --git a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/package.json b/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/package.json deleted file mode 100644 index 3360b30d0f..0000000000 --- a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@polywrap/test-project", - "version": "0.1.0", - "license": "MIT", - "private": true, - "scripts": { - "build": "polywrap build" - }, - "dependencies": { - "@polywrap/wasm-as": "0.3.0" - }, - "devDependencies": { - "assemblyscript": "0.19.23" - } -} diff --git a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/polywrap.custom.build.yaml b/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/polywrap.custom.build.yaml deleted file mode 100644 index c3dcbe22cb..0000000000 --- a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/polywrap.custom.build.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.2.0 -strategies: - image: - node_version: "14.16.0" - include: - - ./package.json -linked_packages: - - name: "@polywrap/wasm-as" - path: ../../../../../../wasm/as diff --git a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/polywrap.custom.yaml b/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/polywrap.custom.yaml deleted file mode 100644 index 24250643cf..0000000000 --- a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/polywrap.custom.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.4.0 -project: - name: test-project - type: wasm/assemblyscript -source: - schema: ./schema.graphql - module: ./src/index.ts -extensions: - build: ./polywrap.build.yaml \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/src/index.ts b/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/src/index.ts deleted file mode 100644 index 862d4cb226..0000000000 --- a/packages/test-cases/cases/cli/docgen/003-custom-manifest-file/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Args_method } from "./wrap"; - -export function method(args: Args_method): string { - return args.arg; -} diff --git a/packages/test-cases/cases/cli/docgen/004-app/.gitignore b/packages/test-cases/cases/cli/docgen/004-app/.gitignore deleted file mode 100644 index 29d09945fc..0000000000 --- a/packages/test-cases/cases/cli/docgen/004-app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -docs -!expected/** \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/004-app/cmd.json b/packages/test-cases/cases/cli/docgen/004-app/cmd.json deleted file mode 100644 index bdf40463c7..0000000000 --- a/packages/test-cases/cases/cli/docgen/004-app/cmd.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "imports": true, - "doc": "docusaurus" -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Ethereum_module.md b/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Ethereum_module.md deleted file mode 100644 index 30ec3c9c04..0000000000 --- a/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Ethereum_module.md +++ /dev/null @@ -1,256 +0,0 @@ ---- -id: Ethereum_module -title: Ethereum Module -sidebar_position: 1 ---- - -### awaitTransaction - -```graphql -awaitTransaction( - txHash: String! - connection: Ethereum_Connection -): Ethereum_TxReceipt! -``` - -### callContractMethod - -```graphql -callContractMethod( - address: String! - method: String! - args: String[] - options: Ethereum_TxOptions - connection: Ethereum_Connection -): Ethereum_TxResponse! -``` - -### callContractMethodAndWait - -```graphql -callContractMethodAndWait( - address: String! - method: String! - args: String[] - options: Ethereum_TxOptions - connection: Ethereum_Connection -): Ethereum_TxReceipt! -``` - -### callContractStatic - -```graphql -callContractStatic( - address: String! - method: String! - args: String[] - options: Ethereum_TxOptions - connection: Ethereum_Connection -): Ethereum_StaticTxResult! -``` - -### callContractView - -```graphql -callContractView( - address: String! - method: String! - args: String[] - connection: Ethereum_Connection -): String! -``` - -### checkAddress - -```graphql -checkAddress( - address: String! - connection: Ethereum_Connection -): Boolean! -``` - -### decodeFunction - -```graphql -decodeFunction( - method: String! - data: String! - connection: Ethereum_Connection -): String[]! -``` - -### deployContract - -```graphql -deployContract( - abi: String! - bytecode: String! - args: String[] - options: Ethereum_TxOptions - connection: Ethereum_Connection -): String! -``` - -### encodeFunction - -```graphql -encodeFunction( - method: String! - args: String[] - connection: Ethereum_Connection -): String! -``` - -### encodeParams - -```graphql -encodeParams( - types: String[]! - values: String[]! - connection: Ethereum_Connection -): String! -``` - -### estimateContractCallGas - -```graphql -estimateContractCallGas( - address: String! - method: String! - args: String[] - options: Ethereum_TxOptions - connection: Ethereum_Connection -): BigInt! -``` - -### estimateEip1559Fees - -```graphql -estimateEip1559Fees( - connection: Ethereum_Connection -): Ethereum_Eip1559FeesEstimate! -``` - -### estimateTransactionGas - -```graphql -estimateTransactionGas( - tx: Ethereum_TxRequest! - connection: Ethereum_Connection -): BigInt! -``` - -### getBalance - -```graphql -getBalance( - address: String! - blockTag: BigInt - connection: Ethereum_Connection -): BigInt! -``` - -### getChainId - -```graphql -getChainId( - connection: Ethereum_Connection -): String! -``` - -### getGasPrice - -```graphql -getGasPrice( - connection: Ethereum_Connection -): BigInt! -``` - -### getSignerAddress - -```graphql -getSignerAddress( - connection: Ethereum_Connection -): String! -``` - -### getSignerBalance - -```graphql -getSignerBalance( - blockTag: BigInt - connection: Ethereum_Connection -): BigInt! -``` - -### getSignerTransactionCount - -```graphql -getSignerTransactionCount( - blockTag: BigInt - connection: Ethereum_Connection -): BigInt! -``` - -### sendRpc - -```graphql -sendRpc( - method: String! - params: String[]! - connection: Ethereum_Connection -): String! -``` - -### sendTransaction - -```graphql -sendTransaction( - tx: Ethereum_TxRequest! - connection: Ethereum_Connection -): Ethereum_TxResponse! -``` - -### sendTransactionAndWait - -```graphql -sendTransactionAndWait( - tx: Ethereum_TxRequest! - connection: Ethereum_Connection -): Ethereum_TxReceipt! -``` - -### signMessage - -```graphql -signMessage( - message: String! - connection: Ethereum_Connection -): String! -``` - -### signMessageBytes - -```graphql -signMessageBytes( - bytes: Bytes! - connection: Ethereum_Connection -): String! -``` - -### toEth - -```graphql -toEth( - wei: String! -): String! -``` - -### toWei - -```graphql -toWei( - eth: String! -): String! -``` - diff --git a/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Ethereum_objects.md b/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Ethereum_objects.md deleted file mode 100644 index 0bee987edc..0000000000 --- a/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Ethereum_objects.md +++ /dev/null @@ -1,149 +0,0 @@ ---- -id: Ethereum_objects -title: Ethereum Object Types -sidebar_position: 2 ---- - - -### Ethereum_AccessItem - -```graphql -type Ethereum_AccessItem { - address: String! - storageKeys: String[]! -} -``` - -### Ethereum_Connection - -```graphql -type Ethereum_Connection { - node: String - networkNameOrChainId: String -} -``` - -### Ethereum_Eip1559FeesEstimate - -```graphql -type Ethereum_Eip1559FeesEstimate { - maxFeePerGas: BigInt! - maxPriorityFeePerGas: BigInt! -} -``` - -### Ethereum_Log - -```graphql -type Ethereum_Log { - blockNumber: BigInt! - blockHash: String! - transactionIndex: UInt32! - removed: Boolean! - address: String! - data: String! - topics: String[]! - transactionHash: String! - logIndex: UInt32! -} -``` - -### Ethereum_StaticTxResult - -```graphql -type Ethereum_StaticTxResult { - result: String! - error: Boolean! -} -``` - -### Ethereum_TxOptions - -```graphql -type Ethereum_TxOptions { - gasLimit: BigInt # Gas supplied for the transaction - maxFeePerGas: BigInt # The max total fee to pay per unit of gas. -The difference between maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is “refunded†to the user. -This property is ignored when gasPrice is not null. - maxPriorityFeePerGas: BigInt # The gas price paid is baseFeePerGas + maxPriorityFeePerGas. -The difference between maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is “refunded†to the user. -This property is ignored when gasPrice is not null. - gasPrice: BigInt # The gas price for legacy transactions. -If this property is not null, a legacy transaction will be sent and maxFeePerGas and maxPriorityFeePerGas will be ignored. - value: BigInt # Ether value sent with transaction - nonce: UInt32 # Override default nonce -} -``` - -### Ethereum_TxReceipt - -```graphql -type Ethereum_TxReceipt { - to: String! - from: String! - contractAddress: String! - transactionIndex: UInt32! - root: String - gasUsed: BigInt! - logsBloom: String! - transactionHash: String! - logs: Ethereum_Log[]! - blockNumber: BigInt! - blockHash: String! - confirmations: UInt32! - cumulativeGasUsed: BigInt! - effectiveGasPrice: BigInt! - type: UInt32! - status: UInt32 -} -``` - -### Ethereum_TxRequest - -```graphql -type Ethereum_TxRequest { - to: String - from: String - data: String - type: UInt32 - chainId: BigInt - accessList: Ethereum_AccessItem[] - gasLimit: BigInt # Gas supplied for the transaction - maxFeePerGas: BigInt # The max total fee to pay per unit of gas. -The difference between maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is “refunded†to the user. -This property is ignored when gasPrice is not null. - maxPriorityFeePerGas: BigInt # The gas price paid is baseFeePerGas + maxPriorityFeePerGas. -The difference between maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is “refunded†to the user. -This property is ignored when gasPrice is not null. - gasPrice: BigInt # The gas price for legacy transactions. -If this property is not null, a legacy transaction will be sent and maxFeePerGas and maxPriorityFeePerGas will be ignored. - value: BigInt # Ether value sent with transaction - nonce: UInt32 # Override default nonce -} -``` - -### Ethereum_TxResponse - -```graphql -type Ethereum_TxResponse { - hash: String! - to: String - from: String! - nonce: UInt32! - gasLimit: BigInt! - maxFeePerGas: BigInt - maxPriorityFeePerGas: BigInt - gasPrice: BigInt - value: BigInt! - chainId: BigInt! - blockNumber: BigInt - blockHash: String - timestamp: UInt32 - r: String - s: String - v: UInt32 - type: UInt32 - accessList: Ethereum_AccessItem[] -} -``` - diff --git a/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Logger_enums.md b/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Logger_enums.md deleted file mode 100644 index c4cac40698..0000000000 --- a/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Logger_enums.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -id: Logger_enums -title: Logger Enum Types -sidebar_position: 3 ---- - - -### Logger_Logger_LogLevel - -```graphql -enum Logger_Logger_LogLevel { - DEBUG - INFO - WARN - ERROR -} -``` - diff --git a/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Logger_module.md b/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Logger_module.md deleted file mode 100644 index c483edc248..0000000000 --- a/packages/test-cases/cases/cli/docgen/004-app/expected/docs/Logger_module.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -id: Logger_module -title: Logger Module -sidebar_position: 1 ---- - -### log - -```graphql -log( - level: Logger_Logger_LogLevel! - message: String! -): Boolean! -``` - diff --git a/packages/test-cases/cases/cli/docgen/004-app/expected/stdout.json b/packages/test-cases/cases/cli/docgen/004-app/expected/stdout.json deleted file mode 100644 index a7621f6c30..0000000000 --- a/packages/test-cases/cases/cli/docgen/004-app/expected/stdout.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "stdout": "Docs were generated successfully", - "exitCode": 0 -} diff --git a/packages/test-cases/cases/cli/docgen/004-app/polywrap.app.yaml b/packages/test-cases/cases/cli/docgen/004-app/polywrap.app.yaml deleted file mode 100644 index 40f884e2a9..0000000000 --- a/packages/test-cases/cases/cli/docgen/004-app/polywrap.app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -format: 0.2.0 -project: - name: test-app - type: app/typescript -source: - schema: ./schema.graphql diff --git a/packages/test-cases/cases/cli/docgen/004-app/schema.graphql b/packages/test-cases/cases/cli/docgen/004-app/schema.graphql deleted file mode 100644 index 09a2a6a315..0000000000 --- a/packages/test-cases/cases/cli/docgen/004-app/schema.graphql +++ /dev/null @@ -1,2 +0,0 @@ -#import * into Ethereum from "wrap://ens/wraps.eth:ethereum@1.0.0" -#import * into Logger from "wrap://ens/wraps.eth:logger@1.0.0" diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/.gitignore b/packages/test-cases/cases/cli/docgen/005-wasm/.gitignore deleted file mode 100644 index 29d09945fc..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -docs -!expected/** \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/cmd.json b/packages/test-cases/cases/cli/docgen/005-wasm/cmd.json deleted file mode 100644 index e88975e499..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/cmd.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "doc": "docusaurus" -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/expected/docs/module.md b/packages/test-cases/cases/cli/docgen/005-wasm/expected/docs/module.md deleted file mode 100644 index a2abb12a0a..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/expected/docs/module.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -id: module -title: Module -sidebar_position: 1 ---- - -### method - -```graphql -method( - arg: String! -): String! -``` - diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/expected/docs/objects.md b/packages/test-cases/cases/cli/docgen/005-wasm/expected/docs/objects.md deleted file mode 100644 index 656ab28e09..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/expected/docs/objects.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -id: objects -title: Object Types -sidebar_position: 2 ---- - - -### Object - -```graphql -type Object { - uint: UInt! - bools: Boolean[]! - bites: Bytes -} -``` - diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/expected/stdout.json b/packages/test-cases/cases/cli/docgen/005-wasm/expected/stdout.json deleted file mode 100644 index a7621f6c30..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/expected/stdout.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "stdout": "Docs were generated successfully", - "exitCode": 0 -} diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/package.json b/packages/test-cases/cases/cli/docgen/005-wasm/package.json deleted file mode 100644 index 3360b30d0f..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "@polywrap/test-project", - "version": "0.1.0", - "license": "MIT", - "private": true, - "scripts": { - "build": "polywrap build" - }, - "dependencies": { - "@polywrap/wasm-as": "0.3.0" - }, - "devDependencies": { - "assemblyscript": "0.19.23" - } -} diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/polywrap-norun.gen.js b/packages/test-cases/cases/cli/docgen/005-wasm/polywrap-norun.gen.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/polywrap.build.yaml b/packages/test-cases/cases/cli/docgen/005-wasm/polywrap.build.yaml deleted file mode 100644 index c3dcbe22cb..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/polywrap.build.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.2.0 -strategies: - image: - node_version: "14.16.0" - include: - - ./package.json -linked_packages: - - name: "@polywrap/wasm-as" - path: ../../../../../../wasm/as diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/polywrap.yaml b/packages/test-cases/cases/cli/docgen/005-wasm/polywrap.yaml deleted file mode 100644 index 24250643cf..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/polywrap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.4.0 -project: - name: test-project - type: wasm/assemblyscript -source: - schema: ./schema.graphql - module: ./src/index.ts -extensions: - build: ./polywrap.build.yaml \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/schema.graphql b/packages/test-cases/cases/cli/docgen/005-wasm/schema.graphql deleted file mode 100644 index d52b08ea00..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/schema.graphql +++ /dev/null @@ -1,11 +0,0 @@ -type Module { - method( - arg: String! - ): String! -} - -type Object { - uint: UInt! - bools: [Boolean!]! - bites: Bytes -} diff --git a/packages/test-cases/cases/cli/docgen/005-wasm/src/index.ts b/packages/test-cases/cases/cli/docgen/005-wasm/src/index.ts deleted file mode 100644 index 862d4cb226..0000000000 --- a/packages/test-cases/cases/cli/docgen/005-wasm/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Args_method } from "./wrap"; - -export function method(args: Args_method): string { - return args.arg; -} diff --git a/packages/test-cases/cases/cli/docgen/006-plugin/.gitignore b/packages/test-cases/cases/cli/docgen/006-plugin/.gitignore deleted file mode 100644 index 29d09945fc..0000000000 --- a/packages/test-cases/cases/cli/docgen/006-plugin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -docs -!expected/** \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/006-plugin/cmd.json b/packages/test-cases/cases/cli/docgen/006-plugin/cmd.json deleted file mode 100644 index e88975e499..0000000000 --- a/packages/test-cases/cases/cli/docgen/006-plugin/cmd.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "doc": "docusaurus" -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/006-plugin/expected/docs/env.md b/packages/test-cases/cases/cli/docgen/006-plugin/expected/docs/env.md deleted file mode 100644 index 277239ca0a..0000000000 --- a/packages/test-cases/cases/cli/docgen/006-plugin/expected/docs/env.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -id: env -title: Env Type -sidebar_position: 4 ---- - - -### Env - -```graphql -type Env { - arg1: String! -} -``` - diff --git a/packages/test-cases/cases/cli/docgen/006-plugin/expected/docs/module.md b/packages/test-cases/cases/cli/docgen/006-plugin/expected/docs/module.md deleted file mode 100644 index 678ec7c901..0000000000 --- a/packages/test-cases/cases/cli/docgen/006-plugin/expected/docs/module.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -id: module -title: Module -sidebar_position: 1 ---- - -### methodOne - -```graphql -methodOne( - str: String! - optStr: String -): Object! -``` - -### methodTwo - -```graphql -methodTwo( - arg: UInt32! -): String! -``` - diff --git a/packages/test-cases/cases/cli/docgen/006-plugin/expected/docs/objects.md b/packages/test-cases/cases/cli/docgen/006-plugin/expected/docs/objects.md deleted file mode 100644 index 794ce00c0a..0000000000 --- a/packages/test-cases/cases/cli/docgen/006-plugin/expected/docs/objects.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -id: objects -title: Object Types -sidebar_position: 2 ---- - - -### Object - -```graphql -type Object { - u: UInt! - array: Boolean[]! - bytes: Bytes -} -``` - diff --git a/packages/test-cases/cases/cli/docgen/006-plugin/expected/stdout.json b/packages/test-cases/cases/cli/docgen/006-plugin/expected/stdout.json deleted file mode 100644 index a7621f6c30..0000000000 --- a/packages/test-cases/cases/cli/docgen/006-plugin/expected/stdout.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "stdout": "Docs were generated successfully", - "exitCode": 0 -} diff --git a/packages/test-cases/cases/cli/docgen/006-plugin/polywrap.plugin.yaml b/packages/test-cases/cases/cli/docgen/006-plugin/polywrap.plugin.yaml deleted file mode 100644 index fefc4fe360..0000000000 --- a/packages/test-cases/cases/cli/docgen/006-plugin/polywrap.plugin.yaml +++ /dev/null @@ -1,7 +0,0 @@ -format: 0.2.0 -project: - name: Test - type: plugin/typescript -source: - schema: ./schema.graphql - module: ./src/index.ts diff --git a/packages/test-cases/cases/cli/docgen/006-plugin/schema.graphql b/packages/test-cases/cases/cli/docgen/006-plugin/schema.graphql deleted file mode 100644 index 4406bc74ce..0000000000 --- a/packages/test-cases/cases/cli/docgen/006-plugin/schema.graphql +++ /dev/null @@ -1,22 +0,0 @@ -#import { Module } into Ethereum from "ens/wraps.eth:ethereum@1.0.0" - -type Module { - methodOne( - str: String! - optStr: String - ): Object! - - methodTwo( - arg: UInt32! - ): String! -} - -type Object { - u: UInt! - array: [Boolean!]! - bytes: Bytes -} - -type Env { - arg1: String! -} diff --git a/packages/test-cases/cases/cli/docgen/006-plugin/src/index.ts b/packages/test-cases/cases/cli/docgen/006-plugin/src/index.ts deleted file mode 100644 index 5bb85ff3e4..0000000000 --- a/packages/test-cases/cases/cli/docgen/006-plugin/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./wrap"; diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/.gitignore b/packages/test-cases/cases/cli/docgen/007-docusaurus/.gitignore deleted file mode 100644 index 29d09945fc..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -docs -!expected/** \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/cmd.json b/packages/test-cases/cases/cli/docgen/007-docusaurus/cmd.json deleted file mode 100644 index e88975e499..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/cmd.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "doc": "docusaurus" -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/docs/enums.md b/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/docs/enums.md deleted file mode 100644 index f5467760a0..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/docs/enums.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -id: enums -title: Enum Types -sidebar_position: 3 ---- - - -### test - -```graphql -enum test { - ARG1 - ARG2 -} -``` - diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/docs/module.md b/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/docs/module.md deleted file mode 100644 index d194ca9215..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/docs/module.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -id: module -title: Module -sidebar_position: 1 ---- - -### method - -```graphql -method( - str: String! - optStr: String -): Object! -``` - diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/docs/objects.md b/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/docs/objects.md deleted file mode 100644 index 96a0bbdbc9..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/docs/objects.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -id: objects -title: Object Types -sidebar_position: 2 ---- - - -### Object - -```graphql -type Object { - u: UInt! - array: Boolean[]! - bytes: Bytes -} -``` - -### Object2 - -_Test Comment_ - -```graphql -type Object2 { - u: UInt! # Test Comment - array: Boolean[]! # Test Comment - bytes: Bytes # Test Comment -} -``` - -### Object3 - -```graphql -type Object3 { - u: UInt! - array: Boolean[]! - bytes: Bytes -} -``` - diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/stdout.json b/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/stdout.json deleted file mode 100644 index a7621f6c30..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/expected/stdout.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "stdout": "Docs were generated successfully", - "exitCode": 0 -} diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/polywrap.build.yaml b/packages/test-cases/cases/cli/docgen/007-docusaurus/polywrap.build.yaml deleted file mode 100644 index 479e3042fe..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/polywrap.build.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.2.0 -strategies: - image: - node_version: "16.13.0" - include: - - ./package.json -linked_packages: - - name: "@polywrap/wasm-as" - path: ../../../../../../wasm/as diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/polywrap.yaml b/packages/test-cases/cases/cli/docgen/007-docusaurus/polywrap.yaml deleted file mode 100644 index 24250643cf..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/polywrap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.4.0 -project: - name: test-project - type: wasm/assemblyscript -source: - schema: ./schema.graphql - module: ./src/index.ts -extensions: - build: ./polywrap.build.yaml \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/schema.graphql b/packages/test-cases/cases/cli/docgen/007-docusaurus/schema.graphql deleted file mode 100644 index ec37fec197..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/schema.graphql +++ /dev/null @@ -1,35 +0,0 @@ -#import { Module } into Ethereum from "ens/wraps.eth:ethereum@1.0.0" - -type Module { - method( - str: String! - optStr: String - ): Object! -} - -type Object { - u: UInt! - array: [Boolean!]! - bytes: Bytes -} - -"""Test Comment""" -type Object2 { - """Test Comment""" - u: UInt! - """Test Comment""" - array: [Boolean!]! - """Test Comment""" - bytes: Bytes -} - -type Object3 { - u: UInt! - array: [Boolean!]! - bytes: Bytes -} - -enum test { - ARG1, - ARG2 -} diff --git a/packages/test-cases/cases/cli/docgen/007-docusaurus/src/index.ts b/packages/test-cases/cases/cli/docgen/007-docusaurus/src/index.ts deleted file mode 100644 index 5bb85ff3e4..0000000000 --- a/packages/test-cases/cases/cli/docgen/007-docusaurus/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./wrap"; diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/.gitignore b/packages/test-cases/cases/cli/docgen/008-jsdoc/.gitignore deleted file mode 100644 index 29d09945fc..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -docs -!expected/** \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/cmd.json b/packages/test-cases/cases/cli/docgen/008-jsdoc/cmd.json deleted file mode 100644 index e26e2d0da8..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/cmd.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "doc": "jsdoc" -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/docs/enums.js b/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/docs/enums.js deleted file mode 100644 index 81d229be22..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/docs/enums.js +++ /dev/null @@ -1,10 +0,0 @@ -/** -* Enum Types -* @module enums -*/ - -/** -* -* @typedef { } module:enums.test -*/ - diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/docs/module.js b/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/docs/module.js deleted file mode 100644 index 1cea6bda95..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/docs/module.js +++ /dev/null @@ -1,14 +0,0 @@ -/** -* Module -* @module module -* -*/ - -/** -* -* @function module:method.method -* @param { String } str -* @param { String | null } optStr -* @returns { Object } -*/ - diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/docs/objects.js b/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/docs/objects.js deleted file mode 100644 index 5ebf119cd0..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/docs/objects.js +++ /dev/null @@ -1,32 +0,0 @@ -/** -* Object Types -* @module objects -*/ - -/** -* -* @typedef {Object} module:objects.Object -* -* @property { UInt } u -* @property { Boolean[] } array -* @property { Bytes } bytes -*/ - -/** -* Test Comment -* @typedef {Object} module:objects.Object2 -* -* @property { UInt } u Test Comment -* @property { Boolean[] } array Test Comment -* @property { Bytes } bytes Test Comment -*/ - -/** -* -* @typedef {Object} module:objects.Object3 -* -* @property { UInt } u -* @property { Boolean[] } array -* @property { Bytes } bytes -*/ - diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/stdout.json b/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/stdout.json deleted file mode 100644 index a7621f6c30..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/expected/stdout.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "stdout": "Docs were generated successfully", - "exitCode": 0 -} diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/polywrap.build.yaml b/packages/test-cases/cases/cli/docgen/008-jsdoc/polywrap.build.yaml deleted file mode 100644 index 479e3042fe..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/polywrap.build.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.2.0 -strategies: - image: - node_version: "16.13.0" - include: - - ./package.json -linked_packages: - - name: "@polywrap/wasm-as" - path: ../../../../../../wasm/as diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/polywrap.yaml b/packages/test-cases/cases/cli/docgen/008-jsdoc/polywrap.yaml deleted file mode 100644 index 24250643cf..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/polywrap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.4.0 -project: - name: test-project - type: wasm/assemblyscript -source: - schema: ./schema.graphql - module: ./src/index.ts -extensions: - build: ./polywrap.build.yaml \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/schema.graphql b/packages/test-cases/cases/cli/docgen/008-jsdoc/schema.graphql deleted file mode 100644 index ec37fec197..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/schema.graphql +++ /dev/null @@ -1,35 +0,0 @@ -#import { Module } into Ethereum from "ens/wraps.eth:ethereum@1.0.0" - -type Module { - method( - str: String! - optStr: String - ): Object! -} - -type Object { - u: UInt! - array: [Boolean!]! - bytes: Bytes -} - -"""Test Comment""" -type Object2 { - """Test Comment""" - u: UInt! - """Test Comment""" - array: [Boolean!]! - """Test Comment""" - bytes: Bytes -} - -type Object3 { - u: UInt! - array: [Boolean!]! - bytes: Bytes -} - -enum test { - ARG1, - ARG2 -} diff --git a/packages/test-cases/cases/cli/docgen/008-jsdoc/src/index.ts b/packages/test-cases/cases/cli/docgen/008-jsdoc/src/index.ts deleted file mode 100644 index 5bb85ff3e4..0000000000 --- a/packages/test-cases/cases/cli/docgen/008-jsdoc/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./wrap"; diff --git a/packages/test-cases/cases/cli/docgen/009-schema/.gitignore b/packages/test-cases/cases/cli/docgen/009-schema/.gitignore deleted file mode 100644 index 29d09945fc..0000000000 --- a/packages/test-cases/cases/cli/docgen/009-schema/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -docs -!expected/** \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/009-schema/cmd.json b/packages/test-cases/cases/cli/docgen/009-schema/cmd.json deleted file mode 100644 index 4127e26415..0000000000 --- a/packages/test-cases/cases/cli/docgen/009-schema/cmd.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "doc": "schema" -} \ No newline at end of file diff --git a/packages/test-cases/cases/cli/docgen/009-schema/expected/docs/generated-schema.graphql b/packages/test-cases/cases/cli/docgen/009-schema/expected/docs/generated-schema.graphql deleted file mode 100644 index 398f33cac6..0000000000 --- a/packages/test-cases/cases/cli/docgen/009-schema/expected/docs/generated-schema.graphql +++ /dev/null @@ -1,436 +0,0 @@ -### Polywrap Header START ### -scalar UInt -scalar UInt8 -scalar UInt16 -scalar UInt32 -scalar Int -scalar Int8 -scalar Int16 -scalar Int32 -scalar Bytes -scalar BigInt -scalar BigNumber -scalar JSON -scalar Map - -directive @imported( - uri: String! - namespace: String! - nativeType: String! -) on OBJECT | ENUM - -directive @imports( - types: [String!]! -) on OBJECT - -directive @capability( - type: String! - uri: String! - namespace: String! -) repeatable on OBJECT - -directive @enabled_interface on OBJECT - -directive @annotate(type: String!) on FIELD - -directive @env(required: Boolean!) on FIELD_DEFINITION - -### Polywrap Header END ### - -type Module @imports( - types: [ - "Ethereum_Module", - "Ethereum_Connection", - "Ethereum_TxOptions", - "Ethereum_StaticTxResult", - "Ethereum_Eip1559FeesEstimate", - "Ethereum_TxRequest", - "Ethereum_AccessItem", - "Ethereum_TxReceipt", - "Ethereum_Log", - "Ethereum_TxResponse" - ] -) { - method( - str: String! - optStr: String - ): Object! -} - -type Object { - u: UInt! - array: [Boolean!]! - bytes: Bytes -} - -""" -Test Comment -""" -type Object2 { - """ - Test Comment - """ - u: UInt! - """ - Test Comment - """ - array: [Boolean!]! - """ - Test Comment - """ - bytes: Bytes -} - -type Object3 { - u: UInt! - array: [Boolean!]! - bytes: Bytes -} - -enum test { - ARG1 - ARG2 -} - -### Imported Modules START ### - -type Ethereum_Module @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "Module" -) { - getChainId( - connection: Ethereum_Connection - ): String! - - callContractView( - address: String! - method: String! - args: [String!] - connection: Ethereum_Connection - ): String! - - callContractStatic( - address: String! - method: String! - args: [String!] - options: Ethereum_TxOptions - connection: Ethereum_Connection - ): Ethereum_StaticTxResult! - - encodeParams( - types: [String!]! - values: [String!]! - connection: Ethereum_Connection - ): String! - - encodeFunction( - method: String! - args: [String!] - connection: Ethereum_Connection - ): String! - - decodeFunction( - method: String! - data: String! - connection: Ethereum_Connection - ): [String!]! - - getSignerAddress( - connection: Ethereum_Connection - ): String! - - getSignerBalance( - blockTag: BigInt - connection: Ethereum_Connection - ): BigInt! - - getBalance( - address: String! - blockTag: BigInt - connection: Ethereum_Connection - ): BigInt! - - getGasPrice( - connection: Ethereum_Connection - ): BigInt! - - estimateEip1559Fees( - connection: Ethereum_Connection - ): Ethereum_Eip1559FeesEstimate! - - sendRpc( - method: String! - params: [String!]! - connection: Ethereum_Connection - ): String! - - getSignerTransactionCount( - blockTag: BigInt - connection: Ethereum_Connection - ): BigInt! - - checkAddress( - address: String! - connection: Ethereum_Connection - ): Boolean! - - toWei( - eth: String! - ): String! - - toEth( - wei: String! - ): String! - - estimateTransactionGas( - tx: Ethereum_TxRequest! - connection: Ethereum_Connection - ): BigInt! - - awaitTransaction( - txHash: String! - connection: Ethereum_Connection - ): Ethereum_TxReceipt! - - sendTransaction( - tx: Ethereum_TxRequest! - connection: Ethereum_Connection - ): Ethereum_TxResponse! - - sendTransactionAndWait( - tx: Ethereum_TxRequest! - connection: Ethereum_Connection - ): Ethereum_TxReceipt! - - deployContract( - abi: String! - bytecode: String! - args: [String!] - options: Ethereum_TxOptions - connection: Ethereum_Connection - ): String! - - estimateContractCallGas( - address: String! - method: String! - args: [String!] - options: Ethereum_TxOptions - connection: Ethereum_Connection - ): BigInt! - - callContractMethod( - address: String! - method: String! - args: [String!] - options: Ethereum_TxOptions - connection: Ethereum_Connection - ): Ethereum_TxResponse! - - callContractMethodAndWait( - address: String! - method: String! - args: [String!] - options: Ethereum_TxOptions - connection: Ethereum_Connection - ): Ethereum_TxReceipt! - - signMessage( - message: String! - connection: Ethereum_Connection - ): String! - - signMessageBytes( - bytes: Bytes! - connection: Ethereum_Connection - ): String! -} - -### Imported Modules END ### - -### Imported Objects START ### - -type Ethereum_Connection @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "Connection" -) { - node: String - networkNameOrChainId: String -} - -type Ethereum_TxOptions @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "TxOptions" -) { - """ - Gas supplied for the transaction - """ - gasLimit: BigInt - """ - The max total fee to pay per unit of gas. -The difference between maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is “refunded†to the user. -This property is ignored when gasPrice is not null. - """ - maxFeePerGas: BigInt - """ - The gas price paid is baseFeePerGas + maxPriorityFeePerGas. -The difference between maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is “refunded†to the user. -This property is ignored when gasPrice is not null. - """ - maxPriorityFeePerGas: BigInt - """ - The gas price for legacy transactions. -If this property is not null, a legacy transaction will be sent and maxFeePerGas and maxPriorityFeePerGas will be ignored. - """ - gasPrice: BigInt - """ - Ether value sent with transaction - """ - value: BigInt - """ - Override default nonce - """ - nonce: UInt32 -} - -type Ethereum_StaticTxResult @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "StaticTxResult" -) { - result: String! - error: Boolean! -} - -type Ethereum_Eip1559FeesEstimate @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "Eip1559FeesEstimate" -) { - maxFeePerGas: BigInt! - maxPriorityFeePerGas: BigInt! -} - -type Ethereum_TxRequest @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "TxRequest" -) { - to: String - from: String - data: String - type: UInt32 - chainId: BigInt - accessList: [Ethereum_AccessItem!] - """ - Gas supplied for the transaction - """ - gasLimit: BigInt - """ - The max total fee to pay per unit of gas. -The difference between maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is “refunded†to the user. -This property is ignored when gasPrice is not null. - """ - maxFeePerGas: BigInt - """ - The gas price paid is baseFeePerGas + maxPriorityFeePerGas. -The difference between maxFeePerGas and baseFeePerGas + maxPriorityFeePerGas is “refunded†to the user. -This property is ignored when gasPrice is not null. - """ - maxPriorityFeePerGas: BigInt - """ - The gas price for legacy transactions. -If this property is not null, a legacy transaction will be sent and maxFeePerGas and maxPriorityFeePerGas will be ignored. - """ - gasPrice: BigInt - """ - Ether value sent with transaction - """ - value: BigInt - """ - Override default nonce - """ - nonce: UInt32 -} - -type Ethereum_AccessItem @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "AccessItem" -) { - address: String! - storageKeys: [String!]! -} - -type Ethereum_TxReceipt @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "TxReceipt" -) { - to: String! - from: String! - contractAddress: String! - transactionIndex: UInt32! - root: String - gasUsed: BigInt! - logsBloom: String! - transactionHash: String! - logs: [Ethereum_Log!]! - blockNumber: BigInt! - blockHash: String! - confirmations: UInt32! - cumulativeGasUsed: BigInt! - effectiveGasPrice: BigInt! - type: UInt32! - status: UInt32 -} - -type Ethereum_Log @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "Log" -) { - blockNumber: BigInt! - blockHash: String! - transactionIndex: UInt32! - removed: Boolean! - address: String! - data: String! - topics: [String!]! - transactionHash: String! - logIndex: UInt32! -} - -type Ethereum_TxResponse @imported( - uri: "ens/wraps.eth:ethereum@1.0.0", - namespace: "Ethereum", - nativeType: "TxResponse" -) { - hash: String! - to: String - from: String! - nonce: UInt32! - gasLimit: BigInt! - maxFeePerGas: BigInt - maxPriorityFeePerGas: BigInt - gasPrice: BigInt - value: BigInt! - chainId: BigInt! - blockNumber: BigInt - blockHash: String - timestamp: UInt32 - r: String - s: String - v: UInt32 - type: UInt32 - accessList: [Ethereum_AccessItem!] -} - -### Imported Objects END ### - -### Imported Envs START ### - -### Imported Envs END ### - diff --git a/packages/test-cases/cases/cli/docgen/009-schema/expected/stdout.json b/packages/test-cases/cases/cli/docgen/009-schema/expected/stdout.json deleted file mode 100644 index a7621f6c30..0000000000 --- a/packages/test-cases/cases/cli/docgen/009-schema/expected/stdout.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "stdout": "Docs were generated successfully", - "exitCode": 0 -} diff --git a/packages/test-cases/cases/cli/docgen/009-schema/polywrap.build.yaml b/packages/test-cases/cases/cli/docgen/009-schema/polywrap.build.yaml deleted file mode 100644 index 479e3042fe..0000000000 --- a/packages/test-cases/cases/cli/docgen/009-schema/polywrap.build.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.2.0 -strategies: - image: - node_version: "16.13.0" - include: - - ./package.json -linked_packages: - - name: "@polywrap/wasm-as" - path: ../../../../../../wasm/as diff --git a/packages/test-cases/cases/cli/docgen/009-schema/polywrap.yaml b/packages/test-cases/cases/cli/docgen/009-schema/polywrap.yaml deleted file mode 100644 index ee9034f333..0000000000 --- a/packages/test-cases/cases/cli/docgen/009-schema/polywrap.yaml +++ /dev/null @@ -1,9 +0,0 @@ -format: 0.4.0 -project: - name: test-project - type: wasm/assemblyscript -source: - schema: ./schema.graphql - module: ./src/index.ts -extensions: - build: ./polywrap.build.yaml diff --git a/packages/test-cases/cases/cli/docgen/009-schema/schema.graphql b/packages/test-cases/cases/cli/docgen/009-schema/schema.graphql deleted file mode 100644 index 5d3415dd5b..0000000000 --- a/packages/test-cases/cases/cli/docgen/009-schema/schema.graphql +++ /dev/null @@ -1,35 +0,0 @@ -#import { Module } into Ethereum from "ens/wraps.eth:ethereum@1.0.0" - -type Module { - method( - str: String! - optStr: String - ): Object! -} - -type Object { - u: UInt! - array: [Boolean!]! - bytes: Bytes -} - -"""Test Comment""" -type Object2 { - """Test Comment""" - u: UInt! - """Test Comment""" - array: [Boolean!]! - """Test Comment""" - bytes: Bytes -} - -type Object3 { - u: UInt! - array: [Boolean!]! - bytes: Bytes -} - -enum test { - ARG1, - ARG2 -} diff --git a/packages/test-cases/cases/cli/docgen/009-schema/src/index.ts b/packages/test-cases/cases/cli/docgen/009-schema/src/index.ts deleted file mode 100644 index 5bb85ff3e4..0000000000 --- a/packages/test-cases/cases/cli/docgen/009-schema/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./wrap"; diff --git a/packages/test-cases/cases/cli/test/008-custom-config/config.ts b/packages/test-cases/cases/cli/test/008-custom-config/config.ts index 1d12fce783..f938e60c8d 100644 --- a/packages/test-cases/cases/cli/test/008-custom-config/config.ts +++ b/packages/test-cases/cases/cli/test/008-custom-config/config.ts @@ -1,11 +1,11 @@ -import { IClientConfigBuilder } from "@polywrap/client-config-builder-js"; +import { ClientConfigBuilder } from "@polywrap/client-config-builder-js"; import path from "path"; -export function configure(builder: IClientConfigBuilder): IClientConfigBuilder { +export function configure(builder: ClientConfigBuilder): ClientConfigBuilder { const wrapperPath = path.join(__dirname, "..", "run-test-wrapper"); const wrapperUri = `fs/${path.resolve(wrapperPath)}/build`; return builder - .addRedirect("wrap://ens/test.eth", wrapperUri) + .setRedirect("wrap://ens/test.eth", wrapperUri) .addEnv( wrapperUri, { diff --git a/packages/test-cases/index.ts b/packages/test-cases/index.ts index a6bea958a7..a11b08f25e 100644 --- a/packages/test-cases/index.ts +++ b/packages/test-cases/index.ts @@ -26,7 +26,7 @@ export async function fetchWrappers(): Promise { zip.extractAllTo(destination, /*overwrite*/ true); } - const tag = "0.1.0" + const tag = "0.2.0" const repoName = "wasm-test-harness" const url = `https://github.com/polywrap/${repoName}/releases/download/${tag}/wrappers`; diff --git a/packages/test-cases/package.json b/packages/test-cases/package.json index 30127a11d2..60910699bb 100644 --- a/packages/test-cases/package.json +++ b/packages/test-cases/package.json @@ -2,14 +2,14 @@ "name": "@polywrap/test-cases", "description": "Reusable Polywrap Test Cases", "private": true, - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "main": "index.ts", "scripts": { "generate:wrappers": "ts-node -e \"import { fetchWrappers } from './'; (async () => await fetchWrappers())()\"" }, "dependencies": { - "@polywrap/os-js": "0.10.6" + "@polywrap/os-js": "0.11.0-pre.4" }, "devDependencies": { "@types/adm-zip": "0.5.0", diff --git a/packages/test-cases/yarn.lock b/packages/test-cases/yarn.lock deleted file mode 100644 index 3a95d739de..0000000000 --- a/packages/test-cases/yarn.lock +++ /dev/null @@ -1,338 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@cspotcode/source-map-support@^0.8.0": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" - integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== - dependencies: - "@jridgewell/trace-mapping" "0.3.9" - -"@jridgewell/resolve-uri@^3.0.3": - version "3.1.1" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz#c08679063f279615a3326583ba3a90d1d82cc721" - integrity sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA== - -"@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.15" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" - integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== - -"@jridgewell/trace-mapping@0.3.9": - version "0.3.9" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" - integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@polywrap/os-js@0.10.5": - version "0.10.5" - resolved "https://registry.yarnpkg.com/@polywrap/os-js/-/os-js-0.10.5.tgz#b9ecae978f69edc341aedec1867161d1e609eb3a" - integrity sha512-Xh7KqCQy2aEoHDGQE5eV2ykCDjhCRzUVryiF+P/HbfxG//bW6Wte4e97H4tcuD8RkApYVaGjmUTAlvX+g+26AQ== - -"@tsconfig/node10@^1.0.7": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" - integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== - -"@tsconfig/node12@^1.0.7": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" - integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== - -"@tsconfig/node14@^1.0.0": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" - integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== - -"@tsconfig/node16@^1.0.2": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.4.tgz#0b92dcc0cc1c81f6f306a381f28e31b1a56536e9" - integrity sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA== - -"@types/adm-zip@0.5.0": - version "0.5.0" - resolved "https://registry.yarnpkg.com/@types/adm-zip/-/adm-zip-0.5.0.tgz#94c90a837ce02e256c7c665a6a1eb295906333c1" - integrity sha512-FCJBJq9ODsQZUNURo5ILAQueuA8WJhRvuihS3ke2iI25mJlfV2LK8jG2Qj2z2AWg8U0FtWWqBHVRetceLskSaw== - dependencies: - "@types/node" "*" - -"@types/glob@*": - version "8.1.0" - resolved "https://registry.yarnpkg.com/@types/glob/-/glob-8.1.0.tgz#b63e70155391b0584dce44e7ea25190bbc38f2fc" - integrity sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w== - dependencies: - "@types/minimatch" "^5.1.2" - "@types/node" "*" - -"@types/minimatch@^5.1.2": - version "5.1.2" - resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca" - integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA== - -"@types/node@*": - version "20.3.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.3.2.tgz#fa6a90f2600e052a03c18b8cb3fd83dd4e599898" - integrity sha512-vOBLVQeCQfIcF/2Y7eKFTqrMnizK5lRNQ7ykML/5RuwVXVWxYkgwS7xbt4B6fKCUPgbSL5FSsjHQpaGQP/dQmw== - -"@types/shelljs@0.8.9": - version "0.8.9" - resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.8.9.tgz#45dd8501aa9882976ca3610517dac3831c2fbbf4" - integrity sha512-flVe1dvlrCyQJN/SGrnBxqHG+RzXrVKsmjD8WS/qYHpq5UPjfq7UWFBENP0ZuOl0g6OpAlL6iBoLSvKYUUmyQw== - dependencies: - "@types/glob" "*" - "@types/node" "*" - -acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - -acorn@^8.4.1: - version "8.9.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.9.0.tgz#78a16e3b2bcc198c10822786fa6679e245db5b59" - integrity sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ== - -adm-zip@0.5.10: - version "0.5.10" - resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.5.10.tgz#4a51d5ab544b1f5ce51e1b9043139b639afff45b" - integrity sha512-x0HvcHqVJNTPk/Bw8JbLWlWoo6Wwnsug0fnYYro1HBrjxZ3G7/AZk7Ahv8JwDe1uIcz8eBqvu86FuF1POiG7vQ== - -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - -axios@1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.2.2.tgz#72681724c6e6a43a9fea860fc558127dbe32f9f1" - integrity sha512-bz/J4gS2S3I7mpN/YZfGFTqhXTYzRho8Ay38w2otuuDR322KzFIWm/4W2K6gIwvWaws5n+mnb7D1lN9uD+QH6Q== - dependencies: - follow-redirects "^1.15.0" - form-data "^4.0.0" - proxy-from-env "^1.1.0" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -create-require@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -follow-redirects@^1.15.0: - version "1.15.2" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" - integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== - -form-data@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" - integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -fs.realpath@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== - -function-bind@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" - integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== - -glob@^7.0.0: - version "7.2.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" - integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.1.1" - once "^1.3.0" - path-is-absolute "^1.0.0" - -has@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" - integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== - dependencies: - function-bind "^1.1.1" - -inflight@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== - dependencies: - once "^1.3.0" - wrappy "1" - -inherits@2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" - integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - -interpret@^1.0.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e" - integrity sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA== - -is-core-module@^2.11.0: - version "2.12.1" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.12.1.tgz#0c0b6885b6f80011c71541ce15c8d66cf5a4f9fd" - integrity sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg== - dependencies: - has "^1.0.3" - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -minimatch@^3.1.1: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -once@^1.3.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== - dependencies: - wrappy "1" - -path-is-absolute@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== - -path-parse@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" - integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== - -proxy-from-env@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" - integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== - -rechoir@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" - integrity sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw== - dependencies: - resolve "^1.1.6" - -resolve@^1.1.6: - version "1.22.2" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.2.tgz#0ed0943d4e301867955766c9f3e1ae6d01c6845f" - integrity sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g== - dependencies: - is-core-module "^2.11.0" - path-parse "^1.0.7" - supports-preserve-symlinks-flag "^1.0.0" - -shelljs@0.8.5: - version "0.8.5" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c" - integrity sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow== - dependencies: - glob "^7.0.0" - interpret "^1.0.0" - rechoir "^0.6.2" - -supports-preserve-symlinks-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" - integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== - -ts-node@10.9.1: - version "10.9.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" - integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== - dependencies: - "@cspotcode/source-map-support" "^0.8.0" - "@tsconfig/node10" "^1.0.7" - "@tsconfig/node12" "^1.0.7" - "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.2" - acorn "^8.4.1" - acorn-walk "^8.1.1" - arg "^4.1.0" - create-require "^1.1.0" - diff "^4.0.1" - make-error "^1.1.1" - v8-compile-cache-lib "^3.0.1" - yn "3.1.1" - -v8-compile-cache-lib@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" - integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== - -wrappy@1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q== diff --git a/packages/wasm/as/package.json b/packages/wasm/as/package.json index 3048d214de..f6e8d828d8 100644 --- a/packages/wasm/as/package.json +++ b/packages/wasm/as/package.json @@ -1,7 +1,7 @@ { "name": "@polywrap/wasm-as", "description": "Polywrap Assemblyscript Runtime", - "version": "0.10.6", + "version": "0.11.0-pre.4", "license": "MIT", "repository": { "type": "git", diff --git a/packages/wasm/rs/Cargo.toml b/packages/wasm/rs/Cargo.toml index 0ed1e58807..eae5b9bee7 100644 --- a/packages/wasm/rs/Cargo.toml +++ b/packages/wasm/rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "polywrap-wasm-rs" -version = "0.10.6" +version = "0.11.0-pre.4" license = "MIT" description = "Polywrap's Rust-Wasm Runtime" homepage = "https://polywrap.io" diff --git a/scripts/patch-peer-deps.ts b/scripts/patch-peer-deps.ts index 7e8538c8b1..b9d386e7bf 100644 --- a/scripts/patch-peer-deps.ts +++ b/scripts/patch-peer-deps.ts @@ -3,8 +3,7 @@ import path from "path"; const packagesToPatch = [ "@polywrap/concurrent-plugin-js", - "@polywrap/ethereum-provider-js-v1", - "@polywrap/ethereum-provider-js", + "@polywrap/ethereum-wallet-js", "@polywrap/file-system-plugin-js", "@polywrap/http-plugin-js", "@polywrap/logger-plugin-js", diff --git a/yarn.lock b/yarn.lock index 8c54b48b48..f98aed85d0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -113,52 +113,52 @@ dependencies: "@babel/highlight" "^7.22.5" -"@babel/compat-data@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.22.5.tgz#b1f6c86a02d85d2dd3368a2b67c09add8cd0c255" - integrity sha512-4Jc/YuIaYqKnDDz892kPIledykKg12Aw1PYX5i/TY28anJtacvM1Rrr8wbieB9GfEJwlzqT0hUEao0CxEebiDA== +"@babel/compat-data@^7.22.9": + version "7.22.9" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.22.9.tgz#71cdb00a1ce3a329ce4cbec3a44f9fef35669730" + integrity sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ== "@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.7.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.22.5.tgz#d67d9747ecf26ee7ecd3ebae1ee22225fe902a89" - integrity sha512-SBuTAjg91A3eKOvD+bPEz3LlhHZRNu1nFOVts9lzDJTXshHTjII0BAtDS3Y2DAkdZdDKWVZGVwkDfc4Clxn1dg== + version "7.22.9" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.22.9.tgz#bd96492c68822198f33e8a256061da3cf391f58f" + integrity sha512-G2EgeufBcYw27U4hhoIwFcgc1XU7TlXJ3mv04oOv1WCuo900U/anZSPzEqNjwdjgffkk2Gs0AN0dW1CKVLcG7w== dependencies: "@ampproject/remapping" "^2.2.0" "@babel/code-frame" "^7.22.5" - "@babel/generator" "^7.22.5" - "@babel/helper-compilation-targets" "^7.22.5" - "@babel/helper-module-transforms" "^7.22.5" - "@babel/helpers" "^7.22.5" - "@babel/parser" "^7.22.5" + "@babel/generator" "^7.22.9" + "@babel/helper-compilation-targets" "^7.22.9" + "@babel/helper-module-transforms" "^7.22.9" + "@babel/helpers" "^7.22.6" + "@babel/parser" "^7.22.7" "@babel/template" "^7.22.5" - "@babel/traverse" "^7.22.5" + "@babel/traverse" "^7.22.8" "@babel/types" "^7.22.5" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" json5 "^2.2.2" - semver "^6.3.0" + semver "^6.3.1" -"@babel/generator@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.22.5.tgz#1e7bf768688acfb05cf30b2369ef855e82d984f7" - integrity sha512-+lcUbnTRhd0jOewtFSedLyiPsD5tswKkbgcezOqqWFUVNEwoUTlpPOBmvhG7OXWLR4jMdv0czPGH5XbflnD1EA== +"@babel/generator@^7.22.7", "@babel/generator@^7.22.9": + version "7.22.9" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.22.9.tgz#572ecfa7a31002fa1de2a9d91621fd895da8493d" + integrity sha512-KtLMbmicyuK2Ak/FTCJVbDnkN1SlT8/kceFTiuDiiRUUSMnHMidxSCdG4ndkTOHHpoomWe/4xkvHkEOncwjYIw== dependencies: "@babel/types" "^7.22.5" "@jridgewell/gen-mapping" "^0.3.2" "@jridgewell/trace-mapping" "^0.3.17" jsesc "^2.5.1" -"@babel/helper-compilation-targets@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.5.tgz#fc7319fc54c5e2fa14b2909cf3c5fd3046813e02" - integrity sha512-Ji+ywpHeuqxB8WDxraCiqR0xfhYjiDE/e6k7FuIaANnoOFxAHskHChz4vA1mJC9Lbm01s1PVAGhQY4FUKSkGZw== +"@babel/helper-compilation-targets@^7.22.9": + version "7.22.9" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.9.tgz#f9d0a7aaaa7cd32a3f31c9316a69f5a9bcacb892" + integrity sha512-7qYrNM6HjpnPHJbopxmb8hSPoZ0gsX8IvUS32JGVoy+pU9e5N0nLr1VjJoR6kA4d9dmGLxNYOjeB8sUDal2WMw== dependencies: - "@babel/compat-data" "^7.22.5" + "@babel/compat-data" "^7.22.9" "@babel/helper-validator-option" "^7.22.5" - browserslist "^4.21.3" + browserslist "^4.21.9" lru-cache "^5.1.1" - semver "^6.3.0" + semver "^6.3.1" "@babel/helper-environment-visitor@^7.22.5": version "7.22.5" @@ -187,19 +187,16 @@ dependencies: "@babel/types" "^7.22.5" -"@babel/helper-module-transforms@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.22.5.tgz#0f65daa0716961b6e96b164034e737f60a80d2ef" - integrity sha512-+hGKDt/Ze8GFExiVHno/2dvG5IdstpzCq0y4Qc9OJ25D4q3pKfiIP/4Vp3/JvhDkLKsDK2api3q3fpIgiIF5bw== +"@babel/helper-module-transforms@^7.22.9": + version "7.22.9" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.22.9.tgz#92dfcb1fbbb2bc62529024f72d942a8c97142129" + integrity sha512-t+WA2Xn5K+rTeGtC8jCsdAH52bjggG5TKRuRrAGNM/mjIbO4GxvlLMFOEz9wXY5I2XQ60PMFsAG2WIcG82dQMQ== dependencies: "@babel/helper-environment-visitor" "^7.22.5" "@babel/helper-module-imports" "^7.22.5" "@babel/helper-simple-access" "^7.22.5" - "@babel/helper-split-export-declaration" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" "@babel/helper-validator-identifier" "^7.22.5" - "@babel/template" "^7.22.5" - "@babel/traverse" "^7.22.5" - "@babel/types" "^7.22.5" "@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.8.0": version "7.22.5" @@ -213,10 +210,10 @@ dependencies: "@babel/types" "^7.22.5" -"@babel/helper-split-export-declaration@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.5.tgz#88cf11050edb95ed08d596f7a044462189127a08" - integrity sha512-thqK5QFghPKWLhAV321lxF95yCg2K3Ob5yw+M3VHWfdia0IkPXUtoLH8x/6Fh486QUvzhb8YOWHChTVen2/PoQ== +"@babel/helper-split-export-declaration@^7.22.6": + version "7.22.6" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.6.tgz#322c61b7310c0997fe4c323955667f18fcefb91c" + integrity sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g== dependencies: "@babel/types" "^7.22.5" @@ -235,13 +232,13 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz#de52000a15a177413c8234fa3a8af4ee8102d0ac" integrity sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw== -"@babel/helpers@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.22.5.tgz#74bb4373eb390d1ceed74a15ef97767e63120820" - integrity sha512-pSXRmfE1vzcUIDFQcSGA5Mr+GxBV9oiRKDuDxXvWQQBCh8HoIjs/2DlDB7H8smac1IVrB9/xdXj2N3Wol9Cr+Q== +"@babel/helpers@^7.22.6": + version "7.22.6" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.22.6.tgz#8e61d3395a4f0c5a8060f309fb008200969b5ecd" + integrity sha512-YjDs6y/fVOYFV8hAf1rxd1QvR9wJe1pDBZ2AREKq/SDayfPzgk0PBnVuTCE5X1acEpMMNOVUqoe+OwiZGJ+OaA== dependencies: "@babel/template" "^7.22.5" - "@babel/traverse" "^7.22.5" + "@babel/traverse" "^7.22.6" "@babel/types" "^7.22.5" "@babel/highlight@^7.22.5": @@ -253,10 +250,10 @@ chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.5.tgz#721fd042f3ce1896238cf1b341c77eb7dee7dbea" - integrity sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.22.5", "@babel/parser@^7.22.7": + version "7.22.7" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.7.tgz#df8cf085ce92ddbdbf668a7f186ce848c9036cae" + integrity sha512-7NF8pOkHP5o2vpmGgNGcfAeCvOYhGLyA3Z4eBQkT1RJlWu47n63bCs93QfJ2hIAFCil7L5P2IWhs1oToVgrL0Q== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -351,18 +348,18 @@ "@babel/parser" "^7.22.5" "@babel/types" "^7.22.5" -"@babel/traverse@^7.1.0", "@babel/traverse@^7.22.5": - version "7.22.5" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.22.5.tgz#44bd276690db6f4940fdb84e1cb4abd2f729ccd1" - integrity sha512-7DuIjPgERaNo6r+PZwItpjCZEa5vyw4eJGufeLxrPdBXBoLcCJCIasvK6pK/9DVNrLZTLFhUGqaC6X/PA007TQ== +"@babel/traverse@^7.1.0", "@babel/traverse@^7.22.6", "@babel/traverse@^7.22.8": + version "7.22.8" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.22.8.tgz#4d4451d31bc34efeae01eac222b514a77aa4000e" + integrity sha512-y6LPR+wpM2I3qJrsheCTwhIinzkETbplIgPBbwvqPKc+uljeA5gP+3nP8irdYt1mjQaDnlIcG+dw8OjAco4GXw== dependencies: "@babel/code-frame" "^7.22.5" - "@babel/generator" "^7.22.5" + "@babel/generator" "^7.22.7" "@babel/helper-environment-visitor" "^7.22.5" "@babel/helper-function-name" "^7.22.5" "@babel/helper-hoist-variables" "^7.22.5" - "@babel/helper-split-export-declaration" "^7.22.5" - "@babel/parser" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.6" + "@babel/parser" "^7.22.7" "@babel/types" "^7.22.5" debug "^4.1.0" globals "^11.1.0" @@ -1858,11 +1855,6 @@ resolved "https://registry.yarnpkg.com/@msgpack/msgpack/-/msgpack-2.7.2.tgz#f34b8aa0c49f0dd55eb7eba577081299cbf3f90b" integrity sha512-rYEi46+gIzufyYUAoHDnRzkWGxajpD9vVXFQ3g1vbjrBm6P7MBmm+s/fqPa46sxa+8FOUdEuRQKaugo5a4JWpw== -"@multiformats/base-x@^4.0.1": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@multiformats/base-x/-/base-x-4.0.1.tgz#95ff0fa58711789d53aefb2590a8b7a4e715d121" - integrity sha512-eMk0b9ReBbV23xXU693TAIrLyeO5iTgBZGSJfpqriG8UkYvr/hC9u9pyMlAakDNHWmbhMZCDs6KQO0jzKD8OTw== - "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -2149,195 +2141,121 @@ resolved "https://registry.yarnpkg.com/@opentelemetry/semantic-conventions/-/semantic-conventions-1.6.0.tgz#ed410c9eb0070491cff9fe914246ce41f88d6f74" integrity sha512-aPfcBeLErM/PPiAuAbNFLN5sNbZLc3KZlar27uohllN8Zs6jJbHyJU1y7cMA6W/zuq+thkaG8mujiS+3iD/FWQ== -"@polywrap/asyncify-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/asyncify-js/-/asyncify-js-0.10.0.tgz#0570ce34501e91710274285b6b4740f1094f08a3" - integrity sha512-/ZhREKykF1hg5H/mm8vQHqv7MSedfCnwzbsNwYuLmH/IUtQi2t7NyD2XXavSLq5PFOHA/apPueatbSFTeIgBdA== - -"@polywrap/asyncify-js@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/asyncify-js/-/asyncify-js-0.10.1.tgz#00d656a39bfd54c1b8af82adf648264b0415259b" - integrity sha512-qXD2GNAoG18sDLPOtN3bbdEJUM+5hhII2EJkcAREJSBpi4g7yFxlySz/qQGzDnlIRNl9MGNgaf+TYbpQnNBeLw== - -"@polywrap/client-config-builder-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/client-config-builder-js/-/client-config-builder-js-0.10.0.tgz#e583f32dca97dfe0b9575db244fdad74a4f42d6f" - integrity sha512-9hZd5r/5rkLoHdeB76NDUNOYcUCzS+b8WjCI9kv5vNQiOR83dZnW3rTnQmcXOWWErRY70h6xvAQWWQ1WrW/SpQ== - dependencies: - "@polywrap/concurrent-plugin-js" "~0.10.0-pre" - "@polywrap/core-js" "0.10.0" - "@polywrap/ethereum-provider-js" "npm:@polywrap/ethereum-provider-js@~0.3.0" - "@polywrap/ethereum-provider-js-v1" "npm:@polywrap/ethereum-provider-js@~0.2.4" - "@polywrap/file-system-plugin-js" "~0.10.0-pre" - "@polywrap/http-plugin-js" "~0.10.0-pre" - "@polywrap/logger-plugin-js" "0.10.0-pre.10" - "@polywrap/uri-resolver-extensions-js" "0.10.0" - "@polywrap/uri-resolvers-js" "0.10.0" - "@polywrap/wasm-js" "0.10.0" - base64-to-uint8array "1.0.0" - -"@polywrap/client-config-builder-js@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/client-config-builder-js/-/client-config-builder-js-0.10.1.tgz#d52430645b4530b235f97318ccdeef256eb4c425" - integrity sha512-cXQXe+u+r9WVCovp507FmERWWFa6OJSl8ZQd3QpKnIaNeBmXbAa4WoM5889VTPe2oe5iDgo4jR4U/fHBg8qoyQ== - dependencies: - "@polywrap/concurrent-plugin-js" "~0.10.0" - "@polywrap/core-js" "0.10.1" - "@polywrap/ethereum-provider-js" "npm:@polywrap/ethereum-provider-js@~0.3.1" - "@polywrap/ethereum-provider-js-v1" "npm:@polywrap/ethereum-provider-js@~0.2.4" - "@polywrap/file-system-plugin-js" "~0.10.0" - "@polywrap/http-plugin-js" "~0.10.0" - "@polywrap/logger-plugin-js" "~0.10.1" - "@polywrap/uri-resolver-extensions-js" "0.10.1" - "@polywrap/uri-resolvers-js" "0.10.1" - "@polywrap/wasm-js" "0.10.1" - base64-to-uint8array "1.0.0" - -"@polywrap/client-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/client-js/-/client-js-0.10.0.tgz#607c24cd65c03f57ca8325f4a8ecc02a5485c993" - integrity sha512-wRr4HZ7a4oLrKuw8CchM5JYcE8er43GGKQnhtf/ylld5Q7FpNpfzhsi8eWknORugQYuvR3CSG7qZey4Ijgj6qQ== - dependencies: - "@polywrap/client-config-builder-js" "0.10.0" - "@polywrap/core-client-js" "0.10.0" - "@polywrap/core-js" "0.10.0" - "@polywrap/msgpack-js" "0.10.0" - "@polywrap/plugin-js" "0.10.0" - "@polywrap/result" "0.10.0" - "@polywrap/tracing-js" "0.10.0" - "@polywrap/uri-resolver-extensions-js" "0.10.0" - "@polywrap/uri-resolvers-js" "0.10.0" - "@polywrap/wrap-manifest-types-js" "0.10.0" - -"@polywrap/client-js@~0.10.0": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/client-js/-/client-js-0.10.1.tgz#d324420b1558d7fb47c6928042c083eef7b3b6f6" - integrity sha512-xIZoGOPPS+J2RjiyEF8A8huMIr0IyN+VEwHWcCUdp7NxTQ1xmve1lxQfbbdE0BC37o5Ni7lJwiIXmAUfhuMyGg== - dependencies: - "@polywrap/client-config-builder-js" "0.10.1" - "@polywrap/core-client-js" "0.10.1" - "@polywrap/core-js" "0.10.1" - "@polywrap/msgpack-js" "0.10.1" - "@polywrap/plugin-js" "0.10.1" - "@polywrap/result" "0.10.1" - "@polywrap/tracing-js" "0.10.1" - "@polywrap/uri-resolver-extensions-js" "0.10.1" - "@polywrap/uri-resolvers-js" "0.10.1" - "@polywrap/wrap-manifest-types-js" "0.10.1" - -"@polywrap/concurrent-plugin-js@~0.10.0", "@polywrap/concurrent-plugin-js@~0.10.0-pre": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/concurrent-plugin-js/-/concurrent-plugin-js-0.10.0.tgz#662e49976f75f30632b302d515bd22c7643afc44" - integrity sha512-sc11ffs34ScBHPB9uHFZuTmF8yPtZT81sBpBj7f4MlmrRDxtJS56Y7k/qL6L1xuwsnmeFipi5JGau1CcBaYmJQ== - dependencies: - "@polywrap/core-js" "0.10.0" - "@polywrap/msgpack-js" "0.10.0" - "@polywrap/plugin-js" "0.10.0" +"@polywrap/asyncify-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/asyncify-js/-/asyncify-js-0.12.0.tgz#8a7425f021b23e7301cd42955950b1d99673e3a7" + integrity sha512-gIom6pyz6MkE42BvFIAJH+DmCyv3oG8mZXpAx4H0oi34CLW4itzluN0uvkUmNZ744P1c5wMiQOMaCnXqTBZS2A== -"@polywrap/core-client-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/core-client-js/-/core-client-js-0.10.0.tgz#bec91479d1294ca86b7fa77f5ed407dab4d2a0b4" - integrity sha512-Sv1fVHM/5ynobtT2N25jbXOKNju1y0Wk4TwFnTJXrAUcARrRMoAfmwLVfTwrqRZ2OjWMQ/AWTc7ziNBtH5dNAg== - dependencies: - "@polywrap/core-js" "0.10.0" - "@polywrap/msgpack-js" "0.10.0" - "@polywrap/result" "0.10.0" - "@polywrap/tracing-js" "0.10.0" - "@polywrap/wrap-manifest-types-js" "0.10.0" - -"@polywrap/core-client-js@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/core-client-js/-/core-client-js-0.10.1.tgz#7342adfcffe2ce97ce7066c4c8ae1fc54250cb4f" - integrity sha512-ew5B4nNTgzgzqt8KZE06bclhqUrfZbA0D9n2BlyQ4+RfiSTQFoqoN8jN53TuHRFJRmt0v/a/RPRvKujF5mMf9g== - dependencies: - "@polywrap/core-js" "0.10.1" - "@polywrap/msgpack-js" "0.10.1" - "@polywrap/result" "0.10.1" - "@polywrap/tracing-js" "0.10.1" - "@polywrap/wrap-manifest-types-js" "0.10.1" - -"@polywrap/core-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/core-js/-/core-js-0.10.0.tgz#5ddc31ff47019342659a2208eec05299b072b216" - integrity sha512-fx9LqRFnxAxLOhDK4M+ymrxMnXQbwuNPMLjCk5Ve5CPa9RFms0/Fzvj5ayMLidZSPSt/dLISkbDgW44vfv6wwA== +"@polywrap/client-config-builder-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/client-config-builder-js/-/client-config-builder-js-0.12.0.tgz#24dae5e133442a80de84f02d71e171bd5d5389bd" + integrity sha512-hWs8G0sTBckumvDjsxDymxrE5ggxmYE6kSYoMBtPvPY5Va5y9ElEJAdTtBTlELIugs6/f/3EHLzPyIdwaYaB/Q== + dependencies: + "@polywrap/config-bundle-types-js" "0.12.0" + "@polywrap/core-js" "0.12.0" + "@polywrap/plugin-js" "0.12.0" + "@polywrap/sys-config-bundle-js" "0.12.0" + "@polywrap/uri-resolver-extensions-js" "0.12.0" + "@polywrap/uri-resolvers-js" "0.12.0" + "@polywrap/wasm-js" "0.12.0" + "@polywrap/web3-config-bundle-js" "0.12.0" + +"@polywrap/client-js@0.12.0", "@polywrap/client-js@~0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/client-js/-/client-js-0.12.0.tgz#c57348f5a760311fcd682b663be4a2a6edfe860b" + integrity sha512-ACdjwA+l3udCgpbDZlRiTzvQftajmb0OFLDZ0KzD/iLFqbNksMp1rFb4Cju3wKKVww6WB48pusgnBWFTdXP2Pw== + dependencies: + "@polywrap/client-config-builder-js" "0.12.0" + "@polywrap/core-client-js" "0.12.0" + "@polywrap/core-js" "0.12.0" + "@polywrap/msgpack-js" "0.12.0" + "@polywrap/plugin-js" "0.12.0" + "@polywrap/result" "0.12.0" + "@polywrap/tracing-js" "0.12.0" + "@polywrap/uri-resolver-extensions-js" "0.12.0" + "@polywrap/uri-resolvers-js" "0.12.0" + "@polywrap/wrap-manifest-types-js" "0.12.0" + +"@polywrap/concurrent-plugin-js@~0.12.0-pre.0": + version "0.12.0-pre.0" + resolved "https://registry.yarnpkg.com/@polywrap/concurrent-plugin-js/-/concurrent-plugin-js-0.12.0-pre.0.tgz#0cd41ff41c2be2f555432bd514392ed8e8448889" + integrity sha512-0+DJ9KO0oX+JxIC5UxNWmaXS6IH6mNUOh1bpMM34jaL+QUXjehZVtwnNpifFsaKd71Xf5DkozAkn3mSDscUgFw== + dependencies: + "@polywrap/core-js" "~0.12.0-pre.0" + "@polywrap/msgpack-js" "~0.12.0-pre.0" + "@polywrap/plugin-js" "~0.12.0-pre.0" + +"@polywrap/config-bundle-types-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/config-bundle-types-js/-/config-bundle-types-js-0.12.0.tgz#fa8d023d470c1d793526339514e4bd59a2e3c518" + integrity sha512-JDihS10m+ncE42QZSP7ujuz4S9ZsSQsUPOZbyhqCZ6sw5LCmCxuR5ogVX6uF9Visd5L92ylQsoxFQk/jLoo0iQ== dependencies: - "@polywrap/result" "0.10.0" - "@polywrap/tracing-js" "0.10.0" - "@polywrap/wrap-manifest-types-js" "0.10.0" + "@polywrap/core-js" "0.12.0" -"@polywrap/core-js@0.10.0-pre.10": - version "0.10.0-pre.10" - resolved "https://registry.yarnpkg.com/@polywrap/core-js/-/core-js-0.10.0-pre.10.tgz#3209dbcd097d3533574f1231c10ef633c2466d5c" - integrity sha512-a/1JtfrHafRh2y0XgK5dNc82gVzjCbXSdKof7ojDghCSRSHUxTw/cJ+pcLrPJhrsTi7VfTM0BFjw3/wC5RutuA== +"@polywrap/core-client-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/core-client-js/-/core-client-js-0.12.0.tgz#8e032bd11dc9608b1b14d371222a53041a4643dc" + integrity sha512-jHDVlBPGujhBbhJ5IjZwc+W4UfdMRc3xZ9RqOkJxp0MG7QFjiBoHhY/UHNNDMahXg7mWxpU1nZyCzcIx+/hO8w== dependencies: - "@polywrap/result" "0.10.0-pre.10" - "@polywrap/tracing-js" "0.10.0-pre.10" - "@polywrap/wrap-manifest-types-js" "0.10.0-pre.10" + "@polywrap/core-js" "0.12.0" + "@polywrap/msgpack-js" "0.12.0" + "@polywrap/result" "0.12.0" + "@polywrap/tracing-js" "0.12.0" + "@polywrap/wrap-manifest-types-js" "0.12.0" -"@polywrap/core-js@0.10.1", "@polywrap/core-js@~0.10.0": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/core-js/-/core-js-0.10.1.tgz#09405c745f591d5f7ec243db95a61540a05296cb" - integrity sha512-BJpWDikfd/6h64Lf7FKy0g5O3a5OKaL915boni1pHP54wF4xBWdHkKixLGD8w4BZWRiW9v42PpYBhWqYZwSNGg== +"@polywrap/core-js@0.12.0", "@polywrap/core-js@~0.12.0", "@polywrap/core-js@~0.12.0-pre.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/core-js/-/core-js-0.12.0.tgz#ec68d6d6489df55bfa7a6bc0d5910a5ff9eb157a" + integrity sha512-wWQQ/pb+A4bM3U9bF6pVvwlKWLjF1nkbO3pJ5AKoHIe/5glFYAM/zCq/CTZlTsFzpNsczcru0mbQY5C8wK8aOw== dependencies: - "@polywrap/result" "0.10.1" - "@polywrap/tracing-js" "0.10.1" - "@polywrap/wrap-manifest-types-js" "0.10.1" + "@polywrap/result" "0.12.0" + "@polywrap/tracing-js" "0.12.0" + "@polywrap/wrap-manifest-types-js" "0.12.0" -"@polywrap/ethereum-provider-js-v1@npm:@polywrap/ethereum-provider-js@~0.2.4": - version "0.2.4" - resolved "https://registry.yarnpkg.com/@polywrap/ethereum-provider-js/-/ethereum-provider-js-0.2.4.tgz#3df1a6548da191618bb5cae7928c7427e69e0030" - integrity sha512-64xRnniboxxHNZ4/gD6SS4T+QmJPUMbIYZ2hyLODb2QgH3qDBiU+i4gdiQ/BL3T8Sn/0iOxvTIgZalVDJRh2iw== +"@polywrap/datetime-plugin-js@~0.12.0-pre.0": + version "0.12.0-pre.0" + resolved "https://registry.yarnpkg.com/@polywrap/datetime-plugin-js/-/datetime-plugin-js-0.12.0-pre.0.tgz#72fa082e6485e1fc259c48fe89a351d69272ae0b" + integrity sha512-BKE5gZlL8LlVl9WSodkdFnIBSkKM4QSxYdTR5JhpMOPiStHFLqsZWQPCpgtRtTy+pyK/rdXxfKihoL5P9ee6oQ== dependencies: - "@ethersproject/address" "5.7.0" - "@ethersproject/providers" "5.7.0" - "@polywrap/core-js" "0.10.0-pre.10" - "@polywrap/plugin-js" "0.10.0-pre.10" - ethers "5.7.0" + "@polywrap/core-js" "~0.12.0-pre.0" + "@polywrap/plugin-js" "~0.12.0-pre.0" -"@polywrap/ethereum-provider-js@npm:@polywrap/ethereum-provider-js@~0.3.0", "@polywrap/ethereum-provider-js@npm:@polywrap/ethereum-provider-js@~0.3.1": - version "0.3.1" - resolved "https://registry.yarnpkg.com/@polywrap/ethereum-provider-js/-/ethereum-provider-js-0.3.1.tgz#ffdb9425c819ee76d3e3d5ade7d1b044077037e0" - integrity sha512-El2d3gE2CFdGNzKQhO+IPP79lhyQmkAGlpQadaW/EDyFDjERLckYDLPrwUCXG0agUcQZcNY1nHn2hknumw/yWg== +"@polywrap/ethereum-wallet-js@~0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@polywrap/ethereum-wallet-js/-/ethereum-wallet-js-0.1.0.tgz#1af5800aab3c4cedfcd1e4e5e305d5d5ef733bea" + integrity sha512-GTg4X0gyFHXNAHSDxe6QfiWJv8z/pwobnVyKw4rcmBLw7tqcTiYXk4kU0QfWV3JLV/8rvzESl+FtXPC68dUMIA== dependencies: "@ethersproject/address" "5.7.0" "@ethersproject/providers" "5.7.0" - "@polywrap/core-js" "0.10.0" - "@polywrap/plugin-js" "0.10.0" + "@polywrap/core-js" "~0.12.0-pre.0" + "@polywrap/plugin-js" "~0.12.0-pre.0" ethers "5.7.0" -"@polywrap/file-system-plugin-js@~0.10.0", "@polywrap/file-system-plugin-js@~0.10.0-pre": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/file-system-plugin-js/-/file-system-plugin-js-0.10.0.tgz#7814e0b1c0bb170ab85500f67aca6af4c17ec19f" - integrity sha512-QWDpeVBACeK8PqZUwby/zlozG/07fpvJN5kQtw5e7ha4K5blX1j1i6ixgLKlYyQsaaTBxS6aAF3C0ryt4BsJcQ== +"@polywrap/file-system-plugin-js@~0.12.0-pre.0": + version "0.12.0-pre.0" + resolved "https://registry.yarnpkg.com/@polywrap/file-system-plugin-js/-/file-system-plugin-js-0.12.0-pre.0.tgz#ca6395d36c65b9a185f63233ce31c82578b9dc81" + integrity sha512-qu1lLoZQhf8tSz9844tjI6d1ndyjrXpQ+P4ZPIKGtPFVnUOLwtVJCfE9eQtY4MAMz/yRBJ9saWEuaoZHI7zUXg== dependencies: - "@polywrap/core-js" "0.10.0" - "@polywrap/plugin-js" "0.10.0" + "@polywrap/core-js" "~0.12.0-pre.0" + "@polywrap/plugin-js" "~0.12.0-pre.0" -"@polywrap/http-plugin-js@~0.10.0", "@polywrap/http-plugin-js@~0.10.0-pre": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/http-plugin-js/-/http-plugin-js-0.10.0.tgz#930ec9dbaa762b71d8905ad02a77d5d574707642" - integrity sha512-t/yvoOAGUwsuS37ZQkkBZOogNbeJadtHwitMMA6XGs1jDANP1Xim/xWXWBYC3W1YJ8pbUeO8bHZHTBaJ7SC0cA== +"@polywrap/http-plugin-js@~0.12.0-pre.0": + version "0.12.0-pre.0" + resolved "https://registry.yarnpkg.com/@polywrap/http-plugin-js/-/http-plugin-js-0.12.0-pre.0.tgz#7e276c5ffd62500b0736444bd95862b133e809b9" + integrity sha512-kB6gwMliDjaoKMIWSetLBusV8QXiAwFbw6dDhiTKhIBkVFSWRdRWLbA2VY3apnSeXkrbwfTX6iIgxS9D8LoOrw== dependencies: - "@polywrap/core-js" "0.10.0" - "@polywrap/plugin-js" "0.10.0" + "@polywrap/core-js" "~0.12.0-pre.0" + "@polywrap/plugin-js" "~0.12.0-pre.0" axios "0.21.4" form-data "4.0.0" -"@polywrap/logger-plugin-js@0.10.0-pre.10": - version "0.10.0-pre.10" - resolved "https://registry.yarnpkg.com/@polywrap/logger-plugin-js/-/logger-plugin-js-0.10.0-pre.10.tgz#de4a995c083edc26d72abb7420628b40d81efed2" - integrity sha512-6wBgBvphQRI+LP22+xi1KPcCq4B9dUMB/ZAXOpVTb/X/fOqdNBOS1LTXV+BtCe2KfdqGS6DKIXwGITcMOxIDCg== - dependencies: - "@polywrap/core-js" "0.10.0-pre.10" - "@polywrap/plugin-js" "0.10.0-pre.10" - -"@polywrap/logger-plugin-js@~0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/logger-plugin-js/-/logger-plugin-js-0.10.1.tgz#220cc248cb1381aa46c1f773ed8ce77da420280c" - integrity sha512-ipqS7A6Mc0Fp0e/qg8RyGIulfk6mGS9acKii3kQoJ59/Zf/Yy4Eg3HWDtnlgBIdIgwyZKD8amiF42VKRO6R3Ig== +"@polywrap/logger-plugin-js@~0.12.0-pre.0": + version "0.12.0-pre.0" + resolved "https://registry.yarnpkg.com/@polywrap/logger-plugin-js/-/logger-plugin-js-0.12.0-pre.0.tgz#ebc6f6f7a80bcbe8f24608303e1c4d63e9f157cf" + integrity sha512-aY3R07nK2svxiBxkJstHHfDak/Gin/23iCDFce4qWISEvsMPA0krte7Ll2VAsAAEBuwX1y1fACQ/xk01xLxmGg== dependencies: - "@polywrap/core-js" "0.10.0" - "@polywrap/plugin-js" "0.10.0" + "@polywrap/core-js" "~0.12.0-pre.0" + "@polywrap/plugin-js" "~0.12.0-pre.0" "@polywrap/msgpack-js@0.10.0": version "0.10.0" @@ -2346,72 +2264,47 @@ dependencies: "@msgpack/msgpack" "2.7.2" -"@polywrap/msgpack-js@0.10.0-pre.10": - version "0.10.0-pre.10" - resolved "https://registry.yarnpkg.com/@polywrap/msgpack-js/-/msgpack-js-0.10.0-pre.10.tgz#ac15d960dba2912f7ed657634f873e3c22c71843" - integrity sha512-z+lMVYKIYRyDrRDW5jFxt8Q6rVXBfMohI48Ht79X9DU1g6FdJInxhgXwVnUUQfrgtVoSgDLChdFlqnpi2JkEaQ== +"@polywrap/msgpack-js@0.12.0", "@polywrap/msgpack-js@~0.12.0-pre.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/msgpack-js/-/msgpack-js-0.12.0.tgz#87dc9fc83c1e8cbe889cca2f6c992141f6324c8f" + integrity sha512-7XVT5jqPkdgiN9Ql1quvkXf6lWxMPWeyEAaMPhrxRb45l5z9E8wFgarvUSRQ3htG1WpAvG5FdXY3/STqvCKXuw== dependencies: "@msgpack/msgpack" "2.7.2" -"@polywrap/msgpack-js@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/msgpack-js/-/msgpack-js-0.10.1.tgz#c3552eb51373164a78abfa80b52d9b02798ffd95" - integrity sha512-EI4Vak4Yi6NqM71eChWc3APe2svoR6BEeCVsxGAGI6p6x04r27J6+C3o1ptwHxiwyy8+J7B5W+ynaVo8qn5Zrw== +"@polywrap/plugin-js@0.12.0", "@polywrap/plugin-js@~0.12.0", "@polywrap/plugin-js@~0.12.0-pre.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/plugin-js/-/plugin-js-0.12.0.tgz#90482acaaec4547aaaea6f9acc3d18adf69751ac" + integrity sha512-ly8bvdJGgQVAXuGuHRJPzdtmUVRpjK1amVwZvzcD4Oaz6mr65l9VtYN79DQK9UXhIZ7hYpxtSBeLFKXZ4hmbOg== dependencies: - "@msgpack/msgpack" "2.7.2" + "@polywrap/core-js" "0.12.0" + "@polywrap/msgpack-js" "0.12.0" + "@polywrap/result" "0.12.0" + "@polywrap/tracing-js" "0.12.0" + "@polywrap/wrap-manifest-types-js" "0.12.0" -"@polywrap/plugin-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/plugin-js/-/plugin-js-0.10.0.tgz#e3bc81bf7832df9c84a4a319515228b159a05ba5" - integrity sha512-f0bjAKnveSu7u68NzWznYLWlzWo4MT8D6fudAF/wlV6S6R1euNJtIb8CTpAzfs6N173f81fzM/4OLS0pSYWdgQ== - dependencies: - "@polywrap/core-js" "0.10.0" - "@polywrap/msgpack-js" "0.10.0" - "@polywrap/result" "0.10.0" - "@polywrap/tracing-js" "0.10.0" - "@polywrap/wrap-manifest-types-js" "0.10.0" - -"@polywrap/plugin-js@0.10.0-pre.10": - version "0.10.0-pre.10" - resolved "https://registry.yarnpkg.com/@polywrap/plugin-js/-/plugin-js-0.10.0-pre.10.tgz#090c1963f40ab862a09deda8c18e6d522fd2e3f2" - integrity sha512-J/OEGEdalP83MnO4bBTeqC7eX+NBMQq6TxmUf68iNIydl8fgN7MNB7+koOTKdkTtNzrwXOnhavHecdSRZxuhDA== - dependencies: - "@polywrap/core-js" "0.10.0-pre.10" - "@polywrap/msgpack-js" "0.10.0-pre.10" - "@polywrap/result" "0.10.0-pre.10" - "@polywrap/tracing-js" "0.10.0-pre.10" - "@polywrap/wrap-manifest-types-js" "0.10.0-pre.10" - -"@polywrap/plugin-js@0.10.1", "@polywrap/plugin-js@~0.10.0": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/plugin-js/-/plugin-js-0.10.1.tgz#e11ce19dde01245750c297a62f2f75fd58ef9ced" - integrity sha512-WBk4ZUrI5m6FG4bIocLHo7XS+QMeNa23odli6Ss6onUyo7mPIo1wlceEgw7Cu4gd/3bmuc6VGoCKRA1/glBT3g== - dependencies: - "@polywrap/core-js" "0.10.1" - "@polywrap/msgpack-js" "0.10.1" - "@polywrap/result" "0.10.1" - "@polywrap/tracing-js" "0.10.1" - "@polywrap/wrap-manifest-types-js" "0.10.1" - -"@polywrap/result@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/result/-/result-0.10.0.tgz#712339223fba524dfabfb0bf868411f357d52e34" - integrity sha512-IxTBfGP89/OPNlUPMkjOrdYt/hwyvgI7TsYap6S35MHo4pXkR9mskzrHJ/AGE5DyGqP81CIIJNSYfooF97KY3A== - -"@polywrap/result@0.10.0-pre.10": - version "0.10.0-pre.10" - resolved "https://registry.yarnpkg.com/@polywrap/result/-/result-0.10.0-pre.10.tgz#6e88ac447d92d8a10c7e7892a6371af29a072240" - integrity sha512-SqNnEbXky4dFXgps2B2juFShq1024do0f1HLUbuj3MlIPp5aW9g9sfBslsy3YTnpg2QW7LFVT15crrJMgbowIQ== +"@polywrap/result@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/result/-/result-0.12.0.tgz#8cd72fa989098848b56316dfd7ed428831c5b540" + integrity sha512-CdZa21Pa+D9HdxoPwaUoLSlxbBppGiaoldnH4GfbeE/iWOCHQ2qnsVecV+jcQdM9Ih/o+Hpl7cqT5VzV9LEzsA== -"@polywrap/result@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/result/-/result-0.10.1.tgz#e60122396521fc07edda6951915ada4aaa5f6694" - integrity sha512-9EoS/JUgKFwRk396lQ+3tDAGbZExsOf26SUG4l41HJv4FZLLLOL5ksppJK8StvjtbpQOIgFls23c83CXzS1hBQ== +"@polywrap/sys-config-bundle-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/sys-config-bundle-js/-/sys-config-bundle-js-0.12.0.tgz#e65efc5b3a080b7e01ed0131882456dbb3439d24" + integrity sha512-6qsH3rgXyfBDE/1xFK1bKwwnqjz3CJvlpr3SHLCm+Y+wS9hVtr0L/t/XdCrlS+gWblU8/GpkpI100RUJJRpPlQ== + dependencies: + "@polywrap/concurrent-plugin-js" "~0.12.0-pre.0" + "@polywrap/config-bundle-types-js" "0.12.0" + "@polywrap/datetime-plugin-js" "~0.12.0-pre.0" + "@polywrap/file-system-plugin-js" "~0.12.0-pre.0" + "@polywrap/http-plugin-js" "~0.12.0-pre.0" + "@polywrap/logger-plugin-js" "~0.12.0-pre.0" + "@polywrap/uri-resolver-extensions-js" "0.12.0" + base64-to-uint8array "1.0.0" -"@polywrap/tracing-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/tracing-js/-/tracing-js-0.10.0.tgz#31d7ca9cc73a1dbd877fc684000652aa2c22acdc" - integrity sha512-077oN9VfbCNsYMRjX9NA6D1vFV+Y3TH92LjZATKQ2W2fRx/IGRARamAjhNfR4qRKstrOCd9D4E2DmaqFax3QIg== +"@polywrap/tracing-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/tracing-js/-/tracing-js-0.12.0.tgz#750238d92f6f29a4e8fc7e1b08cb27c7150c3279" + integrity sha512-wtvhBisczaMf4SAqIpmQlWjkaZmy+psZtRyVf3EDNmnn6gVfXEEqz/+Ewo+HfmBjDhLg7QC/x9XDo/eRgwHrcA== dependencies: "@fetsorn/opentelemetry-console-exporter" "0.0.3" "@opentelemetry/api" "1.2.0" @@ -2420,120 +2313,57 @@ "@opentelemetry/sdk-trace-base" "1.6.0" "@opentelemetry/sdk-trace-web" "1.6.0" -"@polywrap/tracing-js@0.10.0-pre.10": - version "0.10.0-pre.10" - resolved "https://registry.yarnpkg.com/@polywrap/tracing-js/-/tracing-js-0.10.0-pre.10.tgz#f50fb01883dcba4217a1711718aa53f3dd61cb1c" - integrity sha512-6wFw/zANVPG0tWMTSxwDzIpABVSSR9wO4/XxhCnKKgXwW6YANhtLj86uSRMTWqXeX2rpHwpMoWh4MDgYeAf+ng== +"@polywrap/uri-resolver-extensions-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/uri-resolver-extensions-js/-/uri-resolver-extensions-js-0.12.0.tgz#5819a447ae780e4f1092e613bc709741ef9c25e4" + integrity sha512-EE/JaVAH5Zt521kuCMGMRgdrHUlFqTk6f85e0UJo+DX6PcerJVj/KrfHQUKt/rM9SVD4mQaQA53k7/3DJhFnaw== dependencies: - "@fetsorn/opentelemetry-console-exporter" "0.0.3" - "@opentelemetry/api" "1.2.0" - "@opentelemetry/exporter-trace-otlp-http" "0.32.0" - "@opentelemetry/resources" "1.6.0" - "@opentelemetry/sdk-trace-base" "1.6.0" - "@opentelemetry/sdk-trace-web" "1.6.0" + "@polywrap/core-js" "0.12.0" + "@polywrap/result" "0.12.0" + "@polywrap/uri-resolvers-js" "0.12.0" + "@polywrap/wasm-js" "0.12.0" + "@polywrap/wrap-manifest-types-js" "0.12.0" -"@polywrap/tracing-js@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/tracing-js/-/tracing-js-0.10.1.tgz#488dd505f3c5232cb292e848de7a182c83a4405a" - integrity sha512-4ZjPgNBFbX4DIzqRbzyMq64FvYv51JLuFIxL0EweI5paEbR69a1m4iN4BLxJc+jBjDYpWgy399+tYGnc94aM6A== +"@polywrap/uri-resolvers-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/uri-resolvers-js/-/uri-resolvers-js-0.12.0.tgz#2a62a3af134cc091d69c4344f5e151830377b275" + integrity sha512-s1FoSjpmPpycmHYEYFQeZPE/JPh2cvq4ALHmMw/CBgd/6ornmzYc2XQE28zeF1sNBglmZIhB10MEkT7A0J8PDw== dependencies: - "@fetsorn/opentelemetry-console-exporter" "0.0.3" - "@opentelemetry/api" "1.2.0" - "@opentelemetry/exporter-trace-otlp-http" "0.32.0" - "@opentelemetry/resources" "1.6.0" - "@opentelemetry/sdk-trace-base" "1.6.0" - "@opentelemetry/sdk-trace-web" "1.6.0" + "@polywrap/core-js" "0.12.0" + "@polywrap/result" "0.12.0" + "@polywrap/wrap-manifest-types-js" "0.12.0" -"@polywrap/uri-resolver-extensions-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/uri-resolver-extensions-js/-/uri-resolver-extensions-js-0.10.0.tgz#ef0012e9b2231be44b0739f57b023a1c009c1b2b" - integrity sha512-mP8nLESuQFImhxeEV646m4qzJ1rc3d2LLgly9vPFUffXM7YMfJriL0nYNTzbyvZbhvH7PHfeEQ/m5DZFADMc7w== - dependencies: - "@polywrap/core-js" "0.10.0" - "@polywrap/result" "0.10.0" - "@polywrap/uri-resolvers-js" "0.10.0" - "@polywrap/wasm-js" "0.10.0" - "@polywrap/wrap-manifest-types-js" "0.10.0" - -"@polywrap/uri-resolver-extensions-js@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/uri-resolver-extensions-js/-/uri-resolver-extensions-js-0.10.1.tgz#6385ec63de3d53a8eddedeba10c59f0c8b2de36e" - integrity sha512-dsihLqgC3o76xnhWMH+o0Nol58BBy2KljxSoRGdi1XbEEkdHHKx2qwxfWAjOA83ljGJXToh0IsaxbCUuPEMIZQ== - dependencies: - "@polywrap/core-js" "0.10.1" - "@polywrap/result" "0.10.1" - "@polywrap/uri-resolvers-js" "0.10.1" - "@polywrap/wasm-js" "0.10.1" - "@polywrap/wrap-manifest-types-js" "0.10.1" - -"@polywrap/uri-resolvers-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/uri-resolvers-js/-/uri-resolvers-js-0.10.0.tgz#d80163666a5110a4a7bd36be7e0961364af761ce" - integrity sha512-lZP+sN4lnp8xRklYWkrAJFECFNXDsBawGqVk7jUrbcw1CX8YODHyDEB0dSV8vN30DMP4h70W7V4QeNwPiE1EzQ== +"@polywrap/wasm-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/wasm-js/-/wasm-js-0.12.0.tgz#e65320428976fb21eca16f0a499afb3fb12d86f6" + integrity sha512-NLu8AGewxSOq3Wv8eLgWn6y0TMho4nn3E5WFbE1ePgoPm6pm3FalVOrBJi04mUv1INm2Ty/VJTfQrzNVjIKJdQ== dependencies: - "@polywrap/core-js" "0.10.0" - "@polywrap/result" "0.10.0" - "@polywrap/wrap-manifest-types-js" "0.10.0" + "@polywrap/asyncify-js" "0.12.0" + "@polywrap/core-js" "0.12.0" + "@polywrap/msgpack-js" "0.12.0" + "@polywrap/result" "0.12.0" + "@polywrap/tracing-js" "0.12.0" + "@polywrap/wrap-manifest-types-js" "0.12.0" -"@polywrap/uri-resolvers-js@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/uri-resolvers-js/-/uri-resolvers-js-0.10.1.tgz#8ea24ba9348f31da0ccc691f92024c864db27d00" - integrity sha512-/PtGzoR/PwQPIr630iV15/ah7yu/zKYMzm0TfUIFpF+pRWfIR/6VD086d20PLE6h6UE4Jd5VHzEIXeb6FqdbgA== - dependencies: - "@polywrap/core-js" "0.10.1" - "@polywrap/result" "0.10.1" - "@polywrap/wrap-manifest-types-js" "0.10.1" +"@polywrap/web3-config-bundle-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/web3-config-bundle-js/-/web3-config-bundle-js-0.12.0.tgz#e9e2002ca05c913b8ed8a8b1750057b9bc478ec1" + integrity sha512-srhHT+xG4+2EbKmER26RNNJJmoy4LNsYbFRtUOXbjkG9rXRFxNA5gWs2p9ZMozyBGac0X+RQySU6DR5PvqnsGg== + dependencies: + "@polywrap/config-bundle-types-js" "0.12.0" + "@polywrap/ethereum-wallet-js" "~0.1.0" + "@polywrap/sys-config-bundle-js" "0.12.0" + "@polywrap/uri-resolver-extensions-js" "0.12.0" + "@polywrap/wasm-js" "0.12.0" + base64-to-uint8array "1.0.0" -"@polywrap/wasm-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/wasm-js/-/wasm-js-0.10.0.tgz#6947b44669514cc0cb0653db8278f40631c45c7d" - integrity sha512-kI0Q9DQ/PlA0BTEj+Mye4fdt/aLh07l8YHjhbXQheuu46mcZuG9vfgnn78eug9c7wjGEECxlsK+B4hy/FPgYxQ== - dependencies: - "@polywrap/asyncify-js" "0.10.0" - "@polywrap/core-js" "0.10.0" - "@polywrap/msgpack-js" "0.10.0" - "@polywrap/result" "0.10.0" - "@polywrap/tracing-js" "0.10.0" - "@polywrap/wrap-manifest-types-js" "0.10.0" - -"@polywrap/wasm-js@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/wasm-js/-/wasm-js-0.10.1.tgz#21e208e1e65417a41478a8828131d6e0cefcfdcb" - integrity sha512-ZWd/bqbpjyxp7NFx34SNlRvK4S3MF4s/6AWdauIHHZORUyRJvemXtmZSh8etTkltZzXTl+PTJ9xYPM5oEIs4nw== - dependencies: - "@polywrap/asyncify-js" "0.10.1" - "@polywrap/core-js" "0.10.1" - "@polywrap/msgpack-js" "0.10.1" - "@polywrap/result" "0.10.1" - "@polywrap/tracing-js" "0.10.1" - "@polywrap/wrap-manifest-types-js" "0.10.1" - -"@polywrap/wrap-manifest-types-js@0.10.0": - version "0.10.0" - resolved "https://registry.yarnpkg.com/@polywrap/wrap-manifest-types-js/-/wrap-manifest-types-js-0.10.0.tgz#f009a69d1591ee770dd13d67989d88f51e345d36" - integrity sha512-T3G/7NvNTuS1XyguRggTF4k7/h7yZCOcCbbUOTVoyVNfiNUY31hlrNZaFL4iriNqQ9sBDl9x6oRdOuFB7L9mlw== - dependencies: - "@apidevtools/json-schema-ref-parser" "9.0.9" - jsonschema "1.4.0" - semver "7.4.0" - -"@polywrap/wrap-manifest-types-js@0.10.0-pre.10": - version "0.10.0-pre.10" - resolved "https://registry.yarnpkg.com/@polywrap/wrap-manifest-types-js/-/wrap-manifest-types-js-0.10.0-pre.10.tgz#81b339f073c48880b34f06f151aa41373f442f88" - integrity sha512-Hgsa6nJIh0cCqKO14ufjAsN0WEKuLuvFBfBycjoRLfkwD3fcxP/xrvWgE2NRSvwQ77aV6PGMbhlSMDGI5jahrw== - dependencies: - "@apidevtools/json-schema-ref-parser" "9.0.9" - jsonschema "1.4.0" - semver "7.3.8" - -"@polywrap/wrap-manifest-types-js@0.10.1": - version "0.10.1" - resolved "https://registry.yarnpkg.com/@polywrap/wrap-manifest-types-js/-/wrap-manifest-types-js-0.10.1.tgz#df7099357af2ccdbb61a6fb42ebaa047c6d97d70" - integrity sha512-0UxTZY6AcQpEkeL9HMMZvHv5a0OXXSRr4clPVyyo7BAmUjwJRE0veKY2hy0bR0Je7rZjxlwR5uS9+CToqYAd9g== - dependencies: - "@apidevtools/json-schema-ref-parser" "9.0.9" - "@polywrap/msgpack-js" "0.10.1" - jsonschema "1.4.0" +"@polywrap/wrap-manifest-types-js@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@polywrap/wrap-manifest-types-js/-/wrap-manifest-types-js-0.12.0.tgz#5ca209cdcad2f35e2064aa6b8174c2fbbc9fbcbc" + integrity sha512-s5CZ/UNihiQ+zgC8tuJgBBiiAg/5iAE8vjnqq8993nSJ8XtoO9t6NO93ANXUFirPxNtrCK2qQzbrt/HygtdCuA== + dependencies: + "@polywrap/msgpack-js" "0.12.0" + ajv "8.12.0" semver "7.5.0" "@sinclair/typebox@^0.24.1": @@ -2740,9 +2570,9 @@ integrity sha512-0d5Wd09ItQWH1qFbEyQ7oTQ3GZrMfth5JkbN3EvTKLXcHLRDSXeLnlvlOn0wvxVIwK5o2M8JzP/OWz7T3NRsbw== "@types/lodash@^4.14.182": - version "4.14.195" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.195.tgz#bafc975b252eb6cea78882ce8a7b6bf22a6de632" - integrity sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg== + version "4.14.196" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.196.tgz#a7c3d6fc52d8d71328b764e28e080b4169ec7a95" + integrity sha512-22y3o88f4a94mKljsZcanlNWPzO0uBsBdzLAngf2tp533LzZcQzb6+eZPJ+vCTt+bqF2XnvT9gejTLsAcJAJyQ== "@types/minimatch@*", "@types/minimatch@^5.1.2": version "5.1.2" @@ -2764,15 +2594,10 @@ resolved "https://registry.yarnpkg.com/@types/mustache/-/mustache-4.0.1.tgz#e4d421ed2d06d463b120621774185a5cd1b92d77" integrity sha512-wH6Tu9mbiOt0n5EvdoWy0VGQaJMHfLIxY/6wS0xLC7CV1taM6gESEzcYy0ZlWvxxiiljYvfDIvz4hHbUUDRlhw== -"@types/node@*": - version "20.3.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.3.2.tgz#fa6a90f2600e052a03c18b8cb3fd83dd4e599898" - integrity sha512-vOBLVQeCQfIcF/2Y7eKFTqrMnizK5lRNQ7ykML/5RuwVXVWxYkgwS7xbt4B6fKCUPgbSL5FSsjHQpaGQP/dQmw== - -"@types/node@^18.14.6": - version "18.16.18" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.18.tgz#85da09bafb66d4bc14f7c899185336d0c1736390" - integrity sha512-/aNaQZD0+iSBAGnvvN2Cx92HqE5sZCPZtx2TsK+4nvV23fFe09jVDvpArXr2j9DnYlzuU9WuoykDDc6wqvpNcw== +"@types/node@*", "@types/node@18.15.0": + version "18.15.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.0.tgz#286a65e3fdffd691e170541e6ecb0410b16a38be" + integrity sha512-z6nr0TTEOBGkzLGmbypWOGnpSpSIBorEhC4L+4HeQ2iezKCi4f77kyslRwvHeNitymGQ+oFyIWGP96l/DPSV9w== "@types/normalize-package-data@^2.4.0": version "2.4.1" @@ -2960,11 +2785,6 @@ resolved "https://registry.yarnpkg.com/@web3api/assemblyscript-json/-/assemblyscript-json-1.2.0.tgz#f01f11f12a66cd1a319d43f12e476307d1ad3da8" integrity sha512-x+wchJpH1giJzXj3dYs8vh2SKMXepeqVXiaFV/YCtXg4X/KaUnxi0kp5JugbEAyEJurEScH1YuV6IvGhGui/fw== -"@zxing/text-encoding@0.9.0": - version "0.9.0" - resolved "https://registry.yarnpkg.com/@zxing/text-encoding/-/text-encoding-0.9.0.tgz#fb50ffabc6c7c66a0c96b4c03e3d9be74864b70b" - integrity sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA== - JSONStream@^1.0.4: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -2983,13 +2803,6 @@ abbrev@1: resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== -abort-controller@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" - integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== - dependencies: - event-target-shim "^5.0.0" - acorn-globals@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-6.0.0.tgz#46cdd39f0f8ff08a876619b55f5ac8a6dc770b45" @@ -3019,9 +2832,9 @@ acorn@^7.1.1, acorn@^7.4.0: integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== acorn@^8.2.4, acorn@^8.4.1: - version "8.9.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.9.0.tgz#78a16e3b2bcc198c10822786fa6679e245db5b59" - integrity sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ== + version "8.10.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" + integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== add-stream@^1.0.0: version "1.0.0" @@ -3062,6 +2875,16 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" +ajv@8.12.0, ajv@^8.0.1: + version "8.12.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" + integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA== + dependencies: + fast-deep-equal "^3.1.1" + json-schema-traverse "^1.0.0" + require-from-string "^2.0.2" + uri-js "^4.2.2" + ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" @@ -3072,16 +2895,6 @@ ajv@^6.10.0, ajv@^6.12.3, ajv@^6.12.4: json-schema-traverse "^0.4.1" uri-js "^4.2.2" -ajv@^8.0.1: - version "8.12.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.12.0.tgz#d1a0527323e22f53562c567c00991577dfbe19d1" - integrity sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA== - dependencies: - fast-deep-equal "^3.1.1" - json-schema-traverse "^1.0.0" - require-from-string "^2.0.2" - uri-js "^4.2.2" - ansi-colors@^4.1.1: version "4.1.3" resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.3.tgz#37611340eb2243e70cc604cad35d63270d48781b" @@ -3128,14 +2941,6 @@ any-promise@^1.0.0: resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== -any-signal@^2.0.0, any-signal@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/any-signal/-/any-signal-2.1.2.tgz#8d48270de0605f8b218cf9abe8e9c6a0e7418102" - integrity sha512-B+rDnWasMi/eWcajPcCWSlYc7muXOrcYrqgyzcdKisl2H/WTlQ0gip1KyQfr0ZlxJdsuWCj/LWwQm7fhyhRfIQ== - dependencies: - abort-controller "^3.0.0" - native-abort-controller "^1.0.3" - anymatch@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -3262,6 +3067,18 @@ array.prototype.reduce@^1.0.5: es-array-method-boxes-properly "^1.0.0" is-string "^1.0.7" +arraybuffer.prototype.slice@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.1.tgz#9b5ea3868a6eebc30273da577eb888381c0044bb" + integrity sha512-09x0ZWFEjj4WD8PDbykUwo3t9arLn8NIzmmYEJFpYekOAQjpkGSyrQhNoRTcwwcFRu+ycWF78QZ63oWTqSjBcw== + dependencies: + array-buffer-byte-length "^1.0.0" + call-bind "^1.0.2" + define-properties "^1.2.0" + get-intrinsic "^1.2.1" + is-array-buffer "^3.0.2" + is-shared-array-buffer "^1.0.2" + arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -3491,11 +3308,6 @@ before-after-hook@^2.2.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ== -bignumber.js@^9.0.0: - version "9.1.1" - resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6" - integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig== - binary-extensions@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" @@ -3506,27 +3318,6 @@ binaryen@102.0.0-nightly.20211028: resolved "https://registry.yarnpkg.com/binaryen/-/binaryen-102.0.0-nightly.20211028.tgz#8f1efb0920afd34509e342e37f84313ec936afb2" integrity sha512-GCJBVB5exbxzzvyt8MGDv/MeUjs6gkXDvf4xOIItRBptYl0Tz5sm1o/uG95YK0L0VeG5ajDu3hRtkBP2kzqC5w== -bl@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" - integrity sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w== - dependencies: - buffer "^5.5.0" - inherits "^2.0.4" - readable-stream "^3.4.0" - -blakejs@^1.1.0: - version "1.2.1" - resolved "https://registry.yarnpkg.com/blakejs/-/blakejs-1.2.1.tgz#5057e4206eadb4a97f7c0b6e197a505042fc3814" - integrity sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ== - -blob-to-it@^1.0.1: - version "1.0.4" - resolved "https://registry.yarnpkg.com/blob-to-it/-/blob-to-it-1.0.4.tgz#f6caf7a4e90b7bb9215fa6a318ed6bd8ad9898cb" - integrity sha512-iCmk0W4NdbrWgRRuxOriU8aM5ijeVLI61Zulsmg/lUHNr7pYjoj+U77opLefNagevtrrbMt3JQ5Qip7ar178kA== - dependencies: - browser-readablestream-to-it "^1.0.3" - bn.js@^4.11.9: version "4.12.0" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" @@ -3537,19 +3328,6 @@ bn.js@^5.2.1: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== -borc@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/borc/-/borc-2.1.2.tgz#6ce75e7da5ce711b963755117dd1b187f6f8cf19" - integrity sha512-Sy9eoUi4OiKzq7VovMn246iTo17kzuyHJKomCfpWMlI6RpfN1gk95w7d7gH264nApVLg0HZfcpz62/g4VH1Y4w== - dependencies: - bignumber.js "^9.0.0" - buffer "^5.5.0" - commander "^2.15.0" - ieee754 "^1.1.13" - iso-url "~0.4.7" - json-text-sequence "~0.1.0" - readable-stream "^3.6.0" - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -3558,13 +3336,6 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -brace-expansion@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" - integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== - dependencies: - balanced-match "^1.0.0" - braces@^2.3.1: version "2.3.2" resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" @@ -3598,12 +3369,7 @@ browser-process-hrtime@^1.0.0: resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz#3c9b4b7d782c8121e56f10106d84c0d0ffc94626" integrity sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow== -browser-readablestream-to-it@^1.0.1, browser-readablestream-to-it@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/browser-readablestream-to-it/-/browser-readablestream-to-it-1.0.3.tgz#ac3e406c7ee6cdf0a502dd55db33bab97f7fba76" - integrity sha512-+12sHB+Br8HIh6VAMVEG5r3UXCyESIgDW7kzk3BjIXa43DVqVwL7GC5TW3jeh+72dtcH99pPVpw0X8i0jt+/kw== - -browserslist@^4.21.3: +browserslist@^4.21.9: version "4.21.9" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.9.tgz#e11bdd3c313d7e2a9e87e8b4b0c7872b13897635" integrity sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg== @@ -3642,7 +3408,7 @@ buffer-from@1.x, buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== -buffer@^5.4.3, buffer@^5.5.0, buffer@^5.6.0: +buffer@^5.5.0, buffer@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== @@ -3650,14 +3416,6 @@ buffer@^5.4.3, buffer@^5.5.0, buffer@^5.6.0: base64-js "^1.3.1" ieee754 "^1.1.13" -buffer@^6.0.1: - version "6.0.3" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" - integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - builtins@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88" @@ -3750,9 +3508,9 @@ camelcase@^6.0.0: integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== caniuse-lite@^1.0.30001503: - version "1.0.30001509" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001509.tgz#2b7ad5265392d6d2de25cd8776d1ab3899570d14" - integrity sha512-2uDDk+TRiTX5hMcUYT/7CSyzMZxjfGu0vAUjS2g0LSD8UoXOv0LtpH4LxGMemsiPq6LCVIUjNwVM0erkOkGCDA== + version "1.0.30001517" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001517.tgz#90fabae294215c3495807eb24fc809e11dc2f0a8" + integrity sha512-Vdhm5S11DaFVLlyiKu4hiUTkpZu+y1KA/rZZqVQfOD5YdDT/eQKlkt7NaE0WGOFgX32diqt9MiP9CAiFeRklaA== capture-exit@^2.0.0: version "2.0.0" @@ -3850,16 +3608,6 @@ cids@^0.7.1: multicodec "^1.0.0" multihashes "~0.4.15" -cids@^1.0.0: - version "1.1.9" - resolved "https://registry.yarnpkg.com/cids/-/cids-1.1.9.tgz#402c26db5c07059377bcd6fb82f2a24e7f2f4a4f" - integrity sha512-l11hWRfugIcbGuTZwAM5PwpjPPjyb6UZOGwlHSnOBV5o07XhQ4gNpBN67FbODvpjyHtd+0Xs6KNvUcGBiDRsdg== - dependencies: - multibase "^4.0.1" - multicodec "^3.0.1" - multihashes "^4.0.1" - uint8arrays "^3.0.0" - cjs-module-lexer@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-0.6.0.tgz#4186fcca0eae175970aee870b9fe2d6cf8d5655f" @@ -3963,9 +3711,9 @@ code-point-at@^1.0.0: integrity sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA== collect-v8-coverage@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59" - integrity sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg== + version "1.0.2" + resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9" + integrity sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q== collection-visit@^1.0.0: version "1.0.0" @@ -4019,7 +3767,7 @@ commander@9.2.0: resolved "https://registry.yarnpkg.com/commander/-/commander-9.2.0.tgz#6e21014b2ed90d8b7c9647230d8b7a94a4a419a9" integrity sha512-e2i4wANQiSXgnrBlIatyHtP1odfUp0BbV5Y5nEGbxtIrStkEOAAzCUirvLBNXHLr7kwLvJl6V+4V3XV9x7Wd9w== -commander@^2.15.0, commander@^2.19.0: +commander@^2.19.0: version "2.20.3" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== @@ -4291,7 +4039,7 @@ dateformat@^3.0.0: resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-3.0.3.tgz#a6e37499a4d9a9cf85ef5872044d62901c9889ae" integrity sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q== -debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.3: +debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.3: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== @@ -4345,7 +4093,7 @@ dedent@^0.7.0: resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c" integrity sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA== -deep-is@^0.1.3, deep-is@~0.1.3: +deep-is@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== @@ -4402,11 +4150,6 @@ delegates@^1.0.0: resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" integrity sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ== -delimit-stream@0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/delimit-stream/-/delimit-stream-0.1.0.tgz#9b8319477c0e5f8aeb3ce357ae305fc25ea1cd2b" - integrity sha512-a02fiQ7poS5CnjiJBAsjGLPp5EwVoGHNeu9sziBd9huppRfsAFIpv5zNLv0V1gbop53ilngAf5Kf331AwcoRBQ== - depd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" @@ -4485,15 +4228,6 @@ discontinuous-range@1.0.0: resolved "https://registry.yarnpkg.com/discontinuous-range/-/discontinuous-range-1.0.0.tgz#e38331f0844bba49b9a9cb71c771585aab1bc65a" integrity sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ== -dns-over-http-resolver@^1.0.0: - version "1.2.3" - resolved "https://registry.yarnpkg.com/dns-over-http-resolver/-/dns-over-http-resolver-1.2.3.tgz#194d5e140a42153f55bb79ac5a64dd2768c36af9" - integrity sha512-miDiVSI6KSNbi4SVifzO/reD8rMnxgrlnkrlkugOLQpWQTe2qMdHsZp5DmfKjxNE+/T3VAAYLQUZMv9SMr6+AA== - dependencies: - debug "^4.3.1" - native-fetch "^3.0.0" - receptacle "^1.3.2" - docker-compose@0.23.17: version "0.23.17" resolved "https://registry.yarnpkg.com/docker-compose/-/docker-compose-0.23.17.tgz#8816bef82562d9417dc8c790aa4871350f93a2ba" @@ -4550,17 +4284,10 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" -electron-fetch@^1.7.2: - version "1.9.1" - resolved "https://registry.yarnpkg.com/electron-fetch/-/electron-fetch-1.9.1.tgz#e28bfe78d467de3f2dec884b1d72b8b05322f30f" - integrity sha512-M9qw6oUILGVrcENMSRRefE1MbHPIz0h79EKIeJWK9v563aT9Qkh8aEHPO1H5vi970wPirNY+jO9OpFoLiMsMGA== - dependencies: - encoding "^0.1.13" - electron-to-chromium@^1.4.431: - version "1.4.445" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.445.tgz#058d2c5f3a2981ab1a37440f5a5e42d15672aa6d" - integrity sha512-++DB+9VK8SBJwC+X1zlMfJ1tMA3F0ipi39GdEp+x3cV2TyBihqAgad8cNMWtLDEkbH39nlDQP7PfGrDr3Dr7HA== + version "1.4.473" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.473.tgz#4853de13a335c70fe1f9df8d4029be54068767d1" + integrity sha512-aVfC8+440vGfl06l8HKKn8/PD5jRfSnLkTTD65EFvU46igbpQRri1gxSzW9/+TeUlwYzrXk1sw867T96zlyECA== elliptic@6.5.4: version "6.5.4" @@ -4590,7 +4317,7 @@ emoji-regex@^9.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== -encoding@^0.1.12, encoding@^0.1.13: +encoding@^0.1.12: version "0.1.13" resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9" integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A== @@ -4605,11 +4332,12 @@ end-of-stream@^1.1.0: once "^1.4.0" enquirer@^2.3.5: - version "2.3.6" - resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" - integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== + version "2.4.0" + resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.4.0.tgz#4f36f6c644137cc4fd2891da407ede2b1fea904a" + integrity sha512-ehu97t6FTYK2I3ZYtnp0BZ9vt0mvEL/cnHBds7Ct6jo9VX1VIkiFhOvVRWh6eblQqd7KOoICIQV+syZ3neXO/Q== dependencies: ansi-colors "^4.1.1" + strip-ansi "^6.0.1" env-paths@^2.2.0: version "2.2.1" @@ -4621,16 +4349,11 @@ envinfo@^7.7.4: resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.10.0.tgz#55146e3909cc5fe63c22da63fb15b05aeac35b13" integrity sha512-ZtUjZO6l5mwTHvc1L9+1q5p/R3wTopcfqMW8r5t8SJSKqeVI/LtajORwRFEKpEFuekjD0VBjwu1HMxL4UalIRw== -err-code@^2.0.0, err-code@^2.0.2, err-code@^2.0.3: +err-code@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/err-code/-/err-code-2.0.3.tgz#23c2f3b756ffdfc608d30e27c9a941024807e7f9" integrity sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA== -err-code@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/err-code/-/err-code-3.0.1.tgz#a444c7b992705f2b120ee320b09972eef331c920" - integrity sha512-GiaH0KJUewYok+eeY05IIgjtAe4Yltygk9Wqp1V5yVWLdhf0hYZchRjNIT9bb0mSwRcIusT3cx7PJUf3zEIfUA== - error-ex@^1.2.0, error-ex@^1.3.1: version "1.3.2" resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" @@ -4639,17 +4362,18 @@ error-ex@^1.2.0, error-ex@^1.3.1: is-arrayish "^0.2.1" es-abstract@^1.19.0, es-abstract@^1.20.4, es-abstract@^1.21.2: - version "1.21.2" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.21.2.tgz#a56b9695322c8a185dc25975aa3b8ec31d0e7eff" - integrity sha512-y/B5POM2iBnIxCiernH1G7rC9qQoM77lLIMQLuob0zhp8C56Po81+2Nj0WFKnd0pNReDTnkYryc+zhOzpEIROg== + version "1.22.1" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.22.1.tgz#8b4e5fc5cefd7f1660f0f8e1a52900dfbc9d9ccc" + integrity sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw== dependencies: array-buffer-byte-length "^1.0.0" + arraybuffer.prototype.slice "^1.0.1" available-typed-arrays "^1.0.5" call-bind "^1.0.2" es-set-tostringtag "^2.0.1" es-to-primitive "^1.2.1" function.prototype.name "^1.1.5" - get-intrinsic "^1.2.0" + get-intrinsic "^1.2.1" get-symbol-description "^1.0.0" globalthis "^1.0.3" gopd "^1.0.1" @@ -4669,14 +4393,18 @@ es-abstract@^1.19.0, es-abstract@^1.20.4, es-abstract@^1.21.2: object-inspect "^1.12.3" object-keys "^1.1.1" object.assign "^4.1.4" - regexp.prototype.flags "^1.4.3" + regexp.prototype.flags "^1.5.0" + safe-array-concat "^1.0.0" safe-regex-test "^1.0.0" string.prototype.trim "^1.2.7" string.prototype.trimend "^1.0.6" string.prototype.trimstart "^1.0.6" + typed-array-buffer "^1.0.0" + typed-array-byte-length "^1.0.0" + typed-array-byte-offset "^1.0.0" typed-array-length "^1.0.4" unbox-primitive "^1.0.2" - which-typed-array "^1.1.9" + which-typed-array "^1.1.10" es-array-method-boxes-properly@^1.0.0: version "1.0.0" @@ -4760,14 +4488,13 @@ escape-string-regexp@^2.0.0: integrity sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w== escodegen@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.0.0.tgz#5e32b12833e8aa8fa35e1bf0befa89380484c7dd" - integrity sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw== + version "2.1.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.1.0.tgz#ba93bbb7a43986d29d6041f99f5262da773e2e17" + integrity sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w== dependencies: esprima "^4.0.1" estraverse "^5.2.0" esutils "^2.0.2" - optionator "^0.8.1" optionalDependencies: source-map "~0.6.1" @@ -4994,11 +4721,6 @@ event-emitter@^0.3.5: d "1" es5-ext "~0.10.14" -event-target-shim@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" - integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== - eventemitter3@^4.0.4: version "4.0.7" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" @@ -5163,15 +4885,10 @@ fast-diff@^1.1.2: resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== -fast-fifo@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/fast-fifo/-/fast-fifo-1.3.0.tgz#03e381bcbfb29932d7c3afde6e15e83e05ab4d8b" - integrity sha512-IgfweLvEpwyA4WgiQe9Nx6VV2QkML2NkvZnk1oKnIzXgXdWxuhF7zw4DvLTPZJn6PIUneiAXPF24QmoEqHTjyw== - fast-glob@^3.2.5, fast-glob@^3.2.9: - version "3.2.12" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" - integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== + version "3.3.1" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.1.tgz#784b4e897340f3dbbef17413b3f11acf03c874c4" + integrity sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg== dependencies: "@nodelib/fs.stat" "^2.0.2" "@nodelib/fs.walk" "^1.2.3" @@ -5184,7 +4901,7 @@ fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== -fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: +fast-levenshtein@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== @@ -5345,7 +5062,7 @@ fs-extra@9.0.1: jsonfile "^6.0.1" universalify "^1.0.0" -fs-extra@^9.0.1, fs-extra@^9.1.0: +fs-extra@^9.1.0: version "9.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ== @@ -5428,7 +5145,7 @@ get-caller-file@^2.0.1, get-caller-file@^2.0.5: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== -get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0: +get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0, get-intrinsic@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.1.tgz#d295644fed4505fc9cde952c37ee12b477a83d82" integrity sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw== @@ -5438,11 +5155,6 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@ has-proto "^1.0.1" has-symbols "^1.0.3" -get-iterator@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/get-iterator/-/get-iterator-1.0.2.tgz#cd747c02b4c084461fac14f48f6b45a80ed25c82" - integrity sha512-v+dm9bNVfOYsY1OrhaCrmyOcYoSeVvbt+hHZ0Au+T+p1y+0Uyj9aMaGIeUTT6xdpRbWzDeYKvfOslPhggQMcsg== - get-package-type@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" @@ -5594,7 +5306,7 @@ globals@^12.1.0: dependencies: type-fest "^0.8.1" -globalthis@^1.0.1, globalthis@^1.0.3: +globalthis@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf" integrity sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA== @@ -5855,7 +5567,7 @@ iconv-lite@^0.6.2: dependencies: safer-buffer ">= 2.1.2 < 3.0.0" -ieee754@^1.1.13, ieee754@^1.2.1: +ieee754@^1.1.13: version "1.2.1" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== @@ -5994,132 +5706,11 @@ invert-kv@^3.0.0: resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-3.0.1.tgz#a93c7a3d4386a1dc8325b97da9bb1620c0282523" integrity sha512-CYdFeFexxhv/Bcny+Q0BfOV+ltRlJcd4BBZBYFX/O0u4npJrgZtIcjokegtiSMAvlMTJ+Koq0GBCc//3bueQxw== -ip-regex@^4.0.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.3.0.tgz#687275ab0f57fa76978ff8f4dddc8a23d5990db5" - integrity sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q== - ip@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.0.tgz#4cf4ab182fee2314c75ede1276f8c80b479936da" integrity sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ== -ipfs-core-utils@^0.5.4: - version "0.5.4" - resolved "https://registry.yarnpkg.com/ipfs-core-utils/-/ipfs-core-utils-0.5.4.tgz#c7fa508562086be65cebb51feb13c58abbbd3d8d" - integrity sha512-V+OHCkqf/263jHU0Fc9Rx/uDuwlz3PHxl3qu6a5ka/mNi6gucbFuI53jWsevCrOOY9giWMLB29RINGmCV5dFeQ== - dependencies: - any-signal "^2.0.0" - blob-to-it "^1.0.1" - browser-readablestream-to-it "^1.0.1" - cids "^1.0.0" - err-code "^2.0.3" - ipfs-utils "^5.0.0" - it-all "^1.0.4" - it-map "^1.0.4" - it-peekable "^1.0.1" - multiaddr "^8.0.0" - multiaddr-to-uri "^6.0.0" - parse-duration "^0.4.4" - timeout-abort-controller "^1.1.1" - uint8arrays "^1.1.0" - -ipfs-http-client@48.1.3: - version "48.1.3" - resolved "https://registry.yarnpkg.com/ipfs-http-client/-/ipfs-http-client-48.1.3.tgz#d9b91b1f65d54730de92290d3be5a11ef124b400" - integrity sha512-+JV4cdMaTvYN3vd4r6+mcVxV3LkJXzc4kn2ToVbObpVpdqmG34ePf1KlvFF8A9gjcel84WpiP5xCEV/IrisPBA== - dependencies: - any-signal "^2.0.0" - bignumber.js "^9.0.0" - cids "^1.0.0" - debug "^4.1.1" - form-data "^3.0.0" - ipfs-core-utils "^0.5.4" - ipfs-utils "^5.0.0" - ipld-block "^0.11.0" - ipld-dag-cbor "^0.17.0" - ipld-dag-pb "^0.20.0" - ipld-raw "^6.0.0" - it-last "^1.0.4" - it-map "^1.0.4" - it-tar "^1.2.2" - it-to-stream "^0.1.2" - merge-options "^2.0.0" - multiaddr "^8.0.0" - multibase "^3.0.0" - multicodec "^2.0.1" - multihashes "^3.0.1" - nanoid "^3.1.12" - native-abort-controller "~0.0.3" - parse-duration "^0.4.4" - stream-to-it "^0.2.2" - uint8arrays "^1.1.0" - -ipfs-utils@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ipfs-utils/-/ipfs-utils-5.0.1.tgz#7c0053d5e77686f45577257a73905d4523e6b4f7" - integrity sha512-28KZPgO4Uf5duT2ORLAYfboUp98iUshDD7yRAfbNxNAR8Dtidfn6o20rZfoXnkri2zKBVIPlJkuCPmPJB+6erg== - dependencies: - abort-controller "^3.0.0" - any-signal "^2.1.0" - buffer "^6.0.1" - electron-fetch "^1.7.2" - err-code "^2.0.0" - fs-extra "^9.0.1" - is-electron "^2.2.0" - iso-url "^1.0.0" - it-glob "0.0.10" - it-to-stream "^0.1.2" - merge-options "^2.0.0" - nanoid "^3.1.3" - native-abort-controller "0.0.3" - native-fetch "^2.0.0" - node-fetch "^2.6.0" - stream-to-it "^0.2.0" - -ipld-block@^0.11.0: - version "0.11.1" - resolved "https://registry.yarnpkg.com/ipld-block/-/ipld-block-0.11.1.tgz#c3a7b41aee3244187bd87a73f980e3565d299b6e" - integrity sha512-sDqqLqD5qh4QzGq6ssxLHUCnH4emCf/8F8IwjQM2cjEEIEHMUj57XhNYgmGbemdYPznUhffxFGEHsruh5+HQRw== - dependencies: - cids "^1.0.0" - -ipld-dag-cbor@^0.17.0: - version "0.17.1" - resolved "https://registry.yarnpkg.com/ipld-dag-cbor/-/ipld-dag-cbor-0.17.1.tgz#842e6c250603e5791049168831a425ec03471fb1" - integrity sha512-Bakj/cnxQBdscORyf4LRHxQJQfoaY8KWc7PWROQgX+aw5FCzBt8ga0VM/59K+ABOznsqNvyLR/wz/oYImOpXJw== - dependencies: - borc "^2.1.2" - cids "^1.0.0" - is-circular "^1.0.2" - multicodec "^3.0.1" - multihashing-async "^2.0.0" - uint8arrays "^2.1.3" - -ipld-dag-pb@^0.20.0: - version "0.20.0" - resolved "https://registry.yarnpkg.com/ipld-dag-pb/-/ipld-dag-pb-0.20.0.tgz#025c0343aafe6cb9db395dd1dc93c8c60a669360" - integrity sha512-zfM0EdaolqNjAxIrtpuGKvXxWk5YtH9jKinBuQGTcngOsWFQhyybGCTJHGNGGtRjHNJi2hz5Udy/8pzv4kcKyg== - dependencies: - cids "^1.0.0" - class-is "^1.1.0" - multicodec "^2.0.0" - multihashing-async "^2.0.0" - protons "^2.0.0" - reset "^0.1.0" - run "^1.4.0" - stable "^0.1.8" - uint8arrays "^1.0.0" - -ipld-raw@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/ipld-raw/-/ipld-raw-6.0.0.tgz#74d947fcd2ce4e0e1d5bb650c1b5754ed8ea6da0" - integrity sha512-UK7fjncAzs59iu/o2kwYtb8jgTtW6B+cNWIiNpAJkfRwqoMk1xD/6i25ktzwe4qO8gQgoR9RxA5ibC23nq8BLg== - dependencies: - cids "^1.0.0" - multicodec "^2.0.0" - multihashing-async "^2.0.0" - is-absolute@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-1.0.0.tgz#395e1ae84b11f26ad1795e73c17378e48a301576" @@ -6142,14 +5733,6 @@ is-accessor-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" -is-arguments@^1.0.4: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" - integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== - dependencies: - call-bind "^1.0.2" - has-tostringtag "^1.0.0" - is-array-buffer@^3.0.1, is-array-buffer@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz#f2653ced8412081638ecb0ebbd0c41c6e0aecbbe" @@ -6203,11 +5786,6 @@ is-ci@^2.0.0: dependencies: ci-info "^2.0.0" -is-circular@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/is-circular/-/is-circular-1.0.2.tgz#2e0ab4e9835f4c6b0ea2b9855a84acd501b8366c" - integrity sha512-YttjnrswnUYRVJvxCvu8z+PGMUSzC2JttP0OEXezlAEdp3EXzhf7IZ3j0gRAybJBQupedIZFhY61Tga6E0qASA== - is-core-module@^2.11.0, is-core-module@^2.5.0: version "2.12.1" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.12.1.tgz#0c0b6885b6f80011c71541ce15c8d66cf5a4f9fd" @@ -6259,11 +5837,6 @@ is-docker@^2.0.0: resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== -is-electron@^2.2.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/is-electron/-/is-electron-2.2.2.tgz#3778902a2044d76de98036f5dc58089ac4d80bb9" - integrity sha512-FO/Rhvz5tuw4MCWkpMzHFKWD2LsfHzIb7i6MdPYZ/KW7AlxawyLkqdy+jPZP1WubqEADE3O4FUENlJHDfQASRg== - is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" @@ -6298,13 +5871,6 @@ is-generator-fn@^2.0.0: resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.1.0.tgz#7d140adc389aaf3011a8f2a2a4cfa6faadffb118" integrity sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ== -is-generator-function@^1.0.7: - version "1.0.10" - resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.10.tgz#f1558baf1ac17e0deea7c0415c438351ff2b3c72" - integrity sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A== - dependencies: - has-tostringtag "^1.0.0" - is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" @@ -6312,13 +5878,6 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: dependencies: is-extglob "^2.1.1" -is-ip@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/is-ip/-/is-ip-3.1.0.tgz#2ae5ddfafaf05cb8008a62093cf29734f657c5d8" - integrity sha512-35vd5necO7IitFPjd/YBeqwWnyDWbuLH9ZXQdMfDA8TEo7pv5X8yfrvVO3xbJbLUlERCMvf6X0hTUamQxCYJ9Q== - dependencies: - ip-regex "^4.0.0" - is-lambda@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-lambda/-/is-lambda-1.0.1.tgz#3d9877899e6a53efc0160504cde15f82e6f061d5" @@ -6450,16 +6009,12 @@ is-text-path@^1.0.1: dependencies: text-extensions "^1.0.0" -is-typed-array@^1.1.10, is-typed-array@^1.1.3, is-typed-array@^1.1.9: - version "1.1.10" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.10.tgz#36a5b5cb4189b575d1a3e4b08536bfb485801e3f" - integrity sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A== +is-typed-array@^1.1.10, is-typed-array@^1.1.9: + version "1.1.12" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.12.tgz#d0bab5686ef4a76f7a73097b95470ab199c57d4a" + integrity sha512-Z14TF2JNG8Lss5/HMqt0//T9JeHXttXy5pH/DBU4vi98ozO2btxzq9MwYDZYnKwU8nRsz/+GVFVRDq3DkVuSPg== dependencies: - available-typed-arrays "^1.0.5" - call-bind "^1.0.2" - for-each "^0.3.3" - gopd "^1.0.1" - has-tostringtag "^1.0.0" + which-typed-array "^1.1.11" is-typedarray@^1.0.0, is-typedarray@~1.0.0: version "1.0.0" @@ -6512,21 +6067,6 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== -iso-constants@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/iso-constants/-/iso-constants-0.1.2.tgz#3d2456ed5aeaa55d18564f285ba02a47a0d885b4" - integrity sha512-OTCM5ZCQsHBCI4Wdu4tSxvDIkmDHd5EwJDps5mKqnQnWJSKlnwMs3EDZ4n3Fh1tmkWkDlyd2vCDbEYuPbyrUNQ== - -iso-url@^1.0.0: - version "1.2.1" - resolved "https://registry.yarnpkg.com/iso-url/-/iso-url-1.2.1.tgz#db96a49d8d9a64a1c889fc07cc525d093afb1811" - integrity sha512-9JPDgCN4B7QPkLtYAAOrEuAWvP9rWvR5offAr0/SeF046wIkglqH3VXgYYP6NcsKslH80UIVgmPqNe3j7tG2ng== - -iso-url@~0.4.7: - version "0.4.7" - resolved "https://registry.yarnpkg.com/iso-url/-/iso-url-0.4.7.tgz#de7e48120dae46921079fe78f325ac9e9217a385" - integrity sha512-27fFRDnPAMnHGLq36bWTpKET+eiXct3ENlCcdcMdk+mjXrb2kw3mhBUg1B7ewAC0kVzlOPhADzQgz1SE6Tglog== - isobject@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" @@ -6571,12 +6111,12 @@ istanbul-lib-instrument@^5.0.4: semver "^6.3.0" istanbul-lib-report@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#7518fe52ea44de372f460a76b5ecda9ffb73d8a6" - integrity sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw== + version "3.0.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz#908305bac9a5bd175ac6a74489eafd0fc2445a7d" + integrity sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw== dependencies: istanbul-lib-coverage "^3.0.0" - make-dir "^3.0.0" + make-dir "^4.0.0" supports-color "^7.1.0" istanbul-lib-source-maps@^4.0.0: @@ -6589,79 +6129,13 @@ istanbul-lib-source-maps@^4.0.0: source-map "^0.6.1" istanbul-reports@^3.0.2: - version "3.1.5" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.5.tgz#cc9a6ab25cb25659810e4785ed9d9fb742578bae" - integrity sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w== + version "3.1.6" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.6.tgz#2544bcab4768154281a2f0870471902704ccaa1a" + integrity sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg== dependencies: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" -it-all@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/it-all/-/it-all-1.0.6.tgz#852557355367606295c4c3b7eff0136f07749335" - integrity sha512-3cmCc6Heqe3uWi3CVM/k51fa/XbMFpQVzFoDsV0IZNHSQDyAXl3c4MjHkFX5kF3922OGj7Myv1nSEUgRtcuM1A== - -it-concat@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/it-concat/-/it-concat-1.0.3.tgz#84db9376e4c77bf7bc1fd933bb90f184e7cef32b" - integrity sha512-sjeZQ1BWQ9U/W2oI09kZgUyvSWzQahTkOkLIsnEPgyqZFaF9ME5gV6An4nMjlyhXKWQMKEakQU8oRHs2SdmeyA== - dependencies: - bl "^4.0.0" - -it-glob@0.0.10: - version "0.0.10" - resolved "https://registry.yarnpkg.com/it-glob/-/it-glob-0.0.10.tgz#4defd9286f693847c3ff483d2ff65f22e1359ad8" - integrity sha512-p1PR15djgPV7pxdLOW9j4WcJdla8+91rJdUU2hU2Jm68vkxpIEXK55VHBeH8Lvqh2vqLtM83t8q4BuJxue6niA== - dependencies: - fs-extra "^9.0.1" - minimatch "^3.0.4" - -it-last@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/it-last/-/it-last-1.0.6.tgz#4106232e5905ec11e16de15a0e9f7037eaecfc45" - integrity sha512-aFGeibeiX/lM4bX3JY0OkVCFkAw8+n9lkukkLNivbJRvNz8lI3YXv5xcqhFUV2lDJiraEK3OXRDbGuevnnR67Q== - -it-map@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/it-map/-/it-map-1.0.6.tgz#6aa547e363eedcf8d4f69d8484b450bc13c9882c" - integrity sha512-XT4/RM6UHIFG9IobGlQPFQUrlEKkU4eBUFG3qhWhfAdh1JfF2x11ShCrKCdmZ0OiZppPfoLuzcfA4cey6q3UAQ== - -it-peekable@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/it-peekable/-/it-peekable-1.0.3.tgz#8ebe933767d9c5aa0ae4ef8e9cb3a47389bced8c" - integrity sha512-5+8zemFS+wSfIkSZyf0Zh5kNN+iGyccN02914BY4w/Dj+uoFEoPSvj5vaWn8pNZJNSxzjW0zHRxC3LUb2KWJTQ== - -it-reader@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/it-reader/-/it-reader-2.1.0.tgz#b1164be343f8538d8775e10fb0339f61ccf71b0f" - integrity sha512-hSysqWTO9Tlwc5EGjVf8JYZzw0D2FsxD/g+eNNWrez9zODxWt6QlN6JAMmycK72Mv4jHEKEXoyzUN4FYGmJaZw== - dependencies: - bl "^4.0.0" - -it-tar@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/it-tar/-/it-tar-1.2.2.tgz#8d79863dad27726c781a4bcc491f53c20f2866cf" - integrity sha512-M8V4a9I+x/vwXTjqvixcEZbQZHjwDIb8iUQ+D4M2QbhAdNs3WKVSl+45u5/F2XFx6jYMFOGzMVlKNK/uONgNIA== - dependencies: - bl "^4.0.0" - buffer "^5.4.3" - iso-constants "^0.1.2" - it-concat "^1.0.0" - it-reader "^2.0.0" - p-defer "^3.0.0" - -it-to-stream@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/it-to-stream/-/it-to-stream-0.1.2.tgz#7163151f75b60445e86b8ab1a968666acaacfe7b" - integrity sha512-DTB5TJRZG3untmZehcaFN0kGWl2bNv7tnJRgQHAO9QEt8jfvVRrebZtnD5NZd4SCj4WVPjl0LSrugNWE/UaZRQ== - dependencies: - buffer "^5.6.0" - fast-fifo "^1.0.0" - get-iterator "^1.0.2" - p-defer "^3.0.0" - p-fifo "^1.0.0" - readable-stream "^3.6.0" - jest-changed-files@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-26.6.2.tgz#f6198479e1cc66f22f9ae1e22acaa0b429c042d0" @@ -7065,7 +6539,7 @@ jest@26.6.3: import-local "^3.0.2" jest-cli "^26.6.3" -js-sha3@0.8.0, js-sha3@^0.8.0: +js-sha3@0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== @@ -7188,13 +6662,6 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== -json-text-sequence@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/json-text-sequence/-/json-text-sequence-0.1.1.tgz#a72f217dc4afc4629fff5feb304dc1bd51a2f3d2" - integrity sha512-L3mEegEWHRekSHjc7+sc8eJhba9Clq1PZ8kMkzf8OxElhXc8O4TS5MwcVlj9aEbm5dr81N90WHC5nAz3UO971w== - dependencies: - delimit-stream "0.1.0" - json5@2.x, json5@^2.2.2: version "2.2.3" resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" @@ -7314,14 +6781,6 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" -levn@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - integrity sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA== - dependencies: - prelude-ls "~1.1.2" - type-check "~0.3.2" - libnpmaccess@^4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/libnpmaccess/-/libnpmaccess-4.0.3.tgz#dfb0e5b0a53c315a2610d300e46b4ddeb66e7eec" @@ -7492,6 +6951,13 @@ make-dir@^3.0.0: dependencies: semver "^6.0.0" +make-dir@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e" + integrity sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw== + dependencies: + semver "^7.5.3" + make-error@1.x, make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" @@ -7616,13 +7082,6 @@ meow@^8.0.0: type-fest "^0.18.0" yargs-parser "^20.2.3" -merge-options@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/merge-options/-/merge-options-2.0.0.tgz#36ca5038badfc3974dbde5e58ba89d3df80882c3" - integrity sha512-S7xYIeWHl2ZUKF7SDeBhGg6rfv5bKxVBdk95s/I7wVF8d+hjLSztJ/B271cnUiF6CAFduEQ5Zn3HYwAjT16DlQ== - dependencies: - is-plain-obj "^2.0.0" - merge-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" @@ -7692,13 +7151,6 @@ minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== -minimatch@*: - version "9.0.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.2.tgz#397e387fff22f6795844d00badc903a3d5de7057" - integrity sha512-PZOT9g5v2ojiTL7r1xF6plNHLtOeTpSlDI007As2NlA2aYBMfVom17yqa6QzhmDP8QOhn7LjHTg7DFCVSSa6yg== - dependencies: - brace-expansion "^2.0.1" - minimatch@^3.0.3, minimatch@^3.0.4, minimatch@^3.1.1: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" @@ -7856,27 +7308,6 @@ ms@^2.0.0, ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== -multiaddr-to-uri@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/multiaddr-to-uri/-/multiaddr-to-uri-6.0.0.tgz#8f08a75c6eeb2370d5d24b77b8413e3f0fa9bcc0" - integrity sha512-OjpkVHOXEmIKMO8WChzzQ7aZQcSQX8squxmvtDbRpy7/QNmJ3Z7jv6qyD74C28QtaeNie8O8ngW2AkeiMmKP7A== - dependencies: - multiaddr "^8.0.0" - -multiaddr@^8.0.0: - version "8.1.2" - resolved "https://registry.yarnpkg.com/multiaddr/-/multiaddr-8.1.2.tgz#74060ff8636ba1c01b2cf0ffd53950b852fa9b1f" - integrity sha512-r13IzW8+Sv9zab9Gt8RPMIN2WkptIPq99EpAzg4IbJ/zTELhiEwXWr9bAmEatSCI4j/LSA6ESJzvz95JZ+ZYXQ== - dependencies: - cids "^1.0.0" - class-is "^1.1.0" - dns-over-http-resolver "^1.0.0" - err-code "^2.0.3" - is-ip "^3.1.0" - multibase "^3.0.0" - uint8arrays "^1.1.0" - varint "^5.0.0" - multibase@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/multibase/-/multibase-0.7.0.tgz#1adfc1c50abe05eefeb5091ac0c2728d6b84581b" @@ -7885,21 +7316,6 @@ multibase@^0.7.0: base-x "^3.0.8" buffer "^5.5.0" -multibase@^3.0.0, multibase@^3.1.0: - version "3.1.2" - resolved "https://registry.yarnpkg.com/multibase/-/multibase-3.1.2.tgz#59314e1e2c35d018db38e4c20bb79026827f0f2f" - integrity sha512-bpklWHs70LO3smJUHOjcnzGceJJvn9ui0Vau6Za0B/GBepaXswmW8Ufea0uD9pROf/qCQ4N4lZ3sf3U+SNf0tw== - dependencies: - "@multiformats/base-x" "^4.0.1" - web-encoding "^1.0.6" - -multibase@^4.0.1: - version "4.0.6" - resolved "https://registry.yarnpkg.com/multibase/-/multibase-4.0.6.tgz#6e624341483d6123ca1ede956208cb821b440559" - integrity sha512-x23pDe5+svdLz/k5JPGCVdfn7Q5mZVMBETiC+ORfO+sor9Sgs0smJzAjfTbM5tckeCqnaUuMYoz+k3RXMmJClQ== - dependencies: - "@multiformats/base-x" "^4.0.1" - multibase@~0.6.0: version "0.6.1" resolved "https://registry.yarnpkg.com/multibase/-/multibase-0.6.1.tgz#b76df6298536cc17b9f6a6db53ec88f85f8cc12b" @@ -7923,27 +7339,6 @@ multicodec@^1.0.0: buffer "^5.6.0" varint "^5.0.0" -multicodec@^2.0.0, multicodec@^2.0.1: - version "2.1.3" - resolved "https://registry.yarnpkg.com/multicodec/-/multicodec-2.1.3.tgz#b9850635ad4e2a285a933151b55b4a2294152a5d" - integrity sha512-0tOH2Gtio39uO41o+2xl9UhRkCWxU5ZmZSbFCh/OjGzkWJI8e6lkN/s4Mj1YfyWoBod+2+S3W+6wO6nhkwN8pA== - dependencies: - uint8arrays "1.1.0" - varint "^6.0.0" - -multicodec@^3.0.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/multicodec/-/multicodec-3.2.1.tgz#82de3254a0fb163a107c1aab324f2a91ef51efb2" - integrity sha512-+expTPftro8VAW8kfvcuNNNBgb9gPeNYV9dn+z1kJRWF2vih+/S79f2RVeIwmrJBUJ6NT9IUPWnZDQvegEh5pw== - dependencies: - uint8arrays "^3.0.0" - varint "^6.0.0" - -multiformats@^9.4.2: - version "9.9.0" - resolved "https://registry.yarnpkg.com/multiformats/-/multiformats-9.9.0.tgz#c68354e7d21037a8f1f8833c8ccd68618e8f1d37" - integrity sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg== - multihashes@^0.4.15, multihashes@~0.4.15: version "0.4.21" resolved "https://registry.yarnpkg.com/multihashes/-/multihashes-0.4.21.tgz#dc02d525579f334a7909ade8a122dabb58ccfcb5" @@ -7953,36 +7348,6 @@ multihashes@^0.4.15, multihashes@~0.4.15: multibase "^0.7.0" varint "^5.0.0" -multihashes@^3.0.1: - version "3.1.2" - resolved "https://registry.yarnpkg.com/multihashes/-/multihashes-3.1.2.tgz#ffa5e50497aceb7911f7b4a3b6cada9b9730edfc" - integrity sha512-AP4IoV/YzkNrfbQKZE3OMPibrmy350OmCd6cJkwyM8oExaXIlOY4UnOOVSQtAEuq/LR01XfXKCESidzZvSwHCQ== - dependencies: - multibase "^3.1.0" - uint8arrays "^2.0.5" - varint "^6.0.0" - -multihashes@^4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/multihashes/-/multihashes-4.0.3.tgz#426610539cd2551edbf533adeac4c06b3b90fb05" - integrity sha512-0AhMH7Iu95XjDLxIeuCOOE4t9+vQZsACyKZ9Fxw2pcsRmlX4iCn1mby0hS0bb+nQOVpdQYWPpnyusw4da5RPhA== - dependencies: - multibase "^4.0.1" - uint8arrays "^3.0.0" - varint "^5.0.2" - -multihashing-async@^2.0.0: - version "2.1.4" - resolved "https://registry.yarnpkg.com/multihashing-async/-/multihashing-async-2.1.4.tgz#26dce2ec7a40f0e7f9e732fc23ca5f564d693843" - integrity sha512-sB1MiQXPSBTNRVSJc2zM157PXgDtud2nMFUEIvBrsq5Wv96sUclMRK/ecjoP1T/W61UJBqt4tCTwMkUpt2Gbzg== - dependencies: - blakejs "^1.1.0" - err-code "^3.0.0" - js-sha3 "^0.8.0" - multihashes "^4.0.1" - murmurhash3js-revisited "^3.0.0" - uint8arrays "^3.0.0" - multimatch@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-5.0.0.tgz#932b800963cea7a31a033328fa1e0c3a1874dbe6" @@ -7994,11 +7359,6 @@ multimatch@^5.0.0: arrify "^2.0.1" minimatch "^3.0.4" -murmurhash3js-revisited@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/murmurhash3js-revisited/-/murmurhash3js-revisited-3.0.0.tgz#6bd36e25de8f73394222adc6e41fa3fac08a5869" - integrity sha512-/sF3ee6zvScXMb1XFJ8gDsSnY+X8PbOyjIuBhtgis10W2Jx4ZjIhikUCIF9c4gpJxVnQIsPAFrSwTCuAjicP6g== - mustache@4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/mustache/-/mustache-4.0.1.tgz#d99beb031701ad433338e7ea65e0489416c854a2" @@ -8018,11 +7378,6 @@ mz@^2.7.0: object-assign "^4.0.1" thenify-all "^1.0.0" -nanoid@^3.1.12, nanoid@^3.1.3: - version "3.3.6" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.6.tgz#443380c856d6e9f9824267d960b4236ad583ea4c" - integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== - nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -8040,30 +7395,6 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" -native-abort-controller@0.0.3, native-abort-controller@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/native-abort-controller/-/native-abort-controller-0.0.3.tgz#4c528a6c9c7d3eafefdc2c196ac9deb1a5edf2f8" - integrity sha512-YIxU5nWqSHG1Xbu3eOu3pdFRD882ivQpIcu6AiPVe2oSVoRbfYW63DVkZm3g1gHiMtZSvZzF6THSzTGEBYl8YA== - dependencies: - globalthis "^1.0.1" - -native-abort-controller@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/native-abort-controller/-/native-abort-controller-1.0.4.tgz#39920155cc0c18209ff93af5bc90be856143f251" - integrity sha512-zp8yev7nxczDJMoP6pDxyD20IU0T22eX8VwN2ztDccKvSZhRaV33yP1BGwKSZfXuqWUzsXopVFjBdau9OOAwMQ== - -native-fetch@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/native-fetch/-/native-fetch-2.0.1.tgz#319d53741a7040def92d5dc8ea5fe9416b1fad89" - integrity sha512-gv4Bea+ga9QdXINurpkEqun3ap3vnB+WYoe4c8ddqUYEH7B2h6iD39RF8uVN7OwmSfMY3RDxkvBnoI4e2/vLXQ== - dependencies: - globalthis "^1.0.1" - -native-fetch@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/native-fetch/-/native-fetch-3.0.0.tgz#06ccdd70e79e171c365c75117959cf4fe14a09bb" - integrity sha512-G3Z7vx0IFb/FQ4JxvtqGABsOTIqRWvgQz6e+erkB+JJD6LrszQtMozEHI4EkmgZQvnGHrpLVzUWk7t4sJCIkVw== - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -8099,10 +7430,10 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== -node-fetch@^2.6.0, node-fetch@^2.6.1, node-fetch@^2.6.7: - version "2.6.11" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.11.tgz#cde7fc71deef3131ef80a738919f999e6edfff25" - integrity sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w== +node-fetch@^2.6.1, node-fetch@^2.6.7: + version "2.6.12" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.12.tgz#02eb8e22074018e3d5a83016649d04df0e348fba" + integrity sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g== dependencies: whatwg-url "^5.0.0" @@ -8157,9 +7488,9 @@ node-notifier@^8.0.0: which "^2.0.2" node-releases@^2.0.12: - version "2.0.12" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.12.tgz#35627cc224a23bfb06fb3380f2b3afaaa7eb1039" - integrity sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ== + version "2.0.13" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.13.tgz#d5ed1627c23e3461e819b02e57b75e4899b1c81d" + integrity sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ== noms@0.0.0: version "0.0.0" @@ -8339,9 +7670,9 @@ number-is-nan@^1.0.0: integrity sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ== nwsapi@^2.2.0: - version "2.2.5" - resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.5.tgz#a52744c61b3889dd44b0a158687add39b8d935e2" - integrity sha512-6xpotnECFy/og7tKSBVmUNft7J3jyXAka4XvG6AUhFWRz+Q/Ljus7znJAA3bxColfQLdS+XsjoodtJfCgeTEFQ== + version "2.2.7" + resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.7.tgz#738e0707d3128cb750dddcfe90e4610482df0f30" + integrity sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ== oauth-sign@~0.9.0: version "0.9.0" @@ -8430,18 +7761,6 @@ onetime@^5.1.0, onetime@^5.1.2: dependencies: mimic-fn "^2.1.0" -optionator@^0.8.1: - version "0.8.3" - resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" - integrity sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA== - dependencies: - deep-is "~0.1.3" - fast-levenshtein "~2.0.6" - levn "~0.3.0" - prelude-ls "~1.1.2" - type-check "~0.3.2" - word-wrap "~1.2.3" - optionator@^0.9.1: version "0.9.3" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.3.tgz#007397d44ed1872fdc6ed31360190f81814e2c64" @@ -8486,24 +7805,11 @@ p-defer@^1.0.0: resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" integrity sha512-wB3wfAxZpk2AzOfUMJNL+d36xothRSyj8EXOa4f6GMqYDN9BJaaSISbsk+wS9abmnebVw95C2Kb5t85UmpCxuw== -p-defer@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-3.0.0.tgz#d1dceb4ee9b2b604b1d94ffec83760175d4e6f83" - integrity sha512-ugZxsxmtTln604yeYd29EGrNhazN2lywetzpKhfmQjW/VJmhpDmWbiX+h0zL8V91R0UXkhb3KtPmyq9PZw3aYw== - p-each-series@^2.1.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.2.0.tgz#105ab0357ce72b202a8a8b94933672657b5e2a9a" integrity sha512-ycIL2+1V32th+8scbpTvyHNaHe02z0sjgh91XXjAk+ZeXoPN4Z46DVUnzdso0aX4KckKw0FNNFHdjZ2UsZvxiA== -p-fifo@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/p-fifo/-/p-fifo-1.0.0.tgz#e29d5cf17c239ba87f51dde98c1d26a9cfe20a63" - integrity sha512-IjoCxXW48tqdtDFz6fqo5q1UfFVjjVZe8TC1QRflvNUJtNfCUhxOUw6MOVZhDPjqhSzc26xKdugsO17gmzd5+A== - dependencies: - fast-fifo "^1.0.0" - p-defer "^3.0.0" - p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -8628,11 +7934,6 @@ parent-module@^1.0.0: dependencies: callsites "^3.0.0" -parse-duration@^0.4.4: - version "0.4.4" - resolved "https://registry.yarnpkg.com/parse-duration/-/parse-duration-0.4.4.tgz#11c0f51a689e97d06c57bd772f7fda7dc013243c" - integrity sha512-KbAJuYGUhZkB9gotDiKLnZ7Z3VTacK3fgwmDdB6ZVDtJbMBT6MfLga0WJaYpPDu0mzqT0NgHtHDt5PY4l0nidg== - parse-json@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" @@ -8799,11 +8100,6 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== -prelude-ls@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== - prettier-linter-helpers@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" @@ -8894,11 +8190,6 @@ proto-list@~1.2.1: resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" integrity sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA== -protocol-buffers-schema@^3.3.1: - version "3.6.0" - resolved "https://registry.yarnpkg.com/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz#77bc75a48b2ff142c1ad5b5b90c94cd0fa2efd03" - integrity sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw== - protocols@^1.4.0: version "1.4.8" resolved "https://registry.yarnpkg.com/protocols/-/protocols-1.4.8.tgz#48eea2d8f58d9644a4a32caae5d5db290a075ce8" @@ -8909,16 +8200,6 @@ protocols@^2.0.1: resolved "https://registry.yarnpkg.com/protocols/-/protocols-2.0.1.tgz#8f155da3fc0f32644e83c5782c8e8212ccf70a86" integrity sha512-/XJ368cyBJ7fzLMwLKv1e4vLxOju2MNAIokcr7meSaNcVbWz/CPcW22cP04mwxOErdA5mwjA8Q6w/cdAQxVn7Q== -protons@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/protons/-/protons-2.0.3.tgz#94f45484d04b66dfedc43ad3abff1e8907994bb2" - integrity sha512-j6JikP/H7gNybNinZhAHMN07Vjr1i4lVupg598l4I9gSTjJqOvKnwjzYX2PzvBTSVf2eZ2nWv4vG+mtW8L6tpA== - dependencies: - protocol-buffers-schema "^3.3.1" - signed-varint "^2.0.1" - uint8arrays "^3.0.0" - varint "^5.0.0" - proxy-from-env@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" @@ -9124,7 +8405,7 @@ read@1, read@~1.0.1: dependencies: mute-stream "~0.0.4" -readable-stream@3, readable-stream@^3.0.0, readable-stream@^3.0.2, readable-stream@^3.4.0, readable-stream@^3.6.0: +readable-stream@3, readable-stream@^3.0.0, readable-stream@^3.0.2: version "3.6.2" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== @@ -9173,13 +8454,6 @@ readdirp@~3.5.0: dependencies: picomatch "^2.2.1" -receptacle@^1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/receptacle/-/receptacle-1.3.2.tgz#a7994c7efafc7a01d0e2041839dab6c4951360d2" - integrity sha512-HrsFvqZZheusncQRiEE7GatOAETrARKV/lnfYicIm8lbvp/JQOdADOfhjBd2DajvoszEyxSM6RlAAIZgEoeu/A== - dependencies: - ms "^2.1.1" - rechoir@^0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" @@ -9208,7 +8482,7 @@ regex-parser@2.2.11: resolved "https://registry.yarnpkg.com/regex-parser/-/regex-parser-2.2.11.tgz#3b37ec9049e19479806e878cabe7c1ca83ccfe58" integrity sha512-jbD/FT0+9MBU2XAZluI7w2OBs1RBi6p9M83nkoZayQXXU9e8Robt69FcZc7wU4eJD/YFTjn1JdCk3rbMJajz8Q== -regexp.prototype.flags@^1.4.3: +regexp.prototype.flags@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz#fe7ce25e7e4cca8db37b6634c8a2c7009199b9cb" integrity sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA== @@ -9283,11 +8557,6 @@ requires-port@^1.0.0: resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== -reset@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/reset/-/reset-0.1.0.tgz#9fc7314171995ae6cb0b7e58b06ce7522af4bafb" - integrity sha512-RF7bp2P2ODreUPA71FZ4DSK52gNLJJ8dSwA1nhOCoC0mI4KZ4D/W6zhd2nfBqX/JlR+QZ/iUqAYPjq1UQU8l0Q== - resolve-cwd@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" @@ -9332,11 +8601,6 @@ ret@~0.1.10: resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== -retimer@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/retimer/-/retimer-2.0.0.tgz#e8bd68c5e5a8ec2f49ccb5c636db84c04063bbca" - integrity sha512-KLXY85WkEq2V2bKex/LOO1ViXVn2KGYe4PYysAdYdjmraYIUsVkXu8O4am+8+5UbaaGl1qho4aqAAPHNQ4GSbg== - retry@^0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" @@ -9378,13 +8642,6 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -run@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/run/-/run-1.4.0.tgz#e17d9e9043ab2fe17776cb299e1237f38f0b4ffa" - integrity sha512-962oBW07IjQ9SizyMHdoteVbDKt/e2nEsnTRZ0WjK/zs+jfQQICqH0qj0D5lqZNuy0JkbzfA6IOqw0Sk7C3DlQ== - dependencies: - minimatch "*" - rxjs@^6.6.0: version "6.6.7" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.6.7.tgz#90ac018acabf491bf65044235d5863c4dab804c9" @@ -9461,23 +8718,9 @@ scrypt-js@3.0.1: integrity sha512-cdwTTnqPu0Hyvf5in5asVdZocVDTNRmR7XEcJuIzMjJeSHybHl7vpB66AzwTaIg6CLSbtjcxc8fqcySfnTkccA== "semver@2 || 3 || 4 || 5", semver@^5.5.0, semver@^5.6.0, semver@^5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -semver@7.3.8: - version "7.3.8" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" - integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== - dependencies: - lru-cache "^6.0.0" - -semver@7.4.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.4.0.tgz#8481c92feffc531ab1e012a8ffc15bdd3a0f4318" - integrity sha512-RgOxM8Mw+7Zus0+zcLEUn8+JfoLpj/huFTItQy2hsM4khuC1HYRDp0cU482Ewn/Fcy6bCjufD8vAj7voC66KQw== - dependencies: - lru-cache "^6.0.0" + version "5.7.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" + integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== semver@7.5.0: version "7.5.0" @@ -9486,17 +8729,24 @@ semver@7.5.0: dependencies: lru-cache "^6.0.0" -semver@7.5.3, semver@7.x, semver@^7.1.1, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: +semver@7.5.3: version "7.5.3" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.3.tgz#161ce8c2c6b4b3bdca6caadc9fa3317a4c4fe88e" integrity sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ== dependencies: lru-cache "^6.0.0" -semver@^6.0.0, semver@^6.3.0: - version "6.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +semver@7.x, semver@^7.1.1, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.5.3: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + +semver@^6.0.0, semver@^6.3.0, semver@^6.3.1: + version "6.3.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" + integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" @@ -9572,13 +8822,6 @@ signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== -signed-varint@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/signed-varint/-/signed-varint-2.0.1.tgz#50a9989da7c98c2c61dad119bc97470ef8528129" - integrity sha512-abgDPg1106vuZZOvw7cFwdCABddfJRz5akcCcchzTbhyhYnsG31y4AlZEgp315T7W3nQq5P4xeOm186ZiPVFzw== - dependencies: - varint "~5.0.0" - sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" @@ -9801,11 +9044,6 @@ ssri@^8.0.0, ssri@^8.0.1: dependencies: minipass "^3.1.1" -stable@^0.1.8: - version "0.1.8" - resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf" - integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w== - stack-utils@^2.0.2: version "2.0.6" resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" @@ -9821,13 +9059,6 @@ static-extend@^0.1.1: define-property "^0.2.5" object-copy "^0.1.0" -stream-to-it@^0.2.0, stream-to-it@^0.2.2: - version "0.2.4" - resolved "https://registry.yarnpkg.com/stream-to-it/-/stream-to-it-0.2.4.tgz#d2fd7bfbd4a899b4c0d6a7e6a533723af5749bd0" - integrity sha512-4vEbkSs83OahpmBybNJXlJd7d6/RxzkkSdT3I0mnGt79Xd2Kk+e1JqbvAvsQfCeKj3aKb0QIWkyK3/n0j506vQ== - dependencies: - get-iterator "^1.0.2" - strict-uri-encode@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546" @@ -10110,14 +9341,6 @@ through@2, "through@>=2.2.7 <3", through@^2.3.4, through@^2.3.6: resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== -timeout-abort-controller@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/timeout-abort-controller/-/timeout-abort-controller-1.1.1.tgz#2c3c3c66f13c783237987673c276cbd7a9762f29" - integrity sha512-BsF9i3NAJag6T0ZEjki9j654zoafI2X6ayuNd6Tp8+Ul6Tr5s4jo973qFeiWrRSweqvskC+AHDKUmIW4b7pdhQ== - dependencies: - abort-controller "^3.0.0" - retimer "^2.0.0" - timers-ext@^0.1.7: version "0.1.7" resolved "https://registry.yarnpkg.com/timers-ext/-/timers-ext-0.1.7.tgz#6f57ad8578e07a3fb9f91d9387d65647555e25c6" @@ -10280,9 +9503,9 @@ tslib@^1.8.1, tslib@^1.9.0: integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== tslib@^2.1.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.0.tgz#b295854684dbda164e181d259a22cd779dcd7bc3" - integrity sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA== + version "2.6.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" + integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== tsutils@^3.17.1: version "3.21.0" @@ -10310,13 +9533,6 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" -type-check@~0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - integrity sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg== - dependencies: - prelude-ls "~1.1.2" - type-detect@4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" @@ -10357,6 +9573,36 @@ type@^2.7.2: resolved "https://registry.yarnpkg.com/type/-/type-2.7.2.tgz#2376a15a3a28b1efa0f5350dcf72d24df6ef98d0" integrity sha512-dzlvlNlt6AXU7EBSfpAscydQ7gXB+pPGsPnfJnZpiNJBDj7IaJzQlBZYGdEi4R9HmPdBv2XmWJ6YUtoTa7lmCw== +typed-array-buffer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz#18de3e7ed7974b0a729d3feecb94338d1472cd60" + integrity sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.2.1" + is-typed-array "^1.1.10" + +typed-array-byte-length@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz#d787a24a995711611fb2b87a4052799517b230d0" + integrity sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA== + dependencies: + call-bind "^1.0.2" + for-each "^0.3.3" + has-proto "^1.0.1" + is-typed-array "^1.1.10" + +typed-array-byte-offset@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz#cbbe89b51fdef9cd6aaf07ad4707340abbc4ea0b" + integrity sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + has-proto "^1.0.1" + is-typed-array "^1.1.10" + typed-array-length@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.4.tgz#89d83785e5c4098bec72e08b319651f0eac9c1bb" @@ -10393,28 +9639,6 @@ uid-number@0.0.6: resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" integrity sha512-c461FXIljswCuscZn67xq9PpszkPT6RjheWFQTgCyabJrTUozElanb0YEqv2UGgk247YpcJkFBuSGNvBlpXM9w== -uint8arrays@1.1.0, uint8arrays@^1.0.0, uint8arrays@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/uint8arrays/-/uint8arrays-1.1.0.tgz#d034aa65399a9fd213a1579e323f0b29f67d0ed2" - integrity sha512-cLdlZ6jnFczsKf5IH1gPHTtcHtPGho5r4CvctohmQjw8K7Q3gFdfIGHxSTdTaCKrL4w09SsPRJTqRS0drYeszA== - dependencies: - multibase "^3.0.0" - web-encoding "^1.0.2" - -uint8arrays@^2.0.5, uint8arrays@^2.1.3: - version "2.1.10" - resolved "https://registry.yarnpkg.com/uint8arrays/-/uint8arrays-2.1.10.tgz#34d023c843a327c676e48576295ca373c56e286a" - integrity sha512-Q9/hhJa2836nQfEJSZTmr+pg9+cDJS9XEAp7N2Vg5MzL3bK/mkMVfjscRGYruP9jNda6MAdf4QD/y78gSzkp6A== - dependencies: - multiformats "^9.4.2" - -uint8arrays@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/uint8arrays/-/uint8arrays-3.1.1.tgz#2d8762acce159ccd9936057572dade9459f65ae0" - integrity sha512-+QJa8QRnbdXVpHYjLoTpJIdCTiw9Ir62nocClWuXIq2JIh4Uta0cQsTSpFL678p2CN8B+XSApwcU+pQEqVpKWg== - dependencies: - multiformats "^9.4.2" - umask@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/umask/-/umask-1.1.0.tgz#f29cebf01df517912bb58ff9c4e50fde8e33320d" @@ -10542,17 +9766,6 @@ util-promisify@^2.1.0: dependencies: object.getownpropertydescriptors "^2.0.3" -util@^0.12.3: - version "0.12.5" - resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc" - integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA== - dependencies: - inherits "^2.0.3" - is-arguments "^1.0.4" - is-generator-function "^1.0.7" - is-typed-array "^1.1.3" - which-typed-array "^1.1.2" - uuid@^3.3.2: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" @@ -10597,16 +9810,11 @@ validate-npm-package-name@^3.0.0: dependencies: builtins "^1.0.3" -varint@^5.0.0, varint@^5.0.2, varint@~5.0.0: +varint@^5.0.0: version "5.0.2" resolved "https://registry.yarnpkg.com/varint/-/varint-5.0.2.tgz#5b47f8a947eb668b848e034dcfa87d0ff8a7f7a4" integrity sha512-lKxKYG6H03yCZUpAGOPOsMcGxd1RHCu1iKvEHYDPmTyq2HueGhD73ssNBqqQWfvYs04G9iUFRvmAVLW20Jw6ow== -varint@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/varint/-/varint-6.0.0.tgz#9881eb0ce8feaea6512439d19ddf84bf551661d0" - integrity sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg== - verror@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" @@ -10683,15 +9891,6 @@ wcwidth@^1.0.0: dependencies: defaults "^1.0.3" -web-encoding@^1.0.2, web-encoding@^1.0.6: - version "1.1.5" - resolved "https://registry.yarnpkg.com/web-encoding/-/web-encoding-1.1.5.tgz#fc810cf7667364a6335c939913f5051d3e0c4864" - integrity sha512-HYLeVCdJ0+lBYV2FvNZmv3HJ2Nt0QYXqZojk3d9FJOLkwnuhzM9tmamh8d7HPM8QqjKH8DeHkFTx+CFlWpZZDA== - dependencies: - util "^0.12.3" - optionalDependencies: - "@zxing/text-encoding" "0.9.0" - webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" @@ -10752,17 +9951,16 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.1.tgz#776b1fe35d90aebe99e8ac15eb24093389a4a409" integrity sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ== -which-typed-array@^1.1.2, which-typed-array@^1.1.9: - version "1.1.9" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.9.tgz#307cf898025848cf995e795e8423c7f337efbde6" - integrity sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA== +which-typed-array@^1.1.10, which-typed-array@^1.1.11: + version "1.1.11" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.11.tgz#99d691f23c72aab6768680805a271b69761ed61a" + integrity sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew== dependencies: available-typed-arrays "^1.0.5" call-bind "^1.0.2" for-each "^0.3.3" gopd "^1.0.1" has-tostringtag "^1.0.0" - is-typed-array "^1.1.10" which@^1.2.9, which@^1.3.1: version "1.3.1" @@ -10785,11 +9983,6 @@ wide-align@^1.1.0: dependencies: string-width "^1.0.2 || 2 || 3 || 4" -word-wrap@~1.2.3: - version "1.2.3" - resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" - integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== - wordwrap@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"